Ignore:
Timestamp:
Mar 9, 2021, 9:19:49 AM (4 years ago)
Author:
chronos
Message:
  • Modified: Synced code with current trunk version.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/GameServer.pas

    r266 r303  
    77
    88uses
    9   UDpiControls, Protocol, Database, dynlibs, Platform, dateutils, fgl, LazFileUtils, Graphics;
     9  UDpiControls, Protocol, Database, dynlibs, Platform, dateutils, fgl, LazFileUtils,
     10  Graphics;
    1011
    1112const
    12   Version = $010200;
     13  Version = $010300;
    1314  FirstAICompatibleVersion = $000D00;
    1415  FirstBookCompatibleVersion = $010103;
     
    561562  MapFile := TFileStream.Create(GetMapsDir + DirectorySeparator + FileName,
    562563    fmCreate or fmShareExclusive);
    563   MapFile.Position := 0;
    564   s := 'cEvoMap'#0;
    565   MapFile.write(s[1], 8); { file id }
    566   i := 0;
    567   MapFile.write(i, 4); { format id }
    568   MapFile.write(MaxTurn, 4);
    569   MapFile.write(lx, 4);
    570   MapFile.write(ly, 4);
    571   MapFile.write(RealMap, MapSize * 4);
    572   MapFile.Free;
     564  try
     565    MapFile.Position := 0;
     566    s := 'cEvoMap'#0;
     567    MapFile.write(s[1], 8); { file id }
     568    i := 0;
     569    MapFile.write(i, 4); { format id }
     570    MapFile.write(MaxTurn, 4);
     571    MapFile.write(lx, 4);
     572    MapFile.write(ly, 4);
     573    MapFile.write(RealMap, MapSize * 4);
     574  finally
     575    FreeAndNil(MapFile);
     576  end;
    573577end;
    574578
     
    613617      result := true;
    614618    end;
    615     MapFile.Free;
     619    FreeAndNil(MapFile);
    616620  except
    617621    if MapFile <> nil then
    618       MapFile.Free;
     622      FreeAndNil(MapFile);
    619623  end;
    620624end;
     
    694698  else
    695699    CL.SaveToFile(LogFile);
    696   LogFile.Free;
     700  FreeAndNil(LogFile);
    697701  if auto then
    698702  begin
     
    721725        Brains.GetByKind(btAI, AIBrains);
    722726        bix[p1] := AIBrains[DelphiRandom(AIBrains.Count)];
    723         AIBrains.Free;
     727        FreeAndNil(AIBrains);
    724728      end
    725729    else
     
    863867    Human := 0;
    864868    for p1 := 0 to nPl - 1 do
    865       if bix[p1].Kind = btTerm then
     869      if Assigned(bix[p1]) and (bix[p1].Kind = btTerm) then
    866870        inc(Human, 1 shl p1);
    867871    InitMapGame(Human);
     
    992996  CityProcessing.ReleaseGame;
    993997  Database.ReleaseGame;
    994   CL.Free;
     998  FreeAndNil(CL);
    995999end;
    9961000
     
    11901194    CL.LoadFromFile(LogFile);
    11911195  end;
    1192   LogFile.Free;
     1196  FreeAndNil(LogFile);
    11931197  if not result then
    11941198    Exit;
     
    46044608begin
    46054609  FreeAndNil(Picture);
    4606   inherited Destroy;
     4610  inherited;
    46074611end;
    46084612
Note: See TracChangeset for help on using the changeset viewer.