Inightshade
Chieftain
Alright, so I'm finally stuck, unable to figure out where I've gone wrong.
And I think I need a fresh pair of eyes (or some random wisdom).
I have here a piece of code:
That totally works. Except it doesn't.
So here is the gist, the hp increases correctly in game (and works as expected) but I crash (consistently) between turns 20 and 40.
"Disabling" this (by uncommenting that first return) allows me to play until turn 150ish (where I crash due to not having spy names for a few people )
But, but why? It always crashes on the barbs turn (so during post processing I think).
It doesn't run for barbs and minors (that is prevented here:
)
-shrugs-
So some extra info, in code Civ calls for the global max hp, not the units max hp (which actually calls for the global, rather than being dynamic :/ ) so I went through and changed 99% of those. The few I left were AI calculations (half hp) and since I don't really think I'll end up with more than 120 I didn't bother.
However, given that this works (including performing combat! where 99% of the maxhp calls are) I have less than no clue why it's breaking stuff, but only in a delayed fashion. :/
Anyways, I have DnD today, so I won't get back to this until later. Thanks for any insight, wisdom, or logic questions. (Given that the last might help me break out of the stupor that is staring at one peice of code for hours on end).
And I think I need a fresh pair of eyes (or some random wisdom).
I have here a piece of code:
Code:
int CvPlayer::getBonusUnitHpFromBuildings() const
{
int iTotalBonusHpFromBuildings = 0;
const CvCity* pLoopCity;
int iLoop;
// DEBUG
//return iTotalBonusHpFromBuildings;
for (int jFCM = 0; jFCM < GC.getNumBuildingClassInfos(); jFCM++)
{
BuildingClassTypes eBuildingClass = (BuildingClassTypes)jFCM;
CvBuildingClassInfo* pkBuildingClassInfo = GC.getBuildingClassInfo(eBuildingClass);
if (!pkBuildingClassInfo)
{
continue;
}
CvCivilizationInfo& playerCivilizationInfo = getCivilizationInfo();
BuildingTypes eBuilding = (BuildingTypes)playerCivilizationInfo.getCivilizationBuildings(eBuildingClass);
CvBuildingEntry* pBuildingInfo = GC.getBuildingInfo(eBuilding);
if (!pBuildingInfo || !pBuildingInfo->GetHpPer() > 0)
{
continue;
}
for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
{
if (pLoopCity->GetCityBuildings()->GetNumBuilding(eBuilding) > 0)
{
iTotalBonusHpFromBuildings += pBuildingInfo->GetHpPer() * pLoopCity->GetCityBuildings()->GetNumBuilding(eBuilding);
}
}
}
return iTotalBonusHpFromBuildings;
}
That totally works. Except it doesn't.
So here is the gist, the hp increases correctly in game (and works as expected) but I crash (consistently) between turns 20 and 40.
"Disabling" this (by uncommenting that first return) allows me to play until turn 150ish (where I crash due to not having spy names for a few people )
But, but why? It always crashes on the barbs turn (so during post processing I think).
It doesn't run for barbs and minors (that is prevented here:
Code:
int CvPlayer::getBonusUnitHp() const
{
// TODO: add Global value.
int iTotalBonusHp = m_iBonusUnitHp;
// Check buildings (Must have found a city for this to work!)
// We don't care about Barbs or Minors for this. As this is special buildings only.
if (!GetNumCitiesFounded() > 0 || isBarbarian() || isMinorCiv())
iTotalBonusHp += getBonusUnitHpFromBuildings();
//TODO: Add trait?
//TODO: add promotions?
//TODO: Add lua?
return iTotalBonusHp;
}
-shrugs-
So some extra info, in code Civ calls for the global max hp, not the units max hp (which actually calls for the global, rather than being dynamic :/ ) so I went through and changed 99% of those. The few I left were AI calculations (half hp) and since I don't really think I'll end up with more than 120 I didn't bother.
However, given that this works (including performing combat! where 99% of the maxhp calls are) I have less than no clue why it's breaking stuff, but only in a delayed fashion. :/
Anyways, I have DnD today, so I won't get back to this until later. Thanks for any insight, wisdom, or logic questions. (Given that the last might help me break out of the stupor that is staring at one peice of code for hours on end).