Skip to content

Commit b269e03

Browse files
authored
zNPCTypePrawn: matches on zNPCPrawn, aqua_beam, and helpers (bfbbdecomp#717)
1 parent c10207b commit b269e03

File tree

5 files changed

+495
-124
lines changed

5 files changed

+495
-124
lines changed

src/SB/Core/x/containers.h

Lines changed: 120 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,127 @@ template <class T, U32 N> struct fixed_queue
174174
U32 _last;
175175
T _buffer[N + 1];
176176

177-
void reset();
178-
void front();
179-
void pop_front();
180-
void push_front(const T& element);
177+
void reset()
178+
{
179+
clear();
180+
}
181+
void clear()
182+
{
183+
_last = 0;
184+
_first = 0;
185+
}
186+
T& front()
187+
{
188+
fixed_queue<T, N>::iterator it = begin();
189+
return *it;
190+
}
191+
void pop_front()
192+
{
193+
_first = (_first + 1) & N;
194+
}
195+
void push_front()
196+
{
197+
_first = (_first + N) & N;
198+
}
199+
void push_front(const T& data)
200+
{
201+
push_front();
202+
T& new_front = front();
203+
new_front = data;
204+
}
181205
void push_back();
182-
bool full() const;
183-
void back();
184-
void pop_back();
185-
bool empty() const;
186-
U32 size() const;
206+
U32 max_size() const
207+
{
208+
return N;
209+
}
210+
bool full() const
211+
{
212+
return size() == max_size();
213+
}
214+
T& back()
215+
{
216+
fixed_queue<T, N>::iterator it = end() - 1;
217+
return *it;
218+
}
219+
void pop_back()
220+
{
221+
_last = (_last + N) & N;
222+
}
223+
bool empty() const
224+
{
225+
return _last == _first;
226+
}
227+
U32 size() const
228+
{
229+
return _last - _first;
230+
}
231+
232+
struct iterator {
233+
U32 _it;
234+
fixed_queue<T, N>* _owner;
235+
236+
T& operator*() const
237+
{
238+
return _owner->_buffer[_it];
239+
}
240+
241+
bool operator!=(const iterator& other) const
242+
{
243+
return _it != other._it;
244+
}
245+
246+
iterator* operator+=(S32 value)
247+
{
248+
value += _it;
249+
_it = (value + N) & N;
250+
return this;
251+
}
252+
253+
iterator* operator-=(S32 value)
254+
{
255+
iterator* tmp = operator+=(-value);
256+
return tmp;
257+
}
258+
259+
iterator* operator--()
260+
{
261+
*this -= 1;
262+
return this;
263+
}
264+
265+
iterator operator-(S32 value) const
266+
{
267+
iterator tmp;
268+
tmp._it = _it;
269+
tmp._owner = _owner;
270+
tmp -= value;
271+
return tmp;
272+
}
273+
274+
iterator* operator++()
275+
{
276+
*this += 1;
277+
return this;
278+
}
279+
};
280+
281+
iterator create_iterator(u32 initial_location) const
282+
{
283+
iterator it;
284+
it._it = initial_location;
285+
it._owner = const_cast<fixed_queue<T, N>*>(this);
286+
return it;
287+
}
288+
289+
iterator begin() const
290+
{
291+
return create_iterator(_first);
292+
}
293+
294+
iterator end() const
295+
{
296+
return create_iterator(_last);
297+
}
187298
};
188299

189300
#endif

src/SB/Core/x/xSnd.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ void xSndStopAll(U32 mask)
127127
xSndDelayedInit();
128128
}
129129

130+
void xSndStopFade(U32 id, F32 fade_time)
131+
{
132+
}
133+
130134
void xSndSetCategoryVol(sound_category category, F32 vol)
131135
{
132136
gSnd.categoryVolFader[category] = vol;

src/SB/Core/x/xSnd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ void xSndSetVol(U32 snd, F32 vol);
122122
void xSndSetPitch(U32 snd, F32 pitch);
123123
void xSndStop(U32 snd);
124124
void xSndStopAll(U32 mask);
125+
void xSndStopFade(U32, F32);
125126
void xSndPauseAll(U32 pause_effects, U32 pause_streams);
126127
void xSndPauseCategory(U32 mask, U32 pause);
127128
void xSndDelayedInit();

0 commit comments

Comments
 (0)