From 5358406ff99cb8c04a429ebcf9432905cb947ec0 Mon Sep 17 00:00:00 2001 From: anthony Date: Mon, 10 Feb 2003 05:18:35 +0000 Subject: [PATCH] Fixed a crashing bug in the recent tactician patch --- army.cpp | 12 ++++++------ faction.cpp | 4 ++++ faction.h | 1 + object.cpp | 7 ++++--- parseorders.cpp | 14 ++++++++++++++ unit.cpp | 8 ++++++-- unit.h | 2 +- 7 files changed, 36 insertions(+), 12 deletions(-) diff --git a/army.cpp b/army.cpp index 58abdbf0..07ad0e2a 100644 --- a/army.cpp +++ b/army.cpp @@ -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; @@ -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; diff --git a/faction.cpp b/faction.cpp index 20fdccc6..19ef48c3 100644 --- a/faction.cpp +++ b/faction.cpp @@ -126,6 +126,7 @@ Faction::Faction() address = 0; password = 0; times = 0; + allyequals = 0; temformat = TEMPLATE_OFF; quit = 0; defaultattitude = A_NEUTRAL; @@ -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; @@ -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); @@ -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); diff --git a/faction.h b/faction.h index c4639b21..fc68183c 100644 --- a/faction.h +++ b/faction.h @@ -177,6 +177,7 @@ class Faction : public AListElem AString * address; AString * password; int times; + int allyequals; int temformat; char exists; int quit; diff --git a/object.cpp b/object.cpp index 5b0a5fca..978c479c 100644 --- a/object.cpp +++ b/object.cpp @@ -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 & @@ -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); } } } diff --git a/parseorders.cpp b/parseorders.cpp index 3b73ec65..e6023403 100644 --- a/parseorders.cpp +++ b/parseorders.cpp @@ -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; diff --git a/unit.cpp b/unit.cpp index 7b30a348..68257fe6 100644 --- a/unit.cpp +++ b/unit.cpp @@ -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) { @@ -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"; diff --git a/unit.h b/unit.h index ef2f98d3..6ce49d63 100644 --- a/unit.h +++ b/unit.h @@ -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();