Skip to content

Commit

Permalink
Apply review remark: don't const_cast inside GamePlayer::GetHQ
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaau committed Aug 5, 2024
1 parent 2b45ff6 commit 0353ac7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions libs/s25main/GamePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ bool GamePlayer::IsHQTent() const

void GamePlayer::SetHQIsTent(bool isTent)
{
if(nobHQ* hq = GetHQ())
if(nobHQ* hq = const_cast<nobHQ*>(GetHQ()))
hq->SetIsTent(isTent);
}

Expand Down Expand Up @@ -1379,10 +1379,10 @@ void GamePlayer::TestDefeat()
Surrender();
}

nobHQ* GamePlayer::GetHQ() const
const nobHQ* GamePlayer::GetHQ() const
{
const MapPoint& hqPos = GetHQPos();
return const_cast<nobHQ*>(hqPos.isValid() ? GetGameWorld().GetSpecObj<nobHQ>(hqPos) : nullptr);
return hqPos.isValid() ? GetGameWorld().GetSpecObj<nobHQ>(hqPos) : nullptr;
}

void GamePlayer::Surrender()
Expand Down
2 changes: 1 addition & 1 deletion libs/s25main/GamePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ class GamePlayer : public GamePlayerInfo
bool FindWarehouseForJob(Job job, noRoadNode* goal) const;
/// Prüft, ob der Spieler besiegt wurde
void TestDefeat();
nobHQ* GetHQ() const;
const nobHQ* GetHQ() const;

//////////////////////////////////////////////////////////////////////////
/// Unsynchronized state (e.g. lua, gui...)
Expand Down

0 comments on commit 0353ac7

Please sign in to comment.