Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
- repelling grunts fly away if landing on a slope
- server-side model event sounds not precached for playback
- trigger_cdaudio not playing for all players nor new joiners
- scripted_sequence crash
- possibly fix crash with player item updates
- possibly fix barnacle not always animating when killed
  • Loading branch information
wootguy committed Dec 4, 2024
1 parent 19f6488 commit d7602cb
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 37 deletions.
3 changes: 3 additions & 0 deletions dlls/CBaseEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,9 @@ bool CBaseEntity::RunInventoryRules(CBaseEntity* ent) {

void CBaseEntity::ParametricInterpolation(float flInterval) {

// A trace is done so that the client doesn't predict a projectile sliding across a wall
// (try removing this and firing the crossbow up towards a wall, it will start angling
// upward as it approaches the impact point).
TraceResult tr;
UTIL_TraceLine(pev->origin, pev->origin + pev->velocity, ignore_monsters, NULL, &tr);

Expand Down
6 changes: 3 additions & 3 deletions dlls/monster/CBarnacle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void CBarnacle :: BarnacleThink ( void )

// ALERT( at_console, "tounge %f\n", m_flAltitude + m_flTongueAdj );
SetBoneController( 0, -(m_flAltitude + m_flTongueAdj) );
StudioFrameAdvance( 0.1 );
StudioFrameAdvance();
}

//=========================================================
Expand Down Expand Up @@ -365,7 +365,7 @@ void CBarnacle :: Killed( entvars_t *pevAttacker, int iGib )
SetActivity ( ACT_DIESIMPLE );
SetBoneController( 0, 0 );

StudioFrameAdvance( 0.1 );
StudioFrameAdvance();

pev->nextthink = gpGlobals->time + 0.1;
SetThink ( &CBarnacle::WaitTillDead );
Expand All @@ -377,7 +377,7 @@ void CBarnacle :: WaitTillDead ( void )
{
pev->nextthink = gpGlobals->time + 0.1;

float flInterval = StudioFrameAdvance( 0.1 );
float flInterval = StudioFrameAdvance();
DispatchAnimEvents ( flInterval );
UpdateShockEffect();

Expand Down
6 changes: 4 additions & 2 deletions dlls/monster/CBaseGrunt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ void CBaseGrunt::ShootRPG(Vector& vecShootOrigin, Vector& vecShootDir) {
m_occludeTime = 0;
}

if (!m_aimingRocket && !m_cAmmoLoaded || (m_occludeTime && gpGlobals->time - m_occludeTime > 2.0f)) {
if ((!m_aimingRocket && !m_cAmmoLoaded) || (m_occludeTime && gpGlobals->time - m_occludeTime > 2.0f)) {
SetActivity(ACT_IDLE_ANGRY);
TaskFail();
}
Expand Down Expand Up @@ -2516,6 +2516,8 @@ Schedule_t *CBaseGrunt :: GetSchedule( void )
{
// just landed
pev->movetype = MOVETYPE_STEP;
pev->gravity = 0;
pev->friction = 0;
return GetScheduleOfType(SCHED_GRUNT_REPEL_LAND);
}
else
Expand Down Expand Up @@ -2858,7 +2860,7 @@ void CBaseRepel::RepelUse(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYP
// FLY movetype but with client interpolation
pGrunt->pev->movetype = MOVETYPE_BOUNCE;
pGrunt->pev->gravity = FLT_MIN;
pGrunt->pev->friction = 1.0f;
pGrunt->pev->friction = 2.0f; // don't fly away if landing on a slope

pGrunt->pev->velocity = Vector(0, 0, RANDOM_FLOAT(-196, -128));
pGrunt->SetActivity(ACT_GLIDE);
Expand Down
30 changes: 22 additions & 8 deletions dlls/monster/CBaseMonster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5229,7 +5229,10 @@ BOOL CBaseMonster::FScheduleDone(void)
//=========================================================
void CBaseMonster::ChangeSchedule(Schedule_t* pNewSchedule)
{
ASSERT(pNewSchedule != NULL);
if (!pNewSchedule) {
ALERT(at_console, "Attempted to change to NULL schedule\n");
return;
}

m_pSchedule = pNewSchedule;
m_iScheduleIndex = 0;
Expand Down Expand Up @@ -5430,13 +5433,18 @@ void CBaseMonster::MaintainSchedule(void)
{
Task_t* pTask = GetTask();
ASSERT(pTask != NULL);
TaskBegin();
#ifdef DEBUG_MONSTER
if (FClassnameIs(pev, DEBUG_MONSTER)) {
ALERT(at_console, " Start Task %s with data %f\n", GetTaskName(pTask->iTask), pTask->flData);
if (pTask) {
TaskBegin();
#ifdef DEBUG_MONSTER
if (FClassnameIs(pev, DEBUG_MONSTER)) {
ALERT(at_console, " Start Task %s with data %f\n", GetTaskName(pTask->iTask), pTask->flData);
}
#endif
StartTask(pTask);
}
else {
ALERT(at_console, "Monster %s has NULL task\n", STRING(pev->classname));
}
#endif
StartTask(pTask);
}

// UNDONE: Twice?!!!
Expand All @@ -5453,7 +5461,13 @@ void CBaseMonster::MaintainSchedule(void)
{
Task_t* pTask = GetTask();
ASSERT(pTask != NULL);
RunTask(pTask);
if (pTask) {
RunTask(pTask);
}
else {
ALERT(at_console, "Failed to run NULL task for %s (%s)\n",
STRING(pev->targetname), STRING(pev->classname));
}
}

// UNDONE: We have to do this so that we have an animation set to blend to if RunTask changes the animation
Expand Down
2 changes: 2 additions & 0 deletions dlls/monster/CShockTrooper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1907,6 +1907,8 @@ Schedule_t* CShockTrooper::GetSchedule()
{
// just landed
pev->movetype = MOVETYPE_STEP;
pev->gravity = 0;
pev->friction = 0;
return GetScheduleOfType(SCHED_GRUNT_REPEL_LAND);
}
else
Expand Down
6 changes: 4 additions & 2 deletions dlls/player/CBasePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4550,8 +4550,10 @@ void CBasePlayer :: UpdateClientData( void )
// Update all the items
for ( int i = 0; i < MAX_ITEM_TYPES; i++ )
{
if ( m_rgpPlayerItems[i] ) // each item updates it's successors
((CBasePlayerItem*)m_rgpPlayerItems[i].GetEntity())->UpdateClientData(this);
CBaseEntity* ent = m_rgpPlayerItems[i].GetEntity();
CBasePlayerItem* item = ent ? ent->GetWeaponPtr() : NULL;
if (item) // each item updates it's successors
item->UpdateClientData(this);
}

// Cache and client weapon change
Expand Down
10 changes: 8 additions & 2 deletions dlls/util/eng_wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,14 @@ void PRECACHE_MODEL_EXTRAS(const char* path, studiohdr_t* mdl) {
if (opt[0] == '*')
opt = opt.substr(1); // not sure why some models do this, it looks pointless.

// model sounds are loaded on demand, not precached
PRECACHE_GENERIC(STRING(ALLOC_STRING(normalize_path("sound/" + opt).c_str())));
if (evt->event == 5004) {
// sound is loaded by the client on-demand
PRECACHE_GENERIC(STRING(ALLOC_STRING(normalize_path("sound/" + opt).c_str())));
}
else {
// sound is played by the server
PRECACHE_SOUND_ENT(NULL, STRING(ALLOC_STRING(opt.c_str())));
}
}
if (evt->event == 5001 || evt->event == 5011 || evt->event == 5021 || evt->event == 5031) { // muzzleflash sprite
PRECACHE_GENERIC(STRING(ALLOC_STRING(normalize_path(opt).c_str())));
Expand Down
35 changes: 16 additions & 19 deletions dlls/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,10 +1147,10 @@ void UTIL_PlayGlobalMp3(const char* path, bool loop, edict_t* target) {
// surround with ; to prevent multiple commands being joined when sent in the same frame(?)
// this fixes music sometimes not loading/starting/stopping
std::string mp3Path = normalize_path(UTIL_VarArgs("sound/%s", path));
std::string mp3Command = UTIL_VarArgs(";mp3 %s %s;", (loop ? "loop" : "play"), mp3Path.c_str());
std::string mp3Command = UTIL_VarArgs("mp3 %s %s", (loop ? "loop" : "play"), mp3Path.c_str());

MESSAGE_BEGIN(target ? MSG_ONE : MSG_ALL, SVC_STUFFTEXT, NULL, target);
WRITE_STRING(mp3Command.c_str());
WRITE_STRING((mp3Command + "\n").c_str());
MESSAGE_END();

if (!target) {
Expand All @@ -1160,16 +1160,15 @@ void UTIL_PlayGlobalMp3(const char* path, bool loop, edict_t* target) {
}

void UTIL_StopGlobalMp3(edict_t* target) {
const char* cmd = ";mp3 stop;";

MESSAGE_BEGIN(target ? MSG_ONE : MSG_ALL, SVC_STUFFTEXT, NULL, target);
WRITE_STRING(cmd);
WRITE_STRING("mp3 stop\n");
//WRITE_STRING(";cd fadeout;"); // blocked by cl_filterstuffcmd
MESSAGE_END();

if (!target) {
g_mp3Command = "";
ALERT(at_console, "MP3 Command: '%s'\n", cmd);
ALERT(at_console, "MP3 Command: 'mp3 stop'\n");
}
}

Expand Down Expand Up @@ -2857,32 +2856,30 @@ Vector VecBModelOrigin(entvars_t* pevBModel)

void PlayCDTrack(int iTrack)
{
edict_t* pClient;

// manually find the single player.
pClient = g_engfuncs.pfnPEntityOfEntIndex(1);

// Can't play if the client is not connected!
if (!pClient)
return;

if (iTrack < -1 || iTrack > 30)
{
ALERT(at_console, "TriggerCDAudio - Track %d out of range\n");
return;
}

std::string cdCommand = "";

if (iTrack == -1)
{
CLIENT_COMMAND(pClient, "cd stop\n");
cdCommand = "cd stop";
g_mp3Command = "";
}
else
{
char string[64];

snprintf(string, 64, "cd play %3d\n", iTrack);
CLIENT_COMMAND(pClient, string);
cdCommand = UTIL_VarArgs("cd play %d", iTrack);
g_mp3Command = cdCommand; // play for new joiners later
}

MESSAGE_BEGIN(MSG_ALL, SVC_STUFFTEXT);
WRITE_STRING((cdCommand + "\n").c_str());
MESSAGE_END();

ALERT(at_console, "CD Command: '%s'\n", cdCommand.c_str());
}

std::string sanitize_cvar_value(std::string val) {
Expand Down
1 change: 0 additions & 1 deletion dlls/weapon/CRpg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ void CRpgRocket :: FollowThink( void )

float bestDot = -1.0f;
float bestDist = FLT_MAX;
Vector bestDir = vecTarget;

// Examine all entities within a reasonable radius
while ((pOther = UTIL_FindEntityByClassname( pOther, "laser_spot" )) != NULL)
Expand Down

0 comments on commit d7602cb

Please sign in to comment.