Fix #400 and divide by zero (#454)

* Divide by zero fix & cup restart behavior fix

* CI Test

* Fix a divide by zero bug. Fix for cups when using the reset button

* Added defines, renamed function

---------

Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
This commit is contained in:
Dave Demers
2025-07-19 18:59:21 -04:00
committed by GitHub
parent bc9686f1a3
commit d62d4bb900
6 changed files with 25 additions and 9 deletions
+4 -2
View File
@@ -66,12 +66,14 @@ s8 gCharacterSelections[4] = { MARIO, LUIGI, YOSHI, TOAD };
// The current row selected in the mode column for each player indexed
// 0-1 1p / 0-2 2p´/ 0-1 3p / 0-1 4p
s8 gGameModeMenuColumn[4] = { 0, 0, 0, 0 };
s8 gGameModeMenuColumn[NUM_ROWS_GAME_MODE_MENU] = { 0, 0, 0, 0 };
// For Grand Prix and Versus, this will be the CC mode selected. For Time Trials, it will
// be whether 'Begin' or 'Data' is selected. Not used for Battle.
// indexed as [column][row]
s8 gGameModeSubMenuColumn[4][3] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
s8 gGameModeSubMenuColumn[NUM_COLUMN_GAME_MODE_SUB_MENU][NUM_ROWS_GAME_MODE_SUB_MENU] = {
{ 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }
};
s8 gNextDemoId = 0;
s8 gControllerPakSelectedTableRow = 0; // 0-4 index, value of the current visible row select
+5 -1
View File
@@ -190,6 +190,10 @@ enum ControllerPakScrollDirectionTypes {
CONTROLLER_PAK_SCROLL_DIR_UP
};
#define NUM_ROWS_GAME_MODE_MENU 4
#define NUM_COLUMN_GAME_MODE_SUB_MENU 4
#define NUM_ROWS_GAME_MODE_SUB_MENU 3
// This really, really shouldn't be in this header file, but I don't know where else to put it
void rmonPrintf(const char*, ...);
@@ -254,7 +258,7 @@ extern s32 gFadeModeSelection;
extern s8 gCharacterSelections[];
extern s8 gGameModeMenuColumn[];
extern s8 gGameModeSubMenuColumn[4][3];
extern s8 gGameModeSubMenuColumn[NUM_COLUMN_GAME_MODE_SUB_MENU][NUM_ROWS_GAME_MODE_SUB_MENU];
extern s8 gNextDemoId;
extern s8 gControllerPakSelectedTableRow;
extern s8 gControllerPakVisibleTableRows[];
+9 -5
View File
@@ -144,12 +144,8 @@ void CustomEngineInit() {
gWorldInstance.AddCup(gSpecialCup);
gWorldInstance.AddCup(gBattleCup);
/* Set default course; mario raceway */
//SelectMarioRaceway(); // This results in a nullptr
gWorldInstance.CurrentCourse = mario;
gWorldInstance.CurrentCup = gMushroomCup;
gWorldInstance.CurrentCup->CursorPosition = 3;
gWorldInstance.CupIndex = 0;
SetMarioRaceway();
// ModelLoader::LoadModelList bowserStatueList = {
// .course = gBowsersCastle,
@@ -198,6 +194,14 @@ void CM_SpawnFromLevelProps() {
// Editor::SpawnFromLevelProps();
}
// Set default course; mario raceway
void SetMarioRaceway(void) {
SetCourseById(0);
gWorldInstance.CurrentCup = gMushroomCup;
gWorldInstance.CurrentCup->CursorPosition = 3;
gWorldInstance.CupIndex = 0;
}
World* GetWorld(void) {
return &gWorldInstance;
}
+2
View File
@@ -131,6 +131,8 @@ void CM_TickActors();
void CM_DrawBombKarts(s32 cameraId);
void SetMarioRaceway(void);
size_t GetCupCursorPosition();
void SetCupCursorPosition(size_t position);
+4
View File
@@ -4,6 +4,7 @@
#include <libultraship/libultraship.h>
#include "UIWidgets.h"
#include "MenuTypes.h"
#include "../port/Game.h"
extern "C" {
#include "defines.h"
@@ -60,6 +61,9 @@ class Menu : public GuiWindow {
virtual void ProcessReset() {
gGamestateNext = MAIN_MENU_FROM_QUIT;
gIsGamePaused = 0;
SetMarioRaceway();
memset(&gGameModeMenuColumn, 0, sizeof(s8) * NUM_ROWS_GAME_MODE_MENU);
memset(&gGameModeSubMenuColumn, 0, sizeof(s8) * NUM_COLUMN_GAME_MODE_SUB_MENU * NUM_ROWS_GAME_MODE_SUB_MENU);
switch(CVarGetInteger("gSkipIntro", 0)) {
case 0:
+1 -1
View File
@@ -508,7 +508,7 @@ void UpdateResolutionVars() {
((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) {
// Scale to window height
integerScale_maximumBounds = gfx_current_game_window_viewport.height / gfx_current_game_window_viewport.height;
} else {
} else if (gfx_current_game_window_viewport.width) {
// Scale to window width
integerScale_maximumBounds = gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.width;
}