Skip to content

Commit

Permalink
Merge branch 'FireTargets-features'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikk155 committed Mar 15, 2024
2 parents 6b98108 + 28af3cc commit 64de7f7
Show file tree
Hide file tree
Showing 20 changed files with 272 additions and 29 deletions.
75 changes: 75 additions & 0 deletions src/game/server/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"files.associations": {
"chrono": "cpp",
"functional": "cpp",
"optional": "cpp",
"regex": "cpp",
"system_error": "cpp",
"type_traits": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xtr1common": "cpp",
"algorithm": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"format": "cpp",
"forward_list": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"list": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"string": "cpp",
"thread": "cpp",
"tuple": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"utility": "cpp",
"vector": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtree": "cpp",
"xutility": "cpp"
}
}
20 changes: 19 additions & 1 deletion src/game/server/entities/CBaseEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,25 @@ struct ReplacementMap;
// UNDONE: This will ignore transition volumes (trigger_transition), but not the PVS!!!
#define FCAP_FORCE_TRANSITION 0x00000080 // ALWAYS goes across transitions

#define USE_VALUE_USE ( 1 << 0 )
#define USE_VALUE_TOUCH ( 1 << 1 )
#define USE_VALUE_MASTER ( 1 << 2 )
#define USE_VALUE_THINK ( 1 << 3 )

enum USE_TYPE : int
{
USE_UNSET = -1,
USE_OFF = 0,
USE_ON = 1,
USE_SET = 2,
USE_TOGGLE = 3
USE_TOGGLE = 3,
USE_KILL = 4,
USE_SAME = 5,
USE_OPPOSITE = 6,
USE_TOUCH = 7,
USE_LOCK = 8,
USE_UNLOCK = 9,
USE_UNKNOWN = 10
};

// people gib if their health is <= this at the time of death
Expand Down Expand Up @@ -627,6 +640,11 @@ class SINGLE_INHERITANCE CBaseEntity
* @details The entity's angles affect this offset.
*/
Vector m_SoundOffset{};

USE_TYPE m_UseType = USE_UNSET;
USE_TYPE m_UseTypeLast = USE_UNSET;
float m_UseValue;
int m_UseLocked;
};

inline bool FNullEnt(CBaseEntity* ent) { return (ent == nullptr) || FNullEnt(ent->edict()); }
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/entities/CBaseTrigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void CBaseTrigger::ActivateMultiTrigger(CBaseEntity* pActivator)
if (pev->nextthink > gpGlobals->time)
return; // still waiting for reset time

if (!UTIL_IsMasterTriggered(m_sMaster, pActivator))
if (!UTIL_IsMasterTriggered(m_sMaster, pActivator,m_UseLocked))
return;

if (!FStringNull(pev->noise))
Expand Down
6 changes: 3 additions & 3 deletions src/game/server/entities/buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ void CBaseButton::ButtonTouch(CBaseEntity* pOther)
if (code == BUTTON_NOTHING)
return;

if (!UTIL_IsMasterTriggered(m_sMaster, pOther))
if (!UTIL_IsMasterTriggered(m_sMaster, pOther, m_UseLocked))
{
// play button locked sound
PlayLockSounds(this, &m_ls, true, true);
Expand All @@ -544,7 +544,7 @@ void CBaseButton::ButtonActivate()
{
EmitSound(CHAN_VOICE, STRING(m_sounds), 1, ATTN_NORM);

if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator))
if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator, m_UseLocked))
{
// button is locked, play locked sound
PlayLockSounds(this, &m_ls, true, true);
Expand All @@ -570,7 +570,7 @@ void CBaseButton::TriggerAndWait()
{
ASSERT(m_toggle_state == TS_GOING_UP);

if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator))
if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator, m_UseLocked))
return;

m_toggle_state = TS_AT_TOP;
Expand Down
18 changes: 14 additions & 4 deletions src/game/server/entities/cbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void DispatchTouch(edict_t* pentTouched, edict_t* pentOther)
CBaseEntity* pEntity = (CBaseEntity*)GET_PRIVATE(pentTouched);
CBaseEntity* pOther = (CBaseEntity*)GET_PRIVATE(pentOther);

