From 2c09bfb22a12cd10eb401eac00d445d6fe2e3959 Mon Sep 17 00:00:00 2001 From: Dydzio Date: Fri, 30 Dec 2022 15:51:13 +0100 Subject: [PATCH] Fix code formatting --- lib/IGameCallback.cpp | 48 +++++++++++++++++----------------- lib/IGameCallback.h | 40 ++++++++++++++++------------ lib/mapObjects/MiscObjects.cpp | 36 ++++++++++++------------- 3 files changed, 66 insertions(+), 58 deletions(-) diff --git a/lib/IGameCallback.cpp b/lib/IGameCallback.cpp index 9c8ca7325..8e4210d15 100644 --- a/lib/IGameCallback.cpp +++ b/lib/IGameCallback.cpp @@ -110,35 +110,35 @@ void CPrivilegedInfoCallback::getAllTiles(std::unordered_set & else floors.push_back(level); - for (auto zd : floors) + for(auto zd: floors) { - for (int xd = 0; xd < gs->map->width; xd++) + for(int xd = 0; xd < gs->map->width; xd++) { - for (int yd = 0; yd < gs->map->height; yd++) + for(int yd = 0; yd < gs->map->height; yd++) { - bool isTileEligible = false; + bool isTileEligible = false; - switch(tileFilterMode) - { - case MapTerrainFilterMode::NONE: - isTileEligible = true; - break; - case MapTerrainFilterMode::WATER: - isTileEligible = getTile (int3 (xd,yd,zd))->terType->isWater(); - break; - case MapTerrainFilterMode::LAND: - isTileEligible = getTile (int3 (xd,yd,zd))->terType->isLand(); - break; - case MapTerrainFilterMode::LAND_CARTOGRAPHER: - isTileEligible = getTile(int3 (xd,yd,zd))->terType->isSurfaceCartographerCompatible(); - break; - case MapTerrainFilterMode::UNDERGROUND_CARTOGRAPHER: - isTileEligible = getTile(int3 (xd,yd,zd))->terType->isUndergroundCartographerCompatible(); - break; - } + switch(tileFilterMode) + { + case MapTerrainFilterMode::NONE: + isTileEligible = true; + break; + case MapTerrainFilterMode::WATER: + isTileEligible = getTile(int3(xd, yd, zd))->terType->isWater(); + break; + case MapTerrainFilterMode::LAND: + isTileEligible = getTile(int3(xd, yd, zd))->terType->isLand(); + break; + case MapTerrainFilterMode::LAND_CARTOGRAPHER: + isTileEligible = getTile(int3(xd, yd, zd))->terType->isSurfaceCartographerCompatible(); + break; + case MapTerrainFilterMode::UNDERGROUND_CARTOGRAPHER: + isTileEligible = getTile(int3(xd, yd, zd))->terType->isUndergroundCartographerCompatible(); + break; + } - if (isTileEligible) - tiles.insert(int3(xd,yd,zd)); + if(isTileEligible) + tiles.insert(int3(xd, yd, zd)); } } } diff --git a/lib/IGameCallback.h b/lib/IGameCallback.h index 17effb248..edc334dc0 100644 --- a/lib/IGameCallback.h +++ b/lib/IGameCallback.h @@ -40,23 +40,31 @@ namespace scripting class DLL_LINKAGE CPrivilegedInfoCallback : public CGameInfoCallback { public: - enum class MapTerrainFilterMode - { - NONE = 0, - LAND = 1, - WATER = 2, - LAND_CARTOGRAPHER = 3, - UNDERGROUND_CARTOGRAPHER = 4 - }; + enum class MapTerrainFilterMode + { + NONE = 0, + LAND = 1, + WATER = 2, + LAND_CARTOGRAPHER = 3, + UNDERGROUND_CARTOGRAPHER = 4 + }; - CGameState * gameState(); - //used for random spawns - void getFreeTiles (std::vector &tiles) const; - //mode 1 - only unrevealed tiles; mode 0 - all, mode -1 - only revealed - void getTilesInRange(std::unordered_set &tiles, int3 pos, int radious, boost::optional player = boost::optional(), int mode = 0, int3::EDistanceFormula formula = int3::DIST_2D) const; - //returns all tiles on given level (-1 - both levels, otherwise number of level) - void getAllTiles (std::unordered_set &tiles, boost::optional player = boost::optional(), int level=-1, MapTerrainFilterMode tileFilterMode = MapTerrainFilterMode::NONE) const; - void pickAllowedArtsSet(std::vector &out, CRandomGenerator & rand); //gives 3 treasures, 3 minors, 1 major -> used by Black Market and Artifact Merchant + CGameState *gameState(); + + //used for random spawns + void getFreeTiles(std::vector &tiles) const; + + //mode 1 - only unrevealed tiles; mode 0 - all, mode -1 - only revealed + void getTilesInRange(std::unordered_set &tiles, int3 pos, int radious, + boost::optional player = boost::optional(), int mode = 0, + int3::EDistanceFormula formula = int3::DIST_2D) const; + + //returns all tiles on given level (-1 - both levels, otherwise number of level) + void getAllTiles(std::unordered_set &tiles, boost::optional player = boost::optional(), + int level = -1, MapTerrainFilterMode tileFilterMode = MapTerrainFilterMode::NONE) const; + + void pickAllowedArtsSet(std::vector &out, + CRandomGenerator &rand); //gives 3 treasures, 3 minors, 1 major -> used by Black Market and Artifact Merchant void getAllowedSpells(std::vector &out, ui16 level); template diff --git a/lib/mapObjects/MiscObjects.cpp b/lib/mapObjects/MiscObjects.cpp index 7bbdca1c2..1200ddb1b 100644 --- a/lib/mapObjects/MiscObjects.cpp +++ b/lib/mapObjects/MiscObjects.cpp @@ -2068,9 +2068,9 @@ void CCartographer::onHeroVisit( const CGHeroInstance * h ) const void CCartographer::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const { - if (answer) //if hero wants to buy map + if(answer) //if hero wants to buy map { - cb->giveResource (hero->tempOwner, Res::GOLD, -1000); + cb->giveResource(hero->tempOwner, Res::GOLD, -1000); FoWChange fw; fw.mode = 1; fw.player = hero->tempOwner; @@ -2078,24 +2078,24 @@ void CCartographer::blockingDialogAnswered(const CGHeroInstance *hero, ui32 answ //subIDs of different types of cartographers: //water = 0; land = 1; underground = 2; - IGameCallback::MapTerrainFilterMode tileFilterMode = IGameCallback::MapTerrainFilterMode::NONE; + IGameCallback::MapTerrainFilterMode tileFilterMode = IGameCallback::MapTerrainFilterMode::NONE; - switch(subID) - { - case 0: - tileFilterMode = CPrivilegedInfoCallback::MapTerrainFilterMode::WATER; - break; - case 1: - tileFilterMode = CPrivilegedInfoCallback::MapTerrainFilterMode::LAND_CARTOGRAPHER; - break; - case 2: - tileFilterMode = CPrivilegedInfoCallback::MapTerrainFilterMode::UNDERGROUND_CARTOGRAPHER; - break; - } + switch(subID) + { + case 0: + tileFilterMode = CPrivilegedInfoCallback::MapTerrainFilterMode::WATER; + break; + case 1: + tileFilterMode = CPrivilegedInfoCallback::MapTerrainFilterMode::LAND_CARTOGRAPHER; + break; + case 2: + tileFilterMode = CPrivilegedInfoCallback::MapTerrainFilterMode::UNDERGROUND_CARTOGRAPHER; + break; + } - cb->getAllTiles (fw.tiles, hero->tempOwner, -1, tileFilterMode); //reveal appropriate tiles - cb->sendAndApply (&fw); - cb->setObjProperty (id, CCartographer::OBJPROP_VISITED, hero->tempOwner.getNum()); + cb->getAllTiles(fw.tiles, hero->tempOwner, -1, tileFilterMode); //reveal appropriate tiles + cb->sendAndApply(&fw); + cb->setObjProperty(id, CCartographer::OBJPROP_VISITED, hero->tempOwner.getNum()); } }