more gameserver support functions
This commit is contained in:
1 parent
c1426502b4
commit
53ac8b1171
2 files changed
+53
No files matched your search
@@ -231,6 +231,10 @@ void freeUnit(int p, int uix);
|
|||||||
void removeUnit(int p, int uix, int enemy = -1);
|
void removeUnit(int p, int uix, int enemy = -1);
|
||||||
void removeUnitUpdateMap(int p, int uix);
|
void removeUnitUpdateMap(int p, int uix);
|
||||||
void removeDomainUnits(int d, int p, int loc);
|
void removeDomainUnits(int d, int p, int loc);
|
||||||
|
// Removes every unit of player p at loc (not just one) and clears
|
||||||
|
// occupant/ZoC bookkeeping for that tile. Enemy >= 0 counts the units as
|
||||||
|
// lost to that player.
|
||||||
|
void removeAllUnits(int p, int loc, int enemy = -1);
|
||||||
void foundCity(int p, int foundLoc);
|
void foundCity(int p, int foundLoc);
|
||||||
|
|
||||||
// Removes dead (Loc < 0) entries from a player's Un/City/EnemyCity lists,
|
// Removes dead (Loc < 0) entries from a player's Un/City/EnemyCity lists,
|
||||||
@@ -271,6 +275,10 @@ void recalcPeaceMap(int p);
|
|||||||
// recalculate fInEnemyZoC flags for the whole map
|
// recalculate fInEnemyZoC flags for the whole map
|
||||||
void recalcMapZoC(int p);
|
void recalcMapZoC(int p);
|
||||||
|
|
||||||
|
// recalculate fInEnemyZoC flags around a single tile (cheaper than a full
|
||||||
|
// recalcMapZoC() when only one location may have changed).
|
||||||
|
void recalcV8ZoC(int p, int loc);
|
||||||
|
|
||||||
// --- Diplomacy ---
|
// --- Diplomacy ---
|
||||||
|
|
||||||
void introduceEnemy(int p1, int p2);
|
void introduceEnemy(int p1, int p2);
|
||||||
|
|||||||
@@ -749,6 +749,21 @@ void removeDomainUnits(int d, int p, int loc)
|
|||||||
removeUnit(p, uix);
|
removeUnit(p, uix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeAllUnits(int p, int loc, int enemy)
|
||||||
|
{
|
||||||
|
TPlayerContext &player = rw[p];
|
||||||
|
TUn *un = *player.Un;
|
||||||
|
for (int uix = 0; uix < player.nUn; ++uix) {
|
||||||
|
if (un[uix].Loc == loc) {
|
||||||
|
if (enemy >= 0)
|
||||||
|
countLost(p, un[uix].mix, enemy);
|
||||||
|
un[uix].Loc = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
occupant[loc] = -1;
|
||||||
|
zocMap[loc] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void compactLists(int p)
|
void compactLists(int p)
|
||||||
{
|
{
|
||||||
TPlayerContext &player = rw[p];
|
TPlayerContext &player = rw[p];
|
||||||
@@ -1662,6 +1677,36 @@ void updateUnitMap(int loc, bool cityChange)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void recalcV8ZoC(int p, int loc)
|
||||||
|
{
|
||||||
|
if (mode == moLoading_Fast)
|
||||||
|
return;
|
||||||
|
const int observeMask = 3 << (2 * p);
|
||||||
|
Vicinity8Loc adjacent;
|
||||||
|
v8ToLoc(loc, adjacent);
|
||||||
|
std::uint32_t *map = *rw[p].Map;
|
||||||
|
for (int v8 = 0; v8 < 8; ++v8) {
|
||||||
|
const int loc1 = adjacent[static_cast<std::size_t>(v8)];
|
||||||
|
if (loc1 < 0 || loc1 >= mapSize)
|
||||||
|
continue;
|
||||||
|
std::uint32_t &tile1 = map[loc1];
|
||||||
|
tile1 &= ~static_cast<std::uint32_t>(fInEnemyZoC);
|
||||||
|
Vicinity8Loc adjacentAdjacent;
|
||||||
|
v8ToLoc(loc1, adjacentAdjacent);
|
||||||
|
for (int v8v8 = 0; v8v8 < 8; ++v8v8) {
|
||||||
|
const int loc2 = adjacentAdjacent[static_cast<std::size_t>(v8v8)];
|
||||||
|
if (loc2 >= 0 && loc2 < mapSize && zocMap[loc2] > 0 && (observeLevel[loc2] & observeMask)) {
|
||||||
|
const int p1 = occupant[loc2];
|
||||||
|
assert(p1 != nPl);
|
||||||
|
if (p1 != p && rw[p].Treaty[p1] < trAlliance) {
|
||||||
|
tile1 |= fInEnemyZoC;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void recalcMapZoC(int p)
|
void recalcMapZoC(int p)
|
||||||
{
|
{
|
||||||
if (mode == moLoading_Fast)
|
if (mode == moLoading_Fast)
|
||||||
|
|||||||
Reference in new issue
Block a user