diff --git a/game/include/Cevo/Database.h b/game/include/Cevo/Database.h index 95c7951..fc0061e 100644 --- a/game/include/Cevo/Database.h +++ b/game/include/Cevo/Database.h @@ -257,6 +257,10 @@ void completeJob(int p, int loc, int job); // --- Map Editor --- +// Allocates the supervisor's (player 0) map-editor-only Map/MapObservedLast/ +// Territory buffers for standalone map editing (no other player, no +// initGame()). Must be paired with releaseMapEditor(). +void initMapEditor(); // Converts a tile to ocean if it has no grass-or-better neighbor, to shore // otherwise; returns true if the terrain type actually changed. bool checkShore(int loc); diff --git a/game/src/Database.MapEditor.cpp b/game/src/Database.MapEditor.cpp index e2de365..10c97fc 100644 --- a/game/src/Database.MapEditor.cpp +++ b/game/src/Database.MapEditor.cpp @@ -30,9 +30,39 @@ #include "Cevo/Database.h" +#include + namespace Cevo { namespace Database { +void initMapEditor() +{ + calculatePrimitive(); + occupant.fill(-1); + observeLevel.fill(0); + TPlayerContext &player = rw[0]; + resourceMask[0] = 0xFFFFFFFFu; + player.Map = reinterpret_cast(new std::uint32_t[static_cast(mapSize)]()); + player.MapObservedLast = reinterpret_cast(new std::int16_t[static_cast(mapSize)]); + std::memset(*player.MapObservedLast, 0xFF, static_cast(mapSize) * 2); + player.Territory = reinterpret_cast(new std::int8_t[static_cast(mapSize)]); + std::memset(*player.Territory, 0xFF, static_cast(mapSize)); + player.Un = nullptr; + player.Model = nullptr; + player.City = nullptr; + player.EnemyUn = nullptr; + player.EnemyCity = nullptr; + player.EnemyModel = nullptr; + for (int p1 = 0; p1 < nPl; ++p1) + player.EnemyReport[p1] = nullptr; + player.nUn = 0; + player.nModel = 0; + player.nCity = 0; + player.nEnemyUn = 0; + player.nEnemyCity = 0; + player.nEnemyModel = 0; +} + bool checkShore(int loc) { const std::uint32_t oldTile = realMap[loc];