I am entirely confused here, and this seems like improper behavior. I'm sure it's an error on my part but this time, I'm completely stumped. Maybe some fresh eyes can help me, because I'm considering this inconsistent behavior unless I'm really dumb and missed something obvious.
So when you "Restart Game" that's the turn 0 function that regenerates the map, to ensure everyone is on the same page when I'm talking here.
I have a variable m_eMaster as part of CvTeam. It is set to NO_TEAM (enum for -1) in CvTeam::uninit():
Which is run by all teams when the game is restarted and re-initialized. So every m_eMaster should be -1, right?
During player creation the following function chain is called:
The bolded line, IsVassal() returns true. A closer look at the function...
Okay, so check the variables:
WTH???? Why is m_eMaster = 0?
The only other places m_eMaster is ever assigned are:
And no... neither of these functions are called.
Am I missing something? Did I forget to reset the variable somewhere?
And the fix....:
Is this my error? A potential issue with Restart Game?
So when you "Restart Game" that's the turn 0 function that regenerates the map, to ensure everyone is on the same page when I'm talking here.
I have a variable m_eMaster as part of CvTeam. It is set to NO_TEAM (enum for -1) in CvTeam::uninit():
Code:
#if defined(MOD_DIPLOMACY_CIV4_FEATURES)
m_bIsVoluntaryVassal = false;
m_iNumTurnsIsVassal = -1;
m_iNumCitiesWhenVassalMade = 0;
m_iTotalPopulationWhenVassalMade = 0;
[B]m_eMaster = NO_TEAM;[/B]
for(int i = 0; i < MAX_MAJOR_CIVS; i++)
{
m_aiNumTurnsSinceVassalTaxSet[i] = -1;
m_aiVassalTax[i] = 0;
}
#endif
Which is run by all teams when the game is restarted and re-initialized. So every m_eMaster should be -1, right?
During player creation the following function chain is called:
Code:
// CvPlayer::DoUpdateHappiness()
#if defined(MOD_DIPLOMACY_CIV4_FEATURES)
if (MOD_DIPLOMACY_CIV4_FEATURES) {
// Increase from Vassals
m_iHappiness += GetHappinessFromVassals();
}
#endif
// CvPlayer::GetHappinessFromVassals()
int iHappiness = 0;
PlayerTypes ePlayer;
for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
{
ePlayer = (PlayerTypes) iPlayerLoop;
iHappiness += GetHappinessFromVassal(ePlayer);
}
return iHappiness;
// CvPlayer::GetHappinessFromVassal()
int iAmount = 0;
[B]if(GET_TEAM(GET_PLAYER(ePlayer).getTeam()).IsVassal(getTeam()))[/B]
{
iAmount += GET_PLAYER(ePlayer).GetExcessHappiness() * GC.getVASSAL_HAPPINESS_PERCENT();
iAmount /= 100;
}
return iAmount;
The bolded line, IsVassal() returns true. A closer look at the function...
Code:
bool CvTeam::IsVassal(TeamTypes eIndex) const
{
return eIndex!=NO_TEAM && [B]eIndex==m_eMaster[/B];
}
Okay, so check the variables:
Code:
eIndex = 0
m_eMaster= 0
WTH???? Why is m_eMaster = 0?
The only other places m_eMaster is ever assigned are:
Code:
CvTeam::Read()
#if defined(MOD_DIPLOMACY_CIV4_FEATURES)
kStream >> m_iVassalageTradingAllowedCount;
[B]kStream >> m_eMaster;[/B]
kStream >> m_bIsVoluntaryVassal;
kStream >> m_iNumTurnsIsVassal;
kStream >> m_iNumCitiesWhenVassalMade;
kStream >> m_iTotalPopulationWhenVassalMade;
ArrayWrapper<int> kNumTurnsSinceVassalEndedWrapper(MAX_TEAMS, &m_aiNumTurnsSinceVassalEnded[0]);
kStream >> kNumTurnsSinceVassalEndedWrapper;
ArrayWrapper<int> kNumTurnsSinceVassalTaxSetWrapper(MAX_MAJOR_CIVS, &m_aiNumTurnsSinceVassalTaxSet[0]);
kStream >> kNumTurnsSinceVassalTaxSetWrapper;
ArrayWrapper<int> kVassalTaxWrapper(MAX_MAJOR_CIVS, &m_aiVassalTax[0]);
kStream >> kVassalTaxWrapper;
#endif
void CvTeam::setVassal(TeamTypes eIndex, bool bNewValue, bool bVoluntary)
{
//can't be our own master
if(eIndex==GetID())
return;
[B]m_eMaster = bNewValue ? (TeamTypes) eIndex : NO_TEAM;[/B]
m_bIsVoluntaryVassal = bNewValue ? bVoluntary : false;
}
And no... neither of these functions are called.
Am I missing something? Did I forget to reset the variable somewhere?
And the fix....:
Code:
// --------------------------------------------------------------------------------
// Are we a vassal of eIndex?
bool CvTeam::IsVassal(TeamTypes eIndex) const
{
[B]if(!isAlive() || !GET_TEAM(eIndex).isAlive())
return false;[/B]
return eIndex!=NO_TEAM && eIndex==m_eMaster;
}
Is this my error? A potential issue with Restart Game?