Finish LegoVariables class (#698)

* Finish LegoVariables class

* Update legonavcontroller.cpp

* Update legobackgroundcolor.cpp

* Match functions, style, refactor visible

* Use MxBool

* Merge/fix

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Misha 2024-03-19 14:44:42 -04:00 committed by GitHub
parent d92963982a
commit eaa935f646
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 135 additions and 39 deletions

View file

@ -36,7 +36,7 @@ class LegoModelPresenter : public MxVideoPresenter {
void ParseExtra() override; // vtable+0x30
void Destroy() override; // vtable+0x38
MxResult FUN_1007ff70(MxDSChunk& p_chunk, LegoEntity* p_entity, undefined p_modelUnknown0x34, LegoWorld* p_world);
MxResult FUN_1007ff70(MxDSChunk& p_chunk, LegoEntity* p_entity, MxBool p_roiVisible, LegoWorld* p_world);
inline void Reset()
{

View file

@ -71,6 +71,7 @@ class LegoNavController : public MxCore {
MxBool p_urs
);
static void SetLocation(MxU32 p_location);
static void UpdateCameraLocation(const char* p_location);
// SYNTHETIC: LEGO1 0x10054c10
// LegoNavController::`scalar deleting destructor'

View file

@ -64,7 +64,7 @@ void SetIsWorldActive(MxBool p_isWorldActive);
void DeleteObjects(MxAtomId* p_id, MxS32 p_first, MxS32 p_last);
void SetCurrentWorld(LegoWorld* p_world);
void FUN_10015820(MxBool p_disable, MxU16 p_flags);
void SetROIUnknown0x0c(const char* p_name, undefined p_unk0x0c);
void SetROIVisible(const char* p_name, MxBool p_visible);
void SetCurrentActor(IslePathActor* p_currentActor);
#endif // MISC_H

View file

@ -113,7 +113,7 @@ LegoROI* LegoCharacterManager::GetROI(const char* p_key, MxBool p_createEntity)
if (character == NULL) {
LegoROI* roi = CreateROI(p_key);
roi->SetUnknown0x0c(0);
roi->SetVisibility(FALSE);
if (roi != NULL) {
character = new LegoCharacter(roi);

View file

@ -2,8 +2,12 @@
#include "legobuildingmanager.h"
#include "legocharactermanager.h"
#include "legogamestate.h"
#include "legonavcontroller.h"
#include "legoplantmanager.h"
#include "legovideomanager.h"
#include "misc.h"
#include "roi/legoroi.h"
DECOMP_SIZE_ASSERT(VisibilityVariable, 0x24)
DECOMP_SIZE_ASSERT(CameraLocationVariable, 0x24)
@ -27,16 +31,81 @@ const char* g_varCURSOR = "CURSOR";
// STRING: LEGO1 0x100f3a1c
const char* g_varWHOAMI = "WHO_AM_I";
// STUB: LEGO1 0x10037d00
// GLOBAL: LEGO1 0x100f3a50
// STRING: LEGO1 0x100f3a18
const char* g_delimiter2 = " \t";
// GLOBAL: LEGO1 0x100f3a54
// STRING: LEGO1 0x100f3a10
const char* g_varHIDE = "HIDE";
// GLOBAL: LEGO1 0x100f3a58
// STRING: LEGO1 0x100f3a08
const char* g_varSHOW = "SHOW";
// GLOBAL: LEGO1 0x100f3a5c
// STRING: LEGO1 0x100f3a00
const char* g_papa = "Papa";
// GLOBAL: LEGO1 0x100f3a60
// STRING: LEGO1 0x100f39f8
const char* g_mama = "Mama";
// GLOBAL: LEGO1 0x100f3a64
// STRING: LEGO1 0x100f39f0
const char* g_pepper = "Pepper";
// GLOBAL: LEGO1 0x100f3a68
// STRING: LEGO1 0x100f39e8
const char* g_nick = "Nick";
// GLOBAL: LEGO1 0x100f3a6c
// STRING: LEGO1 0x100f39e0
const char* g_laura = "Laura";
// FUNCTION: LEGO1 0x10037d00
void VisibilityVariable::SetValue(const char* p_value)
{
// TODO
MxVariable::SetValue(p_value);
if (p_value) {
char* instruction = strtok(m_value.GetDataPtr(), g_delimiter2);
char* name = strtok(NULL, g_delimiter2);
MxBool show;
if (!strcmpi(instruction, g_varHIDE)) {
show = FALSE;
}
else if (!strcmpi(instruction, g_varSHOW)) {
show = TRUE;
}
else {
return;
}
LegoROI* roi = FindROI(name);
if (roi) {
roi->SetVisibility(show);
}
}
}
// STUB: LEGO1 0x10037d80
// FUNCTION: LEGO1 0x10037d80
void CameraLocationVariable::SetValue(const char* p_value)
{
// TODO
char buffer[256];
MxVariable::SetValue(p_value);
strcpy(buffer, p_value);
char* location = strtok(buffer, ",");
NavController()->UpdateCameraLocation(location);
location = strtok(NULL, ",");
if (location) {
MxFloat pov = (MxFloat) atof(location);
VideoManager()->Get3DManager()->SetFrustrum(pov, 0.1f, 250.0f);
}
}
// FUNCTION: LEGO1 0x10037e30
@ -44,10 +113,26 @@ void CursorVariable::SetValue(const char* p_value)
{
}
// STUB: LEGO1 0x10037e40
// FUNCTION: LEGO1 0x10037e40
void WhoAmIVariable::SetValue(const char* p_value)
{
// TODO
MxVariable::SetValue(p_value);
if (!strcmpi(p_value, g_papa)) {
GameState()->SetActorId(3);
}
else if (!strcmpi(p_value, g_mama)) {
GameState()->SetActorId(2);
}
else if (!strcmpi(p_value, g_pepper)) {
GameState()->SetActorId(1);
}
else if (!strcmpi(p_value, g_nick)) {
GameState()->SetActorId(4);
}
else if (!strcmpi(p_value, g_laura)) {
GameState()->SetActorId(5);
}
}
// FUNCTION: LEGO1 0x10085aa0

View file

@ -124,12 +124,12 @@ LegoROI* FindROI(const char* p_name)
}
// FUNCTION: LEGO1 0x10015860
void SetROIUnknown0x0c(const char* p_name, undefined p_unk0x0c)
void SetROIVisible(const char* p_name, MxBool p_visible)
{
LegoROI* roi = FindROI(p_name);
if (roi) {
roi->SetUnknown0x0c(p_unk0x0c);
roi->SetVisibility(p_visible);
}
}

View file

@ -361,6 +361,12 @@ MxBool LegoNavController::CalculateNewPosDir(
return changed;
}
// STUB: LEGO1 0x10055500
void LegoNavController::UpdateCameraLocation(const char* p_location)
{
// TODO
}
// STUB: LEGO1 0x10055620
void LegoNavController::SetLocation(MxU32 p_location)
{

View file

@ -388,7 +388,7 @@ MxBool LegoInputManager::ProcessOneEvent(LegoEventNotificationParam& p_param)
LegoROI* roi = PickROI(p_param.GetX(), p_param.GetY());
p_param.SetROI(roi);
if (roi && roi->GetUnknown0x0c() == 1) {
if (roi && roi->GetVisibility()) {
for (OrientableROI* parent = roi->GetParentROI(); parent; parent = parent->GetParentROI()) {
roi = (LegoROI*) parent;
}

View file

@ -162,7 +162,7 @@ void LegoAnimPresenter::FUN_100692b0()
roi = CharacterManager()->GetROI(src, TRUE);
if (roi != NULL && str[0] == '*') {
roi->SetUnknown0x0c(0);
roi->SetVisibility(FALSE);
}
}
else if (unk0x04 == 4) {
@ -174,7 +174,7 @@ void LegoAnimPresenter::FUN_100692b0()
roi = CharacterManager()->FUN_10085a80(und, src, 1);
if (roi != NULL) {
roi->SetUnknown0x0c(0);
roi->SetVisibility(FALSE);
}
delete[] src;
@ -198,7 +198,7 @@ void LegoAnimPresenter::FUN_100692b0()
roi = CharacterManager()->FUN_10085210(und, src, 1);
if (roi != NULL) {
roi->SetUnknown0x0c(0);
roi->SetVisibility(FALSE);
}
delete[] src;

View file

@ -208,7 +208,7 @@ MxResult LegoModelPresenter::CreateROI(MxDSChunk* p_chunk)
MxResult LegoModelPresenter::FUN_1007ff70(
MxDSChunk& p_chunk,
LegoEntity* p_entity,
undefined p_modelUnknown0x34,
MxBool p_roiVisible,
LegoWorld* p_world
)
{
@ -222,7 +222,7 @@ MxResult LegoModelPresenter::FUN_1007ff70(
}
if (m_roi != NULL) {
m_roi->SetUnknown0x0c(p_modelUnknown0x34);
m_roi->SetVisibility(p_roiVisible);
}
if (p_entity != NULL) {

View file

@ -296,8 +296,8 @@ MxLong Infocenter::HandleEndAction(MxEndActionNotificationParam& p_param)
m_currentCutscene = e_noIntro;
return 1;
case 2:
SetROIUnknown0x0c(g_object2x4red, 0);
SetROIUnknown0x0c(g_object2x4grn, 0);
SetROIVisible(g_object2x4red, FALSE);
SetROIVisible(g_object2x4grn, FALSE);
BackgroundAudioManager()->RaiseVolume();
return 1;
case 4:
@ -329,7 +329,7 @@ MxLong Infocenter::HandleEndAction(MxEndActionNotificationParam& p_param)
}
m_infocenterState->SetUnknown0x74(2);
SetROIUnknown0x0c("infoman", 1);
SetROIVisible("infoman", TRUE);
return 1;
case 12:
if (action->GetObjectId() == m_currentInfomainScript) {
@ -1067,15 +1067,15 @@ MxLong Infocenter::HandleNotification0(MxNotificationParam& p_param)
}
PlayAction(objectId);
SetROIUnknown0x0c(g_object2x4red, 0);
SetROIUnknown0x0c(g_object2x4grn, 0);
SetROIVisible(g_object2x4red, FALSE);
SetROIVisible(g_object2x4grn, FALSE);
return 1;
}
case 6:
if (m_infocenterState->GetUnknown0x74() == 8) {
StopCurrentAction();
SetROIUnknown0x0c(g_object2x4red, 0);
SetROIUnknown0x0c(g_object2x4grn, 0);
SetROIVisible(g_object2x4red, FALSE);
SetROIVisible(g_object2x4grn, FALSE);
m_infocenterState->SetUnknown0x74(2);
PlayAction(InfomainScript::c_iicb28in_RunAnim);
return 1;

View file

@ -773,11 +773,11 @@ void Isle::Enable(MxBool p_enable)
FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen);
}
SetROIUnknown0x0c("stretch", 0);
SetROIUnknown0x0c("bird", 0);
SetROIUnknown0x0c("rcred", 0);
SetROIUnknown0x0c("towtk", 0);
SetROIUnknown0x0c("pizpie", 0);
SetROIVisible("stretch", FALSE);
SetROIVisible("bird", FALSE);
SetROIVisible("rcred", FALSE);
SetROIVisible("towtk", FALSE);
SetROIVisible("pizpie", FALSE);
}
else {
if (InputManager()->GetWorld() == this) {
@ -828,7 +828,7 @@ MxLong Isle::HandleTransitionEnd()
switch (m_destLocation) {
case LegoGameState::e_infomain:
((LegoEntity*) Find(*g_isleScript, IsleScript::c_InfoCenter_Entity))->GetROI()->SetUnknown0x0c(1);
((LegoEntity*) Find(*g_isleScript, IsleScript::c_InfoCenter_Entity))->GetROI()->SetVisibility(TRUE);
GameState()->SwitchArea(m_destLocation);
m_destLocation = LegoGameState::e_undefined;
break;

View file

@ -324,7 +324,7 @@ void RegistrationBook::ReadyWorld()
LegoROI* infoman = FindROI(g_infoman);
if (infoman != NULL) {
infoman->SetUnknown0x0c(0);
infoman->SetVisibility(FALSE);
}
}
else {

View file

@ -394,7 +394,7 @@ LegoResult LegoROI::FUN_100a8da0(LegoTreeNode* p_node, const Matrix4& p_matrix,
roi->VTable0x1c();
LegoBool und = data->FUN_100a0990(p_time);
roi->SetUnknown0x0c(und);
roi->SetVisibility(und);
for (LegoU32 i = 0; i < p_node->GetNumChildren(); i++) {
FUN_100a8da0(p_node->GetChild(i), roi->m_local2world, p_time, roi);

View file

@ -45,6 +45,9 @@
// LIBRARY: LEGO1 0x1008b680
// _strncmp
// LIBRARY: LEGO1 0x1008b6c0
// _atof
// LIBRARY: LEGO1 0x1008b730
// _fprintf

View file

@ -21,6 +21,7 @@ class MxString : public MxCore {
inline MxS8 Compare(const MxString& p_str) const { return strcmp(m_data, p_str.m_data); }
inline const char* GetData() const { return m_data; }
inline char* GetDataPtr() const { return m_data; }
inline const MxU16 GetLength() const { return m_length; }
// SYNTHETIC: LEGO1 0x100ae280

View file

@ -90,7 +90,7 @@ class ROI {
{
comp = 0;
lods = 0;
m_unk0x0c = 1;
m_visible = true;
}
virtual ~ROI()
{
@ -112,16 +112,16 @@ class ROI {
int GetLODCount() const { return lods ? lods->Size() : 0; }
const CompoundObject* GetComp() const { return comp; }
inline undefined GetUnknown0x0c() { return m_unk0x0c; }
inline void SetUnknown0x0c(undefined p_unk0x0c) { m_unk0x0c = p_unk0x0c; }
inline unsigned char GetVisibility() { return m_visible; }
inline void SetVisibility(unsigned char p_visible) { m_visible = p_visible; }
// SYNTHETIC: LEGO1 0x100a5d60
// ROI::`scalar deleting destructor'
protected:
CompoundObject* comp; // 0x04
LODListBase* lods; // 0x08
undefined m_unk0x0c; // 0x0c
CompoundObject* comp; // 0x04
LODListBase* lods; // 0x08
unsigned char m_visible; // 0x0c
};
// TEMPLATE: LEGO1 0x10084930

View file

@ -185,7 +185,7 @@ void ViewManager::FUN_100a66a0(ViewROI* p_roi)
// FUNCTION: LEGO1 0x100a66f0
inline void ViewManager::FUN_100a66f0(ViewROI* p_roi, int p_und)
{
if (p_roi->GetUnknown0x0c() == FALSE && p_und != -2) {
if (!p_roi->GetVisibility() && p_und != -2) {
FUN_100a66f0(p_roi, -2);
}
else {