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.