I think i fixed the stack problem I had to make it -1 1 not +1
Code:
for (i = m_nElements - 1; 0 <= i; i--) {
void Player::BeginTurnImprovements()
...some code...
for(i = 0; i < m_terrainImprovements->Num(); i++) {
const TerrainImprovementRecord *rec = g_theTerrainImprovementDB->Get(i);
const TerrainImprovementRecord::Effect *effect = rec->GetTerrainEffect(i);
if (effect->GetColony()) {
m_materialPool->AddMaterials(effect->GetBonusProductionExport());
}
}
void Player::BeginTurnImprovements()
...some code...
for(i = 0; i < m_terrainImprovements->Num(); i++) {
const TerrainImprovementRecord *rec = g_theTerrainImprovementDB->Get(i);
const TerrainImprovementRecord::Effect *effect = rec->GetTerrainEffect(i);
if (effect->GetColony()) {
m_materialPool->AddMaterials(effect->GetBonusProductionExport());
}
}
sint32 TradePool::GetGoldValue(sint32 resource, sint32 n)
{
return ((n * (n+1)) / 2) * g_theResourceDB->Get(resource)->GetGold();
#if 0
sint32 terrain = resource % k_BASE_TERRAIN_TYPES;
sint32 good = resource / k_BASE_TERRAIN_TYPES;
sint32 gold = (n+1) *
g_theTerrainDB->Get(terrain)->GetGood(good)->GetGoodGoldValue();
return gold;
#endif
}
sint32 TradePool::GetGoldValue(sint32 resource, sint32 n)
{
return ((n * (n+1)) / 2) * g_theResourceDB->Get(resource)->GetGold();
#if 0
sint32 terrain = resource % k_BASE_TERRAIN_TYPES;
sint32 good = resource / k_BASE_TERRAIN_TYPES;
sint32 gold = (n+1) *
g_theTerrainDB->Get(terrain)->GetGood(good)->GetGoodGoldValue();
return gold;
#endif
}
CityData::CollectResources
...some code...
// Add if city has building GetEnablesGood >0 then that good will be added to the city for trade
sint32 good;
for(sint32 b = 0; b < g_theBuildingDB->NumRecords(); b++) {
if(m_built_improvements & ((uint64)1 << b)) {
const BuildingRecord *rec = g_theBuildingDB->Get(b, g_player[m_owner]->GetGovernmentType());
// Check If needsGood for the building a make bonuses dependent on having that good for further bonus
if (rec->GetNumEnablesGood() > 0){
for(good = 0; good < rec->GetNumEnablesGood(); good++) {
m_collectingResources.AddResource(rec->GetEnablesGoodIndex(good));
}
}
}
}
// end building enables good
// Add if city has wonder GetEnablesGood >0 then that good will be dded to the city for trade
//sint32 wgood;
for(sint32 w = 0; w < g_theWonderDB->NumRecords(); w++) {
if(m_builtWonders & ((uint64)1 << w)) {
const WonderRecord *wrec = wonderutil_Get(w);
// Check If needsGood for the building a make bonuses dependent on having that good for further bonus
if (wrec->GetNumEnablesGood() > 0){
for(good = 0; good < wrec->GetNumEnablesGood(); good++) {
m_collectingResources.AddResource(wrec->GetEnablesGoodIndex(good));
}
}
}
}
CityInfluenceIterator it(cityPos, m_sizeIndex);
for(it.Start(); !it.End(); it.Next()) {
Cell *cell = g_theWorld->GetCell(it.Pos());
sint32 ring = GetRing(it.Pos());
m_ringFood[ring] += cell->GetFoodProduced();
m_ringProd[ring] += cell->GetShieldsProduced();
m_ringGold[ring] += cell->GetGoldProduced();
m_ringSizes[ring]++;
sint32 good;
if(g_theWorld->GetGood(it.Pos(), good)
#if !defined(NEW_RESOURCE_PROCESS)
&& MapPoint::GetSquaredDistance(cityPos, it.Pos()) <= partSquaredRadius
#endif
){
m_collectingResources.AddResource(good);
}
// Added by E (10-29-2005) - If a tileimp has enablegood then give to city
for(sint32 i = 0; i < cell->GetNumDBImprovements(); i++) {
sint32 imp = cell->GetDBImprovement(i);
const TerrainImprovementRecord *rec = g_theTerrainImprovementDB->Get(imp);
if (rec->GetNumEnablesGood() > 0){
for(good = 0; good < rec->GetNumEnablesGood(); good++) {
m_collectingResources.AddResource(rec->GetEnablesGoodIndex(good));
}
}
}
}
void Player::BeginTurnImprovements()
{
int i, n;
n = m_terrainImprovements->Num();
for(i = 0; i < n; i++) {
if(!m_terrainImprovements->Access(i).IsBuilding()) {
if(m_materialPool->GetMaterials() >= m_terrainImprovements->Access(i).GetMaterialCost())
m_terrainImprovements->Access(i).StartBuilding();
else
break;
}
}
for(i=0; i < n; i++) {
g_gevManager->AddEvent(GEV_INSERT_Tail,
GEV_ImprovementAddTurn,
GEA_Improvement, m_terrainImprovements->Access(i),
GEA_End);
}
//EMOD - Get production for TradeProduction Tile Imps move to beginturnimps?
MapPoint pos;
for(sint32 b = 0; b < g_theTerrainImprovementDB->NumRecords(); b++) {
if(m_terrainImprovements && ((uint64)1 << b)) {
const TerrainImprovementRecord *rec = g_theTerrainImprovementDB->Get(b);
const TerrainImprovementRecord::Effect *effect = terrainutil_GetTerrainEffect(rec, pos);
if (effect->GetColony()) {
m_materialPool->AddMaterials(rec->GetBonusProductionExport());
}
}
}
///
MapPoint pos;
for(sint32 b = 0; b < m_allInstallations->Num(); b++) {
Installation inst = m_allInstallations->Access(b);
const TerrainImprovementRecord *rec = inst.GetDBRec();
const TerrainImprovementRecord::Effect *effect = terrainutil_GetTerrainEffect(rec, pos);
if (effect->GetColony()) {
m_materialPool->AddMaterials(rec->GetBonusProductionExport());
}
}
BOOL ArmyData::VerifyAttack(UNIT_ORDER_TYPE order, const MapPoint &pos,
sint32 defense_owner)
{
if(IsEnemy(defense_owner) &&
!g_player[m_owner]->WillViolateCeaseFire(defense_owner) &&
!g_player[m_owner]->WillViolatePact(defense_owner))
// EMOD
{
SlicObject *so = new SlicObject("110bCantAttackHaveTreaty") ;
so->AddRecipient(player->m_owner) ;
so->AddCity(*unit) ;
g_slicEngine->Execute(so) ;
return(FALSE);
}
// end EMOD
return TRUE;
SlicObject *so;
if(g_network.IsActive() && g_network.TeamsEnabled() &&
g_player[m_owner]->m_networkGroup == g_player[defense_owner]->m_networkGroup) {
so = new SlicObject("110aCantAttackTeammates");
} else if(!IsEnemy(defense_owner)) {
so = new SlicObject("110CantAttackAllies");
} else {
so = new SlicObject("110bCantAttackHaveTreaty");
}
so->AddRecipient(m_owner);
so->AddCivilisation(defense_owner);
so->AddUnit(m_array[0]);
so->AddLocation(pos);
so->AddOrder(order);
g_slicEngine->Execute(so);
g_selected_item->ForceDirectorSelect(Army(m_id));
return FALSE;
}
MapPoint pos;
for(sint32 b = 0; b < m_allInstallations->Num(); b++) {
Installation inst = m_allInstallations->Access(b);
const TerrainImprovementRecord *rec = inst.GetDBRec();
const TerrainImprovementRecord::Effect *effect = terrainutil_GetTerrainEffect(rec, pos);
if (effect->GetColony()) {
if (effect->GetBonusProductionExport() > 0){
m_materialPool->AddMaterials(effect->GetBonusProductionExport());
}
}
}
sint32 buildingutil_GetTotalUpkeep(const uint64 built_improvements,
sint32 wonderLevel)
{
sint32 owner = 0;
sint32 upkeep = 0;
for(sint32 i = 0; i < g_theBuildingDB->NumRecords(); i++) {
if(built_improvements & shiftbit(i)) {
if(g_theBuildingDB->Get(i)->GetUpkeep() > wonderLevel) {
upkeep += g_theBuildingDB->Get(i)->GetUpkeep();
//EMOD added new Upkeep calculations (3-13-2006) it might be better for the AI to handle thn using negative "goldper"
upkeep += g_theBuildingDB->Get(i)->GetUpkeepPerUnitWagesReadiness * g_player[owner]->GetNumUnits() * g_player[owner]->m_readiness->GetSupportModifier(g_player[owner]->GetGovernmentType()) * g_player[owner]->GetWagesPerPerson();
upkeep += g_theBuildingDB->Get(i)->GetUpkeepPerCity * g_player[owner]->GetNumCities();
upkeep += g_theBuildingDB->Get(i)->GetUpkeepPerCitySq * g_player[owner]->GetNumCities() * g_player[owner]->GetNumCities();
upkeep += g_theBuildingDB->Get(i)->GetUpkeepPerUnit * g_player[owner]->GetNumUnits();
//end EMOD
}
}
}
return upkeep;
}
Comment