diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 4d19ac5e..3d954a23 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -7749,6 +7749,11 @@ function get_current_save_file_num() -- ... end +--- @return integer +function get_dialog_box_state() + -- ... +end + --- @return integer function get_dialog_id() -- ... diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index 5e62a467..b952265a 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -6830,6 +6830,24 @@
+## [get_dialog_box_state](#get_dialog_box_state) + +### Lua Example +`local integerValue = get_dialog_box_state()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`s8 get_dialog_box_state();` + +[:arrow_up_small:](#) + +
+ ## [get_dialog_id](#get_dialog_id) ### Lua Example diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 758ad9a1..d3df6275 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -1454,6 +1454,7 @@ - [camera_unfreeze](functions-4.md#camera_unfreeze) - [deref_s32_pointer](functions-4.md#deref_s32_pointer) - [get_current_save_file_num](functions-4.md#get_current_save_file_num) + - [get_dialog_box_state](functions-4.md#get_dialog_box_state) - [get_dialog_id](functions-4.md#get_dialog_id) - [get_environment_region](functions-4.md#get_environment_region) - [get_hand_foot_pos_x](functions-4.md#get_hand_foot_pos_x) diff --git a/mods/arena/camera.lua b/mods/arena/camera.lua index 6e61bc6d..aeab34dc 100644 --- a/mods/arena/camera.lua +++ b/mods/arena/camera.lua @@ -17,11 +17,7 @@ local m = gMarioStates[0] function override_camera() local np = gNetworkPlayers[0] - if sOverrideCameraModes[m.area.camera.mode] == nil then - return - end - - if (np.currLevelNum == LEVEL_BOWSER_1 or np.currLevelNum == LEVEL_BOWSER_2 or np.currLevelNum == LEVEL_BOWSER_3) then + if sOverrideCameraModes[m.area.camera.mode] == nil or np.currLevelNum == LEVEL_BOWSER_1 or np.currLevelNum == LEVEL_BOWSER_2 or np.currLevelNum == LEVEL_BOWSER_3 then return end @@ -29,21 +25,11 @@ function override_camera() end function on_set_camera_mode(c, mode, frames) - if mode == CAMERA_MODE_ROM_HACK then - return true - end - - if sOverrideCameraModes[mode] ~= nil then + if sOverrideCameraModes[mode] ~= nil and mode ~= CAMERA_MODE_ROM_HACK then -- do not allow change - if mode ~= CAMERA_MODE_ROM_HACK then - set_camera_mode(c, CAMERA_MODE_ROM_HACK, frames) - return false - end + set_camera_mode(c, CAMERA_MODE_ROM_HACK, frames) return false end - - -- allow camera change - return true end hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode) diff --git a/mods/sm74/camera.lua b/mods/sm74/camera.lua index 93edb42c..eadffdc2 100644 --- a/mods/sm74/camera.lua +++ b/mods/sm74/camera.lua @@ -15,11 +15,7 @@ local m = gMarioStates[0] function override_camera() local np = gNetworkPlayers[0] - if sOverrideCameraModes[m.area.camera.mode] == nil then - return - end - - if (np.currLevelNum == LEVEL_BOWSER_1 or np.currLevelNum == LEVEL_BOWSER_2 or np.currLevelNum == LEVEL_BOWSER_3) then + if sOverrideCameraModes[m.area.camera.mode] == nil or np.currLevelNum == LEVEL_BOWSER_1 or np.currLevelNum == LEVEL_BOWSER_2 or np.currLevelNum == LEVEL_BOWSER_3 then return end @@ -27,21 +23,11 @@ function override_camera() end function on_set_camera_mode(c, mode, frames) - if mode == CAMERA_MODE_ROM_HACK then - return true - end - - if sOverrideCameraModes[mode] ~= nil then + if sOverrideCameraModes[mode] ~= nil and mode ~= CAMERA_MODE_ROM_HACK then -- do not allow change - if mode ~= CAMERA_MODE_ROM_HACK then - set_camera_mode(c, CAMERA_MODE_ROM_HACK, frames) - return false - end + set_camera_mode(c, CAMERA_MODE_ROM_HACK, frames) return false end - - -- allow camera change - return true end hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode) diff --git a/mods/star-road/camera.lua b/mods/star-road/camera.lua index 93edb42c..eadffdc2 100644 --- a/mods/star-road/camera.lua +++ b/mods/star-road/camera.lua @@ -15,11 +15,7 @@ local m = gMarioStates[0] function override_camera() local np = gNetworkPlayers[0] - if sOverrideCameraModes[m.area.camera.mode] == nil then - return - end - - if (np.currLevelNum == LEVEL_BOWSER_1 or np.currLevelNum == LEVEL_BOWSER_2 or np.currLevelNum == LEVEL_BOWSER_3) then + if sOverrideCameraModes[m.area.camera.mode] == nil or np.currLevelNum == LEVEL_BOWSER_1 or np.currLevelNum == LEVEL_BOWSER_2 or np.currLevelNum == LEVEL_BOWSER_3 then return end @@ -27,21 +23,11 @@ function override_camera() end function on_set_camera_mode(c, mode, frames) - if mode == CAMERA_MODE_ROM_HACK then - return true - end - - if sOverrideCameraModes[mode] ~= nil then + if sOverrideCameraModes[mode] ~= nil and mode ~= CAMERA_MODE_ROM_HACK then -- do not allow change - if mode ~= CAMERA_MODE_ROM_HACK then - set_camera_mode(c, CAMERA_MODE_ROM_HACK, frames) - return false - end + set_camera_mode(c, CAMERA_MODE_ROM_HACK, frames) return false end - - -- allow camera change - return true end hook_event(HOOK_ON_SET_CAMERA_MODE, on_set_camera_mode) diff --git a/src/game/behaviors/bowser_key.inc.c b/src/game/behaviors/bowser_key.inc.c index 2e195b71..65a9d262 100644 --- a/src/game/behaviors/bowser_key.inc.c +++ b/src/game/behaviors/bowser_key.inc.c @@ -45,8 +45,6 @@ void bhv_bowser_key_loop(void) { } else { obj_set_hitbox(o, &sBowserKeyHitbox); if (o->oInteractStatus & INT_STATUS_INTERACTED) { - extern u8 gLastCollectedStarOrKey; - gLastCollectedStarOrKey = 1; mark_obj_for_deletion(o); o->oInteractStatus = 0; } diff --git a/src/game/behaviors/sparkle_spawn_star.inc.c b/src/game/behaviors/sparkle_spawn_star.inc.c index 045fb40a..488cbccd 100644 --- a/src/game/behaviors/sparkle_spawn_star.inc.c +++ b/src/game/behaviors/sparkle_spawn_star.inc.c @@ -35,8 +35,6 @@ void bhv_spawned_star_init(void) { void set_sparkle_spawn_star_hitbox(void) { obj_set_hitbox(o, &sSparkleSpawnStarHitbox); if (o->oInteractStatus & INT_STATUS_INTERACTED) { - extern u8 gLastCollectedStarOrKey; - gLastCollectedStarOrKey = 0; mark_obj_for_deletion(o); o->oInteractStatus = 0; } diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c index 76f3fab0..203e29e0 100644 --- a/src/game/behaviors/spawn_star.inc.c +++ b/src/game/behaviors/spawn_star.inc.c @@ -31,8 +31,6 @@ void bhv_collect_star_loop(void) { o->oFaceAngleYaw += 0x800; if (o->oInteractStatus & INT_STATUS_INTERACTED) { - extern u8 gLastCollectedStarOrKey; - gLastCollectedStarOrKey = 0; mark_obj_for_deletion(o); o->oInteractStatus = 0; } diff --git a/src/game/hardcoded.h b/src/game/hardcoded.h index 3e3251cf..0f7ff890 100644 --- a/src/game/hardcoded.h +++ b/src/game/hardcoded.h @@ -37,7 +37,7 @@ struct StarPositions { }; struct LevelValues { - u8 fixCollisionBugs; + bool fixCollisionBugs; enum LevelNum entryLevel; enum LevelNum exitCastleLevel; s16 exitCastleArea; diff --git a/src/game/interaction.c b/src/game/interaction.c index 87b5fdc9..db4f05e7 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -144,6 +144,7 @@ static u32 sBackwardKnockbackActions[][3] = { static u8 sDisplayingDoorText = FALSE; static u8 sJustTeleported = FALSE; u8 gPssSlideStarted = FALSE; +extern u8 gLastCollectedStarOrKey; /** * Returns the type of cap Mario is wearing. @@ -890,6 +891,12 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O u8 stayInLevelCommon = !(gCurrLevelNum == LEVEL_BOWSER_1 || gCurrLevelNum == LEVEL_BOWSER_2 || gCurrLevelNum == LEVEL_BOWSER_3); if (stayInLevelCommon && gServerSettings.stayInLevelAfterStar) { noExit = TRUE; } + if (o->behavior == bhvBowserKey) { + gLastCollectedStarOrKey = 1; + } else { + gLastCollectedStarOrKey = 0; + } + if (m->health >= 0x100) { mario_stop_riding_and_holding(m); queue_rumble_data_mario(m, 5, 80); @@ -1336,7 +1343,11 @@ u8 passes_pvp_interaction_checks(struct MarioState* attacker, struct MarioState* isInCutscene = isInCutscene || (attacker->action == ACT_IN_CANNON) || (victim->action == ACT_IN_CANNON); u8 isAttackerInvulnerable = (attacker->action & ACT_FLAG_INVULNERABLE) || attacker->invincTimer != 0 || attacker->hurtCounter != 0; u8 isInvulnerable = (victim->action & ACT_FLAG_INVULNERABLE) || victim->invincTimer != 0 || victim->hurtCounter != 0 || isInCutscene; - u8 isIgnoredAttack = (attacker->action == ACT_JUMP || attacker->action == ACT_DOUBLE_JUMP || attacker->action == ACT_LONG_JUMP || attacker->action == ACT_SIDE_FLIP); + u8 isIgnoredAttack = (attacker->action == ACT_JUMP || attacker->action == ACT_DOUBLE_JUMP + || attacker->action == ACT_LONG_JUMP || attacker->action == ACT_SIDE_FLIP + || attacker->action == ACT_BACKFLIP || attacker->action == ACT_TRIPLE_JUMP + || attacker->action == ACT_WALL_KICK_AIR || attacker->action == ACT_WATER_JUMP + || attacker->action == ACT_STEEP_JUMP || attacker->action == ACT_HOLD_JUMP); u8 isVictimIntangible = (victim->action & ACT_FLAG_INTANGIBLE); if (victim->knockbackTimer > 0) { return false; diff --git a/src/game/level_update.c b/src/game/level_update.c index b7fba3f4..c880558e 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -1328,6 +1328,12 @@ void update_menu_level(void) { case 8: curLevel = LEVEL_BBH; break; case 9: curLevel = LEVEL_LLL; break; case 10: curLevel = LEVEL_THI; break; + case 11: curLevel = LEVEL_HMC; break; + case 12: curLevel = LEVEL_CCM; break; + case 13: curLevel = LEVEL_RR; break; + case 14: curLevel = LEVEL_BITDW; break; + case 15: curLevel = LEVEL_PSS; break; + case 16: curLevel = LEVEL_TTC; break; default: curLevel = LEVEL_CASTLE_GROUNDS; break; } @@ -1433,6 +1439,35 @@ void update_menu_level(void) { obj_mark_for_deletion(o); } break; + case LEVEL_HMC: + vec3f_set(gMarioState->pos, -3600, -4279, 3616); + vec3f_set(gLakituState.curPos, -6000, -2938, 600); + gMarioState->faceAngle[1] = -0x6000; + break; + case LEVEL_CCM: + vec3f_set(gMarioState->pos, -1127, -3580, 6162); + vec3f_set(gLakituState.curPos, -1330, -2830, 9099); + gMarioState->faceAngle[1] = -0x1000; + break; + case LEVEL_RR: + vec3f_set(gMarioState->pos, 1418, 3167, -2349); + vec3f_set(gLakituState.curPos, -1518, 4567, -4549); + gMarioState->faceAngle[1] = -0x6000; + break; + case LEVEL_BITDW: + vec3f_set(gMarioState->pos, -4507, 1126, -285); + vec3f_set(gLakituState.curPos, -2507, 2126, -285); + break; + case LEVEL_PSS: + vec3f_set(gMarioState->pos, -4729, -3057, -3025); + vec3f_set(gLakituState.curPos, -2729, -1557, -5025); + gMarioState->faceAngle[1] = 0x5000; + break; + case LEVEL_TTC: + vec3f_set(gMarioState->pos, -645, 0, -750); + vec3f_set(gLakituState.curPos, 2500, 570, -240); + gMarioState->faceAngle[1] = 0x2000; + break; } gMarioState->health = 0x880; diff --git a/src/game/mario.c b/src/game/mario.c index d714ea9c..04a51e05 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -2095,7 +2095,8 @@ s32 execute_mario_action(UNUSED struct Object *o) { // Both of the wind handling portions play wind audio only in // non-Japanese releases. - if (gMarioState->floor->type == SURFACE_HORIZONTAL_WIND) { + extern bool gDjuiInMainMenu; + if (gMarioState->floor->type == SURFACE_HORIZONTAL_WIND && !gDjuiInMainMenu) { spawn_wind_particles(0, (gMarioState->floor->force << 8)); #ifndef VERSION_JP play_sound(SOUND_ENV_WIND2, gMarioState->marioObj->header.gfx.cameraToObject); diff --git a/src/game/mario_step.c b/src/game/mario_step.c index a1e1d921..7fbce03e 100644 --- a/src/game/mario_step.c +++ b/src/game/mario_step.c @@ -194,7 +194,8 @@ u32 mario_update_moving_sand(struct MarioState *m) { u32 mario_update_windy_ground(struct MarioState *m) { struct Surface *floor = m->floor; - if (floor->type == SURFACE_HORIZONTAL_WIND) { + extern bool gDjuiInMainMenu; + if (floor->type == SURFACE_HORIZONTAL_WIND && !gDjuiInMainMenu) { f32 pushSpeed; s16 pushAngle = floor->force << 8; diff --git a/src/pc/chat_commands.c b/src/pc/chat_commands.c index 51c5086b..f7b33df1 100644 --- a/src/pc/chat_commands.c +++ b/src/pc/chat_commands.c @@ -10,7 +10,7 @@ #include "level_table.h" -extern u8 gIsModerator; +extern bool gIsModerator; static enum ChatConfirmCommand sConfirming = CCC_NONE; static u8 sConfirmPlayerIndex = 0; @@ -46,7 +46,7 @@ bool exec_chat_command(char* command) { sConfirming = CCC_NONE; if (ccc != CCC_NONE && strcmp("/confirm", command) == 0) { - if (gNetworkType == NT_SERVER || gIsModerator == 1) { + if (gNetworkType == NT_SERVER || gIsModerator) { if (ccc == CCC_KICK) { struct NetworkPlayer* np = &gNetworkPlayers[sConfirmPlayerIndex]; if (!np->connected) { return true; } @@ -62,7 +62,7 @@ bool exec_chat_command(char* command) { return true; } } - if (gNetworkType == NT_SERVER || gIsModerator == 1) { + if (gNetworkType == NT_SERVER || gIsModerator) { if (ccc == CCC_BAN) { struct NetworkPlayer* np = &gNetworkPlayers[sConfirmPlayerIndex]; if (!np->connected) { return true; } @@ -120,7 +120,7 @@ bool exec_chat_command(char* command) { } if (str_starts_with("/kick ", command)) { - if (gNetworkType != NT_SERVER && gIsModerator == 0) { + if (gNetworkType != NT_SERVER && !gIsModerator) { djui_chat_message_create("You do not have permission to use this command."); return true; } @@ -147,7 +147,7 @@ bool exec_chat_command(char* command) { } if (str_starts_with("/ban ", command)) { - if (gNetworkType != NT_SERVER && gIsModerator == 0) { + if (gNetworkType != NT_SERVER && !gIsModerator) { djui_chat_message_create("You do not have permission to use this command."); return true; } @@ -174,7 +174,7 @@ bool exec_chat_command(char* command) { } if (str_starts_with("/permban ", command)) { - if (gNetworkType != NT_SERVER && gIsModerator == 0) { + if (gNetworkType != NT_SERVER && !gIsModerator) { djui_chat_message_create("You do not have permission to use this command."); return true; } @@ -319,7 +319,7 @@ bool exec_chat_command(char* command) { void display_chat_commands(void) { djui_chat_message_create("/players - List all players and their IDs"); - if (gNetworkType == NT_SERVER || gIsModerator == 1) { + if (gNetworkType == NT_SERVER || gIsModerator) { djui_chat_message_create("/kick [NAME|ID] - Kick this player from the current game"); djui_chat_message_create("/ban [NAME|ID] - Ban this player from the current game"); djui_chat_message_create("/permban [NAME|ID] - Ban this player from any game you host"); diff --git a/src/pc/djui/djui_panel_join.c b/src/pc/djui/djui_panel_join.c index 1ee72117..a57d0573 100644 --- a/src/pc/djui/djui_panel_join.c +++ b/src/pc/djui/djui_panel_join.c @@ -100,7 +100,6 @@ static void djui_panel_join_ip_text_change(struct DjuiBase* caller) { static void djui_panel_join_ip_text_set_new(void) { char buffer[256] = { 0 }; - gGetHostName = sInputboxIp->buffer; if (snprintf(buffer, 256, "%s", sInputboxIp->buffer) < 0) { LOG_INFO("truncating IP"); } @@ -119,6 +118,9 @@ static void djui_panel_join_ip_text_set_new(void) { } } + gGetHostName = buffer; + printf("gGetHostName: %s\n", gGetHostName); /* Log the value of gGetHostName. + For some reason this fixes some formatting issues? LOG_INFO isn't working at all in this file. */ if (snprintf(configJoinIp, MAX_CONFIG_STRING, "%s", buffer) < 0) { LOG_INFO("truncating IP"); } @@ -140,7 +142,6 @@ static void djui_panel_join_ip_text_set(struct DjuiInputbox* inputbox1) { } djui_inputbox_set_text(inputbox1, buffer); - djui_inputbox_select_all(inputbox1); } void djui_panel_join_do_join(struct DjuiBase* caller) { diff --git a/src/pc/djui/djui_panel_menu_options.c b/src/pc/djui/djui_panel_menu_options.c index 131c6bcf..dddb7445 100644 --- a/src/pc/djui/djui_panel_menu_options.c +++ b/src/pc/djui/djui_panel_menu_options.c @@ -16,7 +16,7 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { struct DjuiFlowLayout* body = (struct DjuiFlowLayout*)djui_three_panel_get_body(panel); { - char* levelChoices[11] = { + char* levelChoices[17] = { "CG", "BOB", "WF", @@ -28,8 +28,14 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { "BBH", "LLL", "THI", + "HMC", + "CCM", + "RR", + "BITDW", + "PSS", + "TTC", }; - struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(&body->base, "Level", levelChoices, 11, &configMenuLevel); + struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(&body->base, "Level", levelChoices, 17, &configMenuLevel); djui_base_set_size_type(&selectionbox1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&selectionbox1->base, 1.0f, 32); djui_base_set_enabled(&selectionbox1->base, !configMenuRandom); diff --git a/src/pc/djui/djui_panel_misc.c b/src/pc/djui/djui_panel_misc.c index f4625c0d..bdd98dc5 100644 --- a/src/pc/djui/djui_panel_misc.c +++ b/src/pc/djui/djui_panel_misc.c @@ -1,6 +1,7 @@ #include "djui.h" #include "src/pc/utils/misc.h" #include "src/pc/configfile.h" +#include "game/hardcoded.h" #ifdef DEVELOPMENT void djui_panel_options_debug_create(struct DjuiBase* caller) { @@ -16,6 +17,11 @@ void djui_panel_options_debug_create(struct DjuiBase* caller) { djui_base_set_size(&checkbox1->base, 1.0f, 32); defaultBase = &checkbox1->base; + struct DjuiCheckbox* checkbox2 = djui_checkbox_create(&body->base, "Fixed Collisions", &gLevelValues.fixCollisionBugs); + djui_base_set_size_type(&checkbox2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&checkbox2->base, 1.0f, 32); + defaultBase = &checkbox2->base; + struct DjuiButton* button2 = djui_button_create(&body->base, "Back"); djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&button2->base, 1.0f, 64); diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 35029600..52ffd01c 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -17076,6 +17076,15 @@ int smlua_func_get_current_save_file_num(UNUSED lua_State* L) { return 1; } +int smlua_func_get_dialog_box_state(UNUSED lua_State* L) { + if(!smlua_functions_valid_param_count(L, 0)) { return 0; } + + + lua_pushinteger(L, get_dialog_box_state()); + + return 1; +} + int smlua_func_get_dialog_id(UNUSED lua_State* L) { if(!smlua_functions_valid_param_count(L, 0)) { return 0; } @@ -19689,6 +19698,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "camera_unfreeze", smlua_func_camera_unfreeze); smlua_bind_function(L, "deref_s32_pointer", smlua_func_deref_s32_pointer); smlua_bind_function(L, "get_current_save_file_num", smlua_func_get_current_save_file_num); + smlua_bind_function(L, "get_dialog_box_state", smlua_func_get_dialog_box_state); smlua_bind_function(L, "get_dialog_id", smlua_func_get_dialog_id); smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region); smlua_bind_function(L, "get_hand_foot_pos_x", smlua_func_get_hand_foot_pos_x); diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index 4b7a68a1..1e2aba10 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -57,6 +57,11 @@ void set_last_star_or_key(u8 value) { gLastCollectedStarOrKey = value; } +extern s8 gDialogBoxState; +s8 get_dialog_box_state() { + return gDialogBoxState; +} + s32 hud_get_value(enum HudDisplayValue type) { switch (type) { case HUD_DISPLAY_LIVES: return gHudDisplay.lives; diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index b2ecf196..45ed1df3 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -64,6 +64,7 @@ void camera_config_set_deceleration(u32 value); bool is_game_paused(void); bool is_transition_playing(void); +s8 get_dialog_box_state(); s16 get_dialog_id(void); s32 get_last_star_or_key(void); void set_last_star_or_key(u8 value); diff --git a/src/pc/network/network.c b/src/pc/network/network.c index 3b3d776a..4c58e1d4 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -535,8 +535,8 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup) { extern s16 gMenuMode; gMenuMode = -1; - extern u8 gIsModerator; - gIsModerator = 0; + extern bool gIsModerator; + gIsModerator = false; djui_panel_shutdown(); extern bool gDjuiInMainMenu; diff --git a/src/pc/network/network_player.c b/src/pc/network/network_player.c index 0dfdaf58..cd9a5e49 100644 --- a/src/pc/network/network_player.c +++ b/src/pc/network/network_player.c @@ -412,7 +412,7 @@ void network_player_update_course_level(struct NetworkPlayer* np, s16 courseNum, } // If this machine's player changed to a different location, then all of the other np locations are no longer valid - for (u32 i = 0; i < MAX_PLAYERS + 1; i++) { + for (u32 i = 1; i < configAmountofPlayers; i++) { struct NetworkPlayer* npi = &gNetworkPlayers[i]; if ((!npi->connected) || npi == gNetworkPlayerLocal) { continue; } npi->currPositionValid = false; diff --git a/src/pc/network/network_utils.c b/src/pc/network/network_utils.c index 0dce3266..7be8fbc1 100644 --- a/src/pc/network/network_utils.c +++ b/src/pc/network/network_utils.c @@ -23,8 +23,12 @@ u8 network_local_index_from_global(u8 globalIndex) { return globalIndex + ((globalIndex < gNetworkPlayerLocal->globalIndex) ? 1 : 0); } +#ifdef DISCORD_SDK char* network_discord_id_from_local_index(u8 localIndex) { if (gNetworkSystem == &gNetworkSystemDiscord) { return gNetworkSystem->get_id_str(localIndex); } +#else +char* network_discord_id_from_local_index(UNUSED u8 localIndex) { +#endif return NULL; } @@ -33,7 +37,7 @@ bool network_is_server(void) { } bool network_is_moderator(void) { - extern u8 gIsModerator; + extern bool gIsModerator; return gIsModerator; } diff --git a/src/pc/network/packets/packet_command_mod.c b/src/pc/network/packets/packet_command_mod.c index 6e022640..2f933c35 100644 --- a/src/pc/network/packets/packet_command_mod.c +++ b/src/pc/network/packets/packet_command_mod.c @@ -4,10 +4,10 @@ #include "pc/network/ban_list.h" #include "pc/network/moderator_list.h" -u8 gIsModerator = 0; +bool gIsModerator = false; void network_send_chat_command(u8 globalIndex, enum ChatConfirmCommand ccc) { - if (gIsModerator == 1) { + if (gIsModerator) { u8 cccType = ccc; struct Packet p = { 0 }; packet_init(&p, PACKET_COMMAND, false, PLMT_NONE); @@ -17,7 +17,7 @@ void network_send_chat_command(u8 globalIndex, enum ChatConfirmCommand ccc) { } } -void network_recieve_chat_command(struct Packet* p) { +void network_recieve_chat_command(struct Packet *p) { if (!moderator_list_contains(gNetworkSystem->get_id_str(p->localIndex))) { return; } @@ -26,22 +26,28 @@ void network_recieve_chat_command(struct Packet* p) { packet_read(p, &player, sizeof(u8)); packet_read(p, &CCC, sizeof(u8)); if (gNetworkType == NT_SERVER && CCC == CCC_KICK) { - struct NetworkPlayer* np = &gNetworkPlayers[player]; - if (!np->connected) { return; } + struct NetworkPlayer *np = &gNetworkPlayers[player]; + if (!np->connected) { + return; + } network_send_kick(np->localIndex, EKT_KICKED); network_player_disconnected(np->localIndex); char message[256] = { 0 }; - snprintf(message, 256, "\\#fff982\\Kicked '%s%s\\#fff982\\'!", network_get_player_text_color_string(np->localIndex), np->name); + snprintf(message, 256, "\\#fff982\\Kicked '%s%s\\#fff982\\'!", + network_get_player_text_color_string(np->localIndex), np->name); djui_chat_message_create(message); } if (gNetworkType == NT_SERVER && CCC == CCC_BAN) { - struct NetworkPlayer* np = &gNetworkPlayers[player]; - if (!np->connected) { return; } + struct NetworkPlayer *np = &gNetworkPlayers[player]; + if (!np->connected) { + return; + } network_send_kick(np->localIndex, EKT_BANNED); ban_list_add(gNetworkSystem->get_id_str(np->localIndex), false); network_player_disconnected(np->localIndex); char message[256] = { 0 }; - snprintf(message, 256, "\\#fff982\\Banned '%s%s\\#fff982\\'!", network_get_player_text_color_string(np->localIndex), np->name); + snprintf(message, 256, "\\#fff982\\Banned '%s%s\\#fff982\\'!", + network_get_player_text_color_string(np->localIndex), np->name); djui_chat_message_create(message); } } @@ -52,15 +58,11 @@ void network_send_moderator(u8 localIndex) { network_send_to(localIndex, &p); } -void network_recieve_moderator(struct Packet* p) { - if (gIsModerator == 1) { +void network_recieve_moderator(struct Packet *p) { + if ((gIsModerator) || (network_player_any_connected() && gNetworkPlayers[p->localIndex].type != NPT_SERVER)) { return; } - if (network_player_any_connected() && gNetworkPlayers[p->localIndex].type != NPT_SERVER) { - return; - } - - gIsModerator = 1; + gIsModerator = true; djui_chat_message_create("\\#fff982\\You are now a Moderator."); } \ No newline at end of file diff --git a/src/pc/network/packets/packet_kick.c b/src/pc/network/packets/packet_kick.c index 0a16c60a..9d44939f 100644 --- a/src/pc/network/packets/packet_kick.c +++ b/src/pc/network/packets/packet_kick.c @@ -27,10 +27,10 @@ void network_receive_kick(struct Packet* p) { enum KickReasonType kickReason = kickReasonType; switch (kickReason) { - case EKT_FULL_PARTY: djui_panel_join_message_error("\\#ffa0a0\\Error:\\#c8c8c8\\ The party is full."); break; - case EKT_KICKED: djui_panel_join_message_error("\\#ffa0a0\\Error:\\#c8c8c8\\ The server kicked you."); break; - case EKT_BANNED: djui_panel_join_message_error("\\#ffa0a0\\Error:\\#c8c8c8\\ The server banned you."); break; - default: djui_panel_join_message_error("\\#ffa0a0\\Error:\\#c8c8c8\\ Host has closed the connection."); break; + case EKT_FULL_PARTY: djui_popup_create("\\#ffa0a0\\Disconnected:\\#c8c8c8\\ The party is full.", 1); break; + case EKT_KICKED: djui_popup_create("\\#ffa0a0\\Disconnected:\\#c8c8c8\\ The server kicked you.", 1); break; + case EKT_BANNED: djui_popup_create("\\#ffa0a0\\Disconnected:\\#c8c8c8\\ The server banned you.", 1); break; + default: djui_popup_create("\\#ffa0a0\\Disconnected:\\#c8c8c8\\ Host has closed the connection.", 1); break; } network_shutdown(false, false, false); } diff --git a/src/pc/network/socket/domain_res.c b/src/pc/network/socket/domain_res.c index 673fc2f3..5a46f96f 100644 --- a/src/pc/network/socket/domain_res.c +++ b/src/pc/network/socket/domain_res.c @@ -10,13 +10,13 @@ #include #endif -char* gGetHostName = NULL; +char *gGetHostName = NULL; void domain_resolution(void) { struct in_addr addr; char *host_name = configJoinIp; struct hostent *remoteHost; - char* domainname = ""; + char *domainname = ""; if (gGetHostName == NULL) { return; diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 351e5838..1fee6cdc 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -1,7 +1,9 @@ #include #include #include +#ifndef _WIN32 #include +#endif #include "sm64.h" @@ -390,14 +392,10 @@ void main_func(void) { } int main(int argc, char *argv[]) { +#ifndef _WIN32 #ifdef SIGINT signal(SIGINT, inthand); #endif -#ifdef SIGQUIT - signal(SIGQUIT, inthand); -#endif -#ifdef SIGTERM - signal(SIGTERM, inthand); #endif parse_cli_opts(argc, argv); main_func();