@@ -453,7 +453,7 @@ class bsp_info
453453 matrix frame_of_reference; // used to be called 'orientation' - this is just used for setting the rotation axis and the animation angles
454454
455455 int bsp_data_size;
456- ubyte * bsp_data;
456+ std::shared_ptr< ubyte[]> bsp_data;
457457
458458 int collision_tree_index;
459459
@@ -485,7 +485,7 @@ class bsp_info
485485 vertex_buffer buffer;
486486 vertex_buffer trans_buffer;
487487
488- vertex * outline_buffer;
488+ std::shared_ptr< vertex[]> outline_buffer;
489489 uint n_verts_outline;
490490
491491 vec3d render_box_min;
@@ -508,7 +508,7 @@ class bsp_info
508508typedef struct mp_vert {
509509 vec3d pos; // xyz coordinates of vertex in object's frame of reference
510510 int nturrets; // number of turrets guarding this vertex
511- int * turret_ids; // array of indices into ship_subsys linked list (can't index using [] though)
511+ std::shared_ptr< int []> turret_ids; // array of indices into ship_subsys linked list (can't index using [] though)
512512 float radius; // How far the closest obstruction is from this vertex
513513} mp_vert;
514514
@@ -517,7 +517,7 @@ typedef struct model_path {
517517 char parent_name[MAX_NAME_LEN ]; // parent name of submodel that path is linked to in POF
518518 int parent_submodel;
519519 int nverts;
520- mp_vert * verts;
520+ std::shared_ptr< mp_vert[]> verts;
521521 int goal; // Which of the verts is the one closest to the goal of this path
522522 int type; // What this path takes you to... See MP_TYPE_??? defines above for details
523523 int value; // This depends on the type.
@@ -567,7 +567,7 @@ struct glow_point{
567567
568568typedef struct thruster_bank {
569569 int num_points;
570- glow_point * points;
570+ std::shared_ptr< glow_point[]> points;
571571
572572 // Engine wash info
573573 struct engine_wash_info *wash_info_pointer; // index into Engine_wash_info
@@ -590,7 +590,7 @@ typedef struct glow_point_bank { // glow bank structure -Bobboau
590590 int submodel_parent;
591591 int LOD ;
592592 int num_points;
593- glow_point * points;
593+ std::shared_ptr< glow_point[]> points;
594594 int glow_bitmap;
595595 int glow_neb_bitmap;
596596} glow_point_bank;
@@ -650,7 +650,7 @@ typedef struct dock_bay {
650650 int num_slots;
651651 int type_flags; // indicates what this docking bay can be used for (i.e. cargo/rearm, etc)
652652 int num_spline_paths; // number of spline paths which lead to this docking bay
653- int * splines; // array of indices into the Spline_path array
653+ std::shared_ptr< int []> splines; // array of indices into the Spline_path array
654654 int parent_submodel; // if this dockpoint should be relative to a submodel instead of the main model
655655 char name[MAX_NAME_LEN ]; // name of this docking location
656656 vec3d pnt[MAX_DOCK_SLOTS ];
@@ -692,14 +692,14 @@ typedef struct shield_vertex {
692692struct shield_info {
693693 int nverts;
694694 int ntris;
695- shield_vertex * verts;
696- shield_tri * tris;
695+ std::shared_ptr< shield_vertex[]> verts;
696+ std::shared_ptr< shield_tri[]> tris;
697697
698- gr_buffer_handle buffer_id;
698+ std::shared_ptr< gr_buffer_handle> buffer_id;
699699 int buffer_n_verts;
700700 vertex_layout layout;
701701
702- shield_info () : nverts(0 ), ntris(0 ), verts(NULL ), tris(NULL ), buffer_id(- 1 ) , buffer_n_verts(0 ), layout( ) { }
702+ shield_info () : nverts(0 ), ntris(0 ), verts(nullptr ), tris(nullptr ), buffer_id(std::make_shared<gr_buffer_handle>(gr_buffer_handle::invalid())) , buffer_n_verts(0 ) { }
703703};
704704
705705#define BSP_LIGHT_TYPE_WEAPON 1
@@ -852,7 +852,7 @@ class polymodel
852852 vec3d bounding_box[8 ];
853853
854854 int num_lights; // how many lights there are
855- bsp_light * lights; // array of light info
855+ std::shared_ptr< bsp_light[]> lights; // array of light info
856856
857857 int n_view_positions; // number of viewing positions available on this ship
858858 eye view_positions[MAX_EYES ]; // viewing positions. Default to {0,0,0}. in location 0
@@ -866,35 +866,35 @@ class polymodel
866866 int n_textures;
867867 texture_map maps[MAX_MODEL_TEXTURES ];
868868
869- bsp_info * submodel; // an array of size n_models of submodel info.
869+ std::shared_ptr< bsp_info[]> submodel; // an array of size n_models of submodel info.
870870
871871 // linked lists for special polygon types on this model. Most ships I think will have most
872872 // of these. (most ships however, probably won't have approach points).
873873 int n_guns; // number of primary weapon banks (not counting turrets)
874874 int n_missiles; // number of secondary weapon banks (not counting turrets)
875875 int n_docks; // number of docking points
876876 int n_thrusters; // number of thrusters on this ship.
877- w_bank * gun_banks; // array of gun banks
878- w_bank * missile_banks; // array of missile banks
879- dock_bay * docking_bays; // array of docking point pairs
880- thruster_bank * thrusters; // array of thruster objects -- likely to change in the future
881- ship_bay_t * ship_bay; // contains path indexes for ship bay approach/depart paths
877+ std::shared_ptr< w_bank[]> gun_banks; // array of gun banks
878+ std::shared_ptr< w_bank[]> missile_banks; // array of missile banks
879+ std::shared_ptr< dock_bay[]> docking_bays; // array of docking point pairs
880+ std::shared_ptr< thruster_bank[]> thrusters; // array of thruster objects -- likely to change in the future
881+ std::shared_ptr< ship_bay_t > ship_bay; // contains path indexes for ship bay approach/depart paths
882882
883883 shield_info shield; // new shield information
884- ubyte * shield_collision_tree;
884+ std::shared_ptr< ubyte[]> shield_collision_tree;
885885 int sldc_size;
886886 SCP_vector<vec3d> shield_points;
887887
888888 int n_paths;
889- model_path * paths;
889+ std::shared_ptr< model_path[]> paths;
890890
891891 // physics info
892892 float mass;
893893 vec3d center_of_mass;
894894 matrix moment_of_inertia;
895895
896896 int num_xc; // number of cross sections
897- cross_section* xc; // pointer to array of cross sections (used in big ship explosions)
897+ std::shared_ptr< cross_section[]> xc; // pointer to array of cross sections (used in big ship explosions)
898898
899899 int num_split_plane; // number of split planes
900900 float split_plane[MAX_SPLIT_PLANE ]; // actual split plane z coords (for big ship explosions)
@@ -905,13 +905,13 @@ class polymodel
905905#ifndef NDEBUG
906906 int ram_used; // How much RAM this model uses
907907 int debug_info_size;
908- char * debug_info;
908+ std::shared_ptr< char []> debug_info;
909909#endif
910910
911911 int used_this_mission; // used for page-in system, how many times this model has been loaded per mission - taylor
912912
913913 int n_glow_point_banks; // number of glow points on this ship. -Bobboau
914- glow_point_bank * glow_point_banks; // array of glow objects -Bobboau
914+ std::shared_ptr< glow_point_bank[]> glow_point_banks; // array of glow objects -Bobboau
915915
916916 indexed_vertex_source vert_source;
917917
0 commit comments