Shared: Go over the various base classes and bring Save/Restore methods up to date.

This commit is contained in:
Marco Cawthorne 2023-07-07 23:34:58 -07:00
parent bc67e0ab47
commit 9e6a203a02
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
19 changed files with 759 additions and 71 deletions

Binary file not shown.

View File

@ -133,11 +133,12 @@ EV_Shake(void)
void
EV_TraceDebug(void)
{
static void EV_TraceDebug_Draw(void) {
static float EV_TraceDebug_Draw(void) {
R_BeginPolygon("", 0, 0);
R_PolygonVertex(self.origin, [0,1], [0,1,0], 1.0f);
R_PolygonVertex(self.angles, [1,1], [1,0,0], 1.0f);
R_EndPolygon();
return PREDRAW_NEXT;
}
static void EV_TraceDebug_Destroy(void) {
remove(self);

View File

@ -27,12 +27,32 @@ void
NSClient::Save(float handle)
{
super::Save(handle);
/*SaveEntity(handle, "m_xrSpace", m_xrSpace);
SaveEntity(handle, "m_xrInputHead", m_xrInputHead);
SaveEntity(handle, "m_xrInputLeft", m_xrInputLeft);
SaveEntity(handle, "m_xrInputRight", m_xrInputRight);*/
SaveFloat(handle, "score", score);
}
void
NSClient::Restore(string strKey, string strValue)
{
switch (strKey) {
/*case "m_xrSpace":
m_xrSpace = (NSXRSpace)ReadEntity(strValue);
break;
case "m_xrInputHead":
m_xrInputHead = (NSXRInput)ReadEntity(strValue);
break;
case "m_xrInputLeft":
m_xrInputLeft = (NSXRInput)ReadEntity(strValue);
break;
case "m_xrInputRight":
m_xrInputRight = (NSXRInput)ReadEntity(strValue);
break;*/
case "score":
score = ReadFloat(strValue);
break;
default:
super::Restore(strKey, strValue);
}

View File

@ -384,6 +384,7 @@ NSIO::Save(float handle)
SaveString(handle, "m_strOnUser2", m_strOnUser2);
SaveString(handle, "m_strOnUser3", m_strOnUser3);
SaveString(handle, "m_strOnUser4", m_strOnUser4);
SaveString(handle, "m_strModelEventCB", m_strModelEventCB);
}
void
NSIO::Restore(string strKey, string strValue)
@ -673,6 +674,9 @@ NSIO::Restore(string strKey, string strValue)
case "m_strOnUser4":
m_strOnUser4 = ReadString(strValue);
break;
case "m_strModelEventCB":
m_strModelEventCB = ReadString(strValue);
break;
}
}

View File

@ -26,6 +26,8 @@ public:
virtual void Touch(entity);
virtual void Respawn(void);
virtual void SpawnKey(string, string);
virtual void Save(float);
virtual void Restore(string,string);
nonvirtual void SetItem(int i);
nonvirtual int GetItem(void);

View File

@ -15,7 +15,8 @@
*/
#ifdef SERVER
void NSItem::NSItem(void)
void
NSItem::NSItem(void)
{
m_iClip = -1;
m_iWasDropped = 0i;
@ -23,6 +24,7 @@ void NSItem::NSItem(void)
m_sndAcquire = __NULL__;
m_sndRespawn = __NULL__;
m_bFloating = false;
m_bSpins = false;
}
void
@ -34,7 +36,8 @@ NSItem::Spawned(void)
Sound_Precache(m_sndRespawn);
}
void NSItem::Respawn(void)
void
NSItem::Respawn(void)
{
SetSolid(SOLID_TRIGGER);
SetOrigin(GetSpawnOrigin());
@ -90,7 +93,52 @@ NSItem::SpawnKey(string strKey, string strValue)
}
}
void NSItem::Touch(entity eToucher)
void
NSItem::Save(float handle)
{
super::Save(handle);
SaveInt(handle, "m_iClip", m_iClip);
SaveInt(handle, "m_iWasDropped", m_iWasDropped);
SaveInt(handle, "m_iInvItem", m_iInvItem);
SaveString(handle, "m_sndAcquire", m_sndAcquire);
SaveString(handle, "m_sndRespawn", m_sndRespawn);
SaveBool(handle, "m_bFloating", m_bFloating);
SaveBool(handle, "m_bSpins", m_bSpins);
}
void
NSItem::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_iClip":
m_iClip = ReadInt(strValue);
break;
case "m_iWasDropped":
m_iWasDropped = ReadInt(strValue);
break;
case "m_iInvItem":
m_iInvItem = ReadInt(strValue);
break;
case "m_sndAcquire":
m_sndAcquire = ReadString(strValue);
break;
case "m_sndRespawn":
m_sndRespawn = ReadString(strValue);
break;
case "m_bFloating":
m_bFloating = ReadBool(strValue);
break;
case "m_bSpins":
m_bSpins = ReadBool(strValue);
break;
default:
super::Restore(strKey, strValue);
break;
}
}
void
NSItem::Touch(entity eToucher)
{
if (eToucher.classname != "player") {
return;
@ -114,7 +162,8 @@ void NSItem::Touch(entity eToucher)
}
}
void NSItem::SetItem(int i)
void
NSItem::SetItem(int i)
{
m_iInvItem = i;
m_oldModel = Weapons_GetWorldmodel(m_iInvItem);

View File

@ -459,7 +459,6 @@ private:
string m_sndDeath;
string m_sndThud;
/* attack definitions, if defined will fire projectiles */
string m_defSpecial1;
float m_flSpecial1Range;

View File

@ -118,65 +118,126 @@ NSMonster::Save(float handle)
{
super::Save(handle);
SaveEntity(handle, "m_eEnemy", m_eEnemy);
SaveFloat(handle, "m_flHeadYaw", m_flHeadYaw);
SaveFloat(handle, "frame1time", frame1time);
SaveFloat(handle, "subblendfrac", subblendfrac);
SaveFloat(handle, "bonecontrol1", bonecontrol1);
SaveEntity(handle, "m_eLookAt", m_eLookAt);
SaveEntity(handle, "m_ssLast", m_ssLast);
SaveFloat(handle, "base_health", base_health);
SaveFloat(handle, "m_flAttackThink", m_flAttackThink);
SaveFloat(handle, "m_flBaseTime", m_flBaseTime);
SaveFloat(handle, "m_flPitch", m_flPitch);
SaveFloat(handle, "m_flSequenceEnd", m_flSequenceEnd);
SaveFloat(handle, "m_flSequenceSpeed", m_flSequenceSpeed);
SaveInt(handle, "m_iFlags", m_iFlags);
SaveInt(handle, "m_iSequenceFlags", m_iSequenceFlags);
SaveVector(handle, "base_mins", base_mins);
SaveVector(handle, "base_maxs", base_maxs);
SaveFloat(handle, "base_health", base_health);
SaveString(handle, "m_strRouteEnded", m_strRouteEnded);
SaveInt(handle, "m_iSequenceRemove", m_iSequenceRemove);
SaveInt(handle, "m_iSequenceState", m_iSequenceState);
SaveFloat(handle, "m_flSequenceEnd", m_flSequenceEnd);
SaveFloat(handle, "m_flSequenceSpeed", m_flSequenceSpeed);
SaveVector(handle, "m_vecSequenceAngle", m_vecSequenceAngle);
SaveInt(handle, "m_iSequenceFlags", m_iSequenceFlags);
SaveFloat(handle, "m_iMoveState", m_iMoveState);
SaveInt(handle, "m_iTriggerCondition", m_iTriggerCondition);
SaveString(handle, "m_strTriggerTarget", m_strTriggerTarget);
SaveFloat(handle, "m_flBaseTime", m_flBaseTime);
SaveEntity(handle, "m_eEnemy", m_eEnemy);
SaveFloat(handle, "m_flAttackThink", m_flAttackThink);
SaveFloat(handle, "m_iMState", m_iMState);
SaveFloat(handle, "m_iOldMState", m_iOldMState);
SaveFloat(handle, "m_iMoveState", m_iMoveState);
SaveString(handle, "m_strRouteEnded", m_strRouteEnded);
SaveString(handle, "m_strTriggerTarget", m_strTriggerTarget);
SaveVector(handle, "base_maxs", base_maxs);
SaveVector(handle, "base_mins", base_mins);
SaveVector(handle, "m_vecLKPos", m_vecLKPos);
SaveVector(handle, "m_vecSequenceAngle", m_vecSequenceAngle);
SaveFloat(handle, "m_flSeeTime", m_flSeeTime);
SaveFloat(handle, "m_flAnimTime", m_flAnimTime);
SaveFloat(handle, "m_flTrackingTime", m_flTrackingTime);
SaveVector(handle, "view_ofs", view_ofs);
SaveFloat(handle, "m_actIdle", m_actIdle);
SaveBool(handle, "m_bTurning", m_bTurning);
SaveFloat(handle, "m_flIdleNext", m_flIdleNext);
SaveFloat(handle, "_m_flMeleeAttempts", _m_flMeleeAttempts);
SaveFloat(handle, "_m_flMeleeDelay", _m_flMeleeDelay);
SaveFloat(handle, "_m_flBurstCount", _m_flBurstCount);
SaveBool(handle, "_m_bShouldThrow", _m_bShouldThrow);
SaveFloat(handle, "_m_flReloadTracker", _m_flReloadTracker);
SaveBool(handle, "m_bWeaponDrawn", m_bWeaponDrawn);
SaveFloat(handle, "m_flEyeHeight", m_flEyeHeight);
SaveString(handle, "m_sndSight", m_sndSight);
SaveString(handle, "m_sndIdle", m_sndIdle);
SaveFloat(handle, "m_flIdleMin", m_flIdleMin);
SaveFloat(handle, "m_flIdleMax", m_flIdleMax);
SaveString(handle, "m_sndFootstep", m_sndFootstep);
SaveString(handle, "m_sndChatter", m_sndChatter);
SaveString(handle, "m_sndChatterCombat", m_sndChatterCombat);
SaveString(handle, "m_sndPain", m_sndPain);
SaveString(handle, "m_sndMeleeAttack", m_sndMeleeAttack);
SaveString(handle, "m_sndMeleeAttackHit", m_sndMeleeAttackHit);
SaveString(handle, "m_sndMeleeAttackMiss", m_sndMeleeAttackMiss);
SaveString(handle, "m_sndDeath", m_sndDeath);
SaveString(handle, "m_sndThud", m_sndThud);
SaveString(handle, "m_defSpecial1", m_defSpecial1);
SaveFloat(handle, "m_flSpecial1Range", m_flSpecial1Range);
SaveString(handle, "m_defSpecial2", m_defSpecial2);
SaveFloat(handle, "m_flSpecial2Range", m_flSpecial2Range);
SaveString(handle, "m_defRanged1", m_defRanged1);
SaveFloat(handle, "m_flRanged1Range", m_flRanged1Range);
SaveString(handle, "m_defRanged2", m_defRanged2);
SaveFloat(handle, "m_flRanged2Range", m_flRanged2Range);
SaveInt(handle, "m_iNumProjectiles", m_iNumProjectiles);
SaveFloat(handle, "m_flProjectileDelay", m_flProjectileDelay);
SaveFloat(handle, "m_flProjectileSpread", m_flProjectileSpread);
SaveFloat(handle, "m_flAttackCone", m_flAttackCone);
SaveFloat(handle, "m_flAttackAccuracy", m_flAttackAccuracy);
SaveString(handle, "m_defMelee", m_defMelee);
SaveFloat(handle, "m_flMeleeRange", m_flMeleeRange);
SaveString(handle, "m_sndRangedAttack", m_sndRangedAttack);
SaveFloat(handle, "m_flReloadCount", m_flReloadCount);
SaveFloat(handle, "m_flReloadDelay", m_flReloadDelay);
SaveString(handle, "m_sndReload", m_sndReload);
SaveString(handle, "m_sndRangedAttack2", m_sndRangedAttack2);
SaveBool(handle, "m_bWeaponStartsDrawn", m_bWeaponStartsDrawn);
SaveString(handle, "m_strBodyOnDraw", m_strBodyOnDraw);
SaveFloat(handle, "m_flWalkSpeed", m_flWalkSpeed);
SaveFloat(handle, "m_flRunSpeed", m_flRunSpeed);
}
void
NSMonster::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_eEnemy":
m_eEnemy = ReadEntity(strValue);
case "m_flHeadYaw":
m_flHeadYaw = ReadFloat(strValue);
break;
case "frame1time":
frame1time = ReadFloat(strValue);
break;
case "subblendfrac":
subblendfrac = ReadFloat(strValue);
break;
case "bonecontrol1":
bonecontrol1 = ReadFloat(strValue);
break;
case "m_eLookAt":
m_eLookAt = ReadEntity(strValue);
break;
case "m_ssLast":
m_ssLast = ReadEntity(strValue);
break;
case "base_health":
base_health = ReadFloat(strValue);
break;
case "m_flAttackThink":
m_flAttackThink = ReadFloat(strValue);
break;
case "m_flBaseTime":
m_flBaseTime = ReadFloat(strValue);
break;
case "m_flPitch":
m_flPitch = ReadFloat(strValue);
break;
case "m_flSequenceEnd":
m_flSequenceEnd = ReadFloat(strValue);
break;
case "m_flSequenceSpeed":
m_flSequenceSpeed = ReadFloat(strValue);
break;
case "m_iFlags":
m_iFlags = ReadInt(strValue);
break;
case "m_iSequenceFlags":
m_iSequenceFlags = ReadInt(strValue);
case "base_mins":
base_mins = ReadVector(strValue);
break;
case "base_maxs":
base_maxs = ReadVector(strValue);
break;
case "base_health":
base_health = ReadFloat(strValue);
break;
case "m_strRouteEnded":
m_strRouteEnded = ReadString(strValue);
break;
case "m_iSequenceRemove":
m_iSequenceRemove = ReadInt(strValue);
@ -184,42 +245,198 @@ NSMonster::Restore(string strKey, string strValue)
case "m_iSequenceState":
m_iSequenceState = ReadInt(strValue);
break;
case "m_flSequenceEnd":
m_flSequenceEnd = ReadFloat(strValue);
break;
case "m_flSequenceSpeed":
m_flSequenceSpeed = ReadFloat(strValue);
break;
case "m_vecSequenceAngle":
m_vecSequenceAngle = ReadVector(strValue);
break;
case "m_iSequenceFlags":
m_iSequenceFlags = ReadInt(strValue);
break;
case "m_iMoveState":
m_iMoveState = ReadFloat(strValue);
break;
case "m_iTriggerCondition":
m_iTriggerCondition = ReadInt(strValue);
break;
case "m_strTriggerTarget":
m_strTriggerTarget = ReadString(strValue);
break;
case "m_flBaseTime":
m_flBaseTime = ReadFloat(strValue);
break;
case "m_eEnemy":
m_eEnemy = ReadEntity(strValue);
break;
case "m_flAttackThink":
m_flAttackThink = ReadFloat(strValue);
break;
case "m_iMState":
m_iMState = ReadFloat(strValue);
break;
case "m_iOldMState":
m_iOldMState = ReadFloat(strValue);
break;
case "m_iMoveState":
m_iMoveState = ReadFloat(strValue);
break;
case "m_strRouteEnded":
m_strRouteEnded = ReadString(strValue);
break;
case "m_strTriggerTarget":
m_strTriggerTarget = ReadString(strValue);
break;
case "base_maxs":
base_maxs = ReadVector(strValue);
break;
case "base_mins":
base_mins = ReadVector(strValue);
break;
case "m_vecLKPos":
m_vecLKPos = ReadVector(strValue);
break;
case "m_vecSequenceAngle":
m_vecSequenceAngle = ReadVector(strValue);
break;
case "m_flSeeTime":
m_flSeeTime = ReadFloat(strValue);
break;
case "m_flAnimTime":
m_flAnimTime = ReadFloat(strValue);
break;
case "m_flTrackingTime":
m_flTrackingTime = ReadFloat(strValue);
break;
case "view_ofs":
view_ofs = ReadVector(strValue);
break;
case "m_actIdle":
m_actIdle = ReadFloat(strValue);
break;
case "m_bTurning":
m_bTurning = ReadBool(strValue);
break;
case "m_flIdleNext":
m_flIdleNext = ReadFloat(strValue);
break;
case "_m_flMeleeAttempts":
_m_flMeleeAttempts = ReadFloat(strValue);
break;
case "_m_flMeleeDelay":
_m_flMeleeDelay = ReadFloat(strValue);
break;
case "_m_flBurstCount":
_m_flBurstCount = ReadFloat(strValue);
break;
case "_m_bShouldThrow":
_m_bShouldThrow = ReadBool(strValue);
break;
case "_m_flReloadTracker":
_m_flReloadTracker = ReadFloat(strValue);
break;
case "m_bWeaponDrawn":
m_bWeaponDrawn = ReadBool(strValue);
break;
case "m_flEyeHeight":
m_flEyeHeight = ReadFloat(strValue);
break;
case "m_sndSight":
m_sndSight = ReadString(strValue);
break;
case "m_sndIdle":
m_sndIdle = ReadString(strValue);
break;
case "m_flIdleMin":
m_flIdleMin = ReadFloat(strValue);
break;
case "m_flIdleMax":
m_flIdleMax = ReadFloat(strValue);
break;
case "m_sndFootstep":
m_sndFootstep = ReadString(strValue);
break;
case "m_sndChatter":
m_sndChatter = ReadString(strValue);
break;
case "m_sndChatterCombat":
m_sndChatterCombat = ReadString(strValue);
break;
case "m_sndPain":
m_sndPain = ReadString(strValue);
break;
case "m_sndMeleeAttack":
m_sndMeleeAttack = ReadString(strValue);
break;
case "m_sndMeleeAttackHit":
m_sndMeleeAttackHit = ReadString(strValue);
break;
case "m_sndMeleeAttackMiss":
m_sndMeleeAttackMiss = ReadString(strValue);
break;
case "m_sndDeath":
m_sndDeath = ReadString(strValue);
break;
case "m_sndThud":
m_sndThud = ReadString(strValue);
break;
case "m_defSpecial1":
m_defSpecial1 = ReadString(strValue);
break;
case "m_flSpecial1Range":
m_flSpecial1Range = ReadFloat(strValue);
break;
case "m_defSpecial2":
m_defSpecial2 = ReadString(strValue);
break;
case "m_flSpecial2Range":
m_flSpecial2Range = ReadFloat(strValue);
break;
case "m_defRanged1":
m_defRanged1 = ReadString(strValue);
break;
case "m_flRanged1Range":
m_flRanged1Range = ReadFloat(strValue);
break;
case "m_defRanged2":
m_defRanged2 = ReadString(strValue);
break;
case "m_flRanged2Range":
m_flRanged2Range = ReadFloat(strValue);
break;
case "m_iNumProjectiles":
m_iNumProjectiles = ReadInt(strValue);
break;
case "m_flProjectileDelay":
m_flProjectileDelay = ReadFloat(strValue);
break;
case "m_flProjectileSpread":
m_flProjectileSpread = ReadFloat(strValue);
break;
case "m_flAttackCone":
m_flAttackCone = ReadFloat(strValue);
break;
case "m_flAttackAccuracy":
m_flAttackAccuracy = ReadFloat(strValue);
break;
case "m_defMelee":
m_defMelee = ReadString(strValue);
break;
case "m_flMeleeRange":
m_flMeleeRange = ReadFloat(strValue);
break;
case "m_sndRangedAttack":
m_sndRangedAttack = ReadString(strValue);
break;
case "m_flReloadCount":
m_flReloadCount = ReadFloat(strValue);
break;
case "m_flReloadDelay":
m_flReloadDelay = ReadFloat(strValue);
break;
case "m_sndReload":
m_sndReload = ReadString(strValue);
break;
case "m_sndRangedAttack2":
m_sndRangedAttack2 = ReadString(strValue);
break;
case "m_bWeaponStartsDrawn":
m_bWeaponStartsDrawn = ReadBool(strValue);
break;
case "m_strBodyOnDraw":
m_strBodyOnDraw = ReadString(strValue);
break;
case "m_flWalkSpeed":
m_flWalkSpeed = ReadFloat(strValue);
break;
case "m_flRunSpeed":
m_flRunSpeed = ReadFloat(strValue);
break;
default:
super::Restore(strKey, strValue);
break;

View File

@ -44,6 +44,9 @@ NSPortal:NSEntity
virtual vector camera_transform(vector, vector);
#ifdef SERVER
virtual void Save(float);
virtual void Restore(string,string);
virtual void EvaluateEntity(void);
virtual float SendEntity(entity, float);
@ -88,6 +91,13 @@ private:
#ifdef CLIENT
void NSPortal_ReadEntity(bool);
#define READENTITY_PORTAL(field, changedflag) {\
if (flChanged & changedflag) {\
field = (NSPortal)findfloat(world, ::entnum, readentitynum());\
PRINTFLAG(changedflag); \
}\
}
#endif
#define SOLID_PORTAL 21

