Skip to content

Commit 05534f7

Browse files
authored
Qtfred & FRED fix object cloning (scp-fs2open#7460)
* fix ship duplication * prop and jump node duplication * make sure objects on layers are properly registered * waypoint duplication * some cleanup * address feedback * assertion for clang
1 parent 970912f commit 05534f7

12 files changed

Lines changed: 653 additions & 120 deletions

File tree

code/jumpnode/jumpnode.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,16 @@ void CJumpNode::SetModel(const char *model_name, bool show_polys)
258258
m_flags |= JN_SPECIAL_MODEL;
259259
m_radius = model_get_radius(m_modelnum);
260260

261+
// keep the engine-side object radius in sync with the new model. The
262+
// in-game jump-into-subspace check uses model_get_radius() directly so it
263+
// is unaffected, but render culling, HUD brackets and FRED selection all
264+
// read Objects[].radius - leaving it at the default-model radius makes the
265+
// node cull/bracket at the wrong size after a $Special Model parse or a
266+
// set-jumpnode-model sexp.
267+
if (m_objnum >= 0) {
268+
Objects[m_objnum].radius = m_radius;
269+
}
270+
261271
//Do we want to change poly showing?
262272
if(show_polys)
263273
m_flags |= JN_SHOW_POLYS;

code/mission/missionparse.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,6 +2280,11 @@ void parse_copy_wing_ai_to_ship(wing *wingp, ai_info *aip);
22802280
/**
22812281
* Given a stuffed p_object struct, create an object and fill in the necessary fields.
22822282
* @return object number.
2283+
*
2284+
* Per-ship field handling here MUST stay in sync with:
2285+
* Fred_mission_save::save_objects() / save_common_object_data() in missionsave.cpp
2286+
* clone_ship_instance_data() in missioneditor/objectduplication.cpp
2287+
* When you add a new editable ship field, touch all three.
22832288
*/
22842289
int parse_create_object_sub(p_object *p_objp, bool standalone_ship)
22852290
{
@@ -5246,6 +5251,10 @@ void parse_wing(mission *pm)
52465251
// Goober5000 - wing creation stuff moved to post_process_ships_wings
52475252
}
52485253

5254+
// Per-prop field handling here MUST stay in sync with:
5255+
// Fred_mission_save::save_props() in missionsave.cpp
5256+
// clone_prop_instance_data() in missioneditor/objectduplication.cpp
5257+
// When you add a new editable prop field, touch all three.
52495258
void parse_prop(mission* /*pm*/)
52505259
{
52515260
parsed_prop p;
@@ -5922,6 +5931,10 @@ void parse_goals(mission *pm)
59225931
throw parse::ParseException("Number of goals is too high and breaks multi!");
59235932
}
59245933

5934+
// Per-waypoint-path field handling here MUST stay in sync with:
5935+
// Fred_mission_save::save_waypoints() (waypoint-list section) in missionsave.cpp
5936+
// clone_waypoint_path_instance_data() in missioneditor/objectduplication.cpp
5937+
// When you add a new editable waypoint-path field, touch all three.
59255938
void parse_waypoint_list(mission *pm)
59265939
{
59275940
Assert(pm != NULL);
@@ -5973,6 +5986,10 @@ void parse_waypoint_list(mission *pm)
59735986
}
59745987
}
59755988

5989+
// The jump-node section of this function MUST stay in sync with:
5990+
// Fred_mission_save::save_waypoints() (jump-node section) in missionsave.cpp
5991+
// clone_jump_node_instance_data() in missioneditor/objectduplication.cpp
5992+
// When you add a new editable jump-node field, touch all three.
59765993
void parse_waypoints_and_jumpnodes(mission *pm)
59775994
{
59785995
vec3d pos;

code/missioneditor/missionsave.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,10 @@ void Fred_mission_save::fso_comment_pop(bool pop_all)
14421442
fso_ver_comment.pop_back();
14431443
}
14441444

1445+
// Per-ship field handling here MUST stay in sync with:
1446+
// parse_create_object_sub() in missionparse.cpp
1447+
// clone_ship_instance_data() in missioneditor/objectduplication.cpp
1448+
// When you add a new editable ship field, touch all three.
14451449
int Fred_mission_save::save_common_object_data(object* objp, ship* shipp)
14461450
{
14471451
int j, z;
@@ -3474,6 +3478,10 @@ int Fred_mission_save::save_warp_params(WarpDirection direction, ship* shipp)
34743478
return err;
34753479
}
34763480

3481+
// Per-ship field handling here MUST stay in sync with:
3482+
// parse_create_object_sub() in missionparse.cpp
3483+
// clone_ship_instance_data() in missioneditor/objectduplication.cpp
3484+
// When you add a new editable ship field, touch all three.
34773485
int Fred_mission_save::save_objects()
34783486
{
34793487
SCP_string sexp_out;
@@ -4838,6 +4846,10 @@ int Fred_mission_save::save_vector(const vec3d& v)
48384846
return 0;
48394847
}
48404848

4849+
// The jump-node section of this function MUST stay in sync with:
4850+
// the "$Jump Node:" parse block in missionparse.cpp
4851+
// clone_jump_node_instance_data() in missioneditor/objectduplication.cpp
4852+
// When you add a new editable jump-node field, touch all three.
48414853
int Fred_mission_save::save_waypoints()
48424854
{
48434855
// object *ptr;
@@ -4928,6 +4940,10 @@ int Fred_mission_save::save_waypoints()
49284940
fso_comment_pop();
49294941
}
49304942

4943+
// Per-waypoint-path field handling here MUST stay in sync with:
4944+
// parse_waypoint_list() in missionparse.cpp
4945+
// clone_waypoint_path_instance_data() in missioneditor/objectduplication.cpp
4946+
// When you add a new editable waypoint-path field, touch all three.
49314947
bool first_wpt_list = true;
49324948
for (const auto& ii : Waypoint_lists) {
49334949
required_string_either_fred("$Name:", "#Messages");
@@ -5281,6 +5297,10 @@ int Fred_mission_save::save_wings()
52815297
return err;
52825298
}
52835299

5300+
// Per-prop field handling here MUST stay in sync with:
5301+
// parse_prop() in missionparse.cpp
5302+
// clone_prop_instance_data() in missioneditor/objectduplication.cpp
5303+
// When you add a new editable prop field, touch all three.
52845304
int Fred_mission_save::save_props()
52855305
{
52865306
auto num_props = count_items_with_value(Props);

0 commit comments

Comments
 (0)