Changeset 442 for trunk/UnitProcessing.pas
- Timestamp:
- May 18, 2022, 10:43:27 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UnitProcessing.pas
r290 r442 43 43 procedure InitGame; 44 44 procedure ReleaseGame; 45 45 46 46 47 implementation … … 132 133 begin // p observes tile 133 134 result := coKnown or coTrue; 134 exit 135 exit; 135 136 end 136 137 else 137 138 result := coTrue; // p does not observe tile 138 139 end; 139 end 140 end; 140 141 end; 141 142 … … 187 188 MoveCost := Speed; 188 189 result := eMountains; 189 exit 190 exit; 190 191 end; 191 192 end; … … 207 208 dAir: 208 209 MoveCost := 50 * MoveLength; { always valid move } 209 end 210 end 210 end; 211 end; 211 212 end; 212 213 … … 266 267 begin 267 268 result := eTreaty; 268 exit 269 exit; 269 270 end; // keep peace treaty! 270 271 end; … … 280 281 begin 281 282 result := eNoCapturer; 282 exit 283 exit; 283 284 end; 284 285 MoveInfo.MoveType := mtCapture; … … 289 290 begin 290 291 result := eDomainMismatch; 291 exit 292 exit; 292 293 end 293 294 else if (PModel.Attack = 0) and … … 296 297 begin 297 298 result := eNoBombarder; 298 exit 299 exit; 299 300 end 300 301 else if Movement < 100 then 301 302 begin 302 303 result := eNoTime_Bombard; 303 exit 304 exit; 304 305 end; 305 306 MoveInfo.MoveType := mtBombard; 306 307 result := eBombarded; 307 end 308 end; 308 309 end; 309 310 … … 328 329 MoveInfo.EndHealth := BattleForecast.EndHealthAtt; 329 330 MoveInfo.EndHealthDef := BattleForecast.EndHealthDef; 330 end 331 end; 331 332 end 332 333 else // if MoveInfo.MoveType in [mtMove,mtCapture,mtSpyMission] then … … 382 383 then 383 384 Break; 384 end 385 end; 385 386 end; 386 387 if result < rExecuted then … … 401 402 begin 402 403 result := eZOC; 403 exit 404 exit; 404 405 end 405 406 else if not TestOnly and (DestControlled >= coTrue) then 406 407 begin 407 408 result := eZOC_EnemySpotted; 408 exit 409 end 409 exit; 410 end; 410 411 end; 411 412 if (Movement = 0) and (ServerVersion[p] >= $0100F1) or … … 414 415 begin 415 416 result := eNoTime_Load; 416 exit 417 exit; 417 418 end 418 419 else 419 420 begin 420 421 result := eNoTime_Move; 421 exit 422 exit; 422 423 end; 423 424 if (MoveInfo.EndHealth <= 0) or (MoveInfo.MoveType = mtSpyMission) then … … 433 434 MoveInfo.Defender := RealMap[ToLoc] shr 27; 434 435 SearchCity(ToLoc, MoveInfo.Defender, MoveInfo.Dcix); 435 end 436 end 437 end; // CalculateMove436 end; 437 end; 438 end; 438 439 439 440 function GetBattleForecast(Loc: integer; var BattleForecast: TBattleForecast; … … 449 450 begin 450 451 result := eOK; 451 exit 452 exit; 452 453 end; // no attack, simple move 453 454 … … 459 460 EndHealthDef := RW[Defender].Un[Duix].Health; 460 461 result := eOK; 461 exit 462 exit; 462 463 end; 463 464 … … 482 483 begin 483 484 result := eDomainMismatch; 484 exit 485 exit; 485 486 end; // can't attack plane 486 487 end; … … 492 493 begin 493 494 result := eDomainMismatch; 494 exit 495 exit; 495 496 end; 496 497 if (PModel.Attack = 0) and not((PModel.Cap[mcBombs] > 0) and … … 498 499 begin 499 500 result := eInvalid; 500 exit 501 exit; 501 502 end; 502 503 … … 504 505 begin 505 506 result := eNoTime_Attack; 506 exit 507 exit; 507 508 end; 508 509 … … 577 578 DBaseDamage := 1; 578 579 if DBaseDamage > RW[Defender].Un[Duix].Health then 579 DBaseDamage := RW[Defender].Un[Duix].Health 580 DBaseDamage := RW[Defender].Un[Duix].Health; 580 581 end; 581 582 … … 589 590 ABaseDamage := 1; 590 591 if ABaseDamage > HealthAtt then 591 ABaseDamage := HealthAtt 592 ABaseDamage := HealthAtt; 592 593 end; 593 594 … … 625 626 result := eWon 626 627 else 627 result := eBloody 628 end 629 end; // GetBattleForecast628 result := eBloody; 629 end; 630 end; 630 631 631 632 function LoadUnit(p, uix: integer; TestOnly: boolean): integer; … … 654 655 begin 655 656 ToMaster := uix1; 656 Break 657 Break; 657 658 end 658 659 else if ToMaster < 0 then … … 679 680 Master := ToMaster; 680 681 UpdateUnitMap(Loc); 681 end 682 end 683 end 684 end 682 end; 683 end; 684 end; 685 end; 685 686 end; 686 687 … … 721 722 UpdateUnitMap(Loc); 722 723 end; 723 end 724 end; 724 725 end; 725 726 … … 802 803 begin 803 804 result := eInvalid; 804 exit 805 exit; 805 806 end; 806 807 if (a.ToLoc <> maNextCity) and (Map[a.ToLoc] and fTerrain = fUNKNOWN) then 807 808 begin 808 809 result := eNoWay; 809 exit 810 exit; 810 811 end; 811 812 … … 816 817 begin 817 818 result := eDomainMismatch; 818 exit 819 exit; 819 820 end 820 821 else … … 843 844 begin 844 845 result := eDomainMismatch; 845 exit 846 exit; 846 847 end 847 848 else … … 859 860 maxmov := Speed; 860 861 initmov := 0; 861 end 862 end; 862 863 end; 863 864 … … 873 874 begin 874 875 Loc := -1; 875 Break 876 Break; 876 877 end; 877 878 FromTile := Map[Loc]; … … 1029 1030 From[Loc1] := Loc; 1030 1031 Damage[Loc1] := Damage[Loc] + AddDamage; 1031 end 1032 end 1033 end 1034 end 1035 end 1032 end; 1033 end; 1034 end; 1035 end; 1036 end; 1036 1037 end; 1037 1038 FreeAndNil(Q); … … 1074 1075 1075 1076 // QueryPerformanceCounter(tt);{time in s is: (tt-tt0)/PerfFreq} 1076 end; // GetMoveAdvice1077 end; 1077 1078 1078 1079 function CanPlaneReturn(p, uix: integer; … … 1129 1130 begin 1130 1131 result := false; 1131 Break 1132 Break; 1132 1133 end; 1133 1134 if MapFlags[Loc] and mfEnd <> 0 then 1134 1135 begin 1135 1136 result := true; 1136 Break 1137 Break; 1137 1138 end; 1138 1139 FromTile := Map[Loc]; … … 1161 1162 T1 := T + MoveCost shl 8; 1162 1163 Q.Put(Loc1, T1); 1163 end 1164 end 1165 end 1164 end; 1165 end; 1166 end; 1166 1167 end; 1167 1168 FreeAndNil(Q); 1168 end; // CanPlaneReturn1169 end; 1169 1170 1170 1171 { … … 1195 1196 inc(JobWork, RoadBridgeWork) { across river } 1196 1197 else 1197 result := eNoBridgeBuilding 1198 result := eNoBridgeBuilding; 1198 1199 end 1199 1200 else … … 1223 1224 if (IrrEff = 0) or (RealMap[Loc] and fTerImp = tiIrrigation) or 1224 1225 (RealMap[Loc] and fTerImp = tiFarm) then 1225 result := eInvalid 1226 result := eInvalid; 1226 1227 end; 1227 1228 jFarm: … … 1232 1233 JobWork := IrrClearWork * FarmWork; 1233 1234 if (JobWork <= 0) or (RealMap[Loc] and fTerImp = tiFarm) then 1234 result := eInvalid 1235 result := eInvalid; 1235 1236 end; 1236 1237 jAfforest: … … 1243 1244 JobWork := MineAfforestWork; 1244 1245 if (MineEff = 0) or (RealMap[Loc] and fTerImp = tiMine) then 1245 result := eInvalid 1246 result := eInvalid; 1246 1247 end; 1247 1248 jFort: … … 1260 1261 JobWork := TransWork; 1261 1262 if JobWork <= 0 then 1262 result := eInvalid 1263 result := eInvalid; 1263 1264 end; 1264 1265 jPoll: … … 1278 1279 result := eInvalid; 1279 1280 end; 1280 end; // CalculateJobWork1281 end; 1281 1282 1282 1283 function StartJob(p, uix, NewJob: integer; TestOnly: boolean): integer; … … 1291 1292 begin 1292 1293 result := eNotChanged; 1293 exit 1294 exit; 1294 1295 end; 1295 1296 if NewJob = jNone then … … 1297 1298 if not TestOnly then 1298 1299 Job := jNone; 1299 exit 1300 exit; 1300 1301 end; 1301 1302 Loc0 := Loc; … … 1304 1305 begin 1305 1306 result := eDeadLands; 1306 exit 1307 exit; 1307 1308 end; 1308 1309 TerrType := RealMap[Loc0] and fTerrain; … … 1314 1315 begin 1315 1316 result := eInvalid; 1316 exit 1317 exit; 1317 1318 end; 1318 1319 if (JobPreq[NewJob] <> preNone) and … … 1320 1321 begin 1321 1322 result := eNoPreq; 1322 exit 1323 exit; 1323 1324 end; 1324 1325 … … 1347 1348 begin 1348 1349 RemoveUnit_UpdateMap(p, uix); 1349 result := eCity 1350 result := eCity; 1350 1351 end 1351 1352 else if Health <= 0 then … … 1361 1362 Discover21(Loc0, p, lObserveUnhidden, true, true); 1362 1363 // CheckContact; 1363 end 1364 end 1365 end; // with1366 end; // StartJob1364 end; 1365 end; 1366 end; 1367 end; 1367 1368 1368 1369 function Work(p, uix: integer): boolean; … … 1422 1423 end 1423 1424 end 1424 end; // work1425 end; 1425 1426 1426 1427 function GetJobProgress(p, Loc: integer; … … 1438 1439 else 1439 1440 JobProgressData[Job].Done := JobProgressData[Job].Required - 1440 ToWork[Loc, Job] 1441 ToWork[Loc, Job]; 1441 1442 end 1442 1443 else
Note:
See TracChangeset
for help on using the changeset viewer.