Statistics Patch

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

Asterix
Engineer
Engineer
Posts: 121
Joined: 04 Apr 2005 18:17
Location: Germany

Statistics Patch

Post by Asterix »

The original version of the statistics patch is from Celestar.

EDIT: I commented out the saving of statistics (for now), so it should be able to use savegames from this version with other versions, too
The downside is that stats start at 0 after loading a game (same as pressing the reset-button)

What Celestars patch did:
- show how much vehicles are scheduled for the station
- show number of vehicles that visited the station in last month and this month and how much cargo was delivered/picked up/transfered in last month and this month for each cargo individually
- make it possible to reset a station (ratings, which goods are there, ...)
- save the stats in the savegame

now, what did i do?
- i did not touch the transfer order patch
- i moved the resetting of stations to the cheat-menu (if enabled you will get a button when clicking a station to allow resetting it)
- added button to switch between statistics for this/last month and average/min/max statistics
- and added the statistics for average/min/max, of course
- added possibility to reset statistics
EDIT:

- added monthly/yearly statistics for waypoints
EDIT2:
- button to display vehicles scheduled for a waypoint now works
- button "buses" (station-stats) shows only buses
- button "trucks" (station-stats) shows all but buses
- added new function for vehicle-list-creation that makes it possible to select one or more basic vehicle-type and one or more cargotypes to be selected and that not only works for stations, but waypoints as well (this is used for displaying trains and roadvehicles now... please report any problems you encounter)
- changed counting of scheduled vehicles (hopefully the numbers shown are still correct and it is faster... please report problems with that)
EDIT4:
- added wizeman's show station ratings patch
- moved his button beyond the switch for rating/acceptance
- added a button to his window to show all vehicles scheduled for the station for this specific cargo, regardless of type (please report problems with that)
- made roadvehicle list update if selecting buses/trucks in stats-window, while window is already open

Known Issues:
- button for catchment area not working (yet)
- vehicles scheduled for a station with a cargo-type that does not have a rating could not be shown (yet)

EDIT: added known issues, exchanged one screenshot, updated some text and .diff
EDIT2: new version, updated some text and .diff
EDIT3: removed infos of transfer order patch, as this is committed now
EDIT4: new version, updated some text and .diff
EDIT5: new .diff uploaded... some bugfixes
EDIT6: new .diff uploaded... some bugfixes, some magic numbers removed
EDIT7: new .diff uploaded... just made it compile with current SVN, no real changes
EDIT8: new .diff uploaded... fixed a bug with building waypoints, some minor cleanup
EDIT9: replaced one screenshot by a windows-build
Attachments
average/min/max stats page
average/min/max stats page
Stats_Page_2.png (9.55 KiB) Viewed 11463 times
stats_r2724.diff
.diff for r2724
(114.93 KiB) Downloaded 439 times
mingw32.zip
windows binary
(1.27 MiB) Downloaded 414 times
Last edited by Asterix on 27 Jul 2005 20:04, edited 9 times in total.
User avatar
Dextro
Chief Executive
Chief Executive
Posts: 701
Joined: 12 Jan 2005 21:56
Location: Lisboa, Portugal
Contact:

Post by Dextro »

This looks f***inf awsome!!! :mrgreen:
Uncle Dex Says: Follow the KISS Principle!
User avatar
bobingabout
Tycoon
Tycoon
Posts: 1850
Joined: 21 May 2005 15:10
Location: Hull, England

Post by bobingabout »

i like that
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.

[/url]
User avatar
lucaspiller
Tycoon
Tycoon
Posts: 1228
Joined: 18 Apr 2004 20:27

Post by lucaspiller »

Nice! :D

Are you going to have both windows using the same colour scheme / font size in the end?
No longer active here, but you can still reach me via email: luca[at]stackednotion[dot]com
oVRoM
Engineer
Engineer
Posts: 37
Joined: 11 Jan 2003 10:40
Location: Utah

Post by oVRoM »

Very nice patch indeed.

