Skip to content

Commit

Permalink
add fog distance override flag + map fixes
Browse files Browse the repository at this point in the history
- add flag to override env_fog distance adjustment for special cases (mystic_radar_v1)
- fix crash precaching an empty string
- allow train to move from/to the same path_corner (hl_u12_a5)
- fix warnings
  • Loading branch information
wootguy committed Jan 11, 2025
1 parent fe05d79 commit e7de549
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
16 changes: 14 additions & 2 deletions dlls/env/CEnvWeather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@

#define SF_WEATHER_START_OFF 1

// don't auto adjust fog minimum distance, for when you're sure that there will be no issues
// with transparent entities in the map (for instance if fog is only active during a cutscene,
// or if there is no way for a player to move fast from longjumps or falling).
#define SF_WEATHER_FOG_NO_ADJUST 1024

extern "C" uint32_t g_fog_palette[61][256];
extern "C" int g_fog_skins;

Expand Down Expand Up @@ -678,8 +683,15 @@ void CEnvWeather::Spawn(void)
int newMax = V_max(newMin + 100, m_fogEndDist); // fog won't look nice if too compacted

if (newMin > m_fogStartDist || newMax > m_fogEndDist) {
ALERT(at_console, "env_weather: fog distance increased to prevent rendering errors. [%d - %d] -> [%d - %d]\n",
m_fogStartDist, m_fogEndDist, newMin, newMax);
if (pev->spawnflags & SF_WEATHER_FOG_NO_ADJUST) {
newMin = m_fogStartDist;
newMax = m_fogEndDist;
ALERT(at_console, "env_weather: fog distance adjustment disabled via flag. Rendering errors may occur.\n");
}
else {
ALERT(at_console, "env_weather: fog distance increased to prevent rendering errors. [%d - %d] -> [%d - %d]\n",
m_fogStartDist, m_fogEndDist, newMin, newMax);
}
}

m_fogStartDist = newMin;
Expand Down
8 changes: 6 additions & 2 deletions dlls/func/CFuncTrain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CFuncTrain : public CBasePlatTrain
static TYPEDESCRIPTION m_SaveData[];

entvars_t* m_pevCurrentTarget;
EHANDLE m_previousTarget;
int m_sounds;
int m_activated; // 0 = never activated, 1 = activated, 2 = toggled off after activate
};
Expand Down Expand Up @@ -161,8 +162,10 @@ void CFuncTrain::Next(void)
return;
}

if (m_activated != 2 && ENT(m_pevCurrentTarget) == pTarg->edict()) {
return; // prevent infinite recursion

edict_t* prevTarg = m_previousTarget.GetEdict();
if (prevTarg == ENT(m_pevCurrentTarget) && prevTarg == pTarg->edict()) {
return; // prevent infinite recursion (path_corner targeting itself with no distance to move)
}

// Save last target in case we need to find it again
Expand All @@ -176,6 +179,7 @@ void CFuncTrain::Next(void)
pev->speed = m_pevCurrentTarget->speed;
ALERT(at_aiconsole, "Train %s speed to %4.2f\n", STRING(pev->targetname), pev->speed);
}
m_previousTarget = ENT(m_pevCurrentTarget);
m_pevCurrentTarget = pTarg->pev;// keep track of this since path corners change our target for us.

pev->enemy = pTarg->edict();//hack
Expand Down
4 changes: 2 additions & 2 deletions dlls/monster/CBaseMonster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3032,10 +3032,10 @@ void CBaseMonster::HandleAnimEvent(MonsterEvent_t* pEvent)
if (flash.sprite) {
Vector origin, angles;

if (flash.attachment != -1) {
if (flash.attachment != (uint8_t)-1) {
GetAttachment(flash.attachment, origin, angles);
}
else if (flash.bone != -1) {
else if (flash.bone != (uint8_t)-1) {
GetBonePosition(flash.bone, origin, angles);
origin = origin + flash.offset;
}
Expand Down
8 changes: 0 additions & 8 deletions dlls/player/CBasePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4679,12 +4679,6 @@ void CBasePlayer :: UpdateClientData( void )
if ( !II->iId )
continue;

const char *pszName;
if (!II->pszName)
pszName = "Empty";
else
pszName = II->pszName;

MESSAGE_BEGIN(MSG_ONE, gmsgWeaponList, NULL, pev);
WRITE_STRING(II->pszName); // string weapon name
WRITE_BYTE(GetAmmoIndex(II->pszAmmo1)); // byte Ammo Type
Expand Down Expand Up @@ -6427,8 +6421,6 @@ void CBasePlayer::ResolveWeaponSlotConflict(int wepId) {
int CBasePlayer::GetCurrentIdForConflictedSlot(int wepId) {
int mask = g_weaponSlotMasks[wepId];

ItemInfo& II = CBasePlayerItem::ItemInfoArray[wepId];

if (count_bits_set(mask) <= 1) {
return wepId; // impossible for there to be a conflict
}
Expand Down
1 change: 0 additions & 1 deletion dlls/triggers/CBaseTrigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ void CBaseTrigger::ActivateMultiTrigger(CBaseEntity* pActivator, bool isUntouch)
else if (pev->spawnflags & (SF_TRIGGER_FIRE_ON_ENTER | SF_TRIGGER_FIRE_ON_EXIT)) {
int emptySlot = -1;

bool alreadyTouching = false;
for (int i = 0; i < MAX_TOUCHERS; i++) {
if (m_touchers[i].GetEntity() == pActivator) {
return;
Expand Down
4 changes: 4 additions & 0 deletions dlls/util/eng_wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ int PRECACHE_SOUND_ENT(CBaseEntity* ent, const char* path) {
}
}

if (!path || !path[0]) {
return g_engfuncs.pfnPrecacheSound(NOT_PRECACHED_SOUND);
}

g_tryPrecacheSounds.insert(path);

if (g_tryPrecacheSounds.size() <= MAX_PRECACHE_SOUND) {
Expand Down

0 comments on commit e7de549

Please sign in to comment.