diff --git a/platform/cvars.cfg b/platform/cvars.cfg index 3e005249..ab3926da 100644 --- a/platform/cvars.cfg +++ b/platform/cvars.cfg @@ -35,6 +35,7 @@ seta net_showUpdates 0 // Enable/disable console prints about entity updates. // game console variables seta g_gravity 800 // Global gravity setting, in unit per second. seta g_mapCycle "mapcycle.txt" // Map cycle file for multiplayer games. +seta g_developer 0 // Prints game-logic specific debug messages when 1. // input console variables seta in_zoomSensitivity 1.0 // Mouse sensitivity multiplier for when we're using the +zoomin command. @@ -69,6 +70,8 @@ seta xr_roomScale 1.0 // Scales world<>game translation. seta xr_viewHeight -48.0 // Specifies the head offset when in XR mode. seta xr_testInputs 0 // Send faux XR input signals when enabled. +seta s_developer 0 // Prints sound-logic specific debug messages when 1. + // aliases for the older commands (may be removed some day) alias cl_autojump pm_autoJump alias cl_showfps com_showFPS diff --git a/src/shared/NSEntity.qc b/src/shared/NSEntity.qc index d9fd198c..adfe9253 100644 --- a/src/shared/NSEntity.qc +++ b/src/shared/NSEntity.qc @@ -949,21 +949,24 @@ bool NSEntity::StartSound( string strSample, float channel, float flags, bool br return ( false ); if ( broadcast ) { - sound( this, channel, strSample, 1.0, ATTN_NORM ); + sound( this, channel, strSample, 1.0f, ATTN_NORM, 0, SOUNDFLAG_FOLLOW ); } else { #ifdef SERVER msg_entity = this; - sound( this, channel, strSample, 1.0, ATTN_NORM, 0, SOUNDFLAG_UNICAST ); + sound( this, channel, strSample, 1.0f, ATTN_NORM, 0, SOUNDFLAG_UNICAST | SOUNDFLAG_FOLLOW); msg_entity = __NULL__; #else - sound( this, channel, strSample, 1.0, ATTN_NORM ); + sound( this, channel, strSample, 1.0f, ATTN_NORM, 0, SOUNDFLAG_FOLLOW ); #endif } + + SndLog( "^2%s::^3StartSound^7: %s (chan: %d bcast: %d) (%v)", classname, strSample, channel, broadcast, origin ); + return ( true ); } bool NSEntity::StartSoundDef( string strSample, float channel, bool broadcast ) { - NSLog( "^2%s::^3StartSoundDef^7: %s (chan: %d bcast: %d)", classname, strSample, channel, broadcast ); + SndLog( "^2%s::^3StartSoundDef^7: %s (chan: %d bcast: %d)", classname, strSample, channel, broadcast ); Sound_Play( this, channel, strSample ); return ( true ); } diff --git a/src/shared/NSRenderableEntity.qc b/src/shared/NSRenderableEntity.qc index 1d5afa07..68bfe0e4 100644 --- a/src/shared/NSRenderableEntity.qc +++ b/src/shared/NSRenderableEntity.qc @@ -959,23 +959,23 @@ NSRenderableEntity::HandleAnimEvent(float flTimeStamp, int iCode, string strData case 1004: /* plays a sound on CHAN_BODY */ #ifdef CLIENT if (substring(strData, 0, 1) == "*") - sound(self, CHAN_BODY, substring(strData, 1, -1), 1.0f, ATTN_NORM); + StartSound(substring(strData, 1, -1), CHAN_BODY, 0, true); else - sound(self, CHAN_BODY, strData, 1.0f, ATTN_NORM); + StartSound(strData, CHAN_BODY, 0, true); #endif break; case 1008: /* plays a sound on CHAN_VOICE */ #ifdef CLIENT if (substring(strData, 0, 1) == "*") - sound(self, CHAN_VOICE, substring(strData, 1, -1), 1.0f, ATTN_NORM); + StartSound(substring(strData, 1, -1), CHAN_VOICE, 0, true); else - sound(self, CHAN_VOICE, strData, 1.0f, ATTN_NORM); + StartSound(strData, CHAN_VOICE, 0, true); #endif break; -#ifdef CLIENT case 5004: /* view model sound? */ - sound(this, CHAN_AUTO, strData, 1.0, ATTN_NORM, 100, SOUNDFLAG_FOLLOW | SOUNDFLAG_NOSPACIALISE); + StartSound(strData, CHAN_AUTO, 0, true); break; +#ifdef CLIENT case 5001: /* muzzle flash on attachment 0 */ EV_MuzzleFlash_Create(this, m_iNumBones, m_flMuzzleScale, m_iMuzzleModel); break; @@ -993,10 +993,10 @@ NSRenderableEntity::HandleAnimEvent(float flTimeStamp, int iCode, string strData for (entity f = world; (f = find(f, ::targetname, strData));) { NSEntity trigger = (NSEntity)f; if (trigger.Trigger != __NULL__) { - trigger.Trigger(self, TRIG_TOGGLE); + trigger.Trigger(this, TRIG_TOGGLE); NSLog("^2%s^7::^3ModelEvent^7: " \ "Calling trigger '%s'\n", - self.classname, strData); + classname, strData); } } break; diff --git a/src/shared/cloader.h b/src/shared/cloader.h index ccd03633..e53b54fd 100644 --- a/src/shared/cloader.h +++ b/src/shared/cloader.h @@ -18,7 +18,7 @@ @brief Constants macro loader Scripters and level designers are able to define parameters through the use -of name-based lookups. +of name-based lookups, so they can change them later in one convenient place. In the game directory, they are defined within `scripts/constants.txt`. An example file looks like this: @@ -41,7 +41,7 @@ That would look something like this: The same applies to data read within level files and most routines related to parsing key/value pairs, so it is not limited to usage within EntityDef. */ -/** Called upon world init internally to populate our look-up table. +/** Called upon game init internally to populate our look-up table. */ void Constants_Init(void); diff --git a/src/shared/sound.h b/src/shared/sound.h index 282a5568..13ec1c65 100644 --- a/src/shared/sound.h +++ b/src/shared/sound.h @@ -28,6 +28,15 @@ .float maxspeed; .float flags; +var bool autocvar_s_developer = false; +void +_Sound_Log(string msg) +{ + if (autocvar_s_developer == true) + print(sprintf("%f %s\n", time, msg)); +} +#define SndLog(...) _Sound_Log(sprintf(__VA_ARGS__)) + /** Global hash table for name > soundDef id lookup. */ var hashtable g_hashsounds; diff --git a/src/shared/sound.qc b/src/shared/sound.qc index 9ac54a70..3fbd0053 100644 --- a/src/shared/sound.qc +++ b/src/shared/sound.qc @@ -396,9 +396,9 @@ Sound_Precache(string shader) index = g_sounds_count; - dprint("[SOUND] Precaching sound shader "); - dprint(shader); - dprint("\n"); + SndLog("Precaching SoundDef "); + SndLog(shader); + SndLog("\n"); /* create the hash-table if it doesn't exist */ if (!g_hashsounds) { @@ -411,7 +411,7 @@ Sound_Precache(string shader) cache = (int)hash_get(g_hashsounds, shader, -1); if (cache >= 0) { - NSLog("^1Sound_Precache: shader %s already precached", shader); + SndLog("^1Sound_Precache: def %s already precached", shader); return cache; } } @@ -458,7 +458,7 @@ Sound_Precache(string shader) fclose(fh); } - print("^1no soundDef found for "); + print("^1no SoundDef found for "); print(shader); print("\n"); g_sounds_count--; @@ -481,7 +481,7 @@ Sound_Distance(entity target, string shader) sample = (int)hash_get(g_hashsounds, shader, -1); if (sample < 0) { - crossprint(sprintf("^1Sound_Distance: shader %s is not precached\n", shader)); + crossprint(sprintf("^1Sound_Distance: def %s is not precached\n", shader)); return; } @@ -544,7 +544,7 @@ Sound_DistancePos(vector pos, string shader) sample = (int)hash_get(g_hashsounds, shader, -1); if (sample < 0) { - crossprint(sprintf("^1Sound_DistancePos: shader %s is not precached (SERVER)\n", shader)); + SndLog("^1Sound_DistancePos: def %s is not precached (SERVER)\n", shader); return; } @@ -577,10 +577,7 @@ Sound_DistancePos(vector pos, string shader) } #endif -#ifdef DEVELOPER - print(sprintf("Sound_DistancePos: %s\n", argv(r))); -#endif - + SndLog(sprintf("Sound_DistancePos: %s\n", argv(r))); pointsound_proper(pos, argv(r), volume, ATTN_NONE, pitch); } @@ -601,7 +598,7 @@ Sound_Play(entity target, int chan, string shader) sample = (int)hash_get(g_hashsounds, shader, -1); if (sample < 0) { - crossprint(sprintf("^1Sound_Play: shader %s is not precached\n", shader)); + SndLog("^1Sound_Play: def %s is not precached\n", shader); return; } @@ -724,7 +721,7 @@ Sound_PlayAt(vector pos, string shader) sample = (int)hash_get(g_hashsounds, shader, -1); if (sample < 0) { - crossprint(sprintf("^1Sound_PlayAt: shader %s is not precached\n", shader)); + SndLog("^1Sound_PlayAt: def %s is not precached\n", shader); return; } @@ -780,7 +777,7 @@ Sound_PlayLocal(string shader) sample = (int)hash_get(g_hashsounds, shader, -1); if (sample < 0) { - crossprint(sprintf("^1Sound_PlayLocal: shader %s is not precached\n", shader)); + SndLog("^1Sound_PlayLocal: def %s is not precached\n", shader); return; } @@ -866,7 +863,7 @@ Sound_Speak(entity target, string shader) sample = (int)hash_get(g_hashsounds, shader, -1); if (sample < 0) { - crossprint(sprintf("^1Sound_Speak: shader %s is not precached (SERVER)\n", shader)); + SndLog("^1Sound_Speak: def %s is not precached (SERVER)\n", shader); return; }