MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / MultiSendRequestPlayTaunt

Function MultiSendRequestPlayTaunt

Descent3/multi.cpp:8287–8342  ·  view source on GitHub ↗

Client is asking the server to play an audio taunt

Source from the content-addressed store, hash-verified

8285
8286// Client is asking the server to play an audio taunt
8287void MultiSendRequestPlayTaunt(int index) {
8288
8289 if (!(Game_mode & GM_MULTI))
8290 return;
8291
8292 if (index < 0 || index > 3)
8293 return;
8294
8295 if (!taunt_AreEnabled())
8296 return;
8297
8298 // make sure an audio file exists there
8299 char audio_file[_MAX_PATH];
8300
8301 switch (index) {
8302 case 0:
8303 ddio_MakePath(audio_file, LocalCustomSoundsDir, NetPlayers[Player_num].voice_taunt1, NULL);
8304 break;
8305 case 1:
8306 ddio_MakePath(audio_file, LocalCustomSoundsDir, NetPlayers[Player_num].voice_taunt2, NULL);
8307 break;
8308 case 2:
8309 ddio_MakePath(audio_file, LocalCustomSoundsDir, NetPlayers[Player_num].voice_taunt3, NULL);
8310 break;
8311 case 3:
8312 ddio_MakePath(audio_file, LocalCustomSoundsDir, NetPlayers[Player_num].voice_taunt4, NULL);
8313 break;
8314 }
8315
8316 if (!cfexist(audio_file)) {
8317 mprintf(0, "Ignoring request to play audio taunt...it does not exist\n");
8318 return;
8319 }
8320
8321 float t = Gametime;
8322 if ((t - Time_last_taunt_request) < taunt_DelayTime()) {
8323 // too soon since last request
8324 return;
8325 }
8326 Time_last_taunt_request = t;
8327
8328 int count = 0;
8329 uint8_t data[MAX_GAME_DATA_SIZE];
8330 int size_offset = START_DATA(MP_CLIENT_PLAY_TAUNT, data, &count);
8331
8332 MultiAddByte(Player_num, data, &count);
8333 MultiAddByte(index, data, &count);
8334
8335 END_DATA(count, data, size_offset);
8336
8337 if (Netgame.local_role == LR_SERVER) {
8338 MultiDoRequestPlayTaunt(data);
8339 } else {
8340 nw_SendReliable(NetPlayers[Player_num].reliable_socket, data, count);
8341 }
8342}
8343
8344// the server is telling us that about a player's message-type state (is [not] typing a message)

Callers 3

DoKeyboardMiscFunction · 0.85
DoControllerMiscFunction · 0.85
ProcessTestKeysFunction · 0.85

Calls 9

taunt_AreEnabledFunction · 0.85
cfexistFunction · 0.85
taunt_DelayTimeFunction · 0.85
START_DATAFunction · 0.85
MultiAddByteFunction · 0.85
END_DATAFunction · 0.85
MultiDoRequestPlayTauntFunction · 0.85
nw_SendReliableFunction · 0.85
ddio_MakePathFunction · 0.50

Tested by

no test coverage detected