2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/graphics.h>
|
2010-09-07 00:06:11 +00:00
|
|
|
#include <engine/keys.h>
|
2010-10-19 11:37:36 +00:00
|
|
|
#include <engine/demo.h>
|
2010-09-07 00:06:11 +00:00
|
|
|
#include <engine/serverbrowser.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/shared/config.h>
|
2010-09-07 00:06:11 +00:00
|
|
|
#include <engine/storage.h>
|
2009-10-27 14:38:53 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/layers.h>
|
|
|
|
#include <game/client/gameclient.h>
|
|
|
|
#include <game/client/component.h>
|
|
|
|
#include <game/client/render.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/components/camera.h>
|
|
|
|
#include <game/client/components/mapimages.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include "maplayers.h"
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapLayers::CMapLayers(int t)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
m_Type = t;
|
|
|
|
m_pLayers = 0;
|
2011-12-04 13:04:12 +00:00
|
|
|
m_CurrentLocalTick = 0;
|
|
|
|
m_LastLocalTick = 0;
|
|
|
|
m_EnvelopeUpdate = false;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CMapLayers::OnInit()
|
|
|
|
{
|
|
|
|
m_pLayers = Layers();
|
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-12-04 13:04:12 +00:00
|
|
|
void CMapLayers::EnvelopeUpdate()
|
|
|
|
{
|
|
|
|
if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
|
|
|
{
|
|
|
|
const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo();
|
|
|
|
m_CurrentLocalTick = pInfo->m_CurrentTick;
|
|
|
|
m_LastLocalTick = pInfo->m_CurrentTick;
|
|
|
|
m_EnvelopeUpdate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2010-10-17 08:43:27 +00:00
|
|
|
void CMapLayers::MapScreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup, float Zoom)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
float Points[4];
|
|
|
|
RenderTools()->MapscreenToWorld(CenterX, CenterY, pGroup->m_ParallaxX/100.0f, pGroup->m_ParallaxY/100.0f,
|
2010-10-17 08:43:27 +00:00
|
|
|
pGroup->m_OffsetX, pGroup->m_OffsetY, Graphics()->ScreenAspect(), Zoom, Points);
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->MapScreen(Points[0], Points[1], Points[2], Points[3]);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void *pUser)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapLayers *pThis = (CMapLayers *)pUser;
|
|
|
|
pChannels[0] = 0;
|
|
|
|
pChannels[1] = 0;
|
|
|
|
pChannels[2] = 0;
|
|
|
|
pChannels[3] = 0;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-06-09 16:24:38 +00:00
|
|
|
CEnvPoint *pPoints = 0;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
int Start, Num;
|
|
|
|
pThis->m_pLayers->Map()->GetType(MAPITEMTYPE_ENVPOINTS, &Start, &Num);
|
|
|
|
if(Num)
|
|
|
|
pPoints = (CEnvPoint *)pThis->m_pLayers->Map()->GetItem(Start, 0, 0);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int Start, Num;
|
|
|
|
pThis->m_pLayers->Map()->GetType(MAPITEMTYPE_ENVELOPE, &Start, &Num);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Env >= Num)
|
2008-08-27 15:48:50 +00:00
|
|
|
return;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapItemEnvelope *pItem = (CMapItemEnvelope *)pThis->m_pLayers->Map()->GetItem(Start+Env, 0, 0);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2012-01-09 23:49:31 +00:00
|
|
|
static float s_Time = 0.0f;
|
|
|
|
static float s_LastLocalTime = pThis->Client()->LocalTime();
|
2010-10-19 11:37:36 +00:00
|
|
|
if(pThis->Client()->State() == IClient::STATE_DEMOPLAYBACK)
|
|
|
|
{
|
|
|
|
const IDemoPlayer::CInfo *pInfo = pThis->DemoPlayer()->BaseInfo();
|
2015-07-09 00:08:14 +00:00
|
|
|
|
2011-12-04 13:04:12 +00:00
|
|
|
if(!pInfo->m_Paused || pThis->m_EnvelopeUpdate)
|
2011-12-01 17:36:51 +00:00
|
|
|
{
|
2011-12-04 13:04:12 +00:00
|
|
|
if(pThis->m_CurrentLocalTick != pInfo->m_CurrentTick)
|
2011-12-01 17:36:51 +00:00
|
|
|
{
|
2011-12-04 13:04:12 +00:00
|
|
|
pThis->m_LastLocalTick = pThis->m_CurrentLocalTick;
|
|
|
|
pThis->m_CurrentLocalTick = pInfo->m_CurrentTick;
|
2011-12-01 17:36:51 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2012-01-09 23:49:31 +00:00
|
|
|
s_Time = mix(pThis->m_LastLocalTick / (float)pThis->Client()->GameTickSpeed(),
|
2011-12-04 13:04:12 +00:00
|
|
|
pThis->m_CurrentLocalTick / (float)pThis->Client()->GameTickSpeed(),
|
2011-12-01 17:36:51 +00:00
|
|
|
pThis->Client()->IntraGameTick());
|
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2012-01-09 23:49:31 +00:00
|
|
|
pThis->RenderTools()->RenderEvalEnvelope(pPoints+pItem->m_StartPoint, pItem->m_NumPoints, 4, s_Time+TimeOffset, pChannels);
|
2010-10-19 11:37:36 +00:00
|
|
|
}
|
|
|
|
else
|
2011-04-17 20:07:59 +00:00
|
|
|
{
|
2014-10-31 15:10:09 +00:00
|
|
|
if(pThis->m_pClient->m_Snap.m_pGameInfoObj) // && !(pThis->m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED))
|
2011-12-04 13:34:27 +00:00
|
|
|
{
|
2012-01-09 23:49:31 +00:00
|
|
|
if(pItem->m_Version < 2 || pItem->m_Synchronized)
|
|
|
|
{
|
|
|
|
s_Time = mix((pThis->Client()->PrevGameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(),
|
2011-12-04 13:34:27 +00:00
|
|
|
(pThis->Client()->GameTick()-pThis->m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick) / (float)pThis->Client()->GameTickSpeed(),
|
|
|
|
pThis->Client()->IntraGameTick());
|
2012-01-09 23:49:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
s_Time += pThis->Client()->LocalTime()-s_LastLocalTime;
|
2011-12-04 13:34:27 +00:00
|
|
|
}
|
2012-01-09 23:49:31 +00:00
|
|
|
pThis->RenderTools()->RenderEvalEnvelope(pPoints+pItem->m_StartPoint, pItem->m_NumPoints, 4, s_Time+TimeOffset, pChannels);
|
|
|
|
s_LastLocalTime = pThis->Client()->LocalTime();
|
2011-04-17 20:07:59 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CMapLayers::OnRender()
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK)
|
2008-08-30 09:16:29 +00:00
|
|
|
return;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Screen;
|
|
|
|
Graphics()->GetScreen(&Screen.x, &Screen.y, &Screen.w, &Screen.h);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
vec2 Center = m_pClient->m_pCamera->m_Center;
|
2008-08-27 15:48:50 +00:00
|
|
|
//float center_x = gameclient.camera->center.x;
|
|
|
|
//float center_y = gameclient.camera->center.y;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
bool PassedGameLayer = false;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
for(int g = 0; g < m_pLayers->NumGroups(); g++)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapItemGroup *pGroup = m_pLayers->GetGroup(g);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-02-17 09:24:11 +00:00
|
|
|
if(!pGroup)
|
|
|
|
{
|
|
|
|
dbg_msg("MapLayers", "Error:Group was null, Group Number = %d, Total Groups = %d", g, m_pLayers->NumGroups());
|
|
|
|
dbg_msg("MapLayers", "This is here to prevent a crash but the source of this is unknown, please report this for it to get fixed");
|
|
|
|
dbg_msg("MapLayers", "we need mapname and crc and the map that caused this if possible, and anymore info you think is relevant");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(!g_Config.m_GfxNoclip && pGroup->m_Version >= 2 && pGroup->m_UseClipping)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
|
|
|
// set clipping
|
2010-05-29 07:25:38 +00:00
|
|
|
float Points[4];
|
2010-10-17 08:43:27 +00:00
|
|
|
MapScreenToGroup(Center.x, Center.y, m_pLayers->GameGroup(), m_pClient->m_pCamera->m_Zoom);
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->GetScreen(&Points[0], &Points[1], &Points[2], &Points[3]);
|
|
|
|
float x0 = (pGroup->m_ClipX - Points[0]) / (Points[2]-Points[0]);
|
|
|
|
float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]);
|
|
|
|
float x1 = ((pGroup->m_ClipX+pGroup->m_ClipW) - Points[0]) / (Points[2]-Points[0]);
|
|
|
|
float y1 = ((pGroup->m_ClipY+pGroup->m_ClipH) - Points[1]) / (Points[3]-Points[1]);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->ClipEnable((int)(x0*Graphics()->ScreenWidth()), (int)(y0*Graphics()->ScreenHeight()),
|
|
|
|
(int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight()));
|
2011-04-13 18:37:12 +00:00
|
|
|
}
|
|
|
|
|
2014-09-29 19:13:35 +00:00
|
|
|
if(!g_Config.m_ClZoomBackgroundLayers && !pGroup->m_ParallaxX && !pGroup->m_ParallaxY)
|
|
|
|
MapScreenToGroup(Center.x, Center.y, pGroup, 1.0);
|
|
|
|
else
|
|
|
|
MapScreenToGroup(Center.x, Center.y, pGroup, m_pClient->m_pCamera->m_Zoom);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
for(int l = 0; l < pGroup->m_NumLayers; l++)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapItemLayer *pLayer = m_pLayers->GetLayer(pGroup->m_StartLayer+l);
|
|
|
|
bool Render = false;
|
|
|
|
bool IsGameLayer = false;
|
2011-03-16 17:48:16 +00:00
|
|
|
bool IsFrontLayer = false;
|
|
|
|
bool IsSwitchLayer = false;
|
|
|
|
bool IsTeleLayer = false;
|
|
|
|
bool IsSpeedupLayer = false;
|
2014-07-26 10:33:25 +00:00
|
|
|
bool IsTuneLayer = false;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pLayer == (CMapItemLayer*)m_pLayers->GameLayer())
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
IsGameLayer = true;
|
|
|
|
PassedGameLayer = 1;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2011-03-16 17:48:16 +00:00
|
|
|
if(pLayer == (CMapItemLayer*)m_pLayers->FrontLayer())
|
|
|
|
IsFrontLayer = true;
|
|
|
|
|
|
|
|
if(pLayer == (CMapItemLayer*)m_pLayers->SwitchLayer())
|
|
|
|
IsSwitchLayer = true;
|
|
|
|
|
|
|
|
if(pLayer == (CMapItemLayer*)m_pLayers->TeleLayer())
|
|
|
|
IsTeleLayer = true;
|
|
|
|
|
|
|
|
if(pLayer == (CMapItemLayer*)m_pLayers->SpeedupLayer())
|
|
|
|
IsSpeedupLayer = true;
|
2014-03-23 16:44:02 +00:00
|
|
|
|
2014-03-12 23:11:25 +00:00
|
|
|
if(pLayer == (CMapItemLayer*)m_pLayers->TuneLayer())
|
|
|
|
IsTuneLayer = true;
|
2011-03-16 17:48:16 +00:00
|
|
|
|
2009-01-17 22:19:13 +00:00
|
|
|
// skip rendering if detail layers if not wanted
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pLayer->m_Flags&LAYERFLAG_DETAIL && !g_Config.m_GfxHighDetail && !IsGameLayer)
|
2009-01-17 22:19:13 +00:00
|
|
|
continue;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(m_Type == -1)
|
|
|
|
Render = true;
|
|
|
|
else if(m_Type == 0)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(PassedGameLayer)
|
2008-08-27 15:48:50 +00:00
|
|
|
return;
|
2010-05-29 07:25:38 +00:00
|
|
|
Render = true;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
if(PassedGameLayer && !IsGameLayer)
|
|
|
|
Render = true;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-09-07 00:06:11 +00:00
|
|
|
if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown(KEY_KP0))
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
|
|
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
|
|
|
CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data);
|
2010-09-07 00:06:11 +00:00
|
|
|
CServerInfo CurrentServerInfo;
|
|
|
|
Client()->GetServerInfo(&CurrentServerInfo);
|
|
|
|
char aFilename[256];
|
|
|
|
str_format(aFilename, sizeof(aFilename), "dumps/tilelayer_dump_%s-%d-%d-%dx%d.txt", CurrentServerInfo.m_aMap, g, l, pTMap->m_Width, pTMap->m_Height);
|
2010-10-06 21:07:35 +00:00
|
|
|
IOHANDLE File = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE);
|
2010-09-07 00:06:11 +00:00
|
|
|
if(File)
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
2010-09-07 00:06:11 +00:00
|
|
|
for(int y = 0; y < pTMap->m_Height; y++)
|
|
|
|
{
|
|
|
|
for(int x = 0; x < pTMap->m_Width; x++)
|
|
|
|
io_write(File, &(pTiles[y*pTMap->m_Width + x].m_Index), sizeof(pTiles[y*pTMap->m_Width + x].m_Index));
|
2011-12-29 22:36:53 +00:00
|
|
|
io_write_newline(File);
|
2010-09-07 00:06:11 +00:00
|
|
|
}
|
|
|
|
io_close(File);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 17:56:42 +00:00
|
|
|
if((Render && g_Config.m_ClOverlayEntities < 100 && !IsGameLayer && !IsFrontLayer && !IsSwitchLayer && !IsTeleLayer && !IsSpeedupLayer && !IsTuneLayer) || (g_Config.m_ClOverlayEntities && IsGameLayer))
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
|
|
|
//layershot_begin();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(pLayer->m_Type == LAYERTYPE_TILES)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
|
|
|
if(pTMap->m_Image == -1)
|
2011-03-16 12:48:16 +00:00
|
|
|
{
|
2014-05-01 15:44:35 +00:00
|
|
|
if(!IsGameLayer)
|
2011-03-16 12:48:16 +00:00
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
else
|
|
|
|
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());
|
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pTMap->m_Image));
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data);
|
2014-02-10 18:19:49 +00:00
|
|
|
unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(pTMap->m_Data);
|
|
|
|
|
|
|
|
if (Size >= pTMap->m_Width*pTMap->m_Height*sizeof(CTile))
|
|
|
|
{
|
|
|
|
Graphics()->BlendNone();
|
|
|
|
vec4 Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f);
|
2014-05-01 15:44:35 +00:00
|
|
|
if(IsGameLayer && g_Config.m_ClOverlayEntities)
|
|
|
|
Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
|
|
|
if(!IsGameLayer && g_Config.m_ClOverlayEntities)
|
|
|
|
Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*(100-g_Config.m_ClOverlayEntities)/100.0f);
|
2014-02-10 18:19:49 +00:00
|
|
|
RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE,
|
|
|
|
EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset);
|
|
|
|
Graphics()->BlendNormal();
|
|
|
|
RenderTools()->RenderTilemap(pTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT,
|
|
|
|
EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset);
|
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
else if(pLayer->m_Type == LAYERTYPE_QUADS)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CMapItemLayerQuads *pQLayer = (CMapItemLayerQuads *)pLayer;
|
|
|
|
if(pQLayer->m_Image == -1)
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->TextureSet(-1);
|
2008-08-27 15:48:50 +00:00
|
|
|
else
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pQLayer->m_Image));
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CQuad *pQuads = (CQuad *)m_pLayers->Map()->GetDataSwapped(pQLayer->m_Data);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->BlendNone();
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_OPAQUE, EnvelopeEval, this);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->BlendNormal();
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_TRANSPARENT, EnvelopeEval, this);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
|
|
|
//layershot_end();
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2014-05-01 15:44:35 +00:00
|
|
|
else if(g_Config.m_ClOverlayEntities && IsFrontLayer)
|
2011-04-19 14:32:42 +00:00
|
|
|
{
|
|
|
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
|
|
|
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());
|
|
|
|
|
|
|
|
CTile *pFrontTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Front);
|
2014-02-10 18:19:49 +00:00
|
|
|
unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(pTMap->m_Front);
|
|
|
|
|
|
|
|
if (Size >= pTMap->m_Width*pTMap->m_Height*sizeof(CTile))
|
|
|
|
{
|
|
|
|
Graphics()->BlendNone();
|
2015-08-26 22:46:57 +00:00
|
|
|
vec4 Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
2014-02-10 18:19:49 +00:00
|
|
|
RenderTools()->RenderTilemap(pFrontTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE,
|
|
|
|
EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset);
|
|
|
|
Graphics()->BlendNormal();
|
|
|
|
RenderTools()->RenderTilemap(pFrontTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT,
|
|
|
|
EnvelopeEval, this, pTMap->m_ColorEnv, pTMap->m_ColorEnvOffset);
|
|
|
|
}
|
2011-04-19 14:32:42 +00:00
|
|
|
}
|
2014-05-01 15:44:35 +00:00
|
|
|
else if(g_Config.m_ClOverlayEntities && IsSwitchLayer)
|
2011-04-19 14:32:42 +00:00
|
|
|
{
|
|
|
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
|
|
|
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());
|
|
|
|
|
|
|
|
CSwitchTile *pSwitchTiles = (CSwitchTile *)m_pLayers->Map()->GetData(pTMap->m_Switch);
|
2014-02-10 18:19:49 +00:00
|
|
|
unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(pTMap->m_Switch);
|
|
|
|
|
|
|
|
if (Size >= pTMap->m_Width*pTMap->m_Height*sizeof(CSwitchTile))
|
|
|
|
{
|
|
|
|
Graphics()->BlendNone();
|
2015-08-26 22:46:57 +00:00
|
|
|
vec4 Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
2014-02-10 18:19:49 +00:00
|
|
|
RenderTools()->RenderSwitchmap(pSwitchTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
|
|
|
|
Graphics()->BlendNormal();
|
|
|
|
RenderTools()->RenderSwitchmap(pSwitchTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
|
2014-05-01 18:15:53 +00:00
|
|
|
RenderTools()->RenderSwitchOverlay(pSwitchTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, g_Config.m_ClOverlayEntities/100.0f);
|
2014-02-10 18:19:49 +00:00
|
|
|
}
|
2011-04-19 14:32:42 +00:00
|
|
|
}
|
2014-05-01 15:44:35 +00:00
|
|
|
else if(g_Config.m_ClOverlayEntities && IsTeleLayer)
|
2011-04-19 14:32:42 +00:00
|
|
|
{
|
|
|
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
|
|
|
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());
|
|
|
|
|
|
|
|
CTeleTile *pTeleTiles = (CTeleTile *)m_pLayers->Map()->GetData(pTMap->m_Tele);
|
2014-02-10 18:19:49 +00:00
|
|
|
unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(pTMap->m_Tele);
|
|
|
|
|
|
|
|
if (Size >= pTMap->m_Width*pTMap->m_Height*sizeof(CTeleTile))
|
|
|
|
{
|
|
|
|
Graphics()->BlendNone();
|
2015-08-26 22:46:57 +00:00
|
|
|
vec4 Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
2014-02-10 18:19:49 +00:00
|
|
|
RenderTools()->RenderTelemap(pTeleTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
|
|
|
|
Graphics()->BlendNormal();
|
|
|
|
RenderTools()->RenderTelemap(pTeleTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
|
2014-05-01 18:15:53 +00:00
|
|
|
RenderTools()->RenderTeleOverlay(pTeleTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, g_Config.m_ClOverlayEntities/100.0f);
|
2014-02-10 18:19:49 +00:00
|
|
|
}
|
2011-04-19 14:32:42 +00:00
|
|
|
}
|
2014-05-01 15:44:35 +00:00
|
|
|
else if(g_Config.m_ClOverlayEntities && IsSpeedupLayer)
|
2011-04-19 14:32:42 +00:00
|
|
|
{
|
|
|
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
|
|
|
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());
|
|
|
|
|
|
|
|
CSpeedupTile *pSpeedupTiles = (CSpeedupTile *)m_pLayers->Map()->GetData(pTMap->m_Speedup);
|
2014-02-10 18:19:49 +00:00
|
|
|
unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(pTMap->m_Speedup);
|
|
|
|
|
|
|
|
if (Size >= pTMap->m_Width*pTMap->m_Height*sizeof(CSpeedupTile))
|
|
|
|
{
|
|
|
|
Graphics()->BlendNone();
|
2015-08-26 22:46:57 +00:00
|
|
|
vec4 Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
2014-02-10 18:19:49 +00:00
|
|
|
RenderTools()->RenderSpeedupmap(pSpeedupTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
|
|
|
|
Graphics()->BlendNormal();
|
|
|
|
RenderTools()->RenderSpeedupmap(pSpeedupTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
|
2014-05-01 18:15:53 +00:00
|
|
|
RenderTools()->RenderSpeedupOverlay(pSpeedupTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, g_Config.m_ClOverlayEntities/100.0f);
|
2014-02-10 18:19:49 +00:00
|
|
|
}
|
2011-04-19 14:32:42 +00:00
|
|
|
}
|
2014-05-01 15:44:35 +00:00
|
|
|
else if(g_Config.m_ClOverlayEntities && IsTuneLayer)
|
2014-03-12 23:11:25 +00:00
|
|
|
{
|
|
|
|
CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer;
|
|
|
|
Graphics()->TextureSet(m_pClient->m_pMapimages->GetEntities());
|
|
|
|
|
|
|
|
CTuneTile *pTuneTiles = (CTuneTile *)m_pLayers->Map()->GetData(pTMap->m_Tune);
|
|
|
|
unsigned int Size = m_pLayers->Map()->GetUncompressedDataSize(pTMap->m_Tune);
|
|
|
|
|
|
|
|
if (Size >= pTMap->m_Width*pTMap->m_Height*sizeof(CTuneTile))
|
|
|
|
{
|
|
|
|
Graphics()->BlendNone();
|
2015-08-26 22:46:57 +00:00
|
|
|
vec4 Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f*g_Config.m_ClOverlayEntities/100.0f);
|
2014-03-12 23:11:25 +00:00
|
|
|
RenderTools()->RenderTunemap(pTuneTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_OPAQUE);
|
|
|
|
Graphics()->BlendNormal();
|
|
|
|
RenderTools()->RenderTunemap(pTuneTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, Color, TILERENDERFLAG_EXTEND|LAYERRENDERFLAG_TRANSPARENT);
|
2014-07-26 10:33:25 +00:00
|
|
|
//RenderTools()->RenderTuneOverlay(pTuneTiles, pTMap->m_Width, pTMap->m_Height, 32.0f, g_Config.m_ClOverlayEntities/100.0f);
|
2014-03-12 23:11:25 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
if(!g_Config.m_GfxNoclip)
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->ClipDisable();
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(!g_Config.m_GfxNoclip)
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->ClipDisable();
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2009-01-12 14:43:39 +00:00
|
|
|
// reset the screen like it was before
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|