X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=pr_edict.c;h=4643f3e44f2510ef850821ff423bb68def1be512;hb=699c77ca2c9fd357fbe479f00e778486becfd840;hp=2a77bac1d4df77add0a2927f635045d3f2c6103d;hpb=089076bb769d5306e81d587fd611c4c687d7bf2d;p=xonotic%2Fdarkplaces.git diff --git a/pr_edict.c b/pr_edict.c index 2a77bac1..4643f3e4 100644 --- a/pr_edict.c +++ b/pr_edict.c @@ -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"); @@ -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)); + strlcpy (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)); + strlcpy (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; } @@ -606,7 +614,7 @@ void ED_Print (edict_t *ed) if (strlen(name) > 256) { - strncpy(tempstring2, name, 256); + memcpy (tempstring2, name, 256); tempstring2[256] = tempstring2[257] = tempstring2[258] = '.'; tempstring2[259] = 0; name = tempstring2; @@ -619,7 +627,7 @@ void ED_Print (edict_t *ed) name = PR_ValueString(d->type, (eval_t *)v); if (strlen(name) > 256) { - strncpy(tempstring2, name, 256); + memcpy(tempstring2, name, 256); tempstring2[256] = tempstring2[257] = tempstring2[258] = '.'; tempstring2[259] = 0; name = tempstring2; @@ -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,10 @@ 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"); } /* @@ -814,7 +822,7 @@ void ED_EdictSet_f(void) if(Cmd_Argc() != 4) { - Con_Printf("edictset \n"); + Con_Print("edictset \n"); return; } ed = EDICT_NUM(atoi(Cmd_Argv(1))); @@ -858,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; } @@ -938,13 +946,12 @@ qboolean ED_ParseEpair(edict_t *ent, ddef_t *key, const char *s) { while (*s && *s <= ' ') s++; - if (!*s) - break; - val->vector[i] = atof(s); + if (*s) + val->vector[i] = atof(s); + else + val->vector[i] = 0; while (*s > ' ') s++; - if (!*s) - break; } break; @@ -976,7 +983,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; @@ -1058,7 +1065,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; } @@ -1148,8 +1155,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; } @@ -1161,8 +1168,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; @@ -1175,7 +1182,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); } @@ -1225,7 +1232,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"} }; /* @@ -1239,7 +1250,6 @@ void PR_LoadProgs (void) int i; dstatement_t *st; ddef_t *infielddefs; - void *temp; dfunction_t *dfunctions; // flush the non-C variable lookup cache @@ -1249,16 +1259,11 @@ void PR_LoadProgs (void) Mem_EmptyPool(progs_mempool); Mem_EmptyPool(edictstring_mempool); - temp = FS_LoadFile ("progs.dat", false); - if (!temp) + progs = (dprograms_t *)FS_LoadFile ("progs.dat", progs_mempool, false); + if (!progs) Host_Error ("PR_LoadProgs: couldn't load progs.dat"); - progs = (dprograms_t *)Mem_Alloc(progs_mempool, fs_filesize); - - 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); @@ -1268,7 +1273,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); @@ -1462,7 +1467,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)); @@ -1531,7 +1536,7 @@ void PR_Fields_f (void) } if (strlen(name) > 256) { - strncpy(tempstring2, name, 256); + memcpy(tempstring2, name, 256); tempstring2[256] = tempstring2[257] = tempstring2[258] = '.'; tempstring2[259] = 0; name = tempstring2; @@ -1544,7 +1549,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]) @@ -1562,7 +1567,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++)