Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions code/mission/missionparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ path_restriction_t Path_restrictions[MAX_PATH_RESTRICTIONS];

extern int debrief_find_persona_index();

static bool mission_has_layer_name(const mission* pm, const SCP_string& layerName) {
return std::any_of(pm->fred_layers.begin(), pm->fred_layers.end(), [&layerName](const SCP_string& existingLayer) {
return stricmp(existingLayer.c_str(), layerName.c_str()) == 0;
});
}

//XSTR:OFF

const char *Nebula_filenames[NUM_NEBULAS] = {
Expand Down Expand Up @@ -2247,6 +2253,7 @@ int parse_create_object_sub(p_object *p_objp, bool standalone_ship)
}

shipp->group = p_objp->group;
shipp->fred_layer = p_objp->fred_layer;
shipp->escort_priority = p_objp->escort_priority;
shipp->ship_guardian_threshold = p_objp->ship_guardian_threshold;
shipp->use_special_explosion = p_objp->use_special_explosion;
Expand Down Expand Up @@ -3777,6 +3784,17 @@ int parse_object(mission *pm, int /*flag*/, p_object *p_objp)
if (optional_string("+Group:"))
stuff_int(&p_objp->group);

if (optional_string("+Layer:")) {
stuff_string(p_objp->fred_layer, F_NAME);
if (!mission_has_layer_name(&The_mission, p_objp->fred_layer)) {
if (p_objp->fred_layer.empty()) {
p_objp->fred_layer = "Default";
} else {
The_mission.fred_layers.push_back(p_objp->fred_layer);
}
}
}

bool table_score = false;
if (optional_string("+Use Table Score:")) {
table_score = true;
Expand Down Expand Up @@ -5185,6 +5203,17 @@ void parse_prop(mission* /*pm*/)
}
}

if (optional_string("+Layer:")) {
stuff_string(p.fred_layer, F_NAME);
if (!mission_has_layer_name(&The_mission, p.fred_layer)) {
if (p.fred_layer.empty()) {
p.fred_layer = "Default";
} else {
The_mission.fred_layers.push_back(p.fred_layer);
}
}
}

// if idx is still -1 then we have an empty props.tbl so we parse
// everything here and just discard it. A warning has already been generated above.
if (idx < 0) {
Expand Down Expand Up @@ -5366,6 +5395,11 @@ void post_process_mission_props()
if (propp.flags[Mission::Parse_Object_Flags::OF_No_collide]) {
obj.flags.remove(Object::Object_Flags::Collides);
}

auto createdProp = prop_id_lookup(obj.instance);
if (createdProp != nullptr) {
createdProp->fred_layer = propp.fred_layer;
}
}
}
}
Expand Down Expand Up @@ -7102,6 +7136,8 @@ void mission::Reset()

custom_data.clear();
custom_strings.clear();
fred_layers.clear();
fred_layers.emplace_back("Default");
}

void support_ship_info::reset()
Expand Down
2 changes: 2 additions & 0 deletions code/mission/missionparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ typedef struct mission {
SCP_map<SCP_string, SCP_string> custom_data;

SCP_vector<custom_string> custom_strings;
SCP_vector<SCP_string> fred_layers;

void Reset( );

Expand Down Expand Up @@ -474,6 +475,7 @@ class p_object
object *created_object = nullptr; // Goober5000
int collision_group_id = 0; // Goober5000
int group = -1; // group object is within or -1 if none.
SCP_string fred_layer = "Default";
int persona_index = -1;
int kamikaze_damage = 0; // base damage for a kamikaze attack

Expand Down
22 changes: 22 additions & 0 deletions code/missioneditor/missionsave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4057,6 +4057,17 @@ int Fred_mission_save::save_objects()
fout(" %d", shipp->group);
}

if (save_config.save_format != MissionFormat::RETAIL &&
!shipp->fred_layer.empty() &&
stricmp(shipp->fred_layer.c_str(), "Default") != 0) {
if (optional_string_fred("+Layer:", "$Name:"))
parse_comments();
else
fout("\n+Layer:");

fout(" %s", shipp->fred_layer.c_str());
}

// always write out the score to ensure backwards compatibility. If the score is the same as the value
// in the table write out a flag to tell the game to simply use whatever is in the table instead
if (Ship_info[shipp->ship_info_index].score == shipp->score) {
Expand Down Expand Up @@ -5159,6 +5170,17 @@ int Fred_mission_save::save_props()
fout(" \"no_collide\"");
fout(" )");

if (save_config.save_format != MissionFormat::RETAIL &&
!p->fred_layer.empty() &&
stricmp(p->fred_layer.c_str(), "Default") != 0) {
if (optional_string_fred("+Layer:", "$Name:"))
parse_comments();
else
fout("\n+Layer:");

fout(" %s", p->fred_layer.c_str());
}

fso_comment_pop();
}
}
Expand Down
2 changes: 2 additions & 0 deletions code/prop/prop.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ typedef struct prop {
uint create_time; // time prop was created, set by gettime()
fix time_created;
float alpha_mult;
SCP_string fred_layer = "Default";
// glow points
SCP_deque<bool> glow_point_bank_active;
flagset<Prop::Prop_Flags> flags;
Expand All @@ -49,6 +50,7 @@ typedef struct parsed_prop {
matrix orientation;
vec3d position;
flagset<Mission::Parse_Object_Flags> flags;
SCP_string fred_layer = "Default";
} parsed_prop;

extern bool Props_inited;
Expand Down
1 change: 1 addition & 0 deletions code/ship/ship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7273,6 +7273,7 @@ void ship::clear()
swarm_missile_bank = -1;

group = -1;
fred_layer = "Default";
death_roll_snd = sound_handle::invalid();
ship_list_index = -1;

Expand Down
1 change: 1 addition & 0 deletions code/ship/ship.h
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ class ship
int swarm_missile_bank; // The missilebank the swarm was originally launched from

int group; // group ship is in, or -1 if none. Fred thing
SCP_string fred_layer = "Default"; // FRED view layer assignment
sound_handle death_roll_snd; // id of death roll sound, may need to be stopped early
int ship_list_index; // index of ship in Ship_objs[] array

Expand Down
2 changes: 2 additions & 0 deletions qtfred/source_groups.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ add_file_folder("Source/UI/Dialogs"
src/ui/dialogs/GlobalShipFlagsDialog.h
src/ui/dialogs/JumpNodeEditorDialog.cpp
src/ui/dialogs/JumpNodeEditorDialog.h
src/ui/dialogs/LayerManagerDialog.cpp
src/ui/dialogs/LayerManagerDialog.h
src/ui/dialogs/MissionCutscenesDialog.cpp
src/ui/dialogs/MissionCutscenesDialog.h
src/ui/dialogs/MissionEventsDialog.cpp
Expand Down
Loading
Loading