News:

SimuTranslator
Make Simutrans speak your language.

BUG: All buildings not on ground level considered 'deleted'

Started by freddyhayward, October 16, 2020, 08:34:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

freddyhayward

A common warning in the logs is <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?

Mariculous

Quote from: freddyhayward on October 16, 2020, 08:34:19 AMPartially 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.

jamespetts

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.
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.