Skip to content

Commit 2ae6377

Browse files
committed
cleanup
1 parent 9de7d7f commit 2ae6377

File tree

4 files changed

+23
-65
lines changed

4 files changed

+23
-65
lines changed

code/prop/prop.cpp

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void parse_prop_table(const char* filename)
178178
}
179179
// an entry does not exist
180180
else {
181-
// Don't create ship if it has +nocreate and is in a modular table.
181+
// Don't create prop if it has +nocreate and is in a modular table.
182182
if (!create_if_not_found && Parsing_modular_table) {
183183
if (!skip_to_start_of_string_either("$Name:", "#End")) {
184184
error_display(1, "Missing [#End] or [$Name] after prop class %s", fname);
@@ -212,7 +212,7 @@ void parse_prop_table(const char* filename)
212212
if (valid) {
213213
pip->pof_file = temp;
214214
} else {
215-
WarningEx(LOCATION, "Ship %s\nPOF file \"%s\" invalid!", pip->name.c_str(), temp);
215+
WarningEx(LOCATION, "Prop %s\nPOF file \"%s\" invalid!", pip->name.c_str(), temp);
216216
}
217217
}
218218

@@ -360,7 +360,7 @@ void prop_init()
360360
}
361361

362362
/**
363-
* Returns object index of ship.
363+
* Returns object index of prop.
364364
* @return -1 means failed.
365365
*/
366366
int prop_create(matrix* orient, vec3d* pos, int prop_type, const char* name)
@@ -432,22 +432,19 @@ int prop_create(matrix* orient, vec3d* pos, int prop_type, const char* name)
432432
for (int i = 0; i < pm->n_detail_levels; i++)
433433
pm->detail_depth[i] = (i < pip->num_detail_levels) ? i2fl(pip->detail_distance[i]) : 0.0f;
434434

435-
flagset<Object::Object_Flags> default_ship_object_flags;
436-
default_ship_object_flags.set(Object::Object_Flags::Renders);
437-
default_ship_object_flags.set(Object::Object_Flags::Physics);
438-
default_ship_object_flags.set(Object::Object_Flags::Immobile);
439-
// JAS: Nav buoys don't need to do collisions!
440-
// G5K: Corrected to apply specifically for ships with the no-collide flag. (In retail, navbuoys already have this
441-
// flag, so this doesn't break anything.)
442-
default_ship_object_flags.set(Object::Object_Flags::Collides, !pip->flags[Prop::Info_Flags::No_collide]);
435+
flagset<Object::Object_Flags> default_prop_object_flags;
436+
default_prop_object_flags.set(Object::Object_Flags::Renders);
437+
default_prop_object_flags.set(Object::Object_Flags::Physics);
438+
default_prop_object_flags.set(Object::Object_Flags::Immobile);
439+
default_prop_object_flags.set(Object::Object_Flags::Collides, !pip->flags[Prop::Info_Flags::No_collide]);
443440

444441
int objnum = obj_create(OBJ_PROP,
445442
-1,
446443
new_id,
447444
orient,
448445
pos,
449446
model_get_radius(pip->model_num),
450-
default_ship_object_flags);
447+
default_prop_object_flags);
451448
Assert(objnum >= 0);
452449

453450
propp->objnum = objnum;
@@ -493,16 +490,14 @@ int prop_create(matrix* orient, vec3d* pos, int prop_type, const char* name)
493490

494491
//animation::anim_set_initial_states(propp);
495492

496-
// Start up stracking for this ship in multi.
493+
// Start up stracking for this prop in multi.
497494
//if (Game_mode & (GM_MULTIPLAYER)) {
498495
//multi_rollback_ship_record_add_ship(objnum);
499496
//}
500497

501-
// Set time when ship is created
498+
// Set time when prop is created
502499
propp->create_time = timer_get_milliseconds();
503500

504-
//ship_make_create_time_unique(shipp);
505-
506501
propp->time_created = Missiontime;
507502

508503
return objnum;
@@ -622,26 +617,25 @@ void change_prop_type(int n, int prop_type)
622617
{
623618
prop* sp = prop_id_lookup(n);
624619

625-
// do a quick out if we're already using the new ship class
620+
// do a quick out if we're already using the new prop class
626621
if (sp->prop_info_index == prop_type)
627622
return;
628623

629624
int objnum = sp->objnum;
630-
//auto prop_entry = ship_registry_get(sp->prop_name);
631625

632-
prop_info* sip = &(Prop_info[prop_type]);
633-
prop_info* sip_orig = &Prop_info[sp->prop_info_index];
626+
prop_info* pip = &(Prop_info[prop_type]);
627+
prop_info* pip_orig = &Prop_info[sp->prop_info_index];
634628
object* objp = &Objects[objnum];
635629

636-
// point to new ship data
630+
// point to new prop data
637631
prop_model_change(n, prop_type);
638632
sp->prop_info_index = prop_type;
639633

640634
// check class-specific flags
641635

642-
if (sip->flags[Prop::Info_Flags::No_collide]) // changing TO a no-collision ship class
636+
if (pip->flags[Prop::Info_Flags::No_collide]) // changing TO a no-collision prop class
643637
obj_set_flags(objp, objp->flags - Object::Object_Flags::Collides);
644-
else if (sip_orig->flags[Prop::Info_Flags::No_collide]) // changing FROM a no-collision ship class
638+
else if (pip_orig->flags[Prop::Info_Flags::No_collide]) // changing FROM a no-collision prop class
645639
obj_set_flags(objp, objp->flags + Object::Object_Flags::Collides);
646640
}
647641

