Skip to content

Commit 63445de

Browse files
committed
remove Object.parent_type
It's theoretically possible for `parent_type` to get out of sync with the parent's type, particularly if the parent is destroyed. Since the field is almost never used, it can be removed. Should fix #4105.
1 parent 6198474 commit 63445de

File tree

7 files changed

+5
-18
lines changed

7 files changed

+5
-18
lines changed

code/object/objcollide.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ void obj_add_collider(int obj_index)
569569
CheckObjects[obj_index].signature = objp->signature;
570570
CheckObjects[obj_index].flags = objp->flags - Object::Object_Flags::Not_in_coll;
571571
CheckObjects[obj_index].parent_sig = objp->parent_sig;
572-
CheckObjects[obj_index].parent_type = objp->parent_type;
573572
#endif
574573

575574
if(!(objp->flags[Object::Object_Flags::Not_in_coll])){

code/object/object.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ obj_flag_name Object_flag_names[] = {
111111

112112
#ifdef OBJECT_CHECK
113113
checkobject::checkobject()
114-
: type(0), signature(0), parent_sig(0), parent_type(0)
114+
: type(0), signature(0), parent_sig(0)
115115
{
116116
flags.reset();
117117
}
@@ -138,7 +138,7 @@ void object::clear()
138138
{
139139
signature = num_pairs = collision_group_id = 0;
140140
parent = parent_sig = instance = -1;
141-
type = parent_type = OBJ_NONE;
141+
type = OBJ_NONE;
142142
flags.reset();
143143
pos = last_pos = vmd_zero_vector;
144144
orient = last_orient = vmd_identity_matrix;
@@ -505,10 +505,8 @@ int obj_create(ubyte type,int parent_obj,int instance, matrix * orient,
505505
obj->parent = parent_obj;
506506
if (obj->parent != -1) {
507507
obj->parent_sig = Objects[parent_obj].signature;
508-
obj->parent_type = Objects[parent_obj].type;
509508
} else {
510509
obj->parent_sig = obj->signature;
511-
obj->parent_type = obj->type;
512510
}
513511

514512
obj->flags = flags;
@@ -1010,10 +1008,6 @@ void obj_check_object( object *obj )
10101008
mprintf(( "Object parent sig changed!\n" ));
10111009
Int3();
10121010
}
1013-
if ( CheckObjects[objnum].parent_type != obj->parent_type ) {
1014-
mprintf(( "Object's parent type changed!\n" ));
1015-
Int3();
1016-
}
10171011
}
10181012
#endif
10191013

code/object/object.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ class object
123123
char type; // what type of object this is... robot, weapon, hostage, powerup, fireball
124124
int parent; // This object's parent.
125125
int parent_sig; // This object's parent's signature
126-
char parent_type; // This object's parent's type
127126
int instance; // which instance. ie.. if type is Robot, then this indexes into the Robots array
128127
flagset<Object::Object_Flags> flags; // misc flags. Call obj_set_flags to change this.
129128
vec3d pos; // absolute x,y,z coordinate of center of object
@@ -181,7 +180,6 @@ class checkobject
181180
int signature;
182181
flagset<Object::Object_Flags> flags;
183182
int parent_sig;
184-
int parent_type;
185183

186184
checkobject();
187185
};

code/scripting/api/objs/object.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,11 @@ ADE_VIRTVAR(Parent, l_Object, "object", "Parent of the object. Value may also be
8484
{
8585
objh->objp->parent = OBJ_INDEX(newparenth->objp);
8686
objh->objp->parent_sig = newparenth->sig;
87-
objh->objp->parent_type = newparenth->objp->type;
8887
}
8988
else
9089
{
9190
objh->objp->parent = -1;
9291
objh->objp->parent_sig = 0;
93-
objh->objp->parent_type = OBJ_NONE;
9492
}
9593
}
9694

code/ship/shiphit.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,11 +1928,10 @@ void ship_hit_kill(object *ship_objp, object *other_obj, vec3d *hitpos, float pe
19281928
}
19291929

19301930
// maybe praise the player for this kill
1931-
if ( (killer_damage_percent > 10) && (other_obj != NULL) ) {
1931+
if ( (killer_damage_percent > 10) && (other_obj != nullptr) && (other_obj->parent >= 0) ) {
19321932
if (other_obj->parent_sig == Player_obj->signature) {
19331933
ship_maybe_praise_player(sp);
1934-
}
1935-
else if ((other_obj->parent_type == OBJ_SHIP) || (other_obj->parent_type == OBJ_START)) {
1934+
} else if (Objects[other_obj->parent].type == OBJ_SHIP) {
19361935
ship_maybe_praise_self(sp, &Ships[Objects[other_obj->parent].instance]);
19371936
}
19381937
}

code/weapon/weapons.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6455,7 +6455,7 @@ void spawn_child_weapons(object *objp, int spawn_index_override)
64556455
parent_num = objp->parent;
64566456

64576457
if (parent_num >= 0) {
6458-
if ((Objects[parent_num].type != objp->parent_type) || (Objects[parent_num].signature != objp->parent_sig)) {
6458+
if (Objects[parent_num].signature != objp->parent_sig) {
64596459
mprintf(("Warning: Parent of spawn weapon does not exist. Not spawning.\n"));
64606460
return;
64616461
}

fred2/freddoc.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ SerializeInt(fp, mode, objp->signature);
725725
SerializeInt(fp, mode, objp->type);
726726
SerializeInt(fp, mode, objp->parent);
727727
SerializeInt(fp, mode, objp->parent_sig);
728-
SerializeInt(fp, mode, objp->parent_type);
729728
SerializeInt(fp, mode, objp->instance);
730729
SerializeInt(fp, mode, objp->flags);
731730
SerializeInt(fp, mode, objp->flags2); // Goober5000 - code is obsolete, but I added this just in case

0 commit comments

Comments
 (0)