Remove need to restart for coop compatibility

This commit is contained in:
Agent X 2023-12-27 23:50:48 -05:00
parent 0821162349
commit 0c646018c1
17 changed files with 68 additions and 101 deletions

View file

@ -27,7 +27,6 @@
#include "pc/lua/smlua_hooks.h"
#include "pc/djui/djui.h"
#include "pc/djui/djui_panel_pause.h"
#include "pc/pc_main.h"
#include "pc/nametags.h"
struct SpawnInfo gPlayerSpawnInfos[MAX_PLAYERS];
@ -448,7 +447,7 @@ void render_game(void) {
djui_reset_hud_params();
create_dl_ortho_matrix();
djui_gfx_displaylist_begin();
if (!gCoopCompatibility && gServerSettings.nametags && !gDjuiInMainMenu) {
if (!configCoopCompatibility && gServerSettings.nametags && !gDjuiInMainMenu) {
nametags_render();
}
smlua_call_event_on_hud_render_behind(djui_reset_hud_params);

View file

@ -31,7 +31,6 @@
#include "pc/network/network.h"
#include "pc/network/lag_compensation.h"
#include "pc/lua/smlua_hooks.h"
#include "pc/pc_main.h"
u8 sDelayInvincTimer;
s16 gInteractionInvulnerable;
@ -180,7 +179,7 @@ static u32 determine_interaction_internal(struct MarioState *m, struct Object *o
// when set to false, angle checks apply again. I would just restore the original
// determine_interaction function but this is easier with keeping compatibility
if (!gCoopCompatibility) { isPVP = FALSE; }
if (!configCoopCompatibility) { isPVP = FALSE; }
u32 interaction = 0;
u32 action = m->action;
@ -193,7 +192,7 @@ static u32 determine_interaction_internal(struct MarioState *m, struct Object *o
}
if (interaction == 0 && action & ACT_FLAG_ATTACKING) {
u32 flags = gCoopCompatibility ? (MARIO_PUNCHING | MARIO_KICKING | MARIO_TRIPPING) : (MARIO_PUNCHING | MARIO_KICKING);
u32 flags = configCoopCompatibility ? (MARIO_PUNCHING | MARIO_KICKING | MARIO_TRIPPING) : (MARIO_PUNCHING | MARIO_KICKING);
if (m->flags & flags) {
s16 dYawToObject = mario_obj_angle_to_object(m, o) - m->faceAngle[1];
@ -209,7 +208,7 @@ static u32 determine_interaction_internal(struct MarioState *m, struct Object *o
interaction = INT_KICK;
}
}
if (m->flags & MARIO_TRIPPING && gCoopCompatibility) {
if (m->flags & MARIO_TRIPPING && configCoopCompatibility) {
// 180 degrees total, or 90 each way
if (-0x4000 <= dYawToObject && dYawToObject <= 0x4000) {
interaction = INT_TRIP;

View file

@ -7,7 +7,6 @@
#include "object_list_processor.h"
#include "spawn_object.h"
#include "pc/network/network_player.h"
#include "pc/pc_main.h"
struct Object *debug_print_obj_collision(struct Object *a) {
if (!a) { return NULL; }
@ -39,7 +38,7 @@ int detect_player_hitbox_overlap(struct MarioState* local, struct MarioState* re
f32 dx = aTorso[0] - bTorso[0];
UNUSED f32 sp30 = sp3C - sp38;
f32 dz = aTorso[2] - bTorso[2];
f32 collisionRadius = (a->hitboxRadius + b->hitboxRadius) * (gCoopCompatibility ? 2.25f : 1.6f); // 1.5f before
f32 collisionRadius = (a->hitboxRadius + b->hitboxRadius) * (configCoopCompatibility ? 2.25f : 1.6f); // 1.5f before
f32 distance = sqrtf(dx * dx + dz * dz);
if (collisionRadius * scale > distance) {

View file

@ -2,7 +2,6 @@
#include "pc/djui/djui.h"
#include "pc/crash_handler.h"
#include "pc/debuglog.h"
#include "pc/pc_main.h"
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
@ -19,7 +18,7 @@
struct DiscordApplication app = { 0 };
static bool sFatalShown = false;
static bool sDiscordInitialized = false;
bool gDiscordInitialized = false;
static bool sDiscordFailed = false;
static void discord_sdk_log_callback(UNUSED void* hook_data, enum EDiscordLogLevel level, const char* message) {
@ -114,8 +113,13 @@ struct IDiscordUserEvents* discord_user_initialize(void) {
}
static void discord_initialize(void) {
if (sDiscordInitialized) { return; }
sDiscordInitialized = true;
if (gDiscordInitialized) {
return;
} else if (app.core != NULL) { // reinit
app.core->destroy(app.core); // why does it ask for itself?
app.core = NULL;
}
gDiscordInitialized = true;
if (app.core != NULL) {
app.core->set_log_hook(app.core, DiscordLogLevel_Debug, NULL, discord_sdk_log_callback);
@ -124,7 +128,7 @@ static void discord_initialize(void) {
// set up discord params
struct DiscordCreateParams params = { 0 };
DiscordCreateParamsSetDefault(&params);
params.client_id = gCoopCompatibility ? APPLICATION_ID_COOP : APPLICATION_ID_COOPDX; // you have to have activity status on if you don't want discord to prompt you to authorize on every boot
params.client_id = configCoopCompatibility ? APPLICATION_ID_COOP : APPLICATION_ID_COOPDX; // you have to have activity status on if you don't want discord to prompt you to authorize on every boot
params.flags = DiscordCreateFlags_NoRequireDiscord;
params.event_data = &app;
params.user_events = discord_user_initialize();
@ -169,7 +173,7 @@ u64 discord_get_user_id(void) {
void discord_update(void) {
if (sDiscordFailed) { return; }
if (!sDiscordInitialized) { discord_initialize(); }
if (!gDiscordInitialized) { discord_initialize(); }
if (sDiscordFailed) { return; }
discord_activity_update_check();

View file

@ -29,6 +29,8 @@ struct DiscordApplication {
DiscordUserId userId;
};
extern bool gDiscordInitialized;
void discord_update(void);
void discord_fatal(int rc);
void discord_activity_update_check(void);

View file

@ -4,7 +4,6 @@
#include "djui_panel_menu.h"
#include "game/save_file.h"
#include "pc/network/network.h"
#include "pc/pc_main.h"
#include "pc/utils/misc.h"
#include "pc/configfile.h"
#include "djui_inputbox.h"
@ -62,11 +61,11 @@ void djui_panel_host_settings_create(struct DjuiBase* caller) {
djui_checkbox_create(body, DLANG(HOST_SETTINGS, SKIP_INTRO_CUTSCENE), &configSkipIntro, NULL);
djui_checkbox_create(body, DLANG(HOST_SETTINGS, BUBBLE_ON_DEATH), &configBubbleDeath, NULL);
struct DjuiCheckbox* checkbox = djui_checkbox_create(body, DLANG(HOST_SETTINGS, NAMETAGS), &configNametags, NULL);
djui_base_set_enabled(&checkbox->base, !gCoopCompatibility);
djui_base_set_enabled(&checkbox->base, !configCoopCompatibility);
char* bChoices[3] = { DLANG(HOST_SETTINGS, BOUNCY_BOUNDS_OFF), DLANG(HOST_SETTINGS, BOUNCY_BOUNDS_ON), DLANG(HOST_SETTINGS, BOUNCY_BOUNDS_ON_CAP) };
struct DjuiSelectionbox* selectionbox = djui_selectionbox_create(body, DLANG(HOST_SETTINGS, BOUNCY_LEVEL_BOUNDS), bChoices, 3, &configBouncyLevelBounds, NULL);
djui_base_set_enabled(&selectionbox->base, !gCoopCompatibility);
djui_base_set_enabled(&selectionbox->base, !configCoopCompatibility);
struct DjuiRect* rect1 = djui_rect_container_create(body, 32);
{

View file

@ -4,18 +4,16 @@
#include "djui_panel_join_lobbies.h"
#include "djui_panel_join_private.h"
#include "djui_panel_join_direct.h"
#include "djui_panel_main.h"
#include "pc/network/network.h"
#include "pc/utils/misc.h"
#include "pc/pc_main.h"
#include "pc/discord/discord.h"
#ifdef COOPNET
static struct DjuiText* sRestartText = NULL;
static void djui_panel_compatibility_checkbox_on_value_change(UNUSED struct DjuiBase* caller) {
if (gCoopCompatibility != configCoopCompatibility) {
djui_text_set_text(sRestartText, DLANG(DISPLAY, MUST_RESTART));
} else {
djui_text_set_text(sRestartText, "");
gDiscordInitialized = false;
if (gVersionText != NULL) {
djui_text_set_text(gVersionText, get_version_local());
}
}
@ -34,14 +32,10 @@ void djui_panel_join_create(struct DjuiBase* caller) {
djui_button_create(body, DLANG(JOIN, PUBLIC_LOBBIES), DJUI_BUTTON_STYLE_NORMAL, djui_panel_join_public_lobbies);
djui_button_create(body, DLANG(JOIN, PRIVATE_LOBBIES), DJUI_BUTTON_STYLE_NORMAL, djui_panel_join_private_create);
djui_button_create(body, DLANG(JOIN, DIRECT), DJUI_BUTTON_STYLE_NORMAL, djui_panel_join_direct_create);
djui_checkbox_create(body, DLANG(MISC, COOP_COMPATIBILITY), &configCoopCompatibility, djui_panel_compatibility_checkbox_on_value_change);
if (gDjuiInMainMenu) {
djui_checkbox_create(body, DLANG(MISC, COOP_COMPATIBILITY), &configCoopCompatibility, djui_panel_compatibility_checkbox_on_value_change);
}
djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back);
sRestartText = djui_text_create(body, "");
djui_text_set_alignment(sRestartText, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
djui_base_set_color(&sRestartText->base, 255, 100, 100, 255);
djui_base_set_size_type(&sRestartText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&sRestartText->base, 1.0f, 64);
}
djui_panel_add(caller, panel, NULL);

View file

@ -5,24 +5,23 @@
#include "djui_panel_modlist.h"
#include "djui_panel_join_message.h"
#include "djui_lobby_entry.h"
#include "src/pc/network/network.h"
#include "src/pc/network/socket/socket.h"
#include "src/pc/network/coopnet/coopnet.h"
#include "src/pc/network/socket/domain_res.h"
#include "src/pc/utils/misc.h"
#include "src/pc/configfile.h"
#include "src/pc/debuglog.h"
#include "djui_panel_main.h"
#include "pc/network/network.h"
#include "pc/network/socket/socket.h"
#include "pc/network/coopnet/coopnet.h"
#include "pc/network/socket/domain_res.h"
#include "pc/utils/misc.h"
#include "pc/configfile.h"
#include "pc/debuglog.h"
#include "macros.h"
#include "pc/discord/discord.h"
static struct DjuiInputbox* sInputboxIp = NULL;
#ifndef COOPNET
static struct DjuiText* sRestartText = NULL;
static void djui_panel_compatibility_checkbox_on_value_change(UNUSED struct DjuiBase* caller) {
if (gCoopCompatibility != configCoopCompatibility) {
djui_text_set_text(sRestartText, DLANG(DISPLAY, MUST_RESTART));
} else {
djui_text_set_text(sRestartText, "");
gDiscordInitialized = false;
if (gVersionText != NULL) {
djui_text_set_text(gVersionText, get_version_local());
}
}
#endif
@ -184,7 +183,9 @@ void djui_panel_join_direct_create(struct DjuiBase* caller) {
djui_panel_join_direct_ip_text_set(inputbox1);
#ifndef COOPNET
djui_checkbox_create(body, DLANG(MISC, COOP_COMPATIBILITY), &configCoopCompatibility, djui_panel_compatibility_checkbox_on_value_change);
if (gDjuiInMainMenu) {
djui_checkbox_create(body, DLANG(MISC, COOP_COMPATIBILITY), &configCoopCompatibility, djui_panel_compatibility_checkbox_on_value_change);
}
#endif
struct DjuiRect* rect2 = djui_rect_container_create(body, 64);
@ -198,14 +199,6 @@ void djui_panel_join_direct_create(struct DjuiBase* caller) {
djui_base_set_alignment(&button2->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);
defaultBase = &button2->base;
}
#ifndef COOPNET
sRestartText = djui_text_create(body, "");
djui_text_set_alignment(sRestartText, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
djui_base_set_color(&sRestartText->base, 255, 100, 100, 255);
djui_base_set_size_type(&sRestartText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&sRestartText->base, 1.0f, 64);
#endif
}
djui_panel_add(caller, panel, defaultBase);

View file

@ -10,6 +10,8 @@
extern ALIGNED8 u8 texture_coopdx_logo[];
struct DjuiText* gVersionText = NULL;
bool gDjuiPanelMainCreated = false;
static void djui_panel_main_quit_yes(UNUSED struct DjuiBase* caller) {
@ -46,13 +48,11 @@ void djui_panel_main_create(struct DjuiBase* caller) {
djui_base_set_location(&button4->base, 0, -30.0f);
}
char version[MAX_VERSION_LENGTH];
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version_local());
struct DjuiText* footer = djui_text_create(&panel->base, version);
djui_base_set_size_type(&footer->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&footer->base, 1.0f, 1.0f);
djui_base_set_color(&footer->base, 50, 50, 50, 255);
djui_text_set_alignment(footer, DJUI_HALIGN_RIGHT, DJUI_VALIGN_BOTTOM);
gVersionText = djui_text_create(&panel->base, get_version_local());
djui_base_set_size_type(&gVersionText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&gVersionText->base, 1.0f, 1.0f);
djui_base_set_color(&gVersionText->base, 50, 50, 50, 255);
djui_text_set_alignment(gVersionText, DJUI_HALIGN_RIGHT, DJUI_VALIGN_BOTTOM);
}
djui_panel_add(caller, panel, NULL);

View file

@ -1,6 +1,8 @@
#pragma once
#include "djui.h"
extern struct DjuiText* gVersionText;
extern bool gDjuiPanelMainCreated;
void djui_panel_main_create(struct DjuiBase* caller);

View file

@ -9,16 +9,13 @@
#include "djui_panel_changelog.h"
#include "pc/utils/misc.h"
#include "pc/configfile.h"
#include "pc/pc_main.h"
#include "game/hardcoded.h"
static struct DjuiText* sRestartText = NULL;
#include "pc/discord/discord.h"
static void djui_panel_compatibility_checkbox_on_value_change(UNUSED struct DjuiBase* caller) {
if (gCoopCompatibility != configCoopCompatibility) {
djui_text_set_text(sRestartText, DLANG(DISPLAY, MUST_RESTART));
} else {
djui_text_set_text(sRestartText, "");
gDiscordInitialized = false;
if (gVersionText != NULL) {
djui_text_set_text(gVersionText, get_version_local());
}
}
@ -50,7 +47,9 @@ void djui_panel_misc_create(struct DjuiBase* caller) {
{
djui_checkbox_create(body, DLANG(MISC, DISABLE_POPUPS), &configDisablePopups, NULL);
djui_checkbox_create(body, DLANG(MISC, COOP_COMPATIBILITY), &configCoopCompatibility, djui_panel_compatibility_checkbox_on_value_change);
if (gDjuiInMainMenu) {
djui_checkbox_create(body, DLANG(MISC, COOP_COMPATIBILITY), &configCoopCompatibility, djui_panel_compatibility_checkbox_on_value_change);
}
#ifndef DEVELOPMENT
djui_checkbox_create(body, DLANG(MISC, LUA_PROFILER), &configLuaProfiler, NULL);
#endif
@ -63,19 +62,6 @@ void djui_panel_misc_create(struct DjuiBase* caller) {
djui_button_create(body, DLANG(MISC, DEBUG), DJUI_BUTTON_STYLE_NORMAL, djui_panel_options_debug_create);
#endif
djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back);
sRestartText = djui_text_create(body, "");
djui_text_set_alignment(sRestartText, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP);
djui_base_set_color(&sRestartText->base, 255, 100, 100, 255);
djui_base_set_size_type(&sRestartText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&sRestartText->base, 1.0f, 64);
}
// force the restart text to update
if (gCoopCompatibility != configCoopCompatibility) {
djui_text_set_text(sRestartText, DLANG(DISPLAY, MUST_RESTART));
} else {
djui_text_set_text(sRestartText, "");
}
djui_panel_add(caller, panel, NULL);

View file

@ -3,7 +3,6 @@
#include "mods.h"
#include "mods_utils.h"
#include "pc/debuglog.h"
#include "pc/pc_main.h"
#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
@ -29,7 +28,7 @@ void mods_size_enforce(struct Mods* mods) {
void mods_deluxe_enforce(struct Mods* mods) {
for (int i = 0; i < mods->entryCount; i++) {
struct Mod* mod = mods->entries[i];
if (mod->deluxe && gCoopCompatibility) {
if (mod->deluxe && configCoopCompatibility) {
mod->enabled = false;
mod->selectable = false;
}

View file

@ -25,7 +25,6 @@
#include "pc/mods/mods.h"
#include "pc/lua/smlua.h"
#include "pc/configfile.h"
#include "pc/pc_main.h"
extern u8* gOverrideEeprom;
static u8 eeprom[512] = { 0 };
@ -112,14 +111,14 @@ void network_send_join(struct Packet* joinRequestPacket) {
packet_write(&p, &globalIndex, sizeof(u8));
packet_write(&p, &gCurrSaveFileNum, sizeof(s16));
packet_write(&p, &gServerSettings.playerInteractions, sizeof(u8));
if (!gCoopCompatibility) { packet_write(&p, &gServerSettings.bouncyLevelBounds, sizeof(u8)); }
if (!configCoopCompatibility) { packet_write(&p, &gServerSettings.bouncyLevelBounds, sizeof(u8)); }
packet_write(&p, &gServerSettings.playerKnockbackStrength, sizeof(u8));
packet_write(&p, &gServerSettings.stayInLevelAfterStar, sizeof(u8));
packet_write(&p, &gServerSettings.skipIntro, sizeof(u8));
packet_write(&p, &gServerSettings.enableCheats, sizeof(u8));
packet_write(&p, &gServerSettings.bubbleDeath, sizeof(u8));
packet_write(&p, &gServerSettings.headlessServer, sizeof(u8));
if (!gCoopCompatibility) { packet_write(&p, &gServerSettings.nametags, sizeof(u8)); }
if (!configCoopCompatibility) { packet_write(&p, &gServerSettings.nametags, sizeof(u8)); }
packet_write(&p, &gServerSettings.maxPlayers, sizeof(u8));
packet_write(&p, eeprom, sizeof(u8) * 512);
@ -164,7 +163,7 @@ void network_receive_join(struct Packet* p) {
packet_read(p, &myGlobalIndex, sizeof(u8));
packet_read(p, &gCurrSaveFileNum, sizeof(s16));
packet_read(p, &gServerSettings.playerInteractions, sizeof(u8));
if (!gCoopCompatibility) {
if (!configCoopCompatibility) {
packet_read(p, &gServerSettings.bouncyLevelBounds, sizeof(u8));
} else {
gServerSettings.bouncyLevelBounds = BOUNCY_LEVEL_BOUNDS_OFF;
@ -175,7 +174,7 @@ void network_receive_join(struct Packet* p) {
packet_read(p, &gServerSettings.enableCheats, sizeof(u8));
packet_read(p, &gServerSettings.bubbleDeath, sizeof(u8));
packet_read(p, &gServerSettings.headlessServer, sizeof(u8));
if (!gCoopCompatibility) {
if (!configCoopCompatibility) {
packet_read(p, &gServerSettings.nametags, sizeof(u8));
} else {
gServerSettings.nametags = false;

View file

@ -5,7 +5,6 @@
#include "pc/djui/djui.h"
#include "pc/djui/djui_panel_join_message.h"
#include "pc/debuglog.h"
#include "pc/pc_main.h"
#include "pc/mods/mod_cache.h"
void network_send_mod_list_request(void) {
@ -86,7 +85,7 @@ void network_send_mod_list(void) {
packet_write(&p, mod->relativePath, sizeof(u8) * relativePathLength);
packet_write(&p, &modSize, sizeof(u64));
packet_write(&p, &mod->isDirectory, sizeof(u8));
if (!gCoopCompatibility) {
if (!configCoopCompatibility) {
packet_write(&p, &mod->deluxe, sizeof(u8));
}
packet_write(&p, &mod->fileCount, sizeof(u16));
@ -227,7 +226,7 @@ void network_receive_mod_list_entry(struct Packet* p) {
packet_read(p, mod->relativePath, relativePathLength * sizeof(u8));
packet_read(p, &mod->size, sizeof(u64));
packet_read(p, &mod->isDirectory, sizeof(u8));
if (!gCoopCompatibility) {
if (!configCoopCompatibility) {
packet_read(p, &mod->deluxe, sizeof(u8));
}
normalize_path(mod->relativePath);

View file

@ -1,7 +1,6 @@
#include <stdio.h>
#include "version.h"
#include "types.h"
#include "pc/pc_main.h"
#undef VERSION_TEXT
#define VERSION_TEXT "v"
@ -10,7 +9,7 @@ static char sVersionString[MAX_VERSION_LENGTH] = { 0 };
static char sLocalVersionString[MAX_LOCAL_VERSION_LENGTH] = { 0 };
const char* get_version(void) {
if (gCoopCompatibility) {
if (configCoopCompatibility) {
#if defined(VERSION_US)
if (MINOR_VERSION_NUMBER > 0) {
snprintf(sVersionString, MAX_VERSION_LENGTH, "%s%d.%d", VERSION_TEXT, VERSION_NUMBER, MINOR_VERSION_NUMBER);
@ -39,7 +38,7 @@ const char* get_version_local(void) {
return get_version();
}
if (gCoopCompatibility) {
if (configCoopCompatibility) {
#if defined(VERSION_US)
snprintf(sLocalVersionString, MAX_LOCAL_VERSION_LENGTH, "%s%d.%d.%d", VERSION_TEXT, VERSION_NUMBER, MINOR_VERSION_NUMBER, PATCH_VERSION_NUMBER);
#else
@ -57,7 +56,7 @@ const char* get_version_local(void) {
}
const char* get_game_name(void) {
if (gCoopCompatibility) {
if (configCoopCompatibility) {
#ifdef DEVELOPMENT
return "sm64ex-coop-dev";
#elif !defined(VERSION_US)

View file

@ -60,8 +60,6 @@
#include <windows.h>
#endif
bool gCoopCompatibility;
OSMesg D_80339BEC;
OSMesgQueue gSIEventMesgQueue;
@ -316,8 +314,6 @@ void* main_game_init(UNUSED void* arg) {
} else if (memcmp(&configPlayerPalette, &gPalettePresets[i], sizeof(struct PlayerPalette)) == 0) { break; }
}
gCoopCompatibility = configCoopCompatibility;
if (gCLIOpts.FullScreen == 1) { configWindow.fullscreen = true; }
else if (gCLIOpts.FullScreen == 2) { configWindow.fullscreen = false; }

View file

@ -15,8 +15,6 @@ extern "C" {
#include "gfx/gfx_sdl.h"
#include "gfx/gfx_dummy.h"
extern bool gCoopCompatibility;
#if defined(WAPI_SDL1) || defined(WAPI_SDL2)
# define WAPI gfx_sdl
#elif defined(WAPI_DXGI)