Hopefully fix passes_pvp_interaction_checks crash (#343)

* Hopefully fix passes_pvp_interaction_checks crash
* Hopefully fix cur_obj_call_action_function crash
This commit is contained in:
Agent X 2023-04-11 17:32:47 -04:00 committed by GitHub
parent 3b0e650dda
commit aba6483e5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 4 deletions

View file

@ -161,9 +161,7 @@ u32 get_mario_spawn_type(struct Object *o) {
} }
struct ObjectWarpNode *area_get_warp_node(u8 id) { struct ObjectWarpNode *area_get_warp_node(u8 id) {
if (gCurrentArea == NULL || gCurrentArea->warpNodes == NULL) { if (!gCurrentArea || !gCurrentArea->warpNodes) { return NULL; }
return NULL;
}
struct ObjectWarpNode *node = NULL; struct ObjectWarpNode *node = NULL;

View file

@ -1353,6 +1353,8 @@ u8 player_is_sliding(struct MarioState* m) {
} }
u8 passes_pvp_interaction_checks(struct MarioState* attacker, struct MarioState* victim) { u8 passes_pvp_interaction_checks(struct MarioState* attacker, struct MarioState* victim) {
if (!attacker || !victim) { return false; }
// attacked // attacked
u8 isInCutscene = ((attacker->action & ACT_GROUP_MASK) == ACT_GROUP_CUTSCENE) || ((victim->action & ACT_GROUP_MASK) == ACT_GROUP_CUTSCENE); u8 isInCutscene = ((attacker->action & ACT_GROUP_MASK) == ACT_GROUP_CUTSCENE) || ((victim->action & ACT_GROUP_MASK) == ACT_GROUP_CUTSCENE);
isInCutscene = isInCutscene || (attacker->action == ACT_IN_CANNON) || (victim->action == ACT_IN_CANNON); isInCutscene = isInCutscene || (attacker->action == ACT_IN_CANNON) || (victim->action == ACT_IN_CANNON);

View file

@ -2664,7 +2664,10 @@ s32 cur_obj_move_up_and_down(s32 a0) {
} }
void cur_obj_call_action_function(void (*actionFunctions[])(void)) { void cur_obj_call_action_function(void (*actionFunctions[])(void)) {
if (!actionFunctions) { return; }
void (*actionFunction)(void) = actionFunctions[o->oAction]; void (*actionFunction)(void) = actionFunctions[o->oAction];
if (!actionFunction) { return; }
actionFunction(); actionFunction();
} }

View file

@ -332,7 +332,7 @@ static void open_mod_file(struct Mod* mod, struct ModFile* file) {
} }
void network_receive_download(struct Packet* p) { void network_receive_download(struct Packet* p) {
if (p == NULL) { if (!p) {
LOG_ERROR("Received null packet"); LOG_ERROR("Received null packet");
return; return;
} }