2653: Fix background map loading r=def- a=Jupeyy

As reported.

Tested all possible contexts, hope this is right now

Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
bors[bot] 2020-08-26 13:49:30 +00:00 committed by GitHub
commit efdd35439e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 9 deletions

View file

@ -50,14 +50,16 @@ void CBackground::LoadBackground()
m_pLayers = m_pBackgroundLayers;
m_pImages = m_pBackgroundImages;
bool NeedImageLoading = false;
str_copy(m_aMapName, g_Config.m_ClBackgroundEntities, sizeof(m_aMapName));
char aBuf[128];
str_format(aBuf, sizeof(aBuf), "maps/%s", g_Config.m_ClBackgroundEntities);
if(m_pMap->Load(aBuf))
{
m_pLayers->InitBackground(m_pMap);
m_pImages->LoadBackground(m_pMap);
RenderTools()->RenderTilemapGenerateSkip(m_pLayers);
NeedImageLoading = true;
m_Loaded = true;
}
else if(str_comp(g_Config.m_ClBackgroundEntities, CURRENT) == 0)
@ -72,7 +74,11 @@ void CBackground::LoadBackground()
}
if(m_Loaded)
{
CMapLayers::OnMapLoad();
if(NeedImageLoading)
m_pImages->LoadBackground(m_pLayers, m_pMap);
}
m_LastLoad = time_get();
}

View file

@ -29,10 +29,8 @@ void CMapImages::OnInit()
InitOverlayTextures();
}
void CMapImages::OnMapLoad()
void CMapImages::OnMapLoadImpl(class CLayers *pLayers, IMap *pMap)
{
IMap *pMap = Kernel()->RequestInterface<IMap>();
// unload all textures
for(int i = 0; i < m_Count; i++)
{
@ -45,7 +43,6 @@ void CMapImages::OnMapLoad()
int Start;
pMap->GetType(MAPITEMTYPE_IMAGE, &Start, &m_Count);
CLayers *pLayers = m_pClient->Layers();
for(int g = 0; g < pLayers->NumGroups(); g++)
{
CMapItemGroup *pGroup = pLayers->GetGroup(g);
@ -99,9 +96,16 @@ void CMapImages::OnMapLoad()
}
}
void CMapImages::LoadBackground(class IMap *pMap)
void CMapImages::OnMapLoad()
{
CMapImages::OnMapLoad();
IMap *pMap = Kernel()->RequestInterface<IMap>();
CLayers *pLayers = m_pClient->Layers();
OnMapLoadImpl(pLayers, pMap);
}
void CMapImages::LoadBackground(class CLayers *pLayers, class IMap *pMap)
{
OnMapLoadImpl(pLayers, pMap);
}
IGraphics::CTextureHandle CMapImages::GetEntities()

View file

@ -20,9 +20,10 @@ public:
IGraphics::CTextureHandle Get(int Index) const { return m_aTextures[Index]; }
int Num() const { return m_Count; }
void OnMapLoadImpl(class CLayers *pLayers, class IMap *pMap);
virtual void OnMapLoad();
virtual void OnInit();
void LoadBackground(class IMap *pMap);
void LoadBackground(class CLayers *pLayers, class IMap *pMap);
// DDRace
IGraphics::CTextureHandle GetEntities();