View Issue Details

IDProjectCategoryView StatusLast Update
0001936FSSCPtablespublic2010-12-11 04:28
ReporterKeldorKatarn Assigned ToSwifty  
PriorityhighSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformIBM PCOSWindows VistaOS VersionSP 1
Product Version3.6.11 
Target Version3.7.2 
Summary0001936: Per ship custom gauge entries in hud_gauges.tbl do not seem to work
DescriptionI attached an ani file and a hud_gauges.tbl which should work according to the data found in the wiki, but they don't.
TagsNo tags attached.

Relationships

child of 0002071 resolvedSwifty Make custom gauges fully flexible in hud_gauges.tbl 

Activities

2009-06-07 15:55

 

central.ani (10,444 bytes)

2009-06-07 15:55

 

hud_gauges.tbl (1,205 bytes)

portej05

2009-06-08 12:15

reporter   ~0010967

Keldor: Please be more specific when you say 'do not seem to work' - it really isn't helpful to know that they 'do not work'.

I get a crash when using the data provided.

portej05

2009-06-08 12:54

reporter   ~0010968

My best guess at why this one is going wrong:
At hudparse.cpp 1060, parse_ship_start() is called, which proceeds to call required_string("$Ship:");
The while loop at 1058 then calls required_string_either and gets "$Default:" instead of #End or $Ship
parse_ship_start() is called from two places, both within parse_hud_gauges_tbl (1060,1083)
Seems that parse_ship_start is eating characters that are then needed in the loop at 1060 of hudparse.cpp

KeldorKatarn

2009-06-08 13:41

reporter   ~0010969

One can define per ship gauges, but the do not show up.
I don't know why this data crashes on you, make sure you put a different ship in the ship definition of the provided table if you're using retail data.

Anyway, it seems that the wiki either shows a wrong way to define such an entry or the game parses it incorrectly.
The result is simply the game ignoring the entire entry so rigth now it is not possible to define a custom HUD gauge (or any) on a per ship basis.

To it would be prudent to check whether the parsing is working correctly and if so, what entry layout it actually expects.

chief1983

2009-06-18 16:28

administrator   ~0010979

I've said it on the forums and I'll say it again here for good measure, this code is severely lacking on error checking and reporting to the user when things are wrong. Most of the time, if it encounters invalid entries it will just silently stop parsing the file and continue on. So the first thing to be checked is to make sure it's getting to a certain point in the table file. I recommend using a tbm instead, like custom-hdg.tbm, and then look for that filename in the debug log, otherwise it's hard to find where it starts parsing it (again, fairly useless messages related to that table in the parse log). You also of course need +parse in your debug filter.

KeldorKatarn

2009-06-26 17:04

reporter   ~0011002

- This is a Saga show stopper -

chief1983

2009-11-10 04:04

administrator   ~0011235

Hopefully the gauges stuff can be salvaged for the next release, I'm not certain though.

KeldorKatarn

2009-12-10 01:07

reporter   ~0011387

The parsing works fine. All that's missing is marking each gauge as loaded. This way the rendering code thinks it hasn't been loaded and always uses the default one.

Patch attached.

KeldorKatarn

2009-12-10 02:12

reporter   ~0011388

Just found another problem, if more than one ship has to get a custom HUD.
New patch attached. The original code could only process one $Ship: entry.

KeldorKatarn

2009-12-10 03:22

reporter   ~0011389

Last edited: 2009-12-10 03:37

Gee, this is more broken than I thought.
If you don't specify ALL gauges per ship-hud, they aren't initialized.
Therefore a third patch in which the ship-HUD is initialized with the default HUD data first.
File coming soon... this time I want to make sure I found everything.

portej05

2009-12-10 05:05

reporter   ~0011390

Keldor: There're two patches there, which one should be used?
Also, what testing has been done with this?

chief1983

2009-12-10 05:22

administrator   ~0011391

What I have observed is that if there is any issue parsing the table file, it just stops with no warning. The valid data it had already parsed works, but nothing further in the file is checked, and the user isn't notified of anything amiss in debug builds. This needs to be fixed, any time a table isn't finished being parsed a debug build should let the user know, or at least something should be written to the debug log. I've had full debugging enabled and the hud gauges code never throws any errors, no matter how broken I've made the table. I'll check out these patches though.

KeldorKatarn

2009-12-10 06:16

reporter   ~0011392

Last edited: 2009-12-10 06:18

This is quite a problematic thing but I think I got it now.
There was indeed an additional problem. Whenever a HUD is changed to a different ship's HUD or back to the default one, all specifyable gauge images need to be reloaded. This wasn't the case before.
I added code to reload the custom gauge images and needed to play around a bit to be able to also reload the specifyable Main Gauge images (Afterburner energy etc...)
The way I'm reloading the Main Gauges may not be ideal, but I don't see any other way right now and it works.

Patch attached (ship_gauges_final.patch)

KeldorKatarn

2009-12-10 06:23

reporter   ~0011393

Last edited: 2009-12-10 06:24

In terms of testing:

I tested this with a hud_gauges.tbl which specifies one custom gauge and a different gauge layout (including the custom one) for several fighters.

Then I tested several fighters which use the default HUD and those which have their own specified HUD. All of those work fine now. And when using one HUD, then loading a mission with a different fighter, the HUD is correctly reloaded so the correct images for that fighter are used.

Before this wasn't possible.

I attached the table file I used to test the stuff (hud_gauges.tbl-fortest.txt)
It uses several anis additional to the one attached to this issue, but just use any ani, it doesn't matter, as long as it exists and is visible in testing)

KeldorKatarn

2009-12-10 09:14

reporter   ~0011396

Last edited: 2009-12-10 09:16

Ok.. final patch. Found a much smoother way of doing this.
Check the latest patch file. (ship_gauges.patch)

Btw... this custum gauge graphics loading code... it is right now in the rendering code. I'd say that should eventually also be moved into some init function that is called by HUD_init().
But for now I didn't want to move huge code blocks around, since that's refactoring, not fixing stuff.

For now this works just fine and very smoothly and doesn't change all too much.

Btw... how do you delete attached files? If someone can do that please delete all patch files except (ship_gauges.patch)

2009-12-10 09:15

 

ship_gauges.patch (8,287 bytes)   
Index: code/freespace2/freespace.cpp
===================================================================
--- code/freespace2/freespace.cpp	(revision 5709)
+++ code/freespace2/freespace.cpp	(working copy)
@@ -6552,9 +6552,6 @@
 			}			
 			player_restore_target_and_weapon_link_prefs();
 
-			//Set the current hud
-			set_current_hud(Player_ship->ship_info_index);
-
 			Game_mode |= GM_IN_MISSION;
 
 #ifndef NDEBUG
Index: code/hud/hud.cpp
===================================================================
--- code/hud/hud.cpp	(revision 5709)
+++ code/hud/hud.cpp	(working copy)
@@ -72,6 +72,8 @@
 // Externals not related to the HUD code itself
 extern float View_zoom;
 
+extern bool Custom_gauge_images_loaded;
+
 // This is used to prevent drawing of hud (and pause popup)
 
 // globals that will control the color of the HUD gauges
