1313#include " EditorViewport.h"
1414#include < math/fvi.h>
1515#include < jumpnode/jumpnode.h>
16+ #include < prop/prop.h>
1617#include < FredApplication.h>
1718
1819namespace {
@@ -880,6 +881,10 @@ void EditorViewport::drag_rotate_save_backup() {
880881}
881882
882883int EditorViewport::create_object_on_grid (int x, int y, int waypoint_instance) {
884+ return create_object_on_grid (x, y, waypoint_instance, false );
885+ }
886+
887+ int EditorViewport::create_object_on_grid (int x, int y, int waypoint_instance, bool create_prop) {
883888 int obj = -1 ;
884889 float rval;
885890 vec3d dir, pos;
@@ -890,7 +895,7 @@ int EditorViewport::create_object_on_grid(int x, int y, int waypoint_instance) {
890895
891896 if (rval >= 0 .0f ) {
892897 editor->unmark_all ();
893- obj = create_object (&pos, waypoint_instance);
898+ obj = create_object (&pos, waypoint_instance, create_prop );
894899 if (obj >= 0 ) {
895900 editor->markObject (obj);
896901
@@ -904,27 +909,38 @@ int EditorViewport::create_object_on_grid(int x, int y, int waypoint_instance) {
904909
905910 return obj;
906911}
907- int EditorViewport::create_object (vec3d* pos, int waypoint_instance) {
912+ int EditorViewport::create_object (vec3d* pos, int waypoint_instance, bool create_prop ) {
908913
909914 int obj, n;
915+ if (create_prop) {
916+ if (cur_prop_index < 0 || cur_prop_index >= prop_info_size ()) {
917+ return -1 ;
918+ }
910919
911- if (cur_model_index == editor->Id_select_type_waypoint ) {
912- obj = editor->create_waypoint (pos, waypoint_instance);
913- } else if (cur_model_index == editor->Id_select_type_jump_node ) {
914- CJumpNode jnp (pos);
915- obj = jnp.GetSCPObjectNumber ();
916- Jump_nodes.push_back (std::move (jnp));
917- } else if (Ship_info[cur_model_index].flags [Ship::Info_Flags::No_fred]){
918- obj = -1 ;
919- } else { // creating a ship
920- obj = editor->create_ship (NULL , pos, cur_model_index);
921- if (obj == -1 )
920+ obj = prop_create (nullptr , pos, cur_prop_index);
921+ if (obj == -1 ) {
922922 return -1 ;
923+ }
924+ } else {
923925
924- n = Objects[obj].instance ;
925- Ships[n].arrival_cue = alloc_sexp (" true" , SEXP_ATOM , SEXP_ATOM_OPERATOR , -1 , -1 );
926- Ships[n].departure_cue = alloc_sexp (" false" , SEXP_ATOM , SEXP_ATOM_OPERATOR , -1 , -1 );
927- Ships[n].cargo1 = 0 ;
926+ if (cur_model_index == editor->Id_select_type_waypoint ) {
927+ obj = editor->create_waypoint (pos, waypoint_instance);
928+ } else if (cur_model_index == editor->Id_select_type_jump_node ) {
929+ CJumpNode jnp (pos);
930+ obj = jnp.GetSCPObjectNumber ();
931+ Jump_nodes.push_back (std::move (jnp));
932+ } else if (Ship_info[cur_model_index].flags [Ship::Info_Flags::No_fred]){
933+ obj = -1 ;
934+ } else { // creating a ship
935+ obj = editor->create_ship (nullptr , pos, cur_model_index);
936+ if (obj == -1 )
937+ return -1 ;
938+
939+ n = Objects[obj].instance ;
940+ Ships[n].arrival_cue = alloc_sexp (" true" , SEXP_ATOM , SEXP_ATOM_OPERATOR , -1 , -1 );
941+ Ships[n].departure_cue = alloc_sexp (" false" , SEXP_ATOM , SEXP_ATOM_OPERATOR , -1 , -1 );
942+ Ships[n].cargo1 = 0 ;
943+ }
928944 }
929945
930946 if (obj < 0 )
@@ -937,6 +953,12 @@ int EditorViewport::create_object(vec3d* pos, int waypoint_instance) {
937953}
938954void EditorViewport::initialSetup () {
939955 cur_model_index = get_default_player_ship_index ();
956+ for (int i = 0 ; i < prop_info_size (); ++i) {
957+ if (!Prop_info[i].flags [Prop::Info_Flags::No_fred]) {
958+ cur_prop_index = i;
959+ break ;
960+ }
961+ }
940962}
941963
942964int EditorViewport::duplicate_marked_objects ()
0 commit comments