View Issue Details

IDProjectCategoryView StatusLast Update
0003099FSSCPtablespublic2014-09-07 04:00
Reporterz64555 Assigned ToYarn  
PrioritylowSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
Platformx86_64OSMicrosoft WindowsOS Version8.1
Product Version3.7.2 RC3 
Target Version3.7.2 
Summary0003099: HUD Color File (*.HCF) Parser Errors
DescriptionThis 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 InformationNot 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.
TagsNo tags attached.

Activities

Yarn

2014-08-22 22:21

developer  

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()
mantis3099.patch (1,290 bytes)   

Yarn

2014-08-22 22:21

developer   ~0016247

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.

niffiwan

2014-08-23 03:27

developer   ~0016248

Fix committed to trunk@11018.

Related Changesets

fs2open: trunk r11018

2014-08-22 23:58

niffiwan


Ported: N/A

Details Diff
Fix mantis 3099 (from Yarn)

Make HCF parsing more flexible
Affected Issues
0003099
mod - /trunk/fs2_open/code/hud/hudconfig.cpp Diff File

Issue History

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