69 lines
2.5 KiB
C++
69 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include "Cevo/Protocol.h"
|
|
|
|
#include <array>
|
|
#include <cstdint>
|
|
|
|
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<int, 8>;
|
|
using Vicinity21Loc = std::array<int, 28>;
|
|
|
|
// player data
|
|
extern std::array<TPlayerContext, nPl> rw;
|
|
|
|
// map data
|
|
extern std::array<std::uint32_t, lxmax * lymax> realMap;
|
|
extern std::array<std::int8_t, lxmax * lymax> occupant; // occupying player for each tile
|
|
extern std::array<std::int8_t, lxmax * lymax> zocMap;
|
|
extern std::array<std::int32_t, lxmax * lymax> 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
|