From 3b946eb5e1bc6d2dad0f08cd10af30b5cb74e0b8 Mon Sep 17 00:00:00 2001 From: MysterD Date: Tue, 8 Sep 2020 00:00:52 -0700 Subject: [PATCH] Added stay-in-level-after-star server-side setting. Configurable in the server's config file under: coop_stay_in_level_after_star Defaults to off Based on GateGuy's patch --- src/game/interaction.c | 3 +++ src/game/mario_actions_cutscene.c | 1 + src/pc/configfile.c | 2 ++ src/pc/configfile.h | 1 + src/pc/network/network.c | 3 ++- src/pc/network/network.h | 1 + src/pc/network/packets/packet_save_file.c | 2 ++ 7 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/game/interaction.c b/src/game/interaction.c index c5ffbd74..66d2b858 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -820,6 +820,9 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O u32 noExit = (o->oInteractionSubtype & INT_SUBTYPE_NO_EXIT) != 0; u32 grandStar = (o->oInteractionSubtype & INT_SUBTYPE_GRAND_STAR) != 0; + u8 stayInLevelCommon = !(gCurrLevelNum == LEVEL_BOWSER_1 || gCurrLevelNum == LEVEL_BOWSER_2 || gCurrLevelNum == LEVEL_BOWSER_3); + if (stayInLevelCommon && gServerSettings.stayInLevelAfterStar) { noExit = TRUE; } + if (m->health >= 0x100) { mario_stop_riding_and_holding(m); queue_rumble_data_mario(m, 5, 80); diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 91b3ddfd..9dfb7790 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -30,6 +30,7 @@ #include "thread6.h" #include "../../include/libc/stdlib.h" #include "pc/pc_main.h" +#include "pc/network/network.h" // TODO: put this elsewhere enum SaveOption { SAVE_OPT_SAVE_AND_CONTINUE = 1, SAVE_OPT_SAVE_AND_QUIT, SAVE_OPT_SAVE_EXIT_GAME, SAVE_OPT_CONTINUE_DONT_SAVE }; diff --git a/src/pc/configfile.c b/src/pc/configfile.c index f692fc9e..ba05873f 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -102,6 +102,7 @@ unsigned int configHostPort = DEFAULT_PORT; unsigned int configHostSaveSlot = 1; unsigned int configPlayerInteraction = 1; unsigned int configPlayerKnockbackStrength = 25; +unsigned int configStayInLevelAfterStar = 0; static const struct ConfigOption options[] = { {.name = "fullscreen", .type = CONFIG_TYPE_BOOL, .boolValue = &configWindow.fullscreen}, @@ -157,6 +158,7 @@ static const struct ConfigOption options[] = { {.name = "coop_host_save_slot", .type = CONFIG_TYPE_UINT , .uintValue = &configHostSaveSlot}, {.name = "coop_player_interaction", .type = CONFIG_TYPE_UINT , .uintValue = &configPlayerInteraction}, {.name = "coop_player_knockback_strength", .type = CONFIG_TYPE_UINT , .uintValue = &configPlayerKnockbackStrength}, + {.name = "coop_stay_in_level_after_star", .type = CONFIG_TYPE_UINT , .uintValue = &configStayInLevelAfterStar}, }; // Reads an entire line from a file (excluding the newline character) and returns an allocated string diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 45275985..b940d856 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -68,6 +68,7 @@ extern unsigned int configHostPort; extern unsigned int configHostSaveSlot; extern unsigned int configPlayerInteraction; extern unsigned int configPlayerKnockbackStrength; +extern unsigned int configStayInLevelAfterStar; void configfile_load(const char *filename); void configfile_save(const char *filename); diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 7f047935..b13e375c 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -35,8 +35,9 @@ void network_init(enum NetworkType inNetworkType, char* ip, unsigned int port) { // set server settings if (gNetworkType == NT_SERVER) { - gServerSettings.playerInteractions = configPlayerInteraction; + gServerSettings.playerInteractions = configPlayerInteraction; gServerSettings.playerKnockbackStrength = configPlayerKnockbackStrength; + gServerSettings.stayInLevelAfterStar = configStayInLevelAfterStar; } // create a receiver socket to receive datagrams diff --git a/src/pc/network/network.h b/src/pc/network/network.h index e65d61d4..bb9f0e0d 100644 --- a/src/pc/network/network.h +++ b/src/pc/network/network.h @@ -74,6 +74,7 @@ enum PlayerInteractions { struct ServerSettings { enum PlayerInteractions playerInteractions; u8 playerKnockbackStrength; + u8 stayInLevelAfterStar; }; // Networking-specific externs diff --git a/src/pc/network/packets/packet_save_file.c b/src/pc/network/packets/packet_save_file.c index 91591cc6..8751f36a 100644 --- a/src/pc/network/packets/packet_save_file.c +++ b/src/pc/network/packets/packet_save_file.c @@ -43,6 +43,7 @@ void network_send_save_file(void) { packet_write(&p, &gCurrSaveFileNum, sizeof(s16)); packet_write(&p, &gServerSettings.playerInteractions, sizeof(u8)); packet_write(&p, &gServerSettings.playerKnockbackStrength, sizeof(u8)); + packet_write(&p, &gServerSettings.stayInLevelAfterStar, sizeof(u8)); packet_write(&p, eeprom, sizeof(u8) * 512); network_send(&p); } @@ -56,6 +57,7 @@ void network_receive_save_file(struct Packet* p) { packet_read(p, &gCurrSaveFileNum, sizeof(s16)); packet_read(p, &gServerSettings.playerInteractions, sizeof(u8)); packet_read(p, &gServerSettings.playerKnockbackStrength, sizeof(u8)); + packet_read(p, &gServerSettings.stayInLevelAfterStar, sizeof(u8)); packet_read(p, eeprom, sizeof(u8) * 512); save_file_load_all(TRUE);