The International Simutrans Forum

 

Author Topic: Attempting to make fabrik_t connections link directly, not through plan_quadrat  (Read 2597 times)

0 Members and 1 Guest are viewing this topic.

Offline neroden

  • Devotees (Inactive)
  • *
  • Posts: 831
  • Nathanael Nerode
So, I discovered that the factory suppliers and customers connections are connected, in the code, not to actual factories, but to *grid locations*.
 
 Hmm.
 
 This makes the code rather hairy and makes it substantially more difficult to keep track of things.  (It's obstructing my first attempt to alter the goods generation code in experimental.)
 
 By contrast, halts are currently actually directly connected to each other, via halthandle_t.  Now, what I would like to do is to have the factories directly connected to each other the same way.  I think this change would simplify matters immensely, and allow for a lot of cleanups.
 
 However, I'm not quite sure what needs to be done to make this work right.  It seems to me, based on what was done with haltestelle_t vs. halthandle_t, that it's not as simple as having pointers to fabrik_t.  I have to have handles which are persistent across saved games and across the network.
 
 I would appreciate information from someone who helped implement the halthandle_t type as to what needs to be done.
 
 Crossposted to standard development as this code cleanup would (theoretically) affect standard as well as experimental.

Edit:
If it is as simple as using fabrik_t*, let me know. 

For that matter, if it is as simple as using quickstone_tpl<fabrik_t>, I can also do that very quickly.  That should avoid a number of segmentation faults, relative to using direct pointers.
« Last Edit: May 02, 2013, 04:20:48 PM by neroden »

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10642
  • Languages: De,EN,JP
For loading and saving you can still use koord; actually, you must use koord, as there is a very good chance, that those factories do not yet exist during loading. When calling laden_abschliessen(), you can then convert the koord to pointers (same size, you may use a union ... )

Having said this, you should still consider handles, as this will save you all hassles with deleting factories and the like.