Team Xlink
Joined: 25 Jun 2009 Posts: 320
|
Posted: Mon Apr 26, 2010 11:23 pm Post subject: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL |
|
|
DP_SV_NODRAWTOCLIENT and DP_SV_DRAWONLYTOCLIENT are very useful, they have a wide array of possibilities, and implementing them is very easy.
[Tutorial]
Step 1.
Open up progs.h and add this under the edict_t/s struct.
Code: | extern int eval_drawonlytoclient; //Team Xlink DP_SV_DRAWONLYTOCLIENT
extern int eval_nodrawtoclient; //Team Xlink DP_SV_NODRAWTOCLIENT
#define GETEDICTFIELDVALUE(ed, fieldoffset) (fieldoffset ? (eval_t*)((char*)&ed->v + fieldoffset) : NULL) //Team XLink DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT |
Step 2.
Open up pr_edict.c, after ED_FindFeild add this:
Code: | int eval_nodrawtoclient; //Team Xlink DP_SV_NODRAWTOCLIENT
int eval_drawonlytoclient; //Team Xlink DP_SV_DRAWONLYTOCLIENT
//Team XLink 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");
};
//Team XLink DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT End |
Step 3.
Open up quakedef.h and at the end of the entity_state_t struct add this:
Code: | unsigned short nodrawtoclient; //Team Xlink DP_SV_NODRAWTOCLIENT
unsigned short drawonlytoclient; //Team Xlink DP_SV_DRAWONLYTOCLIENT |
Step 4.
Open up sv_main.c, add this at the end of the starting declarations in SV_WriteEntitiesToClient.
Code: | int clentnum; //Team XLink DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT
eval_t *val; //Team XLink DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT |
Step 5.
In SV_WriteEntitiesToClient after this:
Code: | // find the client's PVS
VectorAdd (clent->v.origin, clent->v.view_ofs, org);
pvs = SV_FatPVS (org); |
Add this:
Code: | clentnum = EDICT_TO_PROG(clent); // LordHavoc: for comparison purposes //Team XLink DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT
|
Step 6.
In the same function after:
Code: | // ignore ents without visible models
if (!ent->v.modelindex || !pr_strings[ent->v.model])
continue; |
Add this:
Code: | //Team XLink 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;
//Team XLink DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT End |
That should be all thats required.
**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. _________________
Anonymous wrote: | if it works, it works. if it doesn't, HAHAHA! |
|
|