More custom bhv cleanup

This commit is contained in:
MysterD 2022-06-02 19:33:28 -07:00
parent b2bdf8859c
commit 091437c430
9 changed files with 42 additions and 27 deletions

View File

@ -343,6 +343,7 @@
--- @class GlobalObjectAnimations
--- @field public amp_seg8_anims_08004034 Pointer_ObjectAnimPointer
--- @field public birds_seg5_anims_050009E8 Pointer_ObjectAnimPointer
--- @field public blargg_seg5_anims_0500616C Pointer_ObjectAnimPointer
--- @field public blue_fish_seg3_anims_0301C2B0 Pointer_ObjectAnimPointer
--- @field public bobomb_seg8_anims_0802396C Pointer_ObjectAnimPointer
--- @field public bookend_seg5_anims_05002540 Pointer_ObjectAnimPointer
@ -357,6 +358,7 @@
--- @field public chilly_chief_seg6_anims_06003994 Pointer_ObjectAnimPointer
--- @field public chuckya_seg8_anims_0800C070 Pointer_ObjectAnimPointer
--- @field public clam_shell_seg5_anims_05001744 Pointer_ObjectAnimPointer
--- @field public cyan_fish_seg6_anims_0600E264 Pointer_ObjectAnimPointer
--- @field public door_seg3_anims_030156C0 Pointer_ObjectAnimPointer
--- @field public dorrie_seg6_anims_0600F638 Pointer_ObjectAnimPointer
--- @field public eyerok_seg5_anims_050116E4 Pointer_ObjectAnimPointer
@ -383,6 +385,7 @@
--- @field public skeeter_seg6_anims_06007DE0 Pointer_ObjectAnimPointer
--- @field public snowman_seg5_anims_0500D118 Pointer_ObjectAnimPointer
--- @field public spindrift_seg5_anims_05002D68 Pointer_ObjectAnimPointer
--- @field public spiny_egg_seg5_anims_050157E4 Pointer_ObjectAnimPointer
--- @field public spiny_seg5_anims_05016EAC Pointer_ObjectAnimPointer
--- @field public sushi_seg5_anims_0500AE54 Pointer_ObjectAnimPointer
--- @field public swoop_seg6_anims_060070D0 Pointer_ObjectAnimPointer
@ -421,6 +424,7 @@
--- @field public ddd_seg7_collision_submarine Pointer_Collision
--- @field public door_seg3_collision_0301CE78 Pointer_Collision
--- @field public dorrie_seg6_collision_0600F644 Pointer_Collision
--- @field public dorrie_seg6_collision_0600FBB8 Pointer_Collision
--- @field public exclamation_box_outline_seg8_collision_08025F78 Pointer_Collision
--- @field public hmc_seg7_collision_controllable_platform Pointer_Collision
--- @field public hmc_seg7_collision_controllable_platform_sub Pointer_Collision
@ -477,6 +481,7 @@
--- @field public ttm_seg7_collision_pitoune_2 Pointer_Collision
--- @field public ttm_seg7_collision_podium_warp Pointer_Collision
--- @field public ttm_seg7_collision_ukiki_cage Pointer_Collision
--- @field public unknown_seg8_collision_080262F8 Pointer_Collision
--- @field public warp_pipe_seg3_collision_03009AC8 Pointer_Collision
--- @field public wdw_seg7_collision_arrow_lift Pointer_Collision
--- @field public wdw_seg7_collision_express_elevator_platform Pointer_Collision

View File

