summaryrefslogtreecommitdiffstats
path: root/src/rw/NodeName.cpp
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-04-11 17:37:20 +0200
committerSergeanur <s.anureev@yandex.ua>2020-04-11 22:37:04 +0200
commitdaceee593be76fe7d681e3b8c9101b02c058d186 (patch)
tree13df853a3b0253ef804afc383de0e5e952074533 /src/rw/NodeName.cpp
parentMerge branch 'master' of github.com:gtamodding/re3 (diff)
downloadre3-daceee593be76fe7d681e3b8c9101b02c058d186.tar
re3-daceee593be76fe7d681e3b8c9101b02c058d186.tar.gz
re3-daceee593be76fe7d681e3b8c9101b02c058d186.tar.bz2
re3-daceee593be76fe7d681e3b8c9101b02c058d186.tar.lz
re3-daceee593be76fe7d681e3b8c9101b02c058d186.tar.xz
re3-daceee593be76fe7d681e3b8c9101b02c058d186.tar.zst
re3-daceee593be76fe7d681e3b8c9101b02c058d186.zip
Diffstat (limited to 'src/rw/NodeName.cpp')
-rw-r--r--src/rw/NodeName.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/src/rw/NodeName.cpp b/src/rw/NodeName.cpp
new file mode 100644
index 00000000..2aea3c83
--- /dev/null
+++ b/src/rw/NodeName.cpp
@@ -0,0 +1,77 @@
+#include "common.h"
+#include "patcher.h"
+#include "NodeName.h"
+
+static int32 &gPluginOffset = *(int32*)0x64C610;
+
+enum
+{
+ ID_NODENAME = MAKECHUNKID(rwVENDORID_ROCKSTAR, 0xFE),
+};
+
+#define NODENAMEEXT(o) (RWPLUGINOFFSET(char, o, gPluginOffset))
+
+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)
+{
+ // game checks for null pointer on node name extension but that really happen
+ return rwstrlen(NODENAMEEXT(object));
+}
+
+bool
+NodeNamePluginAttach(void)
+{
+ gPluginOffset = RwFrameRegisterPlugin(24, ID_NODENAME,
+ NodeNameConstructor,
+ NodeNameDestructor,
+ NodeNameCopy);
+ RwFrameRegisterPluginStream(ID_NODENAME,
+ NodeNameStreamRead,
+ NodeNameStreamWrite,
+ NodeNameStreamGetSize);
+ return gPluginOffset != -1;
+}
+
+char*
+GetFrameNodeName(RwFrame *frame)
+{
+ if(gPluginOffset < 0)
+ return nil;
+ return NODENAMEEXT(frame);
+}