mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-26 05:55:15 +00:00
Fix crashes and errors when exit-to-castle isn't set properly
This commit is contained in:
parent
2fa506d774
commit
40dfbb7589
4 changed files with 27 additions and 7 deletions
|
@ -172,6 +172,21 @@ struct ObjectWarpNode *area_get_warp_node(u8 id) {
|
|||
return node;
|
||||
}
|
||||
|
||||
struct ObjectWarpNode *area_get_any_warp_node(void) {
|
||||
if (!gCurrentArea || !gCurrentArea->warpNodes) { return NULL; }
|
||||
|
||||
struct ObjectWarpNode *node = NULL;
|
||||
struct ObjectWarpNode *pick = NULL;
|
||||
|
||||
for (node = gCurrentArea->warpNodes; node != NULL; node = node->next) {
|
||||
if (node->node.destLevel != gCurrLevelNum) { continue; }
|
||||
if (!pick) { pick = node; continue; }
|
||||
if (node->node.destArea < pick->node.destArea) { pick = node; }
|
||||
}
|
||||
|
||||
return pick;
|
||||
}
|
||||
|
||||
struct ObjectWarpNode *area_get_warp_node_from_params(struct Object *o) {
|
||||
if (o == NULL) { return NULL; }
|
||||
|
||||
|
|
|
@ -157,6 +157,7 @@ void override_viewport_and_clip(Vp *a, Vp *b, u8 c, u8 d, u8 e);
|
|||
void print_intro_text(void);
|
||||
u32 get_mario_spawn_type(struct Object *o);
|
||||
struct ObjectWarpNode *area_get_warp_node(u8 id);
|
||||
struct ObjectWarpNode *area_get_any_warp_node(void);
|
||||
struct ObjectWarpNode *area_get_warp_node_from_params(struct Object *o);
|
||||
void clear_areas(void);
|
||||
void clear_area_graph_nodes(void);
|
||||
|
|
|
@ -405,7 +405,9 @@ void init_mario_after_warp(void) {
|
|||
struct ObjectWarpNode *spawnNode = area_get_warp_node(sWarpDest.nodeId);
|
||||
if (spawnNode == NULL || spawnNode->object == NULL) { spawnNode = area_get_warp_node(0xFA); }
|
||||
if (spawnNode == NULL || spawnNode->object == NULL) { spawnNode = area_get_warp_node(0x00); }
|
||||
if (spawnNode == NULL || spawnNode->object == NULL) { spawnNode = area_get_any_warp_node(); }
|
||||
if (spawnNode == NULL || spawnNode->object == NULL) { return; }
|
||||
|
||||
u32 marioSpawnType = get_mario_spawn_type(spawnNode->object);
|
||||
|
||||
if (gMarioState && gMarioState->action != ACT_UNINITIALIZED) {
|
||||
|
|
|
@ -1782,7 +1782,7 @@ Gfx *geo_painting_draw(s32 callContext, struct GraphNode *node, UNUSED void *con
|
|||
* Update the painting system's local copy of Mario's current floor and position.
|
||||
*/
|
||||
Gfx *geo_painting_update(s32 callContext, UNUSED struct GraphNode *node, UNUSED Mat4 c) {
|
||||
struct Surface *surface;
|
||||
struct Surface *surface = NULL;
|
||||
|
||||
// Reset the update counter
|
||||
if (callContext != GEO_CONTEXT_RENDER) {
|
||||
|
@ -1793,13 +1793,15 @@ Gfx *geo_painting_update(s32 callContext, UNUSED struct GraphNode *node, UNUSED
|
|||
gPaintingUpdateCounter = gAreaUpdateCounter;
|
||||
|
||||
// Store Mario's floor and position
|
||||
find_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &surface);
|
||||
if (surface != NULL) {
|
||||
gPaintingMarioFloorType = surface->type;
|
||||
if (gMarioObject) {
|
||||
find_floor(gMarioObject->oPosX, gMarioObject->oPosY, gMarioObject->oPosZ, &surface);
|
||||
if (surface != NULL) {
|
||||
gPaintingMarioFloorType = surface->type;
|
||||
}
|
||||
gPaintingMarioXPos = gMarioObject->oPosX;
|
||||
gPaintingMarioYPos = gMarioObject->oPosY;
|
||||
gPaintingMarioZPos = gMarioObject->oPosZ;
|
||||
}
|
||||
gPaintingMarioXPos = gMarioObject->oPosX;
|
||||
gPaintingMarioYPos = gMarioObject->oPosY;
|
||||
gPaintingMarioZPos = gMarioObject->oPosZ;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue