Change fixCollisionBugs from server setting to mod setting

This commit is contained in:
MysterD 2022-06-25 01:26:53 -07:00
parent a344a23bb9
commit c214acb33f
18 changed files with 40 additions and 43 deletions

View file

@ -622,6 +622,7 @@
--- @field public exitCastleArea integer
--- @field public exitCastleLevel LevelNum
--- @field public exitCastleWarpNode integer
--- @field public fixCollisionBugs integer
--- @field public metalCapDuration integer
--- @field public metalCapDurationCotmc integer
--- @field public pssSlideStarIndex integer
@ -1608,7 +1609,6 @@
--- @class ServerSettings
--- @field public bubbleDeath integer
--- @field public enableCheats integer
--- @field public fixCollisionBugs integer
--- @field public headlessServer integer
--- @field public playerInteractions PlayerInteractions
--- @field public playerKnockbackStrength integer

View file

@ -903,6 +903,7 @@
| exitCastleArea | `integer` | |
| exitCastleLevel | [enum LevelNum](constants.md#enum-LevelNum) | |
| exitCastleWarpNode | `integer` | |
| fixCollisionBugs | `integer` | |
| metalCapDuration | `integer` | |
| metalCapDurationCotmc | `integer` | |
| pssSlideStarIndex | `integer` | |
@ -2023,7 +2024,6 @@
| ----- | ---- | ------ |
| bubbleDeath | `integer` | |
| enableCheats | `integer` | |
| fixCollisionBugs | `integer` | |
| headlessServer | `integer` | |
| playerInteractions | [enum PlayerInteractions](constants.md#enum-PlayerInteractions) | |
| playerKnockbackStrength | `integer` | |

View file

@ -29,7 +29,7 @@ gBehaviorValues.dialogs.KoopaQuickThiWinDialog = DIALOG_031
-- force server settings --
---------------------------
gServerSettings.fixCollisionBugs = 1
gLevelValues.fixCollisionBugs = 1
--------------
-- movtexs --

View file

@ -9,6 +9,7 @@
#include "surface_load.h"
#include "math_util.h"
#include "game/game_init.h"
#include "game/hardcoded.h"
#include "pc/utils/misc.h"
#include "pc/network/network.h"
@ -133,7 +134,7 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
continue;
}
if (gServerSettings.fixCollisionBugs) {
if (gLevelValues.fixCollisionBugs) {
// Check AABB to exclude walls before doing expensive triangle check
f32 minX = MIN(MIN(surf->vertex1[0], surf->vertex2[0]), surf->vertex3[0]) - radius;
f32 minZ = MIN(MIN(surf->vertex1[2], surf->vertex2[2]), surf->vertex3[2]) - radius;
@ -271,8 +272,8 @@ static s32 find_wall_collisions_from_list(struct SurfaceNode *surfaceNode,
//! (Wall Overlaps) Because this doesn't update the x and z local variables,
// multiple walls can push mario more than is required.
// <Fixed when gServerSettings.fixCollisionBugs != 0>
if (gServerSettings.fixCollisionBugs) {
// <Fixed when gLevelValues.fixCollisionBugs != 0>
if (gLevelValues.fixCollisionBugs) {
data->x = cPos[0] + cNorm[0] * radius;
data->z = cPos[2] + cNorm[2] * radius;
x = data->x;
@ -378,7 +379,7 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32
ceil = NULL;
// set pheight to highest value
if (gServerSettings.fixCollisionBugs) {
if (gLevelValues.fixCollisionBugs) {
*pheight = CELL_HEIGHT_LIMIT;
}
@ -432,7 +433,7 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32
height = -(x * nx + nz * z + oo) / ny;
// Reject ceilings below previously found ceiling
if (gServerSettings.fixCollisionBugs && (height > *pheight)) {
if (gLevelValues.fixCollisionBugs && (height > *pheight)) {
continue;
}
@ -440,7 +441,7 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32
//! (Exposed Ceilings) Because any point above a ceiling counts
// as interacting with a ceiling, ceilings far below can cause
// "invisible walls" that are really just exposed ceilings.
// <Fixed when gServerSettings.fixCollisionBugs != 0>
// <Fixed when gLevelValues.fixCollisionBugs != 0>
if (y - (height - -78.0f) > 0.0f) {
continue;
}
@ -448,7 +449,7 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32
*pheight = height;
ceil = surf;
if (!gServerSettings.fixCollisionBugs) {
if (!gLevelValues.fixCollisionBugs) {
break;
}
}
@ -456,7 +457,7 @@ static struct Surface *find_ceil_from_list(struct SurfaceNode *surfaceNode, s32
//! (Surface Cucking) Since only the first ceil is returned and not the lowest,
// lower ceilings can be "cucked" by higher ceilings.
// <Fixed when gServerSettings.fixCollisionBugs != 0>
// <Fixed when gLevelValues.fixCollisionBugs != 0>
return ceil;
}
@ -579,7 +580,7 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32
s32 interpolate;
// set pheight to lowest value
if (gServerSettings.fixCollisionBugs) {
if (gLevelValues.fixCollisionBugs) {
*pheight = FLOOR_LOWER_LIMIT;
}
@ -681,7 +682,7 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32
height = -(x * nx + nz * z + oo) / ny;
// Find highest floor
if (gServerSettings.fixCollisionBugs && (height < *pheight)) {
if (gLevelValues.fixCollisionBugs && (height < *pheight)) {
continue;
}
@ -706,14 +707,14 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32
floor = surf;
if (!gServerSettings.fixCollisionBugs) {
if (!gLevelValues.fixCollisionBugs) {
break;
}
}
//! (Surface Cucking) Since only the first floor is returned and not the highest,
// higher floors can be "cucked" by lower floors.
// <Fixed when gServerSettings.fixCollisionBugs != 0>
// <Fixed when gLevelValues.fixCollisionBugs != 0>
return floor;
}

View file

@ -17,6 +17,7 @@
#include "game/game_init.h"
#include "engine/math_util.h"
#include "game/level_update.h"
#include "game/hardcoded.h"
#include "pc/network/network.h"
#include "pc/lua/smlua_hooks.h"
@ -153,9 +154,9 @@ static void add_surface_to_cell(s16 dynamic, s16 cellX, s16 cellZ, struct Surfac
// many functions only use the first triangle in surface order that fits,
// missing higher surfaces.
// upperY would be a better sort method.
// <Fixed when gServerSettings.fixCollisionBugs != 0>
// <Fixed when gLevelValues.fixCollisionBugs != 0>
surfacePriority = gServerSettings.fixCollisionBugs
surfacePriority = gLevelValues.fixCollisionBugs
? (surface->upperY * sortDir)
: (surface->vertex1[1] * sortDir);

View file

@ -41,6 +41,7 @@ extern Trajectory sThiTinyMetalBallTraj[];
////////////
struct LevelValues gDefaultLevelValues = {
.fixCollisionBugs = 0,
.entryLevel = LEVEL_CASTLE_GROUNDS,
.exitCastleLevel = LEVEL_CASTLE,
.exitCastleArea = 1,

View file

@ -37,6 +37,7 @@ struct StarPositions {
};
struct LevelValues {
u8 fixCollisionBugs;
enum LevelNum entryLevel;
enum LevelNum exitCastleLevel;
s16 exitCastleArea;

View file

@ -736,10 +736,10 @@ void push_mario_out_of_object(struct MarioState *m, struct Object *o, f32 paddin
if (floor != NULL) {
//! Doesn't update Mario's referenced floor (allows oob death when
// an object pushes you into a steep slope while in a ground action)
// <Fixed when gServerSettings.fixCollisionBugs != 0>
// <Fixed when gLevelValues.fixCollisionBugs != 0>
m->pos[0] = newMarioX;
m->pos[2] = newMarioZ;
if (gServerSettings.fixCollisionBugs) {
if (gLevelValues.fixCollisionBugs) {
m->floorHeight = find_floor(m->pos[0], m->pos[1], m->pos[2], &m->floor);
}
}

View file

@ -622,7 +622,7 @@ f32 vec3f_find_ceil(Vec3f pos, f32 height, struct Surface **ceil) {
*/
// Prevent exposed ceilings
f32 vec3f_mario_ceil(Vec3f pos, f32 height, struct Surface **ceil) {
if (gServerSettings.fixCollisionBugs) {
if (gLevelValues.fixCollisionBugs) {
height = MAX(height + 80.0f, pos[1] - 2);
return find_ceil(pos[0], height, pos[2], ceil);
} else {
@ -2275,7 +2275,7 @@ void mario_update_wall(struct MarioState* m, struct WallCollisionData* wcd) {
? wcd->walls[wcd->numWalls - 1]
: NULL;
if (gServerSettings.fixCollisionBugs && wcd->normalCount > 0) {
if (gLevelValues.fixCollisionBugs && wcd->normalCount > 0) {
vec3f_set(m->wallNormal,
wcd->normalAddition[0] / wcd->normalCount,
wcd->normalAddition[1] / wcd->normalCount,

View file

@ -9,6 +9,7 @@
#include "interaction.h"
#include "mario_step.h"
#include "pc/lua/smlua.h"
#include "game/hardcoded.h"
static s16 sMovingSandSpeeds[] = { 12, 8, 4, 0 };
@ -307,7 +308,7 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
if (upperWcd.numWalls > 0) {
for (u8 i = 0; i < upperWcd.numWalls; i++) {
if (!gServerSettings.fixCollisionBugs) {
if (!gLevelValues.fixCollisionBugs) {
i = (upperWcd.numWalls - 1);
}
struct Surface* wall = upperWcd.walls[i];
@ -492,7 +493,7 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
// misalignment, you can activate these conditions in unexpected situations
if ((stepArg & AIR_STEP_CHECK_LEDGE_GRAB) && upperWcd.numWalls == 0 && lowerWcd.numWalls > 0) {
for (u8 i = 0; i < lowerWcd.numWalls; i++) {
if (!gServerSettings.fixCollisionBugs) {
if (!gLevelValues.fixCollisionBugs) {
i = (lowerWcd.numWalls - 1);
}
struct Surface* wall = lowerWcd.walls[i];
@ -515,7 +516,7 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
mario_update_wall(m, &upperWcd);
for (u8 i = 0; i < upperWcd.numWalls; i++) {
if (!gServerSettings.fixCollisionBugs) {
if (!gLevelValues.fixCollisionBugs) {
i = (upperWcd.numWalls - 1);
}
@ -537,7 +538,7 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
mario_update_wall(m, &lowerWcd);
for (u8 i = 0; i < lowerWcd.numWalls; i++) {
if (!gServerSettings.fixCollisionBugs) {
if (!gLevelValues.fixCollisionBugs) {
i = (lowerWcd.numWalls - 1);
}

View file

@ -170,7 +170,7 @@ s8 obj_find_wall(f32 objNewX, f32 objY, f32 objNewZ, f32 objVelX, f32 objVelZ) {
o->oPosY = hitbox.y;
o->oPosZ = hitbox.z;
if (gServerSettings.fixCollisionBugs && hitbox.normalCount > 0) {
if (gLevelValues.fixCollisionBugs && hitbox.normalCount > 0) {
wall_nX = hitbox.normalAddition[0] / hitbox.normalCount;
wall_nY = hitbox.normalAddition[1] / hitbox.normalCount;
wall_nZ = hitbox.normalAddition[2] / hitbox.normalCount;

View file

@ -116,7 +116,6 @@ bool configSkipIntro = 0;
bool configShareLives = 0;
bool configEnableCheats = 0;
bool configBubbleDeath = true;
bool configFixCollBugs = true;
unsigned int configAmountofPlayers = 16;
bool configHUD = true;
#ifdef DISCORDRPC
@ -207,7 +206,6 @@ static const struct ConfigOption options[] = {
{.name = "frame_limit" , .type = CONFIG_TYPE_UINT , .uintValue = &configFrameLimit},
{.name = "amount_of_players", .type = CONFIG_TYPE_UINT , .uintValue = &configAmountofPlayers},
{.name = "bubble_death", .type = CONFIG_TYPE_BOOL , .boolValue = &configBubbleDeath},
{.name = "fix_collision_bugs", .type = CONFIG_TYPE_BOOL , .boolValue = &configFixCollBugs},
{.name = "coop_draw_distance", .type = CONFIG_TYPE_UINT , .uintValue = &configDrawDistance},
{.name = "coop_host_port", .type = CONFIG_TYPE_UINT , .uintValue = &configHostPort},
{.name = "coop_host_save_slot", .type = CONFIG_TYPE_UINT , .uintValue = &configHostSaveSlot},

View file

@ -74,7 +74,6 @@ extern bool configSkipIntro;
extern bool configShareLives;
extern bool configEnableCheats;
extern bool configBubbleDeath;
extern bool configFixCollBugs;
extern unsigned int configAmountofPlayers;
#ifdef DISCORDRPC
extern bool configDiscordRPC;

View file

@ -43,7 +43,7 @@ static void djui_panel_host_player_text_change(struct DjuiBase* caller) {
}
void djui_panel_host_settings_create(struct DjuiBase* caller) {
f32 bodyHeight = 32 * 9 + 64 * 1 + 16 * 9;
f32 bodyHeight = 32 * 8 + 64 * 1 + 16 * 8;
struct DjuiBase* defaultBase = NULL;
struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\S\\#1be700\\E\\#00b3ff\\T\\#ffef00\\T\\#ff0800\\I\\#1be700\\N\\#00b3ff\\G\\#ffef00\\S");
@ -84,10 +84,6 @@ void djui_panel_host_settings_create(struct DjuiBase* caller) {
djui_base_set_size_type(&checkbox5->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox5->base, 1.0f, 32);
struct DjuiCheckbox* checkbox6 = djui_checkbox_create(&body->base, "Fix collision bugs", &configFixCollBugs);
djui_base_set_size_type(&checkbox6->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&checkbox6->base, 1.0f, 32);
struct DjuiRect* rect1 = djui_rect_create(&body->base);
djui_base_set_size_type(&rect1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&rect1->base, 1.0f, 32);

View file

@ -720,13 +720,14 @@ static struct LuaObjectField sLakituStateFields[LUA_LAKITU_STATE_FIELD_COUNT] =
{ "yaw", LVT_S16, offsetof(struct LakituState, yaw), false, LOT_NONE },
};
#define LUA_LEVEL_VALUES_FIELD_COUNT 15
#define LUA_LEVEL_VALUES_FIELD_COUNT 16
static struct LuaObjectField sLevelValuesFields[LUA_LEVEL_VALUES_FIELD_COUNT] = {
{ "coinsRequiredForCoinStar", LVT_S16, offsetof(struct LevelValues, coinsRequiredForCoinStar), false, LOT_NONE },
{ "entryLevel", LVT_S32, offsetof(struct LevelValues, entryLevel), false, LOT_NONE },
{ "exitCastleArea", LVT_S16, offsetof(struct LevelValues, exitCastleArea), false, LOT_NONE },
{ "exitCastleLevel", LVT_S32, offsetof(struct LevelValues, exitCastleLevel), false, LOT_NONE },
{ "exitCastleWarpNode", LVT_U8, offsetof(struct LevelValues, exitCastleWarpNode), false, LOT_NONE },
{ "fixCollisionBugs", LVT_U8, offsetof(struct LevelValues, fixCollisionBugs), false, LOT_NONE },
{ "metalCapDuration", LVT_U16, offsetof(struct LevelValues, metalCapDuration), false, LOT_NONE },
{ "metalCapDurationCotmc", LVT_U16, offsetof(struct LevelValues, metalCapDurationCotmc), false, LOT_NONE },
{ "pssSlideStarIndex", LVT_U8, offsetof(struct LevelValues, pssSlideStarIndex), false, LOT_NONE },
@ -1767,11 +1768,10 @@ static struct LuaObjectField sRayIntersectionInfoFields[LUA_RAY_INTERSECTION_INF
{ "surface", LVT_COBJECT_P, offsetof(struct RayIntersectionInfo, surface), false, LOT_SURFACE },
};
#define LUA_SERVER_SETTINGS_FIELD_COUNT 9
#define LUA_SERVER_SETTINGS_FIELD_COUNT 8
static struct LuaObjectField sServerSettingsFields[LUA_SERVER_SETTINGS_FIELD_COUNT] = {
{ "bubbleDeath", LVT_U8, offsetof(struct ServerSettings, bubbleDeath), false, LOT_NONE },
{ "enableCheats", LVT_U8, offsetof(struct ServerSettings, enableCheats), false, LOT_NONE },
{ "fixCollisionBugs", LVT_U8, offsetof(struct ServerSettings, fixCollisionBugs), false, LOT_NONE },
{ "headlessServer", LVT_U8, offsetof(struct ServerSettings, headlessServer), false, LOT_NONE },
{ "playerInteractions", LVT_S32, offsetof(struct ServerSettings, playerInteractions), false, LOT_NONE },
{ "playerKnockbackStrength", LVT_U8, offsetof(struct ServerSettings, playerKnockbackStrength), false, LOT_NONE },

View file

@ -5,7 +5,6 @@
#include "object_constants.h"
#include "behavior_table.h"
#include "src/game/hardcoded.h"
#include "src/game/rendering_graph_node.h"
#ifdef DISCORD_SDK
#include "discord/discord.h"
#endif
@ -20,6 +19,11 @@
#include "pc/crash_handler.h"
#include "pc/debuglog.h"
// fix warnings when including rendering_graph_node
#undef near
#undef far
#include "src/game/rendering_graph_node.h"
// Mario 64 specific externs
extern s16 sCurrPlayMode;
extern s16 gCurrCourseNum, gCurrActStarNum, gCurrLevelNum, gCurrAreaIndex;
@ -57,7 +61,6 @@ struct ServerSettings gServerSettings = {
.enableCheats = 0,
.bubbleDeath = 1,
.headlessServer = 0,
.fixCollisionBugs = 1,
};
void network_set_system(enum NetworkSystemType nsType) {
@ -93,7 +96,6 @@ bool network_init(enum NetworkType inNetworkType) {
gServerSettings.shareLives = configShareLives;
gServerSettings.enableCheats = configEnableCheats;
gServerSettings.bubbleDeath = configBubbleDeath;
gServerSettings.fixCollisionBugs = configFixCollBugs;
#if defined(RAPI_DUMMY) || defined(WAPI_DUMMY)
gServerSettings.headlessServer = (inNetworkType == NT_SERVER);
#else

View file

@ -69,7 +69,6 @@ struct ServerSettings {
u8 enableCheats;
u8 bubbleDeath;
u8 headlessServer;
u8 fixCollisionBugs;
};
// Networking-specific externs

View file

@ -107,7 +107,6 @@ void network_send_join(struct Packet* joinRequestPacket) {
packet_write(&p, &gServerSettings.shareLives, sizeof(u8));
packet_write(&p, &gServerSettings.enableCheats, sizeof(u8));
packet_write(&p, &gServerSettings.bubbleDeath, sizeof(u8));
packet_write(&p, &gServerSettings.fixCollisionBugs, sizeof(u8));
packet_write(&p, &gServerSettings.headlessServer, sizeof(u8));
packet_write(&p, eeprom, sizeof(u8) * 512);
@ -171,7 +170,6 @@ void network_receive_join(struct Packet* p) {
packet_read(p, &gServerSettings.shareLives, sizeof(u8));
packet_read(p, &gServerSettings.enableCheats, sizeof(u8));
packet_read(p, &gServerSettings.bubbleDeath, sizeof(u8));
packet_read(p, &gServerSettings.fixCollisionBugs, sizeof(u8));
packet_read(p, &gServerSettings.headlessServer, sizeof(u8));
packet_read(p, eeprom, sizeof(u8) * 512);
packet_read(p, &modCount, sizeof(u8));