Author Topic: [fix] depot_frame  (Read 5786 times)

0 Members and 1 Guest are viewing this topic.

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
[fix] depot_frame
« on: May 06, 2009, 03: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  ;)

Offline prissi

  • Head Developer
  • Administrator
  • *
  • Posts: 4511
  • Helpful: 37
  • Languages: De,EN,JP
Re: [fix] depot_frame
« Reply #1 on: May 06, 2009, 04: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.

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
Re: [fix] depot_frame
« Reply #2 on: May 06, 2009, 04: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...
« Last Edit: May 07, 2009, 02:46:33 AM by gerw »

Offline prissi

  • Head Developer
  • Administrator
  • *
  • Posts: 4511
  • Helpful: 37
  • Languages: De,EN,JP
Re: [fix] depot_frame
« Reply #3 on: May 07, 2009, 03: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.

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
Re: [fix] depot_frame
« Reply #4 on: May 08, 2009, 12:57:58 AM »
Maybe a solution is to make the tabs dynamic?

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
Re: [fix] depot_frame
« Reply #5 on: May 08, 2009, 06:54:55 AM »
With this patch, the tabs will be created (and destroyed) dynamicly (also if a catenary is built or removed).

Offline prissi

  • Head Developer
  • Administrator
  • *
  • Posts: 4511
  • Helpful: 37
  • Languages: De,EN,JP
Re: [fix] depot_frame
« Reply #6 on: May 08, 2009, 03: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.

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
Re: [fix] depot_frame
« Reply #7 on: May 08, 2009, 04: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?).
« Last Edit: May 11, 2009, 04:46:55 AM by gerw »

Offline prissi

  • Head Developer
  • Administrator
  • *
  • Posts: 4511
  • Helpful: 37
  • Languages: De,EN,JP
Re: [fix] depot_frame
« Reply #8 on: May 09, 2009, 02:40:38 PM »
This with the static was requested for saving last state.

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
Re: [fix] depot_frame
« Reply #9 on: May 13, 2009, 01:46:35 AM »
Any annotations or bugs about this patch?

Offline prissi

  • Head Developer
  • Administrator
  • *
  • Posts: 4511
  • Helpful: 37
  • Languages: De,EN,JP
Re: [fix] depot_frame
« Reply #10 on: May 13, 2009, 07:47:42 AM »
No time to compile simutrans since sunday ...

Offline prissi

  • Head Developer
  • Administrator
  • *
  • Posts: 4511
  • Helpful: 37
  • Languages: De,EN,JP
Re: [fix] depot_frame
« Reply #11 on: June 02, 2009, 04:12:20 PM »
I think I worked on some of this. But could you update you patch?

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
Re: [fix] depot_frame
« Reply #12 on: June 03, 2009, 01:49:00 AM »

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
Re: [fix] depot_frame
« Reply #13 on: June 16, 2009, 01:07:49 PM »
New version www.tu-chemnitz.de/~gerw/patches/depot_fix_v3.patch

(Minor change + little red bolt is shown, if depot is electrified).

Offline prissi

  • Head Developer
  • Administrator
  • *
  • Posts: 4511
  • Helpful: 37
  • Languages: De,EN,JP
Re: [fix] depot_frame
« Reply #14 on: June 17, 2009, 02: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.

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
Re: [fix] depot_frame
« Reply #15 on: June 17, 2009, 03: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

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
Re: [fix] depot_frame
« Reply #16 on: June 18, 2009, 11:01:48 AM »
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

Online Dwachs

  • DevTeam, Coder/patcher
  • Moderator
  • *
  • Posts: 2022
  • Helpful: 20
  • Languages: EN, DE, AT
Re: [fix] depot_frame
« Reply #17 on: September 01, 2009, 02: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.
How much is the fish?

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
Re: [fix] depot_frame
« Reply #18 on: September 01, 2009, 04: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.

Online Dwachs

  • DevTeam, Coder/patcher
  • Moderator
  • *
  • Posts: 2022
  • Helpful: 20
  • Languages: EN, DE, AT
Re: [fix] depot_frame
« Reply #19 on: September 02, 2009, 12:47:33 AM »
I deleted only the lines I mentioned above.
How much is the fish?

Offline prissi

  • Head Developer
  • Administrator
  • *
  • Posts: 4511
  • Helpful: 37
  • Languages: De,EN,JP
Re: [fix] depot_frame
« Reply #20 on: September 26, 2009, 01:32:43 PM »
IS this now the final version?

Offline gerw

  • Coder/patcher
  • *
  • Posts: 618
  • Helpful: 0
Re: [fix] depot_frame
« Reply #21 on: October 08, 2009, 04:33:26 PM »
Since there was no feedback, I didn't alter the patch. The version posted by Dwachs should be the latest.

Offline prissi

  • Head Developer
  • Administrator
  • *
  • Posts: 4511
  • Helpful: 37
  • Languages: De,EN,JP
Re: [fix] depot_frame
« Reply #22 on: January 01, 2010, 08:56:20 AM »
Incorporated when updating depot_frame for netowrk mode.