diff --git a/autogen/lua_definitions/manual.lua b/autogen/lua_definitions/manual.lua index ec5079116..d45950d53 100644 --- a/autogen/lua_definitions/manual.lua +++ b/autogen/lua_definitions/manual.lua @@ -31,6 +31,9 @@ gPlayerSyncTable = {} --- @type StarPositions gStarPositions = {} +--- @type LevelValues +gLevelValues = {} + ----------- -- hooks -- ----------- diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index 93ee98492..c276e5b70 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -440,6 +440,9 @@ --- @field public unusedVec2 Vec3s --- @field public yaw integer +--- @class LevelValues +--- @field public entryLevel LevelNum + --- @class LinearTransitionPoint --- @field public dist number --- @field public focus Vec3f diff --git a/docs/lua/globals.md b/docs/lua/globals.md index e2d9661ba..585e4cd55 100644 --- a/docs/lua/globals.md +++ b/docs/lua/globals.md @@ -65,6 +65,13 @@ The `gGlobalObjectCollisionData` table contains references to object collision d
+## [gLevelValues](#gLevelValues) +`gLevelValues`'s fields are listed in [LevelValue](structs.md#LevelValue). + +[:arrow_up_small:](#) + +
+ ## [gServerSettings](#gServerSettings) `gServerSettings`'s fields are listed in [ServerSettings](structs.md#ServerSettings). diff --git a/docs/lua/structs.md b/docs/lua/structs.md index 79ced21de..ec8e0122e 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -25,6 +25,7 @@ - [HandheldShakePoint](#HandheldShakePoint) - [InstantWarp](#InstantWarp) - [LakituState](#LakituState) +- [LevelValues](#LevelValues) - [LinearTransitionPoint](#LinearTransitionPoint) - [MarioAnimDmaRelatedThing](#MarioAnimDmaRelatedThing) - [MarioAnimation](#MarioAnimation) @@ -674,6 +675,16 @@
+## [LevelValues](#LevelValues) + +| Field | Type | Access | +| ----- | ---- | ------ | +| entryLevel | [enum LevelNum](constants.md#enum-LevelNum) | | + +[:arrow_up_small:](#) + +
+ ## [LinearTransitionPoint](#LinearTransitionPoint) | Field | Type | Access | diff --git a/levels/entry.c b/levels/entry.c index 681fe93d3..b0880af26 100644 --- a/levels/entry.c +++ b/levels/entry.c @@ -14,7 +14,6 @@ const LevelScript level_script_entry[] = { SET_REG(/*value*/ LEVEL_CASTLE_GROUNDS), - //JUMP(/*target*/ level_main_scripts_entry), EXECUTE(/*seg*/ 0x14, /*script*/ _introSegmentRomStart, /*scriptEnd*/ _introSegmentRomEnd, /*entry*/ level_main_scripts_entry), JUMP(level_script_entry), diff --git a/src/game/hardcoded.c b/src/game/hardcoded.c index 39eedb5cd..9cf825da1 100644 --- a/src/game/hardcoded.c +++ b/src/game/hardcoded.c @@ -1,5 +1,9 @@ #include "hardcoded.h" +struct LevelValues gLevelValues = { + .entryLevel = LEVEL_CASTLE_GROUNDS, +}; + struct StarPositions gStarPositions = { .KoopaBobStarPos = { 3030.0f, 4500.0f, -4600.0f }, .KoopaThiStarPos = { 7100.0f, -1300.0f, -6000.0f }, diff --git a/src/game/hardcoded.h b/src/game/hardcoded.h index 341db7f12..fb0685a8f 100644 --- a/src/game/hardcoded.h +++ b/src/game/hardcoded.h @@ -1,5 +1,10 @@ #ifndef HARDCODED_H #include "types.h" +#include "level_table.h" + +struct LevelValues { + enum LevelNum entryLevel; +}; struct StarPositions { Vec3f KoopaBobStarPos; @@ -30,6 +35,7 @@ struct StarPositions { Vec3f JetstreamRingStarPos; }; +extern struct LevelValues gLevelValues; extern struct StarPositions gStarPositions; #endif \ No newline at end of file diff --git a/src/game/mario.c b/src/game/mario.c index 9875ce3dc..0b2913119 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -37,6 +37,7 @@ #include "sound_init.h" #include "rumble_init.h" #include "obj_behaviors.h" +#include "hardcoded.h" #include "pc/configfile.h" #include "pc/cheats.h" #include "pc/network/network.h" @@ -1533,7 +1534,7 @@ void update_mario_inputs(struct MarioState *m) { gCurrCreditsEntry = NULL; gCurrActStarNum = 0; gCurrActNum = 0; - gChangeLevel = 16; + gChangeLevel = gLevelValues.entryLevel; } if (m->playerIndex == 0) { diff --git a/src/pc/djui/djui_panel_host_message.c b/src/pc/djui/djui_panel_host_message.c index 2c3e65360..ff700ba96 100644 --- a/src/pc/djui/djui_panel_host_message.c +++ b/src/pc/djui/djui_panel_host_message.c @@ -6,6 +6,7 @@ #include "src/pc/configfile.h" #include "pc/utils/misc.h" #include "src/game/level_update.h" +#include "src/game/hardcoded.h" #include "audio/external.h" #include "sounds.h" @@ -44,7 +45,7 @@ void djui_panel_host_message_do_host(UNUSED struct DjuiBase* caller) { djui_panel_modlist_create(NULL); fake_lvl_init_from_save_file(); extern s16 gChangeLevelTransition; - gChangeLevelTransition = 16; + gChangeLevelTransition = gLevelValues.entryLevel; play_sound(SOUND_MENU_STAR_SOUND_OKEY_DOKEY, gGlobalSoundSource); extern void play_transition(s16 transType, s16 time, u8 red, u8 green, u8 blue); play_transition(0x09, 0x14, 0x00, 0x00, 0x00); diff --git a/src/pc/lua/smlua_cobject.c b/src/pc/lua/smlua_cobject.c index bd1fdc568..802705b7a 100644 --- a/src/pc/lua/smlua_cobject.c +++ b/src/pc/lua/smlua_cobject.c @@ -571,6 +571,11 @@ void smlua_cobject_init_globals(void) { lua_setglobal(L, "gStarPositions"); } + { + smlua_push_object(L, LOT_LEVELVALUES, &gLevelValues); + lua_setglobal(L, "gLevelValues"); + } + } void smlua_cobject_init_per_file_globals(char* path) { diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 808b7602d..5e9ca77cb 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -530,6 +530,11 @@ static struct LuaObjectField sLakituStateFields[LUA_LAKITU_STATE_FIELD_COUNT] = { "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE }, }; +#define LUA_LEVEL_VALUES_FIELD_COUNT 1 +static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = { + { "entryLevel", LVT_S32, offsetof(struct LevelValues, entryLevel), false, LOT_NONE }, +}; + #define LUA_LINEAR_TRANSITION_POINT_FIELD_COUNT 5 static struct LuaObjectField sLinearTransitionPointFields[LUA_LINEAR_TRANSITION_POINT_FIELD_COUNT] = { { "dist", LVT_F32, offsetof(struct LinearTransitionPoint, dist), false, LOT_NONE }, @@ -1750,6 +1755,7 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN] { LOT_HANDHELDSHAKEPOINT, sHandheldShakePointFields, LUA_HANDHELD_SHAKE_POINT_FIELD_COUNT }, { LOT_INSTANTWARP, sInstantWarpFields, LUA_INSTANT_WARP_FIELD_COUNT }, { LOT_LAKITUSTATE, sLakituStateFields, LUA_LAKITU_STATE_FIELD_COUNT }, + { LOT_LEVELVALUES, sLevelValuesFields, LUA_LEVEL_VALUES_FIELD_COUNT }, { LOT_LINEARTRANSITIONPOINT, sLinearTransitionPointFields, LUA_LINEAR_TRANSITION_POINT_FIELD_COUNT }, { LOT_MARIOANIMATION, sMarioAnimationFields, LUA_MARIO_ANIMATION_FIELD_COUNT }, { LOT_MARIOBODYSTATE, sMarioBodyStateFields, LUA_MARIO_BODY_STATE_FIELD_COUNT }, diff --git a/src/pc/lua/smlua_cobject_autogen.h b/src/pc/lua/smlua_cobject_autogen.h index 52a3ac1e2..12d3d0336 100644 --- a/src/pc/lua/smlua_cobject_autogen.h +++ b/src/pc/lua/smlua_cobject_autogen.h @@ -29,6 +29,7 @@ enum LuaObjectAutogenType { LOT_HANDHELDSHAKEPOINT, LOT_INSTANTWARP, LOT_LAKITUSTATE, + LOT_LEVELVALUES, LOT_LINEARTRANSITIONPOINT, LOT_MARIOANIMATION, LOT_MARIOBODYSTATE, diff --git a/src/pc/network/network_player.c b/src/pc/network/network_player.c index 2793df5d8..19a62ed5b 100644 --- a/src/pc/network/network_player.c +++ b/src/pc/network/network_player.c @@ -7,6 +7,7 @@ #include "pc/utils/misc.h" #include "game/area.h" #include "game/level_info.h" +#include "game/hardcoded.h" #include "pc/lua/smlua_hooks.h" struct NetworkPlayer gNetworkPlayers[MAX_PLAYERS] = { 0 }; @@ -219,7 +220,7 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode np->currLevelAreaSeqId = 0; np->currLevelSyncValid = false; np->currAreaSyncValid = false; - network_player_update_course_level(np, 0, 0, 16, 1); + network_player_update_course_level(np, 0, 0, gLevelValues.entryLevel, 1); // update visuals np->fadeOpacity = 0; diff --git a/src/pc/network/packets/packet_join.c b/src/pc/network/packets/packet_join.c index ec1f97d37..1bf3a198f 100644 --- a/src/pc/network/packets/packet_join.c +++ b/src/pc/network/packets/packet_join.c @@ -8,6 +8,7 @@ #include "src/engine/math_util.h" #include "src/game/save_file.h" #include "src/game/level_update.h" +#include "src/game/hardcoded.h" #include "src/pc/fs/fs.h" #include "PR/os_eeprom.h" #include "pc/network/version.h" @@ -230,7 +231,7 @@ void network_receive_join(struct Packet* p) { fake_lvl_init_from_save_file(); extern s16 gChangeLevel; - gChangeLevel = 16; + gChangeLevel = gLevelValues.entryLevel; mods_activate(&gRemoteMods); djui_panel_modlist_create(NULL);