Misc code edits

This commit is contained in:
NovaRain
2021-10-22 00:23:58 +08:00
parent 43a8e84dee
commit 8d58e6e3bb
23 changed files with 42 additions and 38 deletions
+1 -1
View File
@@ -134,7 +134,7 @@ void SkillSetTags(long* tags, long num) {
} }
long GetItemType(fo::GameObject* item) { long GetItemType(fo::GameObject* item) {
return fo::util::GetProto(item->protoId)->item.type; return GetProto(item->protoId)->item.type;
} }
__declspec(noinline) fo::GameObject* GetItemPtrSlot(fo::GameObject* critter, fo::InvenType slot) { __declspec(noinline) fo::GameObject* GetItemPtrSlot(fo::GameObject* critter, fo::InvenType slot) {
+2 -1
View File
@@ -16,7 +16,7 @@
/* /*
For functions that have 3 or more arguments, it is preferable to use the fastcall calling convention For functions that have 3 or more arguments, it is preferable to use the fastcall calling convention
because the compiler builds the better/optimized code when calling the engine functions because the compiler can build a better/optimized code when calling the engine functions
*/ */
WRAP_WATCOM_FFUNC4(long, _word_wrap, const char*, text, int, maxWidth, DWORD*, buf, BYTE*, count) WRAP_WATCOM_FFUNC4(long, _word_wrap, const char*, text, int, maxWidth, DWORD*, buf, BYTE*, count)
WRAP_WATCOM_FFUNC4(fo::GameObject*, ai_best_weapon, fo::GameObject*, source, fo::GameObject*, prevItem, fo::GameObject*, checkItem, fo::GameObject*, target) WRAP_WATCOM_FFUNC4(fo::GameObject*, ai_best_weapon, fo::GameObject*, source, fo::GameObject*, prevItem, fo::GameObject*, checkItem, fo::GameObject*, target)
@@ -65,6 +65,7 @@ WRAP_WATCOM_FFUNC3(long, tile_coord, long, tile, long*, outX, long*, outY) // th
WRAP_WATCOM_FFUNC3(long, tile_num_in_direction, long, tile, long, rotation, long, distance) WRAP_WATCOM_FFUNC3(long, tile_num_in_direction, long, tile, long, rotation, long, distance)
WRAP_WATCOM_FFUNC8(void, trans_cscale, void*, fromBuff, long, width, long, height, long, fromPitch, void*, toBuff, long, toWidth, long, toHeight, long, toPitch) WRAP_WATCOM_FFUNC8(void, trans_cscale, void*, fromBuff, long, width, long, height, long, fromPitch, void*, toBuff, long, toWidth, long, toHeight, long, toPitch)
WRAP_WATCOM_FFUNC3(void, win_clip, fo::Window*, window, fo::RectList**, rects, void*, buffer) WRAP_WATCOM_FFUNC3(void, win_clip, fo::Window*, window, fo::RectList**, rects, void*, buffer)
WRAP_WATCOM_FFUNC6(void, win_print, long, winID, const char*, text, long, textWidth, long, xPos, long, yPos, long, colorFlags)
WRAP_WATCOM_FFUNC9(long, windowWrapLineWithSpacing, long, winID, const char*, text, long, width, long, height, long, x, long, y, long, color, long, alignment, long, lineSpacing) WRAP_WATCOM_FFUNC9(long, windowWrapLineWithSpacing, long, winID, const char*, text, long, width, long, height, long, x, long, y, long, color, long, alignment, long, lineSpacing)
WRAP_WATCOM_FFUNC4(void, wmInterfaceDrawSubTileRectFogged, BYTE*, surface, long, width, long, height, long, surfaceWidth) WRAP_WATCOM_FFUNC4(void, wmInterfaceDrawSubTileRectFogged, BYTE*, surface, long, width, long, height, long, surfaceWidth)
+1 -1
View File
@@ -1128,7 +1128,7 @@ struct AudioFile {
// aka PartyMemberRecoveryList // aka PartyMemberRecoveryList
struct ObjectListData { struct ObjectListData {
GameObject* object; GameObject* object;
fo::ScriptInstance* script; ScriptInstance* script;
long* localVarData; long* localVarData;
ObjectListData* nextSaveList; // _itemSaveListHead ObjectListData* nextSaveList; // _itemSaveListHead
}; };
+1
View File
@@ -169,6 +169,7 @@
#define FO_VAR_main_ctd 0x56D2B0 #define FO_VAR_main_ctd 0x56D2B0
#define FO_VAR_main_death_voiceover_done 0x614838 #define FO_VAR_main_death_voiceover_done 0x614838
#define FO_VAR_main_window 0x5194F0 #define FO_VAR_main_window 0x5194F0
#define FO_VAR_main_window_buf 0x5194F4
#define FO_VAR_map_elevation 0x519578 #define FO_VAR_map_elevation 0x519578
#define FO_VAR_map_global_vars 0x51956C #define FO_VAR_map_global_vars 0x51956C
#define FO_VAR_map_name 0x631D58 #define FO_VAR_map_name 0x631D58
+9 -9
View File
@@ -77,8 +77,8 @@ void __stdcall CombatAI::ai_check_drugs(fo::GameObject* source) {
break; break;
} }
if (game::Items::IsHealingItem(itemFind) && !game::Items::item_remove_mult(source, itemFind, 1, 0x4286F0)) { // HOOK_REMOVEINVENOBJ if (Items::IsHealingItem(itemFind) && !Items::item_remove_mult(source, itemFind, 1, 0x4286F0)) { // HOOK_REMOVEINVENOBJ
if (!game::Items::UseDrugItemFunc(source, itemFind)) { // HOOK_USEOBJON if (!Items::UseDrugItemFunc(source, itemFind)) { // HOOK_USEOBJON
drugWasUsed = true; drugWasUsed = true;
} }
@@ -127,8 +127,8 @@ void __stdcall CombatAI::ai_check_drugs(fo::GameObject* source) {
// if the preference counter is less than 3, then AI can use the drug // if the preference counter is less than 3, then AI can use the drug
if (counter < 3) { if (counter < 3) {
// if the item is NOT a healing drug // if the item is NOT a healing drug
if (!game::Items::IsHealingItem(item) && !game::Items::item_remove_mult(source, item, 1, 0x4286F0)) { // HOOK_REMOVEINVENOBJ if (!Items::IsHealingItem(item) && !Items::item_remove_mult(source, item, 1, 0x4286F0)) { // HOOK_REMOVEINVENOBJ
if (!game::Items::UseDrugItemFunc(source, item)) { // HOOK_USEOBJON if (!Items::UseDrugItemFunc(source, item)) { // HOOK_USEOBJON
drugWasUsed = true; drugWasUsed = true;
usedCount++; usedCount++;
} }
@@ -156,15 +156,15 @@ void __stdcall CombatAI::ai_check_drugs(fo::GameObject* source) {
// [FIX] Prevent the use of healing drugs when not necessary // [FIX] Prevent the use of healing drugs when not necessary
// noInvenDrug: is set to 2 that healing is required // noInvenDrug: is set to 2 that healing is required
if (lastItem && noInvenDrug != 2 && game::Items::IsHealingItem(lastItem)) { if (lastItem && noInvenDrug != 2 && Items::IsHealingItem(lastItem)) {
long maxHP = fo::func::stat_level(source, fo::Stat::STAT_max_hit_points); long maxHP = fo::func::stat_level(source, fo::Stat::STAT_max_hit_points);
if (10 + source->critter.health >= maxHP) { // quick check current HP if (10 + source->critter.health >= maxHP) { // quick check current HP
return; // exit: don't use healing item return; // exit: don't use healing item
} }
} }
if (lastItem && !game::Items::item_remove_mult(source, lastItem, 1, 0x4286F0)) { // HOOK_REMOVEINVENOBJ if (lastItem && !Items::item_remove_mult(source, lastItem, 1, 0x4286F0)) { // HOOK_REMOVEINVENOBJ
if (!game::Items::UseDrugItemFunc(source, lastItem)) lastItem = nullptr; // HOOK_USEOBJON if (!Items::UseDrugItemFunc(source, lastItem)) lastItem = nullptr; // HOOK_USEOBJON
source->critter.decreaseAP(aiUseItemAPCost); source->critter.decreaseAP(aiUseItemAPCost);
} }
@@ -172,7 +172,7 @@ void __stdcall CombatAI::ai_check_drugs(fo::GameObject* source) {
} }
} }
static void __declspec(naked) ai_check_drugs_hack() { static void __declspec(naked) ai_check_drugs_replacement() {
__asm { __asm {
push ecx; push ecx;
push eax; // source push eax; // source
@@ -195,7 +195,7 @@ static void __declspec(naked) ai_can_use_drug_hack() {
void CombatAI::init() { void CombatAI::init() {
// Replace ai_check_drugs_ function for code fixes and checking healing items // Replace ai_check_drugs_ function for code fixes and checking healing items
sf::MakeJump(fo::funcoffs::ai_check_drugs_, ai_check_drugs_hack); // 0x428480 sf::MakeJump(fo::funcoffs::ai_check_drugs_, ai_check_drugs_replacement); // 0x428480
// Change ai_can_use_drug_ function code to check healing items // Change ai_can_use_drug_ function code to check healing items
sf::MakeCall(0x429BDE, ai_can_use_drug_hack, 6); sf::MakeCall(0x429BDE, ai_can_use_drug_hack, 6);
+1 -1
View File
@@ -51,7 +51,7 @@ bool __fastcall Items::IsHealingItem(fo::GameObject* item) {
} }
bool Items::UseDrugItemFunc(fo::GameObject* source, fo::GameObject* item) { bool Items::UseDrugItemFunc(fo::GameObject* source, fo::GameObject* item) {
bool result = (game::Items::item_d_take_drug(source, item) == -1); // HOOK_USEOBJON bool result = (Items::item_d_take_drug(source, item) == -1); // HOOK_USEOBJON
if (result) { if (result) {
fo::func::item_add_force(source, item, 1); fo::func::item_add_force(source, item, 1);
} else { } else {
+2 -2
View File
@@ -107,7 +107,7 @@ int __stdcall Stats::trait_adjust_stat(DWORD statID) {
return result; return result;
} }
static void __declspec(naked) trait_adjust_stat_hack() { static void __declspec(naked) trait_adjust_stat_replacement() {
__asm { __asm {
push edx; push edx;
push ecx; push ecx;
@@ -121,7 +121,7 @@ static void __declspec(naked) trait_adjust_stat_hack() {
void Stats::init() { void Stats::init() {
// Replace trait_adjust_stat_ function // Replace trait_adjust_stat_ function
sf::MakeJump(fo::funcoffs::trait_adjust_stat_, trait_adjust_stat_hack); // 0x4B3C7C sf::MakeJump(fo::funcoffs::trait_adjust_stat_, trait_adjust_stat_replacement); // 0x4B3C7C
// Fix the carry weight penalty of the Small Frame trait not being applied to bonus Strength points // Fix the carry weight penalty of the Small Frame trait not being applied to bonus Strength points
smallFrameTraitFix = (sf::IniReader::GetConfigInt("Misc", "SmallFrameFix", 0) != 0); smallFrameTraitFix = (sf::IniReader::GetConfigInt("Misc", "SmallFrameFix", 0) != 0);
+1 -1
View File
@@ -20,7 +20,7 @@
#include "..\main.h" #include "..\main.h"
#include "..\FalloutEngine\Fallout2.h" #include "..\FalloutEngine\Fallout2.h"
#include "..\Version.h" #include "..\version.h"
#include "Credits.h" #include "Credits.h"
+1 -1
View File
@@ -134,7 +134,7 @@ static void RunEditorInternal(SOCKET &s) {
InternalSend(s, reinterpret_cast<void*>(fo::var::game_global_vars), 4 * numGlobals); InternalSend(s, reinterpret_cast<void*>(fo::var::game_global_vars), 4 * numGlobals);
InternalSend(s, reinterpret_cast<void*>(fo::var::map_global_vars), 4 * numMapVars); InternalSend(s, reinterpret_cast<void*>(fo::var::map_global_vars), 4 * numMapVars);
InternalSend(s, sglobals, sizeof(GlobalVar)*numSGlobals); InternalSend(s, sglobals, sizeof(GlobalVar) * numSGlobals);
InternalSend(s, arrays, numArrays * sizeof(sArray)); InternalSend(s, arrays, numArrays * sizeof(sArray));
for (int i = 0; i < numCritters; i++) { for (int i = 0; i < numCritters; i++) {
InternalSend(s, &vec[i][25], 4); InternalSend(s, &vec[i][25], 4);
+5 -5
View File
@@ -115,7 +115,7 @@ static IDirect3DSurface9* backBuffer;
static IDirect3DVertexBuffer9* vertexOrigRes; static IDirect3DVertexBuffer9* vertexOrigRes;
static IDirect3DVertexBuffer9* vertexSfallRes; static IDirect3DVertexBuffer9* vertexSfallRes;
static IDirect3DVertexBuffer9* vertexMovie; static IDirect3DVertexBuffer9* vertexMovie; // for AVI
static IDirect3DTexture9* paletteTex; static IDirect3DTexture9* paletteTex;
static IDirect3DTexture9* gpuPalette; static IDirect3DTexture9* gpuPalette;
@@ -1191,7 +1191,7 @@ static __declspec(naked) void game_init_hook() {
} }
} }
static __declspec(naked) void GNW95_SetPaletteEntries_hack() { static __declspec(naked) void GNW95_SetPaletteEntries_replacement() {
LPPALETTEENTRY palette; LPPALETTEENTRY palette;
DWORD startIndex; DWORD startIndex;
DWORD count; DWORD count;
@@ -1213,7 +1213,7 @@ static __declspec(naked) void GNW95_SetPaletteEntries_hack() {
} }
} }
static __declspec(naked) void GNW95_SetPalette_hack() { static __declspec(naked) void GNW95_SetPalette_replacement() {
LPPALETTEENTRY palette; LPPALETTEENTRY palette;
__asm { __asm {
push ecx; push ecx;
@@ -1268,8 +1268,8 @@ void Graphics::init() {
SafeWrite8(0x50FB6B, '2'); // Set call DirectDrawCreate2 SafeWrite8(0x50FB6B, '2'); // Set call DirectDrawCreate2
HookCall(0x44260C, game_init_hook); HookCall(0x44260C, game_init_hook);
MakeJump(fo::funcoffs::GNW95_SetPaletteEntries_ + 1, GNW95_SetPaletteEntries_hack); // 0x4CB311 MakeJump(fo::funcoffs::GNW95_SetPaletteEntries_ + 1, GNW95_SetPaletteEntries_replacement); // 0x4CB311
MakeJump(fo::funcoffs::GNW95_SetPalette_, GNW95_SetPalette_hack); // 0x4CB568 MakeJump(fo::funcoffs::GNW95_SetPalette_, GNW95_SetPalette_replacement); // 0x4CB568
if (hrpVersionValid) { if (hrpVersionValid) {
// Patch HRP to show the mouse cursor over the window title // Patch HRP to show the mouse cursor over the window title
+1 -1
View File
@@ -26,7 +26,7 @@
#include "PartyControl.h" #include "PartyControl.h"
#include "ScriptExtender.h" #include "ScriptExtender.h"
#include "..\Game\Inventory.h" #include "..\Game\inventory.h"
#include "HeroAppearance.h" #include "HeroAppearance.h"
+1 -1
View File
@@ -12,7 +12,7 @@ namespace sfall
// The hook is executed twice when entering the barter screen and after transaction: the first time is for the player; the second time is for NPC // The hook is executed twice when entering the barter screen and after transaction: the first time is for the player; the second time is for NPC
static DWORD __fastcall BarterPriceHook_Script(register fo::GameObject* source, register fo::GameObject* target, DWORD callAddr) { static DWORD __fastcall BarterPriceHook_Script(register fo::GameObject* source, register fo::GameObject* target, DWORD callAddr) {
bool barterIsParty = (fo::var::getInt(FO_VAR_dialog_target_is_party) != 0); bool barterIsParty = (fo::var::dialog_target_is_party != 0);
long computeCost = fo::func::barter_compute_value(source, target); long computeCost = fo::func::barter_compute_value(source, target);
BeginHook(); BeginHook();
-1
View File
@@ -20,7 +20,6 @@
#include "..\main.h" #include "..\main.h"
#include "..\FalloutEngine\Fallout2.h" #include "..\FalloutEngine\Fallout2.h"
#include "..\FalloutEngine\EngineUtils.h"
#include "..\SimplePatch.h" #include "..\SimplePatch.h"
#include "..\Utils.h" #include "..\Utils.h"
#include "Graphics.h" #include "Graphics.h"
+1 -1
View File
@@ -18,7 +18,7 @@
#include "..\main.h" #include "..\main.h"
#include "..\FalloutEngine\Fallout2.h" #include "..\FalloutEngine\Fallout2.h"
#include "..\Version.h" #include "..\version.h"
#include "KillCounter.h" #include "KillCounter.h"
+2 -2
View File
@@ -18,7 +18,7 @@
#include "..\main.h" #include "..\main.h"
#include "..\FalloutEngine\Fallout2.h" #include "..\FalloutEngine\Fallout2.h"
#include "..\Version.h" #include "..\version.h"
#include "MainMenu.h" #include "MainMenu.h"
@@ -108,7 +108,7 @@ void MainMenu::init() {
SafeWrite32(0x48175C, 460 + offset); SafeWrite32(0x48175C, 460 + offset);
} }
if (offset = IniReader::GetConfigInt("Misc", "MainMenuOffsetX", 0)) { if (offset = IniReader::GetConfigInt("Misc", "MainMenuOffsetX", 0)) {
SafeWrite32(0x48187C, 30 + offset); SafeWrite32(0x48187C, 30 + offset); // button
MainMenuTextOffset = offset; MainMenuTextOffset = offset;
} }
if (offset = IniReader::GetConfigInt("Misc", "MainMenuOffsetY", 0)) { if (offset = IniReader::GetConfigInt("Misc", "MainMenuOffsetY", 0)) {
+2
View File
@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#pragma once
#include "Module.h" #include "Module.h"
namespace sfall namespace sfall
+1 -1
View File
@@ -428,7 +428,7 @@ void __fastcall SetSelfObject(fo::Program* script, fo::GameObject* obj) {
} }
} }
// loads script from .int file into a sScriptProgram struct, filling script pointer and proc lookup table // loads script from .int file into a ScriptProgram struct, filling script pointer and proc lookup table
void InitScriptProgram(ScriptProgram &prog, const char* fileName, bool fullPath) { void InitScriptProgram(ScriptProgram &prog, const char* fileName, bool fullPath) {
fo::Program* scriptPtr = (fullPath) fo::Program* scriptPtr = (fullPath)
? fo::func::allocateProgram(fileName) ? fo::func::allocateProgram(fileName)
+1 -1
View File
@@ -95,7 +95,7 @@ long GetGlobalVarInternal(__int64 val);
void __fastcall SetSelfObject(fo::Program* script, fo::GameObject* obj); void __fastcall SetSelfObject(fo::Program* script, fo::GameObject* obj);
// loads script from .int file into a sScriptProgram struct, filling script pointer and proc lookup table // loads script from .int file into a ScriptProgram struct, filling script pointer and proc lookup table
// prog - reference to program structure // prog - reference to program structure
// fileName - the script file name without extension (if fullPath is false) or a full file path (if fullPath is true) // fileName - the script file name without extension (if fullPath is false) or a full file path (if fullPath is true)
// fullPath - controls how fileName is used (see above) // fullPath - controls how fileName is used (see above)
+1 -1
View File
@@ -277,7 +277,7 @@ static DWORD getBlockingFunc(BlockType type) {
case BlockType::BLOCKING_TYPE_SIGHT: case BlockType::BLOCKING_TYPE_SIGHT:
return fo::funcoffs::obj_sight_blocking_at_; // w/o calling hook return fo::funcoffs::obj_sight_blocking_at_; // w/o calling hook
//case 4: //case 4:
// return obj_scroll_blocking_at_; // return fo::funcoffs::obj_scroll_blocking_at_;
} }
} }
+1
View File
@@ -421,4 +421,5 @@ void Skills::init() {
void Skills::exit() { void Skills::exit() {
delete[] multipliers; delete[] multipliers;
} }
} }

Some files were not shown because too many files have changed in this diff Show More