isle/LEGO1/lego/legoomni/src/common/legostate.cpp

60 lines
994 B
C++
Raw Normal View History

#include "legostate.h"
2024-02-02 14:09:45 -05:00
#include <stdlib.h>
DECOMP_SIZE_ASSERT(LegoState, 0x08)
2024-02-02 14:09:45 -05:00
DECOMP_SIZE_ASSERT(LegoState::Playlist, 0x0c)
2024-02-02 14:09:45 -05:00
// FUNCTION: LEGO1 0x10014d00
MxU32 LegoState::Playlist::Next()
{
2024-02-02 14:09:45 -05:00
MxU32 objectId;
switch (m_mode) {
case e_loop:
objectId = m_objectIds[m_nextIndex];
if (m_nextIndex - m_length == -1) {
m_nextIndex = 0;
}
else {
m_nextIndex++;
}
break;
case e_once:
objectId = m_objectIds[m_nextIndex];
if (m_length > m_nextIndex + 1) {
m_nextIndex++;
}
break;
case e_random:
m_nextIndex = rand() % m_length;
objectId = m_objectIds[m_nextIndex];
break;
case e_loopSkipFirst:
objectId = m_objectIds[m_nextIndex];
if (m_nextIndex - m_length == -1) {
m_nextIndex = 1;
}
else {
m_nextIndex++;
}
}
return objectId;
}
2024-02-02 14:09:45 -05:00
// FUNCTION: LEGO1 0x10014de0
MxBool LegoState::Playlist::Contains(MxU32 p_objectId)
{
2024-02-02 14:09:45 -05:00
for (MxS16 i = 0; i < m_length; i++) {
if (m_objectIds[i] == p_objectId) {
return TRUE;
}
}
return FALSE;
}