DEADSOFTWARE

Console: Automatically save user-defined binds
authorStas'M <x86corez@gmail.com>
Thu, 25 Jul 2019 17:06:57 +0000 (20:06 +0300)
committerStas'M <x86corez@gmail.com>
Thu, 25 Jul 2019 17:06:57 +0000 (20:06 +0300)
src/game/g_console.pas
src/game/g_menu.pas

index fd7c36612ffca0daf6f7ad87daf7ba292502ae6c..6f02743bb8f73df2221dee5749139db5d82dcdee 100644 (file)
@@ -48,6 +48,7 @@ procedure g_Console_Clear;
 function  g_Console_CommandBlacklisted (C: AnsiString): Boolean;
 procedure g_Console_ReadConfig (filename: String);
 procedure g_Console_WriteConfig (filename: String);
 function  g_Console_CommandBlacklisted (C: AnsiString): Boolean;
 procedure g_Console_ReadConfig (filename: String);
 procedure g_Console_WriteConfig (filename: String);
+procedure g_Console_WriteGameConfig;
 
 function  g_Console_Interactive: Boolean;
 function  g_Console_Action (action: Integer): Boolean;
 
 function  g_Console_Interactive: Boolean;
 function  g_Console_Action (action: Integer): Boolean;
@@ -77,6 +78,7 @@ var
   gChatTeam: Boolean = false;
   gAllowConsoleMessages: Boolean = true;
   gJustChatted: Boolean = false; // ÷òîáû àäìèí â èíòåðå ÷àòÿñü íå ïðîìàòûâàë ñòàòèñòèêó
   gChatTeam: Boolean = false;
   gAllowConsoleMessages: Boolean = true;
   gJustChatted: Boolean = false; // ÷òîáû àäìèí â èíòåðå ÷àòÿñü íå ïðîìàòûâàë ñòàòèñòèêó
+  gParsingBinds: Boolean = false; // íå ïåðåñîõðàíÿòü êîíôèã âî âðåìÿ ïàðñèíãà
   gPlayerAction: Array [0..1, 0..LAST_ACTION] of Boolean; // [player, action]
 
 implementation
   gPlayerAction: Array [0..1, 0..LAST_ACTION] of Boolean; // [player, action]
 
 implementation
@@ -954,9 +956,11 @@ begin
   WhitelistCommand('g_scorelimit');
   WhitelistCommand('g_timelimit');
 
   WhitelistCommand('g_scorelimit');
   WhitelistCommand('g_timelimit');
 
+  gParsingBinds := True;
   g_Console_ResetBinds;
   g_Console_ReadConfig(GameDir + '/dfconfig.cfg');
   g_Console_ReadConfig(GameDir + '/autoexec.cfg');
   g_Console_ResetBinds;
   g_Console_ReadConfig(GameDir + '/dfconfig.cfg');
   g_Console_ReadConfig(GameDir + '/autoexec.cfg');
+  gParsingBinds := False;
 
   g_Console_Add(Format(_lc[I_CONSOLE_WELCOME], [GAME_VERSION]));
   g_Console_Add('');
 
   g_Console_Add(Format(_lc[I_CONSOLE_WELCOME], [GAME_VERSION]));
   g_Console_Add('');
@@ -1650,8 +1654,9 @@ begin
   if key > 0 then
   begin
     gInputBinds[key].down := ParseAlias(down);
   if key > 0 then
   begin
     gInputBinds[key].down := ParseAlias(down);
-    gInputBinds[key].up := ParseAlias(up)
-  end
+    gInputBinds[key].up := ParseAlias(up);
+  end;
+  g_Console_WriteGameConfig();
 end;
 
 function g_Console_MatchBind (key: Integer; down: AnsiString; up: AnsiString = ''): Boolean;
 end;
 
 function g_Console_MatchBind (key: Integer; down: AnsiString; up: AnsiString = ''): Boolean;
@@ -1830,10 +1835,10 @@ begin
         while (i <= len) and (s[i] <= ' ') do inc(i);
         (* skip comments *)
         if (i <= len) and ((s[i] <> '#') and ((i + 1 > len) or (s[i] <> '/') or (s[i + 1] <> '/'))) then
         while (i <= len) and (s[i] <= ' ') do inc(i);
         (* skip comments *)
         if (i <= len) and ((s[i] <> '#') and ((i + 1 > len) or (s[i] <> '/') or (s[i + 1] <> '/'))) then
-          g_Console_Process(s, True)
+          g_Console_Process(s, True);
       end
     end;
       end
     end;
-    CloseFile(f)
+    CloseFile(f);
   end
 end;
 
   end
 end;
 
@@ -1869,5 +1874,11 @@ begin
   CloseFile(f)
 end;
 
   CloseFile(f)
 end;
 
+procedure g_Console_WriteGameConfig;
+begin
+  if gParsingBinds then
+    Exit;
+  g_Console_WriteConfig(GameDir + '/dfconfig.cfg');
+end;
 
 end.
 
 end.
index c6e5339a15d0f562e9eaf555373a7e2fb56d40d9..ba91ca3b28500d9f5a19ae442515c8bbe899eb1b 100644 (file)
@@ -369,7 +369,7 @@ begin
   if g_Game_IsClient then MC_SEND_PlayerSettings;
 
   g_Options_Write(GameDir+'/'+CONFIG_FILENAME);
   if g_Game_IsClient then MC_SEND_PlayerSettings;
 
   g_Options_Write(GameDir+'/'+CONFIG_FILENAME);
-  g_Console_WriteConfig(GameDir + '/dfconfig.cfg');
+  g_Console_WriteGameConfig();
 end;
 
 procedure ReadOptions();
 end;
 
 procedure ReadOptions();