Skip to content

Commit fb9304b

Browse files
author
Fabian Woltermann
committed
Fix #4415: Make sure that changing team colors only happens when there are team colors to change and only dump the envmap to disk if there actually is an envmap to dump
1 parent 87e6a13 commit fb9304b

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

code/lab/manager/lab_manager.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ void LabManager::onFrame(float frametime) {
224224
break;
225225

226226
case KEY_M:
227-
gr_dump_envmap(Renderer->currentMissionBackground.c_str());
227+
// Dumping the environment map only makes sense if we actually have a background set
228+
if (Renderer->currentMissionBackground != LAB_MISSION_NONE_STRING)
229+
gr_dump_envmap(Renderer->currentMissionBackground.c_str());
228230
break;
229231

230232
// bail...

code/lab/renderer/lab_renderer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ void LabRenderer::renderModel(float frametime) {
6363
Ships[obj->instance].flags.set(Ship::Ship_Flags::Subsystem_movement_locked, !renderFlags[LabRenderFlag::RotateSubsystems]);
6464
Ships[obj->instance].flags.set(Ship::Ship_Flags::Draw_as_wireframe, renderFlags[LabRenderFlag::ShowWireframe]);
6565
Ships[obj->instance].flags.set(Ship::Ship_Flags::Render_full_detail, renderFlags[LabRenderFlag::ShowFullDetail]);
66-
Ships[obj->instance].flags.set(Ship::Ship_Flags::Render_without_light, renderFlags[LabRenderFlag::NoLighting] || currentMissionBackground == "None");
66+
Ships[obj->instance].flags.set(Ship::Ship_Flags::Render_without_light,
67+
renderFlags[LabRenderFlag::NoLighting] || currentMissionBackground == LAB_MISSION_NONE_STRING);
6768
Ships[obj->instance].flags.set(Ship::Ship_Flags::Render_without_diffuse, renderFlags[LabRenderFlag::NoDiffuseMap]);
6869
Ships[obj->instance].flags.set(Ship::Ship_Flags::Render_without_glowmap, renderFlags[LabRenderFlag::NoGlowMap]);
6970
Ships[obj->instance].flags.set(Ship::Ship_Flags::Render_without_normalmap, renderFlags[LabRenderFlag::NoNormalMap]);
@@ -218,7 +219,7 @@ void LabRenderer::renderHud(float) {
218219
}
219220

220221
//Print current Team Color setting, if any
221-
if (currentTeamColor != "<none>") {
222+
if (currentTeamColor != LAB_TEAM_COLOR_NONE) {
222223
gr_printf_no_resize(gr_screen.center_offset_x + 2,
223224
gr_screen.center_offset_y + gr_screen.center_h - (gr_get_font_height() * 3) - 3,
224225
"Use T and Y to cycle through available Team Color settings. Current: %s",

code/lab/renderer/lab_renderer.h

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ enum class TextureOverride {
6767
Specular
6868
};
6969

70+
constexpr auto LAB_MISSION_NONE_STRING = "None";
71+
constexpr auto LAB_TEAM_COLOR_NONE = "<none>";
72+
7073
class LabRenderer {
7174
public:
7275
LabRenderer() {
@@ -75,8 +78,8 @@ class LabRenderer {
7578
directionalFactor = static_light_factor;
7679
textureQuality = TextureQuality::Maximum;
7780
cameraDistance = 100.0f;
78-
currentTeamColor = "<none>";
79-
useBackground("None");
81+
currentTeamColor = LAB_TEAM_COLOR_NONE;
82+
useBackground(LAB_MISSION_NONE_STRING);
8083

8184
labCamera.reset(new OrbitCamera());
8285

@@ -110,25 +113,28 @@ class LabRenderer {
110113
}
111114

112115
void useNextTeamColorPreset() {
113-
auto color_itr = Team_Colors.find(currentTeamColor);
114-
115-
if (color_itr == Team_Colors.begin()) {
116-
color_itr = --Team_Colors.end();
117-
currentTeamColor = color_itr->first;
118-
}
119-
else {
120-
--color_itr;
121-
currentTeamColor = color_itr->first;
116+
if (!Team_Colors.empty()) {
117+
auto color_itr = Team_Colors.find(currentTeamColor);
118+
119+
if (color_itr == Team_Colors.begin()) {
120+
color_itr = --Team_Colors.end();
121+
currentTeamColor = color_itr->first;
122+
} else {
123+
--color_itr;
124+
currentTeamColor = color_itr->first;
125+
}
122126
}
123127
}
124128

125129
void usePreviousTeamColorPreset() {
126-
auto color_itr = Team_Colors.find(currentTeamColor);
130+
if (!Team_Colors.empty()) {
131+
auto color_itr = Team_Colors.find(currentTeamColor);
127132

128-
++color_itr;
129-
if (color_itr == Team_Colors.end())
130-
color_itr = Team_Colors.begin();
131-
currentTeamColor = color_itr->first;
133+
++color_itr;
134+
if (color_itr == Team_Colors.end())
135+
color_itr = Team_Colors.begin();
136+
currentTeamColor = color_itr->first;
137+
}
132138
}
133139

134140
void setTeamColor(SCP_string teamColor) {

0 commit comments

Comments
 (0)