Skip to content

Commit 0353ac7

Browse files
committed
Apply review remark: don't const_cast inside GamePlayer::GetHQ
1 parent 2b45ff6 commit 0353ac7

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
@@ -386,7 +386,7 @@ bool GamePlayer::IsHQTent() const
386386

387387
void GamePlayer::SetHQIsTent(bool isTent)
388388
{
389-
if(nobHQ* hq = GetHQ())
389+
if(nobHQ* hq = const_cast<nobHQ*>(GetHQ()))
390390
hq->SetIsTent(isTent);
391391
}
392392

@@ -1379,10 +1379,10 @@ void GamePlayer::TestDefeat()
13791379
Surrender();
13801380
}
13811381

1382-
nobHQ* GamePlayer::GetHQ() const
1382+
const nobHQ* GamePlayer::GetHQ() const
13831383
{
13841384
const MapPoint& hqPos = GetHQPos();
1385-
return const_cast<nobHQ*>(hqPos.isValid() ? GetGameWorld().GetSpecObj<nobHQ>(hqPos) : nullptr);
1385+
return hqPos.isValid() ? GetGameWorld().GetSpecObj<nobHQ>(hqPos) : nullptr;
13861386
}
13871387

13881388
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)