Skip to content

Commit 29282c2

Browse files
committed
Add safeguards for invalidated model instances and texture replace specifically
1 parent 60203b6 commit 29282c2

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

code/model/modelrender.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3195,8 +3195,12 @@ void model_render_set_wireframe_color(const color* clr)
31953195

31963196
void modelinstance_replace_active_texture(polymodel_instance* pmi, const char* old_name, const char* new_name)
31973197
{
3198-
Assert(pmi != nullptr);
3198+
if (pmi == nullptr)
3199+
return;
3200+
31993201
polymodel* pm = model_get(pmi->model_num);
3202+
if (pm == nullptr)
3203+
return;
32003204

32013205
int final_index = -1;
32023206

code/ship/ship.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8986,6 +8986,7 @@ void ship_delete( object * obj )
89868986
ct_ship_delete(shipp);
89878987

89888988
model_delete_instance(shipp->model_instance_num);
8989+
shipp->model_instance_num = -1;
89898990

89908991
// free up any weapon model instances
89918992
for (int i = 0; i < shipp->weapons.num_primary_banks; ++i)

0 commit comments

Comments
 (0)