Skip to content

Commit

Permalink
+use fixes
Browse files Browse the repository at this point in the history
regressions from the antiblock change

- pushables not being liftable
- extra use sound on trains/momentary buttons
- not able to use momentaries by holding use before being in range

toggled entities will be used when the hold expires. The old behavior was confusing on sc_tombofdeath_v12-2 because there's a valve that looks like something you hold use on, but holding use plays the error beep.
  • Loading branch information
wootguy committed Dec 18, 2024
1 parent 5198563 commit 1d5bad5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
7 changes: 4 additions & 3 deletions dlls/func/CPushable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,12 @@ void CPushable::Use(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useT
return;
}

if (pev->spawnflags & SF_PUSH_LIFTABLE) {
CBasePlayer* plr = pActivator->MyPlayerPointer();

if (plr && (pev->spawnflags & SF_PUSH_LIFTABLE)) {
int eidx = pActivator->entindex() % 32;
CBasePlayer* plr = (CBasePlayer*)pActivator;
bool isMoving = plr->pev->button & (IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT);
bool releasedUseKey = value == 0;
bool releasedUseKey = plr->m_afButtonReleased & IN_USE;
bool notHoldingOtherPushable = !plr->m_pPushable || plr->m_pPushable.GetEntity() == this;
bool wasMovingWithUse = m_ignoreLiftUse[eidx] || isMoving;
bool isCurrentLifter = m_hLifter.GetEntity() == plr;
Expand Down
6 changes: 1 addition & 5 deletions dlls/hooks/client_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,8 @@ bool Q_UnicodeValidate(const char* pUTF8)
//
void Host_Say(edict_t* pEntity, int teamonly)
{
CBasePlayer* client;
int j;
char* p;
char szTemp[256];
const char* cpSay = "say";
const char* cpSayTeam = "say_team";
const char* pcmd = CMD_ARGV(0);

// We can get a raw string now, without the "say " prepended
Expand All @@ -159,7 +155,7 @@ void Host_Say(edict_t* pEntity, int teamonly)
if (player->m_flNextChatTime > gpGlobals->time)
return;

if (!stricmp(pcmd, cpSay) || !stricmp(pcmd, cpSayTeam))
if (!stricmp(pcmd, "say") || !stricmp(pcmd, "say_team"))
{
if (CMD_ARGC() >= 2)
{
Expand Down
33 changes: 14 additions & 19 deletions dlls/player/CBasePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1745,10 +1745,6 @@ void CBasePlayer::PlayerUse ( void )
{
CALL_HOOKS_VOID(pfnPlayerUse, this);

if (m_useExpired) {
return;
}

if ( IsObserver() )
return;

Expand Down Expand Up @@ -1780,6 +1776,8 @@ void CBasePlayer::PlayerUse ( void )
if (pTrain && (pTrain->Classify() == CLASS_VEHICLE))
((CFuncVehicle*)pTrain)->m_pDriver = NULL;

m_useExpired = true;

return;
}
else
Expand All @@ -1802,6 +1800,9 @@ void CBasePlayer::PlayerUse ( void )
}
else
EMIT_SOUND(ENT(pev), CHAN_ITEM, "plats/train_use1.wav", 0.8, ATTN_NORM);

m_useExpired = true;

return;
}
}
Expand Down Expand Up @@ -1876,7 +1877,7 @@ void CBasePlayer::PlayerUse ( void )
bool useExpiring = (mp_antiblock.value && GetUseTime() > MAX_USE_HOLD_TIME)
|| (!mp_antiblock.value && (m_afButtonPressed & IN_USE));

if (useExpiring && mp_antiblock.value && (!m_usingMomentary || pLooking->IsPlayer())) {
if (!m_useExpired && useExpiring && mp_antiblock.value && (!m_usingMomentary || pLooking->IsPlayer())) {
int antiblockRet = TryAntiBlock();

if (antiblockRet) {
Expand All @@ -1898,20 +1899,21 @@ void CBasePlayer::PlayerUse ( void )
//!!!UNDONE: traceline here to prevent USEing buttons through walls
int caps = pObject->ObjectCaps();
bool isContinuousUse = (pev->button & IN_USE) && (caps & FCAP_CONTINUOUS_USE);

bool shouldToggle = (m_afButtonReleased & IN_USE) || useExpiring;

// if antiblock is enabled, don't trigger things until the button is released
// because the player might be holding it down for an antiblock attempt
bool isToggleUse;
if (mp_antiblock.value) {
isToggleUse = (m_afButtonReleased & IN_USE) && (caps & (FCAP_IMPULSE_USE | FCAP_ONOFF_USE));
isToggleUse = shouldToggle && (caps & (FCAP_IMPULSE_USE | FCAP_ONOFF_USE));
}
else {
isToggleUse = (m_afButtonPressed & IN_USE) && (caps & (FCAP_IMPULSE_USE | FCAP_ONOFF_USE));
isToggleUse = shouldToggle && (caps & (FCAP_IMPULSE_USE | FCAP_ONOFF_USE));
}

if (isContinuousUse || isToggleUse)
if (isContinuousUse || (isToggleUse && !m_useExpired))
{
if (isToggleUse || ((m_afButtonPressed & IN_USE) && isContinuousUse))
if ((isToggleUse || ((m_afButtonPressed & IN_USE) && isContinuousUse)) && !m_usingMomentary)
EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/wpn_select.wav", 0.4, ATTN_NORM);

if (isToggleUse) {
Expand All @@ -1926,22 +1928,15 @@ void CBasePlayer::PlayerUse ( void )

pObject->Use( this, this, USE_SET, 1 );

return;
}
// UNDONE: Send different USE codes for ON/OFF. Cache last ONOFF_USE object to send 'off' if you turn away
else if ((m_afButtonReleased & IN_USE) && (pObject->ObjectCaps() & FCAP_ONOFF_USE) ) // BUGBUG This is an "off" use
{
pObject->Use( this, this, USE_SET, 0 );
m_useExpired = true;

return;
}
}

// nothing has been activated within the use time limit, cancel use and don't consider any more
// uses until the next key press
if (useExpiring || (m_afButtonReleased & IN_USE)) {
EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/wpn_denyselect.wav", 0.8, ATTN_NORM);
if (!m_usingMomentary && !m_useExpired)
EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/wpn_denyselect.wav", 0.8, ATTN_NORM);
m_useExpired = true; // don't consider any more uses until the button is pressed again
}
}
Expand Down
2 changes: 1 addition & 1 deletion rehlds
Submodule rehlds updated 1 files
+14 −11 rehlds/engine/world.cpp

0 comments on commit 1d5bad5

Please sign in to comment.