✅Crash when changing bridge type

Do you have any issues? Don't hesitate to tell us about it.
User avatar
DreamBuilder
Inhabitant of a Megacity
Reactions:
Posts: 203
Joined: 18 Jan 2017, 14:36
Location: Cemetery but not dead
Plugins: Showcase Store
Version: Beta

Platform

✅Crash when changing bridge type

#1

Post by DreamBuilder »

My game instantly crashes when i change bridge type on highways especially long ones

User avatar
Brody Craft
Inhabitant of a Infinity
Reactions:
Posts: 8034
Joined: 24 Jan 2017, 11:15
Location: SE Asia
Plugins: Showcase Store
Version: Beta

Platform

Re: Crash when changing bridge type

#2

Post by Brody Craft »

that happens when theres too much things to process, also happens on weak devices

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Crash when changing bridge type

#3

Post by Lobby »

I was lazy when I implemented it. The code looks a bit like

Code: Select all

void setBridge(Road r, Bridge b) {
  r.bridge = b;
  for (Road _r neighbor of r with _r.bridge != b) {
    setBridge(_r, b);
  }
}
The problem here is that the function calls itself. For each function call within a function memory on the so called stack is needed. As stack size is most often not huge you should avoid too many function calls in other functions :?

User avatar
Lobby
Developer
Reactions:
Posts: 3705
Joined: 26 Oct 2008, 12:34
Plugins: Showcase Store
Version: Beta

Platform

Re: Crash when changing bridge type

#4

Post by Lobby »

Will be fixed in the next update.

The solution to such recursion problems is to use a queue of roads from which you remove roads until it's empty. For every road you might have to add new ones to the queue (neighbor roads), so you have to ensure that you don't add already processed roads again. Otherwise it will take a long long time:

Post Reply Previous topicNext topic

Return to “Problems and Errors (bugs)”