Author Topic: Xref issues and bridges  (Read 1571 times)

0 Members and 1 Guest are viewing this topic.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15553
  • Total likes: 382
  • Helpful: 172
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Xref issues and bridges
« on: December 30, 2014, 12:26:55 PM »
I am currently working on a system to allow for bridges being upgraded to other bridges of the same type for Experimental. The idea is that the cost of "upgrading" the bridge is much lower where the only difference between the two bridges is the type of road surface/rail/etc. on top of them rather than the actual structure of the bridge, to simulate replacing the way on top of the bridge without replacing the bridge itself. To do this, I am trying to use a system where bridges define other bridges to which they can upgrade. I have previously done something similar for vehicles which has worked without much difficulty using the same xref system as is used for the coupling constraints (nachfolger and vorganger), adapting the makeobj and vehicle_reader.cc code.

However, I cannot seem to get the same system to work for bridges: I get access violations on the code trying to read the icon image (wkz->set_icon( besch->get_cursor()->get_bild_nr(1) ); in void brueckenbauer_t::register_besch(bruecke_besch_t *besch)). I have already added the line obj_for_xref(get_type(), besch->get_name(), data); in void bridge_reader_t::register_obj(obj_besch_t *&data), and this has not helped.

Does anyone know what other steps that I need to take in order to allow bridges (and in due course tunnels) to work with the xref system in this way? I should be most grateful for any help.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4233
  • Total likes: 169
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Xref issues and bridges
« Reply #1 on: December 30, 2014, 01:19:27 PM »
You cannot access the other bridge in register_obj. That is, the xref's are not resolved at this point. Other than this I cannot say anything helpful.
Parsley, sage, rosemary, and maggikraut.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15553
  • Total likes: 382
  • Helpful: 172
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Xref issues and bridges
« Reply #2 on: December 30, 2014, 01:48:59 PM »
How do bridges differ from vehicles in this respect?

Edit: I suppose that the other option is not to use xrefs at all, and just use abstract groupings.
« Last Edit: December 30, 2014, 05:41:03 PM by jamespetts »
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4733
  • Total likes: 180
  • Helpful: 108
  • Languages: EN, NO
Re: Xref issues and bridges
« Reply #3 on: December 30, 2014, 07:54:52 PM »
How do bridges differ from vehicles in this respect?

As far as I know, the xref i vehikel_besch_t are only used during play. At the time register_obj is called, not only isn't xrefs resolved, the object referred to might not be loaded yet.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8764
  • Total likes: 307
  • Helpful: 229
  • Languages: De,EN,JP
Re: Xref issues and bridges
« Reply #4 on: January 06, 2015, 10:12:09 PM »
If xrefs work that early, then this is pure luck, since it depends on loading order.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15553
  • Total likes: 382
  • Helpful: 172
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Xref issues and bridges
« Reply #5 on: January 06, 2015, 10:30:36 PM »
Happily, I have managed now to deal with the issue in another way without requiring xrefs.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.