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

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
anboni
Engineer
Engineer
Posts: 23
Joined: 21 May 2006 10:12

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

Post 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.
Attachments
loadingindicators.png
Shows the vehicle windows for all types with their progress indicators in the status bar.
(117.62 KiB) Downloaded 728 times
loadingindicators.diff
New diff against r5317
(5.18 KiB) Downloaded 310 times
Last edited by anboni on 19 Jun 2006 21:37, edited 3 times in total.
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Re: Patch: Loading indicator on vehicle status bar

Post 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.
anboni
Engineer
Engineer
Posts: 23
Joined: 21 May 2006 10:12

Re: Patch: Loading indicator on vehicle status bar

Post 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.
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3053
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post 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.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post 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.
anboni
Engineer
Engineer
Posts: 23
Joined: 21 May 2006 10:12

Post 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 :)
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

now the code looks much better :)
User avatar
charlieg
Transport Coordinator
Transport Coordinator
Posts: 323
Joined: 08 Oct 2003 14:07
Contact:

Post 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.
Open source tycoon games
--
Free Gamer - open source and Free Software games
FreeGameDev forums - open source game development community
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post 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.
Sacro
Tycoon
Tycoon
Posts: 1145
Joined: 18 Jun 2005 21:08
Location: Here
Contact:

Post 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.
We Am De Best

Host of ThroughTheTube site
BamBam
Engineer
Engineer
Posts: 34
Joined: 06 May 2007 17:49

Post by BamBam »

Rediff against trunk r9813.

It's no big deal but I like it.
Attachments
LoadingIndicators_9813.7z
Win32 Executable
(851.14 KiB) Downloaded 171 times
LoadingIndicators_9813.patch
(5.91 KiB) Downloaded 198 times
DeletedUser21
Tycoon
Tycoon
Posts: 11501
Joined: 20 Sep 2004 22:45

Post by DeletedUser21 »

You are on the roll! Great work! This seems as a cool feature. :)
User avatar
Maedhros
OpenTTD Developer
OpenTTD Developer
Posts: 603
Joined: 30 Mar 2006 18:24
Location: Durham, UK

Post 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?
No-one's more important than the earthworm.
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1732
Joined: 30 Mar 2005 09:43

Post by peter1138 »

Would http://fuzzle.org/o/loadingindicators.diff work? I've not tested it...
He's like, some kind of OpenTTD developer.
BamBam
Engineer
Engineer
Posts: 34
Joined: 06 May 2007 17:49

Post 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;
	}
}
Attachments
LoadingIndicators_v2_r9813.patch
(5.85 KiB) Downloaded 205 times
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 37 guests