Skip to content

Commit 60542a4

Browse files
committed
Rename Soldier::building to Soldier::homeBld
1 parent 4f8e2b6 commit 60542a4

9 files changed

Lines changed: 67 additions & 70 deletions

libs/s25main/figures/nofActiveSoldier.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ void nofActiveSoldier::GoalReached()
4343
{
4444
// We reached the military building
4545
// Add myself to the building
46-
if(!building)
46+
if(!homeBld)
4747
{
4848
RTTR_Assert(false);
49-
building = world->GetSpecObj<nobMilitary>(this->GetPos());
50-
if(building)
49+
homeBld = world->GetSpecObj<nobMilitary>(this->GetPos());
50+
if(homeBld)
5151
LOG.write("nofActiveSoldier::GoalRoached() - no valid 'building' but found one at soldier's position "
5252
"(%i,%i) (gf: %u)\n")
5353
% pos.x % pos.y % GetEvMgr().GetCurrentGF();
@@ -59,7 +59,7 @@ void nofActiveSoldier::GoalReached()
5959
throw std::runtime_error("No building found for soldier");
6060
}
6161
}
62-
building->AddActiveSoldier(world->RemoveFigure(pos, *this));
62+
homeBld->AddActiveSoldier(world->RemoveFigure(pos, *this));
6363
}
6464

