summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d1fb1fc)
raw | patch | inline | side by side (parent: d1fb1fc)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 25 Aug 2017 01:42:59 +0000 (04:42 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 25 Aug 2017 01:43:29 +0000 (04:43 +0300) |
src/game/g_console.pas | patch | blob | history | |
src/game/g_game.pas | patch | blob | history | |
src/shared/MAPDEF.pas | patch | blob | history |
diff --git a/src/game/g_console.pas b/src/game/g_console.pas
index 0668507b333bf73cd52bfb3e763705adddbc115d..d16d9d606b8fd637044548619cd9a04ae9972938 100644 (file)
--- a/src/game/g_console.pas
+++ b/src/game/g_console.pas
interface
+uses
+ wadreader; // for SArray
+
procedure g_Console_Init();
procedure g_Console_Update();
procedure g_Console_Draw();
procedure conwriteln (const s: AnsiString; show: Boolean=false);
procedure conwritefln (const s: AnsiString; args: array of const; show: Boolean=false);
+// <0: no arg; 0/1: true/false
+function conGetBoolArg (P: SArray; idx: Integer): Integer;
+
procedure g_Console_Chat_Switch(Team: Boolean = False);
+procedure conRegVar (const conname: AnsiString; pvar: PBoolean; const ahelp: AnsiString; const amsg: AnsiString; acheat: Boolean=false);
+
+
var
gConsoleShow: Boolean; // True - êîíñîëü îòêðûòà èëè îòêðûâàåòñÿ
gChatShow: Boolean;
uses
g_textures, g_main, e_graphics, e_input, g_game,
- SysUtils, g_basic, g_options, wadreader, Math,
+ SysUtils, g_basic, g_options, Math,
g_menu, g_language, g_net, g_netmsg, e_log, conbuf, utils;
type
+ PCommand = ^TCommand;
+
TCmdProc = procedure (P: SArray);
+ TCmdProcEx = procedure (me: PCommand; P: SArray);
TCommand = record
Cmd: String;
Proc: TCmdProc;
+ ProcEx: TCmdProcEx;
help: String;
hidden: Boolean;
+ ptr: Pointer; // various data
+ msg: AnsiString; // message for var changes
+ cheat: Boolean;
end;
TAlias = record
Commands: SArray;
end;
+
const
Step = 32;
Alpha = 25;
//ConsoleHistory: SArray;
CommandHistory: SArray;
Whitelist: SArray;
- Commands: Array of TCommand;
- Aliases: Array of TAlias;
+ Commands: Array of TCommand = nil;
+ Aliases: Array of TAlias = nil;
CmdIndex: Word;
conSkipLines: Integer = 0;
MsgArray: Array [0..4] of record
Time: Word;
end;
+
+// <0: no arg; 0/1: true/false
+function conGetBoolArg (P: SArray; idx: Integer): Integer;
+begin
+ if (idx < 0) or (idx > High(P)) then begin result := -1; exit; end;
+ result := 0;
+ if (P[idx] = '1') or (CompareText(P[idx], 'on') = 0) or (CompareText(P[idx], 'true') = 0) or
+ (CompareText(P[idx], 'tan') = 0) or (CompareText(P[idx], 'yes') = 0) then result := 1;
+end;
+
+
+procedure boolVarHandler (me: PCommand; P: SArray);
+
+ procedure binaryFlag (var flag: Boolean; msg: string);
+ begin
+ if (Length(p) > 2) then
+ begin
+ conwritefln('too many arguments to ''%s''', [P[0]]);
+ end
+ else
+ begin
+ case conGetBoolArg(P, 1) of
+ -1: begin end;
+ 0: if conIsCheatsEnabled then flag := false else begin conwriteln('not available'); exit; end;
+ 1: if conIsCheatsEnabled then flag := true else begin conwriteln('not available'); exit; end;
+ end;
+ if flag then conwritefln('%s: tan', [msg]) else conwritefln('%s: ona', [msg]);
+ end;
+ end;
+
+begin
+ binaryFlag(PBoolean(me.ptr)^, me.msg);
+end;
+
+
+procedure conRegVar (const conname: AnsiString; pvar: PBoolean; const ahelp: AnsiString; const amsg: AnsiString; acheat: Boolean=false);
+var
+ f: Integer;
+ cp: PCommand;
+begin
+ f := Length(Commands);
+ SetLength(Commands, f+1);
+ cp := @Commands[f];
+ cp.Cmd := LowerCase(conname);
+ cp.Proc := nil;
+ cp.ProcEx := boolVarHandler;
+ cp.help := ahelp;
+ cp.hidden := false;
+ cp.ptr := pvar;
+ cp.msg := amsg;
+ cp.cheat := acheat;
+end;
+
+
function GetStrACmd(var Str: String): String;
var
a: Integer;
Whitelist[a] := LowerCase(Cmd);
end;
-procedure AddCommand(Cmd: String; Proc: TCmdProc; ahelp: String=''; ahidden: Boolean=false);
+procedure AddCommand(Cmd: String; Proc: TCmdProc; ahelp: String=''; ahidden: Boolean=false; acheat: Boolean=false);
var
a: Integer;
+ cp: PCommand;
begin
SetLength(Commands, Length(Commands)+1);
a := High(Commands);
- Commands[a].Cmd := LowerCase(Cmd);
- Commands[a].Proc := Proc;
- Commands[a].hidden := ahidden;
- Commands[a].help := ahelp;
+ cp := @Commands[a];
+ cp.Cmd := LowerCase(Cmd);
+ cp.Proc := Proc;
+ cp.ProcEx := nil;
+ cp.help := ahelp;
+ cp.hidden := ahidden;
+ cp.ptr := nil;
+ cp.msg := '';
+ cp.cheat := acheat;
end;
procedure g_Console_Init();
AddCommand('d_player', DebugCommands);
AddCommand('d_joy', DebugCommands);
- AddCommand('pf_draw_frame', ProfilerCommands, 'draw frame rendering profiles');
- //AddCommand('pf_update_frame', ProfilerCommands);
- AddCommand('pf_coldet', ProfilerCommands, 'draw collision detection profiles');
- AddCommand('pf_los', ProfilerCommands, 'draw monster LOS profiles');
- AddCommand('r_sq_draw', ProfilerCommands, 'accelerated spatial queries in rendering');
- AddCommand('cd_sq_enabled', ProfilerCommands, 'accelerated spatial queries in map coldet');
- AddCommand('mon_sq_enabled', ProfilerCommands, 'use accelerated spatial queries for monsters');
- AddCommand('wtrace_sq_enabled', ProfilerCommands, 'use accelerated weapon hitscan trace');
-
- AddCommand('pr_enabled', ProfilerCommands, 'enable/disable particles');
- AddCommand('pr_phys_enabled', ProfilerCommands, 'enable/disable particle physics');
- AddCommand('los_enabled', ProfilerCommands, 'enable/disable LOS calculations');
-
- AddCommand('mon_think', ProfilerCommands, 'enable/disable monster thinking');
- AddCommand('dbg_holmes', ProfilerCommands, 'turn Holmes on/off');
-
AddCommand('p1_name', GameCVars);
AddCommand('p2_name', GameCVars);
AddCommand('p1_color', GameCVars);
AddToHistory(L);
for i := 0 to High(Commands) do
+ begin
if Commands[i].Cmd = LowerCase(Arr[0]) then
- if @Commands[i].Proc <> nil then
+ begin
+ if assigned(Commands[i].ProcEx) then
+ begin
+ Commands[i].ProcEx(@Commands[i], Arr);
+ exit;
+ end;
+ if assigned(Commands[i].Proc) then
begin
Commands[i].Proc(Arr);
- Exit;
+ exit;
end;
+ end;
+ end;
g_Console_Add(Format(_lc[I_CONSOLE_UNKNOWN], [Arr[0]]));
end;
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 02a46f2c4ab9cb90ae13a484b6b08ca7a590770f..75d2693b590e8c317a239c70d27d2a85967b7db6 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
procedure GameCommands(P: SArray);
procedure GameCheats(P: SArray);
procedure DebugCommands(P: SArray);
-procedure ProfilerCommands(P: SArray);
+//procedure ProfilerCommands(P: SArray);
procedure g_Game_Process_Params;
procedure g_Game_SetLoadingText(Text: String; Max: Integer; reWrite: Boolean);
procedure g_Game_StepLoading();
procedure g_AddDynLight (x, y, radius: Integer; r, g, b, a: Single);
procedure g_DynLightExplosion (x, y, radius: Integer; r, g, b: Single);
+function conIsCheatsEnabled (): Boolean;
+
implementation
utils, sfs, g_holmes;
+// ////////////////////////////////////////////////////////////////////////// //
+function conIsCheatsEnabled (): Boolean;
+begin
+ result := false;
+ if (not gGameOn) or (not gCheats) or ((gGameSettings.GameType <> GT_SINGLE) and
+ (gGameSettings.GameMode <> GM_COOP) and (not gDebugMode)) or g_Game_IsNet then exit;
+ result := true;
+end;
+
+
// ////////////////////////////////////////////////////////////////////////// //
var
profileFrameDraw: TProfiler = nil;
end;
end;
+(*
// profiler console commands
procedure ProfilerCommands (P: SArray);
var
if (cmd = 'mon_think') then begin binaryFlag(gmon_debug_think, 'monster thinking'); exit; end;
if (cmd = 'dbg_holmes') then begin binaryFlag(g_holmes_enabled, 'Holmes'); exit; end;
end;
-
+*)
procedure DebugCommands(P: SArray);
var
SetLength(pars, 0);
end;
+begin
+ conRegVar('pf_draw_frame', @g_profile_frame_draw, 'draw frame rendering profiles', 'render profiles');
+ //conRegVar('pf_update_frame', @g_profile_frame_update, 'draw frame updating profiles', 'update profiles');
+ conRegVar('pf_coldet', @g_profile_collision, 'draw collision detection profiles', 'coldet profiles');
+ conRegVar('pf_los', @g_profile_los, 'draw monster LOS profiles', 'monster LOS profiles');
+
+ conRegVar('r_sq_draw', @gdbg_map_use_accel_render, 'accelerated spatial queries in rendering', 'accelerated rendering');
+ conRegVar('cd_sq_enabled', @gdbg_map_use_accel_coldet, 'accelerated spatial queries in map coldet', 'accelerated map coldet');
+ conRegVar('mon_sq_enabled', @gmon_debug_use_sqaccel, 'accelerated spatial queries for monsters', 'accelerated monster coldet');
+ conRegVar('wtrace_sq_enabled', @gwep_debug_fast_trace, 'accelerated spatial queries for weapon hitscan trace', 'accelerated weapon hitscan');
+
+ conRegVar('pr_enabled', @gpart_dbg_enabled, 'enable/disable particles', 'particles');
+ conRegVar('pr_phys_enabled', @gpart_dbg_phys_enabled, 'enable/disable particle physics', 'particle physics');
+
+ conRegVar('los_enabled', @gmon_dbg_los_enabled, 'enable/disable monster LOS calculations', 'monster LOS', true);
+ conRegVar('mon_think', @gmon_debug_think, 'enable/disable monster thinking', 'monster thinking', true);
+
+ conRegVar('dbg_holmes', @g_holmes_enabled, 'enable/disable Holmes', 'Holmes', true);
end.
diff --git a/src/shared/MAPDEF.pas b/src/shared/MAPDEF.pas
index 640b69d4ddbedc5569e756916dcad1ab29349c3c..f6678e921683bb659ec77dd3a6805658f21fb0b2 100644 (file)
--- a/src/shared/MAPDEF.pas
+++ b/src/shared/MAPDEF.pas
uses
MAPSTRUCT;
+// *** WARNING! ***
+// keep all constants in sync with "mapdesc.txt"!
+// or even better: regenerate this part directly from "mapdesc.txt".
const
PANEL_NONE = 0;
PANEL_WALL = 1;