added NodeName plugin

This commit is contained in:
aap 2019-06-12 14:35:15 +02:00
parent 01babd43b1
commit 83cc43eeff
3 changed files with 65 additions and 4 deletions

View File

@ -2,10 +2,72 @@
#include "patcher.h" #include "patcher.h"
#include "NodeName.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)) #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* char*
GetFrameNodeName(RwFrame *frame) GetFrameNodeName(RwFrame *frame)
{ {

View File

@ -1,3 +1,4 @@
#pragma once #pragma once
bool NodeNamePluginAttach(void);
char *GetFrameNodeName(RwFrame *frame); char *GetFrameNodeName(RwFrame *frame);

View File

@ -33,6 +33,7 @@
#include "Garages.h" #include "Garages.h"
#include "MusicManager.h" #include "MusicManager.h"
#include "VisibilityPlugins.h" #include "VisibilityPlugins.h"
#include "NodeName.h"
#include "DMAudio.h" #include "DMAudio.h"
#include "CutsceneMgr.h" #include "CutsceneMgr.h"
#include "Lights.h" #include "Lights.h"
@ -55,9 +56,6 @@
WRAPPER void CameraSize(RwCamera *camera, void *rect, float viewWindow, float aspectRatio) { EAXJMP(0x527170); } WRAPPER void CameraSize(RwCamera *camera, void *rect, float viewWindow, float aspectRatio) { EAXJMP(0x527170); }
//WRAPPER RwBool RpAnimBlendPluginAttach() { EAXJMP(0x4052D0); }
WRAPPER RwBool NodeNamePluginAttach() { EAXJMP(0x527100); }
bool &b_FoundRecentSavedGameWantToLoad = *(bool*)0x95CDA8; bool &b_FoundRecentSavedGameWantToLoad = *(bool*)0x95CDA8;