Page 1 of 1

Patch: Loading indicator on vehicle status bar (update 19/6)

Posted: 18 Jun 2006 22:44
by anboni
In the topic about improving the orders system (http://tt-forums.net/viewtopic.php?t=12193), mention was made of a statusbar indicator for the loading progress. It seems the entire idea got dropped in the transition to someone else picking up that development process, so I made my own.

For now, it splits up the Loading and Unloading displays, and for the Loading display also shows the % of cargo space that has been filled.

*update 19/6*
- Moved all logic to one function as per gigajum's suggestion (thanks peter1138 and Hackykid for the pointers)
- Made the statusbar update on new cargo added, as per gigajum's suggestion (thanks to Tron and glx for pointing in the right direction :) )
- Some coding-style fixes.

Re: Patch: Loading indicator on vehicle status bar

Posted: 18 Jun 2006 23:10
by gigajum
i never said i drop it, but until now no one said it is needed much, so i gave it not top priority. I noticed myself during development, it is usefull, if that information how far the loading process is shown on the statusbar.
anboni wrote: For now, it splits up the Loading and Unloading displays, and for the Loading display also shows the % of cargo space that has been filled.
i suggest you edit that according to the % loading. So that you get shown

"loading 13% of 30%" if you only want to load minimal or exact 30%

I noticed you have 4 times almost the same code in four different functions. It should be better if you create a new function which does that.

Re: Patch: Loading indicator on vehicle status bar

Posted: 19 Jun 2006 06:57
by anboni
gigajum wrote:i never said i drop it, but until now no one said it is needed much, so i gave it not top priority. I noticed myself during development, it is usefull, if that information how far the loading process is shown on the statusbar.
Yeah, sorry, I didn't express myself that well there. Also, frankly, I thought of this feature, then started coding, and only when it was finished did I run across the improved orders patch. Because it was already done anyway, I decided to post it :)
gigajum wrote:i suggest you edit that according to the % loading. So that you get shown

"loading 13% of 30%" if you only want to load minimal or exact 30%
That would be useful information when combined with the improved orders patch. Going by the current state of trunk, it would always show 13% of 100%, which seems kinda redundant :) I'll look into the improved orders patch sometime soon and see if I can prepare my patch for the improved orders stuff.
gigajum wrote: I noticed you have 4 times almost the same code in four different functions. It should be better if you create a new function which does that.
I'm not too sure about that. While the code is all very similar, there's quite a few differences between the various vehicle types (roadveh and ships are almost the same, aircraft and trains both are different). Handling all that in one function might make that single function more complex than the 4 pieces of similar code. Also, this piece of code gets called fairly often while a vehicle is in a station, so I'd prefer to keep it "lean and mean" and avoid extra function calls.

Posted: 19 Jun 2006 07:18
by Darkvater
All 4 functions look really the same, except for the calculation of cargo_count. You can do this beforehand and pass as an argument to a function. Should be the best thing to do.

Posted: 19 Jun 2006 11:58
by gigajum
i noticed that your patch does not mark the window dirty if there are new goods in the vehicle if you keep the window open and the vehicle is beeing loaded.

Posted: 19 Jun 2006 21:40
by anboni
Thanks for the suggestions, gigajum, as you can see, I've picked up most of them (and probably made it a lot easier for anyone to add the others when the rest of the code for the %age loading is done :) )

One thing's for sure, I've learned a lot from this exercise :)

Posted: 20 Jun 2006 10:54
by gigajum
now the code looks much better :)

Posted: 22 Jun 2006 20:08
by charlieg
It'd be nice to show the % indicator above trains waiting in station, so you can discern how efficiently your empire is running without having to bring up train dialogs to monitor them.

Posted: 22 Jun 2006 22:49
by gigajum
i do not understand why. if you set full loading the train will always load 100% not more or less. if not set to full load, why care how full they are? if there are goods left at the station you have to look there and buy another train (or other vehicle) if neded. For me your suggestion is a waste of resources.

Posted: 23 Jun 2006 01:12
by Sacro
gigajum: so when you see a train waiting for a full load, you can click on it and instantly see just how much space its got left to fill, its not much use with coal, iron ore, grain etc, when you can visably see the wagons loaded, but it'd be very useful with goods, passengers, mail etc.

Posted: 08 May 2007 10:50
by BamBam
Rediff against trunk r9813.

It's no big deal but I like it.

Posted: 08 May 2007 11:06
by DeletedUser21
You are on the roll! Great work! This seems as a cool feature. :)

Posted: 08 May 2007 11:22
by Maedhros
As I said in bug 212, this doesn't work too well with gradual loading since parts of the vehicle can be unloading while a different part is loading. Do you have any suggestions for making that work properly?

Posted: 08 May 2007 12:21
by peter1138
Would http://fuzzle.org/o/loadingindicators.diff work? I've not tested it...

Posted: 08 May 2007 13:15
by BamBam
I had a similar idea but loading and unloading will be both count as loading.

Edit:

Ah, I've find it, not:

Code: Select all

for (const Vehicle *u = v; u != NULL; u = u->next) {
	/* Loop through all wagons; add currently loaded amount to cargo_count
	 * and wagon capacity to cargo_cap
	 */
	if (!HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING)) cargo_count += u->cargo_count;
	cargo_cap   += u->cargo_cap;
}
that:

Code: Select all

for (const Vehicle *u = v; u != NULL; u = u->next) {
	/* Loop through all wagons; add currently loaded amount to cargo_count
	 * and wagon capacity to cargo_cap
	 */
	if (!HASBIT(u->vehicle_flags, VF_CARGO_UNLOADING)){
		cargo_count += u->cargo_count;
		cargo_cap   += u->cargo_cap;
	}
}