1 (* Copyright (C) Doom 2D: Forever Developers
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, version 3 of the License ONLY.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 {$INCLUDE ../shared/a_modes.inc}
34 FIRST_ACTION
= ACTION_JUMP
;
35 LAST_ACTION
= ACTION_STRAFE
;
37 var (* private state *)
40 conSkipLines
: Integer;
41 MsgArray
: Array [0..4] of record
46 procedure g_Console_Init
;
47 procedure g_Console_SysInit
;
48 procedure g_Console_Update
;
49 procedure g_Console_Char (C
: AnsiChar);
50 procedure g_Console_Control (K
: Word);
51 procedure g_Console_Process (L
: AnsiString; quiet
: Boolean=false);
52 procedure g_Console_Add (L
: AnsiString; show
: Boolean=false);
53 procedure g_Console_Clear
;
54 function g_Console_CommandBlacklisted (C
: AnsiString): Boolean;
55 procedure g_Console_ReadConfig (filename
: String);
56 procedure g_Console_WriteConfig (filename
: String);
57 procedure g_Console_WriteGameConfig
;
59 function g_Console_Interactive
: Boolean;
60 function g_Console_Action (action
: Integer): Boolean;
61 function g_Console_MatchBind (key
: Integer; down
: AnsiString; up
: AnsiString = ''): Boolean;
62 function g_Console_FindBind (n
: Integer; down
: AnsiString; up
: AnsiString = ''): Integer;
63 procedure g_Console_BindKey (key
: Integer; down
: AnsiString; up
: AnsiString = ''; rep
: Boolean = False);
64 procedure g_Console_ProcessBind (key
: Integer; down
: Boolean);
65 procedure g_Console_ProcessBindRepeat (key
: Integer);
66 procedure g_Console_ResetBinds
;
68 procedure conwriteln (const s
: AnsiString; show
: Boolean=false);
69 procedure conwritefln (const s
: AnsiString; args
: array of const; show
: Boolean=false);
71 procedure conRegVar (const conname
: AnsiString; pvar
: PBoolean; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
72 procedure conRegVar (const conname
: AnsiString; pvar
: PSingle; amin
, amax
: Single; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
73 procedure conRegVar (const conname
: AnsiString; pvar
: PInteger; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
74 procedure conRegVar (const conname
: AnsiString; pvar
: PWord; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
75 procedure conRegVar (const conname
: AnsiString; pvar
: PCardinal; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
76 procedure conRegVar (const conname
: AnsiString; pvar
: PAnsiString; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
78 // <0: no arg; 0/1: true/false
79 function conGetBoolArg (p
: SSArray
; idx
: Integer): Integer;
81 // poor man's floating literal parser; i'm sorry, but `StrToFloat()` sux cocks
82 function conParseFloat (var res
: Single; const s
: AnsiString): Boolean;
86 defaultConfigScript
= 'dfserver.cfg';
88 defaultConfigScript
= 'dfconfig.cfg';
92 gConsoleShow
: Boolean = false; // True - êîíñîëü îòêðûòà èëè îòêðûâàåòñÿ
93 gChatShow
: Boolean = false;
94 gChatTeam
: Boolean = false;
95 gAllowConsoleMessages
: Boolean = true;
96 gJustChatted
: Boolean = false; // ÷òîáû àäìèí â èíòåðå ÷àòÿñü íå ïðîìàòûâàë ñòàòèñòèêó
97 gParsingBinds
: Boolean = true; // íå ïåðåñîõðàíÿòü êîíôèã âî âðåìÿ ïàðñèíãà
98 gPlayerAction
: Array [0..1, 0..LAST_ACTION
] of Boolean; // [player, action]
99 gConfigScript
: string = defaultConfigScript
;
104 g_textures
, g_main
, e_input
, g_game
, g_gfx
, g_player
, g_items
,
105 SysUtils
, g_basic
, g_options
, Math
, g_touch
, e_res
,
106 g_menu
, g_gui
, g_language
, g_net
, g_netmsg
, e_log
, conbuf
, g_weapons
,
110 autoexecScript
= 'autoexec.cfg';
111 configComment
= 'generated by doom2d, do not modify';
114 PCommand
= ^TCommand
;
116 TCmdProc
= procedure (p
: SSArray
);
117 TCmdProcEx
= procedure (me
: PCommand
; p
: SSArray
);
125 ptr
: Pointer; // various data
126 msg
: AnsiString; // message for var changes
128 action
: Integer; // >= 0 for action commands
129 player
: Integer; // used for action commands
140 MaxScriptRecursion
= 16;
143 RecursionDepth
: Word = 0;
144 RecursionLimitHit
: Boolean = False;
145 InputReady
: Boolean; // allow text input in console/chat
146 //ConsoleHistory: SSArray;
147 CommandHistory
: SSArray
;
149 commands
: Array of TCommand
= nil;
150 Aliases
: Array of TAlias
= nil;
153 gInputBinds
: Array [0..e_MaxInputKeys
- 1] of record
157 menu_toggled
: BOOLEAN; (* hack for menu controls *)
158 ConsoleStdIn
: Boolean;
160 procedure g_Console_Switch
;
163 gConsoleShow
:= not gConsoleShow
;
165 g_Touch_ShowKeyboard(gConsoleShow
or gChatShow
);
168 procedure g_Console_Chat_Switch (Team
: Boolean = False);
170 if not g_Game_IsNet
then Exit
;
171 gConsoleShow
:= False;
172 gChatShow
:= not gChatShow
;
177 g_Touch_ShowKeyboard(gConsoleShow
or gChatShow
);
180 // poor man's floating literal parser; i'm sorry, but `StrToFloat()` sux cocks
181 function conParseFloat (var res
: Single; const s
: AnsiString): Boolean;
190 while (slen
> 0) and (s
[slen
] <= ' ') do Dec(slen
);
191 while (pos
<= slen
) and (s
[pos
] <= ' ') do Inc(pos
);
192 if (pos
> slen
) then exit
;
193 if (slen
-pos
= 1) and (s
[pos
] = '.') then exit
; // single dot
195 while (pos
<= slen
) do
197 if (s
[pos
] < '0') or (s
[pos
] > '9') then break
;
198 res
:= res
*10+Byte(s
[pos
])-48;
201 if (pos
<= slen
) then
204 if (s
[pos
] <> '.') then exit
;
206 while (pos
<= slen
) do
208 if (s
[pos
] < '0') or (s
[pos
] > '9') then break
;
210 res
+= frac
*(Byte(s
[pos
])-48);
214 if (pos
<= slen
) then exit
; // oops
219 // ////////////////////////////////////////////////////////////////////////// //
220 // <0: no arg; 0/1: true/false; 666: toggle
221 function conGetBoolArg (p
: SSArray
; idx
: Integer): Integer;
223 if (idx
< 0) or (idx
> High(p
)) then begin result
:= -1; exit
; end;
225 if (p
[idx
] = '1') or (CompareText(p
[idx
], 'on') = 0) or (CompareText(p
[idx
], 'true') = 0) or
226 (CompareText(p
[idx
], 'tan') = 0) or (CompareText(p
[idx
], 'yes') = 0) then result
:= 1
227 else if (CompareText(p
[idx
], 'toggle') = 0) or (CompareText(p
[idx
], 'switch') = 0) or
228 (CompareText(p
[idx
], 't') = 0) then result
:= 666;
232 procedure boolVarHandler (me
: PCommand
; p
: SSArray
);
233 procedure binaryFlag (var flag
: Boolean; msg
: AnsiString);
237 if (Length(p
) > 2) then
239 conwritefln('too many arguments to ''%s''', [p
[0]]);
244 case conGetBoolArg(p
, 1) of
246 0: if not me
.cheat
or conIsCheatsEnabled
then flag
:= false else begin conwriteln('not available'); exit
; end;
247 1: if not me
.cheat
or conIsCheatsEnabled
then flag
:= true else begin conwriteln('not available'); exit
; end;
248 666: if not me
.cheat
or conIsCheatsEnabled
then flag
:= not flag
else begin conwriteln('not available'); exit
; end;
251 g_Console_WriteGameConfig();
252 if (Length(msg
) = 0) then msg
:= p
[0] else msg
+= ':';
253 if flag
then conwritefln('%s tan', [msg
]) else conwritefln('%s ona', [msg
]);
257 binaryFlag(PBoolean(me
.ptr
)^, me
.msg
);
261 procedure intVarHandler (me
: PCommand
; p
: SSArray
);
265 if (Length(p
) <> 2) then
267 conwritefln('%s %d', [me
.cmd
, PInteger(me
.ptr
)^]);
272 old
:= PInteger(me
.ptr
)^;
273 PInteger(me
.ptr
)^ := StrToInt(p
[1]);
274 if PInteger(me
.ptr
)^ <> old
then
275 g_Console_WriteGameConfig();
277 conwritefln('invalid integer value: "%s"', [p
[1]]);
283 procedure wordVarHandler (me
: PCommand
; p
: SSArray
);
287 if (Length(p
) <> 2) then
289 conwritefln('%s %d', [me
.cmd
, PInteger(me
.ptr
)^]);
294 old
:= PWord(me
.ptr
)^;
295 PWord(me
.ptr
)^ := min($FFFF, StrToDWord(p
[1]));
296 if PWord(me
.ptr
)^ <> old
then
297 g_Console_WriteGameConfig();
299 conwritefln('invalid word value: "%s"', [p
[1]]);
305 procedure dwordVarHandler (me
: PCommand
; p
: SSArray
);
309 if (Length(p
) <> 2) then
311 conwritefln('%s %d', [me
.cmd
, PInteger(me
.ptr
)^]);
316 old
:= PCardinal(me
.ptr
)^;
317 PCardinal(me
.ptr
)^ := StrToDWord(p
[1]);
318 if PCardinal(me
.ptr
)^ <> old
then
319 g_Console_WriteGameConfig();
321 conwritefln('invalid dword value: "%s"', [p
[1]]);
327 procedure strVarHandler (me
: PCommand
; p
: SSArray
);
331 if (Length(p
) <> 2) then
333 conwritefln('%s %s', [me
.cmd
, QuoteStr(PAnsiString(me
.ptr
)^)]);
337 old
:= PAnsiString(me
.ptr
)^;
338 PAnsiString(me
.ptr
)^ := p
[1];
339 if PAnsiString(me
.ptr
)^ <> old
then
340 g_Console_WriteGameConfig();
345 procedure conRegVar (const conname
: AnsiString; pvar
: PBoolean; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
350 f
:= Length(commands
);
351 SetLength(commands
, f
+1);
353 cp
.cmd
:= LowerCase(conname
);
355 cp
.procEx
:= boolVarHandler
;
357 cp
.hidden
:= ahidden
;
366 procedure conRegVar (const conname
: AnsiString; pvar
: PInteger; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
371 f
:= Length(commands
);
372 SetLength(commands
, f
+1);
374 cp
.cmd
:= LowerCase(conname
);
376 cp
.procEx
:= intVarHandler
;
378 cp
.hidden
:= ahidden
;
387 procedure conRegVar (const conname
: AnsiString; pvar
: PWord; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
392 f
:= Length(commands
);
393 SetLength(commands
, f
+1);
395 cp
.cmd
:= LowerCase(conname
);
397 cp
.procEx
:= wordVarHandler
;
399 cp
.hidden
:= ahidden
;
408 procedure conRegVar (const conname
: AnsiString; pvar
: PCardinal; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
413 f
:= Length(commands
);
414 SetLength(commands
, f
+1);
416 cp
.cmd
:= LowerCase(conname
);
418 cp
.procEx
:= dwordVarHandler
;
420 cp
.hidden
:= ahidden
;
429 procedure conRegVar (const conname
: AnsiString; pvar
: PAnsiString; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
434 f
:= Length(commands
);
435 SetLength(commands
, f
+1);
437 cp
.cmd
:= LowerCase(conname
);
439 cp
.procEx
:= strVarHandler
;
441 cp
.hidden
:= ahidden
;
449 // ////////////////////////////////////////////////////////////////////////// //
451 PVarSingle
= ^TVarSingle
;
454 min
, max
, def
: Single; // default will be starting value
458 procedure singleVarHandler (me
: PCommand
; p
: SSArray
);
464 if (Length(p
) > 2) then
466 conwritefln('too many arguments to ''%s''', [me
.cmd
]);
469 pv
:= PVarSingle(me
.ptr
);
471 if (Length(p
) = 2) then
473 if me
.cheat
and (not conIsCheatsEnabled
) then begin conwriteln('not available'); exit
; end;
474 if (CompareText(p
[1], 'default') = 0) or (CompareText(p
[1], 'def') = 0) or
475 (CompareText(p
[1], 'd') = 0) or (CompareText(p
[1], 'off') = 0) or
476 (CompareText(p
[1], 'ona') = 0) then
482 if not conParseFloat(nv
, p
[1]) then
484 conwritefln('%s: ''%s'' doesn''t look like a floating number', [me
.cmd
, p
[1]]);
487 if (nv
< pv
.min
) then nv
:= pv
.min
;
488 if (nv
> pv
.max
) then nv
:= pv
.max
;
492 if pv
.val
^ <> old
then
493 g_Console_WriteGameConfig();
495 if (Length(msg
) = 0) then msg
:= me
.cmd
else msg
+= ':';
496 conwritefln('%s %s', [msg
, pv
.val
^]);
500 procedure conRegVar (const conname
: AnsiString; pvar
: PSingle; amin
, amax
: Single; const ahelp
: AnsiString; const amsg
: AnsiString; acheat
: Boolean=false; ahidden
: Boolean=false); overload
;
506 GetMem(pv
, sizeof(TVarSingle
));
511 f
:= Length(commands
);
512 SetLength(commands
, f
+1);
514 cp
.cmd
:= LowerCase(conname
);
516 cp
.procEx
:= singleVarHandler
;
518 cp
.hidden
:= ahidden
;
527 // ////////////////////////////////////////////////////////////////////////// //
528 function GetStrACmd(var Str
: AnsiString): AnsiString;
533 for a
:= 1 to Length(Str
) do
534 if (a
= Length(Str
)) or (Str
[a
+1] = ';') then
536 Result
:= Copy(Str
, 1, a
);
543 function ParseAlias(Str
: AnsiString): SSArray
;
554 SetLength(Result
, Length(Result
)+1);
555 Result
[High(Result
)] := GetStrACmd(Str
);
559 procedure ConsoleCommands(p
: SSArray
);
565 cmd
:= LowerCase(p
[0]);
568 if cmd
= 'clear' then
570 //ConsoleHistory := nil;
574 for a
:= 0 to High(MsgArray
) do
582 if cmd
= 'clearhistory' then
583 CommandHistory
:= nil;
585 if cmd
= 'showhistory' then
586 if CommandHistory
<> nil then
589 for a
:= 0 to High(CommandHistory
) do
590 g_Console_Add(' '+CommandHistory
[a
]);
593 if cmd
= 'commands' then
596 g_Console_Add('commands list:');
597 for a
:= High(commands
) downto 0 do
599 if (Length(commands
[a
].help
) > 0) then
601 g_Console_Add(' '+commands
[a
].cmd
+' -- '+commands
[a
].help
);
605 g_Console_Add(' '+commands
[a
].cmd
);
611 g_Console_Add(TimeToStr(Now
), True);
614 g_Console_Add(DateToStr(Now
), True);
617 if Length(p
) > 1 then
619 if p
[1] = 'ololo' then
624 for a
:= 1 to High(p
) do
626 g_Console_Add(b_Text_Format(s
), True);
635 if ConsoleHistory <> nil then
637 if Length(P) > 1 then
640 s := GameDir+'/console.txt';
645 if IOResult <> 0 then
647 g_Console_Add(Format(_lc[I_CONSOLE_ERROR_WRITE], [s]));
652 for a := 0 to High(ConsoleHistory) do
653 WriteLn(F, ConsoleHistory[a]);
656 g_Console_Add(Format(_lc[I_CONSOLE_DUMPED], [s]));
665 if Length(p
) = 2 then
666 g_Console_ReadConfig(p
[1])
668 g_Console_Add('exec <script file>');
671 if cmd
= 'writeconfig' then
673 // writeconfig <filename>
674 if Length(p
) = 2 then
676 s
:= e_GetWriteableDir(ConfigDirs
);
677 g_Console_WriteConfig(e_CatPath(s
, p
[1]))
681 g_Console_Add('writeconfig <file>')
685 if (cmd
= 'ver') or (cmd
= 'version') then
687 conwriteln('Doom 2D: Forever v. ' + GAME_VERSION
);
688 conwritefln('Net protocol v. %d', [NET_PROTOCOL_VER
]);
689 conwritefln('Build date: %s at %s', [GAME_BUILDDATE
, GAME_BUILDTIME
]);
692 if cmd
= 'alias' then
694 // alias [alias_name] [commands]
695 if Length(p
) > 1 then
697 for a
:= 0 to High(Aliases
) do
698 if Aliases
[a
].name
= p
[1] then
700 if Length(p
) > 2 then
701 Aliases
[a
].commands
:= ParseAlias(p
[2])
703 for b
:= 0 to High(Aliases
[a
].commands
) do
704 g_Console_Add(Aliases
[a
].commands
[b
]);
707 SetLength(Aliases
, Length(Aliases
)+1);
709 Aliases
[a
].name
:= p
[1];
710 if Length(p
) > 2 then
711 Aliases
[a
].commands
:= ParseAlias(p
[2])
713 for b
:= 0 to High(Aliases
[a
].commands
) do
714 g_Console_Add(Aliases
[a
].commands
[b
]);
716 for a
:= 0 to High(Aliases
) do
717 if Aliases
[a
].commands
<> nil then
718 g_Console_Add(Aliases
[a
].name
);
724 if Length(p
) > 1 then
726 if Aliases
= nil then
728 for a
:= 0 to High(Aliases
) do
729 if Aliases
[a
].name
= p
[1] then
731 if Aliases
[a
].commands
<> nil then
733 // with this system proper endless loop detection seems either impossible
734 // or very dirty to implement, so let's have this instead
735 // prevents endless loops
736 for b
:= 0 to High(Aliases
[a
].commands
) do
739 RecursionLimitHit
:= (RecursionDepth
> MaxScriptRecursion
) or RecursionLimitHit
;
740 if not RecursionLimitHit
then
741 g_Console_Process(Aliases
[a
].commands
[b
], True);
744 if (RecursionDepth
= 0) and RecursionLimitHit
then
746 g_Console_Add(Format(_lc
[I_CONSOLE_ERROR_CALL
], [s
]));
747 RecursionLimitHit
:= False;
754 g_Console_Add('call <alias name>');
758 procedure WhitelistCommand(cmd
: AnsiString);
762 SetLength(Whitelist
, Length(Whitelist
)+1);
763 a
:= High(Whitelist
);
764 Whitelist
[a
] := LowerCase(cmd
);
767 procedure segfault (p
: SSArray
);
774 function GetCommandString (p
: SSArray
): AnsiString;
778 if Length(p
) >= 1 then
781 for i
:= 1 to High(p
) do
782 result
:= result
+ '; ' + p
[i
]
786 function QuoteStr(str
: String): String;
788 if Pos(' ', str
) > 0 then
789 Result
:= '"' + str
+ '"'
794 procedure BindCommands (p
: SSArray
);
795 var cmd
, key
: AnsiString; i
: Integer;
797 cmd
:= LowerCase(p
[0]);
800 // bind <key> [down [up]]
801 if (Length(p
) >= 2) and (Length(p
) <= 4) then
804 key
:= LowerCase(p
[1]);
805 while (i
< e_MaxInputKeys
) and (key
<> LowerCase(e_KeyNames
[i
])) do inc(i
);
806 if i
< e_MaxInputKeys
then
808 if Length(p
) = 2 then
809 g_Console_Add(QuoteStr(e_KeyNames
[i
]) + ' = ' + QuoteStr(GetCommandString(gInputBinds
[i
].down
)) + ' ' + QuoteStr(GetCommandString(gInputBinds
[i
].up
)))
810 else if Length(p
) = 3 then
811 g_Console_BindKey(i
, p
[2], '')
813 g_Console_BindKey(i
, p
[2], p
[3])
816 g_Console_Add('bind: "' + p
[1] + '" is not a key')
820 g_Console_Add('bind <key> <down action> [up action]')
824 if Length(p
) = 2 then
826 key
:= LowerCase(p
[1]);
828 while (i
< e_MaxInputKeys
) and (key
<> LowerCase(e_KeyNames
[i
])) do inc(i
);
829 if i
< e_MaxInputKeys
then
830 gInputBinds
[i
].rep
:= True
832 g_Console_Add('bindrep: "' + p
[1] + '" is not a key')
835 g_Console_Add('bindrep <key>');
838 if Length(p
) = 2 then
840 key
:= LowerCase(p
[1]);
842 while (i
< e_MaxInputKeys
) and (key
<> LowerCase(e_KeyNames
[i
])) do inc(i
);
843 if i
< e_MaxInputKeys
then
844 gInputBinds
[i
].rep
:= False
846 g_Console_Add('bindunrep: "' + p
[1] + '" is not a key')
849 g_Console_Add('bindunrep <key>');
851 for i
:= 0 to e_MaxInputKeys
- 1 do
852 if (gInputBinds
[i
].down
<> nil) or (gInputBinds
[i
].up
<> nil) then
853 g_Console_Add(e_KeyNames
[i
] + ' ' + QuoteStr(GetCommandString(gInputBinds
[i
].down
)) + ' ' + QuoteStr(GetCommandString(gInputBinds
[i
].up
)));
856 if Length(p
) = 2 then
858 key
:= LowerCase(p
[1]);
860 while (i
< e_MaxInputKeys
) and (key
<> LowerCase(e_KeyNames
[i
])) do inc(i
);
861 if i
< e_MaxInputKeys
then
862 g_Console_BindKey(i
, '')
864 g_Console_Add('unbind: "' + p
[1] + '" is not a key')
867 g_Console_Add('unbind <key>');
869 for i
:= 0 to e_MaxInputKeys
- 1 do
870 g_Console_BindKey(i
, '');
872 g_Touch_ShowKeyboard(True);
874 g_Touch_ShowKeyboard(False);
879 else if gChatShow
then
880 g_Console_Chat_Switch
888 g_Console_Chat_Switch
;
890 if gGameSettings
.GameMode
in [GM_TDM
, GM_CTF
] then
891 g_Console_Chat_Switch(True);
895 procedure AddCommand(cmd
: AnsiString; proc
: TCmdProc
; ahelp
: AnsiString=''; ahidden
: Boolean=false; acheat
: Boolean=false);
900 SetLength(commands
, Length(commands
)+1);
903 cp
.cmd
:= LowerCase(cmd
);
907 cp
.hidden
:= ahidden
;
915 procedure AddAction (cmd
: AnsiString; action
: Integer; help
: AnsiString = ''; hidden
: Boolean = False; cheat
: Boolean = False);
917 PrefixList
: array [0..1] of AnsiString = ('+', '-');
918 PlayerList
: array [0..1] of Integer = (1, 2);
923 procedure NewAction (cmd
: AnsiString; player
: Integer);
926 SetLength(commands
, Length(commands
) + 1);
927 cp
:= @commands
[High(commands
)];
928 cp
.cmd
:= LowerCase(cmd
);
941 ASSERT(action
>= FIRST_ACTION
);
942 ASSERT(action
<= LAST_ACTION
);
943 for s
in PrefixList
do
945 NewAction(s
+ cmd
, 0);
946 for i
in PlayerList
do
947 NewAction(s
+ 'p' + IntToStr(i
) + '_' + cmd
, i
- 1)
956 gConsoleShow
:= True;
959 KEv
:= PollKeyEvent();
962 K
:= GetKeyEventChar(TranslateKeyEvent(GetKeyEvent()));
965 #8: g_Console_Control(IK_BACKSPACE
);
966 #10, #13: g_Console_Control(IK_RETURN
);
967 #32..#126: g_Console_Char(K
);
968 // arrow keys and DEL all return 0 for some reason, so fuck em
973 procedure g_Console_SysInit
;
976 gConsoleShow
:= False;
981 for a
:= 0 to High(MsgArray
) do
988 AddCommand('segfault', segfault
, 'make segfault');
990 AddCommand('quit', SystemCommands
);
991 AddCommand('exit', SystemCommands
);
992 AddCommand('r_reset', SystemCommands
);
993 AddCommand('r_maxfps', SystemCommands
);
994 AddCommand('g_language', SystemCommands
);
996 AddCommand('bind', BindCommands
);
997 AddCommand('bindrep', BindCommands
);
998 AddCommand('bindunrep', BindCommands
);
999 AddCommand('bindlist', BindCommands
);
1000 AddCommand('unbind', BindCommands
);
1001 AddCommand('unbindall', BindCommands
);
1002 AddCommand('showkeyboard', BindCommands
);
1003 AddCommand('hidekeyboard', BindCommands
);
1004 AddCommand('togglemenu', BindCommands
);
1005 AddCommand('toggleconsole', BindCommands
);
1006 AddCommand('togglechat', BindCommands
);
1007 AddCommand('toggleteamchat', BindCommands
);
1009 AddCommand('clear', ConsoleCommands
, 'clear console');
1010 AddCommand('clearhistory', ConsoleCommands
);
1011 AddCommand('showhistory', ConsoleCommands
);
1012 AddCommand('commands', ConsoleCommands
);
1013 AddCommand('time', ConsoleCommands
);
1014 AddCommand('date', ConsoleCommands
);
1015 AddCommand('echo', ConsoleCommands
);
1016 AddCommand('dump', ConsoleCommands
);
1017 AddCommand('exec', ConsoleCommands
);
1018 AddCommand('writeconfig', ConsoleCommands
);
1019 AddCommand('alias', ConsoleCommands
);
1020 AddCommand('call', ConsoleCommands
);
1021 AddCommand('ver', ConsoleCommands
);
1022 AddCommand('version', ConsoleCommands
);
1024 AddCommand('d_window', DebugCommands
);
1025 AddCommand('d_sounds', DebugCommands
);
1026 AddCommand('d_frames', DebugCommands
);
1027 AddCommand('d_winmsg', DebugCommands
);
1028 AddCommand('d_monoff', DebugCommands
);
1029 AddCommand('d_botoff', DebugCommands
);
1030 AddCommand('d_monster', DebugCommands
);
1031 AddCommand('d_health', DebugCommands
);
1032 AddCommand('d_player', DebugCommands
);
1033 AddCommand('d_joy', DebugCommands
);
1034 AddCommand('d_mem', DebugCommands
);
1036 AddCommand('p1_name', PlayerSettingsCVars
);
1037 AddCommand('p2_name', PlayerSettingsCVars
);
1038 AddCommand('p1_color', PlayerSettingsCVars
);
1039 AddCommand('p2_color', PlayerSettingsCVars
);
1040 AddCommand('p1_model', PlayerSettingsCVars
);
1041 AddCommand('p2_model', PlayerSettingsCVars
);
1042 AddCommand('p1_team', PlayerSettingsCVars
);
1043 AddCommand('p2_team', PlayerSettingsCVars
);
1044 AddCommand('p1_autoswitch', PlayerSettingsCVars
);
1045 AddCommand('p2_autoswitch', PlayerSettingsCVars
);
1046 AddCommand('p1_switch_empty', PlayerSettingsCVars
);
1047 AddCommand('p2_switch_empty', PlayerSettingsCVars
);
1048 AddCommand('p1_skip_fist', PlayerSettingsCVars
);
1049 AddCommand('p2_skip_fist', PlayerSettingsCVars
);
1050 AddCommand('p1_priority_kastet', PlayerSettingsCVars
);
1051 AddCommand('p2_priority_kastet', PlayerSettingsCVars
);
1052 AddCommand('p1_priority_saw', PlayerSettingsCVars
);
1053 AddCommand('p2_priority_saw', PlayerSettingsCVars
);
1054 AddCommand('p1_priority_pistol', PlayerSettingsCVars
);
1055 AddCommand('p2_priority_pistol', PlayerSettingsCVars
);
1056 AddCommand('p1_priority_shotgun1', PlayerSettingsCVars
);
1057 AddCommand('p2_priority_shotgun1', PlayerSettingsCVars
);
1058 AddCommand('p1_priority_shotgun2', PlayerSettingsCVars
);
1059 AddCommand('p2_priority_shotgun2', PlayerSettingsCVars
);
1060 AddCommand('p1_priority_chaingun', PlayerSettingsCVars
);
1061 AddCommand('p2_priority_chaingun', PlayerSettingsCVars
);
1062 AddCommand('p1_priority_rocketlauncher', PlayerSettingsCVars
);
1063 AddCommand('p2_priority_rocketlauncher', PlayerSettingsCVars
);
1064 AddCommand('p1_priority_plasma', PlayerSettingsCVars
);
1065 AddCommand('p2_priority_plasma', PlayerSettingsCVars
);
1066 AddCommand('p1_priority_bfg', PlayerSettingsCVars
);
1067 AddCommand('p2_priority_bfg', PlayerSettingsCVars
);
1068 AddCommand('p1_priority_super', PlayerSettingsCVars
);
1069 AddCommand('p2_priority_super', PlayerSettingsCVars
);
1070 AddCommand('p1_priority_flamethrower', PlayerSettingsCVars
);
1071 AddCommand('p2_priority_flamethrower', PlayerSettingsCVars
);
1072 AddCommand('p1_priority_berserk', PlayerSettingsCVars
);
1073 AddCommand('p2_priority_berserk', PlayerSettingsCVars
);
1075 AddCommand('g_max_particles', GameCVars
);
1076 AddCommand('g_max_shells', GameCVars
);
1077 AddCommand('g_max_gibs', GameCVars
);
1078 AddCommand('g_max_corpses', GameCVars
);
1079 AddCommand('g_force_model', GameCVars
);
1080 AddCommand('g_force_model_name', GameCVars
);
1081 AddCommand('g_gamemode', GameCVars
);
1082 AddCommand('g_friendlyfire', GameCVars
);
1083 AddCommand('g_friendly_hit_trace', GameCVars
);
1084 AddCommand('g_friendly_hit_projectile', GameCVars
);
1085 AddCommand('g_friendly_absorb_damage', GameCVars
);
1086 AddCommand('g_weaponstay', GameCVars
);
1087 AddCommand('g_allow_exit', GameCVars
);
1088 AddCommand('g_dm_keys', GameCVars
);
1089 AddCommand('g_allow_monsters', GameCVars
);
1090 AddCommand('g_allow_dropflag', GameCVars
);
1091 AddCommand('g_throw_flag', GameCVars
);
1092 AddCommand('g_bot_vsmonsters', GameCVars
);
1093 AddCommand('g_bot_vsplayers', GameCVars
);
1094 AddCommand('g_max_bots', GameCVars
); // intentionally not whitelisted
1095 AddCommand('g_scorelimit', GameCVars
);
1096 AddCommand('g_timelimit', GameCVars
);
1097 AddCommand('g_maxlives', GameCVars
);
1098 AddCommand('g_warmup_time', GameCVars
);
1099 AddCommand('g_spawn_invul', GameCVars
);
1100 AddCommand('g_item_respawn_time', GameCVars
);
1101 AddCommand('sv_intertime', GameCVars
);
1103 AddCommand('sv_name', NetServerCVars
);
1104 AddCommand('sv_passwd', NetServerCVars
);
1105 AddCommand('sv_maxplrs', NetServerCVars
);
1106 AddCommand('sv_public', NetServerCVars
);
1107 AddCommand('sv_port', NetServerCVars
);
1109 AddCommand('pause', GameCommands
);
1110 AddCommand('endgame', GameCommands
);
1111 AddCommand('restart', GameCommands
);
1112 AddCommand('addbot', GameCommands
);
1113 AddCommand('bot_add', GameCommands
);
1114 AddCommand('bot_addlist', GameCommands
);
1115 AddCommand('bot_addred', GameCommands
);
1116 AddCommand('bot_addblue', GameCommands
);
1117 AddCommand('bot_removeall', GameCommands
);
1118 AddCommand('chat', GameCommands
);
1119 AddCommand('teamchat', GameCommands
);
1120 AddCommand('announce', GameCommands
);
1121 AddCommand('an', GameCommands
);
1122 AddCommand('game', GameCommands
);
1123 AddCommand('host', GameCommands
);
1124 AddCommand('map', GameCommands
);
1125 AddCommand('nextmap', GameCommands
);
1126 AddCommand('endmap', GameCommands
);
1127 AddCommand('goodbye', GameCommands
);
1128 AddCommand('suicide', GameCommands
);
1129 AddCommand('spectate', GameCommands
);
1130 AddCommand('ready', GameCommands
);
1131 AddCommand('kick', GameCommands
);
1132 AddCommand('kick_id', GameCommands
);
1133 AddCommand('kick_pid', GameCommands
);
1134 AddCommand('ban', GameCommands
);
1135 AddCommand('ban_id', GameCommands
);
1136 AddCommand('ban_pid', GameCommands
);
1137 AddCommand('permban', GameCommands
);
1138 AddCommand('permban_id', GameCommands
);
1139 AddCommand('permban_pid', GameCommands
);
1140 AddCommand('permban_ip', GameCommands
);
1141 AddCommand('unban', GameCommands
);
1142 AddCommand('connect', GameCommands
);
1143 AddCommand('disconnect', GameCommands
);
1144 AddCommand('reconnect', GameCommands
);
1145 AddCommand('say', GameCommands
);
1146 AddCommand('tell', GameCommands
);
1147 AddCommand('centerprint', GameCommands
);
1148 AddCommand('overtime', GameCommands
);
1149 AddCommand('rcon_password', GameCommands
);
1150 AddCommand('rcon', GameCommands
);
1151 AddCommand('callvote', GameCommands
);
1152 AddCommand('vote', GameCommands
);
1153 AddCommand('clientlist', GameCommands
);
1154 AddCommand('event', GameCommands
);
1155 AddCommand('screenshot', GameCommands
);
1156 AddCommand('weapnext', GameCommands
);
1157 AddCommand('weapprev', GameCommands
);
1158 AddCommand('weapon', GameCommands
);
1159 AddCommand('dropflag', GameCommands
);
1160 AddCommand('p1_weapnext', GameCommands
);
1161 AddCommand('p1_weapprev', GameCommands
);
1162 AddCommand('p1_weapon', GameCommands
);
1163 AddCommand('p1_weapbest', GameCommands
);
1164 AddCommand('p1_dropflag', GameCommands
);
1165 AddCommand('p2_weapnext', GameCommands
);
1166 AddCommand('p2_weapprev', GameCommands
);
1167 AddCommand('p2_weapon', GameCommands
);
1168 AddCommand('p2_weapbest', GameCommands
);
1169 AddCommand('p2_dropflag', GameCommands
);
1171 AddCommand('god', GameCheats
);
1172 AddCommand('notarget', GameCheats
);
1173 AddCommand('give', GameCheats
); // "exit" too ;-)
1174 AddCommand('open', GameCheats
);
1175 AddCommand('fly', GameCheats
);
1176 AddCommand('noclip', GameCheats
);
1177 AddCommand('speedy', GameCheats
);
1178 AddCommand('jumpy', GameCheats
);
1179 AddCommand('noreload', GameCheats
);
1180 AddCommand('aimline', GameCheats
);
1181 AddCommand('automap', GameCheats
);
1183 AddAction('jump', ACTION_JUMP
);
1184 AddAction('moveleft', ACTION_MOVELEFT
);
1185 AddAction('moveright', ACTION_MOVERIGHT
);
1186 AddAction('lookup', ACTION_LOOKUP
);
1187 AddAction('lookdown', ACTION_LOOKDOWN
);
1188 AddAction('attack', ACTION_ATTACK
);
1189 AddAction('scores', ACTION_SCORES
);
1190 AddAction('activate', ACTION_ACTIVATE
);
1191 AddAction('strafe', ACTION_STRAFE
);
1193 WhitelistCommand('say');
1194 WhitelistCommand('tell');
1195 WhitelistCommand('overtime');
1196 WhitelistCommand('ready');
1197 WhitelistCommand('map');
1198 WhitelistCommand('nextmap');
1199 WhitelistCommand('endmap');
1200 WhitelistCommand('restart');
1201 WhitelistCommand('kick');
1202 WhitelistCommand('kick_pid');
1203 WhitelistCommand('ban');
1204 WhitelistCommand('ban_pid');
1205 WhitelistCommand('centerprint');
1207 WhitelistCommand('addbot');
1208 WhitelistCommand('bot_add');
1209 WhitelistCommand('bot_addred');
1210 WhitelistCommand('bot_addblue');
1211 WhitelistCommand('bot_removeall');
1213 WhitelistCommand('g_gamemode');
1214 WhitelistCommand('g_friendlyfire');
1215 WhitelistCommand('g_friendly_hit_trace');
1216 WhitelistCommand('g_friendly_hit_projectile');
1217 WhitelistCommand('g_friendly_absorb_damage');
1218 WhitelistCommand('g_weaponstay');
1219 WhitelistCommand('g_allow_exit');
1220 WhitelistCommand('g_dm_keys');
1221 WhitelistCommand('g_allow_monsters');
1222 WhitelistCommand('g_bot_vsmonsters');
1223 WhitelistCommand('g_bot_vsplayers');
1224 WhitelistCommand('g_scorelimit');
1225 WhitelistCommand('g_timelimit');
1226 WhitelistCommand('g_maxlives');
1227 WhitelistCommand('g_warmup_time');
1228 WhitelistCommand('g_spawn_invul');
1229 WhitelistCommand('g_item_respawn_time');
1231 g_Console_ResetBinds
;
1232 g_Console_ReadConfig(gConfigScript
);
1233 g_Console_ReadConfig(autoexecScript
);
1234 gParsingBinds
:= False;
1237 procedure g_Console_Init
;
1239 g_Console_Add(Format(_lc
[I_CONSOLE_WELCOME
], [GAME_VERSION
]));
1242 if ConsoleStdIn
then
1245 conbufStdOutRawMode
:= true;
1250 procedure g_Console_Update
;
1255 if ConsoleStdIn
then
1258 InputReady
:= gConsoleShow
or gChatShow
;
1261 while a
<= High(MsgArray
) do
1263 if MsgArray
[a
].Time
> 0 then
1265 if MsgArray
[a
].Time
= 1 then
1267 if a
< High(MsgArray
) then
1269 for b
:= a
to High(MsgArray
)-1 do
1270 MsgArray
[b
] := MsgArray
[b
+1];
1272 MsgArray
[High(MsgArray
)].Time
:= 0;
1278 Dec(MsgArray
[a
].Time
);
1285 procedure g_Console_Char(C
: AnsiChar);
1287 if InputReady
and (gConsoleShow
or gChatShow
) then
1289 Insert(C
, Line
, CPos
);
1296 tcomplist
: array of AnsiString = nil;
1297 tcompidx
: array of Integer = nil;
1299 procedure Complete ();
1303 ll
, lpfx
, cmd
: AnsiString;
1305 if (Length(Line
) = 0) then
1308 for i
:= 0 to High(commands
) do
1310 // hidden commands are hidden when cheats aren't enabled
1311 if commands
[i
].hidden
and not conIsCheatsEnabled
then continue
;
1312 if (Length(commands
[i
].help
) > 0) then
1314 g_Console_Add(' '+commands
[i
].cmd
+' -- '+commands
[i
].help
);
1318 g_Console_Add(' '+commands
[i
].cmd
);
1324 ll
:= LowerCase(Line
);
1327 if (Length(ll
) > 1) and (ll
[Length(ll
)] = ' ') then
1329 ll
:= Copy(ll
, 0, Length(ll
)-1);
1330 for i
:= 0 to High(commands
) do
1332 // hidden commands are hidden when cheats aren't enabled
1333 if commands
[i
].hidden
and not conIsCheatsEnabled
then continue
;
1334 if (commands
[i
].cmd
= ll
) then
1336 if (Length(commands
[i
].help
) > 0) then
1338 g_Console_Add(' '+commands
[i
].cmd
+' -- '+commands
[i
].help
);
1345 // build completion list
1347 for i
:= 0 to High(commands
) do
1349 // hidden commands are hidden when cheats aren't enabled
1350 if commands
[i
].hidden
and not conIsCheatsEnabled
then continue
;
1351 cmd
:= commands
[i
].cmd
;
1352 if (Length(cmd
) >= Length(ll
)) and (ll
= Copy(cmd
, 0, Length(ll
))) then
1354 if (tused
= Length(tcomplist
)) then
1356 SetLength(tcomplist
, Length(tcomplist
)+128);
1357 SetLength(tcompidx
, Length(tcompidx
)+128);
1359 tcomplist
[tused
] := cmd
;
1360 tcompidx
[tused
] := i
;
1362 if (Length(cmd
) > Length(lpfx
)) then lpfx
:= cmd
;
1366 // get longest prefix
1367 for i
:= 0 to tused
-1 do
1369 cmd
:= tcomplist
[i
];
1370 for c
:= 1 to Length(lpfx
) do
1372 if (c
> Length(cmd
)) then break
;
1373 if (cmd
[c
] <> lpfx
[c
]) then begin lpfx
:= Copy(lpfx
, 0, c
-1); break
; end;
1377 if (tused
= 0) then exit
;
1381 Line
:= tcomplist
[0]+' ';
1382 CPos
:= Length(Line
)+1;
1386 // has longest prefix?
1387 if (Length(lpfx
) > Length(ll
)) then
1390 CPos
:= Length(Line
)+1;
1395 for i
:= 0 to tused
-1 do
1397 if (Length(commands
[tcompidx
[i
]].help
) > 0) then
1399 g_Console_Add(' '+tcomplist
[i
]+' -- '+commands
[tcompidx
[i
]].help
);
1403 g_Console_Add(' '+tcomplist
[i
]);
1411 procedure g_Console_Control(K
: Word);
1415 if (Length(Line
) > 0) and (CPos
> 1) then
1417 Delete(Line
, CPos
-1, 1);
1421 if (Length(Line
) > 0) and (CPos
<= Length(Line
)) then
1422 Delete(Line
, CPos
, 1);
1423 IK_LEFT
, IK_KPLEFT
, VK_LEFT
, JOY0_LEFT
, JOY1_LEFT
, JOY2_LEFT
, JOY3_LEFT
:
1426 IK_RIGHT
, IK_KPRIGHT
, VK_RIGHT
, JOY0_RIGHT
, JOY1_RIGHT
, JOY2_RIGHT
, JOY3_RIGHT
:
1427 if CPos
<= Length(Line
) then
1429 IK_RETURN
, IK_KPRETURN
, VK_OPEN
, VK_FIRE
, JOY0_ATTACK
, JOY1_ATTACK
, JOY2_ATTACK
, JOY3_ATTACK
:
1431 if gConsoleShow
then
1432 g_Console_Process(Line
)
1436 if (Length(Line
) > 0) and g_Game_IsNet
then
1440 if g_Game_IsClient
then
1441 MC_SEND_Chat(b_Text_Format(Line
), NET_CHAT_TEAM
)
1443 MH_SEND_Chat('[' + gPlayer1Settings
.name
+ ']: ' + b_Text_Format(Line
),
1444 NET_CHAT_TEAM
, gPlayer1Settings
.Team
);
1448 if g_Game_IsClient
then
1449 MC_SEND_Chat(b_Text_Format(Line
), NET_CHAT_PLAYER
)
1451 MH_SEND_Chat('[' + gPlayer1Settings
.name
+ ']: ' + b_Text_Format(Line
),
1458 gJustChatted
:= True;
1459 g_Console_Chat_Switch
;
1460 InputReady
:= False;
1464 if not gChatShow
then
1466 IK_DOWN
, IK_KPDOWN
, VK_DOWN
, JOY0_DOWN
, JOY1_DOWN
, JOY2_DOWN
, JOY3_DOWN
:
1467 if not gChatShow
then
1468 if (CommandHistory
<> nil) and
1469 (CmdIndex
< Length(CommandHistory
)) then
1471 if CmdIndex
< Length(CommandHistory
)-1 then
1472 CmdIndex
:= CmdIndex
+ 1;
1473 Line
:= CommandHistory
[CmdIndex
];
1474 CPos
:= Length(Line
) + 1;
1476 IK_UP
, IK_KPUP
, VK_UP
, JOY0_UP
, JOY1_UP
, JOY2_UP
, JOY3_UP
:
1477 if not gChatShow
then
1478 if (CommandHistory
<> nil) and
1479 (CmdIndex
<= Length(CommandHistory
)) then
1481 if CmdIndex
> 0 then
1482 CmdIndex
:= CmdIndex
- 1;
1483 Line
:= CommandHistory
[CmdIndex
];
1484 Cpos
:= Length(Line
) + 1;
1486 IK_PAGEUP
, IK_KPPAGEUP
, VK_PREV
, JOY0_PREV
, JOY1_PREV
, JOY2_PREV
, JOY3_PREV
: // PgUp
1487 if not gChatShow
then Inc(conSkipLines
);
1488 IK_PAGEDN
, IK_KPPAGEDN
, VK_NEXT
, JOY0_NEXT
, JOY1_NEXT
, JOY2_NEXT
, JOY3_NEXT
: // PgDown
1489 if not gChatShow
and (conSkipLines
> 0) then Dec(conSkipLines
);
1493 CPos
:= Length(Line
) + 1;
1494 IK_A
..IK_Z
, IK_SPACE
, IK_SHIFT
, IK_RSHIFT
, IK_CAPSLOCK
, IK_LBRACKET
, IK_RBRACKET
,
1495 IK_SEMICOLON
, IK_QUOTE
, IK_BACKSLASH
, IK_SLASH
, IK_COMMA
, IK_DOT
, (*IK_EQUALS,*)
1496 IK_0
, IK_1
, IK_2
, IK_3
, IK_4
, IK_5
, IK_6
, IK_7
, IK_8
, IK_9
, IK_MINUS
, IK_EQUALS
:
1497 (* see TEXTINPUT event *)
1501 function GetStr(var Str
: AnsiString): AnsiString;
1506 if Str
[1] = '"' then
1508 for b
:= 1 to Length(Str
) do
1509 if (b
= Length(Str
)) or (Str
[b
+1] = '"') then
1511 Result
:= Copy(Str
, 2, b
-1);
1512 Delete(Str
, 1, b
+1);
1518 for a
:= 1 to Length(Str
) do
1519 if (a
= Length(Str
)) or (Str
[a
+1] = ' ') then
1521 Result
:= Copy(Str
, 1, a
);
1522 Delete(Str
, 1, a
+1);
1528 function ParseString(Str
: AnsiString): SSArray
;
1539 SetLength(Result
, Length(Result
)+1);
1540 Result
[High(Result
)] := GetStr(Str
);
1544 procedure g_Console_Add (L
: AnsiString; show
: Boolean=false);
1546 procedure conmsg (s
: AnsiString);
1550 if length(s
) = 0 then exit
;
1551 for a
:= 0 to High(MsgArray
) do
1563 for a
:= 0 to High(MsgArray
)-1 do MsgArray
[a
] := MsgArray
[a
+1];
1564 with MsgArray
[High(MsgArray
)] do
1574 // put it to console
1576 if (length(L
) = 0) or ((L
[length(L
)] <> #10) and (L
[length(L
)] <> #13)) then cbufPut(#10);
1578 // now show 'em out of console too
1579 show
:= show
and gAllowConsoleMessages
;
1580 if show
and gShowMessages
then
1582 // Âûâîä ñòðîê ñ ïåðåíîñàìè ïî î÷åðåäè
1583 while length(L
) > 0 do
1586 if f
<= 0 then f
:= length(L
)+1;
1587 conmsg(Copy(L
, 1, f
-1));
1592 //SetLength(ConsoleHistory, Length(ConsoleHistory)+1);
1593 //ConsoleHistory[High(ConsoleHistory)] := L;
1597 e_WriteLog('CON: ' + L, MSG_NOTIFY);
1604 consolewriterLastWasEOL
: Boolean = false;
1606 procedure consolewriter (constref buf
; len
: SizeUInt
);
1610 if (len
< 1) then exit
;
1612 consolewriterLastWasEOL
:= (b
[len
-1] = 13) or (b
[len
-1] = 10);
1615 if (b
[0] <> 13) and (b
[0] <> 10) then
1617 cbufPut(AnsiChar(b
[0]));
1621 if (len
> 1) and (b
[0] = 13) then begin len
-= 1; b
+= 1; end;
1630 // returns formatted string if `writerCB` is `nil`, empty string otherwise
1631 //function formatstrf (const fmt: AnsiString; args: array of const; writerCB: TFormatStrFCallback=nil): AnsiString;
1632 //TFormatStrFCallback = procedure (constref buf; len: SizeUInt);
1633 procedure conwriteln (const s
: AnsiString; show
: Boolean=false);
1635 g_Console_Add(s
, show
);
1639 procedure conwritefln (const s
: AnsiString; args
: array of const; show
: Boolean=false);
1643 g_Console_Add(formatstrf(s
, args
), true);
1647 consolewriterLastWasEOL
:= false;
1648 formatstrf(s
, args
, consolewriter
);
1649 if not consolewriterLastWasEOL
then cbufPut(#10);
1654 procedure g_Console_Clear();
1656 //ConsoleHistory := nil;
1661 procedure AddToHistory(L
: AnsiString);
1665 len
:= Length(CommandHistory
);
1668 (LowerCase(CommandHistory
[len
-1]) <> LowerCase(L
)) then
1670 SetLength(CommandHistory
, len
+1);
1671 CommandHistory
[len
] := L
;
1674 CmdIndex
:= Length(CommandHistory
);
1677 function g_Console_CommandBlacklisted(C
: AnsiString): Boolean;
1686 if Trim(C
) = '' then
1689 Arr
:= ParseString(C
);
1693 for i
:= 0 to High(Whitelist
) do
1694 if Whitelist
[i
] = LowerCase(Arr
[0]) then
1698 procedure g_Console_Process(L
: AnsiString; quiet
: Boolean = False);
1705 if Trim(L
) = '' then
1708 conSkipLines
:= 0; // "unscroll"
1710 if L
= 'goobers' then
1715 g_Console_Add('Your memory serves you well.');
1721 g_Console_Add('> '+L
);
1726 Arr
:= ParseString(L
);
1730 if commands
= nil then
1736 for i
:= 0 to High(commands
) do
1738 if commands
[i
].cmd
= LowerCase(Arr
[0]) then
1740 if commands
[i
].action
>= 0 then
1742 gPlayerAction
[commands
[i
].player
, commands
[i
].action
] := commands
[i
].cmd
[1] = '+';
1745 if assigned(commands
[i
].procEx
) then
1747 commands
[i
].procEx(@commands
[i
], Arr
);
1750 if assigned(commands
[i
].proc
) then
1752 commands
[i
].proc(Arr
);
1758 g_Console_Add(Format(_lc
[I_CONSOLE_UNKNOWN
], [Arr
[0]]));
1762 function g_Console_Interactive
: Boolean;
1764 Result
:= gConsoleShow
1767 procedure g_Console_BindKey (key
: Integer; down
: AnsiString; up
: AnsiString = ''; rep
: Boolean = False);
1769 //e_LogWritefln('bind "%s" "%s" <%s>', [LowerCase(e_KeyNames[key]), cmd, key]);
1771 ASSERT(key
< e_MaxInputKeys
);
1774 gInputBinds
[key
].rep
:= rep
;
1775 gInputBinds
[key
].down
:= ParseAlias(down
);
1776 gInputBinds
[key
].up
:= ParseAlias(up
);
1778 g_Console_WriteGameConfig();
1781 function g_Console_MatchBind (key
: Integer; down
: AnsiString; up
: AnsiString = ''): Boolean;
1783 function EqualsCommandLists (a
, b
: SSArray
): Boolean;
1784 var i
, len
: Integer;
1788 if len
= Length(b
) then
1791 while (i
< len
) and (a
[i
] = b
[i
]) do inc(i
);
1799 ASSERT(key
< e_MaxInputKeys
);
1800 result
:= EqualsCommandLists(ParseAlias(down
), gInputBinds
[key
].down
) and EqualsCommandLists(ParseAlias(up
), gInputBinds
[key
].up
)
1803 function g_Console_FindBind (n
: Integer; down
: AnsiString; up
: AnsiString = ''): Integer;
1808 if commands
= nil then Exit
;
1810 while (n
>= 1) and (i
< e_MaxInputKeys
) do
1812 if (i
< VK_FIRSTKEY
) or (i
> VK_LASTKEY
) then (* never show virtual keys in gui *)
1814 if g_Console_MatchBind(i
, down
, up
) then
1826 function g_Console_Action (action
: Integer): Boolean;
1827 var i
, len
: Integer;
1829 ASSERT(action
>= FIRST_ACTION
);
1830 ASSERT(action
<= LAST_ACTION
);
1832 len
:= Length(gPlayerAction
);
1833 while (i
< len
) and (not gPlayerAction
[i
, action
]) do inc(i
);
1837 function BindsAllowed (key
: Integer): Boolean;
1840 if (not g_GUIGrabInput
) and (key
>= 0) and (key
< e_MaxInputKeys
) and ((gInputBinds
[key
].down
<> nil) or (gInputBinds
[key
].up
<> nil)) then
1843 Result
:= g_Console_MatchBind(key
, 'togglemenu') or
1844 g_Console_MatchBind(key
, 'showkeyboard') or
1845 g_Console_MatchBind(key
, 'hidekeyboard')
1846 else if gConsoleShow
or (g_ActiveWindow
<> nil) or (gGameSettings
.GameType
= GT_NONE
) then
1847 Result
:= g_Console_MatchBind(key
, 'togglemenu') or
1848 g_Console_MatchBind(key
, 'toggleconsole') or
1849 g_Console_MatchBind(key
, 'showkeyboard') or
1850 g_Console_MatchBind(key
, 'hidekeyboard')
1856 procedure g_Console_ProcessBind (key
: Integer; down
: Boolean);
1859 if BindsAllowed(key
) then
1862 for i
:= 0 to High(gInputBinds
[key
].down
) do
1863 g_Console_Process(gInputBinds
[key
].down
[i
], True)
1865 for i
:= 0 to High(gInputBinds
[key
].up
) do
1866 g_Console_Process(gInputBinds
[key
].up
[i
], True)
1868 if down
and not menu_toggled
then
1870 menu_toggled
:= False
1873 procedure g_Console_ProcessBindRepeat (key
: Integer);
1876 if gConsoleShow
or gChatShow
or (g_ActiveWindow
<> nil) then
1878 KeyPress(key
); // key repeat in menus and shit
1881 if BindsAllowed(key
) and gInputBinds
[key
].rep
then
1883 for i
:= 0 to High(gInputBinds
[key
].down
) do
1884 g_Console_Process(gInputBinds
[key
].down
[i
], True);
1888 procedure g_Console_ResetBinds
;
1891 for i
:= 0 to e_MaxInputKeys
- 1 do
1892 g_Console_BindKey(i
, '', '');
1894 g_Console_BindKey(IK_GRAVE
, 'toggleconsole');
1895 g_Console_BindKey(IK_ESCAPE
, 'togglemenu');
1896 g_Console_BindKey(IK_A
, '+p1_moveleft', '-p1_moveleft');
1897 g_Console_BindKey(IK_D
, '+p1_moveright', '-p1_moveright');
1898 g_Console_BindKey(IK_W
, '+p1_lookup', '-p1_lookup');
1899 g_Console_BindKey(IK_S
, '+p1_lookdown', '-p1_lookdown');
1900 g_Console_BindKey(IK_SPACE
, '+p1_jump', '-p1_jump');
1901 g_Console_BindKey(IK_H
, '+p1_attack', '-p1_attack');
1902 g_Console_BindKey(IK_J
, '+p1_activate', '-p1_activate');
1903 g_Console_BindKey(IK_ALT
, '+p1_strafe', '-p1_strafe');
1904 g_Console_BindKey(IK_E
, 'p1_weapnext', '', True);
1905 g_Console_BindKey(IK_Q
, 'p1_weapprev', '', True);
1906 g_Console_BindKey(IK_R
, 'p1_dropflag', '');
1907 g_Console_BindKey(IK_1
, 'p1_weapon 1');
1908 g_Console_BindKey(IK_2
, 'p1_weapon 2');
1909 g_Console_BindKey(IK_3
, 'p1_weapon 3');
1910 g_Console_BindKey(IK_4
, 'p1_weapon 4');
1911 g_Console_BindKey(IK_5
, 'p1_weapon 5');
1912 g_Console_BindKey(IK_6
, 'p1_weapon 6');
1913 g_Console_BindKey(IK_7
, 'p1_weapon 7');
1914 g_Console_BindKey(IK_8
, 'p1_weapon 8');
1915 g_Console_BindKey(IK_9
, 'p1_weapon 9');
1916 g_Console_BindKey(IK_0
, 'p1_weapon 10');
1917 g_Console_BindKey(IK_MINUS
, 'p1_weapon 11');
1918 g_Console_BindKey(IK_T
, 'togglechat');
1919 g_Console_BindKey(IK_Y
, 'toggleteamchat');
1920 g_Console_BindKey(IK_F11
, 'screenshot');
1921 g_Console_BindKey(IK_TAB
, '+scores', '-scores');
1922 g_Console_BindKey(IK_PAUSE
, 'pause');
1923 g_Console_BindKey(IK_F1
, 'vote');
1925 (* for i := 0 to e_MaxJoys - 1 do *)
1928 g_Console_BindKey(e_JoyHatToKey(i
, 0, HAT_LEFT
), '+p' + IntToStr(i
mod 2 + 1) + '_moveleft', '-p' + IntToStr(i
mod 2 + 1) + '_moveleft');
1929 g_Console_BindKey(e_JoyHatToKey(i
, 0, HAT_RIGHT
), '+p' + IntToStr(i
mod 2 + 1) + '_moveright', '-p' + IntToStr(i
mod 2 + 1) + '_moveright');
1930 g_Console_BindKey(e_JoyHatToKey(i
, 0, HAT_UP
), '+p' + IntToStr(i
mod 2 + 1) + '_lookup', '-p' + IntToStr(i
mod 2 + 1) + '_lookup');
1931 g_Console_BindKey(e_JoyHatToKey(i
, 0, HAT_DOWN
), '+p' + IntToStr(i
mod 2 + 1) + '_lookdown', '-p' + IntToStr(i
mod 2 + 1) + '_lookdown');
1932 g_Console_BindKey(e_JoyButtonToKey(i
, 2), '+p' + IntToStr(i
mod 2 + 1) + '_jump', '-p' + IntToStr(i
mod 2 + 1) + '_jump');
1933 g_Console_BindKey(e_JoyButtonToKey(i
, 0), '+p' + IntToStr(i
mod 2 + 1) + '_attack', '-p' + IntToStr(i
mod 2 + 1) + '_attack');
1934 g_Console_BindKey(e_JoyButtonToKey(i
, 3), '+p' + IntToStr(i
mod 2 + 1) + '_activate', '-p' + IntToStr(i
mod 2 + 1) + '_activate');
1935 g_Console_BindKey(e_JoyButtonToKey(i
, 7), '+p' + IntToStr(i
mod 2 + 1) + '_strafe', '-p' + IntToStr(i
mod 2 + 1) + '_strafe');
1936 g_Console_BindKey(e_JoyButtonToKey(i
, 1), 'p' + IntToStr(i
mod 2 + 1) + '_weapnext', '', True);
1937 g_Console_BindKey(e_JoyButtonToKey(i
, 4), 'p' + IntToStr(i
mod 2 + 1) + '_weapprev', '', True);
1938 g_Console_BindKey(e_JoyButtonToKey(i
, 10), 'togglemenu');
1941 g_Console_BindKey(VK_ESCAPE
, 'togglemenu');
1942 g_Console_BindKey(VK_LSTRAFE
, '+moveleft; +strafe', '-moveleft; -strafe');
1943 g_Console_BindKey(VK_RSTRAFE
, '+moveright; +strafe', '-moveright; -strafe');
1944 g_Console_BindKey(VK_LEFT
, '+moveleft', '-moveleft');
1945 g_Console_BindKey(VK_RIGHT
, '+moveright', '-moveright');
1946 g_Console_BindKey(VK_UP
, '+lookup', '-lookup');
1947 g_Console_BindKey(VK_DOWN
, '+lookdown', '-lookdown');
1948 g_Console_BindKey(VK_JUMP
, '+jump', '-jump');
1949 g_Console_BindKey(VK_FIRE
, '+attack', '-attack');
1950 g_Console_BindKey(VK_OPEN
, '+activate', '-activate');
1951 g_Console_BindKey(VK_STRAFE
, '+strafe', '-strafe');
1952 g_Console_BindKey(VK_NEXT
, 'weapnext', '', True);
1953 g_Console_BindKey(VK_PREV
, 'weapprev', '', True);
1954 g_Console_BindKey(VK_0
, 'weapon 1');
1955 g_Console_BindKey(VK_1
, 'weapon 2');
1956 g_Console_BindKey(VK_2
, 'weapon 3');
1957 g_Console_BindKey(VK_3
, 'weapon 4');
1958 g_Console_BindKey(VK_4
, 'weapon 5');
1959 g_Console_BindKey(VK_5
, 'weapon 6');
1960 g_Console_BindKey(VK_6
, 'weapon 7');
1961 g_Console_BindKey(VK_7
, 'weapon 8');
1962 g_Console_BindKey(VK_8
, 'weapon 9');
1963 g_Console_BindKey(VK_9
, 'weapon 10');
1964 g_Console_BindKey(VK_A
, 'weapon 11');
1965 g_Console_BindKey(VK_CHAT
, 'togglechat');
1966 g_Console_BindKey(VK_TEAM
, 'toggleteamchat');
1967 g_Console_BindKey(VK_CONSOLE
, 'toggleconsole');
1968 g_Console_BindKey(VK_PRINTSCR
, 'screenshot');
1969 g_Console_BindKey(VK_STATUS
, '+scores', '-scores');
1970 g_Console_BindKey(VK_SHOWKBD
, 'showkeyboard');
1971 g_Console_BindKey(VK_HIDEKBD
, 'hidekeyboard');
1974 procedure g_Console_ReadConfig (filename
: String);
1975 var f
: TextFile
; s
: AnsiString; i
, len
: Integer;
1977 e_LogWritefln('g_Console_ReadConfig (1) "%s"', [filename
]);
1978 if e_FindResource(ConfigDirs
, filename
, false) = true then
1980 e_LogWritefln('g_Console_ReadConfig (2) "%s"', [filename
]);
1981 AssignFile(f
, filename
);
1991 while (i
<= len
) and (s
[i
] <= ' ') do inc(i
);
1993 if (i
<= len
) and ((s
[i
] <> '#') and ((i
+ 1 > len
) or (s
[i
] <> '/') or (s
[i
+ 1] <> '/'))) then
1994 g_Console_Process(s
, True);
2001 procedure g_Console_WriteConfig (filename
: String);
2002 var f
: TextFile
; i
, j
: Integer;
2004 procedure WriteFlag(name
: string; flag
: LongWord);
2006 WriteLn(f
, name
, IfThen(LongBool(gsGameFlags
and flag
), 1, 0));
2009 function FormatTeam(team
: Byte): string;
2011 if team
= TEAM_BLUE
then
2018 AssignFile(f
, filename
);
2020 WriteLn(f
, '// ' + configComment
);
2023 WriteLn(f
, 'unbindall');
2024 for i
:= 0 to e_MaxInputKeys
- 1 do
2025 if (Length(gInputBinds
[i
].down
) > 0) or (Length(gInputBinds
[i
].up
) > 0) then
2027 Write(f
, 'bind ', e_KeyNames
[i
], ' ', QuoteStr(GetCommandString(gInputBinds
[i
].down
)));
2028 if Length(gInputBinds
[i
].down
) = 0 then
2030 if Length(gInputBinds
[i
].up
) > 0 then
2031 Write(f
, ' ', QuoteStr(GetCommandString(gInputBinds
[i
].up
)));
2033 if gInputBinds
[i
].rep
then
2034 WriteLn(f
, 'bindrep ', e_KeyNames
[i
]);
2038 if gAskLanguage
then
2039 WriteLn(f
, 'g_language ask')
2041 WriteLn(f
, 'g_language ', gLanguage
);
2044 WriteLn(f
, 'sv_name ', QuoteStr(NetServerName
));
2045 WriteLn(f
, 'sv_passwd ', QuoteStr(NetPassword
));
2046 WriteLn(f
, 'sv_maxplrs ', NetMaxClients
);
2047 WriteLn(f
, 'sv_port ', NetPort
);
2048 WriteLn(f
, 'sv_public ', IfThen(NetUseMaster
, 1, 0));
2051 WriteLn(f
, 'g_max_particles ', g_GFX_GetMax());
2052 WriteLn(f
, 'g_max_shells ', g_Shells_GetMax());
2053 WriteLn(f
, 'g_max_gibs ', g_Gibs_GetMax());
2054 WriteLn(f
, 'g_max_corpses ', g_Corpses_GetMax());
2055 WriteLn(f
, 'g_force_model ', g_Force_Model_Get());
2056 WriteLn(f
, 'g_force_model_name ', g_Forced_Model_GetName());
2057 WriteLn(f
, 'sv_intertime ', gDefInterTime
);
2059 // gameplay settings
2060 WriteLn(f
, 'g_gamemode ', gsGameMode
);
2061 WriteLn(f
, 'g_scorelimit ', gsScoreLimit
);
2062 WriteLn(f
, 'g_timelimit ', gsTimeLimit
);
2063 WriteLn(f
, 'g_maxlives ', gsMaxLives
);
2064 WriteLn(f
, 'g_item_respawn_time ', gsItemRespawnTime
);
2065 WriteLn(f
, 'g_spawn_invul ', gsSpawnInvul
);
2066 WriteLn(f
, 'g_warmup_time ', gsWarmupTime
);
2068 WriteFlag('g_friendlyfire ', GAME_OPTION_TEAMDAMAGE
);
2069 WriteFlag('g_friendly_hit_trace ', GAME_OPTION_TEAMHITTRACE
);
2070 WriteFlag('g_friendly_hit_projectile ', GAME_OPTION_TEAMHITPROJECTILE
);
2071 WriteFlag('g_allow_exit ', GAME_OPTION_ALLOWEXIT
);
2072 WriteFlag('g_allow_monsters ', GAME_OPTION_MONSTERS
);
2073 WriteFlag('g_allow_dropflag ', GAME_OPTION_ALLOWDROPFLAG
);
2074 WriteFlag('g_throw_flag ', GAME_OPTION_THROWFLAG
);
2075 WriteFlag('g_dm_keys ', GAME_OPTION_DMKEYS
);
2076 WriteFlag('g_weaponstay ', GAME_OPTION_WEAPONSTAY
);
2077 WriteFlag('g_bot_vsmonsters ', GAME_OPTION_BOTVSMONSTER
);
2078 WriteFlag('g_bot_vsplayers ', GAME_OPTION_BOTVSPLAYER
);
2081 with gPlayer1Settings
do
2083 WriteLn(f
, 'p1_name ', QuoteStr(Name
));
2084 WriteLn(f
, 'p1_color ', Color
.R
, ' ', Color
.G
, ' ', Color
.B
);
2085 WriteLn(f
, 'p1_model ', QuoteStr(Model
));
2086 WriteLn(f
, 'p1_team ', FormatTeam(Team
));
2087 WriteLn(f
, 'p1_autoswitch ', WeaponSwitch
);
2088 WriteLn(f
, 'p1_switch_empty ', SwitchToEmpty
);
2089 WriteLn(f
, 'p1_priority_kastet ', Max(0, WeaponPreferences
[WEAPON_KASTET
]));
2090 WriteLn(f
, 'p1_priority_saw ', Max(0, WeaponPreferences
[WEAPON_SAW
]));
2091 WriteLn(f
, 'p1_priority_pistol ', Max(0, WeaponPreferences
[WEAPON_PISTOL
]));
2092 WriteLn(f
, 'p1_priority_shotgun1 ', Max(0, WeaponPreferences
[WEAPON_SHOTGUN1
]));
2093 WriteLn(f
, 'p1_priority_shotgun2 ', Max(0, WeaponPreferences
[WEAPON_SHOTGUN2
] ));
2094 WriteLn(f
, 'p1_priority_chaingun ', Max(0, WeaponPreferences
[WEAPON_CHAINGUN
]));
2095 WriteLn(f
, 'p1_priority_rocketlauncher ', Max(0, WeaponPreferences
[WEAPON_ROCKETLAUNCHER
]));
2096 WriteLn(f
, 'p1_priority_plasma ', Max(0, WeaponPreferences
[WEAPON_PLASMA
]));
2097 WriteLn(f
, 'p1_priority_bfg ', Max(0, WeaponPreferences
[WEAPON_BFG
]));
2098 WriteLn(f
, 'p1_priority_super ', Max(0, WeaponPreferences
[WEAPON_SUPERPULEMET
]));
2099 WriteLn(f
, 'p1_priority_flamethrower ', Max(0, WeaponPreferences
[WEAPON_FLAMETHROWER
]));
2100 WriteLn(f
, 'p1_priority_berserk ', Max(0, WeaponPreferences
[WP_LAST
+1]));
2103 with gPlayer2Settings
do
2105 WriteLn(f
, 'p2_name ', QuoteStr(Name
));
2106 WriteLn(f
, 'p2_color ', Color
.R
, ' ', Color
.G
, ' ', Color
.B
);
2107 WriteLn(f
, 'p2_model ', QuoteStr(Model
));
2108 WriteLn(f
, 'p2_team ', FormatTeam(Team
));
2109 WriteLn(f
, 'p2_autoswitch ', WeaponSwitch
);
2110 WriteLn(f
, 'p2_switch_empty ', SwitchToEmpty
);
2111 WriteLn(f
, 'p2_priority_kastet ', Max(0, WeaponPreferences
[WEAPON_KASTET
]));
2112 WriteLn(f
, 'p2_priority_saw ', Max(0, WeaponPreferences
[WEAPON_SAW
]));
2113 WriteLn(f
, 'p2_priority_pistol ', Max(0, WeaponPreferences
[WEAPON_PISTOL
]));
2114 WriteLn(f
, 'p2_priority_shotgun1 ', Max(0, WeaponPreferences
[WEAPON_SHOTGUN1
]));
2115 WriteLn(f
, 'p2_priority_shotgun2 ', Max(0, WeaponPreferences
[WEAPON_SHOTGUN1
]));
2116 WriteLn(f
, 'p2_priority_chaingun ', Max(0, WeaponPreferences
[WEAPON_CHAINGUN
]));
2117 WriteLn(f
, 'p2_priority_rocketlauncher ', Max(0, WeaponPreferences
[WEAPON_ROCKETLAUNCHER
]));
2118 WriteLn(f
, 'p2_priority_plasma ', Max(0, WeaponPreferences
[WEAPON_PLASMA
]));
2119 WriteLn(f
, 'p2_priority_bfg ', Max(0, WeaponPreferences
[WEAPON_BFG
]));
2120 WriteLn(f
, 'p2_priority_super ', Max(0, WeaponPreferences
[WEAPON_SUPERPULEMET
]));
2121 WriteLn(f
, 'p2_priority_flamethrower ', Max(0, WeaponPreferences
[WEAPON_FLAMETHROWER
]));
2122 WriteLn(f
, 'p2_priority_berserk ', Max(0, WeaponPreferences
[WP_LAST
+1]));
2126 for i
:= 0 to High(commands
) do
2128 if not commands
[i
].cheat
then
2130 if @commands
[i
].procEx
= @boolVarHandler
then
2132 if PBoolean(commands
[i
].ptr
)^ then j
:= 1 else j
:= 0;
2133 WriteLn(f
, commands
[i
].cmd
, ' ', j
)
2135 else if @commands
[i
].procEx
= @intVarHandler
then
2137 WriteLn(f
, commands
[i
].cmd
, ' ', PInteger(commands
[i
].ptr
)^)
2139 else if @commands
[i
].procEx
= @wordVarHandler
then
2141 WriteLn(f
, commands
[i
].cmd
, ' ', PWord(commands
[i
].ptr
)^)
2143 else if @commands
[i
].procEx
= @dwordVarHandler
then
2145 WriteLn(f
, commands
[i
].cmd
, ' ', PCardinal(commands
[i
].ptr
)^)
2147 else if @commands
[i
].procEx
= @singleVarHandler
then
2149 WriteLn(f
, commands
[i
].cmd
, ' ', PVarSingle(commands
[i
].ptr
).val
^:0:6)
2151 else if @commands
[i
].procEx
= @strVarHandler
then
2153 if Length(PAnsiString(commands
[i
].ptr
)^) = 0 then
2154 WriteLn(f
, commands
[i
].cmd
, ' ""')
2156 WriteLn(f
, commands
[i
].cmd
, ' ', QuoteStr(PAnsiString(commands
[i
].ptr
)^))
2161 WriteLn(f
, 'r_maxfps ', gMaxFPS
);
2162 WriteLn(f
, 'r_reset');
2166 procedure g_Console_WriteGameConfig
;
2169 if gParsingBinds
= false then
2171 s
:= e_GetWriteableDir(ConfigDirs
);
2172 g_Console_WriteConfig(e_CatPath(s
, gConfigScript
))
2179 conRegVar('console_stdin', @ConsoleStdIn
, 'enable reading commands from stdin', 'enable reading commands from stdin');
2181 ConsoleStdIn
:= True;
2183 ConsoleStdIn
:= False;
2185 conRegVar('d_eres', @debug_e_res
, '', '');
2186 for i
:= 1 to e_MaxJoys
do
2187 conRegVar('joy' + IntToStr(i
) + '_deadzone', @e_JoystickDeadzones
[i
- 1], '', '')
2196 conbufStdOutRawMode
:= false;