isle-portable/LEGO1/lego/legoomni/src/entity/legoworld.cpp

384 lines
8.4 KiB
C++
Raw Normal View History

#include "legoworld.h"
2023-10-24 19:38:27 -04:00
#include "legoanimpresenter.h"
#include "legocontrolmanager.h"
#include "legoinputmanager.h"
2023-10-24 19:38:27 -04:00
#include "legoomni.h"
#include "legoutil.h"
#include "legovideomanager.h"
#include "mxactionnotificationparam.h"
#include "mxnotificationmanager.h"
#include "mxnotificationparam.h"
#include "mxomni.h"
#include "mxticklemanager.h"
2024-01-15 15:59:57 -05:00
DECOMP_SIZE_ASSERT(LegoWorld, 0xf8)
DECOMP_SIZE_ASSERT(LegoEntityList, 0x18)
DECOMP_SIZE_ASSERT(LegoEntityListCursor, 0x10)
DECOMP_SIZE_ASSERT(LegoCacheSoundList, 0x18)
DECOMP_SIZE_ASSERT(LegoCacheSoundListCursor, 0x10)
2024-01-22 10:18:46 -05:00
// FUNCTION: LEGO1 0x1001ca40
LegoWorld::LegoWorld() : m_list0x68(TRUE)
{
m_unk0xf4 = 4;
2024-01-22 10:18:46 -05:00
m_cameraController = NULL;
m_entityList = NULL;
m_cacheSoundList = NULL;
2024-01-22 10:18:46 -05:00
m_unk0xa4 = 0; // MxBool?
m_hideAnimPresenter = NULL;
2024-01-22 10:18:46 -05:00
m_worldStarted = FALSE;
NotificationManager()->Register(this);
}
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// FUNCTION: LEGO1 0x1001d670
MxBool LegoWorld::VTable0x5c()
{
return FALSE;
}
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// FUNCTION: LEGO1 0x1001d680
MxBool LegoWorld::VTable0x64()
{
return FALSE;
}
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// STUB: LEGO1 0x1001dfa0
LegoWorld::~LegoWorld()
{
2023-10-24 19:38:27 -04:00
// TODO
}
// FUNCTION: LEGO1 0x1001e0b0
MxResult LegoWorld::Create(MxDSAction& p_dsAction)
{
MxEntity::Create(p_dsAction);
m_entityList = new LegoEntityList(TRUE);
if (!m_entityList)
return FAILURE;
m_cacheSoundList = new LegoCacheSoundList(TRUE);
if (!m_cacheSoundList)
return FAILURE;
if (!VTable0x54())
return FAILURE;
if (p_dsAction.GetFlags() & MxDSAction::c_enabled) {
if (GetCurrentWorld()) {
GetCurrentWorld()->VTable0x68(0);
}
SetCurrentWorld(this);
ControlManager()->FUN_10028df0(&m_controlPresenters);
}
SetIsWorldActive(TRUE);
m_unk0xec = -1;
return SUCCESS;
}
// STUB: LEGO1 0x1001e9d0
void LegoWorld::Destroy(MxBool p_fromDestructor)
{
// TODO
}
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// FUNCTION: LEGO1 0x1001f5e0
MxLong LegoWorld::Notify(MxParam& p_param)
{
MxLong ret = 0;
switch (((MxNotificationParam&) p_param).GetNotification()) {
case c_notificationEndAction: {
MxPresenter* presenter = (MxPresenter*) ((MxEndActionNotificationParam&) p_param).GetSender();
Remove(presenter);
ret = 1;
break;
}
case c_notificationNewPresenter:
TickleManager()->RegisterClient(this, 100);
break;
}
return ret;
}
// FUNCTION: LEGO1 0x1001f630
LegoCameraController* LegoWorld::VTable0x54()
{
MxBool success = FALSE;
if (!VideoManager()) {
goto done;
}
if (!(m_cameraController = new LegoCameraController())) {
goto done;
}
if (m_cameraController->Create() != SUCCESS) {
goto done;
}
m_cameraController->OnViewSize(
VideoManager()->GetVideoParam().GetRect().GetWidth(),
VideoManager()->GetVideoParam().GetRect().GetHeight()
);
success = TRUE;
done:
if (!success) {
if (m_cameraController) {
delete m_cameraController;
m_cameraController = NULL;
}
}
return m_cameraController;
}
// STUB: LEGO1 0x1001fc80
void LegoWorld::FUN_1001fc80(IslePathActor* p_actor)
{
}
// STUB: LEGO1 0x10020120
MxS32 LegoWorld::GetCurrPathInfo(LegoPathBoundary** p_path, MxS32& p_value)
{
// TODO
return 0;
}
// FUNCTION: LEGO1 0x10020220
void LegoWorld::Add(MxCore* p_object)
{
if (p_object && !p_object->IsA("LegoWorld") && !p_object->IsA("LegoWorldPresenter")) {
if (p_object->IsA("LegoAnimPresenter")) {
LegoAnimPresenter* animPresenter = (LegoAnimPresenter*) p_object;
if (!strcmpi(animPresenter->GetAction()->GetObjectName(), "ConfigAnimation")) {
FUN_1003e050(animPresenter);
animPresenter->GetAction()->SetDuration(animPresenter->GetUnknown0x64()->GetUnknown0x8());
}
}
if (p_object->IsA("MxControlPresenter")) {
MxPresenterListCursor cursor(&m_controlPresenters);
if (cursor.Find((MxPresenter*) p_object))
return;
m_controlPresenters.Append((MxPresenter*) p_object);
}
else if (p_object->IsA("MxEntity")) {
LegoEntityListCursor cursor(m_entityList);
if (cursor.Find((LegoEntity*) p_object))
return;
m_entityList->Append((LegoEntity*) p_object);
}
else if (p_object->IsA("LegoLocomotionAnimPresenter") || p_object->IsA("LegoHideAnimPresenter") || p_object->IsA("LegoLoopingAnimPresenter")) {
MxPresenterListCursor cursor(&m_animPresenters);
if (cursor.Find((MxPresenter*) p_object))
return;
((MxPresenter*) p_object)->SendToCompositePresenter(Lego());
m_animPresenters.Append(((MxPresenter*) p_object));
if (p_object->IsA("LegoHideAnimPresenter"))
m_hideAnimPresenter = (LegoHideAnimPresenter*) p_object;
}
else if (p_object->IsA("LegoCacheSound")) {
LegoCacheSoundListCursor cursor(m_cacheSoundList);
if (cursor.Find((LegoCacheSound*) p_object))
return;
m_cacheSoundList->Append((LegoCacheSound*) p_object);
}
else {
if (m_set0xa8.find(p_object) == m_set0xa8.end())
m_set0xa8.insert(p_object);
}
if (!m_set0xd0.empty() && p_object->IsA("MxPresenter")) {
if (((MxPresenter*) p_object)->IsEnabled()) {
((MxPresenter*) p_object)->Enable(FALSE);
m_set0xd0.insert(p_object);
}
}
}
}
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// STUB: LEGO1 0x10020f10
void LegoWorld::Remove(MxCore* p_object)
{
// TODO
}
// FUNCTION: LEGO1 0x100213a0
MxCore* LegoWorld::Find(const char* p_class, const char* p_name)
{
if (!strcmp(p_class, "MxControlPresenter")) {
MxPresenterListCursor cursor(&m_controlPresenters);
MxPresenter* presenter;
while (cursor.Next(presenter)) {
MxDSAction* action = presenter->GetAction();
if (!strcmp(action->GetObjectName(), p_name))
return presenter;
}
return NULL;
}
else if (!strcmp(p_class, "MxEntity")) {
LegoEntityListCursor cursor(m_entityList);
LegoEntity* entity;
while (cursor.Next(entity)) {
if (!p_name)
return entity;
LegoROI* roi = entity->GetROI();
if (roi && !strcmpi(roi->GetUnknown0xe4(), p_name))
return entity;
}
return NULL;
}
else if (!strcmp(p_class, "LegoAnimPresenter")) {
MxPresenterListCursor cursor(&m_animPresenters);
MxPresenter* presenter;
while (cursor.Next(presenter)) {
if (!strcmpi(((LegoAnimPresenter*) presenter)->GetActionObjectName(), p_name))
return presenter;
}
return NULL;
}
else {
for (MxCoreSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) {
if ((*it)->IsA(p_class) && (*it)->IsA("MxPresenter")) {
MxPresenter* presenter = (MxPresenter*) *it;
MxDSAction* action = presenter->GetAction();
if (!strcmp(action->GetObjectName(), p_name))
return *it;
}
}
return NULL;
}
}
// FUNCTION: LEGO1 0x10021790
MxCore* LegoWorld::Find(const MxAtomId& p_atom, MxS32 p_entityId)
{
LegoEntityListCursor entityCursor(m_entityList);
LegoEntity* entity;
while (entityCursor.Next(entity)) {
if (entity->GetAtom() == p_atom && entity->GetEntityId() == p_entityId)
return entity;
}
MxPresenterListCursor controlPresenterCursor(&m_controlPresenters);
MxPresenter* presenter;
while (controlPresenterCursor.Next(presenter)) {
MxDSAction* action = presenter->GetAction();
if (action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId)
return presenter;
}
MxPresenterListCursor animPresenterCursor(&m_animPresenters);
while (animPresenterCursor.Next(presenter)) {
MxDSAction* action = presenter->GetAction();
if (action && action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId)
return presenter;
}
for (MxCoreSet::iterator it = m_set0xa8.begin(); it != m_set0xa8.end(); it++) {
MxCore* core = *it;
if (core->IsA("MxPresenter")) {
MxPresenter* presenter = (MxPresenter*) *it;
MxDSAction* action = presenter->GetAction();
if (action->GetAtomId() == p_atom && action->GetObjectId() == p_entityId)
return *it;
}
}
return NULL;
}
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// STUB: LEGO1 0x10021a70
2023-10-24 19:38:27 -04:00
void LegoWorld::VTable0x68(MxBool p_add)
{
2023-10-24 19:38:27 -04:00
// TODO
}
// FUNCTION: LEGO1 0x10022080
MxResult LegoWorld::Tickle()
{
if (!m_worldStarted) {
switch (m_unk0xf4) {
case 0:
m_worldStarted = TRUE;
SetAppCursor(0);
VTable0x50();
return TRUE;
case 2:
if (FUN_100220e0() == 1)
break;
default:
m_unk0xf4--;
}
}
return TRUE;
}
// STUB: LEGO1 0x100220e0
undefined LegoWorld::FUN_100220e0()
{
return 0;
}
(Proposal) Adjustments to "decomp" language (#308) * Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commit d87d665127fae7dd6e5bd48d9af14a0a829bf9e2. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit 8c815418d261ba8c5f67a9a2cae349fe4ac92db8. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
2023-12-06 07:10:45 -05:00
// FUNCTION: LEGO1 0x10022340
void LegoWorld::VTable0x50()
{
TickleManager()->UnregisterClient(this);
}
// STUB: LEGO1 0x100727e0
2024-01-12 19:34:38 -05:00
MxBool LegoWorld::FUN_100727e0(MxU32, Mx3DPointFloat& p_loc, Mx3DPointFloat& p_dir, Mx3DPointFloat& p_up)
{
return FALSE;
}
// STUB: LEGO1 0x10072980
2024-01-12 19:34:38 -05:00
MxBool LegoWorld::FUN_10072980(MxU32, Mx3DPointFloat& p_loc, Mx3DPointFloat& p_dir, Mx3DPointFloat& p_up)
{
return FALSE;
}
// STUB: LEGO1 0x10073400
void LegoWorld::FUN_10073400()
{
}
// STUB: LEGO1 0x10073430
void LegoWorld::FUN_10073430()
{
}