Skip to content

Commit

Permalink
map features + 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)
- robogrunt can use rpg/sniper (shockraid_jungle)
- fix crash precaching an empty string
- allow train to move from/to the same path_corner (hl_u12_a5)
- fix warnings
- hwgrunt stuck in a cover/spinup loop (svencontra2)
- fix ambient_generic direction wrong when far from the world origin
  • Loading branch information
wootguy committed Jan 11, 2025
1 parent fe05d79 commit 0899ddb
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 18 deletions.
4 changes: 4 additions & 0 deletions dlls/env/CAmbientGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ void CAmbientGeneric::Spawn(void)
m_fLooping = m_forceLoop;
}

// prevent sound direction looping around to the other side of the world due to short coordinates
Vector v = pev->origin;
UTIL_SetOrigin(pev, Vector(clampf(v.x, -4095, 4095), clampf(v.y, -4095, 4095), clampf(v.z, -4095, 4095)));

Precache();
}

Expand Down
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/CBaseGrunt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2281,8 +2281,8 @@ Schedule_t* CBaseGrunt::GetShootSchedule(void) {
else
{

if (HasMemory(bits_MEMORY_MOVE_FAILED)) {
// tried and failed to take cover, just shoot
if (HasMemory(bits_MEMORY_MOVE_FAILED) || HasEquipment(MEQUIP_MINIGUN)) {
// tried and failed to take cover, or too slow to take cover, so just shoot
return GetScheduleOfType(SCHED_RANGE_ATTACK1);
}
else {
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
24 changes: 24 additions & 0 deletions dlls/monster/CRoboGrunt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#define GUN_MP5 0
#define GUN_SHOTGUN 1
#define GUN_NONE 2
#define GUN_ROCKETLAUNCHER 3
#define GUN_SNIPERRIFLE 4

#define HGRUNT_9MMAR ( 1 << 0)
#define HGRUNT_HANDGRENADE ( 1 << 1)
Expand Down Expand Up @@ -164,6 +166,22 @@ void CRoboGrunt::Spawn() {
SetBodygroup(GUN_GROUP, GUN_SHOTGUN);
m_cClipSize = 8;
}
else if (FBitSet(pev->weapons, HGRUNT_ROCKETLAUNCHER))
{
SetBodygroup(GUN_GROUP, GUN_ROCKETLAUNCHER);
m_cClipSize = 1;
m_flDistTooFar = 4096.0;
m_flDistLook = 4096.0;
maxShootDist = 4096;
}
else if (m_iEquipment & MEQUIP_SNIPER)
{
SetBodygroup(GUN_GROUP, GUN_SNIPERRIFLE);
m_cClipSize = 1;
m_flDistTooFar = 4096.0;
m_flDistLook = 4096.0;
maxShootDist = 4096;
}
else
{
m_cClipSize = GRUNT_CLIP_SIZE;
Expand Down Expand Up @@ -200,6 +218,12 @@ void CRoboGrunt::Precache()
if (FBitSet(pev->weapons, HGRUNT_GRENADELAUNCHER)) {
m_iEquipment |= MEQUIP_GRENADE_LAUNCHER;
}
if (FBitSet(pev->weapons, HGRUNT_ROCKETLAUNCHER)) {
m_iEquipment |= MEQUIP_RPG;
}
if (FBitSet(pev->weapons, HGRUNT_SNIPERRIFLE)) {
m_iEquipment |= MEQUIP_SNIPER;
}

BasePrecache();

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
12 changes: 12 additions & 0 deletions dlls/util/eng_wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ int PRECACHE_GENERIC(const char* path) {
return -1;
}

if (!path || !path[0]) {
return -1;
}

g_tryPrecacheGeneric.insert(path);

if (g_tryPrecacheGeneric.size() < MAX_PRECACHE) {
Expand Down Expand Up @@ -234,6 +238,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 Expand Up @@ -435,6 +443,10 @@ int PRECACHE_MODEL_ENT(CBaseEntity* ent, const char* path) {
}
}

if (!path || !path[0]) {
return g_engfuncs.pfnPrecacheModel(NOT_PRECACHED_MODEL);
}

g_tryPrecacheModels.insert(path);

// Tested with sc_darknebula.
Expand Down
2 changes: 1 addition & 1 deletion rehlds

0 comments on commit 0899ddb

Please sign in to comment.