mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Tweaked/fixed reg_anim_callback function
This commit is contained in:
@@ -219,7 +219,7 @@ Some additional reg_anim_* functions were introduced. They all work in the same
|
|||||||
- makes object change its direction to face given tile num or target object.
|
- makes object change its direction to face given tile num or target object.
|
||||||
|
|
||||||
> void reg_anim_callback(procedure proc)
|
> void reg_anim_callback(procedure proc)
|
||||||
- registers the given procedure and executes it after previously registered animations are finished.
|
- adds the given procedure to an animation sequence-list and executes it in the registered sequence.
|
||||||
|
|
||||||
> int metarule2_explosions(int arg1, int arg2, int arg3)
|
> int metarule2_explosions(int arg1, int arg2, int arg3)
|
||||||
was made as a dirty easy hack to allow dynamically change some explosion parameters (ranged attack). All changed parameters are reset to vanilla state automatically after each attack action. Following macros are available in sfall.h:
|
was made as a dirty easy hack to allow dynamically change some explosion parameters (ranged attack). All changed parameters are reset to vanilla state automatically after each attack action. Following macros are available in sfall.h:
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ struct TScript {
|
|||||||
long self_obj_id;
|
long self_obj_id;
|
||||||
long local_var_offset;
|
long local_var_offset;
|
||||||
long num_local_vars;
|
long num_local_vars;
|
||||||
long scr_return;
|
long return_value;
|
||||||
long action;
|
long action;
|
||||||
long fixed_param;
|
long fixed_param;
|
||||||
TGameObj *self_obj;
|
TGameObj *self_obj;
|
||||||
|
|||||||
+21
-10
@@ -893,11 +893,18 @@ static void __declspec(naked) sfall_ver_build() {
|
|||||||
|
|
||||||
|
|
||||||
//END OF SCRIPT FUNCTIONS
|
//END OF SCRIPT FUNCTIONS
|
||||||
static const DWORD scr_ptr_back = scr_ptr_ + 5;
|
|
||||||
static const DWORD scr_find_sid_from_program = scr_find_sid_from_program_ + 5;
|
|
||||||
static const DWORD scr_find_obj_from_program = scr_find_obj_from_program_ + 7;
|
|
||||||
|
|
||||||
static DWORD _stdcall FindSid(DWORD script) {
|
long __stdcall GetScriptReturnValue() {
|
||||||
|
return OverrideScriptStruct.return_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
long __stdcall GetResetScriptReturnValue() {
|
||||||
|
long val = GetScriptReturnValue();
|
||||||
|
OverrideScriptStruct.return_value = 0;
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD __stdcall FindSid(DWORD script) {
|
||||||
stdext::hash_map<DWORD, SelfOverrideObj>::iterator overrideIt = selfOverrideMap.find(script);
|
stdext::hash_map<DWORD, SelfOverrideObj>::iterator overrideIt = selfOverrideMap.find(script);
|
||||||
if (overrideIt != selfOverrideMap.end()) {
|
if (overrideIt != selfOverrideMap.end()) {
|
||||||
DWORD scriptId = overrideIt->second.object->scriptID; // script
|
DWORD scriptId = overrideIt->second.object->scriptID; // script
|
||||||
@@ -918,12 +925,18 @@ static DWORD _stdcall FindSid(DWORD script) {
|
|||||||
} else {
|
} else {
|
||||||
OverrideScriptStruct.fixed_param = 0;
|
OverrideScriptStruct.fixed_param = 0;
|
||||||
}
|
}
|
||||||
OverrideScriptStruct.target_obj = OverrideScriptStruct.self_obj = 0;
|
OverrideScriptStruct.target_obj = 0;
|
||||||
|
OverrideScriptStruct.self_obj = 0;
|
||||||
|
OverrideScriptStruct.return_value = 0;
|
||||||
return -2; // override struct
|
return -2; // override struct
|
||||||
}
|
}
|
||||||
return -1; // change nothing
|
return -1; // change nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const DWORD scr_ptr_back = scr_ptr_ + 5;
|
||||||
|
static const DWORD scr_find_sid_from_program = scr_find_sid_from_program_ + 5;
|
||||||
|
//static const DWORD scr_find_obj_from_program = scr_find_obj_from_program_ + 7;
|
||||||
|
|
||||||
static void __declspec(naked) FindSidHack() {
|
static void __declspec(naked) FindSidHack() {
|
||||||
__asm {
|
__asm {
|
||||||
push eax;
|
push eax;
|
||||||
@@ -1762,19 +1775,17 @@ void RunScriptProc(sScriptProgram* prog, const char* procName) {
|
|||||||
|
|
||||||
void RunScriptProc(sScriptProgram* prog, DWORD procId) {
|
void RunScriptProc(sScriptProgram* prog, DWORD procId) {
|
||||||
if (procId > 0 && procId <= SCRIPT_PROC_MAX) {
|
if (procId > 0 && procId <= SCRIPT_PROC_MAX) {
|
||||||
DWORD sptr = prog->ptr;
|
|
||||||
DWORD procNum = prog->procLookup[procId];
|
DWORD procNum = prog->procLookup[procId];
|
||||||
if (procNum != -1) {
|
if (procNum != -1) {
|
||||||
RunScriptProcByNum(sptr, procNum);
|
RunScriptProcByNum(prog->ptr, procNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int RunScriptStartProc(sScriptProgram* prog) {
|
int RunScriptStartProc(sScriptProgram* prog) {
|
||||||
DWORD sptr = prog->ptr;
|
|
||||||
DWORD procNum = prog->procLookup[start];
|
DWORD procNum = prog->procLookup[start];
|
||||||
if (procNum != -1) {
|
if (procNum != -1) {
|
||||||
RunScriptProcByNum(sptr, procNum);
|
RunScriptProcByNum(prog->ptr, procNum);
|
||||||
}
|
}
|
||||||
return procNum;
|
return procNum;
|
||||||
}
|
}
|
||||||
@@ -1907,7 +1918,7 @@ static long _stdcall HandleTimedEventScripts() {
|
|||||||
}
|
}
|
||||||
if (wereRunning) {
|
if (wereRunning) {
|
||||||
for (auto _it = timerEventScripts.cbegin(); _it != timerIt; _it++) {
|
for (auto _it = timerEventScripts.cbegin(); _it != timerIt; _it++) {
|
||||||
DevPrintf("\n[TimedEventScripts] delete events: %d", _it->time);
|
DevPrintf("\n[TimedEventScripts] delete event: %d", _it->time);
|
||||||
}
|
}
|
||||||
timerEventScripts.erase(timerEventScripts.cbegin(), timerIt);
|
timerEventScripts.erase(timerEventScripts.cbegin(), timerIt);
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-11
@@ -29,6 +29,13 @@ enum SfallDataType {
|
|||||||
DATATYPE_STR
|
DATATYPE_STR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SCRIPT_PROC_MAX (27)
|
||||||
|
typedef struct {
|
||||||
|
DWORD ptr;
|
||||||
|
DWORD procLookup[SCRIPT_PROC_MAX + 1];
|
||||||
|
char initialized;
|
||||||
|
} sScriptProgram;
|
||||||
|
|
||||||
#pragma pack(push, 8)
|
#pragma pack(push, 8)
|
||||||
struct sGlobalVar {
|
struct sGlobalVar {
|
||||||
__int64 id;
|
__int64 id;
|
||||||
@@ -37,13 +44,6 @@ struct sGlobalVar {
|
|||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#define SCRIPT_PROC_MAX (27)
|
|
||||||
typedef struct {
|
|
||||||
DWORD ptr;
|
|
||||||
DWORD procLookup[SCRIPT_PROC_MAX + 1];
|
|
||||||
char initialized;
|
|
||||||
} sScriptProgram;
|
|
||||||
|
|
||||||
void ScriptExtenderInit();
|
void ScriptExtenderInit();
|
||||||
bool _stdcall IsGameScript(const char* filename);
|
bool _stdcall IsGameScript(const char* filename);
|
||||||
void LoadGlobalScripts();
|
void LoadGlobalScripts();
|
||||||
@@ -54,10 +54,6 @@ void RunGlobalScripts3();
|
|||||||
void _stdcall RunGlobalScriptsAtProc(DWORD procId);
|
void _stdcall RunGlobalScriptsAtProc(DWORD procId);
|
||||||
void AfterAttackCleanup();
|
void AfterAttackCleanup();
|
||||||
|
|
||||||
void _stdcall AddTimerEventScripts(DWORD script, long time, long param);
|
|
||||||
void _stdcall RemoveTimerEventScripts(DWORD script, long param);
|
|
||||||
void _stdcall RemoveTimerEventScripts(DWORD script);
|
|
||||||
|
|
||||||
bool LoadGlobals(HANDLE h);
|
bool LoadGlobals(HANDLE h);
|
||||||
void SaveGlobals(HANDLE h);
|
void SaveGlobals(HANDLE h);
|
||||||
void ClearGlobals();
|
void ClearGlobals();
|
||||||
@@ -88,9 +84,16 @@ void RunScriptProc(sScriptProgram* prog, DWORD procId);
|
|||||||
|
|
||||||
int RunScriptStartProc(sScriptProgram* prog);
|
int RunScriptStartProc(sScriptProgram* prog);
|
||||||
|
|
||||||
|
long __stdcall GetScriptReturnValue();
|
||||||
|
long __stdcall GetResetScriptReturnValue();
|
||||||
|
|
||||||
void AddProgramToMap(sScriptProgram &prog);
|
void AddProgramToMap(sScriptProgram &prog);
|
||||||
sScriptProgram* GetGlobalScriptProgram(DWORD scriptPtr);
|
sScriptProgram* GetGlobalScriptProgram(DWORD scriptPtr);
|
||||||
|
|
||||||
|
void _stdcall AddTimerEventScripts(DWORD script, long time, long param);
|
||||||
|
void _stdcall RemoveTimerEventScripts(DWORD script, long param);
|
||||||
|
void _stdcall RemoveTimerEventScripts(DWORD script);
|
||||||
|
|
||||||
char* _stdcall mysubstr(char* str, int pos, int length);
|
char* _stdcall mysubstr(char* str, int pos, int length);
|
||||||
|
|
||||||
// variables
|
// variables
|
||||||
|
|||||||
@@ -171,6 +171,13 @@ end:
|
|||||||
_OP_END
|
_OP_END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void __declspec(naked) ExecuteCallback() {
|
||||||
|
__asm {
|
||||||
|
call executeProcedure_;
|
||||||
|
jmp GetResetScriptReturnValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void _stdcall op_reg_anim_callback2() {
|
static void _stdcall op_reg_anim_callback2() {
|
||||||
const ScriptValue &procArg = opHandler.arg(0);
|
const ScriptValue &procArg = opHandler.arg(0);
|
||||||
|
|
||||||
@@ -178,7 +185,7 @@ static void _stdcall op_reg_anim_callback2() {
|
|||||||
RegisterObjectCall(
|
RegisterObjectCall(
|
||||||
reinterpret_cast<long*>(opHandler.program()),
|
reinterpret_cast<long*>(opHandler.program()),
|
||||||
reinterpret_cast<long*>(procArg.rawValue()), // callback procedure
|
reinterpret_cast<long*>(procArg.rawValue()), // callback procedure
|
||||||
reinterpret_cast<void*>(executeProcedure_),
|
reinterpret_cast<void*>(ExecuteCallback),
|
||||||
-1
|
-1
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user