Implement/match LegoCharacterManager::FUN_10085210 (#763)

* Implement/match LegoCharacterManager::FUN_10085210

* Update params

* Update param names

* param to bool

* Update var names based on beta
This commit is contained in:
Christian Semmler 2024-03-31 10:05:38 -04:00 committed by GitHub
parent a956b19ac6
commit 60388c8c5d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 94 additions and 26 deletions

View file

@ -58,13 +58,14 @@ class LegoCharacterManager {
LegoCharacterData* GetData(LegoROI* p_roi); LegoCharacterData* GetData(LegoROI* p_roi);
MxBool FUN_10084ec0(LegoROI* p_roi); MxBool FUN_10084ec0(LegoROI* p_roi);
MxU32 FUN_10085140(LegoROI* p_roi, MxBool p_und); MxU32 FUN_10085140(LegoROI* p_roi, MxBool p_und);
LegoROI* FUN_10085210(const char*, char*, undefined); LegoROI* FUN_10085210(const char* p_name, const char* p_lodName, MxBool p_createEntity);
LegoROI* FUN_10085a80(char* p_und1, char* p_und2, undefined p_und3); LegoROI* FUN_10085a80(const char* p_name, const char* p_lodName, MxBool p_createEntity);
static const char* GetCustomizeAnimFile() { return g_customizeAnimFile; } static const char* GetCustomizeAnimFile() { return g_customizeAnimFile; }
private: private:
LegoROI* CreateROI(const char* p_key); LegoROI* CreateROI(const char* p_key);
MxResult FUN_10085870(LegoROI* p_roi);
static char* g_customizeAnimFile; static char* g_customizeAnimFile;
@ -100,6 +101,9 @@ class LegoCharacterManager {
// TEMPLATE: LEGO1 0x10083890 // TEMPLATE: LEGO1 0x10083890
// _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Insert // _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Insert
// TEMPLATE: LEGO1 0x10085500
// _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::insert
// GLOBAL: LEGO1 0x100fc508 // GLOBAL: LEGO1 0x100fc508
// _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Nil // _Tree<char const *,pair<char const * const,LegoCharacter *>,map<char const *,LegoCharacter *,LegoCharacterComparator,allocator<LegoCharacter *> >::_Kfn,LegoCharacterComparator,allocator<LegoCharacter *> >::_Nil
// clang-format on // clang-format on

View file

@ -23,6 +23,9 @@ MxU32 g_unk0x100fc4d8 = 50;
// GLOBAL: LEGO1 0x100fc4dc // GLOBAL: LEGO1 0x100fc4dc
MxU32 g_unk0x100fc4dc = 66; MxU32 g_unk0x100fc4dc = 66;
// GLOBAL: LEGO1 0x100fc4f0
MxU32 g_unk0x100fc4f0 = 0;
// GLOBAL: LEGO1 0x10104f20 // GLOBAL: LEGO1 0x10104f20
LegoCharacterData g_characterData[66]; LegoCharacterData g_characterData[66];
@ -491,14 +494,75 @@ void LegoCharacterManager::SetCustomizeAnimFile(const char* p_value)
} }
} }
// STUB: LEGO1 0x10085210 // FUNCTION: LEGO1 0x10085210
LegoROI* LegoCharacterManager::FUN_10085210(const char*, char*, undefined) LegoROI* LegoCharacterManager::FUN_10085210(const char* p_name, const char* p_lodName, MxBool p_createEntity)
{ {
LegoROI* roi = NULL;
MxMatrix mat;
Tgl::Renderer* renderer = VideoManager()->GetRenderer();
ViewLODListManager* lodManager = GetViewLODListManager();
LegoTextureContainer* textureContainer = TextureContainer();
ViewLODList* lodList = lodManager->Lookup(p_lodName);
if (lodList == NULL || lodList->Size() == 0) {
return NULL; return NULL;
}
roi = new LegoROI(renderer, lodList);
const char* name;
char buf[20];
if (p_name != NULL) {
name = p_name;
}
else {
sprintf(buf, "autoROI_%d", g_unk0x100fc4f0++);
name = buf;
}
roi->SetName(name);
lodList->Release();
if (roi != NULL && FUN_10085870(roi) != SUCCESS) {
delete roi;
roi = NULL;
}
if (roi != NULL) {
roi->SetVisibility(FALSE);
LegoCharacter* character = new LegoCharacter(roi);
char* key = new char[strlen(name) + 1];
if (key != NULL) {
strcpy(key, name);
(*m_characters)[key] = character;
VideoManager()->Get3DManager()->Add(*roi);
if (p_createEntity && roi->GetEntity() == NULL) {
LegoEntity* entity = new LegoEntity();
entity->SetROI(roi, FALSE, FALSE);
entity->FUN_100114e0(4);
entity->SetFlag(LegoActor::c_bit2);
}
}
}
return roi;
}
// STUB: LEGO1 0x10085870
MxResult LegoCharacterManager::FUN_10085870(LegoROI* p_roi)
{
// TODO
return SUCCESS;
} }
// FUNCTION: LEGO1 0x10085a80 // FUNCTION: LEGO1 0x10085a80
LegoROI* LegoCharacterManager::FUN_10085a80(char* p_und1, char* p_und2, undefined p_und3) LegoROI* LegoCharacterManager::FUN_10085a80(const char* p_name, const char* p_lodName, MxBool p_createEntity)
{ {
return FUN_10085210(p_und1, p_und2, p_und3); return FUN_10085210(p_name, p_lodName, p_createEntity);
} }

