Following is documentation for how the way universe graphs should be used. (Or in other words how i intend to refactor the graphs)
This came up when fixing exploration and path finding issues in AI
#5158 and #5159.
Basic situation: on clients (i.e. human client or AI client) and server we have different needs for keeping universe graphs (i.e. system nodes connected by starlane edges).
So to make it more consistent: on the client fall back to use the system graph. And a ALL_EMPIRES view would be only used for neutral/monsters.
This came up when fixing exploration and path finding issues in AI
#5158 and #5159.
Basic situation: on clients (i.e. human client or AI client) and server we have different needs for keeping universe graphs (i.e. system nodes connected by starlane edges).
- Each client needs to keep only one universe representation built from its incomplete knowledge and must not get the complete universe graph sent in order to not to leak information to the clients.
- The server needs to know the real universe graph, and a universe graph per client in order to match pathfinding effects in the clients.
- in PathFinder.cpp we have a system graph and empire_system_graph_views for storing graphs per empire.
- On the server, for each empire, the empire_system_graph_views has an entry. There is also an entry for empire id -1 (ALL_EMPIRES). ALL_EMPIRES is a bit fuzzy in the codebase - it sometimes means no empire (i.e. neutrals/monsters) and sometimes means any empire. In Pathfinder it is also used for neutrals/monsters, but in some cases it is used as fallback if there is no entry for a given empire id.
- The intended fallback should only be triggered on the clients, because there is no entry for the clients empire. But in a few cases, also the system_graph might be used.
- Finding nearest neighbor was recently changed to use system graph in all cases, because if a client knows a system, it knows all neighbors (and the distance).
Currently the implementation is surprising. And probably it will stay a bit surprising, but at least it needs to be more consistent and self-documented so we programmers dont get confused and shoot our own feet.Potentially / in future, clients could have mutiple graphs, eg. for observers or moderators to see what a specific empire knows, or perhaps via espionage for players about other players.
So to make it more consistent: on the client fall back to use the system graph. And a ALL_EMPIRES view would be only used for neutral/monsters.
as i dont see how to distinguish between client/server in PathFinder in a good way; i would implement like this:What i would want:
on server if there is no empire specific graph -> error
on client if there is no empire specific graph -> use system_graph
- on server if there is no empire specific graph -> use system_graph
- on client if there is no empire specific graph -> use system_graph
Statistics: Posted by Ophiuchus — Fri Apr 11, 2025 9:25 am