I've got a small suggestion though... There isn't enough room for the 'Statistics' button, so now a new row was added. Wouldn't it be possible to move the "Rename" button to the top of the window? Like it is with trains? It's more consistent, and you don't need two rows.

The windows I'm talking about:
Image
Asterix
Engineer
Engineer
Posts: 121
Joined: 04 Apr 2005 18:17
Location: Germany

Post by Asterix »

oVRoM wrote:I've got a small suggestion though... There isn't enough room for the 'Statistics' button, so now a new row was added. Wouldn't it be possible to move the "Rename" button to the top of the window? Like it is with trains? It's more consistent, and you don't need two rows.
Well, there is a cause why i left the button, where Celestar put it :)
If you enable "Reset Station" in the Cheat-menu the button for resetting the station appears on the free place there...
And I was thinking about including wizeman's "detailed station ratings" patch as well and put his butten on there, too :)
User avatar
Jump
Traffic Manager
Traffic Manager
Posts: 147
Joined: 22 Sep 2004 21:10
Location: Belgium

Post by Jump »

What abut a button to show the station coverage area like in locomotion? Would be nice to see the coverage area even if the station is already build.
Asterix
Engineer
Engineer
Posts: 121
Joined: 04 Apr 2005 18:17
Location: Germany

Post by Asterix »

Jumper wrote:What abut a button to show the station coverage area like in locomotion? Would be nice to see the coverage area even if the station is already build.
Hmm, I might think about adding that below the icons for the different vehicle-types (even though I don't know locomotion at all ;) )
But I don't know yet how much work this will be and how long it will take to do it.
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

When are patches going to be added to the OTTD main code? Pleeeeease??
User avatar
Jump
Traffic Manager
Traffic Manager
Posts: 147
Joined: 22 Sep 2004 21:10
Location: Belgium

Post by Jump »

Asterix wrote:
Jumper wrote:What abut a button to show the station coverage area like in locomotion? Would be nice to see the coverage area even if the station is already build.
Hmm, I might think about adding that below the icons for the different vehicle-types (even though I don't know locomotion at all ;) )
But I don't know yet how much work this will be and how long it will take to do it.
In locomotion that button shows a blue coverage area. Mayby it can be done with the same tiles/sprites that are used for displaying the coverage area while building the station.
Attachments
locostyle.png
locostyle.png (79.11 KiB) Viewed 11302 times
User avatar
lucaspiller
Tycoon
Tycoon
Posts: 1228
Joined: 18 Apr 2004 20:27

Post by lucaspiller »

MeusH wrote:When are patches going to be added to the OTTD main code? Pleeeeease??
For the 503983848483727th time: When they are ready.
No longer active here, but you can still reach me via email: luca[at]stackednotion[dot]com
Asterix
Engineer
Engineer
Posts: 121
Joined: 04 Apr 2005 18:17
Location: Germany

Post by Asterix »

MeusH wrote:When are patches going to be added to the OTTD main code? Pleeeeease??
Hmm, this patch isnt ready for being included in the trunk, yet...
There are still things to do, so i can only repeat, what lucaspiller wrote: When its ready! :roll:
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post by MeusH »

okay, copy that, thanks
Jango
Traffic Manager
Traffic Manager
Posts: 189
Joined: 28 Aug 2004 12:13

Post by Jango »

Jumper wrote:
Asterix wrote:
Jumper wrote:What abut a button to show the station coverage area like in locomotion? Would be nice to see the coverage area even if the station is already build.
Hmm, I might think about adding that below the icons for the different vehicle-types (even though I don't know locomotion at all ;) )
But I don't know yet how much work this will be and how long it will take to do it.
In locomotion that button shows a blue coverage area. Mayby it can be done with the same tiles/sprites that are used for displaying the coverage area while building the station.
This is not difficult to do. I gave Celestar a patch a while back which enabled this simply by clicking on a button from within a station dialog. The main problem with implementing it on the current base is that some of the viewport stuff is really poorly written. My patch works on the map branch where a lot of this code is revised and cleaned up (mostly by Truelight, Blathijs and Celestar).

Maybe I'll look into doing this on the current code base...
Asterix
Engineer
Engineer
Posts: 121
Joined: 04 Apr 2005 18:17
Location: Germany

Post by Asterix »

Jango wrote:This is not difficult to do. I gave Celestar a patch a while back which enabled this simply by clicking on a button from within a station dialog. The main problem with implementing it on the current base is that some of the viewport stuff is really poorly written. My patch works on the map branch where a lot of this code is revised and cleaned up (mostly by Truelight, Blathijs and Celestar).

Maybe I'll look into doing this on the current code base...
If you already have a patch for this, even if its not for the current code, it might be interesting for me, how you did it and maybe use some of your old code (that is, if you dont update it yourself ;) ).

Currently I add some statistics to waypoints.
Then there is still including wizeman's patch and making it possible to show only buses *or* trucks in the road-vehicle-list on my ToDo-List.
Catchment-area is the last thing in that list :)
Jango
Traffic Manager
Traffic Manager
Posts: 189
Joined: 28 Aug 2004 12:13

Post by Jango »

i'd be more than happy to give you the patch (if i can find it) for you to look at. If i can't find it, then i'm sure Celestar has it somewhere.

The principle is pretty easy. Within viewport.c there is the possibility to overlay squares with either blue (for catchment) or red (error) or white outlines. The map rewrite handled this much better than the existing code.

I then had a simple linked list which kept track of all the stations which currently were supposed to be displaying their catchment area. If i remember rightly, whenever the viewport code wanted to draw a square, it would quickly iterate through the stations within the linked list (normally 0 or 1 stations) and check to see whether the square came within the bounds, and if so, it would draw a blue box.

Celestar thought about doing it a different way. I believe he was thinking about putting an additional variable within the station struct (or reutilising existing bits). I suspect that although the code would be much easier to understand, the performance would not be as good because you'd have to iterate through every station to check this bit.

Celestar, if you ever read this, perhaps you could comment....
Asterix
Engineer
Engineer
Posts: 121
Joined: 04 Apr 2005 18:17
Location: Germany

Post by Asterix »

Jango wrote:i'd be more than happy to give you the patch (if i can find it) for you to look at.
thanks, got it now, but still have to look at it :)

