From 47be56e1c7bddb55b9777df97ec8a7a51dfc4d57 Mon Sep 17 00:00:00 2001 From: defacube <85292886+yoyeet961@users.noreply.github.com> Date: Tue, 7 Nov 2023 19:29:09 +1100 Subject: [PATCH] Add support for 16 areas (#502) --- autogen/lua_definitions/constants.lua | 2 +- src/engine/level_script.c | 6 +++--- src/game/area.c | 4 ++-- src/game/area.h | 2 +- src/pc/lua/smlua_constants_autogen.c | 4 ++-- src/pc/network/packets/packet_level_macro.c | 7 ++++--- src/pc/network/packets/packet_level_spawn_info.c | 5 +++-- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index 554793b1..a85292c1 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -388,7 +388,7 @@ INSTANT_WARP_INDEX_START = 0x00 INSTANT_WARP_INDEX_STOP = 0x04 --- @type integer -MAX_AREAS = 8 +MAX_AREAS = 16 --- @type integer WARP_TRANSITION_FADE_FROM_BOWSER = 0x12 diff --git a/src/engine/level_script.c b/src/engine/level_script.c index 8190bf61..29621ff4 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -373,7 +373,7 @@ static void level_reset_globals(void) { gEnvFxMode = ENVFX_MODE_NONE; // clear area's level pool pointers - for (int i = 0; i < 8; i++) { + for (int i = 0; i < MAX_AREAS; i++) { gAreas[i].unk04 = NULL; } @@ -407,7 +407,7 @@ static void level_cmd_free_level_pool(void) { gLevelPool = NULL; } - for (i = 0; i < 8; i++) { + for (i = 0; i < MAX_AREAS; i++) { if (gAreaData[i].terrainData != NULL) { alloc_surface_pools(); break; @@ -421,7 +421,7 @@ static void level_cmd_begin_area(void) { u8 areaIndex = CMD_GET(u8, 2); void *geoLayoutAddr = CMD_GET(void *, 4); - if (areaIndex < 8) { + if (areaIndex < MAX_AREAS) { u32 id = 0; struct GraphNodeRoot *screenArea = (struct GraphNodeRoot *) dynos_model_load_geo(&id, MODEL_POOL_LEVEL, geoLayoutAddr, false); struct GraphNodeCamera *node = (struct GraphNodeCamera *) screenArea->views[0]; diff --git a/src/game/area.c b/src/game/area.c index 27791589..f7b1374a 100644 --- a/src/game/area.c +++ b/src/game/area.c @@ -226,7 +226,7 @@ void clear_areas(void) { gPlayerSpawnInfos[0].areaIndex = -1; gPlayerSpawnInfos[1].areaIndex = -1; - for (s32 i = 0; i < 8; i++) { + for (s32 i = 0; i < MAX_AREAS; i++) { gAreaData[i].index = i; gAreaData[i].flags = 0; gAreaData[i].terrainType = 0; @@ -256,7 +256,7 @@ void clear_area_graph_nodes(void) { gWarpTransition.isActive = FALSE; } - for (s32 i = 0; i < 8; i++) { + for (s32 i = 0; i < MAX_AREAS; i++) { if (gAreaData[i].unk04 != NULL) { geo_call_global_function_nodes(&gAreaData[i].unk04->node, GEO_CONTEXT_AREA_INIT); gAreaData[i].unk04 = NULL; diff --git a/src/game/area.h b/src/game/area.h index 14b8003c..71440599 100644 --- a/src/game/area.h +++ b/src/game/area.h @@ -26,7 +26,7 @@ struct ObjectWarpNode #define INSTANT_WARP_INDEX_START 0x00 // Equal and greater than Surface 0x1B #define INSTANT_WARP_INDEX_STOP 0x04 // Less than Surface 0x1F -#define MAX_AREAS 8 +#define MAX_AREAS 16 struct InstantWarp { diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index 226ab11a..17e2d7bf 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -343,7 +343,7 @@ char gSmluaConstants[] = "" "COURSE_MIN = 1\n" "INSTANT_WARP_INDEX_START = 0x00\n" "INSTANT_WARP_INDEX_STOP = 0x04\n" -"MAX_AREAS = 8\n" +"MAX_AREAS = 16\n" "WARP_TRANSITION_FADE_FROM_COLOR = 0x00\n" "WARP_TRANSITION_FADE_INTO_COLOR = 0x01\n" "WARP_TRANSITION_FADE_FROM_STAR = 0x08\n" @@ -4298,4 +4298,4 @@ char gSmluaConstants[] = "" "VERSION_REGION = 'US'\n" "MAX_VERSION_LENGTH = 32\n" "MAX_LOCAL_VERSION_LENGTH = 36\n" -; \ No newline at end of file +; diff --git a/src/pc/network/packets/packet_level_macro.c b/src/pc/network/packets/packet_level_macro.c index 03b521dd..f858a057 100644 --- a/src/pc/network/packets/packet_level_macro.c +++ b/src/pc/network/packets/packet_level_macro.c @@ -6,6 +6,7 @@ #include "game/interaction.h" #include "game/level_update.h" #include "game/macro_special_objects.h" +#include "game/area.h" #include "macro_presets.h" #include "object_constants.h" #include "object_fields.h" @@ -115,7 +116,7 @@ void network_send_level_macro(struct NetworkPlayer* destNp) { return; } - for (s32 i = 0; i < 8; i++) { + for (s32 i = 0; i < MAX_AREAS; i++) { network_send_level_macro_area(destNp, i); } } @@ -134,7 +135,7 @@ void network_receive_level_macro(struct Packet* p) { u8 thisAreaIndex; packet_read(p, &thisAreaIndex, sizeof(u8)); - if (thisAreaIndex >= 8) { + if (thisAreaIndex >= MAX_AREAS) { LOG_ERROR("Receiving 'location response' with invalid areaIndex!"); return; } @@ -231,4 +232,4 @@ void network_receive_level_macro(struct Packet* p) { } } } -} \ No newline at end of file +} diff --git a/src/pc/network/packets/packet_level_spawn_info.c b/src/pc/network/packets/packet_level_spawn_info.c index acb89939..e73c6aae 100644 --- a/src/pc/network/packets/packet_level_spawn_info.c +++ b/src/pc/network/packets/packet_level_spawn_info.c @@ -1,5 +1,6 @@ #include #include "../network.h" +#include "game/area.h" #include "game/interaction.h" #include "game/object_list_processor.h" #include "game/object_helpers.h" @@ -84,7 +85,7 @@ void network_send_level_spawn_info(struct NetworkPlayer* destNp) { return; } - for (s32 i = 0; i < 8; i++) { + for (s32 i = 0; i < MAX_AREAS; i++) { network_send_level_spawn_info_area(destNp, i); } } @@ -135,4 +136,4 @@ void network_receive_level_spawn_info(struct Packet* p) { spawnInfo = spawnInfo->next; spawnInfoIndex++; } -} \ No newline at end of file +}