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...
so we need to call this ourselves */
me.OnRemoveEntity();
if (me.OnRemoveEntity)
me.OnRemoveEntity();
/* frees one slot the engine won't free for us */
if (me.skeletonindex)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -92,7 +92,7 @@ class prop_vehicle_driveable:NSVehicle
prop_vehicle_driveable_wheel m_wlBR;
vector m_vecControlMins;
vector m_vecControlMaxs;
PREDICTED_FLOAT(m_flTurn);
PREDICTED_FLOAT(m_flTurn)
float m_flBRWheelAxel;
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);
}
/* 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 */
if (eTarget.GetHealth() <= 0) {
if (eTarget.flags & FL_CLIENT) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,6 +26,7 @@ enum
EV_WEAPON_RELOAD,
EV_WEAPON_PICKUP,
EV_DAMAGE,
EV_HITNOTIFY,
EV_ANGLE,
EV_IMPACT,
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.
That way you can dual (or even triple) wield them.
*/
class
NSXRInput
{
private:
class NSXRInput {
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 );
private:
/** Reference to the space we belong to */
NSXRSpace m_xrSpace;
vector m_vecOrigin;
vector m_vecAngles;
vector m_vecVelocity;
vector m_vecVelocity;
vector m_vecAVelocity;
unsigned int m_iStatus;
unsigned int m_iWeapon;
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.
*/
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
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()));
}
void
NSXRInput::NSXRInput(void)
{
}

View File

@ -18,32 +18,34 @@
It's used to handle room to world translation for VR, for example.
*/
class
NSXRSpace
{
class 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:
vector m_vecForward;
vector m_vecRight;
vector m_vecUp;
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.
*/
void
NSXRSpace::NSXRSpace(void)
{
m_vecForward =
m_vecRight =
m_vecUp =
m_vecOrigin = [0.0f, 0.0f, 0.0f];
}
vector
NSXRSpace::GetForward(void)
{
@ -64,9 +73,4 @@ NSXRSpace::SetAngles(vector vecAngles)
m_vecForward = v_forward;
m_vecRight = v_right;
m_vecUp = v_up;
}
void
NSXRSpace::NSXRSpace(void)
{
}
}