2023-06-30 14:34:39 -04:00
|
|
|
#include "legogamestate.h"
|
2023-10-07 11:30:04 -04:00
|
|
|
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "3dmanager/lego3dmanager.h"
|
2024-02-24 08:55:00 -05:00
|
|
|
#include "act1state.h"
|
2024-03-23 13:06:31 -04:00
|
|
|
#include "act2main_actions.h"
|
|
|
|
#include "act3_actions.h"
|
|
|
|
#include "carrace_actions.h"
|
|
|
|
#include "carracer_actions.h"
|
|
|
|
#include "copter_actions.h"
|
2024-02-24 08:55:00 -05:00
|
|
|
#include "define.h"
|
2024-02-28 15:03:27 -05:00
|
|
|
#include "dunebuggy.h"
|
2024-03-23 13:06:31 -04:00
|
|
|
#include "dunecar_actions.h"
|
|
|
|
#include "elevbott_actions.h"
|
|
|
|
#include "garage_actions.h"
|
2024-02-28 15:03:27 -05:00
|
|
|
#include "helicopter.h"
|
2024-03-23 13:06:31 -04:00
|
|
|
#include "histbook_actions.h"
|
|
|
|
#include "hospital_actions.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "infocenterstate.h"
|
2024-03-23 13:06:31 -04:00
|
|
|
#include "infodoor_actions.h"
|
|
|
|
#include "infomain_actions.h"
|
|
|
|
#include "infoscor_actions.h"
|
2024-02-28 15:03:27 -05:00
|
|
|
#include "isle.h"
|
2024-03-23 13:06:31 -04:00
|
|
|
#include "isle_actions.h"
|
2024-02-24 08:55:00 -05:00
|
|
|
#include "islepathactor.h"
|
2024-03-23 13:06:31 -04:00
|
|
|
#include "jetrace_actions.h"
|
|
|
|
#include "jetracer_actions.h"
|
2024-02-28 15:03:27 -05:00
|
|
|
#include "jetski.h"
|
2024-03-23 13:06:31 -04:00
|
|
|
#include "jetski_actions.h"
|
2024-03-18 15:00:58 -04:00
|
|
|
#include "jukebox_actions.h"
|
2024-03-23 13:06:31 -04:00
|
|
|
#include "jukeboxw_actions.h"
|
2024-01-13 15:42:09 -05:00
|
|
|
#include "legoanimationmanager.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "legobackgroundcolor.h"
|
2024-02-27 15:04:17 -05:00
|
|
|
#include "legobuildingmanager.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "legocharactermanager.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "legofullscreenmovie.h"
|
2024-05-04 08:06:32 -04:00
|
|
|
#include "legomain.h"
|
2024-02-24 08:55:00 -05:00
|
|
|
#include "legonavcontroller.h"
|
2024-02-27 15:04:17 -05:00
|
|
|
#include "legoplantmanager.h"
|
2023-10-12 12:18:24 -04:00
|
|
|
#include "legostate.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "legoutils.h"
|
2024-01-13 15:42:09 -05:00
|
|
|
#include "legovideomanager.h"
|
2024-02-02 16:32:50 -05:00
|
|
|
#include "legoworld.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "misc.h"
|
2024-01-13 15:42:09 -05:00
|
|
|
#include "mxbackgroundaudiomanager.h"
|
2024-03-09 15:07:52 -05:00
|
|
|
#include "mxmisc.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "mxnotificationmanager.h"
|
|
|
|
#include "mxnotificationparam.h"
|
2023-10-12 12:18:24 -04:00
|
|
|
#include "mxobjectfactory.h"
|
|
|
|
#include "mxstring.h"
|
2024-05-03 12:19:12 -04:00
|
|
|
#include "mxutilities.h"
|
2023-10-24 19:38:27 -04:00
|
|
|
#include "mxvariabletable.h"
|
2024-03-23 13:06:31 -04:00
|
|
|
#include "police_actions.h"
|
2024-02-28 15:03:27 -05:00
|
|
|
#include "racecar.h"
|
2024-03-23 13:06:31 -04:00
|
|
|
#include "racecar_actions.h"
|
|
|
|
#include "regbook_actions.h"
|
2024-01-08 04:58:49 -05:00
|
|
|
#include "roi/legoroi.h"
|
2024-05-04 08:06:32 -04:00
|
|
|
#include "scripts.h"
|
2024-03-23 13:06:31 -04:00
|
|
|
#include "sndanim_actions.h"
|
2023-09-29 16:38:08 -04:00
|
|
|
|
2024-01-06 12:56:15 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2024-03-19 10:15:24 -04:00
|
|
|
DECOMP_SIZE_ASSERT(LegoGameState::Username, 0x0e)
|
2024-02-19 09:24:30 -05:00
|
|
|
DECOMP_SIZE_ASSERT(LegoGameState::ScoreItem, 0x2c)
|
2024-02-26 11:19:16 -05:00
|
|
|
DECOMP_SIZE_ASSERT(LegoGameState::History, 0x374)
|
2023-09-29 16:38:08 -04:00
|
|
|
DECOMP_SIZE_ASSERT(LegoGameState, 0x430)
|
2024-03-22 21:30:58 -04:00
|
|
|
DECOMP_SIZE_ASSERT(ColorStringStruct, 0x08)
|
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] = {
|
2024-02-26 11:19:16 -05:00
|
|
|
{"c_dbbkfny0", "lego red"}, {"c_dbbkxly0", "lego white"}, // dunebuggy back fender, dunebuggy back axle
|
|
|
|
{"c_chbasey0", "lego black"}, {"c_chbacky0", "lego black"}, // copter base, copter back
|
|
|
|
{"c_chdishy0", "lego white"}, {"c_chhorny0", "lego black"}, // copter dish, copter horn
|
|
|
|
{"c_chljety1", "lego black"}, {"c_chrjety1", "lego black"}, // copter left jet, copter right jet
|
|
|
|
{"c_chmidly0", "lego black"}, {"c_chmotry0", "lego blue"}, // copter middle, copter motor
|
|
|
|
{"c_chsidly0", "lego black"}, {"c_chsidry0", "lego black"}, // copter side left, copter side right
|
|
|
|
{"c_chstuty0", "lego black"}, {"c_chtaily0", "lego black"}, // copter ???, copter tail
|
|
|
|
{"c_chwindy1", "lego black"}, {"c_dbfbrdy0", "lego red"}, // copter ???, dunebuggy ???
|
|
|
|
{"c_dbflagy0", "lego yellow"}, {"c_dbfrfny4", "lego red"}, // dunebuggy flag, dunebuggy front fender
|
|
|
|
{"c_dbfrxly0", "lego white"}, {"c_dbhndly0", "lego white"}, // dunebuggy front axle, dunebuggy handlebar
|
|
|
|
{"c_dbltbry0", "lego white"}, {"c_jsdashy0", "lego white"}, // dunebuggy ???, jetski dash
|
|
|
|
{"c_jsexhy0", "lego black"}, {"c_jsfrnty5", "lego black"}, // jetski exhaust, jetski front
|
|
|
|
{"c_jshndly0", "lego red"}, {"c_jslsidy0", "lego black"}, // jetski handlebar, jetski left side
|
|
|
|
{"c_jsrsidy0", "lego black"}, {"c_jsskiby0", "lego red"}, // jetski right side, jetski ???
|
|
|
|
{"c_jswnshy5", "lego white"}, {"c_rcbacky6", "lego green"}, // jetski windshield, racecar back
|
|
|
|
{"c_rcedgey0", "lego green"}, {"c_rcfrmey0", "lego red"}, // racecar edge, racecar frame
|
|
|
|
{"c_rcfrnty6", "lego green"}, {"c_rcmotry0", "lego white"}, // racecar front, racecar motor
|
|
|
|
{"c_rcsidey0", "lego green"}, {"c_rcstery0", "lego white"}, // racecar side, racecar steering wheel
|
|
|
|
{"c_rcstrpy0", "lego yellow"}, {"c_rctailya", "lego white"}, // racecar stripe, racecar tail
|
|
|
|
{"c_rcwhl1y0", "lego white"}, {"c_rcwhl2y0", "lego white"}, // racecar wheels 1, racecar wheels 2
|
|
|
|
{"c_jsbasey0", "lego white"}, {"c_chblady0", "lego black"}, // jetski base, copter blades
|
|
|
|
{"c_chseaty0", "lego white"}, // copter seat
|
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()
|
|
|
|
{
|
2024-02-26 11:19:16 -05:00
|
|
|
SetColors();
|
2023-11-01 11:12:03 -04:00
|
|
|
SetROIHandlerFunction();
|
|
|
|
|
2024-02-26 11:19:16 -05:00
|
|
|
m_stateCount = 0;
|
|
|
|
m_actorId = 0;
|
|
|
|
m_savePath = NULL;
|
|
|
|
m_stateArray = NULL;
|
2024-03-18 15:00:58 -04:00
|
|
|
m_unk0x41c = JukeboxScript::c_noneJukebox;
|
2024-03-13 13:17:20 -04:00
|
|
|
m_currentArea = e_undefined;
|
|
|
|
m_previousArea = e_undefined;
|
|
|
|
m_unk0x42c = e_undefined;
|
2024-02-28 15:03:27 -05:00
|
|
|
m_playerCount = 0;
|
2024-02-26 11:19:16 -05:00
|
|
|
m_isDirty = FALSE;
|
|
|
|
m_loadedAct = e_actNotFound;
|
|
|
|
SetCurrentAct(e_act1);
|
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
|
|
|
|
2024-02-26 11:19:16 -05:00
|
|
|
m_tempBackgroundColor = new LegoBackgroundColor("tempBackgroundColor", "set 56 54 68");
|
2023-10-24 19:38:27 -04:00
|
|
|
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()
|
|
|
|
{
|
2024-03-05 12:38:53 -05:00
|
|
|
LegoROI::FUN_100a9d30(NULL);
|
2023-11-01 11:12:03 -04:00
|
|
|
|
|
|
|
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-02-26 11:19:16 -05:00
|
|
|
// FUNCTION: LEGO1 0x10039780
|
|
|
|
void LegoGameState::SetActor(MxU8 p_actorId)
|
2024-01-17 11:53:53 -05:00
|
|
|
{
|
2024-02-26 11:19:16 -05:00
|
|
|
if (p_actorId) {
|
|
|
|
m_actorId = p_actorId;
|
|
|
|
}
|
|
|
|
|
|
|
|
IslePathActor* oldActor = CurrentActor();
|
|
|
|
SetCurrentActor(NULL);
|
|
|
|
|
|
|
|
IslePathActor* newActor = new IslePathActor();
|
|
|
|
const char* actorName = LegoActor::GetActorName(m_actorId);
|
2024-03-19 14:23:34 -04:00
|
|
|
LegoROI* roi = CharacterManager()->GetROI(actorName, FALSE);
|
2024-02-26 11:19:16 -05:00
|
|
|
MxDSAction action;
|
|
|
|
|
|
|
|
action.SetAtomId(*g_isleScript);
|
|
|
|
action.SetObjectId(100000);
|
|
|
|
newActor->Create(action);
|
|
|
|
newActor->SetActorId(p_actorId);
|
|
|
|
newActor->SetROI(roi, FALSE, FALSE);
|
|
|
|
|
|
|
|
if (oldActor) {
|
|
|
|
newActor->GetROI()->FUN_100a58f0(oldActor->GetROI()->GetLocal2World());
|
2024-03-26 13:51:52 -04:00
|
|
|
newActor->SetBoundary(oldActor->GetBoundary());
|
2024-02-26 11:19:16 -05:00
|
|
|
delete oldActor;
|
|
|
|
}
|
|
|
|
|
|
|
|
newActor->ClearFlag(0x02);
|
|
|
|
SetCurrentActor(newActor);
|
2024-01-17 11:53:53 -05:00
|
|
|
}
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
// FUNCTION: LEGO1 0x10039910
|
|
|
|
void LegoGameState::RemoveActor()
|
|
|
|
{
|
|
|
|
IslePathActor* actor = CurrentActor();
|
|
|
|
SetCurrentActor(NULL);
|
|
|
|
delete actor;
|
|
|
|
m_actorId = 0;
|
|
|
|
}
|
|
|
|
|
2024-02-27 15:04:17 -05:00
|
|
|
// FUNCTION: LEGO1 0x10039940
|
|
|
|
void LegoGameState::ResetROI()
|
2024-02-02 12:18:46 -05:00
|
|
|
{
|
2024-02-27 15:04:17 -05:00
|
|
|
if (m_actorId) {
|
|
|
|
IslePathActor* actor = CurrentActor();
|
|
|
|
|
|
|
|
if (actor) {
|
|
|
|
LegoROI* roi = actor->GetROI();
|
|
|
|
|
|
|
|
if (roi) {
|
|
|
|
VideoManager()->Get3DManager()->GetLego3DView()->Remove(*roi);
|
|
|
|
VideoManager()->Get3DManager()->GetLego3DView()->Add(*roi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-02-02 12:18:46 -05:00
|
|
|
}
|
|
|
|
|
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
|
|
|
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()) {
|
2024-02-27 15:04:17 -05:00
|
|
|
return SUCCESS;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2024-02-27 15:04:17 -05:00
|
|
|
MxResult result = FAILURE;
|
2024-02-28 15:03:27 -05:00
|
|
|
LegoFile fileStorage;
|
2024-02-27 15:04:17 -05:00
|
|
|
MxVariableTable* variableTable = VariableTable();
|
|
|
|
MxS16 count = 0;
|
|
|
|
MxU32 i;
|
|
|
|
MxS32 j;
|
|
|
|
MxU16 area;
|
2023-10-24 19:38:27 -04:00
|
|
|
|
2024-02-27 15:04:17 -05:00
|
|
|
MxString savePath;
|
|
|
|
GetFileSavePath(&savePath, p_slot);
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
if (fileStorage.Open(savePath.GetData(), LegoFile::c_write) == FAILURE) {
|
2024-02-27 15:04:17 -05:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
Write(&fileStorage, 0x1000c);
|
|
|
|
Write(&fileStorage, m_unk0x24);
|
|
|
|
Write(&fileStorage, (MxU16) m_currentAct);
|
|
|
|
Write(&fileStorage, m_actorId);
|
2024-02-27 15:04:17 -05:00
|
|
|
|
2024-05-14 10:35:22 -04:00
|
|
|
for (i = 0; i < sizeOfArray(g_colorSaveData); i++) {
|
2024-02-28 15:03:27 -05:00
|
|
|
if (WriteVariable(&fileStorage, variableTable, g_colorSaveData[i].m_targetName) == FAILURE) {
|
2024-02-27 15:04:17 -05:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
if (WriteVariable(&fileStorage, variableTable, "backgroundcolor") == FAILURE) {
|
2024-02-27 15:04:17 -05:00
|
|
|
goto done;
|
|
|
|
}
|
2024-02-28 15:03:27 -05:00
|
|
|
if (WriteVariable(&fileStorage, variableTable, "lightposition") == FAILURE) {
|
2024-02-27 15:04:17 -05:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
WriteEndOfVariables(&fileStorage);
|
2024-03-22 13:40:19 -04:00
|
|
|
CharacterManager()->Write(&fileStorage);
|
2024-04-21 09:42:08 -04:00
|
|
|
PlantManager()->Write(&fileStorage);
|
|
|
|
result = BuildingManager()->Write(&fileStorage);
|
2024-02-27 15:04:17 -05:00
|
|
|
|
|
|
|
for (j = 0; j < m_stateCount; j++) {
|
2024-04-21 09:42:08 -04:00
|
|
|
if (m_stateArray[j]->IsSerializable()) {
|
2024-02-27 15:04:17 -05:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
Write(&fileStorage, count);
|
2024-02-27 15:04:17 -05:00
|
|
|
|
|
|
|
for (j = 0; j < m_stateCount; j++) {
|
2024-04-21 09:42:08 -04:00
|
|
|
if (m_stateArray[j]->IsSerializable()) {
|
|
|
|
m_stateArray[j]->Serialize(&fileStorage);
|
2023-10-24 19:38:27 -04:00
|
|
|
}
|
|
|
|
}
|
2024-02-27 15:04:17 -05:00
|
|
|
|
|
|
|
area = m_unk0x42c;
|
2024-02-28 15:03:27 -05:00
|
|
|
Write(&fileStorage, (MxU16) area);
|
2024-02-27 15:04:17 -05:00
|
|
|
SerializeScoreHistory(2);
|
|
|
|
m_isDirty = FALSE;
|
|
|
|
|
|
|
|
done:
|
2023-10-24 19:38:27 -04:00
|
|
|
return result;
|
2023-06-30 14:34:39 -04:00
|
|
|
}
|
|
|
|
|
2024-02-27 15:04:17 -05:00
|
|
|
// FUNCTION: LEGO1 0x10039bf0
|
|
|
|
MxResult LegoGameState::DeleteState()
|
|
|
|
{
|
|
|
|
MxS16 stateCount = m_stateCount;
|
|
|
|
LegoState** stateArray = m_stateArray;
|
|
|
|
|
|
|
|
m_stateCount = 0;
|
|
|
|
m_stateArray = NULL;
|
|
|
|
|
|
|
|
for (MxS32 count = 0; count < stateCount; count++) {
|
2024-04-21 09:42:08 -04:00
|
|
|
if (!stateArray[count]->SetFlag() && stateArray[count]->IsSerializable()) {
|
2024-02-27 15:04:17 -05:00
|
|
|
delete stateArray[count];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RegisterState(stateArray[count]);
|
|
|
|
stateArray[count] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete[] stateArray;
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x10039c60
|
|
|
|
MxResult LegoGameState::Load(MxULong p_slot)
|
2023-06-30 14:34:39 -04:00
|
|
|
{
|
2024-02-27 15:04:17 -05:00
|
|
|
MxResult result = FAILURE;
|
2024-02-28 15:03:27 -05:00
|
|
|
LegoFile fileStorage;
|
2024-02-27 15:04:17 -05:00
|
|
|
MxVariableTable* variableTable = VariableTable();
|
|
|
|
|
|
|
|
MxString savePath;
|
|
|
|
GetFileSavePath(&savePath, p_slot);
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
if (fileStorage.Open(savePath.GetData(), LegoFile::c_read) == FAILURE) {
|
2024-02-27 15:04:17 -05:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
MxU32 version, status;
|
|
|
|
MxS16 count, area, act;
|
|
|
|
const char* lightPosition;
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
Read(&fileStorage, &version);
|
2024-02-27 15:04:17 -05:00
|
|
|
|
|
|
|
if (version != 0x1000c) {
|
|
|
|
OmniError("Saved game version mismatch", 0);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
Read(&fileStorage, &m_unk0x24);
|
2024-02-27 15:04:17 -05:00
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
Read(&fileStorage, &act);
|
2024-02-27 15:04:17 -05:00
|
|
|
SetCurrentAct((Act) act);
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
Read(&fileStorage, &m_actorId);
|
2024-02-27 15:04:17 -05:00
|
|
|
if (m_actorId) {
|
|
|
|
SetActor(m_actorId);
|
|
|
|
}
|
|
|
|
|
|
|
|
do {
|
2024-02-28 15:03:27 -05:00
|
|
|
status = ReadVariable(&fileStorage, variableTable);
|
2024-02-27 15:04:17 -05:00
|
|
|
if (status == 1) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
} while (status != 2);
|
|
|
|
|
2024-03-29 16:50:00 -04:00
|
|
|
m_backgroundColor->SetLightColor();
|
2024-02-27 15:04:17 -05:00
|
|
|
lightPosition = VariableTable()->GetVariable("lightposition");
|
|
|
|
|
|
|
|
if (lightPosition) {
|
|
|
|
SetLightPosition(atoi(lightPosition));
|
|
|
|
}
|
|
|
|
|
2024-03-22 13:40:19 -04:00
|
|
|
if (CharacterManager()->Read(&fileStorage) == FAILURE) {
|
2024-02-27 15:04:17 -05:00
|
|
|
goto done;
|
|
|
|
}
|
2024-04-21 09:42:08 -04:00
|
|
|
if (PlantManager()->Read(&fileStorage) == FAILURE) {
|
2024-02-27 15:04:17 -05:00
|
|
|
goto done;
|
|
|
|
}
|
2024-04-21 09:42:08 -04:00
|
|
|
if (BuildingManager()->Read(&fileStorage) == FAILURE) {
|
2024-02-27 15:04:17 -05:00
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (DeleteState() != SUCCESS) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
char stateName[80];
|
2024-02-28 15:03:27 -05:00
|
|
|
Read(&fileStorage, &count);
|
2024-02-27 15:04:17 -05:00
|
|
|
|
|
|
|
if (count) {
|
|
|
|
for (MxS16 i = 0; i < count; i++) {
|
|
|
|
MxS16 stateNameLength;
|
2024-02-28 15:03:27 -05:00
|
|
|
Read(&fileStorage, &stateNameLength);
|
|
|
|
Read(&fileStorage, stateName, (MxULong) stateNameLength);
|
2024-02-27 15:04:17 -05:00
|
|
|
stateName[stateNameLength] = 0;
|
|
|
|
|
|
|
|
LegoState* state = GetState(stateName);
|
|
|
|
if (!state) {
|
|
|
|
state = CreateState(stateName);
|
|
|
|
|
|
|
|
if (!state) {
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-21 09:42:08 -04:00
|
|
|
state->Serialize(&fileStorage);
|
2024-02-27 15:04:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
Read(&fileStorage, &area);
|
2024-02-27 15:04:17 -05:00
|
|
|
|
|
|
|
if (m_currentAct == 0) {
|
2024-03-13 13:17:20 -04:00
|
|
|
m_unk0x42c = e_undefined;
|
2024-02-27 15:04:17 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_unk0x42c = (Area) area;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = SUCCESS;
|
|
|
|
m_isDirty = FALSE;
|
|
|
|
|
|
|
|
done:
|
|
|
|
if (result != SUCCESS) {
|
|
|
|
OmniError("Game state loading was not successful!", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
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
|
2024-02-26 11:19:16 -05:00
|
|
|
MxResult LegoGameState::WriteVariable(LegoStorage* p_storage, MxVariableTable* p_from, const char* p_variableName)
|
2024-01-24 12:12:57 -05:00
|
|
|
{
|
|
|
|
MxResult result = FAILURE;
|
|
|
|
const char* variableValue = p_from->GetVariable(p_variableName);
|
|
|
|
|
|
|
|
if (variableValue) {
|
|
|
|
MxU8 length = strlen(p_variableName);
|
2024-02-28 15:03:27 -05:00
|
|
|
if (p_storage->Write(&length, sizeof(length)) == SUCCESS) {
|
2024-02-26 11:19:16 -05:00
|
|
|
if (p_storage->Write(p_variableName, length) == SUCCESS) {
|
2024-01-24 12:12:57 -05:00
|
|
|
length = strlen(variableValue);
|
2024-02-28 15:03:27 -05:00
|
|
|
if (p_storage->Write(&length, sizeof(length)) == SUCCESS) {
|
|
|
|
result = p_storage->Write(variableValue, length);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-24 12:12:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-02-26 11:19:16 -05:00
|
|
|
|
2024-01-24 12:12:57 -05:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003a020
|
2024-02-26 11:19:16 -05:00
|
|
|
MxResult LegoGameState::WriteEndOfVariables(LegoStorage* p_storage)
|
2023-11-21 03:44:45 -05:00
|
|
|
{
|
2023-12-13 05:48:14 -05:00
|
|
|
MxU8 len = strlen(g_endOfVariables);
|
2024-02-26 11:19:16 -05:00
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
if (p_storage->Write(&len, sizeof(len)) == SUCCESS) {
|
2024-02-26 11:19:16 -05:00
|
|
|
return p_storage->Write(g_endOfVariables, len);
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-02-26 11:19:16 -05:00
|
|
|
|
2023-11-21 03:44:45 -05:00
|
|
|
return FAILURE;
|
|
|
|
}
|
|
|
|
|
2024-01-24 12:12:57 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003a080
|
2024-02-26 11:19:16 -05:00
|
|
|
MxS32 LegoGameState::ReadVariable(LegoStorage* p_storage, MxVariableTable* p_to)
|
2024-01-24 12:12:57 -05:00
|
|
|
{
|
|
|
|
MxS32 result = 1;
|
|
|
|
MxU8 length;
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
if (p_storage->Read(&length, sizeof(length)) == SUCCESS) {
|
2024-01-24 12:12:57 -05:00
|
|
|
char nameBuffer[256];
|
2024-02-26 11:19:16 -05:00
|
|
|
if (p_storage->Read(nameBuffer, length) == SUCCESS) {
|
2024-01-24 12:12:57 -05:00
|
|
|
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 {
|
2024-02-28 15:03:27 -05:00
|
|
|
if (p_storage->Read(&length, sizeof(length)) == SUCCESS) {
|
2024-01-24 12:12:57 -05:00
|
|
|
char valueBuffer[256];
|
2024-02-26 11:19:16 -05:00
|
|
|
if (p_storage->Read(valueBuffer, length) == SUCCESS) {
|
2024-01-24 12:12:57 -05:00
|
|
|
valueBuffer[length] = '\0';
|
|
|
|
p_to->SetVariable(nameBuffer, valueBuffer);
|
2024-02-28 15:03:27 -05:00
|
|
|
result = SUCCESS;
|
2024-01-24 12:12:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-02-26 11:19:16 -05:00
|
|
|
|
2024-01-24 12:12:57 -05:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003a170
|
2024-02-28 15:03:27 -05:00
|
|
|
void LegoGameState::GetFileSavePath(MxString* p_outPath, MxU8 p_slotn)
|
2023-11-21 03:44:45 -05:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003a2e0
|
|
|
|
void LegoGameState::SerializePlayersInfo(MxS16 p_flags)
|
|
|
|
{
|
|
|
|
LegoFile fileStorage;
|
|
|
|
MxString playersGSI = MxString(m_savePath);
|
|
|
|
|
|
|
|
playersGSI += "\\";
|
|
|
|
playersGSI += g_playersGSI;
|
|
|
|
|
|
|
|
if (fileStorage.Open(playersGSI.GetData(), p_flags) == SUCCESS) {
|
|
|
|
if (fileStorage.IsReadMode()) {
|
|
|
|
Read(&fileStorage, &m_playerCount);
|
|
|
|
}
|
|
|
|
else if (fileStorage.IsWriteMode()) {
|
|
|
|
Write(&fileStorage, m_playerCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (MxS16 i = 0; i < m_playerCount; i++) {
|
|
|
|
m_players[i].ReadWrite(&fileStorage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x1003a3f0
|
|
|
|
MxResult LegoGameState::AddPlayer(Username& p_player)
|
|
|
|
{
|
|
|
|
MxString from, to;
|
|
|
|
|
|
|
|
if (m_playerCount == 9) {
|
|
|
|
GetFileSavePath(&from, 8);
|
|
|
|
DeleteFile(from.GetData());
|
|
|
|
m_playerCount--;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (MxS16 i = m_playerCount; i > 0; i--) {
|
|
|
|
m_players[i] = m_players[i - 1];
|
|
|
|
GetFileSavePath(&from, i - 1);
|
|
|
|
GetFileSavePath(&to, i);
|
|
|
|
MoveFile(from.GetData(), to.GetData());
|
|
|
|
}
|
|
|
|
|
|
|
|
m_playerCount++;
|
|
|
|
m_players[0].Set(p_player);
|
|
|
|
m_unk0x24 = m_history.m_unk0x372;
|
|
|
|
m_history.m_unk0x372 = m_unk0x24 + 1;
|
|
|
|
m_history.WriteScoreHistory();
|
|
|
|
SetCurrentAct(e_act1);
|
|
|
|
|
|
|
|
return DeleteState();
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x1003a540
|
|
|
|
void LegoGameState::SwitchPlayer(MxS16 p_playerId)
|
|
|
|
{
|
|
|
|
if (p_playerId > 0) {
|
|
|
|
MxString from, temp, to;
|
|
|
|
|
|
|
|
GetFileSavePath(&from, p_playerId);
|
|
|
|
GetFileSavePath(&temp, 36);
|
|
|
|
|
|
|
|
Username selectedName(m_players[p_playerId]);
|
|
|
|
|
|
|
|
MoveFile(from.GetData(), temp.GetData());
|
|
|
|
|
|
|
|
for (MxS16 i = p_playerId; i > 0; i--) {
|
|
|
|
m_players[i] = m_players[i - 1];
|
|
|
|
GetFileSavePath(&from, i - 1);
|
|
|
|
GetFileSavePath(&to, i);
|
|
|
|
MoveFile(from.GetData(), to.GetData());
|
|
|
|
}
|
|
|
|
|
|
|
|
m_players[0] = selectedName;
|
|
|
|
GetFileSavePath(&from, 0);
|
|
|
|
MoveFile(temp.GetData(), from.GetData());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Load(0) != SUCCESS) {
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x1003a6e0
|
|
|
|
MxS16 LegoGameState::FindPlayer(Username& p_player)
|
2023-11-21 03:44:45 -05:00
|
|
|
{
|
2024-02-28 15:03:27 -05:00
|
|
|
for (MxS16 i = 0; i < m_playerCount; i++) {
|
|
|
|
if (memcmp(&m_players[i], &p_player, sizeof(p_player)) == 0) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
2023-11-21 03:44:45 -05:00
|
|
|
}
|
|
|
|
|
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-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c__Isle, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_isleScript, IsleScript::c__Isle, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_sndAnimScript, SndanimScript::c_SoundAndAnim_Action, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_infomain:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_infomainScript, InfomainScript::c__InfoMain, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_infomainScript, InfomainScript::c__InfoMain, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_infodoor:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_infodoorScript, InfodoorScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_infodoorScript, InfodoorScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_elevbott:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_elevbottScript, ElevbottScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_elevbottScript, ElevbottScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_elevride:
|
|
|
|
case e_elevride2:
|
2024-03-23 13:06:31 -04:00
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_ElevRide_Background_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_ElevRide_Info_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_ElevRide_Two_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_ElevRide_Three_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Meter1_3_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Meter2_3_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Meter3_1_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Meter3_2_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Meter2_1_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Meter1_2_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Meter3_Bitmap, *g_isleScript, 0);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_elevopen:
|
2024-03-23 13:06:31 -04:00
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_ElevOpen_Background_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_ElevOpen_LeftArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_ElevOpen_RightArrow_Ctl, *g_isleScript, 0);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_seaview:
|
2024-03-23 13:06:31 -04:00
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_SeaView_Background_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_SeaView_LeftArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_SeaView_RightArrow_Ctl, *g_isleScript, 0);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_observe:
|
2024-03-23 13:06:31 -04:00
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Background_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_LeftArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_RightArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Plane_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Sun_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Moon_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_SkyColor_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_LCab_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_RCab_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_GlobeRArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_GlobeLArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Globe1_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Globe2_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Globe3_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Globe4_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Globe5_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Globe6_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Draw1_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Observe_Draw2_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_Radio_Ctl, *g_isleScript, 0);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_elevdown:
|
2024-03-23 13:06:31 -04:00
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_ElevDown_Background_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_ElevDown_LeftArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_ElevDown_RightArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_ElevDown_Elevator_Ctl, *g_isleScript, 0);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_regbook:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_regbookScript, RegbookScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_regbookScript, RegbookScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_infoscor:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_infoscorScript, InfoscorScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_infoscorScript, InfoscorScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_jetrace:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_jetraceScript, JetraceScript::c__JetRace_World, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_jetraceScript, JetraceScript::c__JetRace_World, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
InvokeAction(Extra::e_close, *g_jetracerScript, 0, NULL);
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_carrace:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_carraceScript, CarraceScript::c__CarRace_World, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_carraceScript, CarraceScript::c__CarRace_World, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_carracerScript, CarracerScript::c_nrt002pz_Anim, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
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);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_garageScript, GarageScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_garageScript, GarageScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_garadoor:
|
2024-03-23 13:06:31 -04:00
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_GaraDoor_Background_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_GaraDoor_LeftArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_GaraDoor_RightArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_GaraDoor_Door_Ctl, *g_isleScript, 0);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_hospital:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_hospitalScript, HospitalScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_hospitalScript, HospitalScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_police:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_policeScript, PoliceScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_policeScript, PoliceScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_polidoor:
|
2024-03-23 13:06:31 -04:00
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_PoliDoor_Background_Bitmap, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_PoliDoor_LeftArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_PoliDoor_RightArrow_Ctl, *g_isleScript, 0);
|
|
|
|
RemoveFromWorld(*g_isleScript, IsleScript::c_PoliDoor_Door_Ctl, *g_isleScript, 0);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-03-17 13:01:47 -04:00
|
|
|
case e_copterbuild:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_jukeboxScript, JukeboxScript::c_HelicopterBuild_Movie, NULL);
|
|
|
|
InvokeAction(Extra::e_stop, *g_copterScript, CopterScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_copterScript, CopterScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-03-17 13:01:47 -04:00
|
|
|
case e_dunecarbuild:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_jukeboxScript, JukeboxScript::c_DuneCarBuild_Movie, NULL);
|
|
|
|
InvokeAction(Extra::e_stop, *g_dunecarScript, DunecarScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_dunecarScript, DunecarScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-03-17 13:01:47 -04:00
|
|
|
case e_jetskibuild:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_jukeboxScript, JukeboxScript::c_JetskiBuild_Movie, NULL);
|
|
|
|
InvokeAction(Extra::e_stop, *g_jetskiScript, JetskiScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_jetskiScript, JetskiScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-03-17 13:01:47 -04:00
|
|
|
case e_racecarbuild:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_jukeboxScript, JukeboxScript::c_RaceCarBuild_Movie, NULL);
|
|
|
|
InvokeAction(Extra::e_stop, *g_racecarScript, RacecarScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_racecarScript, RacecarScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_act2main:
|
2024-01-31 07:34:36 -05:00
|
|
|
if (m_currentArea != 2) {
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_act2mainScript, Act2mainScript::c__Act2Main, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_act2mainScript, Act2mainScript::c__Act2Main, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
}
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_act3script:
|
2024-01-31 07:34:36 -05:00
|
|
|
if (m_currentArea != 2) {
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_act3Script, Act3Script::c__Act3, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_act3Script, Act3Script::c__Act3, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
}
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_jukeboxw:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_stop, *g_jukeboxwScript, JukeboxwScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_jukeboxwScript, JukeboxwScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_histbook:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::e_disable, *g_histbookScript, HistbookScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_stop, *g_histbookScript, HistbookScript::c__StartUp, NULL);
|
|
|
|
InvokeAction(Extra::e_close, *g_histbookScript, HistbookScript::c__StartUp, NULL);
|
2024-01-31 07:34:36 -05:00
|
|
|
break;
|
|
|
|
}
|
2023-11-21 03:44:45 -05:00
|
|
|
}
|
|
|
|
|
2024-02-24 08:55:00 -05:00
|
|
|
inline void LoadIsle()
|
|
|
|
{
|
|
|
|
LegoWorld* world = FindWorld(*g_isleScript, 0);
|
|
|
|
if (world != NULL) {
|
|
|
|
if (!world->GetUnknown0xd0().empty()) {
|
2024-04-22 08:11:38 -04:00
|
|
|
NotificationManager()->Send(world, MxNotificationParam(c_notificationType20, NULL));
|
2024-02-24 08:55:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_isleScript, IsleScript::c__Isle, NULL);
|
2024-02-24 08:55:00 -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();
|
2024-04-30 04:27:57 -04:00
|
|
|
AnimationManager()->Suspend();
|
2024-01-31 09:47:15 -05:00
|
|
|
VideoManager()->SetUnk0x554(FALSE);
|
2024-01-13 15:42:09 -05:00
|
|
|
|
|
|
|
switch (p_area) {
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_isle:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_isleScript, IsleScript::c__Isle, 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-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_infomainScript, InfomainScript::c__InfoMain, 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-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_infodoorScript, InfodoorScript::c__StartUp, NULL);
|
2024-02-10 09:36:01 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk4:
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_jetrace2:
|
|
|
|
case e_jetraceExterior:
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk17:
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_carraceExterior:
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk20:
|
|
|
|
case e_unk21:
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_pizzeriaExterior:
|
|
|
|
case e_garageExterior:
|
|
|
|
case e_hospitalExterior:
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk31:
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_policeExterior:
|
2024-03-17 13:01:47 -04:00
|
|
|
case e_bike:
|
|
|
|
case e_dunecar:
|
|
|
|
case e_motocycle:
|
|
|
|
case e_copter:
|
|
|
|
case e_skateboard:
|
|
|
|
case e_jetski:
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_unk66:
|
2024-02-24 08:55:00 -05:00
|
|
|
LoadIsle();
|
2024-01-13 15:42:09 -05:00
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_elevbott:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_elevbottScript, ElevbottScript::c__StartUp, NULL);
|
2024-01-31 09:47:15 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_elevride:
|
|
|
|
case e_elevride2:
|
|
|
|
LoadIsle();
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, IsleScript::c_ElevRide, NULL);
|
2024-02-10 09:36:01 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_elevopen:
|
2024-02-10 09:36:01 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, IsleScript::c_ElevOpen, NULL);
|
2024-02-10 09:36:01 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_seaview:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, IsleScript::c_SeaView, NULL);
|
2024-02-10 09:36:01 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_observe:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, IsleScript::c_Observe, NULL);
|
2024-02-10 09:36:01 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_elevdown:
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, IsleScript::c_ElevDown, 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-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_regbookScript, RegbookScript::c__StartUp, 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-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_infoscorScript, InfoscorScript::c__StartUp, 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) {
|
2024-02-24 08:55:00 -05:00
|
|
|
m_currentArea = e_jetrace2;
|
|
|
|
LoadIsle();
|
|
|
|
}
|
|
|
|
else {
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_jetraceScript, JetraceScript::c__JetRace_World, NULL);
|
2024-02-10 09:36:01 -05:00
|
|
|
}
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_carrace:
|
|
|
|
if (m_previousArea == e_infomain) {
|
2024-02-24 08:55:00 -05:00
|
|
|
m_currentArea = e_carraceExterior;
|
|
|
|
LoadIsle();
|
|
|
|
}
|
|
|
|
else {
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_carraceScript, CarraceScript::c__CarRace_World, NULL);
|
2024-02-10 09:36:01 -05:00
|
|
|
}
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_garage:
|
2024-02-10 09:36:01 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_garageScript, GarageScript::c__StartUp, NULL);
|
2024-02-10 09:36:01 -05:00
|
|
|
break;
|
2024-02-24 08:55:00 -05:00
|
|
|
case e_garadoor:
|
|
|
|
LoadIsle();
|
|
|
|
VariableTable()->SetVariable("VISIBILITY", "Hide Gas");
|
2024-02-26 11:19:16 -05:00
|
|
|
CurrentActor()->ResetWorldTransform(FALSE);
|
2024-05-10 14:07:38 -04:00
|
|
|
NavController()->UpdateLocation(59); // LCAMZG1 in g_cameraLocations
|
2024-02-24 08:55:00 -05:00
|
|
|
VideoManager()->Get3DManager()->SetFrustrum(90, 0.1f, 250.0f);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, IsleScript::c_GaraDoor, NULL);
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
|
|
|
case e_unk28: {
|
|
|
|
Act1State* state = (Act1State*) GameState()->GetState("Act1State");
|
|
|
|
LoadIsle();
|
2024-03-19 07:45:29 -04:00
|
|
|
|
2024-02-24 08:55:00 -05:00
|
|
|
if (state->GetUnknown18() == 7) {
|
|
|
|
VideoManager()->Get3DManager()->SetFrustrum(90, 0.1f, 250.0f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetCameraControllerFromIsle();
|
2024-02-26 11:19:16 -05:00
|
|
|
CurrentActor()->ResetWorldTransform(TRUE);
|
2024-04-30 04:27:57 -04:00
|
|
|
AnimationManager()->Resume();
|
2024-02-24 08:55:00 -05:00
|
|
|
}
|
2024-03-19 07:45:29 -04:00
|
|
|
|
2024-05-04 10:13:05 -04:00
|
|
|
CurrentActor()->SpawnPlayer(
|
|
|
|
p_area,
|
|
|
|
TRUE,
|
|
|
|
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
|
|
|
|
);
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case e_hospital:
|
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_hospitalScript, HospitalScript::c__StartUp, NULL);
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
|
|
|
case e_unk33:
|
|
|
|
LoadIsle();
|
|
|
|
SetCameraControllerFromIsle();
|
2024-02-26 11:19:16 -05:00
|
|
|
CurrentActor()->ResetWorldTransform(TRUE);
|
2024-04-30 04:27:57 -04:00
|
|
|
AnimationManager()->Resume();
|
2024-05-04 10:13:05 -04:00
|
|
|
CurrentActor()->SpawnPlayer(
|
|
|
|
p_area,
|
|
|
|
TRUE,
|
|
|
|
IslePathActor::c_spawnBit1 | IslePathActor::c_playMusic | IslePathActor::c_spawnBit3
|
|
|
|
);
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
|
|
|
case e_police:
|
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_policeScript, PoliceScript::c__StartUp, NULL);
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
|
|
|
case e_polidoor:
|
|
|
|
LoadIsle();
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_start, *g_isleScript, IsleScript::c_PoliDoor, NULL);
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
2024-03-17 13:01:47 -04:00
|
|
|
case e_copterbuild:
|
2024-02-24 08:55:00 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_copterScript, CopterScript::c__StartUp, NULL);
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
2024-03-17 13:01:47 -04:00
|
|
|
case e_dunecarbuild:
|
2024-02-24 08:55:00 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_dunecarScript, DunecarScript::c__StartUp, NULL);
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
2024-03-17 13:01:47 -04:00
|
|
|
case e_jetskibuild:
|
2024-02-24 08:55:00 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_jetskiScript, JetskiScript::c__StartUp, NULL);
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
2024-03-17 13:01:47 -04:00
|
|
|
case e_racecarbuild:
|
2024-02-24 08:55:00 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_racecarScript, RacecarScript::c__StartUp, NULL);
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
|
|
|
case e_act2main: {
|
|
|
|
LegoWorld* act2main = FindWorld(*g_act2mainScript, 0);
|
2024-03-19 07:45:29 -04:00
|
|
|
|
2024-02-24 08:55:00 -05:00
|
|
|
if (act2main == NULL) {
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_act2mainScript, Act2mainScript::c__Act2Main, NULL);
|
2024-02-24 08:55:00 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
act2main->Enable(TRUE);
|
|
|
|
}
|
2024-03-19 07:45:29 -04:00
|
|
|
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case e_act3script: {
|
|
|
|
LegoWorld* act3 = FindWorld(*g_act3Script, 0);
|
2024-03-19 07:45:29 -04:00
|
|
|
|
2024-02-24 08:55:00 -05:00
|
|
|
if (act3 == NULL) {
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_act3Script, Act3Script::c__Act3, NULL);
|
2024-02-24 08:55:00 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
act3->Enable(TRUE);
|
|
|
|
}
|
2024-03-19 07:45:29 -04:00
|
|
|
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case e_jukeboxw:
|
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_jukeboxwScript, JukeboxwScript::c__StartUp, NULL);
|
2024-02-24 08:55:00 -05:00
|
|
|
break;
|
|
|
|
case e_unk54:
|
|
|
|
LoadIsle();
|
|
|
|
break;
|
2024-02-10 13:17:07 -05:00
|
|
|
case e_histbook:
|
2024-02-10 09:36:01 -05:00
|
|
|
VideoManager()->SetUnk0x554(TRUE);
|
2024-03-23 13:06:31 -04:00
|
|
|
InvokeAction(Extra::ActionType::e_opendisk, *g_histbookScript, HistbookScript::c__StartUp, NULL);
|
2024-02-10 09:36:01 -05:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2023-11-21 03:44:45 -05:00
|
|
|
}
|
|
|
|
|
2024-02-26 11:19:16 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003ba90
|
|
|
|
void LegoGameState::SetColors()
|
|
|
|
{
|
|
|
|
MxVariableTable* variableTable = VariableTable();
|
|
|
|
|
2024-05-14 10:35:22 -04:00
|
|
|
for (MxS32 i = 0; i < sizeOfArray(g_colorSaveData); i++) {
|
2024-02-26 11:19:16 -05:00
|
|
|
variableTable->SetVariable(g_colorSaveData[i].m_targetName, g_colorSaveData[i].m_colorName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003bac0
|
2023-11-01 11:12:03 -04:00
|
|
|
void LegoGameState::SetROIHandlerFunction()
|
|
|
|
{
|
2024-03-05 12:38:53 -05:00
|
|
|
LegoROI::FUN_100a9d30(&ROIHandlerFunction);
|
2023-11-01 11:12:03 -04:00
|
|
|
}
|
|
|
|
|
2023-12-06 07:10:45 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003bad0
|
2024-03-05 12:38:53 -05:00
|
|
|
MxBool ROIHandlerFunction(const char* p_input, char* p_output, MxU32 p_copyLen)
|
2023-11-01 11:12:03 -04:00
|
|
|
{
|
|
|
|
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-03-25 14:34:28 -04:00
|
|
|
delete m_stateArray[targetIndex];
|
2023-10-24 19:38:27 -04:00
|
|
|
m_stateArray[targetIndex] = p_state;
|
2023-10-23 07:16:21 -04:00
|
|
|
}
|
|
|
|
|
2024-02-28 15:03:27 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003bd00
|
|
|
|
void LegoGameState::Init()
|
|
|
|
{
|
|
|
|
m_backgroundColor->SetValue("set 56 54 68");
|
2024-03-29 16:50:00 -04:00
|
|
|
m_backgroundColor->SetLightColor();
|
2024-02-28 15:03:27 -05:00
|
|
|
m_tempBackgroundColor->SetValue("set 56 54 68");
|
|
|
|
VariableTable()->SetVariable("lightposition", "2");
|
|
|
|
SetLightPosition(2);
|
|
|
|
PlantManager()->Init();
|
|
|
|
BuildingManager()->Init();
|
2024-03-22 13:40:19 -04:00
|
|
|
CharacterManager()->Init();
|
2024-04-27 10:31:50 -04:00
|
|
|
AnimationManager()->Reset(TRUE);
|
2024-02-28 15:03:27 -05:00
|
|
|
SetColors();
|
|
|
|
RemoveActor();
|
|
|
|
DeleteState();
|
|
|
|
m_isDirty = FALSE;
|
|
|
|
FindLoadedAct();
|
|
|
|
SetCurrentAct(e_act1);
|
|
|
|
|
|
|
|
if (m_loadedAct == e_act1) {
|
|
|
|
Isle* isle = (Isle*) FindWorld(*g_isleScript, 0);
|
|
|
|
|
2024-04-28 07:27:17 -04:00
|
|
|
Helicopter* copter = (Helicopter*) isle->Find(*g_copterScript, CopterScript::c_Helicopter_Actor);
|
2024-02-28 15:03:27 -05:00
|
|
|
if (copter) {
|
2024-05-13 06:46:59 -04:00
|
|
|
isle->RemovePathActor(copter);
|
2024-02-28 15:03:27 -05:00
|
|
|
isle->VTable0x6c(copter);
|
|
|
|
delete copter;
|
|
|
|
}
|
|
|
|
|
2024-04-28 07:27:17 -04:00
|
|
|
DuneBuggy* dunebuggy = (DuneBuggy*) isle->Find(*g_dunecarScript, DunecarScript::c_DuneBugy_Actor);
|
2024-02-28 15:03:27 -05:00
|
|
|
if (dunebuggy) {
|
2024-05-13 06:46:59 -04:00
|
|
|
isle->RemovePathActor(dunebuggy);
|
2024-02-28 15:03:27 -05:00
|
|
|
isle->VTable0x6c(dunebuggy);
|
|
|
|
delete dunebuggy;
|
|
|
|
}
|
|
|
|
|
2024-04-28 07:27:17 -04:00
|
|
|
Jetski* jetski = (Jetski*) isle->Find(*g_jetskiScript, JetskiScript::c_Jetski_Actor);
|
2024-02-28 15:03:27 -05:00
|
|
|
if (jetski) {
|
2024-05-13 06:46:59 -04:00
|
|
|
isle->RemovePathActor(jetski);
|
2024-02-28 15:03:27 -05:00
|
|
|
isle->VTable0x6c(jetski);
|
|
|
|
delete jetski;
|
|
|
|
}
|
|
|
|
|
2024-04-28 07:27:17 -04:00
|
|
|
RaceCar* racecar = (RaceCar*) isle->Find(*g_racecarScript, RacecarScript::c_RaceCar_Actor);
|
2024-02-28 15:03:27 -05:00
|
|
|
if (racecar) {
|
2024-05-13 06:46:59 -04:00
|
|
|
isle->RemovePathActor(racecar);
|
2024-02-28 15:03:27 -05:00
|
|
|
isle->VTable0x6c(racecar);
|
|
|
|
delete racecar;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-13 13:17:20 -04:00
|
|
|
m_unk0x42c = e_undefined;
|
2024-02-28 15:03:27 -05:00
|
|
|
}
|
|
|
|
|
2024-02-26 11:19:16 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003c670
|
|
|
|
LegoGameState::Username::Username()
|
|
|
|
{
|
|
|
|
memset(m_letters, -1, sizeof(m_letters));
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x1003c690
|
|
|
|
MxResult LegoGameState::Username::ReadWrite(LegoStorage* p_storage)
|
|
|
|
{
|
|
|
|
if (p_storage->IsReadMode()) {
|
|
|
|
for (MxS16 i = 0; i < 7; i++) {
|
|
|
|
p_storage->Read(&m_letters[i], sizeof(m_letters[i]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (p_storage->IsWriteMode()) {
|
|
|
|
for (MxS16 i = 0; i < 7; i++) {
|
|
|
|
MxS16 letter = m_letters[i];
|
|
|
|
p_storage->Write(&letter, sizeof(letter));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2024-02-19 09:24:30 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003c710
|
2024-02-28 15:03:27 -05:00
|
|
|
LegoGameState::Username& LegoGameState::Username::operator=(const Username& p_other)
|
2024-02-19 09:24:30 -05:00
|
|
|
{
|
2024-02-28 15:03:27 -05:00
|
|
|
memcpy(m_letters, p_other.m_letters, sizeof(m_letters));
|
|
|
|
return *this;
|
2024-02-19 09:24:30 -05:00
|
|
|
}
|
|
|
|
|
2024-02-26 11:19:16 -05:00
|
|
|
// FUNCTION: LEGO1 0x1003c830
|
|
|
|
LegoGameState::History::History()
|
|
|
|
{
|
|
|
|
m_count = 0;
|
|
|
|
m_unk0x372 = 0;
|
|
|
|
}
|
|
|
|
|
2023-12-15 17:01:09 -05:00
|
|
|
// STUB: LEGO1 0x1003c870
|
2024-02-26 11:19:16 -05:00
|
|
|
void LegoGameState::History::WriteScoreHistory()
|
2023-12-15 17:01:09 -05:00
|
|
|
{
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
// STUB: LEGO1 0x1003ccf0
|
2024-02-26 11:19:16 -05:00
|
|
|
void LegoGameState::History::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) {
|
2024-02-26 11:19:16 -05:00
|
|
|
m_history.WriteScoreHistory();
|
2023-12-15 17:01:09 -05:00
|
|
|
}
|
|
|
|
|
2024-01-24 12:12:57 -05:00
|
|
|
if (stream.Open(savePath.GetData(), p_flags) == SUCCESS) {
|
2024-02-26 11:19:16 -05:00
|
|
|
m_history.FUN_1003ccf0(stream);
|
2023-12-15 17:01:09 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|