View File

@ -55,6 +55,54 @@ NSPortal::NSPortal(void)
}
#ifdef SERVER
void
NSPortal::Save(float handle)
{
super::Save(handle);
SaveEntity(handle, "m_ePortalTarget", m_ePortalTarget);
SaveVector(handle, "m_vecTargetPos", m_vecTargetPos);
SaveVector(handle, "m_vecTargetAngle", m_vecTargetAngle);
SaveVector(handle, "m_vecPortalPos", m_vecPortalPos);
SaveVector(handle, "m_vecPortalN", m_vecPortalN);
SaveVector(handle, "m_vecPortalS", m_vecPortalS);
SaveVector(handle, "m_vecPortalT", m_vecPortalT);
SaveInt(handle, "m_iPortalValue", m_iPortalValue);
}
void
NSPortal::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_ePortalTarget":
m_ePortalTarget = (NSPortal)ReadEntity(strValue);
break;
case "m_vecTargetPos":
m_vecTargetPos = ReadVector(strValue);
break;
case "m_vecTargetAngle":
m_vecTargetAngle = ReadVector(strValue);
break;
case "m_vecPortalPos":
m_vecPortalPos = ReadVector(strValue);
break;
case "m_vecPortalN":
m_vecPortalN = ReadVector(strValue);
break;
case "m_vecPortalS":
m_vecPortalS = ReadVector(strValue);
break;
case "m_vecPortalT":
m_vecPortalT = ReadVector(strValue);
break;
case "m_iPortalValue":
m_iPortalValue = ReadInt(strValue);
break;
default:
super::Restore(strKey, strValue);
break;
}
}
void
NSPortal::PortalAutoLink(void)
{
@ -360,8 +408,8 @@ void
NSPortal::ReceiveEntity(float flNew, float flChanged)
{
if (m_ePortalTarget) {
m_ePortalTarget.m_ePortalTarget = world;
m_ePortalTarget = world;
m_ePortalTarget.m_ePortalTarget = __NULL__;
m_ePortalTarget = __NULL__;
}
READENTITY_COORD(origin[0], PORTALFL_CHANGED_ORIGIN_X)
@ -370,7 +418,7 @@ NSPortal::ReceiveEntity(float flNew, float flChanged)
READENTITY_FLOAT(angles[0], PORTALFL_CHANGED_ANGLES_X)
READENTITY_FLOAT(angles[1], PORTALFL_CHANGED_ANGLES_Y)
READENTITY_FLOAT(angles[2], PORTALFL_CHANGED_ANGLES_Z)
READENTITY_ENTITY(m_ePortalTarget, PORTALFL_CHANGED_TARG_ENTITY)
READENTITY_PORTAL(m_ePortalTarget, PORTALFL_CHANGED_TARG_ENTITY)
READENTITY_COORD(m_vecTargetPos[0], PORTALFL_CHANGED_TARG_ORIGIN_X)
READENTITY_COORD(m_vecTargetPos[1], PORTALFL_CHANGED_TARG_ORIGIN_Y)
@ -381,7 +429,7 @@ NSPortal::ReceiveEntity(float flNew, float flChanged)
if (m_ePortalTarget) {
if (m_ePortalTarget.m_ePortalTarget)
m_ePortalTarget.m_ePortalTarget.m_ePortalTarget = world;
m_ePortalTarget.m_ePortalTarget.m_ePortalTarget = __NULL__;
m_ePortalTarget. m_ePortalTarget = this;
} else {

View File

@ -122,6 +122,8 @@ public:
virtual void SpawnKey(string, string);
virtual void EvaluateEntity(void);
virtual float SendEntity(entity, float);
virtual void Save(float);
virtual void Restore(string, string);
nonvirtual void _FuseEnded(void);
nonvirtual void _Explode(void);

View File

@ -200,6 +200,179 @@ NSProjectile::SpawnKey(string strKey, string strValue)
}
}
void
NSProjectile::Save(float handle)
{
super::Save(handle);
SaveInt(handle, "m_iProjectileAnimEnd", m_iProjectileAnimEnd);
SaveInt(handle, "m_iProjectileAnimStart", m_iProjectileAnimStart);
SaveFloat(handle, "m_flProjectileFramerate", m_flProjectileFramerate);
SaveFloat(handle, "m_flDmgMultiplier", m_flDmgMultiplier);
SaveString(handle, "m_defDamage", m_defDamage);
SaveString(handle, "m_defSplashDamage", m_defSplashDamage);
SaveVector(handle, "m_vecLaunchVelocity", m_vecLaunchVelocity);
SaveFloat(handle, "m_flThrust", m_flThrust);
SaveFloat(handle, "m_flThrustStart", m_flThrustStart);
SaveFloat(handle, "m_flThrustEnd", m_flThrustEnd);
SaveFloat(handle, "m_flFrictionLinear", m_flFrictionLinear);
SaveFloat(handle, "m_flBounce", m_flBounce);
SaveFloat(handle, "m_flMass", m_flMass);
SaveFloat(handle, "m_flGravity", m_flGravity);
SaveFloat(handle, "m_flFuse", m_flFuse);
SaveBool(handle, "m_bDetonateOnFuse", m_bDetonateOnFuse);
SaveBool(handle, "m_bDetonateOnDeath", m_bDetonateOnDeath);
SaveBool(handle, "m_bDetonateOnWorld", m_bDetonateOnWorld);
SaveBool(handle, "m_bDetonateOnActor", m_bDetonateOnActor);
SaveBool(handle, "m_bImpactEffect", m_bImpactEffect);
SaveBool(handle, "m_bImpactGib", m_bImpactGib);
SaveString(handle, "m_matDetonate", m_matDetonate);
SaveFloat(handle, "m_flDecalSize", m_flDecalSize);
SaveString(handle, "m_partSmokeFly", m_partSmokeFly);
SaveString(handle, "m_partModelDetonate", m_partModelDetonate);
SaveString(handle, "m_partSmokeDetonate", m_partSmokeDetonate);
SaveString(handle, "m_partSmokeBounce", m_partSmokeBounce);
SaveString(handle, "m_partSmokeFuse", m_partSmokeFuse);
SaveInt(handle, "m_iDebrisCount", m_iDebrisCount);
SaveVector(handle, "m_vecLightColor", m_vecLightColor);
SaveFloat(handle, "m_flLightRadius", m_flLightRadius);
SaveFloat(handle, "m_flLightOffset", m_flLightOffset);
SaveVector(handle, "m_vecExplodeLightColor", m_vecExplodeLightColor);
SaveFloat(handle, "m_fExplodelLightRadius", m_fExplodelLightRadius);
SaveFloat(handle, "m_fExplodelLightFadetime", m_fExplodelLightFadetime);
SaveString(handle, "m_sndFly", m_sndFly);
SaveString(handle, "m_sndExplode", m_sndExplode);
SaveString(handle, "m_sndBounce", m_sndBounce);
SaveBool(handle, "m_bIsBullet", m_bIsBullet);
}
void
NSProjectile::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_iProjectileAnimEnd":
m_iProjectileAnimEnd = ReadInt(strValue);
break;
case "m_iProjectileAnimStart":
m_iProjectileAnimStart = ReadInt(strValue);
break;
case "m_flProjectileFramerate":
m_flProjectileFramerate = ReadFloat(strValue);
break;
case "m_flDmgMultiplier":
m_flDmgMultiplier = ReadFloat(strValue);
break;
case "m_defDamage":
m_defDamage = ReadString(strValue);
break;
case "m_defSplashDamage":
m_defSplashDamage = ReadString(strValue);
break;
case "m_vecLaunchVelocity":
m_vecLaunchVelocity = ReadVector(strValue);
break;
case "m_flThrust":
m_flThrust = ReadFloat(strValue);
break;
case "m_flThrustStart":
m_flThrustStart = ReadFloat(strValue);
break;
case "m_flThrustEnd":
m_flThrustEnd = ReadFloat(strValue);
break;
case "m_flFrictionLinear":
m_flFrictionLinear = ReadFloat(strValue);
break;
case "m_flBounce":
m_flBounce = ReadFloat(strValue);
break;
case "m_flMass":
m_flMass = ReadFloat(strValue);
break;
case "m_flGravity":
m_flGravity = ReadFloat(strValue);
break;
case "m_flFuse":
m_flFuse = ReadFloat(strValue);
break;
case "m_bDetonateOnFuse":
m_bDetonateOnFuse = ReadBool(strValue);
break;
case "m_bDetonateOnDeath":
m_bDetonateOnDeath = ReadBool(strValue);
break;
case "m_bDetonateOnWorld":
m_bDetonateOnWorld = ReadBool(strValue);
break;
case "m_bDetonateOnActor":
m_bDetonateOnActor = ReadBool(strValue);
break;
case "m_bImpactEffect":
m_bImpactEffect = ReadBool(strValue);
break;
case "m_bImpactGib":
m_bImpactGib = ReadBool(strValue);
break;
case "m_matDetonate":
m_matDetonate = ReadString(strValue);
break;
case "m_flDecalSize":
m_flDecalSize = ReadFloat(strValue);
break;
case "m_partSmokeFly":
m_partSmokeFly = ReadString(strValue);
break;
case "m_partModelDetonate":
m_partModelDetonate = ReadString(strValue);
break;
case "m_partSmokeDetonate":
m_partSmokeDetonate = ReadString(strValue);
break;
case "m_partSmokeBounce":
m_partSmokeBounce = ReadString(strValue);
break;
case "m_partSmokeFuse":
m_partSmokeFuse = ReadString(strValue);
break;
case "m_iDebrisCount":
m_iDebrisCount = ReadInt(strValue);
break;
case "m_vecLightColor":
m_vecLightColor = ReadVector(strValue);
break;
case "m_flLightRadius":
m_flLightRadius = ReadFloat(strValue);
break;
case "m_flLightOffset":
m_flLightOffset = ReadFloat(strValue);
break;
case "m_vecExplodeLightColor":
m_vecExplodeLightColor = ReadVector(strValue);
break;
case "m_fExplodelLightRadius":
m_fExplodelLightRadius = ReadFloat(strValue);
break;
case "m_fExplodelLightFadetime":
m_fExplodelLightFadetime = ReadFloat(strValue);
break;
case "m_sndFly":
m_sndFly = ReadString(strValue);
break;
case "m_sndExplode":
m_sndExplode = ReadString(strValue);
break;
case "m_sndBounce":
m_sndBounce = ReadString(strValue);
break;
case "m_bIsBullet":
m_bIsBullet = ReadBool(strValue);
break;
default:
super::Restore(strKey, strValue);
break;
}
}
void
NSProjectile::Spawned(void)
{

View File

@ -847,20 +847,54 @@ void
NSRenderableEntity::Save(float handle)
{
super::Save(handle);
SaveFloat(handle, "m_flBoneControl1", m_flBoneControl1);
SaveFloat(handle, "m_flBoneControl2", m_flBoneControl2);
SaveFloat(handle, "m_flBoneControl3", m_flBoneControl3);
SaveFloat(handle, "m_flBoneControl4", m_flBoneControl4);
SaveFloat(handle, "m_flBoneControl5", m_flBoneControl5);
SaveFloat(handle, "modelflags", modelflags);
SaveInt(handle, "m_iBody", m_iBody);
SaveFloat(handle, "colormap", colormap);
SaveVector(handle, "glowmod", glowmod);
SaveFloat(handle, "m_flRenderAmt", m_flRenderAmt);
SaveVector(handle, "m_vecRenderColor", m_vecRenderColor);
SaveFloat(handle, "m_iRenderMode", m_iRenderMode);
SaveFloat(handle, "m_iRenderFX", m_iRenderFX);
SaveVector(handle, "m_vecAxialScale", m_vecAxialScale);
SaveFloat(handle, "m_flBaseTime", m_flBaseTime);
}
void
NSRenderableEntity::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_flBoneControl1":
m_flBoneControl1 = ReadFloat(strValue);
break;
case "m_flBoneControl2":
m_flBoneControl2 = ReadFloat(strValue);
break;
case "m_flBoneControl3":
m_flBoneControl3 = ReadFloat(strValue);
break;
case "m_flBoneControl4":
m_flBoneControl4 = ReadFloat(strValue);
break;
case "m_flBoneControl5":
m_flBoneControl5 = ReadFloat(strValue);
break;
case "modelflags":
modelflags = ReadFloat(strValue);
break;
case "m_iBody":
m_iBody = ReadInt(strValue);
break;
case "colormap":
colormap = ReadFloat(strValue);
break;
case "glowmod":
glowmod = ReadVector(strValue);
break;
case "m_flRenderAmt":
m_flRenderAmt = ReadFloat(strValue);
break;
@ -873,6 +907,12 @@ NSRenderableEntity::Restore(string strKey, string strValue)
case "m_iRenderFX":
m_iRenderFX = ReadFloat(strValue);
break;
case "m_vecAxialScale":
m_vecAxialScale = ReadVector(strValue);
break;
case "m_flBaseTime":
m_flBaseTime = ReadFloat(strValue);
break;
default:
super::Restore(strKey, strValue);
}

