I’m back from holiday. I’ve done some thinking.
Before I left I did a brief multiplayer test (just me on a remote dedi). It lagged like a British rail service (that’s a lot) because of the volume of moving things (not CPU-intensive, but network-intensive). So I need a new approach.
Something I’m going to try is not using serverside entities for simple, not-messed-with-yet people and cars, and instead just using a table containing pos/ang/velocity of each person and car in the city. Every 0.5 seconds a function will simulate the movement of everything in the table. Cars never change velocity until interacted with, people change velocity when they hit brushes right now… cars may theoretically collide but oh well, I’ll work something out. A system of pseudo-entities, basically.
Clients will only be sent info about pseudo-entities in their field of view, and only once, unless their velocity changes. For example, if a UFO hovers close enough to 6 citizens walking around a building, the UFO’s player will be told about where each citizen is and their velocity. The client will create sufficient clientside-only entities and place them. However, from then on, the client simulates the citizens on its own (they’ll just keep walking forwards at constant speed until they turn). When they do turn, the server updates the client with the pseudo-entity’s new velocity, and the client applies this new velocity to the relevant clientside entity.
Working out when UFOs can pick up these pseudo-entities, turning them into real entities when this happens, removing the relevant clientside entities, solving the problem that pseudo-entities will not have collision and pretty much everything I’ve forgotten will, of course, be handled by technomagic I’ll devise tomorrow.
If it works, I can make cities with a truly awesome number of citizens and cars, and players won’t be able to tell they are cheap sims up until they are beamed/whacked/destroyed.
too long; didn’t read? brb, recoding Source engine.