X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=pr_edict.c;h=23872816059a4257ac9d5cb2e8a60ff3b1d0a291;hb=8468ffaf8162a4fe8361127385c40141c375661d;hp=93d306b6190db306f1c2080428a2fc8b1df0910f;hpb=5c41d784306266a94c8caf92c6ea2680f98a5e01;p=xonotic%2Fdarkplaces.git diff --git a/pr_edict.c b/pr_edict.c index 93d306b6..23872816 100644 --- a/pr_edict.c +++ b/pr_edict.c @@ -39,31 +39,32 @@ int type_size[8] = {1,sizeof(string_t)/4,1,3,1,1,sizeof(func_t)/4,sizeof(void * ddef_t *ED_FieldAtOfs (int ofs); qboolean ED_ParseEpair (void *base, ddef_t *key, char *s); -cvar_t nomonsters = {"nomonsters", "0"}; -cvar_t gamecfg = {"gamecfg", "0"}; -cvar_t scratch1 = {"scratch1", "0"}; -cvar_t scratch2 = {"scratch2", "0"}; -cvar_t scratch3 = {"scratch3", "0"}; -cvar_t scratch4 = {"scratch4", "0"}; -cvar_t savedgamecfg = {"savedgamecfg", "0", true}; -cvar_t saved1 = {"saved1", "0", true}; -cvar_t saved2 = {"saved2", "0", true}; -cvar_t saved3 = {"saved3", "0", true}; -cvar_t saved4 = {"saved4", "0", true}; -cvar_t decors = {"decors", "0"}; -cvar_t nehx00 = {"nehx00", "0"};cvar_t nehx01 = {"nehx01", "0"}; -cvar_t nehx02 = {"nehx02", "0"};cvar_t nehx03 = {"nehx03", "0"}; -cvar_t nehx04 = {"nehx04", "0"};cvar_t nehx05 = {"nehx05", "0"}; -cvar_t nehx06 = {"nehx06", "0"};cvar_t nehx07 = {"nehx07", "0"}; -cvar_t nehx08 = {"nehx08", "0"};cvar_t nehx09 = {"nehx09", "0"}; -cvar_t nehx10 = {"nehx10", "0"};cvar_t nehx11 = {"nehx11", "0"}; -cvar_t nehx12 = {"nehx12", "0"};cvar_t nehx13 = {"nehx13", "0"}; -cvar_t nehx14 = {"nehx14", "0"};cvar_t nehx15 = {"nehx15", "0"}; -cvar_t nehx16 = {"nehx16", "0"};cvar_t nehx17 = {"nehx17", "0"}; -cvar_t nehx18 = {"nehx18", "0"};cvar_t nehx19 = {"nehx19", "0"}; -cvar_t cutscene = {"cutscene", "1"}; +cvar_t pr_checkextension = {0, "pr_checkextension", "1"}; +cvar_t nomonsters = {0, "nomonsters", "0"}; +cvar_t gamecfg = {0, "gamecfg", "0"}; +cvar_t scratch1 = {0, "scratch1", "0"}; +cvar_t scratch2 = {0,"scratch2", "0"}; +cvar_t scratch3 = {0, "scratch3", "0"}; +cvar_t scratch4 = {0, "scratch4", "0"}; +cvar_t savedgamecfg = {CVAR_SAVE, "savedgamecfg", "0"}; +cvar_t saved1 = {CVAR_SAVE, "saved1", "0"}; +cvar_t saved2 = {CVAR_SAVE, "saved2", "0"}; +cvar_t saved3 = {CVAR_SAVE, "saved3", "0"}; +cvar_t saved4 = {CVAR_SAVE, "saved4", "0"}; +cvar_t decors = {0, "decors", "0"}; +cvar_t nehx00 = {0, "nehx00", "0"};cvar_t nehx01 = {0, "nehx01", "0"}; +cvar_t nehx02 = {0, "nehx02", "0"};cvar_t nehx03 = {0, "nehx03", "0"}; +cvar_t nehx04 = {0, "nehx04", "0"};cvar_t nehx05 = {0, "nehx05", "0"}; +cvar_t nehx06 = {0, "nehx06", "0"};cvar_t nehx07 = {0, "nehx07", "0"}; +cvar_t nehx08 = {0, "nehx08", "0"};cvar_t nehx09 = {0, "nehx09", "0"}; +cvar_t nehx10 = {0, "nehx10", "0"};cvar_t nehx11 = {0, "nehx11", "0"}; +cvar_t nehx12 = {0, "nehx12", "0"};cvar_t nehx13 = {0, "nehx13", "0"}; +cvar_t nehx14 = {0, "nehx14", "0"};cvar_t nehx15 = {0, "nehx15", "0"}; +cvar_t nehx16 = {0, "nehx16", "0"};cvar_t nehx17 = {0, "nehx17", "0"}; +cvar_t nehx18 = {0, "nehx18", "0"};cvar_t nehx19 = {0, "nehx19", "0"}; +cvar_t cutscene = {0, "cutscene", "1"}; // 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 pr_boundscheck = {"pr_boundscheck", "1"}; +cvar_t pr_boundscheck = {0, "pr_boundscheck", "1"}; #define MAX_FIELD_LEN 64 #define GEFV_CACHESIZE 2 @@ -106,11 +107,13 @@ int eval_idealpitch; int eval_pitch_speed; int eval_viewmodelforclient; int eval_nodrawtoclient; +int eval_exteriormodeltoclient; int eval_drawonlytoclient; int eval_colormod; int eval_ping; int eval_movement; int eval_pmodel; +int eval_punchvector; dfunction_t *SV_PlayerPhysicsQC; dfunction_t *EndFrameQC; @@ -124,7 +127,7 @@ int FindFieldOffset(char *field) return d->ofs*4; } -void FindEdictFieldOffsets() +void FindEdictFieldOffsets(void) { eval_gravity = FindFieldOffset("gravity"); eval_button3 = FindFieldOffset("button3"); @@ -153,11 +156,13 @@ void FindEdictFieldOffsets() eval_pitch_speed = FindFieldOffset("pitch_speed"); eval_viewmodelforclient = FindFieldOffset("viewmodelforclient"); eval_nodrawtoclient = FindFieldOffset("nodrawtoclient"); + eval_exteriormodeltoclient = FindFieldOffset("exteriormodeltoclient"); eval_drawonlytoclient = FindFieldOffset("drawonlytoclient"); eval_colormod = FindFieldOffset("colormod"); eval_ping = FindFieldOffset("ping"); eval_movement = FindFieldOffset("movement"); eval_pmodel = FindFieldOffset("pmodel"); + eval_punchvector = FindFieldOffset("punchvector"); // LordHavoc: allowing QuakeC to override the player movement code SV_PlayerPhysicsQC = ED_FindFunction ("SV_PlayerPhysics"); @@ -235,8 +240,8 @@ void ED_Free (edict_t *ed) ed->v.colormap = 0; ed->v.skin = 0; ed->v.frame = 0; - VectorCopy (vec3_origin, ed->v.origin); - VectorCopy (vec3_origin, ed->v.angles); + VectorClear(ed->v.origin); + VectorClear(ed->v.angles); ed->v.nextthink = -1; ed->v.solid = 0; @@ -302,7 +307,6 @@ ddef_t *ED_FindField (char *name) return NULL; } - /* ============ ED_FindGlobal @@ -385,7 +389,7 @@ Returns a string describing *data in a type specific manner */ char *PR_ValueString (etype_t type, eval_t *val) { - static char line[256]; + static char line[1024]; // LordHavoc: enlarged a bit (was 256) ddef_t *def; dfunction_t *f; @@ -411,10 +415,12 @@ char *PR_ValueString (etype_t type, eval_t *val) sprintf (line, "void"); break; case ev_float: - sprintf (line, "%5.1f", val->_float); + // LordHavoc: changed from %5.1f to %10.4f + sprintf (line, "%10.4f", val->_float); break; case ev_vector: - sprintf (line, "'%5.1f %5.1f %5.1f'", val->vector[0], val->vector[1], val->vector[2]); + // LordHavoc: changed from %5.1f to %10.4f + sprintf (line, "'%10.4f %10.4f %10.4f'", val->vector[0], val->vector[1], val->vector[2]); break; case ev_pointer: sprintf (line, "pointer"); @@ -538,7 +544,7 @@ ED_Print For debugging ============= */ -// LordHavoc: optimized this to print out much more quickly +// LordHavoc: optimized this to print out much more quickly (tempstring) void ED_Print (edict_t *ed) { int l; @@ -576,9 +582,9 @@ void ED_Print (edict_t *ed) continue; strcat(tempstring, name); - l = strlen (name); - while (l++ < 15) + for (l = strlen(name);l < 14;l++) strcat(tempstring, " "); + strcat(tempstring, " "); strcat(tempstring, PR_ValueString(d->type, (eval_t *)v)); strcat(tempstring, "\n"); @@ -593,7 +599,7 @@ ED_Write For savegames ============= */ -void ED_Write (FILE *f, edict_t *ed) +void ED_Write (QFile *f, edict_t *ed) { ddef_t *d; int *v; @@ -601,11 +607,11 @@ void ED_Write (FILE *f, edict_t *ed) char *name; int type; - fprintf (f, "{\n"); + Qprintf (f, "{\n"); if (ed->free) { - fprintf (f, "}\n"); + Qprintf (f, "}\n"); return; } @@ -626,11 +632,11 @@ void ED_Write (FILE *f, edict_t *ed) if (j == type_size[type]) continue; - fprintf (f,"\"%s\" ",name); - fprintf (f,"\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v)); + Qprintf (f,"\"%s\" ",name); + Qprintf (f,"\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v)); } - fprintf (f, "}\n"); + Qprintf (f, "}\n"); } void ED_PrintNum (int ent) @@ -724,14 +730,14 @@ FIXME: need to tag constants, doesn't really work ED_WriteGlobals ============= */ -void ED_WriteGlobals (FILE *f) +void ED_WriteGlobals (QFile *f) { ddef_t *def; int i; char *name; int type; - fprintf (f,"{\n"); + Qprintf (f,"{\n"); for (i=0 ; inumglobaldefs ; i++) { def = &pr_globaldefs[i]; @@ -740,16 +746,14 @@ void ED_WriteGlobals (FILE *f) continue; type &= ~DEF_SAVEGLOBAL; - if (type != ev_string - && type != ev_float - && type != ev_entity) + if (type != ev_string && type != ev_float && type != ev_entity) continue; name = pr_strings + def->s_name; - fprintf (f,"\"%s\" ", name); - fprintf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs])); + Qprintf (f,"\"%s\" ", name); + Qprintf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs])); } - fprintf (f,"}\n"); + Qprintf (f,"}\n"); } /* @@ -759,7 +763,7 @@ ED_ParseGlobals */ void ED_ParseGlobals (char *data) { - char keyname[64]; + char keyname[1024]; // LordHavoc: good idea? bad idea? was 64 ddef_t *key; while (1) @@ -807,7 +811,7 @@ char *ED_NewString (char *string) int i,l; l = strlen(string) + 1; - new = Hunk_Alloc (l); + new = Hunk_AllocName (l, "edict string"); new_p = new; for (i=0 ; i< l ; i++) @@ -1086,7 +1090,7 @@ void ED_LoadFromFile (char *data) } pr_global_struct->self = EDICT_TO_PROG(ent); - PR_ExecuteProgram (func - pr_functions); + PR_ExecuteProgram (func - pr_functions, ""); } Con_DPrintf ("%i entities inhibited\n", inhibit); @@ -1277,6 +1281,32 @@ void PR_LoadProgs (void) } +void PR_Fields_f (void) +{ + int i; + if (!sv.active) + { + Con_Printf("no progs loaded\n"); + return; + } + for (i = 0;i < progs->numfielddefs;i++) + Con_Printf("%s\n", (pr_strings + pr_fielddefs[i].s_name)); + Con_Printf("%i entity fields, totalling %i bytes per edict, %i edicts, %i bytes total spent on edict fields\n", progs->entityfields, progs->entityfields * 4, MAX_EDICTS, progs->entityfields * 4 * MAX_EDICTS); +} + +void PR_Globals_f (void) +{ + int i; + if (!sv.active) + { + Con_Printf("no progs loaded\n"); + return; + } + for (i = 0;i < progs->numglobaldefs;i++) + Con_Printf("%s\n", (pr_strings + pr_globaldefs[i].s_name)); + Con_Printf("%i global variables, totalling %i bytes\n", progs->numglobals, progs->numglobals * 4); +} + /* =============== PR_Init @@ -1288,6 +1318,9 @@ void PR_Init (void) Cmd_AddCommand ("edicts", ED_PrintEdicts); Cmd_AddCommand ("edictcount", ED_Count); Cmd_AddCommand ("profile", PR_Profile_f); + Cmd_AddCommand ("pr_fields", PR_Fields_f); + Cmd_AddCommand ("pr_globals", PR_Globals_f); + Cvar_RegisterVariable (&pr_checkextension); Cvar_RegisterVariable (&nomonsters); Cvar_RegisterVariable (&gamecfg); Cvar_RegisterVariable (&scratch1);