Skip to content

Commit 6104e6f

Browse files
Merge pull request #4404 from JohnAFernandez/Let's-support-the-hack-that-was-such-a-good-idea
Fix the standalone ship being added to ship list
2 parents 113b57d + 6098675 commit 6104e6f

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

code/mission/missionparse.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,7 +1798,7 @@ void parse_dock_one_docked_object(p_object *pobjp, p_object *parent_pobjp)
17981798
ai_dock_with_object(objp, dockpoint, parent_objp, parent_dockpoint, AIDO_DOCK_NOW);
17991799
}
18001800

1801-
int parse_create_object_sub(p_object *objp);
1801+
int parse_create_object_sub(p_object *objp, bool standalone_ship = false);
18021802

18031803
// Goober5000
18041804
void parse_create_docked_object_helper(p_object *pobjp, p_dock_function_info *infop)
@@ -1825,7 +1825,7 @@ void parse_create_docked_object_helper(p_object *pobjp, p_dock_function_info *in
18251825
* This is a bit tricky because of the way initial docking is now handled.
18261826
* Docking groups require special treatment.
18271827
*/
1828-
int parse_create_object(p_object *pobjp)
1828+
int parse_create_object(p_object *pobjp, bool standalone_ship)
18291829
{
18301830
object *objp;
18311831

@@ -1861,7 +1861,7 @@ int parse_create_object(p_object *pobjp)
18611861
// create normally
18621862
else
18631863
{
1864-
parse_create_object_sub(pobjp);
1864+
parse_create_object_sub(pobjp, standalone_ship);
18651865
}
18661866

18671867
// get the main object
@@ -1894,7 +1894,7 @@ void parse_bring_in_docked_wing(p_object *p_objp, int wingnum, int shipnum);
18941894
* Given a stuffed p_object struct, create an object and fill in the necessary fields.
18951895
* @return object number.
18961896
*/
1897-
int parse_create_object_sub(p_object *p_objp)
1897+
int parse_create_object_sub(p_object *p_objp, bool standalone_ship)
18981898
{
18991899
int i, j, k, objnum, shipnum;
19001900
int anchor_objnum = -1;
@@ -1912,7 +1912,7 @@ int parse_create_object_sub(p_object *p_objp)
19121912
MONITOR_INC(NumShipArrivals, 1);
19131913

19141914
// base level creation - need ship name in case of duplicate textures
1915-
objnum = ship_create(&p_objp->orient, &p_objp->pos, p_objp->ship_class, p_objp->name);
1915+
objnum = ship_create(&p_objp->orient, &p_objp->pos, p_objp->ship_class, p_objp->name, standalone_ship);
19161916
Assert(objnum != -1);
19171917
shipnum = Objects[objnum].instance;
19181918

code/mission/missionparse.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ p_object *mission_parse_get_arrival_ship(const char *name);
495495
bool mission_check_ship_yet_to_arrive(const char *name);
496496
p_object *mission_parse_get_parse_object(ushort net_signature);
497497
p_object *mission_parse_get_parse_object(const char *name);
498-
int parse_create_object(p_object *objp);
498+
int parse_create_object(p_object *objp, bool standalone_ship = false);
499499
void resolve_parse_flags(object *objp, flagset<Mission::Parse_Object_Flags> &parse_flags);
500500

501501
void mission_parse_close();

code/network/multiutil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ void multi_create_standalone_object()
15641564
Net_player->m_player->objnum = objnum;
15651565

15661566
// create the default player ship object and use that as my default virtual "ship", and make it "invisible"
1567-
pobj_num = parse_create_object(Player_start_pobject);
1567+
pobj_num = parse_create_object(Player_start_pobject, true);
15681568
Assert(pobj_num != -1);
15691569
flagset<Object::Object_Flags> tmp_flags;
15701570
obj_set_flags(&Objects[pobj_num], tmp_flags + Object::Object_Flags::Player_ship);

code/ship/ship.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ int Player_ship_class; // needs to be player specific, move to player structure
196196
#define SHIP_OBJ_USED (1<<0) // flag used in ship_obj struct
197197
#define MAX_SHIP_OBJS MAX_SHIPS // max number of ships tracked in ship list
198198
ship_obj Ship_objs[MAX_SHIP_OBJS]; // array used to store ship object indexes
199-
ship_obj Ship_obj_list; // head of linked list of ship_obj structs
199+
ship_obj Ship_obj_list; // head of linked list of ship_obj structs, Standalone ship cannot be in this list or it will cause bugs.
200200

201201
SCP_vector<ship_info> Ship_info;
202202
reinforcements Reinforcements[MAX_REINFORCEMENTS];
@@ -9882,7 +9882,7 @@ static void ship_init_afterburners(ship *shipp)
98829882
* Returns object index of ship.
98839883
* @return -1 means failed.
98849884
*/
9885-
int ship_create(matrix* orient, vec3d* pos, int ship_type, const char* ship_name)
9885+
int ship_create(matrix* orient, vec3d* pos, int ship_type, const char* ship_name, bool standalone_ship)
98869886
{
98879887
int i, n, objnum, j, k, t;
98889888
ship_info *sip;
@@ -10074,8 +10074,10 @@ int ship_create(matrix* orient, vec3d* pos, int ship_type, const char* ship_name
1007410074

1007510075
animation::anim_set_initial_states(shipp);
1007610076

10077-
// Add this ship to Ship_obj_list
10078-
shipp->ship_list_index = ship_obj_list_add(objnum);
10077+
// Add this ship to Ship_obj_list, if it is *not* the standalone ship. That can cause big time bugs.
10078+
if (!standalone_ship){
10079+
shipp->ship_list_index = ship_obj_list_add(objnum);
10080+
}
1007910081

1008010082
// Goober5000 - update the ship registry
1008110083
// (since scripts and sexps can create ships, the entry may not yet exist)

code/ship/ship.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ extern void ship_init(); // called once at game start
15841584
extern void ship_level_init(); // called before the start of each level
15851585

15861586
//returns -1 if failed
1587-
extern int ship_create(matrix* orient, vec3d* pos, int ship_type, const char* ship_name = nullptr);
1587+
extern int ship_create(matrix* orient, vec3d* pos, int ship_type, const char* ship_name = nullptr, bool standalone_ship = false);
15881588
extern void change_ship_type(int n, int ship_type, int by_sexp = 0);
15891589
extern void ship_process_pre( object * objp, float frametime );
15901590
extern void ship_process_post( object * objp, float frametime );

0 commit comments

Comments
 (0)