Reset hardcoded values on disconnect

This commit is contained in:
MysterD 2022-05-17 01:22:45 -07:00
parent 18503ecc52
commit ef4c7d780c
4 changed files with 30 additions and 9 deletions

View File

@ -37,7 +37,7 @@
// Levels //
////////////
struct LevelValues gLevelValues = {
struct LevelValues gDefaultLevelValues = {
.entryLevel = LEVEL_CASTLE_GROUNDS,
.exitCastleLevel = LEVEL_CASTLE,
.exitCastleArea = 1,
@ -86,11 +86,13 @@ struct LevelValues gLevelValues = {
},
};
struct LevelValues gLevelValues = { 0 };
///////////////
// Behaviors //
///////////////
struct BehaviorValues gBehaviorValues = {
struct BehaviorValues gDefaultBehaviorValues = {
.KoopaBobAgility = 4.0f,
.KoopaCatchupAgility = 8.0f,
.KoopaThiAgility = 6.0f,
@ -218,3 +220,14 @@ struct BehaviorValues gBehaviorValues = {
.PlatformLll2Trajectory = (Trajectory*) lll_seg7_trajectory_07028660,
},
};
struct BehaviorValues gBehaviorValues = { 0 };
///////////////
// functions //
///////////////
void hardcoded_reset_default_values(void) {
gLevelValues = gDefaultLevelValues;
gBehaviorValues = gDefaultBehaviorValues;
}

View File

@ -195,4 +195,6 @@ struct BehaviorValues {
extern struct BehaviorValues gBehaviorValues;
void hardcoded_reset_default_values(void);
#endif

View File

@ -378,10 +378,10 @@ static void geo_process_ortho_projection(struct GraphNodeOrthoProjection *node)
if (node->node.children != NULL) {
Mtx *mtx = alloc_display_list(sizeof(*mtx));
if (mtx == NULL) { return; }
f32 left = (gCurGraphNodeRoot->x - gCurGraphNodeRoot->width) / 2.0f * node->scale;
f32 right = (gCurGraphNodeRoot->x + gCurGraphNodeRoot->width) / 2.0f * node->scale;
f32 top = (gCurGraphNodeRoot->y - gCurGraphNodeRoot->height) / 2.0f * node->scale;
f32 bottom = (gCurGraphNodeRoot->y + gCurGraphNodeRoot->height) / 2.0f * node->scale;
f32 left = ((gCurGraphNodeRoot->x - gCurGraphNodeRoot->width) / 2.0f) * node->scale;
f32 right = ((gCurGraphNodeRoot->x + gCurGraphNodeRoot->width) / 2.0f) * node->scale;
f32 top = ((gCurGraphNodeRoot->y - gCurGraphNodeRoot->height) / 2.0f) * node->scale;
f32 bottom = ((gCurGraphNodeRoot->y + gCurGraphNodeRoot->height) / 2.0f) * node->scale;
guOrtho(mtx, left, right, bottom, top, -2.0f, 2.0f, 1.0f);
gSPPerspNormalize(gDisplayListHead++, 0xFFFF);
@ -404,10 +404,12 @@ static void geo_process_perspective(struct GraphNodePerspective *node) {
Mtx *mtx = alloc_display_list(sizeof(*mtx));
if (mtx == NULL) { return; }
f32 divisor = (f32) gCurGraphNodeRoot->height;
if (divisor == 0) { divisor = 1; }
#ifdef VERSION_EU
f32 aspect = ((f32) gCurGraphNodeRoot->width / (f32) gCurGraphNodeRoot->height) * 1.1f;
f32 aspect = ((f32) gCurGraphNodeRoot->width / divisor) * 1.1f;
#else
f32 aspect = (f32) gCurGraphNodeRoot->width / (f32) gCurGraphNodeRoot->height;
f32 aspect = (f32) gCurGraphNodeRoot->width / divisor;
#endif
guPerspective(mtx, &perspNorm, not_zero(node->prevFov, gOverrideFOV), aspect, not_zero(node->near, gOverrideNear), not_zero(node->far, gOverrideFar), 1.0f);
@ -1066,7 +1068,9 @@ static s32 obj_is_in_view(struct GraphNodeObject *node, Mat4 matrix) {
// Half of the fov in in-game angle units instead of degrees.
s16 halfFov = (gCurGraphNodeCamFrustum->fov / 2.0f + 1.0f) * 32768.0f / 180.0f + 0.5f;
f32 hScreenEdge = -matrix[3][2] * sins(halfFov) / coss(halfFov);
f32 divisor = coss(halfFov);
if (divisor == 0) { divisor = 1; }
f32 hScreenEdge = -matrix[3][2] * sins(halfFov) / divisor;
// -matrix[3][2] is the depth, which gets multiplied by tan(halfFov) to get
// the amount of units between the center of the screen and the horizontal edge
// given the distance from the object to the camera.

View File

@ -1,4 +1,5 @@
#include "smlua.h"
#include "game/hardcoded.h"
#include "pc/mods/mods.h"
#include "pc/mods/mods_utils.h"
#include "pc/crash_handler.h"
@ -178,6 +179,7 @@ void smlua_update(void) {
}
void smlua_shutdown(void) {
hardcoded_reset_default_values();
smlua_text_utils_reset_all();
smlua_audio_utils_reset_all();
audio_custom_shutdown();