Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sun Nov 18, 2018 1:20 pm

All times are UTC




Post new topic  Reply to topic  [ 39 posts ]  Go to page 1 2 Next
Author Message
 Post subject: Patch: Trip History
PostPosted: Wed Aug 01, 2007 11:59 am 
Offline
Engineer
Engineer

Joined: Sun Jul 27, 2003 4:06 pm
Posts: 3
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

Attachment:
File comment: Train and ship trip history
Sadborough Transport, 30th Jul 2010.png
Sadborough Transport, 30th Jul 2010.png [ 79.3 KiB | Viewed 10154 times ]


Attachment:
File comment: Road vehicle and aircraft trip history window
Sadborough Transport, 29th Jul 2010.png
Sadborough Transport, 29th Jul 2010.png [ 85.32 KiB | Viewed 10155 times ]


Attachments:
triphistory_v0.2_r10737.patch [21.84 KiB]
Downloaded 234 times


Last edited by Molp on Thu Aug 02, 2007 12:17 am, edited 1 time in total.
Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Wed Aug 01, 2007 12:08 pm 
Offline
Traffic Manager
Traffic Manager
User avatar

Joined: Thu May 17, 2007 1:36 pm
Posts: 253
Location: Netherlands
/me likes

could you add the departure & arrival stations?

edit: welcome to the forums :]
edit2: change recieved to received <-- just a hint, great patch!

_________________
Image
alternate airport building rules (r10663)


Last edited by rav on Wed Aug 01, 2007 12:56 pm, edited 2 times in total.

Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Wed Aug 01, 2007 12:49 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 02, 2005 11:05 am
Posts: 15415
Skype: XeryusTC
Location: localhost
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 :).

_________________
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)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Wed Aug 01, 2007 2:45 pm 
Offline
Traffic Manager
Traffic Manager

Joined: Mon Apr 30, 2007 10:26 am
Posts: 141
this is a really good addition, and something you can use to debug/improve your system with.


keep up the good work


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Wed Aug 01, 2007 3:01 pm 
Offline
Route Supervisor
Route Supervisor

Joined: Thu Oct 07, 2004 10:05 am
Posts: 415
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

Code:
65, SL_MAX_VERSION
should be
73, SL_MAX_VERSION


That way loading old savegames with your patch should be no problem :)


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Wed Aug 01, 2007 3:41 pm 
Offline
Tycoon
Tycoon

Joined: Mon Oct 25, 2004 3:39 pm
Posts: 4349
Location: Mississauga
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


Last edited by MeusH on Wed Aug 01, 2007 6:32 pm, edited 1 time in total.

Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Wed Aug 01, 2007 5:03 pm 
Offline
Engineer
Engineer

Joined: Thu Jun 16, 2005 1:17 pm
Posts: 75
Location: Lappeenranta, Finland
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.


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Thu Aug 02, 2007 12:24 am 
Offline
Engineer
Engineer

Joined: Sun Jul 27, 2003 4:06 pm
Posts: 3
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!


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.

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


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Thu Aug 02, 2007 4:53 pm 
Offline
Engineer
Engineer
User avatar

Joined: Wed Jul 11, 2007 4:36 pm
Posts: 66
Cool! Can't wait for the next ChrisIN!

Quote:
Also, I don't think 0% should be red - it isn't bad - it's rather neutral

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%.


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Thu Aug 02, 2007 6:26 pm 
Offline
Tycoon
Tycoon

Joined: Mon Oct 25, 2004 3:39 pm
Posts: 4349
Location: Mississauga
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?


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Thu Aug 02, 2007 6:55 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Wed Jun 06, 2007 9:07 pm
Posts: 1710
Location: Czech Republic
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 ....

_________________
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)


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Fri Aug 03, 2007 11:40 am 
Offline
Engineer
Engineer
User avatar

Joined: Tue Apr 26, 2005 8:49 am
Posts: 38
Location: Karlskrona, Sweden
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? :/


Last edited by browneyedboy on Fri Aug 03, 2007 6:06 pm, edited 1 time in total.

Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Fri Aug 03, 2007 2:54 pm 
Offline
Engineer
Engineer

Joined: Tue Jun 06, 2006 12:54 pm
Posts: 46
oo very useful. i like


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Tue Aug 07, 2007 10:20 am 
Offline
Route Supervisor
Route Supervisor

Joined: Thu Oct 07, 2004 10:05 am
Posts: 415
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 :cry:


Attachments:
debug crash.png [586.07 KiB]
Downloaded 115 times
Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Tue Aug 07, 2007 9:45 pm 
Offline
TTDPatch Developer
TTDPatch Developer

Joined: Wed Feb 18, 2004 3:06 am
Posts: 10285
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.

_________________
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


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Fri Aug 17, 2007 5:27 pm 
Offline
Route Supervisor
Route Supervisor

Joined: Thu Oct 07, 2004 10:05 am
Posts: 415
The problem is this portion of code in the added triphistory_gui.cpp

Code:
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;
   }
}


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 :)


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Sun Aug 19, 2007 4:05 pm 
Offline
Engineer
Engineer

Joined: Tue Aug 14, 2007 7:47 am
Posts: 19
valgrind trace shows all of those 3 free's as invalid.

Code:
==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)


(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


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Sun Aug 19, 2007 6:31 pm 
Offline
Engineer
Engineer

Joined: Thu Aug 02, 2007 11:12 am
Posts: 11
Great patch!

But will it work in ChrisIN?


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Mon Aug 20, 2007 9:53 am 
Offline
Route Supervisor
Route Supervisor

Joined: Thu Oct 07, 2004 10:05 am
Posts: 415
Yes it works in ChrisIN and is in my local build which will be published this week already :)


Top
   
 Post subject: Re: Patch: Trip History
PostPosted: Sun Aug 26, 2007 4:22 pm 
Offline
Engineer
Engineer

Joined: Sun Aug 26, 2007 4:12 pm
Posts: 5
Thanks for the patch.

Just a small glitch: I'm using ChrisIN-r10982 (yes, already :D ) 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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 39 posts ]  Go to page 1 2 Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.