6565
void nofActiveSoldier::ReturnHome()
@@ -71,7 +71,7 @@ void nofActiveSoldier::ReturnHome()
7171
void nofActiveSoldier::WalkingHome()
7272
{
7373
// Is our home military building destroyed?
74-
if(!building)
74+
if(!homeBld)
7575
{
7676
// Start wandering around
7777
state = SoldierState::FigureWork;
@@ -83,13 +83,13 @@ void nofActiveSoldier::WalkingHome()
8383

8484
// Walking home to our military building
8585

86-
if(GetPos() == building->GetFlagPos()) // Are we already at the flag?
86+
if(GetPos() == homeBld->GetFlagPos()) // Are we already at the flag?
8787
StartWalking(Direction::NorthWest); // Enter via the door
88-
else if(GetPos() == building->GetPos()) // or are we at the building
89-
building->AddActiveSoldier(world->RemoveFigure(pos, *this));
88+
else if(GetPos() == homeBld->GetPos()) // or are we at the building
89+
homeBld->AddActiveSoldier(world->RemoveFigure(pos, *this));
9090
else
9191
{
92-
const auto dir = world->FindHumanPath(pos, building->GetFlagPos(), 100);
92+
const auto dir = world->FindHumanPath(pos, homeBld->GetFlagPos(), 100);
9393

9494
if(dir)
9595
{

libs/s25main/figures/nofActiveSoldier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class nofActiveSoldier : public nofSoldier
133133
SoldierState GetState() const { return state; }
134134
/// Set the home (building) to nullptr
135135
/// e.g. after the soldier was removed from the homes list but it was not destroyed
136-
void ResetHome() { building = nullptr; }
136+
void ResetHome() { homeBld = nullptr; }
137137
void FightVsDefenderStarted() { state = SoldierState::AttackingFightingVsDefender; }
138138

139139
// For debugging

libs/s25main/figures/nofAggressiveDefender.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ void nofAggressiveDefender::Walked()
7272

7373
void nofAggressiveDefender::HomeDestroyed()
7474
{
75-
building = nullptr;
75+
homeBld = nullptr;
7676
}
7777

7878
void nofAggressiveDefender::HomeDestroyedAtBegin()
7979
{
80-
building = nullptr;
80+
homeBld = nullptr;
8181

8282
// angegriffenem Gebäude Bescheid sagen, dass wir doch nicht mehr kommen
8383
InformTargetsAboutCancelling();
@@ -105,7 +105,7 @@ void nofAggressiveDefender::WonFighting()
105105
IncreaseRank();
106106

107107
// Ist evtl. unser Heimatgebäude zerstört?
108-
if(!building)
108+
if(!homeBld)
109109
{
110110
// Ziel Bescheid sagen
111111
InformTargetsAboutCancelling();
@@ -177,7 +177,7 @@ void nofAggressiveDefender::MissAggressiveDefendingContinueWalking()
177177

178178
void nofAggressiveDefender::MissAggressiveDefendingWalk()
179179
{
180-
if(!building)
180+
if(!homeBld)
181181
{
182182
// Home destroyed so abort and wander around
183183
InformTargetsAboutCancelling();

libs/s25main/figures/nofAttacker.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,15 @@ void nofAttacker::Walked()
202202
{
203203
RTTR_Assert(dynamic_cast<nobMilitary*>(attacked_goal));
204204
// We will now have this building as the new home, so inform old home, hunting soldier and ship
205-
if(building)
206-
building->SoldierLost(this);
205+
if(homeBld)
206+
homeBld->SoldierLost(this);
207207
CancelAtHuntingDefender();
208208
if(ship_obj_id)
209209
CancelAtShip();
210210
// Store the goal in a temporary as attacked_goal will be reset
211211
auto* goal = static_cast<nobMilitary*>(attacked_goal);
212212
goal->Capture(player);
213-
building = attacked_goal;
213+
homeBld = attacked_goal;
214214
attacked_goal->AddActiveSoldier(world->RemoveFigure(pos, *this));
215215
RemoveFromAttackedGoal();
216216
// This might call other capturers
@@ -292,7 +292,7 @@ void nofAttacker::HomeDestroyed()
292292
if(ship_obj_id)
293293
CancelAtShip();
294294

295-
building = nullptr;
295+
homeBld = nullptr;
296296
state = SoldierState::FigureWork;
297297
StartWandering();
298298
Wander();
@@ -302,15 +302,15 @@ void nofAttacker::HomeDestroyed()
302302
} else
303303
{
304304
// If we were going back home, reset that goal
305-
if(goal_ == building)
305+
if(goal_ == homeBld)
306306
goal_ = nullptr;
307-
building = nullptr;
307+
homeBld = nullptr;
308308
}
309309
}
310310

311311
void nofAttacker::HomeDestroyedAtBegin()
312312
{
313-
building = nullptr;
313+
homeBld = nullptr;
314314

315315
// We are lost now and hence not targetable
316316
InformTargetsAboutCancelling();
@@ -327,7 +327,7 @@ void nofAttacker::WonFighting()
327327
IncreaseRank();
328328
// If our home was destroyed then we are lost
329329
// unless we are currently fighting at the flag so that building can become our new home
330-
if(!building && state != SoldierState::AttackingFightingVsDefender)
330+
if(!homeBld && state != SoldierState::AttackingFightingVsDefender)
331331
{
332332
// Lost -> Tell all dependents
333333
InformTargetsAboutCancelling();
@@ -397,7 +397,7 @@ void nofAttacker::ReturnHomeMissionAttacking()
397397
void nofAttacker::MissAttackingWalk()
398398
{
399399
// If our home is destroyed we are lost
400-
if(!building)
400+
if(!homeBld)
401401
{
402402
InformTargetsAboutCancelling();
403403
if(ship_obj_id)
@@ -581,7 +581,7 @@ void nofAttacker::AttackedGoalDestroyed()
581581
auto* harbor = world->GetSpecObj<nobHarborBuilding>(harborPos);
582582
RTTR_Assert(harbor);
583583
// go home
584-
goal_ = building;
584+
goal_ = homeBld;
585585
state = SoldierState::FigureWork;
586586
fs = FigureState::GotToGoal;
587587
harbor->CancelSeaAttacker(this);
@@ -655,12 +655,12 @@ void nofAttacker::CapturingWalking()
655655
if(pos == attacked_goal->GetPos())
656656
{
657657
// We switch buildings
658-
if(building)
659-
building->SoldierLost(this);
658+
if(homeBld)
659+
homeBld->SoldierLost(this);
660660
CancelAtHuntingDefender();
661661
if(ship_obj_id)
662662
CancelAtShip();
663-
building = attacked_goal;
663+
homeBld = attacked_goal;
664664
attacked_goal->AddActiveSoldier(world->RemoveFigure(pos, *this));
665665

666666
// No longer attacking
@@ -687,7 +687,7 @@ void nofAttacker::CapturingWalking()
687687
StartWalking(Direction::NorthWest);
688688
RTTR_Assert(attacked_goal->GetPlayer() == player); // Assumed by the call below
689689
static_cast<nobMilitary*>(attacked_goal)->NeedOccupyingTroops();
690-
} else if(!building)
690+
} else if(!homeBld)
691691
{
692692
// If our home is destroyed we are lost and don't walk to the target (our new home if we were at least at the
693693
// flag already) Notify it, if it still exists (could be destroyed in the meantime too)
@@ -845,7 +845,7 @@ void nofAttacker::StartReturnViaShip(noShip& ship)
845845
InformTargetsAboutCancelling();
846846
}
847847

848-
goal_ = building;
848+
goal_ = homeBld;
849849
state = SoldierState::FigureWork;
850850
fs = FigureState::GotToGoal;
851851
on_ship = true;
@@ -883,7 +883,7 @@ void nofAttacker::CancelAtHuntingDefender()
883883

884884
void nofAttacker::HandleState_SeaAttack_ReturnToShip()
885885
{
886-
if(!building)
886+
if(!homeBld)
887887
{
888888
// Home destroyed -> start wandering
889889
state = SoldierState::FigureWork;
@@ -921,7 +921,7 @@ void nofAttacker::HandleState_SeaAttack_ReturnToShip()
921921
Wander();
922922

923923
// Notify home and ship
924-
building->SoldierLost(this);
924+
homeBld->SoldierLost(this);
925925
CancelAtShip();
926926
}
927927
}

libs/s25main/figures/nofDefender.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void nofDefender::Walked()
5151
attacker->FightVsDefenderStarted();
5252
break;
5353
case SoldierState::DefendingWalkingFrom:
54-
if(!building)
54+
if(!homeBld)
5555
{
5656
// Home destroyed -> Start wandering around
5757
attacker = nullptr;
@@ -68,7 +68,7 @@ void nofDefender::Walked()
6868
StartWalking(Direction::SouthEast);
6969
} else
7070
{
71-
nobBaseMilitary* bld = building;
71+
nobBaseMilitary* bld = homeBld;
7272
RTTR_Assert(bld->GetDefender() == this); // I should be the defender
7373
bld->AddActiveSoldier(world->RemoveFigure(pos, *this));
7474
RTTR_Assert(!bld->GetDefender()); // No defender anymore
@@ -81,7 +81,7 @@ void nofDefender::Walked()
8181

8282
void nofDefender::HomeDestroyed()
8383
{
84-
building = nullptr;
84+
homeBld = nullptr;
8585

8686
switch(state)
8787
{
@@ -106,7 +106,7 @@ void nofDefender::HomeDestroyed()
106106

107107
void nofDefender::HomeDestroyedAtBegin()
108108
{
109-
building = nullptr;
109+
homeBld = nullptr;
110110

111111
state = SoldierState::FigureWork;
112112

@@ -122,7 +122,7 @@ void nofDefender::WonFighting()
122122
// Attacker is dead
123123
attacker = nullptr;
124124

125-
if(!building)
125+
if(!homeBld)
126126
{
127127
// Home destroyed so abort and wander around
128128
state = SoldierState::FigureWork;
@@ -132,7 +132,7 @@ void nofDefender::WonFighting()
132132
return;
133133
}
134134

135-
attacker = building->FindAttackerNearBuilding();
135+
attacker = homeBld->FindAttackerNearBuilding();
136136
if(attacker)
137137
{
138138
// New attacker found so wait for him
@@ -150,23 +150,23 @@ void nofDefender::LostFighting()
150150
attacker = nullptr;
151151

152152
// Notify building if it still exists
153-
if(building)
153+
if(homeBld)
154154
{
155-
building->ResetDefender();
155+
homeBld->ResetDefender();
156156
// A military building potentially needs to get new soldiers if this wasn't the last one
157-
if(BuildingProperties::IsMilitary(building->GetBuildingType()))
157+
if(BuildingProperties::IsMilitary(homeBld->GetBuildingType()))
158158
{
159-
RTTR_Assert(dynamic_cast<nobBaseMilitary*>(building));
160-
if(static_cast<nobMilitary*>(building)->GetNumTroops())
161-
static_cast<nobMilitary*>(building)->RegulateTroops();
159+
RTTR_Assert(dynamic_cast<nobBaseMilitary*>(homeBld));
160+
if(static_cast<nobMilitary*>(homeBld)->GetNumTroops())
161+
static_cast<nobMilitary*>(homeBld)->RegulateTroops();
162162
}
163-
building = nullptr;
163+
homeBld = nullptr;
164164
}
165165
}
166166

167167
void nofDefender::AttackerArrested()
168168
{
169-
attacker = building->FindAttackerNearBuilding();
169+
attacker = homeBld->FindAttackerNearBuilding();
170170
if(!attacker)
171171
{
172172
// Go back into the building

libs/s25main/figures/nofPassiveSoldier.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,24 @@ void nofPassiveSoldier::Heal()
9797

9898
void nofPassiveSoldier::GoalReached()
9999
{
100-
static_cast<nobMilitary*>(building)->AddPassiveSoldier(world->RemoveFigure(pos, *this));
100+
static_cast<nobMilitary*>(homeBld)->AddPassiveSoldier(world->RemoveFigure(pos, *this));
101101
}
102102

103103
void nofPassiveSoldier::LeaveBuilding()
104104
{
105105
// Nach Hause in ein Lagerhaus gehen
106106
rs_dir = true;
107107
rs_pos = 1;
108-
cur_rs = building->GetRoute(Direction::SouthEast);
108+
cur_rs = homeBld->GetRoute(Direction::SouthEast);
109109
GoHome();
110110

111-
building = nullptr;
111+
homeBld = nullptr;
112112
}
113113

114114
void nofPassiveSoldier::Upgrade()
115115
{
116116
// We must not be in the buildings list while upgrading. This would destroy the ordered list
117-
RTTR_Assert(!building || !static_cast<nobMilitary*>(building)->IsInTroops(*this));
117+
RTTR_Assert(!homeBld || !static_cast<nobMilitary*>(homeBld)->IsInTroops(*this));
118118
// Einen Rang höher
119119
job_ = Job(unsigned(job_) + 1);
120120

@@ -139,11 +139,11 @@ void nofPassiveSoldier::Walked()
139139

140140
void nofPassiveSoldier::NotNeeded()
141141
{
142-
building = nullptr;
142+
homeBld = nullptr;
143143
GoHome();
144144
}
145145

146146
nobMilitary* nofPassiveSoldier::getHome() const
147147
{
148-
return checkedCast<nobMilitary*>(building);
148+
return checkedCast<nobMilitary*>(homeBld);
149149
}

libs/s25main/figures/nofPassiveSoldier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ class nofPassiveSoldier : public nofSoldier
5353
/// Soldat befindet sich auf dem Hinweg zum Militärgebäude und wird nich länger gebraucht
5454
void NotNeeded();
5555
/// Tells the soldier it is not in its home building anymore (e.g. died, or converted to attacker)
56-
void LeftBuilding() { building = nullptr; }
56+
void LeftBuilding() { homeBld = nullptr; }
5757
nobMilitary* getHome() const;
5858
};

0 commit comments

Comments
 (0)