From e2b2309c31a4a7b95b4db962794eafa82789bc77 Mon Sep 17 00:00:00 2001 From: GateGuy Date: Thu, 26 Nov 2020 00:50:08 -0500 Subject: [PATCH 1/3] Added draw distance settings --- include/text_options_strings.h.in | 2 ++ src/engine/behavior_script.c | 3 ++- src/engine/surface_load.c | 3 ++- src/game/behaviors/bub.inc.c | 4 +++- src/game/behaviors/chain_chomp.inc.c | 6 ++++-- src/game/behaviors/cloud.inc.c | 6 ++++-- src/game/behaviors/coin.inc.c | 6 ++++-- src/game/behaviors/enemy_lakitu.inc.c | 4 +++- src/game/behaviors/fish.inc.c | 12 +++++++----- src/game/behaviors/goomba.inc.c | 6 ++++-- src/game/behaviors/heave_ho.inc.c | 4 +++- src/game/behaviors/king_bobomb.inc.c | 4 +++- src/game/behaviors/lll_floating_wood_piece.inc.c | 6 ++++-- src/game/behaviors/lll_rotating_hex_flame.inc.c | 6 ++++-- src/game/behaviors/piranha_plant.inc.c | 4 +++- src/game/behaviors/pokey.inc.c | 6 ++++-- src/game/behaviors/sl_walking_penguin.inc.c | 4 +++- src/game/behaviors/snufit.inc.c | 4 +++- src/game/behaviors/triplet_butterfly.inc.c | 4 +++- src/game/behaviors/water_bomb_cannon.inc.c | 6 ++++-- src/game/behaviors/whirlpool.inc.c | 4 +++- src/game/behaviors/whomp.inc.c | 6 ++++-- src/game/obj_behaviors.c | 3 ++- src/game/options_menu.c | 6 +++++- src/pc/configfile.c | 6 ++++++ src/pc/configfile.h | 3 +++ 26 files changed, 92 insertions(+), 36 deletions(-) diff --git a/include/text_options_strings.h.in b/include/text_options_strings.h.in index 8c6732e4d5..3ba7cc8ada 100644 --- a/include/text_options_strings.h.in +++ b/include/text_options_strings.h.in @@ -56,6 +56,7 @@ #define TEXT_OPT_AUTO _("AUTO") #define TEXT_OPT_HUD _("HUD") #define TEXT_OPT_THREEPT _("THREE POINT") +#define TEXT_OPT_DRAWDIST _("DRAW DISTANCE") #define TEXT_OPT_APPLY _("APPLY") #define TEXT_OPT_RESETWND _("RESET WINDOW") @@ -120,6 +121,7 @@ #define TEXT_OPT_AUTO _("Auto") #define TEXT_OPT_HUD _("HUD") #define TEXT_OPT_THREEPT _("Three-point") +#define TEXT_OPT_DRAWDIST _("Draw Distance") #define TEXT_OPT_APPLY _("Apply") #define TEXT_OPT_RESETWND _("Reset Window") diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index f61f2bf4b8..037d39d754 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -13,6 +13,7 @@ #include "game/object_list_processor.h" #include "graph_node.h" #include "surface_collision.h" +#include "pc/configfile.h" // Macros for retrieving arguments from behavior scripts. #define BHV_CMD_GET_1ST_U8(index) (u8)((gCurBhvCommand[index] >> 24) & 0xFF) // unused @@ -999,7 +1000,7 @@ void cur_obj_update(void) { if (!(objFlags & OBJ_FLAG_ACTIVE_FROM_AFAR)) { // If the object has a render distance, check if it should be shown. #ifndef NODRAWINGDISTANCE - if (distanceFromMario > gCurrentObject->oDrawingDistance) { + if (distanceFromMario > gCurrentObject->oDrawingDistance * configDrawDistance / 100.0f) { // Out of render distance, hide the object. gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_ACTIVE; gCurrentObject->activeFlags |= ACTIVE_FLAG_FAR_AWAY; diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index ac2ee50cae..a4beaee713 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -14,6 +14,7 @@ #include "game/mario.h" #include "game/object_list_processor.h" #include "surface_load.h" +#include "pc/configfile.h" s32 unused8038BE90; @@ -786,7 +787,7 @@ void load_object_collision_model(void) { } #ifndef NODRAWINGDISTANCE - if (marioDist < gCurrentObject->oDrawingDistance) { + if (marioDist < gCurrentObject->oDrawingDistance * configDrawDistance / 100.0f) { #endif gCurrentObject->header.gfx.node.flags |= GRAPH_RENDER_ACTIVE; #ifndef NODRAWINGDISTANCE diff --git a/src/game/behaviors/bub.inc.c b/src/game/behaviors/bub.inc.c index 7bf7169077..7c804a36ae 100644 --- a/src/game/behaviors/bub.inc.c +++ b/src/game/behaviors/bub.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + // bub.c.inc // NOTE: These first set of functions spawn a school of bub depending on objF4's @@ -9,7 +11,7 @@ void bub_spawner_act_0(void) { s32 i; s32 sp18 = o->oBirdChirpChirpUnkF4; #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 1500.0f) { + if (o->oDistanceToMario < 15 * configDrawDistance) { #endif for (i = 0; i < sp18; i++) spawn_object(o, MODEL_BUB, bhvBub); diff --git a/src/game/behaviors/chain_chomp.inc.c b/src/game/behaviors/chain_chomp.inc.c index 9b9c3423b8..715ae3bf97 100644 --- a/src/game/behaviors/chain_chomp.inc.c +++ b/src/game/behaviors/chain_chomp.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + /** * Behavior for bhvChainChomp, bhvChainChompChainPart, bhvWoodenPost, and bhvChainChompGate. @@ -54,7 +56,7 @@ static void chain_chomp_act_uninitialized(void) { s32 i; #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 3000.0f) { + if (o->oDistanceToMario < 30 * configDrawDistance) { #endif segments = mem_pool_alloc(gObjectMemoryPool, 5 * sizeof(struct ChainSegment)); if (segments != NULL) { @@ -364,7 +366,7 @@ static void chain_chomp_act_move(void) { // Unload chain if mario is far enough #ifndef NODRAWINGDISTANCE - if (o->oChainChompReleaseStatus == CHAIN_CHOMP_NOT_RELEASED && o->oDistanceToMario > 4000.0f) { + if (o->oChainChompReleaseStatus == CHAIN_CHOMP_NOT_RELEASED && o->oDistanceToMario > 40 * configDrawDistance) { o->oAction = CHAIN_CHOMP_ACT_UNLOAD_CHAIN; o->oForwardVel = o->oVelY = 0.0f; } else { diff --git a/src/game/behaviors/cloud.inc.c b/src/game/behaviors/cloud.inc.c index c1d708bfd4..772af172d5 100644 --- a/src/game/behaviors/cloud.inc.c +++ b/src/game/behaviors/cloud.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + /** * Behavior for bhvCloud and bhvCloudPart. @@ -48,7 +50,7 @@ static void cloud_act_spawn_parts(void) { */ static void cloud_act_fwoosh_hidden(void) { #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 2000.0f) { + if (o->oDistanceToMario < 20 * configDrawDistance) { #endif cur_obj_unhide(); o->oAction = CLOUD_ACT_SPAWN_PARTS; @@ -63,7 +65,7 @@ static void cloud_act_fwoosh_hidden(void) { */ static void cloud_fwoosh_update(void) { #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario > 2500.0f) { + if (o->oDistanceToMario > 25 * configDrawDistance) { o->oAction = CLOUD_ACT_UNLOAD; } else { #endif diff --git a/src/game/behaviors/coin.inc.c b/src/game/behaviors/coin.inc.c index 9b7099deb3..0a12998630 100644 --- a/src/game/behaviors/coin.inc.c +++ b/src/game/behaviors/coin.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + // coin.c.inc struct ObjectHitbox sYellowCoinHitbox = { @@ -185,7 +187,7 @@ void bhv_coin_formation_loop(void) { switch (o->oAction) { case 0: #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 2000.0f) { + if (o->oDistanceToMario < 20 * configDrawDistance) { #endif for (bitIndex = 0; bitIndex < 8; bitIndex++) { if (!(o->oCoinUnkF4 & (1 << bitIndex))) @@ -198,7 +200,7 @@ void bhv_coin_formation_loop(void) { break; case 1: #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario > 2100.0f) + if (o->oDistanceToMario > 21 * configDrawDistance) o->oAction++; #endif break; diff --git a/src/game/behaviors/enemy_lakitu.inc.c b/src/game/behaviors/enemy_lakitu.inc.c index cacd732f79..55f2c362cf 100644 --- a/src/game/behaviors/enemy_lakitu.inc.c +++ b/src/game/behaviors/enemy_lakitu.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + /** * Behavior for bhvEnemyLakitu. @@ -25,7 +27,7 @@ static struct ObjectHitbox sEnemyLakituHitbox = { */ static void enemy_lakitu_act_uninitialized(void) { #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 2000.0f) { + if (o->oDistanceToMario < 20 * configDrawDistance) { #endif spawn_object_relative_with_scale(CLOUD_BP_LAKITU_CLOUD, 0, 0, 0, 2.0f, o, MODEL_MIST, bhvCloud); diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c index d169ecf78b..3e67bb6cc5 100644 --- a/src/game/behaviors/fish.inc.c +++ b/src/game/behaviors/fish.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + /** * @file fish.inc.c * Implements behaviour and spawning for fish located in the Secret Aquarium and other levels. @@ -19,22 +21,22 @@ void fish_act_spawn(void) { // Blue fish with a quanitiy of twenty. case 0: - model = MODEL_FISH; schoolQuantity = 20; minDistToMario = 1500.0f; fishAnimation = blue_fish_seg3_anims_0301C2B0; + model = MODEL_FISH; schoolQuantity = 20; minDistToMario = 15 * configDrawDistance; fishAnimation = blue_fish_seg3_anims_0301C2B0; break; // Blue fish with a quanitiy of five. case 1: - model = MODEL_FISH; schoolQuantity = 5; minDistToMario = 1500.0f; fishAnimation = blue_fish_seg3_anims_0301C2B0; + model = MODEL_FISH; schoolQuantity = 5; minDistToMario = 15 * configDrawDistance; fishAnimation = blue_fish_seg3_anims_0301C2B0; break; // Cyan fish with a quanitiy of twenty. case 2: - model = MODEL_CYAN_FISH; schoolQuantity = 20; minDistToMario = 1500.0f; fishAnimation = cyan_fish_seg6_anims_0600E264; + model = MODEL_CYAN_FISH; schoolQuantity = 20; minDistToMario = 15 * configDrawDistance; fishAnimation = cyan_fish_seg6_anims_0600E264; break; // Cyan fish with a quanitiy of five. case 3: - model = MODEL_CYAN_FISH; schoolQuantity = 5; minDistToMario = 1500.0f; fishAnimation = cyan_fish_seg6_anims_0600E264; + model = MODEL_CYAN_FISH; schoolQuantity = 5; minDistToMario = 15 * configDrawDistance; fishAnimation = cyan_fish_seg6_anims_0600E264; break; } /** @@ -64,7 +66,7 @@ void fish_act_spawn(void) { void fish_act_respawn(void) { #ifndef NODRAWINGDISTANCE if (gCurrLevelNum != LEVEL_SA) { - if (gMarioObject->oPosY - o->oPosY > 2000.0f) { + if (gMarioObject->oPosY - o->oPosY > 20 * configDrawDistance) { o->oAction = FISH_ACT_RESPAWN; } } diff --git a/src/game/behaviors/goomba.inc.c b/src/game/behaviors/goomba.inc.c index bf47dda1d0..429d91576d 100644 --- a/src/game/behaviors/goomba.inc.c +++ b/src/game/behaviors/goomba.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + /** * Behavior for bhvGoomba and bhvGoombaTripletSpawner, @@ -79,7 +81,7 @@ void bhv_goomba_triplet_spawner_update(void) { // spawn them if (o->oAction == GOOMBA_TRIPLET_SPAWNER_ACT_UNLOADED) { #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 3000.0f) { + if (o->oDistanceToMario < 30 * configDrawDistance) { #endif // The spawner is capable of spawning more than 3 goombas, but this // is not used in the game @@ -102,7 +104,7 @@ void bhv_goomba_triplet_spawner_update(void) { o->oAction += 1; #ifndef NODRAWINGDISTANCE } - } else if (o->oDistanceToMario > 4000.0f) { + } else if (o->oDistanceToMario > 40 * configDrawDistance) { // If mario is too far away, enter the unloaded action. The goombas // will detect this and unload themselves o->oAction = GOOMBA_TRIPLET_SPAWNER_ACT_UNLOADED; diff --git a/src/game/behaviors/heave_ho.inc.c b/src/game/behaviors/heave_ho.inc.c index 1a247607ad..d25fb470f7 100644 --- a/src/game/behaviors/heave_ho.inc.c +++ b/src/game/behaviors/heave_ho.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + // heave_ho.c.inc s16 D_8032F460[][2] = { { 30, 0 }, { 42, 1 }, { 52, 0 }, { 64, 1 }, { 74, 0 }, @@ -73,7 +75,7 @@ void heave_ho_act_3(void) { void heave_ho_act_0(void) { #ifndef NODRAWINGDISTANCE - if (find_water_level(o->oPosX, o->oPosZ) < o->oPosY && o->oDistanceToMario < 4000.0f) { + if (find_water_level(o->oPosX, o->oPosZ) < o->oPosY && o->oDistanceToMario < 40 * configDrawDistance) { #else if (find_water_level(o->oPosX, o->oPosZ) < (o->oPosY - 50.0f)) { #endif diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c index 7942b2bb87..709f6d204e 100644 --- a/src/game/behaviors/king_bobomb.inc.c +++ b/src/game/behaviors/king_bobomb.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + // king_bobomb.c.inc // Copy of geo_update_projectile_pos_from_parent @@ -296,7 +298,7 @@ void king_bobomb_move(void) { cur_obj_call_action_function(sKingBobombActions); exec_anim_sound_state(sKingBobombSoundStates); #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 5000.0f) + if (o->oDistanceToMario < 50 * configDrawDistance) #endif cur_obj_enable_rendering(); #ifndef NODRAWINGDISTANCE diff --git a/src/game/behaviors/lll_floating_wood_piece.inc.c b/src/game/behaviors/lll_floating_wood_piece.inc.c index 7994e2d9fc..102337c3b1 100644 --- a/src/game/behaviors/lll_floating_wood_piece.inc.c +++ b/src/game/behaviors/lll_floating_wood_piece.inc.c @@ -1,5 +1,7 @@ // lll_floating_wood_piece.c.inc +#include "pc/configfile.h" + void bhv_lll_wood_piece_loop(void) { if (o->oTimer == 0) o->oPosY -= 100.0f; @@ -15,7 +17,7 @@ void bhv_lll_floating_wood_bridge_loop(void) { switch (o->oAction) { case 0: #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 2500.0f) { + if (o->oDistanceToMario < 25 * configDrawDistance) { #endif for (i = 1; i < 4; i++) { sp3C = spawn_object_relative(0, (i - 2) * 300, 0, 0, o, MODEL_LLL_WOOD_BRIDGE, @@ -29,7 +31,7 @@ void bhv_lll_floating_wood_bridge_loop(void) { break; case 1: #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario > 2600.0f) + if (o->oDistanceToMario > 26 * configDrawDistance) o->oAction = 2; #endif break; diff --git a/src/game/behaviors/lll_rotating_hex_flame.inc.c b/src/game/behaviors/lll_rotating_hex_flame.inc.c index fc70733055..36f0b5afbf 100644 --- a/src/game/behaviors/lll_rotating_hex_flame.inc.c +++ b/src/game/behaviors/lll_rotating_hex_flame.inc.c @@ -1,5 +1,7 @@ // lll_rotating_hex_flame.c.inc +#include "pc/configfile.h" + void bhv_lll_rotating_hex_flame_loop(void) { f32 sp24 = o->oLllRotatingHexFlameUnkF4; f32 sp20 = o->oLllRotatingHexFlameUnkF8; @@ -31,7 +33,7 @@ void fire_bar_spawn_flames(s16 a0) { void fire_bar_act_0(void) { #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 3000.0f) + if (o->oDistanceToMario < 30 * configDrawDistance) #endif o->oAction = 1; } @@ -48,7 +50,7 @@ void fire_bar_act_2(void) { o->oAngleVelYaw = -0x100; o->oMoveAngleYaw += o->oAngleVelYaw; #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario > 3200.0f) + if (o->oDistanceToMario > 32 * configDrawDistance) o->oAction = 3; #endif } diff --git a/src/game/behaviors/piranha_plant.inc.c b/src/game/behaviors/piranha_plant.inc.c index 328f451853..dcf358413b 100644 --- a/src/game/behaviors/piranha_plant.inc.c +++ b/src/game/behaviors/piranha_plant.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + /** * Behavior for bhvPiranhaPlant. * This controls Piranha Plants, which alternate between sleeping, attacking, @@ -331,7 +333,7 @@ void bhv_piranha_plant_loop(void) { #ifndef NODRAWINGDISTANCE // In WF, hide all Piranha Plants once high enough up. if (gCurrLevelNum == LEVEL_WF) { - if (gMarioObject->oPosY > 3400.0f) + if (gMarioObject->oPosY > 34 * configDrawDistance) cur_obj_hide(); else cur_obj_unhide(); diff --git a/src/game/behaviors/pokey.inc.c b/src/game/behaviors/pokey.inc.c index cfcc92c265..dfd6453f9f 100644 --- a/src/game/behaviors/pokey.inc.c +++ b/src/game/behaviors/pokey.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + /** * Behavior for bhvPokey and bhvPokeyBodyPart. @@ -152,7 +154,7 @@ static void pokey_act_uninitialized(void) { s16 partModel; #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 2000.0f) { + if (o->oDistanceToMario < 20 * configDrawDistance) { #endif partModel = MODEL_POKEY_HEAD; @@ -190,7 +192,7 @@ static void pokey_act_wander(void) { if (o->oPokeyNumAliveBodyParts == 0) { obj_mark_for_deletion(o); #ifndef NODRAWINGDISTANCE - } else if (o->oDistanceToMario > 2500.0f) { + } else if (o->oDistanceToMario > 25 * configDrawDistance) { o->oAction = POKEY_ACT_UNLOAD_PARTS; o->oForwardVel = 0.0f; #endif diff --git a/src/game/behaviors/sl_walking_penguin.inc.c b/src/game/behaviors/sl_walking_penguin.inc.c index 59428acbbe..9f0ad34c65 100644 --- a/src/game/behaviors/sl_walking_penguin.inc.c +++ b/src/game/behaviors/sl_walking_penguin.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + // sl_walking_penguin.c.inc struct SLWalkingPenguinStep { @@ -98,7 +100,7 @@ void bhv_sl_walking_penguin_loop(void) { cur_obj_move_standard(-78); #ifndef NODRAWINGDISTANCE - if (!cur_obj_hide_if_mario_far_away_y(1000.0f)) + if (!cur_obj_hide_if_mario_far_away_y(10 * configDrawDistance)) #endif play_penguin_walking_sound(PENGUIN_WALK_BIG); diff --git a/src/game/behaviors/snufit.inc.c b/src/game/behaviors/snufit.inc.c index 2acf442f20..0d234d9a0d 100644 --- a/src/game/behaviors/snufit.inc.c +++ b/src/game/behaviors/snufit.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + /** * Behavior file for bhvSnufit and bhvSnufitBalls. * Snufits are present in HMC and CotMC, and are the fly guy @@ -181,7 +183,7 @@ void bhv_snufit_balls_loop(void) { // If far from Mario or in a different room, despawn. if ((o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) #ifndef NODRAWINGDISTANCE - || (o->oTimer != 0 && o->oDistanceToMario > 1500.0f) + || (o->oTimer != 0 && o->oDistanceToMario > 15 * configDrawDistance) #endif ){ obj_mark_for_deletion(o); diff --git a/src/game/behaviors/triplet_butterfly.inc.c b/src/game/behaviors/triplet_butterfly.inc.c index 5f97185400..3958a364b3 100644 --- a/src/game/behaviors/triplet_butterfly.inc.c +++ b/src/game/behaviors/triplet_butterfly.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + struct TripletButterflyActivationData { s32 model; const BehaviorScript *behavior; @@ -55,7 +57,7 @@ static void triplet_butterfly_act_init(void) { static void triplet_butterfly_act_wander(void) { #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario > 1500.0f) { + if (o->oDistanceToMario > 15 * configDrawDistance) { obj_mark_for_deletion(o); } else { #endif diff --git a/src/game/behaviors/water_bomb_cannon.inc.c b/src/game/behaviors/water_bomb_cannon.inc.c index fb82e43ccd..8f4d9ec243 100644 --- a/src/game/behaviors/water_bomb_cannon.inc.c +++ b/src/game/behaviors/water_bomb_cannon.inc.c @@ -1,5 +1,7 @@ // water_bomb_cannon.inc.c +#include "pc/configfile.h" + void bhv_bubble_cannon_barrel_loop(void) { struct Object *val04; @@ -39,7 +41,7 @@ void bhv_bubble_cannon_barrel_loop(void) { void water_bomb_cannon_act_0(void) { #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 2000.0f) { + if (o->oDistanceToMario < 20 * configDrawDistance) { #endif spawn_object(o, MODEL_CANNON_BARREL, bhvCannonBarrelBubbles); cur_obj_unhide(); @@ -53,7 +55,7 @@ void water_bomb_cannon_act_0(void) { void water_bomb_cannon_act_1(void) { #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario > 2500.0f) { + if (o->oDistanceToMario > 25 * configDrawDistance) { o->oAction = 2; } else if (o->oBehParams2ndByte == 0) { #else diff --git a/src/game/behaviors/whirlpool.inc.c b/src/game/behaviors/whirlpool.inc.c index 5aebebd24b..1a54baeabe 100644 --- a/src/game/behaviors/whirlpool.inc.c +++ b/src/game/behaviors/whirlpool.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + // whirlpool.c.inc static struct ObjectHitbox sWhirlpoolHitbox = { @@ -36,7 +38,7 @@ void whirpool_orient_graph(void) { void bhv_whirlpool_loop(void) { #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < 5000.0f) { + if (o->oDistanceToMario < 50 * configDrawDistance) { #endif o->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; diff --git a/src/game/behaviors/whomp.inc.c b/src/game/behaviors/whomp.inc.c index 1f3bcb7f09..30795f7d86 100644 --- a/src/game/behaviors/whomp.inc.c +++ b/src/game/behaviors/whomp.inc.c @@ -1,3 +1,5 @@ +#include "pc/configfile.h" + // whomp.c.inc void whomp_play_sfx_from_pound_animation(void) { @@ -250,9 +252,9 @@ void bhv_whomp_loop(void) { // o->oBehParams2ndByte here seems to be a flag // indicating whether this is a normal or king whomp if (o->oBehParams2ndByte != 0) - cur_obj_hide_if_mario_far_away_y(2000.0f); + cur_obj_hide_if_mario_far_away_y(20 * configDrawDistance); else - cur_obj_hide_if_mario_far_away_y(1000.0f); + cur_obj_hide_if_mario_far_away_y(10 * configDrawDistance); #endif load_object_collision_model(); } diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c index 601c45f14b..edd24c7fb4 100644 --- a/src/game/obj_behaviors.c +++ b/src/game/obj_behaviors.c @@ -27,6 +27,7 @@ #include "obj_behaviors.h" #include "object_helpers.h" #include "object_list_processor.h" +#include "pc/configfile.h" #include "rendering_graph_node.h" #include "save_file.h" #include "spawn_object.h" @@ -531,7 +532,7 @@ void set_object_visibility(struct Object *obj, s32 dist) { f32 objZ = obj->oPosZ; #ifndef NODRAWINGDISTANCE - if (is_point_within_radius_of_mario(objX, objY, objZ, dist) == TRUE) { + if (is_point_within_radius_of_mario(objX, objY, objZ, dist * configDrawDistance / 100) == TRUE) { #endif obj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; #ifndef NODRAWINGDISTANCE diff --git a/src/game/options_menu.c b/src/game/options_menu.c index 56ebdebeaf..e6e4ca2997 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -85,6 +85,7 @@ static const u8 optsVideoStr[][32] = { { TEXT_OPT_AUTO }, { TEXT_OPT_HUD }, { TEXT_OPT_THREEPT }, + { TEXT_OPT_DRAWDIST }, { TEXT_OPT_APPLY }, }; @@ -261,8 +262,11 @@ static struct Option optsVideo[] = { DEF_OPT_TOGGLE( optsVideoStr[5], &configWindow.vsync ), DEF_OPT_CHOICE( optsVideoStr[1], &configFiltering, filterChoices ), DEF_OPT_TOGGLE( optsVideoStr[7], &configHUD ), +#ifndef NODRAWINGDISTANCE + DEF_OPT_SCROLL( optsVideoStr[9], &configDrawDistance, 50, 509, 10 ), +#endif DEF_OPT_BUTTON( optsVideoStr[4], optvideo_reset_window ), - DEF_OPT_BUTTON( optsVideoStr[9], optvideo_apply ), + DEF_OPT_BUTTON( optsVideoStr[10], optvideo_apply ), }; static struct Option optsAudio[] = { diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 7411d4f84b..2c7ce62c97 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -90,6 +90,9 @@ bool configCameraMouse = false; #endif bool configSkipIntro = 0; bool configHUD = true; +#ifndef NODRAWINGDISTANCE +unsigned int configDrawDistance = 100; +#endif #ifdef DISCORDRPC bool configDiscordRPC = true; #endif @@ -102,6 +105,9 @@ static const struct ConfigOption options[] = { {.name = "window_h", .type = CONFIG_TYPE_UINT, .uintValue = &configWindow.h}, {.name = "vsync", .type = CONFIG_TYPE_BOOL, .boolValue = &configWindow.vsync}, {.name = "texture_filtering", .type = CONFIG_TYPE_UINT, .uintValue = &configFiltering}, + #ifndef NODRAWINGDISTANCE + {.name = "drawing_distance", .type = CONFIG_TYPE_UINT, .uintValue = &configDrawDistance}, + #endif {.name = "master_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configMasterVolume}, {.name = "music_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configMusicVolume}, {.name = "sfx_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configSfxVolume}, diff --git a/src/pc/configfile.h b/src/pc/configfile.h index b92ae7beae..e20abf3aa1 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -55,6 +55,9 @@ extern bool configCameraMouse; extern bool configCameraAnalog; #endif extern bool configHUD; +#ifndef NODRAWINGDISTANCE +extern unsigned int configDrawDistance; +#endif extern bool configSkipIntro; #ifdef DISCORDRPC extern bool configDiscordRPC; From 38d6c1f615349a1d0433132300eed7a931972e43 Mon Sep 17 00:00:00 2001 From: GateGuy Date: Thu, 26 Nov 2020 16:11:47 -0500 Subject: [PATCH 2/3] Fixed fish bug Also changed applicable files to only import configfile if NODRAWINGDISTANCE is not used (otherwise it's an unused import) --- src/engine/behavior_script.c | 2 ++ src/engine/surface_load.c | 2 ++ src/game/behaviors/bub.inc.c | 2 ++ src/game/behaviors/chain_chomp.inc.c | 2 ++ src/game/behaviors/cloud.inc.c | 2 ++ src/game/behaviors/coin.inc.c | 2 ++ src/game/behaviors/enemy_lakitu.inc.c | 2 ++ src/game/behaviors/fish.inc.c | 12 +++++++----- src/game/behaviors/goomba.inc.c | 2 ++ src/game/behaviors/heave_ho.inc.c | 2 ++ src/game/behaviors/king_bobomb.inc.c | 2 ++ src/game/behaviors/lll_floating_wood_piece.inc.c | 2 ++ src/game/behaviors/lll_rotating_hex_flame.inc.c | 2 ++ src/game/behaviors/piranha_plant.inc.c | 2 ++ src/game/behaviors/pokey.inc.c | 2 ++ src/game/behaviors/sl_walking_penguin.inc.c | 2 ++ src/game/behaviors/snufit.inc.c | 2 ++ src/game/behaviors/triplet_butterfly.inc.c | 2 ++ src/game/behaviors/water_bomb_cannon.inc.c | 2 ++ src/game/behaviors/whirlpool.inc.c | 2 ++ src/game/behaviors/whomp.inc.c | 2 ++ src/game/obj_behaviors.c | 2 ++ 22 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index 037d39d754..2848e97717 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -13,7 +13,9 @@ #include "game/object_list_processor.h" #include "graph_node.h" #include "surface_collision.h" +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif // Macros for retrieving arguments from behavior scripts. #define BHV_CMD_GET_1ST_U8(index) (u8)((gCurBhvCommand[index] >> 24) & 0xFF) // unused diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index a4beaee713..c62ef0038a 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -14,7 +14,9 @@ #include "game/mario.h" #include "game/object_list_processor.h" #include "surface_load.h" +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif s32 unused8038BE90; diff --git a/src/game/behaviors/bub.inc.c b/src/game/behaviors/bub.inc.c index 7c804a36ae..f8577d47f4 100644 --- a/src/game/behaviors/bub.inc.c +++ b/src/game/behaviors/bub.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif // bub.c.inc diff --git a/src/game/behaviors/chain_chomp.inc.c b/src/game/behaviors/chain_chomp.inc.c index 715ae3bf97..4d0af942f7 100644 --- a/src/game/behaviors/chain_chomp.inc.c +++ b/src/game/behaviors/chain_chomp.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif /** diff --git a/src/game/behaviors/cloud.inc.c b/src/game/behaviors/cloud.inc.c index 772af172d5..ec5f7a9095 100644 --- a/src/game/behaviors/cloud.inc.c +++ b/src/game/behaviors/cloud.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif /** diff --git a/src/game/behaviors/coin.inc.c b/src/game/behaviors/coin.inc.c index 0a12998630..5370f2d63c 100644 --- a/src/game/behaviors/coin.inc.c +++ b/src/game/behaviors/coin.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif // coin.c.inc diff --git a/src/game/behaviors/enemy_lakitu.inc.c b/src/game/behaviors/enemy_lakitu.inc.c index 55f2c362cf..72553dcc49 100644 --- a/src/game/behaviors/enemy_lakitu.inc.c +++ b/src/game/behaviors/enemy_lakitu.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif /** diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c index 3e67bb6cc5..0ac2d34b31 100644 --- a/src/game/behaviors/fish.inc.c +++ b/src/game/behaviors/fish.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif /** * @file fish.inc.c @@ -21,22 +23,22 @@ void fish_act_spawn(void) { // Blue fish with a quanitiy of twenty. case 0: - model = MODEL_FISH; schoolQuantity = 20; minDistToMario = 15 * configDrawDistance; fishAnimation = blue_fish_seg3_anims_0301C2B0; + model = MODEL_FISH; schoolQuantity = 20; minDistToMario = 15; fishAnimation = blue_fish_seg3_anims_0301C2B0; break; // Blue fish with a quanitiy of five. case 1: - model = MODEL_FISH; schoolQuantity = 5; minDistToMario = 15 * configDrawDistance; fishAnimation = blue_fish_seg3_anims_0301C2B0; + model = MODEL_FISH; schoolQuantity = 5; minDistToMario = 15; fishAnimation = blue_fish_seg3_anims_0301C2B0; break; // Cyan fish with a quanitiy of twenty. case 2: - model = MODEL_CYAN_FISH; schoolQuantity = 20; minDistToMario = 15 * configDrawDistance; fishAnimation = cyan_fish_seg6_anims_0600E264; + model = MODEL_CYAN_FISH; schoolQuantity = 20; minDistToMario = 15; fishAnimation = cyan_fish_seg6_anims_0600E264; break; // Cyan fish with a quanitiy of five. case 3: - model = MODEL_CYAN_FISH; schoolQuantity = 5; minDistToMario = 15 * configDrawDistance; fishAnimation = cyan_fish_seg6_anims_0600E264; + model = MODEL_CYAN_FISH; schoolQuantity = 5; minDistToMario = 15; fishAnimation = cyan_fish_seg6_anims_0600E264; break; } /** @@ -45,7 +47,7 @@ void fish_act_spawn(void) { * Fish moves at random with a max-range of 700.0f. */ #ifndef NODRAWINGDISTANCE - if (o->oDistanceToMario < minDistToMario || gCurrLevelNum == LEVEL_SA) { + if (o->oDistanceToMario < minDistToMario * configDrawDistance / 100 || gCurrLevelNum == LEVEL_SA) { #endif for (i = 0; i < schoolQuantity; i++) { fishObject = spawn_object(o, model, bhvFish); diff --git a/src/game/behaviors/goomba.inc.c b/src/game/behaviors/goomba.inc.c index 429d91576d..6fce18b347 100644 --- a/src/game/behaviors/goomba.inc.c +++ b/src/game/behaviors/goomba.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif /** diff --git a/src/game/behaviors/heave_ho.inc.c b/src/game/behaviors/heave_ho.inc.c index d25fb470f7..1da0b2435b 100644 --- a/src/game/behaviors/heave_ho.inc.c +++ b/src/game/behaviors/heave_ho.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif // heave_ho.c.inc diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c index 709f6d204e..6aec3d15bf 100644 --- a/src/game/behaviors/king_bobomb.inc.c +++ b/src/game/behaviors/king_bobomb.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif // king_bobomb.c.inc diff --git a/src/game/behaviors/lll_floating_wood_piece.inc.c b/src/game/behaviors/lll_floating_wood_piece.inc.c index 102337c3b1..9e28fca4e3 100644 --- a/src/game/behaviors/lll_floating_wood_piece.inc.c +++ b/src/game/behaviors/lll_floating_wood_piece.inc.c @@ -1,6 +1,8 @@ // lll_floating_wood_piece.c.inc +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif void bhv_lll_wood_piece_loop(void) { if (o->oTimer == 0) diff --git a/src/game/behaviors/lll_rotating_hex_flame.inc.c b/src/game/behaviors/lll_rotating_hex_flame.inc.c index 36f0b5afbf..2c6bad00de 100644 --- a/src/game/behaviors/lll_rotating_hex_flame.inc.c +++ b/src/game/behaviors/lll_rotating_hex_flame.inc.c @@ -1,6 +1,8 @@ // lll_rotating_hex_flame.c.inc +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif void bhv_lll_rotating_hex_flame_loop(void) { f32 sp24 = o->oLllRotatingHexFlameUnkF4; diff --git a/src/game/behaviors/piranha_plant.inc.c b/src/game/behaviors/piranha_plant.inc.c index dcf358413b..f59d27ce1b 100644 --- a/src/game/behaviors/piranha_plant.inc.c +++ b/src/game/behaviors/piranha_plant.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif /** * Behavior for bhvPiranhaPlant. diff --git a/src/game/behaviors/pokey.inc.c b/src/game/behaviors/pokey.inc.c index dfd6453f9f..b19db8e6d5 100644 --- a/src/game/behaviors/pokey.inc.c +++ b/src/game/behaviors/pokey.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif /** diff --git a/src/game/behaviors/sl_walking_penguin.inc.c b/src/game/behaviors/sl_walking_penguin.inc.c index 9f0ad34c65..0599a16c92 100644 --- a/src/game/behaviors/sl_walking_penguin.inc.c +++ b/src/game/behaviors/sl_walking_penguin.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif // sl_walking_penguin.c.inc diff --git a/src/game/behaviors/snufit.inc.c b/src/game/behaviors/snufit.inc.c index 0d234d9a0d..a740e2771b 100644 --- a/src/game/behaviors/snufit.inc.c +++ b/src/game/behaviors/snufit.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif /** * Behavior file for bhvSnufit and bhvSnufitBalls. diff --git a/src/game/behaviors/triplet_butterfly.inc.c b/src/game/behaviors/triplet_butterfly.inc.c index 3958a364b3..6309b488af 100644 --- a/src/game/behaviors/triplet_butterfly.inc.c +++ b/src/game/behaviors/triplet_butterfly.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif struct TripletButterflyActivationData { s32 model; diff --git a/src/game/behaviors/water_bomb_cannon.inc.c b/src/game/behaviors/water_bomb_cannon.inc.c index 8f4d9ec243..ae242fa8fb 100644 --- a/src/game/behaviors/water_bomb_cannon.inc.c +++ b/src/game/behaviors/water_bomb_cannon.inc.c @@ -1,6 +1,8 @@ // water_bomb_cannon.inc.c +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif void bhv_bubble_cannon_barrel_loop(void) { struct Object *val04; diff --git a/src/game/behaviors/whirlpool.inc.c b/src/game/behaviors/whirlpool.inc.c index 1a54baeabe..04f9c6cf86 100644 --- a/src/game/behaviors/whirlpool.inc.c +++ b/src/game/behaviors/whirlpool.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif // whirlpool.c.inc diff --git a/src/game/behaviors/whomp.inc.c b/src/game/behaviors/whomp.inc.c index 30795f7d86..34c5a59f83 100644 --- a/src/game/behaviors/whomp.inc.c +++ b/src/game/behaviors/whomp.inc.c @@ -1,4 +1,6 @@ +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif // whomp.c.inc diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c index edd24c7fb4..369853ba1c 100644 --- a/src/game/obj_behaviors.c +++ b/src/game/obj_behaviors.c @@ -27,7 +27,9 @@ #include "obj_behaviors.h" #include "object_helpers.h" #include "object_list_processor.h" +#ifndef NODRAWINGDISTANCE #include "pc/configfile.h" +#endif #include "rendering_graph_node.h" #include "save_file.h" #include "spawn_object.h" From b71d7d96e1a0b202daad1e516c452f36324424f3 Mon Sep 17 00:00:00 2001 From: GateGuy Date: Thu, 26 Nov 2020 18:06:17 -0500 Subject: [PATCH 3/3] Fixed previous bug fix --- src/game/behaviors/fish.inc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game/behaviors/fish.inc.c b/src/game/behaviors/fish.inc.c index 0ac2d34b31..f957272562 100644 --- a/src/game/behaviors/fish.inc.c +++ b/src/game/behaviors/fish.inc.c @@ -23,22 +23,22 @@ void fish_act_spawn(void) { // Blue fish with a quanitiy of twenty. case 0: - model = MODEL_FISH; schoolQuantity = 20; minDistToMario = 15; fishAnimation = blue_fish_seg3_anims_0301C2B0; + model = MODEL_FISH; schoolQuantity = 20; minDistToMario = 1500.0f; fishAnimation = blue_fish_seg3_anims_0301C2B0; break; // Blue fish with a quanitiy of five. case 1: - model = MODEL_FISH; schoolQuantity = 5; minDistToMario = 15; fishAnimation = blue_fish_seg3_anims_0301C2B0; + model = MODEL_FISH; schoolQuantity = 5; minDistToMario = 1500.0f; fishAnimation = blue_fish_seg3_anims_0301C2B0; break; // Cyan fish with a quanitiy of twenty. case 2: - model = MODEL_CYAN_FISH; schoolQuantity = 20; minDistToMario = 15; fishAnimation = cyan_fish_seg6_anims_0600E264; + model = MODEL_CYAN_FISH; schoolQuantity = 20; minDistToMario = 1500.0f; fishAnimation = cyan_fish_seg6_anims_0600E264; break; // Cyan fish with a quanitiy of five. case 3: - model = MODEL_CYAN_FISH; schoolQuantity = 5; minDistToMario = 15; fishAnimation = cyan_fish_seg6_anims_0600E264; + model = MODEL_CYAN_FISH; schoolQuantity = 5; minDistToMario = 1500.0f; fishAnimation = cyan_fish_seg6_anims_0600E264; break; } /**