@ -563,7 +563,7 @@ enum BehaviorId get_id_from_vanilla_behavior(const BehaviorScript* behavior) {
}
const BehaviorScript* get_behavior_from_id(enum BehaviorId id) {
const BehaviorScript* behavior = get_hooked_behavior_from_id(id, true);
const BehaviorScript* behavior = smlua_get_hooked_behavior_from_id(id, true);
if (behavior != NULL) { return behavior; }
if (id < 0 || id >= id_bhv_max_count) {

View File

@ -2547,7 +2547,7 @@ GfxData *DynOS_Bhv_LoadFromBinary(const SysPath &aFilename, const char *aBehavio
for (bool _Done = false; !_Done;) {
switch (ReadBytes<u8>(_File)) {
case DATA_TYPE_BEHAVIOR_SCRIPT: DynOS_Bhv_Load(_File, _GfxData); break;
default: _Done = true; break;
default: _Done = true; break;
}
}
fclose(_File);

View File

@ -85,7 +85,7 @@ const char *DynOS_Bhv_GetToken(BehaviorScript *bhvScript, u32 index) {
if (index >= gfxData->mLuaTokenList.Count()) {
return NULL;
}
return gfxData->mLuaTokenList[index].begin();
}
@ -96,9 +96,9 @@ void DynOS_Bhv_HookAllCustomBehaviors() {
auto &scriptName = _CustomBehaviorScripts[i].first;
auto &aGfxData = _CustomBehaviorScripts[i].second;
auto &script = aGfxData->mBehaviorScripts[aGfxData->mBehaviorScripts.Count() - 1]->mData;
// Theres currently no better place but to do this here.
if (hook_behavior(script, scriptName) == 0) {
if (smlua_hook_customn_bhv(script, scriptName) == 0) {
PrintError(" ERROR: Failed to add custom behavior '%s'!", scriptName);
}
}

View File

@ -553,6 +553,7 @@
| ----- | ---- | ------ |
| amp_seg8_anims_08004034 | `Pointer` <`ObjectAnimPointer`> | read-only |
| birds_seg5_anims_050009E8 | `Pointer` <`ObjectAnimPointer`> | read-only |
| blargg_seg5_anims_0500616C | `Pointer` <`ObjectAnimPointer`> | read-only |
| blue_fish_seg3_anims_0301C2B0 | `Pointer` <`ObjectAnimPointer`> | read-only |
| bobomb_seg8_anims_0802396C | `Pointer` <`ObjectAnimPointer`> | read-only |
| bookend_seg5_anims_05002540 | `Pointer` <`ObjectAnimPointer`> | read-only |
@ -567,6 +568,7 @@
| chilly_chief_seg6_anims_06003994 | `Pointer` <`ObjectAnimPointer`> | read-only |
| chuckya_seg8_anims_0800C070 | `Pointer` <`ObjectAnimPointer`> | read-only |
| clam_shell_seg5_anims_05001744 | `Pointer` <`ObjectAnimPointer`> | read-only |
| cyan_fish_seg6_anims_0600E264 | `Pointer` <`ObjectAnimPointer`> | read-only |
| door_seg3_anims_030156C0 | `Pointer` <`ObjectAnimPointer`> | read-only |
| dorrie_seg6_anims_0600F638 | `Pointer` <`ObjectAnimPointer`> | read-only |
| eyerok_seg5_anims_050116E4 | `Pointer` <`ObjectAnimPointer`> | read-only |
@ -593,6 +595,7 @@
| skeeter_seg6_anims_06007DE0 | `Pointer` <`ObjectAnimPointer`> | read-only |
| snowman_seg5_anims_0500D118 | `Pointer` <`ObjectAnimPointer`> | read-only |
| spindrift_seg5_anims_05002D68 | `Pointer` <`ObjectAnimPointer`> | read-only |
| spiny_egg_seg5_anims_050157E4 | `Pointer` <`ObjectAnimPointer`> | read-only |
| spiny_seg5_anims_05016EAC | `Pointer` <`ObjectAnimPointer`> | read-only |
| sushi_seg5_anims_0500AE54 | `Pointer` <`ObjectAnimPointer`> | read-only |
| swoop_seg6_anims_060070D0 | `Pointer` <`ObjectAnimPointer`> | read-only |
@ -638,6 +641,7 @@
| ddd_seg7_collision_submarine | `Pointer` <`Collision`> | |
| door_seg3_collision_0301CE78 | `Pointer` <`Collision`> | |
| dorrie_seg6_collision_0600F644 | `Pointer` <`Collision`> | |
| dorrie_seg6_collision_0600FBB8 | `Pointer` <`Collision`> | |
| exclamation_box_outline_seg8_collision_08025F78 | `Pointer` <`Collision`> | |
| hmc_seg7_collision_controllable_platform | `Pointer` <`Collision`> | |
| hmc_seg7_collision_controllable_platform_sub | `Pointer` <`Collision`> | |
@ -694,6 +698,7 @@
| ttm_seg7_collision_pitoune_2 | `Pointer` <`Collision`> | |
| ttm_seg7_collision_podium_warp | `Pointer` <`Collision`> | |
| ttm_seg7_collision_ukiki_cage | `Pointer` <`Collision`> | |
| unknown_seg8_collision_080262F8 | `Pointer` <`Collision`> | |
| warp_pipe_seg3_collision_03009AC8 | `Pointer` <`Collision`> | |
| wdw_seg7_collision_arrow_lift | `Pointer` <`Collision`> | |
| wdw_seg7_collision_express_elevator_platform | `Pointer` <`Collision`> | |

View File

@ -83,7 +83,7 @@ struct LinkedList *unused_try_allocate(struct LinkedList *destList,
*/
struct Object *try_allocate_object(struct ObjectNode *destList, struct ObjectNode *freeList) {
struct ObjectNode *nextObj = NULL;
if (destList == NULL || freeList == NULL) {
fprintf(stderr, "FATAL ERROR: Failed to try and allocate a object because either the destList %p or freeList %p was NULL!\n", destList, freeList);
return NULL;
@ -105,7 +105,7 @@ struct Object *try_allocate_object(struct ObjectNode *destList, struct ObjectNod
} else {
return NULL;
}
geo_remove_child(&nextObj->gfx.node);
geo_add_child(&gObjParentGraphNode, &nextObj->gfx.node);
@ -354,7 +354,7 @@ static void snap_object_to_floor(struct Object *obj) {
struct Object *create_object(const BehaviorScript *bhvScript) {
if (!bhvScript) { return NULL; }
s32 objListIndex = OBJ_LIST_DEFAULT;
bool luaBehavior = is_behavior_hooked_from_lua(bhvScript);
bool luaBehavior = smlua_is_behavior_hooked(bhvScript);
const BehaviorScript *behavior = smlua_override_behavior(bhvScript);
// If the first behavior script command is "begin <object list>", then
@ -362,7 +362,7 @@ struct Object *create_object(const BehaviorScript *bhvScript) {
if ((behavior[0] >> 24) == 0) {
objListIndex = (behavior[0] >> 16) & 0xFFFF;
}
if (objListIndex >= NUM_OBJ_LISTS) {
fprintf(stderr, "Failed to create object with non-existent object list index %i with behavior script %p.\n", objListIndex, bhvScript);
return NULL;

View File

@ -415,10 +415,11 @@ static struct LuaObjectField sFloorGeometryFields[LUA_FLOOR_GEOMETRY_FIELD_COUNT
// { "unused", LOT_???, offsetof(struct FloorGeometry, unused), false, LOT_??? }, <--- UNIMPLEMENTED
};
#define LUA_GLOBAL_OBJECT_ANIMATIONS_FIELD_COUNT 53
#define LUA_GLOBAL_OBJECT_ANIMATIONS_FIELD_COUNT 56
static struct LuaObjectField sGlobalObjectAnimationsFields[LUA_GLOBAL_OBJECT_ANIMATIONS_FIELD_COUNT] = {
{ "amp_seg8_anims_08004034", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, amp_seg8_anims_08004034), true, LOT_POINTER },
{ "birds_seg5_anims_050009E8", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, birds_seg5_anims_050009E8), true, LOT_POINTER },
{ "blargg_seg5_anims_0500616C", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, blargg_seg5_anims_0500616C), true, LOT_POINTER },
{ "blue_fish_seg3_anims_0301C2B0", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, blue_fish_seg3_anims_0301C2B0), true, LOT_POINTER },
{ "bobomb_seg8_anims_0802396C", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, bobomb_seg8_anims_0802396C), true, LOT_POINTER },
{ "bookend_seg5_anims_05002540", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, bookend_seg5_anims_05002540), true, LOT_POINTER },
@ -433,6 +434,7 @@ static struct LuaObjectField sGlobalObjectAnimationsFields[LUA_GLOBAL_OBJECT_ANI
{ "chilly_chief_seg6_anims_06003994", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, chilly_chief_seg6_anims_06003994), true, LOT_POINTER },
{ "chuckya_seg8_anims_0800C070", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, chuckya_seg8_anims_0800C070), true, LOT_POINTER },
{ "clam_shell_seg5_anims_05001744", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, clam_shell_seg5_anims_05001744), true, LOT_POINTER },
{ "cyan_fish_seg6_anims_0600E264", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, cyan_fish_seg6_anims_0600E264), true, LOT_POINTER },
{ "door_seg3_anims_030156C0", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, door_seg3_anims_030156C0), true, LOT_POINTER },
{ "dorrie_seg6_anims_0600F638", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, dorrie_seg6_anims_0600F638), true, LOT_POINTER },
{ "eyerok_seg5_anims_050116E4", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, eyerok_seg5_anims_050116E4), true, LOT_POINTER },
@ -459,6 +461,7 @@ static struct LuaObjectField sGlobalObjectAnimationsFields[LUA_GLOBAL_OBJECT_ANI
{ "skeeter_seg6_anims_06007DE0", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, skeeter_seg6_anims_06007DE0), true, LOT_POINTER },
{ "snowman_seg5_anims_0500D118", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, snowman_seg5_anims_0500D118), true, LOT_POINTER },
{ "spindrift_seg5_anims_05002D68", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, spindrift_seg5_anims_05002D68), true, LOT_POINTER },
{ "spiny_egg_seg5_anims_050157E4", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, spiny_egg_seg5_anims_050157E4), true, LOT_POINTER },
{ "spiny_seg5_anims_05016EAC", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, spiny_seg5_anims_05016EAC), true, LOT_POINTER },
{ "sushi_seg5_anims_0500AE54", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, sushi_seg5_anims_0500AE54), true, LOT_POINTER },
{ "swoop_seg6_anims_060070D0", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, swoop_seg6_anims_060070D0), true, LOT_POINTER },
@ -472,7 +475,7 @@ static struct LuaObjectField sGlobalObjectAnimationsFields[LUA_GLOBAL_OBJECT_ANI
{ "yoshi_seg5_anims_05024100", LVT_OBJECTANIMPOINTER_P, offsetof(struct GlobalObjectAnimations, yoshi_seg5_anims_05024100), true, LOT_POINTER },
};
#define LUA_GLOBAL_OBJECT_COLLISION_DATA_FIELD_COUNT 99
#define LUA_GLOBAL_OBJECT_COLLISION_DATA_FIELD_COUNT 101
static struct LuaObjectField sGlobalObjectCollisionDataFields[LUA_GLOBAL_OBJECT_COLLISION_DATA_FIELD_COUNT] = {
{ "bbh_seg7_collision_coffin", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, bbh_seg7_collision_coffin), false, LOT_POINTER },
{ "bbh_seg7_collision_haunted_bookshelf", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, bbh_seg7_collision_haunted_bookshelf), false, LOT_POINTER },
@ -499,6 +502,7 @@ static struct LuaObjectField sGlobalObjectCollisionDataFields[LUA_GLOBAL_OBJECT_
{ "ddd_seg7_collision_submarine", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, ddd_seg7_collision_submarine), false, LOT_POINTER },
{ "door_seg3_collision_0301CE78", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, door_seg3_collision_0301CE78), false, LOT_POINTER },
{ "dorrie_seg6_collision_0600F644", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, dorrie_seg6_collision_0600F644), false, LOT_POINTER },
{ "dorrie_seg6_collision_0600FBB8", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, dorrie_seg6_collision_0600FBB8), false, LOT_POINTER },
{ "exclamation_box_outline_seg8_collision_08025F78", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, exclamation_box_outline_seg8_collision_08025F78), false, LOT_POINTER },
{ "hmc_seg7_collision_controllable_platform", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, hmc_seg7_collision_controllable_platform), false, LOT_POINTER },
{ "hmc_seg7_collision_controllable_platform_sub", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, hmc_seg7_collision_controllable_platform_sub), false, LOT_POINTER },
@ -555,6 +559,7 @@ static struct LuaObjectField sGlobalObjectCollisionDataFields[LUA_GLOBAL_OBJECT_
{ "ttm_seg7_collision_pitoune_2", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, ttm_seg7_collision_pitoune_2), false, LOT_POINTER },
{ "ttm_seg7_collision_podium_warp", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, ttm_seg7_collision_podium_warp), false, LOT_POINTER },
{ "ttm_seg7_collision_ukiki_cage", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, ttm_seg7_collision_ukiki_cage), false, LOT_POINTER },
{ "unknown_seg8_collision_080262F8", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, unknown_seg8_collision_080262F8), false, LOT_POINTER },
{ "warp_pipe_seg3_collision_03009AC8", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, warp_pipe_seg3_collision_03009AC8), false, LOT_POINTER },
{ "wdw_seg7_collision_arrow_lift", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, wdw_seg7_collision_arrow_lift), false, LOT_POINTER },
{ "wdw_seg7_collision_express_elevator_platform", LVT_COLLISION_P, offsetof(struct GlobalObjectCollisionData, wdw_seg7_collision_express_elevator_platform), false, LOT_POINTER },

