Changeset 442 for trunk/Database.pas
- Timestamp:
- May 18, 2022, 10:43:27 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Database.pas
r328 r442 171 171 function DoSpyMission(p, pCity, cix, Mission: integer): Cardinal; 172 172 173 173 174 implementation 174 175 … … 247 248 if Tiles and (1 shl V21) <> 0 then 248 249 assert(UsedByCity[Radius[V21]] = Loc); 249 end 250 end; 250 251 {$ENDIF} 251 252 end; 252 end; // CompactLists253 end; 253 254 254 255 { … … 265 266 result := $10000000 266 267 else 267 result := trunc(c0) 268 result := trunc(c0); 268 269 end; 269 270 … … 281 282 else 282 283 result := result * 4; 283 end 284 end; 284 285 end; 285 286 … … 363 364 end; 364 365 inc(RW[p].nModel); 365 end 366 end; 366 367 end; 367 368 end; … … 380 381 Built := 0; 381 382 Lost := 0; 382 ID := p shl 12 + nModel 383 ID := p shl 12 + nModel; 383 384 end; 384 385 inc(nModel); 385 inc(Researched[p]) 386 end 386 inc(Researched[p]); 387 end; 387 388 end; 388 389 … … 392 393 RW[p].Tech[ad] := tsSeen; 393 394 // inc(nTech[p]); 394 inc(Researched[p]) 395 inc(Researched[p]); 395 396 end; 396 397 … … 403 404 for uix := 0 to RW[p1].nUn - 1 do 404 405 if RW[p1].Model[RW[p1].Un[uix].mix].Kind = mkSlaves then 405 RW[p1].Un[uix].Job := jNone 406 RW[p1].Un[uix].Job := jNone; 406 407 end; 407 408 … … 475 476 GWonder[Wonder].EffectiveOwner := -1; 476 477 if Wonder = woPyramids then 477 FreeSlaves 478 end 478 FreeSlaves; 479 end; 479 480 end; 480 481 … … 542 543 inc(VicinityLoc[2], lx0); 543 544 inc(VicinityLoc[4], lx0); 544 end 545 end 545 end; 546 end; 546 547 end 547 548 else … … 552 553 dec(VicinityLoc[0], lx0); 553 554 dec(VicinityLoc[6], lx0); 554 end 555 end; 555 556 end; 556 557 end; … … 612 613 if (MapSize + 1) mod i = 0 then 613 614 primitive := 0; 614 inc(i) 615 inc(i); 615 616 end; 616 617 … … 622 623 repeat 623 624 inc(j); 624 i := i * primitive mod (MapSize + 1) 625 i := i * primitive mod (MapSize + 1); 625 626 until (i = 1) or (j = MapSize + 1); 626 627 until j = MapSize; … … 629 630 function MapGeneratorAvailable: boolean; 630 631 begin 631 result := (primitive > 0) and (lx >= 20) and (ly >= 40) 632 result := (primitive > 0) and (lx >= 20) and (ly >= 40); 632 633 end; 633 634 … … 666 667 ca[x] := cos(v) / ly; 667 668 f1[x] := 2 * pi * exp(Detail * (x - 1)); 668 f2[x] := exp(-x * Smooth) 669 f2[x] := exp(-x * Smooth); 669 670 end; 670 671 … … 688 689 else 689 690 Elevation[x + lx * y] := Round((v + 4) * 20); 690 inc(ElCount[Elevation[x + lx * y]]) 691 inc(ElCount[Elevation[x + lx * y]]); 691 692 end; 692 693 end; … … 709 710 for i := a to Stop do 710 711 if Continent[i] = a then 711 Continent[i] := b 712 Continent[i] := b; 712 713 end; 713 714 … … 736 737 ReplaceCont(Continent[Loc - 1], Continent[Loc], Loc); 737 738 if Continent[Loc] = -1 then 738 Continent[Loc] := Loc 739 end 739 Continent[Loc] := Loc; 740 end; 740 741 end; 741 742 … … 754 755 Wrong := Continent[lx - 1 + lx * (y + 1)]; 755 756 if Wrong >= 0 then 756 ReplaceCont(Wrong, Continent[lx * y], MapSize - 1) 757 ReplaceCont(Wrong, Continent[lx * y], MapSize - 1); 757 758 end; 758 759 end; … … 797 798 inc(AreaCount[xBlock, yBlock]); 798 799 if DelphiRandom(AreaCount[xBlock, yBlock]) = 0 then 799 RareByArea[xBlock, yBlock] := Loc0 800 end 800 RareByArea[xBlock, yBlock] := Loc0; 801 end; 801 802 end; 802 803 end; 803 end 804 end; 804 805 end; 805 806 totalrare := 0; … … 848 849 inc(RareAdjacent[(x + 7) mod 8, y + 1]); 849 850 end; 850 end 851 end; 851 852 end; 852 853 xworst := 0; … … 862 863 xworst := x; 863 864 yworst := y; 864 Cnt := 1 865 Cnt := 1; 865 866 end 866 867 else if (RareAdjacent[x, y] = RareAdjacent[xworst, yworst]) then … … 871 872 xworst := x; 872 873 yworst := y; 873 end 874 end; 874 875 end; 875 876 end; 876 877 AreaCount[xworst, yworst] := 0; 877 dec(totalrare) 878 dec(totalrare); 878 879 end; 879 880 … … 884 885 begin 885 886 RareLoc[Cnt] := RareByArea[x, y]; 886 inc(Cnt) 887 inc(Cnt); 887 888 end; 888 889 for i := 0 to 11 do … … 897 898 if (Loc1 >= 0) and (RealMap[Loc1] and fTerrain = fMountains) then 898 899 RealMap[Loc1] := RealMap[Loc1] and not fTerrain or fHills; 899 end 900 end; 900 901 end; 901 902 for i := 0 to 11 do … … 921 922 begin 922 923 iBest := i; 923 jbest := j 924 end 925 end 924 jbest := j; 925 end; 926 end; 926 927 end 927 928 else if (Cnt = 0) or (Dist[i, j] > Dist[iBest, jbest]) then … … 938 939 RareLoc[jbest] := -1; 939 940 end; 940 end; // RarePositions941 end; 941 942 942 943 function CheckShore(Loc: integer): boolean; … … 1097 1098 begin 1098 1099 dec(bMountains); 1099 inc(plus, ElCount[bMountains]) 1100 inc(plus, ElCount[bMountains]); 1100 1101 end; 1101 1102 Count := plus; … … 1105 1106 begin 1106 1107 dec(bHills); 1107 inc(plus, ElCount[bHills]) 1108 inc(plus, ElCount[bHills]); 1108 1109 end; 1109 1110 inc(Count, plus); … … 1112 1113 begin 1113 1114 dec(bLand); 1114 inc(Count, ElCount[bLand]) 1115 inc(Count, ElCount[bLand]); 1115 1116 end; 1116 1117 … … 1138 1139 end; 1139 1140 if Count = 8 then 1140 RealMap[Loc0] := fOcean 1141 RealMap[Loc0] := fOcean; 1141 1142 end; 1142 1143 … … 1202 1203 Loc1 := CopyFrom[Loc1]; 1203 1204 RealMap[Loc0] := RealMap[Loc0] and not fTerrain or 1204 RealMap[Loc1] and fTerrain 1205 RealMap[Loc1] and fTerrain; 1205 1206 end; 1206 1207 … … 1225 1226 if Loc1 >= 0 then 1226 1227 if RealMap[Loc1] and fTerrain < fGrass then 1227 inc(Count, 2) 1228 inc(Count, 2); 1228 1229 end; 1229 1230 end; 1230 1231 if Count >= 4 then 1231 RealMap[Loc0] := RealMap[Loc0] and not fTerrain or fPrairie 1232 RealMap[Loc0] := RealMap[Loc0] and not fTerrain or fPrairie; 1232 1233 end; 1233 1234 … … 1241 1242 if Loc1 >= 0 then 1242 1243 if RealMap[Loc1] and fTerrain <> fDesert then 1243 inc(Count) 1244 inc(Count); 1244 1245 end; 1245 1246 if Count >= 4 then 1246 RealMap[Loc0] := RealMap[Loc0] and not fTerrain or fPrairie 1247 RealMap[Loc0] := RealMap[Loc0] and not fTerrain or fPrairie; 1247 1248 end; 1248 1249 … … 1257 1258 RealMap[x + lx * (ly - 2)] := RealMap[x + lx * (ly - 2)] and 1258 1259 not fTerrain or fTundra; 1259 RealMap[x + lx * (ly - 1)] := fArctic 1260 RealMap[x + lx * (ly - 1)] := fArctic; 1260 1261 end; 1261 1262 … … 1355 1356 if p1 < nAlive + 1 then 1356 1357 sc[p1] := sc[p1 - 1]; 1357 dec(p1) 1358 dec(p1); 1358 1359 end; 1359 1360 if p1 < nAlive + 1 then … … 1370 1371 Break; // even least crowded continent is more crowded than smallest 1371 1372 inc(sccount[c]); 1372 dec(nsc) 1373 dec(nsc); 1373 1374 until sccount[nsc] > 1; 1374 1375 … … 1380 1381 begin 1381 1382 inc(CountGood); 1382 MinGood := 6 1383 MinGood := 6; 1383 1384 end; 1384 1385 FillChar(nCityLoc, SizeOf(nCityLoc), 0); … … 1401 1402 Loc1 := Radius[V21]; 1402 1403 if (Loc1 >= 0) and (Loc1 < MapSize) and IsGoodTile(Loc1) then 1403 inc(CntGood) 1404 inc(CntGood); 1404 1405 end; 1405 1406 if CntGood >= MinGood then 1406 1407 begin 1407 1408 CityLoc[c, nCityLoc[c]] := Loc; 1408 inc(nCityLoc[c]) 1409 inc(nCityLoc[c]); 1409 1410 end; 1410 1411 end; … … 1449 1450 TestDist := Distance(TestStartLoc[i], TestStartLoc[j]); 1450 1451 if TestDist < MinDist then 1451 MinDist := TestDist 1452 MinDist := TestDist; 1452 1453 end; 1453 1454 if i = sccount[c] - 1 then … … 1595 1596 end; 1596 1597 end; 1597 end; { StartPositions }1598 end; 1598 1599 1599 1600 procedure PredefinedStartPositions(Human: integer); … … 1654 1655 end; 1655 1656 SaveMapCenterLoc := StartLoc[0]; 1656 end; { PredefinedStartPositions }1657 end; 1657 1658 1658 1659 procedure InitGame; … … 1768 1769 Model[nModel].ID := p shl 12 + nModel; 1769 1770 SetModelFlags(Model[nModel]); 1770 inc(nModel) 1771 inc(nModel); 1771 1772 end; 1772 1773 nUn := 0; … … 1790 1791 TerritoryCount[nPl] := MapSize; 1791 1792 // fillchar(NewContact, sizeof(NewContact), false); 1792 end; // InitGame1793 end; 1793 1794 1794 1795 procedure InitRandomGame; … … 1897 1898 if (NewTile and fTerImp = tiIrrigation) or (NewTile and fTerImp = tiFarm) 1898 1899 then 1899 NewTile := NewTile and not fTerImp 1900 NewTile := NewTile and not fTerImp; 1900 1901 end; 1901 1902 if (Terrain[NewTile and fTerrain].MineEff = 0) and … … 1921 1922 RealMap[Loc1] := RealMap[Loc1] or ($F shl 27); 1922 1923 RW[0].Map[Loc1] := RealMap[Loc1] and $07FFFFFF or fObserved; 1923 end 1924 end; 1924 1925 end; 1925 1926 // RealMap[Loc]:=RealMap[Loc] and not fSpecial; … … 2053 2054 end; 2054 2055 result := eOK; 2055 end; { GetTileInfo }2056 end; 2056 2057 2057 2058 procedure Strongest(Loc: integer; var uix, Strength, Bonus, Cnt: integer); … … 2136 2137 if Health < 100 then 2137 2138 result := ((result - 250) * Health div 5000) * 50 + 250; 2138 end 2139 end 2139 end; 2140 end; 2140 2141 end; 2141 2142 … … 2314 2315 (1 shl trPeace or 1 shl TrFriendlyContact) <> 0 then 2315 2316 AddFlags := AddFlags or fPeace; 2316 end 2317 end; 2317 2318 end; 2318 2319 … … 2363 2364 if (Loc1 >= 0) and (Loc1 < MapSize) then 2364 2365 Map[Loc1] := Map[Loc1] or fInEnemyZoC 2365 end 2366 end; 2366 2367 end; 2367 2368 if EnableContact and (mox.Domain = dGround) then … … 2437 2438 Cardinal(Level) shl (2 * pTell); 2438 2439 end; 2439 end; // DiscoverTile2440 end; 2440 2441 2441 2442 function Discover9(Loc, p, Level: integer; … … 2574 2575 begin 2575 2576 RW[pTell].EnemyCity[ecix].Loc := -1; 2576 RW[pTell].Map[Loc] := RW[pTell].Map[Loc] and not fCity 2577 RW[pTell].Map[Loc] := RW[pTell].Map[Loc] and not fCity; 2577 2578 end; 2578 2579 end; … … 2695 2696 begin 2696 2697 Tile1^ := Tile1^ or fInEnemyZoC; 2697 Break 2698 Break; 2698 2699 end; 2699 2700 end; … … 2725 2726 Loc1 := Adjacent[V8]; 2726 2727 if (Loc1 >= 0) and (Loc1 < MapSize) then 2727 RW[p].Map[Loc1] := RW[p].Map[Loc1] or fInEnemyZoC 2728 RW[p].Map[Loc1] := RW[p].Map[Loc1] or fInEnemyZoC; 2728 2729 end; 2729 2730 end; … … 2944 2945 {$IFOPT O-} if OriginLoc <> -2 then 2945 2946 CheckBorders(-2); {$ENDIF} // check: single pass should do! 2946 end; // CheckBorders2947 end; 2947 2948 2948 2949 procedure LogCheckBorders(p, cix, PlayerLosingCity: integer); … … 2976 2977 begin 2977 2978 Fuel := Model[mix].Cap[mcFuel]; 2978 Flags := Flags or unBombsLoaded 2979 Flags := Flags or unBombsLoaded; 2979 2980 end; 2980 2981 Job := jNone; … … 2999 3000 Job := jNone; 3000 3001 Flags := Flags and not(unFortified or unMountainDelay); 3001 Loc0 := Loc 3002 Loc0 := Loc; 3002 3003 end; 3003 3004 if Occupant[Loc0] >= 0 then … … 3014 3015 begin 3015 3016 ZoC := true; 3016 Break 3017 end 3017 Break; 3018 end; 3018 3019 end; 3019 3020 if not Occ then … … 3091 3092 if Enemy >= 0 then 3092 3093 CountLost(p, RW[p].Un[uix].mix, Enemy); 3093 RW[p].Un[uix].Loc := -1 3094 RW[p].Un[uix].Loc := -1; 3094 3095 end; 3095 3096 Occupant[Loc] := -1; … … 3141 3142 (fTerrain or fSpecial or fRiver or nPl shl 27) or fCity; 3142 3143 3143 ChangeTerritory(Loc, p) 3144 ChangeTerritory(Loc, p); 3144 3145 end; 3145 3146 end; … … 3179 3180 Distance(RW[p].City[nearest].Loc, Loc))) then 3180 3181 nearest := cix1; 3181 Home := nearest 3182 Home := nearest; 3182 3183 end 3183 3184 else … … 3374 3375 fPoll) or RealMap[Loc] and (fTerrain or fSpecial or fTerImp or 3375 3376 fRoad or fRR or fCanal or fPoll); 3376 end; // CompleteJob3377 end; 3377 3378 3378 3379 { … … 3595 3596 begin 3596 3597 if execute then 3597 GiveCivilReport(pTarget, pSender) 3598 GiveCivilReport(pTarget, pSender); 3598 3599 end 3599 3600 else if RW[pSender].EnemyReport[pSubject].TurnOfCivilReport < 0 then … … 3610 3611 begin 3611 3612 if execute then 3612 GiveMilReport(pTarget, pSender) 3613 GiveMilReport(pTarget, pSender); 3613 3614 end 3614 3615 else if RW[pSender].EnemyReport[pSubject].TurnOfMilReport < 0 then 3615 3616 result := false 3616 3617 else if execute then 3617 CopyMilReport(pSender, pTarget, pSubject) 3618 CopyMilReport(pSender, pTarget, pSubject); 3618 3619 end; 3619 3620 opMap: … … 3628 3629 begin // agreed treaty end 3629 3630 if execute then 3630 CancelTreaty(pSender, pTarget, false) 3631 CancelTreaty(pSender, pTarget, false); 3631 3632 end 3632 3633 else … … 3732 3733 begin 3733 3734 if execute then 3734 CopyModel(pSender, pTarget, Price - opModel) 3735 CopyModel(pSender, pTarget, Price - opModel); 3735 3736 end 3736 3737 else … … 3747 3748 result:=false 3748 3749 end; } 3749 end 3750 end; 3750 3751 end; 3751 3752 … … 3895 3896 begin // make p1 and p2 know each other 3896 3897 if RW[p1].Treaty[p2] = trNoContact then 3897 IntroduceEnemy(p1, p2) 3898 IntroduceEnemy(p1, p2); 3898 3899 end; 3899 3900 … … 3941 3942 var 3942 3943 i, p1: integer; 3943 3944 3944 begin 3945 3945 if Mode = moPlaying then … … 4032 4032 DiscoverViewAreas(Player); 4033 4033 DiscoverViewAreas(Subject); 4034 Break 4035 end 4034 Break; 4035 end; 4036 4036 end; 4037 4037 4038 4038 sIntSetDevModel: 4039 4039 if Mode < moPlaying then 4040 move(Data, RW[Player].DevModel.Kind, sIntSetDevModel and $F * 4);4040 Move(Data, RW[Player].DevModel.Kind, sIntSetDevModel and $F * 4); 4041 4041 4042 4042 sIntSetModelStatus: … … 4071 4071 RW[Player].EnemyCity[Subject].Status := integer(Data); 4072 4072 end; 4073 4074 end; { case command } 4075 end; { IntServer } 4073 end; 4074 end; 4076 4075 4077 4076 end.
Note:
See TracChangeset
for help on using the changeset viewer.