mfunction_t *SV_PlayerPhysicsQC;
mfunction_t *EndFrameQC;
+//KrimZon - SERVER COMMANDS IN QUAKEC
+mfunction_t *SV_ParseClientCommandQC;
int FindFieldOffset(const char *field)
{
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");
}
/*
void ED_ClearEdict (edict_t *e)
{
memset (e->v, 0, progs->entityfields * 4);
- e->free = false;
+ e->e->free = false;
}
/*
angles and bad trails.
=================
*/
+extern void SV_IncreaseEdicts(void);
edict_t *ED_Alloc (void)
{
int i;
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;
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);
{
SV_UnlinkEdict (ed); // unlink from world bsp
- ed->free = true;
+ ed->e->free = true;
ed->v->model = 0;
ed->v->takedamage = 0;
ed->v->modelindex = 0;
ed->v->nextthink = -1;
ed->v->solid = 0;
- ed->freetime = sv.time;
+ ed->e->freetime = sv.time;
}
//===========================================================================
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
int type;
char tempstring[8192], tempstring2[260]; // temporary string buffers
- if (ed->free)
+ if (ed->e->free)
{
Con_Printf ("FREE\n");
return;
FS_Printf (f, "{\n");
- if (ed->free)
+ if (ed->e->free)
{
FS_Printf (f, "}\n");
return;
for (i=0 ; i<sv.num_edicts ; i++)
{
ent = EDICT_NUM(i);
- if (ent->free)
+ if (ent->e->free)
continue;
active++;
if (ent->v->solid)
}
if (!init)
- ent->free = true;
+ ent->e->free = true;
return data;
}
pr_global_struct->self = EDICT_TO_PROG(ent);
PR_ExecuteProgram (func - pr_functions, "");
spawned++;
- if (ent->free)
+ if (ent->e->free)
died++;
}
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++)
{
}
// 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_ERROR(edict_t *e)
+{
+ Host_Error ("NUM_FOR_EDICT: bad pointer %p (world is %p, entity number would be %i)", e, sv.edicts, e - sv.edicts);
+ return 0;
+}
+
int NUM_FOR_EDICT(edict_t *e)
{
int n;
return n;
}
-int NoCrash_NUM_FOR_EDICT(edict_t *e)
-{
- return e - sv.edicts;
-}
+//int NoCrash_NUM_FOR_EDICT(edict_t *e)
+//{
+// return e - sv.edicts;
+//}
//#define EDICT_TO_PROG(e) ((qbyte *)(((edict_t *)e)->v) - (qbyte *)(sv.edictsfields))
-//#define PROG_TO_EDICT(e) (sv.edictstable[(e) / (progs->entityfields * 4)])
+//#define PROG_TO_EDICT(e) (sv.edicts + ((e) / (progs->entityfields * 4)))
int EDICT_TO_PROG(edict_t *e)
{
int n;
{
if ((unsigned int)n >= (unsigned int)sv.max_edicts)
Host_Error("PROG_TO_EDICT: invalid edict number %i\n", n);
- return sv.edictstable[n]; // EXPERIMENTAL
- //return sv.edictstable[(n) / (progs->entityfields * 4)];
+ return sv.edicts + n; // EXPERIMENTAL
+ //return sv.edicts + ((n) / (progs->entityfields * 4));
}
+*/