Skip to content

Commit f0c8c9a

Browse files
authored
Merge pull request #5658 from Goober5000/fix_barrel_roll
fix barrel roll crash in Star Fox: Event Horizon
2 parents be8ec82 + 79579ed commit f0c8c9a

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

code/mission/missionparse.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,6 +2518,7 @@ int parse_create_object_sub(p_object *p_objp, bool standalone_ship)
25182518

25192519
if (ship_it != Ship_registry_map.end()) {
25202520
auto entry = &Ship_registry[ship_it->second];
2521+
entry->status = ShipStatus::NOT_YET_PRESENT;
25212522
entry->p_objp = p_objp;
25222523
}
25232524

@@ -4261,6 +4262,7 @@ int parse_wing_create_ships( wing *wingp, int num_to_create, bool force_create,
42614262
if (!ship_registry_get(p_objp->name))
42624263
{
42634264
ship_registry_entry entry(p_objp->name);
4265+
entry.status = ShipStatus::NOT_YET_PRESENT;
42644266
entry.p_objp = p_objp;
42654267

42664268
Ship_registry.push_back(entry);
@@ -4880,6 +4882,7 @@ void post_process_ships_wings()
48804882
for (auto &p_obj : Parse_objects)
48814883
{
48824884
ship_registry_entry entry(p_obj.name);
4885+
entry.status = ShipStatus::NOT_YET_PRESENT;
48834886
entry.p_objp = &p_obj;
48844887

48854888
Ship_registry.push_back(entry);

code/parse/sexp.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6593,7 +6593,7 @@ void eval_object_ship_wing_point_team(object_ship_wing_point_team *oswpt, int no
65936593
break;
65946594

65956595
default:
6596-
Assertion(false, "Unhandled ship status!");
6596+
UNREACHABLE("Unhandled ship registry entry status for %s: %d", ship_entry->name, (int)ship_entry->status);
65976597
}
65986598

65996599
return;
@@ -16267,8 +16267,8 @@ void sexp_deal_with_ship_flag(int node, bool process_subsequent_nodes, Object::O
1626716267
Current_sexp_network_packet.send_ship(ship_entry->shipp);
1626816268
}
1626916269
}
16270-
// if it's not in-mission
16271-
else
16270+
// if it hasn't arrived yet
16271+
else if (ship_entry->status == ShipStatus::NOT_YET_PRESENT)
1627216272
{
1627316273
// see if we have a p_object flag to set
1627416274
if (p_object_flag != Mission::Parse_Object_Flags::NUM_VALUES)
@@ -16495,12 +16495,13 @@ void sexp_alter_ship_flag_helper(object_ship_wing_point_team &oswpt, bool future
1649516495
// set or clear?
1649616496
Ai_info[oswpt.ship_entry->shipp->ai_index].ai_flags.set(ai_flag, set_flag);
1649716497
}
16498-
16498+
1649916499
// no break statement. We want to fall through.
1650016500
FALLTHROUGH;
1650116501

1650216502
case OSWPT_TYPE_PARSE_OBJECT:
16503-
if (!future_ships) {
16503+
// only apply the flag to future ships if we want to and we are able to
16504+
if (!future_ships || !oswpt.ship_entry->p_objp) {
1650416505
return;
1650516506
}
1650616507

@@ -16511,7 +16512,7 @@ void sexp_alter_ship_flag_helper(object_ship_wing_point_team &oswpt, bool future
1651116512
}
1651216513

1651316514
// see if we have a p_object flag to set
16514-
if (parse_obj_flag != Mission::Parse_Object_Flags::NUM_VALUES && oswpt.ship_entry->p_objp != nullptr)
16515+
if (parse_obj_flag != Mission::Parse_Object_Flags::NUM_VALUES)
1651516516
{
1651616517
oswpt.ship_entry->p_objp->flags.set(parse_obj_flag, set_flag);
1651716518
}
@@ -16520,7 +16521,6 @@ void sexp_alter_ship_flag_helper(object_ship_wing_point_team &oswpt, bool future
1652016521
default:
1652116522
break;
1652216523
}
16523-
1652416524
}
1652516525

1652616526
void alter_flag_for_all_ships(bool future_ships, Object::Object_Flags object_flag, Ship::Ship_Flags ship_flag, Mission::Parse_Object_Flags parse_obj_flag, AI::AI_Flags ai_flag, bool set_flag)

code/scripting/api/objs/oswpt.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ void object_ship_wing_point_team::deserialize(lua_State* /*L*/, const scripting:
6262
case oswpt_type::PARSE_OBJECT: {
6363
ushort net_signature;
6464
GET_USHORT(net_signature);
65-
new(data_ptr) object_ship_wing_point_team(mission_parse_get_arrival_ship(net_signature));
65+
auto p_objp = mission_parse_get_arrival_ship(net_signature);
66+
if (p_objp == nullptr)
67+
new(data_ptr) object_ship_wing_point_team;
68+
else
69+
new(data_ptr) object_ship_wing_point_team(p_objp);
6670
break;
6771
}
6872
case oswpt_type::WING:

code/ship/ship.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,11 @@ extern int ship_find_exited_ship_by_signature( int signature);
900900
// Stuff for overall ship status, useful for reference by sexps and scripts. Status changes occur in the same frame as mission log entries.
901901
enum class ShipStatus
902902
{
903+
// The ship_registry_entry hasn't been initialized yet
904+
INVALID = 0,
905+
903906
// A ship is on the arrival list as a parse object
904-
NOT_YET_PRESENT = 0,
907+
NOT_YET_PRESENT,
905908

906909
// A ship is currently in-mission, and its objp and shipp pointers are valid
907910
PRESENT,
@@ -915,7 +918,7 @@ enum class ShipStatus
915918

916919
struct ship_registry_entry
917920
{
918-
ShipStatus status = ShipStatus::NOT_YET_PRESENT;
921+
ShipStatus status = ShipStatus::INVALID;
919922
char name[NAME_LENGTH];
920923

921924
p_object *p_objp = nullptr;

0 commit comments

Comments
 (0)