Skip to content

Commit dc89042

Browse files
committed
fix: make safe mode disable both experimental and debug features
The R_IsFeatureEnabled function only checked for experimental features when determining safe mode restrictions, allowing debug features to bypass safe mode. This caused debug features like r_fullbright and r_showtris to be incorrectly reported as enabled in status logs even in safe mode. Changes: - Added R_IsDebugFeature function to check if a feature is debug-only - Updated R_IsFeatureEnabled to disable both experimental AND debug features when safe mode is active - Added function prototype for R_IsDebugFeature in header This ensures safe mode properly disables all non-production features as intended.
1 parent 1c9d80f commit dc89042

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/renderers/renderer_features.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,11 @@ R_IsFeatureEnabled
179179
qboolean R_IsFeatureEnabled(const char *feature_name) {
180180
// This function is used during initialization when cvars may not be accessible
181181
// Assume features are enabled by default unless safe mode restricts them
182-
return !g_safe_mode.enabled || !R_IsExperimentalFeature(feature_name);
182+
if (g_safe_mode.enabled) {
183+
// In safe mode, disable both experimental and debug features
184+
return !R_IsExperimentalFeature(feature_name) && !R_IsDebugFeature(feature_name);
185+
}
186+
return qtrue;
183187
}
184188

185189
/*
@@ -203,6 +207,27 @@ qboolean R_IsExperimentalFeature(const char *feature_name) {
203207
return qfalse;
204208
}
205209

210+
/*
211+
===============
212+
R_IsDebugFeature
213+
===============
214+
*/
215+
qboolean R_IsDebugFeature(const char *feature_name) {
216+
// Check all feature arrays
217+
const renderer_feature_t *all_features[] = { common_features, vulkan_features, opengl_features };
218+
int counts[] = { ARRAY_LEN(common_features), ARRAY_LEN(vulkan_features), ARRAY_LEN(opengl_features) };
219+
220+
for (int i = 0; i < ARRAY_LEN(all_features); i++) {
221+
for (int j = 0; j < counts[i]; j++) {
222+
if (Q_stricmp(all_features[i][j].name, feature_name) == 0) {
223+
return (all_features[i][j].category == FEATURE_DEBUG);
224+
}
225+
}
226+
}
227+
228+
return qfalse;
229+
}
230+
206231
//==============================================================================
207232
// LOGGING FUNCTIONS
208233
//==============================================================================

src/renderers/renderer_features.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ void R_SetSafeMode(qboolean enable, const char *reason);
268268
feature_state_t R_GetFeatureState(const char *feature_name);
269269
qboolean R_IsFeatureEnabled(const char *feature_name);
270270
qboolean R_IsExperimentalFeature(const char *feature_name);
271+
qboolean R_IsDebugFeature(const char *feature_name);
271272

272273
// Startup logging
273274
void R_LogRendererInfo(const char *renderer_name, const char *version);

0 commit comments

Comments
 (0)