diff options
author | Fire-Head <Fire-Head@users.noreply.github.com> | 2019-06-13 02:40:46 +0200 |
---|---|---|
committer | Fire-Head <Fire-Head@users.noreply.github.com> | 2019-06-13 02:40:46 +0200 |
commit | 06e48c70595808f8c3143d4284e5757e29d81800 (patch) | |
tree | e321a452104d4dd3716b1bdfaa1bda81a739be26 /src/NodeName.cpp | |
parent | CPad done (diff) | |
parent | Merge pull request #6 from GTAmodding/master (diff) | |
download | re3-06e48c70595808f8c3143d4284e5757e29d81800.tar re3-06e48c70595808f8c3143d4284e5757e29d81800.tar.gz re3-06e48c70595808f8c3143d4284e5757e29d81800.tar.bz2 re3-06e48c70595808f8c3143d4284e5757e29d81800.tar.lz re3-06e48c70595808f8c3143d4284e5757e29d81800.tar.xz re3-06e48c70595808f8c3143d4284e5757e29d81800.tar.zst re3-06e48c70595808f8c3143d4284e5757e29d81800.zip |
Diffstat (limited to '')
-rw-r--r-- | src/NodeName.cpp | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/src/NodeName.cpp b/src/NodeName.cpp index c2ffe048..2aea3c83 100644 --- a/src/NodeName.cpp +++ b/src/NodeName.cpp @@ -2,10 +2,72 @@ #include "patcher.h" #include "NodeName.h" -int &gPluginOffset = *(int*)0x64C610; +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) { |