Misc consistency cleanups

This commit is contained in:
Marco Cawthorne 2022-11-22 22:37:07 -08:00
parent 2265047bfe
commit 29a1bea943
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
22 changed files with 198 additions and 160 deletions

View File

@ -578,7 +578,8 @@ CSQC_Ent_Remove(void)
/* we don't want to call Destroy, as that's delayed by a frame... /* we don't want to call Destroy, as that's delayed by a frame...
so we need to call this ourselves */ so we need to call this ourselves */
me.OnRemoveEntity(); if (me.OnRemoveEntity)
me.OnRemoveEntity();
/* frees one slot the engine won't free for us */ /* frees one slot the engine won't free for us */
if (me.skeletonindex) if (me.skeletonindex)

View File

@ -31,6 +31,8 @@ Event_Parse(float type)
iDmgFlags = readint(); iDmgFlags = readint();
CSQC_Parse_Damage_New(vecDmgPos, iDmgTake, iDmgFlags); CSQC_Parse_Damage_New(vecDmgPos, iDmgTake, iDmgFlags);
break; break;
case EV_HITNOTIFY:
break;
case EV_INTERMISSION: case EV_INTERMISSION:
int cam; int cam;
vector pos, ang; vector pos, ang;

View File

@ -63,11 +63,11 @@ enumflags
class ambient_generic:NSTalkMonster class ambient_generic:NSTalkMonster
{ {
/* networked attributes */ /* networked attributes */
PREDICTED_STRING(m_strActivePath); PREDICTED_STRING(m_strActivePath)
PREDICTED_FLOAT(m_flVolume); PREDICTED_FLOAT(m_flVolume)
PREDICTED_FLOAT(m_flRadius); PREDICTED_FLOAT(m_flRadius)
PREDICTED_FLOAT(m_flPitch); PREDICTED_FLOAT(m_flPitch)
PREDICTED_BOOL(m_bLoops); PREDICTED_BOOL(m_bLoops)
bool m_bToggle; bool m_bToggle;
/* spawn values */ /* spawn values */

View File

@ -58,10 +58,10 @@ enumflags
class class
env_bubbles:NSPointTrigger env_bubbles:NSPointTrigger
{ {
PREDICTED_INT(m_iDensity); PREDICTED_INT(m_iDensity)
PREDICTED_FLOAT(m_flFrequency); PREDICTED_FLOAT(m_flFrequency)
PREDICTED_FLOAT(m_flCurrent); PREDICTED_FLOAT(m_flCurrent)
PREDICTED_BOOL(m_bEnabled); PREDICTED_BOOL(m_bEnabled)
/* spawn values */ /* spawn values */
int m_iSpawnDensity; int m_iSpawnDensity;

View File

@ -67,15 +67,15 @@ class
env_fog_controller:NSPointTrigger env_fog_controller:NSPointTrigger
{ {
/* networked attributes */ /* networked attributes */
PREDICTED_INT(m_iFogActive); PREDICTED_INT(m_iFogActive)
PREDICTED_INT(m_iFogBlend); PREDICTED_INT(m_iFogBlend)
PREDICTED_FLOAT(m_flFogStart); PREDICTED_FLOAT(m_flFogStart)
PREDICTED_FLOAT(m_flFogEnd); PREDICTED_FLOAT(m_flFogEnd)
PREDICTED_FLOAT(m_flFogMaxDensity); PREDICTED_FLOAT(m_flFogMaxDensity)
PREDICTED_FLOAT(m_flFogFarZ); PREDICTED_FLOAT(m_flFogFarZ)
PREDICTED_VECTOR(m_vecFogColor); PREDICTED_VECTOR(m_vecFogColor)
PREDICTED_VECTOR(m_vecFogColor2); PREDICTED_VECTOR(m_vecFogColor2)
PREDICTED_VECTOR(m_vecFogDir); PREDICTED_VECTOR(m_vecFogDir)
void(void) env_fog_controller; void(void) env_fog_controller;

View File

@ -65,8 +65,8 @@ class env_sprite:NSRenderableEntity
int m_iToggled; int m_iToggled;
float m_flEffects; float m_flEffects;
PREDICTED_STRING(m_strMaterial); PREDICTED_STRING(m_strMaterial)
PREDICTED_FLOAT(m_flFramerate); PREDICTED_FLOAT(m_flFramerate)
#ifdef CLIENT #ifdef CLIENT
int m_iMaxFrame; int m_iMaxFrame;

View File

@ -125,7 +125,7 @@ func_vehicle:NSVehicle
float m_flWidth; float m_flWidth;
float m_flLength; float m_flLength;
PREDICTED_FLOAT(m_flTurn); PREDICTED_FLOAT(m_flTurn)
void(void) func_vehicle; void(void) func_vehicle;
virtual void(void) Spawned; virtual void(void) Spawned;

View File

@ -54,10 +54,10 @@ var int autocvar_rope_maxsegments = -1;
class prop_rope:NSEntity class prop_rope:NSEntity
{ {
string m_strShader; string m_strShader;
PREDICTED_FLOAT(m_flSag); PREDICTED_FLOAT(m_flSag)
PREDICTED_FLOAT(m_flSwingFactor); PREDICTED_FLOAT(m_flSwingFactor)
PREDICTED_INT(m_iSegments); PREDICTED_INT(m_iSegments)
PREDICTED_VECTOR(m_vecTarget); PREDICTED_VECTOR(m_vecTarget)
void(void) prop_rope; void(void) prop_rope;

View File

@ -92,7 +92,7 @@ class prop_vehicle_driveable:NSVehicle
prop_vehicle_driveable_wheel m_wlBR; prop_vehicle_driveable_wheel m_wlBR;
vector m_vecControlMins; vector m_vecControlMins;
vector m_vecControlMaxs; vector m_vecControlMaxs;
PREDICTED_FLOAT(m_flTurn); PREDICTED_FLOAT(m_flTurn)
float m_flBRWheelAxel; float m_flBRWheelAxel;
float m_flBLWheelAxel; float m_flBLWheelAxel;

View File

@ -342,6 +342,17 @@ NSGameRules::DamageApply(entity t, entity c, float dmg, int w, damageType_t type
multicast([0,0,0], MULTICAST_ONE_R); multicast([0,0,0], MULTICAST_ONE_R);
} }
/* only hit notify on clients */
if ((g_dmg_eTarget.flags & FL_CLIENT) || (g_dmg_eTarget.flags & FL_MONSTER)) {
/* server-side hitnotify */
if ((g_dmg_eAttacker.flags & FL_CLIENT) && (g_dmg_eTarget != g_dmg_eAttacker)) {
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EV_HITNOTIFY);
msg_entity = c;
multicast([0,0,0], MULTICAST_ONE);
}
}
/* they died */ /* they died */
if (eTarget.GetHealth() <= 0) { if (eTarget.GetHealth() <= 0) {
if (eTarget.flags & FL_CLIENT) { if (eTarget.flags & FL_CLIENT) {

View File

@ -23,32 +23,32 @@ class
NSClientPlayer:NSClientSpectator NSClientPlayer:NSClientSpectator
{ {
#ifdef SERVER #ifdef SERVER
PREDICTED_INT_N(weaponframe); PREDICTED_INT_N(weaponframe)
#else #else
PREDICTED_INT(weaponframe); PREDICTED_INT(weaponframe)
PREDICTED_FLOAT(vehicle_entnum); PREDICTED_FLOAT(vehicle_entnum)
#endif #endif
PREDICTED_FLOAT(health); PREDICTED_FLOAT(health)
PREDICTED_FLOAT(armor); PREDICTED_FLOAT(armor)
PREDICTED_FLOAT_N(colormap); PREDICTED_FLOAT_N(colormap)
PREDICTED_FLOAT_N(gflags); PREDICTED_FLOAT_N(gflags)
PREDICTED_FLOAT(viewzoom); PREDICTED_FLOAT(viewzoom)
PREDICTED_VECTOR_N(view_ofs); PREDICTED_VECTOR_N(view_ofs)
PREDICTED_VECTOR(v_angle); PREDICTED_VECTOR(v_angle)
PREDICTED_FLOAT_N(pmove_flags); PREDICTED_FLOAT_N(pmove_flags)
PREDICTED_FLOAT(w_attack_next); PREDICTED_FLOAT(w_attack_next)
PREDICTED_FLOAT(w_idle_next); PREDICTED_FLOAT(w_idle_next)
PREDICTED_FLOAT(teleport_time); PREDICTED_FLOAT(teleport_time)
PREDICTED_FLOAT(weapontime); PREDICTED_FLOAT(weapontime)
PREDICTED_VECTOR(punchangle); PREDICTED_VECTOR(punchangle)
/* We can't use the default .items field, because FTE will assume /* We can't use the default .items field, because FTE will assume
* effects of some bits. Such as invisibility, quad, etc. * effects of some bits. Such as invisibility, quad, etc.
* also, modders probably want 32 bits for items. */ * also, modders probably want 32 bits for items. */
PREDICTED_INT(g_items); PREDICTED_INT(g_items)
PREDICTED_FLOAT(activeweapon); PREDICTED_FLOAT(activeweapon)
#ifdef NEW_INVENTORY #ifdef NEW_INVENTORY
NSWeapon m_weapons[MAX_WEAPONS]; NSWeapon m_weapons[MAX_WEAPONS];
@ -56,7 +56,7 @@ NSClientPlayer:NSClientSpectator
#endif #endif
/* vehicle info */ /* vehicle info */
PREDICTED_ENT(vehicle); PREDICTED_ENT(vehicle)
/* these are NOT networked */ /* these are NOT networked */
int a_ammo1; int a_ammo1;

View File

@ -49,8 +49,8 @@ of type NSClientSpectator.
class NSClientSpectator:NSClient class NSClientSpectator:NSClient
{ {
private: private:
PREDICTED_FLOAT(spec_ent); PREDICTED_FLOAT(spec_ent)
PREDICTED_FLOAT(spec_flags); PREDICTED_FLOAT(spec_flags)
NSClientSpectatorMode_t spec_mode; NSClientSpectatorMode_t spec_mode_net; NSClientSpectatorMode_t spec_mode; NSClientSpectatorMode_t spec_mode_net;
vector spec_org; vector spec_org;

View File

@ -60,25 +60,25 @@ private:
string m_oldModel; /**< contains the model that the entity spawned with */ string m_oldModel; /**< contains the model that the entity spawned with */
float m_oldSolid; /**< contains the collision type the entity spawned with */ float m_oldSolid; /**< contains the collision type the entity spawned with */
PREDICTED_VECTOR_N(origin); PREDICTED_VECTOR_N(origin)
PREDICTED_VECTOR_N(angles); PREDICTED_VECTOR_N(angles)
PREDICTED_FLOAT_N(modelindex); PREDICTED_FLOAT_N(modelindex)
PREDICTED_VECTOR_N(size); PREDICTED_VECTOR_N(size)
PREDICTED_VECTOR_N(mins); PREDICTED_VECTOR_N(mins)
PREDICTED_VECTOR_N(maxs); PREDICTED_VECTOR_N(maxs)
PREDICTED_FLOAT_N(solid); PREDICTED_FLOAT_N(solid)
PREDICTED_FLOAT_N(movetype); PREDICTED_FLOAT_N(movetype)
PREDICTED_FLOAT_N(scale); PREDICTED_FLOAT_N(scale)
PREDICTED_FLOAT_N(flags); PREDICTED_FLOAT_N(flags)
PREDICTED_VECTOR_N(velocity); PREDICTED_VECTOR_N(velocity)
PREDICTED_VECTOR_N(avelocity); PREDICTED_VECTOR_N(avelocity)
#ifdef SERVER #ifdef SERVER
string m_parent; string m_parent;
string m_parent_attachment; string m_parent_attachment;
PREDICTED_FLOAT_N(frame); PREDICTED_FLOAT_N(frame)
PREDICTED_FLOAT_N(skin); PREDICTED_FLOAT_N(skin)
PREDICTED_FLOAT_N(effects); PREDICTED_FLOAT_N(effects)
#endif #endif
public: public:

View File

@ -67,7 +67,7 @@ private:
virtual void _TouchThink(void); virtual void _TouchThink(void);
#ifdef SERVER #ifdef SERVER
PREDICTED_VECTOR(m_vecNetAngles); PREDICTED_VECTOR(m_vecNetAngles)
#endif #endif
public: public:

View File

@ -93,19 +93,19 @@ class NSRenderableEntity:NSEntity
{ {
private: private:
/* new */ /* new */
PREDICTED_FLOAT(m_flBoneControl1); PREDICTED_FLOAT(m_flBoneControl1)
PREDICTED_FLOAT(m_flBoneControl2); PREDICTED_FLOAT(m_flBoneControl2)
PREDICTED_FLOAT(m_flBoneControl3); PREDICTED_FLOAT(m_flBoneControl3)
PREDICTED_FLOAT(m_flBoneControl4); PREDICTED_FLOAT(m_flBoneControl4)
PREDICTED_FLOAT(m_flBoneControl5); PREDICTED_FLOAT(m_flBoneControl5)
PREDICTED_INT(m_iBody); PREDICTED_INT(m_iBody)
PREDICTED_FLOAT_N(colormap); PREDICTED_FLOAT_N(colormap)
PREDICTED_VECTOR_N(glowmod); PREDICTED_VECTOR_N(glowmod)
PREDICTED_FLOAT(m_iRenderFX); PREDICTED_FLOAT(m_iRenderFX)
PREDICTED_FLOAT(m_iRenderMode); PREDICTED_FLOAT(m_iRenderMode)
PREDICTED_FLOAT(m_flRenderAmt); PREDICTED_FLOAT(m_flRenderAmt)
PREDICTED_VECTOR(m_vecRenderColor); PREDICTED_VECTOR(m_vecRenderColor)
/* model events */ /* model events */
float m_flBaseTime; float m_flBaseTime;

View File

@ -28,12 +28,12 @@ private:
vector m_vecExitPos; vector m_vecExitPos;
/* FIXME: Aren't those already defined in parent classes? */ /* FIXME: Aren't those already defined in parent classes? */
PREDICTED_VECTOR_N(angles); PREDICTED_VECTOR_N(angles)
PREDICTED_VECTOR_N(origin); PREDICTED_VECTOR_N(origin)
PREDICTED_VECTOR_N(velocity); PREDICTED_VECTOR_N(velocity)
#ifdef CLIENT #ifdef CLIENT
PREDICTED_FLOAT(driver_entnum); PREDICTED_FLOAT(driver_entnum)
#endif #endif
public: public:

View File

@ -15,21 +15,21 @@
*/ */
/* networking helpers */ /* networking helpers */
#define PREDICTED_INT(x) int x; int x ##_net #define PREDICTED_INT(x) int x; int x ##_net;
#define PREDICTED_FLOAT(x) float x; float x ##_net #define PREDICTED_FLOAT(x) float x; float x ##_net;
#define PREDICTED_VECTOR(x) vector x; vector x ##_net #define PREDICTED_VECTOR(x) vector x; vector x ##_net;
#define PREDICTED_ENT(x) entity x; entity x ##_net #define PREDICTED_ENT(x) entity x; entity x ##_net;
#define PREDICTED_STRING(x) string x; string x ##_net #define PREDICTED_STRING(x) string x; string x ##_net;
#define PREDICTED_BOOL(x) bool x; bool x ##_net #define PREDICTED_BOOL(x) bool x; bool x ##_net;
#define PREDICTED_INT_N(x) int x ##_net #define PREDICTED_INT_N(x) int x ##_net;
#define PREDICTED_FLOAT_N(x) float x ##_net #define PREDICTED_FLOAT_N(x) float x ##_net;
#define PREDICTED_VECTOR_N(x) vector x ##_net #define PREDICTED_VECTOR_N(x) vector x ##_net;
#define PREDICTED_STRING_N(x) string x ##_net #define PREDICTED_STRING_N(x) string x ##_net;
#define ROLL_BACK(x) x = x ##_net #define ROLL_BACK(x) x = x ##_net;
#define SAVE_STATE(x) x ##_net = x #define SAVE_STATE(x) x ##_net = x;
#define SAVE_STATE_FIELD(x, y) x ##_net[y] = x[y] #define SAVE_STATE_FIELD(x, y) x ##_net[y] = x[y];
#define ATTR_CHANGED(x) (x ##_net != x) #define ATTR_CHANGED(x) (x ##_net != x)
#define VEC_CHANGED(x,y) (x ##_net[y] != x[y]) #define VEC_CHANGED(x,y) (x ##_net[y] != x[y])

View File

@ -26,6 +26,7 @@ enum
EV_WEAPON_RELOAD, EV_WEAPON_RELOAD,
EV_WEAPON_PICKUP, EV_WEAPON_PICKUP,
EV_DAMAGE, EV_DAMAGE,
EV_HITNOTIFY,
EV_ANGLE, EV_ANGLE,
EV_IMPACT, EV_IMPACT,
EV_GIBHUMAN, EV_GIBHUMAN,

View File

@ -47,46 +47,55 @@ these inputs as well.
Each input has the ability to have a NSWeapon reference tied to it. Each input has the ability to have a NSWeapon reference tied to it.
That way you can dual (or even triple) wield them. That way you can dual (or even triple) wield them.
*/ */
class class NSXRInput {
NSXRInput public:
{ void NSXRInput( void );
private:
/** Sets the NSXRInput type. */
virtual void SetType( xrinput_t );
/** Sets which NSXRSpace this input belongs to. */
virtual void SetParentSpace( NSXRSpace );
/** Returns the world space position of this NSXRInput. */
virtual vector GetOrigin( void );
/** Returns the direction this NSXRInput is facing. */
virtual vector GetAngles( void );
/** Returns the current velocity of this NSXRInput. */
virtual vector GetVelocity( void );
/** Returns the rotational movement of this NSXRInput. */
virtual vector GetAngularVelocity( void );
/** Returns the status of the NSXRInput. */
virtual unsigned int GetStatus( void );
/** Returns the weapon this NSXRInput is wielding. */
virtual unsigned int GetWeapon( void );
/** Returns the type of NSXRInput, check xrinput_t for details. */
virtual xrinput_t GetType( void );
/** Returns if this NSXRInput is available/active. */
virtual bool IsAvailable( void );
/** Run every single input event. */
virtual void InputFrame( void );
/** Debug function that can be called every single frame. */
virtual void PrintInfo( void );
private:
/** Reference to the space we belong to */ /** Reference to the space we belong to */
NSXRSpace m_xrSpace; NSXRSpace m_xrSpace;
vector m_vecOrigin; vector m_vecOrigin;
vector m_vecAngles; vector m_vecAngles;
vector m_vecVelocity; vector m_vecVelocity;
vector m_vecAVelocity; vector m_vecAVelocity;
unsigned int m_iStatus; unsigned int m_iStatus;
unsigned int m_iWeapon; unsigned int m_iWeapon;
xrinput_t m_inputType; xrinput_t m_inputType;
public:
void NSXRInput(void);
/** Sets the NSXRInput type. */
virtual void SetType(xrinput_t);
/** Sets which NSXRSpace this input belongs to. */
virtual void SetParentSpace(NSXRSpace);
/** Returns the world space position of this NSXRInput. */
virtual vector GetOrigin(void);
/** Returns the direction this NSXRInput is facing. */
virtual vector GetAngles(void);
/** Returns the current velocity of this NSXRInput. */
virtual vector GetVelocity(void);
/** Returns the rotational movement of this NSXRInput. */
virtual vector GetAngularVelocity(void);
/** Returns the status of the NSXRInput. */
virtual unsigned int GetStatus(void);
/** Returns the weapon this NSXRInput is wielding. */
virtual unsigned int GetWeapon(void);
/** Returns the type of NSXRInput, check xrinput_t for details. */
virtual xrinput_t GetType(void);
/** Returns if this NSXRInput is available/active. */
virtual bool IsAvailable(void);
/** Run every single input event. */
virtual void InputFrame(void);
/** Debug function that can be called every single frame. */
virtual void PrintInfo(void);
}; };

View File

@ -14,6 +14,19 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
void
NSXRInput::NSXRInput(void)
{
m_xrSpace = __NULL__;
m_vecOrigin = [0.0f, 0.0f, 0.0f];
m_vecAngles = [0.0f, 0.0f, 0.0f];
m_vecVelocity = [0.0f, 0.0f, 0.0f];
m_vecAVelocity = [0.0f, 0.0f, 0.0f];
m_iStatus = 0i;
m_iWeapon = 0i;
m_inputType = XR_INPUT_UNKNOWN;
}
vector vector
NSXRInput::GetOrigin(void) NSXRInput::GetOrigin(void)
{ {
@ -158,8 +171,3 @@ NSXRInput::PrintInfo(void)
crossprint(sprintf("%s o: %v a: %v v:%v va:%v s:%i w:%i\n", deviceType, GetOrigin(), GetAngles(), GetVelocity(), GetAngularVelocity(), GetStatus(), GetWeapon())); crossprint(sprintf("%s o: %v a: %v v:%v va:%v s:%i w:%i\n", deviceType, GetOrigin(), GetAngles(), GetVelocity(), GetAngularVelocity(), GetStatus(), GetWeapon()));
} }
void
NSXRInput::NSXRInput(void)
{
}

View File

@ -18,32 +18,34 @@
It's used to handle room to world translation for VR, for example. It's used to handle room to world translation for VR, for example.
*/ */
class class NSXRSpace {
NSXRSpace public:
{ void NSXRSpace( void );
/** Sets the placement of the space in the 3D world. */
virtual void SetOrigin( vector );
/** Sets the direction offset of the space in the 3D world. */
virtual void SetAngles( vector );
/** Get the forward facing direction in a normalized vector. */
virtual vector GetForward( void );
/** Get the right facing direction in a normalized vector. */
virtual vector GetRight( void );
/** Get the up facing direction in a normalized vector. */
virtual vector GetUp( void );
/** Takes a room-space position and translates it into world position. */
virtual vector RoomToWorldOrigin( vector );
/** Takes a room-space angle and translates it into world angles. */
virtual vector RoomToWorldAngles( vector );
private: private:
vector m_vecForward; vector m_vecForward;
vector m_vecRight; vector m_vecRight;
vector m_vecUp; vector m_vecUp;
vector m_vecOrigin; vector m_vecOrigin;
public:
void NSXRSpace(void);
/** Sets the placement of the space in the 3D world. */
virtual void SetOrigin(vector);
/** Sets the direction offset of the space in the 3D world. */
virtual void SetAngles(vector);
/** Get the forward facing direction in a normalized vector. */
virtual vector GetForward(void);
/** Get the right facing direction in a normalized vector. */
virtual vector GetRight(void);
/** Get the up facing direction in a normalized vector. */
virtual vector GetUp(void);
/** Takes a room-space position and translates it into world position. */
virtual vector RoomToWorldOrigin(vector);
/** Takes a room-space angle and translates it into world angles. */
virtual vector RoomToWorldAngles(vector);
}; };

View File

@ -14,6 +14,15 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
void
NSXRSpace::NSXRSpace(void)
{
m_vecForward =
m_vecRight =
m_vecUp =
m_vecOrigin = [0.0f, 0.0f, 0.0f];
}
vector vector
NSXRSpace::GetForward(void) NSXRSpace::GetForward(void)
{ {
@ -64,9 +73,4 @@ NSXRSpace::SetAngles(vector vecAngles)
m_vecForward = v_forward; m_vecForward = v_forward;
m_vecRight = v_right; m_vecRight = v_right;
m_vecUp = v_up; m_vecUp = v_up;
} }
void
NSXRSpace::NSXRSpace(void)
{
}