@@ -669,9 +663,6 @@ void prop_render(object* obj, model_draw_list* scene)
669663
render_info.set_alpha_mult(propp->alpha_mult);
670664
}
671665

672-
// Valathil - maybe do a scripting hook here to do some scriptable effects?
673-
//ship_render_set_animated_effect(&render_info, shipp, &render_flags);
674-
675666
if (pip->flags[Prop::Info_Flags::No_lighting]) {
676667
render_flags |= MR_NO_LIGHTING;
677668
}

code/prop/prop.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ typedef struct prop_info {
1414
SCP_string name; // Prop name
1515
SCP_string category; // Category name
1616
SCP_string pof_file; // Pof filename
17-
vec3d closeup_pos; // position for camera when using ship in closeup view (eg briefing and techroom)
18-
float closeup_zoom; // zoom when using ship in closeup view (eg briefing and techroom)
17+
vec3d closeup_pos; // position for camera when using prop in closeup view (eg briefing and techroom)
18+
float closeup_zoom; // zoom when using prop in closeup view (eg briefing and techroom)
1919
int model_num; // The model number of the loaded POF
2020
int num_detail_levels; // Detail levels of the model
2121
int detail_distance[MAX_PROP_DETAIL_LEVELS]; // distance to change detail levels at
@@ -74,7 +74,7 @@ inline int prop_info_size()
7474
void prop_init();
7575

7676
// Object management
77-
int prop_create(matrix* orient, vec3d* pos, int prop_type, const char* ship_name = nullptr);
77+
int prop_create(matrix* orient, vec3d* pos, int prop_type, const char* name = nullptr);
7878
void prop_delete(object* obj);
7979
void prop_render(object* obj, model_draw_list* scene);
8080

code/scripting/api/objs/prop.cpp

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,11 @@
33

44
#include "globalincs/utility.h"
55

6-
#include "animation_handle.h"
7-
#include "cockpit_display.h"
8-
#include "enums.h"
9-
#include "message.h"
106
#include "modelinstance.h"
117
#include "object.h"
12-
#include "order.h"
13-
#include "parse_object.h"
14-
#include "ship.h"
15-
#include "ship_bank.h"
16-
#include "shipclass.h"
17-
#include "subsystem.h"
18-
#include "team.h"
19-
#include "texture.h"
20-
#include "vecmath.h"
21-
#include "waypoint.h"
22-
#include "weaponclass.h"
23-
#include "wing.h"
24-
258
#include "prop.h"
269
#include "propclass.h"
2710

28-
#include "ai/aigoals.h"
29-
#include "hud/hudets.h"
30-
#include "hud/hudshield.h"
31-
#include "mission/missionlog.h"
32-
#include "mission/missionmessage.h"
33-
#include "model/model.h"
34-
#include "network/multiutil.h"
35-
#include "object/object.h"
36-
#include "object/objectdock.h"
37-
#include "parse/parselo.h"
38-
#include "playerman/player.h"
39-
#include "scripting/api/objs/message.h"
40-
#include "ship/ship.h"
41-
#include "ship/shipfx.h"
42-
#include "ship/shiphit.h"
43-
4411
#include "prop/prop.h"
4512

4613
namespace scripting {
@@ -92,7 +59,7 @@ ADE_VIRTVAR(Class,
9259

9360
prop* propp = prop_id_lookup(objh->objp()->instance);
9461

95-
if (ADE_SETTING_VAR && idx > -1) {
62+
if (ADE_SETTING_VAR && SCP_vector_inbounds(Prop_info, idx)) {
9663
change_prop_type(objh->objp()->instance, idx);
9764
}
9865

code/scripting/api/objs/propclass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ ADE_FUNC(renderTechModel,
242242
&lighting))
243243
return ade_set_error(L, "b", false);
244244

245-
if (idx < 0 || idx >= ship_info_size())
245+
if (idx < 0 || idx >= prop_info_size())
246246
return ade_set_args(L, "b", false);
247247

248248
if (x2 < x1 || y2 < y1)
@@ -280,7 +280,7 @@ ADE_FUNC(renderTechModel2,
280280
if (!ade_get_args(L, "oiiiio|f", l_Propclass.Get(&idx), &x1, &y1, &x2, &y2, l_Matrix.GetPtr(&mh), &zoom))
281281
return ade_set_error(L, "b", false);
282282

283-
if (idx < 0 || idx >= ship_info_size())
283+
if (idx < 0 || idx >= prop_info_size())
284284
return ade_set_args(L, "b", false);
285285

286286
if (x2 < x1 || y2 < y1)

0 commit comments

Comments
 (0)