View File

@ -27,6 +27,8 @@ public:
/* overrides */
virtual void Spawned(void);
virtual void SpawnKey(string, string);
virtual void Save(float);
virtual void Restore(string, string);
/** Overridable: Called when this NPC became squad leader. */
virtual void HasBecomeSquadLeader(void);

View File

@ -46,6 +46,59 @@ NSSquadMonster::SpawnKey(string strKey, string strValue)
}
}
void
NSSquadMonster::Save(float handle)
{
super::Save(handle);
SaveString(handle, "m_strSquadLeaderBody", m_strSquadLeaderBody);
SaveBool(handle, "m_bStartAsLeader", m_bStartAsLeader);
SaveBool(handle, "m_inSquad", m_inSquad);
SaveEntity(handle, "m_eSquadLeader", m_eSquadLeader);
SaveEntity(handle, "m_eSquadMembers0", m_eSquadMembers[0]);
SaveEntity(handle, "m_eSquadMembers1", m_eSquadMembers[1]);
SaveEntity(handle, "m_eSquadMembers2", m_eSquadMembers[2]);
SaveEntity(handle, "m_eSquadMembers3", m_eSquadMembers[3]);
SaveEntity(handle, "m_eSquadMembers4", m_eSquadMembers[4]);
}
void
NSSquadMonster::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_strSquadLeaderBody":
m_strSquadLeaderBody = ReadString(strValue);
break;
case "m_bStartAsLeader":
m_bStartAsLeader = ReadBool(strValue);
break;
case "m_inSquad":
m_inSquad = ReadBool(strValue);
break;
case "m_eSquadLeader":
m_eSquadLeader = (NSSquadMonster)ReadEntity(strValue);
break;
case "m_eSquadMembers0":
m_eSquadMembers[0] = (NSSquadMonster)ReadEntity(strValue);
break;
case "m_eSquadMembers1":
m_eSquadMembers[1] = (NSSquadMonster)ReadEntity(strValue);
break;
case "m_eSquadMembers2":
m_eSquadMembers[2] = (NSSquadMonster)ReadEntity(strValue);
break;
case "m_eSquadMembers3":
m_eSquadMembers[3] = (NSSquadMonster)ReadEntity(strValue);
break;
case "m_eSquadMembers4":
m_eSquadMembers[4] = (NSSquadMonster)ReadEntity(strValue);
break;
default:
super::Restore(strKey, strValue);
break;
}
}
void
NSSquadMonster::Spawned(void)
{

View File

@ -526,20 +526,34 @@ void
NSSurfacePropEntity::Save(float handle)
{
super::Save(handle);
SaveFloat(handle, "m_flBurnNext", m_flBurnNext);
SaveFloat(handle, "armor", armor);
SaveFloat(handle, "health", health);
SaveFloat(handle, "m_eBurner", num_for_edict(m_eBurner));
SaveInt(handle, "m_iBurnWeapon", m_iBurnWeapon);
SaveFloat(handle,"m_flBurnTime", m_flBurnTime);
SaveFloat(handle, "m_flBurnNext", m_flBurnNext);
SaveFloat(handle, "m_flBurnDmgTime", m_flBurnDmgTime);
SaveString(handle, "m_strOnBreak", m_strOnBreak);
SaveFloat(handle, "m_oldHealth", m_oldHealth);
SaveVector(handle, "m_vecBloodColor", m_vecBloodColor);
SaveInt(handle, "m_iMaterial", m_iMaterial);
SaveInt(handle, "m_iPropData", m_iPropData);
SaveFloat(handle, "m_flDeathTime", m_flDeathTime);
}
void
NSSurfacePropEntity::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_flBurnNext":
m_flBurnNext = ReadFloat(strValue);
break;
case "armor":
armor = ReadFloat(strValue);
break;
case "health":
health = ReadFloat(strValue);
break;
case "m_eBurner":
m_eBurner = edict_num(ReadFloat(strValue));
break;
@ -549,8 +563,8 @@ NSSurfacePropEntity::Restore(string strKey, string strValue)
case "m_flBurnTime":
m_flBurnTime = ReadFloat(strValue);
break;
case "m_flBurnNext":
m_flBurnNext = ReadFloat(strValue);
case "m_flBurnDmgTime":
m_flBurnDmgTime = ReadFloat(strValue);
break;
case "m_strOnBreak":
m_strOnBreak = ReadString(strValue);
@ -558,12 +572,18 @@ NSSurfacePropEntity::Restore(string strKey, string strValue)
case "m_oldHealth":
m_oldHealth = ReadFloat(strValue);
break;
case "m_vecBloodColor":
m_vecBloodColor = ReadVector(strValue);
break;
case "m_iMaterial":
m_iMaterial = ReadInt(strValue);
break;
case "m_iPropData":
m_iPropData = ReadInt(strValue);
break;
case "m_flDeathTime":
m_flDeathTime = ReadFloat(strValue);
break;
default:
super::Restore(strKey, strValue);
}