View file

@ -166,25 +166,25 @@ void LegoAnimPresenter::FUN_100692b0()
} }
} }
else if (unk0x04 == 4) { else if (unk0x04 == 4) {
LegoChar* src = new LegoChar[strlen(str)]; LegoChar* baseName = new LegoChar[strlen(str)];
strcpy(src, str + 1); strcpy(baseName, str + 1);
strlwr(src); strlwr(baseName);
LegoChar* und = FUN_10069150(str); LegoChar* und = FUN_10069150(str);
roi = CharacterManager()->FUN_10085a80(und, src, 1); roi = CharacterManager()->FUN_10085a80(und, baseName, TRUE);
if (roi != NULL) { if (roi != NULL) {
roi->SetVisibility(FALSE); roi->SetVisibility(FALSE);
} }
delete[] src; delete[] baseName;
delete[] und; delete[] und;
} }
else if (unk0x04 == 3) { else if (unk0x04 == 3) {
LegoChar* src = new LegoChar[strlen(str)]; LegoChar* lodName = new LegoChar[strlen(str)];
strcpy(src, str + 1); strcpy(lodName, str + 1);
for (LegoChar* i = &src[strlen(src) - 1]; i > src; i--) { for (LegoChar* i = &lodName[strlen(lodName) - 1]; i > lodName; i--) {
if ((*i < '0' || *i > '9') && *i != '_') { if ((*i < '0' || *i > '9') && *i != '_') {
break; break;
} }
@ -192,16 +192,16 @@ void LegoAnimPresenter::FUN_100692b0()
*i = '\0'; *i = '\0';
} }
strlwr(src); strlwr(lodName);
LegoChar* und = FUN_10069150(str); LegoChar* und = FUN_10069150(str);
roi = CharacterManager()->FUN_10085210(und, src, 1); roi = CharacterManager()->FUN_10085210(und, lodName, TRUE);
if (roi != NULL) { if (roi != NULL) {
roi->SetVisibility(FALSE); roi->SetVisibility(FALSE);
} }
delete[] src; delete[] lodName;
delete[] und; delete[] und;
} }
@ -228,20 +228,20 @@ void LegoAnimPresenter::FUN_100695c0()
undefined4 unk0x04 = m_anim->GetActorUnknown0x04(i); undefined4 unk0x04 = m_anim->GetActorUnknown0x04(i);
if (unk0x04 == 5 || unk0x04 == 6) { if (unk0x04 == 5 || unk0x04 == 6) {
LegoChar dest[256]; LegoChar lodName[256];
const LegoChar* str = m_anim->GetActorName(i); const LegoChar* actorName = m_anim->GetActorName(i);
LegoU32 len = strlen(str); LegoU32 len = strlen(actorName);
strcpy(dest, str); strcpy(lodName, actorName);
for (LegoChar* i = &dest[len - 1]; isdigit(*i) || *i == '_'; i--) { for (LegoChar* i = &lodName[len - 1]; isdigit(*i) || *i == '_'; i--) {
*i = '\0'; *i = '\0';
} }
strlwr(dest); strlwr(lodName);
CharacterManager()->FUN_10085210(str, dest, 0); CharacterManager()->FUN_10085210(actorName, lodName, FALSE);
FUN_100698b0(rois, str); FUN_100698b0(rois, actorName);
} }
} }
} }