@@ -637,6 +639,7 @@
 //
 void HUD_init()
 {
+	set_current_hud(Player_ship->ship_info_index);	
 	HUD_init_colors();
 	hud_init_msg_window();
 	hud_init_targeting();
@@ -1269,9 +1272,8 @@
 	if (!(Viewer_mode & (VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY ))) {
 		//Custom hud stuff
 		int i;
-		static bool image_ids_set = false;
 		static hud_frames image_ids[MAX_CUSTOM_HUD_GAUGES];
-		if(!image_ids_set)
+		if(!Custom_gauge_images_loaded)
 		{
 			for(i = 0; i < Num_custom_gauges; i++)
 			{
@@ -1292,7 +1294,7 @@
 					image_ids[i].first_frame = -1;
 				}
 			}
-			image_ids_set = true;
+			Custom_gauge_images_loaded = true;
 		}
 
 		//Display the gauges
Index: code/hud/hudescort.cpp
===================================================================
--- code/hud/hudescort.cpp	(revision 5709)
+++ code/hud/hudescort.cpp	(working copy)
@@ -52,7 +52,6 @@
 
 
 hud_frames Escort_gauges[NUM_ESCORT_FRAMES];
-int Escort_gauges_loaded = 0;
 
 //int Escort_gauge_y[MAX_ESCORT_SHIPS] = { 219, 230, 241 };
 
@@ -152,22 +151,18 @@
 void hud_escort_init()
 {
 	int i;
-
-	if ( !Escort_gauges_loaded ) {
-		for ( i = 0; i < NUM_ESCORT_FRAMES; i++ ) {
-			if ( strlen(current_hud->Escort_filename[i]) ) {
-				Escort_gauges[i].first_frame = bm_load_animation(current_hud->Escort_filename[i], &Escort_gauges[i].num_frames);
-
-				if (Escort_gauges[i].first_frame == -1) {
-					Warning(LOCATION, "Could not load in ani: %s\n", current_hud->Escort_filename[i]);
-					return;
-				}
-			} else {
-				Escort_gauges[i].first_frame = -1;
+	
+	for ( i = 0; i < NUM_ESCORT_FRAMES; i++ ) {
+		if ( strlen(current_hud->Escort_filename[i]) ) {
+			Escort_gauges[i].first_frame = bm_load_animation(current_hud->Escort_filename[i], &Escort_gauges[i].num_frames);
+			
+			if (Escort_gauges[i].first_frame == -1) {
+				Warning(LOCATION, "Could not load in ani: %s\n", current_hud->Escort_filename[i]);
+				return;
 			}
+		} else {
+			Escort_gauges[i].first_frame = -1;
 		}
-
-		Escort_gauges_loaded = 1;
 	}
 
 	Last_target_index = -1;
Index: code/hud/hudparse.cpp
===================================================================
--- code/hud/hudparse.cpp	(revision 5709)
+++ code/hud/hudparse.cpp	(working copy)
@@ -22,6 +22,7 @@
 
 //Global stuffs
 hud_info *current_hud = NULL; //If not set, it's NULL. This should always be null outside of a mission.
+bool Custom_gauge_images_loaded = false;
 hud_info default_hud;
 hud_info ship_huds[MAX_SHIP_CLASSES];
 extern int ships_inited; //Need this
@@ -68,7 +69,6 @@
 int Num_gauge_types = 17;
 int Num_custom_gauges = 0;
 
-
 static void load_hud_defaults(hud_info *hud)
 {
 	//X values
@@ -298,6 +298,8 @@
 			stuff_coords(dest_hud, cg);
 		}
 	}
+
+	dest_hud->loaded = true;
 }
 
 static void parse_resolution_gauges(hud_info* dest_hud)
@@ -579,9 +581,16 @@
 			{
 				if(dest_hud = parse_ship_start(), dest_hud)
 				{
-					while(rval = required_string_3("#End", "$Default:", "$Resolution:"), rval)
+					// Copy defaults
+					if(!dest_hud->loaded && default_hud.loaded)
 					{
-						if(parse_resolution_start(dest_hud, rval))
+						memcpy(dest_hud, &default_hud, sizeof(hud_info));
+						dest_hud->loaded = false;
+					}
+
+					while(rval = required_string_4("#End", "$Ship:", "$Default:", "$Resolution:"), rval > 1)
+					{
+						if(parse_resolution_start(dest_hud, rval - 1))
 						{
 							parse_resolution(dest_hud);
 						}
@@ -602,9 +611,16 @@
 			{
 				if(dest_hud = parse_ship_start(), dest_hud)
 				{
-					while(rval = required_string_3("#End", "$Default:", "$Resolution:"), rval)
+					// Copy defaults
+					if(!dest_hud->loaded && default_hud.loaded)
 					{
-						if(parse_resolution_start(dest_hud, rval))
+						memcpy(dest_hud, &default_hud, sizeof(hud_info));
+						dest_hud->loaded = false;
+					}
+
+					while(rval = required_string_4("#End", "$Ship:", "$Default:", "$Resolution:"), rval > 1)
+					{
+						if(parse_resolution_start(dest_hud, rval - 1))
 						{
 							parse_resolution_gauges(dest_hud);
 						}
@@ -667,9 +683,10 @@
 	else
 	{
 		memcpy(&real_current_hud, &default_hud, sizeof(hud_info));
-	}
+	}	
 
-	current_hud = &real_current_hud;
+	current_hud = &real_current_hud;	
+	Custom_gauge_images_loaded = false;
 }
 
 /* - not POD so GCC won't take it for offsetof - taylor
Index: code/hud/hudshield.cpp
===================================================================
--- code/hud/hudshield.cpp	(revision 5709)
+++ code/hud/hudshield.cpp	(working copy)
@@ -155,24 +155,21 @@
 
 	hud_shield_hit_reset(1);	// reset for the player
 
-	if ( Hud_shield_inited ) {
-		return;
-	}	
-
-	for ( i = 0; i < MAX_SHIELD_ICONS; i++ ) {
-		Shield_gauges[i].first_frame = -1;
-		Shield_gauges[i].num_frames  = 0;
-	}
-
-	Hud_shield_inited = 1;
-	if ( !Shield_mini_loaded ) {
-		Shield_mini_gauge.first_frame = bm_load_animation(current_hud->Shield_mini_fname, &Shield_mini_gauge.num_frames);
-		if ( Shield_mini_gauge.first_frame == -1 ) {
-			Warning(LOCATION, "Could not load in the HUD shield ani: Shield_mini_fname\n");
-			return;
+	if ( !Hud_shield_inited ) {
+		for ( i = 0; i < MAX_SHIELD_ICONS; i++ ) {
+			Shield_gauges[i].first_frame = -1;
+			Shield_gauges[i].num_frames  = 0;
 		}
-		Shield_mini_loaded = 1;
+		
+		Hud_shield_inited = 1;
 	}
+	
+	Shield_mini_gauge.first_frame = bm_load_animation(current_hud->Shield_mini_fname, &Shield_mini_gauge.num_frames);
+	if ( Shield_mini_gauge.first_frame == -1 ) {
+		Warning(LOCATION, "Could not load in the HUD shield ani: Shield_mini_fname\n");
+		return;
+	}
+	Shield_mini_loaded = 1;
 }
 
 int hud_shield_maybe_flash(int gauge, int target_index, int shield_offset)
Index: code/hud/hudtarget.cpp
===================================================================
--- code/hud/hudtarget.cpp	(revision 5709)
+++ code/hud/hudtarget.cpp	(working copy)
@@ -192,8 +192,6 @@
 //				3	=>		gun energy light
 hud_frames Aburn_bar_gauge;
 hud_frames Wenergy_bar_gauge;
-int Aburn_bar_gauge_loaded = 0;
-int Wenergy_bar_gauge_loaded = 0;
 /*int Weapon_energy_text_coords[GR_NUM_RESOLUTIONS][2] = {
 	{ // GR_640
 		439, 318
@@ -1180,21 +1178,17 @@
 		}
 		Lead_indicator_gauge_loaded = 1;
 	}
-	if (!Aburn_bar_gauge_loaded) {
-		Aburn_bar_gauge.first_frame = bm_load_animation(current_hud->Aburn_fname, &Aburn_bar_gauge.num_frames);
-		if ( Aburn_bar_gauge.first_frame < 0 ) {
-			Warning(LOCATION,"Cannot load hud ani: %s\n", current_hud->Aburn_fname);
-		}
-		Aburn_bar_gauge_loaded = 1;
+
+	Aburn_bar_gauge.first_frame = bm_load_animation(current_hud->Aburn_fname, &Aburn_bar_gauge.num_frames);
+	if ( Aburn_bar_gauge.first_frame < 0 ) {
+		Warning(LOCATION,"Cannot load hud ani: %s\n", current_hud->Aburn_fname);
 	}
 
-	if (!Wenergy_bar_gauge_loaded) {
-		Wenergy_bar_gauge.first_frame = bm_load_animation(current_hud->Wenergy_fname, &Wenergy_bar_gauge.num_frames);
-		if ( Wenergy_bar_gauge.first_frame < 0 ) {
-			Warning(LOCATION,"Cannot load hud ani: %s\n", current_hud->Wenergy_fname);
-		}
-		Wenergy_bar_gauge_loaded = 1;
+	Wenergy_bar_gauge.first_frame = bm_load_animation(current_hud->Wenergy_fname, &Wenergy_bar_gauge.num_frames);
+	if ( Wenergy_bar_gauge.first_frame < 0 ) {
+		Warning(LOCATION,"Cannot load hud ani: %s\n", current_hud->Wenergy_fname);
 	}
+
 	if (!Toggle_gauge_loaded) {
 		Toggle_gauge.first_frame = bm_load_animation(Toggle_fname[gr_screen.res], &Toggle_gauge.num_frames);
 		if ( Toggle_gauge.first_frame < 0 ) {
ship_gauges.patch (8,287 bytes)   

chief1983

2009-12-12 20:00

administrator   ~0011406

Actually we've been doing a lot of refactoring lately. If it's significant, you might want to request a spot in the Antipodes branch. Then you'd have less worry about other significant rewrites getting in the way of your stuff. Right now we've got things like post-processing, and a new memory allocator coming.

KeldorKatarn

2009-12-12 21:22

reporter   ~0011407

I don't really get what you're trying to tell me. If what is significant and request a spot in the branch for what exactly?
For this patch?

At the moment I don't really get what this post has to do with the topic, I'm sorry, maybe I'm too tired.

chief1983

2009-12-12 23:13

administrator   ~0011408

I mean you're right, it probably needs refactoring. It hasn't worked well in the past so even if it breaks for a while no one's probably going to be too upset. But if refactoring it is going to be a significant undertaking, it might be best to work on that when it's the only major project underway. The Antipodes branch is being used for such things, so they're done one at a time and don't keep getting in each other's way.

KeldorKatarn

2009-12-12 23:22

reporter   ~0011409

Ah ok. Well that refactoring has time anyway. Once all his guage stuff is in trunk (this fix and my color inheritance code from the forum) I'll add one more flag into hud_gauges.tbl with which one can select whether a gauge moves during pan view (like the reticle and speed indicator etc) or stays remains static (like directive list or shields e.g.)
With all that custom gauges should be fully flexible.

portej05

2009-12-13 07:17

reporter   ~0011410

Is there something that would stop this extra flag from going into the current patch?

chief1983

2009-12-13 09:55

administrator   ~0011411

Actually, if they are fairly independent might as well keep them separate commits. But having that patch handy in here would probably be nice.

KeldorKatarn

2009-12-13 15:33

reporter   ~0011412

Last edited: 2009-12-13 15:36

Well The problem is that this patch changes a lot in the way custom gauges are parsed and executed (the original version didn't work after all).
Well, maybe not a lot, but it adds if-blocks and stuff, so it changes some code structure in key places.

So any patch that adds functionality will have to be built on top of this if it is supposed to be simply addable by applying it with SVN.
The patch I posted in the forum thread about color inheritance already only works on the code if THIS patch has already been commited.

I kind want to avoid working on another one before this is actually in trunk. Because if something changes before this hits trunk, or someone changes something in this patch before commiting it (like a better variable name for somehting or whatever) I can start working all over again.

If you WANT me to include color inheritance and pan view flag all into this patch then tell me. But remember that this would mean mixing a bugfix with two new features which might not get your approval because of the way I've implemented them.

It is true that only with bugfix AND the two new features this will be at a point where it is no longer a Saga show stopper, because we need the full flexibility for our hud or we can't use our gauge, but it's still mixing three separate things.
I can do it if you say it's ok. The pan view stuff is really simple to implement. 90% of the work is implementing the flag in the table. The checking for it in the rendering code and adjusting the gauge position, that's just one single line, I already tested that.

All in all I'd prefer though if you'd first commit THIS patch to trunk (together with all changes that you think are necessary) so I can build the other two new features directly on a trunk version, so I know the code base won't change.

portej05

2009-12-13 15:45

reporter   ~0011413

I've PM'd Swifty pointing him towards this mantis issue (0001936), he was at one point (recently) working on the HUD system.

KeldorKatarn

2009-12-19 02:33

reporter   ~0011444

Well...?

chief1983

2009-12-19 21:35

administrator   ~0011448

Can we get a parent issue about finishing hud_gauges.tbl, and put the other patches individually in there? Then make this a child ticket that has to be completed before the other ones. I'd just like all this documented in tickets before it gets committed, as this code has caused a lot of headache in the last year or so for some people.

KeldorKatarn

2009-12-20 13:54

reporter   ~0011450

Last edited: 2009-12-20 14:00

Well there aren't any tickets for the rest yet. THIS is just the bugfix to get per-ship-gauges working.

For the rest I don't have any tickets yet. This is just the bugfix.

For color inheritance and pan-view gauge movement I'll open separate tickets if you want.

If you want to create a parent ticket, go ahead. I don't know how to assign children to a parent ticket so...

Edit: Ok I created a parent issue here: http://scp.indiegames.us/mantis/view.php?id=2071

chief1983

2009-12-20 20:07

administrator   ~0011451

This is now a child of 0002071

Also KK, in Mantis you can shorthand links to other issues by putting the # sign in front of the number.

KeldorKatarn

2010-01-01 17:50

reporter   ~0011478

Last edited: 2010-01-01 17:51

Can someone please look into this, check out the code, and either post necessary corrections or put it into trunk so we can get this under way? We need this HUD stuff to work for a possible trailer.
We'd rather not have to hack our way thruogh that by constantly hand-changing our hud_gauges.tbl

2010-01-17 22:48

 

hud1936_5825.diff (8,287 bytes)   
Index: code/freespace2/freespace.cpp
===================================================================
--- code/freespace2/freespace.cpp	(revision 5825)
+++ code/freespace2/freespace.cpp	(working copy)
@@ -6572,9 +6572,6 @@
 			}			
 			player_restore_target_and_weapon_link_prefs();
 
-			//Set the current hud
-			set_current_hud(Player_ship->ship_info_index);
-
 			Game_mode |= GM_IN_MISSION;
 
 #ifndef NDEBUG
Index: code/hud/hud.cpp
===================================================================
--- code/hud/hud.cpp	(revision 5825)
+++ code/hud/hud.cpp	(working copy)
@@ -72,6 +72,8 @@
 // Externals not related to the HUD code itself
 extern float View_zoom;
 
+extern bool Custom_gauge_images_loaded;
+
 // This is used to prevent drawing of hud (and pause popup)
 
 // globals that will control the color of the HUD gauges
@@ -637,6 +639,7 @@
 //
 void HUD_init()
 {
+	set_current_hud(Player_ship->ship_info_index);	
 	HUD_init_colors();
 	hud_init_msg_window();
 	hud_init_targeting();
@@ -1269,9 +1272,8 @@
 	if (!(Viewer_mode & (VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY ))) {
 		//Custom hud stuff
 		int i;
-		static bool image_ids_set = false;
 		static hud_frames image_ids[MAX_CUSTOM_HUD_GAUGES];
-		if(!image_ids_set)
+		if(!Custom_gauge_images_loaded)
 		{
 			for(i = 0; i < Num_custom_gauges; i++)
 			{
@@ -1292,7 +1294,7 @@
 					image_ids[i].first_frame = -1;
 				}
 			}
-			image_ids_set = true;
+			Custom_gauge_images_loaded = true;
 		}
 
 		//Display the gauges
Index: code/hud/hudescort.cpp
===================================================================
--- code/hud/hudescort.cpp	(revision 5825)
+++ code/hud/hudescort.cpp	(working copy)
@@ -52,7 +52,6 @@
 
 
 hud_frames Escort_gauges[NUM_ESCORT_FRAMES];
-int Escort_gauges_loaded = 0;
 
 //int Escort_gauge_y[MAX_ESCORT_SHIPS] = { 219, 230, 241 };
 
@@ -152,22 +151,18 @@
 void hud_escort_init()
 {
 	int i;
-
-	if ( !Escort_gauges_loaded ) {
-		for ( i = 0; i < NUM_ESCORT_FRAMES; i++ ) {
-			if ( strlen(current_hud->Escort_filename[i]) ) {
-				Escort_gauges[i].first_frame = bm_load_animation(current_hud->Escort_filename[i], &Escort_gauges[i].num_frames);
-
-				if (Escort_gauges[i].first_frame == -1) {
-					Warning(LOCATION, "Could not load in ani: %s\n", current_hud->Escort_filename[i]);
-					return;
-				}
-			} else {
-				Escort_gauges[i].first_frame = -1;
+	
+	for ( i = 0; i < NUM_ESCORT_FRAMES; i++ ) {
+		if ( strlen(current_hud->Escort_filename[i]) ) {
+			Escort_gauges[i].first_frame = bm_load_animation(current_hud->Escort_filename[i], &Escort_gauges[i].num_frames);
+			
+			if (Escort_gauges[i].first_frame == -1) {
+				Warning(LOCATION, "Could not load in ani: %s\n", current_hud->Escort_filename[i]);
+				return;
 			}
+		} else {
+			Escort_gauges[i].first_frame = -1;
 		}
-
-		Escort_gauges_loaded = 1;
 	}
 
 	Last_target_index = -1;
Index: code/hud/hudparse.cpp
===================================================================
--- code/hud/hudparse.cpp	(revision 5825)
+++ code/hud/hudparse.cpp	(working copy)
@@ -22,6 +22,7 @@
 
 //Global stuffs
 hud_info *current_hud = NULL; //If not set, it's NULL. This should always be null outside of a mission.
+bool Custom_gauge_images_loaded = false;
 hud_info default_hud;
 hud_info ship_huds[MAX_SHIP_CLASSES];
 extern int ships_inited; //Need this
@@ -68,7 +69,6 @@
 int Num_gauge_types = 17;
 int Num_custom_gauges = 0;
 
-
 static void load_hud_defaults(hud_info *hud)
 {
 	//X values
@@ -298,6 +298,8 @@
 			stuff_coords(dest_hud, cg);
 		}
 	}
+
+	dest_hud->loaded = true;
 }
 
 static void parse_resolution_gauges(hud_info* dest_hud)
@@ -579,9 +581,16 @@
 			{
 				if(dest_hud = parse_ship_start(), dest_hud)
 				{
-					while(rval = required_string_3("#End", "$Default:", "$Resolution:"), rval)
+					// Copy defaults
+					if(!dest_hud->loaded && default_hud.loaded)
 					{
-						if(parse_resolution_start(dest_hud, rval))
+						memcpy(dest_hud, &default_hud, sizeof(hud_info));
+						dest_hud->loaded = false;
+					}
+
+					while(rval = required_string_4("#End", "$Ship:", "$Default:", "$Resolution:"), rval > 1)
+					{
+						if(parse_resolution_start(dest_hud, rval - 1))
 						{
 							parse_resolution(dest_hud);
 						}
@@ -602,9 +611,16 @@
 			{
 				if(dest_hud = parse_ship_start(), dest_hud)
 				{
-					while(rval = required_string_3("#End", "$Default:", "$Resolution:"), rval)
+					// Copy defaults
+					if(!dest_hud->loaded && default_hud.loaded)
 					{
-						if(parse_resolution_start(dest_hud, rval))
+						memcpy(dest_hud, &default_hud, sizeof(hud_info));
+						dest_hud->loaded = false;
+					}
+
+					while(rval = required_string_4("#End", "$Ship:", "$Default:", "$Resolution:"), rval > 1)
+					{
+						if(parse_resolution_start(dest_hud, rval - 1))
 						{
 							parse_resolution_gauges(dest_hud);
 						}
@@ -667,9 +683,10 @@
 	else
 	{
 		memcpy(&real_current_hud, &default_hud, sizeof(hud_info));
-	}
+	}	
 
-	current_hud = &real_current_hud;
+	current_hud = &real_current_hud;	
+	Custom_gauge_images_loaded = false;
 }
 
 /* - not POD so GCC won't take it for offsetof - taylor
Index: code/hud/hudshield.cpp
===================================================================
--- code/hud/hudshield.cpp	(revision 5825)
+++ code/hud/hudshield.cpp	(working copy)
@@ -155,24 +155,21 @@
 
 	hud_shield_hit_reset(1);	// reset for the player
 
-	if ( Hud_shield_inited ) {
-		return;
-	}	
-
-	for ( i = 0; i < MAX_SHIELD_ICONS; i++ ) {
-		Shield_gauges[i].first_frame = -1;
-		Shield_gauges[i].num_frames  = 0;
-	}
-
-	Hud_shield_inited = 1;
-	if ( !Shield_mini_loaded ) {
-		Shield_mini_gauge.first_frame = bm_load_animation(current_hud->Shield_mini_fname, &Shield_mini_gauge.num_frames);
-		if ( Shield_mini_gauge.first_frame == -1 ) {
-			Warning(LOCATION, "Could not load in the HUD shield ani: Shield_mini_fname\n");
-			return;
+	if ( !Hud_shield_inited ) {
+		for ( i = 0; i < MAX_SHIELD_ICONS; i++ ) {
+			Shield_gauges[i].first_frame = -1;
+			Shield_gauges[i].num_frames  = 0;
 		}
-		Shield_mini_loaded = 1;
+		
+		Hud_shield_inited = 1;
 	}
+	
+	Shield_mini_gauge.first_frame = bm_load_animation(current_hud->Shield_mini_fname, &Shield_mini_gauge.num_frames);
+	if ( Shield_mini_gauge.first_frame == -1 ) {
+		Warning(LOCATION, "Could not load in the HUD shield ani: Shield_mini_fname\n");
+		return;
+	}
+	Shield_mini_loaded = 1;
 }
 
 int hud_shield_maybe_flash(int gauge, int target_index, int shield_offset)
Index: code/hud/hudtarget.cpp
===================================================================
--- code/hud/hudtarget.cpp	(revision 5825)
+++ code/hud/hudtarget.cpp	(working copy)
@@ -192,8 +192,6 @@
 //				3	=>		gun energy light
 hud_frames Aburn_bar_gauge;
 hud_frames Wenergy_bar_gauge;
-int Aburn_bar_gauge_loaded = 0;
-int Wenergy_bar_gauge_loaded = 0;
 /*int Weapon_energy_text_coords[GR_NUM_RESOLUTIONS][2] = {
 	{ // GR_640
 		439, 318
@@ -1180,21 +1178,17 @@
 		}
 		Lead_indicator_gauge_loaded = 1;
 	}
-	if (!Aburn_bar_gauge_loaded) {
-		Aburn_bar_gauge.first_frame = bm_load_animation(current_hud->Aburn_fname, &Aburn_bar_gauge.num_frames);
-		if ( Aburn_bar_gauge.first_frame < 0 ) {
-			Warning(LOCATION,"Cannot load hud ani: %s\n", current_hud->Aburn_fname);
-		}
-		Aburn_bar_gauge_loaded = 1;
+
+	Aburn_bar_gauge.first_frame = bm_load_animation(current_hud->Aburn_fname, &Aburn_bar_gauge.num_frames);
+	if ( Aburn_bar_gauge.first_frame < 0 ) {
+		Warning(LOCATION,"Cannot load hud ani: %s\n", current_hud->Aburn_fname);
 	}
 
-	if (!Wenergy_bar_gauge_loaded) {
-		Wenergy_bar_gauge.first_frame = bm_load_animation(current_hud->Wenergy_fname, &Wenergy_bar_gauge.num_frames);
-		if ( Wenergy_bar_gauge.first_frame < 0 ) {
-			Warning(LOCATION,"Cannot load hud ani: %s\n", current_hud->Wenergy_fname);
-		}
-		Wenergy_bar_gauge_loaded = 1;
+	Wenergy_bar_gauge.first_frame = bm_load_animation(current_hud->Wenergy_fname, &Wenergy_bar_gauge.num_frames);
+	if ( Wenergy_bar_gauge.first_frame < 0 ) {
+		Warning(LOCATION,"Cannot load hud ani: %s\n", current_hud->Wenergy_fname);
 	}
+
 	if (!Toggle_gauge_loaded) {
 		Toggle_gauge.first_frame = bm_load_animation(Toggle_fname[gr_screen.res], &Toggle_gauge.num_frames);
 		if ( Toggle_gauge.first_frame < 0 ) {
hud1936_5825.diff (8,287 bytes)   

chief1983

2010-01-17 22:48

administrator   ~0011531

Fixed the link in the description and added a patched based on current trunk.

chief1983

2010-01-18 16:15

administrator   ~0011536

Committed in r5828. Please test in a future nightly or your test build.

chief1983

2010-01-19 16:24

administrator   ~0011542

Nightlies available now for OS X and Windows with this patch.

KeldorKatarn

2010-01-20 18:43

reporter   ~0011545

Works for me

chief1983

2010-01-22 07:06

administrator   ~0011559

Last edited: 2010-01-22 07:07

Definitely looks like it introduced an issue with the modular version of the table. Might still need to take a look at this.

http://www.hard-light.net/forums/index.php?topic=67615.msg1336954#msg1336954

KeldorKatarn

2010-01-22 12:39

reporter   ~0011562

Can't be more than a parsing problem with the modular table. What exactly doesn't work with a tbm?

KeldorKatarn

2010-01-23 15:54

reporter   ~0011563

Last edited: 2010-01-23 15:56

I think I found the error. A fix I made for the ship gauges actually broke some other stuff (which shouldn't have worked in the first place btw so it's actually good I broke it). I fixed several other issues now.

The problem was that you cannot specify $Default: twice since you might specify a different default resolution the second time, which would have already written data invalid.

Problem is.. a tbm actually does exactly that. This worked before because the parser never actually saved that the parsing was complete. This is what broke part of the ship-specific stuff.

I fixed the issue now by telling the parser to reset earlier data back to defaults if any $Default: declaration sets a different resolution than its predecessor (any previous data cannot be used in this case anymore so it needs to be reset).

Now the tbm should work. To make sure the data from the original table is kept however it should use the exact same resolution in $Default:

All this was totally broken before, I honestly don't understand how this stuff ever worked. The parsing was a complete mess and did everything wrong.
At places it even tried to copy memory onto itself and stuff like that. Gee...

As soon as Talon reports that the build works I'll post the patch file here.

KeldorKatarn

2010-01-23 19:39

reporter   ~0011564

Correct functionality was confirmed. Patch file attached.

2010-01-23 19:40

 

gauges_fix.patch (3,370 bytes)   
Index: code/hud/hudparse.cpp
===================================================================
--- code/hud/hudparse.cpp	(revision 5831)
+++ code/hud/hudparse.cpp	(working copy)
@@ -294,7 +294,6 @@
 		cg = &gauges[i];
 		if(cg->parent == NULL && strlen(cg->fieldname))
 		{
-
 			stuff_coords(dest_hud, cg);
 		}
 	}
@@ -306,7 +305,7 @@
 {
 	char gaugename[NAME_LENGTH];
 	gauge_info *cg, *parent;
-	while(!required_string_3("$Gauge:","$Resolution:","#End"))
+	while(!required_string_4("$Gauge:", "$Default:", "$Resolution:", "#End"))
 	{
 		required_string("$Gauge:");
 		stuff_string(gaugename, F_NAME, NAME_LENGTH);
@@ -316,14 +315,19 @@
 		for(int i = 0; i < Num_gauge_types; i++)
 		{
 			cg = &gauges[i];
-			if(!parent)
+			
+			if(!parent && !strnicmp(cg->fieldname + sizeof(char), gaugename, strlen(cg->fieldname) - 2))
 			{
-				if(!strnicmp(cg->fieldname + sizeof(char), gaugename, strlen(cg->fieldname) - 2))
-				{
-					parent = cg;
-				}
+				parent = cg;
+				break;
 			}
-			else if(parent == cg->parent)
+		}
+
+		for(int i = 0; i < Num_gauge_types; i++)
+		{
+			cg = &gauges[i];
+			
+			if(parent == cg->parent)
 			{
 				stuff_coords(dest_hud, cg);
 			}
@@ -380,16 +384,26 @@
 	if(str_token == 1)
 	{
 		required_string("$Default:");
-		if(!dest_hud->loaded)
+		stuff_int_list(buffer, 2, RAW_INTEGER_TYPE);
+
+		if(buffer[0] == 0 || buffer == 0)
 		{
-			stuff_int_list(dest_hud->resolution, 2, RAW_INTEGER_TYPE);
-			if(dest_hud->resolution[0] == 0 || dest_hud->resolution == 0)
-			{
-				dest_hud->resolution[0] = gr_screen.max_w;
-				dest_hud->resolution[1] = gr_screen.max_h;
-			}
-			return dest_hud;
+			buffer[0] = gr_screen.max_w;
+			buffer[1] = gr_screen.max_h;
 		}
+		
+		// In case of a second $Default: declaration (in a tbm or a ship gauge perhaps),
+		// check if it declares the same resolution as before. If not, reload defaults.
+		if(dest_hud->loaded && (buffer[0] != dest_hud->resolution[0]) || (buffer[1] != dest_hud->resolution[1]))
+		{
+			load_hud_defaults(dest_hud);
+		}
+		
+		//Set the resolution
+		memcpy(dest_hud->resolution, buffer, sizeof(buffer));
+		dest_hud->loaded = false;
+		
+		return dest_hud;
 	}
 	else
 	{
@@ -398,18 +412,14 @@
 
 		if ( (buffer[0] == gr_screen.max_w_unscaled) && (buffer[1] == gr_screen.max_h_unscaled) )
 		{
-			//Get the ship HUD ready w/ defaults
-			if(default_hud.loaded)
+			if(dest_hud->loaded)
 			{
-				memcpy(dest_hud, &default_hud, sizeof(hud_info));
-				//It's not really loaded
-				dest_hud->loaded = false;
+				load_hud_defaults(dest_hud);
 			}
-			else
-			{
-				//Set the resolution
-				memcpy(dest_hud->resolution, buffer, sizeof(buffer));
-			}
+			
+			//Set the resolution
+			memcpy(dest_hud->resolution, buffer, sizeof(buffer));
+			dest_hud->loaded = false;
 
 			return dest_hud;
 		}
@@ -585,7 +595,6 @@
 					if(!dest_hud->loaded && default_hud.loaded)
 					{
 						memcpy(dest_hud, &default_hud, sizeof(hud_info));
-						dest_hud->loaded = false;
 					}
 
 					while(rval = required_string_4("#End", "$Ship:", "$Default:", "$Resolution:"), rval > 1)
@@ -615,7 +624,6 @@
 					if(!dest_hud->loaded && default_hud.loaded)
 					{
 						memcpy(dest_hud, &default_hud, sizeof(hud_info));
-						dest_hud->loaded = false;
 					}
 
 					while(rval = required_string_4("#End", "$Ship:", "$Default:", "$Resolution:"), rval > 1)
gauges_fix.patch (3,370 bytes)   

chief1983

2010-01-23 22:05

administrator   ~0011565

Committed in r5836, probably be in a nightly build sometime today.

KeldorKatarn

2010-01-23 23:27

reporter   ~0011566

Last edited: 2010-01-24 02:58

I found another bug and also managed to make the resolution entries really additive. So you can now specify a default resolution and specific resolutions and all entries will be read. Default should go first of course since otherwise it will override any resolution specific stuff.

A bug in the usage of +Size and +Percentage has been corrected. Now that can also be used exactly right.

I'll also update the Wiki.

2010-01-23 19:40
Argh. Hold on, there's a small bug in what I wrote in the last file.
Stand by. new file will be uploaded in a bit.

2010-01-23 20:41
edited on: 2010-01-23 20:41
Waiting for feedback again. Standby. (One thing I can say already. Additivity of the resolution tags is not possible at the moment. but I believe I found a small piece of code that is problematic and actually dangerous. I'd like to correct that piece and I'm waiting for feedback to make sure I broke nothing.)
The upcoming patch will only provide a small code improvement and get rid of some uglyness. The behavior remains the same.

Please ignore (and possibly remove) the latest patch file: gauges_fix_2.patch
It contains buggy code and should NOT be commited.

2010-01-23 21:05
Jesus Christ, the entire HUD rendering code is broken. Gaah.
This default and scaling only works if you specify 1024x768 as default. Otherwise it's broken. Additional to that one could save a whole lot of HUD rendering time by not always scaling the crap but instead store the scaled positions.

Stand by. I'll clean this up and improve the HUD rendering performance in the process.

2010-01-23 23:27

 

gauges_fix_2.patch (4,466 bytes)   
Index: code/hud/hudparse.cpp
===================================================================
--- code/hud/hudparse.cpp	(revision 5836)
+++ code/hud/hudparse.cpp	(working copy)
@@ -170,15 +170,13 @@
 /****************************************************************************************************/
 /* You shouldn't have to modify anything past here to add gauges */
 /****************************************************************************************************/
-//This doesn't belong in parse_lo, it's not really that low.
-static int size_temp[2];
-static float percentage_temp[2];
 int stuff_coords(hud_info* dest_hud, gauge_info* cg, bool required = false)
 {
-	//Speed up calculations
-	static hud_info* factor_for_hud;
-	static float resize_factor[2];
-	float fl_buffer[2];
+	// Speed up calculations
+	float resize_factor[2];
+	float coords_temp[2];
+	float percentage_temp[2];
+	int size_temp[2];
 	bool size_defined = false;
 
 	if(required)
@@ -190,34 +188,26 @@
 		return 0;
 	}
 
-	//stuff_int_list(HUD_INT(dest_hud, i), 2, RAW_INTEGER_TYPE);
-	stuff_float_list(fl_buffer, 2);
-	if(!cg->parent)
-	{
-		factor_for_hud = NULL;
-		resize_factor[0] = 1;
-		resize_factor[1] = 1;
-	}
-	else if(dest_hud != factor_for_hud)
-	{
-		resize_factor[0] = (float)gr_screen.max_w / (float)dest_hud->resolution[0];
-		resize_factor[1] = (float)gr_screen.max_h / (float)dest_hud->resolution[1];
-	}
-	//Resize to current res
-	HUD_INT(dest_hud, cg->coord_dest)[0] = fl2i(fl_buffer[0] * resize_factor[0]);
-	HUD_INT(dest_hud, cg->coord_dest)[1] = fl2i(fl_buffer[1] * resize_factor[1]);
+	stuff_float_list(coords_temp, 2);
+	
+	resize_factor[0] = (float)gr_screen.max_w / (float)dest_hud->resolution[0];
+	resize_factor[1] = (float)gr_screen.max_h / (float)dest_hud->resolution[1];
 
+	// Resize to current screen resolution
+	HUD_INT(dest_hud, cg->coord_dest)[0] = fl2i(coords_temp[0] * resize_factor[0]);
+	HUD_INT(dest_hud, cg->coord_dest)[1] = fl2i(coords_temp[1] * resize_factor[1]);
+
 	if(optional_string("+Size:"))
 	{
 		stuff_int_list(size_temp, 2, RAW_INTEGER_TYPE);
+		
 		if(cg->size_dest)
 		{
-			HUD_INT(dest_hud, cg->size_dest)[0] = size_temp[0];
-			HUD_INT(dest_hud, cg->size_dest)[1] = size_temp[1];
+			HUD_INT(dest_hud, cg->size_dest)[0] = fl2i(size_temp[0] * resize_factor[0]);
+			HUD_INT(dest_hud, cg->size_dest)[1] = fl2i(size_temp[1] * resize_factor[1]);
+			
+			size_defined = true;
 		}
-		
-		//For %
-		size_defined = false;
 	}
 
 	if(optional_string("+Percentage:"))
@@ -226,8 +216,7 @@
 		percentage_temp[0] *= (gr_screen.max_w / 100.0f);
 		percentage_temp[1] *= (gr_screen.max_h / 100.0f);
 
-		//Bool true, size defined
-		if(!size_defined)
+		if(size_defined)
 		{
 			if(percentage_temp[0])
 			{
@@ -238,6 +227,7 @@
 				percentage_temp[1] -= size_temp[1] / 2;
 			}
 		}
+
 		HUD_INT(dest_hud, cg->coord_dest)[0] += fl2i(percentage_temp[0]);
 		HUD_INT(dest_hud, cg->coord_dest)[1] += fl2i(percentage_temp[1]);
 	}
@@ -287,11 +277,12 @@
 
 static void parse_resolution(hud_info* dest_hud)
 {
-	//Parse it
 	gauge_info* cg;
+	
 	for(int i = 0; i < Num_gauge_types; i++)
 	{
 		cg = &gauges[i];
+		
 		if(cg->parent == NULL && strlen(cg->fieldname))
 		{
 			stuff_coords(dest_hud, cg);
@@ -305,6 +296,7 @@
 {
 	char gaugename[NAME_LENGTH];
 	gauge_info *cg, *parent;
+	
 	while(!required_string_4("$Gauge:", "$Default:", "$Resolution:", "#End"))
 	{
 		required_string("$Gauge:");
@@ -392,16 +384,8 @@
 			buffer[1] = gr_screen.max_h;
 		}
 		
-		// In case of a second $Default: declaration (in a tbm or a ship gauge perhaps),
-		// check if it declares the same resolution as before. If not, reload defaults.
-		if(dest_hud->loaded && (buffer[0] != dest_hud->resolution[0]) || (buffer[1] != dest_hud->resolution[1]))
-		{
-			load_hud_defaults(dest_hud);
-		}
-		
 		//Set the resolution
 		memcpy(dest_hud->resolution, buffer, sizeof(buffer));
-		dest_hud->loaded = false;
 		
 		return dest_hud;
 	}
@@ -410,16 +394,10 @@
 		required_string("$Resolution:");
 		stuff_int_list(buffer, 2, RAW_INTEGER_TYPE);
 
-		if ( (buffer[0] == gr_screen.max_w_unscaled) && (buffer[1] == gr_screen.max_h_unscaled) )
+		if ( (buffer[0] == gr_screen.max_w) && (buffer[1] == gr_screen.max_h) )
 		{
-			if(dest_hud->loaded)
-			{
-				load_hud_defaults(dest_hud);
-			}
-			
 			//Set the resolution
 			memcpy(dest_hud->resolution, buffer, sizeof(buffer));
-			dest_hud->loaded = false;
 
 			return dest_hud;
 		}
gauges_fix_2.patch (4,466 bytes)   

Zacam

2010-01-24 03:01

administrator   ~0011570

A: Edit the posts on the comments.

B: Test more thoroughly before deciding that shit is good to go. It's in Trunk now. It shouldn't have gone in to Trunk needing this many regression edits as it should have been accomplished prior to it being committed.

If you want assistance, ask. And provide a method by which other people can immediately test and provide feedback on.

KeldorKatarn

2010-01-24 08:21

reporter   ~0011571

Last edited: 2010-01-24 08:42

Kiss my butt. be happy I do the work. I don't need to be insulted here for providing fixes for stuff. SOMEONE in the SCP suggested that this "shit" was good to go long before I took a look at it. And it didn't work AT ALL. So be happy I'm trying to fix it instead for coming here and yelling at me for doing it.
I have one small bug in a feature that didn't work before either. The rest works fine. What doesn't work is the percentages crap and that didn't work before I tried to fix it either. So I didn't "break" anything but I fixed about 10 other bugs by now and the table is finally usable thanks to me.


Edit2: Final patch, fixing the percentage functionality (which was broken from the start and not by me)

I originally wanted to make it possible to use $Default: with resolutions other than 1024x768 or 640x480 and make the resolution tags additive and improve performance a bit.
But after the answer I just got I'd rather not spent more time on this that I took from time I needed to work on my thesis anyway.

Stuff works now. Stuff that never worked since this table existed. And oh yeah.. patch2 never made it to the trunk and the original diff and patch1 work just fine. They just pointed me to other bugs that had always been there and I wanted to fix those. By doing that I broke some minor parsing in patch2 and immediately reported not to commit it, which obviously worked.

This final patch is the correct fix, fixing percentage and size usage. Tested by me and Talon.

Good day.. gentlemen. it's been REALLY fun.

2010-01-24 08:43

 

gauges_fix_3.patch (2,753 bytes)   
Index: code/hud/hudparse.cpp
===================================================================
--- code/hud/hudparse.cpp	(revision 5836)
+++ code/hud/hudparse.cpp	(working copy)
@@ -170,15 +170,11 @@
 /****************************************************************************************************/
 /* You shouldn't have to modify anything past here to add gauges */
 /****************************************************************************************************/
-//This doesn't belong in parse_lo, it's not really that low.
-static int size_temp[2];
-static float percentage_temp[2];
 int stuff_coords(hud_info* dest_hud, gauge_info* cg, bool required = false)
 {
-	//Speed up calculations
-	static hud_info* factor_for_hud;
-	static float resize_factor[2];
-	float fl_buffer[2];
+	// Speed up calculations
+	float percentage_temp[2];
+	int size_temp[2];
 	bool size_defined = false;
 
 	if(required)
@@ -190,54 +186,39 @@
 		return 0;
 	}
 
-	//stuff_int_list(HUD_INT(dest_hud, i), 2, RAW_INTEGER_TYPE);
-	stuff_float_list(fl_buffer, 2);
-	if(!cg->parent)
-	{
-		factor_for_hud = NULL;
-		resize_factor[0] = 1;
-		resize_factor[1] = 1;
-	}
-	else if(dest_hud != factor_for_hud)
-	{
-		resize_factor[0] = (float)gr_screen.max_w / (float)dest_hud->resolution[0];
-		resize_factor[1] = (float)gr_screen.max_h / (float)dest_hud->resolution[1];
-	}
-	//Resize to current res
-	HUD_INT(dest_hud, cg->coord_dest)[0] = fl2i(fl_buffer[0] * resize_factor[0]);
-	HUD_INT(dest_hud, cg->coord_dest)[1] = fl2i(fl_buffer[1] * resize_factor[1]);
+	stuff_int_list(HUD_INT(dest_hud, cg->coord_dest), 2, RAW_INTEGER_TYPE);
 
 	if(optional_string("+Size:"))
 	{
 		stuff_int_list(size_temp, 2, RAW_INTEGER_TYPE);
+		
 		if(cg->size_dest)
 		{
 			HUD_INT(dest_hud, cg->size_dest)[0] = size_temp[0];
 			HUD_INT(dest_hud, cg->size_dest)[1] = size_temp[1];
+			
+			size_defined = true;
 		}
-		
-		//For %
-		size_defined = false;
 	}
 
 	if(optional_string("+Percentage:"))
 	{
 		stuff_float_list(percentage_temp, 2);
-		percentage_temp[0] *= (gr_screen.max_w / 100.0f);
-		percentage_temp[1] *= (gr_screen.max_h / 100.0f);
+		percentage_temp[0] *= (dest_hud->resolution[0] / 100.0f);
+		percentage_temp[1] *= (dest_hud->resolution[1] / 100.0f);
 
-		//Bool true, size defined
-		if(!size_defined)
+		if(size_defined)
 		{
 			if(percentage_temp[0])
 			{
-				percentage_temp[0] -= size_temp[0] / 2;
+				percentage_temp[0] -= fl2i(size_temp[0] / 2.0f);
 			}
 			if(percentage_temp[1])
 			{
-				percentage_temp[1] -= size_temp[1] / 2;
+				percentage_temp[1] -= fl2i(size_temp[1] / 2.0f);
 			}
 		}
+
 		HUD_INT(dest_hud, cg->coord_dest)[0] += fl2i(percentage_temp[0]);
 		HUD_INT(dest_hud, cg->coord_dest)[1] += fl2i(percentage_temp[1]);
 	}
gauges_fix_3.patch (2,753 bytes)   

chief1983

2010-01-24 09:10

administrator   ~0011572

You're right, it didn't work before. But you've been submitting many patches implying that it should work fine several times, and keep managing to find bugs. Since Swifty is gutting this whole section of code and doing a full rewrite of it, the only reason I've been committing it is in the hopes that it will work better than it did in the interim, allowing some development work to get done by interested parties. Otherwise there'd be a lot more review of what's been submitted, and hopefully many of these issues that keep showing up would be caught without needing a dozen patches.

We don't _need_ $Default res other than 1024 or 640. I don't think you understand their purpose if you think we do, and if you're writing code with that in mind, you should stop now. FreeSpace in some level only sees the game in two modes, 640 and 1024. Everything is based off of that no matter what resolution you're in. Currently this is the cause for HUD stretching at widescreen resolutions. It's taking a snapshot of the HUD at 1024, and then scaling it to whatever res it needs to, with no aspect correction done on the gauges. _That_ needs to be fixed, but it is independent of this custom gauge code, and should _not_ be taken into account by it, that's a lot of unnecessary effort.

KeldorKatarn

2010-01-24 09:45

reporter   ~0011573

I took the possibility into account because the Wiki implies that this was at some point intended to work.

But again.. sorry for putting any work into this.

chief1983

2010-01-24 10:11

administrator   ~0011574

Well I didn't know Swifty was rewriting the whole thing either, when you submitted the first patch I was glad it might be getting fixed finally. FotG needs it working too, and the sooner we have something to work with the better. Who knows when Swifty's rewrite will get done, I'm not a fan of relying on eggs that haven't hatched.

I'm not sure what you mean by the wiki. $Resolution is for overriding the scaling on specific resolutions. I think the $Default one is only supposed to be 640 or 1024.

Zacam

2010-01-24 10:17

administrator   ~0011575

In taking a moment to reflect, I do need to put in here that the matter here was not helped any by the phrasing or handling of my commentary that was offered.

Thank you, Keldor, for the rapid follow up and resolution of the discovered issues. Regardless of how they happened or when, code ownership took place and as such, I do apologize for the tone of my earlier commentary.

KeldorKatarn

2010-01-24 10:24

reporter   ~0011576

Accepted. I've been told I might have missunderstood some phrases as worse than they were meant, possibly due to a language barrier so I appologize if my response to it has been over the top.
But as you might now I've gotten a little sensitive to negative responses like that from the direction of SCP, so I have a short fuse there.
Anyway, to the topic, this stuff should work as intended now. I thought the $Default: stuff could be extended a little, since the Wiki suggested that was the plan, but if that's not needed and wanted, I won't try to do anything further.

As it is now it should all work.
As soon as this has been approved and committed I'll provide the patches for the color inheritance and Move_in_PanView features based on that revision.
I would think that other mods will welcome those features too.

chief1983

2010-06-14 14:55

administrator   ~0012070

Assigning to Swifty as his new HUD code should be capable of dealing with this issue, and he can close it once his code hits trunk.

chief1983

2010-07-21 04:09

administrator   ~0012251

Status changed, as we're not waiting on feedback now, we're waiting on Swifty's new hud code.

The_E

2010-12-11 04:28

administrator   ~0012540

Fixed in antipodes 7

Issue History

Date Modified Username Field Change
2009-06-07 15:55 KeldorKatarn New Issue
2009-06-07 15:55 KeldorKatarn File Added: central.ani
2009-06-07 15:55 KeldorKatarn File Added: hud_gauges.tbl
2009-06-08 12:15 portej05 Note Added: 0010967
2009-06-08 12:15 portej05 Status new => confirmed
2009-06-08 12:54 portej05 Note Added: 0010968
2009-06-08 13:41 KeldorKatarn Note Added: 0010969
2009-06-18 16:28 chief1983 Note Added: 0010979
2009-06-26 17:04 KeldorKatarn Note Added: 0011002
2009-06-26 17:09 portej05 Priority normal => high
2009-11-10 04:04 chief1983 Note Added: 0011235
2009-11-10 04:04 chief1983 Target Version => 3.6.12 RC1
2009-12-10 01:07 KeldorKatarn Note Added: 0011387
2009-12-10 01:08 KeldorKatarn File Added: ship_gauges_patch.patch
2009-12-10 02:12 KeldorKatarn Note Added: 0011388
2009-12-10 02:13 KeldorKatarn File Added: ship_gauges_new.patch
2009-12-10 03:22 KeldorKatarn Note Added: 0011389
2009-12-10 03:37 KeldorKatarn Note Edited: 0011389
2009-12-10 05:05 portej05 Note Added: 0011390
2009-12-10 05:22 chief1983 Note Added: 0011391
2009-12-10 06:16 KeldorKatarn Note Added: 0011392
2009-12-10 06:16 KeldorKatarn File Added: ship_gauges_final.patch
2009-12-10 06:17 KeldorKatarn Note Edited: 0011392
2009-12-10 06:18 KeldorKatarn Note Edited: 0011392
2009-12-10 06:23 KeldorKatarn Note Added: 0011393
2009-12-10 06:24 KeldorKatarn File Added: hud_gauges.tbl-fortest.txt
2009-12-10 06:24 KeldorKatarn Note Edited: 0011393
2009-12-10 09:14 KeldorKatarn Note Added: 0011396
2009-12-10 09:15 KeldorKatarn File Added: ship_gauges.patch
2009-12-10 09:16 KeldorKatarn Note Edited: 0011396
2009-12-10 15:08 Wanderer File Deleted: hud_gauges.tbl-fortest.txt
2009-12-10 15:08 Wanderer File Deleted: ship_gauges_final.patch
2009-12-10 15:09 Wanderer File Deleted: ship_gauges_new.patch
2009-12-10 15:09 Wanderer File Deleted: ship_gauges_patch.patch
2009-12-12 20:00 chief1983 Note Added: 0011406
2009-12-12 21:22 KeldorKatarn Note Added: 0011407
2009-12-12 23:13 chief1983 Note Added: 0011408
2009-12-12 23:22 KeldorKatarn Note Added: 0011409
2009-12-13 07:17 portej05 Note Added: 0011410
2009-12-13 09:55 chief1983 Note Added: 0011411
2009-12-13 15:33 KeldorKatarn Note Added: 0011412
2009-12-13 15:35 KeldorKatarn Note Edited: 0011412
2009-12-13 15:36 KeldorKatarn Note Edited: 0011412
2009-12-13 15:45 portej05 Note Added: 0011413
2009-12-19 02:33 KeldorKatarn Note Added: 0011444
2009-12-19 21:35 chief1983 Note Added: 0011448
2009-12-20 13:54 KeldorKatarn Note Added: 0011450
2009-12-20 13:55 KeldorKatarn Note Edited: 0011450
2009-12-20 14:00 KeldorKatarn Note Edited: 0011450
2009-12-20 20:06 chief1983 Relationship added child of 0002071
2009-12-20 20:07 chief1983 Note Added: 0011451
2010-01-01 17:50 KeldorKatarn Note Added: 0011478
2010-01-01 17:51 KeldorKatarn Note Edited: 0011478
2010-01-17 22:48 chief1983 File Added: hud1936_5825.diff
2010-01-17 22:48 chief1983 Note Added: 0011531
2010-01-18 16:15 chief1983 Note Added: 0011536
2010-01-18 16:15 chief1983 Assigned To => chief1983
2010-01-18 16:15 chief1983 Status confirmed => feedback
2010-01-19 16:24 chief1983 Note Added: 0011542
2010-01-20 18:43 KeldorKatarn Note Added: 0011545
2010-01-22 07:06 chief1983 Note Added: 0011559
2010-01-22 07:07 chief1983 Note Edited: 0011559
2010-01-22 12:39 KeldorKatarn Note Added: 0011562
2010-01-23 15:54 KeldorKatarn Note Added: 0011563
2010-01-23 15:55 KeldorKatarn Note Edited: 0011563
2010-01-23 15:56 KeldorKatarn Note Edited: 0011563
2010-01-23 19:39 KeldorKatarn Note Added: 0011564
2010-01-23 19:40 KeldorKatarn File Added: gauges_fix.patch
2010-01-23 22:05 chief1983 Note Added: 0011565
2010-01-23 23:27 KeldorKatarn Note Added: 0011566
2010-01-23 23:27 KeldorKatarn File Added: gauges_fix_2.patch
2010-01-24 02:58 Zacam Note Edited: 0011566
2010-01-24 03:01 Zacam Note Added: 0011570
2010-01-24 08:21 KeldorKatarn Note Added: 0011571
2010-01-24 08:24 KeldorKatarn Note Edited: 0011571
2010-01-24 08:42 KeldorKatarn Note Edited: 0011571
2010-01-24 08:43 KeldorKatarn File Added: gauges_fix_3.patch
2010-01-24 09:10 chief1983 Note Added: 0011572
2010-01-24 09:45 KeldorKatarn Note Added: 0011573
2010-01-24 10:11 chief1983 Note Added: 0011574
2010-01-24 10:17 Zacam Note Added: 0011575
2010-01-24 10:24 KeldorKatarn Note Added: 0011576
2010-06-14 14:55 chief1983 Note Added: 0012070
2010-06-14 14:55 chief1983 Assigned To chief1983 => Swifty
2010-07-21 04:09 chief1983 Note Added: 0012251
2010-07-21 04:09 chief1983 Status feedback => assigned
2010-08-05 20:03 chief1983 Target Version 3.6.12 RC1 => 3.7.2
2010-12-11 04:28 The_E Note Added: 0012540
2010-12-11 04:28 The_E Status assigned => resolved
2010-12-11 04:28 The_E Resolution open => fixed