[Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
Moderator: InsideQC Admins
14 posts
• Page 1 of 1
[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.
Step 2.
Open up pr_edict.c, after ED_FindFeild add this:
Step 3.
Open up quakedef.h and at the end of the entity_state_t struct add this:
Step 4.
Open up sv_main.c, add this at the end of the starting declarations in SV_WriteEntitiesToClient.
Step 5.
In SV_WriteEntitiesToClient after this:
Add this:
Step 6.
In the same function after:
Add this:
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.
EDIT: September 20th, 2013
*Removed shameful self plugs
[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
Step 2.
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
Step 3.
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
Step 4.
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
Step 5.
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);
Add this:
- Code: Select all
clentnum = EDICT_TO_PROG(clent); // LordHavoc: for comparison purposes //DP_SV_DRAWONLYTOCLIENT & DP_SV_NODRAWTOCLIENT
Step 6.
In the same function after:
- Code: Select all
// ignore ents without visible models
if (!ent->v.modelindex || !pr_strings[ent->v.model])
continue;
Add this:
- 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
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.
EDIT: September 20th, 2013
*Removed shameful self plugs
Last edited by Team Xlink on Sat Sep 21, 2013 1:19 am, edited 1 time in total.
- Team Xlink
- Posts: 368
- Joined: Thu Jun 25, 2009 4:45 am
- Location: Michigan
Yeah it worked!
The lack of other confirmation had me worried that I missed something in the tutorial, because I attempted to implement it in an engine that wasn't standard and it worked, so I tutorialized it from the engine I implemented it in.
The lack of other confirmation had me worried that I missed something in the tutorial, because I attempted to implement it in an engine that wasn't standard and it worked, so I tutorialized it from the engine I implemented it in.
- Team Xlink
- Posts: 368
- Joined: Thu Jun 25, 2009 4:45 am
- Location: Michigan
Re: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
Sorry for bumping this but it seems not to work with Kurok engine...
I added everything and it compiled fine but i can still see all the stuff -.-
In Darkplaces everything works fine but not with your stuff...
I added everything and it compiled fine but i can still see all the stuff -.-
In Darkplaces everything works fine but not with your stuff...
-

drm_wayne - Posts: 232
- Joined: Sat Feb 11, 2012 5:47 pm
Re: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
its the last part that contains the 'magic'.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Re: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
Wrong, i even tested a Kurokbuild where HE added that stuff and Drawonlytoclient DOESNT work...
-

drm_wayne - Posts: 232
- Joined: Sat Feb 11, 2012 5:47 pm
Re: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
Not wrong at all. step 6 IS the part that contains the logic that is the whole point of the two extensions.
If you actually stop to figure out what's actually happening, you might manage to see what's not happening.
Yes, it lacks a single instruction, literally. Yay for branches.
Without that instruction, its all dead code.
Have fun trying to find it.
If you actually stop to figure out what's actually happening, you might manage to see what's not happening.
Yes, it lacks a single instruction, literally. Yay for branches.
Without that instruction, its all dead code.
Have fun trying to find it.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Re: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
i dont get it...
everybody wrote above YAY IT WORKED but its not working...
But well, i dont expect getting help here, PSP Quakers are not really welcome here...
everybody wrote above YAY IT WORKED but its not working...
But well, i dont expect getting help here, PSP Quakers are not really welcome here...
-

drm_wayne - Posts: 232
- Joined: Sat Feb 11, 2012 5:47 pm
Re: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
To get this to work add this in pr_edict.c at the end of the
PR_LoadProgs function:
PR_LoadProgs function:
- Code: Select all
FindEdictFieldOffsets (); // The stuff Team Xlink forget to add... Shame on you xD
-

drm_wayne - Posts: 232
- Joined: Sat Feb 11, 2012 5:47 pm
Re: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
I didn't run into that, never knew why until now. This tutorial must be for a non-vanilla GetEdictFieldValue? Vanilla passes string, like GetEdictFieldValue(ent, "drawonlytoclient")) and the workaround isn't needed. Vanilla:
- Code: Select all
eval_t *GetEdictFieldValue(edict_t *ed, char *field)
{
ddef_t *def = NULL;
int i;
static int rep = 0;
for (i=0 ; i<GEFV_CACHESIZE ; i++)
{
if (!Q_strcmp(field, gefvCache[i].field))
{
def = gefvCache[i].pcache;
goto Done;
}
}
def = ED_FindField (field);
if (Q_strlen(field) < MAX_FIELD_LEN)
{
gefvCache[rep].pcache = def;
Q_strcpy (gefvCache[rep].field, field);
rep ^= 1;
}
Done:
if (!def)
return NULL;
return (eval_t *)((char *)&ed->v + def->ofs*4);
}
-
qbism - Posts: 1236
- Joined: Thu Nov 04, 2004 5:51 am
Re: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
Its for the PSP Kurok engine (and all other similar ones)...
I mainly needed it for 3rd person weapons and 1st person legs:

I mainly needed it for 3rd person weapons and 1st person legs:

-

drm_wayne - Posts: 232
- Joined: Sat Feb 11, 2012 5:47 pm
Re: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
The legs are cool. Qfusion was the first time I saw that effect. It uses the lower body from md3 models.
-
qbism - Posts: 1236
- Joined: Thu Nov 04, 2004 5:51 am
Re: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
First time I saw first-person legs was Montezuma's Return!
Soon after we saw first-person breasts in Trespasser, rarely ever seen again, and they were vital for having a health meter TATOO
Soon after we saw first-person breasts in Trespasser, rarely ever seen again, and they were vital for having a health meter TATOO
i should not be here
- leileilol
- Posts: 2783
- Joined: Fri Oct 15, 2004 3:23 am
Re: [Tutorial PSP/PC] - DP_SV_NODRAWTOCLIENT & DP_SV_DRAWONL
i sucked at trespasser -.-
-

ceriux - Posts: 2223
- Joined: Sat Sep 06, 2008 3:30 pm
- Location: Indiana, USA
14 posts
• Page 1 of 1
Return to Programming Tutorials
Who is online
Users browsing this forum: No registered users and 1 guest