Skip to content

Commit 010441f

Browse files
fix parsing issues with hud color presets
The first issue is that if a gauge isn't found it will fail to parse any remaining gauges in the file. The second issue is that when saving the preset the game uses translated strings for the gauge name but when loading the preset it uses untranslated strings. This should address both issues while keeping the original purpose of the changes as well as not breaking existing presets or requiring any mod changes. Ref: http://scp.indiegames.us/mantis/view.php?id=3099
1 parent a44adde commit 010441f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

code/hud/hudconfig.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,7 @@ void hud_config_color_load(const char *name)
16131613
int idx;
16141614
char str[1024];
16151615
char *fname;
1616+
ubyte r, g, b, a;
16161617

16171618
fname = cf_add_ext(name, ".hcf");
16181619

@@ -1630,13 +1631,18 @@ void hud_config_color_load(const char *name)
16301631
while (optional_string("+Gauge:")) {
16311632
stuff_string(str, F_NAME, sizeof(str));
16321633

1634+
required_string("+RGBA:");
1635+
stuff_ubyte(&r);
1636+
stuff_ubyte(&g);
1637+
stuff_ubyte(&b);
1638+
stuff_ubyte(&a);
1639+
16331640
for (idx = 0; idx < NUM_HUD_GAUGES; idx++) {
1634-
if (!stricmp(str, Hud_Gauge_Names[idx])) {
1635-
required_string("+RGBA:");
1636-
stuff_ubyte(&HUD_config.clr[idx].red);
1637-
stuff_ubyte(&HUD_config.clr[idx].green);
1638-
stuff_ubyte(&HUD_config.clr[idx].blue);
1639-
stuff_ubyte(&HUD_config.clr[idx].alpha);
1641+
if (!stricmp(str, HC_gauge_descriptions(idx))) {
1642+
HUD_config.clr[idx].red = r;
1643+
HUD_config.clr[idx].green = g;
1644+
HUD_config.clr[idx].blue = b;
1645+
HUD_config.clr[idx].alpha = a;
16401646
break;
16411647
}
16421648
}

0 commit comments

Comments
 (0)