This commit is contained in:
Christian Semmler 2024-03-21 12:44:53 -04:00
parent 9256554406
commit 3e7d9834a9
5 changed files with 140 additions and 71 deletions

View File

@ -33,29 +33,24 @@ struct LegoCharacter {
typedef map<const char*, LegoCharacter*, LegoCharacterComparator> LegoCharacterMap; typedef map<const char*, LegoCharacter*, LegoCharacterComparator> LegoCharacterMap;
struct LegoSaveDataEntry3 { // SIZE 0x108
char* m_name; struct LegoCharacterData {
void* m_unk0x04; // SIZE 0x18
LegoActor* m_actor; struct Unknown {
MxS32 m_savePart1; undefined m_unk0x00; // 0x00 - offset used with unk0x04
MxS32 m_savePart2; undefined4 m_unk0x04; // 0x04 - presumably pointer into global 100da40c
MxU8 m_savePart3; undefined m_unk0x08; // 0x08 - offset used with unk0x04
undefined4 m_unk0x18[6]; undefined4 m_unk0x0c[2]; // 0x0c
MxU8 m_frameOffsetInDwords; // 0x30 undefined m_unk0x14; // 0x14
MxS32* m_pFrameData; };
MxU8 m_currentFrame;
undefined4 m_unk0x3c[2]; char* m_name; // 0x00
MxU8 m_savePart5; // 0x44 void* m_unk0x04; // 0x04
undefined4 m_unk0x48[5]; LegoActor* m_actor; // 0x08
MxU8 m_savePart6; // 0x5c MxS32 m_unk0x0c; // 0x0c
undefined4 m_unk0x60[11]; MxS32 m_unk0x10; // 0x10
MxU8 m_savePart7; // 0x8c MxU8 m_unk0x14; // 0x14
undefined4 m_unk0x90[5]; Unknown m_unk0x18[10]; // 0x18
MxU8 m_savePart8; // 0xa4
undefined4 m_unk0xa8[17];
MxU8 m_savePart9; // 0xec
undefined4 m_unk0xf0[5];
MxU8 m_savePart10; // 0x104
}; };
// SIZE 0x08 // SIZE 0x08
@ -63,18 +58,18 @@ class LegoCharacterManager {
public: public:
LegoCharacterManager(); LegoCharacterManager();
MxResult WriteSaveData3(LegoStorage* p_storage); MxResult FUN_10083310(LegoStorage* p_storage);
MxResult ReadSaveData3(LegoStorage* p_storage); MxResult FUN_100833f0(LegoStorage* p_storage);
LegoROI* GetROI(const char* p_key, MxBool p_createEntity); LegoROI* GetROI(const char* p_key, MxBool p_createEntity);
void InitSaveData(); void FUN_10083270();
static void SetCustomizeAnimFile(const char* p_value); static void SetCustomizeAnimFile(const char* p_value);
static MxBool FUN_10084c00(const LegoChar*); static MxBool FUN_10084c00(const LegoChar*);
void FUN_100832a0(); void FUN_100832a0();
void FUN_10083db0(LegoROI* p_roi); void FUN_10083db0(LegoROI* p_roi);
void FUN_10083f10(LegoROI* p_roi); void FUN_10083f10(LegoROI* p_roi);
LegoSaveDataEntry3* FUN_10084c60(const char* p_key); LegoCharacterData* FUN_10084c60(const char* p_key);
MxBool FUN_10084ec0(LegoROI* p_roi); MxBool FUN_10084ec0(LegoROI* p_roi);
MxU32 FUN_10085140(LegoROI*, MxBool); MxU32 FUN_10085140(LegoROI*, MxBool);
LegoROI* FUN_10085210(const LegoChar*, LegoChar*, undefined); LegoROI* FUN_10085210(const LegoChar*, LegoChar*, undefined);

View File

@ -9,32 +9,33 @@
DECOMP_SIZE_ASSERT(LegoCharacter, 0x08) DECOMP_SIZE_ASSERT(LegoCharacter, 0x08)
DECOMP_SIZE_ASSERT(LegoCharacterManager, 0x08) DECOMP_SIZE_ASSERT(LegoCharacterManager, 0x08)
DECOMP_SIZE_ASSERT(LegoSaveDataEntry3, 0x108) DECOMP_SIZE_ASSERT(LegoCharacterData::Unknown, 0x18)
DECOMP_SIZE_ASSERT(LegoCharacterData, 0x108)
// GLOBAL: LEGO1 0x100f80c0 // GLOBAL: LEGO1 0x100f80c0
LegoSaveDataEntry3 g_saveDataInit[66]; // TODO: add data LegoCharacterData g_characterDataInit[66]; // TODO: add data
// GLOBAL: LEGO1 0x100fc4e4 // GLOBAL: LEGO1 0x100fc4e4
char* LegoCharacterManager::g_customizeAnimFile = NULL; char* LegoCharacterManager::g_customizeAnimFile = NULL;
// GLOBAL: LEGO1 0x10104f20 // GLOBAL: LEGO1 0x10104f20
LegoSaveDataEntry3 g_saveData3[66]; LegoCharacterData g_characterData[66];
// FUNCTION: LEGO1 0x10082a20 // FUNCTION: LEGO1 0x10082a20
LegoCharacterManager::LegoCharacterManager() LegoCharacterManager::LegoCharacterManager()
{ {
m_characters = new LegoCharacterMap(); m_characters = new LegoCharacterMap();
InitSaveData(); FUN_10083270();
m_customizeAnimFile = new CustomizeAnimFileVariable("CUSTOMIZE_ANIM_FILE"); m_customizeAnimFile = new CustomizeAnimFileVariable("CUSTOMIZE_ANIM_FILE");
VariableTable()->SetVariable(m_customizeAnimFile); VariableTable()->SetVariable(m_customizeAnimFile);
} }
// FUNCTION: LEGO1 0x10083270 // FUNCTION: LEGO1 0x10083270
void LegoCharacterManager::InitSaveData() void LegoCharacterManager::FUN_10083270()
{ {
for (MxS32 i = 0; i < 66; i++) { for (MxS32 i = 0; i < _countof(g_characterData); i++) {
g_saveData3[i] = g_saveDataInit[i]; g_characterData[i] = g_characterDataInit[i];
} }
} }
@ -45,57 +46,53 @@ void LegoCharacterManager::FUN_100832a0()
} }
// FUNCTION: LEGO1 0x10083310 // FUNCTION: LEGO1 0x10083310
MxResult LegoCharacterManager::WriteSaveData3(LegoStorage* p_storage) MxResult LegoCharacterManager::FUN_10083310(LegoStorage* p_storage)
{ {
MxResult result = FAILURE; MxResult result = FAILURE;
// This should probably be a for loop but I can't figure out how to for (MxS32 i = 0; i < _countof(g_characterData); i++) {
// make it match as a for loop. LegoCharacterData* data = &g_characterData[i];
LegoSaveDataEntry3* entry = g_saveData3;
const LegoSaveDataEntry3* end = &g_saveData3[66];
while (TRUE) { if (p_storage->Write(&data->m_unk0x0c, sizeof(data->m_unk0x0c)) != SUCCESS) {
if (p_storage->Write(&entry->m_savePart1, 4) != SUCCESS) { goto done;
break;
} }
if (p_storage->Write(&entry->m_savePart2, 4) != SUCCESS) { if (p_storage->Write(&data->m_unk0x10, sizeof(data->m_unk0x10)) != SUCCESS) {
break; goto done;
} }
if (p_storage->Write(&entry->m_savePart3, 1) != SUCCESS) { if (p_storage->Write(&data->m_unk0x14, sizeof(data->m_unk0x14)) != SUCCESS) {
break; goto done;
} }
if (p_storage->Write(&entry->m_currentFrame, 1) != SUCCESS) { if (p_storage->Write(&data->m_unk0x18[1].m_unk0x08, sizeof(data->m_unk0x18[1].m_unk0x08)) != SUCCESS) {
break; goto done;
} }
if (p_storage->Write(&entry->m_savePart5, 1) != SUCCESS) { if (p_storage->Write(&data->m_unk0x18[1].m_unk0x14, sizeof(data->m_unk0x18[1].m_unk0x14)) != SUCCESS) {
break; goto done;
} }
if (p_storage->Write(&entry->m_savePart6, 1) != SUCCESS) { if (p_storage->Write(&data->m_unk0x18[2].m_unk0x14, sizeof(data->m_unk0x18[2].m_unk0x14)) != SUCCESS) {
break; goto done;
} }
if (p_storage->Write(&entry->m_savePart7, 1) != SUCCESS) { if (p_storage->Write(&data->m_unk0x18[4].m_unk0x14, sizeof(data->m_unk0x18[4].m_unk0x14)) != SUCCESS) {
break; goto done;
} }
if (p_storage->Write(&entry->m_savePart8, 1) != SUCCESS) { if (p_storage->Write(&data->m_unk0x18[5].m_unk0x14, sizeof(data->m_unk0x18[5].m_unk0x14)) != SUCCESS) {
break; goto done;
} }
if (p_storage->Write(&entry->m_savePart9, 1) != SUCCESS) { if (p_storage->Write(&data->m_unk0x18[8].m_unk0x14, sizeof(data->m_unk0x18[8].m_unk0x14)) != SUCCESS) {
break; goto done;
} }
if (p_storage->Write(&entry->m_savePart10, 1) != SUCCESS) { if (p_storage->Write(&data->m_unk0x18[9].m_unk0x14, sizeof(data->m_unk0x18[9].m_unk0x14)) != SUCCESS) {
break; goto done;
}
if (++entry >= end) {
result = SUCCESS;
break;
} }
} }
result = SUCCESS;
done:
return result; return result;
} }
// STUB: LEGO1 0x100833f0 // STUB: LEGO1 0x100833f0
MxResult LegoCharacterManager::ReadSaveData3(LegoStorage* p_storage) MxResult LegoCharacterManager::FUN_100833f0(LegoStorage* p_storage)
{ {
return SUCCESS; return SUCCESS;
} }
@ -160,10 +157,66 @@ void LegoCharacterManager::FUN_10083f10(LegoROI* p_roi)
// TODO // TODO
} }
// STUB: LEGO1 0x10084030 // FUNCTION: LEGO1 0x10084030
LegoROI* LegoCharacterManager::CreateROI(const char* p_key) LegoROI* LegoCharacterManager::CreateROI(const char* p_key)
{ {
return NULL; MxBool success = FALSE;
LegoROI* roi = NULL;
BoundingSphere boundingSphere;
BoundingBox boundingBox;
MxMatrix mat;
CompoundObject* comp;
Tgl::Renderer* renderer = VideoManager()->GetRenderer();
ViewLODListManager* lodManager = GetViewLODListManager();
LegoTextureContainer* textureContainer = TextureContainer();
LegoCharacterData* entry = FUN_10084c60(p_key);
if (entry == NULL) {
goto done;
}
if (!strcmpi(p_key, "pep")) {
LegoCharacterData* pepper = FUN_10084c60("pepper");
entry->m_unk0x0c = pepper->m_unk0x0c;
entry->m_unk0x10 = pepper->m_unk0x10;
entry->m_unk0x14 = pepper->m_unk0x14;
for (MxS32 i = 0; i < _countof(entry->m_unk0x18); i++) {
entry->m_unk0x18[i] = pepper->m_unk0x18[i];
}
}
roi = new LegoROI(renderer);
roi->SetName(p_key);
boundingSphere.Center()[0] = 0.000267f;
boundingSphere.Center()[1] = 0.78080797f;
boundingSphere.Center()[2] = -0.01906f;
boundingSphere.Radius() = 0.951612f;
roi->SetBoundingSphere(boundingSphere);
boundingBox.Min()[0] = -0.46116599f;
boundingBox.Min()[1] = -0.002794f;
boundingBox.Min()[2] = -0.29944199f;
boundingBox.Max()[0] = 0.46169999f;
boundingBox.Max()[1] = 1.56441f;
boundingBox.Max()[2] = 0.261321f;
roi->SetUnknown0x80(boundingBox);
comp = new CompoundObject();
roi->SetComp(comp);
done:
if (!success && roi != NULL) {
delete roi;
roi = NULL;
}
return roi;
} }
// STUB: LEGO1 0x10084c00 // STUB: LEGO1 0x10084c00
@ -174,7 +227,7 @@ MxBool LegoCharacterManager::FUN_10084c00(const LegoChar*)
} }
// STUB: LEGO1 0x10084c60 // STUB: LEGO1 0x10084c60
LegoSaveDataEntry3* LegoCharacterManager::FUN_10084c60(const char* p_key) LegoCharacterData* LegoCharacterManager::FUN_10084c60(const char* p_key)
{ {
return NULL; return NULL;
} }

