Skip to content

Commit

Permalink
Fixed a crashing bug in the recent tactician patch
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony committed Feb 10, 2003
1 parent 5a85742 commit 5358406
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 12 deletions.
12 changes: 6 additions & 6 deletions army.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ void Soldier::Dead()
Army::Army(Unit * ldr,AList * locs,int regtype,int ass)
{
int tacspell = 0;
Unit * tactitian = ldr;
Unit * tactician = ldr;

leader = ldr;
round = 0;
Expand All @@ -484,19 +484,19 @@ Army::Army(Unit * ldr,AList * locs,int regtype,int ass)
int temp = u->GetAttribute("tactics");
if (temp > tac) {
tac = temp;
tactitian = u;
tactician = u;
}
}
}
// If TACTICS_NEEDS_WAR is enabled, we don't want to push leaders
// from tact-4 to tact-5!
if (Globals->TACTICS_NEEDS_WAR) {
int currskill = tactitian->skills.GetDays(S_TACTICS)/tactitian->GetMen();
if (Globals->TACTICS_NEEDS_WAR && (tactician->skills.Num() != 0)) {
int currskill = tactician->skills.GetDays(S_TACTICS)/tactician->GetMen();
if (currskill < 450 - Globals->SKILL_PRACTICE_AMOUNT) {
tactitian->PracticeAttribute("tactics");
tactician->PracticeAttribute("tactics");
}
} else { // Only Globals->TACTICS_NEEDS_WAR == 0
tactitian->PracticeAttribute("tactics");
tactician->PracticeAttribute("tactics");
}
soldiers = new SoldierPtr[count];
int x = 0;
Expand Down
4 changes: 4 additions & 0 deletions faction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ Faction::Faction()
address = 0;
password = 0;
times = 0;
allyequals = 0;
temformat = TEMPLATE_OFF;
quit = 0;
defaultattitude = A_NEUTRAL;
Expand All @@ -148,6 +149,7 @@ Faction::Faction(int n)
address = new AString("NoAddress");
password = new AString("none");
times = 1;
allyequals = 0;
temformat = TEMPLATE_LONG;
defaultattitude = A_NEUTRAL;
quit = 0;
Expand Down Expand Up @@ -180,6 +182,7 @@ void Faction::Writeout(Aoutfile *f)
f->PutStr(*address);
f->PutStr(*password);
f->PutInt(times);
f->PutInt(allyequals);
f->PutInt(temformat);

skills.Writeout(f);
Expand All @@ -205,6 +208,7 @@ void Faction::Readin(Ainfile *f, ATL_VER v)
address = f->GetStr();
password = f->GetStr();
times = f->GetInt();
allyequals = f->GetInt();
temformat = f->GetInt();

skills.Readin(f);
Expand Down
1 change: 1 addition & 0 deletions faction.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class Faction : public AListElem
AString * address;
AString * password;
int times;
int allyequals;
int temformat;
char exists;
int quit;
Expand Down
7 changes: 4 additions & 3 deletions object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,12 @@ void Object::Report(Areport *f, Faction *fac, int obs, int truesight,

forlist ((&units)) {
Unit *u = (Unit *) elem;
int isally = fac->GetAttitude(u->faction->num);
if (u->faction == fac) {
u->WriteReport(f, -1, 1, 1, 1);
u->WriteReport(f, -1, 1, 1, 1, isally);
} else {
if(present) {
u->WriteReport(f, obs, truesight, detfac, type != O_DUMMY);
u->WriteReport(f, obs, truesight, detfac, type != O_DUMMY, isally);
} else {
if(((type == O_DUMMY) &&
(Globals->TRANSIT_REPORT &
Expand All @@ -327,7 +328,7 @@ void Object::Report(Areport *f, Faction *fac, int obs, int truesight,
(Globals->TRANSIT_REPORT &
GameDefs::REPORT_SHOW_GUARDS))) {
u->WriteReport(f, passobs, passtrue, passdetfac,
type != O_DUMMY);
type != O_DUMMY, isally);
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions parseorders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,20 @@ void Game::ProcessOptionOrder(Unit *u, AString *o, OrdersCheck *pCheck)
return;
}

if (*token == "allyequals") {
delete token;
u->faction->Event("Allies will now have an equals sign in front.");
u->faction->allyequals = 1;
return;
}

if (*token == "noallyequals") {
delete token;
u->faction->Event("Allies will now have a minus sign in front.");
u->faction->allyequals = 0;
return;
}

if (*token == "template") {
delete token;

Expand Down
8 changes: 6 additions & 2 deletions unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ AString Unit::SpoilsReport() {
}

void Unit::WriteReport(Areport *f, int obs, int truesight, int detfac,
int autosee)
int autosee, int isally)
{
int stealth = GetAttribute("stealth");
if (obs==-1) {
Expand Down Expand Up @@ -402,7 +402,11 @@ void Unit::WriteReport(Areport *f, int obs, int truesight, int detfac,
if (obs == 2) {
temp += AString("* ") + *name;
} else {
temp += AString("- ") + *name;
if (faction->allyequals == 1 && isally) {
temp += AString("= ") +*name;
} else {
temp += AString("- ") + *name;
}
}

if (guard == GUARD_GUARD) temp += ", on guard";
Expand Down
2 changes: 1 addition & 1 deletion unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class Unit : public AListElem

AString SpoilsReport(void);
int CanGetSpoil(Item *i);
void WriteReport(Areport *,int,int,int,int);
void WriteReport(Areport *,int,int,int,int, int);
AString GetName(int);
AString MageReport();
AString ReadyItem();
Expand Down

0 comments on commit 5358406

Please sign in to comment.