First post updated with new .diff, as i added stats for waypoints, so if you click on a rail-tile with a waypoint on it (not the waypoint-sign) you will get a statswindow (see first post for more info).

comments welcome ;)

EDIT: updated first post with new version again, look there for details
domi
Engineer
Engineer
Posts: 6
Joined: 26 May 2005 19:59

Post by domi »

Thank you for the waypoint patch.
In my opinion it's a great improvement for designing railway networks... I have to go back optimizing my last game :wink:

Vielen Dank!
User avatar
lucaspiller
Tycoon
Tycoon
Posts: 1228
Joined: 18 Apr 2004 20:27

Post by lucaspiller »

I have just noticed that GCC gives quite a few warnings (see the attachement), this is with r2448.

EDIT: Ok, your testy one seems to fix most of those, except:

Code: Select all

vehicle_gui.c: In function `BuildVehicleListMasked':
vehicle_gui.c:1069: warning: left shift count >= width of type
Attachments
warnings.txt
(15.13 KiB) Downloaded 304 times
No longer active here, but you can still reach me via email: luca[at]stackednotion[dot]com
Asterix
Engineer
Engineer
Posts: 121
Joined: 04 Apr 2005 18:17
Location: Germany

Post by Asterix »

Thanks, for help with those warnings...
They didnt show up on MSVC... For the one left, I forgot to do something about it (and it doesnt show up for me, too, as the code itself should be ok)

Anyway: New version in top post, now with rating stats, and a new station-rating system (which could be deactivated in patchsettings->stations)

On the station-rating window there is a button which should show ALL vehicles that transport the currently selected cargo-type (please report bugs/problems). I already found one issue: the currently selected button sometimes gets unpressed when pushing the button for the list (didnt find how to solve this yet)

The button for showing catchment-area does NOT work yet, I just put it there for getting the gui-thingys right ;)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: ketony and 5 guests