mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed the script attached to an object not running upon object creation (#359)
Minor code style edits.
This commit is contained in:
@@ -346,13 +346,14 @@ To add proper check for ammo before shooting and proper calculation of number of
|
||||
Item arg0 - The weapon
|
||||
int arg1 - Number of bullets in burst or 1 for single shots
|
||||
int arg2 - The amount of ammo that will be consumed, calculated by the original ammo cost function (this is basically 2 for Super Cattle Prod and Mega Power Fist)
|
||||
NOTE: for hook type 2, this value is the ammo cost per round (default is always 1)
|
||||
int arg3 - Type of hook:
|
||||
0 - when subtracting ammo after single shot attack
|
||||
1 - when checking for "out of ammo" before attack
|
||||
2 - when calculating number of burst rounds
|
||||
3 - when subtracting ammo after burst attack
|
||||
|
||||
int ret0 - The new amount of ammo to be consumed, or ammo cost of each round for hook type 2 (set to 0 for unlimited ammo)
|
||||
int ret0 - The new amount of ammo to be consumed, or ammo cost per round for hook type 2 (set to 0 for unlimited ammo)
|
||||
|
||||
-------------------------------------------
|
||||
|
||||
|
||||
+1
-1
@@ -27,9 +27,9 @@ public:
|
||||
|
||||
static DWORD IniReader::modifiedIni;
|
||||
|
||||
static const char* IniReader::GetConfigFile();
|
||||
static void IniReader::SetDefaultConfigFile();
|
||||
static void IniReader::SetConfigFile(const char* iniFile);
|
||||
static const char* IniReader::GetConfigFile();
|
||||
|
||||
// Gets the integer value from the default config (i.e. ddraw.ini)
|
||||
static int IniReader::GetIntDefaultConfig(const char* section, const char* setting, int defaultValue);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "Modules\Module.h"
|
||||
|
||||
namespace sfall
|
||||
namespace sfall
|
||||
{
|
||||
|
||||
// Singleton for managing all of Sfall modules.
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
|
||||
void initAll();
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
void add()
|
||||
{
|
||||
_modules.emplace_back(new T());
|
||||
|
||||
@@ -1559,11 +1559,11 @@ end:
|
||||
|
||||
static void __declspec(naked) ai_combat_turn_run_hook() {
|
||||
__asm {
|
||||
call fo::funcoffs::combat_turn_run_;
|
||||
movzx dx, word ptr [esi + damageFlags]; // combat_data.results
|
||||
test dx, DAM_DEAD or DAM_KNOCKED_OUT or DAM_LOSE_TURN;
|
||||
jz end;
|
||||
mov [esi + movePoints], 0; // pobj.curr_mp (source reset ap)
|
||||
call fo::funcoffs::combat_turn_run_;
|
||||
mov edx, [esi + damageFlags]; // combat_data.results
|
||||
test edx, DAM_DEAD or DAM_KNOCKED_OUT or DAM_LOSE_TURN;
|
||||
jz end;
|
||||
mov [esi + movePoints], 0; // pobj.curr_mp (source reset ap)
|
||||
end:
|
||||
retn;
|
||||
}
|
||||
@@ -2881,6 +2881,18 @@ skip:
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) op_create_object_sid_hack() {
|
||||
__asm {
|
||||
mov ebx, [esp + 0x50 - 0x20 + 4]; // createObj
|
||||
mov edx, 1; // 'start' procedure
|
||||
mov eax, [ebx + scriptId];
|
||||
call fo::funcoffs::exec_script_proc_;
|
||||
mov edx, ebx;
|
||||
mov eax, esi;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
void BugFixes::init()
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
@@ -3635,6 +3647,9 @@ void BugFixes::init()
|
||||
// Fix for the "Leave" event procedure of the window region not being triggered when the cursor moves to a non-scripted window
|
||||
MakeJump(0x4B6C3B, checkAllRegions_hack);
|
||||
HookCall(0x4B6C13, checkAllRegions_hook);
|
||||
|
||||
// Fix for the script attached to an object not running upon object creation
|
||||
MakeCall(0x4551C0, op_create_object_sid_hack, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -740,8 +740,10 @@ static void EngineOptimizationPatches() {
|
||||
// Speed up display_msg script function
|
||||
HookCall(0x455404, op_display_msg_hook);
|
||||
|
||||
// Remove duplicate code from intface_redraw_ engine function
|
||||
BlockCall(0x45EBBF);
|
||||
// Remove redundant/duplicate code
|
||||
BlockCall(0x45EBBF); // intface_redraw_
|
||||
BlockCall(0x4A4859); // exec_script_proc_
|
||||
SafeMemSet(0x455189, CodeType::Nop, 11); // op_create_object_sid_
|
||||
|
||||
// Improve performance of the data conversion of script interpreter
|
||||
// mov eax, [edx+eax]; bswap eax; ret;
|
||||
|
||||
@@ -616,8 +616,7 @@ static const char* GetOverrideTerrainName(long x, long y) {
|
||||
|
||||
long subTileID = x + y * (fo::var::wmNumHorizontalTiles * 7);
|
||||
auto it = std::find_if(wmTerrainTypeNames.crbegin(), wmTerrainTypeNames.crend(),
|
||||
[=](const std::pair<long, std::string> &el)
|
||||
{ return el.first == subTileID; }
|
||||
[=](const std::pair<long, std::string> &el) { return el.first == subTileID; }
|
||||
);
|
||||
return (it != wmTerrainTypeNames.crend()) ? it->second.c_str() : nullptr;
|
||||
}
|
||||
|
||||
+2
-2
@@ -3,13 +3,13 @@
|
||||
namespace sfall
|
||||
{
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
T SimplePatch(DWORD addr, const char* iniSection, const char* iniKey, T defaultValue, T minValue = 0, T maxValue = INT_MAX)
|
||||
{
|
||||
return SimplePatch<T>(&addr, 1, iniSection, iniKey, defaultValue, minValue, maxValue);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
T SimplePatch(DWORD *addrs, int numAddrs, const char* iniSection, const char* iniKey, T defaultValue, T minValue = 0, T maxValue = INT_MAX)
|
||||
{
|
||||
T value;
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ namespace sfall
|
||||
|
||||
// splits a string by given delimiter
|
||||
// taken from: http://stackoverflow.com/a/236803/4331475
|
||||
template<typename T>
|
||||
template <typename T>
|
||||
void split(const std::string &s, char delim, T result, size_t limit = -1) {
|
||||
std::stringstream ss;
|
||||
ss.str(s);
|
||||
|
||||
+1
-2
@@ -47,8 +47,8 @@
|
||||
#include "Modules\ExtraSaveSlots.h"
|
||||
#include "Modules\FileSystem.h"
|
||||
#include "Modules\Graphics.h"
|
||||
#include "Modules\HookScripts.h"
|
||||
#include "Modules\HeroAppearance.h"
|
||||
#include "Modules\HookScripts.h"
|
||||
#include "Modules\Input.h"
|
||||
#include "Modules\Interface.h"
|
||||
#include "Modules\Inventory.h"
|
||||
@@ -80,7 +80,6 @@
|
||||
#include "Modules\Worldmap.h"
|
||||
|
||||
#include "CRC.h"
|
||||
#include "SimplePatch.h"
|
||||
#include "Logging.h"
|
||||
#include "ReplacementFuncs.h"
|
||||
#include "Version.h"
|
||||
|
||||
Reference in New Issue
Block a user