|
64 | 64 | #include "parse/generic_log.h" |
65 | 65 | #include "parse/parselo.h" |
66 | 66 | #include "parse/sexp_container.h" |
| 67 | +#include "prop/prop.h" |
67 | 68 | #include "scripting/global_hooks.h" |
68 | 69 | #include "scripting/hook_api.h" |
69 | 70 | #include "scripting/hook_conditions.h" |
@@ -140,6 +141,9 @@ p_object Ship_arrival_list; // for linked list of ships to arrive later |
140 | 141 | // all the ships that we parse |
141 | 142 | SCP_vector<p_object> Parse_objects; |
142 | 143 |
|
| 144 | +// all the props that we parse |
| 145 | +SCP_vector<parsed_prop> Parse_props; |
| 146 | + |
143 | 147 |
|
144 | 148 | // list for arriving support ship |
145 | 149 | p_object Support_ship_pobj; |
@@ -4934,17 +4938,50 @@ void parse_wing(mission *pm) |
4934 | 4938 | // Goober5000 - wing creation stuff moved to post_process_ships_wings |
4935 | 4939 | } |
4936 | 4940 |
|
| 4941 | +void parse_prop(mission* pm) |
| 4942 | +{ |
| 4943 | + parsed_prop prop; |
| 4944 | + required_string("$Name:"); |
| 4945 | + stuff_string(prop.name, F_NAME, NAME_LENGTH); |
| 4946 | + |
| 4947 | + // Maybe do this by name instead? |
| 4948 | + required_string("$Class:"); |
| 4949 | + stuff_int(&prop.prop_info_index); |
| 4950 | + |
| 4951 | + required_string("$Location:"); |
| 4952 | + stuff_vec3d(&prop.position); |
| 4953 | + |
| 4954 | + required_string("$Orientation:"); |
| 4955 | + stuff_matrix(&prop.orientation); |
| 4956 | + |
| 4957 | + Parse_props.emplace_back(prop); |
| 4958 | +} |
| 4959 | + |
4937 | 4960 | void parse_wings(mission* pm) |
4938 | 4961 | { |
4939 | 4962 | required_string("#Wings"); |
4940 | | - while (required_string_either("#Events", "$Name:")) |
4941 | | - { |
| 4963 | + while (true) { |
| 4964 | + int which = required_string_one_of(3, "#Events", "#Props", "$Name:"); |
| 4965 | + |
| 4966 | + if (which == -1 || which == 0 || which == 1) // #Events or #Props |
| 4967 | + break; |
| 4968 | + |
4942 | 4969 | Assert(Num_wings < MAX_WINGS); |
4943 | 4970 | parse_wing(pm); |
4944 | 4971 | Num_wings++; |
4945 | 4972 | } |
4946 | 4973 | } |
4947 | 4974 |
|
| 4975 | +void parse_props(mission* pm) |
| 4976 | +{ |
| 4977 | + if (optional_string("#Props")) { |
| 4978 | + while (required_string_either("#Events", "$Name:")) { |
| 4979 | + Assert(Parse_props.size() < MAX_PROPS); |
| 4980 | + parse_prop(pm); |
| 4981 | + } |
| 4982 | + } |
| 4983 | +} |
| 4984 | + |
4948 | 4985 | // Goober5000 |
4949 | 4986 | void resolve_path_masks(int anchor, int *path_mask) |
4950 | 4987 | { |
@@ -5023,6 +5060,15 @@ void post_process_path_stuff() |
5023 | 5060 | } |
5024 | 5061 | } |
5025 | 5062 |
|
| 5063 | +// MjnMixael |
| 5064 | +void post_process_props() |
| 5065 | +{ |
| 5066 | + for (int i = 0; i < static_cast<int>(Parse_props.size()); i++) { |
| 5067 | + parsed_prop* propp = &Parse_props[i]; |
| 5068 | + prop_create(&propp->orientation, &propp->position, propp->prop_info_index, propp->name); |
| 5069 | + } |
| 5070 | +} |
| 5071 | + |
5026 | 5072 | // Goober5000 |
5027 | 5073 | void post_process_ships_wings() |
5028 | 5074 | { |
@@ -5147,7 +5193,6 @@ void post_process_ships_wings() |
5147 | 5193 | mission_parse_maybe_create_parse_object(&p_obj); |
5148 | 5194 | } |
5149 | 5195 |
|
5150 | | - |
5151 | 5196 | // ----------------- at this point the ships have been created ----------------- |
5152 | 5197 | // Now set up the wings. This must be done after both dock stuff and ship stuff. |
5153 | 5198 |
|
@@ -6298,6 +6343,7 @@ bool parse_mission(mission *pm, int flags) |
6298 | 6343 | parse_player_info(pm); |
6299 | 6344 | parse_objects(pm, flags); |
6300 | 6345 | parse_wings(pm); |
| 6346 | + parse_props(pm); |
6301 | 6347 | parse_events(pm); |
6302 | 6348 | parse_goals(pm); |
6303 | 6349 | parse_waypoints_and_jumpnodes(pm); |
@@ -6383,6 +6429,8 @@ bool post_process_mission(mission *pm) |
6383 | 6429 | ship_weapon *swp; |
6384 | 6430 | ship_obj *so; |
6385 | 6431 |
|
| 6432 | + post_process_props(); |
| 6433 | + |
6386 | 6434 | // Goober5000 - this must be done even before post_process_ships_wings because it is a prerequisite |
6387 | 6435 | ship_clear_ship_type_counts(); |
6388 | 6436 |
|
@@ -6839,6 +6887,7 @@ void mission_init(mission *pm) |
6839 | 6887 |
|
6840 | 6888 | jumpnode_level_close(); |
6841 | 6889 | waypoint_level_close(); |
| 6890 | + props_level_close(); |
6842 | 6891 |
|
6843 | 6892 | red_alert_invalidate_timestamp(); |
6844 | 6893 | event_music_reset_choices(); |
@@ -6870,6 +6919,8 @@ void mission_init(mission *pm) |
6870 | 6919 |
|
6871 | 6920 | Num_reinforcements = 0; |
6872 | 6921 |
|
| 6922 | + Parse_props.clear(); |
| 6923 | + |
6873 | 6924 | Asteroid_field.num_initial_asteroids = 0; |
6874 | 6925 |
|
6875 | 6926 | // This could be set with a sexp, so we should reset it here |
|
0 commit comments