mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 16:34:06 +00:00
Some tweaks to LegoCharacterManager (#1305)
This commit is contained in:
@@ -67,7 +67,7 @@ public:
|
|||||||
void ReleaseActor(const char* p_name);
|
void ReleaseActor(const char* p_name);
|
||||||
void ReleaseActor(LegoROI* p_roi);
|
void ReleaseActor(LegoROI* p_roi);
|
||||||
void ReleaseAutoROI(LegoROI* p_roi);
|
void ReleaseAutoROI(LegoROI* p_roi);
|
||||||
MxBool FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_textureInfo);
|
MxBool FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_texture);
|
||||||
LegoExtraActor* GetExtraActor(const char* p_name);
|
LegoExtraActor* GetExtraActor(const char* p_name);
|
||||||
LegoActorInfo* GetActorInfo(const char* p_name);
|
LegoActorInfo* GetActorInfo(const char* p_name);
|
||||||
LegoActorInfo* GetActorInfo(LegoROI* p_roi);
|
LegoActorInfo* GetActorInfo(LegoROI* p_roi);
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#include "roi/legolod.h"
|
#include "roi/legolod.h"
|
||||||
#include "viewmanager/viewmanager.h"
|
#include "viewmanager/viewmanager.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <vec.h>
|
#include <vec.h>
|
||||||
|
|
||||||
DECOMP_SIZE_ASSERT(LegoCharacter, 0x08)
|
DECOMP_SIZE_ASSERT(LegoCharacter, 0x08)
|
||||||
@@ -52,10 +53,11 @@ MxU32 g_unk0x100fc4f0 = 0;
|
|||||||
LegoActorInfo g_actorInfo[66];
|
LegoActorInfo g_actorInfo[66];
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10082a20
|
// FUNCTION: LEGO1 0x10082a20
|
||||||
|
// FUNCTION: BETA10 0x10073c60
|
||||||
LegoCharacterManager::LegoCharacterManager()
|
LegoCharacterManager::LegoCharacterManager()
|
||||||
{
|
{
|
||||||
m_characters = new LegoCharacterMap();
|
m_characters = new LegoCharacterMap();
|
||||||
Init();
|
Init(); // DECOMP: inlined here in BETA10
|
||||||
|
|
||||||
m_customizeAnimFile = new CustomizeAnimFileVariable("CUSTOMIZE_ANIM_FILE");
|
m_customizeAnimFile = new CustomizeAnimFileVariable("CUSTOMIZE_ANIM_FILE");
|
||||||
VariableTable()->SetVariable(m_customizeAnimFile);
|
VariableTable()->SetVariable(m_customizeAnimFile);
|
||||||
@@ -228,9 +230,10 @@ const char* LegoCharacterManager::GetActorName(MxS32 p_index)
|
|||||||
if (p_index < sizeOfArray(g_actorInfo)) {
|
if (p_index < sizeOfArray(g_actorInfo)) {
|
||||||
return g_actorInfo[p_index].m_name;
|
return g_actorInfo[p_index].m_name;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100834f0
|
// FUNCTION: LEGO1 0x100834f0
|
||||||
// FUNCTION: BETA10 0x1007432a
|
// FUNCTION: BETA10 0x1007432a
|
||||||
@@ -244,9 +247,9 @@ MxU32 LegoCharacterManager::GetNumActors()
|
|||||||
LegoROI* LegoCharacterManager::GetActorROI(const char* p_name, MxBool p_createEntity)
|
LegoROI* LegoCharacterManager::GetActorROI(const char* p_name, MxBool p_createEntity)
|
||||||
{
|
{
|
||||||
LegoCharacter* character = NULL;
|
LegoCharacter* character = NULL;
|
||||||
LegoCharacterMap::iterator it = m_characters->find(const_cast<char*>(p_name));
|
LegoCharacterMap::const_iterator it = m_characters->find(const_cast<char*>(p_name));
|
||||||
|
|
||||||
if (it != m_characters->end()) {
|
if (!(it == m_characters->end())) {
|
||||||
character = (*it).second;
|
character = (*it).second;
|
||||||
character->AddRef();
|
character->AddRef();
|
||||||
}
|
}
|
||||||
@@ -254,13 +257,9 @@ LegoROI* LegoCharacterManager::GetActorROI(const char* p_name, MxBool p_createEn
|
|||||||
if (character == NULL) {
|
if (character == NULL) {
|
||||||
LegoROI* roi = CreateActorROI(p_name);
|
LegoROI* roi = CreateActorROI(p_name);
|
||||||
|
|
||||||
if (roi == NULL) {
|
if (roi != NULL) {
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
roi->SetVisibility(FALSE);
|
roi->SetVisibility(FALSE);
|
||||||
|
|
||||||
if (roi != NULL) {
|
|
||||||
character = new LegoCharacter(roi);
|
character = new LegoCharacter(roi);
|
||||||
char* name = new char[strlen(p_name) + 1];
|
char* name = new char[strlen(p_name) + 1];
|
||||||
|
|
||||||
@@ -276,7 +275,6 @@ LegoROI* LegoCharacterManager::GetActorROI(const char* p_name, MxBool p_createEn
|
|||||||
VideoManager()->Get3DManager()->Add(*character->m_roi);
|
VideoManager()->Get3DManager()->Add(*character->m_roi);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
|
||||||
if (character != NULL) {
|
if (character != NULL) {
|
||||||
if (p_createEntity && character->m_roi->GetEntity() == NULL) {
|
if (p_createEntity && character->m_roi->GetEntity() == NULL) {
|
||||||
LegoExtraActor* actor = new LegoExtraActor();
|
LegoExtraActor* actor = new LegoExtraActor();
|
||||||
@@ -289,15 +287,15 @@ done:
|
|||||||
|
|
||||||
return character->m_roi;
|
return character->m_roi;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10083b20
|
// FUNCTION: LEGO1 0x10083b20
|
||||||
// FUNCTION: BETA10 0x10074608
|
// FUNCTION: BETA10 0x10074608
|
||||||
MxBool LegoCharacterManager::Exists(const char* p_name)
|
MxBool LegoCharacterManager::Exists(const char* p_name)
|
||||||
{
|
{
|
||||||
LegoCharacter* character = NULL;
|
|
||||||
LegoCharacterMap::iterator it = m_characters->find(const_cast<char*>(p_name));
|
LegoCharacterMap::iterator it = m_characters->find(const_cast<char*>(p_name));
|
||||||
|
|
||||||
if (it != m_characters->end()) {
|
if (it != m_characters->end()) {
|
||||||
@@ -454,6 +452,7 @@ void LegoCharacterManager::RemoveROI(LegoROI* p_roi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10084030
|
// FUNCTION: LEGO1 0x10084030
|
||||||
|
// FUNCTION: BETA10 0x10074e4f
|
||||||
LegoROI* LegoCharacterManager::CreateActorROI(const char* p_key)
|
LegoROI* LegoCharacterManager::CreateActorROI(const char* p_key)
|
||||||
{
|
{
|
||||||
MxBool success = FALSE;
|
MxBool success = FALSE;
|
||||||
@@ -601,7 +600,7 @@ done:
|
|||||||
|
|
||||||
// FUNCTION: LEGO1 0x100849a0
|
// FUNCTION: LEGO1 0x100849a0
|
||||||
// FUNCTION: BETA10 0x10075b51
|
// FUNCTION: BETA10 0x10075b51
|
||||||
MxBool LegoCharacterManager::FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_textureInfo)
|
MxBool LegoCharacterManager::FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_texture)
|
||||||
{
|
{
|
||||||
LegoResult result = SUCCESS;
|
LegoResult result = SUCCESS;
|
||||||
LegoROI* head = FindChildROI(p_roi, g_actorLODs[c_headLOD].m_name);
|
LegoROI* head = FindChildROI(p_roi, g_actorLODs[c_headLOD].m_name);
|
||||||
@@ -610,24 +609,30 @@ MxBool LegoCharacterManager::FUN_100849a0(LegoROI* p_roi, LegoTextureInfo* p_tex
|
|||||||
char lodName[256];
|
char lodName[256];
|
||||||
|
|
||||||
ViewLODList* lodList = GetViewLODListManager()->Lookup(g_actorLODs[c_headLOD].m_parentName);
|
ViewLODList* lodList = GetViewLODListManager()->Lookup(g_actorLODs[c_headLOD].m_parentName);
|
||||||
|
assert(lodList);
|
||||||
|
|
||||||
MxS32 lodSize = lodList->Size();
|
MxS32 lodSize = lodList->Size();
|
||||||
sprintf(lodName, "%s%s%d", p_roi->GetName(), "head", g_unk0x100fc4e8++);
|
sprintf(lodName, "%s%s%d", p_roi->GetName(), "head", g_unk0x100fc4e8++);
|
||||||
ViewLODList* dupLodList = GetViewLODListManager()->Create(lodName, lodSize);
|
ViewLODList* dupLodList = GetViewLODListManager()->Create(lodName, lodSize);
|
||||||
|
assert(dupLodList);
|
||||||
|
|
||||||
Tgl::Renderer* renderer = VideoManager()->GetRenderer();
|
Tgl::Renderer* renderer = VideoManager()->GetRenderer();
|
||||||
|
|
||||||
if (p_textureInfo == NULL) {
|
if (p_texture == NULL) {
|
||||||
LegoActorInfo* info = GetActorInfo(p_roi->GetName());
|
LegoActorInfo* info = GetActorInfo(p_roi->GetName());
|
||||||
|
assert(info);
|
||||||
|
|
||||||
LegoActorInfo::Part& part = info->m_parts[c_headPart];
|
LegoActorInfo::Part& part = info->m_parts[c_headPart];
|
||||||
p_textureInfo = TextureContainer()->Get(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]]);
|
p_texture = TextureContainer()->Get(part.m_unk0x10[part.m_unk0x0c[part.m_unk0x14]]);
|
||||||
|
assert(p_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MxS32 i = 0; i < lodSize; i++) {
|
for (MxS32 i = 0; i < lodSize; i++) {
|
||||||
LegoLOD* lod = (LegoLOD*) (*lodList)[i];
|
LegoLOD* lod = (LegoLOD*) (*lodList)[i];
|
||||||
LegoLOD* clone = lod->Clone(renderer);
|
LegoLOD* clone = lod->Clone(renderer);
|
||||||
|
|
||||||
if (p_textureInfo != NULL) {
|
if (p_texture != NULL) {
|
||||||
clone->FUN_100aad70(p_textureInfo);
|
clone->FUN_100aad70(p_texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
dupLodList->PushBack(clone);
|
dupLodList->PushBack(clone);
|
||||||
@@ -672,6 +677,7 @@ LegoExtraActor* LegoCharacterManager::GetExtraActor(const char* p_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10084c60
|
// FUNCTION: LEGO1 0x10084c60
|
||||||
|
// FUNCTION: BETA10 0x10075ede
|
||||||
LegoActorInfo* LegoCharacterManager::GetActorInfo(const char* p_name)
|
LegoActorInfo* LegoCharacterManager::GetActorInfo(const char* p_name)
|
||||||
{
|
{
|
||||||
MxU32 i;
|
MxU32 i;
|
||||||
@@ -685,11 +691,13 @@ LegoActorInfo* LegoCharacterManager::GetActorInfo(const char* p_name)
|
|||||||
if (i < sizeOfArray(g_actorInfo)) {
|
if (i < sizeOfArray(g_actorInfo)) {
|
||||||
return &g_actorInfo[i];
|
return &g_actorInfo[i];
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10084cb0
|
// FUNCTION: LEGO1 0x10084cb0
|
||||||
|
// FUNCTION: BETA10 0x10075f66
|
||||||
LegoActorInfo* LegoCharacterManager::GetActorInfo(LegoROI* p_roi)
|
LegoActorInfo* LegoCharacterManager::GetActorInfo(LegoROI* p_roi)
|
||||||
{
|
{
|
||||||
MxU32 i;
|
MxU32 i;
|
||||||
@@ -703,21 +711,24 @@ LegoActorInfo* LegoCharacterManager::GetActorInfo(LegoROI* p_roi)
|
|||||||
if (i < sizeOfArray(g_actorInfo)) {
|
if (i < sizeOfArray(g_actorInfo)) {
|
||||||
return &g_actorInfo[i];
|
return &g_actorInfo[i];
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10084cf0
|
// FUNCTION: LEGO1 0x10084cf0
|
||||||
// FUNCTION: BETA10 0x10075fe2
|
// FUNCTION: BETA10 0x10075fe2
|
||||||
LegoROI* LegoCharacterManager::FindChildROI(LegoROI* p_roi, const char* p_name)
|
LegoROI* LegoCharacterManager::FindChildROI(LegoROI* p_roi, const char* p_name)
|
||||||
{
|
{
|
||||||
|
#ifdef COMPAT_MODE
|
||||||
|
CompoundObject::const_iterator it;
|
||||||
|
#else
|
||||||
|
CompoundObject::iterator it;
|
||||||
|
#endif
|
||||||
|
|
||||||
const CompoundObject* comp = p_roi->GetComp();
|
const CompoundObject* comp = p_roi->GetComp();
|
||||||
|
|
||||||
#ifdef COMPAT_MODE
|
for (it = comp->begin(); it != comp->end(); it++) {
|
||||||
for (CompoundObject::const_iterator it = comp->begin(); !(it == comp->end()); it++) {
|
|
||||||
#else
|
|
||||||
for (CompoundObject::iterator it = comp->begin(); !(it == comp->end()); it++) {
|
|
||||||
#endif
|
|
||||||
LegoROI* roi = (LegoROI*) *it;
|
LegoROI* roi = (LegoROI*) *it;
|
||||||
|
|
||||||
if (!strcmpi(p_name, roi->GetName())) {
|
if (!strcmpi(p_name, roi->GetName())) {
|
||||||
@@ -911,11 +922,13 @@ MxU32 LegoCharacterManager::GetAnimationId(LegoROI* p_roi)
|
|||||||
if (info != NULL) {
|
if (info != NULL) {
|
||||||
return info->m_move + g_characterAnimationId;
|
return info->m_move + g_characterAnimationId;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10085140
|
// FUNCTION: LEGO1 0x10085140
|
||||||
|
// FUNCTION: BETA10 0x10076855
|
||||||
MxU32 LegoCharacterManager::GetSoundId(LegoROI* p_roi, MxBool p_und)
|
MxU32 LegoCharacterManager::GetSoundId(LegoROI* p_roi, MxBool p_und)
|
||||||
{
|
{
|
||||||
LegoActorInfo* info = GetActorInfo(p_roi);
|
LegoActorInfo* info = GetActorInfo(p_roi);
|
||||||
@@ -927,9 +940,10 @@ MxU32 LegoCharacterManager::GetSoundId(LegoROI* p_roi, MxBool p_und)
|
|||||||
if (info != NULL) {
|
if (info != NULL) {
|
||||||
return info->m_sound + g_unk0x100fc4d8;
|
return info->m_sound + g_unk0x100fc4d8;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x10085180
|
// FUNCTION: LEGO1 0x10085180
|
||||||
// FUNCTION: BETA10 0x100768c5
|
// FUNCTION: BETA10 0x100768c5
|
||||||
@@ -940,9 +954,10 @@ MxU8 LegoCharacterManager::GetMood(LegoROI* p_roi)
|
|||||||
if (info != NULL) {
|
if (info != NULL) {
|
||||||
return info->m_mood;
|
return info->m_mood;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FUNCTION: LEGO1 0x100851a0
|
// FUNCTION: LEGO1 0x100851a0
|
||||||
void LegoCharacterManager::SetCustomizeAnimFile(const char* p_value)
|
void LegoCharacterManager::SetCustomizeAnimFile(const char* p_value)
|
||||||
|
Reference in New Issue
Block a user