X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Feffects%2Fqc%2Fglobalsound.qc;h=8ce2b6ed3a4a8b7ea0fd09ddf75bf9b241b03847;hb=977d7262b039aa7771fccce01ce3f9846df19e4b;hp=d60b2e8a65892bd33f4d0b285ce00328b2b095a0;hpb=f34fd47ee0a7f283ab60592a17399ec5a500416c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/effects/qc/globalsound.qc b/qcsrc/common/effects/qc/globalsound.qc index d60b2e8a6..8ce2b6ed3 100644 --- a/qcsrc/common/effects/qc/globalsound.qc +++ b/qcsrc/common/effects/qc/globalsound.qc @@ -2,7 +2,6 @@ #include -#ifdef IMPLEMENTATION #include #ifdef SVQC @@ -12,8 +11,6 @@ REGISTER_NET_TEMP(globalsound) REGISTER_NET_TEMP(playersound) - string GlobalSound_sample(string pair, float r); - #ifdef SVQC /** * @param from the source entity, its position is sent @@ -45,9 +42,7 @@ WriteByte(channel, floor(_atten * 64)); entcs_force_origin(from); vector o = from.origin + 0.5 * (from.mins + from.maxs); - WriteCoord(channel, o.x); - WriteCoord(channel, o.y); - WriteCoord(channel, o.z); + WriteVector(channel, o); } /** @@ -82,9 +77,7 @@ WriteByte(channel, floor(_atten * 64)); entcs_force_origin(from); vector o = from.origin + 0.5 * (from.mins + from.maxs); - WriteCoord(channel, o.x); - WriteCoord(channel, o.y); - WriteCoord(channel, o.z); + WriteVector(channel, o); } #endif @@ -92,7 +85,7 @@ NET_HANDLE(globalsound, bool isnew) { - entity gs = GlobalSounds_from(ReadByte()); + entity gs = REGISTRY_GET(GlobalSounds, ReadByte()); float r = ReadByte() / 255; string sample = GlobalSound_sample(gs.m_globalsoundstr, r); int who = ReadByte(); @@ -100,10 +93,7 @@ int chan = ReadSByte(); float vol = ReadByte() / 255; float atten = ReadByte() / 64; - vector o; - o.x = ReadCoord(); - o.y = ReadCoord(); - o.z = ReadCoord(); + vector o = ReadVector(); // TODO: is this really what we want to be doing? Footsteps that follow the player at head height? if (who == player_currententnum) e = findfloat(NULL, entnum, who); // play at camera position for full volume else if (e) e.origin = o; @@ -122,7 +112,7 @@ NET_HANDLE(playersound, bool isnew) { - entity ps = PlayerSounds_from(ReadByte()); + entity ps = REGISTRY_GET(PlayerSounds, ReadByte()); float r = ReadByte() / 255; int who = ReadByte(); entity e = entcs_receiver(who - 1); @@ -132,10 +122,7 @@ int chan = ReadSByte(); float vol = ReadByte() / 255; float atten = ReadByte() / 64; - vector o; - o.x = ReadCoord(); - o.y = ReadCoord(); - o.z = ReadCoord(); + vector o = ReadVector(); if (who == player_currententnum) e = findfloat(NULL, entnum, who); // play at camera position for full volume else if (e) e.origin = o; if (e) @@ -250,8 +237,7 @@ .string fld = it.m_playersoundfld; if (this.(fld)) { - strunzone(this.(fld)); - this.(fld) = string_null; + strfree(this.(fld)); } }); } @@ -277,13 +263,12 @@ if (GetPlayerSoundSampleField_notFound) field = GetVoiceMessageSampleField(key); if (GetPlayerSoundSampleField_notFound) { - LOG_TRACEF("Invalid sound info field: %s", key); + LOG_TRACEF("Invalid sound info field in player sound file '%s': %s", f, key); continue; } string file = argv(1); string variants = argv(2); - if (this.(field)) strunzone(this.(field)); - this.(field) = strzone(strcat(file, " ", variants)); + strcpy(this.(field), strcat(file, " ", variants)); } fclose(fh); return true; @@ -297,16 +282,15 @@ void UpdatePlayerSounds(entity this) { if (this.model == this.model_for_playersound && this.skin == this.skin_for_playersound) return; - if (this.model_for_playersound) strunzone(this.model_for_playersound); - this.model_for_playersound = strzone(this.model); + strcpy(this.model_for_playersound, this.model); this.skin_for_playersound = this.skin; ClearPlayerSounds(this); LoadPlayerSounds(this, "sound/player/default.sounds", true); if (this.model == "null" #ifdef SVQC - && autocvar_g_debug_globalsounds + && autocvar_g_debug_globalsounds #endif - ) return; + ) return; if (autocvar_g_debug_defaultsounds) return; if (LoadPlayerSounds(this, get_model_datafilename(this.model, this.skin, "sounds"), false)) return; LoadPlayerSounds(this, get_model_datafilename(this.model, 0, "sounds"), true); @@ -333,7 +317,7 @@ msg_entity = this.pusher; if (IS_REAL_CLIENT(msg_entity)) { - float atten = (msg_entity.cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; + float atten = (CS(msg_entity).cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten); else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten); else soundto(MSG_ONE, this, chan, sample, vol, atten); @@ -353,12 +337,11 @@ { #define X() \ MACRO_BEGIN \ - { \ - float atten = (msg_entity.cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; \ + float atten = (CS(msg_entity).cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; \ if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten); \ else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten); \ else soundto(MSG_ONE, this, chan, sample, vol, atten); \ - } MACRO_END + MACRO_END if (fake) { msg_entity = this; X(); } else @@ -368,33 +351,37 @@ X(); }); } - #undef X + #undef X break; } case VOICETYPE_AUTOTAUNT: case VOICETYPE_TAUNT: { - if (voicetype == VOICETYPE_AUTOTAUNT) if (!sv_autotaunt) { break; }else {} - else if (IS_PLAYER(this) && !IS_DEAD(this)) animdecide_setaction(this, ANIMACTION_TAUNT, - true); + if (voicetype == VOICETYPE_AUTOTAUNT) + { + if (!sv_autotaunt) break; + } + else if (IS_PLAYER(this) && !IS_DEAD(this)) + animdecide_setaction(this, ANIMACTION_TAUNT, true); + if (!sv_taunt) break; if (autocvar_sv_gentle) break; float tauntrand = 0; if (voicetype == VOICETYPE_AUTOTAUNT) tauntrand = random(); + #define X() \ MACRO_BEGIN \ - { \ - if (voicetype != VOICETYPE_AUTOTAUNT || tauntrand < msg_entity.cvar_cl_autotaunt) \ + if (voicetype != VOICETYPE_AUTOTAUNT || tauntrand < CS(msg_entity).cvar_cl_autotaunt) \ { \ - float atten = (msg_entity.cvar_cl_voice_directional >= 1) \ - ? bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, \ + float atten = (CS(msg_entity).cvar_cl_voice_directional >= 1) \ + ? bound(ATTEN_MIN, CS(msg_entity).cvar_cl_voice_directional_taunt_attenuation, \ ATTEN_MAX) \ : ATTEN_NONE; \ if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten); \ else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten); \ else soundto(MSG_ONE, this, chan, sample, vol, atten); \ } \ - } MACRO_END + MACRO_END if (fake) { msg_entity = this; @@ -407,7 +394,7 @@ X(); }); } - #undef X + #undef X break; } case VOICETYPE_PLAYERSOUND: @@ -436,4 +423,3 @@ } #endif -#endif