Skip to content

Commit

Permalink
Replace 4 functions with a single function.
Browse files Browse the repository at this point in the history
  • Loading branch information
serg-bloim committed Nov 12, 2019
1 parent 91bb5e2 commit b531f42
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 87 deletions.
8 changes: 4 additions & 4 deletions postbuild/server.mp
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@
0 150 52DA11 // presumably drop all
0 151 5610B6 // quest reward scaling
0 201 53973E // fix spell duration overflow
0 206 53BF9C // fix spell duration overflow
0 203 53C0E1 // fix spell duration overflow
0 204 53C21E // fix spell duration overflow
0 205 53C52A // fix spell duration overflow
1 202 53BFA1 // fix spell duration overflow
1 202 53C0E1 // fix spell duration overflow
1 202 53C21E // fix spell duration overflow
1 202 53C52A // fix spell duration overflow
////////// 0: jmp, 1: call

84 changes: 7 additions & 77 deletions spell_duration_fix.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#define FTOL 0x005BF1AC
void __declspec(naked) fix_spell_duration_overflow_0053973E()
{ // 0053973E
__asm
{
cmp eax, 0xFFFF
jle short ret_point1
jle short ret_point
mov eax, 0xFFFF
ret_point1:
ret_point:
// restore overridden code begin
mov edx, [ebp-0xC]
mov [edx+10h], ax
Expand All @@ -18,87 +17,18 @@ void __declspec(naked) fix_spell_duration_overflow_0053973E()
}
// FUNCTIONS BELOW ARE DIFFERENT
void __declspec(naked) fix_spell_duration_overflow()
{ // 53BF9C
{ // 0053BFA1
__asm
{
mov eax, FTOL
call eax
cmp eax, 0xFFFF
jle short ret_point
mov eax, 0xFFFF
ret_point:
ret
}
}
// FUNCTIONS BELOW ARE DIFFERENT
void __declspec(naked) fix_spell_duration_overflow_0053BFA1()
{ // 0053BFA1
__asm
{
cmp eax, 0xFFFF
jle short ret_point2
mov eax, 0xFFFF
ret_point2:
// restore overridden code begin
mov edx, [ebp-0x44]
mov [edx+0x42], ax
// restore overridden code
// jump back
mov edx, 0x0053BFA8
jmp edx
}
}

void __declspec(naked) fix_spell_duration_overflow_0053C0E1()
{ // 0053C0E1
__asm
{
cmp eax, 0xFFFF
jle short ret_point3
mov eax, 0xFFFF
ret_point3:
// restore overridden code begin
mov edx, [ebp-0x44]
mov [edx+0x42], ax
// restore overridden code
// jump back
mov edx, 0x0053C0E8
jmp edx
}
}

void __declspec(naked) fix_spell_duration_overflow_0053C21E()
{ // 0053C21E
__asm
{
cmp eax, 0xFFFF
jle short ret_point4
mov eax, 0xFFFF
ret_point4:
// restore overridden code begin
mov edx, [ebp-0x44]
mov [edx+0x42], ax
// restore overridden code
// jump back
mov edx, 0x0053C225
jmp edx
}
}

void __declspec(naked) fix_spell_duration_overflow_0053C52A()
{ // 0053C52A
__asm
{
cmp eax, 0xFFFF
jle short ret_point5
mov eax, 0xFFFF
ret_point5:
// restore overridden code begin
mov edx, [ebp-0x44]
mov [edx+0x42], ax
// restore overridden code
// jump back
mov edx, 0x0053C531
jmp edx
pop eax
inc eax
push eax
ret
}
}
8 changes: 2 additions & 6 deletions srvmgr.def
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,5 @@ imp_ExtDiplomacy @148
imp_GMNoLevelDown @149
imp_DropAll @150
imp_ScaleSoftcoreExperienceReward @151
fix_spell_duration_overflow_0053973E @201
fix_spell_duration_overflow_0053BFA1 @202
fix_spell_duration_overflow_0053C0E1 @203
fix_spell_duration_overflow_0053C21E @204
fix_spell_duration_overflow_0053C52A @205
fix_spell_duration_overflow @206
fix_spell_duration_overflow_0053973E @201
fix_spell_duration_overflow @202
1 change: 1 addition & 0 deletions srvmgr.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<ClCompile Include="scanrange.cpp" />
<ClCompile Include="scanrange_check.cpp" />
<ClCompile Include="shared.cpp" />
<ClCompile Include="spell_duration_fix.cpp" />
<ClCompile Include="srvmgr.cpp" />
<ClCompile Include="srvmgr_new.cpp" />
<ClCompile Include="unit_info.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions srvmgr.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
<ClCompile Include="python.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="spell_duration_fix.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="charcheck.h">
Expand Down

0 comments on commit b531f42

Please sign in to comment.