I am pretty sure you are having the same old crazy bug. Try this ExpandCity function:
Note: I got game crashs when when i added the medieval age function.
Code:
int_f ExpandCity(int_t owner, location_t cityLoc, int_t cityRadius, int_t tileType, int_t addDelete) { location_t tmpLoc; location_t tmp2Loc; int_t i; int_t j; int_t k; int_t sucess; int_t newType; int_t searchRadius; int_t addDeleteYN; int_t ownerNum; if (FAI_INIT == 1000) { searchRadius = 1; sucess = 0; newType = tileType; addDeleteYN = addDelete; ownerNum = owner; j = random(6); if (j == 0 || j == 5 || j == 2 || j == 7) { j = 6; } while (searchRadius <= cityRadius && sucess == 0) { tmpLoc = cityLoc; for (k = 0; k < searchRadius; k = k + 1) { GetNeighbor(tmpLoc, j, tmp2Loc); tmpLoc = tmp2Loc; } if (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && !HasAdvance(owner, ID_ADVANCE_CONCRETE) && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && !HasAdvance(owner, ID_ADVANCE_EUGENICS) && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplacePCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && HasAdvance(owner, ID_ADVANCE_CONCRETE) && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && !HasAdvance(owner, ID_ADVANCE_EUGENICS) && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && HasAdvance(owner, ID_ADVANCE_CONCRETE) && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && !HasAdvance(owner, ID_ADVANCE_EUGENICS) && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplaceMCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && HasAdvance(owner, ID_ADVANCE_CONCRETE) && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && !HasAdvance(owner, ID_ADVANCE_EUGENICS) && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && HasAdvance(owner, ID_ADVANCE_CONCRETE) && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && HasAdvance(owner, ID_ADVANCE_EUGENICS) && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplaceGCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && HasAdvance(owner, ID_ADVANCE_CONCRETE) && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && HasAdvance(owner, ID_ADVANCE_EUGENICS) && HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplaceALTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } i = j + 1; while (i != j && sucess == 0) { tmpLoc = cityLoc; for (k = 0; k < searchRadius; k = k + 1) { GetNeighbor(tmpLoc, i, tmp2Loc); tmpLoc = tmp2Loc; } if (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && !HasAdvance(owner, ID_ADVANCE_CONCRETE) && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && !HasAdvance(owner, ID_ADVANCE_EUGENICS) && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplacePCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && HasAdvance(owner, ID_ADVANCE_CONCRETE) && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && !HasAdvance(owner, ID_ADVANCE_EUGENICS) && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && HasAdvance(owner, ID_ADVANCE_CONCRETE) && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && !HasAdvance(owner, ID_ADVANCE_EUGENICS) && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplaceMCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && HasAdvance(owner, ID_ADVANCE_CONCRETE) && !HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && !HasAdvance(owner, ID_ADVANCE_EUGENICS) && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplaceACTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && HasAdvance(owner, ID_ADVANCE_CONCRETE) && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && HasAdvance(owner, ID_ADVANCE_EUGENICS) && !HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplaceGCTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } elseif (HasAdvance(owner, ID_ADVANCE_TOOLMAKING) && HasAdvance(owner, ID_ADVANCE_CONCRETE) && HasAdvance(owner, ID_ADVANCE_GLOBAL_ECONOMICS) && HasAdvance(owner, ID_ADVANCE_EUGENICS) && HasAdvance(owner, ID_ADVANCE_ARCOLOGIES)) { sucess = ReplaceALTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } sucess = ReplaceALTile(ownerNum, tmpLoc, searchRadius, j, newType, addDeleteYN); } i = i + 1; if (i == 8) { i = 0; } } searchRadius = searchRadius + 1; } return sucess; } else { return 0; } }
Comment