Properly handle map resizes in Atlas, fixes #4800.
Reviewed By: vladislavbelov Differential Revision: https://code.wildfiregames.com/D946 This was SVN commit r21675.
This commit is contained in:
parent
dfa2048dc5
commit
593a6a228e
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
/* Copyright (C) 2018 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -552,6 +552,16 @@ void CCmpPathfinder::TerrainUpdateHelper(bool expandPassability/* = true */)
|
||||
|
||||
SAFE_DELETE(m_TerrainOnlyGrid);
|
||||
m_TerrainOnlyGrid = new Grid<NavcellData>(m_MapSize * Pathfinding::NAVCELLS_PER_TILE, m_MapSize * Pathfinding::NAVCELLS_PER_TILE);
|
||||
|
||||
// If this update comes from a map resizing, we must reinitialize the other grids as well
|
||||
if (!m_TerrainOnlyGrid->compare_sizes(m_Grid))
|
||||
{
|
||||
SAFE_DELETE(m_Grid);
|
||||
m_Grid = new Grid<NavcellData>(m_MapSize * Pathfinding::NAVCELLS_PER_TILE, m_MapSize * Pathfinding::NAVCELLS_PER_TILE);
|
||||
|
||||
m_DirtinessInformation = { true, true, Grid<u8>(m_MapSize * Pathfinding::NAVCELLS_PER_TILE, m_MapSize * Pathfinding::NAVCELLS_PER_TILE) };
|
||||
m_AIPathfinderDirtinessInformation = m_DirtinessInformation;
|
||||
}
|
||||
}
|
||||
|
||||
Grid<u16> shoreGrid = ComputeShoreGrid();
|
||||
|
@ -165,7 +165,7 @@ public:
|
||||
template<typename U>
|
||||
bool compare_sizes(const Grid<U>* g) const
|
||||
{
|
||||
return m_W == g->m_W && m_H == g->m_H;
|
||||
return g && m_W == g->m_W && m_H == g->m_H;
|
||||
}
|
||||
|
||||
u16 m_W, m_H;
|
||||
|
Loading…
Reference in New Issue
Block a user