Changeset 447 for trunk/CityProcessing.pas
- Timestamp:
- May 19, 2022, 10:39:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CityProcessing.pas
r425 r447 8 8 9 9 // Reporting 10 procedure GetCityAreaInfo( p, Loc: integer; var CityAreaInfo: TCityAreaInfo);11 function CanCityGrow( p, cix: integer): boolean;12 function GetCityReport( p, cix: integer; var CityReport: TCityReport): integer;13 function GetCityReportNew( p, cix: integer;14 var CityReportNew: TCityReportNew): integer;10 procedure GetCityAreaInfo(P, Loc: Integer; var CityAreaInfo: TCityAreaInfo); 11 function CanCityGrow(P, cix: Integer): Boolean; 12 function GetCityReport(P, cix: Integer; var CityReport: TCityReport): Integer; 13 function GetCityReportNew(P, cix: Integer; 14 var CityReportNew: TCityReportNew): Integer; 15 15 16 16 // Internal Tile Picking 17 function AddBestCityTile( p, cix: integer): boolean;18 procedure CityGrowth( p, cix: integer);19 procedure CityShrink( p, cix: integer);20 procedure Pollute( p, cix: integer);17 function AddBestCityTile(P, cix: Integer): Boolean; 18 procedure CityGrowth(P, cix: Integer); 19 procedure CityShrink(P, cix: Integer); 20 procedure Pollute(P, cix: Integer); 21 21 22 22 // Turn Processing 23 procedure PayCityMaintenance( p, cix: integer);24 procedure CollectCityResources( p, cix: integer);25 function CityTurn( p, cix: integer): boolean;23 procedure PayCityMaintenance(P, cix: Integer); 24 procedure CollectCityResources(P, cix: Integer); 25 function CityTurn(P, cix: Integer): Boolean; 26 26 27 27 // Tile Access 28 function SetCityTiles( p, cix, NewTiles: integer;29 TestOnly: boolean = false): integer;30 procedure GetCityTileAdvice( p, cix: integer; var Advice: TCityTileAdviceData);28 function SetCityTiles(P, cix, NewTiles: Integer; 29 TestOnly: Boolean = False): Integer; 30 procedure GetCityTileAdvice(P, cix: Integer; var Advice: TCityTileAdviceData); 31 31 32 32 // Start/End Game … … 67 67 68 68 var 69 MaxDist: integer;69 MaxDist: Integer; 70 70 71 71 { … … 73 73 ____________________________________________________________________ 74 74 } 75 procedure GetCityAreaInfo( p, Loc: integer; var CityAreaInfo: TCityAreaInfo);76 var 77 V21, Loc1, p1: integer;75 procedure GetCityAreaInfo(P, Loc: Integer; var CityAreaInfo: TCityAreaInfo); 76 var 77 V21, Loc1, p1: Integer; 78 78 Radius: TVicinity21Loc; 79 79 begin 80 {$IFOPT O-} assert(1 shl pand InvalidTreatyMap = 0); {$ENDIF}80 {$IFOPT O-}Assert(1 shl P and InvalidTreatyMap = 0); {$ENDIF} 81 81 with CityAreaInfo do 82 82 begin … … 90 90 begin 91 91 p1 := RealMap[Loc1] shr 27; 92 if (p1 < nPl) and (p1 <> p) and (RW[p].Treaty[p1] >= trPeace) then92 if (p1 < nPl) and (p1 <> P) and (RW[P].Treaty[p1] >= trPeace) then 93 93 Available[V21] := faTreaty 94 else if (ZoCMap[Loc1] > 0) and (Occupant[Loc1] <> p) and95 (RW[ p].Treaty[Occupant[Loc1]] < trAlliance) then94 else if (ZoCMap[Loc1] > 0) and (Occupant[Loc1] <> P) and 95 (RW[P].Treaty[Occupant[Loc1]] < trAlliance) then 96 96 Available[V21] := faSiege 97 97 else if (UsedByCity[Loc1] <> -1) and (UsedByCity[Loc1] <> Loc) then … … 104 104 end; 105 105 106 function CanCityGrow( p, cix: integer): boolean;107 begin 108 with RW[ p].City[cix] do109 result := (Size < MaxCitySize) and106 function CanCityGrow(P, cix: Integer): Boolean; 107 begin 108 with RW[P].City[cix] do 109 Result := (Size < MaxCitySize) and 110 110 ((Size < NeedAqueductSize) or (Built[imAqueduct] = 1) and 111 111 (Size < NeedSewerSize) or (Built[imSewer] = 1)); 112 112 end; 113 113 114 procedure DetermineCityProdProcessing( p, cix: integer;114 procedure DetermineCityProdProcessing(P, cix: Integer; 115 115 var ProdProcessing: TProdProcessing); 116 116 begin 117 with RW[ p].City[cix], ProdProcessing do117 with RW[P].City[cix], ProdProcessing do 118 118 begin 119 119 ProdBonus := 0; 120 120 PollBonus := 0; 121 121 if Built[imFactory] = 1 then 122 inc(ProdBonus);122 Inc(ProdBonus); 123 123 if Built[imMfgPlant] = 1 then 124 inc(ProdBonus);124 Inc(ProdBonus); 125 125 if (Built[imPower] = 1) or (Built[imHydro] = 1) or (Built[imNuclear] = 1) or 126 (GWonder[woHoover].EffectiveOwner = p) then126 (GWonder[woHoover].EffectiveOwner = P) then 127 127 ProdBonus := ProdBonus * 2; 128 128 if Built[imFactory] = 1 then 129 inc(PollBonus);129 Inc(PollBonus); 130 130 if Built[imMfgPlant] = 1 then 131 inc(PollBonus);131 Inc(PollBonus); 132 132 if (Built[imFactory] + Built[imMfgPlant] > 0) then 133 if (Built[imHydro] > 0) or (GWonder[woHoover].EffectiveOwner = p) then134 dec(PollBonus)133 if (Built[imHydro] > 0) or (GWonder[woHoover].EffectiveOwner = P) then 134 Dec(PollBonus) 135 135 else if (Built[imNuclear] = 0) and (Built[imPower] = 1) then 136 inc(PollBonus);137 if (RW[ p].Government <= gDespotism) or (Built[imRecycling] = 1) then136 Inc(PollBonus); 137 if (RW[P].Government <= gDespotism) or (Built[imRecycling] = 1) then 138 138 PollBonus := -2; // no pollution 139 139 PollThreshold := Size; 140 140 FutProdBonus := 0; 141 if RW[ p].Tech[futProductionTechnology] > 0 then141 if RW[P].Tech[futProductionTechnology] > 0 then 142 142 begin // future tech benefits 143 143 if Built[imFactory] = 1 then 144 inc(FutProdBonus, FactoryFutureBonus * RW[p].Tech144 Inc(FutProdBonus, FactoryFutureBonus * RW[P].Tech 145 145 [futProductionTechnology]); 146 146 if Built[imMfgPlant] = 1 then 147 inc(FutProdBonus, MfgPlantFutureBonus * RW[p].Tech147 Inc(FutProdBonus, MfgPlantFutureBonus * RW[P].Tech 148 148 [futProductionTechnology]); 149 149 end; … … 151 151 end; 152 152 153 procedure BoostProd(BaseProd: integer; ProdProcessing: TProdProcessing;154 var Prod, Poll: integer);153 procedure BoostProd(BaseProd: Integer; ProdProcessing: TProdProcessing; 154 var Prod, Poll: Integer); 155 155 begin 156 156 Poll := BaseProd * (2 + ProdProcessing.PollBonus) shr 1; … … 158 158 Poll := 0 159 159 else 160 dec(Poll, ProdProcessing.PollThreshold);160 Dec(Poll, ProdProcessing.PollThreshold); 161 161 if ProdProcessing.FutProdBonus > 0 then 162 162 Prod := BaseProd * (100 + ProdProcessing.ProdBonus * 50 + … … 166 166 end; 167 167 168 procedure DetermineCityTradeProcessing( p, cix, HappinessBeforeLux: integer;168 procedure DetermineCityTradeProcessing(P, cix, HappinessBeforeLux: Integer; 169 169 var TradeProcessing: TTradeProcessing); 170 170 var 171 i, Dist: integer;172 begin 173 with RW[ p].City[cix], TradeProcessing do171 I, Dist: Integer; 172 begin 173 with RW[P].City[cix], TradeProcessing do 174 174 begin 175 175 TaxBonus := 0; 176 176 ScienceBonus := 0; 177 177 if Built[imMarket] = 1 then 178 inc(TaxBonus, 2);178 Inc(TaxBonus, 2); 179 179 if Built[imBank] = 1 then 180 180 begin 181 inc(TaxBonus, 3);182 if RW[ p].NatBuilt[imStockEx] = 1 then183 inc(TaxBonus, 3);181 Inc(TaxBonus, 3); 182 if RW[P].NatBuilt[imStockEx] = 1 then 183 Inc(TaxBonus, 3); 184 184 end; 185 185 LuxBonus := TaxBonus; 186 186 if Built[imLibrary] = 1 then 187 inc(ScienceBonus, 2);187 Inc(ScienceBonus, 2); 188 188 if Built[imUniversity] = 1 then 189 inc(ScienceBonus, 3);189 Inc(ScienceBonus, 3); 190 190 if Built[imResLab] = 1 then 191 inc(ScienceBonus, 3);191 Inc(ScienceBonus, 3); 192 192 ScienceDoubling := 0; 193 193 if Built[imNatObs] > 0 then 194 inc(ScienceDoubling);195 if RW[ p].Government = gFundamentalism then196 dec(ScienceDoubling)197 else if (GWonder[woNewton].EffectiveOwner = p) and198 (RW[ p].Government = gMonarchy) then199 inc(ScienceDoubling);200 FlexibleLuxury := ((ServerVersion[ p] >= $0100F1) and201 (GWonder[woLiberty].EffectiveOwner = p) or (ServerVersion[p] < $0100F1)202 and (GWonder[woMich].EffectiveOwner = p)) and203 (RW[ p].Government <> gAnarchy);194 Inc(ScienceDoubling); 195 if RW[P].Government = gFundamentalism then 196 Dec(ScienceDoubling) 197 else if (GWonder[woNewton].EffectiveOwner = P) and 198 (RW[P].Government = gMonarchy) then 199 Inc(ScienceDoubling); 200 FlexibleLuxury := ((ServerVersion[P] >= $0100F1) and 201 (GWonder[woLiberty].EffectiveOwner = P) or (ServerVersion[P] < $0100F1) 202 and (GWonder[woMich].EffectiveOwner = P)) and 203 (RW[P].Government <> gAnarchy); 204 204 FutResBonus := 0; 205 if RW[ p].Tech[futResearchTechnology] > 0 then205 if RW[P].Tech[futResearchTechnology] > 0 then 206 206 begin // future tech benefits 207 207 if Built[imUniversity] = 1 then 208 inc(FutResBonus, UniversityFutureBonus * RW[p].Tech208 Inc(FutResBonus, UniversityFutureBonus * RW[P].Tech 209 209 [futResearchTechnology]); 210 210 if Built[imResLab] = 1 then 211 inc(FutResBonus, ResLabFutureBonus * RW[p].Tech[futResearchTechnology]);212 end; 213 if (RW[ p].NatBuilt[imPalace] > 0) or (ServerVersion[p] < $010000) then211 Inc(FutResBonus, ResLabFutureBonus * RW[P].Tech[futResearchTechnology]); 212 end; 213 if (RW[P].NatBuilt[imPalace] > 0) or (ServerVersion[P] < $010000) then 214 214 begin // calculate corruption 215 215 Dist := MaxDist; 216 for i := 0 to RW[p].nCity - 1 do217 if (RW[ p].City[i].Loc >= 0) and (RW[p].City[i].Built[imPalace] = 1) then218 Dist := Distance(Loc, RW[ p].City[i].Loc);219 if (Dist = 0) or (CorrLevel[RW[ p].Government] = 0) then216 for I := 0 to RW[P].nCity - 1 do 217 if (RW[P].City[I].Loc >= 0) and (RW[P].City[I].Built[imPalace] = 1) then 218 Dist := Distance(Loc, RW[P].City[I].Loc); 219 if (Dist = 0) or (CorrLevel[RW[P].Government] = 0) then 220 220 RelCorr := 0.0 221 221 else 222 222 begin 223 223 RelCorr := Dist / MaxDist; 224 if CorrLevel[RW[ p].Government] > 1 then225 RelCorr := Exp(ln(RelCorr) / CorrLevel[RW[ p].Government]);224 if CorrLevel[RW[P].Government] > 1 then 225 RelCorr := Exp(ln(RelCorr) / CorrLevel[RW[P].Government]); 226 226 if Built[imCourt] = 1 then 227 227 RelCorr := RelCorr / 2; … … 237 237 end; 238 238 239 procedure SplitTrade(Trade, TaxRate, LuxRate, Working: integer;239 procedure SplitTrade(Trade, TaxRate, LuxRate, Working: Integer; 240 240 TradeProcessing: TTradeProcessing; var Corruption, Tax, Lux, 241 Science: integer);242 var 243 plus: integer;241 Science: Integer); 242 var 243 plus: Integer; 244 244 begin 245 245 Corruption := Trunc(Trade * TradeProcessing.RelCorr); … … 276 276 end; 277 277 278 function GetProjectCost( p, cix: integer): integer;279 var 280 i: integer;281 begin 282 with RW[ p].City[cix] do278 function GetProjectCost(P, cix: Integer): Integer; 279 var 280 I: Integer; 281 begin 282 with RW[P].City[cix] do 283 283 begin 284 284 if Project and cpImp = 0 then 285 285 begin 286 result := RW[p].Model[Project and cpIndex].Cost; { unit project }286 Result := RW[P].Model[Project and cpIndex].Cost; { unit project } 287 287 if Project and cpConscripts <> 0 then 288 288 begin 289 i := RW[p].Model[Project and cpIndex].MCost;290 result := result - 3 * i;291 if result <= 0 then292 result := i;289 I := RW[P].Model[Project and cpIndex].MCost; 290 Result := Result - 3 * I; 291 if Result <= 0 then 292 Result := I; 293 293 end 294 else if RW[ p].Model[Project and cpIndex].Cap[mcLine] > 0 then294 else if RW[P].Model[Project and cpIndex].Cap[mcLine] > 0 then 295 295 if Project0 and (not cpAuto or cpRepeat) = Project and not cpAuto or cpRepeat 296 296 then 297 result := result shr 1297 Result := Result shr 1 298 298 else 299 result := result * 2;299 Result := Result * 2; 300 300 end 301 301 else 302 302 begin { improvement project } 303 result := Imp[Project and cpIndex].Cost;304 if (Project and cpIndex < nWonder) and (GWonder[woColossus].EffectiveOwner = p)303 Result := Imp[Project and cpIndex].Cost; 304 if (Project and cpIndex < nWonder) and (GWonder[woColossus].EffectiveOwner = P) 305 305 then 306 result := result * ColossusEffect div 100;307 end; 308 result := result * BuildCostMod[Difficulty[p]] div 12;309 end; 310 end; 311 312 function GetSmallCityReport( p, cix: integer; var CityReport: TCityReport;313 PCityReportEx: PCityReportEx = nil): integer;314 var 315 i, uix, V21, Loc1, ForcedSupport, BaseHappiness, Control: integer;306 Result := Result * ColossusEffect div 100; 307 end; 308 Result := Result * BuildCostMod[Difficulty[P]] div 12; 309 end; 310 end; 311 312 function GetSmallCityReport(P, cix: Integer; var CityReport: TCityReport; 313 PCityReportEx: PCityReportEx = nil): Integer; 314 var 315 I, uix, V21, Loc1, ForcedSupport, BaseHappiness, Control: Integer; 316 316 ProdProcessing: TProdProcessing; 317 317 TradeProcessing: TTradeProcessing; 318 318 Radius: TVicinity21Loc; 319 319 UnitReport: TUnitReport; 320 RareOK: array [0 .. 3] of integer;320 RareOK: array [0 .. 3] of Integer; 321 321 TileInfo: TTileInfo; 322 322 begin 323 with RW[ p].City[cix], CityReport do323 with RW[P].City[cix], CityReport do 324 324 begin 325 325 if HypoTiles <= 0 then 326 326 HypoTiles := Tiles; 327 327 if HypoTax < 0 then 328 HypoTax := RW[ p].TaxRate;328 HypoTax := RW[P].TaxRate; 329 329 if HypoLux < 0 then 330 HypoLux := RW[ p].LuxRate;331 332 if (Flags and chCaptured <> 0) or (RW[ p].Government = gAnarchy) then330 HypoLux := RW[P].LuxRate; 331 332 if (Flags and chCaptured <> 0) or (RW[P].Government = gAnarchy) then 333 333 begin 334 334 Working := 0; 335 335 for V21 := 1 to 26 do 336 336 if HypoTiles and (1 shl V21) <> 0 then 337 inc(Working); // for backward compatibility338 339 if RW[ p].Government = gFundamentalism then337 Inc(Working); // for backward compatibility 338 339 if RW[P].Government = gFundamentalism then 340 340 begin 341 341 Happy := Size; … … 380 380 BaseHappiness := Size; 381 381 end; 382 for i:= 0 to nWonder - 1 do383 if Built[ i] = 1 then382 for I := 0 to nWonder - 1 do 383 if Built[I] = 1 then 384 384 begin 385 inc(Happy);386 inc(BaseHappiness, 2);385 Inc(Happy); 386 Inc(BaseHappiness, 2); 387 387 end; 388 388 if Built[imTemple] = 1 then 389 389 begin 390 inc(Happy);391 inc(BaseHappiness, 2);390 Inc(Happy); 391 Inc(BaseHappiness, 2); 392 392 end; 393 393 if Built[imCathedral] = 1 then 394 394 begin 395 inc(Happy, 2);396 inc(BaseHappiness, 4);397 if GWonder[woBach].EffectiveOwner = pthen395 Inc(Happy, 2); 396 Inc(BaseHappiness, 4); 397 if GWonder[woBach].EffectiveOwner = P then 398 398 begin 399 inc(Happy);400 inc(BaseHappiness, 2);399 Inc(Happy); 400 Inc(BaseHappiness, 2); 401 401 end; 402 402 end; 403 403 if Built[imTheater] > 0 then 404 404 begin 405 inc(Happy, 2);406 inc(BaseHappiness, 4);405 Inc(Happy, 2); 406 Inc(BaseHappiness, 4); 407 407 end; 408 408 409 409 // calculate unit support 410 {$IFOPT O-} assert(InvalidTreatyMap = 0); {$ENDIF}410 {$IFOPT O-}Assert(InvalidTreatyMap = 0); {$ENDIF} 411 411 Support := 0; 412 412 ForcedSupport := 0; 413 413 Eaten := Size * 2; 414 414 Deployed := 0; 415 for uix := 0 to RW[ p].nUn - 1 do416 with RW[ p].Un[uix] do415 for uix := 0 to RW[P].nUn - 1 do 416 with RW[P].Un[uix] do 417 417 if (Loc >= 0) and (Home = cix) then 418 418 begin 419 GetUnitReport( p, uix, UnitReport);420 inc(Eaten, UnitReport.FoodSupport);419 GetUnitReport(P, uix, UnitReport); 420 Inc(Eaten, UnitReport.FoodSupport); 421 421 if UnitReport.ReportFlags and urfAlwaysSupport <> 0 then 422 inc(ForcedSupport, UnitReport.ProdSupport)422 Inc(ForcedSupport, UnitReport.ProdSupport) 423 423 else 424 inc(Support, UnitReport.ProdSupport);424 Inc(Support, UnitReport.ProdSupport); 425 425 if UnitReport.ReportFlags and urfDeployed <> 0 then 426 inc(Deployed);426 Inc(Deployed); 427 427 end; 428 428 if Deployed >= Happy then 429 429 Happy := 0 430 430 else 431 dec(Happy, Deployed);432 dec(Support, Size * SupportFree[RW[p].Government] shr 1);431 Dec(Happy, Deployed); 432 Dec(Support, Size * SupportFree[RW[P].Government] shr 1); 433 433 if Support < 0 then 434 434 Support := 0; 435 inc(Support, ForcedSupport);435 Inc(Support, ForcedSupport); 436 436 437 437 { control } 438 case RW[ p].Government of438 case RW[P].Government of 439 439 gDespotism: 440 for uix := 0 to RW[ p].nUn - 1 do441 if (RW[ p].Un[uix].Loc = Loc) and442 (RW[ p].Model[RW[p].Un[uix].mix].Kind = mkSpecial_TownGuard) then440 for uix := 0 to RW[P].nUn - 1 do 441 if (RW[P].Un[uix].Loc = Loc) and 442 (RW[P].Model[RW[P].Un[uix].mix].Kind = mkSpecial_TownGuard) then 443 443 begin 444 inc(Happy);445 inc(Control, 2);444 Inc(Happy); 445 Inc(Control, 2); 446 446 end; 447 447 gFundamentalism: … … 454 454 455 455 // collect processing parameters 456 DetermineCityProdProcessing( p, cix, ProdProcessing);457 DetermineCityTradeProcessing( p, cix, BaseHappiness + Control - 2 *456 DetermineCityProdProcessing(P, cix, ProdProcessing); 457 DetermineCityTradeProcessing(P, cix, BaseHappiness + Control - 2 * 458 458 Deployed, TradeProcessing); 459 459 … … 472 472 // HypoTiles go beyond map border! 473 473 begin 474 result := eInvalid;475 exit;474 Result := eInvalid; 475 Exit; 476 476 end; 477 GetTileInfo( p, cix, Loc1, TileInfo);478 inc(FoodRep, TileInfo.Food);479 inc(ProdRep, TileInfo.Prod);480 inc(Trade, TileInfo.Trade);477 GetTileInfo(P, cix, Loc1, TileInfo); 478 Inc(FoodRep, TileInfo.Food); 479 Inc(ProdRep, TileInfo.Prod); 480 Inc(Trade, TileInfo.Trade); 481 481 if (RealMap[Loc1] and fModern <> 0) and 482 (RW[ p].Tech[adMassProduction] >= tsApplicable) then483 inc(RareOK[RealMap[Loc1] shr 25 and 3]);484 inc(Working);482 (RW[P].Tech[adMassProduction] >= tsApplicable) then 483 Inc(RareOK[RealMap[Loc1] shr 25 and 3]); 484 Inc(Working); 485 485 end; 486 486 if Built[imAlgae] = 1 then 487 inc(FoodRep, 12);487 Inc(FoodRep, 12); 488 488 489 489 if PCityReportEx <> nil then … … 510 510 end; 511 511 end; 512 result := eOk;513 end; 514 515 function GetCityReport( p, cix: integer; var CityReport: TCityReport): integer;516 begin 517 result := GetSmallCityReport(p, cix, CityReport);518 CityReport.Storage := StorageSize[Difficulty[ p]];519 CityReport.ProdCost := GetProjectCost( p, cix);520 end; 521 522 function GetCityReportNew( p, cix: integer;523 var CityReportNew: TCityReportNew): integer;512 Result := eOk; 513 end; 514 515 function GetCityReport(P, cix: Integer; var CityReport: TCityReport): Integer; 516 begin 517 Result := GetSmallCityReport(P, cix, CityReport); 518 CityReport.Storage := StorageSize[Difficulty[P]]; 519 CityReport.ProdCost := GetProjectCost(P, cix); 520 end; 521 522 function GetCityReportNew(P, cix: Integer; 523 var CityReportNew: TCityReportNew): Integer; 524 524 var 525 525 CityReport: TCityReport; … … 531 531 CityReport.HypoTax := HypoTaxRate; 532 532 CityReport.HypoLux := HypoLuxuryRate; 533 result := GetSmallCityReport(p, cix, CityReport, @CityReportEx);534 FoodSupport := CityReport.Eaten - 2 * RW[ p].City[cix].Size;533 Result := GetSmallCityReport(P, cix, CityReport, @CityReportEx); 534 FoodSupport := CityReport.Eaten - 2 * RW[P].City[cix].Size; 535 535 MaterialSupport := CityReport.Support; 536 ProjectCost := GetProjectCost( p, cix);537 Storage := StorageSize[Difficulty[ p]];536 ProjectCost := GetProjectCost(P, cix); 537 Storage := StorageSize[Difficulty[P]]; 538 538 Deployed := CityReport.Deployed; 539 539 Morale := CityReportEx.BaseHappiness; 540 540 CollectedControl := CityReportEx.BaseControl + 541 (RW[ p].City[cix].Size - CityReport.Working) * 2;541 (RW[P].City[cix].Size - CityReport.Working) * 2; 542 542 CollectedFood := CityReport.FoodRep; 543 543 CollectedMaterial := CityReportEx.Material; … … 551 551 Luxury := CityReport.Lux; 552 552 FoodSurplus := CityReport.FoodRep - CityReport.Eaten; 553 HappinessBalance := Morale + Luxury + CollectedControl - RW[ p].City[cix]553 HappinessBalance := Morale + Luxury + CollectedControl - RW[P].City[cix] 554 554 .Size - 2 * Deployed; 555 555 end; … … 560 560 ____________________________________________________________________ 561 561 } 562 procedure NextBest( p, cix: integer; var SelectedLoc, SelectedV21: integer);562 procedure NextBest(P, cix: Integer; var SelectedLoc, SelectedV21: Integer); 563 563 { best tile unused but available by city cix } 564 564 var 565 Resources, Most, Loc1, p1, V21: integer;565 Resources, Most, Loc1, p1, V21: Integer; 566 566 TileInfo: TTileInfo; 567 567 Radius: TVicinity21Loc; 568 568 begin 569 {$IFOPT O-} assert(1 shl pand InvalidTreatyMap = 0); {$ENDIF}569 {$IFOPT O-}Assert(1 shl P and InvalidTreatyMap = 0); {$ENDIF} 570 570 Most := 0; 571 571 SelectedLoc := -1; 572 572 SelectedV21 := -1; 573 with RW[ p].City[cix] do573 with RW[P].City[cix] do 574 574 begin 575 575 V21_to_Loc(Loc, Radius); … … 580 580 begin 581 581 p1 := RealMap[Loc1] shr 27; 582 if ((p1 = nPl) or (p1 = p) or (RW[p].Treaty[p1] < trPeace)) and583 ((ZoCMap[Loc1] = 0) or (Occupant[Loc1] = p) or584 (RW[ p].Treaty[Occupant[Loc1]] = trAlliance)) then582 if ((p1 = nPl) or (p1 = P) or (RW[P].Treaty[p1] < trPeace)) and 583 ((ZoCMap[Loc1] = 0) or (Occupant[Loc1] = P) or 584 (RW[P].Treaty[Occupant[Loc1]] = trAlliance)) then 585 585 begin 586 GetTileInfo( p, cix, Loc1, TileInfo);586 GetTileInfo(P, cix, Loc1, TileInfo); 587 587 Resources := TileInfo.Food shl 16 + TileInfo.Prod shl 8 + 588 588 TileInfo.Trade; … … 600 600 end; 601 601 602 procedure NextWorst( p, cix: integer; var SelectedLoc, SelectedV21: integer);602 procedure NextWorst(P, cix: Integer; var SelectedLoc, SelectedV21: Integer); 603 603 { worst tile used by city cix } 604 604 var 605 Resources, Least, Loc1, V21: integer;605 Resources, Least, Loc1, V21: Integer; 606 606 Radius: TVicinity21Loc; 607 607 TileInfo: TTileInfo; … … 610 610 SelectedLoc := -1; 611 611 SelectedV21 := -1; 612 with RW[ p].City[cix] do612 with RW[P].City[cix] do 613 613 begin 614 614 V21_to_Loc(Loc, Radius); … … 619 619 if (Loc1 >= 0) and (Loc1 < MapSize) and (1 shl V21 and Tiles <> 0) then 620 620 begin 621 GetTileInfo( p, cix, Loc1, TileInfo);621 GetTileInfo(P, cix, Loc1, TileInfo); 622 622 Resources := TileInfo.Food shl 16 + TileInfo.Prod shl 8 + 623 623 TileInfo.Trade; … … 634 634 end; 635 635 636 function NextPoll( p, cix: integer): integer;637 var 638 Resources, Best, dx, dy, Loc1, Dist, BestDist, V21, pTerr: integer;636 function NextPoll(P, cix: Integer): Integer; 637 var 638 Resources, Best, dx, dy, Loc1, Dist, BestDist, V21, pTerr: Integer; 639 639 Radius: TVicinity21Loc; 640 640 TileInfo: TTileInfo; 641 641 begin 642 642 BestDist := MaxInt; 643 {$IFOPT O-} assert(1 shl pand InvalidTreatyMap = 0); {$ENDIF}643 {$IFOPT O-}Assert(1 shl P and InvalidTreatyMap = 0); {$ENDIF} 644 644 Best := 0; 645 result := -1;646 with RW[ p].City[cix] do645 Result := -1; 646 with RW[P].City[cix] do 647 647 begin 648 648 V21_to_Loc(Loc, Radius); … … 656 656 begin 657 657 pTerr := RealMap[Loc1] shr 27; 658 if (pTerr = nPl) or (pTerr = p) or (RW[p].Treaty[pTerr] < trPeace)658 if (pTerr = nPl) or (pTerr = P) or (RW[P].Treaty[pTerr] < trPeace) 659 659 then 660 660 begin 661 GetTileInfo( p, cix, Loc1, TileInfo);661 GetTileInfo(P, cix, Loc1, TileInfo); 662 662 Resources := TileInfo.Prod shl 16 + TileInfo.Trade shl 8 + 663 663 TileInfo.Food; … … 669 669 then 670 670 begin 671 result := Loc1;671 Result := Loc1; 672 672 Best := Resources; 673 673 BestDist := Dist; … … 679 679 end; 680 680 681 function AddBestCityTile( p, cix: integer): boolean;682 var 683 TileLoc, V21: integer;684 begin 685 NextBest( p, cix, TileLoc, V21);686 result := TileLoc >= 0;687 if result then688 with RW[ p].City[cix] do689 begin 690 assert(1 shl V21 and Tiles = 0);681 function AddBestCityTile(P, cix: Integer): Boolean; 682 var 683 TileLoc, V21: Integer; 684 begin 685 NextBest(P, cix, TileLoc, V21); 686 Result := TileLoc >= 0; 687 if Result then 688 with RW[P].City[cix] do 689 begin 690 Assert(1 shl V21 and Tiles = 0); 691 691 Tiles := Tiles or (1 shl V21); 692 692 UsedByCity[TileLoc] := Loc; … … 694 694 end; 695 695 696 procedure CityGrowth( p, cix: integer);697 var 698 TileLoc, V21: integer;696 procedure CityGrowth(P, cix: Integer); 697 var 698 TileLoc, V21: Integer; 699 699 AltCityReport: TCityReport; 700 700 begin 701 with RW[ p].City[cix] do701 with RW[P].City[cix] do 702 702 begin 703 inc(Size);704 NextBest( p, cix, TileLoc, V21);703 Inc(Size); 704 NextBest(P, cix, TileLoc, V21); 705 705 if TileLoc >= 0 then 706 706 begin { test whether exploitation of tile would lead to disorder } … … 708 708 AltCityReport.HypoTax := -1; 709 709 AltCityReport.HypoLux := -1; 710 GetSmallCityReport( p, cix, AltCityReport);710 GetSmallCityReport(P, cix, AltCityReport); 711 711 if AltCityReport.Working - AltCityReport.Happy <= Size shr 1 then 712 712 // !!! change to new style disorder 713 713 begin { no disorder -- exploit tile } 714 assert(1 shl V21 and Tiles = 0);714 Assert(1 shl V21 and Tiles = 0); 715 715 Tiles := Tiles or (1 shl V21); 716 716 UsedByCity[TileLoc] := Loc; … … 720 720 end; 721 721 722 procedure CityShrink( p, cix: integer);723 var 724 TileLoc, V21, Working: integer;722 procedure CityShrink(P, cix: Integer); 723 var 724 TileLoc, V21, Working: Integer; 725 725 AltCityReport: TCityReport; 726 726 begin 727 with RW[ p].City[cix] do727 with RW[P].City[cix] do 728 728 begin 729 729 Working := 0; 730 730 for V21 := 1 to 26 do 731 731 if Tiles and (1 shl V21) <> 0 then 732 inc(Working);733 dec(Size);734 if Food > StorageSize[Difficulty[ p]] then735 Food := StorageSize[Difficulty[ p]];736 NextWorst( p, cix, TileLoc, V21);732 Inc(Working); 733 Dec(Size); 734 if Food > StorageSize[Difficulty[P]] then 735 Food := StorageSize[Difficulty[P]]; 736 NextWorst(P, cix, TileLoc, V21); 737 737 if Working > Size then 738 738 begin { all citizens were working -- worst tile no longer exploited } 739 assert(1 shl V21 and Tiles <> 0);739 Assert(1 shl V21 and Tiles <> 0); 740 740 Tiles := Tiles and not(1 shl V21); 741 741 UsedByCity[TileLoc] := -1; … … 746 746 AltCityReport.HypoTax := -1; 747 747 AltCityReport.HypoLux := -1; 748 GetSmallCityReport( p, cix, AltCityReport);748 GetSmallCityReport(P, cix, AltCityReport); 749 749 if AltCityReport.Working - AltCityReport.Happy > Size shr 1 then 750 750 // !!! change to new style disorder 751 751 begin { disorder -- don't exploit tile } 752 assert(1 shl V21 and Tiles <> 0);752 Assert(1 shl V21 and Tiles <> 0); 753 753 Tiles := Tiles and not(1 shl V21); 754 754 UsedByCity[TileLoc] := -1; … … 758 758 end; 759 759 760 procedure Pollute( p, cix: integer);761 var 762 PollutionLoc: integer;763 begin 764 with RW[ p].City[cix] do760 procedure Pollute(P, cix: Integer); 761 var 762 PollutionLoc: Integer; 763 begin 764 with RW[P].City[cix] do 765 765 begin 766 766 Pollution := Pollution - MaxPollution; 767 PollutionLoc := NextPoll( p, cix);767 PollutionLoc := NextPoll(P, cix); 768 768 if PollutionLoc >= 0 then 769 769 begin 770 inc(Flags, chPollution);770 Inc(Flags, chPollution); 771 771 RealMap[PollutionLoc] := RealMap[PollutionLoc] or fPoll; 772 772 end; … … 778 778 ____________________________________________________________________ 779 779 } 780 procedure PayCityMaintenance( p, cix: integer);781 var 782 i: integer;783 begin 784 with RW[ p], City[cix] do785 for i:= nWonder to nImp - 1 do786 if (Built[ i] > 0) and (Project0 and (cpImp or cpIndex) <> (cpImp or i))780 procedure PayCityMaintenance(P, cix: Integer); 781 var 782 I: Integer; 783 begin 784 with RW[P], City[cix] do 785 for I := nWonder to nImp - 1 do 786 if (Built[I] > 0) and (Project0 and (cpImp or cpIndex) <> (cpImp or I)) 787 787 then // don't pay maintenance when just completed 788 788 begin 789 dec(Money, Imp[i].Maint);789 Dec(Money, Imp[I].Maint); 790 790 if Money < 0 then 791 791 begin { out of money - sell improvement } 792 inc(Money, Imp[i].Cost * BuildCostMod[Difficulty[p]] div 12);793 Built[ i] := 0;794 if Imp[ i].Kind <> ikCommon then792 Inc(Money, Imp[I].Cost * BuildCostMod[Difficulty[P]] div 12); 793 Built[I] := 0; 794 if Imp[I].Kind <> ikCommon then 795 795 begin 796 assert(i<> imSpacePort);796 Assert(I <> imSpacePort); 797 797 // never sell automatically! (solution: no maintenance) 798 NatBuilt[ i] := 0;799 if i= imGrWall then800 GrWallContinent[ p] := -1;798 NatBuilt[I] := 0; 799 if I = imGrWall then 800 GrWallContinent[P] := -1; 801 801 end; 802 inc(Flags, chImprovementLost);803 end; 804 end; 805 end; 806 807 procedure CollectCityResources( p, cix: integer);808 var 809 CityStorage, CityProjectCost: integer;802 Inc(Flags, chImprovementLost); 803 end; 804 end; 805 end; 806 807 procedure CollectCityResources(P, cix: Integer); 808 var 809 CityStorage, CityProjectCost: Integer; 810 810 CityReport: TCityReportNew; 811 Disorder: boolean;812 begin 813 with RW[ p], City[cix], CityReport do811 Disorder: Boolean; 812 begin 813 with RW[P], City[cix], CityReport do 814 814 if Flags and chCaptured <> 0 then 815 815 begin 816 816 Flags := Flags and not chDisorder; 817 dec(Flags, $10000);817 Dec(Flags, $10000); 818 818 if Flags and chCaptured = 0 then 819 819 Flags := Flags or chAfterCapture; … … 826 826 HypoTaxRate := -1; 827 827 HypoLuxuryRate := -1; 828 GetCityReportNew( p, cix, CityReport);829 CityStorage := StorageSize[Difficulty[ p]];830 CityProjectCost := GetProjectCost( p, cix);828 GetCityReportNew(P, cix, CityReport); 829 CityStorage := StorageSize[Difficulty[P]]; 830 CityProjectCost := GetProjectCost(P, cix); 831 831 832 832 Disorder := (HappinessBalance < 0); … … 840 840 if not Disorder and ((Government = gFuture) or (Size >= NeedAqueductSize) 841 841 and (FoodSurplus < 2)) and (FoodSurplus > 0) then 842 inc(Money, FoodSurplus)842 Inc(Money, FoodSurplus) 843 843 else if not(Disorder and (FoodSurplus > 0)) then 844 844 begin { calculate new food storage } … … 849 849 (Project and (cpImp + cpIndex) <> cpImp + imAqueduct) and 850 850 (Project and (cpImp + cpIndex) <> cpImp + imSewer) and 851 not CanCityGrow( p, cix) then852 inc(Flags, chNoGrowthWarning);851 not CanCityGrow(P, cix) then 852 Inc(Flags, chNoGrowthWarning); 853 853 end; 854 854 855 855 if Prod > CityProjectCost then 856 856 begin 857 inc(Money, Prod - CityProjectCost);857 Inc(Money, Prod - CityProjectCost); 858 858 Prod := CityProjectCost; 859 859 end; … … 862 862 else if not Disorder and (Flags and chProductionSabotaged = 0) then 863 863 if Project and (cpImp + cpIndex) = cpImp + imTrGoods then 864 inc(Money, Production)864 Inc(Money, Production) 865 865 else 866 inc(Prod, Production);866 Inc(Prod, Production); 867 867 868 868 if not Disorder then 869 869 begin 870 870 { sum research points and taxes } 871 inc(Research, Science);872 inc(Money, Tax);871 Inc(Research, Science); 872 Inc(Money, Tax); 873 873 Pollution := Pollution + AddPollution; 874 874 end; … … 876 876 end; 877 877 878 function CityTurn( p, cix: integer): boolean;878 function CityTurn(P, cix: Integer): Boolean; 879 879 // return value: whether city keeps existing 880 880 var 881 i, uix, cix2, p1, SizeMod, CityStorage, CityProjectCost, NewImp, Det,882 TestDet: integer;883 LackOfMaterial, CheckGrow, DoProd, IsActive: boolean;884 begin 885 with RW[ p], City[cix] do881 I, uix, cix2, p1, SizeMod, CityStorage, CityProjectCost, NewImp, Det, 882 TestDet: Integer; 883 LackOfMaterial, CheckGrow, DoProd, IsActive: Boolean; 884 begin 885 with RW[P], City[cix] do 886 886 begin 887 887 SizeMod := 0; 888 CityStorage := StorageSize[Difficulty[ p]];889 CityProjectCost := GetProjectCost( p, cix);888 CityStorage := StorageSize[Difficulty[P]]; 889 CityProjectCost := GetProjectCost(P, cix); 890 890 891 891 LackOfMaterial := Flags and chUnitLost <> 0; … … 897 897 if CheckGrow and (GTestFlags and tfImmGrow <> 0) then { fast growth } 898 898 begin 899 if CanCityGrow( p, cix) then900 inc(SizeMod);899 if CanCityGrow(P, cix) then 900 Inc(SizeMod); 901 901 end 902 902 else if CheckGrow and (Food >= CityStorage) then { normal growth } 903 903 begin 904 if CanCityGrow( p, cix) then904 if CanCityGrow(P, cix) then 905 905 begin 906 906 if Built[imGranary] = 1 then 907 dec(Food, CityStorage shr 1)907 Dec(Food, CityStorage shr 1) 908 908 else 909 dec(Food, CityStorage);910 inc(SizeMod);909 Dec(Food, CityStorage); 910 Inc(SizeMod); 911 911 end; 912 912 end … … 916 916 // check if settlers or conscripts there to disband 917 917 uix := -1; 918 for i:= 0 to nUn - 1 do919 if (Un[ i].Loc >= 0) and (Un[i].Home = cix) and920 ((Model[Un[ i].mix].Kind = mkSettler)918 for I := 0 to nUn - 1 do 919 if (Un[I].Loc >= 0) and (Un[I].Home = cix) and 920 ((Model[Un[I].mix].Kind = mkSettler) 921 921 { and (GWonder[woFreeSettlers].EffectiveOwner<>p) } 922 or (Un[ i].Flags and unConscripts <> 0)) and923 ((uix = -1) or (Model[Un[ i].mix].Cost < Model[Un[uix].mix].Cost) or924 (Model[Un[ i].mix].Cost = Model[Un[uix].mix].Cost) and925 (Un[ i].Exp < Un[uix].Exp)) then926 uix := i;922 or (Un[I].Flags and unConscripts <> 0)) and 923 ((uix = -1) or (Model[Un[I].mix].Cost < Model[Un[uix].mix].Cost) or 924 (Model[Un[I].mix].Cost = Model[Un[uix].mix].Cost) and 925 (Un[I].Exp < Un[uix].Exp)) then 926 uix := I; 927 927 928 928 if uix >= 0 then 929 929 begin 930 RemoveUnit_UpdateMap( p, uix);931 inc(Flags, chUnitLost);930 RemoveUnit_UpdateMap(P, uix); 931 Inc(Flags, chUnitLost); 932 932 end 933 933 else 934 934 begin 935 dec(SizeMod);936 inc(Flags, chPopDecrease);935 Dec(SizeMod); 936 Inc(Flags, chPopDecrease); 937 937 end 938 938 end; … … 946 946 uix := -1; 947 947 Det := MaxInt; 948 for i:= 0 to nUn - 1 do949 if (Un[ i].Loc >= 0) and (Un[i].Home = cix) then950 with Model[Un[ i].mix] do948 for I := 0 to nUn - 1 do 949 if (Un[I].Loc >= 0) and (Un[I].Home = cix) then 950 with Model[Un[I].mix] do 951 951 begin 952 952 if Kind = mkSpecial_TownGuard then 953 TestDet := Un[ i].Health + Un[i].Exp shl 8953 TestDet := Un[I].Health + Un[I].Exp shl 8 954 954 // disband townguards first 955 955 else 956 956 begin 957 TestDet := Un[ i].Health + Un[i].Exp shl 8 + Cost shl 16;957 TestDet := Un[I].Health + Un[I].Exp shl 8 + Cost shl 16; 958 958 // value of unit 959 959 if Flags and mdDoubleSupport <> 0 then … … 963 963 if TestDet < Det then 964 964 begin 965 uix := i;965 uix := I; 966 966 Det := TestDet; 967 967 end; … … 969 969 if uix >= 0 then 970 970 begin 971 RemoveUnit_UpdateMap( p, uix);972 inc(Flags, chUnitLost);971 RemoveUnit_UpdateMap(P, uix); 972 Inc(Flags, chUnitLost); 973 973 end; 974 974 end; … … 984 984 (GWonder[Project and cpIndex].CityID <> WonderNotBuiltYet) then 985 985 begin 986 inc(Flags, chOldWonder);987 DoProd := false;986 Inc(Flags, chOldWonder); 987 DoProd := False; 988 988 end; 989 989 … … 995 995 (Project and cpConscripts <> 0))) then 996 996 begin 997 inc(Flags, chNoSettlerProd);998 DoProd := false;997 Inc(Flags, chNoSettlerProd); 998 DoProd := False; 999 999 end; 1000 1000 1001 1001 if DoProd then 1002 1002 begin { project complete } 1003 dec(Prod, CityProjectCost);1003 Dec(Prod, CityProjectCost); 1004 1004 if Project and cpImp = 0 then { produce unit } 1005 1005 begin 1006 1006 if nUn < numax then 1007 1007 begin 1008 CreateUnit( p, Project and cpIndex);1008 CreateUnit(P, Project and cpIndex); 1009 1009 Un[nUn - 1].Loc := Loc; 1010 1010 with Un[nUn - 1] do … … 1020 1020 Flags := Flags or unConscripts; 1021 1021 end; 1022 PlaceUnit( p, nUn - 1);1022 PlaceUnit(P, nUn - 1); 1023 1023 UpdateUnitMap(Loc); 1024 1024 if Model[Project and cpIndex].Kind = mkSettler then 1025 dec(SizeMod, 2) { settler produced - city shrink }1025 Dec(SizeMod, 2) { settler produced - city shrink } 1026 1026 else if (Model[Project and cpIndex].Kind = mkSlaves) or 1027 1027 (Project and cpConscripts <> 0) then 1028 dec(SizeMod); { slaves/conscripts produced - city shrink }1028 Dec(SizeMod); { slaves/conscripts produced - city shrink } 1029 1029 end; 1030 1030 Project0 := Project or cpRepeat or cpCompleted; … … 1032 1032 else if Imp[Project and cpIndex].Kind = ikShipPart then 1033 1033 begin { produce ship parts } 1034 inc(GShip[p].Parts[Project and cpIndex - imShipComp]);1034 Inc(GShip[P].Parts[Project and cpIndex - imShipComp]); 1035 1035 Project0 := Project or cpCompleted; 1036 1036 end … … 1038 1038 begin 1039 1039 NewImp := Project and cpIndex; 1040 inc(Money, Prod); { change rest to money }1040 Inc(Money, Prod); { change rest to money } 1041 1041 Project0 := Project or cpCompleted; 1042 1042 Project := cpImp + imTrGoods; … … 1045 1045 if Imp[NewImp].Kind in [ikNatLocal, ikNatGlobal] then 1046 1046 begin // nat. project 1047 for i:= 0 to nCity - 1 do1048 if (City[ i].Loc >= 0) and (City[i].Built[NewImp] = 1) then1047 for I := 0 to nCity - 1 do 1048 if (City[I].Loc >= 0) and (City[I].Built[NewImp] = 1) then 1049 1049 begin { allowed only once } 1050 inc(Money, Imp[NewImp].Cost * BuildCostMod[Difficulty[p]] div 12);1051 City[ i].Built[NewImp] := 0;1050 Inc(Money, Imp[NewImp].Cost * BuildCostMod[Difficulty[P]] div 12); 1051 City[I].Built[NewImp] := 0; 1052 1052 end; 1053 1053 NatBuilt[NewImp] := 1; … … 1056 1056 case NewImp of 1057 1057 imGrWall: 1058 GrWallContinent[ p] := Continent[Loc];1058 GrWallContinent[P] := Continent[Loc]; 1059 1059 end; 1060 1060 end; … … 1063 1063 begin // wonder 1064 1064 GWonder[NewImp].CityID := ID; 1065 GWonder[NewImp].EffectiveOwner := p;1065 GWonder[NewImp].EffectiveOwner := P; 1066 1066 CheckExpiration(NewImp); 1067 1067 … … 1070 1070 woEiffel: 1071 1071 begin // reactivate wonders 1072 for i:= 0 to nWonder - 1 do1073 if Imp[ i].Expiration >= 0 then1072 for I := 0 to nWonder - 1 do 1073 if Imp[I].Expiration >= 0 then 1074 1074 for cix2 := 0 to nCity - 1 do 1075 if (City[cix2].Loc >= 0) and (City[cix2].Built[ i] = 1)1075 if (City[cix2].Loc >= 0) and (City[cix2].Built[I] = 1) 1076 1076 then 1077 GWonder[ i].EffectiveOwner := p;1077 GWonder[I].EffectiveOwner := P; 1078 1078 end; 1079 1079 woLighthouse: 1080 CheckSpecialModels( p, preLighthouse);1080 CheckSpecialModels(P, preLighthouse); 1081 1081 woLeo: 1082 1082 begin 1083 inc(Research, TechBaseCost(nTech[p], Difficulty[p]) +1084 TechBaseCost(nTech[ p] + 2, Difficulty[p]));1085 CheckSpecialModels( p, preLeo);1083 Inc(Research, TechBaseCost(nTech[P], Difficulty[P]) + 1084 TechBaseCost(nTech[P] + 2, Difficulty[P])); 1085 CheckSpecialModels(P, preLeo); 1086 1086 end; 1087 1087 woPyramids: 1088 CheckSpecialModels( p, preBuilder);1088 CheckSpecialModels(P, preBuilder); 1089 1089 woMir: 1090 1090 begin 1091 1091 for p1 := 0 to nPl - 1 do 1092 if (p1 <> p) and (1 shl p1 and GAlive <> 0) then1092 if (p1 <> P) and (1 shl p1 and GAlive <> 0) then 1093 1093 begin 1094 if RW[ p].Treaty[p1] = trNoContact then1095 IntroduceEnemy( p, p1);1096 GiveCivilReport( p, p1);1097 GiveMilReport( p, p1);1094 if RW[P].Treaty[p1] = trNoContact then 1095 IntroduceEnemy(P, p1); 1096 GiveCivilReport(P, p1); 1097 GiveMilReport(P, p1); 1098 1098 end; 1099 1099 end; … … 1101 1101 end; 1102 1102 1103 for i:= 0 to nImpReplacement - 1 do // sell obsolete buildings1104 if (ImpReplacement[ i].NewImp = NewImp) and1105 (Built[ImpReplacement[ i].OldImp] > 0) then1103 for I := 0 to nImpReplacement - 1 do // sell obsolete buildings 1104 if (ImpReplacement[I].NewImp = NewImp) and 1105 (Built[ImpReplacement[I].OldImp] > 0) then 1106 1106 begin 1107 inc(RW[p].Money, Imp[ImpReplacement[i].OldImp].Cost * BuildCostMod1108 [Difficulty[ p]] div 12);1109 Built[ImpReplacement[ i].OldImp] := 0;1107 Inc(RW[P].Money, Imp[ImpReplacement[I].OldImp].Cost * BuildCostMod 1108 [Difficulty[P]] div 12); 1109 Built[ImpReplacement[I].OldImp] := 0; 1110 1110 end; 1111 1111 1112 1112 if NewImp in [imPower, imHydro, imNuclear] then 1113 for i:= 0 to nImp - 1 do1114 if ( i <> NewImp) and (iin [imPower, imHydro, imNuclear]) and1115 (Built[ i] > 0) then1113 for I := 0 to nImp - 1 do 1114 if (I <> NewImp) and (I in [imPower, imHydro, imNuclear]) and 1115 (Built[I] > 0) then 1116 1116 begin // sell obsolete power plant 1117 inc(RW[p].Money, Imp[i].Cost * BuildCostMod[Difficulty[p]1117 Inc(RW[P].Money, Imp[I].Cost * BuildCostMod[Difficulty[P] 1118 1118 ] div 12); 1119 Built[ i] := 0;1119 Built[I] := 0; 1120 1120 end; 1121 1121 … … 1123 1123 end; 1124 1124 Prod0 := Prod; 1125 inc(Flags, chProduction);1125 Inc(Flags, chProduction); 1126 1126 end 1127 1127 else … … 1135 1135 if SizeMod > 0 then 1136 1136 begin 1137 CityGrowth( p, cix);1138 inc(Flags, chPopIncrease);1139 end; 1140 result := Size + SizeMod >= 2;1141 if result then1137 CityGrowth(P, cix); 1138 Inc(Flags, chPopIncrease); 1139 end; 1140 Result := Size + SizeMod >= 2; 1141 if Result then 1142 1142 while SizeMod < 0 do 1143 1143 begin 1144 CityShrink( p, cix);1145 inc(SizeMod);1144 CityShrink(P, cix); 1145 Inc(SizeMod); 1146 1146 end; 1147 1147 end; … … 1152 1152 ____________________________________________________________________ 1153 1153 } 1154 function SetCityTiles( p, cix, NewTiles: integer;1155 TestOnly: boolean = false): integer;1156 var 1157 V21, Working, ChangeTiles, AddTiles, Loc1: integer;1154 function SetCityTiles(P, cix, NewTiles: Integer; 1155 TestOnly: Boolean = False): Integer; 1156 var 1157 V21, Working, ChangeTiles, AddTiles, Loc1: Integer; 1158 1158 CityAreaInfo: TCityAreaInfo; 1159 1159 Radius: TVicinity21Loc; 1160 1160 begin 1161 with RW[ p].City[cix] do1161 with RW[P].City[cix] do 1162 1162 begin 1163 ChangeTiles := NewTiles xor integer(Tiles);1163 ChangeTiles := NewTiles xor Integer(Tiles); 1164 1164 AddTiles := NewTiles and not Tiles; 1165 1165 if Mode = moPlaying then … … 1167 1167 if NewTiles and not $67F7F76 <> 0 then 1168 1168 begin 1169 result := eInvalid;1170 exit1169 Result := eInvalid; 1170 Exit 1171 1171 end; // invalid tile index included 1172 1172 if NewTiles and (1 shl 13) = 0 then 1173 1173 begin 1174 result := eViolation;1175 exit1174 Result := eViolation; 1175 Exit 1176 1176 end; // city tile must be exploited 1177 1177 if ChangeTiles = 0 then 1178 1178 begin 1179 result := eNotChanged;1180 exit1179 Result := eNotChanged; 1180 Exit 1181 1181 end; 1182 1182 if AddTiles <> 0 then 1183 1183 begin 1184 1184 // check if new tiles possible 1185 GetCityAreaInfo( p, Loc, CityAreaInfo);1185 GetCityAreaInfo(P, Loc, CityAreaInfo); 1186 1186 for V21 := 1 to 26 do 1187 1187 if AddTiles and (1 shl V21) <> 0 then 1188 1188 if CityAreaInfo.Available[V21] <> faAvailable then 1189 1189 begin 1190 result := eTileNotAvailable;1191 exit;1190 Result := eTileNotAvailable; 1191 Exit; 1192 1192 end; 1193 1193 // not more tiles than inhabitants … … 1195 1195 for V21 := 1 to 26 do 1196 1196 if NewTiles and (1 shl V21) <> 0 then 1197 inc(Working);1197 Inc(Working); 1198 1198 if Working > Size then 1199 1199 begin 1200 result := eNoWorkerAvailable;1201 exit;1202 end; 1203 end; 1204 end; 1205 result := eOk;1200 Result := eNoWorkerAvailable; 1201 Exit; 1202 end; 1203 end; 1204 end; 1205 Result := eOk; 1206 1206 if not TestOnly then 1207 1207 begin … … 1211 1211 begin 1212 1212 Loc1 := Radius[V21]; 1213 assert((Loc1 >= 0) and (Loc1 < MapSize));1213 Assert((Loc1 >= 0) and (Loc1 < MapSize)); 1214 1214 if NewTiles and (1 shl V21) <> 0 then 1215 1215 UsedByCity[Loc1] := Loc // employ tile 1216 1216 else if UsedByCity[Loc1] <> Loc then 1217 assert(Mode < moPlaying)1217 Assert(Mode < moPlaying) 1218 1218 // should only happen during loading, because of wrong sSetCityTiles command order 1219 1219 else … … 1225 1225 end; 1226 1226 1227 procedure GetCityTileAdvice( p, cix: integer; var Advice: TCityTileAdviceData);1227 procedure GetCityTileAdvice(P, cix: Integer; var Advice: TCityTileAdviceData); 1228 1228 const 1229 1229 oFood = 0; … … 1240 1240 end; 1241 1241 var 1242 i, V21, Loc1, nHierarchy, iH, iT, iH_Switch, MinWorking, MaxWorking,1242 I, V21, Loc1, nHierarchy, iH, iT, iH_Switch, MinWorking, MaxWorking, 1243 1243 WantedProd, MinFood, MinProd, count, Take, MaxTake, AreaSize, FormulaCode, 1244 1244 NeedRare, RareTiles, cix1, dx, dy, BestTiles, ProdBeforeBoost, TestTiles, 1245 SubPlus, SuperPlus: integer;1246 SuperValue, BestSuperValue, SubValue, BestSubValue: integer;1247 Value, BestValue, ValuePlus: extended;1248 ValueFormula_Weight: array [oFood .. oScience] of extended;1249 ValueFormula_Multiply: array [oFood .. oScience] of boolean;1250 Output: array [oFood .. oScience] of integer;1245 SubPlus, SuperPlus: Integer; 1246 SuperValue, BestSuperValue, SubValue, BestSubValue: Integer; 1247 Value, BestValue, ValuePlus: Extended; 1248 ValueFormula_Weight: array [oFood .. oScience] of Extended; 1249 ValueFormula_Multiply: array [oFood .. oScience] of Boolean; 1250 Output: array [oFood .. oScience] of Integer; 1251 1251 TileInfo, BaseTileInfo: TTileInfo; 1252 1252 Radius, Radius1: TVicinity21Loc; … … 1255 1255 CityAreaInfo: TCityAreaInfo; 1256 1256 Hierarchy: array [0 .. 20, 0 .. 31] of TTileData; 1257 nTile, nSelection: array [0 .. 20] of integer;1258 SubCriterion: array [0 .. 27] of integer;1259 FoodWasted, FoodToTax, ProdToTax, RareOK, NeedStep2, IsBest: boolean;1260 begin 1261 if (RW[ p].Government = gAnarchy) or (RW[p].City[cix].Flags and chCaptured <> 0)1257 nTile, nSelection: array [0 .. 20] of Integer; 1258 SubCriterion: array [0 .. 27] of Integer; 1259 FoodWasted, FoodToTax, ProdToTax, RareOK, NeedStep2, IsBest: Boolean; 1260 begin 1261 if (RW[P].Government = gAnarchy) or (RW[P].City[cix].Flags and chCaptured <> 0) 1262 1262 then 1263 1263 begin … … 1265 1265 Advice.Tiles := 1 shl CityOwnTile; 1266 1266 Advice.CityReport.HypoTiles := 1 shl CityOwnTile; 1267 exit;1268 end; 1269 1270 for i:= oFood to oScience do1267 Exit; 1268 end; 1269 1270 for I := oFood to oScience do 1271 1271 begin // decode evaluation formula from weights parameter 1272 FormulaCode := Advice.ResourceWeights shr (24 - 8 * i) and $FF;1273 ValueFormula_Multiply[ i] := FormulaCode and $80 <> 0;1272 FormulaCode := Advice.ResourceWeights shr (24 - 8 * I) and $FF; 1273 ValueFormula_Multiply[I] := FormulaCode and $80 <> 0; 1274 1274 if FormulaCode and $40 <> 0 then 1275 ValueFormula_Weight[ i] := (FormulaCode and $0F) *1275 ValueFormula_Weight[I] := (FormulaCode and $0F) * 1276 1276 (1 shl (FormulaCode and $30 shr 4)) / 16 1277 1277 else 1278 ValueFormula_Weight[ i] := (FormulaCode and $0F) *1278 ValueFormula_Weight[I] := (FormulaCode and $0F) * 1279 1279 (1 shl (FormulaCode and $30 shr 4)); 1280 1280 end; … … 1283 1283 TestReport.HypoTax := -1; 1284 1284 TestReport.HypoLux := -1; 1285 GetSmallCityReport( p, cix, TestReport, @CityReportEx);1286 with RW[ p].City[cix] do1285 GetSmallCityReport(P, cix, TestReport, @CityReportEx); 1286 with RW[P].City[cix] do 1287 1287 begin 1288 1288 V21_to_Loc(Loc, Radius); 1289 FoodToTax := RW[ p].Government = gFuture;1289 FoodToTax := RW[P].Government = gFuture; 1290 1290 ProdToTax := Project and (cpImp + cpIndex) = cpImp + imTrGoods; 1291 FoodWasted := not FoodToTax and (Food = StorageSize[Difficulty[ p]]) and1292 not CanCityGrow( p, cix);1291 FoodWasted := not FoodToTax and (Food = StorageSize[Difficulty[P]]) and 1292 not CanCityGrow(P, cix); 1293 1293 1294 1294 // sub criteria … … 1300 1300 V21 xor $15; 1301 1301 end; 1302 for cix1 := 0 to RW[ p].nCity - 1 do1302 for cix1 := 0 to RW[P].nCity - 1 do 1303 1303 if cix1 <> cix then 1304 1304 begin 1305 Loc1 := RW[ p].City[cix1].Loc;1305 Loc1 := RW[P].City[cix1].Loc; 1306 1306 if Loc1 >= 0 then 1307 1307 begin … … 1316 1316 begin 1317 1317 dxdy(Loc, Loc1, dx, dy); 1318 dec(SubCriterion[(dy + 3) shl 2 + (dx + 3) shr 1], 160);1318 Dec(SubCriterion[(dy + 3) shl 2 + (dx + 3) shr 1], 160); 1319 1319 end; 1320 1320 end; … … 1323 1323 end; 1324 1324 1325 GetCityAreaInfo( p, Loc, CityAreaInfo);1325 GetCityAreaInfo(P, Loc, CityAreaInfo); 1326 1326 AreaSize := 0; 1327 1327 for V21 := 1 to 26 do 1328 1328 if CityAreaInfo.Available[V21] = faAvailable then 1329 inc(AreaSize);1330 1331 if RW[ p].Government = gFundamentalism then1329 Inc(AreaSize); 1330 1331 if RW[P].Government = gFundamentalism then 1332 1332 begin 1333 1333 MinWorking := Size; … … 1339 1339 if MinWorking > Size then 1340 1340 MinWorking := Size; 1341 if (RW[ p].LuxRate = 0) and not CityReportEx.TradeProcessing.FlexibleLuxury1341 if (RW[P].LuxRate = 0) and not CityReportEx.TradeProcessing.FlexibleLuxury 1342 1342 then 1343 1343 MaxWorking := MinWorking … … 1376 1376 Loc1 := Radius[V21]; 1377 1377 if (Loc1 >= 0) and (Loc1 < MapSize) and 1378 (RealMap[Loc1] and fModern = cardinal(NeedRare)) then1378 (RealMap[Loc1] and fModern = Cardinal(NeedRare)) then 1379 1379 RareTiles := RareTiles or (1 shl V21); 1380 1380 end; … … 1388 1388 begin 1389 1389 Loc1 := Radius[V21]; 1390 assert((Loc1 >= 0) and (Loc1 < MapSize));1391 GetTileInfo( p, cix, Loc1, TileInfo);1390 Assert((Loc1 >= 0) and (Loc1 < MapSize)); 1391 GetTileInfo(P, cix, Loc1, TileInfo); 1392 1392 if V21 = CityOwnTile then 1393 1393 BaseTileInfo := TileInfo … … 1405 1405 (TileInfo.Trade = Hierarchy[iH, iT].Trade) and 1406 1406 (SubCriterion[V21] >= SubCriterion[Hierarchy[iH, iT].V21])) do 1407 inc(iT);1407 Inc(iT); 1408 1408 if (iT = nTile[iH]) // new worst tile in this hierarchy 1409 1409 or ((TileInfo.Food >= Hierarchy[iH, iT].Food) … … 1411 1411 and (TileInfo.Prod >= Hierarchy[iH, iT].Prod) and 1412 1412 (TileInfo.Trade >= Hierarchy[iH, iT].Trade)) then 1413 break; // insert position found!1414 inc(iH);1413 Break; // insert position found! 1414 Inc(iH); 1415 1415 end; 1416 1416 if iH = nHierarchy then 1417 1417 begin // need to start new hierarchy 1418 1418 nTile[iH] := 0; 1419 inc(nHierarchy);1419 Inc(nHierarchy); 1420 1420 iT := 0; 1421 1421 end; 1422 move(Hierarchy[iH, iT], Hierarchy[iH, iT + 1],1422 Move(Hierarchy[iH, iT], Hierarchy[iH, iT + 1], 1423 1423 (nTile[iH] - iT) * SizeOf(TTileData)); 1424 inc(nTile[iH]);1424 Inc(nTile[iH]); 1425 1425 Hierarchy[iH, iT].V21 := V21; 1426 1426 Hierarchy[iH, iT].Food := TileInfo.Food; … … 1438 1438 begin 1439 1439 Loc1 := Radius[V21]; 1440 assert((V21 <> CityOwnTile) and (Loc1 >= 0) and (Loc1 < MapSize));1441 GetTileInfo( p, cix, Loc1, TileInfo);1440 Assert((V21 <> CityOwnTile) and (Loc1 >= 0) and (Loc1 < MapSize)); 1441 GetTileInfo(P, cix, Loc1, TileInfo); 1442 1442 if iH = nHierarchy then 1443 1443 begin // need to start new hierarchy 1444 1444 nTile[iH] := 0; 1445 inc(nHierarchy);1445 Inc(nHierarchy); 1446 1446 iT := 0; 1447 1447 end 1448 1448 else 1449 1449 iT := nTile[iH]; 1450 inc(nTile[iH]);1450 Inc(nTile[iH]); 1451 1451 Hierarchy[iH, iT].V21 := V21; 1452 1452 Hierarchy[iH, iT].Food := TileInfo.Food; // = 0 … … 1457 1457 end; 1458 1458 if Built[imAlgae] > 0 then 1459 inc(BaseTileInfo.Food, 12);1459 Inc(BaseTileInfo.Food, 12); 1460 1460 1461 1461 // step 2: summarize resources 1462 1462 for iH := 0 to nHierarchy - 1 do 1463 1463 begin 1464 move(Hierarchy[iH, 0], Hierarchy[iH, 1], nTile[iH] * SizeOf(TTileData));1464 Move(Hierarchy[iH, 0], Hierarchy[iH, 1], nTile[iH] * SizeOf(TTileData)); 1465 1465 Hierarchy[iH, 0].Food := 0; 1466 1466 Hierarchy[iH, 0].Prod := 0; … … 1470 1470 for iT := 1 to nTile[iH] do 1471 1471 begin 1472 inc(Hierarchy[iH, iT].Food, Hierarchy[iH, iT - 1].Food);1473 inc(Hierarchy[iH, iT].Prod, Hierarchy[iH, iT - 1].Prod);1474 inc(Hierarchy[iH, iT].Trade, Hierarchy[iH, iT - 1].Trade);1475 inc(Hierarchy[iH, iT].SubValue, Hierarchy[iH, iT - 1].SubValue);1472 Inc(Hierarchy[iH, iT].Food, Hierarchy[iH, iT - 1].Food); 1473 Inc(Hierarchy[iH, iT].Prod, Hierarchy[iH, iT - 1].Prod); 1474 Inc(Hierarchy[iH, iT].Trade, Hierarchy[iH, iT - 1].Trade); 1475 Inc(Hierarchy[iH, iT].SubValue, Hierarchy[iH, iT - 1].SubValue); 1476 1476 Hierarchy[iH, iT].V21 := 1 shl Hierarchy[iH, iT].V21 + 1477 1477 Hierarchy[iH, iT - 1].V21; … … 1501 1501 (ProdBeforeBoost < WantedProd)) do 1502 1502 begin 1503 assert(nSelection[iH] = 0);1503 Assert(nSelection[iH] = 0); 1504 1504 Take := MinWorking - TestReport.Working; 1505 1505 if Take > nTile[iH] then … … 1514 1514 while (Take < MaxTake) and 1515 1515 (TestReport.FoodRep + Hierarchy[iH, Take].Food < MinFood) do 1516 inc(Take);1516 Inc(Take); 1517 1517 while (Take < MaxTake) and 1518 1518 (ProdBeforeBoost + Hierarchy[iH, Take].Prod < MinProd) do 1519 inc(Take);1519 Inc(Take); 1520 1520 end; 1521 1521 nSelection[iH] := Take; 1522 inc(TestReport.Working, Take);1522 Inc(TestReport.Working, Take); 1523 1523 with Hierarchy[iH, Take] do 1524 1524 begin 1525 inc(TestReport.FoodRep, Food);1526 inc(ProdBeforeBoost, Prod);1527 inc(TestReport.Trade, Trade);1528 end; 1529 inc(iH);1530 end; 1531 1532 assert((TestReport.Working >= MinWorking) and1525 Inc(TestReport.FoodRep, Food); 1526 Inc(ProdBeforeBoost, Prod); 1527 Inc(TestReport.Trade, Trade); 1528 end; 1529 Inc(iH); 1530 end; 1531 1532 Assert((TestReport.Working >= MinWorking) and 1533 1533 (TestReport.Working <= MaxWorking)); 1534 1534 if (TestReport.FoodRep >= MinFood) and (ProdBeforeBoost >= MinProd) then 1535 1535 begin 1536 SplitTrade(TestReport.Trade, RW[ p].TaxRate, RW[p].LuxRate,1536 SplitTrade(TestReport.Trade, RW[P].TaxRate, RW[P].LuxRate, 1537 1537 TestReport.Working, CityReportEx.TradeProcessing, 1538 1538 TestReport.Corruption, TestReport.Tax, TestReport.Lux, … … 1543 1543 TestReport.Deployed >= Size then 1544 1544 begin // city is not in disorder -- evaluate combination 1545 inc(count);1545 Inc(count); 1546 1546 if (MinProd < WantedProd) and (ProdBeforeBoost > MinProd) then 1547 1547 begin // no combination reached wanted prod yet … … 1591 1591 then 1592 1592 begin 1593 inc(Output[oTax], Output[oFood]);1593 Inc(Output[oTax], Output[oFood]); 1594 1594 Output[oFood] := 0; 1595 1595 end; … … 1603 1603 if NeedRare > 0 then 1604 1604 begin 1605 RareOK := false;1605 RareOK := False; 1606 1606 for iH := 0 to nHierarchy - 1 do 1607 1607 if Hierarchy[iH, nSelection[iH]].V21 and RareTiles <> 0 then 1608 RareOK := true;1608 RareOK := True; 1609 1609 if not RareOK then 1610 1610 TestReport.ProdRep := TestReport.Support; … … 1613 1613 if ProdToTax then 1614 1614 begin 1615 inc(Output[oTax], Output[oProd]);1615 Inc(Output[oTax], Output[oProd]); 1616 1616 Output[oProd] := 0; 1617 1617 end; 1618 1618 end; 1619 1619 1620 NeedStep2 := false;1620 NeedStep2 := False; 1621 1621 Value := 0; 1622 for i:= oFood to oScience do1623 if ValueFormula_Multiply[ i] then1624 NeedStep2 := true1622 for I := oFood to oScience do 1623 if ValueFormula_Multiply[I] then 1624 NeedStep2 := True 1625 1625 else 1626 Value := Value + ValueFormula_Weight[ i] * Output[i];1626 Value := Value + ValueFormula_Weight[I] * Output[I]; 1627 1627 if NeedStep2 then 1628 1628 begin 1629 1629 if Value > 0 then 1630 1630 Value := ln(Value) + 123; 1631 for i:= oFood to oScience do1632 if ValueFormula_Multiply[ i] and (Output[i] > 0) then1633 Value := Value + ValueFormula_Weight[ i] *1634 (ln(Output[ i]) + 123);1631 for I := oFood to oScience do 1632 if ValueFormula_Multiply[I] and (Output[I] > 0) then 1633 Value := Value + ValueFormula_Weight[I] * 1634 (ln(Output[I]) + 123); 1635 1635 end; 1636 1636 … … 1643 1643 for iH := 0 to nHierarchy - 1 do 1644 1644 begin 1645 inc(TestTiles, Hierarchy[iH, nSelection[iH]].V21);1646 inc(SubValue, Hierarchy[iH, nSelection[iH]].SubValue);1645 Inc(TestTiles, Hierarchy[iH, nSelection[iH]].V21); 1646 Inc(SubValue, Hierarchy[iH, nSelection[iH]].SubValue); 1647 1647 end; 1648 IsBest := true;1648 IsBest := True; 1649 1649 if (SuperPlus = 0) and (ValuePlus = 0.0) then 1650 1650 begin 1651 1651 SubPlus := SubValue - BestSubValue; 1652 1652 if SubPlus < 0 then 1653 IsBest := false1653 IsBest := False 1654 1654 else if SubPlus = 0 then 1655 1655 begin 1656 assert(TestTiles <> BestTiles);1656 Assert(TestTiles <> BestTiles); 1657 1657 IsBest := TestTiles > BestTiles 1658 1658 end … … 1679 1679 with Hierarchy[iH_Switch, nSelection[iH_Switch]] do 1680 1680 begin 1681 dec(TestReport.FoodRep, Food);1682 dec(ProdBeforeBoost, Prod);1683 dec(TestReport.Trade, Trade);1684 end; 1685 inc(nSelection[iH_Switch]);1686 inc(TestReport.Working);1681 Dec(TestReport.FoodRep, Food); 1682 Dec(ProdBeforeBoost, Prod); 1683 Dec(TestReport.Trade, Trade); 1684 end; 1685 Inc(nSelection[iH_Switch]); 1686 Inc(TestReport.Working); 1687 1687 if (nSelection[iH_Switch] <= nTile[iH_Switch]) and 1688 1688 (TestReport.Working <= MaxWorking) then … … 1690 1690 with Hierarchy[iH_Switch, nSelection[iH_Switch]] do 1691 1691 begin 1692 inc(TestReport.FoodRep, Food);1693 inc(ProdBeforeBoost, Prod);1694 inc(TestReport.Trade, Trade);1692 Inc(TestReport.FoodRep, Food); 1693 Inc(ProdBeforeBoost, Prod); 1694 Inc(TestReport.Trade, Trade); 1695 1695 end; 1696 break;1697 end; 1698 dec(TestReport.Working, nSelection[iH_Switch]);1696 Break; 1697 end; 1698 Dec(TestReport.Working, nSelection[iH_Switch]); 1699 1699 nSelection[iH_Switch] := 0; 1700 inc(iH_Switch);1700 Inc(iH_Switch); 1701 1701 until iH_Switch = nHierarchy; 1702 1702 until iH_Switch = nHierarchy; // everything tested -- done 1703 1703 end; 1704 assert(BestSuperValue > 0); // advice should always be possible1704 Assert(BestSuperValue > 0); // advice should always be possible 1705 1705 Advice.Tiles := BestTiles; 1706 1706 Advice.CityReport.HypoTiles := BestTiles; … … 1713 1713 procedure InitGame; 1714 1714 var 1715 p, i, mixTownGuard: integer;1715 P, I, mixTownGuard: Integer; 1716 1716 begin 1717 1717 MaxDist := Distance(0, MapSize - lx shr 1); 1718 for p:= 0 to nPl - 1 do1719 if (1 shl pand GAlive <> 0) then1720 with RW[ p] do1718 for P := 0 to nPl - 1 do 1719 if (1 shl P and GAlive <> 0) then 1720 with RW[P] do 1721 1721 begin // initialize capital 1722 1722 mixTownGuard := 0; 1723 1723 while Model[mixTownGuard].Kind <> mkSpecial_TownGuard do 1724 inc(mixTownGuard);1724 Inc(mixTownGuard); 1725 1725 with City[0] do 1726 1726 begin 1727 1727 Built[imPalace] := 1; 1728 1728 Size := 4; 1729 for i:= 2 to Size do1730 AddBestCityTile( p, 0);1729 for I := 2 to Size do 1730 AddBestCityTile(P, 0); 1731 1731 Project := mixTownGuard; 1732 1732 end;
Note:
See TracChangeset
for help on using the changeset viewer.