The International Simutrans Forum

 

Author Topic: BUG: All buildings not on ground level considered 'deleted'  (Read 124 times)

0 Members and 1 Guest are viewing this topic.

Offline freddyhayward

  • Devotee
  • *
  • Posts: 437
  • Languages: EN
BUG: All buildings not on ground level considered 'deleted'
« on: October 16, 2020, 08:34:19 AM »
A common warning in the logs is
Code: [Select]
<x> <goods> delivered to <stop> were intended for a building that has been deleted.. Upon closer inspection, almost all of these warnings occur at stops that are either elevated or have some elevated component. Upon further investigation of the code, I found that passenger destinations are stored as 2D coordinates ('koord') and upon arriving, only buildings located on the ground can and are being looked up. All others are considered 'deleted', and there is no way to search for them without significant changes to the code.
I am honestly at a loss as to what to do about this problem. Leaving it as is leads to misleading warnings and in incorrect behaviour. Fully supporting these buildings as reachable destinations by storing destinations as 3d coordinateds would take a large amount of effort and probably lead to a performance loss. Partially supporting them by checking for upper-level buildings after arrival would lead to anomalies because the exact building cannot be determined. Fully excluding them from being reachable destinations would lead to inconsistent behaviour: ground-level stop buildings will attract and generate passengers and mail while upper-level ones would not, despite  being identical buildings. I suppose the last option is to eliminate the concept of stop buildings (but not station buildings) from being buildings altogether, or at least from generating/attracting passengers altogether. I'm not sure about that one either.
Does anyone have any thoughts?

Offline Freahk

  • Devotee
  • *
  • Posts: 1325
  • Languages: DE, EN
Re: BUG: All buildings not on ground level considered 'deleted'
« Reply #1 on: October 16, 2020, 03:30:16 PM »
Partially supporting them by checking for upper-level buildings after arrival would lead to anomalies because the exact building cannot be determined.

That's a quite simple, still good solution imho.
It's an edge case and, except from building stats and commuting trips, it does not really matter where exactly on the same koord the passengers or mail arrive. Cargo is a different thing, there cannot be any cargo destination above or below ground level, so no need to care about it.

That means, if there is no building at all on ground level, search for any building at that koord which accepts our "ware" (passenger or mail) and send it there.
If it is a commuting trip, search for all buildings on that koord that offers jobs and send it to one of those with jobs available. If there is none, send the commuter anywhere.

I am aware this does not replicate the exact behvior we would get when actually generating passengers with koord3d destinations, but I don't think it's worth the effort and that solution should be good enough.

Looking at the code, using koord3d instead should not be too difficult too. In some places we already get the koord from a koord3d directly, in many cases, we can safely take the 3d koord on ground level from the 2d koord, as industries are always on ground level.
Some cases need a little more attention.

Koord3d is definitely the cleanest option and from the code, I would not expect it to affect performance nor memory consumption very much, so it's definitely a viable option too.
It will just take a lot more effort than the above solution, so I'm not sure if it's worth, given it's an edge case and the above does only affect some stats which is not a big issue.
« Last Edit: October 16, 2020, 03:55:14 PM by Freahk »

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 20274
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: BUG: All buildings not on ground level considered 'deleted'
« Reply #2 on: October 17, 2020, 05:28:06 PM »
Thank you for reporting this. We need to consider whether we might in the reasonably foreseeable future need to implement more significant buildings not on the ground. If we do, then we will need the full koord3d fix. If not, then the more basic fix will suffice.

I cannot immediately think of any reason to implement the buildings not on ground, but we may need to consider whether there is such a need before progressing this.