View File

@ -235,7 +235,7 @@ MxResult LegoGameState::Save(MxULong p_slot)
} }
WriteEndOfVariables(&fileStorage); WriteEndOfVariables(&fileStorage);
CharacterManager()->WriteSaveData3(&fileStorage); CharacterManager()->FUN_10083310(&fileStorage);
PlantManager()->Save(&fileStorage); PlantManager()->Save(&fileStorage);
result = BuildingManager()->Save(&fileStorage); result = BuildingManager()->Save(&fileStorage);
@ -334,7 +334,7 @@ MxResult LegoGameState::Load(MxULong p_slot)
SetLightPosition(atoi(lightPosition)); SetLightPosition(atoi(lightPosition));
} }
if (CharacterManager()->ReadSaveData3(&fileStorage) == FAILURE) { if (CharacterManager()->FUN_100833f0(&fileStorage) == FAILURE) {
goto done; goto done;
} }
if (PlantManager()->Load(&fileStorage) == FAILURE) { if (PlantManager()->Load(&fileStorage) == FAILURE) {
@ -1057,7 +1057,7 @@ void LegoGameState::Init()
SetLightPosition(2); SetLightPosition(2);
PlantManager()->Init(); PlantManager()->Init();
BuildingManager()->Init(); BuildingManager()->Init();
CharacterManager()->InitSaveData(); CharacterManager()->FUN_10083270();
AnimationManager()->FUN_1005ee80(TRUE); AnimationManager()->FUN_1005ee80(TRUE);
SetColors(); SetColors();
RemoveActor(); RemoveActor();

View File

@ -553,6 +553,23 @@ void LegoROI::FUN_100a9d30(ROIHandler p_func)
g_unk0x101013ac = p_func; g_unk0x101013ac = p_func;
} }
// FUNCTION: LEGO1 0x100a9d40
void LegoROI::SetName(const LegoChar* p_name)
{
if (m_name != NULL) {
delete[] m_name;
}
if (p_name != NULL) {
m_name = new LegoChar[strlen(p_name) + 1];
strcpy(m_name, p_name);
strlwr(m_name);
}
else {
m_name = NULL;
}
}
// FUNCTION: LEGO1 0x100a9e10 // FUNCTION: LEGO1 0x100a9e10
void LegoROI::SetDisplayBB(int p_displayBB) void LegoROI::SetDisplayBB(int p_displayBB)
{ {

View File

@ -34,6 +34,7 @@ class LegoROI : public ViewROI {
LegoResult SetFrame(LegoAnim* p_anim, LegoTime p_time); LegoResult SetFrame(LegoAnim* p_anim, LegoTime p_time);
LegoResult FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha); LegoResult FUN_100a9170(LegoFloat p_red, LegoFloat p_green, LegoFloat p_blue, LegoFloat p_alpha);
LegoResult FUN_100a9210(LegoTextureInfo* p_textureInfo); LegoResult FUN_100a9210(LegoTextureInfo* p_textureInfo);
void SetName(const LegoChar* p_name);
float IntrinsicImportance() const override; // vtable+0x04 float IntrinsicImportance() const override; // vtable+0x04
void UpdateWorldBoundingVolumes() override; // vtable+0x18 void UpdateWorldBoundingVolumes() override; // vtable+0x18
@ -58,6 +59,9 @@ class LegoROI : public ViewROI {
inline LegoEntity* GetEntity() { return m_entity; } inline LegoEntity* GetEntity() { return m_entity; }
inline void SetEntity(LegoEntity* p_entity) { m_entity = p_entity; } inline void SetEntity(LegoEntity* p_entity) { m_entity = p_entity; }
inline void SetComp(CompoundObject* p_comp) { comp = p_comp; }
inline void SetBoundingSphere(const BoundingSphere& p_sphere) { m_sphere = m_world_bounding_sphere = p_sphere; }
inline void SetUnknown0x80(const BoundingBox& p_unk0x80) { m_unk0x80 = p_unk0x80; }
// SYNTHETIC: LEGO1 0x100a82b0 // SYNTHETIC: LEGO1 0x100a82b0
// LegoROI::`scalar deleting destructor' // LegoROI::`scalar deleting destructor'