if (pEntity && pOther && ((pEntity->pev->flags | pOther->pev->flags) & FL_KILLME) == 0)
if( pEntity && pOther && ( (pEntity->pev->flags | pOther->pev->flags) & FL_KILLME) == 0 && !FBitSet( pEntity->m_UseLocked, USE_VALUE_TOUCH ) )
pEntity->Touch(pOther);
}

Expand All @@ -184,14 +184,14 @@ void DispatchUse(edict_t* pentUsed, edict_t* pentOther)
CBaseEntity* pEntity = (CBaseEntity*)GET_PRIVATE(pentUsed);
CBaseEntity* pOther = (CBaseEntity*)GET_PRIVATE(pentOther);

if (pEntity && (pEntity->pev->flags & FL_KILLME) == 0)
if (pEntity && (pEntity->pev->flags & FL_KILLME) == 0 && !FBitSet( pEntity->m_UseLocked, USE_VALUE_USE ) )
pEntity->Use(pOther, pOther, USE_TOGGLE, 0);
}

void DispatchThink(edict_t* pent)
{
CBaseEntity* pEntity = (CBaseEntity*)GET_PRIVATE(pent);
if (pEntity)
if( pEntity && !FBitSet( pEntity->m_UseLocked, USE_VALUE_THINK ) )
{
if (FBitSet(pEntity->pev->flags, FL_DORMANT))
CBaseEntity::Logger->error("Dormant entity {} is thinking!!", STRING(pEntity->pev->classname));
Expand Down Expand Up @@ -598,6 +598,16 @@ bool CBaseEntity::RequiredKeyValue(KeyValueData* pkvd)

return true;
}
else if( FStrEq( pkvd->szKeyName, "m_UseType" ) && atoi( pkvd->szValue ) > USE_UNSET && atoi( pkvd->szValue ) < USE_UNKNOWN )
{
m_UseType = static_cast<USE_TYPE>( atoi( pkvd->szValue ) );
return true;
}
else if( FStrEq( pkvd->szKeyName, "m_UseValue" ) )
{
m_UseValue = atof( pkvd->szValue );
return true;
}

return false;
}
Expand Down Expand Up @@ -820,7 +830,7 @@ bool CBaseEntity::IsDormant()

bool CBaseEntity::IsLockedByMaster()
{
return !FStringNull(m_sMaster) && !UTIL_IsMasterTriggered(m_sMaster, m_hActivator);
return !FStringNull(m_sMaster) && !UTIL_IsMasterTriggered(m_sMaster, m_hActivator, m_UseLocked);
}

bool CBaseEntity::IsInWorld()
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/entities/changelevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void CTriggerSave::Spawn()

void CTriggerSave::SaveTouch(CBaseEntity* pOther)
{
if (!UTIL_IsMasterTriggered(m_sMaster, pOther))
if (!UTIL_IsMasterTriggered(m_sMaster, pOther, m_UseLocked))
return;

// Only save on clients
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/entities/ctf/CHUDIconTrigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void CHUDIconTrigger::Spawn()

void CHUDIconTrigger::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value)
{
if (m_flNextActiveTime <= gpGlobals->time && UTIL_IsMasterTriggered(m_sMaster, pActivator))
if (m_flNextActiveTime <= gpGlobals->time && UTIL_IsMasterTriggered(m_sMaster, pActivator, m_UseLocked))
{
if (!FStringNull(pev->noise))
EmitSound(CHAN_VOICE, STRING(pev->noise), VOL_NORM, ATTN_NORM);
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/entities/ctf/CTFSpawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ bool CTFSpawn::IsTriggered(CBaseEntity* pEntity)
if (!FStringNull(pev->targetname) && STRING(pev->targetname))
return m_fState;
else
return UTIL_IsMasterTriggered(m_sMaster, pEntity);
return UTIL_IsMasterTriggered(m_sMaster, pEntity, m_UseLocked);
}
4 changes: 2 additions & 2 deletions src/game/server/entities/doors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ void CBaseDoor::DoorTouch(CBaseEntity* pOther)
// If door has master, and it's not ready to trigger,
// play 'locked' sound

if (!FStringNull(m_sMaster) && !UTIL_IsMasterTriggered(m_sMaster, pOther))
if (!FStringNull(m_sMaster) && !UTIL_IsMasterTriggered(m_sMaster, pOther, m_UseLocked))
PlayLockSounds(this, &m_ls, true, false);

// If door is somebody's target, then touching does nothing.
Expand Down Expand Up @@ -371,7 +371,7 @@ void CBaseDoor::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useT

bool CBaseDoor::DoorActivate()
{
if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator))
if (!UTIL_IsMasterTriggered(m_sMaster, m_hActivator, m_UseLocked))
return false;

