X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=pr_edict.c;h=b7d347304a8c2c3c22245668fe001cd97129b7bc;hb=b132ccbd81d360fc065fa54fc846fe416c62e66e;hp=8520ede01ac44f24623ef63cf23292e506ce6f5e;hpb=d634ac06383b4927e3354605e5261902eed22e99;p=xonotic%2Fdarkplaces.git diff --git a/pr_edict.c b/pr_edict.c index 8520ede0..b7d34730 100644 --- a/pr_edict.c +++ b/pr_edict.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" dprograms_t *progs; -dfunction_t *pr_functions; +mfunction_t *pr_functions; char *pr_strings; ddef_t *pr_fielddefs; ddef_t *pr_globaldefs; @@ -82,7 +82,7 @@ typedef struct { static gefv_cache gefvCache[GEFV_CACHESIZE] = {{NULL, ""}, {NULL, ""}}; ddef_t *ED_FindField (const char *name); -dfunction_t *ED_FindFunction (const char *name); +mfunction_t *ED_FindFunction (const char *name); // LordHavoc: in an effort to eliminate time wasted on GetEdictFieldValue... these are defined as externs in progs.h int eval_gravity; @@ -120,8 +120,10 @@ int eval_pmodel; int eval_punchvector; int eval_viewzoom; -dfunction_t *SV_PlayerPhysicsQC; -dfunction_t *EndFrameQC; +mfunction_t *SV_PlayerPhysicsQC; +mfunction_t *EndFrameQC; +//KrimZon - SERVER COMMANDS IN QUAKEC +mfunction_t *SV_ParseClientCommandQC; int FindFieldOffset(const char *field) { @@ -173,6 +175,8 @@ void FindEdictFieldOffsets(void) SV_PlayerPhysicsQC = ED_FindFunction ("SV_PlayerPhysics"); // LordHavoc: support for endframe EndFrameQC = ED_FindFunction ("EndFrame"); + //KrimZon - SERVER COMMANDS IN QUAKEC + SV_ParseClientCommandQC = ED_FindFunction ("SV_ParseClientCommand"); } /* @@ -184,8 +188,8 @@ Sets everything to NULL */ void ED_ClearEdict (edict_t *e) { - memset (&e->v, 0, progs->entityfields * 4); - e->free = false; + memset (e->v, 0, progs->entityfields * 4); + e->e->free = false; } /* @@ -199,6 +203,7 @@ instead of being removed and recreated, which can cause interpolated angles and bad trails. ================= */ +extern void SV_IncreaseEdicts(void); edict_t *ED_Alloc (void) { int i; @@ -209,17 +214,19 @@ edict_t *ED_Alloc (void) e = EDICT_NUM(i); // the first couple seconds of server time can involve a lot of // freeing and allocating, so relax the replacement policy - if (e->free && ( e->freetime < 2 || sv.time - e->freetime > 0.5 ) ) + if (e->e->free && ( e->e->freetime < 2 || sv.time - e->e->freetime > 0.5 ) ) { ED_ClearEdict (e); return e; } } - + if (i == MAX_EDICTS) Host_Error ("ED_Alloc: no free edicts"); - + sv.num_edicts++; + if (sv.num_edicts >= sv.max_edicts) + SV_IncreaseEdicts(); e = EDICT_NUM(i); ED_ClearEdict (e); @@ -238,19 +245,19 @@ void ED_Free (edict_t *ed) { SV_UnlinkEdict (ed); // unlink from world bsp - ed->free = true; - ed->v.model = 0; - ed->v.takedamage = 0; - ed->v.modelindex = 0; - ed->v.colormap = 0; - ed->v.skin = 0; - ed->v.frame = 0; - VectorClear(ed->v.origin); - VectorClear(ed->v.angles); - ed->v.nextthink = -1; - ed->v.solid = 0; - - ed->freetime = sv.time; + ed->e->free = true; + ed->v->model = 0; + ed->v->takedamage = 0; + ed->v->modelindex = 0; + ed->v->colormap = 0; + ed->v->skin = 0; + ed->v->frame = 0; + VectorClear(ed->v->origin); + VectorClear(ed->v->angles); + ed->v->nextthink = -1; + ed->v->solid = 0; + + ed->e->freetime = sv.time; } //=========================================================================== @@ -264,7 +271,7 @@ ddef_t *ED_GlobalAtOfs (int ofs) { ddef_t *def; int i; - + for (i=0 ; inumglobaldefs ; i++) { def = &pr_globaldefs[i]; @@ -283,7 +290,7 @@ ddef_t *ED_FieldAtOfs (int ofs) { ddef_t *def; int i; - + for (i=0 ; inumfielddefs ; i++) { def = &pr_fielddefs[i]; @@ -306,7 +313,7 @@ ddef_t *ED_FindField (const char *name) for (i=0 ; inumfielddefs ; i++) { def = &pr_fielddefs[i]; - if (!strcmp(pr_strings + def->s_name,name) ) + if (!strcmp(PR_GetString(def->s_name), name)) return def; } return NULL; @@ -325,7 +332,7 @@ ddef_t *ED_FindGlobal (const char *name) for (i=0 ; inumglobaldefs ; i++) { def = &pr_globaldefs[i]; - if (!strcmp(pr_strings + def->s_name,name) ) + if (!strcmp(PR_GetString(def->s_name), name)) return def; } return NULL; @@ -337,15 +344,15 @@ ddef_t *ED_FindGlobal (const char *name) ED_FindFunction ============ */ -dfunction_t *ED_FindFunction (const char *name) +mfunction_t *ED_FindFunction (const char *name) { - dfunction_t *func; + mfunction_t *func; int i; for (i=0 ; inumfunctions ; i++) { func = &pr_functions[i]; - if (!strcmp(pr_strings + func->s_name,name) ) + if (!strcmp(PR_GetString(func->s_name), name)) return func; } return NULL; @@ -364,7 +371,7 @@ char *PR_ValueString (etype_t type, eval_t *val) { static char line[1024]; // LordHavoc: enlarged a bit (was 256) ddef_t *def; - dfunction_t *f; + mfunction_t *f; int n; type &= ~DEF_SAVEGLOBAL; @@ -372,10 +379,11 @@ char *PR_ValueString (etype_t type, eval_t *val) switch (type) { case ev_string: - sprintf (line, "%s", pr_strings + val->string); + sprintf (line, "%s", PR_GetString(val->string)); break; case ev_entity: - n = NoCrash_NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)); + //n = NoCrash_NUM_FOR_EDICT(PROG_TO_EDICT(val->edict)); + n = val->edict; if (n < 0 || n >= MAX_EDICTS) sprintf (line, "entity %i (invalid!)", n); else @@ -383,11 +391,11 @@ char *PR_ValueString (etype_t type, eval_t *val) break; case ev_function: f = pr_functions + val->function; - sprintf (line, "%s()", pr_strings + f->s_name); + sprintf (line, "%s()", PR_GetString(f->s_name)); break; case ev_field: def = ED_FieldAtOfs ( val->_int ); - sprintf (line, ".%s", pr_strings + def->s_name); + sprintf (line, ".%s", PR_GetString(def->s_name)); break; case ev_void: sprintf (line, "void"); @@ -425,29 +433,29 @@ char *PR_UglyValueString (etype_t type, eval_t *val) int i; char *s; ddef_t *def; - dfunction_t *f; + mfunction_t *f; type &= ~DEF_SAVEGLOBAL; switch (type) { case ev_string: - sprintf (line, "%s", pr_strings + val->string); + sprintf (line, "%s", PR_GetString(val->string)); break; case ev_entity: sprintf (line, "%i", NUM_FOR_EDICT(PROG_TO_EDICT(val->edict))); break; case ev_function: f = pr_functions + val->function; - sprintf (line, "%s", pr_strings + f->s_name); + sprintf (line, "%s", PR_GetString(f->s_name)); break; case ev_field: def = ED_FieldAtOfs ( val->_int ); // LordHavoc: parse the string a bit to turn special characters // (like newline, specifically) into escape codes, // this fixes saving games from various mods - //sprintf (line, "%s", pr_strings + def->s_name); - s = pr_strings + def->s_name; + //sprintf (line, "%s", PR_GetString(def->s_name)); + s = PR_GetString(def->s_name); for (i = 0;i < 4095 && *s;) { if (*s == '\n') @@ -506,7 +514,7 @@ char *PR_GlobalString (int ofs) else { s = PR_ValueString (def->type, val); - sprintf (line,"%i(%s)%s", ofs, pr_strings + def->s_name, s); + sprintf (line,"%i(%s)%s", ofs, PR_GetString(def->s_name), s); } i = strlen(line); @@ -527,7 +535,7 @@ char *PR_GlobalStringNoContents (int ofs) if (!def) sprintf (line,"%i(?)", ofs); else - sprintf (line,"%i(%s)", ofs, pr_strings + def->s_name); + sprintf (line,"%i(%s)", ofs, PR_GetString(def->s_name)); i = strlen(line); for ( ; i<20 ; i++) @@ -557,7 +565,7 @@ void ED_Print (edict_t *ed) int type; char tempstring[8192], tempstring2[260]; // temporary string buffers - if (ed->free) + if (ed->e->free) { Con_Printf ("FREE\n"); return; @@ -568,11 +576,11 @@ void ED_Print (edict_t *ed) for (i=1 ; inumfielddefs ; i++) { d = &pr_fielddefs[i]; - name = pr_strings + d->s_name; + name = PR_GetString(d->s_name); if (name[strlen(name)-2] == '_') continue; // skip _x, _y, _z vars - v = (int *)((char *)&ed->v + d->ofs*4); + v = (int *)((char *)ed->v + d->ofs*4); // if the value is still all 0, skip the field type = d->type & ~DEF_SAVEGLOBAL; @@ -622,7 +630,7 @@ ED_Write For savegames ============= */ -void ED_Write (QFile *f, edict_t *ed) +void ED_Write (qfile_t *f, edict_t *ed) { ddef_t *d; int *v; @@ -630,22 +638,22 @@ void ED_Write (QFile *f, edict_t *ed) char *name; int type; - Qprintf (f, "{\n"); + FS_Printf (f, "{\n"); - if (ed->free) + if (ed->e->free) { - Qprintf (f, "}\n"); + FS_Printf (f, "}\n"); return; } for (i=1 ; inumfielddefs ; i++) { d = &pr_fielddefs[i]; - name = pr_strings + d->s_name; + name = PR_GetString(d->s_name); if (name[strlen(name)-2] == '_') continue; // skip _x, _y, _z vars - v = (int *)((char *)&ed->v + d->ofs*4); + v = (int *)((char *)ed->v + d->ofs*4); // if the value is still all 0, skip the field type = d->type & ~DEF_SAVEGLOBAL; @@ -655,11 +663,11 @@ void ED_Write (QFile *f, edict_t *ed) if (j == type_size[type]) continue; - Qprintf (f,"\"%s\" ",name); - Qprintf (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)); } - Qprintf (f, "}\n"); + FS_Printf (f, "}\n"); } void ED_PrintNum (int ent) @@ -720,14 +728,14 @@ void ED_Count (void) for (i=0 ; ifree) + if (ent->e->free) continue; active++; - if (ent->v.solid) + if (ent->v->solid) solid++; - if (ent->v.model) + if (ent->v->model) models++; - if (ent->v.movetype == MOVETYPE_STEP) + if (ent->v->movetype == MOVETYPE_STEP) step++; } @@ -753,14 +761,14 @@ FIXME: need to tag constants, doesn't really work ED_WriteGlobals ============= */ -void ED_WriteGlobals (QFile *f) +void ED_WriteGlobals (qfile_t *f) { ddef_t *def; int i; char *name; int type; - Qprintf (f,"{\n"); + FS_Printf (f,"{\n"); for (i=0 ; inumglobaldefs ; i++) { def = &pr_globaldefs[i]; @@ -772,11 +780,11 @@ void ED_WriteGlobals (QFile *f) if (type != ev_string && type != ev_float && type != ev_entity) continue; - name = pr_strings + def->s_name; - Qprintf (f,"\"%s\" ", name); - Qprintf (f,"\"%s\"\n", PR_UglyValueString(type, (eval_t *)&pr_globals[def->ofs])); + 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])); } - Qprintf (f,"}\n"); + FS_Printf (f,"}\n"); } /* @@ -868,20 +876,20 @@ qboolean ED_ParseEpair (void *base, ddef_t *key, const char *s) ddef_t *def; char *v, *w; void *d; - dfunction_t *func; + mfunction_t *func; d = (void *)((int *)base + key->ofs); switch (key->type & ~DEF_SAVEGLOBAL) { case ev_string: - *(string_t *)d = ED_NewString (s) - pr_strings; + *(string_t *)d = PR_SetString(ED_NewString(s)); break; - + case ev_float: *(float *)d = atof (s); break; - + case ev_vector: strcpy (string, s); v = string; @@ -911,7 +919,7 @@ qboolean ED_ParseEpair (void *base, ddef_t *key, const char *s) } *(int *)d = G_INT(def->ofs); break; - + case ev_function: func = ED_FindFunction (s); if (!func) @@ -949,7 +957,7 @@ const char *ED_ParseEdict (const char *data, edict_t *ent) // clear it if (ent != sv.edicts) // hack - memset (&ent->v, 0, progs->entityfields * 4); + memset (ent->v, 0, progs->entityfields * 4); // go through all the dictionary pairs while (1) @@ -1012,12 +1020,12 @@ const char *ED_ParseEdict (const char *data, edict_t *ent) sprintf (com_token, "0 %s 0", temp); } - if (!ED_ParseEpair ((void *)&ent->v, key, com_token)) + if (!ED_ParseEpair ((void *)ent->v, key, com_token)) Host_Error ("ED_ParseEdict: parse error"); } if (!init) - ent->free = true; + ent->e->free = true; return data; } @@ -1041,13 +1049,16 @@ to call ED_CallSpawnFunctions () to let the objects initialize themselves. void ED_LoadFromFile (const char *data) { edict_t *ent; - int inhibit; - dfunction_t *func; + int parsed, inhibited, spawned, died; + mfunction_t *func; ent = NULL; - inhibit = 0; + parsed = 0; + inhibited = 0; + spawned = 0; + died = 0; pr_global_struct->time = sv.time; - + // parse ents while (1) { @@ -1062,30 +1073,31 @@ void ED_LoadFromFile (const char *data) else ent = ED_Alloc (); data = ED_ParseEdict (data, ent); + parsed++; // remove things from different skill levels or deathmatch if (deathmatch.integer) { - if (((int)ent->v.spawnflags & SPAWNFLAG_NOT_DEATHMATCH)) + if (((int)ent->v->spawnflags & SPAWNFLAG_NOT_DEATHMATCH)) { - ED_Free (ent); - inhibit++; + ED_Free (ent); + inhibited++; continue; } } - else if ((current_skill == 0 && ((int)ent->v.spawnflags & SPAWNFLAG_NOT_EASY )) - || (current_skill == 1 && ((int)ent->v.spawnflags & SPAWNFLAG_NOT_MEDIUM)) - || (current_skill >= 2 && ((int)ent->v.spawnflags & SPAWNFLAG_NOT_HARD ))) + else if ((current_skill == 0 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_EASY )) + || (current_skill == 1 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_MEDIUM)) + || (current_skill >= 2 && ((int)ent->v->spawnflags & SPAWNFLAG_NOT_HARD ))) { - ED_Free (ent); - inhibit++; + ED_Free (ent); + inhibited++; continue; } // // immediately call spawn function // - if (!ent->v.classname) + if (!ent->v->classname) { Con_Printf ("No classname for:\n"); ED_Print (ent); @@ -1094,7 +1106,7 @@ void ED_LoadFromFile (const char *data) } // look for the spawn function - func = ED_FindFunction ( pr_strings + ent->v.classname ); + func = ED_FindFunction (PR_GetString(ent->v->classname)); if (!func) { @@ -1109,9 +1121,12 @@ void ED_LoadFromFile (const char *data) pr_global_struct->self = EDICT_TO_PROG(ent); PR_ExecuteProgram (func - pr_functions, ""); + spawned++; + if (ent->e->free) + died++; } - Con_DPrintf ("%i entities inhibited\n", inhibit); + Con_DPrintf ("%i entities parsed, %i inhibited, %i spawned (%i removed self, %i stayed)\n", parsed, inhibited, spawned, died, spawned - died); } @@ -1166,12 +1181,14 @@ dpfield_t dpfields[] = PR_LoadProgs =============== */ +extern void PR_Cmd_Reset (void); void PR_LoadProgs (void) { int i; dstatement_t *st; ddef_t *infielddefs; void *temp; + dfunction_t *dfunctions; // flush the non-C variable lookup cache for (i=0 ; iversion != PROG_VERSION) @@ -1202,7 +1219,8 @@ void PR_LoadProgs (void) if (progs->crc != PROGHEADER_CRC) Host_Error ("progs.dat system vars have been modified, progdefs.h is out of date"); - pr_functions = (dfunction_t *)((qbyte *)progs + progs->ofs_functions); + //pr_functions = (dfunction_t *)((qbyte *)progs + progs->ofs_functions); + dfunctions = (dfunction_t *)((qbyte *)progs + progs->ofs_functions); pr_strings = (char *)progs + progs->ofs_strings; pr_globaldefs = (ddef_t *)((qbyte *)progs + progs->ofs_globaldefs); @@ -1227,14 +1245,16 @@ void PR_LoadProgs (void) pr_statements[i].c = LittleShort(pr_statements[i].c); } - for (i=0 ; inumfunctions; i++) + pr_functions = Mem_Alloc(progs_mempool, sizeof(mfunction_t) * progs->numfunctions); + for (i = 0;i < progs->numfunctions;i++) { - pr_functions[i].first_statement = LittleLong (pr_functions[i].first_statement); - pr_functions[i].parm_start = LittleLong (pr_functions[i].parm_start); - pr_functions[i].s_name = LittleLong (pr_functions[i].s_name); - pr_functions[i].s_file = LittleLong (pr_functions[i].s_file); - pr_functions[i].numparms = LittleLong (pr_functions[i].numparms); - pr_functions[i].locals = LittleLong (pr_functions[i].locals); + pr_functions[i].first_statement = LittleLong (dfunctions[i].first_statement); + pr_functions[i].parm_start = LittleLong (dfunctions[i].parm_start); + pr_functions[i].s_name = LittleLong (dfunctions[i].s_name); + pr_functions[i].s_file = LittleLong (dfunctions[i].s_file); + pr_functions[i].numparms = LittleLong (dfunctions[i].numparms); + pr_functions[i].locals = LittleLong (dfunctions[i].locals); + memcpy(pr_functions[i].parm_size, dfunctions[i].parm_size, sizeof(dfunctions[i].parm_size)); } for (i=0 ; inumglobaldefs ; i++) @@ -1255,11 +1275,11 @@ void PR_LoadProgs (void) } // append the darkplaces fields - for (i = 0;i < DPFIELDS;i++) + for (i = 0;i < (int) DPFIELDS;i++) { pr_fielddefs[progs->numfielddefs].type = dpfields[i].type; pr_fielddefs[progs->numfielddefs].ofs = progs->entityfields; - pr_fielddefs[progs->numfielddefs].s_name = dpfields[i].string - pr_strings; + pr_fielddefs[progs->numfielddefs].s_name = PR_SetString(dpfields[i].string); if (pr_fielddefs[progs->numfielddefs].type == ev_vector) progs->entityfields += 3; else @@ -1271,8 +1291,8 @@ void PR_LoadProgs (void) ((int *)pr_globals)[i] = LittleLong (((int *)pr_globals)[i]); // moved edict_size calculation down here, below field adding code - pr_edict_size = progs->entityfields * 4 + sizeof (edict_t) - sizeof(entvars_t); - + // LordHavoc: this no longer includes the edict_t header + pr_edict_size = progs->entityfields * 4; pr_edictareasize = pr_edict_size * MAX_EDICTS; // LordHavoc: bounds check anything static @@ -1376,6 +1396,7 @@ void PR_LoadProgs (void) FindEdictFieldOffsets(); // LordHavoc: update field offset list PR_Execute_ProgsLoaded(); + PR_Cmd_Reset(); } @@ -1396,15 +1417,15 @@ void PR_Fields_f (void) for (ednum = 0;ednum < MAX_EDICTS;ednum++) { ed = EDICT_NUM(ednum); - if (ed->free) + if (ed->e->free) continue; for (i = 1;i < progs->numfielddefs;i++) { d = &pr_fielddefs[i]; - name = pr_strings + d->s_name; + name = PR_GetString(d->s_name); if (name[strlen(name)-2] == '_') continue; // skip _x, _y, _z vars - v = (int *)((char *)&ed->v + d->ofs*4); + v = (int *)((char *)ed->v + d->ofs*4); // if the value is still all 0, skip the field for (j = 0;j < type_size[d->type & ~DEF_SAVEGLOBAL];j++) { @@ -1422,7 +1443,7 @@ void PR_Fields_f (void) for (i = 0;i < progs->numfielddefs;i++) { d = &pr_fielddefs[i]; - name = pr_strings + d->s_name; + name = PR_GetString(d->s_name); if (name[strlen(name)-2] == '_') continue; // skip _x, _y, _z vars switch(d->type & ~DEF_SAVEGLOBAL) @@ -1493,7 +1514,7 @@ void PR_Globals_f (void) return; } for (i = 0;i < progs->numglobaldefs;i++) - Con_Printf("%s\n", (pr_strings + pr_globaldefs[i].s_name)); + Con_Printf("%s\n", PR_GetString(pr_globaldefs[i].s_name)); Con_Printf("%i global variables, totalling %i bytes\n", progs->numglobals, progs->numglobals * 4); } @@ -1502,6 +1523,7 @@ void PR_Globals_f (void) PR_Init =============== */ +extern void PR_Cmd_Init(void); void PR_Init (void) { Cmd_AddCommand ("edict", ED_PrintEdict_f); @@ -1545,33 +1567,55 @@ void PR_Init (void) progs_mempool = Mem_AllocPool("progs.dat"); edictstring_mempool = Mem_AllocPool("edict strings"); + + PR_Cmd_Init(); } // LordHavoc: turned EDICT_NUM into a #define for speed reasons -edict_t *EDICT_NUM_ERROR(int n) +edict_t *EDICT_NUM_ERROR(int n, char *filename, int fileline) { - Host_Error ("EDICT_NUM: bad number %i", n); + Host_Error ("EDICT_NUM: bad number %i (called at %f:%i)", n, filename, fileline); return NULL; } -int NUM_FOR_EDICT(edict_t *e) +/* +int NUM_FOR_EDICT_ERROR(edict_t *e) { - int b; - - b = (qbyte *)e - (qbyte *)sv.edicts; - b = b / pr_edict_size; + Host_Error ("NUM_FOR_EDICT: bad pointer %p (world is %p, entity number would be %i)", e, sv.edicts, e - sv.edicts); + return 0; +} - if (b < 0 || b >= sv.num_edicts) +int NUM_FOR_EDICT(edict_t *e) +{ + int n; + n = e - sv.edicts; + if ((unsigned int)n >= MAX_EDICTS) Host_Error ("NUM_FOR_EDICT: bad pointer"); - return b; + return n; } -int NoCrash_NUM_FOR_EDICT(edict_t *e) -{ - int b; +//int NoCrash_NUM_FOR_EDICT(edict_t *e) +//{ +// return e - sv.edicts; +//} - b = (qbyte *)e - (qbyte *)sv.edicts; - b = b / pr_edict_size; - return b; +//#define EDICT_TO_PROG(e) ((qbyte *)(((edict_t *)e)->v) - (qbyte *)(sv.edictsfields)) +//#define PROG_TO_EDICT(e) (sv.edicts + ((e) / (progs->entityfields * 4))) +int EDICT_TO_PROG(edict_t *e) +{ + int n; + n = e - sv.edicts; + if ((unsigned int)n >= (unsigned int)sv.max_edicts) + Host_Error("EDICT_TO_PROG: invalid edict %8p (number %i compared to world at %8p)\n", e, n, sv.edicts); + return n;// EXPERIMENTAL + //return (qbyte *)e->v - (qbyte *)sv.edictsfields; } +edict_t *PROG_TO_EDICT(int n) +{ + if ((unsigned int)n >= (unsigned int)sv.max_edicts) + Host_Error("PROG_TO_EDICT: invalid edict number %i\n", n); + return sv.edicts + n; // EXPERIMENTAL + //return sv.edicts + ((n) / (progs->entityfields * 4)); +} +*/