isle/LEGO1/legoomni.cpp

374 lines
7 KiB
C++
Raw Normal View History

#include "legoomni.h"
#include "legogamestate.h"
#include "legoinputmanager.h"
2023-10-24 19:38:27 -04:00
#include "legoobjectfactory.h"
#include "legoutil.h"
2023-10-21 17:02:55 -04:00
#include "legoworld.h"
2023-10-24 19:38:27 -04:00
#include "mxbackgroundaudiomanager.h"
#include "mxdsfile.h"
// 0x100f4588
2023-10-24 19:38:27 -04:00
MxAtomId* g_nocdSourceName = NULL;
// 0x100f456c
2023-10-24 19:38:27 -04:00
MxAtomId* g_jukeboxScript = NULL;
// 0x101020e8
2023-10-24 19:38:27 -04:00
void (*g_omniUserMessage)(const char*, int);
// OFFSET: LEGO1 0x10058a00
LegoOmni::LegoOmni()
{
2023-10-24 19:38:27 -04:00
Init();
}
// OFFSET: LEGO1 0x10058b50
LegoOmni::~LegoOmni()
{
2023-10-24 19:38:27 -04:00
Destroy();
}
// OFFSET: LEGO1 0x1005b560
void LegoOmni::CreateBackgroundAudio()
{
2023-10-24 19:38:27 -04:00
if (m_bkgAudioManager)
m_bkgAudioManager->Create(*g_jukeboxScript, 100);
}
// OFFSET: LEGO1 0x1005af10 STUB
2023-10-24 19:38:27 -04:00
void LegoOmni::RemoveWorld(const MxAtomId& p1, MxLong p2)
{
2023-10-24 19:38:27 -04:00
// TODO
}
// OFFSET: LEGO1 0x1005b400 STUB
2023-10-24 19:38:27 -04:00
int LegoOmni::GetCurrPathInfo(LegoPathBoundary**, int&)
{
2023-10-24 19:38:27 -04:00
// TODO
return 0;
}
Implement some MxStreamer functions (#130) * Implement some MxStreamer stuff * Implement/match MxVideoManager::Tickle (#128) * Implement/match MxPresenter::StartAction * Update mxpoint32.h * Implement/match MxVideoManager::Tickle * Update mxlist.h * Update mxpresenter.cpp * MxFlcPresenter ctor/dtor (#132) * MxFlcPresenter ctor/dtor * Match constructor --------- Co-authored-by: Christian Semmler <mail@csemmler.com> * LegoOmni::CreateStreamObject and related (#129) * LegoOmni::CreateStreamObject and related * Revert change to MxDSSource/MxDSFile Read export * Bootstrap MxDSMultiAction (#133) * Bootstrap MxDSMultiAction * Move destroy function to list class * Fix unk14 call * Quick patch for EqualsDataProduct (#134) * MxLong Tickle() -> MxResult Tickle() (#135) * MxLong Tickle() -> MxResult Tickle() * Remove garbage * Fix implementations * PresenterNameDispatch (#137) * PresenterNameDispatch * Use reference for PresenterNameDispatch param - fix or add const markers so we can use a const reference * Implement/match remaining MxDSMultiAction functions (#136) * Implement/match MxDSMultiAction::Deserialize * Implement remaining functions of MxDSMultiAction * Remove space * Implement/match MxDSParallelAction (#138) * Implement/match MxDSParallelAction * Fix type * Remove space * Add neccessary MxDSMultiAction functions * Implement/match MxDSSerialAction (#139) * Implement/match MxDSSerialAction * Add neccessary MxDSMultiAction functions * Fix LegoOmni vtable (#140) * matched GetOpenStream * matched MakeSourceName * add MxDSBuffer stub * add MxRAMStreamController stub * add stubbed functions for MxStreamController used by MxStreamer * implement AddStreamControllerToOpenList * implement most of MxStreamer::Open * add note for MxStreamerSubclass1 * fix compiler issue * implement MxStreamer::Notify --------- Co-authored-by: Christian Semmler <mail@csemmler.com> Co-authored-by: Joshua Peisach <itzswirlz2020@outlook.com> Co-authored-by: MS <disinvite@users.noreply.github.com>
2023-09-25 22:30:56 -04:00
// OFFSET: LEGO1 0x100b6ff0
2023-10-24 19:38:27 -04:00
void MakeSourceName(char* p_output, const char* p_input)
{
2023-10-24 19:38:27 -04:00
const char* cln = strchr(p_input, ':');
if (cln) {
p_input = cln + 1;
}
Implement some MxStreamer functions (#130) * Implement some MxStreamer stuff * Implement/match MxVideoManager::Tickle (#128) * Implement/match MxPresenter::StartAction * Update mxpoint32.h * Implement/match MxVideoManager::Tickle * Update mxlist.h * Update mxpresenter.cpp * MxFlcPresenter ctor/dtor (#132) * MxFlcPresenter ctor/dtor * Match constructor --------- Co-authored-by: Christian Semmler <mail@csemmler.com> * LegoOmni::CreateStreamObject and related (#129) * LegoOmni::CreateStreamObject and related * Revert change to MxDSSource/MxDSFile Read export * Bootstrap MxDSMultiAction (#133) * Bootstrap MxDSMultiAction * Move destroy function to list class * Fix unk14 call * Quick patch for EqualsDataProduct (#134) * MxLong Tickle() -> MxResult Tickle() (#135) * MxLong Tickle() -> MxResult Tickle() * Remove garbage * Fix implementations * PresenterNameDispatch (#137) * PresenterNameDispatch * Use reference for PresenterNameDispatch param - fix or add const markers so we can use a const reference * Implement/match remaining MxDSMultiAction functions (#136) * Implement/match MxDSMultiAction::Deserialize * Implement remaining functions of MxDSMultiAction * Remove space * Implement/match MxDSParallelAction (#138) * Implement/match MxDSParallelAction * Fix type * Remove space * Add neccessary MxDSMultiAction functions * Implement/match MxDSSerialAction (#139) * Implement/match MxDSSerialAction * Add neccessary MxDSMultiAction functions * Fix LegoOmni vtable (#140) * matched GetOpenStream * matched MakeSourceName * add MxDSBuffer stub * add MxRAMStreamController stub * add stubbed functions for MxStreamController used by MxStreamer * implement AddStreamControllerToOpenList * implement most of MxStreamer::Open * add note for MxStreamerSubclass1 * fix compiler issue * implement MxStreamer::Notify --------- Co-authored-by: Christian Semmler <mail@csemmler.com> Co-authored-by: Joshua Peisach <itzswirlz2020@outlook.com> Co-authored-by: MS <disinvite@users.noreply.github.com>
2023-09-25 22:30:56 -04:00
2023-10-24 19:38:27 -04:00
strcpy(p_output, p_input);
Implement some MxStreamer functions (#130) * Implement some MxStreamer stuff * Implement/match MxVideoManager::Tickle (#128) * Implement/match MxPresenter::StartAction * Update mxpoint32.h * Implement/match MxVideoManager::Tickle * Update mxlist.h * Update mxpresenter.cpp * MxFlcPresenter ctor/dtor (#132) * MxFlcPresenter ctor/dtor * Match constructor --------- Co-authored-by: Christian Semmler <mail@csemmler.com> * LegoOmni::CreateStreamObject and related (#129) * LegoOmni::CreateStreamObject and related * Revert change to MxDSSource/MxDSFile Read export * Bootstrap MxDSMultiAction (#133) * Bootstrap MxDSMultiAction * Move destroy function to list class * Fix unk14 call * Quick patch for EqualsDataProduct (#134) * MxLong Tickle() -> MxResult Tickle() (#135) * MxLong Tickle() -> MxResult Tickle() * Remove garbage * Fix implementations * PresenterNameDispatch (#137) * PresenterNameDispatch * Use reference for PresenterNameDispatch param - fix or add const markers so we can use a const reference * Implement/match remaining MxDSMultiAction functions (#136) * Implement/match MxDSMultiAction::Deserialize * Implement remaining functions of MxDSMultiAction * Remove space * Implement/match MxDSParallelAction (#138) * Implement/match MxDSParallelAction * Fix type * Remove space * Add neccessary MxDSMultiAction functions * Implement/match MxDSSerialAction (#139) * Implement/match MxDSSerialAction * Add neccessary MxDSMultiAction functions * Fix LegoOmni vtable (#140) * matched GetOpenStream * matched MakeSourceName * add MxDSBuffer stub * add MxRAMStreamController stub * add stubbed functions for MxStreamController used by MxStreamer * implement AddStreamControllerToOpenList * implement most of MxStreamer::Open * add note for MxStreamerSubclass1 * fix compiler issue * implement MxStreamer::Notify --------- Co-authored-by: Christian Semmler <mail@csemmler.com> Co-authored-by: Joshua Peisach <itzswirlz2020@outlook.com> Co-authored-by: MS <disinvite@users.noreply.github.com>
2023-09-25 22:30:56 -04:00
2023-10-24 19:38:27 -04:00
strlwr(p_output);
Implement some MxStreamer functions (#130) * Implement some MxStreamer stuff * Implement/match MxVideoManager::Tickle (#128) * Implement/match MxPresenter::StartAction * Update mxpoint32.h * Implement/match MxVideoManager::Tickle * Update mxlist.h * Update mxpresenter.cpp * MxFlcPresenter ctor/dtor (#132) * MxFlcPresenter ctor/dtor * Match constructor --------- Co-authored-by: Christian Semmler <mail@csemmler.com> * LegoOmni::CreateStreamObject and related (#129) * LegoOmni::CreateStreamObject and related * Revert change to MxDSSource/MxDSFile Read export * Bootstrap MxDSMultiAction (#133) * Bootstrap MxDSMultiAction * Move destroy function to list class * Fix unk14 call * Quick patch for EqualsDataProduct (#134) * MxLong Tickle() -> MxResult Tickle() (#135) * MxLong Tickle() -> MxResult Tickle() * Remove garbage * Fix implementations * PresenterNameDispatch (#137) * PresenterNameDispatch * Use reference for PresenterNameDispatch param - fix or add const markers so we can use a const reference * Implement/match remaining MxDSMultiAction functions (#136) * Implement/match MxDSMultiAction::Deserialize * Implement remaining functions of MxDSMultiAction * Remove space * Implement/match MxDSParallelAction (#138) * Implement/match MxDSParallelAction * Fix type * Remove space * Add neccessary MxDSMultiAction functions * Implement/match MxDSSerialAction (#139) * Implement/match MxDSSerialAction * Add neccessary MxDSMultiAction functions * Fix LegoOmni vtable (#140) * matched GetOpenStream * matched MakeSourceName * add MxDSBuffer stub * add MxRAMStreamController stub * add stubbed functions for MxStreamController used by MxStreamer * implement AddStreamControllerToOpenList * implement most of MxStreamer::Open * add note for MxStreamerSubclass1 * fix compiler issue * implement MxStreamer::Notify --------- Co-authored-by: Christian Semmler <mail@csemmler.com> Co-authored-by: Joshua Peisach <itzswirlz2020@outlook.com> Co-authored-by: MS <disinvite@users.noreply.github.com>
2023-09-25 22:30:56 -04:00
2023-10-24 19:38:27 -04:00
char* extLoc = strstr(p_output, ".si");
if (extLoc) {
*extLoc = 0;
}
}
// OFFSET: LEGO1 0x100b7050
2023-10-24 19:38:27 -04:00
MxBool KeyValueStringParse(char* p_outputValue, const char* p_key, const char* p_source)
{
2023-10-24 19:38:27 -04:00
MxBool didMatch = FALSE;
2023-10-24 19:38:27 -04:00
MxS16 len = strlen(p_source);
char* temp = new char[len + 1];
strcpy(temp, p_source);
2023-10-24 19:38:27 -04:00
char* token = strtok(temp, ", \t\r\n:");
while (token) {
len -= (strlen(token) + 1);
2023-10-24 19:38:27 -04:00
if (strcmpi(token, p_key) == 0) {
if (p_outputValue && len > 0) {
char* cur = &token[strlen(p_key)];
cur++;
while (*cur != ',') {
if (*cur == ' ' || *cur == '\0' || *cur == '\t' || *cur == '\n' || *cur == '\r')
break;
*p_outputValue++ = *cur++;
}
*p_outputValue = '\0';
}
2023-10-24 19:38:27 -04:00
didMatch = TRUE;
break;
}
2023-10-24 19:38:27 -04:00
token = strtok(NULL, ", \t\r\n:");
}
2023-10-24 19:38:27 -04:00
delete[] temp;
return didMatch;
}
// OFFSET: LEGO1 0x100b7210
2023-10-24 19:38:27 -04:00
void SetOmniUserMessage(void (*p_userMsg)(const char*, int))
{
2023-10-24 19:38:27 -04:00
g_omniUserMessage = p_userMsg;
}
// OFFSET: LEGO1 0x100acf50
MxResult Start(MxDSAction* p_dsAction)
{
2023-10-24 19:38:27 -04:00
return MxOmni::GetInstance()->Start(p_dsAction);
}
2023-06-18 23:56:55 -04:00
// OFFSET: LEGO1 0x1005ad10
2023-10-24 19:38:27 -04:00
LegoOmni* LegoOmni::GetInstance()
{
2023-10-24 19:38:27 -04:00
return (LegoOmni*) MxOmni::GetInstance();
}
// OFFSET: LEGO1 0x1005ac90
void LegoOmni::CreateInstance()
{
2023-10-24 19:38:27 -04:00
MxOmni::DestroyInstance();
MxOmni::SetInstance(new LegoOmni());
}
2023-06-18 23:56:55 -04:00
// OFFSET: LEGO1 0x10015700
2023-10-24 19:38:27 -04:00
LegoOmni* Lego()
{
2023-10-24 19:38:27 -04:00
return (LegoOmni*) MxOmni::GetInstance();
}
2023-06-22 12:23:54 -04:00
// OFFSET: LEGO1 0x10015710
2023-10-24 19:38:27 -04:00
LegoSoundManager* SoundManager()
2023-06-22 12:23:54 -04:00
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetSoundManager();
2023-06-22 12:23:54 -04:00
}
2023-06-18 23:56:55 -04:00
// OFFSET: LEGO1 0x10015720
2023-10-24 19:38:27 -04:00
LegoVideoManager* VideoManager()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetVideoManager();
2023-06-18 23:56:55 -04:00
}
// OFFSET: LEGO1 0x10015730
2023-10-24 19:38:27 -04:00
MxBackgroundAudioManager* BackgroundAudioManager()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetBackgroundAudioManager();
}
// OFFSET: LEGO1 0x10015740
2023-10-24 19:38:27 -04:00
LegoInputManager* InputManager()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetInputManager();
}
// OFFSET: LEGO1 0x10015750
2023-10-24 19:38:27 -04:00
LegoControlManager* ControlManager()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetInputManager()->GetControlManager();
}
// OFFSET: LEGO1 0x10015760
2023-10-24 19:38:27 -04:00
LegoGameState* GameState()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetGameState();
}
// OFFSET: LEGO1 0x10015770
2023-10-24 19:38:27 -04:00
LegoAnimationManager* AnimationManager()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetAnimationManager();
}
// OFFSET: LEGO1 0x10015780
2023-10-24 19:38:27 -04:00
LegoNavController* NavController()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetNavController();
}
// OFFSET: LEGO1 0x10015790
2023-10-24 19:38:27 -04:00
LegoWorld* GetCurrentVehicle()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetCurrentVehicle();
}
// OFFSET: LEGO1 0x100157a0
2023-10-24 19:38:27 -04:00
LegoWorld* GetCurrentWorld()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetCurrentWorld();
}
// OFFSET: LEGO1 0x100157e0
2023-10-24 19:38:27 -04:00
LegoPlantManager* PlantManager()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetLegoPlantManager();
}
// OFFSET: LEGO1 0x100157f0
2023-10-24 19:38:27 -04:00
LegoBuildingManager* BuildingManager()
2023-06-22 12:23:54 -04:00
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetLegoBuildingManager();
}
// OFFSET: LEGO1 0x10015800
2023-10-24 19:38:27 -04:00
GifManager* GetGifManager()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetGifManager();
}
// OFFSET: LEGO1 0x10015900
2023-10-24 19:38:27 -04:00
MxTransitionManager* TransitionManager()
{
2023-10-24 19:38:27 -04:00
return LegoOmni::GetInstance()->GetTransitionManager();
2023-06-22 12:23:54 -04:00
}
// OFFSET: LEGO1 0x100c0280
2023-10-24 19:38:27 -04:00
MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs)
{
2023-10-24 19:38:27 -04:00
char* buf;
_MMCKINFO tmp_chunk;
2023-10-24 19:38:27 -04:00
if (p_file->Seek(((MxLong*) p_file->GetBuffer())[p_ofs], 0)) {
return NULL;
}
2023-10-24 19:38:27 -04:00
if (p_file->Read((MxU8*) &tmp_chunk.ckid, 8) == 0 && tmp_chunk.ckid == FOURCC('M', 'x', 'S', 't')) {
if (p_file->Read((MxU8*) &tmp_chunk.ckid, 8) == 0 && tmp_chunk.ckid == FOURCC('M', 'x', 'O', 'b')) {
2023-10-24 19:38:27 -04:00
buf = new char[tmp_chunk.cksize];
if (!buf) {
return NULL;
}
2023-10-24 19:38:27 -04:00
if (p_file->Read((MxU8*) buf, tmp_chunk.cksize) != 0) {
return NULL;
}
2023-10-24 19:38:27 -04:00
// Save a copy so we can clean up properly, because
// this function will alter the pointer value.
char* copy = buf;
MxDSObject* obj = DeserializeDSObjectDispatch(&buf, -1);
delete[] copy;
return obj;
}
return NULL;
}
2023-10-24 19:38:27 -04:00
return NULL;
}
// OFFSET: LEGO1 0x10053430
2023-10-24 19:38:27 -04:00
const char* GetNoCD_SourceName()
{
2023-10-24 19:38:27 -04:00
return g_nocdSourceName->GetInternal();
}
// OFFSET: LEGO1 0x1005b5f0
2023-10-24 19:38:27 -04:00
MxLong LegoOmni::Notify(MxParam& p)
{
2023-10-24 19:38:27 -04:00
// TODO
return 0;
}
// OFFSET: LEGO1 0x1003dd70 STUB
2023-10-24 19:38:27 -04:00
LegoROI* PickROI(MxLong, MxLong)
{
2023-10-24 19:38:27 -04:00
// TODO
return NULL;
}
// OFFSET: LEGO1 0x1003ddc0 STUB
2023-10-24 19:38:27 -04:00
LegoEntity* PickEntity(MxLong, MxLong)
{
2023-10-24 19:38:27 -04:00
// TODO
return NULL;
}
// OFFSET: LEGO1 0x10058bd0
void LegoOmni::Init()
{
2023-10-24 19:38:27 -04:00
MxOmni::Init();
m_unk68 = 0;
m_inputMgr = NULL;
m_unk6c = 0;
m_gifManager = NULL;
m_unk78 = 0;
m_currentWorld = NULL;
m_unk80 = FALSE;
m_currentVehicle = NULL;
m_unkLegoSaveDataWriter = NULL;
m_plantManager = NULL;
m_gameState = NULL;
m_animationManager = NULL;
m_buildingManager = NULL;
m_bkgAudioManager = NULL;
m_unk13c = TRUE;
m_transitionManager = NULL;
}
// OFFSET: LEGO1 0x10058e70 STUB
2023-10-24 19:38:27 -04:00
MxResult LegoOmni::Create(MxOmniCreateParam& p)
{
2023-10-24 19:38:27 -04:00
MxOmni::Create(p);
2023-10-24 19:38:27 -04:00
m_objectFactory = new LegoObjectFactory();
m_gameState = new LegoGameState();
m_bkgAudioManager = new MxBackgroundAudioManager();
2023-10-24 19:38:27 -04:00
return SUCCESS;
}
// OFFSET: LEGO1 0x10058c30 STUB
void LegoOmni::Destroy()
{
2023-10-24 19:38:27 -04:00
// TODO
}
// OFFSET: LEGO1 0x1005b580
MxResult LegoOmni::Start(MxDSAction* action)
{
2023-10-24 19:38:27 -04:00
MxResult result = MxOmni::Start(action);
this->m_action.SetAtomId(action->GetAtomId());
this->m_action.SetObjectId(action->GetObjectId());
this->m_action.SetUnknown24(action->GetUnknown24());
return result;
}
// OFFSET: LEGO1 0x1005b1d0 STUB
2023-10-24 19:38:27 -04:00
MxResult LegoOmni::DeleteObject(MxDSAction& ds)
{
2023-10-24 19:38:27 -04:00
// TODO
return FAILURE;
}
// OFFSET: LEGO1 0x1005b3c0 STUB
2023-10-24 19:38:27 -04:00
MxBool LegoOmni::DoesEntityExist(MxDSAction& ds)
{
2023-10-24 19:38:27 -04:00
// TODO
return TRUE;
}
// OFFSET: LEGO1 0x1005b2f0 STUB
int LegoOmni::Vtable0x30(char*, int, MxCore*)
{
2023-10-24 19:38:27 -04:00
// TODO
return 0;
}
2023-10-21 17:02:55 -04:00
// OFFSET: LEGO1 0x1005b3a0
2023-10-24 19:38:27 -04:00
void LegoOmni::NotifyCurrentEntity(MxNotificationParam* p_param)
{
2023-10-24 19:38:27 -04:00
if (m_currentWorld)
NotificationManager()->Send(m_currentWorld, p_param);
}
// OFFSET: LEGO1 0x1005b640
2023-09-25 16:28:25 -04:00
void LegoOmni::StartTimer()
{
2023-10-24 19:38:27 -04:00
MxOmni::StartTimer();
SetAppCursor(2);
}
// OFFSET: LEGO1 0x1005b650
void LegoOmni::StopTimer()
{
2023-10-24 19:38:27 -04:00
MxOmni::StopTimer();
SetAppCursor(0);
}