From 04ca8aca9f3d3d61806b171df0024f82af46cf29 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Mon, 15 Jul 2024 07:41:53 +0000 Subject: [PATCH] Update tests --- client/mapView/MapRendererContext.cpp | 4 ++-- lib/gameState/GameStatistics.cpp | 2 +- server/CGameHandler.cpp | 2 +- server/processors/NewTurnProcessor.cpp | 4 ++-- test/game/CGameStateTest.cpp | 2 +- test/map/CMapEditManagerTest.cpp | 16 ++++++++-------- test/map/MapComparer.cpp | 5 +---- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/client/mapView/MapRendererContext.cpp b/client/mapView/MapRendererContext.cpp index 291322f31..d6644b394 100644 --- a/client/mapView/MapRendererContext.cpp +++ b/client/mapView/MapRendererContext.cpp @@ -275,7 +275,7 @@ std::string MapRendererAdventureContext::overlayText(const int3 & coordinates) c const auto & tile = getMapTile(coordinates); - if (!tile.visitable) + if (!tile.visitable()) return {}; return tile.visitableObjects.back()->getObjectName(); @@ -288,7 +288,7 @@ ColorRGBA MapRendererAdventureContext::overlayTextColor(const int3 & coordinates const auto & tile = getMapTile(coordinates); - if (!tile.visitable) + if (!tile.visitable()) return {}; const auto * object = tile.visitableObjects.back(); diff --git a/lib/gameState/GameStatistics.cpp b/lib/gameState/GameStatistics.cpp index a6ee5041c..46b797845 100644 --- a/lib/gameState/GameStatistics.cpp +++ b/lib/gameState/GameStatistics.cpp @@ -291,7 +291,7 @@ float Statistic::getMapExploredRatio(const CGameState * gs, PlayerColor player) { TerrainTile tile = gs->map->getTile(int3(x, y, layer)); - if(tile.blocked && (!tile.visitable)) + if(tile.blocked() && !tile.visitable()) continue; if(gs->isVisible(int3(x, y, layer), player)) diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 12bcf0b7a..1c21ef43f 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -4211,7 +4211,7 @@ CGObjectInstance * CGameHandler::createNewObject(const int3 & visitablePosition, throw std::runtime_error("Attempt to create object outside map at " + visitablePosition.toString()); const TerrainTile & t = gs->map->getTile(visitablePosition); - terrainType = t.terType->getId(); + terrainType = t.getTerrainID(); auto handler = VLC->objtypeh->getHandlerFor(objectID, subID); diff --git a/server/processors/NewTurnProcessor.cpp b/server/processors/NewTurnProcessor.cpp index a850cb99f..73bbf9bf4 100644 --- a/server/processors/NewTurnProcessor.cpp +++ b/server/processors/NewTurnProcessor.cpp @@ -423,7 +423,7 @@ RumorState NewTurnProcessor::pickNewRumor() rumorId = *RandomGeneratorUtil::nextItem(sRumorTypes, rand); if(rumorId == RumorState::RUMOR_GRAIL) { - rumorExtra = gameHandler->gameState()->getTile(gameHandler->gameState()->map->grailPos)->terType->getIndex(); + rumorExtra = gameHandler->gameState()->getTile(gameHandler->gameState()->map->grailPos)->getTerrainID().getNum(); break; } @@ -555,7 +555,7 @@ std::vector NewTurnProcessor::updateHeroesMovementPoints() { auto ti = std::make_unique(h, 1); // NOTE: this code executed when bonuses of previous day not yet updated (this happen in NewTurn::applyGs). See issue 2356 - int32_t newMovementPoints = h->movementPointsLimitCached(gameHandler->gameState()->map->getTile(h->visitablePos()).terType->isLand(), ti.get()); + int32_t newMovementPoints = h->movementPointsLimitCached(gameHandler->gameState()->map->getTile(h->visitablePos()).isLand(), ti.get()); if (newMovementPoints != h->movementPointsRemaining()) result.emplace_back(h->id, newMovementPoints, true); diff --git a/test/game/CGameStateTest.cpp b/test/game/CGameStateTest.cpp index 1047da97c..9313a0f8b 100644 --- a/test/game/CGameStateTest.cpp +++ b/test/game/CGameStateTest.cpp @@ -196,7 +196,7 @@ public: const auto & t = *gameCallback->getTile(tile); - auto terrain = t.terType->getId(); + auto terrain = t.getTerrainID(); BattleField terType(0); BattleLayout layout = BattleLayout::createDefaultLayout(gameState->callback, attacker, defender); diff --git a/test/map/CMapEditManagerTest.cpp b/test/map/CMapEditManagerTest.cpp index b1e7f56e6..542167082 100644 --- a/test/map/CMapEditManagerTest.cpp +++ b/test/map/CMapEditManagerTest.cpp @@ -38,17 +38,17 @@ TEST(MapManager, DrawTerrain_Type) static const int3 squareCheck[] = { int3(5,5,0), int3(5,4,0), int3(4,4,0), int3(4,5,0) }; for(const auto & tile : squareCheck) { - EXPECT_EQ(map->getTile(tile).terType->getId(), ETerrainId::GRASS); + EXPECT_EQ(map->getTile(tile).getTerrainID(), ETerrainId::GRASS); } // Concat to square editManager->getTerrainSelection().select(int3(6, 5, 0)); editManager->drawTerrain(ETerrainId::GRASS, 10, &rand); - EXPECT_EQ(map->getTile(int3(6, 4, 0)).terType->getId(), ETerrainId::GRASS); + EXPECT_EQ(map->getTile(int3(6, 4, 0)).getTerrainID(), ETerrainId::GRASS); editManager->getTerrainSelection().select(int3(6, 5, 0)); editManager->drawTerrain(ETerrainId::LAVA, 10, &rand); - EXPECT_EQ(map->getTile(int3(4, 4, 0)).terType->getId(), ETerrainId::GRASS); - EXPECT_EQ(map->getTile(int3(7, 4, 0)).terType->getId(), ETerrainId::LAVA); + EXPECT_EQ(map->getTile(int3(4, 4, 0)).getTerrainID(), ETerrainId::GRASS); + EXPECT_EQ(map->getTile(int3(7, 4, 0)).getTerrainID(), ETerrainId::LAVA); // Special case water,rock editManager->getTerrainSelection().selectRange(MapRect(int3(10, 10, 0), 10, 5)); @@ -57,7 +57,7 @@ TEST(MapManager, DrawTerrain_Type) editManager->drawTerrain(ETerrainId::GRASS, 10, &rand); editManager->getTerrainSelection().select(int3(21, 16, 0)); editManager->drawTerrain(ETerrainId::GRASS, 10, &rand); - EXPECT_EQ(map->getTile(int3(20, 15, 0)).terType->getId(), ETerrainId::GRASS); + EXPECT_EQ(map->getTile(int3(20, 15, 0)).getTerrainID(), ETerrainId::GRASS); // Special case non water,rock static const int3 diagonalCheck[] = { int3(31,42,0), int3(32,42,0), int3(32,43,0), int3(33,43,0), int3(33,44,0), @@ -68,7 +68,7 @@ TEST(MapManager, DrawTerrain_Type) editManager->getTerrainSelection().select(tile); } editManager->drawTerrain(ETerrainId::GRASS, 10, &rand); - EXPECT_EQ(map->getTile(int3(35, 44, 0)).terType->getId(), ETerrainId::WATER); + EXPECT_EQ(map->getTile(int3(35, 44, 0)).getTerrainID(), ETerrainId::WATER); // Rock case editManager->getTerrainSelection().selectRange(MapRect(int3(1, 1, 1), 15, 15)); @@ -77,7 +77,7 @@ TEST(MapManager, DrawTerrain_Type) int3(8, 7, 1), int3(4, 8, 1), int3(5, 8, 1), int3(6, 8, 1)}); editManager->getTerrainSelection().setSelection(vec); editManager->drawTerrain(ETerrainId::ROCK, 10, &rand); - EXPECT_TRUE(!map->getTile(int3(5, 6, 1)).terType->isPassable() || !map->getTile(int3(7, 8, 1)).terType->isPassable()); + EXPECT_TRUE(!map->getTile(int3(5, 6, 1)).getTerrain()->isPassable() || !map->getTile(int3(7, 8, 1)).getTerrain()->isPassable()); //todo: add checks here and enable, also use smaller size #if 0 @@ -144,7 +144,7 @@ TEST(MapManager, DrawTerrain_View) int3 pos((si32)posVector[0].Float(), (si32)posVector[1].Float(), (si32)posVector[2].Float()); const auto & originalTile = originalMap->getTile(pos); editManager->getTerrainSelection().selectRange(MapRect(pos, 1, 1)); - editManager->drawTerrain(originalTile.terType->getId(), 10, &gen); + editManager->drawTerrain(originalTile.getTerrainID(), 10, &gen); const auto & tile = map->getTile(pos); bool isInRange = false; for(const auto & range : mapping) diff --git a/test/map/MapComparer.cpp b/test/map/MapComparer.cpp index 8d1744520..61e1f018e 100644 --- a/test/map/MapComparer.cpp +++ b/test/map/MapComparer.cpp @@ -133,7 +133,7 @@ void checkEqual(const ObjectTemplate & actual, const ObjectTemplate & expected) void checkEqual(const TerrainTile & actual, const TerrainTile & expected) { //fatal fail here on any error - VCMI_REQUIRE_FIELD_EQUAL(terType); + VCMI_REQUIRE_FIELD_EQUAL(terrainType); VCMI_REQUIRE_FIELD_EQUAL(terView); VCMI_REQUIRE_FIELD_EQUAL(riverType); VCMI_REQUIRE_FIELD_EQUAL(riverDir); @@ -143,9 +143,6 @@ void checkEqual(const TerrainTile & actual, const TerrainTile & expected) ASSERT_EQ(actual.blockingObjects.size(), expected.blockingObjects.size()); ASSERT_EQ(actual.visitableObjects.size(), expected.visitableObjects.size()); - - VCMI_REQUIRE_FIELD_EQUAL(visitable); - VCMI_REQUIRE_FIELD_EQUAL(blocked); } //MapComparer