View File

@ -649,15 +649,15 @@ const BehaviorScript* smlua_override_behavior(const BehaviorScript *behavior) {
if (L == NULL) { return behavior; }
enum BehaviorId id = get_id_from_behavior(behavior);
const BehaviorScript *hookedBehavior = get_hooked_behavior_from_id(id, false);
const BehaviorScript *hookedBehavior = smlua_get_hooked_behavior_from_id(id, false);
if (hookedBehavior != NULL) { return hookedBehavior; }
return behavior + *sBehaviorOffset;
}
const BehaviorScript* get_hooked_behavior_from_id(enum BehaviorId id, bool returnOriginal) {
const BehaviorScript* smlua_get_hooked_behavior_from_id(enum BehaviorId id, bool returnOriginal) {
lua_State *L = gLuaState;
if (L == NULL) { return NULL; }
for (int i = 0; i < sHookedBehaviorsCount; i++) {
struct LuaHookedBehavior* hooked = &sHookedBehaviors[i];
if (hooked->behaviorId != id && hooked->overrideId != id) { continue; }
@ -667,29 +667,29 @@ const BehaviorScript* get_hooked_behavior_from_id(enum BehaviorId id, bool retur
return NULL;
}
bool is_behavior_hooked_from_lua(const BehaviorScript *behavior) {
bool smlua_is_behavior_hooked(const BehaviorScript *behavior) {
lua_State *L = gLuaState;
if (L == NULL) { return false; }
enum BehaviorId id = get_id_from_behavior(behavior);
for (int i = 0; i < sHookedBehaviorsCount; i++) {
struct LuaHookedBehavior *hooked = &sHookedBehaviors[i];
if (hooked->behaviorId != id && hooked->overrideId != id) { continue; }
return hooked->luaBehavior;
}
return false;
}
int hook_behavior(BehaviorScript *bhvScript, const char *bhvName) {
int smlua_hook_customn_bhv(BehaviorScript *bhvScript, const char *bhvName) {
if (sHookedBehaviorsCount >= MAX_HOOKED_BEHAVIORS) {
LOG_ERROR("Hooked behaviors exceeded maximum references!");
return 0;
}
u32 originalBehaviorId = get_id_from_behavior(bhvScript);
u8 newBehavior = originalBehaviorId >= id_bhv_max_count;
struct LuaHookedBehavior *hooked = &sHookedBehaviors[sHookedBehaviorsCount];
u16 customBehaviorId = (sHookedBehaviorsCount & 0xFFFF) | LUA_BEHAVIOR_FLAG;
hooked->behavior = bhvScript;
@ -705,7 +705,7 @@ int hook_behavior(BehaviorScript *bhvScript, const char *bhvName) {
hooked->mod = gLuaActiveMod;
sHookedBehaviorsCount++;
// We want to push the behavior into the global LUA state. So mods can access it.
// It's also used for some things that would normally access a LUA behavior instead.
lua_State* L = gLuaState;
@ -713,7 +713,7 @@ int hook_behavior(BehaviorScript *bhvScript, const char *bhvName) {
lua_pushinteger(L, customBehaviorId);
lua_setglobal(L, bhvName);
}
return 1;
}
@ -823,7 +823,7 @@ bool smlua_call_behavior_hook(const BehaviorScript** behavior, struct Object* ob
if (!before && hooked->replace) {
return false;
}
// This behavior doesn't call it's LUA functions in this manner. It actually uses the normal behavior
// system.
if (!hooked->luaBehavior) {
@ -1074,7 +1074,7 @@ void smlua_clear_hooks(void) {
for (int i = 0; i < sHookedBehaviorsCount; i++) {
struct LuaHookedBehavior* hooked = &sHookedBehaviors[i];
// If this is NULL. We can't do anything with it.
if (hooked->behavior != NULL) {
// If it's a LUA made behavior, The behavior is allocated so reset and free it.

View File

@ -66,7 +66,7 @@ static const char* LuaHookedEventTypeName[] = {
extern u32 gLuaMarioActionIndex;
int hook_behavior(BehaviorScript *bhvScript, const char *bhvName);
int smlua_hook_customn_bhv(BehaviorScript *bhvScript, const char *bhvName);
void smlua_call_event_hooks(enum LuaHookedEventType hookType);
void smlua_call_event_hooks_bool_param(enum LuaHookedEventType hookType, bool value);
@ -84,8 +84,8 @@ void smlua_call_event_hooks_value_param(enum LuaHookedEventType hookType, int mo
enum BehaviorId smlua_get_original_behavior_id(const BehaviorScript* behavior);
const BehaviorScript* smlua_override_behavior(const BehaviorScript* behavior);
const BehaviorScript* get_hooked_behavior_from_id(enum BehaviorId id, bool returnOriginal);
bool is_behavior_hooked_from_lua(const BehaviorScript *behavior);
const BehaviorScript* smlua_get_hooked_behavior_from_id(enum BehaviorId id, bool returnOriginal);
bool smlua_is_behavior_hooked(const BehaviorScript *behavior);
bool smlua_call_behavior_hook(const BehaviorScript** behavior, struct Object* object, bool before);
int smlua_call_hook(lua_State* L, int nargs, int nresults, int errfunc, struct Mod* activeMod);