The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: gerw on May 06, 2009, 08:55:30 pm

Title: [fix] depot_frame
Post by: gerw on May 06, 2009, 08:55:30 pm
build_vehicle_list was called twice, while opening a depot window. First time it is called without timeline. Therefore the electric tab was shown (in an electrified depot), even if you couldn't build any electric engine.

I love fixing bugs while deleting lines  ;)
Title: Re: [fix] depot_frame
Post by: prissi on May 06, 2009, 09:22:38 pm
This is done deliberately, since later opening this no electric engines will be shown or if the depot is open for longer time.
Title: Re: [fix] depot_frame
Post by: gerw on May 06, 2009, 09:24:59 pm
But the depot_frame isn't updated, if there is a new vehicle available, is it?

Edit:
If this is the desired behaviour, I've found an other bug: If you open a depot_frame and electrify the depot afterwards, there isn't an electric tab...
Title: Re: [fix] depot_frame
Post by: prissi on May 07, 2009, 08:13:35 pm
This is indeed a problem, because if you send a vehicle to a depot that does not has this category, it can crash the depot. Furthermore, if a certain kind of vehicle is obsolete, the tab is empty. But when you activate "show all" then it will be shown.

The electricity look therefore like a bug.
Title: Re: [fix] depot_frame
Post by: gerw on May 08, 2009, 05:57:58 am
Maybe a solution is to make the tabs dynamic?
Title: Re: [fix] depot_frame
Post by: gerw on May 08, 2009, 11:54:55 am
With this patch, the tabs will be created (and destroyed) dynamicly (also if a catenary is built or removed).
Title: Re: [fix] depot_frame
Post by: prissi on May 08, 2009, 08:44:23 pm
Still not 100% correct. Build a tram depot in pak 64 in 2030. Open Depot. Seletc show obsolete. ONly one car is there. Close window. Open again => All cars are there, not only the obsolete one (like show all). Not sure if this is related to your patch or was just hidden before.
Title: Re: [fix] depot_frame
Post by: gerw on May 08, 2009, 09:23:32 pm
Still not 100% correct. Build a tram depot in pak 64 in 2030. Open Depot. Seletc show obsolete. ONly one car is there. Close window. Open again => All cars are there, not only the obsolete one (like show all). Not sure if this is related to your patch or was just hidden before.
I can't reproduce this. If I open the depot first time, 'show all' is selected, 'show obsolete' isn't. If I reopen the depot, it shows always the same selection as before closing.

Edit: There is some other issue with the static show_retired_vehicles/show_all: If you have more then one depot_gui, then changing the state in one window, changes also the state in the others (it's static), but doesn't updates there vehicle lists. Edit3: Now, all depot_frames get refreshed. So this is solved.

Edit2: New patch version. Now, the depot frame is refreshed each new month (new vehicles?).
Title: Re: [fix] depot_frame
Post by: prissi on May 09, 2009, 07:40:38 pm
This with the static was requested for saving last state.
Title: Re: [fix] depot_frame
Post by: gerw on May 13, 2009, 06:46:35 am
Any annotations or bugs about this patch?
Title: Re: [fix] depot_frame
Post by: prissi on May 13, 2009, 12:47:42 pm
No time to compile simutrans since sunday ...
Title: Re: [fix] depot_frame
Post by: prissi on June 02, 2009, 09:12:20 pm
I think I worked on some of this. But could you update you patch?
Title: Re: [fix] depot_frame
Post by: gerw on June 03, 2009, 06:49:00 am
You can find the patch at
www.tu-chemnitz.de/~gerw/patches/depot_fix_v2.patch (http://www.tu-chemnitz.de/~gerw/patches/depot_fix_v2.patch)
Title: Re: [fix] depot_frame
Post by: gerw on June 16, 2009, 06:07:49 pm
New version www.tu-chemnitz.de/~gerw/patches/depot_fix_v3.patch (http://www.tu-chemnitz.de/~gerw/patches/depot_fix_v3.patch)

(Minor change + little red bolt is shown, if depot is electrified).
Title: Re: [fix] depot_frame
Post by: prissi on June 17, 2009, 07:41:56 pm
I get a memory corruption as soon as a convoi enters the depot. However, it seems this happend already earlier within the code, it writing in a readonly place aparently occurs. I think this patch needs to be handled with valgrind before it can become productive.
Title: Re: [fix] depot_frame
Post by: gerw on June 17, 2009, 08:32:58 pm
Thank you for reporting. I've found the bug. It's caused by an ugly data structure in depot_frame:
vehicle_map has pointers to the entries of the vectors electrics_vec, pas_vec,... But if they get resized, the pointers become invalid....

In the old code, the size of the vectors was set, before filling them. I deleted this code, cause the vectors will resize themselves.

Now I will look, how to change the vehicle_map thing, because the pointers to the vectors aren't very nice imho - and cause programming errors  ;D
Title: Re: [fix] depot_frame
Post by: gerw on June 18, 2009, 04:01:48 pm
Ok, now I've reinserted the old code, albeit I don't like it, but I hadn't any good idea, how to handle this.

tu-chemnitz.de/~gerw/patches/depot_fix_v4.patch (http://tu-chemnitz.de/~gerw/patches/depot_fix_v4.patch)
Title: Re: [fix] depot_frame
Post by: Dwachs on September 01, 2009, 07:50:00 pm
The patch worked with Tortoise ;) I updated the patch.

I have one question: What purpose does this block serve:
Code: [Select]
@@ -640,6 +589,11 @@
  loks_vec.clear();
  waggons_vec.clear();
 
+ pas_vec.resize(depot->get_vehicle_type()->get_count());
+ electrics_vec.resize(depot->get_vehicle_type()->get_count());
+ loks_vec.resize(depot->get_vehicle_type()->get_count());
+ waggons_vec.resize(depot->get_vehicle_type()->get_count());
+
  vehicle_map.clear();
 
  // we do not allow to built electric vehicle in a depot without electrification
The vectors are resized above this block anyway.
Title: Re: [fix] depot_frame
Post by: gerw on September 01, 2009, 09:15:13 pm
The patch worked with Tortoise ;) I updated the patch.
Did you just update the patch or did you change something?

Quote
I have one question: What purpose does this block serve:
...
The vectors are resized above this block anyway.
Mmmh. Maybe this lines are superfluous and could be deleted.
Title: Re: [fix] depot_frame
Post by: Dwachs on September 02, 2009, 05:47:33 am
I deleted only the lines I mentioned above.
Title: Re: [fix] depot_frame
Post by: prissi on September 26, 2009, 06:32:43 pm
IS this now the final version?
Title: Re: [fix] depot_frame
Post by: gerw on October 08, 2009, 09:33:26 pm
Since there was no feedback, I didn't alter the patch. The version posted by Dwachs should be the latest.
Title: Re: [fix] depot_frame
Post by: prissi on January 01, 2010, 02:56:20 pm
Incorporated when updating depot_frame for netowrk mode.