View File

@ -101,6 +101,7 @@ NSTalkMonster::Save(float handle)
SaveFloat(handle, "m_flTraceTime", m_flTraceTime);
SaveFloat(handle, "m_flFollowSpeedChanged", m_flFollowSpeedChanged);
SaveFloat(handle, "m_flFollowSpeed", m_flFollowSpeed);
SaveBool(handle, "m_bFollowOnUse", m_bFollowOnUse);
SaveString(handle, "m_talkAnswer", m_talkAnswer);
SaveString(handle, "m_talkAsk", m_talkAsk);
@ -123,6 +124,7 @@ NSTalkMonster::Save(float handle)
SaveString(handle, "m_talkUnfollow", m_talkUnfollow);
SaveString(handle, "m_talkFollow", m_talkFollow);
SaveString(handle, "m_talkStopFollow", m_talkStopFollow);
SaveString(handle, "m_talkDenyFollow", m_talkDenyFollow);
}
void
@ -159,6 +161,9 @@ NSTalkMonster::Restore(string strKey, string strValue)
case "m_flFollowSpeed":
m_flFollowSpeed = ReadFloat(strValue);
break;
case "m_bFollowOnUse":
m_bFollowOnUse = ReadBool(strValue);
break;
case "m_talkAnswer":
m_talkAnswer = ReadString(strValue);
break;
@ -222,6 +227,9 @@ NSTalkMonster::Restore(string strKey, string strValue)
case "m_talkStopFollow":
m_talkStopFollow = ReadString(strValue);
break;
case "m_talkDenyFollow":
m_talkDenyFollow = ReadString(strValue);
break;
default:
super::Restore(strKey, strValue);
}

