Isle
Loading...
Searching...
No Matches
legocachesoundmanager.h
Go to the documentation of this file.
1#ifndef LEGOCACHESOUNDMANAGER_H
2#define LEGOCACHESOUNDMANAGER_H
3
4#include "decomp.h"
5#include "legocachsound.h"
6#include "mxstl/stlcompat.h"
7#include "mxtypes.h"
8
9#pragma warning(disable : 4237)
10
18 LegoCacheSoundEntry() : m_sound(NULL), m_name(NULL) {}
19
23 LegoCacheSoundEntry(LegoCacheSound* p_sound, const char* p_name) : m_sound(p_sound), m_name(p_name) {}
24
28 LegoCacheSoundEntry(LegoCacheSound* p_sound) : m_sound(p_sound), m_name(p_sound->GetUnknown0x48().GetData()) {}
29
32 {
33 if (m_sound == NULL && m_name != NULL) {
34 delete[] const_cast<char*>(m_name);
35 }
36 }
37
40 bool operator==(LegoCacheSoundEntry) const { return 0; }
43 bool operator<(LegoCacheSoundEntry) const { return 0; }
44
46 LegoCacheSound* GetSound() const { return m_sound; }
48 const char* GetName() const { return m_name; }
49
51 friend struct Set100d6b4cComparator;
52
53private:
54 LegoCacheSound* m_sound;
55 const char* m_name;
56};
57
64 bool operator()(const LegoCacheSoundEntry& p_a, const LegoCacheSoundEntry& p_b) const
65 {
66 return strcmpi(p_a.m_name, p_b.m_name) > 0;
67 }
68};
69
71typedef set<LegoCacheSoundEntry, Set100d6b4cComparator> Set100d6b4c;
72
74typedef list<LegoCacheSoundEntry> List100d6b4c;
75
82public:
87
90 virtual MxResult Tickle(); // vtable+0x00
91
95 LegoCacheSound* FindSoundByKey(const char* p_key);
96
102
109 LegoCacheSound* Play(const char* p_key, const char* p_name, MxBool p_looping);
110
116 LegoCacheSound* Play(LegoCacheSound* p_sound, const char* p_name, MxBool p_looping);
117
120 void Stop(LegoCacheSound*& p_sound);
121
124 void Destroy(LegoCacheSound*& p_sound);
125
126private:
127 Set100d6b4c m_set;
128 List100d6b4c m_list;
129};
130
131// clang-format off
132// TEMPLATE: see source for template usages and STL-style implementation notes [AI]
133
134// clang-format on
135
136#endif // LEGOCACHESOUNDMANAGER_H
[AI] Manages caching, reuse, and playback of LegoCacheSound objects.
LegoCacheSoundManager()
[AI] Default constructor. [AI]
void Destroy(LegoCacheSound *&p_sound)
[AI] Destroys (deletes and removes) the specified sound object from all tracking.
LegoCacheSound * FindSoundByKey(const char *p_key)
[AI] Attempts to find and return a cached sound by its key (case-insensitive).
~LegoCacheSoundManager()
[AI] Destructor. Cleans up all cached sound entries in set and list, stops sounds and deletes sound o...
LegoCacheSound * ManageSoundEntry(LegoCacheSound *p_sound)
[AI] Manages a sound entry.
LegoCacheSound * Play(const char *p_key, const char *p_name, MxBool p_looping)
[AI] Plays a sound identified by key, with the given playback name and looping flag.
void Stop(LegoCacheSound *&p_sound)
[AI] Stops playback of the specified sound object.
virtual MxResult Tickle()
[AI] Advances or cleans up all managed sounds.
Sound cache object managing DirectSound buffers and 3D positioning for preloaded sound data.
Definition: legocachsound.h:17
set< LegoCacheSoundEntry, Set100d6b4cComparator > Set100d6b4c
[AI] Set of LegoCacheSoundEntry, sorted by case-insensitive name for fast lookup. [AI]
list< LegoCacheSoundEntry > List100d6b4c
[AI] List of LegoCacheSoundEntry, used for maintaining order of managed/playing sounds....
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
[AI] STL compatibility layer header to provide consistent STL (Standard Template Library) types and a...
[AI] Represents a single entry in the cached sound system, linking a sound pointer with its identifyi...
LegoCacheSoundEntry(LegoCacheSound *p_sound, const char *p_name)
[AI] Constructs a sound entry with a given sound and name string pointer.
LegoCacheSoundEntry(LegoCacheSound *p_sound)
[AI] Constructs a sound entry referencing a given sound, using its internal name data.
const char * GetName() const
[AI] Returns the name (string key) of this sound entry. [AI]
bool operator<(LegoCacheSoundEntry) const
[AI] Dummy less-than operator (always returns false).
~LegoCacheSoundEntry()
[AI] Destructor for LegoCacheSoundEntry. Deletes the name only if entry does NOT own a sound (m_sound...
LegoCacheSoundEntry()
[AI] Constructs an empty sound entry with null pointers. [AI]
bool operator==(LegoCacheSoundEntry) const
[AI] Dummy equality operator (always returns false).
LegoCacheSound * GetSound() const
[AI] Returns the pointer to the cached LegoCacheSound. [AI]
[AI] Comparator used in the sound cache sound entry set (Set100d6b4c).
bool operator()(const LegoCacheSoundEntry &p_a, const LegoCacheSoundEntry &p_b) const
[AI] Performs case-insensitive reverse-lexical comparison between sound names (for set order).