Skip to content

Commit cb0e9ce

Browse files
committed
sync setting and getting of collides and no_collide
The `collides` and `no_collide` flags are equivalent, but opposite. So when sexps or scripts get or set those flags, allow each to be used as an anti-synonym (not exactly an antonym) for the other.
1 parent 5749b85 commit cb0e9ce

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

code/parse/sexp.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16481,6 +16481,14 @@ void sexp_alter_ship_flag_helper(object_ship_wing_point_team &oswpt, bool future
1648116481
}
1648216482
}
1648316483

16484+
// special case: the "no_collide" parse object flag is the same, but opposite, as the "collides" object flag
16485+
if (parse_obj_flag == Mission::Parse_Object_Flags::OF_No_collide)
16486+
{
16487+
auto tmp_flagset = oswpt.objp->flags;
16488+
tmp_flagset.set(Object::Object_Flags::Collides, !set_flag);
16489+
obj_set_flags(oswpt.objp, tmp_flagset);
16490+
}
16491+
1648416492
// see if we have an ai flag to set
1648516493
if (ai_flag != AI::AI_Flags::NUM_VALUES)
1648616494
{
@@ -16496,6 +16504,12 @@ void sexp_alter_ship_flag_helper(object_ship_wing_point_team &oswpt, bool future
1649616504
return;
1649716505
}
1649816506

16507+
// special case: the "collides" object flag is the same, but opposite, as the "no_collide" parse object flag
16508+
if (object_flag == Object::Object_Flags::Collides)
16509+
{
16510+
oswpt.ship_entry->p_objp->flags.set(Mission::Parse_Object_Flags::OF_No_collide, !set_flag);
16511+
}
16512+
1649916513
// see if we have a p_object flag to set
1650016514
if (parse_obj_flag != Mission::Parse_Object_Flags::NUM_VALUES && oswpt.ship_entry->p_objp != nullptr)
1650116515
{
@@ -16619,7 +16633,11 @@ int sexp_are_ship_flags_set(int node)
1661916633
return SEXP_FALSE;
1662016634
}
1662116635

16622-
// we don't check parse flags
16636+
// we don't check parse flags, except for one that can be an object flag in reverse
16637+
if (parse_obj_flag == Mission::Parse_Object_Flags::OF_No_collide) {
16638+
if (objp->flags[Object::Object_Flags::Collides])
16639+
return SEXP_FALSE;
16640+
}
1662316641

1662416642
if (ai_flag != AI::AI_Flags::NUM_VALUES) {
1662516643
if (!(aip->ai_flags[ai_flag]))

code/scripting/api/objs/parse_object.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,12 @@ ADE_FUNC(getFlag, l_ParseObject, "string flag_name", "Checks whether one or more
183183
return ADE_RETURN_FALSE;
184184
}
185185

186-
// we only check parse flags
186+
// we only check parse flags, unless this is the one object flag that is the same thing in reverse
187+
if (object_flag == Object::Object_Flags::Collides)
188+
{
189+
if (pobjp->flags[Mission::Parse_Object_Flags::OF_No_collide])
190+
return ADE_RETURN_FALSE;
191+
}
187192

188193
if (parse_obj_flag != Mission::Parse_Object_Flags::NUM_VALUES)
189194
{

code/scripting/api/objs/ship.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,12 @@ ADE_FUNC(getFlag, l_Ship, "string flag_name", "Checks whether one or more flags
269269
return ADE_RETURN_FALSE;
270270
}
271271

272-
// we don't check parse flags
272+
// we don't check parse flags, except for one that can be an object flag in reverse
273+
if (parse_obj_flag == Mission::Parse_Object_Flags::OF_No_collide)
274+
{
275+
if (objp->flags[Object::Object_Flags::Collides])
276+
return ADE_RETURN_FALSE;
277+
}
273278

274279
if (ai_flag != AI::AI_Flags::NUM_VALUES)
275280
{

0 commit comments

Comments
 (0)