Skip to content

Commit 9563197

Browse files
committed
Remove HasNoHome and HasNoGoal methods
Replaced by `GetHome` & `GetGoal`
1 parent 913f4ff commit 9563197

6 files changed

Lines changed: 12 additions & 16 deletions

File tree

libs/s25main/buildings/nobHarborBuilding.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ void nobHarborBuilding::DestroyBuilding()
128128

129129
soldier.CancelSeaAttack();
130130
RTTR_Assert(!soldier.GetAttackedGoal());
131-
RTTR_Assert(soldier.HasNoHome());
132-
RTTR_Assert(soldier.HasNoGoal());
131+
RTTR_Assert(!soldier.GetHomeBld());
132+
RTTR_Assert(!soldier.GetGoal());
133133
soldier.StartWandering();
134134
soldier.StartWalking(RANDOM_ENUM(Direction));
135135
}
@@ -1032,7 +1032,7 @@ void nobHarborBuilding::ReceiveGoodsFromShip(std::list<std::unique_ptr<noFigure>
10321032
{
10331033
figure->SetGoalTonullptr();
10341034
AddFigure(std::move(figure), true);
1035-
} else if(figure->HasNoGoal())
1035+
} else if(!figure->GetGoal())
10361036
{
10371037
AddDependentFigure(*figure); // No goal? We take it
10381038
AddFigure(std::move(figure), true);
@@ -1212,8 +1212,8 @@ void nobHarborBuilding::AddSeaAttacker(std::unique_ptr<nofAttacker> attacker)
12121212
// notify target about noShow, notify home that soldier wont return, add to inventory
12131213
attacker->SeaAttackFailedBeforeLaunch(); // set state, remove target & home
12141214
RTTR_Assert(!attacker->GetAttackedGoal());
1215-
RTTR_Assert(attacker->HasNoHome());
1216-
RTTR_Assert(attacker->HasNoGoal());
1215+
RTTR_Assert(!attacker->GetHomeBld());
1216+
RTTR_Assert(!attacker->GetGoal());
12171217
AddFigure(std::move(attacker), true);
12181218
return;
12191219
}
@@ -1232,7 +1232,7 @@ void nobHarborBuilding::CancelSeaAttacker(nofAttacker* attacker)
12321232
helpers::find_if(soldiers_for_ships, [attacker](const auto& it) { return it.attacker.get() == attacker; });
12331233

12341234
RTTR_Assert(it != soldiers_for_ships.end());
1235-
if(attacker->HasNoGoal())
1235+
if(!attacker->GetGoal())
12361236
{
12371237
// No goal? We take it
12381238
AddDependentFigure(*attacker);

libs/s25main/figures/noFigure.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ noFigure::noFigure(const Job job, const MapPoint pos, const unsigned char player
6767

6868
void noFigure::Destroy()
6969
{
70-
RTTR_Assert(HasNoGoal());
70+
RTTR_Assert(!goal_);
7171
RTTR_Assert(!cur_rs);
7272
noMovable::Destroy();
7373

@@ -455,7 +455,7 @@ void noFigure::GoHome(noRoadNode* goal)
455455

456456
void noFigure::StartWandering(const unsigned burned_wh_id)
457457
{
458-
RTTR_Assert(HasNoGoal());
458+
RTTR_Assert(!goal_);
459459
fs = FigureState::Wander;
460460
cur_rs = nullptr;
461461
rs_pos = 0;

libs/s25main/figures/noFigure.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ class noFigure : public noMovable
235235
void StartShipJourney();
236236
/// Tells the figure it arrived at a harbor at the given position
237237
void ArrivedByShip(MapPoint harborPos);
238-
/// Gibt zurück, ob die Figur kein Ziel mehr hat und damit nach einer Schifffahrt im
239-
/// Lagerhaus interniert werden muss
240-
bool HasNoGoal() const { return (goal_ == nullptr); }
241238
/// Gibt zurück, ob die Figur auf Straßen läuft zu ihrem Arbeitsplatz o.Ä.
242239
bool IsWalkingOnRoad() const
243240
{

libs/s25main/figures/nofSoldier.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ class nofSoldier : public noFigure
3333

3434
void Destroy() override
3535
{
36-
RTTR_Assert(HasNoHome());
36+
RTTR_Assert(!GetHomeBld());
3737
noFigure::Destroy();
3838
}
3939
void Serialize(SerializedGameData& sgd) const override;
4040

4141
unsigned char GetRank() const;
4242
unsigned char GetHitpoints() const;
43-
bool HasNoHome() const { return homeBld == nullptr; }
4443
const nobBaseMilitary* GetHomeBld() const { return homeBld; }
4544
};
4645

tests/s25Main/integration/testAttacking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ struct AttackFixtureBase : public WorldWithGCExecution<T_numPlayers, T_width, T_
143143
}
144144
// Let him "walk" to goal -> Already reached -> Added and all internal states set correctly
145145
soldier.WalkToGoal();
146-
BOOST_TEST_REQUIRE(soldier.HasNoGoal());
146+
BOOST_TEST_REQUIRE(!soldier.GetGoal());
147147
}
148148
BOOST_TEST_REQUIRE(bld->GetNumTroops() == oldNumSoldiers + numSoldiers);
149149
}
@@ -754,7 +754,7 @@ BOOST_FIXTURE_TEST_CASE(ConquerWithMultipleWalkingIn, AttackFixture4P)
754754

755755
// 1. Attackers from this building
756756
// No home -> Wander
757-
BOOST_TEST_REQUIRE(attackerFromPl0.HasNoHome());
757+
BOOST_TEST_REQUIRE(!attackerFromPl0.GetHomeBld());
758758
rescheduleWalkEvent(em, attackerFromPl0, 1);
759759
RTTR_EXEC_TILL(2, attackerFromPl0.IsWandering());
760760
// 2. Aggressive defenders from this building

tests/s25Main/integration/testSeaAttacking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ struct SeaAttackFixture : public SeaWorldWithGCExecution<3, 62, 64>
180180
world.GetPlayer(bld->GetPlayer()).IncreaseInventoryJob(soldier.GetJobType(), 1);
181181
// Let him "walk" to goal -> Already reached -> Added and all internal states set correctly
182182
soldier.WalkToGoal();
183-
BOOST_TEST_REQUIRE(soldier.HasNoGoal());
183+
BOOST_TEST_REQUIRE(!soldier.GetGoal());
184184
}
185185
BOOST_TEST_REQUIRE(bld->GetNumTroops() == oldNumSoldiers + numSoldiers);
186186
}

0 commit comments

Comments
 (0)