diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 558df8370..3478f1235 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -9158,7 +9158,13 @@ HOOK_ON_NAMETAGS_RENDER = 46 HOOK_ON_DJUI_THEME_CHANGED = 47 --- @type LuaHookedEventType -HOOK_MAX = 48 +HOOK_ON_GEO_PROCESS = 48 + +--- @type LuaHookedEventType +HOOK_BEFORE_GEO_PROCESS = 49 + +--- @type LuaHookedEventType +HOOK_MAX = 50 --- @class LuaModMenuElementType diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 59a198b2c..e6958ea75 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -826,6 +826,7 @@ --- @field public children GraphNode --- @field public extraFlags integer --- @field public flags integer +--- @field public hookProcess integer --- @field public next GraphNode --- @field public parent GraphNode --- @field public prev GraphNode diff --git a/docs/lua/constants.md b/docs/lua/constants.md index 3380e2253..e25a9f9a0 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -3335,7 +3335,9 @@ | HOOK_ON_MODS_LOADED | 45 | | HOOK_ON_NAMETAGS_RENDER | 46 | | HOOK_ON_DJUI_THEME_CHANGED | 47 | -| HOOK_MAX | 48 | +| HOOK_ON_GEO_PROCESS | 48 | +| HOOK_BEFORE_GEO_PROCESS | 49 | +| HOOK_MAX | 50 | ### [enum LuaModMenuElementType](#LuaModMenuElementType) | Identifier | Value | diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 2253e0ce4..5850c4788 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -1195,6 +1195,7 @@ | children | [GraphNode](structs.md#GraphNode) | read-only | | extraFlags | `integer` | | | flags | `integer` | | +| hookProcess | `integer` | | | next | [GraphNode](structs.md#GraphNode) | read-only | | parent | [GraphNode](structs.md#GraphNode) | read-only | | prev | [GraphNode](structs.md#GraphNode) | read-only | diff --git a/include/types.h b/include/types.h index 7860eae12..f567c0c50 100644 --- a/include/types.h +++ b/include/types.h @@ -130,6 +130,7 @@ struct GraphNode struct GraphNode *children; const void *georef; u8 extraFlags; + u8 hookProcess; }; struct AnimInfo diff --git a/src/engine/graph_node.c b/src/engine/graph_node.c index 46029905e..3cc0f1459 100644 --- a/src/engine/graph_node.c +++ b/src/engine/graph_node.c @@ -33,6 +33,7 @@ void init_scene_graph_node_links(struct GraphNode *graphNode, s32 type) { graphNode->parent = NULL; graphNode->children = NULL; graphNode->georef = NULL; + graphNode->hookProcess = 0; graphNode->_guard1 = GRAPH_NODE_GUARD; graphNode->_guard2 = GRAPH_NODE_GUARD; } diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index bc9ee763d..fb9d7808a 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -1538,6 +1538,7 @@ void geo_process_node_and_siblings(struct GraphNode *firstNode) { } if (curGraphNode->flags & GRAPH_RENDER_ACTIVE) { + if (curGraphNode->hookProcess) smlua_call_event_hooks_graph_node_and_int_param(HOOK_BEFORE_GEO_PROCESS, curGraphNode, curGraphNode->hookProcess); if (curGraphNode->flags & GRAPH_RENDER_CHILDREN_FIRST) { geo_try_process_children(curGraphNode); } else { @@ -1605,6 +1606,7 @@ void geo_process_node_and_siblings(struct GraphNode *firstNode) { break; } } + if (curGraphNode->hookProcess) smlua_call_event_hooks_graph_node_and_int_param(HOOK_ON_GEO_PROCESS, curGraphNode, curGraphNode->hookProcess); } else { if (curGraphNode && curGraphNode->type == GRAPH_NODE_TYPE_OBJECT) { ((struct GraphNodeObject *) curGraphNode)->throwMatrix = NULL; diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 3821f5838..909810171 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -61,14 +61,14 @@ static struct LuaObjectField sAnimationFields[LUA_ANIMATION_FIELD_COUNT] = { #define LUA_ANIMATION_TABLE_FIELD_COUNT 1 static struct LuaObjectField sAnimationTableFields[LUA_ANIMATION_TABLE_FIELD_COUNT] = { -// { "const anims", LOT_???, offsetof(struct AnimationTable, const anims), true, LOT_??? }, <--- UNIMPLEMENTED +// { "const anims", LVT_???, offsetof(struct AnimationTable, const anims), true, LOT_??? }, <--- UNIMPLEMENTED { "count", LVT_U32, offsetof(struct AnimationTable, count), true, LOT_NONE }, }; #define LUA_AREA_FIELD_COUNT 18 static struct LuaObjectField sAreaFields[LUA_AREA_FIELD_COUNT] = { { "camera", LVT_COBJECT_P, offsetof(struct Area, camera), false, LOT_CAMERA }, -// { "dialog", LOT_???, offsetof(struct Area, dialog), false, LOT_??? }, <--- UNIMPLEMENTED +// { "dialog", LVT_???, offsetof(struct Area, dialog), false, LOT_??? }, <--- UNIMPLEMENTED { "flags", LVT_S8, offsetof(struct Area, flags), false, LOT_NONE }, { "index", LVT_S8, offsetof(struct Area, index), false, LOT_NONE }, { "instantWarps", LVT_COBJECT_P, offsetof(struct Area, instantWarps), false, LOT_INSTANTWARP }, @@ -88,7 +88,7 @@ static struct LuaObjectField sAreaFields[LUA_AREA_FIELD_COUNT] = { // { "unk04", LVT_COBJECT_P, offsetof(struct Area, unk04), true, LOT_??? }, <--- UNIMPLEMENTED // { "unused28", LVT_COBJECT_P, offsetof(struct Area, unused28), false, LOT_??? }, <--- UNIMPLEMENTED { "warpNodes", LVT_COBJECT_P, offsetof(struct Area, warpNodes), true, LOT_OBJECTWARPNODE }, -// { "whirlpools", LOT_???, offsetof(struct Area, whirlpools), false, LOT_??? }, <--- UNIMPLEMENTED +// { "whirlpools", LVT_???, offsetof(struct Area, whirlpools), false, LOT_??? }, <--- UNIMPLEMENTED }; #define LUA_BEHAVIOR_DIALOGS_FIELD_COUNT 84 @@ -267,8 +267,8 @@ static struct LuaObjectField sCameraFields[LUA_CAMERA_FIELD_COUNT] = { { "cutscene", LVT_U8, offsetof(struct Camera, cutscene), false, LOT_NONE }, { "defMode", LVT_U8, offsetof(struct Camera, defMode), false, LOT_NONE }, { "doorStatus", LVT_U8, offsetof(struct Camera, doorStatus), false, LOT_NONE }, -// { "filler31", LOT_???, offsetof(struct Camera, filler31), false, LOT_??? }, <--- UNIMPLEMENTED -// { "filler3C", LOT_???, offsetof(struct Camera, filler3C), false, LOT_??? }, <--- UNIMPLEMENTED +// { "filler31", LVT_???, offsetof(struct Camera, filler31), false, LOT_??? }, <--- UNIMPLEMENTED +// { "filler3C", LVT_???, offsetof(struct Camera, filler3C), false, LOT_??? }, <--- UNIMPLEMENTED { "focus", LVT_COBJECT, offsetof(struct Camera, focus), true, LOT_VEC3F }, { "mode", LVT_U8, offsetof(struct Camera, mode), false, LOT_NONE }, { "mtx", LVT_COBJECT, offsetof(struct Camera, mtx), true, LOT_MAT4 }, @@ -543,7 +543,7 @@ static struct LuaObjectField sCharacterFields[LUA_CHARACTER_FIELD_COUNT] = { { "animWaterStarDance", LVT_S32, offsetof(struct Character, animWaterStarDance), true, LOT_NONE }, { "animWaterThrowObj", LVT_S32, offsetof(struct Character, animWaterThrowObj), true, LOT_NONE }, { "animWingCapFly", LVT_S32, offsetof(struct Character, animWingCapFly), true, LOT_NONE }, -// { "anims", LOT_???, offsetof(struct Character, anims), true, LOT_??? }, <--- UNIMPLEMENTED +// { "anims", LVT_???, offsetof(struct Character, anims), true, LOT_??? }, <--- UNIMPLEMENTED { "cameraHudHead", LVT_U32, offsetof(struct Character, cameraHudHead), true, LOT_NONE }, // { "capEnemyDecalGfx", LVT_???, offsetof(struct Character, capEnemyDecalGfx), true, LOT_??? }, <--- UNIMPLEMENTED // { "capEnemyGfx", LVT_???, offsetof(struct Character, capEnemyGfx), true, LOT_??? }, <--- UNIMPLEMENTED @@ -601,7 +601,7 @@ static struct LuaObjectField sCharacterFields[LUA_CHARACTER_FIELD_COUNT] = { { "soundYahoo", LVT_S32, offsetof(struct Character, soundYahoo), true, LOT_NONE }, { "soundYahooWahaYippee", LVT_S32, offsetof(struct Character, soundYahooWahaYippee), true, LOT_NONE }, { "soundYawning", LVT_S32, offsetof(struct Character, soundYawning), true, LOT_NONE }, -// { "sounds", LOT_???, offsetof(struct Character, sounds), true, LOT_??? }, <--- UNIMPLEMENTED +// { "sounds", LVT_???, offsetof(struct Character, sounds), true, LOT_??? }, <--- UNIMPLEMENTED { "torsoRotMult", LVT_F32, offsetof(struct Character, torsoRotMult), true, LOT_NONE }, { "type", LVT_S32, offsetof(struct Character, type), true, LOT_NONE }, }; @@ -748,7 +748,7 @@ static struct LuaObjectField sFloorGeometryFields[LUA_FLOOR_GEOMETRY_FIELD_COUNT { "normalY", LVT_F32, offsetof(struct FloorGeometry, normalY), false, LOT_NONE }, { "normalZ", LVT_F32, offsetof(struct FloorGeometry, normalZ), false, LOT_NONE }, { "originOffset", LVT_F32, offsetof(struct FloorGeometry, originOffset), false, LOT_NONE }, -// { "unused", LOT_???, offsetof(struct FloorGeometry, unused), false, LOT_??? }, <--- UNIMPLEMENTED +// { "unused", LVT_???, offsetof(struct FloorGeometry, unused), false, LOT_??? }, <--- UNIMPLEMENTED }; #define LUA_FN_GRAPH_NODE_FIELD_COUNT 1 @@ -940,16 +940,17 @@ static struct LuaObjectField sGlobalTexturesFields[LUA_GLOBAL_TEXTURES_FIELD_COU { "wario_head", LVT_COBJECT, offsetof(struct GlobalTextures, wario_head), true, LOT_TEXTUREINFO }, }; -#define LUA_GRAPH_NODE_FIELD_COUNT 7 +#define LUA_GRAPH_NODE_FIELD_COUNT 8 static struct LuaObjectField sGraphNodeFields[LUA_GRAPH_NODE_FIELD_COUNT] = { - { "children", LVT_COBJECT_P, offsetof(struct GraphNode, children), true, LOT_GRAPHNODE }, - { "extraFlags", LVT_U8, offsetof(struct GraphNode, extraFlags), false, LOT_NONE }, - { "flags", LVT_S16, offsetof(struct GraphNode, flags), false, LOT_NONE }, -// { "georef", LVT_???, offsetof(struct GraphNode, georef), true, LOT_??? }, <--- UNIMPLEMENTED - { "next", LVT_COBJECT_P, offsetof(struct GraphNode, next), true, LOT_GRAPHNODE }, - { "parent", LVT_COBJECT_P, offsetof(struct GraphNode, parent), true, LOT_GRAPHNODE }, - { "prev", LVT_COBJECT_P, offsetof(struct GraphNode, prev), true, LOT_GRAPHNODE }, - { "type", LVT_S16, offsetof(struct GraphNode, type), true, LOT_NONE }, + { "children", LVT_COBJECT_P, offsetof(struct GraphNode, children), true, LOT_GRAPHNODE }, + { "extraFlags", LVT_U8, offsetof(struct GraphNode, extraFlags), false, LOT_NONE }, + { "flags", LVT_S16, offsetof(struct GraphNode, flags), false, LOT_NONE }, +// { "georef", LVT_???, offsetof(struct GraphNode, georef), true, LOT_??? }, <--- UNIMPLEMENTED + { "hookProcess", LVT_U8, offsetof(struct GraphNode, hookProcess), false, LOT_NONE }, + { "next", LVT_COBJECT_P, offsetof(struct GraphNode, next), true, LOT_GRAPHNODE }, + { "parent", LVT_COBJECT_P, offsetof(struct GraphNode, parent), true, LOT_GRAPHNODE }, + { "prev", LVT_COBJECT_P, offsetof(struct GraphNode, prev), true, LOT_GRAPHNODE }, + { "type", LVT_S16, offsetof(struct GraphNode, type), true, LOT_NONE }, }; #define LUA_GRAPH_NODE_ANIMATED_PART_FIELD_COUNT 2 @@ -978,7 +979,7 @@ static struct LuaObjectField sGraphNodeBillboardFields[LUA_GRAPH_NODE_BILLBOARD_ #define LUA_GRAPH_NODE_CAMERA_FIELD_COUNT 10 static struct LuaObjectField sGraphNodeCameraFields[LUA_GRAPH_NODE_CAMERA_FIELD_COUNT] = { -// { "config", LOT_???, offsetof(struct GraphNodeCamera, config), false, LOT_??? }, <--- UNIMPLEMENTED +// { "config", LVT_???, offsetof(struct GraphNodeCamera, config), false, LOT_??? }, <--- UNIMPLEMENTED { "fnNode", LVT_COBJECT, offsetof(struct GraphNodeCamera, fnNode), true, LOT_FNGRAPHNODE }, { "focus", LVT_COBJECT, offsetof(struct GraphNodeCamera, focus), true, LOT_VEC3F }, { "matrixPtr", LVT_COBJECT_P, offsetof(struct GraphNodeCamera, matrixPtr), false, LOT_MAT4 }, @@ -995,7 +996,7 @@ static struct LuaObjectField sGraphNodeCameraFields[LUA_GRAPH_NODE_CAMERA_FIELD_ static struct LuaObjectField sGraphNodeCullingRadiusFields[LUA_GRAPH_NODE_CULLING_RADIUS_FIELD_COUNT] = { { "cullingRadius", LVT_S16, offsetof(struct GraphNodeCullingRadius, cullingRadius), false, LOT_NONE }, { "node", LVT_COBJECT, offsetof(struct GraphNodeCullingRadius, node), true, LOT_GRAPHNODE }, -// { "pad1E", LOT_???, offsetof(struct GraphNodeCullingRadius, pad1E), false, LOT_??? }, <--- UNIMPLEMENTED +// { "pad1E", LVT_???, offsetof(struct GraphNodeCullingRadius, pad1E), false, LOT_??? }, <--- UNIMPLEMENTED }; #define LUA_GRAPH_NODE_DISPLAY_LIST_FIELD_COUNT 1 @@ -1029,8 +1030,8 @@ static struct LuaObjectField sGraphNodeLevelOfDetailFields[LUA_GRAPH_NODE_LEVEL_ #define LUA_GRAPH_NODE_MASTER_LIST_FIELD_COUNT 1 static struct LuaObjectField sGraphNodeMasterListFields[LUA_GRAPH_NODE_MASTER_LIST_FIELD_COUNT] = { -// { "listHeads", LOT_???, offsetof(struct GraphNodeMasterList, listHeads), false, LOT_??? }, <--- UNIMPLEMENTED -// { "listTails", LOT_???, offsetof(struct GraphNodeMasterList, listTails), false, LOT_??? }, <--- UNIMPLEMENTED +// { "listHeads", LVT_???, offsetof(struct GraphNodeMasterList, listHeads), false, LOT_??? }, <--- UNIMPLEMENTED +// { "listTails", LVT_???, offsetof(struct GraphNodeMasterList, listTails), false, LOT_??? }, <--- UNIMPLEMENTED { "node", LVT_COBJECT, offsetof(struct GraphNodeMasterList, node), true, LOT_GRAPHNODE }, }; @@ -1130,7 +1131,7 @@ static struct LuaObjectField sGraphNodeSwitchCaseFields[LUA_GRAPH_NODE_SWITCH_CA static struct LuaObjectField sGraphNodeTranslationFields[LUA_GRAPH_NODE_TRANSLATION_FIELD_COUNT] = { // { "displayList", LVT_???, offsetof(struct GraphNodeTranslation, displayList), false, LOT_??? }, <--- UNIMPLEMENTED { "node", LVT_COBJECT, offsetof(struct GraphNodeTranslation, node), true, LOT_GRAPHNODE }, -// { "pad1E", LOT_???, offsetof(struct GraphNodeTranslation, pad1E), false, LOT_??? }, <--- UNIMPLEMENTED +// { "pad1E", LVT_???, offsetof(struct GraphNodeTranslation, pad1E), false, LOT_??? }, <--- UNIMPLEMENTED { "translation", LVT_COBJECT, offsetof(struct GraphNodeTranslation, translation), true, LOT_VEC3S }, }; @@ -1144,7 +1145,7 @@ static struct LuaObjectField sGraphNodeTranslationRotationFields[LUA_GRAPH_NODE_ #define LUA_GRAPH_NODE_802_A45_E4_FIELD_COUNT 6 static struct LuaObjectField sGraphNode_802A45E4Fields[LUA_GRAPH_NODE_802_A45_E4_FIELD_COUNT] = { -// { "0x00]", LOT_???, offsetof(struct GraphNode_802A45E4, 0x00]), false, LOT_??? }, <--- UNIMPLEMENTED +// { "0x00]", LVT_???, offsetof(struct GraphNode_802A45E4, 0x00]), false, LOT_??? }, <--- UNIMPLEMENTED { "unk18", LVT_S16, offsetof(struct GraphNode_802A45E4, unk18), false, LOT_NONE }, { "unk1A", LVT_S16, offsetof(struct GraphNode_802A45E4, unk1A), false, LOT_NONE }, { "unk1C", LVT_S16, offsetof(struct GraphNode_802A45E4, unk1C), false, LOT_NONE }, @@ -1182,9 +1183,9 @@ static struct LuaObjectField sLakituStateFields[LUA_LAKITU_STATE_FIELD_COUNT] = { "curFocus", LVT_COBJECT, offsetof(struct LakituState, curFocus), true, LOT_VEC3F }, { "curPos", LVT_COBJECT, offsetof(struct LakituState, curPos), true, LOT_VEC3F }, { "defMode", LVT_U8, offsetof(struct LakituState, defMode), false, LOT_NONE }, -// { "filler30", LOT_???, offsetof(struct LakituState, filler30), false, LOT_??? }, <--- UNIMPLEMENTED -// { "filler3E", LOT_???, offsetof(struct LakituState, filler3E), false, LOT_??? }, <--- UNIMPLEMENTED -// { "filler72", LOT_???, offsetof(struct LakituState, filler72), false, LOT_??? }, <--- UNIMPLEMENTED +// { "filler30", LVT_???, offsetof(struct LakituState, filler30), false, LOT_??? }, <--- UNIMPLEMENTED +// { "filler3E", LVT_???, offsetof(struct LakituState, filler3E), false, LOT_??? }, <--- UNIMPLEMENTED +// { "filler72", LVT_???, offsetof(struct LakituState, filler72), false, LOT_??? }, <--- UNIMPLEMENTED { "focHSpeed", LVT_F32, offsetof(struct LakituState, focHSpeed), false, LOT_NONE }, { "focVSpeed", LVT_F32, offsetof(struct LakituState, focVSpeed), false, LOT_NONE }, { "focus", LVT_COBJECT, offsetof(struct LakituState, focus), true, LOT_VEC3F }, @@ -1287,7 +1288,7 @@ static struct LuaObjectField sLinearTransitionPointFields[LUA_LINEAR_TRANSITION_ static struct LuaObjectField sMarioAnimationFields[LUA_MARIO_ANIMATION_FIELD_COUNT] = { // { "animDmaTable", LVT_COBJECT_P, offsetof(struct MarioAnimation, animDmaTable), true, LOT_??? }, <--- UNIMPLEMENTED { "currentAnimAddr", LVT_U8_P, offsetof(struct MarioAnimation, currentAnimAddr), true, LOT_POINTER }, -// { "padding", LOT_???, offsetof(struct MarioAnimation, padding), false, LOT_??? }, <--- UNIMPLEMENTED +// { "padding", LVT_???, offsetof(struct MarioAnimation, padding), false, LOT_??? }, <--- UNIMPLEMENTED { "targetAnim", LVT_COBJECT_P, offsetof(struct MarioAnimation, targetAnim), false, LOT_ANIMATION }, }; @@ -1298,7 +1299,7 @@ static struct LuaObjectField sMarioBodyStateFields[LUA_MARIO_BODY_STATE_FIELD_CO { "capState", LVT_S8, offsetof(struct MarioBodyState, capState), false, LOT_NONE }, { "eyeState", LVT_S8, offsetof(struct MarioBodyState, eyeState), false, LOT_NONE }, { "grabPos", LVT_S8, offsetof(struct MarioBodyState, grabPos), false, LOT_NONE }, -// { "handFootPos", LOT_???, offsetof(struct MarioBodyState, handFootPos), false, LOT_??? }, <--- UNIMPLEMENTED +// { "handFootPos", LVT_???, offsetof(struct MarioBodyState, handFootPos), false, LOT_??? }, <--- UNIMPLEMENTED { "handState", LVT_S8, offsetof(struct MarioBodyState, handState), false, LOT_NONE }, { "headAngle", LVT_COBJECT, offsetof(struct MarioBodyState, headAngle), true, LOT_VEC3S }, { "headPos", LVT_COBJECT, offsetof(struct MarioBodyState, headPos), true, LOT_VEC3F }, @@ -1445,7 +1446,7 @@ static struct LuaObjectField sModAudioSampleCopiesFields[LUA_MOD_AUDIO_SAMPLE_CO #define LUA_MOD_FILE_FIELD_COUNT 3 static struct LuaObjectField sModFileFields[LUA_MOD_FILE_FIELD_COUNT] = { { "cachedPath", LVT_STRING_P, offsetof(struct ModFile, cachedPath), true, LOT_NONE }, -// { "dataHash", LOT_???, offsetof(struct ModFile, dataHash), true, LOT_??? }, <--- UNIMPLEMENTED +// { "dataHash", LVT_???, offsetof(struct ModFile, dataHash), true, LOT_??? }, <--- UNIMPLEMENTED // { "fp", LVT_???, offsetof(struct ModFile, fp), true, LOT_??? }, <--- UNIMPLEMENTED { "relativePath", LVT_STRING, offsetof(struct ModFile, relativePath), true, LOT_NONE }, // { "size", LVT_???, offsetof(struct ModFile, size), true, LOT_??? }, <--- UNIMPLEMENTED @@ -1501,8 +1502,8 @@ static struct LuaObjectField sNetworkPlayerFields[LUA_NETWORK_PLAYER_FIELD_COUNT { "palette", LVT_COBJECT, offsetof(struct NetworkPlayer, palette), true, LOT_PLAYERPALETTE }, { "paletteIndex", LVT_U8, offsetof(struct NetworkPlayer, paletteIndex), true, LOT_NONE }, { "ping", LVT_U32, offsetof(struct NetworkPlayer, ping), true, LOT_NONE }, -// { "rxPacketHash", LOT_???, offsetof(struct NetworkPlayer, rxPacketHash), true, LOT_??? }, <--- UNIMPLEMENTED -// { "rxSeqIds", LOT_???, offsetof(struct NetworkPlayer, rxSeqIds), true, LOT_??? }, <--- UNIMPLEMENTED +// { "rxPacketHash", LVT_???, offsetof(struct NetworkPlayer, rxPacketHash), true, LOT_??? }, <--- UNIMPLEMENTED +// { "rxSeqIds", LVT_???, offsetof(struct NetworkPlayer, rxSeqIds), true, LOT_??? }, <--- UNIMPLEMENTED { "type", LVT_U8, offsetof(struct NetworkPlayer, type), true, LOT_NONE }, }; @@ -1516,10 +1517,10 @@ static struct LuaObjectField sObjectFields[LUA_OBJECT_FIELD_COUNT] = { { "areaTimerType", LVT_S32, offsetof(struct Object, areaTimerType), false, LOT_NONE }, { "behavior", LVT_BEHAVIORSCRIPT_P, offsetof(struct Object, behavior), true, LOT_POINTER }, { "bhvDelayTimer", LVT_S16, offsetof(struct Object, bhvDelayTimer), false, LOT_NONE }, -// { "bhvStack", LOT_???, offsetof(struct Object, bhvStack), false, LOT_??? }, <--- UNIMPLEMENTED +// { "bhvStack", LVT_???, offsetof(struct Object, bhvStack), false, LOT_??? }, <--- UNIMPLEMENTED { "bhvStackIndex", LVT_U32, offsetof(struct Object, bhvStackIndex), true, LOT_NONE }, { "collidedObjInteractTypes", LVT_U32, offsetof(struct Object, collidedObjInteractTypes), false, LOT_NONE }, -// { "collidedObjs", LOT_???, offsetof(struct Object, collidedObjs), false, LOT_??? }, <--- UNIMPLEMENTED +// { "collidedObjs", LVT_???, offsetof(struct Object, collidedObjs), false, LOT_??? }, <--- UNIMPLEMENTED { "collisionData", LVT_COLLISION_P, offsetof(struct Object, collisionData), false, LOT_POINTER }, { "coopFlags", LVT_U8, offsetof(struct Object, coopFlags), true, LOT_NONE }, { "ctx", LVT_U8, offsetof(struct Object, ctx), false, LOT_NONE }, @@ -2275,8 +2276,8 @@ static struct LuaObjectField sObjectFields[LUA_OBJECT_FIELD_COUNT] = { { "parentObj", LVT_COBJECT_P, offsetof(struct Object, parentObj), false, LOT_OBJECT }, { "platform", LVT_COBJECT_P, offsetof(struct Object, platform), false, LOT_OBJECT }, { "prevObj", LVT_COBJECT_P, offsetof(struct Object, prevObj), false, LOT_OBJECT }, -// { "ptrData", LOT_???, offsetof(struct Object, ptrData), false, LOT_??? }, <--- UNIMPLEMENTED -// { "rawData", LOT_???, offsetof(struct Object, rawData), false, LOT_??? }, <--- UNIMPLEMENTED +// { "ptrData", LVT_???, offsetof(struct Object, ptrData), false, LOT_??? }, <--- UNIMPLEMENTED +// { "rawData", LVT_???, offsetof(struct Object, rawData), false, LOT_??? }, <--- UNIMPLEMENTED // { "respawnInfo", LVT_???, offsetof(struct Object, respawnInfo), false, LOT_??? }, <--- UNIMPLEMENTED { "respawnInfoType", LVT_S16, offsetof(struct Object, respawnInfoType), true, LOT_NONE }, { "setHome", LVT_U8, offsetof(struct Object, setHome), false, LOT_NONE }, @@ -2351,7 +2352,7 @@ static struct LuaObjectField sPaintingFields[LUA_PAINTING_FIELD_COUNT] = { { "rippleTrigger", LVT_S8, offsetof(struct Painting, rippleTrigger), false, LOT_NONE }, { "rippleX", LVT_F32, offsetof(struct Painting, rippleX), false, LOT_NONE }, { "rippleY", LVT_F32, offsetof(struct Painting, rippleY), false, LOT_NONE }, -// { "ripples", LOT_???, offsetof(struct Painting, ripples), false, LOT_??? }, <--- UNIMPLEMENTED +// { "ripples", LVT_???, offsetof(struct Painting, ripples), false, LOT_??? }, <--- UNIMPLEMENTED { "size", LVT_F32, offsetof(struct Painting, size), false, LOT_NONE }, { "state", LVT_S8, offsetof(struct Painting, state), false, LOT_NONE }, // { "textureArray", LVT_???, offsetof(struct Painting, textureArray), true, LOT_??? }, <--- UNIMPLEMENTED @@ -2364,8 +2365,8 @@ static struct LuaObjectField sPaintingFields[LUA_PAINTING_FIELD_COUNT] = { #define LUA_PAINTING_MESH_VERTEX_FIELD_COUNT 0 static struct LuaObjectField sPaintingMeshVertexFields[LUA_PAINTING_MESH_VERTEX_FIELD_COUNT] = { -// { "norm", LOT_???, offsetof(struct PaintingMeshVertex, norm), false, LOT_??? }, <--- UNIMPLEMENTED -// { "pos", LOT_???, offsetof(struct PaintingMeshVertex, pos), false, LOT_??? }, <--- UNIMPLEMENTED +// { "norm", LVT_???, offsetof(struct PaintingMeshVertex, norm), false, LOT_??? }, <--- UNIMPLEMENTED +// { "pos", LVT_???, offsetof(struct PaintingMeshVertex, pos), false, LOT_??? }, <--- UNIMPLEMENTED }; #define LUA_PAINTING_VALUES_FIELD_COUNT 16 @@ -2426,7 +2427,7 @@ static struct LuaObjectField sPlayerGeometryFields[LUA_PLAYER_GEOMETRY_FIELD_COU #define LUA_PLAYER_PALETTE_FIELD_COUNT 0 static struct LuaObjectField sPlayerPaletteFields[LUA_PLAYER_PALETTE_FIELD_COUNT] = { -// { "parts", LOT_???, offsetof(struct PlayerPalette, parts), false, LOT_??? }, <--- UNIMPLEMENTED +// { "parts", LVT_???, offsetof(struct PlayerPalette, parts), false, LOT_??? }, <--- UNIMPLEMENTED }; #define LUA_RAY_INTERSECTION_INFO_FIELD_COUNT 2 @@ -2585,7 +2586,7 @@ static struct LuaObjectField sWallCollisionDataFields[LUA_WALL_COLLISION_DATA_FI { "offsetY", LVT_F32, offsetof(struct WallCollisionData, offsetY), false, LOT_NONE }, { "radius", LVT_F32, offsetof(struct WallCollisionData, radius), false, LOT_NONE }, { "unused", LVT_S16, offsetof(struct WallCollisionData, unused), false, LOT_NONE }, -// { "walls", LOT_???, offsetof(struct WallCollisionData, walls), false, LOT_??? }, <--- UNIMPLEMENTED +// { "walls", LVT_???, offsetof(struct WallCollisionData, walls), false, LOT_??? }, <--- UNIMPLEMENTED { "x", LVT_F32, offsetof(struct WallCollisionData, x), false, LOT_NONE }, { "y", LVT_F32, offsetof(struct WallCollisionData, y), false, LOT_NONE }, { "z", LVT_F32, offsetof(struct WallCollisionData, z), false, LOT_NONE }, diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index e6c1965a4..7ef77bea6 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -3202,7 +3202,9 @@ char gSmluaConstants[] = "" "HOOK_ON_MODS_LOADED = 45\n" "HOOK_ON_NAMETAGS_RENDER = 46\n" "HOOK_ON_DJUI_THEME_CHANGED = 47\n" -"HOOK_MAX = 48\n" +"HOOK_ON_GEO_PROCESS = 48\n" +"HOOK_BEFORE_GEO_PROCESS = 49\n" +"HOOK_MAX = 50\n" "ACTION_HOOK_EVERY_FRAME = 0\n" "ACTION_HOOK_GRAVITY = 1\n" "ACTION_HOOK_MAX = 2\n" diff --git a/src/pc/lua/smlua_hooks.c b/src/pc/lua/smlua_hooks.c index f61a2c822..a56c6f38c 100644 --- a/src/pc/lua/smlua_hooks.c +++ b/src/pc/lua/smlua_hooks.c @@ -1049,6 +1049,28 @@ void smlua_call_event_hooks_graph_node_object_and_int_param(enum LuaHookedEventT } } +void smlua_call_event_hooks_graph_node_and_int_param(enum LuaHookedEventType hookType, struct GraphNode* node, s32 param) { + lua_State* L = gLuaState; + if (L == NULL) { return; } + struct LuaHookedEvent* hook = &sHookedEvents[hookType]; + for (int i = 0; i < hook->count; i++) { + // push the callback onto the stack + lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]); + + // push graph node + smlua_push_object(L, LOT_GRAPHNODE, node); + + // push param + lua_pushinteger(L, param); + + // call the callback + if (0 != smlua_call_hook(L, 2, 0, 0, hook->mod[i])) { + LOG_LUA("Failed to call the callback: %u", hookType); + continue; + } + } +} + const char *smlua_call_event_hooks_int_ret_bool_and_string(enum LuaHookedEventType hookType, s32 param, bool* returnValue) { lua_State* L = gLuaState; if (L == NULL) { return NULL; } diff --git a/src/pc/lua/smlua_hooks.h b/src/pc/lua/smlua_hooks.h index 5edeea0d5..db46cc509 100644 --- a/src/pc/lua/smlua_hooks.h +++ b/src/pc/lua/smlua_hooks.h @@ -59,6 +59,8 @@ enum LuaHookedEventType { HOOK_ON_MODS_LOADED, HOOK_ON_NAMETAGS_RENDER, HOOK_ON_DJUI_THEME_CHANGED, + HOOK_ON_GEO_PROCESS, + HOOK_BEFORE_GEO_PROCESS, HOOK_MAX, }; @@ -111,6 +113,8 @@ static const char* LuaHookedEventTypeName[] = { "HOOK_ON_MODS_LOADED", "HOOK_ON_NAMETAGS_RENDER", "HOOK_ON_DJUI_THEME_CHANGED", + "HOOK_ON_GEO_PROCESS", + "HOOK_BEFORE_GEO_PROCESS", "HOOK_MAX" }; @@ -187,6 +191,7 @@ bool smlua_call_event_hooks_mario_param_and_int_ret_int(enum LuaHookedEventType bool smlua_call_event_hooks_mario_param_ret_float(enum LuaHookedEventType hookType, struct MarioState* m, f32* returnValue); bool smlua_call_event_hooks_mario_param_and_int_and_int_ret_int(enum LuaHookedEventType hookType, struct MarioState* m, s32 param, u32 args, s32* returnValue); void smlua_call_event_hooks_graph_node_object_and_int_param(enum LuaHookedEventType hookType, struct GraphNodeObject* node, s32 param); +void smlua_call_event_hooks_graph_node_and_int_param(enum LuaHookedEventType hookType, struct GraphNode* node, s32 param); void smlua_call_event_hooks_on_seq_load(enum LuaHookedEventType hookType, u32 player, u32 seqId, s32 loadAsync, s16* returnValue); const char *smlua_call_event_hooks_int_ret_bool_and_string(enum LuaHookedEventType hookType, s32 param, bool* returnValue); void smlua_call_event_hooks_string_param(enum LuaHookedEventType hookType, const char* string);