mirror of
https://github.com/nolen777/eagle0.git
synced 2026-07-28 20:55:44 +00:00
Recompute fire-cleared map hash (#8768)
This commit is contained in:
@@ -55,7 +55,7 @@ auto UnitIdsRequiringWaterCrossing(
|
||||
.mutate_present(false);
|
||||
}
|
||||
|
||||
const auto mapId = ActionPointDistancesCache::GetMapId(mapCopy);
|
||||
const auto mapId = RecomputeModifierHash(mapCopy.Get());
|
||||
|
||||
vector<UnitId> unitIdsToReturn{};
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class AIWaterCrossingCalculatorTest : public ::testing::Test {
|
||||
InitializeGameSettings();
|
||||
|
||||
apdCache = std::make_shared<ActionPointDistancesCache>();
|
||||
ActionPointDistancesCache::ClearThreadLocalCache();
|
||||
|
||||
heavyCavalry = GetGameSettingsGetter().GetBattalionType(
|
||||
net::eagle0::shardok::storage::fb::BattalionTypeId_HEAVY_CAVALRY);
|
||||
@@ -148,6 +149,36 @@ TEST_F(AIWaterCrossingCalculatorTest, UnitsRequiringWaterCrossing_oneOtherSide_r
|
||||
}));
|
||||
}
|
||||
|
||||
TEST_F(AIWaterCrossingCalculatorTest,
|
||||
UnitsRequiringWaterCrossing_fireChanges_reusesFireClearedDistances) {
|
||||
CoordsSet destinations(hexMap);
|
||||
destinations.Add(acrossDestination);
|
||||
const auto battalionTypeGetter = [](BattalionTypeId typeId) {
|
||||
return GetGameSettings()->GetGetter().GetBattalionType(typeId);
|
||||
};
|
||||
|
||||
const auto beforeFire = UnitIdsRequiringWaterCrossing(
|
||||
gameState,
|
||||
0,
|
||||
destinations,
|
||||
apdCache,
|
||||
battalionTypeGetter);
|
||||
EXPECT_EQ(1, ActionPointDistancesCache::GetThreadLocalCacheSize());
|
||||
|
||||
MutableTerrain(hexMap, Coords(0, 0))->mutable_modifier().mutable_fire().mutate_present(true);
|
||||
hexMap->mutate_modifier_hash(0);
|
||||
hexMap->mutate_modifier_hash(ActionPointDistancesCache::GetMapId(hexMap).modifierId);
|
||||
|
||||
const auto afterFire = UnitIdsRequiringWaterCrossing(
|
||||
gameState,
|
||||
0,
|
||||
destinations,
|
||||
apdCache,
|
||||
battalionTypeGetter);
|
||||
EXPECT_EQ(beforeFire, afterFire);
|
||||
EXPECT_EQ(1, ActionPointDistancesCache::GetThreadLocalCacheSize());
|
||||
}
|
||||
|
||||
TEST_F(AIWaterCrossingCalculatorTest, CanReach_sameSide_returnsTrue) {
|
||||
EXPECT_TRUE(CanReach(origin, sameSideDestination, hexMap, mapId, apdCache, heavyCavalry));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user