1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Formatting and cleanup

This commit is contained in:
Ivan Savenko 2023-04-17 16:19:56 +03:00
parent 365f552fa1
commit dd227d24c3
7 changed files with 18 additions and 27 deletions

View File

@ -8,12 +8,10 @@
* *
*/ */
#include "StdInc.h" #include "StdInc.h"
#include "ClientCommandManager.h" #include "ClientCommandManager.h"
#include "Client.h" #include "Client.h"
#include "adventureMap/CInGameConsole.h" #include "adventureMap/CInGameConsole.h"
#include "adventureMap/CAdventureMapInterface.h"
#include "CPlayerInterface.h" #include "CPlayerInterface.h"
#include "PlayerLocalState.h" #include "PlayerLocalState.h"
#include "CServerHandler.h" #include "CServerHandler.h"

View File

@ -117,13 +117,13 @@ const CGTownInstance * PlayerLocalState::getCurrentTown() const
const CArmedInstance * PlayerLocalState::getCurrentArmy() const const CArmedInstance * PlayerLocalState::getCurrentArmy() const
{ {
if (currentSelection) if(currentSelection)
return dynamic_cast<const CArmedInstance *>(currentSelection); return dynamic_cast<const CArmedInstance *>(currentSelection);
else else
return nullptr; return nullptr;
} }
void PlayerLocalState::setSelection(const CArmedInstance *selection) void PlayerLocalState::setSelection(const CArmedInstance * selection)
{ {
currentSelection = selection; currentSelection = selection;
} }
@ -133,7 +133,7 @@ bool PlayerLocalState::isHeroSleeping(const CGHeroInstance * hero) const
return vstd::contains(sleepingHeroes, hero); return vstd::contains(sleepingHeroes, hero);
} }
void PlayerLocalState::setHeroAsleep(const CGHeroInstance *hero) void PlayerLocalState::setHeroAsleep(const CGHeroInstance * hero)
{ {
assert(hero); assert(hero);
assert(vstd::contains(wanderingHeroes, hero)); assert(vstd::contains(wanderingHeroes, hero));
@ -158,7 +158,7 @@ const std::vector<const CGHeroInstance *> & PlayerLocalState::getWanderingHeroes
const CGHeroInstance * PlayerLocalState::getWanderingHero(size_t index) const CGHeroInstance * PlayerLocalState::getWanderingHero(size_t index)
{ {
if (index < wanderingHeroes.size()) if(index < wanderingHeroes.size())
return wanderingHeroes[index]; return wanderingHeroes[index];
return nullptr; return nullptr;
} }
@ -185,7 +185,7 @@ const std::vector<const CGTownInstance *> & PlayerLocalState::getOwnedTowns()
const CGTownInstance * PlayerLocalState::getOwnedTown(size_t index) const CGTownInstance * PlayerLocalState::getOwnedTown(size_t index)
{ {
if (index < ownedTowns.size()) if(index < ownedTowns.size())
return ownedTowns[index]; return ownedTowns[index];
return nullptr; return nullptr;
} }

View File

@ -34,9 +34,9 @@ class PlayerLocalState
std::vector<const CGHeroInstance *> wanderingHeroes; //our heroes on the adventure map (not the garrisoned ones) std::vector<const CGHeroInstance *> wanderingHeroes; //our heroes on the adventure map (not the garrisoned ones)
std::vector<const CGTownInstance *> ownedTowns; //our towns on the adventure map std::vector<const CGTownInstance *> ownedTowns; //our towns on the adventure map
void saveHeroPaths(std::map<const CGHeroInstance *, int3> & paths); void saveHeroPaths(std::map<const CGHeroInstance *, int3> & paths);
void loadHeroPaths(std::map<const CGHeroInstance *, int3> & paths); void loadHeroPaths(std::map<const CGHeroInstance *, int3> & paths);
public: public:
struct SpellbookLastSetting struct SpellbookLastSetting
{ {
@ -46,7 +46,8 @@ public:
int spellbookLastTabBattle = 4; int spellbookLastTabBattle = 4;
int spellbookLastTabAdvmap = 4; int spellbookLastTabAdvmap = 4;
template <typename Handler> void serialize( Handler &h, const int version ) template<typename Handler>
void serialize(Handler & h, const int version)
{ {
h & spellbookLastPageBattle; h & spellbookLastPageBattle;
h & spellbokLastPageAdvmap; h & spellbokLastPageAdvmap;
@ -71,15 +72,15 @@ public:
void addWanderingHero(const CGHeroInstance * hero); void addWanderingHero(const CGHeroInstance * hero);
void removeWanderingHero(const CGHeroInstance * hero); void removeWanderingHero(const CGHeroInstance * hero);
void setPath(const CGHeroInstance *h, const CGPath & path); void setPath(const CGHeroInstance * h, const CGPath & path);
bool setPath(const CGHeroInstance *h, const int3 & destination); bool setPath(const CGHeroInstance * h, const int3 & destination);
const CGPath & getPath(const CGHeroInstance *h) const; const CGPath & getPath(const CGHeroInstance * h) const;
bool hasPath(const CGHeroInstance *h) const; bool hasPath(const CGHeroInstance * h) const;
void removeLastNode(const CGHeroInstance *h); void removeLastNode(const CGHeroInstance * h);
void erasePath(const CGHeroInstance *h); void erasePath(const CGHeroInstance * h);
void verifyPath(const CGHeroInstance *h); void verifyPath(const CGHeroInstance * h);
/// Returns currently selected object /// Returns currently selected object
const CGHeroInstance * getCurrentHero() const; const CGHeroInstance * getCurrentHero() const;
@ -87,10 +88,10 @@ public:
const CArmedInstance * getCurrentArmy() const; const CArmedInstance * getCurrentArmy() const;
/// Changes currently selected object /// Changes currently selected object
void setSelection(const CArmedInstance *selection); void setSelection(const CArmedInstance * selection);
template <typename Handler> template<typename Handler>
void serialize( Handler &h, int version ) void serialize(Handler & h, int version)
{ {
//WARNING: this code is broken and not used. See CClient::loadGame //WARNING: this code is broken and not used. See CClient::loadGame
std::map<const CGHeroInstance *, int3> pathsMap; //hero -> dest std::map<const CGHeroInstance *, int3> pathsMap; //hero -> dest

View File

@ -27,7 +27,6 @@
#include "../windows/GUIClasses.h" #include "../windows/GUIClasses.h"
#include "../windows/InfoWindows.h" #include "../windows/InfoWindows.h"
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "../CMusicHandler.h"
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../lobby/CSavingScreen.h" #include "../lobby/CSavingScreen.h"
#include "../render/CAnimation.h" #include "../render/CAnimation.h"
@ -48,9 +47,6 @@
#include "../../lib/mapObjects/CGTownInstance.h" #include "../../lib/mapObjects/CGTownInstance.h"
#include "../../lib/CPathfinder.h" #include "../../lib/CPathfinder.h"
#include "../../lib/mapping/CMap.h" #include "../../lib/mapping/CMap.h"
#include "../../lib/UnlockGuard.h"
#include "../../lib/TerrainHandler.h"
#include <SDL_keycode.h>
#define ADVOPT (conf.go()->ac) #define ADVOPT (conf.go()->ac)

View File

@ -11,8 +11,6 @@
#include "StdInc.h" #include "StdInc.h"
#include "CAdventureOptions.h" #include "CAdventureOptions.h"
#include "CAdventureMapInterface.h"
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../PlayerLocalState.h" #include "../PlayerLocalState.h"

View File

@ -16,7 +16,6 @@
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../PlayerLocalState.h" #include "../PlayerLocalState.h"
#include "../ClientCommandManager.h" #include "../ClientCommandManager.h"
#include "../adventureMap/CAdventureMapInterface.h"
#include "../gui/CGuiHandler.h" #include "../gui/CGuiHandler.h"
#include "../render/Colors.h" #include "../render/Colors.h"

View File

@ -18,7 +18,6 @@
#include "../CGameInfo.h" #include "../CGameInfo.h"
#include "../CPlayerInterface.h" #include "../CPlayerInterface.h"
#include "../PlayerLocalState.h" #include "../PlayerLocalState.h"
#include "../adventureMap/CAdventureMapInterface.h"
#include "../../lib/CPathfinder.h" #include "../../lib/CPathfinder.h"
#include "../../lib/Point.h" #include "../../lib/Point.h"