[Tutorial]
Step 1.
Open up progs.h and add this under the edict_t/s struct.
Code: Select all
extern int eval_drawonlytoclient; //DP_SV_DRAWONLYTOCLIENT
extern int eval_nodrawtoclient; //DP_SV_NODRAWTOCLIENT
#define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t*)((char*)&ed->v + fieldoffset) : NULL) //DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT
Open up pr_edict.c, after ED_FindFeild add this:
Code: Select all
int eval_nodrawtoclient; //DP_SV_NODRAWTOCLIENT
int eval_drawonlytoclient; //DP_SV_DRAWONLYTOCLIENT
//DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT Start
int FindFieldOffset(char *field)
{
ddef_t *d;
d = ED_FindField(field);
if (!d)
return 0;
return d->ofs*4;
}
void FindEdictFieldOffsets()
{
eval_nodrawtoclient = FindFieldOffset("nodrawtoclient");
eval_drawonlytoclient = FindFieldOffset("drawonlytoclient");
};
//DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT End
Open up quakedef.h and at the end of the entity_state_t struct add this:
Code: Select all
unsigned short nodrawtoclient; //DP_SV_NODRAWTOCLIENT
unsigned short drawonlytoclient; //DP_SV_DRAWONLYTOCLIENT
Open up sv_main.c, add this at the end of the starting declarations in SV_WriteEntitiesToClient.
Code: Select all
int clentnum; //DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT
eval_t *val; //DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT
In SV_WriteEntitiesToClient after this:
Code: Select all
// find the client's PVS
VectorAdd (clent->v.origin, clent->v.view_ofs, org);
pvs = SV_FatPVS (org);
Code: Select all
clentnum = EDICT_TO_PROG(clent); // LordHavoc: for comparison purposes //DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT
In the same function after:
Code: Select all
// ignore ents without visible models
if (!ent->v.modelindex || !pr_strings[ent->v.model])
continue;
Code: Select all
//DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT Start
if ((val = GETEDICTFIELDVALUE(ent, eval_drawonlytoclient)) && val->edict && val->edict != clentnum)
continue;
if ((val = GETEDICTFIELDVALUE(ent, eval_nodrawtoclient)) && val->edict == clentnum)
continue;
//DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT End
**NOTICE**
This tutorial doesn't cover DPCHECKEXTENSIONS, I needed just these to DP_Extensions in my engine and didn't require the ability to check them, considering my engine is just for my own education ,experimentation and creation. It should be pretty straightforward on implementing it.
EDIT August 12th, 2010
I fixed some typos and formatting errors.
EDIT: September 20th, 2013
*Removed shameful self plugs