Increased the max number of objects that can be outlined simultaneously

(from 100 to 500, same as Mash's HRP 4.x)

Minor code edits to npc_engine_level_up function.
This commit is contained in:
NovaRain
2026-07-27 22:33:11 +08:00
parent fcbb07a883
commit 2e3087bde8
4 changed files with 25 additions and 4 deletions
+23
View File
@@ -29,6 +29,8 @@ namespace sfall
static int unjamTimeState;
static int maxCountLoadProto = 512;
static fo::GameObject* outlinedObjs[500];
long Objects::uniqueID = UniqueID::Start; // current counter id, saving to sfallgv.sav
bool Objects::IsUniqueID(long id) {
@@ -251,6 +253,18 @@ skip:
}
}
static __declspec(naked) void obj_render_pre_roof_hack() {
__asm {
cmp eax, 500;
jge jbreak;
retn;
jbreak:
pop edx;
add edx, 13; // offset to next section (0x4896E8, 0x4897C7)
jmp edx;
}
}
void Objects::init() {
LoadGameHook::OnGameReset() += []() {
RestoreObjUnjamAllLocks();
@@ -273,6 +287,15 @@ void Objects::init() {
// Place some objects on the lower z-layer of the tile
MakeCall(0x48D918, obj_insert_hack, 1);
// Increase the maximum number of objects that can be outlined simultaneously (when w/o HRP 4.x by Mash)
if (*(DWORD*)0x48981D == 0x639C00) {
// replace _outlinedObjects array (was 100 objects)
SafeWriteBatch<DWORD>((DWORD)outlinedObjs - 4, {0x4896DF, 0x4897BE}); // obj_render_pre_roof_
SafeWrite32(0x48981D, (DWORD)outlinedObjs); // obj_render_post_roof_
// change the maximum limit to 500
MakeCalls(obj_render_pre_roof_hack, {0x4896D6, 0x4897B5});
}
}
}
@@ -27,8 +27,6 @@ namespace script
class OpcodeContext;
void ClearInterfaceArtCache();
// input_functions
void op_input_funcs_available();
@@ -126,7 +126,7 @@ static const SfallMetarule metarules[] = {
{"loot_obj", mf_get_loot_object, 0, 0},
{"message_box", mf_message_box, 1, 4, -1, {ARG_STRING, ARG_INT, ARG_INT, ARG_INT}},
{"metarule_exist", mf_metarule_exist, 1, 1}, // no arg check
{"npc_engine_level_up", mf_npc_engine_level_up, 1, 1},
{"npc_engine_level_up", mf_npc_engine_level_up, 1, 1, -1, {ARG_INT}},
{"obj_is_openable", mf_obj_is_openable, 1, 1, 0, {ARG_OBJECT}},
{"obj_under_cursor", mf_obj_under_cursor, 2, 2, 0, {ARG_INT, ARG_INT}},
{"objects_in_radius", mf_objects_in_radius, 3, 4, 0, {ARG_INT, ARG_INT, ARG_INT, ARG_INT}},
+1 -1
View File
@@ -615,7 +615,7 @@ void mf_objects_in_radius(OpcodeContext& ctx) {
}
void mf_npc_engine_level_up(OpcodeContext& ctx) {
if (ctx.arg(0).asBool()) {
if (ctx.arg(0).rawValue()) {
if (!npcEngineLevelUp) SafeWrite16(0x4AFC1C, 0x840F); // enable
npcEngineLevelUp = true;
} else {