Reset Mario animations on server shutdown
Some checks failed
Build coop / build-linux (push) Has been cancelled
Build coop / build-steamos (push) Has been cancelled
Build coop / build-windows-opengl (push) Has been cancelled
Build coop / build-windows-directx (push) Has been cancelled
Build coop / build-macos-arm (push) Has been cancelled
Build coop / build-macos-intel (push) Has been cancelled

This commit is contained in:
PeachyPeachSM64 2025-08-14 00:49:09 +02:00
parent a2b4ac8f08
commit 7405ae7244
10 changed files with 36 additions and 5 deletions

View file

@ -132,7 +132,7 @@ override_disallowed_functions = {
"src/pc/djui/djui_hud_utils.h": [ "djui_hud_render_texture_raw", "djui_hud_render_texture_tile_raw" ],
"src/pc/lua/utils/smlua_level_utils.h": [ "smlua_level_util_reset" ],
"src/pc/lua/utils/smlua_text_utils.h": [ "smlua_text_utils_init", "smlua_text_utils_shutdown", "get_dialog_text_ascii", "smlua_text_utils_dialog_get_unmodified"],
"src/pc/lua/utils/smlua_anim_utils.h": [ "smlua_anim_util_reset", "smlua_anim_util_register_animation" ],
"src/pc/lua/utils/smlua_anim_utils.h": [ "smlua_anim_util_init", "smlua_anim_util_reset", "smlua_anim_util_register_animation" ],
"src/pc/lua/utils/smlua_gfx_utils.h": [ "gfx_allocate_internal", "vtx_allocate_internal", "gfx_get_length_no_sentinel" ],
"src/pc/network/lag_compensation.h": [ "lag_compensation_clear" ],
"src/game/first_person_cam.h": [ "first_person_update" ],

View file

@ -98,6 +98,7 @@ override_field_invisible = {
"GraphNodeRoot": ["unk15", "views"],
"FnGraphNode": [ "luaTokenIndex" ],
"Object": [ "firstSurface" ],
"Animation": [ "unusedBoneCount" ],
"ModAudio": [ "sound", "decoder", "buffer", "bufferSize", "sampleCopiesTail" ],
"DialogEntry": [ "str" ],
"ModFsFile": [ "data", "capacity" ],

View file

@ -22,7 +22,6 @@
--- @field public loopEnd integer
--- @field public loopStart integer
--- @field public startFrame integer
--- @field public unusedBoneCount integer
--- @field public values Pointer_integer
--- @field public valuesLength integer

View file

@ -161,7 +161,6 @@
| loopEnd | `integer` | |
| loopStart | `integer` | |
| startFrame | `integer` | |
| unusedBoneCount | `integer` | |
| values | `Pointer` <`integer`> | |
| valuesLength | `integer` | |

View file

@ -54,6 +54,8 @@ extern struct MarioAnimation D_80339D10[MAX_PLAYERS];
extern struct MarioAnimation gDemo;
extern u8 gMarioAnims[];
extern size_t gMarioAnimsSize;
extern u8 gDemoInputs[];
extern u16 frameBufferIndex;

View file

@ -337,6 +337,7 @@ void smlua_init(void) {
smlua_cobject_init_globals();
smlua_model_util_initialize();
smlua_anim_util_init();
// load scripts
mods_size_enforce(&gActiveMods);

View file

@ -178,7 +178,7 @@ static struct LuaObjectField sAnimInfoFields[LUA_ANIM_INFO_FIELD_COUNT] = {
{ "prevAnimPtr", LVT_COBJECT_P, offsetof(struct AnimInfo, prevAnimPtr), false, LOT_ANIMATION, 1, sizeof(struct Animation*) },
};
#define LUA_ANIMATION_FIELD_COUNT 11
#define LUA_ANIMATION_FIELD_COUNT 10
static struct LuaObjectField sAnimationFields[LUA_ANIMATION_FIELD_COUNT] = {
{ "animYTransDivisor", LVT_S16, offsetof(struct Animation, animYTransDivisor), false, LOT_NONE, 1, sizeof(s16) },
{ "flags", LVT_S16, offsetof(struct Animation, flags), false, LOT_NONE, 1, sizeof(s16) },
@ -188,7 +188,6 @@ static struct LuaObjectField sAnimationFields[LUA_ANIMATION_FIELD_COUNT] = {
{ "loopEnd", LVT_S16, offsetof(struct Animation, loopEnd), false, LOT_NONE, 1, sizeof(s16) },
{ "loopStart", LVT_S16, offsetof(struct Animation, loopStart), false, LOT_NONE, 1, sizeof(s16) },
{ "startFrame", LVT_S16, offsetof(struct Animation, startFrame), false, LOT_NONE, 1, sizeof(s16) },
{ "unusedBoneCount", LVT_S16, offsetof(struct Animation, unusedBoneCount), false, LOT_NONE, 1, sizeof(s16) },
{ "values", LVT_U16_P, offsetof(struct Animation, values), false, LOT_POINTER, 1, sizeof(u16*) },
{ "valuesLength", LVT_U32, offsetof(struct Animation, valuesLength), false, LOT_NONE, 1, sizeof(u32) },
};

View file

@ -88,6 +88,28 @@ struct GlobalObjectAnimations gGlobalObjectAnimations = {
.yoshi_seg5_anims_05024100 = (struct AnimationTable*) &yoshi_seg5_anims_05024100,
};
//////////////////////
// mario animations //
//////////////////////
static u8 *sMarioAnimsOrig = NULL;
static void smlua_anim_util_init_mario_animations() {
if (!sMarioAnimsOrig) {
sMarioAnimsOrig = malloc(gMarioAnimsSize);
if (!sMarioAnimsOrig) {
sys_fatal("Cannot initialize Mario animations");
}
memcpy(sMarioAnimsOrig, gMarioAnims, gMarioAnimsSize);
}
}
static void smlua_anim_util_reset_mario_animations() {
if (sMarioAnimsOrig) {
memcpy(gMarioAnims, sMarioAnimsOrig, gMarioAnimsSize);
}
}
struct Animation *get_mario_vanilla_animation(u16 index) {
static struct MarioAnimDmaRelatedThing *marioAnims = (struct MarioAnimDmaRelatedThing *) gMarioAnims;
@ -125,7 +147,13 @@ static struct CustomAnimation *get_custom_animation_node(const char *name) {
return NULL;
}
void smlua_anim_util_init(void) {
smlua_anim_util_init_mario_animations();
}
void smlua_anim_util_reset(void) {
smlua_anim_util_reset_mario_animations();
for (struct CustomAnimation *node = sCustomAnimationHead; node;) {
struct CustomAnimation *next = node->next;
if (node->name) {

View file

@ -69,6 +69,7 @@ extern struct GlobalObjectAnimations gGlobalObjectAnimations;
/* |description|Gets a vanilla mario Animation with `index`|descriptionEnd| */
struct Animation *get_mario_vanilla_animation(u16 index);
void smlua_anim_util_init();
void smlua_anim_util_reset();
void smlua_anim_util_register_animation(const char *name, s16 flags, s16 animYTransDivisor, s16 startFrame, s16 loopStart, s16 loopEnd, u16 *values, u32 valuesLength, u16 *index, u32 indexLength);
/* |description|Sets the animation of `obj` to the animation `name` corresponds to|descriptionEnd| */

View file

@ -179,6 +179,7 @@ try:
for s in structobj:
print(s)
print("};")
print("size_t gMarioAnimsSize = sizeof(gMarioAnims);")
for asset in asset_loads:
print(asset)