Changed the fix in commit 583105a to an option (#412)

This commit is contained in:
NovaRain
2021-11-06 22:44:14 +08:00
parent 163b9ed5d3
commit d4f011913c
4 changed files with 22 additions and 14 deletions
+5
View File
@@ -620,6 +620,11 @@ AttackComplexFix=0
;Note that enabling this option may cause unexpected results with some existing game scripts ;Note that enabling this option may cause unexpected results with some existing game scripts
CreateObjectSidFix=0 CreateObjectSidFix=0
;Set to 1 to make grave type containers in the open state run the 'use_p_proc' procedure of attached script when being used
;By default, using open graves does not run the 'use_p_proc' procedure of attached script like other containers
;Note that enabling this option will cause problems for many existing graves
GraveUseProcFix=0
;Set to 1 to fix the issue with the division operator treating negative integers as unsigned ;Set to 1 to fix the issue with the division operator treating negative integers as unsigned
;Note: To perform the unsigned integer division, use the new 'div' operator ;Note: To perform the unsigned integer division, use the new 'div' operator
DivisionOperatorFix=1 DivisionOperatorFix=1
+5 -5
View File
@@ -102,7 +102,7 @@ WRAP_WATCOM_FUNC0(void, display_stats)
WRAP_WATCOM_FUNC1(long, critter_kill_count_type, fo::GameObject*, critter) WRAP_WATCOM_FUNC1(long, critter_kill_count_type, fo::GameObject*, critter)
WRAP_WATCOM_FUNC1(void, EndLoad, fo::DbFile*, file) WRAP_WATCOM_FUNC1(void, EndLoad, fo::DbFile*, file)
// Execute script proc by internal proc number (from script's proc table, basically a sequential number of a procedure as defined in code, starting from 1) // Execute script proc by internal proc number (from script's proc table, basically a sequential number of a procedure as defined in code, starting from 1)
WRAP_WATCOM_FUNC2(void, executeProcedure, fo::Program*, sptr, long, procPosition) WRAP_WATCOM_FUNC2(void, executeProcedure, fo::Program*, sptr, long, procNum)
WRAP_WATCOM_FUNC1(long, folder_print_line, const char*, text) WRAP_WATCOM_FUNC1(long, folder_print_line, const char*, text)
WRAP_WATCOM_FUNC1(long, folder_print_seperator, const char*, text) WRAP_WATCOM_FUNC1(long, folder_print_seperator, const char*, text)
WRAP_WATCOM_FUNC1(const char*, findCurrentProc, fo::Program*, program) // Returns the name of current procedure by program pointer WRAP_WATCOM_FUNC1(const char*, findCurrentProc, fo::Program*, program) // Returns the name of current procedure by program pointer
@@ -265,12 +265,12 @@ WRAP_WATCOM_FUNC0(void, tile_refresh_display) // Redraws the whole screen
WRAP_WATCOM_FUNC2(void, tile_refresh_rect, fo::BoundRect*, boundRect, long, elevation) // Redraws the given rectangle on screen WRAP_WATCOM_FUNC2(void, tile_refresh_rect, fo::BoundRect*, boundRect, long, elevation) // Redraws the given rectangle on screen
WRAP_WATCOM_FUNC1(long, trait_level, long, traitID) WRAP_WATCOM_FUNC1(long, trait_level, long, traitID)
WRAP_WATCOM_FUNC6(long, win_add, long, x, long, y, long, width, long, height, long, bgColorIndex, long, flags) WRAP_WATCOM_FUNC6(long, win_add, long, x, long, y, long, width, long, height, long, bgColorIndex, long, flags)
WRAP_WATCOM_FUNC1(void, win_show, DWORD, winRef) WRAP_WATCOM_FUNC1(void, win_delete, DWORD, winRef)
WRAP_WATCOM_FUNC1(void, win_hide, DWORD, winRef)
WRAP_WATCOM_FUNC1(BYTE*, win_get_buf, DWORD, winRef)
WRAP_WATCOM_FUNC1(void, win_draw, DWORD, winRef) WRAP_WATCOM_FUNC1(void, win_draw, DWORD, winRef)
WRAP_WATCOM_FUNC2(void, win_draw_rect, DWORD, winRef, RECT*, rect) WRAP_WATCOM_FUNC2(void, win_draw_rect, DWORD, winRef, RECT*, rect)
WRAP_WATCOM_FUNC1(void, win_delete, DWORD, winRef) WRAP_WATCOM_FUNC1(BYTE*, win_get_buf, DWORD, winRef)
WRAP_WATCOM_FUNC1(void, win_hide, DWORD, winRef)
WRAP_WATCOM_FUNC1(void, win_show, DWORD, winRef)
WRAP_WATCOM_FUNC0(long, windowWidth) WRAP_WATCOM_FUNC0(long, windowWidth)
WRAP_WATCOM_FUNC1(void, wmCarUseGas, long, gasAmount) WRAP_WATCOM_FUNC1(void, wmCarUseGas, long, gasAmount)
WRAP_WATCOM_FUNC1(long, wmEvalTileNumForPlacement, long, tile) WRAP_WATCOM_FUNC1(long, wmEvalTileNumForPlacement, long, tile)
+4
View File
@@ -616,8 +616,12 @@ void Animations::init() {
MakeCall(0x419A17, art_alias_fid_hack); MakeCall(0x419A17, art_alias_fid_hack);
// Fix for grave type containers in the open state not executing the use_p_proc procedure // Fix for grave type containers in the open state not executing the use_p_proc procedure
if (IniReader::GetConfigInt("Misc", "GraveUseProcFix", 0) != 0) {
dlog("Applying use_p_proc fix for grave type containers.", DL_INIT);
HookCall(0x49CFAC, obj_use_container_hook); HookCall(0x49CFAC, obj_use_container_hook);
SafeWrite16(0x4122D9, 0x9090); // action_get_an_object_ SafeWrite16(0x4122D9, 0x9090); // action_get_an_object_
dlogr(" Done", DL_INIT);
}
} }
//void Animations::exit() { //void Animations::exit() {
+6 -7
View File
@@ -59,17 +59,16 @@ void DamageMod::DamageGlovz(fo::ComputeAttackResult &ctd, DWORD &accumulatedDama
long ammoY = fo::func::item_w_dam_div(ctd.weapon); // ammoY value (divisor) long ammoY = fo::func::item_w_dam_div(ctd.weapon); // ammoY value (divisor)
if (ammoY <= 0) ammoY = 1; if (ammoY <= 0) ammoY = 1;
long calcDT = armorDT;
if (armorDT > 0) calcDT = DivRound(armorDT, ammoY); // compare the armorDT value to 0
long ammoX = fo::func::item_w_dam_mult(ctd.weapon); // ammoX value long ammoX = fo::func::item_w_dam_mult(ctd.weapon); // ammoX value
if (ammoX <= 0) ammoX = 1; if (ammoX <= 0) ammoX = 1;
long ammoDRM = fo::func::item_w_dr_adjust(ctd.weapon); // ammoDRM value long ammoDRM = fo::func::item_w_dr_adjust(ctd.weapon); // ammoDRM value
if (ammoDRM > 0) ammoDRM = -ammoDRM; if (ammoDRM > 0) ammoDRM = -ammoDRM; // to negative
long calcDT = (armorDT > 0) ? DivRound(armorDT, ammoY) : armorDT;
long calcDR = armorDR; long calcDR = armorDR;
if (armorDR > 0) { // compare the armorDR value to 0 if (armorDR > 0) {
if (difficulty > 100) { // if the CD value is greater than 100 if (difficulty > 100) { // if the CD value is greater than 100
calcDR -= 20; // subtract 20 from the armorDR value calcDR -= 20; // subtract 20 from the armorDR value
} else if (difficulty < 100) { // if the CD value is less than 100 } else if (difficulty < 100) { // if the CD value is less than 100
@@ -77,7 +76,7 @@ void DamageMod::DamageGlovz(fo::ComputeAttackResult &ctd, DWORD &accumulatedDama
} }
calcDR += ammoDRM; // add the ammoDRM value to the armorDR value calcDR += ammoDRM; // add the ammoDRM value to the armorDR value
calcDR = DivRound(calcDR, ammoX); // goto divTwo calcDR = DivRound(calcDR, ammoX); // goto divTwo
if (calcDR >= 100) return; // if armorDR >= 100, stop damage calculation and exit if (calcDR >= 100) return; // if armorDR >= 100, skip damage calculation
} }
// start of damage calculation loop // start of damage calculation loop
@@ -143,7 +142,7 @@ void DamageMod::DamageYAAM(fo::ComputeAttackResult &ctd, DWORD &accumulatedDamag
if (calcDR < 0) { // Is DR >= 0? if (calcDR < 0) { // Is DR >= 0?
calcDR = 0; // If no, set DR = 0 calcDR = 0; // If no, set DR = 0
} else if (calcDR >= 100) { // Is DR >= 100? } else if (calcDR >= 100) { // Is DR >= 100?
return; // If yes, damage will be zero, so stop calculating and exit return; // If yes, damage will be zero, so stop calculating
} }
// Start of damage calculation loop // Start of damage calculation loop