ddef_t *PRVM_ED_FieldAtOfs(int ofs);
qboolean PRVM_ED_ParseEpair(prvm_edict_t *ent, ddef_t *key, const char *s, qboolean parsebackslash);
-// LordHavoc: optional runtime bounds checking (speed drain, but worth it for security, on by default - breaks most QCCX features (used by CRMod and others))
-#ifdef PRVM_BOUNDSCHECK_CVAR
-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)"};
-#endif
// 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_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"};
+qboolean prvm_runawaycheck = true;
+
+// LordHavoc: optional runtime bounds checking (speed drain, but worth it for security, on by default - breaks most QCCX features (used by CRMod and others))
+// 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)
+qboolean prvm_boundscheck = true;
+
extern sizebuf_t vm_tempstringsbuf;
//============================================================================
line[i++] = '\\';
line[i++] = '\\';
}
+ else if (*s == '"')
+ {
+ line[i++] = '\\';
+ line[i++] = '"';
+ }
else
line[i++] = *s;
s++;
For savegames
=============
*/
+extern cvar_t developer_entityparsing;
void PRVM_ED_Write (qfile_t *f, prvm_edict_t *ed)
{
ddef_t *d;
{
d = &prog->fielddefs[i];
name = PRVM_GetString(d->s_name);
+
+ if(developer_entityparsing.integer)
+ Con_Printf("PRVM_ED_Write: at entity %d field %s\n", PRVM_NUM_FOR_EDICT(ed), name);
+
if (name[strlen(name)-2] == '_')
continue; // skip _x, _y, _z vars
continue;
name = PRVM_GetString(def->s_name);
+
+ if(developer_entityparsing.integer)
+ Con_Printf("PRVM_ED_WriteGlobals: at global %s\n", name);
+
FS_Printf(f,"\"%s\" ", name);
FS_Printf(f,"\"%s\"\n", PRVM_UglyValueString((etype_t)type, (prvm_eval_t *)&prog->globals.generic[def->ofs]));
}
if (com_token[0] == '}')
break;
+ if (developer_entityparsing.integer)
+ Con_Printf("Key: \"%s\"", com_token);
+
strlcpy (keyname, com_token, sizeof(keyname));
// parse value
if (!COM_ParseToken_Simple(&data, false, true))
PRVM_ERROR ("PRVM_ED_ParseGlobals: EOF without closing brace");
+ if (developer_entityparsing.integer)
+ Con_Printf(" \"%s\"\n", com_token);
+
if (com_token[0] == '}')
PRVM_ERROR ("PRVM_ED_ParseGlobals: closing brace without data");
break;
case ev_float:
- while (*s && *s <= ' ')
+ while (*s && ISWHITESPACE(*s))
s++;
val->_float = atof(s);
break;
case ev_vector:
for (i = 0;i < 3;i++)
{
- while (*s && *s <= ' ')
+ while (*s && ISWHITESPACE(*s))
s++;
if (!*s)
break;
val->vector[i] = atof(s);
- while (*s > ' ')
+ while (!ISWHITESPACE(*s))
s++;
if (!*s)
break;
break;
case ev_entity:
- while (*s && *s <= ' ')
+ while (*s && ISWHITESPACE(*s))
s++;
i = atoi(s);
if (i >= prog->limit_edicts)
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;
continue;
}
+ if (prog->funcoffsets.SV_OnEntityPreSpawnFunction)
+ {
+ // self = ent
+ PRVM_GLOBALFIELDVALUE(prog->globaloffsets.self)->edict = PRVM_EDICT_TO_PROG(ent);
+ PRVM_ExecuteProgram (prog->funcoffsets.SV_OnEntityPreSpawnFunction, "QC function SV_OnEntityPreSpawnFunction is missing");
+ }
+
//
// immediately call spawn function, but only if there is a self global and a classname
//
+ if(!ent->priv.required->free)
if(prog->globaloffsets.self >= 0 && prog->fieldoffsets.classname >= 0)
{
string_t handle = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.classname)->string;
PRVM_ED_Print(ent, NULL);
}
PRVM_ED_Free (ent);
- continue;
+ continue; // not included in "inhibited" count
}
}
else
}
}
+ if(!ent->priv.required->free)
+ if (prog->funcoffsets.SV_OnEntityPostSpawnFunction)
+ {
+ // self = ent
+ PRVM_GLOBALFIELDVALUE(prog->globaloffsets.self)->edict = PRVM_EDICT_TO_PROG(ent);
+ PRVM_ExecuteProgram (prog->funcoffsets.SV_OnEntityPostSpawnFunction, "QC function SV_OnEntityPostSpawnFunction is missing");
+ }
+
spawned++;
if (ent->priv.required->free)
died++;
// server and client qc use a lot of similar fields, so this is combined
prog->fieldoffsets.SendEntity = PRVM_ED_FindFieldOffset("SendEntity");
+ prog->fieldoffsets.SendFlags = PRVM_ED_FindFieldOffset("SendFlags");
prog->fieldoffsets.Version = PRVM_ED_FindFieldOffset("Version");
prog->fieldoffsets.alpha = PRVM_ED_FindFieldOffset("alpha");
prog->fieldoffsets.ammo_cells1 = PRVM_ED_FindFieldOffset("ammo_cells1");
prog->fieldoffsets.viewzoom = PRVM_ED_FindFieldOffset("viewzoom");
prog->fieldoffsets.yaw_speed = PRVM_ED_FindFieldOffset("yaw_speed");
prog->fieldoffsets.clientcamera = PRVM_ED_FindFieldOffset("clientcamera");
+ prog->fieldoffsets.clientstatus = PRVM_ED_FindFieldOffset("clientstatus");
prog->funcoffsets.CSQC_ConsoleCommand = PRVM_ED_FindFunctionOffset("CSQC_ConsoleCommand");
prog->funcoffsets.CSQC_Ent_Remove = PRVM_ED_FindFunctionOffset("CSQC_Ent_Remove");
prog->funcoffsets.CSQC_Ent_Update = PRVM_ED_FindFunctionOffset("CSQC_Ent_Update");
prog->funcoffsets.SV_ParseClientCommand = PRVM_ED_FindFunctionOffset("SV_ParseClientCommand");
prog->funcoffsets.SV_PlayerPhysics = PRVM_ED_FindFunctionOffset("SV_PlayerPhysics");
prog->funcoffsets.SV_OnEntityNoSpawnFunction = PRVM_ED_FindFunctionOffset("SV_OnEntityNoSpawnFunction");
+ prog->funcoffsets.SV_OnEntityPreSpawnFunction = PRVM_ED_FindFunctionOffset("SV_OnEntityPreSpawnFunction");
+ prog->funcoffsets.SV_OnEntityPostSpawnFunction = PRVM_ED_FindFunctionOffset("SV_OnEntityPostSpawnFunction");
prog->funcoffsets.GameCommand = PRVM_ED_FindFunctionOffset("GameCommand");
prog->funcoffsets.SV_Shutdown = PRVM_ED_FindFunctionOffset("SV_Shutdown");
+ prog->funcoffsets.URI_Get_Callback = PRVM_ED_FindFunctionOffset("URI_Get_Callback");
prog->globaloffsets.SV_InitCmd = PRVM_ED_FindGlobalOffset("SV_InitCmd");
prog->globaloffsets.self = PRVM_ED_FindGlobalOffset("self");
prog->globaloffsets.time = PRVM_ED_FindGlobalOffset("time");
prog->globaloffsets.trace_plane_normal = PRVM_ED_FindGlobalOffset("trace_plane_normal");
prog->globaloffsets.trace_plane_dist = PRVM_ED_FindGlobalOffset("trace_plane_dist");
prog->globaloffsets.trace_ent = PRVM_ED_FindGlobalOffset("trace_ent");
+ prog->globaloffsets.trace_networkentity = PRVM_ED_FindGlobalOffset("trace_networkentity");
prog->globaloffsets.trace_dphitcontents = PRVM_ED_FindGlobalOffset("trace_dphitcontents");
prog->globaloffsets.trace_dphitq3surfaceflags = PRVM_ED_FindGlobalOffset("trace_dphitq3surfaceflags");
prog->globaloffsets.trace_dphittexturename = PRVM_ED_FindGlobalOffset("trace_dphittexturename");
prog->globaloffsets.sb_showscores = PRVM_ED_FindGlobalOffset("sb_showscores");
prog->globaloffsets.drawfont = PRVM_ED_FindGlobalOffset("drawfont");
prog->globaloffsets.require_spawnfunc_prefix = PRVM_ED_FindGlobalOffset("require_spawnfunc_prefix");
+ prog->globaloffsets.worldstatus = PRVM_ED_FindGlobalOffset("worldstatus");
// menu qc only uses some functions, nothing else
prog->funcoffsets.m_draw = PRVM_ED_FindFunctionOffset("m_draw");
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");
- // LordHavoc: optional runtime bounds checking (speed drain, but worth it for security, on by default - breaks most QCCX features (used by CRMod and others))
-#ifdef PRVM_BOUNDSCHECK_CVAR
- Cvar_RegisterVariable (&prvm_boundscheck);
-#endif
+
+ // COMMANDLINEOPTION: PRVM: -noboundscheck disables the bounds checks (security hole if CSQC is in use!)
+ prvm_boundscheck = !COM_CheckParm("-noboundscheck");
+
Cvar_RegisterVariable (&prvm_traceqc);
Cvar_RegisterVariable (&prvm_statementprofiling);
Cvar_RegisterVariable (&prvm_backtraceforwarnings);
Cvar_RegisterVariable (&prvm_leaktest_ignore_classnames);
Cvar_RegisterVariable (&prvm_errordump);
+ // COMMANDLINEOPTION: PRVM: -norunaway disables the runaway loop check (it might be impossible to exit DarkPlaces if used!)
+ prvm_runawaycheck = !COM_CheckParm("-norunaway");
+
//VM_Cmd_Init();
}
{
// TODO someone add more stuff here
cl_entvars_t *ev = edict->fields.client;
+ if(ev->entnum) // csqc networked
+ return true;
if(ev->modelindex) // visible ent?
return true;
if(ev->effects) // particle effect?