 |
|  |
 |
|
Mr Ogre
|
|
Azeroth
Jan 1970 time: 05:31
|
|
quote: Originally posted by Admiral PJ
while(y < 0) {
y += g_mp_size.y;
x = (x + g_mp_size.x - (((g_mp_size.y / 2) % g_mp_size.x) - 1)) % g_mp_size.x;
}
|
AAHHHHHHHHH THE HORROR!!!!!!!!!!!!!!!!!
It's for doing vertical wrap around. The math is very, very tricky for any map whose vertical size is not a multiple of it's horizontal size.
If you don't have vertical wrap turned on, you should ever hit that loop. It's only a loop, I think, in case something wraps a really long way. Normally it would only go through that once.
|
|
|  |
 |
|
MrBaggins
|
|
The Veteran bug
SYMPTOM: Veteran status does not effect combat in any shape, form or way.
CAUSE: [CTP2Combat.cpp] The CombatUnit class does not include a veteran status variable, the CombatField::FillFrom function doesn't modify attack/defence strength & the CTP2Combat::ExecuteAttack doesn't attempt to look up veteran status or anything similar digging through the unit class.
SOLUTION:
Add veteran variable & populate in CombatUnit constructor. I.E. unit->IsVeteran()
Alter attack/def strength in CTP2Combat::ExecuteAttack
I.E. * g_theConstDB->GetVetCoef()
|
|
|  |
 |
|
MrBaggins
|
|
The "not working" is a bit of a bummer. Also the fact that we are stuck with 1.0 kinda sucks. We have to reinvent the wheel a bit... but fwiw adding new SLIC functionality isn't rocket science.
|
|
|  |
 |
|
MrBaggins
|
|
Hmmm... time to dig up the patch readme to check what we need to fix again ourselves.
|
|
|  |
 |
|
Maquiladora
|
|
You can find all the seperate altered files in the XPatch zip file in the directory, if you need to know all the specific files that were added/changed.
|
|
|  |
 |
|
J Bytheway
|
 |
England
Jul 2001 time: 05:31
|
|
The rush buy bug
This particularly infamous bug seems to arise from the following dirty hack in ui\interface\NationalManagementDialog.cpp, around line 1255:
code: g_gevManager->AddEvent(GEV_INSERT_Tail, GEV_BuyFront, GEA_City, city, GEA_End);
Which simply tells the city to rush buy no matter the circumstances, and so it is unsurprising that problems arose. I have replaced it with the following:
code: // JJB removed the following:
// g_gevManager->AddEvent(GEV_INSERT_Tail, GEV_BuyFront, GEA_City, city, GEA_End);
// and replaced it with the following:
if (!city.GetCityData()->AlreadyBoughtFront()) {
city.GetCityData()->AddBuyFront();
}
// in the hope of fixing the rush buy bug.
Which calls the routines in the city to do it, which seems like what should have been done anyway.
Because of this on line 479 an additional condition needs to be added:
code: // JJB added this inner if so that things add up properly
if (!city.GetCityData()->AlreadyBoughtFront()) {
rushBuyTotal += city.GetCityData()->GetOvertimeCost();
}
so that the total cost displayed for rush buying is correct.
Brief tests suggest that this all works correctly.
|
|
|  |
 |
|
Solver
|
|
Apolyton Duke Of Something
|
 |
Latvia, Riga
Sep 2000 time: 07:31
|
|
I wonder if anyone who gets the compiled game to actually run can test this code, which is supposed to fix the veteran bug.
CombatUnit class declaration changed to be:
code:
class CombatUnit {
private:
double m_offense, m_defense,
m_strength, m_armor,
m_ranged, m_hp;
bool m_veteran;
UNIT_TYPE m_type;
sint32 m_preferredCol;
sint32 m_priority;
bool m_valid;
public:
bool m_alreadyExploded;
bool m_alreadyAttacked;
#ifdef TEST_APP
uint32 m_id;
#else
Unit m_unit;
#endif
CombatUnit() { m_valid = false; }
#ifdef TEST_APP
CombatUnit::CombatUnit(double offense, double defense,
double strength, double armor,
double ranged, double hp, bool veteran,
UNIT_TYPE type); //bool veteran added
#else
CombatUnit::CombatUnit(double offense, double defense,
double strength, double armor,
double ranged, double hp, bool veteran,
Unit &u); //bool veteran added by solver
#endif
double GetOffense() { return m_offense; }
double GetDefense() { return m_defense; }
double GetStrength() { return m_strength; }
double GetArmor() { return m_armor; }
double GetRangedAttack() { return m_ranged; }
UNIT_TYPE GetCombatType() { return m_type; }
sint32 GetPreferredCol() { return m_preferredCol; }
void SetPreferredCol(sint32 col) { m_preferredCol = col; }
sint32 GetPriority() { return m_priority; }
void SetPriority(sint32 pri) { m_priority = pri; }
//following two added by Solver
void SetAttack (double att) { m_offense = att; }
void SetDefense (double def) { m_defense = def; }
double GetHP() { return m_hp; }
bool IsVeteran(){ return m_veteran; }
void DeductHP(double amt)
#ifndef TEST_APP
;
#else
{
m_hp -= amt;
if(m_hp < 0.001) {
m_hp = 0;
}
}
#endif
bool IsValid() { return m_valid; }
bool IsAlive() { return m_hp > 0.001; }
bool IsActive() { return IsValid() && IsAlive(); }
void AddKill();
void Invalidate() { m_valid = false; }
};
Round line 867 in CtP2Combat.cpp, changed code to:
code: CombatUnit newUnit(rec->GetAttack(), rec->GetDefense(), rec->GetFirepower(),
rec->GetArmor(), rec->GetZBRangeAttack(), u->GetHP(),
u->IsVeteran(), u);
Function CtP2Combat::ExecuteAttack now contains this code in beggining:
code:
void CTP2Combat::ExecuteAttack(CombatField *attacker, sint32 attX, sint32 attY,
CombatField *defender, sint32 defX, sint32 defY)
{
m_noAttacksPossible = false;
CombatUnit *att = &attacker->GetUnit(attX, attY);
CombatUnit *def = &defender->GetUnit(defX, defY);
//Solver added the following to add veteran check
if (att->IsVeteran()) {
double vetattack; double vetdefense;
vetattack=att->GetOffense() + att->GetOffense() * g_theConstDB->GetVetCoef();
att->SetAttack(vetattack);
vetdefense=att->GetDefense() + att->GetDefense() * g_theConstDB->GetVetCoef();
att->SetDefense(vetdefense);
}
Finally, to CtP2Combat.cpp I added
code:
#include "ConstDB.h" //the const db for veteran
extern ConstDB *g_theConstDB; //to get vetstatus
in the beggining.
I hope this fixes the bug, if I understood the way code works from my quick look at it.
|
|
|  |
 |
|  |
All times are GMT. The time now is 05:31. Apolyton Time is 00:31. |
top of page
|
|
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|