2023-06-30 14:34:39 -04:00
|
|
|
#include "legogamestate.h"
|
2023-10-07 11:30:04 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "infocenterstate.h"
|
2024-01-13 15:42:09 -05:00
|
|
|
#include "legoanimationmanager.h"
|
2023-07-03 13:25:37 -04:00
|
|
|
#include "legoomni.h"
|
2023-10-12 12:18:24 -04:00
|
|
|
#include "legostate.h"
|
2024-01-13 15:42:09 -05:00
|
|
|
#include "legoutil.h"
|
|
|
|
#include "legovideomanager.h"
|
2024-02-02 16:32:50 -05:00
|
|
|
#include "legoworld.h"
|
2024-01-13 15:42:09 -05:00
|
|
|
#include "mxbackgroundaudiomanager.h"
|
2023-10-12 12:18:24 -04:00
|
|
|
#include "mxobjectfactory.h"
|
|
|
|
#include "mxstring.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "mxvariabletable.h"
|
2024-01-08 04:58:49 -05:00
|
|
|
#include "roi/legoroi.h"
|
2023-09-29 16:38:08 -04:00
|
|
|
|
2024-01-06 12:56:15 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2024-02-19 09:24:30 -05:00
|
|
|
DECOMP_SIZE_ASSERT(LegoGameState::ScoreName, 0xe)
|
|
|
|
DECOMP_SIZE_ASSERT(LegoGameState::ScoreItem, 0x2c)
|
|
|
|
DECOMP_SIZE_ASSERT(LegoGameState::Scores, 0x372)
|
2023-09-29 16:38:08 -04:00
|
|
|
DECOMP_SIZE_ASSERT(LegoGameState, 0x430)
|
2023-06-30 14:34:39 -04:00
|
|
|
|
2024-01-14 16:28:46 -05:00
|
|
|
// GLOBAL: LEGO1 0x100f3e40
|
2024-01-17 06:56:34 -05:00
|
|
|
// STRING: LEGO1 0x100f3e3c
|
2024-01-14 16:28:46 -05:00
|
|
|
const char* g_fileExtensionGS = ".GS";
|
2023-12-15 17:01:09 -05:00
|
|
|
|
2024-01-14 16:28:46 -05:00
|
|
|
// GLOBAL: LEGO1 0x100f3e44
|
2024-01-17 06:56:34 -05:00
|
|
|
// STRING: LEGO1 0x100f3e30
|
2023-12-15 17:01:09 -05:00
|
|
|
const char* g_playersGSI = "Players.gsi";
|
|
|
|
|
2024-01-14 16:28:46 -05:00
|
|
|
// GLOBAL: LEGO1 0x100f3e48
|
2024-01-17 06:56:34 -05:00
|
|
|
// STRING: LEGO1 0x100f3e24
|
2024-01-14 16:28:46 -05:00
|
|
|
const char* g_historyGSI = "History.gsi";
|
2023-10-12 12:18:24 -04:00
|
|
|
|
2024-01-24 12:12:57 -05:00
|
|
|
// This is a pointer to the end of the global variable name table, which has
|
|
|
|
// the text "END_OF_VARIABLES" in it.
|
|
|
|
// TODO: make g_endOfVariables reference the actual end of the variable array.
|
|
|
|
// GLOBAL: LEGO1 0x100f3e50
|
|
|
|
// STRING: LEGO1 0x100f3e00
|
|
|
|
const char* g_endOfVariables = "END_OF_VARIABLES";
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// GLOBAL: LEGO1 0x100f3e58
|
2023-10-12 12:18:24 -04:00
|
|
|
ColorStringStruct g_colorSaveData[43] = {
|
2023-10-24 19:38:27 -04:00
|
|
|
{"c_dbbkfny0", "lego red"}, {"c_dbbkxly0", "lego white"}, {"c_chbasey0", "lego black"},
|
|
|
|
{"c_chbacky0", "lego black"}, {"c_chdishy0", "lego white"}, {"c_chhorny0", "lego black"},
|
|
|
|
{"c_chljety1", "lego black"}, {"c_chrjety1", "lego black"}, {"c_chmidly0", "lego black"},
|
|
|
|
{"c_chmotry0", "lego blue"}, {"c_chsidly0", "lego black"}, {"c_chsidry0", "lego black"},
|
|
|
|
{"c_chstuty0", "lego black"}, {"c_chtaily0", "lego black"}, {"c_chwindy1", "lego black"},
|
|
|
|
{"c_dbfbrdy0", "lego red"}, {"c_dbflagy0", "lego yellow"}, {"c_dbfrfny4", "lego red"},
|
|
|
|
{"c_dbfrxly0", "lego white"}, {"c_dbhndly0", "lego white"}, {"c_dbltbry0", "lego white"},
|
|
|
|
{"c_jsdashy0", "lego white"}, {"c_jsexhy0", "lego black"}, {"c_jsfrnty5", "lego black"},
|
|
|
|
{"c_jshndly0", "lego red"}, {"c_jslsidy0", "lego black"}, {"c_jsrsidy0", "lego black"},
|
|
|
|
{"c_jsskiby0", "lego red"}, {"c_jswnshy5", "lego white"}, {"c_rcbacky6", "lego green"},
|
|
|
|
{"c_rcedgey0", "lego green"}, {"c_rcfrmey0", "lego red"}, {"c_rcfrnty6", "lego green"},
|
|
|
|
{"c_rcmotry0", "lego white"}, {"c_rcsidey0", "lego green"}, {"c_rcstery0", "lego white"},
|
|
|
|
{"c_rcstrpy0", "lego yellow"}, {"c_rctailya", "lego white"}, {"c_rcwhl1y0", "lego white"},
|
|
|
|
{"c_rcwhl2y0", "lego white"}, {"c_jsbasey0", "lego white"}, {"c_chblady0", "lego black"},
|
|
|
|
{"c_chseaty0", "lego white"},
|
2023-10-12 12:18:24 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// NOTE: This offset = the end of the variables table, the last entry
|
|
|
|
// in that table is a special entry, the string "END_OF_VARIABLES"
|
2023-12-13 05:48:14 -05:00
|
|
|
extern const char* g_endOfVariables;
|
2023-10-12 12:18:24 -04:00
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10039550
|
2023-06-30 14:34:39 -04:00
|
|
|
LegoGameState::LegoGameState()
|
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
// TODO
|
2023-11-01 11:12:03 -04:00
|
|
|
SetROIHandlerFunction();
|
|
|
|
|
2024-01-17 16:24:22 -05:00
|
|
|
this->m_stateCount = 0;
|
2024-01-29 16:17:17 -05:00
|
|
|
this->m_unk0x0c = 0;
|
2024-01-17 16:24:22 -05:00
|
|
|
this->m_savePath = NULL;
|
2024-02-10 13:17:07 -05:00
|
|
|
this->m_currentArea = e_noArea;
|
|
|
|
this->m_previousArea = e_noArea;
|
|
|
|
this->m_unk0x42c = e_noArea;
|
2024-01-17 16:24:22 -05:00
|
|
|
this->m_isDirty = FALSE;
|
2024-02-10 11:37:22 -05:00
|
|
|
this->m_loadedAct = e_actNotFound;
|
2024-01-17 16:24:22 -05:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
m_backgroundColor = new LegoBackgroundColor("backgroundcolor", "set 56 54 68");
|
|
|
|
VariableTable()->SetVariable(m_backgroundColor);
|
2023-09-29 16:38:08 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
m_tempBackgroundColor = new LegoBackgroundColor("tempBackgroundcolor", "set 56 54 68");
|
|
|
|
VariableTable()->SetVariable(m_tempBackgroundColor);
|
2023-09-29 16:38:08 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
m_fullScreenMovie = new LegoFullScreenMovie("fsmovie", "disable");
|
|
|
|
VariableTable()->SetVariable(m_fullScreenMovie);
|
2023-09-29 16:38:08 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
VariableTable()->SetVariable("lightposition", "2");
|
|
|
|
SerializeScoreHistory(1);
|
2023-06-30 14:34:39 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10039720
|
2023-06-30 14:34:39 -04:00
|
|
|
LegoGameState::~LegoGameState()
|
|
|
|
{
|
2023-11-01 11:12:03 -04:00
|
|
|
LegoROI::SetSomeHandlerFunction(NULL);
|
|
|
|
|
|
|
|
if (m_stateCount) {
|
|
|
|
for (MxS16 i = 0; i < m_stateCount; i++) {
|
|
|
|
LegoState* state = m_stateArray[i];
|
2024-02-01 15:42:10 -05:00
|
|
|
if (state) {
|
2023-11-01 11:12:03 -04:00
|
|
|
delete state;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-11-01 11:12:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
delete[] m_stateArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] m_savePath;
|
2023-06-30 14:34:39 -04:00
|
|
|
}
|
|
|
|
|
2024-01-17 11:53:53 -05:00
|
|
|
// STUB: LEGO1 0x10039780
|
|
|
|
void LegoGameState::FUN_10039780(MxU8)
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2024-02-02 12:18:46 -05:00
|
|
|
// STUB: LEGO1 0x10039940
|
|
|
|
void LegoGameState::FUN_10039940()
|
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10039980
|
2023-10-12 12:18:24 -04:00
|
|
|
MxResult LegoGameState::Save(MxULong p_slot)
|
2023-06-30 14:34:39 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
MxResult result;
|
|
|
|
InfocenterState* infocenterState = (InfocenterState*) GameState()->GetState("InfocenterState");
|
2024-01-17 11:53:53 -05:00
|
|
|
|
2024-02-11 10:44:55 -05:00
|
|
|
if (!infocenterState || !infocenterState->HasRegistered()) {
|
2023-10-24 19:38:27 -04:00
|
|
|
result = SUCCESS;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-10-24 19:38:27 -04:00
|
|
|
else {
|
|
|
|
result = FAILURE;
|
|
|
|
MxVariableTable* variableTable = VariableTable();
|
|
|
|
MxString savePath;
|
|
|
|
GetFileSavePath(&savePath, p_slot);
|
2024-01-24 12:12:57 -05:00
|
|
|
LegoFile fileStream;
|
|
|
|
if (fileStream.Open(savePath.GetData(), LegoFile::c_write) != FAILURE) {
|
2023-10-24 19:38:27 -04:00
|
|
|
MxU32 maybeVersion = 0x1000C;
|
|
|
|
fileStream.Write(&maybeVersion, 4);
|
2023-12-13 05:48:14 -05:00
|
|
|
fileStream.Write(&m_unk0x24, 2);
|
2024-02-10 11:37:22 -05:00
|
|
|
fileStream.Write(&m_currentAct, 2);
|
2024-01-29 16:17:17 -05:00
|
|
|
fileStream.Write(&m_unk0x0c, 1);
|
2023-10-24 19:38:27 -04:00
|
|
|
|
|
|
|
for (MxS32 i = 0; i < sizeof(g_colorSaveData) / sizeof(g_colorSaveData[0]); ++i) {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (WriteVariable(&fileStream, variableTable, g_colorSaveData[i].m_targetName) == FAILURE) {
|
2023-10-24 19:38:27 -04:00
|
|
|
return result;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-10-24 19:38:27 -04:00
|
|
|
}
|
|
|
|
|
2024-01-24 12:12:57 -05:00
|
|
|
if (WriteVariable(&fileStream, variableTable, "backgroundcolor") != FAILURE) {
|
|
|
|
if (WriteVariable(&fileStream, variableTable, "lightposition") != FAILURE) {
|
2023-10-24 19:38:27 -04:00
|
|
|
WriteEndOfVariables(&fileStream);
|
|
|
|
|
|
|
|
// TODO: Calls down to more aggregate writing functions
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
2023-06-30 14:34:39 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// STUB: LEGO1 0x10039c60
|
2023-11-21 03:44:45 -05:00
|
|
|
MxResult LegoGameState::Load(MxULong)
|
2023-06-30 14:34:39 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
// TODO
|
2023-11-21 03:44:45 -05:00
|
|
|
return 0;
|
2023-11-06 04:00:24 -05:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x10039f00
|
2023-10-24 19:38:27 -04:00
|
|
|
void LegoGameState::SetSavePath(char* p_savePath)
|
2023-06-30 14:34:39 -04:00
|
|
|
{
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_savePath != NULL) {
|
2023-10-24 19:38:27 -04:00
|
|
|
delete[] m_savePath;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-10-24 19:38:27 -04:00
|
|
|
|
|
|
|
if (p_savePath) {
|
|
|
|
m_savePath = new char[strlen(p_savePath) + 1];
|
|
|
|
strcpy(m_savePath, p_savePath);
|
|
|
|
}
|
2024-02-01 15:42:10 -05:00
|
|
|
else {
|
2023-10-24 19:38:27 -04:00
|
|
|
m_savePath = NULL;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-06-30 14:34:39 -04:00
|
|
|
}
|
2023-10-12 12:18:24 -04:00
|
|
|
|
2024-01-24 12:12:57 -05:00
|
|
|
// FUNCTION: LEGO1 0x10039f70
|
|
|
|
MxResult LegoGameState::WriteVariable(LegoStorage* p_stream, MxVariableTable* p_from, const char* p_variableName)
|
|
|
|
{
|
|
|
|
MxResult result = FAILURE;
|
|
|
|
const char* variableValue = p_from->GetVariable(p_variableName);
|
|
|
|
|
|
|
|
if (variableValue) {
|
|
|
|
MxU8 length = strlen(p_variableName);
|
|
|
|
if (p_stream->Write((char*) &length, 1) == SUCCESS) {
|
|
|
|
if (p_stream->Write(p_variableName, length) == SUCCESS) {
|
|
|
|
length = strlen(variableValue);
|
2024-02-01 15:42:10 -05:00
|
|
|
if (p_stream->Write((char*) &length, 1) == SUCCESS) {
|
2024-01-24 12:12:57 -05:00
|
|
|
result = p_stream->Write((char*) variableValue, length);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-24 12:12:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003a020
|
2024-01-24 12:12:57 -05:00
|
|
|
MxResult LegoGameState::WriteEndOfVariables(LegoStorage* p_stream)
|
2023-11-21 03:44:45 -05:00
|
|
|
{
|
2023-12-13 05:48:14 -05:00
|
|
|
MxU8 len = strlen(g_endOfVariables);
|
2024-02-01 15:42:10 -05:00
|
|
|
if (p_stream->Write(&len, 1) == SUCCESS) {
|
2023-12-13 05:48:14 -05:00
|
|
|
return p_stream->Write(g_endOfVariables, len);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-11-21 03:44:45 -05:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2024-01-24 12:12:57 -05:00
|
|
|
// 95% match, just some instruction ordering differences on the call to
|
|
|
|
// MxVariableTable::SetVariable at the end.
|
|
|
|
// FUNCTION: LEGO1 0x1003a080
|
|
|
|
MxS32 LegoGameState::ReadVariable(LegoStorage* p_stream, MxVariableTable* p_to)
|
|
|
|
{
|
|
|
|
MxS32 result = 1;
|
|
|
|
MxU8 length;
|
|
|
|
|
|
|
|
if (p_stream->Read((char*) &length, 1) == SUCCESS) {
|
|
|
|
char nameBuffer[256];
|
|
|
|
if (p_stream->Read(nameBuffer, length) == SUCCESS) {
|
|
|
|
nameBuffer[length] = '\0';
|
2024-02-01 15:42:10 -05:00
|
|
|
if (strcmp(nameBuffer, g_endOfVariables) == 0) {
|
2024-01-24 12:12:57 -05:00
|
|
|
// 2 -> "This was the last entry, done reading."
|
|
|
|
result = 2;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-24 12:12:57 -05:00
|
|
|
else {
|
|
|
|
if (p_stream->Read((char*) &length, 1) == SUCCESS) {
|
|
|
|
char valueBuffer[256];
|
|
|
|
if (p_stream->Read(valueBuffer, length) == SUCCESS) {
|
|
|
|
result = 0;
|
|
|
|
valueBuffer[length] = '\0';
|
|
|
|
p_to->SetVariable(nameBuffer, valueBuffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003a170
|
2023-11-21 03:44:45 -05:00
|
|
|
void LegoGameState::GetFileSavePath(MxString* p_outPath, MxULong p_slotn)
|
|
|
|
{
|
|
|
|
char baseForSlot[2] = "0";
|
|
|
|
char path[1024] = "";
|
|
|
|
|
|
|
|
// Save path base
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_savePath != NULL) {
|
2023-11-21 03:44:45 -05:00
|
|
|
strcpy(path, m_savePath);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-11-21 03:44:45 -05:00
|
|
|
|
|
|
|
// Slot: "G0", "G1", ...
|
2024-01-14 16:28:46 -05:00
|
|
|
strcat(path, "\\G");
|
2023-11-21 03:44:45 -05:00
|
|
|
baseForSlot[0] += p_slotn;
|
|
|
|
strcat(path, baseForSlot);
|
|
|
|
|
|
|
|
// Extension: ".GS"
|
|
|
|
strcat(path, g_fileExtensionGS);
|
|
|
|
*p_outPath = MxString(path);
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// STUB: LEGO1 0x1003a2e0
|
2023-12-13 05:48:14 -05:00
|
|
|
void LegoGameState::SerializePlayersInfo(MxS16)
|
2023-11-21 03:44:45 -05:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2024-01-31 07:34:36 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003a720
|
2024-02-10 13:17:07 -05:00
|
|
|
void LegoGameState::StopArea(Area p_area)
|
2023-11-21 03:44:45 -05:00
|
|
|
{
|
2024-02-10 13:17:07 -05:00
|
|
|
if (p_area == e_previousArea) {
|
2024-01-31 07:34:36 -05:00
|
|
|
p_area = m_previousArea;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (p_area) {
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_isle:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_isleScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_isleScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_sndAnimScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_infomain:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_infomainScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_infomainScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_infodoor:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_infodoorScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_infodoorScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_elevbott:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_elevbottScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_elevbottScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk6:
|
|
|
|
case e_unk7:
|
2024-01-31 07:34:36 -05:00
|
|
|
RemoveFromWorld(*g_isleScript, 0x41b, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 1052, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x41d, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x41e, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x420, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x422, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x424, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x426, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x428, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x42a, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x42b, *g_isleScript, 0);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk8:
|
2024-01-31 07:34:36 -05:00
|
|
|
RemoveFromWorld(*g_isleScript, 0x45b, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x45c, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x45d, *g_isleScript, 0);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk9:
|
2024-01-31 07:34:36 -05:00
|
|
|
RemoveFromWorld(*g_isleScript, 0x475, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x476, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x477, *g_isleScript, 0);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk10:
|
2024-01-31 07:34:36 -05:00
|
|
|
RemoveFromWorld(*g_isleScript, 0x45f, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x460, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x461, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x462, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x463, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x464, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x465, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x466, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x467, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x469, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x468, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x46a, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x46b, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x46c, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x46d, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x46e, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x46f, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x471, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x472, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x12, *g_isleScript, 0);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk11:
|
2024-01-31 07:34:36 -05:00
|
|
|
RemoveFromWorld(*g_isleScript, 0x47a, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x47b, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x47c, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x47d, *g_isleScript, 0);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_regbook:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_regbookScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_regbookScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_infoscor:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_infoscorScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_infoscorScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_jetrace:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_jetraceScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_jetraceScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_jetracerScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_carrace:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_carraceScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_carraceScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_carracerScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_garage:
|
2024-01-31 07:34:36 -05:00
|
|
|
Lego()->RemoveWorld(*g_garageScript, 0);
|
|
|
|
InvokeAction(Extra::e_stop, *g_garageScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_garageScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk27:
|
2024-01-31 07:34:36 -05:00
|
|
|
RemoveFromWorld(*g_isleScript, 0x489, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x48a, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x48b, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x48c, *g_isleScript, 0);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_hospital:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_hospitalScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_hospitalScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_police:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_policeScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_policeScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk35:
|
2024-01-31 07:34:36 -05:00
|
|
|
RemoveFromWorld(*g_isleScript, 0x47f, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x480, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x481, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, 0x482, *g_isleScript, 0);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_copter:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_jukeboxScript, 0x2f, NULL);
|
|
|
|
InvokeAction(Extra::e_stop, *g_copterScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_copterScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_dunecar:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_jukeboxScript, 0x31, NULL);
|
|
|
|
InvokeAction(Extra::e_stop, *g_dunecarScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_dunecarScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_jetski:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_jukeboxScript, 0x33, NULL);
|
|
|
|
InvokeAction(Extra::e_stop, *g_jetskiScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_jetskiScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_racecar:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_jukeboxScript, 0x35, NULL);
|
|
|
|
InvokeAction(Extra::e_stop, *g_racecarScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_racecarScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_act2main:
|
2024-01-31 07:34:36 -05:00
|
|
|
if (m_currentArea != 2) {
|
|
|
|
InvokeAction(Extra::e_stop, *g_act2mainScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_act2mainScript, 0, NULL);
|
|
|
|
}
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_act3script:
|
2024-01-31 07:34:36 -05:00
|
|
|
if (m_currentArea != 2) {
|
|
|
|
InvokeAction(Extra::e_stop, *g_act3Script, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_act3Script, 0, NULL);
|
|
|
|
}
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_jukeboxw:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_stop, *g_jukeboxwScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_jukeboxwScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_histbook:
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_disable, *g_histbookScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_stop, *g_histbookScript, 0, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_histbookScript, 0, NULL);
|
|
|
|
break;
|
|
|
|
}
|
2023-11-21 03:44:45 -05:00
|
|
|
}
|
|
|
|
|
2024-02-10 09:36:01 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003b060
|
2024-02-10 13:17:07 -05:00
|
|
|
void LegoGameState::SwitchArea(Area p_area)
|
2023-11-21 03:44:45 -05:00
|
|
|
{
|
2024-01-31 07:34:36 -05:00
|
|
|
m_previousArea = m_currentArea;
|
|
|
|
m_currentArea = p_area;
|
|
|
|
|
2024-02-10 09:36:01 -05:00
|
|
|
FUN_10015820(TRUE, LegoOmni::c_disableInput | LegoOmni::c_disable3d);
|
2024-01-13 15:42:09 -05:00
|
|
|
BackgroundAudioManager()->Stop();
|
|
|
|
AnimationManager()->FUN_1005ef10();
|
2024-01-31 09:47:15 -05:00
|
|
|
VideoManager()->SetUnk0x554(FALSE);
|
2024-01-13 15:42:09 -05:00
|
|
|
|
2024-02-02 16:32:50 -05:00
|
|
|
LegoWorld* world;
|
|
|
|
|
2024-01-13 15:42:09 -05:00
|
|
|
switch (p_area) {
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_isle:
|
2024-02-10 09:36:01 -05:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_isleScript, 0, NULL);
|
2024-01-13 15:42:09 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_infomain:
|
2024-01-31 09:47:15 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-02-10 09:36:01 -05:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_infomainScript, 0, NULL);
|
2024-01-13 15:42:09 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_infodoor:
|
2024-01-31 09:47:15 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-02-10 09:36:01 -05:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_infodoorScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk4:
|
|
|
|
case e_unk15:
|
|
|
|
case e_unk16:
|
|
|
|
case e_unk17:
|
|
|
|
case e_unk19:
|
|
|
|
case e_unk20:
|
|
|
|
case e_unk21:
|
|
|
|
case e_unk22:
|
|
|
|
case e_unk25:
|
|
|
|
case e_unk29:
|
|
|
|
case e_unk31:
|
|
|
|
case e_unk32:
|
|
|
|
case e_unk57:
|
|
|
|
case e_unk58:
|
|
|
|
case e_unk59:
|
|
|
|
case e_unk60:
|
|
|
|
case e_unk61:
|
|
|
|
case e_unk64:
|
|
|
|
case e_unk66:
|
2024-02-10 09:36:01 -05:00
|
|
|
world = FindWorld(*g_isleScript, 0);
|
|
|
|
if (world != NULL) {
|
|
|
|
if (world->GetUnknown0xd0().empty()) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef COMPAT_MODE
|
|
|
|
{
|
|
|
|
MxNotificationParam param(c_notificationType20, NULL);
|
|
|
|
NotificationManager()->Send(world, ¶m);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
NotificationManager()->Send(world, &MxNotificationParam(c_notificationType20, NULL));
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_isleScript, 0, NULL);
|
2024-01-13 15:42:09 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_elevbott:
|
2024-02-10 09:36:01 -05:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_elevbottScript, 0, NULL);
|
2024-01-31 09:47:15 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk6:
|
|
|
|
case e_unk7:
|
2024-02-02 16:32:50 -05:00
|
|
|
world = FindWorld(*g_isleScript, 0);
|
|
|
|
|
|
|
|
if (world == NULL) {
|
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_isleScript, 0, NULL);
|
|
|
|
}
|
2024-02-10 09:36:01 -05:00
|
|
|
else if (!world->GetUnknown0xd0().empty()) {
|
2024-02-02 16:32:50 -05:00
|
|
|
#ifdef COMPAT_MODE
|
|
|
|
{
|
|
|
|
MxNotificationParam param(c_notificationType20, NULL);
|
|
|
|
NotificationManager()->Send(world, ¶m);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
NotificationManager()->Send(world, &MxNotificationParam(c_notificationType20, NULL));
|
|
|
|
#endif
|
|
|
|
}
|
2024-02-10 09:36:01 -05:00
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, 1050, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk8:
|
2024-02-10 09:36:01 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, 1114, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk9:
|
2024-02-10 09:36:01 -05:00
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, 1140, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk10:
|
2024-02-10 09:36:01 -05:00
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, 1118, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk11:
|
2024-02-10 09:36:01 -05:00
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, 1145, NULL);
|
2024-02-02 16:32:50 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_regbook:
|
2024-01-31 09:47:15 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-02-10 09:36:01 -05:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_regbookScript, 0, NULL);
|
2024-01-31 09:47:15 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_infoscor:
|
2024-01-31 09:47:15 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-02-10 09:36:01 -05:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_infoscorScript, 0, NULL);
|
2024-01-31 09:47:15 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_jetrace:
|
|
|
|
if (m_previousArea == e_infomain) {
|
|
|
|
m_currentArea = e_unk15;
|
2024-01-13 15:42:09 -05:00
|
|
|
|
2024-02-10 09:36:01 -05:00
|
|
|
world = FindWorld(*g_isleScript, 0);
|
|
|
|
if (world != NULL) {
|
|
|
|
if (world->GetUnknown0xd0().empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef COMPAT_MODE
|
|
|
|
{
|
|
|
|
MxNotificationParam param(c_notificationType20, NULL);
|
|
|
|
NotificationManager()->Send(world, ¶m);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
NotificationManager()->Send(world, &MxNotificationParam(c_notificationType20, NULL));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_isleScript, 0, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_jetraceScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_carrace:
|
|
|
|
if (m_previousArea == e_infomain) {
|
|
|
|
m_currentArea = e_unk19;
|
2024-01-13 15:42:09 -05:00
|
|
|
|
2024-02-10 09:36:01 -05:00
|
|
|
world = FindWorld(*g_isleScript, 0);
|
|
|
|
if (world != NULL) {
|
|
|
|
if (world->GetUnknown0xd0().empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef COMPAT_MODE
|
|
|
|
{
|
|
|
|
MxNotificationParam param(c_notificationType20, NULL);
|
|
|
|
NotificationManager()->Send(world, ¶m);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
NotificationManager()->Send(world, &MxNotificationParam(c_notificationType20, NULL));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_carraceScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_garage:
|
2024-02-10 09:36:01 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_garageScript, 0, NULL);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// TODO: implement other cases
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_histbook:
|
2024-02-10 09:36:01 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_histbookScript, 0, NULL);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2023-11-21 03:44:45 -05:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003bac0
|
2023-11-01 11:12:03 -04:00
|
|
|
void LegoGameState::SetROIHandlerFunction()
|
|
|
|
{
|
|
|
|
LegoROI::SetSomeHandlerFunction(&ROIHandlerFunction);
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003bad0
|
2023-11-01 11:12:03 -04:00
|
|
|
MxBool ROIHandlerFunction(char* p_input, char* p_output, MxU32 p_copyLen)
|
|
|
|
{
|
|
|
|
if (p_output != NULL && p_copyLen != 0 &&
|
|
|
|
(strnicmp(p_input, "INDIR-F-", strlen("INDIR-F-")) == 0 ||
|
|
|
|
strnicmp(p_input, "INDIR-G-", strlen("INDIR-F-")) == 0)) {
|
|
|
|
|
|
|
|
char buf[256];
|
|
|
|
sprintf(buf, "c_%s", &p_input[strlen("INDIR-F-")]);
|
|
|
|
|
|
|
|
const char* value = VariableTable()->GetVariable(buf);
|
|
|
|
if (value != NULL) {
|
|
|
|
strncpy(p_output, value, p_copyLen);
|
|
|
|
p_output[p_copyLen - 1] = '\0';
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003bbb0
|
2024-01-06 12:56:15 -05:00
|
|
|
LegoState* LegoGameState::GetState(const char* p_stateName)
|
2023-10-12 12:18:24 -04:00
|
|
|
{
|
2024-02-01 15:42:10 -05:00
|
|
|
for (MxS32 i = 0; i < m_stateCount; ++i) {
|
|
|
|
if (m_stateArray[i]->IsA(p_stateName)) {
|
2023-10-24 19:38:27 -04:00
|
|
|
return m_stateArray[i];
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
|
|
|
}
|
2023-10-24 19:38:27 -04:00
|
|
|
return NULL;
|
2023-10-12 12:18:24 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003bc00
|
2024-01-06 12:56:15 -05:00
|
|
|
LegoState* LegoGameState::CreateState(const char* p_stateName)
|
2023-10-12 12:18:24 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
LegoState* newState = (LegoState*) ObjectFactory()->Create(p_stateName);
|
|
|
|
RegisterState(newState);
|
2023-10-24 19:24:29 -04:00
|
|
|
|
2023-10-24 19:38:27 -04:00
|
|
|
return newState;
|
2023-10-12 12:18:24 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003bc30
|
2023-10-24 19:38:27 -04:00
|
|
|
void LegoGameState::RegisterState(LegoState* p_state)
|
2023-10-12 12:18:24 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
MxS32 targetIndex;
|
2024-02-01 15:42:10 -05:00
|
|
|
for (targetIndex = 0; targetIndex < m_stateCount; ++targetIndex) {
|
|
|
|
if (m_stateArray[targetIndex]->IsA(p_state->ClassName())) {
|
2023-10-24 19:38:27 -04:00
|
|
|
break;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
|
|
|
}
|
2023-10-24 19:38:27 -04:00
|
|
|
|
|
|
|
if (targetIndex == m_stateCount) {
|
|
|
|
LegoState** newBuffer = new LegoState*[m_stateCount + 1];
|
|
|
|
|
|
|
|
if (m_stateCount != 0) {
|
|
|
|
memcpy(newBuffer, m_stateArray, m_stateCount * sizeof(LegoState*));
|
|
|
|
delete[] m_stateArray;
|
|
|
|
}
|
|
|
|
|
|
|
|
newBuffer[m_stateCount++] = p_state;
|
|
|
|
m_stateArray = newBuffer;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (m_stateArray[targetIndex]) {
|
2023-10-24 19:38:27 -04:00
|
|
|
delete m_stateArray[targetIndex];
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-10-24 19:38:27 -04:00
|
|
|
m_stateArray[targetIndex] = p_state;
|
2023-10-23 07:16:21 -04:00
|
|
|
}
|
|
|
|
|
2024-02-19 09:24:30 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003c710
|
|
|
|
LegoGameState::ScoreName* LegoGameState::ScoreName::operator=(const ScoreName* p_other)
|
|
|
|
{
|
|
|
|
memcpy(m_letters, p_other->m_letters, sizeof(m_letters));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2023-12-15 17:01:09 -05:00
|
|
|
// STUB: LEGO1 0x1003c870
|
2024-02-19 09:24:30 -05:00
|
|
|
void LegoGameState::Scores::WriteScoreHistory()
|
2023-12-15 17:01:09 -05:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x1003ccf0
|
2024-02-19 09:24:30 -05:00
|
|
|
void LegoGameState::Scores::FUN_1003ccf0(LegoFile&)
|
2023-10-23 07:16:21 -04:00
|
|
|
{
|
2023-10-24 19:38:27 -04:00
|
|
|
// TODO
|
2023-10-23 07:16:21 -04:00
|
|
|
}
|
|
|
|
|
2023-12-15 17:01:09 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003cdd0
|
|
|
|
void LegoGameState::SerializeScoreHistory(MxS16 p_flags)
|
|
|
|
{
|
2024-01-24 12:12:57 -05:00
|
|
|
LegoFile stream;
|
2023-12-15 17:01:09 -05:00
|
|
|
MxString savePath(m_savePath);
|
|
|
|
savePath += "\\";
|
|
|
|
savePath += g_historyGSI;
|
|
|
|
|
2024-01-24 12:12:57 -05:00
|
|
|
if (p_flags == LegoFile::c_write) {
|
2023-12-15 17:01:09 -05:00
|
|
|
m_unk0xa6.WriteScoreHistory();
|
|
|
|
}
|
|
|
|
|
2024-01-24 12:12:57 -05:00
|
|
|
if (stream.Open(savePath.GetData(), p_flags) == SUCCESS) {
|
2023-12-15 17:01:09 -05:00
|
|
|
m_unk0xa6.FUN_1003ccf0(stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003cea0
|
2024-02-10 11:37:22 -05:00
|
|
|
void LegoGameState::SetCurrentAct(Act p_currentAct)
|
2023-10-23 07:16:21 -04:00
|
|
|
{
|
2024-02-10 11:37:22 -05:00
|
|
|
m_currentAct = p_currentAct;
|
2023-10-24 19:24:29 -04:00
|
|
|
}
|
2023-12-15 17:01:09 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x1003ceb0
|
2024-02-10 11:37:22 -05:00
|
|
|
void LegoGameState::FindLoadedAct()
|
2023-12-15 17:01:09 -05:00
|
|
|
{
|
2024-01-26 16:00:02 -05:00
|
|
|
if (FindWorld(*g_isleScript, 0)) {
|
2024-02-10 11:37:22 -05:00
|
|
|
m_loadedAct = e_act1;
|
2023-12-15 17:01:09 -05:00
|
|
|
}
|
2024-01-26 16:00:02 -05:00
|
|
|
else if (FindWorld(*g_act2mainScript, 0)) {
|
2024-02-10 11:37:22 -05:00
|
|
|
m_loadedAct = e_act2;
|
2023-12-15 17:01:09 -05:00
|
|
|
}
|
2024-01-26 16:00:02 -05:00
|
|
|
else if (FindWorld(*g_act3Script, 0)) {
|
2024-02-10 11:37:22 -05:00
|
|
|
m_loadedAct = e_act3;
|
2023-12-15 17:01:09 -05:00
|
|
|
}
|
|
|
|
else {
|
2024-02-10 11:37:22 -05:00
|
|
|
m_loadedAct = e_actNotFound;
|
2023-12-15 17:01:09 -05:00
|
|
|
}
|
|
|
|
}
|