X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_console.pas;h=fd8e24b3cf1bd05371a5d9a1c277fc4bdb194418;hb=31039aaf7e1623de1a4be292d0c77532fcfbf3e6;hp=7b68cce099b4130ca24d2a779501b32caecef2be;hpb=de40ee608b5563a84872642f7fbae6ee8e4b635d;p=d2df-sdl.git diff --git a/src/game/g_console.pas b/src/game/g_console.pas index 7b68cce..fd8e24b 100644 --- a/src/game/g_console.pas +++ b/src/game/g_console.pas @@ -21,6 +21,22 @@ interface uses utils; // for SSArray + const + ACTION_JUMP = 0; + ACTION_MOVELEFT = 1; + ACTION_MOVERIGHT = 2; + ACTION_LOOKDOWN = 3; + ACTION_LOOKUP = 4; + ACTION_ATTACK = 5; + ACTION_SCORES = 6; + ACTION_ACTIVATE = 7; + ACTION_STRAFE = 8; + ACTION_WEAPNEXT = 9; + ACTION_WEAPPREV = 10; + + FIRST_ACTION = ACTION_JUMP; + LAST_ACTION = ACTION_WEAPPREV; + procedure g_Console_Init (); procedure g_Console_Update (); procedure g_Console_Draw (); @@ -31,6 +47,15 @@ procedure g_Console_Process (L: AnsiString; quiet: Boolean=false); procedure g_Console_Add (L: AnsiString; show: Boolean=false); 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_Interactive: Boolean; +function g_Console_Action (action: Integer): Boolean; +function g_Console_FindBind (n: Integer; down: AnsiString; up: AnsiString = ''): Integer; +procedure g_Console_BindKey (key: Integer; down: AnsiString; up: AnsiString = ''); +procedure g_Console_ProcessBind (key: Integer; down: Boolean); +procedure g_Console_ResetBinds; procedure conwriteln (const s: AnsiString; show: Boolean=false); procedure conwritefln (const s: AnsiString; args: array of const; show: Boolean=false); @@ -53,9 +78,8 @@ var gChatShow: Boolean = false; gChatTeam: Boolean = false; gAllowConsoleMessages: Boolean = true; - gChatEnter: Boolean = true; gJustChatted: Boolean = false; // ÷òîáû àäìèí â èíòåðå ÷àòÿñü íå ïðîìàòûâàë ñòàòèñòèêó - + gPlayerAction: Array [0..1, 0..LAST_ACTION] of Boolean; // [player, action] implementation @@ -80,6 +104,8 @@ type ptr: Pointer; // various data msg: AnsiString; // message for var changes cheat: Boolean; + action: Integer; // >= 0 for action commands + player: Integer; // used for action commands end; TAlias = record @@ -116,6 +142,10 @@ var Time: Word; end; + gInputBinds: Array [0..e_MaxInputKeys - 1] of record + down, up: SSArray; + end; + // poor man's floating literal parser; i'm sorry, but `StrToFloat()` sux cocks function conParseFloat (var res: Single; const s: AnsiString): Boolean; @@ -244,6 +274,8 @@ begin cp.ptr := pvar; cp.msg := amsg; cp.cheat := acheat; + cp.action := -1; + cp.player := -1; end; @@ -263,6 +295,8 @@ begin cp.ptr := pvar; cp.msg := amsg; cp.cheat := acheat; + cp.action := -1; + cp.player := -1; end; @@ -336,6 +370,8 @@ begin cp.ptr := pv; cp.msg := amsg; cp.cheat := acheat; + cp.action := -1; + cp.player := -1; end; @@ -375,7 +411,7 @@ procedure ConsoleCommands(p: SSArray); var cmd, s: AnsiString; a, b: Integer; - F: TextFile; + (* F: TextFile; *) begin cmd := LowerCase(p[0]); s := ''; @@ -477,53 +513,21 @@ begin if cmd = 'exec' then begin // exec - if Length(p) > 1 then - begin - s := GameDir+'/'+p[1]; - - {$I-} - AssignFile(F, s); - Reset(F); - if IOResult <> 0 then - begin - g_Console_Add(Format(_lc[I_CONSOLE_ERROR_READ], [s])); - CloseFile(F); - Exit; - end; - g_Console_Add(Format(_lc[I_CONSOLE_EXEC], [s])); - - while not EOF(F) do - begin - ReadLn(F, s); - if IOResult <> 0 then - begin - g_Console_Add(Format(_lc[I_CONSOLE_ERROR_READ], [s])); - CloseFile(F); - Exit; - end; - if Pos('#', s) <> 1 then // script comment - begin - // prevents endless loops - Inc(RecursionDepth); - RecursionLimitHit := (RecursionDepth > MaxScriptRecursion) or RecursionLimitHit; - if not RecursionLimitHit then - g_Console_Process(s, True); - Dec(RecursionDepth); - end; - end; - if (RecursionDepth = 0) and RecursionLimitHit then - begin - g_Console_Add(Format(_lc[I_CONSOLE_ERROR_CALL], [s])); - RecursionLimitHit := False; - end; - - CloseFile(F); - {$I+} - end + if Length(p) = 2 then + g_Console_ReadConfig(GameDir + '/' + p[1]) else g_Console_Add('exec