From 6f911738cf4244a5d731aa11f6434f93a89597d3 Mon Sep 17 00:00:00 2001 From: Prince Frizzy Date: Fri, 4 Mar 2022 23:07:35 -0500 Subject: [PATCH 1/2] Adds some sanity checks to network_receive_area, And add LOG_DEBUG (#10) --- src/pc/debuglog.h | 5 ++++- src/pc/logfile.h | 9 ++++++--- src/pc/network/packets/packet_area.c | 25 +++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/pc/debuglog.h b/src/pc/debuglog.h index f415fba2..ab669ee5 100644 --- a/src/pc/debuglog.h +++ b/src/pc/debuglog.h @@ -43,12 +43,15 @@ static void _debuglog_print_log(char* logType, char* filename) { } #if defined(DEBUG) && defined(DISABLE_MODULE_LOG) + #define LOG_DEBUG(...) #define LOG_INFO(...) #define LOG_ERROR(...) ( _debuglog_print_log("ERROR", __FILE__), printf(__VA_ARGS__), printf("\n") ) #elif defined(DEBUG) && !defined(DISABLE_MODULE_LOG) - #define LOG_INFO(...) ( _debuglog_print_log("INFO ", __FILE__), printf(__VA_ARGS__), printf("\n") ) + #define LOG_DEBUG(...) ( _debuglog_print_log("DEBUG", __FILE__), printf(__VA_ARGS__), printf("\n") ) + #define LOG_INFO(...) ( _debuglog_print_log("INFO", __FILE__), printf(__VA_ARGS__), printf("\n") ) #define LOG_ERROR(...) ( _debuglog_print_log("ERROR", __FILE__), printf(__VA_ARGS__), printf("\n") ) #else + #define LOG_DEBUG(...) #define LOG_INFO(...) #define LOG_ERROR(...) #endif diff --git a/src/pc/logfile.h b/src/pc/logfile.h index 7e1f9387..de08e88a 100644 --- a/src/pc/logfile.h +++ b/src/pc/logfile.h @@ -59,13 +59,16 @@ static void _logfile_print_log(enum LogFileType logFileType, char* logType, char } #if defined(DEBUG) && defined(DISABLE_MODULE_LOG) - #define LOGFILE_INFO(_LFT, ...) ( _logfile_print_log(_LFT, "INFO ", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n")) + #define LOGFILE_DEBUG(_LFT, ...) ( _logfile_print_log(_LFT, "DEBUG", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n")) + #define LOGFILE_INFO(_LFT, ...) ( _logfile_print_log(_LFT, "INFO", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n")) #define LOGFILE_ERROR(_LFT, ...) ( _logfile_print_log(_LFT, "ERROR", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n"), LOG_ERROR(__VA_ARGS__)) #elif defined(DEBUG) && !defined(DISABLE_MODULE_LOG) - #define LOGFILE_INFO(_LFT, ...) ( _logfile_print_log(_LFT, "INFO ", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n"), LOG_INFO (__VA_ARGS__)) + #define LOGFILE_DEBUG(_LFT, ...) ( _logfile_print_log(_LFT, "DEBUG", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n"), LOG_DEBUG(__VA_ARGS__)) + #define LOGFILE_INFO(_LFT, ...) ( _logfile_print_log(_LFT, "INFO", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n"), LOG_INFO (__VA_ARGS__)) #define LOGFILE_ERROR(_LFT, ...) ( _logfile_print_log(_LFT, "ERROR", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n"), LOG_ERROR(__VA_ARGS__)) #else - #define LOGFILE_INFO(_LFT, ...) ( _logfile_print_log(_LFT, "INFO ", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n")) + #define LOGFILE_DEBUG(_LFT, ...) ( _logfile_print_log(_LFT, "DEBUG", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n")) + #define LOGFILE_INFO(_LFT, ...) ( _logfile_print_log(_LFT, "INFO", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n")) #define LOGFILE_ERROR(_LFT, ...) ( _logfile_print_log(_LFT, "ERROR", __FILE__, __LINE__), fprintf(gLogFiles[_LFT].file, __VA_ARGS__), fprintf(gLogFiles[_LFT].file, "\n")) #endif diff --git a/src/pc/network/packets/packet_area.c b/src/pc/network/packets/packet_area.c index 3d13319f..ea52fe4d 100644 --- a/src/pc/network/packets/packet_area.c +++ b/src/pc/network/packets/packet_area.c @@ -136,6 +136,11 @@ void network_send_area(struct NetworkPlayer* toNp) { void network_receive_area(struct Packet* p) { LOG_INFO("rx area"); + + if (p == NULL) { + LOG_ERROR("rx area: the packet was NULL, failed to recieve the area."); + return; + } // read level location s16 courseNum, actNum, levelNum, areaIndex; @@ -172,7 +177,7 @@ void network_receive_area(struct Packet* p) { // read removed sync ids area_remove_sync_ids_clear(); packet_read(p, &sRemoveSyncIdsIndex, sizeof(u8)); - for (int i = 0; i < sRemoveSyncIdsIndex; i++) { + for (s32 i = 0; i < sRemoveSyncIdsIndex; i++) { packet_read(p, &sRemoveSyncIds[i], sizeof(u8)); struct SyncObject* so = &gSyncObjects[sRemoveSyncIds[i]]; if (so->o != NULL) { @@ -187,7 +192,7 @@ void network_receive_area(struct Packet* p) { packet_read(p, &respawnerCount, sizeof(u8)); // read respawners - for (int i = 0; i < respawnerCount; i++) { + for (s32 i = 0; i < respawnerCount; i++) { f32 posX, posY, posZ; packet_read(p, &posX, sizeof(f32)); packet_read(p, &posY, sizeof(f32)); @@ -205,6 +210,22 @@ void network_receive_area(struct Packet* p) { packet_read(p, &syncId, sizeof(u32)); struct SyncObject* so = &gSyncObjects[syncId]; + + if (so == NULL) { + LOG_ERROR("rx area: Sync object was NULL, Skipping respawner."); + LOG_DEBUG("rx area debug: Sync Object DEBUG:\n\n \ + POS X: %f\n \ + POS Y: %f\n \ + POS Z: %f\n \ + BEHAVIOR PARAMS: 0x%X\n \ + RESPAWN MODEL: %i\n \ + MIN RESPAWN DIST: %f\n \ + RESPAWN BEHAVIOR: %u\n \ + SYNC ID: %u\n\n", + posX, posY, posZ, behParams, respawnerModelToRespawn, + respawnerMinSpawnDist, behaviorToRespawn, syncId); + continue; + } LOG_INFO("rx respawner"); if (syncId < RESERVED_IDS_SYNC_OBJECT_OFFSET) { From f2efa5a5d01988b47c56019a38f936aa4a8675a5 Mon Sep 17 00:00:00 2001 From: Amy54Desu <69287652+Amy54Desu@users.noreply.github.com> Date: Fri, 4 Mar 2022 23:08:57 -0500 Subject: [PATCH 2/2] Spin Pound dive removal and Wario bug fix. (#11) * Update character-movesets.lua This new version removes the dive for Luigi's Spin Pound and fixes the momentum glitch with Wario * Spin Pound Dive removal and Wario bug fix The Spin Pound Dive was easily removed by just removing the code that puts you into a dive when B is pressed. The Wario bug was also fixed by simply making it so if Wario is in the Water Jump Hold action the faster air speed from holding an item doesn't apply to him. --- mods/character-movesets.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mods/character-movesets.lua b/mods/character-movesets.lua index c99010d2..88b7265f 100644 --- a/mods/character-movesets.lua +++ b/mods/character-movesets.lua @@ -50,12 +50,6 @@ function act_spin_pound(m) set_mario_animation(m, MARIO_ANIM_TWIRL) - if (m.input & INPUT_B_PRESSED) ~= 0 then - mario_set_forward_vel(m, 10.0) - m.vel.y = 35 - set_mario_action(m, ACT_DIVE, 0) - end - local stepResult = perform_air_step(m, 0) if stepResult == AIR_STEP_LANDED then if should_get_stuck_in_ground(m) ~= 0 then @@ -788,6 +782,11 @@ function wario_before_phys_step(m) end end + -- fixes the momentum bug + if (m.action & ACT_HOLD_WATER_JUMP) then + return + end + -- faster holding item if m.heldObj ~= nil then m.vel.y = m.vel.y - 1