Skip to content

Commit bf2ca61

Browse files
committed
Fix invalid indexing in object orientation editor
This could happen if the user enabled "Point to" and selected "Object" without having an object selected. This can only happen when there is only one object in the mission so it's only a minor bug but still something worth fixing.
1 parent ffe647b commit bf2ca61

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fred2/orienteditor.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,10 @@ void orient_editor::update_object(object *ptr)
215215
loc.xyz.y = convert(m_location_y);
216216
loc.xyz.z = convert(m_location_z);
217217
if (((CButton *) GetDlgItem(IDC_POINT_TO_OBJECT))->GetCheck() == 1) {
218-
v = Objects[index[m_object_index]].pos;
219-
vm_vec_sub2(&v, &ptr->pos);
220-
218+
if (m_object_index >= 0) {
219+
v = Objects[index[m_object_index]].pos;
220+
vm_vec_sub2(&v, &ptr->pos);
221+
}
221222
} else if (((CButton *) GetDlgItem(IDC_POINT_TO_LOCATION))->GetCheck() == 1) {
222223
vm_vec_sub(&v, &loc, &ptr->pos);
223224

0 commit comments

Comments
 (0)