Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add relevant model ID asserts to level script load commands #722

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/engine/level_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "buffers/framebuffers.h"
#include "buffers/zbuffer.h"
#include "game/area.h"
#include "game/debug.h"
#include "game/game_init.h"
#include "game/mario.h"
#include "game/memory.h"
Expand Down Expand Up @@ -431,6 +432,7 @@ static void level_cmd_load_model_from_dl(void) {
s16 layer = CMD_GET(u16, 0x8);
void *dl_ptr = CMD_GET(void *, 4);

assert(model < MODEL_ID_COUNT, "Tried to load an invalid model ID.");
if (model < MODEL_ID_COUNT) {
gLoadedGraphNodes[model] =
(struct GraphNode *) init_graph_node_display_list(sLevelPool, 0, layer, dl_ptr);
Expand All @@ -443,6 +445,7 @@ static void level_cmd_load_model_from_geo(void) {
ModelID16 model = CMD_GET(ModelID16, 2);
void *geo = CMD_GET(void *, 4);

assert(model < MODEL_ID_COUNT, "Tried to load an invalid model ID.");
if (model < MODEL_ID_COUNT) {
gLoadedGraphNodes[model] = process_geo_layout(sLevelPool, geo);
}
Expand All @@ -456,6 +459,7 @@ static void level_cmd_23(void) {
void *dl = CMD_GET(void *, 4);
s32 scale = CMD_GET(s32, 8);

assert(model < MODEL_ID_COUNT, "Tried to load an invalid model ID.");
if (model < MODEL_ID_COUNT) {
// GraphNodeScale has a GraphNode at the top. This
// is being stored to the array, so cast the pointer.
Expand Down