#pragma once #include "Cevo/Protocol.h" #include #include namespace Cevo { namespace Database { // Equivalent of Database.pas's global `var` state and free functions. Kept // as flat global state/free functions - matching the original's own // architecture (a single shared-state game server module) - rather than // wrapped in a class/singleton that wasn't asked for and would be a large, // separate refactor. // // Database.pas is ~4080 lines with heavy dependencies on Protocol.pas's big // gameplay structs (TPlayerContext, TModel, TCity, TUn, ...) - all already // available via Cevo/Protocol.h (see game/CMakeLists.txt: cevogame links // cevoai to reuse its exact port of those shared structs/constants, since // perso/cevo/Protocol.pas and the AI-facing "AI Template/Protocol.pas" // define them identically). Ported INCREMENTALLY regardless: this only // covers globals/functions actually consumed by whichever caller (Database // itself, CityProcessing, ...) has been ported so far. Add more here only // once a new batch needs them. // // `rw[p].City`/`.Un`/`.Model` are pointer-to-array fields (TCityList* etc.) // that stay null until Database's InitGame-equivalent (not ported yet) // allocates them - dereference as `(*rw[p].City)[cix]`, or cache a decayed // `TCity *city = *rw[p].City;` first if indexing repeatedly (same idiom // ai/src/CustomAI.cpp already uses for `myCity`). extern int lx; extern int ly; extern int mapSize; // = lx * ly using Vicinity8Loc = std::array; using Vicinity21Loc = std::array; // player data extern std::array rw; // map data extern std::array realMap; extern std::array occupant; // occupying player for each tile extern std::array zocMap; extern std::array usedByCity; // -1 if not exploited // Equivalent of Database.pas's MaskD(). void maskD(std::uint32_t *x, int count, std::uint32_t mask); // --- Location Navigation --- // Relative location, dx in hor and dy in ver direction from loc. Returns -1 // if the result would fall outside the map. int dLoc(int loc, int dx, int dy); void dxdy(int loc0, int loc1, int &dx, int &dy); int distance(int loc0, int loc1); void v8ToLoc(int loc0, Vicinity8Loc &vicinityLoc); void v21ToLoc(int loc0, Vicinity21Loc &vicinityLoc); // --- Map Creation --- void calculatePrimitive(); bool mapGeneratorAvailable(); } // namespace Database } // namespace Cevo