Implement/match LegoAnimationManager::ModelExists (#894)

* Implement/match LegoAnimationManager::FUN_10062520

* Name function
This commit is contained in:
Christian Semmler 2024-05-09 15:53:13 -04:00 committed by GitHub
parent 5629eb3c85
commit 9ae2acbea8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 18 deletions

View file

@ -5,7 +5,7 @@
// SIZE 0x30 // SIZE 0x30
struct ModelInfo { struct ModelInfo {
char* m_modelName; // 0x00 char* m_name; // 0x00
MxU8 m_unk0x04; // 0x04 MxU8 m_unk0x04; // 0x04
float m_location[3]; // 0x08 float m_location[3]; // 0x08
float m_direction[3]; // 0x14 float m_direction[3]; // 0x14
@ -15,7 +15,7 @@ struct ModelInfo {
// SIZE 0x30 // SIZE 0x30
struct AnimInfo { struct AnimInfo {
char* m_animName; // 0x00 char* m_name; // 0x00
MxU32 m_objectId; // 0x04 MxU32 m_objectId; // 0x04
MxS16 m_unk0x08; // 0x08 MxS16 m_unk0x08; // 0x08
MxBool m_unk0x0a; // 0x0a MxBool m_unk0x0a; // 0x0a

View file

@ -138,7 +138,7 @@ class LegoAnimationManager : public MxCore {
); );
MxS8 GetCharacterIndex(const char* p_name); MxS8 GetCharacterIndex(const char* p_name);
MxBool FUN_100623a0(AnimInfo& p_info); MxBool FUN_100623a0(AnimInfo& p_info);
MxBool FUN_10062520(AnimInfo& p_info, const char*); MxBool ModelExists(AnimInfo& p_info, const char* p_name);
void FUN_10062580(AnimInfo& p_info); void FUN_10062580(AnimInfo& p_info);
MxBool FUN_10062650(Vector3&, float, LegoROI*); MxBool FUN_10062650(Vector3&, float, LegoROI*);
MxBool FUN_10062710(AnimInfo& p_info); MxBool FUN_10062710(AnimInfo& p_info);

View file

@ -475,7 +475,7 @@ MxResult LegoAnimationManager::LoadScriptInfo(MxS32 p_scriptIndex)
goto done; goto done;
} }
m_anims[j].m_unk0x28 = GetCharacterIndex(m_anims[j].m_animName + strlen(m_anims[j].m_animName) - 2); m_anims[j].m_unk0x28 = GetCharacterIndex(m_anims[j].m_name + strlen(m_anims[j].m_name) - 2);
m_anims[j].m_unk0x29 = FALSE; m_anims[j].m_unk0x29 = FALSE;
for (k = 0; k < 3; k++) { for (k = 0; k < 3; k++) {
@ -484,7 +484,7 @@ MxResult LegoAnimationManager::LoadScriptInfo(MxS32 p_scriptIndex)
if (m_anims[j].m_unk0x08 == -1) { if (m_anims[j].m_unk0x08 == -1) {
for (MxS32 l = 0; l < m_anims[j].m_modelCount; l++) { for (MxS32 l = 0; l < m_anims[j].m_modelCount; l++) {
MxS32 index = GetCharacterIndex(m_anims[j].m_models[l].m_modelName); MxS32 index = GetCharacterIndex(m_anims[j].m_models[l].m_name);
if (index >= 0) { if (index >= 0) {
g_characters[index].m_active = TRUE; g_characters[index].m_active = TRUE;
@ -496,7 +496,7 @@ MxResult LegoAnimationManager::LoadScriptInfo(MxS32 p_scriptIndex)
for (MxS32 m = 0; m < m_anims[j].m_modelCount; m++) { for (MxS32 m = 0; m < m_anims[j].m_modelCount; m++) {
MxU32 n; MxU32 n;
if (FindVehicle(m_anims[j].m_models[m].m_modelName, n) && m_anims[j].m_models[m].m_unk0x2c) { if (FindVehicle(m_anims[j].m_models[m].m_name, n) && m_anims[j].m_models[m].m_unk0x2c) {
m_anims[j].m_unk0x2a[count++] = n; m_anims[j].m_unk0x2a[count++] = n;
if (count > 3) { if (count > 3) {
break; break;
@ -560,12 +560,12 @@ MxResult LegoAnimationManager::ReadAnimInfo(LegoFile* p_file, AnimInfo* p_info)
goto done; goto done;
} }
p_info->m_animName = new char[length + 1]; p_info->m_name = new char[length + 1];
if (p_file->Read(p_info->m_animName, length) == FAILURE) { if (p_file->Read(p_info->m_name, length) == FAILURE) {
goto done; goto done;
} }
p_info->m_animName[length] = 0; p_info->m_name[length] = 0;
if (p_file->Read(&p_info->m_objectId, sizeof(p_info->m_objectId)) == FAILURE) { if (p_file->Read(&p_info->m_objectId, sizeof(p_info->m_objectId)) == FAILURE) {
goto done; goto done;
} }
@ -621,12 +621,12 @@ MxResult LegoAnimationManager::ReadModelInfo(LegoFile* p_file, ModelInfo* p_info
goto done; goto done;
} }
p_info->m_modelName = new char[length + 1]; p_info->m_name = new char[length + 1];
if (p_file->Read(p_info->m_modelName, length) == FAILURE) { if (p_file->Read(p_info->m_name, length) == FAILURE) {
goto done; goto done;
} }
p_info->m_modelName[length] = 0; p_info->m_name[length] = 0;
if (p_file->Read(&p_info->m_unk0x04, sizeof(p_info->m_unk0x04)) == FAILURE) { if (p_file->Read(&p_info->m_unk0x04, sizeof(p_info->m_unk0x04)) == FAILURE) {
goto done; goto done;
} }
@ -657,11 +657,11 @@ void LegoAnimationManager::DeleteAnimations()
if (m_anims != NULL) { if (m_anims != NULL) {
for (MxS32 i = 0; i < m_animCount; i++) { for (MxS32 i = 0; i < m_animCount; i++) {
delete m_anims[i].m_animName; delete m_anims[i].m_name;
if (m_anims[i].m_models != NULL) { if (m_anims[i].m_models != NULL) {
for (MxS32 j = 0; j < m_anims[i].m_modelCount; j++) { for (MxS32 j = 0; j < m_anims[i].m_modelCount; j++) {
delete m_anims[i].m_models[j].m_modelName; delete m_anims[i].m_models[j].m_name;
} }
delete m_anims[i].m_models; delete m_anims[i].m_models;
@ -1401,7 +1401,7 @@ MxBool LegoAnimationManager::FUN_100623a0(AnimInfo& p_info)
LegoROI* roi = entity->GetROI(); LegoROI* roi = entity->GetROI();
if (roi->GetVisibility() && FUN_10062650(vec, und, roi)) { if (roi->GetVisibility() && FUN_10062650(vec, und, roi)) {
if (!FUN_10062520(p_info, roi->GetName())) { if (!ModelExists(p_info, roi->GetName())) {
return TRUE; return TRUE;
} }
} }
@ -1413,11 +1413,22 @@ MxBool LegoAnimationManager::FUN_100623a0(AnimInfo& p_info)
return FALSE; return FALSE;
} }
// STUB: LEGO1 0x10062520 // FUNCTION: LEGO1 0x10062520
// FUNCTION: BETA10 0x100434bf // FUNCTION: BETA10 0x100434bf
MxBool LegoAnimationManager::FUN_10062520(AnimInfo& p_info, const char*) MxBool LegoAnimationManager::ModelExists(AnimInfo& p_info, const char* p_name)
{ {
return TRUE; ModelInfo* models = p_info.m_models;
MxU8 modelCount = p_info.m_modelCount;
if (models != NULL && modelCount) {
for (MxU8 i = 0; i < modelCount; i++) {
if (!strcmpi(models[i].m_name, p_name)) {
return TRUE;
}
}
}
return FALSE;
} }
// STUB: LEGO1 0x10062580 // STUB: LEGO1 0x10062580