prvm_eval_t prvm_badvalue; // used only for error returns
-cvar_t prvm_language = {CVAR_SAVE, "prvm_language", "", "when set, loads PROGSFILE.LANGUAGENAME.po and common.LANGUAGENAME.po for string translations; when set to dump, PROGSFILE.pot is written from the strings in the progs"};
-// LordHavoc: prints every opcode as it executes - warning: this is significant spew
-cvar_t prvm_traceqc = {0, "prvm_traceqc", "0", "prints every QuakeC statement as it is executed (only for really thorough debugging!)"};
-// LordHavoc: counts usage of each QuakeC statement
-cvar_t prvm_statementprofiling = {0, "prvm_statementprofiling", "0", "counts how many times each QuakeC statement has been executed, these counts are displayed in prvm_printfunction output (if enabled)"};
-cvar_t prvm_timeprofiling = {0, "prvm_timeprofiling", "0", "counts how long each function has been executed, these counts are displayed in prvm_profile output (if enabled)"};
-cvar_t prvm_coverage = {0, "prvm_coverage", "0", "report and count coverage events (1: per-function, 2: coverage() builtin, 4: per-statement)"};
-cvar_t prvm_backtraceforwarnings = {0, "prvm_backtraceforwarnings", "0", "print a backtrace for warnings too"};
-cvar_t prvm_leaktest = {0, "prvm_leaktest", "0", "try to detect memory leaks in strings or entities"};
-cvar_t prvm_leaktest_follow_targetname = {0, "prvm_leaktest_follow_targetname", "0", "if set, target/targetname links are considered when leak testing; this should normally not be required, as entities created during startup - e.g. info_notnull - are never considered leaky"};
-cvar_t prvm_leaktest_ignore_classnames = {0, "prvm_leaktest_ignore_classnames", "", "classnames of entities to NOT leak check because they are found by find(world, classname, ...) but are actually spawned by QC code (NOT map entities)"};
-cvar_t prvm_errordump = {0, "prvm_errordump", "0", "write a savegame on crash to crash-server.dmp"};
-cvar_t prvm_breakpointdump = {0, "prvm_breakpointdump", "0", "write a savegame on breakpoint to breakpoint-server.dmp"};
-cvar_t prvm_reuseedicts_startuptime = {0, "prvm_reuseedicts_startuptime", "2", "allows immediate re-use of freed entity slots during start of new level (value in seconds)"};
-cvar_t prvm_reuseedicts_neverinsameframe = {0, "prvm_reuseedicts_neverinsameframe", "1", "never allows re-use of freed entity slots during same frame"};
+cvar_t prvm_language = {CVAR_CLIENT | CVAR_SERVER | CVAR_SAVE, "prvm_language", "", "when set, loads PROGSFILE.LANGUAGENAME.po and common.LANGUAGENAME.po for string translations; when set to dump, PROGSFILE.pot is written from the strings in the progs"};
+// LadyHavoc: prints every opcode as it executes - warning: this is significant spew
+cvar_t prvm_traceqc = {CVAR_CLIENT | CVAR_SERVER, "prvm_traceqc", "0", "prints every QuakeC statement as it is executed (only for really thorough debugging!)"};
+// LadyHavoc: counts usage of each QuakeC statement
+cvar_t prvm_statementprofiling = {CVAR_CLIENT | CVAR_SERVER, "prvm_statementprofiling", "0", "counts how many times each QuakeC statement has been executed, these counts are displayed in prvm_printfunction output (if enabled)"};
+cvar_t prvm_timeprofiling = {CVAR_CLIENT | CVAR_SERVER, "prvm_timeprofiling", "0", "counts how long each function has been executed, these counts are displayed in prvm_profile output (if enabled)"};
+cvar_t prvm_coverage = {CVAR_CLIENT | CVAR_SERVER, "prvm_coverage", "0", "report and count coverage events (1: per-function, 2: coverage() builtin, 4: per-statement)"};
+cvar_t prvm_backtraceforwarnings = {CVAR_CLIENT | CVAR_SERVER, "prvm_backtraceforwarnings", "0", "print a backtrace for warnings too"};
+cvar_t prvm_leaktest = {CVAR_CLIENT | CVAR_SERVER, "prvm_leaktest", "0", "try to detect memory leaks in strings or entities"};
+cvar_t prvm_leaktest_follow_targetname = {CVAR_CLIENT | CVAR_SERVER, "prvm_leaktest_follow_targetname", "0", "if set, target/targetname links are considered when leak testing; this should normally not be required, as entities created during startup - e.g. info_notnull - are never considered leaky"};
+cvar_t prvm_leaktest_ignore_classnames = {CVAR_CLIENT | CVAR_SERVER, "prvm_leaktest_ignore_classnames", "", "classnames of entities to NOT leak check because they are found by find(world, classname, ...) but are actually spawned by QC code (NOT map entities)"};
+cvar_t prvm_errordump = {CVAR_CLIENT | CVAR_SERVER, "prvm_errordump", "0", "write a savegame on crash to crash-server.dmp"};
+cvar_t prvm_breakpointdump = {CVAR_CLIENT | CVAR_SERVER, "prvm_breakpointdump", "0", "write a savegame on breakpoint to breakpoint-server.dmp"};
+cvar_t prvm_reuseedicts_startuptime = {CVAR_CLIENT | CVAR_SERVER, "prvm_reuseedicts_startuptime", "2", "allows immediate re-use of freed entity slots during start of new level (value in seconds)"};
+cvar_t prvm_reuseedicts_neverinsameframe = {CVAR_CLIENT | CVAR_SERVER, "prvm_reuseedicts_neverinsameframe", "1", "never allows re-use of freed entity slots during same frame"};
static double prvm_reuseedicts_always_allow = 0;
qboolean prvm_runawaycheck = true;
dpsnprintf (line, linelength, "entity %i", n);
break;
case ev_function:
- f = prog->functions + val->function;
- dpsnprintf (line, linelength, "%s()", PRVM_GetString(prog, f->s_name));
+ if ((unsigned int)val->function < (unsigned int)prog->progs_numfunctions)
+ {
+ f = prog->functions + val->function;
+ dpsnprintf (line, linelength, "%s()", PRVM_GetString(prog, f->s_name));
+ }
+ else
+ dpsnprintf (line, linelength, "function%i() (invalid!)", val->function);
break;
case ev_field:
def = PRVM_ED_FieldAtOfs ( prog, val->_int );
- dpsnprintf (line, linelength, ".%s", PRVM_GetString(prog, def->s_name));
+ if (def != NULL)
+ dpsnprintf (line, linelength, ".%s", PRVM_GetString(prog, def->s_name));
+ else
+ dpsnprintf (line, linelength, "field%i (invalid!)", val->_int );
break;
case ev_void:
dpsnprintf (line, linelength, "void");
break;
case ev_float:
- // LordHavoc: changed from %5.1f to %10.4f
+ // LadyHavoc: changed from %5.1f to %10.4f
dpsnprintf (line, linelength, FLOAT_LOSSLESS_FORMAT, val->_float);
break;
case ev_vector:
- // LordHavoc: changed from %5.1f to %10.4f
+ // LadyHavoc: changed from %5.1f to %10.4f
dpsnprintf (line, linelength, "'" VECTOR_LOSSLESS_FORMAT "'", val->vector[0], val->vector[1], val->vector[2]);
break;
case ev_pointer:
dpsnprintf (line, linelength, "%i", i);
break;
case ev_function:
- f = prog->functions + val->function;
- strlcpy (line, PRVM_GetString (prog, f->s_name), linelength);
+ if ((unsigned int)val->function < (unsigned int)prog->progs_numfunctions)
+ {
+ f = prog->functions + val->function;
+ strlcpy (line, PRVM_GetString (prog, f->s_name), linelength);
+ }
+ else
+ dpsnprintf (line, linelength, "bad function %i (invalid!)", val->function);
break;
case ev_field:
def = PRVM_ED_FieldAtOfs ( prog, val->_int );
- dpsnprintf (line, linelength, ".%s", PRVM_GetString(prog, def->s_name));
+ if (def != NULL)
+ dpsnprintf (line, linelength, ".%s", PRVM_GetString(prog, def->s_name));
+ else
+ dpsnprintf (line, linelength, "field%i (invalid!)", val->_int );
break;
case ev_void:
dpsnprintf (line, linelength, "void");
For debugging
=============
*/
-// LordHavoc: optimized this to print out much more quickly (tempstring)
-// LordHavoc: changed to print out every 4096 characters (incase there are a lot of fields to print)
+// LadyHavoc: optimized this to print out much more quickly (tempstring)
+// LadyHavoc: changed to print out every 4096 characters (incase there are a lot of fields to print)
void PRVM_ED_Print(prvm_prog_t *prog, prvm_edict_t *ed, const char *wildcard_fieldname)
{
size_t l;
For debugging, prints all the entities in the current server
=============
*/
-void PRVM_ED_PrintEdicts_f (void)
+void PRVM_ED_PrintEdicts_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
int i;
const char *wildcard_fieldname;
- if(Cmd_Argc() < 2 || Cmd_Argc() > 3)
+ if(Cmd_Argc(cmd) < 2 || Cmd_Argc(cmd) > 3)
{
Con_Print("prvm_edicts <program name> <optional field name wildcard>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- if( Cmd_Argc() == 3)
- wildcard_fieldname = Cmd_Argv(2);
+ if( Cmd_Argc(cmd) == 3)
+ wildcard_fieldname = Cmd_Argv(cmd, 2);
else
wildcard_fieldname = NULL;
For debugging, prints a single edict
=============
*/
-static void PRVM_ED_PrintEdict_f (void)
+static void PRVM_ED_PrintEdict_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
int i;
const char *wildcard_fieldname;
- if(Cmd_Argc() < 3 || Cmd_Argc() > 4)
+ if(Cmd_Argc(cmd) < 3 || Cmd_Argc(cmd) > 4)
{
Con_Print("prvm_edict <program name> <edict number> <optional field name wildcard>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- i = atoi (Cmd_Argv(2));
+ i = atoi (Cmd_Argv(cmd, 2));
if (i >= prog->num_edicts)
{
Con_Print("Bad edict number\n");
return;
}
- if( Cmd_Argc() == 4)
+ if( Cmd_Argc(cmd) == 4)
// Optional Wildcard Provided
- wildcard_fieldname = Cmd_Argv(3);
+ wildcard_fieldname = Cmd_Argv(cmd, 3);
else
// Use All
wildcard_fieldname = NULL;
*/
// 2 possibilities : 1. just displaying the active edict count
// 2. making a function pointer [x]
-static void PRVM_ED_Count_f (void)
+static void PRVM_ED_Count_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
- if(Cmd_Argc() != 2)
+ if(Cmd_Argc(cmd) != 2)
{
Con_Print("prvm_count <program name>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
prog->count_edicts(prog);
QC, mg in menu QC.
=============
*/
-static void PRVM_GameCommand(const char *whichprogs, const char *whichcmd)
+static void PRVM_GameCommand(cmd_state_t *cmd, const char *whichprogs, const char *whichcmd)
{
prvm_prog_t *prog;
- if(Cmd_Argc() < 1)
+ if(Cmd_Argc(cmd) < 1)
{
Con_Printf("%s text...\n", whichcmd);
return;
int restorevm_tempstringsbuf_cursize;
const char *s;
- s = Cmd_Args();
+ s = Cmd_Args(cmd);
restorevm_tempstringsbuf_cursize = prog->tempstringsbuf.cursize;
PRVM_G_INT(OFS_PARM0) = PRVM_SetTempString(prog, s ? s : "");
prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
}
}
-static void PRVM_GameCommand_Server_f(void)
+static void PRVM_GameCommand_Server_f(cmd_state_t *cmd)
{
- PRVM_GameCommand("server", "sv_cmd");
+ PRVM_GameCommand(cmd, "server", "sv_cmd");
}
-static void PRVM_GameCommand_Client_f(void)
+static void PRVM_GameCommand_Client_f(cmd_state_t *cmd)
{
- PRVM_GameCommand("client", "cl_cmd");
+ PRVM_GameCommand(cmd, "client", "cl_cmd");
}
-static void PRVM_GameCommand_Menu_f(void)
+static void PRVM_GameCommand_Menu_f(cmd_state_t *cmd)
{
- PRVM_GameCommand("menu", "menu_cmd");
+ PRVM_GameCommand(cmd, "menu", "menu_cmd");
}
/*
Console command to load a field of a specified edict
=============
*/
-static void PRVM_ED_EdictGet_f(void)
+static void PRVM_ED_EdictGet_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
prvm_edict_t *ed;
prvm_eval_t *v;
char valuebuf[MAX_INPUTLINE];
- if(Cmd_Argc() != 4 && Cmd_Argc() != 5)
+ if(Cmd_Argc(cmd) != 4 && Cmd_Argc(cmd) != 5)
{
Con_Print("prvm_edictget <program name> <edict number> <field> [<cvar>]\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- ed = PRVM_EDICT_NUM(atoi(Cmd_Argv(2)));
+ ed = PRVM_EDICT_NUM(atoi(Cmd_Argv(cmd, 2)));
- if((key = PRVM_ED_FindField(prog, Cmd_Argv(3))) == 0)
+ if((key = PRVM_ED_FindField(prog, Cmd_Argv(cmd, 3))) == 0)
{
- Con_Printf("Key %s not found !\n", Cmd_Argv(3));
+ Con_Printf("Key %s not found !\n", Cmd_Argv(cmd, 3));
goto fail;
}
v = (prvm_eval_t *)(ed->fields.fp + key->ofs);
s = PRVM_UglyValueString(prog, (etype_t)key->type, v, valuebuf, sizeof(valuebuf));
- if(Cmd_Argc() == 5)
+ if(Cmd_Argc(cmd) == 5)
{
- cvar_t *cvar = Cvar_FindVar(Cmd_Argv(4));
+ cvar_t *cvar = Cvar_FindVar(cmd->cvars, Cmd_Argv(cmd, 4), cmd->cvars_flagsmask);
if (cvar && cvar->flags & CVAR_READONLY)
{
Con_Printf("prvm_edictget: %s is read-only\n", cvar->name);
goto fail;
}
- Cvar_Get(Cmd_Argv(4), s, 0, NULL);
+ Cvar_Get(cmd->cvars, Cmd_Argv(cmd, 4), s, cmd->cvars_flagsmask, NULL);
}
else
Con_Printf("%s\n", s);
;
}
-static void PRVM_ED_GlobalGet_f(void)
+static void PRVM_ED_GlobalGet_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
ddef_t *key;
prvm_eval_t *v;
char valuebuf[MAX_INPUTLINE];
- if(Cmd_Argc() != 3 && Cmd_Argc() != 4)
+ if(Cmd_Argc(cmd) != 3 && Cmd_Argc(cmd) != 4)
{
Con_Print("prvm_globalget <program name> <global> [<cvar>]\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- key = PRVM_ED_FindGlobal(prog, Cmd_Argv(2));
+ key = PRVM_ED_FindGlobal(prog, Cmd_Argv(cmd, 2));
if(!key)
{
- Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(2), Cmd_Argv(1) );
+ Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(cmd, 2), Cmd_Argv(cmd, 1) );
goto fail;
}
v = (prvm_eval_t *) &prog->globals.fp[key->ofs];
s = PRVM_UglyValueString(prog, (etype_t)key->type, v, valuebuf, sizeof(valuebuf));
- if(Cmd_Argc() == 4)
+ if(Cmd_Argc(cmd) == 4)
{
- cvar_t *cvar = Cvar_FindVar(Cmd_Argv(3));
+ cvar_t *cvar = Cvar_FindVar(cmd->cvars, Cmd_Argv(cmd, 3), cmd->cvars_flagsmask);
if (cvar && cvar->flags & CVAR_READONLY)
{
Con_Printf("prvm_globalget: %s is read-only\n", cvar->name);
goto fail;
}
- Cvar_Get(Cmd_Argv(3), s, 0, NULL);
+ Cvar_Get(cmd->cvars, Cmd_Argv(cmd, 3), s, cmd->cvars_flagsmask, NULL);
}
else
Con_Printf("%s\n", s);
Console command to set a field of a specified edict
=============
*/
-static void PRVM_ED_EdictSet_f(void)
+static void PRVM_ED_EdictSet_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
prvm_edict_t *ed;
ddef_t *key;
- if(Cmd_Argc() != 5)
+ if(Cmd_Argc(cmd) != 5)
{
Con_Print("prvm_edictset <program name> <edict number> <field> <value>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- ed = PRVM_EDICT_NUM(atoi(Cmd_Argv(2)));
+ ed = PRVM_EDICT_NUM(atoi(Cmd_Argv(cmd, 2)));
- if((key = PRVM_ED_FindField(prog, Cmd_Argv(3))) == 0)
- Con_Printf("Key %s not found !\n", Cmd_Argv(3));
+ if((key = PRVM_ED_FindField(prog, Cmd_Argv(cmd, 3))) == 0)
+ Con_Printf("Key %s not found !\n", Cmd_Argv(cmd, 3));
else
- PRVM_ED_ParseEpair(prog, ed, key, Cmd_Argv(4), true);
+ PRVM_ED_ParseEpair(prog, ed, key, Cmd_Argv(cmd, 4), true);
}
/*
prog->numfielddefs++;
}
- // LordHavoc: TODO: reorder globals to match engine struct
- // LordHavoc: TODO: reorder fields to match engine struct
+ // LadyHavoc: TODO: reorder globals to match engine struct
+ // LadyHavoc: TODO: reorder fields to match engine struct
#define remapglobal(index) (index)
#define remapfield(index) (index)
// copy globals
- // FIXME: LordHavoc: this uses a crude way to identify integer constants, rather than checking for matching globaldefs and checking their type
+ // FIXME: LadyHavoc: this uses a crude way to identify integer constants, rather than checking for matching globaldefs and checking their type
for (i = 0;i < prog->progs_numglobals;i++)
{
u.i = LittleLong(inglobals[i]);
}
}
- // LordHavoc: TODO: support 32bit progs statement formats
+ // LadyHavoc: TODO: support 32bit progs statement formats
// copy, remap globals in statements, bounds check
for (i = 0;i < prog->progs_numstatements;i++)
{
}
}
- for (cvar = cvar_vars; cvar; cvar = cvar->next)
+ for (cvar = prog->console_cmd->cvars->vars; cvar; cvar = cvar->next)
cvar->globaldefindex[prog - prvm_prog_list] = -1;
for (i=0 ; i<prog->numglobaldefs ; i++)
)
{
prvm_eval_t *val = PRVM_GLOBALFIELDVALUE(prog->globaldefs[i].ofs);
- cvar = Cvar_FindVar(name + 9);
+ cvar = Cvar_FindVar(prog->console_cmd->cvars, name + 9, prog->console_cmd->cvars_flagsmask);
//Con_Printf("PRVM_LoadProgs: autocvar global %s in %s, processing...\n", name, prog->name);
if(!cvar)
{
Con_Printf("PRVM_LoadProgs: invalid type of autocvar global %s in %s\n", name, prog->name);
goto fail;
}
- cvar = Cvar_Get(name + 9, value, 0, NULL);
+ cvar = Cvar_Get(prog->console_cmd->cvars, name + 9, value, prog->console_cmd->cvars_flagsmask, NULL);
if((prog->globaldefs[i].type & ~DEF_SAVEGLOBAL) == ev_string)
{
val->string = PRVM_SetEngineString(prog, cvar->string);
}
-static void PRVM_Fields_f (void)
+static void PRVM_Fields_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
int i, j, ednum, used, usedamount;
}
*/
- if(Cmd_Argc() != 2)
+ if(Cmd_Argc(cmd) != 2)
{
Con_Print("prvm_fields <program name>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
counts = (int *)Mem_Alloc(tempmempool, prog->numfielddefs * sizeof(int));
Con_Printf("%s: %i entity fields (%i in use), totalling %i bytes per edict (%i in use), %i edicts allocated, %i bytes total spent on edict fields (%i needed)\n", prog->name, prog->entityfields, used, prog->entityfields * 4, usedamount * 4, prog->max_edicts, prog->entityfields * 4 * prog->max_edicts, usedamount * 4 * prog->max_edicts);
}
-static void PRVM_Globals_f (void)
+static void PRVM_Globals_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
int i;
Con_Print("no progs loaded\n");
return;
}*/
- if(Cmd_Argc () < 2 || Cmd_Argc() > 3)
+ if(Cmd_Argc (cmd) < 2 || Cmd_Argc(cmd) > 3)
{
Con_Print("prvm_globals <program name> <optional name wildcard>\n");
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- if( Cmd_Argc() == 3)
- wildcard = Cmd_Argv(2);
+ if( Cmd_Argc(cmd) == 3)
+ wildcard = Cmd_Argv(cmd, 2);
else
wildcard = NULL;
PRVM_Global
===============
*/
-static void PRVM_Global_f(void)
+static void PRVM_Global_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
ddef_t *global;
char valuebuf[MAX_INPUTLINE];
- if( Cmd_Argc() != 3 ) {
+ if( Cmd_Argc(cmd) != 3 ) {
Con_Printf( "prvm_global <program name> <global name>\n" );
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- global = PRVM_ED_FindGlobal( prog, Cmd_Argv(2) );
+ global = PRVM_ED_FindGlobal( prog, Cmd_Argv(cmd, 2) );
if( !global )
- Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(2), Cmd_Argv(1) );
+ Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(cmd, 2), Cmd_Argv(cmd, 1) );
else
- Con_Printf( "%s: %s\n", Cmd_Argv(2), PRVM_ValueString( prog, (etype_t)global->type, PRVM_GLOBALFIELDVALUE(global->ofs), valuebuf, sizeof(valuebuf) ) );
+ Con_Printf( "%s: %s\n", Cmd_Argv(cmd, 2), PRVM_ValueString( prog, (etype_t)global->type, PRVM_GLOBALFIELDVALUE(global->ofs), valuebuf, sizeof(valuebuf) ) );
}
/*
PRVM_GlobalSet
===============
*/
-static void PRVM_GlobalSet_f(void)
+static void PRVM_GlobalSet_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
ddef_t *global;
- if( Cmd_Argc() != 4 ) {
+ if( Cmd_Argc(cmd) != 4 ) {
Con_Printf( "prvm_globalset <program name> <global name> <value>\n" );
return;
}
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
- global = PRVM_ED_FindGlobal( prog, Cmd_Argv(2) );
+ global = PRVM_ED_FindGlobal( prog, Cmd_Argv(cmd, 2) );
if( !global )
- Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(2), Cmd_Argv(1) );
+ Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(cmd, 2), Cmd_Argv(cmd, 1) );
else
- PRVM_ED_ParseEpair( prog, NULL, global, Cmd_Argv(3), true );
+ PRVM_ED_ParseEpair( prog, NULL, global, Cmd_Argv(cmd, 3), true );
}
/*
prog->watch_field_type = ev_void;
}
-static void PRVM_Breakpoint_f(void)
+static void PRVM_Breakpoint_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
- if( Cmd_Argc() == 2 ) {
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if( Cmd_Argc(cmd) == 2 ) {
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
PRVM_UpdateBreakpoints(prog);
return;
}
- if( Cmd_Argc() != 3 ) {
+ if( Cmd_Argc(cmd) != 3 ) {
Con_Printf( "prvm_breakpoint <program name> <function name | statement>\n" );
return;
}
- if (!(prog = PRVM_ProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_ProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
- strlcpy(debug->break_statement, Cmd_Argv(2), sizeof(debug->break_statement));
+ strlcpy(debug->break_statement, Cmd_Argv(cmd, 2), sizeof(debug->break_statement));
}
PRVM_UpdateBreakpoints(prog);
}
-static void PRVM_GlobalWatchpoint_f(void)
+static void PRVM_GlobalWatchpoint_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
- if( Cmd_Argc() == 2 ) {
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if( Cmd_Argc(cmd) == 2 ) {
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
PRVM_UpdateBreakpoints(prog);
return;
}
- if( Cmd_Argc() != 3 ) {
+ if( Cmd_Argc(cmd) != 3 ) {
Con_Printf( "prvm_globalwatchpoint <program name> <global name>\n" );
return;
}
- if (!(prog = PRVM_ProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_ProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
- strlcpy(debug->watch_global, Cmd_Argv(2), sizeof(debug->watch_global));
+ strlcpy(debug->watch_global, Cmd_Argv(cmd, 2), sizeof(debug->watch_global));
}
PRVM_UpdateBreakpoints(prog);
}
-static void PRVM_EdictWatchpoint_f(void)
+static void PRVM_EdictWatchpoint_f(cmd_state_t *cmd)
{
prvm_prog_t *prog;
- if( Cmd_Argc() == 2 ) {
- if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(1))))
+ if( Cmd_Argc(cmd) == 2 ) {
+ if (!(prog = PRVM_FriendlyProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
PRVM_UpdateBreakpoints(prog);
return;
}
- if( Cmd_Argc() != 4 ) {
+ if( Cmd_Argc(cmd) != 4 ) {
Con_Printf( "prvm_edictwatchpoint <program name> <edict number> <field name>\n" );
return;
}
- if (!(prog = PRVM_ProgFromString(Cmd_Argv(1))))
+ if (!(prog = PRVM_ProgFromString(Cmd_Argv(cmd, 1))))
return;
{
debug_data_t *debug = &debug_data[prog - prvm_prog_list];
- debug->watch_edict = atoi(Cmd_Argv(2));
- strlcpy(debug->watch_field, Cmd_Argv(3), sizeof(debug->watch_field));
+ debug->watch_edict = atoi(Cmd_Argv(cmd, 2));
+ strlcpy(debug->watch_field, Cmd_Argv(cmd, 3), sizeof(debug->watch_field));
}
PRVM_UpdateBreakpoints(prog);
}
*/
void PRVM_Init (void)
{
- Cmd_AddCommand ("prvm_edict", PRVM_ED_PrintEdict_f, "print all data about an entity number in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_edicts", PRVM_ED_PrintEdicts_f, "prints all data about all entities in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_edictcount", PRVM_ED_Count_f, "prints number of active entities in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_profile", PRVM_Profile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_childprofile", PRVM_ChildProfile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu), sorted by time taken in function with child calls");
- Cmd_AddCommand ("prvm_callprofile", PRVM_CallProfile_f, "prints execution statistics about the most time consuming QuakeC calls from the engine in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_fields", PRVM_Fields_f, "prints usage statistics on properties (how many entities have non-zero values) in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_globals", PRVM_Globals_f, "prints all global variables in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_global", PRVM_Global_f, "prints value of a specified global variable in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_globalset", PRVM_GlobalSet_f, "sets value of a specified global variable in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_edictset", PRVM_ED_EdictSet_f, "changes value of a specified property of a specified entity in the selected VM (server, client, menu)");
- Cmd_AddCommand ("prvm_edictget", PRVM_ED_EdictGet_f, "retrieves the value of a specified property of a specified entity in the selected VM (server, client menu) into a cvar or to the console");
- Cmd_AddCommand ("prvm_globalget", PRVM_ED_GlobalGet_f, "retrieves the value of a specified global variable in the selected VM (server, client menu) into a cvar or to the console");
- Cmd_AddCommand ("prvm_printfunction", PRVM_PrintFunction_f, "prints a disassembly (QuakeC instructions) of the specified function in the selected VM (server, client, menu)");
- Cmd_AddCommand ("cl_cmd", PRVM_GameCommand_Client_f, "calls the client QC function GameCommand with the supplied string as argument");
- Cmd_AddCommand ("menu_cmd", PRVM_GameCommand_Menu_f, "calls the menu QC function GameCommand with the supplied string as argument");
- Cmd_AddCommand ("sv_cmd", PRVM_GameCommand_Server_f, "calls the server QC function GameCommand with the supplied string as argument");
-
- Cmd_AddCommand ("prvm_breakpoint", PRVM_Breakpoint_f, "marks a statement or function as breakpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear breakpoint");
- Cmd_AddCommand ("prvm_globalwatchpoint", PRVM_GlobalWatchpoint_f, "marks a global as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
- Cmd_AddCommand ("prvm_edictwatchpoint", PRVM_EdictWatchpoint_f, "marks an entity field as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
+ Cmd_AddCommand(&cmd_client, "prvm_edict", PRVM_ED_PrintEdict_f, "print all data about an entity number in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_edicts", PRVM_ED_PrintEdicts_f, "prints all data about all entities in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_edictcount", PRVM_ED_Count_f, "prints number of active entities in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_profile", PRVM_Profile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_childprofile", PRVM_ChildProfile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu), sorted by time taken in function with child calls");
+ Cmd_AddCommand(&cmd_client, "prvm_callprofile", PRVM_CallProfile_f, "prints execution statistics about the most time consuming QuakeC calls from the engine in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_fields", PRVM_Fields_f, "prints usage statistics on properties (how many entities have non-zero values) in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_globals", PRVM_Globals_f, "prints all global variables in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_global", PRVM_Global_f, "prints value of a specified global variable in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_globalset", PRVM_GlobalSet_f, "sets value of a specified global variable in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_edictset", PRVM_ED_EdictSet_f, "changes value of a specified property of a specified entity in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "prvm_edictget", PRVM_ED_EdictGet_f, "retrieves the value of a specified property of a specified entity in the selected VM (server, client menu) into a cvar or to the console");
+ Cmd_AddCommand(&cmd_client, "prvm_globalget", PRVM_ED_GlobalGet_f, "retrieves the value of a specified global variable in the selected VM (server, client menu) into a cvar or to the console");
+ Cmd_AddCommand(&cmd_client, "prvm_printfunction", PRVM_PrintFunction_f, "prints a disassembly (QuakeC instructions) of the specified function in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_client, "cl_cmd", PRVM_GameCommand_Client_f, "calls the client QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_client, "menu_cmd", PRVM_GameCommand_Menu_f, "calls the menu QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_client, "sv_cmd", PRVM_GameCommand_Server_f, "calls the server QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_client, "prvm_breakpoint", PRVM_Breakpoint_f, "marks a statement or function as breakpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear breakpoint");
+ Cmd_AddCommand(&cmd_client, "prvm_globalwatchpoint", PRVM_GlobalWatchpoint_f, "marks a global as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
+ Cmd_AddCommand(&cmd_client, "prvm_edictwatchpoint", PRVM_EdictWatchpoint_f, "marks an entity field as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
+
+ Cmd_AddCommand(&cmd_server, "prvm_edict", PRVM_ED_PrintEdict_f, "print all data about an entity number in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_edicts", PRVM_ED_PrintEdicts_f, "prints all data about all entities in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_edictcount", PRVM_ED_Count_f, "prints number of active entities in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_profile", PRVM_Profile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_childprofile", PRVM_ChildProfile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu), sorted by time taken in function with child calls");
+ Cmd_AddCommand(&cmd_server, "prvm_callprofile", PRVM_CallProfile_f, "prints execution statistics about the most time consuming QuakeC calls from the engine in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_fields", PRVM_Fields_f, "prints usage statistics on properties (how many entities have non-zero values) in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_globals", PRVM_Globals_f, "prints all global variables in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_global", PRVM_Global_f, "prints value of a specified global variable in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_globalset", PRVM_GlobalSet_f, "sets value of a specified global variable in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_edictset", PRVM_ED_EdictSet_f, "changes value of a specified property of a specified entity in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "prvm_edictget", PRVM_ED_EdictGet_f, "retrieves the value of a specified property of a specified entity in the selected VM (server, client menu) into a cvar or to the console");
+ Cmd_AddCommand(&cmd_server, "prvm_globalget", PRVM_ED_GlobalGet_f, "retrieves the value of a specified global variable in the selected VM (server, client menu) into a cvar or to the console");
+ Cmd_AddCommand(&cmd_server, "prvm_printfunction", PRVM_PrintFunction_f, "prints a disassembly (QuakeC instructions) of the specified function in the selected VM (server, client, menu)");
+ Cmd_AddCommand(&cmd_server, "cl_cmd", PRVM_GameCommand_Client_f, "calls the client QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_server, "menu_cmd", PRVM_GameCommand_Menu_f, "calls the menu QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_server, "sv_cmd", PRVM_GameCommand_Server_f, "calls the server QC function GameCommand with the supplied string as argument");
+ Cmd_AddCommand(&cmd_server, "prvm_breakpoint", PRVM_Breakpoint_f, "marks a statement or function as breakpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear breakpoint");
+ Cmd_AddCommand(&cmd_server, "prvm_globalwatchpoint", PRVM_GlobalWatchpoint_f, "marks a global as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
+ Cmd_AddCommand(&cmd_server, "prvm_edictwatchpoint", PRVM_EdictWatchpoint_f, "marks an entity field as watchpoint (when this is executed, a stack trace is printed); to actually halt and investigate state, combine this with a gdb breakpoint on PRVM_Breakpoint, or with prvm_breakpointdump; run with just progs name to clear watchpoint");
Cvar_RegisterVariable (&prvm_language);
Cvar_RegisterVariable (&prvm_traceqc);
PRVM_InitProg
===============
*/
-void PRVM_Prog_Init(prvm_prog_t *prog)
+void PRVM_Prog_Init(prvm_prog_t *prog, cmd_state_t *cmd)
{
PRVM_Prog_Reset(prog);
prog->leaktest_active = prvm_leaktest.integer != 0;
+ prog->console_cmd = cmd;
}
-// LordHavoc: turned PRVM_EDICT_NUM into a #define for speed reasons
+// LadyHavoc: turned PRVM_EDICT_NUM into a #define for speed reasons
unsigned int PRVM_EDICT_NUM_ERROR(prvm_prog_t *prog, unsigned int n, const char *filename, int fileline)
{
prog->error_cmd("PRVM_EDICT_NUM: %s: bad number %i (called at %s:%i)", prog->name, n, filename, fileline);