mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-08-03 15:47:34 -04:00
Let LegoStorage know of memory size (#129)
This commit is contained in:
parent
23182618cc
commit
0b778de731
@ -152,6 +152,7 @@ target_include_directories(lego1 PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/L
|
||||
target_include_directories(lego1 PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/LEGO1/lego/legoomni/include>")
|
||||
target_include_directories(lego1 PUBLIC "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/LEGO1/lego/legoomni/include/actions>")
|
||||
target_link_libraries(lego1 PRIVATE SDL3::SDL3)
|
||||
target_link_libraries(lego1 PUBLIC SDL3::Headers)
|
||||
target_link_libraries(lego1 PRIVATE $<$<BOOL:${ISLE_USE_DX5}>:DirectX5::DirectX5>)
|
||||
if(WIN32)
|
||||
set_property(TARGET lego1 PROPERTY PREFIX "")
|
||||
|
@ -85,8 +85,13 @@ public:
|
||||
// SYNTHETIC: LEGO1 0x10045740
|
||||
// LegoPathController::`scalar deleting destructor'
|
||||
|
||||
virtual MxResult Create(MxU8* p_data, const Vector3& p_location, const MxAtomId& p_trigger); // vtable+0x14
|
||||
virtual void Destroy(); // vtable+0x18
|
||||
virtual MxResult Create(
|
||||
MxU8* p_data,
|
||||
LegoU32 p_dataSize,
|
||||
const Vector3& p_location,
|
||||
const MxAtomId& p_trigger
|
||||
); // vtable+0x14
|
||||
virtual void Destroy(); // vtable+0x18
|
||||
|
||||
MxResult PlaceActor(
|
||||
LegoPathActor* p_actor,
|
||||
|
@ -665,6 +665,7 @@ MxResult LegoAnimationManager::LoadWorldInfo(LegoOmni::World p_worldId)
|
||||
goto done;
|
||||
}
|
||||
|
||||
assert(version == 3);
|
||||
if (version != 3) {
|
||||
OmniError("World animation version mismatch", 0);
|
||||
goto done;
|
||||
|
@ -369,6 +369,7 @@ MxResult LegoGameState::Load(MxULong p_slot)
|
||||
|
||||
storage.ReadS32(version);
|
||||
|
||||
assert(version == 0x1000c);
|
||||
if (version != 0x1000c) {
|
||||
OmniError("Saved game version mismatch", 0);
|
||||
goto done;
|
||||
|
@ -226,6 +226,7 @@ LegoEntity* LegoPlantManager::CreatePlant(MxS32 p_index, LegoWorld* p_world, Leg
|
||||
sprintf(lodName, "%s", g_plantLodNames[g_plantInfo[p_index].m_variant][g_plantInfo[p_index].m_color]);
|
||||
|
||||
LegoROI* roi = CharacterManager()->CreateAutoROI(name, lodName, TRUE);
|
||||
assert(roi != NULL);
|
||||
roi->SetVisibility(TRUE);
|
||||
|
||||
entity = roi->GetEntity();
|
||||
|
@ -83,10 +83,15 @@ LegoPathController::LegoPathController()
|
||||
|
||||
// FUNCTION: LEGO1 0x10045880
|
||||
// FUNCTION: BETA10 0x100b6959
|
||||
MxResult LegoPathController::Create(MxU8* p_data, const Vector3& p_location, const MxAtomId& p_trigger)
|
||||
MxResult LegoPathController::Create(
|
||||
MxU8* p_data,
|
||||
LegoU32 p_dataSize,
|
||||
const Vector3& p_location,
|
||||
const MxAtomId& p_trigger
|
||||
)
|
||||
{
|
||||
MxResult result = FAILURE;
|
||||
LegoMemory storage(p_data);
|
||||
LegoMemory storage(p_data, p_dataSize);
|
||||
|
||||
if ((result = Read(&storage)) == SUCCESS) {
|
||||
MxS32 i;
|
||||
|
@ -81,7 +81,7 @@ void LegoPathPresenter::ReadyTickle()
|
||||
else {
|
||||
ParseExtra();
|
||||
|
||||
controller->Create(chunk->GetData(), m_action->GetLocation(), m_trigger);
|
||||
controller->Create(chunk->GetData(), chunk->GetLength(), m_action->GetLocation(), m_trigger);
|
||||
world->AddPath(controller);
|
||||
|
||||
m_subscriber->FreeDataChunk(chunk);
|
||||
|
@ -140,7 +140,7 @@ void LegoAnimPresenter::Destroy(MxBool p_fromDestructor)
|
||||
MxResult LegoAnimPresenter::CreateAnim(MxStreamChunk* p_chunk)
|
||||
{
|
||||
MxResult result = FAILURE;
|
||||
LegoMemory storage(p_chunk->GetData());
|
||||
LegoMemory storage(p_chunk->GetData(), p_chunk->GetLength());
|
||||
MxS32 magicSig;
|
||||
LegoS32 parseScene = 0;
|
||||
MxS32 val3;
|
||||
|
@ -52,7 +52,7 @@ MxResult LegoModelPresenter::CreateROI(MxDSChunk* p_chunk)
|
||||
MxResult result = FAILURE;
|
||||
LegoU32 numROIs;
|
||||
Mx3DPointFloat vect;
|
||||
LegoMemory storage(p_chunk->GetData());
|
||||
LegoMemory storage(p_chunk->GetData(), p_chunk->GetLength());
|
||||
LegoAnim anim;
|
||||
LegoU32 version, textureInfoOffset, i, numTextures, skipTextures;
|
||||
MxMatrix mat;
|
||||
@ -70,6 +70,7 @@ MxResult LegoModelPresenter::CreateROI(MxDSChunk* p_chunk)
|
||||
if (storage.Read(&version, sizeof(LegoU32)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
assert(version == MODEL_VERSION);
|
||||
if (version != MODEL_VERSION) {
|
||||
goto done;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ MxResult LegoPalettePresenter::ParsePalette(MxStreamChunk* p_chunk)
|
||||
RGBQUAD palette[256];
|
||||
MxResult result = FAILURE;
|
||||
|
||||
LegoMemory stream((char*) p_chunk->GetData());
|
||||
LegoMemory stream((char*) p_chunk->GetData(), p_chunk->GetLength());
|
||||
if (stream.Read(buffer, 40 * sizeof(MxU8)) == SUCCESS) {
|
||||
if (stream.Read(palette, 256 * 4 * sizeof(MxU8)) == SUCCESS) {
|
||||
m_palette = new MxPalette(palette);
|
||||
|
@ -59,7 +59,7 @@ MxResult LegoPartPresenter::Read(MxDSChunk& p_chunk)
|
||||
{
|
||||
MxResult result = FAILURE;
|
||||
LegoU32 numROIs, numLODs;
|
||||
LegoMemory storage(p_chunk.GetData());
|
||||
LegoMemory storage(p_chunk.GetData(), p_chunk.GetLength());
|
||||
LegoU32 textureInfoOffset, i, j, numTextures;
|
||||
LegoU32 roiNameLength, roiInfoOffset, surplusLODs;
|
||||
LegoLODList* lods;
|
||||
|
@ -33,7 +33,7 @@ MxResult LegoTexturePresenter::AddToManager()
|
||||
MxResult LegoTexturePresenter::Read(MxDSChunk& p_chunk)
|
||||
{
|
||||
MxResult result = FAILURE;
|
||||
LegoMemory storage(p_chunk.GetData());
|
||||
LegoMemory storage(p_chunk.GetData(), p_chunk.GetLength());
|
||||
LegoChar* textureName = NULL;
|
||||
LegoS32 hardwareMode = VideoManager()->GetDirect3D()->AssignedDevice()->GetHardwareMode();
|
||||
|
||||
|
@ -10,15 +10,17 @@ DECOMP_SIZE_ASSERT(LegoMemory, 0x10);
|
||||
DECOMP_SIZE_ASSERT(LegoFile, 0x0c);
|
||||
|
||||
// FUNCTION: LEGO1 0x10099080
|
||||
LegoMemory::LegoMemory(void* p_buffer) : LegoStorage()
|
||||
LegoMemory::LegoMemory(void* p_buffer, LegoU32 p_size) : LegoStorage()
|
||||
{
|
||||
m_buffer = (LegoU8*) p_buffer;
|
||||
m_position = 0;
|
||||
m_size = p_size;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10099160
|
||||
LegoResult LegoMemory::Read(void* p_buffer, LegoU32 p_size)
|
||||
{
|
||||
assert(m_position + p_size <= m_size);
|
||||
memcpy(p_buffer, m_buffer + m_position, p_size);
|
||||
m_position += p_size;
|
||||
return SUCCESS;
|
||||
@ -27,6 +29,7 @@ LegoResult LegoMemory::Read(void* p_buffer, LegoU32 p_size)
|
||||
// FUNCTION: LEGO1 0x10099190
|
||||
LegoResult LegoMemory::Write(const void* p_buffer, LegoU32 p_size)
|
||||
{
|
||||
assert(m_position + p_size <= m_size);
|
||||
memcpy(m_buffer + m_position, p_buffer, p_size);
|
||||
m_position += p_size;
|
||||
return SUCCESS;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "mxstring.h"
|
||||
|
||||
#include <SDL3/SDL_iostream.h>
|
||||
#include <assert.h>
|
||||
|
||||
// VTABLE: LEGO1 0x100d7d80
|
||||
// SIZE 0x08
|
||||
@ -192,7 +193,7 @@ protected:
|
||||
// SIZE 0x10
|
||||
class LegoMemory : public LegoStorage {
|
||||
public:
|
||||
LegoMemory(void* p_buffer);
|
||||
LegoMemory(void* p_buffer, LegoU32 p_size);
|
||||
LegoResult Read(void* p_buffer, LegoU32 p_size) override; // vtable+0x04
|
||||
LegoResult Write(const void* p_buffer, LegoU32 p_size) override; // vtable+0x08
|
||||
|
||||
@ -206,6 +207,7 @@ public:
|
||||
// FUNCTION: LEGO1 0x100994b0
|
||||
LegoResult SetPosition(LegoU32 p_position) override // vtable+0x10
|
||||
{
|
||||
assert(p_position <= m_size);
|
||||
m_position = p_position;
|
||||
return SUCCESS;
|
||||
}
|
||||
@ -219,6 +221,7 @@ public:
|
||||
protected:
|
||||
LegoU8* m_buffer; // 0x04
|
||||
LegoU32 m_position; // 0x08
|
||||
LegoU32 m_size;
|
||||
};
|
||||
|
||||
// VTABLE: LEGO1 0x100db730
|
||||
|
@ -30,7 +30,6 @@ typedef MxLong MxResult;
|
||||
#endif
|
||||
|
||||
typedef MxU8 MxBool;
|
||||
static_assert(sizeof(MxBool) == 1, "Incorrect size");
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
@ -62,6 +61,7 @@ typedef union {
|
||||
// BYTE all; // ?
|
||||
} FlagBitfield;
|
||||
|
||||
static_assert(sizeof(MxBool) == 1, "sizeof(MxBool) == 1");
|
||||
static_assert(sizeof(MxU8) == 1, "sizeof(MxU8) == 1");
|
||||
static_assert(sizeof(MxS8) == 1, "sizeof(MxS8) == 1");
|
||||
static_assert(sizeof(MxU16) == 2, "sizeof(MxU16) == 2");
|
||||
|
@ -430,7 +430,7 @@ MxResult MxDSBuffer::CalcBytesRemaining(MxU8* p_data)
|
||||
}
|
||||
else {
|
||||
ptr = p_data + MxStreamChunk::GetHeaderSize() + 8;
|
||||
bytesRead = (*(MxU32*) (p_data + 4)) - MxStreamChunk::GetHeaderSize();
|
||||
bytesRead = UnalignedRead<MxU32>(p_data + 4) - MxStreamChunk::GetHeaderSize();
|
||||
}
|
||||
|
||||
if (bytesRead <= m_bytesRemaining) {
|
||||
|
@ -216,7 +216,7 @@ inline MxS32 MxVideoPresenter::PrepareRects(RECT& p_rectDest, RECT& p_rectSrc)
|
||||
p_rectSrc.right = 640;
|
||||
}
|
||||
|
||||
LONG height, width;
|
||||
int height, width;
|
||||
if ((height = (p_rectDest.bottom - p_rectDest.top) + 1) <= 1 ||
|
||||
(width = (p_rectDest.right - p_rectDest.left) + 1) <= 1) {
|
||||
return -1;
|
||||
|
@ -27,4 +27,8 @@ typedef unsigned char undefined;
|
||||
typedef unsigned short undefined2;
|
||||
typedef unsigned int undefined4;
|
||||
|
||||
static_assert(sizeof(undefined) == 1, "sizeof(undefined) == 1");
|
||||
static_assert(sizeof(undefined2) == 2, "sizeof(undefined2) == 2");
|
||||
static_assert(sizeof(undefined4) == 4, "sizeof(undefined4) == 4");
|
||||
|
||||
#endif // DECOMP_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user