qboolean PRVM_ED_ParseEpair(prvm_edict_t *ent, ddef_t *key, const char *s);
// LordHavoc: optional runtime bounds checking (speed drain, but worth it for security, on by default - breaks most QCCX features (used by CRMod and others))
-cvar_t prvm_boundscheck = {0, "prvm_boundscheck", "1"};
+cvar_t prvm_boundscheck = {0, "prvm_boundscheck", "1", "enables detection of out of bounds memory access in the QuakeC code being run (in other words, prevents really exceedingly bad QuakeC code from doing nasty things to your computer)"};
// LordHavoc: prints every opcode as it executes - warning: this is significant spew
-cvar_t prvm_traceqc = {0, "prvm_traceqc", "0"};
+cvar_t prvm_traceqc = {0, "prvm_traceqc", "0", "prints every QuakeC statement as it is executed (only for really thorough debugging!)"};
//============================================================================
// mempool handling
*/
char *PRVM_ValueString (etype_t type, prvm_eval_t *val)
{
- static char line[1024]; // LordHavoc: enlarged a bit (was 256)
+ static char line[MAX_INPUTLINE];
ddef_t *def;
mfunction_t *f;
int n;
*/
char *PRVM_UglyValueString (etype_t type, prvm_eval_t *val)
{
- static char line[4096];
+ static char line[MAX_INPUTLINE];
int i;
const char *s;
ddef_t *def;
int i, j;
const char *name;
int type;
- char tempstring[8192], tempstring2[260]; // temporary string buffers
+ char tempstring[MAX_INPUTLINE], tempstring2[260]; // temporary string buffers
if (ed->priv.required->free)
{
if (j == prvm_type_size[type])
continue;
- if (strlen(name) > 256)
+ if (strlen(name) > sizeof(tempstring2)-4)
{
- memcpy (tempstring2, name, 256);
- tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
- tempstring2[259] = 0;
+ memcpy (tempstring2, name, sizeof(tempstring2)-4);
+ tempstring2[sizeof(tempstring2)-4] = tempstring2[sizeof(tempstring2)-3] = tempstring2[sizeof(tempstring2)-2] = '.';
+ tempstring2[sizeof(tempstring2)-1] = 0;
name = tempstring2;
}
strcat(tempstring, name);
strcat(tempstring, " ");
name = PRVM_ValueString((etype_t)d->type, (prvm_eval_t *)v);
- if (strlen(name) > 256)
+ if (strlen(name) > sizeof(tempstring2)-4)
{
- memcpy (tempstring2, name, 256);
- tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
- tempstring2[259] = 0;
+ memcpy (tempstring2, name, sizeof(tempstring2)-4);
+ tempstring2[sizeof(tempstring2)-4] = tempstring2[sizeof(tempstring2)-3] = tempstring2[sizeof(tempstring2)-2] = '.';
+ tempstring2[sizeof(tempstring2)-1] = 0;
name = tempstring2;
}
strcat(tempstring, name);
strcat(tempstring, "\n");
- if (strlen(tempstring) >= 4096)
+ if (strlen(tempstring) >= sizeof(tempstring)/2)
{
Con_Print(tempstring);
tempstring[0] = 0;
*/
void PRVM_ED_ParseGlobals (const char *data)
{
- char keyname[1024]; // LordHavoc: good idea? bad idea? was 64
+ char keyname[MAX_INPUTLINE];
ddef_t *key;
while (1)
{
// parse key
if (!COM_ParseToken(&data, false))
- PRVM_ERROR ("PRVM_ED_ParseEntity: EOF without closing brace");
+ PRVM_ERROR ("PRVM_ED_ParseGlobals: EOF without closing brace");
if (com_token[0] == '}')
break;
// parse value
if (!COM_ParseToken(&data, false))
- PRVM_ERROR ("PRVM_ED_ParseEntity: EOF without closing brace");
+ PRVM_ERROR ("PRVM_ED_ParseGlobals: EOF without closing brace");
if (com_token[0] == '}')
- PRVM_ERROR ("PRVM_ED_ParseEntity: closing brace without data");
+ PRVM_ERROR ("PRVM_ED_ParseGlobals: closing brace without data");
key = PRVM_ED_FindGlobal (keyname);
if (!key)
Used for initial level load and for savegames.
====================
*/
+extern cvar_t developer_entityparsing;
const char *PRVM_ED_ParseEdict (const char *data, prvm_edict_t *ent)
{
ddef_t *key;
{
// parse key
if (!COM_ParseToken(&data, false))
- PRVM_ERROR ("PRVM_ED_ParseEntity: EOF without closing brace");
+ PRVM_ERROR ("PRVM_ED_ParseEdict: EOF without closing brace");
+ if (developer_entityparsing.integer)
+ Con_Printf("Key: \"%s\"", com_token);
if (com_token[0] == '}')
break;
// parse value
if (!COM_ParseToken(&data, false))
- PRVM_ERROR ("PRVM_ED_ParseEntity: EOF without closing brace");
+ PRVM_ERROR ("PRVM_ED_ParseEdict: EOF without closing brace");
+ if (developer_entityparsing.integer)
+ Con_Printf(" \"%s\"\n", com_token);
if (com_token[0] == '}')
- PRVM_ERROR ("PRVM_ED_ParseEntity: closing brace without data");
+ PRVM_ERROR ("PRVM_ED_ParseEdict: closing brace without data");
init = true;
PRVM_ERROR("PRVM_LoadProgs: out of bounds global index (statement %d) in %s", i, PRVM_NAME);
break;
default:
- PRVM_ERROR("PRVM_LoadProgs: unknown opcode %d at statement %d in %s", st->op, i, PRVM_NAME);
+ Con_DPrintf("PRVM_LoadProgs: unknown opcode %d at statement %d in %s", st->op, i, PRVM_NAME);
break;
}
}
{
int i, j, ednum, used, usedamount;
int *counts;
- char tempstring[5000], tempstring2[260];
+ char tempstring[MAX_INPUTLINE], tempstring2[260];
const char *name;
prvm_edict_t *ed;
ddef_t *d;
strcat(tempstring, tempstring2);
break;
}
- if (strlen(name) > 256)
+ if (strlen(name) > sizeof(tempstring2)-4)
{
- memcpy (tempstring2, name, 256);
- tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
- tempstring2[259] = 0;
+ memcpy (tempstring2, name, sizeof(tempstring2)-4);
+ tempstring2[sizeof(tempstring2)-4] = tempstring2[sizeof(tempstring2)-3] = tempstring2[sizeof(tempstring2)-2] = '.';
+ tempstring2[sizeof(tempstring2)-1] = 0;
name = tempstring2;
}
strcat(tempstring, name);
sprintf(tempstring2, "%5d", counts[i]);
strcat(tempstring, tempstring2);
strcat(tempstring, "\n");
- if (strlen(tempstring) >= 4096)
+ if (strlen(tempstring) >= sizeof(tempstring)/2)
{
Con_Print(tempstring);
tempstring[0] = 0;
*/
void PRVM_Init (void)
{
- Cmd_AddCommand ("prvm_edict", PRVM_ED_PrintEdict_f);
- Cmd_AddCommand ("prvm_edicts", PRVM_ED_PrintEdicts_f);
- Cmd_AddCommand ("prvm_edictcount", PRVM_ED_Count_f);
- Cmd_AddCommand ("prvm_profile", PRVM_Profile_f);
- Cmd_AddCommand ("prvm_fields", PRVM_Fields_f);
- Cmd_AddCommand ("prvm_globals", PRVM_Globals_f);
- Cmd_AddCommand ("prvm_global", PRVM_Global_f);
- Cmd_AddCommand ("prvm_globalset", PRVM_GlobalSet_f);
- Cmd_AddCommand ("prvm_edictset", PRVM_ED_EdictSet_f);
+ 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, "set a property on an entity number 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_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)");
// LordHavoc: optional runtime bounds checking (speed drain, but worth it for security, on by default - breaks most QCCX features (used by CRMod and others))
Cvar_RegisterVariable (&prvm_boundscheck);
Cvar_RegisterVariable (&prvm_traceqc);