Skip to content

Commit 373fae4

Browse files
committed
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.
1 parent 63606b9 commit 373fae4

3 files changed

Lines changed: 12 additions & 14 deletions

File tree

sfall/Modules/Objects.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ static __declspec(naked) void new_obj_id_hook() {
109109
}
110110

111111
// Reassigns object IDs to all critters upon first loading a map and updates their HP stats
112+
// also fixes their combat_data.who_hit_me values (same as map_fix_critter_combat_data_)
112113
// TODO: for items?
113-
static void map_fix_critter_id() {
114+
static void __stdcall map_fix_critter_id_combat_data() {
114115
long npcStartID = 4096; // 0x1000
115116
fo::GameObject* obj = fo::func::obj_find_first();
116117
while (obj) {
@@ -119,19 +120,15 @@ static void map_fix_critter_id() {
119120
obj->id = npcStartID++;
120121
Objects::SetScriptObjectID(obj);
121122
}
123+
if (obj->critter.whoHitMe == (fo::GameObject*)-1) {
124+
obj->critter.whoHitMe = nullptr;
125+
}
122126
Stats::UpdateHPStat(obj);
123127
}
124128
obj = fo::func::obj_find_next();
125129
}
126130
}
127131

128-
static __declspec(naked) void map_load_file_hook() {
129-
__asm {
130-
call map_fix_critter_id;
131-
jmp fo::funcoffs::map_fix_critter_combat_data_;
132-
}
133-
}
134-
135132
static __declspec(naked) void queue_add_hack() {
136133
using namespace fo;
137134
using namespace Fields;
@@ -270,7 +267,7 @@ void Objects::init() {
270267
MakeCall(0x477A0E, item_identical_hack); // don't put item with unique ID to items stack
271268

272269
// Fix mapper bug by reassigning object IDs to critters (for unvisited maps)
273-
HookCall(0x482DE2, map_load_file_hook);
270+
HookCall(0x482DE2, map_fix_critter_id_combat_data); // replace map_fix_critter_combat_data_
274271
// Additionally fix object IDs for queued events
275272
MakeCall(0x4A25BA, queue_add_hack);
276273

sfall/WinProc.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,16 @@ void WinProc::SetStyle(long windowStyle) {
223223

224224
void WinProc::SetTitle(long wWidth, long wHeight, long gMode) {
225225
char windowTitle[128];
226-
char mode[4] = "DD7";
226+
char mode[8] = "DD7";
227227
if (gMode >= 4) std::strcpy(mode, "DX9");
228+
else if (extWrapper) std::strcpy(mode, "wrapper");
228229

229230
if (HRP::Setting::ScreenWidth() != wWidth || HRP::Setting::ScreenHeight() != wHeight) {
230231
std::sprintf(windowTitle, "%s @sfall " VERSION_STRING " : %ix%i >> %ix%i [%s]",
231-
(const char*)0x50AF08, HRP::Setting::ScreenWidth(), HRP::Setting::ScreenHeight(), wWidth, wHeight, mode);
232+
(const char*)0x50AF08, HRP::Setting::ScreenWidth(), HRP::Setting::ScreenHeight(), wWidth, wHeight, mode);
232233
} else {
233234
std::sprintf(windowTitle, "%s @sfall " VERSION_STRING " : %ix%i [%s]",
234-
(const char*)0x50AF08, HRP::Setting::ScreenWidth(), HRP::Setting::ScreenHeight(), mode);
235+
(const char*)0x50AF08, HRP::Setting::ScreenWidth(), HRP::Setting::ScreenHeight(), mode);
235236
}
236237
SetWindowTextA(window, windowTitle);
237238
}

sfall/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
#define VERSION_MAJOR 4
2626
#define VERSION_MINOR 5
2727
#define VERSION_BUILD 0
28-
#define VERSION_REV 0
28+
#define VERSION_REV 1
2929

30-
#define VERSION_STRING "4.5"
30+
#define VERSION_STRING "4.5.0.1"

0 commit comments

Comments
 (0)