mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Improved the division function in previous commit
Rewrote the text hook for main_menu_create_ in C++ (from HRP branch) Updated version number.
This commit is contained in:
+16
-18
@@ -35,25 +35,21 @@ int DamageMod::formula;
|
||||
// Integer division w/ round half to even for Glovz's damage formula
|
||||
// Prerequisite: both dividend and divisor must be positive integers (should already be handled in the main function)
|
||||
static long DivRound(long dividend, long divisor) {
|
||||
if (dividend == divisor) return 1;
|
||||
|
||||
if (dividend < divisor) {
|
||||
dividend <<= 1; // multiply by 2
|
||||
return (dividend <= divisor) ? 0 : 1;
|
||||
} else {
|
||||
long quotient = dividend / divisor;
|
||||
dividend %= divisor; // get the remainder
|
||||
// check the remainder
|
||||
if (dividend) {
|
||||
dividend <<= 1; // multiply by 2
|
||||
if (dividend > divisor) {
|
||||
quotient++;
|
||||
} else if (dividend == divisor) {
|
||||
if ((quotient & 1) != 0) quotient++; // round half to even
|
||||
}
|
||||
}
|
||||
return quotient;
|
||||
if (dividend <= divisor) {
|
||||
// if equal then return 1
|
||||
return (dividend != divisor && (dividend << 1) <= divisor) ? 0 : 1;
|
||||
}
|
||||
|
||||
long quotient = dividend / divisor;
|
||||
dividend %= divisor; // get the remainder
|
||||
|
||||
// check the remainder
|
||||
if (dividend == 0) return quotient;
|
||||
|
||||
dividend <<= 1; // multiply by 2
|
||||
|
||||
// if equal then round to even
|
||||
return (dividend > divisor || (dividend == divisor && (quotient & 1))) ? ++quotient : quotient;
|
||||
}
|
||||
|
||||
// Damage Fix v5 (with v5.1 Damage Multiplier tweak) by Glovz 2014.04.16.xx.xx
|
||||
@@ -62,8 +58,10 @@ void DamageMod::DamageGlovz(fo::ComputeAttackResult &ctd, DWORD &accumulatedDama
|
||||
|
||||
long ammoY = fo::func::item_w_dam_div(ctd.weapon); // ammoY value (divisor)
|
||||
if (ammoY <= 0) ammoY = 1;
|
||||
|
||||
long ammoX = fo::func::item_w_dam_mult(ctd.weapon); // ammoX value
|
||||
if (ammoX <= 0) ammoX = 1;
|
||||
|
||||
long ammoDRM = fo::func::item_w_dr_adjust(ctd.weapon); // ammoDRM value
|
||||
if (ammoDRM > 0) ammoDRM = -ammoDRM;
|
||||
|
||||
|
||||
+15
-50
@@ -31,12 +31,12 @@ static const char* VerString1 = "SFALL " VERSION_STRING;
|
||||
static const char* VerString1 = "SFALL " VERSION_STRING " Debug Build";
|
||||
#endif
|
||||
|
||||
static DWORD MainMenuYOffset;
|
||||
static DWORD MainMenuTextOffset;
|
||||
static long MainMenuYOffset;
|
||||
static long MainMenuTextOffset; // sum: x + (y * w)
|
||||
|
||||
static long OverrideColour, OverrideColour2;
|
||||
|
||||
static void __declspec(naked) MainMenuButtonYHook() {
|
||||
static void __declspec(naked) MainMenuHookButtonYOffset() {
|
||||
static const DWORD MainMenuButtonYHookRet = 0x48184A;
|
||||
__asm {
|
||||
xor edi, edi;
|
||||
@@ -46,57 +46,22 @@ static void __declspec(naked) MainMenuButtonYHook() {
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) MainMenuTextYHook() {
|
||||
static void __declspec(naked) MainMenuHookTextYOffset() {
|
||||
__asm {
|
||||
add eax, MainMenuTextOffset;
|
||||
jmp dword ptr ds:[FO_VAR_text_to_buf];
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) FontColour() {
|
||||
__asm {
|
||||
test OverrideColour, 0xFF;
|
||||
jnz override;
|
||||
movzx eax, byte ptr ds:[0x6A8B33];
|
||||
or eax, 0x6000000;
|
||||
retn;
|
||||
override:
|
||||
mov eax, OverrideColour;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
static void __fastcall main_menu_create_hook_print_text(long xPos, const char* text, long yPos, long color) {
|
||||
long winId = fo::var::main_window;
|
||||
if (OverrideColour) color = OverrideColour;
|
||||
|
||||
static void __declspec(naked) MainMenuTextHook() {
|
||||
static const DWORD MainMenuTextRet = 0x4817B0;
|
||||
__asm {
|
||||
mov esi, eax; // winptr
|
||||
mov ebp, ecx; // keep xpos
|
||||
mov edi, [esp]; // ypos
|
||||
mov eax, edi;
|
||||
sub eax, 12; // shift y position up by 12
|
||||
mov [esp], eax;
|
||||
call FontColour;
|
||||
mov [esp + 4], eax; // colour
|
||||
mov eax, esi;
|
||||
mov esi, edx; // keep fallout buff
|
||||
call fo::funcoffs::win_print_;
|
||||
// sfall print
|
||||
mov eax, esi;
|
||||
call ds:[FO_VAR_text_width];
|
||||
add ebp, eax; // xpos shift (right align)
|
||||
call FontColour;
|
||||
push eax; // colour
|
||||
mov edx, VerString1; // msg
|
||||
mov eax, edx;
|
||||
call ds:[FO_VAR_text_width];
|
||||
mov ecx, ebp; // xpos
|
||||
sub ecx, eax; // left shift position
|
||||
push edi; // ypos
|
||||
xor ebx, ebx; // font
|
||||
mov eax, dword ptr ds:[FO_VAR_main_window]; // winptr
|
||||
call fo::funcoffs::win_print_;
|
||||
jmp MainMenuTextRet;
|
||||
}
|
||||
long fWidth = fo::util::GetTextWidth(text);
|
||||
fo::func::win_print(winId, text, fWidth, xPos, yPos - 12, color); // fallout print
|
||||
|
||||
long sWidth = fo::util::GetTextWidth(VerString1);
|
||||
fo::func::win_print(winId, VerString1, sWidth, xPos + fWidth - sWidth, yPos, color); // sfall print
|
||||
}
|
||||
|
||||
void MainMenu::init() {
|
||||
@@ -114,13 +79,13 @@ void MainMenu::init() {
|
||||
if (offset = IniReader::GetConfigInt("Misc", "MainMenuOffsetY", 0)) {
|
||||
MainMenuYOffset = offset;
|
||||
MainMenuTextOffset += offset * 640;
|
||||
MakeJump(0x481844, MainMenuButtonYHook);
|
||||
MakeJump(0x481844, MainMenuHookButtonYOffset);
|
||||
}
|
||||
if (MainMenuTextOffset) {
|
||||
MakeCall(0x481933, MainMenuTextYHook, 1);
|
||||
MakeCall(0x481933, MainMenuHookTextYOffset, 1);
|
||||
}
|
||||
|
||||
MakeJump(0x4817AB, MainMenuTextHook);
|
||||
HookCall(0x4817AB, main_menu_create_hook_print_text);
|
||||
|
||||
OverrideColour = IniReader::GetConfigInt("Misc", "MainMenuFontColour", 0);
|
||||
if (OverrideColour & 0xFF) {
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@
|
||||
|
||||
#define VERSION_MAJOR 4
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_BUILD 1
|
||||
#define VERSION_BUILD 2
|
||||
#define VERSION_REV 0
|
||||
|
||||
#define VERSION_STRING "4.3.1"
|
||||
#define VERSION_STRING "4.3.2"
|
||||
|
||||
Reference in New Issue
Block a user