Changeset 663
- Timestamp:
- Jul 5, 2025, 10:57:12 AM (3 hours ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/AI/StdAI/CustomAI.pas
r592 r663 177 177 178 178 procedure Loc_to_ab(Loc0, Loc: Integer; var A, B: Integer); 179 {$IFDEF FPC}// freepascal180 179 var 181 180 dx, dy: Integer; … … 187 186 B := (dy - dx) div 2; 188 187 end; 189 190 {$ELSE}// delphi191 register;192 asm193 push ebx194 195 // calculate196 push ecx197 div Byte ptr [G]198 xor ebx,ebx199 mov bl,ah // ebx:=Loc0 mod G.lx200 mov ecx,eax201 and ecx,$000000FF // ecx:=Loc0 div G.lx202 mov eax,edx203 div Byte ptr [G]204 xor edx,edx205 mov dl,ah // edx:=Loc mod G.lx206 and eax,$000000FF // eax:=Loc div G.lx207 sub edx,ebx // edx:=Loc mod G.lx-Loc0 mod G.lx208 mov ebx,eax209 sub ebx,ecx // ebx:=dy210 and eax,1211 and ecx,1212 add edx,edx213 add eax,edx214 sub eax,ecx // eax:=dx, not normalized215 pop ecx216 217 // normalize218 mov edx,dword ptr [G]219 cmp eax,edx220 jl @A221 sub eax,edx222 sub eax,edx223 jmp @ok224 @A:225 neg edx226 cmp eax,edx227 jnl @ok228 sub eax,edx229 sub eax,edx230 231 // return results232 @ok:233 mov edx,ebx234 sub edx,eax235 add eax,ebx236 sar edx,1 // edx:=b237 mov ebx,[B]238 mov [ebx],edx239 sar eax,1 // eax:=a240 mov [A],eax241 242 pop ebx243 end;244 {$ENDIF}245 188 246 189 procedure ab_to_V8(A, B: Integer; var V8: Integer); -
trunk/AI/StdAI/ToolAI.pas
r592 r663 613 613 dGround: 614 614 begin 615 Inc(Result, (50 + (Speed - 150) * 13 shr 7) shl 8); // HeavyCost615 Inc(Result, (50 + (Speed - 150) * 13 shr 7) shl 8); // HeavyCost 616 616 if RO.Wonder[woShinkansen].EffectiveOwner <> Me then 617 617 Inc(Result, Speed * (4 * 1311) shr 17); // RailCost 618 if (RO.Wonder[woGardens].EffectiveOwner <> Me) or619 (Kind = mkSettler) and (Speed >= 200) then618 if (RO.Wonder[woGardens].EffectiveOwner <> Me) and 619 not ((Kind = mkSettler) and (Speed >= 200)) then 620 620 Inc(Result, msHostile); 621 621 if Kind = mkDiplomat then -
trunk/UnitProcessing.pas
r558 r663 21 21 Worked: array [0 .. nPl - 1] of Integer; { settler work statistics } 22 22 23 23 // Moving/Combat 24 24 function HostileDamage(P, mix, Loc, MP: Integer): Integer; 25 25 function CalculateMove(P, uix, ToLoc, MoveLength: Integer; TestOnly: Boolean; … … 79 79 ToWork: ^TToWorkList; { work left for each tile and job } 80 80 81 82 83 84 81 { 82 Moving/Combat 83 ____________________________________________________________________ 84 } 85 85 function HostileDamage(P, mix, Loc, MP: Integer): Integer; 86 86 var … … 97 97 begin 98 98 Assert((Tile and fTerImp <> tiIrrigation) and (Tile and fTerImp <> tiFarm)); 99 Result := (DesertThurst * MP - 1) div RW[P].Model[mix].Speed + 1 99 Result := (DesertThurst * MP - 1) div RW[P].Model[mix].Speed + 1; 100 100 end 101 101 else if Tile and fTerrain = fArctic then 102 102 begin 103 103 Assert((Tile and fTerImp <> tiIrrigation) and (Tile and fTerImp <> tiFarm)); 104 Result := (ArcticThurst * MP - 1) div RW[P].Model[mix].Speed + 1 104 Result := (ArcticThurst * MP - 1) div RW[P].Model[mix].Speed + 1; 105 105 end 106 106 else … … 346 346 begin 347 347 Result := eOK; 348 MoveInfo.MountainDelay := True 348 MoveInfo.MountainDelay := True; 349 349 end; 350 350 end; … … 748 748 Recovery := FastRecovery { city has baracks/shipyard/airport } 749 749 else 750 Recovery := CityRecovery 750 Recovery := CityRecovery; 751 751 end 752 752 else if (RealMap[Loc] and fTerrain >= fGrass) and (Model[mix].Domain <> dAir) … … 778 778 gmaAlpine = 8; 779 779 var 780 I, FromLoc, EndLoc, T, T1, maxmov, initmov, Loc, Loc1, FromTile, ToTile, V8,780 I, FromLoc, EndLoc, T, T1, MaxMov, InitMov, Loc, Loc1, FromTile, ToTile, V8, 781 781 MoveInfo, HeavyCost, RailCost, MoveCost, AddDamage, MaxDamage, 782 782 MovementLeft: Integer; … … 867 867 Damage[FromLoc] := 0; 868 868 Q := TIPQ.Create(MapSize); 869 Q.Put(FromLoc, ( maxmov - RW[P].Un[uix].Movement) shl 8);869 Q.Put(FromLoc, (MaxMov - RW[P].Un[uix].Movement) shl 8); 870 870 while Q.Get(Loc, T) do 871 871 begin … … 955 955 3: 956 956 begin 957 MoveCost := maxmov;957 MoveCost := MaxMov; 958 958 MountainDelay := True; 959 959 end; … … 967 967 if V8 and 1 <> 0 then 968 968 AddDamage := ((DesertThurst * 3) * MoveCost - 1) 969 div maxmov + 1969 div MaxMov + 1 970 970 else 971 971 AddDamage := ((DesertThurst * 2) * MoveCost - 1) 972 div maxmov + 1972 div MaxMov + 1; 973 973 end 974 974 else if ToTile and (fTerrain or fCity or fRiver or fCanal) = fArctic … … 977 977 if V8 and 1 <> 0 then 978 978 AddDamage := ((ArcticThurst * 3) * MoveCost - 1) 979 div maxmov + 1979 div MaxMov + 1 980 980 else 981 981 AddDamage := ((ArcticThurst * 2) * MoveCost - 1) 982 div maxmov + 1982 div MaxMov + 1; 983 983 end; 984 end 985 else 986 MoveCost := -1; 987 984 end else MoveCost := -1; 988 985 end; 989 986 … … 998 995 fOwned) // assume ship/airplane is transport -- load! 999 996 or (MoveCost >= 0) and (FromTile and fTerrain < fGrass)) then 1000 MoveCost := maxmov; // transport load or unload997 MoveCost := MaxMov; // transport load or unload 1001 998 1002 999 if MoveCost >= 0 then 1003 1000 begin { valid move } 1004 MovementLeft := maxmov - T shr 8 and $FFF - MoveCost;1001 MovementLeft := MaxMov - T shr 8 and $FFF - MoveCost; 1005 1002 if (MovementLeft < 0) or ((MoveCost = 0) and (MovementLeft = 0)) 1006 1003 then … … 1011 1008 if FromTile and (fTerrain or fCity or fRiver or fCanal or 1012 1009 fSpecial1 { Oasis } ) = fDesert then 1013 Inc(AddDamage, (DesertThurst * ( maxmov - T shr 8 and $FFF) -1014 1) div maxmov + 1)1010 Inc(AddDamage, (DesertThurst * (MaxMov - T shr 8 and $FFF) - 1011 1) div MaxMov + 1) 1015 1012 else if FromTile and (fTerrain or fCity or fRiver or fCanal) = fArctic 1016 1013 then 1017 Inc(AddDamage, (ArcticThurst * ( maxmov - T shr 8 and $FFF) -1018 1) div maxmov + 1);1019 1020 T1 := T and $7FF000FF + $100000 + ( initmov + MoveCost) shl 8;1014 Inc(AddDamage, (ArcticThurst * (MaxMov - T shr 8 and $FFF) - 1015 1) div MaxMov + 1); 1016 1017 T1 := T and $7FF000FF + $100000 + (InitMov + MoveCost) shl 8; 1021 1018 end 1022 1019 else … … 1062 1059 mod (2 * lx) - lx; 1063 1060 A.dy[I] := Loc div lx - From[Loc] div lx; 1064 end 1061 end; 1065 1062 end; 1066 1063 Loc := From[Loc]; 1067 1064 end; 1068 A.MaxHostile_MovementLeft := maxmov - Time[EndLoc] shr 8 and $FFF;1065 A.MaxHostile_MovementLeft := MaxMov - Time[EndLoc] shr 8 and $FFF; 1069 1066 if A.nStep > 25 then 1070 1067 A.nStep := 25; 1071 Result := eOK 1068 Result := eOK; 1072 1069 end 1073 1070 else … … 1412 1409 for uix1 := 0 to RW[P].nUn - 1 do 1413 1410 if (RW[P].Un[uix1].Loc = Loc) and (RW[P].Un[uix1].Job = j0) then 1414 RW[P].Un[uix1].Job := jNone 1411 RW[P].Un[uix1].Job := jNone; 1415 1412 end 1416 1413 else … … 1421 1418 Health := Health - HostileDamage(P, mix, Loc, Movement); 1422 1419 Movement := 0; 1423 end 1424 end 1420 end; 1421 end; 1425 1422 end; 1426 1423
Note:
See TracChangeset
for help on using the changeset viewer.