mirror of
				https://github.com/coop-deluxe/sm64coopdx.git
				synced 2025-10-30 08:01:01 +00:00 
			
		
		
		
	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
This commit is contained in:
		
							parent
							
								
									2f8d119301
								
							
						
					
					
						commit
						3b946eb5e1
					
				
					 7 changed files with 12 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -74,6 +74,7 @@ enum PlayerInteractions {
 | 
			
		|||
struct ServerSettings {
 | 
			
		||||
    enum PlayerInteractions playerInteractions;
 | 
			
		||||
    u8 playerKnockbackStrength;
 | 
			
		||||
    u8 stayInLevelAfterStar;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Networking-specific externs
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue