Prevent some mod init related lua crashes

This commit is contained in:
Agent X 2023-11-17 19:55:20 -05:00
parent 5fd6d685d7
commit 72c58f722e
2 changed files with 6 additions and 0 deletions

View file

@ -35,6 +35,9 @@ bool first_person_check_cancels(void) {
if (m->action == ACT_FIRST_PERSON || m->action == ACT_IN_CANNON || m->action == ACT_READING_NPC_DIALOG || m->action == ACT_DISAPPEARED) {
return true;
}
if (gLuaLoadingMod != NULL) { return false; }
struct Object *bowser = find_object_with_behavior(bhvBowser);
if (bowser != NULL && (bowser->oAction == 5 || bowser->oAction == 6)) {
return true;

View file

@ -11,6 +11,9 @@
#include "pc/debuglog.h"
static struct Object* spawn_object_internal(enum BehaviorId behaviorId, enum ModelExtendedId modelId, f32 x, f32 y, f32 z, LuaFunction objSetupFunction, bool doSync) {
// prevent spawning objects on mod init, this can cause issues if --server is specificed
if (gLuaLoadingMod != NULL) { return NULL; }
if (doSync) {
// prevent spawning objects before area is synchronized
if (gNetworkPlayerLocal == NULL || !gNetworkPlayerLocal->currAreaSyncValid) { return NULL; }