1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-10 21:29:16 +00:00
re3/src/rw/NodeName.cpp

78 lines
1.8 KiB
C++
Raw Normal View History

2019-05-15 14:52:37 +00:00
#include "common.h"
2020-04-17 13:31:11 +00:00
2019-05-15 14:52:37 +00:00
#include "NodeName.h"
2020-04-17 05:54:14 +00:00
static int32 gPluginOffset;
2019-06-12 12:35:15 +00:00
enum
{
ID_NODENAME = MAKECHUNKID(rwVENDORID_ROCKSTAR, 0xFE),
};
2019-05-15 14:52:37 +00:00
#define NODENAMEEXT(o) (RWPLUGINOFFSET(char, o, gPluginOffset))
2019-06-12 12:35:15 +00:00
void*
NodeNameConstructor(void *object, RwInt32 offsetInObject, RwInt32 sizeInObject)
{
if(gPluginOffset > 0)
NODENAMEEXT(object)[0] = '\0';
return object;
}
void*
NodeNameDestructor(void *object, RwInt32 offsetInObject, RwInt32 sizeInObject)
{
return object;
}
void*
NodeNameCopy(void *dstObject, const void *srcObject, RwInt32 offsetInObject, RwInt32 sizeInObject)
{
strncpy(NODENAMEEXT(dstObject), NODENAMEEXT(srcObject), 23);
return nil;
}
RwStream*
NodeNameStreamRead(RwStream *stream, RwInt32 binaryLength, void *object, RwInt32 offsetInObject, RwInt32 sizeInObject)
{
RwStreamRead(stream, NODENAMEEXT(object), binaryLength);
NODENAMEEXT(object)[binaryLength] = '\0';
return stream;
}
RwStream*
NodeNameStreamWrite(RwStream *stream, RwInt32 binaryLength, const void *object, RwInt32 offsetInObject, RwInt32 sizeInObject)
{
RwStreamWrite(stream, NODENAMEEXT(object), binaryLength);
return stream;
}
RwInt32
NodeNameStreamGetSize(const void *object, RwInt32 offsetInObject, RwInt32 sizeInObject)
{
2020-08-20 10:55:41 +00:00
char *name = NODENAMEEXT(object); // can't be nil
return name ? (RwInt32)rwstrlen(name) : 0;
2019-06-12 12:35:15 +00:00
}
bool
NodeNamePluginAttach(void)
{
gPluginOffset = RwFrameRegisterPlugin(24, ID_NODENAME,
NodeNameConstructor,
NodeNameDestructor,
NodeNameCopy);
RwFrameRegisterPluginStream(ID_NODENAME,
NodeNameStreamRead,
NodeNameStreamWrite,
NodeNameStreamGetSize);
return gPluginOffset != -1;
}
2019-05-15 14:52:37 +00:00
char*
GetFrameNodeName(RwFrame *frame)
{
if(gPluginOffset < 0)
return nil;
return NODENAMEEXT(frame);
}