From 1dc484980fd2d8dac564072ca20fbd7bff718f30 Mon Sep 17 00:00:00 2001 From: s1lent Date: Wed, 14 Jun 2017 00:42:57 +0700 Subject: [PATCH] Fix func_rotating --- regamedll/dlls/bmodels.cpp | 65 +++++++++++++++++++++------ regamedll/dlls/bmodels.h | 43 +++++++++++------- regamedll/dlls/cbase.h | 4 ++ regamedll/dlls/triggers.h | 10 ++--- regamedll/dlls/util.h | 17 ------- regamedll/extra/cssdk/dlls/bmodels.h | 37 ++++++++++----- regamedll/extra/cssdk/dlls/cbase.h | 4 ++ regamedll/extra/cssdk/dlls/triggers.h | 6 ++- regamedll/extra/cssdk/dlls/util.h | 17 ------- 9 files changed, 123 insertions(+), 80 deletions(-) diff --git a/regamedll/dlls/bmodels.cpp b/regamedll/dlls/bmodels.cpp index 97bffead..be68e285 100644 --- a/regamedll/dlls/bmodels.cpp +++ b/regamedll/dlls/bmodels.cpp @@ -352,6 +352,58 @@ void CFuncRotating::__MAKE_VHOOK(Spawn)() Precache(); } +#ifdef REGAMEDLL_FIXES +void CFuncRotating::Restart() +{ + // fan is spinning, so stop it. + SetThink(&CFuncRotating::SpinDown); + pev->nextthink = pev->ltime + 0.1; + + // restore angles + pev->angles = m_angles; + pev->avelocity = g_vecZero; + + // some rotating objects like fake volumetric lights will not be solid. + if (pev->spawnflags & SF_ROTATING_NOT_SOLID) + { + pev->solid = SOLID_NOT; + pev->skin = CONTENTS_EMPTY; + pev->movetype = MOVETYPE_PUSH; + } + else + { + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; + } + + UTIL_SetOrigin(pev, pev->origin); + SET_MODEL(ENT(pev), STRING(pev->model)); + + SetUse(&CFuncRotating::RotatingUse); + + // did level designer forget to assign speed? + if (pev->speed <= 0) + { + pev->speed = 0; + } + + // instant-use brush? + if (pev->spawnflags & SF_BRUSH_ROTATE_INSTANT) + { + SetThink(&CFuncRotating::SUB_CallUseToggle); + + // leave a magic delay for client to start up + pev->nextthink = pev->ltime + 0.1; + } + + // can this brush inflict pain? + if (pev->spawnflags & SF_BRUSH_HURT) + { + SetTouch(&CFuncRotating::HurtTouch); + } +} +#endif + void CFuncRotating::__MAKE_VHOOK(Precache)() { char *szSoundFile = (char *)STRING(pev->message); @@ -554,19 +606,6 @@ void CFuncRotating::Rotate() pev->nextthink = pev->ltime + 10; } -#ifdef REGAMEDLL_FIXES -void CFuncRotating::Restart() -{ - // fan is spinning, so stop it. - SetThink(&CFuncRotating::SpinDown); - pev->nextthink = pev->ltime + 0.1; - - // restore angles - pev->angles = m_angles; - pev->avelocity = g_vecZero; -} -#endif - // Rotating Use - when a rotating brush is triggered void CFuncRotating::RotatingUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { diff --git a/regamedll/dlls/bmodels.h b/regamedll/dlls/bmodels.h index 7cf3bcf6..232713ff 100644 --- a/regamedll/dlls/bmodels.h +++ b/regamedll/dlls/bmodels.h @@ -32,28 +32,41 @@ #pragma once #endif -#define SF_PENDULUM_SWING 2 // spawnflag that makes a pendulum a rope swing. +// func_rotating +#define SF_BRUSH_ROTATE_Y_AXIS 0 +#define SF_BRUSH_ROTATE_INSTANT 1 +#define SF_BRUSH_ROTATE_BACKWARDS 2 +#define SF_BRUSH_ROTATE_Z_AXIS 4 +#define SF_BRUSH_ROTATE_X_AXIS 8 -#define SF_BRUSH_ACCDCC 16 // brush should accelerate and decelerate when toggled -#define SF_BRUSH_HURT 32 // rotating brush that inflicts pain based on rotation speed -#define SF_ROTATING_NOT_SOLID 64 // some special rotating objects are not solid. +#define SF_BRUSH_ACCDCC 16 // brush should accelerate and decelerate when toggled +#define SF_BRUSH_HURT 32 // rotating brush that inflicts pain based on rotation speed -#define SF_WALL_START_OFF 0x0001 +#define SF_ROTATING_NOT_SOLID 64 // some special rotating objects are not solid. -#define SF_CONVEYOR_VISUAL 0x0001 -#define SF_CONVEYOR_NOTSOLID 0x0002 +#define SF_BRUSH_ROTATE_SMALLRADIUS 128 +#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256 +#define SF_BRUSH_ROTATE_LARGERADIUS 512 -#define SF_WORLD_DARK 0x0001 // Fade from black at startup -#define SF_WORLD_TITLE 0x0002 // Display game title at startup -#define SF_WORLD_FORCETEAM 0x0004 // Force teams +#define FANPITCHMIN 30 +#define FANPITCHMAX 100 -#define FANPITCHMIN 30 -#define FANPITCHMAX 100 +// func_pendulum +#define SF_PENDULUM_SWING 2 // spawnflag that makes a pendulum a rope swing. +#define SF_PENDULUM_AUTO_RETURN 16 +#define SF_PENDULUM_PASSABLE 32 + +// func_wall_toggle +#define SF_WALL_START_OFF 0x0001 + +// func_conveyor +#define SF_CONVEYOR_VISUAL 0x0001 +#define SF_CONVEYOR_NOTSOLID 0x0002 // covering cheesy noise1, noise2, & noise3 fields so they make more sense (for rotating fans) -#define noiseStart noise1 -#define noiseStop noise2 -#define noiseRunning noise3 +#define noiseStart noise1 +#define noiseStop noise2 +#define noiseRunning noise3 // This is just a solid wall if not inhibited class CFuncWall: public CBaseEntity diff --git a/regamedll/dlls/cbase.h b/regamedll/dlls/cbase.h index bd88649f..6d786d23 100644 --- a/regamedll/dlls/cbase.h +++ b/regamedll/dlls/cbase.h @@ -680,6 +680,10 @@ public: int m_sounds; }; +#define SF_WORLD_DARK 0x0001 // Fade from black at startup +#define SF_WORLD_TITLE 0x0002 // Display game title at startup +#define SF_WORLD_FORCETEAM 0x0004 // Force teams + // This spawns first when each level begins. class CWorld: public CBaseEntity { public: diff --git a/regamedll/dlls/triggers.h b/regamedll/dlls/triggers.h index 673cf161..6b0e55ee 100644 --- a/regamedll/dlls/triggers.h +++ b/regamedll/dlls/triggers.h @@ -35,8 +35,12 @@ #define GRENADETYPE_SMOKE 1 #define GRENADETYPE_FLASH 2 +#define SPAWNFLAG_NOMESSAGE 1 +#define SPAWNFLAG_NOTOUCH 1 +#define SPAWNFLAG_DROIDONLY 4 + #define MAX_ITEM_COUNTS 32 -#define MAX_ENTITY 512 // We can only ever move 512 entities across a transition +#define MAX_ENTITY 512 // We can only ever move 512 entities across a transition // triggers #define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger @@ -531,10 +535,6 @@ public: #endif -#ifdef REGAMEDLL_FIXES -private: - Vector m_vecAngles; -#endif }; class CTriggerTeleport: public CBaseTrigger diff --git a/regamedll/dlls/util.h b/regamedll/dlls/util.h index d27280a0..3af11c1d 100644 --- a/regamedll/dlls/util.h +++ b/regamedll/dlls/util.h @@ -115,23 +115,6 @@ extern globalvars_t *gpGlobals; #define SVC_ROOMTYPE 37 #define SVC_DIRECTOR 51 -// func_rotating -#define SF_BRUSH_ROTATE_Y_AXIS 0 -#define SF_BRUSH_ROTATE_INSTANT 1 -#define SF_BRUSH_ROTATE_BACKWARDS 2 -#define SF_BRUSH_ROTATE_Z_AXIS 4 -#define SF_BRUSH_ROTATE_X_AXIS 8 -#define SF_PENDULUM_AUTO_RETURN 16 -#define SF_PENDULUM_PASSABLE 32 - -#define SF_BRUSH_ROTATE_SMALLRADIUS 128 -#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256 -#define SF_BRUSH_ROTATE_LARGERADIUS 512 - -#define SPAWNFLAG_NOMESSAGE 1 -#define SPAWNFLAG_NOTOUCH 1 -#define SPAWNFLAG_DROIDONLY 4 - #define VEC_HULL_MIN_Z Vector(0, 0, -36) #define VEC_DUCK_HULL_MIN_Z Vector(0, 0, -18) diff --git a/regamedll/extra/cssdk/dlls/bmodels.h b/regamedll/extra/cssdk/dlls/bmodels.h index 83ec4781..d6e948b3 100644 --- a/regamedll/extra/cssdk/dlls/bmodels.h +++ b/regamedll/extra/cssdk/dlls/bmodels.h @@ -27,23 +27,36 @@ */ #pragma once -#define SF_PENDULUM_SWING 2 // spawnflag that makes a pendulum a rope swing. +// func_rotating +#define SF_BRUSH_ROTATE_Y_AXIS 0 +#define SF_BRUSH_ROTATE_INSTANT 1 +#define SF_BRUSH_ROTATE_BACKWARDS 2 +#define SF_BRUSH_ROTATE_Z_AXIS 4 +#define SF_BRUSH_ROTATE_X_AXIS 8 -#define SF_BRUSH_ACCDCC 16 // brush should accelerate and decelerate when toggled -#define SF_BRUSH_HURT 32 // rotating brush that inflicts pain based on rotation speed -#define SF_ROTATING_NOT_SOLID 64 // some special rotating objects are not solid. +#define SF_BRUSH_ACCDCC 16 // brush should accelerate and decelerate when toggled +#define SF_BRUSH_HURT 32 // rotating brush that inflicts pain based on rotation speed -#define SF_WALL_START_OFF 0x0001 +#define SF_ROTATING_NOT_SOLID 64 // some special rotating objects are not solid. -#define SF_CONVEYOR_VISUAL 0x0001 -#define SF_CONVEYOR_NOTSOLID 0x0002 +#define SF_BRUSH_ROTATE_SMALLRADIUS 128 +#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256 +#define SF_BRUSH_ROTATE_LARGERADIUS 512 -#define SF_WORLD_DARK 0x0001 // Fade from black at startup -#define SF_WORLD_TITLE 0x0002 // Display game title at startup -#define SF_WORLD_FORCETEAM 0x0004 // Force teams +#define FANPITCHMIN 30 +#define FANPITCHMAX 100 -#define FANPITCHMIN 30 -#define FANPITCHMAX 100 +// func_pendulum +#define SF_PENDULUM_SWING 2 // spawnflag that makes a pendulum a rope swing. +#define SF_PENDULUM_AUTO_RETURN 16 +#define SF_PENDULUM_PASSABLE 32 + +// func_wall_toggle +#define SF_WALL_START_OFF 0x0001 + +// func_conveyor +#define SF_CONVEYOR_VISUAL 0x0001 +#define SF_CONVEYOR_NOTSOLID 0x0002 // This is just a solid wall if not inhibited class CFuncWall: public CBaseEntity { diff --git a/regamedll/extra/cssdk/dlls/cbase.h b/regamedll/extra/cssdk/dlls/cbase.h index c7852437..af0bed8f 100644 --- a/regamedll/extra/cssdk/dlls/cbase.h +++ b/regamedll/extra/cssdk/dlls/cbase.h @@ -315,6 +315,10 @@ public: string_t m_globalstate; }; +#define SF_WORLD_DARK 0x0001 // Fade from black at startup +#define SF_WORLD_TITLE 0x0002 // Display game title at startup +#define SF_WORLD_FORCETEAM 0x0004 // Force teams + // This spawns first when each level begins. class CWorld: public CBaseEntity { public: diff --git a/regamedll/extra/cssdk/dlls/triggers.h b/regamedll/extra/cssdk/dlls/triggers.h index af790aa9..576b4c3e 100644 --- a/regamedll/extra/cssdk/dlls/triggers.h +++ b/regamedll/extra/cssdk/dlls/triggers.h @@ -30,8 +30,12 @@ #define GRENADETYPE_SMOKE 1 #define GRENADETYPE_FLASH 2 +#define SPAWNFLAG_NOMESSAGE 1 +#define SPAWNFLAG_NOTOUCH 1 +#define SPAWNFLAG_DROIDONLY 4 + #define MAX_ITEM_COUNTS 32 -#define MAX_ENTITY 512 // We can only ever move 512 entities across a transition +#define MAX_ENTITY 512 // We can only ever move 512 entities across a transition // triggers #define SF_TRIGGER_ALLOWMONSTERS 1 // monsters allowed to fire this trigger diff --git a/regamedll/extra/cssdk/dlls/util.h b/regamedll/extra/cssdk/dlls/util.h index 8e36d48f..4eaafbf9 100644 --- a/regamedll/extra/cssdk/dlls/util.h +++ b/regamedll/extra/cssdk/dlls/util.h @@ -79,23 +79,6 @@ extern globalvars_t *gpGlobals; #define SVC_ROOMTYPE 37 #define SVC_DIRECTOR 51 -// func_rotating -#define SF_BRUSH_ROTATE_Y_AXIS 0 -#define SF_BRUSH_ROTATE_INSTANT 1 -#define SF_BRUSH_ROTATE_BACKWARDS 2 -#define SF_BRUSH_ROTATE_Z_AXIS 4 -#define SF_BRUSH_ROTATE_X_AXIS 8 -#define SF_PENDULUM_AUTO_RETURN 16 -#define SF_PENDULUM_PASSABLE 32 - -#define SF_BRUSH_ROTATE_SMALLRADIUS 128 -#define SF_BRUSH_ROTATE_MEDIUMRADIUS 256 -#define SF_BRUSH_ROTATE_LARGERADIUS 512 - -#define SPAWNFLAG_NOMESSAGE 1 -#define SPAWNFLAG_NOTOUCH 1 -#define SPAWNFLAG_DROIDONLY 4 - #define VEC_HULL_MIN_Z Vector(0, 0, -36) #define VEC_DUCK_HULL_MIN_Z Vector(0, 0, -18)