mirror of
https://github.com/aap/librw.git
synced 2024-11-24 12:45:43 +00:00
Added destructor code for native data.
This commit is contained in:
parent
dfdb90369e
commit
f173620763
2
main.cpp
2
main.cpp
@ -19,8 +19,8 @@ main(int argc, char *argv[])
|
|||||||
// Rw::Build = 0;
|
// Rw::Build = 0;
|
||||||
|
|
||||||
registerNodeNamePlugin();
|
registerNodeNamePlugin();
|
||||||
registerMeshPlugin();
|
|
||||||
registerNativeDataPlugin();
|
registerNativeDataPlugin();
|
||||||
|
registerMeshPlugin();
|
||||||
Rw::Clump *c;
|
Rw::Clump *c;
|
||||||
|
|
||||||
ifstream in(argv[1], ios::binary);
|
ifstream in(argv[1], ios::binary);
|
||||||
|
13
plugins.cpp
13
plugins.cpp
@ -183,6 +183,17 @@ registerMeshPlugin(void)
|
|||||||
|
|
||||||
// Native Data
|
// Native Data
|
||||||
|
|
||||||
|
static void*
|
||||||
|
destroyNativeData(void *object, int32 offset, int32 size)
|
||||||
|
{
|
||||||
|
Geometry *geometry = (Geometry*)object;
|
||||||
|
if(geometry->instData == NULL)
|
||||||
|
return object;
|
||||||
|
if(geometry->instData->platform == PLATFORM_PS2)
|
||||||
|
return DestroyNativeDataPS2(object, offset, size);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
readNativeData(istream &stream, int32 len, void *object, int32 o, int32 s)
|
readNativeData(istream &stream, int32 len, void *object, int32 o, int32 s)
|
||||||
{
|
{
|
||||||
@ -236,7 +247,7 @@ getSizeNativeData(void *object, int32 offset, int32 size)
|
|||||||
void
|
void
|
||||||
registerNativeDataPlugin(void)
|
registerNativeDataPlugin(void)
|
||||||
{
|
{
|
||||||
Rw::Geometry::registerPlugin(0, 0x510, NULL, NULL, NULL);
|
Rw::Geometry::registerPlugin(0, 0x510, NULL, destroyNativeData, NULL);
|
||||||
Rw::Geometry::registerPluginStream(0x510, (StreamRead)readNativeData,
|
Rw::Geometry::registerPluginStream(0x510, (StreamRead)readNativeData,
|
||||||
(StreamWrite)writeNativeData,
|
(StreamWrite)writeNativeData,
|
||||||
(StreamGetSize)getSizeNativeData);
|
(StreamGetSize)getSizeNativeData);
|
||||||
|
20
ps2.cpp
20
ps2.cpp
@ -15,8 +15,22 @@ using namespace std;
|
|||||||
|
|
||||||
namespace Rw {
|
namespace Rw {
|
||||||
|
|
||||||
|
void*
|
||||||
|
DestroyNativeDataPS2(void *object, int32, int32)
|
||||||
|
{
|
||||||
|
Geometry *geometry = (Geometry*)object;
|
||||||
|
assert(geometry->instData->platform == PLATFORM_PS2);
|
||||||
|
PS2InstanceDataHeader *header =
|
||||||
|
(PS2InstanceDataHeader*)geometry->instData;
|
||||||
|
for(uint32 i = 0; i < header->numMeshes; i++)
|
||||||
|
delete[] header->instanceMeshes[i].data;
|
||||||
|
delete[] header->instanceMeshes;
|
||||||
|
delete header;
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ReadNativeDataPS2(istream &stream, int32 len, void *object, int32, int32)
|
ReadNativeDataPS2(istream &stream, int32, void *object, int32, int32)
|
||||||
{
|
{
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
assert(FindChunk(stream, ID_STRUCT, NULL, NULL));
|
assert(FindChunk(stream, ID_STRUCT, NULL, NULL));
|
||||||
@ -43,7 +57,8 @@ WriteNativeDataPS2(ostream &stream, int32 len, void *object, int32, int32)
|
|||||||
{
|
{
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
WriteChunkHeader(stream, ID_STRUCT, len-12);
|
WriteChunkHeader(stream, ID_STRUCT, len-12);
|
||||||
writeUInt32(4, stream);
|
assert(geometry->instData->platform == PLATFORM_PS2);
|
||||||
|
writeUInt32(PLATFORM_PS2, stream);
|
||||||
assert(geometry->instData != NULL);
|
assert(geometry->instData != NULL);
|
||||||
PS2InstanceDataHeader *header =
|
PS2InstanceDataHeader *header =
|
||||||
(PS2InstanceDataHeader*)geometry->instData;
|
(PS2InstanceDataHeader*)geometry->instData;
|
||||||
@ -62,6 +77,7 @@ GetSizeNativeDataPS2(void *object, int32, int32)
|
|||||||
{
|
{
|
||||||
Geometry *geometry = (Geometry*)object;
|
Geometry *geometry = (Geometry*)object;
|
||||||
int32 size = 16;
|
int32 size = 16;
|
||||||
|
assert(geometry->instData->platform == PLATFORM_PS2);
|
||||||
assert(geometry->instData != NULL);
|
assert(geometry->instData != NULL);
|
||||||
PS2InstanceDataHeader *header =
|
PS2InstanceDataHeader *header =
|
||||||
(PS2InstanceDataHeader*)geometry->instData;
|
(PS2InstanceDataHeader*)geometry->instData;
|
||||||
|
1
rwps2.h
1
rwps2.h
@ -14,6 +14,7 @@ struct PS2InstanceDataHeader : InstanceDataHeader
|
|||||||
PS2InstanceData *instanceMeshes;
|
PS2InstanceData *instanceMeshes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void *DestroyNativeDataPS2(void *object, int32, int32);
|
||||||
void ReadNativeDataPS2(std::istream &stream, int32 len, void *object, int32, int32);
|
void ReadNativeDataPS2(std::istream &stream, int32 len, void *object, int32, int32);
|
||||||
void WriteNativeDataPS2(std::ostream &stream, int32 len, void *object, int32, int32);
|
void WriteNativeDataPS2(std::ostream &stream, int32 len, void *object, int32, int32);
|
||||||
int32 GetSizeNativeDataPS2(void *object, int32, int32);
|
int32 GetSizeNativeDataPS2(void *object, int32, int32);
|
||||||
|
Loading…
Reference in New Issue
Block a user