Skip to content

Commit

Permalink
Merge pull request #479 from grantramsay/fix/save-const-correctness
Browse files Browse the repository at this point in the history
Fix/save const correctness
  • Loading branch information
wheybags authored Mar 12, 2020
2 parents e69dc55 + 8dfcb8c commit aaeec34
Show file tree
Hide file tree
Showing 43 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion apps/freeablo/farender/animationplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace FARender
mFrameSequence.push_back(loader.load<int32_t>());
}

void AnimationPlayer::save(FASaveGame::GameSaver& saver)
void AnimationPlayer::save(FASaveGame::GameSaver& saver) const
{
Serial::ScopedCategorySaver cat("AnimationPlayer", saver);

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/farender/animationplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace FARender

AnimationPlayer() {}
AnimationPlayer(FASaveGame::GameLoader& loader);
void save(FASaveGame::GameSaver& saver);
void save(FASaveGame::GameSaver& saver) const;

std::pair<FARender::FASpriteGroup*, int32_t> getCurrentFrame();
AnimationType getCurrentAnimationType() { return mPlayingAnimType; }
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ namespace FAWorld
mType = ActorType(loader.load<uint8_t>());
}

void Actor::save(FASaveGame::GameSaver& saver)
void Actor::save(FASaveGame::GameSaver& saver) const
{
Serial::ScopedCategorySaver cat("Actor", saver);

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace FAWorld
Actor(World& world, const DiabloExe::Npc& npc, const DiabloExe::DiabloExe& exe);
Actor(World& world, FASaveGame::GameLoader& loader);
virtual ~Actor();
virtual void save(FASaveGame::GameSaver& saver);
virtual void save(FASaveGame::GameSaver& saver) const;

virtual int32_t getOnKilledExperience() const { return 0; }
void pickupItem(Target::ItemTarget target);
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/actoranimationmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace FAWorld
mInterruptedAnimationFrame = loader.load<int32_t>();
}

void ActorAnimationManager::save(FASaveGame::GameSaver& saver)
void ActorAnimationManager::save(FASaveGame::GameSaver& saver) const
{
Serial::ScopedCategorySaver cat("ActorAnimationManager", saver);

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/actoranimationmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace FAWorld
public:
ActorAnimationManager();
ActorAnimationManager(FASaveGame::GameLoader& loader);
void save(FASaveGame::GameSaver& saver);
void save(FASaveGame::GameSaver& saver) const;

void initAnimMaps();

Expand Down
4 changes: 2 additions & 2 deletions apps/freeablo/faworld/actorstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace FAWorld
mLevelXpCounts.push_back(loader.load<uint32_t>());
}

void ActorStats::save(FASaveGame::GameSaver& saver)
void ActorStats::save(FASaveGame::GameSaver& saver) const
{
Serial::ScopedCategorySaver cat("ActorStats", saver);

Expand Down Expand Up @@ -69,7 +69,7 @@ namespace FAWorld
mMana.setMax(mCalculatedStats.maxMana);
}

