Patch: Trip History
Moderator: OpenTTD Developers
Patch: Trip History
Trip History Patch v0.2 (Works with nightly r10737+)
This patch is designed to show information about the last 10 trips that a vehicle has made.
The columns are:
Received: When the vehicle delivered the cargo
Profit: Profit from the cargo
Change: Shows the percentage difference between the current and last trips profits
TBT (Time between trips): Shows the time taken between each trip
Change: Shows the change (in days) between the TBT values
The screenshots should give you a better understanding.
This is a WIP - features requests etc are welcome.
CHANGELOG
v0.2
Fixed spelling mistakes
0% values are now shown in green
Transfer virtual profit is now shown (in yellow)
Fixed save game compatibility
v0.1
Initial release
This patch is designed to show information about the last 10 trips that a vehicle has made.
The columns are:
Received: When the vehicle delivered the cargo
Profit: Profit from the cargo
Change: Shows the percentage difference between the current and last trips profits
TBT (Time between trips): Shows the time taken between each trip
Change: Shows the change (in days) between the TBT values
The screenshots should give you a better understanding.
This is a WIP - features requests etc are welcome.
CHANGELOG
v0.2
Fixed spelling mistakes
0% values are now shown in green
Transfer virtual profit is now shown (in yellow)
Fixed save game compatibility
v0.1
Initial release
- Attachments
-
- triphistory_v0.2_r10737.patch
- (21.84 KiB) Downloaded 409 times
Last edited by Molp on 02 Aug 2007 00:17, edited 1 time in total.
Re: Patch: Trip History
/me likes
could you add the departure & arrival stations?
edit: welcome to the forums
edit2: change recieved to received <-- just a hint, great patch!
could you add the departure & arrival stations?
edit: welcome to the forums
edit2: change recieved to received <-- just a hint, great patch!
Last edited by rav on 01 Aug 2007 12:56, edited 2 times in total.
Re: Patch: Trip History
Ah very nice, I always liked it that you could see the amount of money a vehicle earned on its last trip .
Maybe it would be nice to also add an average running costs per day next to the average earnings per day. It might be a nice comparison .
Maybe it would be nice to also add an average running costs per day next to the average earnings per day. It might be a nice comparison .
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
-
- Traffic Manager
- Posts: 141
- Joined: 30 Apr 2007 10:26
Re: Patch: Trip History
this is a really good addition, and something you can use to debug/improve your system with.
keep up the good work
keep up the good work
-
- Route Supervisor
- Posts: 415
- Joined: 07 Oct 2004 10:05
Re: Patch: Trip History
This is an awesome patch that should certainly be in ChrisIN if you don't mind and also welcome to the forums!! Great first post!
Maybe a tip for not breaking savegame compatibility:
In saveload.cpp change the savegame version to 73 (72 is the current version in trunk iirc).
And then in vehicle.cpp
That way loading old savegames with your patch should be no problem
Maybe a tip for not breaking savegame compatibility:
In saveload.cpp change the savegame version to 73 (72 is the current version in trunk iirc).
And then in vehicle.cpp
Code: Select all
65, SL_MAX_VERSION
should be
73, SL_MAX_VERSION
Re: Patch: Trip History
This patch is great
However, I'm wondering why values of "change" (in days) are not one row below? I think it would be better if values of last column were moved down by one row.
Also, I don't think 0% should be red - it isn't bad - it's rather neutral, but using too many colours (like extra yellow) isn't a good idea either. Making it green would be better, because I think that red colour is reserved for danger, or at least bad things
However, I'm wondering why values of "change" (in days) are not one row below? I think it would be better if values of last column were moved down by one row.
Also, I don't think 0% should be red - it isn't bad - it's rather neutral, but using too many colours (like extra yellow) isn't a good idea either. Making it green would be better, because I think that red colour is reserved for danger, or at least bad things
Last edited by MeusH on 01 Aug 2007 18:32, edited 1 time in total.
Re: Patch: Trip History
I'm personally interested about anything related to accounting and following the movement of money in the game so I like the idea too.
XeryusTC suggested comparing average running costs per day and average earnings per day, I'm not sure if he meant this to be per round trip comparison but I would like that. Also to add more Return On Investment feel to it the comparison should include the value of the vehicles lost while on the trip.
XeryusTC suggested comparing average running costs per day and average earnings per day, I'm not sure if he meant this to be per round trip comparison but I would like that. Also to add more Return On Investment feel to it the comparison should include the value of the vehicles lost while on the trip.
Re: Patch: Trip History
You can certainly put it in ChrisIN. The only things needed to be changed would be moving the button in the train description window to not interfere with the routemarkers, and change the respective case statement number to the correct value.chrissicom wrote:This is an awesome patch that should certainly be in ChrisIN if you don't mind and also welcome to the forums!! Great first post!
try:
{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 295, 369, 32, 43, STR_TRIP_HISTORY, STR_TRIP_HISTORY_TOOLTIP},
(does look a bit off with the Max T.E value above it, but you can change it to make it look better)
Updated the patch to v0.2
Re: Patch: Trip History
Cool! Can't wait for the next ChrisIN!
Actually the change is negative in this case if you compare the absolute values. So showing it red is correct. I assume there could also be green 0%.Also, I don't think 0% should be red - it isn't bad - it's rather neutral
Re: Patch: Trip History
Thank you Lupin III
Also please disregard my previous post, now I realised the dates are sorted in descending, causing my confusion because I was sure they are ascending.
By the way, how about ability to sort by date ascending/descending?
Also please disregard my previous post, now I realised the dates are sorted in descending, causing my confusion because I was sure they are ascending.
By the way, how about ability to sort by date ascending/descending?
Re: Patch: Trip History
This will be very useful.
I also wonder if it is possible to have similar window also for vehicle groups? Showing either sum or average from these values ....
I also wonder if it is possible to have similar window also for vehicle groups? Showing either sum or average from these values ....
If you need something, do it yourself or it will be never done.
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility
Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
- browneyedboy
- Engineer
- Posts: 38
- Joined: 26 Apr 2005 08:49
- Location: Karlskrona, Sweden
Re: Patch: Trip History
I tried patching this just now, but it wont work.
I use nightly r10753
I followed the steps on how to add a .patch/.diff-file
What am I doing wrong? :/
I use nightly r10753
I followed the steps on how to add a .patch/.diff-file
What am I doing wrong? :/
Last edited by browneyedboy on 03 Aug 2007 18:06, edited 1 time in total.
-
- Engineer
- Posts: 46
- Joined: 06 Jun 2006 12:54
Re: Patch: Trip History
oo very useful. i like
-
- Route Supervisor
- Posts: 415
- Joined: 07 Oct 2004 10:05
Re: Patch: Trip History
There's an assertion bug with this patch, although I couldn't find out yet why. I compiled a debug version of the patch with ChrisIN, and whenever I close any of the vehicle windows the game crashes with the following error message... maybe you have an idea
P.S.: If it wasn't clear, only the debug build crashes on closing a vehicle, vehicle details or trip history window, the release build works fine I had a similar problem with the copy & paste patch which I fixed, if I would just remember how
P.S.: If it wasn't clear, only the debug build crashes on closing a vehicle, vehicle details or trip history window, the release build works fine I had a similar problem with the copy & paste patch which I fixed, if I would just remember how
- Attachments
-
- debug crash.png
- (586.07 KiB) Downloaded 115 times
Re: Patch: Trip History
That's usually caused by:
1) freeing a pointer that wasn't malloced (Did you step through an array by modifying the pointer instead of an index?)
2) freeing a pointer has already been freed, resp,
3) freeing a stack pointer (see #1)
(The same applies for new/delete and new[]/delete[]. All three heap allocation stytems must be kept separate.)
One thing it is notably NOT caused by is freeing/deleting/delete[]ing NULL. That is guaranteed to be a nop.
The release build doesn't assert because it's a release build, and those try to work, instead of trying to make debugging easy.
1) freeing a pointer that wasn't malloced (Did you step through an array by modifying the pointer instead of an index?)
2) freeing a pointer has already been freed, resp,
3) freeing a stack pointer (see #1)
(The same applies for new/delete and new[]/delete[]. All three heap allocation stytems must be kept separate.)
One thing it is notably NOT caused by is freeing/deleting/delete[]ing NULL. That is guaranteed to be a nop.
The release build doesn't assert because it's a release build, and those try to work, instead of trying to make debugging easy.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
-
- Route Supervisor
- Posts: 415
- Joined: 07 Oct 2004 10:05
Re: Patch: Trip History
The problem is this portion of code in the added triphistory_gui.cpp
When I comment out the WE_DESTROY case everything works fine. The WE_DESTROY case will reset all the trip history values and is supposed to free the created arrays which is causing the crash in the debug version afaik. I think this whole WE_DESTROY is not needed anyway so I just removed it for ChrisIN
Code: Select all
static void VehicleTripHistoryWndProc(Window *w, WindowEvent *e)
{
Vehicle *v;
v = GetVehicle(w->window_number);
switch (e->event) {
case WE_CREATE:
CreateTripHistoryInformation(v);
break;
case WE_PAINT:
DrawVehicleTripHistoryWindow(w);
break;
case WE_DESTROY:
free(v->trip_history_pchange_array);
free(v->trip_history_TBT_array);
free(v->trip_history_TBT_change_array);
v->trip_history_avg_daylength = 0;
v->trip_history_profitpd = 0;
v->trip_history_total_change = 0;
v->trip_history_total_profit = 0;
break;
}
}
Re: Patch: Trip History
valgrind trace shows all of those 3 free's as invalid.
(and identical for line 94 and 95), translating to:
free(v->trip_history_pchange_array);
free(v->trip_history_TBT_array);
free(v->trip_history_TBT_change_array);
in WE_DESTROY in VehicleTripHistoryWndProc.
//edit, just noticed the "v" (vehicle) it's freeing does not exist here, only in WE_CREATE
Code: Select all
==19592== Invalid free() / delete / delete[]
==19592== at 0x4A1F88A: free (in /usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
==19592== by 0x51816B: VehicleTripHistoryWndProc(Window*, WindowEvent*) (triphistory_gui.cpp:93)
free(v->trip_history_pchange_array);
free(v->trip_history_TBT_array);
free(v->trip_history_TBT_change_array);
in WE_DESTROY in VehicleTripHistoryWndProc.
//edit, just noticed the "v" (vehicle) it's freeing does not exist here, only in WE_CREATE
-
- Engineer
- Posts: 11
- Joined: 02 Aug 2007 11:12
Re: Patch: Trip History
Great patch!
But will it work in ChrisIN?
But will it work in ChrisIN?
-
- Route Supervisor
- Posts: 415
- Joined: 07 Oct 2004 10:05
Re: Patch: Trip History
Yes it works in ChrisIN and is in my local build which will be published this week already
Re: Patch: Trip History
Thanks for the patch.
Just a small glitch: I'm using ChrisIN-r10982 (yes, already ) and when the train arrives at station with history window opened, new line is inserted, but only received and profit columns are added. Change and TBT columns don't move so they are displayed for wrong journey. Reopening history window helps.
Just a small glitch: I'm using ChrisIN-r10982 (yes, already ) and when the train arrives at station with history window opened, new line is inserted, but only received and profit columns are added. Change and TBT columns don't move so they are displayed for wrong journey. Reopening history window helps.
Who is online
Users browsing this forum: No registered users and 14 guests