I located the neutral tile pillage bug in gaiacontroller.cpp or at least I can fix it there:
The problem is the GetGaiaController() function. If it is used on a player with index -1 the game crashs. I guess is that there is no player with index -1 and therefore this function tries to access an object that doesn't exist.
In player.cpp I tried this:
But without any success maybe the game crashs when the function is called and not when its code is executed. So what do you think about it? I will add it to the altered source files thread once I got your comments or some time passed.
-Martin
Code:
STDEHANDLER(GaiaController_CutImprovements)
{
sint32 owner;
sint32 type;
MapPoint pos;
if(!args->GetPos(0, pos))
return GEV_HD_Continue;
TerrainImprovement ti;
Cell *cell = g_theWorld->GetCell(pos);
owner = cell->GetOwner();
//Added by Martin Gühmann to make shure that
//g_player[-1] does not happen.
//Not a problem for the array but for the
//GetGaiaController()
if (owner < 0)
return GEV_HD_Continue;
Player *owner_player = g_player[owner];
if (owner_player == NULL ||
owner_player->GetGaiaController() == NULL)
return GEV_HD_Continue;
sint32 num = cell->GetNumDBImprovements();
for (sint16 i = 0; i < num; i++)
{
type = cell->GetDBImprovement(i);
if (GaiaController::sm_endgameImprovements & ((uint64)0x1 << (uint64)type))
{
owner_player->GetGaiaController()->
HandleTerrImprovementChange(type,pos, -1);
}
}
return GEV_HD_Continue;
}
In player.cpp I tried this:
Code:
GaiaController *Player::GetGaiaController()
{
if(this->m_owner < 0) return NULL; //Added
return m_gaiaController;
}
-Martin
Comment