void BaseStats::save(FASaveGame::GameSaver& saver)
void BaseStats::save(FASaveGame::GameSaver& saver) const
{
saver.save(strength);
saver.save(magic);
Expand Down
4 changes: 2 additions & 2 deletions apps/freeablo/faworld/actorstats.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace FAWorld
{
struct BaseStats
{
void save(FASaveGame::GameSaver& saver);
void save(FASaveGame::GameSaver& saver) const;
void load(FASaveGame::GameLoader& loader);

int32_t strength = 0;
Expand Down Expand Up @@ -84,7 +84,7 @@ namespace FAWorld
void initialise(const BaseStats& baseStats);

ActorStats(const Actor& actor, FASaveGame::GameLoader& loader);
void save(FASaveGame::GameSaver& saver);
void save(FASaveGame::GameSaver& saver) const;

ActorStats& operator=(const ActorStats& other) = default;

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/behaviour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace FAWorld

BasicMonsterBehaviour::BasicMonsterBehaviour(FASaveGame::GameLoader& loader) { mTicksSinceLastAction = loader.load<Tick>(); }

void BasicMonsterBehaviour::save(FASaveGame::GameSaver& saver)
void BasicMonsterBehaviour::save(FASaveGame::GameSaver& saver) const
{
Serial::ScopedCategorySaver cat("BasicMonsterBehaviour", saver);

Expand Down
6 changes: 3 additions & 3 deletions apps/freeablo/faworld/behaviour.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace FAWorld
Behaviour() = default;

virtual const std::string& getTypeId() = 0;
virtual void save(FASaveGame::GameSaver& saver) = 0;
virtual void save(FASaveGame::GameSaver& saver) const = 0;
virtual void update() = 0;

virtual ~Behaviour() {}
Expand All @@ -41,7 +41,7 @@ namespace FAWorld
NullBehaviour(FAWorld::Actor* actor) : Behaviour(actor) {}
NullBehaviour() = default;

virtual void save(FASaveGame::GameSaver&) override {}
virtual void save(FASaveGame::GameSaver&) const override {}
virtual void update() override {}

virtual ~NullBehaviour() {}
Expand All @@ -56,7 +56,7 @@ namespace FAWorld
BasicMonsterBehaviour(FAWorld::Actor* monster) : Behaviour(monster) {}
BasicMonsterBehaviour(FASaveGame::GameLoader& loader);

virtual void save(FASaveGame::GameSaver& saver) override;
virtual void save(FASaveGame::GameSaver& saver) const override;
virtual void update() override;

virtual ~BasicMonsterBehaviour() {}
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/faction.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace FAWorld

static Faction heaven() { return Faction(FactionType::heaven); }

FactionType getType() { return mFaction; }
FactionType getType() const { return mFaction; }

private:
FactionType mFaction;
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/gamelevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace FAWorld
actorMapRefresh();
}

void GameLevel::save(FASaveGame::GameSaver& saver)
void GameLevel::save(FASaveGame::GameSaver& saver) const
{
Serial::ScopedCategorySaver cat("GameLevel", saver);

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/gamelevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace FAWorld

GameLevel(World& world, FASaveGame::GameLoader& gameLoader);

void save(FASaveGame::GameSaver& gameSaver);
void save(FASaveGame::GameSaver& gameSaver) const;

~GameLevel();

Expand Down
4 changes: 2 additions & 2 deletions apps/freeablo/faworld/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace FAWorld
}
}

void BasicInventory::save(FASaveGame::GameSaver& saver)
void BasicInventory::save(FASaveGame::GameSaver& saver) const
{
saver.save(mInventoryBox.width());
saver.save(mInventoryBox.height());
Expand Down Expand Up @@ -317,7 +317,7 @@ namespace FAWorld
}
}

void CharacterInventory::save(FASaveGame::GameSaver& saver)
void CharacterInventory::save(FASaveGame::GameSaver& saver) const
{
mMainInventory.save(saver);
mBelt.save(saver);
Expand Down
4 changes: 2 additions & 2 deletions apps/freeablo/faworld/inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace FAWorld
public:
BasicInventory(int32_t width, int32_t height, bool treatAllItemsAs1By1 = false);

void save(FASaveGame::GameSaver& saver);
void save(FASaveGame::GameSaver& saver) const;
void load(FASaveGame::GameLoader& loader);

bool canFitItem(const Item& item) const;
Expand Down Expand Up @@ -97,7 +97,7 @@ namespace FAWorld
{
public:
CharacterInventory();
void save(FASaveGame::GameSaver& saver);
void save(FASaveGame::GameSaver& saver) const;
void load(FASaveGame::GameLoader& loader);

bool autoPlaceItem(const Item& item);
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/itemmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace FAWorld
}
}

void ItemMap::save(FASaveGame::GameSaver& saver)
void ItemMap::save(FASaveGame::GameSaver& saver) const
{
uint32_t itemsSize = uint32_t(mItems.size());
saver.save(itemsSize);
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/itemmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace FAWorld
ItemMap(const GameLevel* level);
ItemMap(FASaveGame::GameLoader& loader, const GameLevel* level);

void save(FASaveGame::GameSaver& saver);
void save(FASaveGame::GameSaver& saver) const;

~ItemMap();
bool dropItem(std::unique_ptr<FAWorld::Item>&& item, const Actor& actor, const Tile& tile);
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/missile/missile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace FAWorld::Missile
mGraphics.push_back(std::make_unique<MissileGraphic>(loader));
}

void Missile::save(FASaveGame::GameSaver& saver)
void Missile::save(FASaveGame::GameSaver& saver) const
{
Serial::ScopedCategorySaver cat("Missile", saver);

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/missile/missile.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace FAWorld::Missile
Missile(MissileId missileId, Actor& creator, Misc::Point dest);
Missile(FASaveGame::GameLoader& loader);

virtual void save(FASaveGame::GameSaver& saver);
virtual void save(FASaveGame::GameSaver& saver) const;
virtual void update();
virtual bool isComplete() const { return mComplete; }
MissileId getMissileId() const { return mMissileId; }
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/missile/missilegraphic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace FAWorld::Missile

MissileGraphic::~MissileGraphic() { mLevel->mMissileGraphics.erase(this); }

void MissileGraphic::save(FASaveGame::GameSaver& saver)
void MissileGraphic::save(FASaveGame::GameSaver& saver) const
{
mCurPos.save(saver);
saver.save(mMainGraphicPath);
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/missile/missilegraphic.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace FAWorld::Missile
MissileGraphic(std::string initialGraphicPath, std::string mainGraphicPath, std::optional<int32_t> singleFrame, Position position, GameLevel* level);
MissileGraphic(FASaveGame::GameLoader& loader);

virtual void save(FASaveGame::GameSaver& saver);
virtual void save(FASaveGame::GameSaver& saver) const;
virtual void update();

std::pair<FARender::FASpriteGroup*, int32_t> getCurrentFrame();
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace FAWorld
mInitialised = true;
}

void Monster::save(FASaveGame::GameSaver& saver)
void Monster::save(FASaveGame::GameSaver& saver) const
{
Serial::ScopedCategorySaver cat("Monster", saver);
Actor::save(saver);
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace FAWorld
Monster(World& world, const DiabloExe::Monster& monsterStats);
Monster(World& world, FASaveGame::GameLoader& loader);

void save(FASaveGame::GameSaver& saver) override;
void save(FASaveGame::GameSaver& saver) const override;

virtual void calculateStats(LiveActorStats& stats, const ActorStats& actorStats) const override;
void die() override;
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/movementhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace FAWorld
mSpeedTilesPerSecond.load(loader);
}

void MovementHandler::save(FASaveGame::GameSaver& saver)
void MovementHandler::save(FASaveGame::GameSaver& saver) const
{
Serial::ScopedCategorySaver cat("MovementHandler", saver);

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/movementhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace FAWorld
public:
MovementHandler() = default;
explicit MovementHandler(FASaveGame::GameLoader& loader);
void save(FASaveGame::GameSaver& saver);
void save(FASaveGame::GameSaver& saver) const;

Misc::Point getDestination() const;
void setDestination(Misc::Point dest, bool adjacent = false);
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ namespace FAWorld
mPlayerInitialised = true;
}

void Player::save(FASaveGame::GameSaver& saver)
void Player::save(FASaveGame::GameSaver& saver) const
{
release_assert(mPlayerInitialised);

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace FAWorld
Player(World& world, PlayerClass playerClass, const DiabloExe::CharacterStats& charStats);
void initCommon();
Player(World& world, FASaveGame::GameLoader& loader);
void save(FASaveGame::GameSaver& saver) override;
void save(FASaveGame::GameSaver& saver) const override;

virtual ~Player();
void updateSprites() override;
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/playerbehaviour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace FAWorld
hotkey = (SpellId)loader.load<int32_t>();
}

void PlayerBehaviour::save(FASaveGame::GameSaver& saver)
void PlayerBehaviour::save(FASaveGame::GameSaver& saver) const
{
saver.save((int32_t)mActiveSpell);

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/playerbehaviour.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace FAWorld
PlayerBehaviour(FASaveGame::GameLoader& loader);
PlayerBehaviour() = default;

virtual void save(FASaveGame::GameSaver& saver) override;
virtual void save(FASaveGame::GameSaver& saver) const override;
virtual void reAttach(Actor* actor) override;
virtual void update() override;

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace FAWorld
mFractionalPos = Vec2Fix(loader);
}

void Position::save(FASaveGame::GameSaver& saver)
void Position::save(FASaveGame::GameSaver& saver) const
{
Serial::ScopedCategorySaver cat("Position", saver);

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace FAWorld
explicit Position(Misc::Point point = Misc::Point::zero(), Misc::Direction direction = Misc::Direction(Misc::Direction8::south));

Position(FASaveGame::GameLoader& loader);
void save(FASaveGame::GameSaver& saver);
void save(FASaveGame::GameSaver& saver) const;

FixedPoint update(FixedPoint moveDistance);
Misc::Point current() const; ///< where we are coming from
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace FAWorld
}
}

void Target::save(FASaveGame::GameSaver& saver)
void Target::save(FASaveGame::GameSaver& saver) const
{
saver.save(uint8_t(mType));

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace FAWorld
Target() = default;

void load(FASaveGame::GameLoader& loader);
void save(FASaveGame::GameSaver& saver);
void save(FASaveGame::GameSaver& saver) const;

void clear();

Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace FAWorld
loader.currentlyLoadingWorld = nullptr;
}

void World::save(FASaveGame::GameSaver& saver)
void World::save(FASaveGame::GameSaver& saver) const
{
mRng->save(saver);
mLevelRng->save(saver);
Expand Down
2 changes: 1 addition & 1 deletion apps/freeablo/faworld/world.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace FAWorld
{
public:
World(const DiabloExe::DiabloExe& exe, uint32_t seed);
void save(FASaveGame::GameSaver& saver);
void save(FASaveGame::GameSaver& saver) const;
void load(FASaveGame::GameLoader& loader);
~World();

Expand Down
2 changes: 1 addition & 1 deletion components/level/dun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace Level

Dun::Dun() {}

void Dun::save(Serial::Saver& saver)
void Dun::save(Serial::Saver& saver) const
{
Serial::ScopedCategorySaver cat("Dun", saver);

Expand Down
2 changes: 1 addition & 1 deletion components/level/dun.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Level
Dun();
Dun(int32_t width, int32_t height);

void save(Serial::Saver& saver);
void save(Serial::Saver& saver) const;

static Dun getTown(const Dun& sector1, const Dun& sector2, const Dun& sector3, const Dun& sector4);

Expand Down
2 changes: 1 addition & 1 deletion components/level/level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace Level
mNext = loader.load<int32_t>();
}

void Level::save(Serial::Saver& saver)
void Level::save(Serial::Saver& saver) const
{
Serial::ScopedCategorySaver cat("Level", saver);

Expand Down
Loading

0 comments on commit aaeec34

Please sign in to comment.