View File

@ -14,6 +14,8 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
.void(void) _m_NSTimerFunc;
/** This class provides a way to trigger a function in the future.
It has the ability to clean itself up afterwards, too. */
class
@ -21,7 +23,6 @@ NSTimer:NSEntity
{
private:
entity m_eReceiver;
virtual void(void) m_vFunc = 0;
float m_flTime;
bool m_bRepeats;
@ -47,4 +48,9 @@ public:
nonvirtual void StopTimer(void);
virtual void OnRemoveEntity(void);
#ifdef SERVER
virtual void Save(float);
virtual void Restore(string, string);
#endif
};

View File

@ -18,7 +18,7 @@ void
NSTimer::NSTimer(void)
{
m_eReceiver = __NULL__;
m_vFunc = __NULL__;
_m_NSTimerFunc = __NULL__;
m_flTime = 0.0f;
m_bRepeats = false;
}
@ -36,7 +36,7 @@ _NSTimerWrapper(entity receiver, void() func)
void
NSTimer::_TimerThink(void)
{
_NSTimerWrapper(m_eReceiver, m_vFunc);
_NSTimerWrapper(m_eReceiver, _m_NSTimerFunc);
if (m_bRepeats == true)
nextthink = time + m_flTime;
@ -45,7 +45,7 @@ NSTimer::_TimerThink(void)
void
NSTimer::_TempTimerThink(void)
{
_NSTimerWrapper(m_eReceiver, m_vFunc);
_NSTimerWrapper(m_eReceiver, _m_NSTimerFunc);
if (m_bRepeats == true)
nextthink = time + m_flTime;
@ -69,7 +69,7 @@ NSTimer::ScheduleTimer(entity receiver, void() call, float interval, bool repeat
ret.m_eReceiver = receiver;
ret.m_flTime = interval;
ret.m_vFunc = call;
ret._m_NSTimerFunc = call;
ret.m_bRepeats = repeats;
/* time to start running */
@ -92,7 +92,7 @@ NSTimer::TemporaryTimer(entity receiver, void() call, float interval, bool repea
ret.m_eReceiver = receiver;
ret.m_flTime = interval;
ret.m_vFunc = call;
ret._m_NSTimerFunc = call;
ret.m_bRepeats = repeats;
/* time to start running */
@ -122,7 +122,7 @@ NSTimer::SetupTimer(entity receiver, void() call, float interval, bool repeats)
ret.m_eReceiver = receiver;
ret.m_flTime = interval;
ret.m_vFunc = call;
ret._m_NSTimerFunc = call;
ret.m_bRepeats = repeats;
return ret;
}
@ -141,4 +141,38 @@ NSTimer::StopTimer(void)
nextthink = 0.0f;
think = __NULL__;
}
}
}
#ifdef SERVER
void
NSTimer::Save(float handle)
{
super::Save(handle);
SaveEntity(handle, "m_eReceiver", m_eReceiver);
SaveString(handle, "_m_NSTimerFunc", getentityfieldstring(findentityfield("_m_NSTimerFunc"), this));
SaveFloat(handle, "m_flTime", m_flTime);
SaveBool(handle, "m_bRepeats", m_bRepeats);
}
void
NSTimer::Restore(string strKey, string strValue)
{
switch (strKey) {
case "m_eReceiver":
m_eReceiver = ReadEntity(strValue);
break;
case "_m_NSTimerFunc":
_m_NSTimerFunc = externvalue(-1, strValue);
break;
case "m_flTime":
m_flTime = ReadFloat(strValue);
break;
case "m_bRepeats":
m_bRepeats = ReadBool(strValue);
break;
default:
super::Restore(strKey, strValue);
break;
}
}
#endif