private void InternalCheckCellsInMemory() { uint centerX = ((uint)CenterPosition.X / 8); uint centerY = ((uint)CenterPosition.Y / 8); for (int y = -c_CellsInMemory; y <= c_CellsInMemory; y++) { uint cellY = (uint)(centerY + y) % MapData.ChunkHeight; for (int x = -c_CellsInMemory; x <= c_CellsInMemory; x++) { uint cellX = (uint)(centerX + x) % MapData.ChunkWidth; uint cellIndex = (cellY % c_CellsInMemorySpan) * c_CellsInMemorySpan + (cellX % c_CellsInMemorySpan); if (m_Chunks[cellIndex] == null || m_Chunks[cellIndex].ChunkX != cellX || m_Chunks[cellIndex].ChunkY != cellY) { if (m_Chunks[cellIndex] != null) { m_Chunks[cellIndex].Unload(); } m_Chunks[cellIndex] = new MapChunk(cellX, cellY); m_Chunks[cellIndex].Load(MapData, this); // if we have a translator and it's not spring, change some statics! if (Season != Seasons.Spring && SeasonalTranslator != null) { SeasonalTranslator(m_Chunks[cellIndex], Season); } // let any active multis know that a new map chunk is ready, so they can load in their pieces. Multi.AnnounceMapChunkLoaded(m_Chunks[cellIndex]); } } } }