Skip to content

Commit 0642dcc

Browse files
committed
fix a few bugs in model loading
Each time `model_load` is called with a `ship_info` pointer, which causes it to load subsystems, the model number MUST be assigned to the ship_info.
1 parent 09a848a commit 0642dcc

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

code/mission/missionparse.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5347,6 +5347,7 @@ void resolve_path_masks(bool path_user_is_ship, const char *path_user, anchor_t
53475347
// Load the anchor ship model with subsystems and all; it'll need to be done for this mission anyway
53485348
auto anchor_sip = anchor_ship_entry->sip();
53495349
modelnum = model_load(anchor_sip->pof_file, anchor_sip);
5350+
anchor_sip->model_num = modelnum;
53505351

53515352
// resolve names to indexes
53525353
*path_mask = 0;
@@ -7075,6 +7076,7 @@ bool post_process_mission(mission *pm)
70757076
if (valid) {
70767077
ship_info* sip = &Ship_info[icon.ship_class];
70777078
stage.icons[j].modelnum = model_load(sip->pof_file, sip);
7079+
sip->model_num = stage.icons[j].modelnum;
70787080
}
70797081
}
70807082
}
@@ -8944,6 +8946,7 @@ void check_anchor_for_hangar_bay(SCP_string &message, SCP_set<anchor_t> &anchors
89448946
// Load the anchor ship model with subsystems and all; it'll need to be done for this mission anyway
89458947
auto anchor_sip = anchor_ship_entry->sip();
89468948
int modelnum = model_load(anchor_sip->pof_file, anchor_sip);
8949+
anchor_sip->model_num = modelnum;
89478950

89488951
// Check if this model has a hangar bay
89498952
if (!model_has_hangar_bay(modelnum))

code/model/model.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,9 +1005,11 @@ void model_free_all();
10051005
void model_instance_free_all();
10061006

10071007
// Alias to model_load, checks if a pof tech model exists and loads it if specified, otherwise loads the default pof. --wookieejedi
1008+
// NOTE: Each time model_load is called with a ship_info pointer, which causes it to load subsystems, the model number MUST be assigned to the ship_info.
10081009
int model_load(ship_info* sip, bool prefer_tech_model);
10091010

10101011
// Loads a model from disk and returns the model number it loaded into.
1012+
// NOTE: Each time model_load is called with a ship_info pointer, which causes it to load subsystems, the model number MUST be assigned to the ship_info.
10111013
int model_load(const char *filename, ship_info* sip = nullptr, ErrorType error_type = ErrorType::FATAL_ERROR, bool allow_redundant_load = false);
10121014

10131015
int model_create_instance(int objnum, int model_num);

0 commit comments

Comments
 (0)