View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003099 | FSSCP | tables | public | 2014-08-22 04:12 | 2014-09-07 04:00 |
Reporter | z64555 | Assigned To | Yarn | ||
Priority | low | Severity | minor | Reproducibility | have not tried |
Status | resolved | Resolution | fixed | ||
Platform | x86_64 | OS | Microsoft Windows | OS Version | 8.1 |
Product Version | 3.7.2 RC3 | ||||
Target Version | 3.7.2 | ||||
Summary | 0003099: HUD Color File (*.HCF) Parser Errors | ||||
Description | This cropped up when BlackYoshi was asking around for the file type that contained the predefined color codes for the HUD. I took a peek at the source code and quickly found the parsing routine with an interesting flaw. The string passed to the +Gauge field is completely ignored, and the color is stuffed to the gauges sequentially. So you could put DEADBEEF in every single field of +Gauge and FSO will load it without a care in a world. It does care, however, if there isn't the same number of +Gauge entries as there are HUD gauge elements, since required_string() is used here | ||||
Additional Information | Not a critical feature, but more of a loose end. Expected behavior from this sort of thing would be to look for the gauge by name or index and apply to it appropriately. Missing entries would have the default value, and maybe raise an error if a color entry is missing and the HUD element is active as per the hudgauges.tbl. | ||||
Tags | No tags attached. | ||||
|
mantis3099.patch (1,290 bytes)
Index: code/hud/hudconfig.cpp =================================================================== --- code/hud/hudconfig.cpp (revision 11017) +++ code/hud/hudconfig.cpp (working copy) @@ -1655,17 +1655,26 @@ read_file_text(fname); reset_parse(); - // write out all gauges - for(idx=0; idx<NUM_HUD_GAUGES; idx++){ - required_string("+Gauge:"); + // First, set all gauges to the current main color + for (idx=0; idx<NUM_HUD_GAUGES; idx++){ + gr_init_alphacolor(&HUD_config.clr[idx], HUD_color_red, HUD_color_green, HUD_color_blue, (HUD_color_alpha+1)*16); + } + + // Now read in the color values for the gauges + while (optional_string("+Gauge:")) { stuff_string(str, F_NAME, sizeof(str)); - required_string("+RGBA:"); - stuff_ubyte(&HUD_config.clr[idx].red); - stuff_ubyte(&HUD_config.clr[idx].green); - stuff_ubyte(&HUD_config.clr[idx].blue); - stuff_ubyte(&HUD_config.clr[idx].alpha); - } + for (idx=0; idx<NUM_HUD_GAUGES; idx++) { + if (!stricmp(str, Hud_Gauge_Names[idx])) { + required_string("+RGBA:"); + stuff_ubyte(&HUD_config.clr[idx].red); + stuff_ubyte(&HUD_config.clr[idx].green); + stuff_ubyte(&HUD_config.clr[idx].blue); + stuff_ubyte(&HUD_config.clr[idx].alpha); + break; + } + } + } } void hud_config_alpha_slider_up() |
|
I've attached a fix. It also applies your suggestions, except it doesn't throw an error if a gauge entry is missing and the respective gauge is enabled in hud_gauges.tbl; in such a case, the main color (green, blue, or amber) is applied instead. |
|
Fix committed to trunk@11018. |
Date Modified | Username | Field | Change |
---|---|---|---|
2014-08-22 04:12 | z64555 | New Issue | |
2014-08-22 22:21 | Yarn | File Added: mantis3099.patch | |
2014-08-22 22:21 | Yarn | Note Added: 0016247 | |
2014-08-22 22:21 | Yarn | Assigned To | => Yarn |
2014-08-22 22:21 | Yarn | Status | new => code review |
2014-08-23 03:27 | niffiwan | Changeset attached | => fs2open trunk r11018 |
2014-08-23 03:27 | niffiwan | Note Added: 0016248 | |
2014-08-23 03:27 | niffiwan | Status | code review => resolved |
2014-08-23 03:27 | niffiwan | Resolution | open => fixed |
2014-09-07 04:00 | Goober5000 | Target Version | 3.7.5 => 3.7.2 |