Skip to content

Commit ed5a22e

Browse files
committed
add missing guardian threshold and fix var name
1 parent 14c27bd commit ed5a22e

File tree

1 file changed

+67
-54
lines changed

1 file changed

+67
-54
lines changed

code/missioneditor/missionsave.cpp

Lines changed: 67 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3817,6 +3817,19 @@ int Fred_mission_save::save_objects()
38173817
fout(" %d", shipp->escort_priority);
38183818
}
38193819

3820+
// Custom Guardian Thrshold
3821+
if (save_config.save_format != MissionFormat::RETAIL) {
3822+
if (shipp->ship_guardian_threshold != 0) {
3823+
if (optional_string_fred("+Guardian Threshold:", "$Name:")) {
3824+
parse_comments();
3825+
} else {
3826+
fout("\n+Guardian Threshold:");
3827+
}
3828+
3829+
fout(" %d", shipp->ship_guardian_threshold);
3830+
}
3831+
}
3832+
38203833
// special explosions
38213834
if (save_config.save_format != MissionFormat::RETAIL) {
38223835
if (shipp->use_special_explosion) {
@@ -4841,77 +4854,77 @@ int Fred_mission_save::save_wings()
48414854
parse_comments(2);
48424855
fout("\t\t;! %d total", Num_wings);
48434856

4844-
for (auto& wing : Wings) {
4845-
if (!wing.wave_count)
4857+
for (auto& w : Wings) {
4858+
if (!w.wave_count)
48464859
continue;
48474860

48484861
count++;
48494862
required_string_either_fred("$Name:", "#Events");
48504863
required_string_fred("$Name:");
48514864
parse_comments(2);
4852-
fout(" %s", wing.name);
4865+
fout(" %s", w.name);
48534866

48544867
// squad logo - Goober5000
48554868
if (save_config.save_format != MissionFormat::RETAIL) {
4856-
if (strlen(wing.wing_squad_filename) > 0) //-V805
4869+
if (strlen(w.wing_squad_filename) > 0) //-V805
48574870
{
48584871
if (optional_string_fred("+Squad Logo:", "$Name:"))
48594872
parse_comments();
48604873
else
48614874
fout("\n+Squad Logo:");
48624875

4863-
fout(" %s", wing.wing_squad_filename);
4876+
fout(" %s", w.wing_squad_filename);
48644877
}
48654878
}
48664879

48674880
required_string_fred("$Waves:");
48684881
parse_comments();
4869-
fout(" %d", wing.num_waves);
4882+
fout(" %d", w.num_waves);
48704883

48714884
required_string_fred("$Wave Threshold:");
48724885
parse_comments();
4873-
fout(" %d", wing.threshold);
4886+
fout(" %d", w.threshold);
48744887

48754888
required_string_fred("$Special Ship:");
48764889
parse_comments();
4877-
fout(" %d\t\t;! %s", wing.special_ship, Ships[wing.ship_index[wing.special_ship]].ship_name);
4890+
fout(" %d\t\t;! %s", w.special_ship, Ships[w.ship_index[w.special_ship]].ship_name);
48784891

48794892
if (save_config.save_format != MissionFormat::RETAIL) {
4880-
if (wing.formation >= 0 && wing.formation < static_cast<int>(Wing_formations.size())) {
4893+
if (w.formation >= 0 && w.formation < static_cast<int>(Wing_formations.size())) {
48814894
if (optional_string_fred("+Formation:", "$Name:")) {
48824895
parse_comments();
48834896
} else {
48844897
fout("\n+Formation:");
48854898
}
4886-
fout(" %s", Wing_formations[wing.formation].name);
4899+
fout(" %s", Wing_formations[w.formation].name);
48874900
}
4888-
if (!fl_equal(wing.formation_scale, 1.0f, 0.001f)) {
4901+
if (!fl_equal(w.formation_scale, 1.0f, 0.001f)) {
48894902
if (optional_string_fred("+Formation Scale:", "$Name:")) {
48904903
parse_comments();
48914904
} else {
48924905
fout("\n+Formation Scale:");
48934906
}
4894-
fout(" %f", wing.formation_scale);
4907+
fout(" %f", w.formation_scale);
48954908
}
48964909
}
48974910

48984911
required_string_fred("$Arrival Location:");
48994912
parse_comments();
4900-
fout(" %s", Arrival_location_names[static_cast<int>(wing.arrival_location)]);
4913+
fout(" %s", Arrival_location_names[static_cast<int>(w.arrival_location)]);
49014914

4902-
if (wing.arrival_location != ArrivalLocation::AT_LOCATION) {
4915+
if (w.arrival_location != ArrivalLocation::AT_LOCATION) {
49034916
if (optional_string_fred("+Arrival Distance:", "$Name:"))
49044917
parse_comments();
49054918
else
49064919
fout("\n+Arrival Distance:");
49074920

4908-
fout(" %d", wing.arrival_distance);
4921+
fout(" %d", w.arrival_distance);
49094922
if (optional_string_fred("$Arrival Anchor:", "$Name:"))
49104923
parse_comments();
49114924
else
49124925
fout("\n$Arrival Anchor:");
49134926

4914-
int z = wing.arrival_anchor;
4927+
int z = w.arrival_anchor;
49154928
if (z < 0) {
49164929
fout(" <error>");
49174930
} else if (z & SPECIAL_ARRIVAL_ANCHOR_FLAG) {
@@ -4928,18 +4941,18 @@ int Fred_mission_save::save_wings()
49284941

49294942
// Goober5000
49304943
if (save_config.save_format != MissionFormat::RETAIL) {
4931-
if ((wing.arrival_location == ArrivalLocation::FROM_DOCK_BAY) && (wing.arrival_path_mask > 0)) {
4944+
if ((w.arrival_location == ArrivalLocation::FROM_DOCK_BAY) && (w.arrival_path_mask > 0)) {
49324945
int anchor_shipnum;
49334946
polymodel* pm;
49344947

4935-
anchor_shipnum = wing.arrival_anchor;
4948+
anchor_shipnum = w.arrival_anchor;
49364949
Assert(anchor_shipnum >= 0 && anchor_shipnum < MAX_SHIPS);
49374950

49384951
fout("\n+Arrival Paths: ( ");
49394952

49404953
pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].model_num);
49414954
for (auto n = 0; n < pm->ship_bay->num_paths; n++) {
4942-
if (wing.arrival_path_mask & (1 << n)) {
4955+
if (w.arrival_path_mask & (1 << n)) {
49434956
fout("\"%s\" ", pm->paths[pm->ship_bay->path_indexes[n]].name);
49444957
}
49454958
}
@@ -4948,48 +4961,48 @@ int Fred_mission_save::save_wings()
49484961
}
49494962
}
49504963

4951-
if (wing.arrival_delay) {
4964+
if (w.arrival_delay) {
49524965
if (optional_string_fred("+Arrival delay:", "$Name:"))
49534966
parse_comments();
49544967
else
49554968
fout("\n+Arrival delay:");
49564969

4957-
fout(" %d", wing.arrival_delay);
4970+
fout(" %d", w.arrival_delay);
49584971
}
49594972

49604973
required_string_fred("$Arrival Cue:");
49614974
parse_comments();
4962-
convert_sexp_to_string(sexp_out, wing.arrival_cue, SEXP_SAVE_MODE);
4975+
convert_sexp_to_string(sexp_out, w.arrival_cue, SEXP_SAVE_MODE);
49634976
fout(" %s", sexp_out.c_str());
49644977

49654978
required_string_fred("$Departure Location:");
49664979
parse_comments();
4967-
fout(" %s", Departure_location_names[static_cast<int>(wing.departure_location)]);
4980+
fout(" %s", Departure_location_names[static_cast<int>(w.departure_location)]);
49684981

4969-
if (wing.departure_location != DepartureLocation::AT_LOCATION) {
4982+
if (w.departure_location != DepartureLocation::AT_LOCATION) {
49704983
required_string_fred("$Departure Anchor:");
49714984
parse_comments();
49724985

4973-
if (wing.departure_anchor >= 0)
4974-
fout(" %s", Ships[wing.departure_anchor].ship_name);
4986+
if (w.departure_anchor >= 0)
4987+
fout(" %s", Ships[w.departure_anchor].ship_name);
49754988
else
49764989
fout(" <error>");
49774990
}
49784991

49794992
// Goober5000
49804993
if (save_config.save_format != MissionFormat::RETAIL) {
4981-
if ((wing.departure_location == DepartureLocation::TO_DOCK_BAY) && (wing.departure_path_mask > 0)) {
4994+
if ((w.departure_location == DepartureLocation::TO_DOCK_BAY) && (w.departure_path_mask > 0)) {
49824995
int anchor_shipnum;
49834996
polymodel* pm;
49844997

4985-
anchor_shipnum = wing.departure_anchor;
4998+
anchor_shipnum = w.departure_anchor;
49864999
Assert(anchor_shipnum >= 0 && anchor_shipnum < MAX_SHIPS);
49875000

49885001
fout("\n+Departure Paths: ( ");
49895002

49905003
pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].model_num);
49915004
for (auto n = 0; n < pm->ship_bay->num_paths; n++) {
4992-
if (wing.departure_path_mask & (1 << n)) {
5005+
if (w.departure_path_mask & (1 << n)) {
49935006
fout("\"%s\" ", pm->paths[pm->ship_bay->path_indexes[n]].name);
49945007
}
49955008
}
@@ -4998,43 +5011,43 @@ int Fred_mission_save::save_wings()
49985011
}
49995012
}
50005013

5001-
if (wing.departure_delay) {
5014+
if (w.departure_delay) {
50025015
if (optional_string_fred("+Departure delay:", "$Name:"))
50035016
parse_comments();
50045017
else
50055018
fout("\n+Departure delay:");
50065019

5007-
fout(" %d", wing.departure_delay);
5020+
fout(" %d", w.departure_delay);
50085021
}
50095022

50105023
required_string_fred("$Departure Cue:");
50115024
parse_comments();
5012-
convert_sexp_to_string(sexp_out, wing.departure_cue, SEXP_SAVE_MODE);
5025+
convert_sexp_to_string(sexp_out, w.departure_cue, SEXP_SAVE_MODE);
50135026
fout(" %s", sexp_out.c_str());
50145027

50155028
required_string_fred("$Ships:");
50165029
parse_comments();
5017-
fout(" (\t\t;! %d total\n", wing.wave_count);
5030+
fout(" (\t\t;! %d total\n", w.wave_count);
50185031

5019-
for (int j = 0; j < wing.wave_count; j++) {
5020-
//ship = wing.ship_index[j];
5032+
for (int j = 0; j < w.wave_count; j++) {
5033+
//ship = w.ship_index[j];
50215034
// if (Objects[Ships[ship].objnum].type == OBJ_START)
50225035
// fout("\t\"Player 1\"\n");
50235036
// else
5024-
fout("\t\"%s\"\n", Ships[wing.ship_index[j]].ship_name);
5037+
fout("\t\"%s\"\n", Ships[w.ship_index[j]].ship_name);
50255038
}
50265039

50275040
fout(")");
50285041

5029-
save_ai_goals(wing.ai_goals, -1);
5042+
save_ai_goals(w.ai_goals, -1);
50305043

5031-
if (wing.hotkey != -1) {
5044+
if (w.hotkey != -1) {
50325045
if (optional_string_fred("+Hotkey:", "$Name:"))
50335046
parse_comments();
50345047
else
50355048
fout("\n+Hotkey:");
50365049

5037-
fout(" %d", wing.hotkey);
5050+
fout(" %d", w.hotkey);
50385051
}
50395052

50405053
if (optional_string_fred("+Flags:", "$Name:")) {
@@ -5052,49 +5065,49 @@ int Fred_mission_save::save_wings()
50525065
return nullptr;
50535066
};
50545067

5055-
if (wing.flags[Ship::Wing_Flags::Ignore_count])
5068+
if (w.flags[Ship::Wing_Flags::Ignore_count])
50565069
fout(" \"%s\"", get_flag_name(Ship::Wing_Flags::Ignore_count));
5057-
if (wing.flags[Ship::Wing_Flags::Reinforcement])
5070+
if (w.flags[Ship::Wing_Flags::Reinforcement])
50585071
fout(" \"%s\"", get_flag_name(Ship::Wing_Flags::Reinforcement));
5059-
if (wing.flags[Ship::Wing_Flags::No_arrival_music])
5072+
if (w.flags[Ship::Wing_Flags::No_arrival_music])
50605073
fout(" \"%s\"", get_flag_name(Ship::Wing_Flags::No_arrival_music));
5061-
if (wing.flags[Ship::Wing_Flags::No_arrival_message])
5074+
if (w.flags[Ship::Wing_Flags::No_arrival_message])
50625075
fout(" \"%s\"", get_flag_name(Ship::Wing_Flags::No_arrival_message));
5063-
if (wing.flags[Ship::Wing_Flags::No_first_wave_message])
5076+
if (w.flags[Ship::Wing_Flags::No_first_wave_message])
50645077
fout(" \"%s\"", get_flag_name(Ship::Wing_Flags::No_first_wave_message));
5065-
if (wing.flags[Ship::Wing_Flags::No_arrival_warp])
5078+
if (w.flags[Ship::Wing_Flags::No_arrival_warp])
50665079
fout(" \"%s\"", get_flag_name(Ship::Wing_Flags::No_arrival_warp));
5067-
if (wing.flags[Ship::Wing_Flags::No_departure_warp])
5080+
if (w.flags[Ship::Wing_Flags::No_departure_warp])
50685081
fout(" \"%s\"", get_flag_name(Ship::Wing_Flags::No_departure_warp));
5069-
if (wing.flags[Ship::Wing_Flags::No_dynamic])
5082+
if (w.flags[Ship::Wing_Flags::No_dynamic])
50705083
fout(" \"%s\"", get_flag_name(Ship::Wing_Flags::No_dynamic));
50715084
if (save_config.save_format != MissionFormat::RETAIL) {
5072-
if (wing.flags[Ship::Wing_Flags::Nav_carry])
5085+
if (w.flags[Ship::Wing_Flags::Nav_carry])
50735086
fout(" \"%s\"", get_flag_name(Ship::Wing_Flags::Nav_carry));
5074-
if (wing.flags[Ship::Wing_Flags::Same_arrival_warp_when_docked])
5087+
if (w.flags[Ship::Wing_Flags::Same_arrival_warp_when_docked])
50755088
fout(" \"%s\"", get_flag_name(Ship::Wing_Flags::Same_arrival_warp_when_docked));
5076-
if (wing.flags[Ship::Wing_Flags::Same_departure_warp_when_docked])
5089+
if (w.flags[Ship::Wing_Flags::Same_departure_warp_when_docked])
50775090
fout(" \"%s\"", get_flag_name(Ship::Wing_Flags::Same_departure_warp_when_docked));
50785091
}
50795092

50805093
fout(" )");
50815094

5082-
if (wing.wave_delay_min) {
5095+
if (w.wave_delay_min) {
50835096
if (optional_string_fred("+Wave Delay Min:", "$Name:"))
50845097
parse_comments();
50855098
else
50865099
fout("\n+Wave Delay Min:");
50875100

5088-
fout(" %d", wing.wave_delay_min);
5101+
fout(" %d", w.wave_delay_min);
50895102
}
50905103

5091-
if (wing.wave_delay_max) {
5104+
if (w.wave_delay_max) {
50925105
if (optional_string_fred("+Wave Delay Max:", "$Name:"))
50935106
parse_comments();
50945107
else
50955108
fout("\n+Wave Delay Max:");
50965109

5097-
fout(" %d", wing.wave_delay_max);
5110+
fout(" %d", w.wave_delay_max);
50985111
}
50995112

51005113
fso_comment_pop();

0 commit comments

Comments
 (0)