/** * @brief Play a sound on the client side * @param[in] self Pointer to the event structure that is currently executed * @param[in] msg holds the network data * @sa EV_SOUND * @note if the last character of the sound file string that was sent by the * server is a '+', we will select a random sound file by replacing the '+' * character with a number between 01..99 */ void CL_SoundEvent (const eventRegister_t* self, dbuffer* msg) { char sound[MAX_QPATH]; vec3_t origin; int number; int step; /* read data */ NET_ReadFormat(msg, self->formatString, &number, &origin, &step, &sound, sizeof(sound)); le_t* le = LE_Get(number); if (le) { if (LE_IsLivingActor(le) && le->team != cls.team) { /** @todo render */ } else if (LE_IsDoor(le) || LE_IsBreakable(le)) { /** @todo render */ } } const char* file = CL_ConvertSoundFromEvent(sound, sizeof(sound)); Com_DPrintf(DEBUG_SOUND, "Play network sample %s at (%f:%f:%f)\n", file, origin[0], origin[1], origin[2]); if (step >= 0 && step < MAX_ROUTE) { le_t* closest = CL_ActorGetClosest(origin, cls.team); if (closest != nullptr) { vec3_t tmp; VectorCopy(cl.cam.camorg, tmp); VectorCopy(closest->origin, cl.cam.camorg); S_LoadAndPlaySample(file, origin, SOUND_ATTN_NORM, SND_VOLUME_DEFAULT); VectorCopy(tmp, cl.cam.camorg); } return; } S_LoadAndPlaySample(file, origin, SOUND_ATTN_NORM, SND_VOLUME_DEFAULT); }
/** * @brief Play a sound on the client side * @param[in] self Pointer to the event structure that is currently executed * @param[in] msg holds the network data * @sa EV_SOUND * @note if the last character of the sound file string that was sent by the * server is a '+', we will select a random sound file by replacing the '+' * character with a number between 01..99 */ void CL_SoundEvent (const eventRegister_t *self, struct dbuffer *msg) { char sound[MAX_QPATH]; vec3_t origin; int number; le_t *le; size_t length; /* read data */ NET_ReadFormat(msg, self->formatString, &number, &origin, &sound, sizeof(sound)); le = LE_Get(number); if (le) { if (LE_IsLivingActor(le) && le->team != cls.team) { /** @todo render */ } else if (LE_IsDoor(le) || LE_IsBreakable(le)) { /** @todo render */ } } length = strlen(sound) - 1; if (sound[length] == '+') { int i; sound[length] = '\0'; for (i = 1; i <= 99; i++) { if (FS_CheckFile("sounds/%s%02i", sound, i) == -1) break; } Com_sprintf(sound + length, sizeof(sound) - length, "%02i", rand() % i + 1); } Com_DPrintf(DEBUG_SOUND, "Play network sample %s at (%f:%f:%f)\n", sound, origin[0], origin[1], origin[2]); S_LoadAndPlaySample(sound, origin, SOUND_ATTN_NORM, SND_VOLUME_DEFAULT); }