Improved the critter object ID fix

* Now looping through critters on a map runs only once instead of twice.

[HRP] Changed the window title to indicate a DDraw wrapper is loaded.
This commit is contained in:
NovaRain
2026-06-16 23:12:10 +08:00
parent 63606b96d7
commit 373fae4942
3 changed files with 12 additions and 14 deletions
+6 -9
View File
@@ -109,8 +109,9 @@ pickNewID: // skip PM range (18000 - 16795215)
}
// Reassigns object IDs to all critters upon first loading a map and updates their HP stats
// also fixes their combat_data.who_hit_me values (same as map_fix_critter_combat_data_)
// TODO: for items?
static void map_fix_critter_id() {
static void __stdcall map_fix_critter_id_combat_data() {
long npcStartID = 4096; // 0x1000
fo::GameObject* obj = fo::func::obj_find_first();
while (obj) {
@@ -119,19 +120,15 @@ static void map_fix_critter_id() {
obj->id = npcStartID++;
Objects::SetScriptObjectID(obj);
}
if (obj->critter.whoHitMe == (fo::GameObject*)-1) {
obj->critter.whoHitMe = nullptr;
}
Stats::UpdateHPStat(obj);
}
obj = fo::func::obj_find_next();
}
}
static __declspec(naked) void map_load_file_hook() {
__asm {
call map_fix_critter_id;
jmp fo::funcoffs::map_fix_critter_combat_data_;
}
}
static __declspec(naked) void queue_add_hack() {
using namespace fo;
using namespace Fields;
@@ -270,7 +267,7 @@ void Objects::init() {
MakeCall(0x477A0E, item_identical_hack); // don't put item with unique ID to items stack
// Fix mapper bug by reassigning object IDs to critters (for unvisited maps)
HookCall(0x482DE2, map_load_file_hook);
HookCall(0x482DE2, map_fix_critter_id_combat_data); // replace map_fix_critter_combat_data_
// Additionally fix object IDs for queued events
MakeCall(0x4A25BA, queue_add_hack);
+4 -3
View File
@@ -223,15 +223,16 @@ void WinProc::SetStyle(long windowStyle) {
void WinProc::SetTitle(long wWidth, long wHeight, long gMode) {
char windowTitle[128];
char mode[4] = "DD7";
char mode[8] = "DD7";
if (gMode >= 4) std::strcpy(mode, "DX9");
else if (extWrapper) std::strcpy(mode, "wrapper");
if (HRP::Setting::ScreenWidth() != wWidth || HRP::Setting::ScreenHeight() != wHeight) {
std::sprintf(windowTitle, "%s @sfall " VERSION_STRING " : %ix%i >> %ix%i [%s]",
(const char*)0x50AF08, HRP::Setting::ScreenWidth(), HRP::Setting::ScreenHeight(), wWidth, wHeight, mode);
(const char*)0x50AF08, HRP::Setting::ScreenWidth(), HRP::Setting::ScreenHeight(), wWidth, wHeight, mode);
} else {
std::sprintf(windowTitle, "%s @sfall " VERSION_STRING " : %ix%i [%s]",
(const char*)0x50AF08, HRP::Setting::ScreenWidth(), HRP::Setting::ScreenHeight(), mode);
(const char*)0x50AF08, HRP::Setting::ScreenWidth(), HRP::Setting::ScreenHeight(), mode);
}
SetWindowTextA(window, windowTitle);
}
+2 -2
View File
@@ -25,6 +25,6 @@
#define VERSION_MAJOR 4
#define VERSION_MINOR 5
#define VERSION_BUILD 0
#define VERSION_REV 0
#define VERSION_REV 1
#define VERSION_STRING "4.5"
#define VERSION_STRING "4.5.0.1"