bahrmichael / factorio-tycoon

GNU General Public License v3.0
10 stars 7 forks source link

bug: towns can get stuck in their expansion without telling the player #186

Open bahrmichael opened 1 year ago

bahrmichael commented 1 year ago

I built quite a constricted town around the base resources I was given, however there seems to be space to build and that isn’t being used for some reason. Currency is still spawning so I know that it hasn’t fully stopped working

Screenshot 2023-10-20 at 15 33 47

Can also happen for other reasons, like being locked in between water, cliffs, resources and entities.

winex commented 8 months ago

hmm, i've ran into this issue with one auto-generated town by rbgen right now.

it has only trees around it - doesn't build steps try to remove them? scrot 20240308_194709 town_is_stuck half

after checking some code...

bugged town just returns by this: https://github.com/bahrmichael/factorio-tycoon/blob/743d716ab55fd0c79a4ef0a3f8d9c98c1b5f20cf/city.lua#L799-L803 that Queue for that city is empty for some reason? i don't understand that, yet

61091.527 Script @__tycoon__/city.lua:794: attempts: 10                    
61091.527 Script @__tycoon__/city.lua:796: debug A: allowedCoordinates: nil
--- repeats, no point B ---

roadEnds for this town is { first = 6, last = 5 } - might it be because it can't build roads when they're looped like that? it seems that updatepossibleBuildingLocations() is not called from: https://github.com/bahrmichael/factorio-tycoon/blob/743d716ab55fd0c79a4ef0a3f8d9c98c1b5f20cf/control.lua#L39-L42

while...

another town with treasury already-built on the map passes this check and:

61108.551 Script @__tycoon__/city.lua:794: attempts: 10
61108.551 Script @__tycoon__/city.lua:796: debug A: allowedCoordinates: nil
61108.551 Script @__tycoon__/city.lua:808: debug B: coordinates: {x = 2, y = 4}
61180.733 Script @__tycoon__/city.lua:794: attempts: 10
61180.733 Script @__tycoon__/city.lua:796: debug A: allowedCoordinates: nil
61180.733 Script @__tycoon__/city.lua:808: debug B: coordinates: {x = 3, y = 7}
61252.800 Script @__tycoon__/city.lua:794: attempts: 10
61252.800 Script @__tycoon__/city.lua:796: debug A: allowedCoordinates: nil
61252.800 Script @__tycoon__/city.lua:808: debug B: coordinates: {x = 7, y = 6}

...BUT!

the last town doesn't seem to decrease construction materials from HW-store! it's still 100 plates, 100 bricks after 3 houses built -- another little issue -> #273...

winex commented 8 months ago

here some debug logs added of big town (5K citizens, started as v0.3.x save!):

2105.633 Script @__tycoon__/city.lua:829: debug B: coordinates: {x = 57, y = 22}
2105.633 Script @__tycoon__/city.lua:829: debug B: coordinates: {x = 57, y = 10}
2105.633 Script @__tycoon__/city.lua:829: debug B: coordinates: {x = 59, y = 49}
2105.633 Script @__tycoon__/city.lua:829: debug B: coordinates: {x = 58, y = 33}
2105.634 Script @__tycoon__/city.lua:829: debug B: coordinates: {x = 58, y = 46}
2105.634 Script @__tycoon__/city.lua:829: debug B: coordinates: {x = 66, y = 34}
2105.634 Script @__tycoon__/city.lua:829: debug B: coordinates: {x = 41, y = 13}
2105.634 Script @__tycoon__/city.lua:829: debug B: coordinates: {x = 71, y = 56}
2105.634 Script @__tycoon__/city.lua:829: debug B: coordinates: {x = 24, y = 27}
2105.634 Script @__tycoon__/city.lua:829: debug B: coordinates: {x = 72, y = 57}
2105.635 Script @__tycoon__/city.lua:895: unable to construct: simple

it just tries 10 times and nothing happens... hmm, we should revise that code some time later...

winex commented 7 months ago

this part of issue https://github.com/bahrmichael/factorio-tycoon/issues/186#issuecomment-1986058243 is probably because city.roadEnds was fully emptied when chunk is not charted. that's when rbgen placed towns in dark areas of map. trying to fix in new PR - one more migration, lol