XeryusTC wrote:putting the GUI into its own thread is a really bad thing, you will need a lot of mutexes every time it needs information to fill a window causing other threads to wait or in the worst case it can even cause a deadlock.
Indeed. But on the other hand, the interface doesn't have to poll the game data intensively.
Given that the number of UI windows is finite, comparing to the number of game entities, I guess the engine could just prepare the statistics for the enities requested by the GUI (no matter threaded or not), and do it at a very modest rate, maybe once or twice in a second at best.
Separate rendering/viewport states wouldn't need much polling as well, and even less if there's a kind of view frustum culling.
Caching an entire route so you wont need pathfinding is bad too
I never meant caching entire routes for each single vehicle or eliminating tile-based pathfinding completely
. I was rather thinking about a graph of all the possible
arcs that can ever make a route, something like "arc 1 is a road that connects tile x and tile y, rather free", "arc 2 is a unidirectional rail track that connects tile X and tile Y and has bidirectional semaphores at both ends, rather crowded" etc.
So when a vehicle is given an order, the pathifinder just looks through the top-level graph nodes associated with the current station/dock/airstrip etc. and determines if the destination station/dock etc is reacheable, then creates a route that consists of all the arcs (waypoints) it needs to pass. When a road is removed, a station is created etc. only the affected arcs need to be modified. And if there's a traffic collision, sepahore locked etc., the vehicle can intiate a search for alternative routes.
if only one thing in the network changes it needs te be re-calculated for all the trains in the network at the same time; lane load balancing wont work because all trains will try to enter the same lane causing a traffic jam, this is exactly the opposite what you tried to do with the lane load balancing
I would go for the KUDr way, cache the weight of a piece of track between two signals so the path only needs re-calculation when the train enters a junction in stead of every tile.
Yep, that's what I'm basically talking about
OTOH splitting AI up into a different thread might prove to be useful
The current player AI isn not clever enough to be CPU-intensive