Skip to content

Commit

Permalink
Fixes the client not resending its request for the hashes of the taun…
Browse files Browse the repository at this point in the history
…ts in use when the MsgShareAudioTauntIdentifiers packet from the Server got lost
  • Loading branch information
luponix committed Apr 15, 2023
1 parent 1b0439d commit 1b52a5e
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions GameMod/MPAudioTaunts.cs
Expand Up @@ -999,6 +999,27 @@ private static void OnPlayAudioTaunt(NetworkMessage rawMsg)
{
PlayAudioTauntFromAudioclip(match_taunts[msg.hash].audioclip, msg.sender_name);
}
// If someone tries to play a taunt that we dont even know existed before then we missed the ShareAudioTauntIdentifiers packet
else if (!match_taunts.ContainsKey(msg.hash))
{
UnityEngine.Debug.Log("[AudioTaunts] Client was unaware of a taunts existence. Resending MsgShareAudioTauntIdentifiers!");
string fileHashes = "";
for (int i = 0; i < local_taunts.Length; i++)
{
if (local_taunts[i].hash != null && !local_taunts[i].hash.Equals("EMPTY"))
{
fileHashes += local_taunts[i].hash;
if (i != local_taunts.Length - 1)
fileHashes += "/";
}
}

Client.GetClient().SendByChannel(MessageTypes.MsgShareAudioTauntIdentifiers,
new ShareAudioTauntIdentifiers
{
hashes = fileHashes
}, 0);
}
}


Expand Down Expand Up @@ -1074,7 +1095,7 @@ static void Prefix(NetworkMessage msg)
}
if (item.Value.is_data_complete)
{
item.Value.providing_clients = new List<int>;
item.Value.providing_clients = new List<int>();
taunt_buffer.Add(item.Key, item.Value);
}

Expand Down Expand Up @@ -1159,9 +1180,11 @@ private static void OnShareAudioTauntIdentifiers(NetworkMessage rawMsg)
{
match_taunts[hash].providing_clients = new List<int>();
}

match_taunts[hash].providing_clients.Add(rawMsg.conn.connectionId);
UnityEngine.Debug.Log(" match_taunts:" + hash + " exists, added: " + rawMsg.conn.connectionId + " as a provider");
if(!match_taunts[hash].providing_clients.Contains(rawMsg.conn.connectionId))
{
match_taunts[hash].providing_clients.Add(rawMsg.conn.connectionId);
UnityEngine.Debug.Log(" match_taunts:" + hash + " exists, added: " + rawMsg.conn.connectionId + " as a provider");
}
}
// this taunt doesnt exist, add it
else
Expand Down

0 comments on commit 1b52a5e

Please sign in to comment.