diff options
author | Sergeanur <s.anureev@yandex.ua> | 2021-08-21 11:18:11 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2021-08-21 11:18:45 +0200 |
commit | b683c047dc879ad313070397e28b77b3dcd4b44d (patch) | |
tree | 74c117128ffa0a25c6f92e1e7b6fad72c4d447e7 /src/audio/PolRadio.h | |
parent | fix (diff) | |
download | re3-b683c047dc879ad313070397e28b77b3dcd4b44d.tar re3-b683c047dc879ad313070397e28b77b3dcd4b44d.tar.gz re3-b683c047dc879ad313070397e28b77b3dcd4b44d.tar.bz2 re3-b683c047dc879ad313070397e28b77b3dcd4b44d.tar.lz re3-b683c047dc879ad313070397e28b77b3dcd4b44d.tar.xz re3-b683c047dc879ad313070397e28b77b3dcd4b44d.tar.zst re3-b683c047dc879ad313070397e28b77b3dcd4b44d.zip |
Diffstat (limited to 'src/audio/PolRadio.h')
-rw-r--r-- | src/audio/PolRadio.h | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/src/audio/PolRadio.h b/src/audio/PolRadio.h index 368708b6..f402c200 100644 --- a/src/audio/PolRadio.h +++ b/src/audio/PolRadio.h @@ -1,6 +1,7 @@ #pragma once #include "Crime.h" +#include "AudioSamples.h" struct cAMCrime { int32 type; @@ -17,30 +18,49 @@ struct cAMCrime { VALIDATE_SIZE(cAMCrime, 20); +#define POLICE_RADIO_QUEUE_MAX_SAMPLES 60 + class cPoliceRadioQueue { public: - int32 crimesSamples[60]; - uint8 policeChannelTimer; - uint8 policeChannelTimerSeconds; - uint8 policeChannelCounterSeconds; - cAMCrime crimes[10]; + int32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES]; + uint8 m_nSamplesInQueue; + uint8 m_nAddOffset; + uint8 m_nRemoveOffset; cPoliceRadioQueue() { - policeChannelTimerSeconds = 0; - policeChannelCounterSeconds = 0; - policeChannelTimer = 0; + Reset(); + } + + void Reset() + { + m_nAddOffset = 0; + m_nRemoveOffset = 0; + m_nSamplesInQueue = 0; + } + + bool8 Add(uint32 sample) + { + if (m_nSamplesInQueue != POLICE_RADIO_QUEUE_MAX_SAMPLES) { + m_aSamples[m_nAddOffset] = sample; + m_nSamplesInQueue++; + m_nAddOffset = (m_nAddOffset + 1) % POLICE_RADIO_QUEUE_MAX_SAMPLES; + return TRUE; + } + return FALSE; } - void Add(uint32 sample) + uint32 Remove() { - if (policeChannelTimer != 60) { - crimesSamples[policeChannelTimerSeconds] = sample; - policeChannelTimer++; - policeChannelTimerSeconds = (policeChannelTimerSeconds + 1) % 60; + if (m_nSamplesInQueue != 0) { + uint32 sample = m_aSamples[m_nRemoveOffset]; + m_nSamplesInQueue--; + m_nRemoveOffset = (m_nRemoveOffset + 1) % POLICE_RADIO_QUEUE_MAX_SAMPLES; + return sample; } + return TOTAL_AUDIO_SAMPLES; } }; -VALIDATE_SIZE(cPoliceRadioQueue, 444); +VALIDATE_SIZE(cPoliceRadioQueue, 244); |