Comments (11)
So the question then begins how does it get an offset of 2 for the order insert position. The caller is sub_486ECF
which is an ai function. Now if we look at sub_486ECF
it is inserting orders for all the stations of an AiThought. And it doesn't bother to check if the order insert was successful! And if it was not successful then it will send an invalid order offset! So we now know why it is sending an offset 2. Its because there is a order insert that has failed. So now we need to find out why the first insert failed.
from openloco.
When we look at previous failed order inserts there is a curious failure just before with a vehicle trying to insert an order for a station it doesn't own! This sounds like our problem order. The station it is trying to insert an order for is station id 0. 0 is always a high chance for issues! Sounds like the ai doesn't have its stations correct in its thoughts.
from openloco.
Now the question becomes is the station id being incorrect in the ai a vanilla ai mistake or a OpenLoco mistake. The ai hasn't been fully implemented yet so its always slightly hard to diagnose but from what we have implemented you can see how a value of 0 could get set for the station id. It could happen if _lastPlacedTrackStationId is null. And that could happen if a station placement failed for some reason.
from openloco.
tested this on latest master, it crashes in OpenLoco::Vehicles::OrderManager::shiftOrdersRight()
its an out of bounds memory access, looks like it's caused from stack corruption.
in the frame of the calling function, OpenLoco::Vehicles::OrderManager::insertOrder()
, shiftOrdersRight
is called with params (0+2, 2)
which is just (2, 2)
. in the frame of shiftOrdersRight
however, the offsetToShiftFrom
is 280, not 2, which is causing the problem. not sure what is causing it though, other than some funky stack corruption
from openloco.
One question: what is it an order? Is it when a company purchases a vehicle? And the order table?
Orders are what you give a vehicle to describe its route. It will be things like stop at this waypoint, stop at this station, wait for this type, unload this type. All the orders for every vehicle are stored in one big table this is split into individual slots for each vehicle. Annoyingly even though you can only have 64 orders per vehicle the order table for a vehicle is variable size. So you need to shift everyone's order around whenever you insert or remove an order. If you mess this up you get issues...
In this save a vehicle with a size 1 order table (i.e. no orders) is trying to insert an order at offset 2 which is impossible the only insert position is offset 0.
from openloco.
I have lost some autosaves because they were overwritten, but I have this slightly older save which doesn't crash: 2nd october.zip.
However, I can't understand the difference between the two saves which produces the crash.
from openloco.
I have tried to debug as far as I can and I get that when the crash happens:
- the
head
parameter ininsertOrder()
hasvehicletype
tram - in
OpenLoco::GameCommands::sub_470312()
, which is called by the commandcreateVehicle
,head->orderTableOffset = OrderManager::orderTableLength();
which is 278
I noticed that the crash happens when the company called Thin Lines is building a tram track near Finway. The track seems finished. I think that maybe Thin Lines is trying to build a passenger stop in the same point where Finway Transport already has one (Finway West). I don't know if this can be related to the problem.
However, at this point I imagine Thin Lines is going to create a tram and at this point the game crashes.
One question: what is it an order? Is it when a company purchases a vehicle? And the order table?
P.S. In the saved game here:
I have lost some autosaves because they were overwritten, but I have this slightly older save which doesn't crash: 2nd october.zip. However, I can't understand the difference between the two saves which produces the crash.
Thin Lines is not building that tram track and the game is not crashing. This is not a proof but maybe an hint.
from openloco.
Thanks @duncanspumpkin for all the details! In the end it seems something like this is happening:
I think that maybe Thin Lines is trying to build a passenger stop in the same point where Finway Transport already has one (Finway West).
So we need to understand what happens when one ai tries to place something which is in conflict with another ai.
Usually when you as a player build something near one ai, you are restricted to build where the ai is planning to build, so I think that every ai reserves all the blocks it needs to build its route. I imagine that also one ai can't plan a route where another ai has reserved some blocks.
The peculiar fact in this save is that there are no conflicts in the route, since both ai can use the same road, but only in the station placement. It could be that the stations conflict is not checked when Thin Lines ai is planning its station.
from openloco.
I still have one older save of that game. I've created this save Thin Lines 11th October.zip because Thin Lines starts building Tram Track near Finway on 12th October, so maybe this can be useful. I have tried to look into // 0x00430762 void aiThink(const CompanyId id)
and put some breakpoints but I can't find anything about the route planning.
from openloco.
I still have one older save of that game. I've created this save Thin Lines 11th October.zip because Thin Lines starts building Tram Track near Finway on 12th October, so maybe this can be useful. I have tried to look into
// 0x00430762 void aiThink(const CompanyId id)
and put some breakpoints but I can't find anything about the route planning.
Unfortunately we've not implemented the function that does the insert order code. But we need to i think to investigate the station creation ai code. Afair there are multiple bits of ai code that does station creation so it's really not easy to work out.
from openloco.
I wrote route previously but what I mean is the road/rail line with the stations, not the route as the sequence of orders. I imagine that at some point there should be an object containing the stations and the array of road/rail sections needed to connect them and that this object is validated. But this is only my idea.
from openloco.
Related Issues (20)
- Gridlines on landscape are toggled with the land window HOT 1
- Crash in alertCargoAcceptanceChange/MessageManager::post
- Set maximum width for the toolbars GUI HOT 4
- Multiple coal mines with the same name (minor) HOT 1
- Scenario editor: Can't change name of existing scenario HOT 3
- Scenario editor: Landscape generation options flickering HOT 2
- Allow trains to pass at junctions if the paths do not cross HOT 2
- Cannot unpause by pressing normal speed button while build when paused cheat active HOT 2
- "Deselect All" button in object selection window HOT 1
- "Deselct All" button in object selection HOT 1
- [Suggestion] Invert right mouse dragging apply to map dragging (minor)
- Leap Year 😄 HOT 1
- Make bridges and stations transparent and show track / road
- Removal of structures HOT 8
- [BUG] Gridlines disappear after leaving construction mode HOT 1
- Crash on load up of Scenario with missing Objects HOT 3
- Don't show loading bar every Month HOT 1
- Rival companies having different vehicles. HOT 2
- The regular train has to wait longer for the upcoming express train
- Crash when building track HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openloco.