X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=prvm_edict.c;h=ea8392751e9760f2aff73c0881557e1f7c608557;hb=365e221966b15c24c6e2f4cbb6e619b0db443ebf;hp=cccc66dfdc4bbd09d0fe0754bfbde0cd810c65da;hpb=7ca9ce4420b332de3fa6f2d6beaa437f171ab97c;p=xonotic%2Fdarkplaces.git diff --git a/prvm_edict.c b/prvm_edict.c index cccc66df..ea839275 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -29,29 +29,29 @@ int prvm_type_size[8] = {1,sizeof(string_t)/4,1,3,1,1,sizeof(func_t)/4,sizeof(v prvm_eval_t prvm_badvalue; // used only for error returns -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"}; +cvar_t prvm_language = {CF_CLIENT | CF_SERVER | CF_ARCHIVE, "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!)"}; +cvar_t prvm_traceqc = {CF_CLIENT | CF_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"}; -cvar_t prvm_garbagecollection_enable = {CVAR_CLIENT | CVAR_SERVER, "prvm_garbagecollection_enable", "1", "automatically scan for and free resources that are not referenced by the code being executed in the VM"}; -cvar_t prvm_garbagecollection_notify = {CVAR_CLIENT | CVAR_SERVER, "prvm_garbagecollection_notify", "0", "print out a notification for each resource freed by garbage collection"}; -cvar_t prvm_garbagecollection_scan_limit = {CVAR_CLIENT | CVAR_SERVER, "prvm_garbagecollection_scan_limit", "10000", "scan this many fields or resources per frame to free up unreferenced resources"}; -cvar_t prvm_garbagecollection_strings = {CVAR_CLIENT | CVAR_SERVER, "prvm_garbagecollection_strings", "1", "automatically call strunzone() on strings that are not referenced"}; -cvar_t prvm_stringdebug = {CVAR_CLIENT | CVAR_SERVER, "prvm_stringdebug", "0", "Print debug and warning messages related to strings"}; +cvar_t prvm_statementprofiling = {CF_CLIENT | CF_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 = {CF_CLIENT | CF_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 = {CF_CLIENT | CF_SERVER, "prvm_coverage", "0", "report and count coverage events (1: per-function, 2: coverage() builtin, 4: per-statement)"}; +cvar_t prvm_backtraceforwarnings = {CF_CLIENT | CF_SERVER, "prvm_backtraceforwarnings", "0", "print a backtrace for warnings too"}; +cvar_t prvm_leaktest = {CF_CLIENT | CF_SERVER, "prvm_leaktest", "0", "try to detect memory leaks in strings or entities"}; +cvar_t prvm_leaktest_follow_targetname = {CF_CLIENT | CF_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 = {CF_CLIENT | CF_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 = {CF_CLIENT | CF_SERVER, "prvm_errordump", "0", "write a savegame on crash to crash-server.dmp"}; +cvar_t prvm_breakpointdump = {CF_CLIENT | CF_SERVER, "prvm_breakpointdump", "0", "write a savegame on breakpoint to breakpoint-server.dmp"}; +cvar_t prvm_reuseedicts_startuptime = {CF_CLIENT | CF_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 = {CF_CLIENT | CF_SERVER, "prvm_reuseedicts_neverinsameframe", "1", "never allows re-use of freed entity slots during same frame"}; +cvar_t prvm_garbagecollection_enable = {CF_CLIENT | CF_SERVER, "prvm_garbagecollection_enable", "1", "automatically scan for and free resources that are not referenced by the code being executed in the VM"}; +cvar_t prvm_garbagecollection_notify = {CF_CLIENT | CF_SERVER, "prvm_garbagecollection_notify", "0", "print out a notification for each resource freed by garbage collection"}; +cvar_t prvm_garbagecollection_scan_limit = {CF_CLIENT | CF_SERVER, "prvm_garbagecollection_scan_limit", "10000", "scan this many fields or resources per frame to free up unreferenced resources"}; +cvar_t prvm_garbagecollection_strings = {CF_CLIENT | CF_SERVER, "prvm_garbagecollection_strings", "1", "automatically call strunzone() on strings that are not referenced"}; +cvar_t prvm_stringdebug = {CF_CLIENT | CF_SERVER, "prvm_stringdebug", "0", "Print debug and warning messages related to strings"}; static double prvm_reuseedicts_always_allow = 0; -qboolean prvm_runawaycheck = true; +qbool prvm_runawaycheck = true; //============================================================================ // mempool handling @@ -204,8 +204,8 @@ freed and sets the allocation origin. void PRVM_ED_ClearEdict(prvm_prog_t *prog, prvm_edict_t *e) { memset(e->fields.fp, 0, prog->entityfields * sizeof(prvm_vec_t)); - e->priv.required->free = false; - e->priv.required->freetime = host.realtime; + e->free = false; + e->freetime = host.realtime; if(e->priv.required->allocation_origin) Mem_Free((char *)e->priv.required->allocation_origin); e->priv.required->allocation_origin = PRVM_AllocationOrigin(prog); @@ -233,17 +233,17 @@ PRVM_ED_CanAlloc Returns if this particular edict could get allocated by PRVM_ED_Alloc ================= */ -qboolean PRVM_ED_CanAlloc(prvm_prog_t *prog, prvm_edict_t *e) +qbool PRVM_ED_CanAlloc(prvm_prog_t *prog, prvm_edict_t *e) { - if(!e->priv.required->free) + if(!e->free) return false; if(prvm_reuseedicts_always_allow == host.realtime) return true; - if(host.realtime <= e->priv.required->freetime + 0.1 && prvm_reuseedicts_neverinsameframe.integer) + if(host.realtime <= e->freetime + 0.1 && prvm_reuseedicts_neverinsameframe.integer) return false; // never allow reuse in same frame (causes networking trouble) - if(e->priv.required->freetime < prog->starttime + prvm_reuseedicts_startuptime.value) + if(e->freetime < prog->starttime + prvm_reuseedicts_startuptime.value) return true; - if(host.realtime > e->priv.required->freetime + 1) + if(host.realtime > e->freetime + 1) return true; return false; // entity slot still blocked because the entity was freed less than one second ago } @@ -308,8 +308,8 @@ void PRVM_ED_Free(prvm_prog_t *prog, prvm_edict_t *ed) prog->free_edict(prog, ed); - ed->priv.required->free = true; - ed->priv.required->freetime = host.realtime; + ed->free = true; + ed->freetime = host.realtime; if(ed->priv.required->allocation_origin) { Mem_Free((char *)ed->priv.required->allocation_origin); @@ -474,11 +474,11 @@ static char *PRVM_ValueString (prvm_prog_t *prog, etype_t type, prvm_eval_t *val break; case ev_float: // LadyHavoc: changed from %5.1f to %10.4f - dpsnprintf (line, linelength, FLOAT_LOSSLESS_FORMAT, val->_float); + dpsnprintf (line, linelength, PRVM_FLOAT_LOSSLESS_FORMAT, val->_float); break; case ev_vector: // LadyHavoc: changed from %5.1f to %10.4f - dpsnprintf (line, linelength, "'" VECTOR_LOSSLESS_FORMAT "'", val->vector[0], val->vector[1], val->vector[2]); + dpsnprintf (line, linelength, "'" PRVM_VECTOR_LOSSLESS_FORMAT "'", val->vector[0], val->vector[1], val->vector[2]); break; case ev_pointer: dpsnprintf (line, linelength, "pointer"); @@ -567,10 +567,10 @@ char *PRVM_UglyValueString (prvm_prog_t *prog, etype_t type, prvm_eval_t *val, c dpsnprintf (line, linelength, "void"); break; case ev_float: - dpsnprintf (line, linelength, FLOAT_LOSSLESS_FORMAT, val->_float); + dpsnprintf (line, linelength, PRVM_FLOAT_LOSSLESS_FORMAT, val->_float); break; case ev_vector: - dpsnprintf (line, linelength, VECTOR_LOSSLESS_FORMAT, val->vector[0], val->vector[1], val->vector[2]); + dpsnprintf (line, linelength, PRVM_VECTOR_LOSSLESS_FORMAT, val->vector[0], val->vector[1], val->vector[2]); break; default: dpsnprintf (line, linelength, "bad type %i", type); @@ -654,7 +654,7 @@ void PRVM_ED_Print(prvm_prog_t *prog, prvm_edict_t *ed, const char *wildcard_fie char tempstring[MAX_INPUTLINE], tempstring2[260]; // temporary string buffers char valuebuf[MAX_INPUTLINE]; - if (ed->priv.required->free) + if (ed->free) { Con_Printf("%s: FREE\n",prog->name); return; @@ -737,7 +737,7 @@ void PRVM_ED_Write (prvm_prog_t *prog, qfile_t *f, prvm_edict_t *ed) FS_Print(f, "{\n"); - if (ed->priv.required->free) + if (ed->free) { FS_Print(f, "}\n"); return; @@ -977,7 +977,7 @@ Can parse either fields or globals returns false if error ============= */ -qboolean PRVM_ED_ParseEpair(prvm_prog_t *prog, prvm_edict_t *ent, mdef_t *key, const char *s, qboolean parsebackslash) +qbool PRVM_ED_ParseEpair(prvm_prog_t *prog, prvm_edict_t *ent, mdef_t *key, const char *s, qbool parsebackslash) { int i, l; char *new_p; @@ -1270,8 +1270,8 @@ Used for initial level load and for savegames. const char *PRVM_ED_ParseEdict (prvm_prog_t *prog, const char *data, prvm_edict_t *ent) { mdef_t *key; - qboolean anglehack; - qboolean init; + qbool anglehack; + qbool init; char keyname[256]; size_t n; @@ -1351,8 +1351,8 @@ const char *PRVM_ED_ParseEdict (prvm_prog_t *prog, const char *data, prvm_edict_ } if (!init) { - ent->priv.required->free = true; - ent->priv.required->freetime = host.realtime; + ent->free = true; + ent->freetime = host.realtime; } return data; @@ -1369,7 +1369,7 @@ void PRVM_ED_CallPrespawnFunction(prvm_prog_t *prog, prvm_edict_t *ent) } } -qboolean PRVM_ED_CallSpawnFunction(prvm_prog_t *prog, prvm_edict_t *ent, const char *data, const char *start) +qbool PRVM_ED_CallSpawnFunction(prvm_prog_t *prog, prvm_edict_t *ent, const char *data, const char *start) { const char *funcname; mfunction_t *func; @@ -1379,7 +1379,7 @@ qboolean PRVM_ED_CallSpawnFunction(prvm_prog_t *prog, prvm_edict_t *ent, const c // // immediately call spawn function, but only if there is a self global and a classname // - if (!ent->priv.required->free) + if (!ent->free) { if (!PRVM_alledictstring(ent, classname)) { @@ -1455,7 +1455,7 @@ qboolean PRVM_ED_CallSpawnFunction(prvm_prog_t *prog, prvm_edict_t *ent, const c void PRVM_ED_CallPostspawnFunction (prvm_prog_t *prog, prvm_edict_t *ent) { - if(!ent->priv.required->free) + if(!ent->free) if (PRVM_serverfunction(SV_OnEntityPostSpawnFunction)) { // self = ent @@ -1530,19 +1530,21 @@ void PRVM_ED_LoadFromFile (prvm_prog_t *prog, const char *data) PRVM_ED_CallPrespawnFunction(prog, ent); - if(ent->priv.required->free) + if(ent->free) { inhibited++; continue; } + SV_LinkEdict(ent); + if(!PRVM_ED_CallSpawnFunction(prog, ent, data, start)) continue; PRVM_ED_CallPostspawnFunction(prog, ent); spawned++; - if (ent->priv.required->free) + if (ent->free) died++; } @@ -2057,8 +2059,8 @@ void PRVM_Prog_Load(prvm_prog_t *prog, const char * filename, unsigned char * da dprograms_v7_t *v7 = (dprograms_v7_t*)dprograms; structtype = LittleLong(v7->secondaryversion); if (structtype == PROG_SECONDARYVERSION16 || - structtype == PROG_SECONDARYVERSION32) - ;//supported + structtype == PROG_SECONDARYVERSION32) // barely supported + Con_Printf(CON_WARN "WARNING: %s: %s targets FTEQW, for which support is incomplete. Proceed at your own risk.\n", prog->name, filename); else prog->error_cmd("%s: %s targets unknown engine", prog->name, filename); @@ -2458,7 +2460,7 @@ void PRVM_Prog_Load(prvm_prog_t *prog, const char * filename, unsigned char * da if ( a >= prog->progs_numglobals) prog->error_cmd("PRVM_LoadProgs: out of bounds global index (statement %d) in %s", i, prog->name); if (b || c) //Spike -- added this check just as a diagnostic... - Con_DPrintf("PRVM_LoadProgs: unxpected offset on call opcode in %s. Hexen2 format is not supported\n", prog->name); + Con_DPrintf("PRVM_LoadProgs: unexpected offset on call opcode in %s. Hexen2 format is not supported\n", prog->name); prog->statements[i].op = op; prog->statements[i].operand[0] = remapglobal(a); prog->statements[i].operand[1] = -1; @@ -2500,7 +2502,7 @@ void PRVM_Prog_Load(prvm_prog_t *prog, const char * filename, unsigned char * da // in CSQC we really shouldn't be able to change how stuff works... sorry for now // later idea: include a list of authorized .po file checksums with the csprogs { - qboolean deftrans = prog == CLVM_prog; + qbool deftrans = prog == CLVM_prog; const char *realfilename = (prog != CLVM_prog ? filename : csqc_progname.string); if(deftrans) // once we have dotranslate_ strings, ALWAYS use the opt-in method! { @@ -2645,7 +2647,7 @@ void PRVM_Prog_Load(prvm_prog_t *prog, const char * filename, unsigned char * da prog->error_cmd("PRVM_LoadProgs: could not create cvar for autocvar global %s in %s", name, prog->name); cvar->globaldefindex[prog - prvm_prog_list] = i; } - else if((cvar->flags & CVAR_PRIVATE) == 0) + else if((cvar->flags & CF_PRIVATE) == 0) { // MUST BE SYNCED WITH cvar.c Cvar_Set int j; @@ -2744,7 +2746,7 @@ static void PRVM_Fields_f(cmd_state_t *cmd) for (ednum = 0;ednum < prog->max_edicts;ednum++) { ed = PRVM_EDICT_NUM(ednum); - if (ed->priv.required->free) + if (ed->free) continue; for (i = 1;i < prog->numfielddefs;i++) { @@ -3138,26 +3140,26 @@ PRVM_Init */ void PRVM_Init (void) { - Cmd_AddCommand(CMD_SHARED, "prvm_edict", PRVM_ED_PrintEdict_f, "print all data about an entity number in the selected VM (server, client, menu)"); - Cmd_AddCommand(CMD_SHARED, "prvm_edicts", PRVM_ED_PrintEdicts_f, "prints all data about all entities in the selected VM (server, client, menu)"); - Cmd_AddCommand(CMD_SHARED, "prvm_edictcount", PRVM_ED_Count_f, "prints number of active entities in the selected VM (server, client, menu)"); - Cmd_AddCommand(CMD_SHARED, "prvm_profile", PRVM_Profile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu)"); - Cmd_AddCommand(CMD_SHARED, "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_SHARED, "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_SHARED, "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_SHARED, "prvm_globals", PRVM_Globals_f, "prints all global variables in the selected VM (server, client, menu)"); - Cmd_AddCommand(CMD_SHARED, "prvm_global", PRVM_Global_f, "prints value of a specified global variable in the selected VM (server, client, menu)"); - Cmd_AddCommand(CMD_SHARED, "prvm_globalset", PRVM_GlobalSet_f, "sets value of a specified global variable in the selected VM (server, client, menu)"); - Cmd_AddCommand(CMD_SHARED, "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_SHARED, "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_SHARED, "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_SHARED, "prvm_printfunction", PRVM_PrintFunction_f, "prints a disassembly (QuakeC instructions) of the specified function in the selected VM (server, client, menu)"); - Cmd_AddCommand(CMD_SHARED, "cl_cmd", PRVM_GameCommand_Client_f, "calls the client QC function GameCommand with the supplied string as argument"); - Cmd_AddCommand(CMD_SHARED, "menu_cmd", PRVM_GameCommand_Menu_f, "calls the menu QC function GameCommand with the supplied string as argument"); - Cmd_AddCommand(CMD_SHARED, "sv_cmd", PRVM_GameCommand_Server_f, "calls the server QC function GameCommand with the supplied string as argument"); - Cmd_AddCommand(CMD_SHARED, "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_SHARED, "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_SHARED, "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(CF_SHARED, "prvm_edict", PRVM_ED_PrintEdict_f, "print all data about an entity number in the selected VM (server, client, menu)"); + Cmd_AddCommand(CF_SHARED, "prvm_edicts", PRVM_ED_PrintEdicts_f, "prints all data about all entities in the selected VM (server, client, menu)"); + Cmd_AddCommand(CF_SHARED, "prvm_edictcount", PRVM_ED_Count_f, "prints number of active entities in the selected VM (server, client, menu)"); + Cmd_AddCommand(CF_SHARED, "prvm_profile", PRVM_Profile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu)"); + Cmd_AddCommand(CF_SHARED, "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(CF_SHARED, "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(CF_SHARED, "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(CF_SHARED, "prvm_globals", PRVM_Globals_f, "prints all global variables in the selected VM (server, client, menu)"); + Cmd_AddCommand(CF_SHARED, "prvm_global", PRVM_Global_f, "prints value of a specified global variable in the selected VM (server, client, menu)"); + Cmd_AddCommand(CF_SHARED, "prvm_globalset", PRVM_GlobalSet_f, "sets value of a specified global variable in the selected VM (server, client, menu)"); + Cmd_AddCommand(CF_SHARED, "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(CF_SHARED, "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(CF_SHARED, "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(CF_SHARED, "prvm_printfunction", PRVM_PrintFunction_f, "prints a disassembly (QuakeC instructions) of the specified function in the selected VM (server, client, menu)"); + Cmd_AddCommand(CF_SHARED, "cl_cmd", PRVM_GameCommand_Client_f, "calls the client QC function GameCommand with the supplied string as argument"); + Cmd_AddCommand(CF_SHARED, "menu_cmd", PRVM_GameCommand_Menu_f, "calls the menu QC function GameCommand with the supplied string as argument"); + Cmd_AddCommand(CF_SHARED, "sv_cmd", PRVM_GameCommand_Server_f, "calls the server QC function GameCommand with the supplied string as argument"); + Cmd_AddCommand(CF_SHARED, "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(CF_SHARED, "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(CF_SHARED, "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); @@ -3428,7 +3430,7 @@ void PRVM_FreeString(prvm_prog_t *prog, int num) prog->error_cmd("PRVM_FreeString: invalid string offset %i", num); } -static qboolean PRVM_IsStringReferenced(prvm_prog_t *prog, string_t string) +static qbool PRVM_IsStringReferenced(prvm_prog_t *prog, string_t string) { int i, j; @@ -3444,7 +3446,7 @@ static qboolean PRVM_IsStringReferenced(prvm_prog_t *prog, string_t string) for(j = 0; j < prog->num_edicts; ++j) { prvm_edict_t *ed = PRVM_EDICT_NUM(j); - if (ed->priv.required->free) + if (ed->free) continue; for (i=0; inumfielddefs; ++i) { @@ -3459,13 +3461,13 @@ static qboolean PRVM_IsStringReferenced(prvm_prog_t *prog, string_t string) return false; } -static qboolean PRVM_IsEdictRelevant(prvm_prog_t *prog, prvm_edict_t *edict) +static qbool PRVM_IsEdictRelevant(prvm_prog_t *prog, prvm_edict_t *edict) { char vabuf[1024]; char vabuf2[1024]; if(PRVM_NUM_FOR_EDICT(edict) <= prog->reserved_edicts) return true; // world or clients - if (edict->priv.required->freetime <= prog->inittime) + if (edict->freetime <= prog->inittime) return true; // created during startup if (prog == SVVM_prog) { @@ -3511,7 +3513,7 @@ static qboolean PRVM_IsEdictRelevant(prvm_prog_t *prog, prvm_edict_t *edict) return false; } -static qboolean PRVM_IsEdictReferenced(prvm_prog_t *prog, prvm_edict_t *edict, int mark) +static qbool PRVM_IsEdictReferenced(prvm_prog_t *prog, prvm_edict_t *edict, int mark) { int i, j; int edictnum = PRVM_NUM_FOR_EDICT(edict); @@ -3554,7 +3556,7 @@ static qboolean PRVM_IsEdictReferenced(prvm_prog_t *prog, prvm_edict_t *edict, i static void PRVM_MarkReferencedEdicts(prvm_prog_t *prog) { int i, j; - qboolean found_new; + qbool found_new; int stage; // Stage 1: world, all entities that are relevant, and all entities that are referenced by globals. @@ -3562,7 +3564,7 @@ static void PRVM_MarkReferencedEdicts(prvm_prog_t *prog) for(j = 0; j < prog->num_edicts; ++j) { prvm_edict_t *ed = PRVM_EDICT_NUM(j); - if(ed->priv.required->free) + if(ed->free) continue; ed->priv.required->mark = PRVM_IsEdictRelevant(prog, ed) ? stage : 0; } @@ -3588,7 +3590,7 @@ static void PRVM_MarkReferencedEdicts(prvm_prog_t *prog) for(j = 0; j < prog->num_edicts; ++j) { prvm_edict_t *ed = PRVM_EDICT_NUM(j); - if(ed->priv.required->free) + if(ed->free) continue; if(ed->priv.required->mark) continue; @@ -3607,7 +3609,7 @@ static void PRVM_MarkReferencedEdicts(prvm_prog_t *prog) void PRVM_LeakTest(prvm_prog_t *prog) { int i, j; - qboolean leaked = false; + qbool leaked = false; if(!prog->leaktest_active) return; @@ -3630,7 +3632,7 @@ void PRVM_LeakTest(prvm_prog_t *prog) for(j = 0; j < prog->num_edicts; ++j) { prvm_edict_t *ed = PRVM_EDICT_NUM(j); - if(ed->priv.required->free) + if(ed->free) continue; if(!ed->priv.required->mark) if(ed->priv.required->allocation_origin)