if (FBitSet(pev->spawnflags, SF_DOOR_NO_AUTO_RETURN) && m_toggle_state == TS_AT_TOP)
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/entities/func_tank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ bool CFuncTank::StartControl(CBasePlayer* pController)
// Team only or disabled?
if (!FStringNull(m_sMaster))
{
if (!UTIL_IsMasterTriggered(m_sMaster, pController))
if (!UTIL_IsMasterTriggered(m_sMaster, pController, m_UseLocked))
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/server/entities/items/chargers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void CBaseCharger::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE u
CheckIfOutOfCharge(true);

// if the player doesn't have the suit, or there is no juice left, or the master isn't active, make the deny noise
if (!UTIL_IsMasterTriggered(m_sMaster, player) ||
if (!UTIL_IsMasterTriggered(m_sMaster, player, m_UseLocked) ||
(m_Juice != UnlimitedJuice && m_Juice <= 0) ||
!player->HasSuit())
{
Expand Down
8 changes: 4 additions & 4 deletions src/game/server/entities/logic_entities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool CLogicSetCVar::KeyValue(KeyValueData* pkvd)

void CLogicSetCVar::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value)
{
if (!UTIL_IsMasterTriggered(m_sMaster, pActivator))
if (!UTIL_IsMasterTriggered(m_sMaster, pActivator, m_UseLocked))
{
return;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ bool CLogicIsSkill::KeyValue(KeyValueData* pkvd)

void CLogicIsSkill::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value)
{
if (!UTIL_IsMasterTriggered(m_sMaster, pActivator))
if (!UTIL_IsMasterTriggered(m_sMaster, pActivator, m_UseLocked))
{
return;
}
Expand Down Expand Up @@ -217,7 +217,7 @@ void CLogicSetSkill::Spawn()

void CLogicSetSkill::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value)
{
if (!UTIL_IsMasterTriggered(m_sMaster, pActivator))
if (!UTIL_IsMasterTriggered(m_sMaster, pActivator, m_UseLocked))
{
return;
}
Expand Down Expand Up @@ -279,7 +279,7 @@ void CLogicSetSkillVar::Spawn()

void CLogicSetSkillVar::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value)
{
if (!UTIL_IsMasterTriggered(m_sMaster, pActivator))
if (!UTIL_IsMasterTriggered(m_sMaster, pActivator, m_UseLocked))
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/entities/maprules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bool CRuleEntity::CanFireForActivator(CBaseEntity* pActivator)
{
if (!FStringNull(m_sMaster))
{
if (UTIL_IsMasterTriggered(m_sMaster, pActivator))
if (UTIL_IsMasterTriggered(m_sMaster, pActivator, m_UseLocked))
return true;
else
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/game/server/entities/spawnpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LINK_ENTITY_TO_CLASS(info_player_deathmatch, CBaseDMStart);

bool CBaseDMStart::IsTriggered(CBaseEntity* pEntity)
{
return UTIL_IsMasterTriggered(m_sMaster, pEntity);
return UTIL_IsMasterTriggered(m_sMaster, pEntity, m_UseLocked);
}

/**
Expand Down
Loading

0 comments on commit 64de7f7

Please sign in to comment.