X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=blobdiff_plain;f=pr_edict.c;h=151e62f0dafaf64bb3357aed577c7a69fabcecbc;hp=b2264f59ded446c8ce249c0fd3367b012f32d3ab;hb=ff46d6ff516fda192c5adc55a5c9b82007545bd2;hpb=472b1d5d4cd8c2d1b0da2aaef186eaa153b7a37e diff --git a/pr_edict.c b/pr_edict.c index b2264f59..151e62f0 100644 --- a/pr_edict.c +++ b/pr_edict.c @@ -42,7 +42,7 @@ 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(edict_t *ent, ddef_t *key, const char *s); -cvar_t pr_checkextension = {0, "pr_checkextension", "1"}; +cvar_t pr_checkextension = {CVAR_READONLY, "pr_checkextension", "1"}; cvar_t nomonsters = {0, "nomonsters", "0"}; cvar_t gamecfg = {0, "gamecfg", "0"}; cvar_t scratch1 = {0, "scratch1", "0"}; @@ -122,6 +122,10 @@ int eval_viewzoom; int eval_clientcolors; int eval_tag_entity; int eval_tag_index; +int eval_light_lev; +int eval_color; +int eval_style; +int eval_pflags; mfunction_t *SV_PlayerPhysicsQC; mfunction_t *EndFrameQC; @@ -176,6 +180,10 @@ void FindEdictFieldOffsets(void) eval_clientcolors = FindFieldOffset("clientcolors"); eval_tag_entity = FindFieldOffset("tag_entity"); eval_tag_index = FindFieldOffset("tag_index"); + eval_light_lev = FindFieldOffset("light_lev"); + eval_color = FindFieldOffset("color"); + eval_style = FindFieldOffset("style"); + eval_pflags = FindFieldOffset("pflags"); // LordHavoc: allowing QuakeC to override the player movement code SV_PlayerPhysicsQC = ED_FindFunction ("SV_PlayerPhysics"); @@ -380,7 +388,7 @@ PR_ValueString Returns a string describing *data in a type specific manner ============= */ -int NoCrash_NUM_FOR_EDICT(edict_t *e); +//int NoCrash_NUM_FOR_EDICT(edict_t *e); char *PR_ValueString (etype_t type, eval_t *val) { static char line[1024]; // LordHavoc: enlarged a bit (was 256) @@ -393,7 +401,7 @@ char *PR_ValueString (etype_t type, eval_t *val) switch (type) { case ev_string: - snprintf (line, sizeof (line), "%s", PR_GetString(val->string)); + strncpy(line, PR_GetString(val->string), sizeof(line)); break; case ev_entity: //n = NoCrash_NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)); @@ -481,7 +489,7 @@ char *PR_UglyValueString (etype_t type, eval_t *val) break; case ev_function: f = pr_functions + val->function; - snprintf (line, sizeof (line), "%s", PR_GetString(f->s_name)); + strncpy(line, PR_GetString(f->s_name), sizeof(line)); break; case ev_field: def = ED_FieldAtOfs ( val->_int ); @@ -568,7 +576,7 @@ 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) -void ED_Print (edict_t *ed) +void ED_Print(edict_t *ed) { int l; ddef_t *d; @@ -580,7 +588,7 @@ void ED_Print (edict_t *ed) if (ed->e->free) { - Con_Printf ("FREE\n"); + Con_Print("FREE\n"); return; } @@ -628,12 +636,12 @@ void ED_Print (edict_t *ed) strlcat (tempstring, "\n", sizeof (tempstring)); if (strlen(tempstring) >= 4096) { - Con_Printf("%s", tempstring); + Con_Print(tempstring); tempstring[0] = 0; } } if (tempstring[0]) - Con_Printf("%s", tempstring); + Con_Print(tempstring); } /* @@ -651,11 +659,11 @@ void ED_Write (qfile_t *f, edict_t *ed) char *name; int type; - FS_Printf (f, "{\n"); + FS_Print(f, "{\n"); if (ed->e->free) { - FS_Printf (f, "}\n"); + FS_Print(f, "}\n"); return; } @@ -676,16 +684,16 @@ void ED_Write (qfile_t *f, edict_t *ed) if (j == type_size[type]) continue; - FS_Printf (f,"\"%s\" ",name); - FS_Printf (f,"\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v)); + FS_Printf(f,"\"%s\" ",name); + FS_Printf(f,"\"%s\"\n", PR_UglyValueString(d->type, (eval_t *)v)); } - FS_Printf (f, "}\n"); + FS_Print(f, "}\n"); } void ED_PrintNum (int ent) { - ED_Print (EDICT_NUM(ent)); + ED_Print(EDICT_NUM(ent)); } /* @@ -699,7 +707,7 @@ void ED_PrintEdicts (void) { int i; - Con_Printf ("%i entities\n", sv.num_edicts); + Con_Printf("%i entities\n", sv.num_edicts); for (i=0 ; i= sv.num_edicts) + if (i < 0 || i >= sv.num_edicts) { - Con_Printf("Bad edict number\n"); + Con_Print("Bad edict number\n"); return; } ED_PrintNum (i); @@ -752,11 +760,11 @@ void ED_Count (void) step++; } - Con_Printf ("num_edicts:%3i\n", sv.num_edicts); - Con_Printf ("active :%3i\n", active); - Con_Printf ("view :%3i\n", models); - Con_Printf ("touch :%3i\n", solid); - Con_Printf ("step :%3i\n", step); + Con_Printf("num_edicts:%3i\n", sv.num_edicts); + Con_Printf("active :%3i\n", active); + Con_Printf("view :%3i\n", models); + Con_Printf("touch :%3i\n", solid); + Con_Printf("step :%3i\n", step); } @@ -781,7 +789,7 @@ void ED_WriteGlobals (qfile_t *f) char *name; int type; - FS_Printf (f,"{\n"); + FS_Print(f,"{\n"); for (i=0 ; inumglobaldefs ; i++) { def = &pr_globaldefs[i]; @@ -794,10 +802,38 @@ void ED_WriteGlobals (qfile_t *f) continue; name = PR_GetString(def->s_name); - FS_Printf (f,"\"%s\" ", name); - FS_Printf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs])); + FS_Printf(f,"\"%s\" ", name); + FS_Printf(f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs])); } - FS_Printf (f,"}\n"); + FS_Print(f,"}\n"); +} + +/* +============= +ED_EdictSet_f + +Console command to set a field of a specified edict +============= +*/ +void ED_EdictSet_f(void) +{ + edict_t *ed; + ddef_t *key; + + if(Cmd_Argc() != 4) + { + Con_Print("edictset \n"); + return; + } + ed = EDICT_NUM(atoi(Cmd_Argv(1))); + + if((key = ED_FindField(Cmd_Argv(2))) == 0) + { + Con_Printf("Key %s not found !\n", Cmd_Argv(2)); + return; + } + + ED_ParseEpair(ed, key, Cmd_Argv(3)); } /* @@ -830,7 +866,7 @@ void ED_ParseGlobals (const char *data) key = ED_FindGlobal (keyname); if (!key) { - Con_DPrintf ("'%s' is not a global\n", keyname); + Con_DPrintf("'%s' is not a global\n", keyname); continue; } @@ -948,7 +984,7 @@ qboolean ED_ParseEpair(edict_t *ent, ddef_t *key, const char *s) func = ED_FindFunction(s); if (!func) { - Con_Printf ("ED_ParseEpair: Can't find function %s\n", s); + Con_Printf("ED_ParseEpair: Can't find function %s\n", s); return false; } val->function = func - pr_functions; @@ -1030,7 +1066,7 @@ const char *ED_ParseEdict (const char *data, edict_t *ent) key = ED_FindField (keyname); if (!key) { - Con_DPrintf ("'%s' is not a field\n", keyname); + Con_DPrintf("'%s' is not a field\n", keyname); continue; } @@ -1120,8 +1156,8 @@ void ED_LoadFromFile (const char *data) // if (!ent->v->classname) { - Con_Printf ("No classname for:\n"); - ED_Print (ent); + Con_Print("No classname for:\n"); + ED_Print(ent); ED_Free (ent); continue; } @@ -1133,8 +1169,8 @@ void ED_LoadFromFile (const char *data) { if (developer.integer) // don't confuse non-developers with errors { - Con_Printf ("No spawn function for:\n"); - ED_Print (ent); + Con_Print("No spawn function for:\n"); + ED_Print(ent); } ED_Free (ent); continue; @@ -1147,7 +1183,7 @@ void ED_LoadFromFile (const char *data) died++; } - Con_DPrintf ("%i entities parsed, %i inhibited, %i spawned (%i removed self, %i stayed)\n", parsed, inhibited, spawned, died, spawned - died); + Con_DPrintf("%i entities parsed, %i inhibited, %i spawned (%i removed self, %i stayed)\n", parsed, inhibited, spawned, died, spawned - died); } @@ -1197,7 +1233,11 @@ dpfield_t dpfields[] = {ev_vector, "punchvector"}, {ev_float, "clientcolors"}, {ev_entity, "tag_entity"}, - {ev_float, "tag_index"} + {ev_float, "tag_index"}, + {ev_float, "light_lev"}, + {ev_float, "color"}, + {ev_float, "style"}, + {ev_float, "pflags"} }; /* @@ -1230,7 +1270,7 @@ void PR_LoadProgs (void) memcpy(progs, temp, fs_filesize); Mem_Free(temp); - Con_DPrintf ("Programs occupy %iK.\n", fs_filesize/1024); + Con_DPrintf("Programs occupy %iK.\n", fs_filesize/1024); pr_crc = CRC_Block((qbyte *)progs, fs_filesize); @@ -1240,7 +1280,7 @@ void PR_LoadProgs (void) if (progs->version != PROG_VERSION) Host_Error ("progs.dat has wrong version number (%i should be %i)", progs->version, PROG_VERSION); - if (progs->crc != PROGHEADER_CRC) + if (progs->crc != PROGHEADER_CRC && progs->crc != 32401) // tenebrae crc also allowed Host_Error ("progs.dat system vars have been modified, progdefs.h is out of date"); //pr_functions = (dfunction_t *)((qbyte *)progs + progs->ofs_functions); @@ -1434,7 +1474,7 @@ void PR_Fields_f (void) int *v; if (!sv.active) { - Con_Printf("no progs loaded\n"); + Con_Print("no progs loaded\n"); return; } counts = Mem_Alloc(tempmempool, progs->numfielddefs * sizeof(int)); @@ -1516,7 +1556,7 @@ void PR_Fields_f (void) strlcat (tempstring, "\n", sizeof (tempstring)); if (strlen(tempstring) >= 4096) { - Con_Printf("%s", tempstring); + Con_Print(tempstring); tempstring[0] = 0; } if (counts[i]) @@ -1534,7 +1574,7 @@ void PR_Globals_f (void) int i; if (!sv.active) { - Con_Printf("no progs loaded\n"); + Con_Print("no progs loaded\n"); return; } for (i = 0;i < progs->numglobaldefs;i++) @@ -1553,6 +1593,7 @@ void PR_Init (void) Cmd_AddCommand ("edict", ED_PrintEdict_f); Cmd_AddCommand ("edicts", ED_PrintEdicts); Cmd_AddCommand ("edictcount", ED_Count); + Cmd_AddCommand ("edictset", ED_EdictSet_f); Cmd_AddCommand ("profile", PR_Profile_f); Cmd_AddCommand ("pr_fields", PR_Fields_f); Cmd_AddCommand ("pr_globals", PR_Globals_f);