Changeset 401 for tags/1.4.0/Game.pas


Ignore:
Timestamp:
Jan 6, 2025, 11:12:12 AM (3 days ago)
Author:
chronos
Message:

Merged revision(s) 396-400 from trunk:

  • Fixed: Charts form chart was not drawn on the initial show.
  • Fixed: Run Randomize only once at startup.
  • Fixed: Store current state of RandSeed to game save.
  • Fixed: Load/store RandSeed as its Cardinal type instead of Integer.
  • Modified: Maximum number of player set to 12.
  • Fixed: Standard yellow color is too bright and not readable with white text. Used darker yellow instead.
  • Fixed: Integrity checks for id references loaded from game file.
  • Fixed: Wrong players and units id recalculation during game save causing bad references.
  • Modified: Set new created players as computer.
  • Fixed: Scale charts line width.
  • Fixed: Item form made bigger to avoid showing scrollbars.
  • Fixed: Item form string control made shorter.
Location:
tags/1.4.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tags/1.4.0

  • tags/1.4.0/Game.pas

    r377 r401  
    1111  DefaultPlayerStartUnits = 5;
    1212  MinPlayerCount = 1;
    13   MaxPlayerCount = 8;
     13  MaxPlayerCount = 12;
    1414  GameFileExt = '.xtg';
    1515
     
    529529begin
    530530  with Config do begin
    531     SetValue(DOMString(Path + '/RandSeed'), Integer(StoredRandSeed));
     531    SetValue(DOMString(Path + '/RandSeed'), DOMString(IntToStr(StoredRandSeed)));
    532532    SetValue(DOMString(Path + '/GridType'), Integer(MapType));
    533533    SetValue(DOMString(Path + '/MapImage'), DOMString(MapImageFileName));
     
    558558var
    559559  Value: Integer;
     560  ValueInt64: Int64;
    560561begin
    561562  with Config do begin
    562     StoredRandSeed := GetValue(DOMString(Path + '/RandSeed'), 0);
    563     MapType := TMapType(GetValue(DOMString(Path + '/GridType'), Integer(mtHexagonVertical)));
    564     Map.Size := TPoint.Create(GetValue(DOMString(Path + '/MapSizeX'), 10),
    565       GetValue(DOMString(Path + '/MapSizeY'), 10));
     563    if TryStrToInt64(string(GetValue(DOMString(Path + '/RandSeed'), DOMString(IntToStr(StoredRandSeed)))), ValueInt64) then
     564      StoredRandSeed := ValueInt64;
     565    MapType := TMapType(GetValue(DOMString(Path + '/GridType'), Integer(MapType)));
     566    Map.Size := TPoint.Create(GetValue(DOMString(Path + '/MapSizeX'), Map.Size.X),
     567      GetValue(DOMString(Path + '/MapSizeY'), Map.Size.Y));
    566568    MapImageFileName := string(GetValue(DOMString(Path + '/MapImage'), DOMString(MapImageFileName)));
    567     SymetricMap := GetValue(DOMString(Path + '/SymetricMap'), False);
    568     CyclicMap := GetValue(DOMString(Path + '/CyclicMap'), False);
    569     FogOfWar := GetValue(DOMString(Path + '/FogOfWar'), False);
    570     VoidEnabled := GetValue(DOMString(Path + '/VoidEnabled'), True);
    571     VoidPercentage := GetValue(DOMString(Path + '/VoidPercentage'), 20);
    572     Value := GetValue(DOMString(Path + '/MapShape'), 0);
     569    SymetricMap := GetValue(DOMString(Path + '/SymetricMap'), SymetricMap);
     570    CyclicMap := GetValue(DOMString(Path + '/CyclicMap'), CyclicMap);
     571    FogOfWar := GetValue(DOMString(Path + '/FogOfWar'), FogOfWar);
     572    VoidEnabled := GetValue(DOMString(Path + '/VoidEnabled'), VoidEnabled);
     573    VoidPercentage := GetValue(DOMString(Path + '/VoidPercentage'), VoidPercentage);
     574    Value := GetValue(DOMString(Path + '/MapShape'), Integer(Map.Shape));
    573575    if (Value >= Integer(Low(TMapShape))) and (Value <= Integer(High(TMapShape))) then
    574576      Map.Shape := TMapShape(Value) else Map.Shape := Low(TMapShape);
    575     CityEnabled := GetValue(DOMString(Path + '/CityEnabled'), False);
    576     CityPercentage := GetValue(DOMString(Path + '/CityPercentage'), 10);
    577     BridgeEnabled := GetValue(DOMString(Path + '/BridgeEnabled'), True);
    578     Value := GetValue(DOMString(Path + '/GrowAmount'), Integer(gaBySquareRoot));
     577    CityEnabled := GetValue(DOMString(Path + '/CityEnabled'), CityEnabled);
     578    CityPercentage := GetValue(DOMString(Path + '/CityPercentage'), CityPercentage);
     579    BridgeEnabled := GetValue(DOMString(Path + '/BridgeEnabled'), BridgeEnabled);
     580    Value := GetValue(DOMString(Path + '/GrowAmount'), Integer(GrowAmount));
    579581    if (Value >= Integer(Low(TGrowAmount))) and (Value <= Integer(High(TGrowAmount))) then
    580582      GrowAmount := TGrowAmount(Value) else GrowAmount := Low(TGrowAmount);
    581     Value := GetValue(DOMString(Path + '/GrowCells'), Integer(gcPlayerAll));
     583    Value := GetValue(DOMString(Path + '/GrowCells'), Integer(GrowCells));
    582584    if (Value >= Integer(Low(TGrowCells))) and (Value <= Integer(High(TGrowCells))) then
    583585      GrowCells := TGrowCells(Value) else GrowCells := Low(TGrowCells);
    584     Value := GetValue(DOMString(Path + '/WinObjective'), Integer(woDefeatAllOponents));
     586    Value := GetValue(DOMString(Path + '/WinObjective'), Integer(WinObjective));
    585587    if (Value >= Integer(Low(TWinObjective))) and (Value <= Integer(High(TWinObjective))) then
    586588      WinObjective := TWinObjective(Value) else WinObjective := Low(TWinObjective);
    587     StayAliveForDefinedTurns := GetValue(DOMString(Path + '/StayAliveForDefinedTurns'), 20);
    588     SpecialCaptureCellCount := GetValue(DOMString(Path + '/SpecialCaptureCellCount'), 1);
    589     MaxNeutralUnits := GetValue(DOMString(Path + '/MaxNeutralUnits'), 5);
    590     MaxPower := GetValue(DOMString(Path + '/MaxPower'), 99);
     589    StayAliveForDefinedTurns := GetValue(DOMString(Path + '/StayAliveForDefinedTurns'), StayAliveForDefinedTurns);
     590    SpecialCaptureCellCount := GetValue(DOMString(Path + '/SpecialCaptureCellCount'), SpecialCaptureCellCount);
     591    MaxNeutralUnits := GetValue(DOMString(Path + '/MaxNeutralUnits'), MaxNeutralUnits);
     592    MaxPower := GetValue(DOMString(Path + '/MaxPower'), MaxPower);
    591593    Players.LoadConfig(Config, Path + '/Players');
    592594  end;
     
    608610    RootNode := Doc.DocumentElement;
    609611    with RootNode do begin
    610       StoredRandSeed := ReadInteger(RootNode, 'RandSeed', 0);
     612      StoredRandSeed := ReadInt64(RootNode, 'RandSeed', 0);
    611613      MapType := TMapType(ReadInteger(RootNode, 'MapType', Integer(mtNone)));
    612614      SymetricMap := ReadBoolean(RootNode, 'SymetricMap', False);
     
    672674    AppendChild(RootNode);
    673675    with RootNode do begin
    674       WriteInteger(RootNode, 'RandSeed', Integer(StoredRandSeed));
     676      StoredRandSeed := RandSeed;
     677      WriteInt64(RootNode, 'RandSeed', StoredRandSeed);
    675678      WriteInteger(RootNode, 'MapType', Integer(MapType));
    676679      WriteBoolean(RootNode, 'SymetricMap', SymetricMap);
     
    691694      WriteBoolean(RootNode, 'Running', Running);
    692695      WriteInteger(RootNode, 'CurrentPlayer', CurrentPlayer.Id);
     696
     697      Units.RecalculateItemsId;
     698      Players.RecalculateItemsId;
    693699
    694700      NewNode := OwnerDocument.CreateElement('GameSystem');
     
    910916
    911917  GeneratePlayers := True;
     918  StoredRandSeed := RandSeed;
    912919  MapImageFileName := '';
    913   Randomize;
    914   StoredRandSeed := RandSeed;
    915   InitDefaultPlayers;
    916 
     920  MapType := mtHexagonVertical;
     921  Map.Size := TPoint.Create(10, 10);
     922
     923  CityPercentage := 20;
    917924  VoidEnabled := True;
    918925  VoidPercentage := 20;
    919926  MaxPower := DefaultMaxPower;
    920927  MaxNeutralUnits := Min(4, MaxPower);
    921 
    922   Map.Size := TPoint.Create(3, 3);
     928  BridgeEnabled := True;
     929  MaxNeutralUnits := 5;
     930  MaxPower := 99;
     931  SpecialCaptureCellCount := 1;
     932  StayAliveForDefinedTurns := 20;
     933  WinObjective := woDefeatAllOponents;
     934  GrowCells := gcPlayerAll;
     935  GrowAmount := gaBySquareRoot;
     936
     937  InitDefaultPlayers;
    923938end;
    924939
Note: See TracChangeset for help on using the changeset viewer.