Changeset 74


Ignore:
Timestamp:
Jan 15, 2017, 5:04:32 PM (7 years ago)
Author:
chronos
Message:
  • Modified: Changed registry key path '\SOFTWARE\C-evo'.
  • Modified: Use everythere same root registry key constant AppRegistryKey.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Term.pas

    r73 r74  
    34113411  with Reg do
    34123412  try
    3413     OpenKey('SOFTWARE\cevo\RegVer9', false);
     3413    OpenKey(AppRegistryKey, false);
    34143414    if ValueExists('TileWidth') then xxt := ReadInteger('TileWidth') div 2
    34153415      else xxt := 48;
     
    34233423      else CityRepMask := Cardinal(not chPopIncrease and not chNoGrowthWarning and
    34243424          not chCaptured);
    3425     CloseKey;
    34263425    if OptionChecked and (7 shl 16) = 0 then
    34273426      OptionChecked := OptionChecked or (1 shl 16);
     
    79937992  with Reg do
    79947993  try
    7995     OpenKey('SOFTWARE\cevo\RegVer9', true);
     7994    OpenKey(AppRegistryKey, true);
    79967995    WriteInteger('TileWidth', xxt * 2);
    79977996    WriteInteger('TileHeight', yyt * 2);
     
    79997998    WriteInteger('MapOptionChecked', MapOptionChecked);
    80007999    WriteInteger('CityReport', integer(CityRepMask));
    8001     CloseKey;
    80028000  finally
    80038001    Free;
  • trunk/ScreenTools.pas

    r73 r74  
    215215
    216216  UniFont: array [TFontType] of TFont;
     217  AppRegistryKey: string = '\SOFTWARE\C-evo';
    217218
    218219implementation
     
    15161517procedure UnitInit;
    15171518begin
    1518   Reg := TRegistry.create;
     1519  Reg := TRegistry.Create;
    15191520  with Reg do
    15201521  try
    1521     OpenKey('SOFTWARE\cevo\RegVer9', true);
     1522    OpenKey(AppRegistryKey, True);
    15221523    if ValueExists('Gamma') then
    15231524      Gamma := ReadInteger('Gamma')
     
    16341635  with Reg do
    16351636  try
    1636     OpenKey('SOFTWARE\cevo\RegVer9', true);
     1637    OpenKey(AppRegistryKey, True);
    16371638    WriteString('Locale', LocaleCode);
     1639    WriteInteger('Gamma', Gamma);
    16381640  finally
    16391641    Free;
  • trunk/Start.pas

    r73 r74  
    186186  r0, r1: HRgn;
    187187  Reg: TRegistry;
    188   FirstStart: Boolean;
    189188  Location: TPoint;
    190189begin
    191190  Reg := TRegistry.Create;
    192   FirstStart := not Reg.KeyExists('SOFTWARE\cevo\RegVer9\Start');
    193 
    194   if FirstStart then
    195   with Reg do begin
     191  with Reg do try
    196192    // initialize AI assignment
    197     OpenKey('SOFTWARE\cevo\RegVer9\Start', true);
    198     for I := 0 to nPlOffered - 1 do
    199     begin
     193    OpenKey(AppRegistryKey + '\AI', True);
     194    for I := 0 to nPlOffered - 1 do begin
    200195      if i = 0 then s := ':StdIntf'
    201196        else s := 'StdAI';
    202       WriteString('Control' + IntToStr(i), s);
    203       WriteInteger('Diff' + IntToStr(i), 2);
     197      if not ValueExists('Control' + IntToStr(i)) then
     198        WriteString('Control' + IntToStr(i), s);
     199      if not ValueExists('Diff' + IntToStr(i)) then
     200        WriteInteger('Diff' + IntToStr(i), 2);
    204201    end;
    205202    WriteInteger('MultiControl', 0);
    206     CloseKey;
    207   end;
    208 
    209   with Reg do begin
    210     OpenKey('SOFTWARE\cevo\RegVer9\Start', False);
     203
     204    OpenKey(AppRegistryKey, True);
    211205    if ValueExists('WorldSize') then WorldSize := Reg.ReadInteger('WorldSize')
    212206      else WorldSize := DefaultWorldSize;
     
    221215    if ValueExists('AutoDiff') then AutoDiff := Reg.ReadInteger('AutoDiff')
    222216      else AutoDiff := 1;
    223     CloseKey;
    224   end;
    225 
    226   FullScreen := true;
    227   with Reg do begin
    228     OpenKey('SOFTWARE\cevo\RegVer9', False);
     217
    229218    if ValueExists('ScreenMode') then
    230219      ScreenMode := ReadInteger('ScreenMode')
     
    244233        ResolutionFreq);
    245234    {$ENDIF}
    246     CloseKey;
    247   end;
    248   Reg.Free;
     235  finally
     236    Free;
     237  end;
    249238
    250239  ActionsOffered := [maManual, maCredits, maWeb];
     
    891880
    892881        Reg := TRegistry.Create;
    893         Reg.OpenKey('SOFTWARE\cevo\RegVer9\Start', true);
    894         if Reg.ValueExists('GameCount') then GameCount := Reg.ReadInteger('GameCount')
    895           else GameCount := 0;
    896 
    897         if (AutoDiff < 0) and (bixView[0] = bixNoTerm) then
    898           FileName := 'Round' + IntToStr(GetProcessID())
    899         else
    900         begin
    901           inc(GameCount);
    902           FileName := Format(Phrases.Lookup('GAME'), [GameCount]);
     882        with Reg do
     883        try
     884          OpenKey(AppRegistryKey, true);
     885          if ValueExists('GameCount') then GameCount := ReadInteger('GameCount')
     886            else GameCount := 0;
     887
     888          if (AutoDiff < 0) and (bixView[0] = bixNoTerm) then
     889            FileName := 'Round' + IntToStr(GetProcessID())
     890          else begin
     891            inc(GameCount);
     892            FileName := Format(Phrases.Lookup('GAME'), [GameCount]);
     893          end;
     894
     895          // save settings and AI assignment
     896          if Page = pgStartRandom then begin
     897            WriteInteger('WorldSize', WorldSize);
     898            WriteInteger('LandMass', StartLandMass);
     899
     900            OpenKey(AppRegistryKey + '\AI', True);
     901            if AutoDiff < 0 then
     902              for i := 0 to nPlOffered - 1 do begin
     903                if bixView[i] = -1 then
     904                  Reg.WriteString('Control' + IntToStr(i), '')
     905                else Reg.WriteString('Control' + IntToStr(i),
     906                  Brain[bixView[i]].FileName);
     907                WriteInteger('Diff' + IntToStr(i), Difficulty[i]);
     908              end;
     909            WriteInteger('MultiControl', MultiControl);
     910          end;
     911
     912          OpenKey(AppRegistryKey, True);
     913          if AutoDiff > 0 then
     914          begin
     915            WriteString('DefaultAI', Brain[bixDefault].FileName);
     916            SlotAvailable := 0; // bixView will be invalid hereafter
     917            bixView[0] := bixTerm;
     918            Difficulty[0] := PlayerAutoDiff[AutoDiff];
     919            for i := 1 to nPl - 1 do
     920              if (Page = pgStartRandom) and (i <= AutoEnemies) or
     921                (Page = pgStartMap) and (i < nMapStartPositions) then begin
     922                if AutoDiff = 1 then bixView[i] := bixBeginner
     923                  else bixView[i] := bixDefault;
     924                Difficulty[i] := EnemyAutoDiff[AutoDiff];
     925              end  else bixView[i] := -1;
     926          end else begin
     927            for i := 6 to 8 do
     928              if (bixView[0] <> bixNoTerm) and (MultiControl and (1 shl i) <> 0)
     929              then begin
     930                bixView[i + 3] := bixView[i];
     931                Difficulty[i + 3] := Difficulty[i];
     932                bixView[i + 6] := bixView[i];
     933                Difficulty[i + 6] := Difficulty[i];
     934              end else begin
     935                bixView[i + 3] := -1;
     936                bixView[i + 6] := -1;
     937              end
     938          end;
     939
     940          WriteInteger('AutoDiff', AutoDiff);
     941          WriteInteger('AutoEnemies', AutoEnemies);
     942          WriteInteger('MaxTurn', MaxTurn);
     943          WriteInteger('GameCount', GameCount);
     944        finally
     945          Free;
    903946        end;
    904 
    905         // save settings and AI assignment
    906         if Page = pgStartRandom then
    907         begin
    908           Reg.WriteInteger('WorldSize', WorldSize);
    909           Reg.WriteInteger('LandMass', StartLandMass);
    910           if AutoDiff < 0 then
    911             for i := 0 to nPlOffered - 1 do
    912             begin
    913               if bixView[i] = -1 then
    914                 Reg.WriteString('Control' + IntToStr(i), '')
    915               else
    916                 Reg.WriteString('Control' + IntToStr(i),
    917                   Brain[bixView[i]].FileName);
    918               Reg.WriteInteger('Diff' + IntToStr(i), Difficulty[i]);
    919             end;
    920           Reg.WriteInteger('MultiControl', MultiControl);
    921         end;
    922 
    923         if AutoDiff > 0 then
    924         begin
    925           Reg.WriteString('DefaultAI', Brain[bixDefault].FileName);
    926           SlotAvailable := 0; // bixView will be invalid hereafter
    927           bixView[0] := bixTerm;
    928           Difficulty[0] := PlayerAutoDiff[AutoDiff];
    929           for i := 1 to nPl - 1 do
    930             if (Page = pgStartRandom) and (i <= AutoEnemies) or
    931               (Page = pgStartMap) and (i < nMapStartPositions) then
    932             begin
    933               if AutoDiff = 1 then
    934                 bixView[i] := bixBeginner
    935               else
    936                 bixView[i] := bixDefault;
    937               Difficulty[i] := EnemyAutoDiff[AutoDiff];
    938             end
    939             else
    940               bixView[i] := -1;
    941         end
    942         else
    943         begin
    944           for i := 6 to 8 do
    945             if (bixView[0] <> bixNoTerm) and (MultiControl and (1 shl i) <> 0)
    946             then
    947             begin
    948               bixView[i + 3] := bixView[i];
    949               Difficulty[i + 3] := Difficulty[i];
    950               bixView[i + 6] := bixView[i];
    951               Difficulty[i + 6] := Difficulty[i];
    952             end
    953             else
    954             begin
    955               bixView[i + 3] := -1;
    956               bixView[i + 6] := -1;
    957             end
    958         end;
    959 
    960         Reg.WriteInteger('AutoDiff', AutoDiff);
    961         Reg.WriteInteger('AutoEnemies', AutoEnemies);
    962         Reg.WriteInteger('MaxTurn', MaxTurn);
    963         Reg.WriteInteger('GameCount', GameCount);
    964         Reg.closekey;
    965         Reg.Free;
    966947
    967948        StartNewGame(DataDir + 'Saved' + DirectorySeparator, FileName + '.cevo', MapFileName,
     
    976957      begin
    977958        Reg := TRegistry.Create;
    978         Reg.OpenKey('SOFTWARE\cevo\RegVer9\Start', true);
    979         if Reg.ValueExists('MapCount') then
    980           MapCount := Reg.ReadInteger('MapCount')
    981           else  MapCount := 0;
    982         inc(MapCount);
    983         Reg.WriteInteger('MapCount', MapCount);
    984         Reg.closekey;
    985         Reg.Free;
     959        with Reg do
     960        try
     961          OpenKey(AppRegistryKey, True);
     962          if ValueExists('MapCount') then MapCount := ReadInteger('MapCount')
     963            else MapCount := 0;
     964          Inc(MapCount);
     965          WriteInteger('MapCount', MapCount);
     966        finally
     967          Free;
     968        end;
    986969        MapFileName := Format(Phrases.Lookup('MAP'), [MapCount]) + '.cevo map';
    987970        EditMap(MapFileName, lxpre[WorldSize], lypre[WorldSize], StartLandMass);
     
    14181401          begin // restore AI assignment of last start
    14191402            Reg := TRegistry.Create;
    1420             Reg.OpenKey('SOFTWARE\cevo\RegVer9\Start', false);
    1421             for p1 := 0 to nPlOffered - 1 do
    1422             begin
    1423               bixView[p1] := -1;
    1424               s := Reg.ReadString('Control' + IntToStr(p1));
    1425               Difficulty[p1] := Reg.ReadInteger('Diff' + IntToStr(p1));
    1426               if s <> '' then
    1427                 for j := 0 to nBrain - 1 do
    1428                   if AnsiCompareFileName(s, Brain[j].FileName) = 0 then
    1429                     bixView[p1] := j;
     1403            with Reg do
     1404            try
     1405              OpenKey(AppRegistryKey + '\AI', True);
     1406              for p1 := 0 to nPlOffered - 1 do begin
     1407                bixView[p1] := -1;
     1408                s := ReadString('Control' + IntToStr(p1));
     1409                Difficulty[p1] := ReadInteger('Diff' + IntToStr(p1));
     1410                if s <> '' then
     1411                  for j := 0 to nBrain - 1 do
     1412                    if AnsiCompareFileName(s, Brain[j].FileName) = 0 then
     1413                      bixView[p1] := j;
     1414              end;
     1415              MultiControl := Reg.ReadInteger('MultiControl');
     1416            finally
     1417              Free;
    14301418            end;
    1431             MultiControl := Reg.ReadInteger('MultiControl');
    1432             Reg.closekey;
    1433             Reg.Free;
    14341419          end
    14351420          else
Note: See TracChangeset for help on using the changeset viewer.