Skip to content

Commit 47b869f

Browse files
committed
Apply review remark: don't const_cast inside GamePlayer::GetHQ
1 parent dbd105d commit 47b869f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

libs/s25main/GamePlayer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ bool GamePlayer::IsHQTent() const
421421

422422
void GamePlayer::SetHQIsTent(bool isTent)
423423
{
424-
if(nobHQ* hq = GetHQ())
424+
if(nobHQ* hq = const_cast<nobHQ*>(GetHQ()))
425425
hq->SetIsTent(isTent);
426426
}
427427

@@ -1414,10 +1414,10 @@ void GamePlayer::TestDefeat()
14141414
Surrender();
14151415
}
14161416

1417-
nobHQ* GamePlayer::GetHQ() const
1417+
const nobHQ* GamePlayer::GetHQ() const
14181418
{
14191419
const MapPoint& hqPos = GetHQPos();
1420-
return const_cast<nobHQ*>(hqPos.isValid() ? GetGameWorld().GetSpecObj<nobHQ>(hqPos) : nullptr);
1420+
return hqPos.isValid() ? GetGameWorld().GetSpecObj<nobHQ>(hqPos) : nullptr;
14211421
}
14221422

14231423
void GamePlayer::Surrender()

libs/s25main/GamePlayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class GamePlayer : public GamePlayerInfo
430430
bool FindWarehouseForJob(Job job, noRoadNode* goal) const;
431431
/// Prüft, ob der Spieler besiegt wurde
432432
void TestDefeat();
433-
nobHQ* GetHQ() const;
433+
const nobHQ* GetHQ() const;
434434

435435
//////////////////////////////////////////////////////////////////////////
436436
/// Unsynchronized state (e.g. lua, gui...)

0 commit comments

Comments
 (0)