From 971ddc00cdd1ca509738f1e0d95ad7f09e71fca4 Mon Sep 17 00:00:00 2001 From: Agent X <44549182+AgentXLP@users.noreply.github.com> Date: Wed, 26 Jun 2024 18:38:08 -0400 Subject: [PATCH] Remove legacy struct fields, fix a function name --- autogen/convert_structs.py | 5 +- autogen/lua_definitions/functions.lua | 2 +- autogen/lua_definitions/structs.lua | 4 -- docs/lua/functions-4.md | 6 +-- docs/lua/functions.md | 2 +- src/pc/lua/smlua_cobject_autogen.c | 68 +++++++++++++-------------- src/pc/lua/smlua_functions.c | 4 +- src/pc/lua/smlua_functions_autogen.c | 10 ++-- src/pc/lua/smlua_hooks.c | 2 +- src/pc/lua/smlua_sync_table.c | 10 ++-- src/pc/network/network.c | 3 -- src/pc/network/network.h | 1 - src/pc/network/network_player.c | 2 +- src/pc/network/network_player.h | 7 +-- 14 files changed, 53 insertions(+), 73 deletions(-) diff --git a/autogen/convert_structs.py b/autogen/convert_structs.py index 354ef9cd..836d7266 100644 --- a/autogen/convert_structs.py +++ b/autogen/convert_structs.py @@ -71,8 +71,7 @@ override_field_types = { override_field_mutable = { "NetworkPlayer": [ "overrideModelIndex", - "overridePalette", - "overridePaletteIndex", + "overridePalette" ], "Animation": [ "values", @@ -89,8 +88,6 @@ override_field_invisible = { } override_field_deprecated = { - "ServerSettings": [ "enableCheats" ], - "NetworkPlayer": [ "paletteIndex", "overridePaletteIndex", "overridePaletteIndexLp" ] } override_field_immutable = { diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 0c114a2d..0e6df384 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -5413,7 +5413,7 @@ function network_player_is_override_palette_same(np) end --- @param np NetworkPlayer -function network_player_reset_override_palette_color(np) +function network_player_reset_override_palette(np) -- ... end diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index b6438629..e360b92a 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -1123,10 +1123,7 @@ --- @field public onRxSeqId integer --- @field public overrideModelIndex integer --- @field public overridePalette PlayerPalette ---- @field public overridePaletteIndex integer ---- @field public overridePaletteIndexLp integer --- @field public palette PlayerPalette ---- @field public paletteIndex integer --- @field public ping integer --- @field public type integer @@ -2012,7 +2009,6 @@ --- @class ServerSettings --- @field public bouncyLevelBounds BouncyLevelBounds --- @field public bubbleDeath integer ---- @field public enableCheats integer --- @field public enablePlayerList integer --- @field public enablePlayersInLevelDisplay integer --- @field public headlessServer integer diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index 077f9b16..c165bdc4 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -1377,10 +1377,10 @@
-## [network_player_reset_override_palette_color](#network_player_reset_override_palette_color) +## [network_player_reset_override_palette](#network_player_reset_override_palette) ### Lua Example -`network_player_reset_override_palette_color(np)` +`network_player_reset_override_palette(np)` ### Parameters | Field | Type | @@ -1391,7 +1391,7 @@ - None ### C Prototype -`void network_player_reset_override_palette_color(struct NetworkPlayer *np);` +`void network_player_reset_override_palette(struct NetworkPlayer *np);` [:arrow_up_small:](#) diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 88fbc64c..4560b450 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1201,7 +1201,7 @@ - [network_player_get_override_palette_color_channel](functions-4.md#network_player_get_override_palette_color_channel) - [network_player_get_palette_color_channel](functions-4.md#network_player_get_palette_color_channel) - [network_player_is_override_palette_same](functions-4.md#network_player_is_override_palette_same) - - [network_player_reset_override_palette_color](functions-4.md#network_player_reset_override_palette_color) + - [network_player_reset_override_palette](functions-4.md#network_player_reset_override_palette) - [network_player_set_description](functions-4.md#network_player_set_description) - [network_player_set_override_palette_color](functions-4.md#network_player_set_override_palette_color) diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 94df0bc2..74efa454 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -1245,41 +1245,38 @@ static struct LuaObjectField sNametagsSettingsFields[LUA_NAMETAGS_SETTINGS_FIELD { "showSelfTag", LVT_BOOL, offsetof(struct NametagsSettings, showSelfTag), false, LOT_NONE }, }; -#define LUA_NETWORK_PLAYER_FIELD_COUNT 31 +#define LUA_NETWORK_PLAYER_FIELD_COUNT 28 static struct LuaObjectField sNetworkPlayerFields[LUA_NETWORK_PLAYER_FIELD_COUNT] = { - { "connected", LVT_BOOL, offsetof(struct NetworkPlayer, connected), true, LOT_NONE }, - { "currActNum", LVT_S16, offsetof(struct NetworkPlayer, currActNum), true, LOT_NONE }, - { "currAreaIndex", LVT_S16, offsetof(struct NetworkPlayer, currAreaIndex), true, LOT_NONE }, - { "currAreaSyncValid", LVT_BOOL, offsetof(struct NetworkPlayer, currAreaSyncValid), true, LOT_NONE }, - { "currCourseNum", LVT_S16, offsetof(struct NetworkPlayer, currCourseNum), true, LOT_NONE }, - { "currLevelAreaSeqId", LVT_U16, offsetof(struct NetworkPlayer, currLevelAreaSeqId), true, LOT_NONE }, - { "currLevelNum", LVT_S16, offsetof(struct NetworkPlayer, currLevelNum), true, LOT_NONE }, - { "currLevelSyncValid", LVT_BOOL, offsetof(struct NetworkPlayer, currLevelSyncValid), true, LOT_NONE }, - { "currPositionValid", LVT_BOOL, offsetof(struct NetworkPlayer, currPositionValid), true, LOT_NONE }, - { "description", LVT_STRING, offsetof(struct NetworkPlayer, description), true, LOT_NONE }, - { "descriptionA", LVT_U8, offsetof(struct NetworkPlayer, descriptionA), true, LOT_NONE }, - { "descriptionB", LVT_U8, offsetof(struct NetworkPlayer, descriptionB), true, LOT_NONE }, - { "descriptionG", LVT_U8, offsetof(struct NetworkPlayer, descriptionG), true, LOT_NONE }, - { "descriptionR", LVT_U8, offsetof(struct NetworkPlayer, descriptionR), true, LOT_NONE }, - { "fadeOpacity", LVT_U8, offsetof(struct NetworkPlayer, fadeOpacity), true, LOT_NONE }, - { "globalIndex", LVT_U8, offsetof(struct NetworkPlayer, globalIndex), true, LOT_NONE }, - { "lastPingSent", LVT_F32, offsetof(struct NetworkPlayer, lastPingSent), true, LOT_NONE }, - { "lastReceived", LVT_F32, offsetof(struct NetworkPlayer, lastReceived), true, LOT_NONE }, - { "lastSent", LVT_F32, offsetof(struct NetworkPlayer, lastSent), true, LOT_NONE }, - { "localIndex", LVT_U8, offsetof(struct NetworkPlayer, localIndex), true, LOT_NONE }, - { "modelIndex", LVT_U8, offsetof(struct NetworkPlayer, modelIndex), true, LOT_NONE }, - { "name", LVT_STRING, offsetof(struct NetworkPlayer, name), true, LOT_NONE }, - { "onRxSeqId", LVT_U8, offsetof(struct NetworkPlayer, onRxSeqId), true, LOT_NONE }, - { "overrideModelIndex", LVT_U8, offsetof(struct NetworkPlayer, overrideModelIndex), false, LOT_NONE }, - { "overridePalette", LVT_COBJECT, offsetof(struct NetworkPlayer, overridePalette), false, LOT_PLAYERPALETTE }, - { "overridePaletteIndex", LVT_U8, offsetof(struct NetworkPlayer, overridePaletteIndex), false, LOT_NONE }, - { "overridePaletteIndexLp", LVT_U8, offsetof(struct NetworkPlayer, overridePaletteIndexLp), true, LOT_NONE }, - { "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 - { "type", LVT_U8, offsetof(struct NetworkPlayer, type), true, LOT_NONE }, + { "connected", LVT_BOOL, offsetof(struct NetworkPlayer, connected), true, LOT_NONE }, + { "currActNum", LVT_S16, offsetof(struct NetworkPlayer, currActNum), true, LOT_NONE }, + { "currAreaIndex", LVT_S16, offsetof(struct NetworkPlayer, currAreaIndex), true, LOT_NONE }, + { "currAreaSyncValid", LVT_BOOL, offsetof(struct NetworkPlayer, currAreaSyncValid), true, LOT_NONE }, + { "currCourseNum", LVT_S16, offsetof(struct NetworkPlayer, currCourseNum), true, LOT_NONE }, + { "currLevelAreaSeqId", LVT_U16, offsetof(struct NetworkPlayer, currLevelAreaSeqId), true, LOT_NONE }, + { "currLevelNum", LVT_S16, offsetof(struct NetworkPlayer, currLevelNum), true, LOT_NONE }, + { "currLevelSyncValid", LVT_BOOL, offsetof(struct NetworkPlayer, currLevelSyncValid), true, LOT_NONE }, + { "currPositionValid", LVT_BOOL, offsetof(struct NetworkPlayer, currPositionValid), true, LOT_NONE }, + { "description", LVT_STRING, offsetof(struct NetworkPlayer, description), true, LOT_NONE }, + { "descriptionA", LVT_U8, offsetof(struct NetworkPlayer, descriptionA), true, LOT_NONE }, + { "descriptionB", LVT_U8, offsetof(struct NetworkPlayer, descriptionB), true, LOT_NONE }, + { "descriptionG", LVT_U8, offsetof(struct NetworkPlayer, descriptionG), true, LOT_NONE }, + { "descriptionR", LVT_U8, offsetof(struct NetworkPlayer, descriptionR), true, LOT_NONE }, + { "fadeOpacity", LVT_U8, offsetof(struct NetworkPlayer, fadeOpacity), true, LOT_NONE }, + { "globalIndex", LVT_U8, offsetof(struct NetworkPlayer, globalIndex), true, LOT_NONE }, + { "lastPingSent", LVT_F32, offsetof(struct NetworkPlayer, lastPingSent), true, LOT_NONE }, + { "lastReceived", LVT_F32, offsetof(struct NetworkPlayer, lastReceived), true, LOT_NONE }, + { "lastSent", LVT_F32, offsetof(struct NetworkPlayer, lastSent), true, LOT_NONE }, + { "localIndex", LVT_U8, offsetof(struct NetworkPlayer, localIndex), true, LOT_NONE }, + { "modelIndex", LVT_U8, offsetof(struct NetworkPlayer, modelIndex), true, LOT_NONE }, + { "name", LVT_STRING, offsetof(struct NetworkPlayer, name), true, LOT_NONE }, + { "onRxSeqId", LVT_U8, offsetof(struct NetworkPlayer, onRxSeqId), true, LOT_NONE }, + { "overrideModelIndex", LVT_U8, offsetof(struct NetworkPlayer, overrideModelIndex), false, LOT_NONE }, + { "overridePalette", LVT_COBJECT, offsetof(struct NetworkPlayer, overridePalette), false, LOT_PLAYERPALETTE }, + { "palette", LVT_COBJECT, offsetof(struct NetworkPlayer, palette), true, LOT_PLAYERPALETTE }, + { "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 + { "type", LVT_U8, offsetof(struct NetworkPlayer, type), true, LOT_NONE }, }; #define LUA_OBJECT_FIELD_COUNT 759 @@ -2211,11 +2208,10 @@ static struct LuaObjectField sRayIntersectionInfoFields[LUA_RAY_INTERSECTION_INF { "surface", LVT_COBJECT_P, offsetof(struct RayIntersectionInfo, surface), false, LOT_SURFACE }, }; -#define LUA_SERVER_SETTINGS_FIELD_COUNT 13 +#define LUA_SERVER_SETTINGS_FIELD_COUNT 12 static struct LuaObjectField sServerSettingsFields[LUA_SERVER_SETTINGS_FIELD_COUNT] = { { "bouncyLevelBounds", LVT_S32, offsetof(struct ServerSettings, bouncyLevelBounds), false, LOT_NONE }, { "bubbleDeath", LVT_U8, offsetof(struct ServerSettings, bubbleDeath), false, LOT_NONE }, - { "enableCheats", LVT_U8, offsetof(struct ServerSettings, enableCheats), false, LOT_NONE }, { "enablePlayerList", LVT_U8, offsetof(struct ServerSettings, enablePlayerList), false, LOT_NONE }, { "enablePlayersInLevelDisplay", LVT_U8, offsetof(struct ServerSettings, enablePlayersInLevelDisplay), false, LOT_NONE }, { "headlessServer", LVT_U8, offsetof(struct ServerSettings, headlessServer), false, LOT_NONE }, diff --git a/src/pc/lua/smlua_functions.c b/src/pc/lua/smlua_functions.c index 9cd75924..481d26d1 100644 --- a/src/pc/lua/smlua_functions.c +++ b/src/pc/lua/smlua_functions.c @@ -72,7 +72,7 @@ int smlua_func_atan2s(lua_State* L) { int smlua_func_init_mario_after_warp(lua_State* L) { if (network_player_connected_count() >= 2) { - LOG_LUA_LINE("init_mario_after_warp can only be used in single-player"); + LOG_LUA_LINE("init_mario_after_warp() can only be used in singleplayer"); return 0; } @@ -104,7 +104,7 @@ int smlua_func_initiate_warp(lua_State* L) { int smlua_func_reset_level(lua_State* L) { if (network_player_connected_count() >= 2) { - LOG_LUA_LINE("reset_level() can only be used in single-player"); + LOG_LUA_LINE("reset_level() can only be used in singleplayer"); return 0; } diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 919de0f5..5edcf529 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -20804,19 +20804,19 @@ int smlua_func_network_player_is_override_palette_same(lua_State* L) { return 1; } -int smlua_func_network_player_reset_override_palette_color(lua_State* L) { +int smlua_func_network_player_reset_override_palette(lua_State* L) { if (L == NULL) { return 0; } int top = lua_gettop(L); if (top != 1) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "network_player_reset_override_palette_color", 1, top); + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "network_player_reset_override_palette", 1, top); return 0; } struct NetworkPlayer* np = (struct NetworkPlayer*)smlua_to_cobject(L, 1, LOT_NETWORKPLAYER); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_player_reset_override_palette_color"); return 0; } + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "network_player_reset_override_palette"); return 0; } - network_player_reset_override_palette_color(np); + network_player_reset_override_palette(np); return 1; } @@ -33923,7 +33923,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "network_player_get_override_palette_color_channel", smlua_func_network_player_get_override_palette_color_channel); smlua_bind_function(L, "network_player_get_palette_color_channel", smlua_func_network_player_get_palette_color_channel); smlua_bind_function(L, "network_player_is_override_palette_same", smlua_func_network_player_is_override_palette_same); - smlua_bind_function(L, "network_player_reset_override_palette_color", smlua_func_network_player_reset_override_palette_color); + smlua_bind_function(L, "network_player_reset_override_palette", smlua_func_network_player_reset_override_palette); smlua_bind_function(L, "network_player_set_description", smlua_func_network_player_set_description); smlua_bind_function(L, "network_player_set_override_palette_color", smlua_func_network_player_set_override_palette_color); diff --git a/src/pc/lua/smlua_hooks.c b/src/pc/lua/smlua_hooks.c index 6690fb8e..b5d5471c 100644 --- a/src/pc/lua/smlua_hooks.c +++ b/src/pc/lua/smlua_hooks.c @@ -141,7 +141,7 @@ int smlua_hook_event(lua_State* L) { int ref = luaL_ref(L, LUA_REGISTRYINDEX); if (ref == -1) { - LOG_LUA_LINE("tried to hook undefined function to '%s'", LuaHookedEventTypeName[hookType]); + LOG_LUA_LINE("Tried to hook undefined function to '%s'", LuaHookedEventTypeName[hookType]); return 0; } diff --git a/src/pc/lua/smlua_sync_table.c b/src/pc/lua/smlua_sync_table.c index 886f425a..34e16a03 100644 --- a/src/pc/lua/smlua_sync_table.c +++ b/src/pc/lua/smlua_sync_table.c @@ -44,7 +44,7 @@ static bool smlua_sync_table_unwind(int syncTableIndex, int keyIndex) { // get key sUnwoundLnts[sUnwoundLntsCount++] = smlua_to_lnt(L, keyIndex); if (!gSmLuaConvertSuccess) { - LOG_LUA_LINE("attempted to unwind sync table with invalid key type"); + LOG_LUA_LINE("Attempted to unwind sync table with invalid key type"); return false; } @@ -55,7 +55,7 @@ static bool smlua_sync_table_unwind(int syncTableIndex, int keyIndex) { while (true) { // make sure we remain within limits if (sUnwoundLntsCount >= MAX_UNWOUND_LNT) { - LOG_LUA_LINE("attempted to unwind sync table past its limit"); + LOG_LUA_LINE("Attempted to unwind sync table past its limit"); return false; } @@ -76,7 +76,7 @@ static bool smlua_sync_table_unwind(int syncTableIndex, int keyIndex) { lua_pop(L, 1); // pop _name value if (!gSmLuaConvertSuccess) { - LOG_LUA_LINE("attempted to unwind sync table with invalid parent"); + LOG_LUA_LINE("Attempted to unwind sync table with invalid parent"); lua_pop(L, 1); // pop iterative _parent return false; } @@ -90,7 +90,7 @@ static bool smlua_sync_table_unwind(int syncTableIndex, int keyIndex) { // validate parent type if (parentType != LUA_TTABLE) { if (parentType != LUA_TNIL) { - LOG_LUA_LINE("attempted to unwind sync table into an invalid parent"); + LOG_LUA_LINE("Attempted to unwind sync table into an invalid parent"); return false; } break; @@ -106,7 +106,7 @@ static bool smlua_sync_table_unwind(int syncTableIndex, int keyIndex) { } if (unwoundSize >= MAX_UNWOUND_SIZE) { - LOG_LUA_LINE("attempted to unwind sync table with too long of a key/parent length"); + LOG_LUA_LINE("Attempted to unwind sync table with too long of a key/parent length"); return false; } diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 81d8aa0a..7999a2d5 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -76,7 +76,6 @@ struct ServerSettings gServerSettings = { .bouncyLevelBounds = BOUNCY_LEVEL_BOUNDS_OFF, .playerKnockbackStrength = 25, .skipIntro = FALSE, - .enableCheats = FALSE, .bubbleDeath = TRUE, .enablePlayersInLevelDisplay = TRUE, .enablePlayerList = TRUE, @@ -124,7 +123,6 @@ bool network_init(enum NetworkType inNetworkType, bool reconnecting) { gServerSettings.playerKnockbackStrength = configPlayerKnockbackStrength; gServerSettings.stayInLevelAfterStar = configStayInLevelAfterStar; gServerSettings.skipIntro = gCLIOpts.skipIntro ? TRUE : configSkipIntro; - gServerSettings.enableCheats = 0; gServerSettings.bubbleDeath = configBubbleDeath; gServerSettings.enablePlayersInLevelDisplay = TRUE; gServerSettings.enablePlayerList = TRUE; @@ -734,7 +732,6 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect reset_window_title(); - gDjuiLuaErrorTimeout = 0; djui_panel_shutdown(); extern bool gDjuiInMainMenu; if (!gDjuiInMainMenu) { diff --git a/src/pc/network/network.h b/src/pc/network/network.h index f4595060..85779a26 100644 --- a/src/pc/network/network.h +++ b/src/pc/network/network.h @@ -75,7 +75,6 @@ struct ServerSettings { u8 playerKnockbackStrength; u8 stayInLevelAfterStar; u8 skipIntro; - u8 enableCheats; u8 bubbleDeath; u8 enablePlayersInLevelDisplay; u8 enablePlayerList; diff --git a/src/pc/network/network_player.c b/src/pc/network/network_player.c index 8cfb344e..b60733a0 100644 --- a/src/pc/network/network_player.c +++ b/src/pc/network/network_player.c @@ -148,7 +148,7 @@ void network_player_set_override_palette_color(struct NetworkPlayer *np, enum Pl np->overridePalette.parts[part][2] = color[2]; } -void network_player_reset_override_palette_color(struct NetworkPlayer *np) { +void network_player_reset_override_palette(struct NetworkPlayer *np) { if (np == NULL) { return; } np->overridePalette = np->palette; diff --git a/src/pc/network/network_player.h b/src/pc/network/network_player.h index 7fbf4ae6..91dce8c0 100644 --- a/src/pc/network/network_player.h +++ b/src/pc/network/network_player.h @@ -57,11 +57,6 @@ struct NetworkPlayer { u16 rxSeqIds[MAX_RX_SEQ_IDS]; u32 rxPacketHash[MAX_RX_SEQ_IDS]; - - // legacy fields to allow mods not to fully break (they don't do anything anymore) - u8 paletteIndex; - u8 overridePaletteIndex; - u8 overridePaletteIndexLp; }; extern struct NetworkPlayer gNetworkPlayers[]; @@ -82,7 +77,7 @@ struct NetworkPlayer* get_network_player_smallest_global(void); u8 network_player_get_palette_color_channel(struct NetworkPlayer *np, enum PlayerPart part, u8 index); u8 network_player_get_override_palette_color_channel(struct NetworkPlayer *np, enum PlayerPart part, u8 index); void network_player_set_override_palette_color(struct NetworkPlayer *np, enum PlayerPart part, Color color); -void network_player_reset_override_palette_color(struct NetworkPlayer *np); +void network_player_reset_override_palette(struct NetworkPlayer *np); bool network_player_is_override_palette_same(struct NetworkPlayer *np); void network_player_update(void);