X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Feffects%2Fqc%2Fglobalsound.qc;h=8c0dfd5080312fda7d1ed4d10a66a108bdd34075;hb=60b0e81cdaed847a7aac9d234f219937ab9462b2;hp=8c1ed1ca8305759ef85ee3a7cb691975c51ca7f7;hpb=05ee5b1212a6537e5c5acb76dbc1ef9df40f85c6;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/effects/qc/globalsound.qc b/qcsrc/common/effects/qc/globalsound.qc index 8c1ed1ca8..8c0dfd508 100644 --- a/qcsrc/common/effects/qc/globalsound.qc +++ b/qcsrc/common/effects/qc/globalsound.qc @@ -2,18 +2,15 @@ #include -#ifdef IMPLEMENTATION #include #ifdef SVQC - #include + #include #endif 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 @@ -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; @@ -114,7 +104,7 @@ else { // Can this happen? - LOG_WARNINGF("Missing entcs data for player %d\n", who); + LOG_WARNF("Missing entcs data for player %d", who); sound8(e, o, chan, sample, vol, atten, 0, 0); } return true; @@ -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) @@ -146,7 +133,7 @@ else { // Can this happen? - LOG_WARNINGF("Missing entcs data for player %d\n", who); + LOG_WARNF("Missing entcs data for player %d", who); sound8(e, o, chan, sample, vol, atten, 0, 0); } return true; @@ -219,7 +206,7 @@ int fh = fopen(f, FILE_READ); if (fh < 0) { - LOG_WARNINGF("Player sound file not found: %s\n", f); + LOG_WARNF("Player sound file not found: %s", f); return; } for (string s; (s = fgets(fh)); ) @@ -227,7 +214,7 @@ int n = tokenize_console(s); if (n != 3) { - if (n != 0) LOG_WARNINGF("Invalid sound info line: %s\n", s); + if (n != 0) LOG_WARNF("Invalid sound info line: %s", s); continue; } string file = argv(1); @@ -250,8 +237,7 @@ .string fld = it.m_playersoundfld; if (this.(fld)) { - strunzone(this.(fld)); - this.(fld) = string_null; + strfree(this.(fld)); } }); } @@ -261,7 +247,7 @@ int fh = fopen(f, FILE_READ); if (fh < 0) { - if (strict) LOG_WARNINGF("Player sound file not found: %s\n", f); + if (strict) LOG_WARNF("Player sound file not found: %s", f); return false; } for (string s; (s = fgets(fh)); ) @@ -269,7 +255,7 @@ int n = tokenize_console(s); if (n != 3) { - if (n != 0) LOG_WARNINGF("Invalid sound info line: %s\n", s); + if (n != 0) LOG_WARNF("Invalid sound info line: %s", s); continue; } string key = argv(0); @@ -277,13 +263,12 @@ if (GetPlayerSoundSampleField_notFound) field = GetVoiceMessageSampleField(key); if (GetPlayerSoundSampleField_notFound) { - LOG_TRACEF("Invalid sound info field: %s\n", key); + LOG_TRACEF("Invalid sound info field: %s", 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,8 +282,7 @@ 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); @@ -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); @@ -354,7 +338,7 @@ #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); \ @@ -384,10 +368,10 @@ #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); \ @@ -436,4 +420,3 @@ } #endif -#endif