// sv_phys.c
#include "quakedef.h"
-// used only for VM_GetTempString
-#include "prvm_cmds.h"
/*
if (trace.startsupercontents & SUPERCONTENTS_SOLID)
return true;
else
+ {
+ if (sv.worldmodel->brushq1.hulls && !VectorCompare(ent->fields.server->mins, ent->fields.server->maxs))
+ {
+ // q1bsp/hlbsp use hulls and if the entity does not exactly match
+ // a hull size it is incorrectly tested, so this code tries to
+ // 'fix' it slightly...
+ int i;
+ vec3_t v;
+ for (i = 0;i < 8;i++)
+ {
+ v[0] = (i & 1) ? ent->fields.server->maxs[0] : ent->fields.server->mins[0];
+ v[1] = (i & 2) ? ent->fields.server->maxs[1] : ent->fields.server->mins[1];
+ v[2] = (i & 4) ? ent->fields.server->maxs[2] : ent->fields.server->mins[2];
+ if (SV_PointSuperContents(v) & SUPERCONTENTS_SOLID)
+ return true;
+ }
+ }
return false;
+ }
}
/*
}
}
+// DRESK - Support for Entity Contents Transition Event
+/*
+================
+SV_CheckContentsTransition
+
+returns true if entity had a valid contentstransition function call
+================
+*/
+int SV_CheckContentsTransition(prvm_edict_t *ent, const int nContents)
+{
+ int bValidFunctionCall;
+ prvm_eval_t *contentstransition;
+
+ // Default Valid Function Call to False
+ bValidFunctionCall = false;
+
+ if(ent->fields.server->watertype != nContents)
+ { // Changed Contents
+ // Acquire Contents Transition Function from QC
+ contentstransition = PRVM_GETEDICTFIELDVALUE(ent, eval_contentstransition);
+
+ if(contentstransition->function)
+ { // Valid Function; Execute
+ // Assign Valid Function
+ bValidFunctionCall = true;
+ // Prepare Parameters (Original Contents, New Contents)
+ // Original Contents
+ PRVM_G_FLOAT(OFS_PARM0) = ent->fields.server->watertype;
+ // New Contents
+ PRVM_G_FLOAT(OFS_PARM1) = nContents;
+ // Execute VM Function
+ PRVM_ExecuteProgram(contentstransition->function, "contentstransition: NULL function");
+ }
+ }
+
+ // Return if Function Call was Valid
+ return bValidFunctionCall;
+}
+
+
/*
================
SV_CheckVelocity
if ((val = PRVM_GETGLOBALFIELDVALUE(gval_trace_dphittexturename)))
{
if (trace->hittexture)
- {
- char *s = VM_GetTempString();
- strlcpy(s, trace->hittexture->name, VM_STRINGTEMP_LENGTH);
- val->string = PRVM_SetEngineString(s);
- }
+ val->string = PRVM_SetTempString(trace->hittexture->name);
else
val->string = 0;
}
Does not change the entities velocity at all
============
*/
-trace_t SV_PushEntity (prvm_edict_t *ent, vec3_t push, qboolean failonstartsolid)
+static trace_t SV_PushEntity (prvm_edict_t *ent, vec3_t push, qboolean failonbmodelstartsolid)
{
int type;
trace_t trace;
type = MOVE_NORMAL;
trace = SV_Move (ent->fields.server->origin, ent->fields.server->mins, ent->fields.server->maxs, end, type, ent);
- if (trace.startsolid && failonstartsolid)
+ if (trace.bmodelstartsolid && failonbmodelstartsolid)
return trace;
VectorCopy (trace.endpos, ent->fields.server->origin);
SV_LinkEdict (ent, true);
- if (trace.ent && (!((int)ent->fields.server->flags & FL_ONGROUND) || ent->fields.server->groundentity != PRVM_EDICT_TO_PROG(trace.ent)))
+ if (ent->fields.server->solid >= SOLID_TRIGGER && trace.ent && (!((int)ent->fields.server->flags & FL_ONGROUND) || ent->fields.server->groundentity != PRVM_EDICT_TO_PROG(trace.ent)))
SV_Impact (ent, &trace);
return trace;
}
}
VectorCopy (org, ent->fields.server->origin);
- Con_DPrintf("Stuck entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname));
+ if (developer.integer >= 100)
+ Con_Printf("Stuck entity %i (classname \"%s\").\n", (int)PRVM_EDICT_TO_PROG(ent), PRVM_GetString(ent->fields.server->classname));
}
qboolean SV_CheckWater (prvm_edict_t *ent)
{
int cont;
+ int nNativeContents;
vec3_t point;
point[0] = ent->fields.server->origin[0];
point[1] = ent->fields.server->origin[1];
point[2] = ent->fields.server->origin[2] + ent->fields.server->mins[2] + 1;
+ // DRESK - Support for Entity Contents Transition Event
+ // NOTE: Some logic needed to be slightly re-ordered
+ // to not affect performance and allow for the feature.
+
+ // Acquire Super Contents Prior to Resets
+ cont = SV_PointSuperContents(point);
+ // Acquire Native Contents Here
+ nNativeContents = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, cont);
+
+ // DRESK - Support for Entity Contents Transition Event
+ if(ent->fields.server->watertype)
+ // Entity did NOT Spawn; Check
+ SV_CheckContentsTransition(ent, nNativeContents);
+
+
ent->fields.server->waterlevel = 0;
ent->fields.server->watertype = CONTENTS_EMPTY;
cont = SV_PointSuperContents(point);
if (cont & (SUPERCONTENTS_LIQUIDSMASK))
{
- ent->fields.server->watertype = Mod_Q1BSP_NativeContentsFromSuperContents(NULL, cont);
+ ent->fields.server->watertype = nNativeContents;
ent->fields.server->waterlevel = 1;
point[2] = ent->fields.server->origin[2] + (ent->fields.server->mins[2] + ent->fields.server->maxs[2])*0.5;
if (SV_PointSuperContents(point) & (SUPERCONTENTS_LIQUIDSMASK))
return;
}
- // check if the entity crossed into or out of water
- if (sv_sound_watersplash.string && ((ent->fields.server->watertype == CONTENTS_WATER || ent->fields.server->watertype == CONTENTS_SLIME) != (cont == CONTENTS_WATER || cont == CONTENTS_SLIME)))
- SV_StartSound (ent, 0, sv_sound_watersplash.string, 255, 1);
+ // DRESK - Support for Entity Contents Transition Event
+ // NOTE: Call here BEFORE updating the watertype below,
+ // and suppress watersplash sound if a valid function
+ // call was made to allow for custom "splash" sounds.
+ if( !SV_CheckContentsTransition(ent, cont) )
+ { // Contents Transition Function Invalid; Potentially Play Water Sound
+ // check if the entity crossed into or out of water
+ if (sv_sound_watersplash.string && ((ent->fields.server->watertype == CONTENTS_WATER || ent->fields.server->watertype == CONTENTS_SLIME) != (cont == CONTENTS_WATER || cont == CONTENTS_SLIME)))
+ SV_StartSound (ent, 0, sv_sound_watersplash.string, 255, 1);
+ }
if (cont <= CONTENTS_WATER)
{