Changeset 592 for trunk


Ignore:
Timestamp:
Aug 10, 2024, 3:40:04 PM (3 months ago)
Author:
chronos
Message:
  • Fixed: Avoided more GTK2 chrashes.
  • Fixed: Build StdAI with O1 optimization level to avoid crash.
  • Modified: Code cleanup.
Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/AI Template/AI.pas

    r582 r592  
    185185          begin // tile is exploited, but not the city own tile -- check if improvable
    186186            RadiusLoc := Radius[V21];
    187             assert((RadiusLoc >= 0) and (RadiusLoc < MapSize));
     187            Assert((RadiusLoc >= 0) and (RadiusLoc < MapSize));
    188188            if (RadiusLoc >= 0) and (RadiusLoc < MapSize) then
    189189            begin
  • trunk/AI Template/CustomAI.pas

    r583 r592  
    687687  Result := True;
    688688  // always returns true so that it can be used like
    689   // "assert(DebugMessage(...));" -> not compiled in release build
     689  // "Assert(DebugMessage(...));" -> not compiled in release build
    690690end;
    691691
     
    696696  Result := True;
    697697  // always returns true so that it can be used like
    698   // "assert(SetDebugMap(...));" -> not compiled in release build
     698  // "Assert(SetDebugMap(...));" -> not compiled in release build
    699699end;
    700700
  • trunk/AI Template/ToolAI.pas

    r582 r592  
    293293procedure TToolAI.JobAssignment_AddUnit(uix: integer);
    294294begin
    295   assert(MyModel[MyUnit[uix].mix].Kind in [mkSettler, mkSlaves]);
     295  Assert(MyModel[MyUnit[uix].mix].Kind in [mkSettler, mkSlaves]);
    296296  JobLocOfSettler[uix] := ToAssign;
    297297end;
     
    598598  MoveCost, RecoverCost: integer;
    599599begin
    600   assert(((FromTile and fTerrain <= fMountains) or (FromTile and fTerrain = fUNKNOWN)) and
     600  Assert(((FromTile and fTerrain <= fMountains) or (FromTile and fTerrain = fUNKNOWN)) and
    601601    ((ToTile and fTerrain <= fMountains) or (ToTile and fTerrain = fUNKNOWN)));
    602602  // do not pass location codes for FromTile and ToTile!
     
    775775  end
    776776
    777   else {if MoveStyle<msSpy+$10000000 then}
     777  else {if MoveStyle < msSpy + $10000000 then}
    778778  begin // spies
    779779    if (ToTile + 1) and fTerrain < fGrass + 1 then
     
    834834  // todo: check exit condition, e.g. whether destination reached
    835835
    836   Reached[Loc]:=true;
     836  Reached[Loc]:=True;
    837837  V8_to_Loc(Loc, Adjacent);
    838838  for V8:=0 to 7 do
     
    844844          Pile.Put(NextLoc, NextTime+RecoverTurns*$1000);
    845845        csForbiddenTile:
    846           Reached[NextLoc]:=true; // don't check moving there again
     846          Reached[NextLoc]:=True; // don't check moving there again
    847847        csCheckTerritory:
    848848          if RO.Territory[NextLoc]=RO.Territory[Loc] then
     
    954954  i: integer;
    955955begin
    956   assert(not InitComplete); // call order violation!
     956  Assert(not InitComplete); // call order violation!
    957957  if Map[MyUnit[uix].Loc] and fTerrain < fGrass then exit;
    958958  for i := 0 to nTransportLoad - 1 do
    959     if uix = uixTransportLoad[i] then exit;
     959    if uix = uixTransportLoad[i] then Exit;
    960960  uixTransportLoad[nTransportLoad] := uix;
    961961  Inc(nTransportLoad);
     
    966966  MoveStyle: integer;
    967967begin
    968   assert(not InitComplete); // call order violation!
    969   assert(MyModel[MyUnit[uix].mix].Cap[mcSeaTrans] > 0);
     968  Assert(not InitComplete); // call order violation!
     969  Assert(MyModel[MyUnit[uix].mix].Cap[mcSeaTrans] > 0);
    970970  TransportAvailable[uix] := 1;
    971971  with MyModel[MyUnit[uix].mix] do
     
    983983procedure TToolAI.SeaTransport_AddDestination(Loc: integer);
    984984begin
    985   assert(not InitComplete); // call order violation!
     985  Assert(not InitComplete); // call order violation!
    986986  Pile.Put(Loc, $800);
    987987  HaveDestinations := True;
     
    993993  Adjacent: TVicinity8Loc;
    994994begin
    995   assert(not InitComplete); // call order violation!
     995  Assert(not InitComplete); // call order violation!
    996996  InitComplete := True;
    997997  if HaveDestinations then
     
    10401040  GroupComplete: array[0..lxmax * lymax - 1] of boolean;
    10411041begin
    1042   assert(InitComplete); // call order violation!
     1042  Assert(InitComplete); // call order violation!
    10431043
    10441044  if HaveDestinations and (nTransportLoad > 0) then
     
    10541054          if (abs(a) <= 1) and (abs(b) <= 1) then
    10551055          begin
    1056             assert((a <> 0) or (b <> 0));
     1056            Assert((a <> 0) or (b <> 0));
    10571057            Inc(GroupCount);
    10581058          end;
     
    10901090    for tuix := 0 to nTransportLoad - 1 do
    10911091    begin
    1092       assert(Map[MyUnit[uixTransportLoad[tuix]].Loc] and fTerrain >= fGrass);
     1092      Assert(Map[MyUnit[uixTransportLoad[tuix]].Loc] and fTerrain >= fGrass);
    10931093      f := Formation[MyUnit[uixTransportLoad[tuix]].Loc];
    10941094      if f >= 0 then Inc(Arrived[f]);
  • trunk/AI/StdAI/AI.pas

    r549 r592  
    289289    end;
    290290  end;
    291   //!!!assert(Quality>0);
     291  //!!!Assert(Quality > 0);
    292292end;
    293293
  • trunk/AI/StdAI/CustomAI.pas

    r531 r592  
    687687  Result := True;
    688688  // always returns true so that it can be used like
    689   // "assert(DebugMessage(...));" -> not compiled in release build
     689  // "Assert(DebugMessage(...));" -> not compiled in release build
    690690end;
    691691
     
    696696  Result := True;
    697697  // always returns true so that it can be used like
    698   // "assert(SetDebugMap(...));" -> not compiled in release build
     698  // "Assert(SetDebugMap(...));" -> not compiled in release build
    699699end;
    700700
  • trunk/AI/StdAI/StdAI.lpi

    r289 r592  
    22<CONFIG>
    33  <ProjectOptions>
    4     <Version Value="11"/>
     4    <Version Value="12"/>
    55    <PathDelim Value="\"/>
    66    <General>
     
    99        <MainUnitHasCreateFormStatements Value="False"/>
    1010        <MainUnitHasTitleStatement Value="False"/>
     11        <MainUnitHasScaledStatement Value="False"/>
     12        <CompatibilityMode Value="True"/>
    1113      </Flags>
    1214      <SessionStorage Value="InProjectDir"/>
    13       <MainUnit Value="0"/>
    1415      <Title Value="StdAI"/>
    1516      <UseAppBundle Value="False"/>
     
    4041            </SyntaxOptions>
    4142          </Parsing>
    42           <CodeGeneration>
    43             <Optimizations>
    44               <OptimizationLevel Value="3"/>
    45             </Optimizations>
    46           </CodeGeneration>
    4743          <Linking>
    4844            <Debugging>
     
    6965    <RunParams>
    7066      <FormatVersion Value="2"/>
    71       <Modes Count="0"/>
    7267    </RunParams>
    7368    <RequiredPackages Count="1">
  • trunk/AI/StdAI/ToolAI.pas

    r548 r592  
    652652  MoveCost, RecoverCost: Integer;
    653653begin
    654   //IsCapture:=true;
     654  //IsCapture := True;
    655655  Assert(((FromTile and fTerrain <= fMountains) or (FromTile and
    656656    fTerrain = fUNKNOWN)) and ((ToTile and fTerrain <= fMountains) or
  • trunk/Brain.pas

    r589 r592  
    8484    with Picture.Canvas do begin
    8585      Brush.Color := $904830;
    86       FillRect(Rect(0, 0, 64, 64));
     86      FillRect(Rect(0, 0, Picture.Width, Picture.Height));
    8787      Font.Assign(UniFont[ftTiny]);
    8888      Font.Style := [];
    8989      Font.Color := $5FDBFF;
    9090      TextSize := TextExtent(FileName);
    91       TextOut(32 - TextSize.Width div 2, 32 - TextSize.Height div 2, FileName);
     91      TextOut((Picture.Width - TextSize.Width) div 2,
     92        (Picture.Height - TextSize.Height) div 2, FileName);
    9293    end;
    9394  end;
     
    110111  Flags := fMultiple;
    111112  Client := nil;
    112   Initialized := false;
     113  Initialized := False;
    113114  ServerVersion := 0;
    114115  if not FileExists(AIFileName) then
     
    118119  while not EOF(T) do
    119120  begin
    120     ReadLn(T, s);
    121     s := trim(s);
     121    ReadLn(T, S);
     122    S := Trim(s);
    122123    if Pos(' ', S) > 0 then begin
    123124      Key := Copy(S, 1, Pos(' ', S) - 1);
     
    160161    {$ENDIF}{$ENDIF}
    161162    else if Key = '#GAMEVERSION' then
    162       for i := 1 to Length(Value) do
    163         case Value[i] of
     163      for I := 1 to Length(Value) do
     164        case Value[I] of
    164165          '0' .. '9':
    165166            ServerVersion := ServerVersion and $FFFF00 + ServerVersion and
    166               $FF * 10 + ord(Value[i]) - 48;
     167              $FF * 10 + Ord(Value[I]) - 48;
    167168          '.':
    168169          ServerVersion := ServerVersion shl 8;
  • trunk/Database.pas

    r591 r592  
    22832283      Exit;
    22842284    IntServer(sIntTellAboutNation, p1, p2, nil^);
    2285     // NewContact[p1,p2]:=true
     2285    // NewContact[p1, p2] := True
    22862286  end;
    22872287
  • trunk/GameServer.pas

    r591 r592  
    331331        NullOffer.nCost := 0;
    332332        Server(scDipOffer, pDipActive, 0, NullOffer);
    333       end
    334     end
     333      end;
     334    end;
    335335end;
    336336
     
    10311031    with RW[pTurn].City[cix] do
    10321032      if Loc >= 0 then begin
    1033         // if SavedResourceWeights[cix] <> ResourceWeights then Result := true;
     1033        // if SavedResourceWeights[cix] <> ResourceWeights then Result := True;
    10341034        if SavedTiles[cix] <> Tiles then begin
    10351035          Result := True;
  • trunk/LocalPlayer/CityScreen.pas

    r550 r592  
    14721472          IconKind := mikImp;
    14731473          IconIndex := NewProject and cpIndex;
     1474          Gtk2Fix;
    14741475          ShowModal;
    14751476          QueryOk := ModalResult = mrOK;
     
    15121513        (MyCity[cix].Size < 3) and
    15131514        ((MyModel[NewProject and cpIndex].Kind = mkSlaves) or
    1514         (NewProject and cpConscripts <> 0))) then
    1515         if SimpleQuery(mkYesNo, Phrases.Lookup('EMIGRATE'), 'MSG_DEFAULT') <> mrOK
    1516         then
    1517           NewProject := NewProject or cpDisbandCity;
     1515        (NewProject and cpConscripts <> 0))) then begin
     1516          Gtk2Fix;
     1517          if SimpleQuery(mkYesNo, Phrases.Lookup('EMIGRATE'), 'MSG_DEFAULT') <> mrOK then
     1518            NewProject := NewProject or cpDisbandCity;
     1519        end;
    15181520      Server(sSetCityProject, Me, cix, NewProject);
    15191521      C.Project := MyCity[cix].Project;
  • trunk/LocalPlayer/ClientTools.pas

    r549 r592  
    601601              // TODO: What is this assert for?
    602602              // Need to optimize city tiles but CheckOnly true?
    603               //assert(false)
     603              //Assert(false)
    604604            end
    605605            else
  • trunk/LocalPlayer/Nego.pas

    r558 r592  
    875875          InputDlg.EditInput.Text := '';
    876876          InputDlg.CenterToRect(BoundsRect);
     877          Gtk2Fix;
    877878          InputDlg.ShowModal;
    878879          if InputDlg.ModalResult <> mrOK then
  • trunk/LocalPlayer/Term.pas

    r580 r592  
    75737573      or (MyRO.TestFlags and (tfAllTechs or tfUncover or tfAllContact) <> 0);
    75747574    mEUnitStat.Enabled := MyRO.nEnemyModel > 0;
    7575     { mWonders.Enabled:= false;
    7576       for I:=0 to nWonder - 1 do if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then
    7577       mWonders.Enabled:=True; }
     7575    { mWonders.Enabled:= False;
     7576      for I := 0 to nWonder - 1 do if MyRO.Wonder[I].CityID <> WonderNotBuiltYet then
     7577      mWonders.Enabled := True; }
    75787578    mDiagram.Enabled := MyRO.Turn >= 2;
    75797579    mShips.Enabled := False;
  • trunk/Packages/Common/StopWatch.pas

    r456 r592  
    2222    function GetElapsed: string;
    2323  public
    24     constructor Create(const startOnCreate : Boolean = False) ;
     24    constructor Create(const startOnCreate: Boolean = False) ;
    2525    procedure Start;
    2626    procedure Stop;
     
    3535implementation
    3636
    37 constructor TStopWatch.Create(const startOnCreate : boolean = false) ;
     37constructor TStopWatch.Create(const startOnCreate: Boolean = False) ;
    3838begin
    3939  inherited Create;
  • trunk/Packages/DpiControls/Dpi.StdCtrls.pas

    r568 r592  
    158158    property ItemHeight: Integer read GetItemHeight write SetItemHeight;
    159159    property IntegralHeight: Boolean read GetIntegralHeight write SetIntegralHeight default False;
    160     property ExtendedSelect: Boolean read GetExtendedSelect write SetExtendedSelect default true;
     160    property ExtendedSelect: Boolean read GetExtendedSelect write SetExtendedSelect default True;
    161161    property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle default bsNone;
    162162    property Visible;
Note: See TracChangeset for help on using the changeset viewer.