mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Correction to the previous commit
* shouldn't modify the string in-place.
This commit is contained in:
@@ -185,35 +185,6 @@ static __declspec(naked) void display_print_line_break_extHRP() {
|
||||
}
|
||||
}
|
||||
|
||||
static void __fastcall ObjDescStripNewlines(char* desc) {
|
||||
size_t i = 0, j = 0;
|
||||
while (desc[i]) {
|
||||
if (desc[i] == '\\' && desc[i + 1] == 'n') {
|
||||
desc[j++] = ' ';
|
||||
i += 2;
|
||||
} else {
|
||||
desc[j++] = desc[i++];
|
||||
}
|
||||
}
|
||||
desc[j] = '\0'; // null-terminate the modified string
|
||||
}
|
||||
|
||||
static __declspec(naked) void obj_examine_func_hack() {
|
||||
__asm {
|
||||
cmp dword ptr [esp + 0x1AC - 0x14 + 4], 0x445448; // gdialogDisplayMsg_
|
||||
jne skip;
|
||||
push eax;
|
||||
push ecx;
|
||||
mov ecx, eax;
|
||||
call ObjDescStripNewlines;
|
||||
pop ecx;
|
||||
pop eax;
|
||||
skip:
|
||||
mov edx, ds:[FO_VAR_proto_none_str]; // overwritten engine code
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
void Text::init() {
|
||||
void* printFunc = display_print_line_break; // for vanilla and HRP 4.1.8
|
||||
|
||||
@@ -228,8 +199,6 @@ void Text::init() {
|
||||
// Support for the newline control character '\n' in the object description in pro_*.msg files
|
||||
sf::SafeWriteBatch<DWORD>((DWORD)printFunc, {0x46ED87, 0x49AD7A}); // setup_inventory_, obj_examine_
|
||||
sf::SafeWrite32(0x472F9A, (DWORD)&inven_display_msg_line_break); // inven_obj_examine_func_
|
||||
// Remove visible newline control characters when examining items in the barter screen
|
||||
sf::MakeCall(0x49AE33, obj_examine_func_hack, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1825,6 +1825,35 @@ skip:
|
||||
}
|
||||
}
|
||||
|
||||
static void __fastcall StripNewlines(char* desc) {
|
||||
size_t i = 0, j = 0;
|
||||
while (desc[i] && j < sizeof(messageBuffer) - 1) {
|
||||
if (desc[i] == '\\' && desc[i + 1] == 'n') {
|
||||
messageBuffer[j++] = ' ';
|
||||
i += 2;
|
||||
} else {
|
||||
messageBuffer[j++] = desc[i++];
|
||||
}
|
||||
}
|
||||
messageBuffer[j] = '\0'; // null-terminate the modified string
|
||||
}
|
||||
|
||||
static __declspec(naked) void obj_examine_func_hack_objdesc() {
|
||||
__asm {
|
||||
cmp dword ptr [esp + 0x1AC - 0x14 + 4], 0x445448; // gdialogDisplayMsg_
|
||||
jne skip;
|
||||
push ecx;
|
||||
mov ecx, eax;
|
||||
call StripNewlines;
|
||||
pop ecx;
|
||||
lea eax, messageBuffer;
|
||||
mov esi, eax;
|
||||
skip:
|
||||
mov edx, ds:[FO_VAR_proto_none_str]; // overwritten engine code
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
static DWORD expSwiftLearner; // experience points for print
|
||||
|
||||
static __declspec(naked) void statPCAddExperienceCheckPMs_hack() {
|
||||
@@ -3928,6 +3957,9 @@ void BugFixes::init() {
|
||||
dlogr("Applying full item description in barter patch.", DL_FIX);
|
||||
HookCall(0x49B452, obj_examine_func_hack_weapon); // it's jump
|
||||
}
|
||||
// Remove visible newline control characters when examining items in the barter screen
|
||||
// Supplementary fix for hacks in Game\GUI\Text.cpp
|
||||
MakeCall(0x49AE33, obj_examine_func_hack_objdesc, 1);
|
||||
|
||||
// Display experience points with the bonus from Swift Learner perk when gained from non-scripted situations
|
||||
//if (IniReader::GetConfigInt("Misc", "DisplaySwiftLearnerExp", 1)) {
|
||||
|
||||
Reference in New Issue
Block a user