mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-28 02:31:15 +00:00
WIP Read WDB
This commit is contained in:
parent
de5cd98b76
commit
8b7b826a5b
@ -387,6 +387,7 @@ add_library(lego1 SHARED
|
||||
LEGO1/lego/legoomni/src/video/legovideomanager.cpp
|
||||
LEGO1/lego/legoomni/src/video/mxtransitionmanager.cpp
|
||||
LEGO1/main.cpp
|
||||
LEGO1/modeldb/modeldb.cpp
|
||||
)
|
||||
register_lego1_target(lego1)
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
// SIZE 0x54 (from inlined construction at 0x10009fac)
|
||||
class LegoPartPresenter : public MxMediaPresenter {
|
||||
public:
|
||||
LegoPartPresenter() { Reset(); }
|
||||
~LegoPartPresenter() override { Destroy(TRUE); }
|
||||
|
||||
// FUNCTION: LEGO1 0x1000cf70
|
||||
@ -31,8 +32,15 @@ class LegoPartPresenter : public MxMediaPresenter {
|
||||
// SYNTHETIC: LEGO1 0x1000d060
|
||||
// LegoPartPresenter::`scalar deleting destructor'
|
||||
|
||||
inline void Reset() { m_partData = NULL; }
|
||||
|
||||
MxResult ParsePart(MxDSChunk& p_chunk);
|
||||
void FUN_1007df20();
|
||||
|
||||
private:
|
||||
void Destroy(MxBool p_fromDestructor);
|
||||
|
||||
MxDSChunk* m_partData; // 0x54
|
||||
};
|
||||
|
||||
#endif // LEGOPARTPRESENTER_H
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
// SIZE 0x54 (from inlined construction at 0x10009bb5)
|
||||
class LegoTexturePresenter : public MxMediaPresenter {
|
||||
public:
|
||||
LegoTexturePresenter() : m_textureData(NULL) {}
|
||||
~LegoTexturePresenter() override;
|
||||
|
||||
// FUNCTION: LEGO1 0x1000ce50
|
||||
@ -28,6 +29,12 @@ class LegoTexturePresenter : public MxMediaPresenter {
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1000cf40
|
||||
// LegoTexturePresenter::`scalar deleting destructor'
|
||||
|
||||
MxResult ParseTexture(MxDSChunk& p_chunk);
|
||||
void FUN_1004f290();
|
||||
|
||||
private:
|
||||
MxDSChunk* m_textureData; // 0x54
|
||||
};
|
||||
|
||||
#endif // LEGOTEXTUREPRESENTER_H
|
||||
|
||||
@ -33,7 +33,7 @@ class LegoWorldPresenter : public LegoEntityPresenter {
|
||||
MxResult StartAction(MxStreamController* p_controller, MxDSAction* p_action) override; // vtable+0x3c
|
||||
void VTable0x60(MxPresenter* p_presenter) override; // vtable+0x60
|
||||
|
||||
void LoadWorld(char* p_worldName, LegoWorld* p_world);
|
||||
MxResult LoadWorld(char* p_worldName, LegoWorld* p_world);
|
||||
|
||||
// SYNTHETIC: LEGO1 0x10066750
|
||||
// LegoWorldPresenter::`scalar deleting destructor'
|
||||
|
||||
@ -5,12 +5,16 @@
|
||||
#include "legobuildingmanager.h"
|
||||
#include "legoentity.h"
|
||||
#include "legoomni.h"
|
||||
#include "legopartpresenter.h"
|
||||
#include "legoplantmanager.h"
|
||||
#include "legotexturepresenter.h"
|
||||
#include "legovideomanager.h"
|
||||
#include "legoworld.h"
|
||||
#include "modeldb/modeldb.h"
|
||||
#include "mxactionnotificationparam.h"
|
||||
#include "mxautolocker.h"
|
||||
#include "mxdsactionlist.h"
|
||||
#include "mxdschunk.h"
|
||||
#include "mxdsmediaaction.h"
|
||||
#include "mxdsmultiaction.h"
|
||||
#include "mxnotificationmanager.h"
|
||||
@ -19,8 +23,13 @@
|
||||
#include "mxstl/stlcompat.h"
|
||||
#include "mxutil.h"
|
||||
|
||||
#include <io.h>
|
||||
|
||||
// GLOBAL: LEGO1 0x100f75d4
|
||||
undefined4 g_legoWorldPresenterQuality = 1;
|
||||
MxS32 g_legoWorldPresenterQuality = 1;
|
||||
|
||||
// GLOBAL: LEGO1 0x100f75d8
|
||||
long g_wdbOffset = 0;
|
||||
|
||||
// FUNCTION: LEGO1 0x100665b0
|
||||
void LegoWorldPresenter::configureLegoWorldPresenter(MxS32 p_legoWorldPresenterQuality)
|
||||
@ -152,9 +161,103 @@ void LegoWorldPresenter::StartingTickle()
|
||||
ProgressTickleState(e_streaming);
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10066b40
|
||||
void LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world)
|
||||
// FUNCTION: LEGO1 0x10066b40
|
||||
MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world)
|
||||
{
|
||||
char wdbPath[512];
|
||||
sprintf(wdbPath, "%s", MxOmni::GetHD());
|
||||
|
||||
if (wdbPath[strlen(wdbPath) - 1] != '\\') {
|
||||
strcat(wdbPath, "\\");
|
||||
}
|
||||
|
||||
strcat(wdbPath, "lego\\data\\world.wdb");
|
||||
|
||||
if (access(wdbPath, 4) != 0) {
|
||||
sprintf(wdbPath, "%s", MxOmni::GetCD());
|
||||
|
||||
if (wdbPath[strlen(wdbPath) - 1] != '\\') {
|
||||
strcat(wdbPath, "\\");
|
||||
}
|
||||
|
||||
strcat(wdbPath, "lego\\data\\world.wdb");
|
||||
|
||||
if (access(wdbPath, 4) != 0) {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
ModelDbWorld* worlds;
|
||||
MxS32 numWorlds;
|
||||
FILE* wdbFile = fopen(wdbPath, "rb");
|
||||
|
||||
if (wdbFile == NULL) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
ReadModelDbWorlds(wdbFile, worlds, numWorlds);
|
||||
|
||||
MxS32 i;
|
||||
for (i = 0; i < numWorlds; i++) {
|
||||
if (!strcmpi(worlds[i].m_worldName, p_worldName)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == numWorlds) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (g_wdbOffset == 0) {
|
||||
MxU32 size;
|
||||
if (fread(&size, sizeof(size), 1, wdbFile) != 1) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
MxU8* buff = new MxU8[size];
|
||||
if (fread(&buff, size, 1, wdbFile) != 1) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
MxDSChunk chunk;
|
||||
chunk.SetLength(size);
|
||||
chunk.SetData(buff);
|
||||
|
||||
LegoTexturePresenter texturePresenter;
|
||||
if (texturePresenter.ParseTexture(chunk) == SUCCESS) {
|
||||
texturePresenter.FUN_1004f290();
|
||||
}
|
||||
|
||||
delete[] buff;
|
||||
// buff = NULL;
|
||||
|
||||
if (fread(&size, sizeof(size), 1, wdbFile) != 1) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
if (fread(&buff, size, 1, wdbFile) != 1) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
chunk.SetLength(size);
|
||||
chunk.SetData(buff);
|
||||
|
||||
LegoPartPresenter partPresenter;
|
||||
if (partPresenter.ParsePart(chunk) == SUCCESS) {
|
||||
partPresenter.FUN_1007df20();
|
||||
}
|
||||
|
||||
delete[] buff;
|
||||
|
||||
g_wdbOffset = ftell(wdbFile);
|
||||
}
|
||||
else {
|
||||
if (fseek(wdbFile, g_wdbOffset, SEEK_SET) != 0) {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10067a70
|
||||
|
||||
@ -4,10 +4,10 @@
|
||||
#include "legovideomanager.h"
|
||||
|
||||
// GLOBAL: LEGO1 0x100f7aa0
|
||||
int g_partPresenterConfig1 = 1;
|
||||
MxS32 g_partPresenterConfig1 = 1;
|
||||
|
||||
// GLOBAL: LEGO1 0x100f7aa4
|
||||
int g_partPresenterConfig2 = 100;
|
||||
MxS32 g_partPresenterConfig2 = 100;
|
||||
|
||||
// FUNCTION: LEGO1 0x1000cf60
|
||||
void LegoPartPresenter::Destroy()
|
||||
@ -35,8 +35,21 @@ void LegoPartPresenter::Destroy(MxBool p_fromDestructor)
|
||||
// TODO
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1007ca30
|
||||
MxResult LegoPartPresenter::ParsePart(MxDSChunk& p_chunk)
|
||||
{
|
||||
// TODO
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1007deb0
|
||||
void LegoPartPresenter::ReadyTickle()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1007df20
|
||||
void LegoPartPresenter::FUN_1007df20()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
#include "legovideomanager.h"
|
||||
#include "mxcompositepresenter.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoTexturePresenter, 0x54)
|
||||
|
||||
// FUNCTION: LEGO1 0x1004eb40
|
||||
LegoTexturePresenter::~LegoTexturePresenter()
|
||||
{
|
||||
@ -17,6 +19,19 @@ MxResult LegoTexturePresenter::AddToManager()
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1004ebd0
|
||||
MxResult LegoTexturePresenter::ParseTexture(MxDSChunk& p_chunk)
|
||||
{
|
||||
// TODO
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1004f290
|
||||
void LegoTexturePresenter::FUN_1004f290()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1004fc60
|
||||
MxResult LegoTexturePresenter::PutData()
|
||||
{
|
||||
|
||||
77
LEGO1/modeldb/modeldb.cpp
Normal file
77
LEGO1/modeldb/modeldb.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
#include "modeldb.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(ModelDbWorld, 0x18)
|
||||
DECOMP_SIZE_ASSERT(ModelDbPart, 0x18)
|
||||
DECOMP_SIZE_ASSERT(ModelDbModel, 0x38)
|
||||
|
||||
// STUB: LEGO1 0x100276b0
|
||||
MxResult ModelDbModel::Read(FILE* p_file)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10027850
|
||||
MxResult ModelDbPart::Read(FILE* p_file)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10027910
|
||||
MxResult ReadModelDbWorlds(FILE* p_file, ModelDbWorld*& p_worlds, MxS32& p_numWorlds)
|
||||
{
|
||||
p_worlds = NULL;
|
||||
p_numWorlds = 0;
|
||||
|
||||
MxS32 numWorlds;
|
||||
if (fread(&numWorlds, sizeof(numWorlds), 1, p_file) != 1) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
ModelDbWorld* worlds = new ModelDbWorld[numWorlds];
|
||||
|
||||
for (MxS32 i = 0; i < numWorlds; i++) {
|
||||
MxU32 worldNameLen;
|
||||
if (fread(&worldNameLen, sizeof(worldNameLen), 1, p_file) != 1) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
worlds[i].m_worldName = new char[worldNameLen];
|
||||
if (fread(&worlds[i].m_worldName, worldNameLen, 1, p_file) != 1) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
MxS32 numParts;
|
||||
if (fread(&numParts, sizeof(numParts), 1, p_file) != 1) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
worlds[i].m_partList = new ModelDbPartList();
|
||||
|
||||
MxS32 j;
|
||||
for (j = 0; j < numParts; j++) {
|
||||
ModelDbPart* part = new ModelDbPart();
|
||||
|
||||
if (part->Read(p_file) != SUCCESS) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
worlds[i].m_partList->Append(part);
|
||||
}
|
||||
|
||||
if (fread(&worlds[i].m_numModels, sizeof(worlds[i].m_numModels), 1, p_file) != 1) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
worlds[i].m_models = new ModelDbModel[worlds[i].m_numModels];
|
||||
|
||||
for (j = 0; j < worlds[i].m_numModels; j++) {
|
||||
if (worlds[i].m_models[j].Read(p_file) != SUCCESS) {
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p_worlds = worlds;
|
||||
p_numWorlds = numWorlds;
|
||||
return SUCCESS;
|
||||
}
|
||||
88
LEGO1/modeldb/modeldb.h
Normal file
88
LEGO1/modeldb/modeldb.h
Normal file
@ -0,0 +1,88 @@
|
||||
#ifndef MODELDB_H
|
||||
#define MODELDB_H
|
||||
|
||||
#include "decomp.h"
|
||||
#include "mxlist.h"
|
||||
#include "mxstring.h"
|
||||
#include "mxtypes.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// SIZE 0x18
|
||||
struct ModelDbPart {
|
||||
MxResult Read(FILE* p_file);
|
||||
|
||||
MxString m_name; // 0x00
|
||||
undefined4 m_unk0x10; // 0x10
|
||||
undefined4 m_unk0x14; // 0x14
|
||||
};
|
||||
|
||||
// VTABLE: LEGO1 0x100d6888
|
||||
// class MxCollection<ModelDbPart *>
|
||||
|
||||
// VTABLE: LEGO1 0x100d68a0
|
||||
// class MxList<ModelDbPart *>
|
||||
|
||||
// VTABLE: LEGO1 0x100d68b8
|
||||
// SIZE 0x1c
|
||||
class ModelDbPartList : public MxList<ModelDbPart*> {
|
||||
public:
|
||||
ModelDbPartList() { m_unk0x18 = 1; }
|
||||
|
||||
// FUNCTION: LEGO1 0x10027c40
|
||||
MxS8 Compare(ModelDbPart* p_a, ModelDbPart* p_b) override
|
||||
{
|
||||
MxS32 compare = !strcmpi(p_a->m_name.GetData(), p_b->m_name.GetData());
|
||||
|
||||
if (compare == 0) {
|
||||
p_b->m_unk0x10 = p_a->m_unk0x10;
|
||||
p_b->m_unk0x14 = p_a->m_unk0x14;
|
||||
}
|
||||
|
||||
return compare;
|
||||
} // vtable+0x14
|
||||
|
||||
// SYNTHETIC: LEGO1 0x10027d70
|
||||
// ModelDbPartList::`scalar deleting destructor'
|
||||
|
||||
private:
|
||||
undefined m_unk0x18;
|
||||
};
|
||||
|
||||
// TEMPLATE: LEGO1 0x10027c70
|
||||
// MxCollection<ModelDbPart *>::Compare
|
||||
|
||||
// TEMPLATE: LEGO1 0x10027c80
|
||||
// MxCollection<ModelDbPart *>::~MxCollection<ModelDbPart *>
|
||||
|
||||
// TEMPLATE: LEGO1 0x10027cd0
|
||||
// MxCollection<ModelDbPart *>::Destroy
|
||||
|
||||
// TEMPLATE: LEGO1 0x10027ce0
|
||||
// MxList<ModelDbPart *>::~MxList<ModelDbPart *>
|
||||
|
||||
// SYNTHETIC: LEGO1 0x10027de0
|
||||
// MxCollection<ModelDbPart *>::`scalar deleting destructor'
|
||||
|
||||
// SYNTHETIC: LEGO1 0x10027e50
|
||||
// MxList<ModelDbPart *>::`scalar deleting destructor'
|
||||
|
||||
// SIZE 0x38
|
||||
struct ModelDbModel {
|
||||
MxResult Read(FILE* p_file);
|
||||
|
||||
undefined m_unk0x00[0x38]; // 0x00
|
||||
};
|
||||
|
||||
// SIZE 0x18
|
||||
struct ModelDbWorld {
|
||||
char* m_worldName; // 0x00
|
||||
ModelDbPartList* m_partList; // 0x04
|
||||
MxS32 m_numModels; // 0x08
|
||||
ModelDbModel* m_models; // 0x0c
|
||||
undefined m_unk0x10[0x08]; // 0x10
|
||||
};
|
||||
|
||||
MxResult ReadModelDbWorlds(FILE* p_file, ModelDbWorld*& p_worlds, MxS32& p_numWorlds);
|
||||
|
||||
#endif // MODELDB_H
|
||||
Loading…
Reference in New Issue
Block a user