Skip to content

Commit e01b496

Browse files
committed
Load custom head milo when prefab head is hidden
this only impacts custom characters being loaded through modified prefabs and is purely to better support mods, there is no impact to vanilla rb3
1 parent d094efd commit e01b496

File tree

8 files changed

+73
-1
lines changed

8 files changed

+73
-1
lines changed

include/MiloSceneHooks.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include "rb3/DirLoader.h"
88
#include "rb3/Object.h"
99
#include "rb3/Vector.h"
10+
#include "rb3/String.h"
1011

1112
// void DirLoaderOpenFileHook(DirLoader *thisDirLoader);
1213
void LoadObj(Object *object, BinStream *stream);
13-
void VertexReadHook(BinStream *thisBinStream, Vector3 *vec3);
14+
void VertexReadHook(BinStream *thisBinStream, Vector3 *vec3);
15+
void MakeOutfitPathHook(void *thisBandCharDesc, Symbol part, String *filePath);

include/ports_wii.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
#define PORT_FILEISLOCAL 0x802fb548 // FileIsLocal
108108
#define PORT_FILEISDLC 0x802fb54c // FileIsDLC
109109
#define PORT_SDMODECHECK 0x802F5638 // WiiContentMgr::SDModeCheck
110+
#define PORT_CHARBANDDESC_MAKEOUTFITPATH 0x803dbf70 // CharBandDesc::MakeOutfitPath
110111
// instance addresses
111112
#define PORT_MODIFIERMGR_POINTER 0x808fda68 // pointer to ModifierManager
112113
#define PORT_ROCKCENTRALGATEWAY 0x80900870 // address of RockCentralGateway

include/ports_xbox360.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#define PORT_STAGEKIT_EXISTS 0x8228d03c // StageKit check. nop over to allow for fog command without a physical StageKit connected.
5151
#define PORT_VERTEX_READ_1 0x82418704 // call to Vector3::operator>> to read vertex position
5252
#define PORT_VERTEX_READ_2 0x82418748 // call to Vector3::operator>> to read vertex normals
53+
#define PORT_CHARBANDDESC_MAKEOUTFITPATH 0x82335220 // CharBandDesc::MakeOutfitPath
5354
#define PORT_MULTIPLAYER_CRASH 0x82ae6880 // branch to a function that can crash in online multiplayer
5455
#define PORT_MULTIPLAYER_FIX 0x8282b238 // the function that doesn't crash
5556
#define PORT_QUAZAL_BREAKPOINT 0x828410c0 // address to DbgBreakPoint in Quazal::Platform::Breakpoint

include/rb3/CharBandDesc.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef _CHARBANDDESC_H
2+
#define _CHARBANDDESC_H
3+
4+
#include "Symbol.h"
5+
6+
extern void MakeOutfitPath(void *thisBandCharDesc, Symbol part, String *filePath);
7+
8+
#endif // _CHARBANDDESC_H

include/rb3_include.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "rb3/BandUser.h"
1010
#include "rb3/BandUserMgr.h"
1111
#include "rb3/BinStream.h"
12+
#include "rb3/CharBandDesc.h"
1213
#include "rb3/Casting.h"
1314
#include "rb3/ChunkStream.h"
1415
#include "rb3/Data.h"

source/MiloSceneHooks.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ void DirLoaderOpenFileHook(DirLoader *thisDirLoader)
2020
}
2121
*/
2222

23+
static char headPath[512] = "char/main/head/male/head_custom.milo";
24+
2325
void LoadObj(Object *object, BinStream *stream)
2426
{
2527
char newPath[512] = {0};
@@ -91,4 +93,57 @@ void VertexReadHook(BinStream *thisBinStream, Vector3 *vec3)
9193

9294
return;
9395
#endif
96+
}
97+
98+
99+
// the third arg is not really a String but a FilePath but shhh i wont tell if you dont
100+
void MakeOutfitPathHook(void *thisBandCharDesc, Symbol part, String *filePath)
101+
{
102+
const char *path;
103+
char *copy;
104+
size_t len;
105+
106+
// check if the head is hidden on the prefab and we are trying to load the head part
107+
if (*(char *)((char *)thisBandCharDesc + 0x20) == 1 && strcmp(part.sym, "head") == 0)
108+
{
109+
// determine gender, gender is a Symbol at 0x10
110+
Symbol *genderSym = (Symbol *)((char *)thisBandCharDesc + 0x10);
111+
if (strcmp(genderSym->sym, "female") == 0)
112+
{
113+
path = "char/main/head/female/head_custom.milo";
114+
len = strlen(path);
115+
116+
RB3E_DEBUG("Head is hidden on female prefab, using custom head milo", 0);
117+
118+
copy = (char *)malloc(len + 1);
119+
if (copy != NULL)
120+
{
121+
strcpy(copy, path);
122+
filePath->buf = copy;
123+
filePath->length = (int)len;
124+
}
125+
return;
126+
}
127+
else if (strcmp(genderSym->sym, "male") == 0)
128+
{
129+
path = "char/main/head/male/head_custom.milo";
130+
len = strlen(path);
131+
132+
RB3E_DEBUG("Head is hidden on male prefab, using custom head milo", 0);
133+
134+
copy = (char *)malloc(len + 1);
135+
if (copy != NULL)
136+
{
137+
strcpy(copy, path);
138+
filePath->buf = copy;
139+
filePath->length = (int)len;
140+
}
141+
return;
142+
} else {
143+
RB3E_DEBUG("Unknown gender, cannot load custom head milo", 0);
144+
return;
145+
}
146+
}
147+
148+
MakeOutfitPath(thisBandCharDesc, part, filePath);
94149
}

source/_functions.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ RB3E_STUB(ResolvedModuleKeyboard)
113113
RB3E_STUB(XboxContentConstruct)
114114
RB3E_STUB(CacheMgrXbox_MountAsync)
115115
RB3E_STUB(DataArrayExecute)
116+
RB3E_STUB(MakeOutfitPath)
116117

117118
#ifdef RB3E_WII
118119
// Wii-specific functions

source/rb3enhanced.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ void ApplyHooks()
452452
POKE_BL(PORT_LOADOBJS_BCTRL, &LoadObj);
453453
POKE_BL(PORT_VERTEX_READ_1, &VertexReadHook);
454454
POKE_BL(PORT_VERTEX_READ_2, &VertexReadHook);
455+
456+
// outfit path stuff is 360 only for now
457+
HookFunction(PORT_CHARBANDDESC_MAKEOUTFITPATH, &MakeOutfitPath, &MakeOutfitPathHook);
455458
#endif
456459
RB3E_MSG("Hooks applied!", NULL);
457460
}

0 commit comments

Comments
 (0)