← All posts

Project archive

Showing players only the ships they have detected

What I accomplished this week. I spent a long time fighting with a task that seems simple but is difficult within a networked architecture: letting a player see their own ships without seeing anyone else's. The nuance is that every player has a separate list of ships, and that list can change dynamically during play. The hardest part, though, was that the ship data is generated in one part of the code, linked to another and transferred there, then moved to a third part, from which it interacts with elements in the first. After all that, it creates an individual view on each client without falling out of sync with the server or other clients. Why is this necessary? To simulate detecting an enemy and obtaining accurate data about them. Here's a counterexample from EVE Online. You can see enemy ships. SEE them. But your system has to lock them before you can fire. Without a lock, you're out of luck. Weak justifications for this don't survive contact with realism. If you can clearly see a target through an optical channel and have measured the range with a laser, you can fire. Moreover, if you see the enemy ship's type and know its dimensions, its angular size already lets you determine the range fairly accurately without any rangefinder. You have all the data needed for accurate fire. You can also see the target, understand its maneuvers and position, and anticipate how the situation may develop. In short, this is a major game convention, like aiming dispersion in World of Tanks. To avoid that problem, you'll see the enemy ship's complete model in its true position only when your ship's sensors have detected it conclusively, assuming those sensors exist and work. For most weapon systems, that already provides enough data to calculate a firing solution.

Before that point, you'll only be able to estimate the enemy's location, especially if they're trying not to emit anything. Later, at medium and long range, your sensors may give you the target's approximate location. That can sometimes be enough to launch certain missiles or deploy drones, but wholly insufficient for gunfire and most missiles. You also won't yet know what kind of target it is. For that matter, you generally won't know whether it's friendly or hostile...

In the end, I solved it and got it working. Everything is now displayed correctly everywhere. The radar-calculation algorithm has been ready for two years, so I'll move it over from the laptop and implement it fully in the system. One important point: having conquered the architecture, everything that follows is much easier because all the information flows and connections are already in place.

Project Facebook profile ↗