From 0ddc7fddb4052ce7c1052d11d8ba7963d0f6b7ec Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Tue, 22 Sep 2020 02:01:22 +0200 Subject: [PATCH] Don't rely on snapshot for ddnet gametype --- src/game/client/components/mapimages.cpp | 42 ++++++++++++------------ src/game/client/components/mapimages.h | 10 +++--- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/game/client/components/mapimages.cpp b/src/game/client/components/mapimages.cpp index b41895ab4..fe54f5acf 100644 --- a/src/game/client/components/mapimages.cpp +++ b/src/game/client/components/mapimages.cpp @@ -113,29 +113,29 @@ void CMapImages::LoadBackground(class CLayers *pLayers, class IMap *pMap) OnMapLoadImpl(pLayers, pMap); } -bool CMapImages::HasFrontLayer() +bool CMapImages::HasFrontLayer(EMapImageModType ModType) { - return GameClient()->m_GameInfo.m_EntitiesDDNet || GameClient()->m_GameInfo.m_EntitiesDDRace; + return ModType == MAP_IMAGE_MOD_TYPE_DDNET || ModType == MAP_IMAGE_MOD_TYPE_DDRACE; } -bool CMapImages::HasSpeedupLayer() +bool CMapImages::HasSpeedupLayer(EMapImageModType ModType) { - return GameClient()->m_GameInfo.m_EntitiesDDNet || GameClient()->m_GameInfo.m_EntitiesDDRace; + return ModType == MAP_IMAGE_MOD_TYPE_DDNET || ModType == MAP_IMAGE_MOD_TYPE_DDRACE; } -bool CMapImages::HasSwitchLayer() +bool CMapImages::HasSwitchLayer(EMapImageModType ModType) { - return GameClient()->m_GameInfo.m_EntitiesDDNet || GameClient()->m_GameInfo.m_EntitiesDDRace; + return ModType == MAP_IMAGE_MOD_TYPE_DDNET || ModType == MAP_IMAGE_MOD_TYPE_DDRACE; } -bool CMapImages::HasTeleLayer() +bool CMapImages::HasTeleLayer(EMapImageModType ModType) { - return GameClient()->m_GameInfo.m_EntitiesDDNet || GameClient()->m_GameInfo.m_EntitiesDDRace; + return ModType == MAP_IMAGE_MOD_TYPE_DDNET || ModType == MAP_IMAGE_MOD_TYPE_DDRACE; } -bool CMapImages::HasTuneLayer() +bool CMapImages::HasTuneLayer(EMapImageModType ModType) { - return GameClient()->m_GameInfo.m_EntitiesDDNet || GameClient()->m_GameInfo.m_EntitiesDDRace; + return ModType == MAP_IMAGE_MOD_TYPE_DDNET || ModType == MAP_IMAGE_MOD_TYPE_DDRACE; } IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType EntityLayerType) @@ -175,9 +175,9 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit EntitiesModType = MAP_IMAGE_MOD_TYPE_VANILLA; } - if(!m_EntitiesIsLoaded[EntitiesModType + (int)EntitesAreMasked]) + if(!m_EntitiesIsLoaded[(EntitiesModType * 2) + (int)EntitesAreMasked]) { - m_EntitiesIsLoaded[EntitiesModType + (int)EntitesAreMasked] = true; + m_EntitiesIsLoaded[(EntitiesModType * 2) + (int)EntitesAreMasked] = true; // any mod that does not mask, will get all layers unmasked bool WasUnknwon = !EntitesAreMasked; @@ -185,11 +185,11 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit char aPath[64]; str_format(aPath, sizeof(aPath), "editor/entities_clear/%s.png", pEntities); - bool GameTypeHasFrontLayer = HasFrontLayer() || WasUnknwon; - bool GameTypeHasSpeedupLayer = HasSpeedupLayer() || WasUnknwon; - bool GameTypeHasSwitchLayer = HasSwitchLayer() || WasUnknwon; - bool GameTypeHasTeleLayer = HasTeleLayer() || WasUnknwon; - bool GameTypeHasTuneLayer = HasTuneLayer() || WasUnknwon; + bool GameTypeHasFrontLayer = HasFrontLayer(EntitiesModType) || WasUnknwon; + bool GameTypeHasSpeedupLayer = HasSpeedupLayer(EntitiesModType) || WasUnknwon; + bool GameTypeHasSwitchLayer = HasSwitchLayer(EntitiesModType) || WasUnknwon; + bool GameTypeHasTeleLayer = HasTeleLayer(EntitiesModType) || WasUnknwon; + bool GameTypeHasTuneLayer = HasTuneLayer(EntitiesModType) || WasUnknwon; int TextureLoadFlag = Graphics()->HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE; @@ -224,7 +224,7 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit else if(n == MAP_IMAGE_ENTITY_LAYER_TYPE_TUNE && !GameTypeHasTuneLayer) BuildThisLayer = false; - dbg_assert(m_EntitiesTextures[EntitiesModType + (int)EntitesAreMasked][n] == -1, "entities texture already loaded when it should not be"); + dbg_assert(m_EntitiesTextures[(EntitiesModType * 2) + (int)EntitesAreMasked][n] == -1, "entities texture already loaded when it should not be"); if(BuildThisLayer) { @@ -293,7 +293,7 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit } } - m_EntitiesTextures[EntitiesModType + (int)EntitesAreMasked][n] = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, pBuildImgData, ImgInfo.m_Format, TextureLoadFlag, aPath); + m_EntitiesTextures[(EntitiesModType * 2) + (int)EntitesAreMasked][n] = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, pBuildImgData, ImgInfo.m_Format, TextureLoadFlag, aPath); } else { @@ -304,7 +304,7 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit m_TransparentTexture = Graphics()->LoadTextureRaw(ImgInfo.m_Width, ImgInfo.m_Height, ImgInfo.m_Format, pBuildImgData, ImgInfo.m_Format, TextureLoadFlag, aPath); } - m_EntitiesTextures[EntitiesModType + (int)EntitesAreMasked][n] = m_TransparentTexture; + m_EntitiesTextures[(EntitiesModType * 2) + (int)EntitesAreMasked][n] = m_TransparentTexture; } } @@ -312,7 +312,7 @@ IGraphics::CTextureHandle CMapImages::GetEntities(EMapImageEntityLayerType Entit } } - return m_EntitiesTextures[EntitiesModType + (int)EntitesAreMasked][EntityLayerType]; + return m_EntitiesTextures[(EntitiesModType * 2) + (int)EntitesAreMasked][EntityLayerType]; } IGraphics::CTextureHandle CMapImages::GetSpeedupArrow() diff --git a/src/game/client/components/mapimages.h b/src/game/client/components/mapimages.h index 2150d44b0..426ca6538 100644 --- a/src/game/client/components/mapimages.h +++ b/src/game/client/components/mapimages.h @@ -36,11 +36,11 @@ class CMapImages : public CComponent int m_aTextureUsedByTileOrQuadLayerFlag[64]; // 0: nothing, 1(as flag): tile layer, 2(as flag): quad layer int m_Count; - bool HasFrontLayer(); - bool HasSpeedupLayer(); - bool HasSwitchLayer(); - bool HasTeleLayer(); - bool HasTuneLayer(); + bool HasFrontLayer(EMapImageModType ModType); + bool HasSpeedupLayer(EMapImageModType ModType); + bool HasSwitchLayer(EMapImageModType ModType); + bool HasTeleLayer(EMapImageModType ModType); + bool HasTuneLayer(EMapImageModType ModType); public: CMapImages();