Remove replicated rider pawn actors unless rider position is occupied

Issue #106 resolved
Matt Hands created an issue

Rider pawns are a VehicleWeaponPawn and by default are replicated to all clients for which the server considers the actor net relevant, which crudely speaking means within a certain range. The server has to maintain a separate net channel for each rider pawn that is relevant to each client. In maps with lots of vehicles this results in very large numbers of net channels & associated replication, which can result in a substantial load on the network. This will only worsen as rider positions are added to more vehicles.

I have designed & tested a new system that avoids rider pawns needing to exist on net clients unless that rider position is occupied. This can substantially cut down the number of net channels & associated replication. As it's a major change, I will document (these notes are also commented in the class):

We toggle the bTearOff flag for each rider pawn when it is unoccupied/occupied, which causes the usual clientside simulated actors to spawn or be destroyed. When bTearOff is set, the actor stops being net relevant & the server closes the channel, stops replicating the actor & destroys the clientside version.

The trick is to stop the actor from actually being torn off on the client, otherwise that causes us big problems & breaks the system. There is a built-in delay of 5 seconds before the server decides the actor isn't net relevant, closes the channel & destroys the clientside actor. If a player switches back to the old rider position within these 5 secs, we need them to re-occupy the existing rider pawn & abort closing the channel.

I've found a way to achieve this is to delay the next NetUpdateTime to be >5 seconds in the future, which delays bTearOff from replicating to clients. That way the server closes the channel & destroys the clientside actor before bTearOff is sent to the client, so it never actually gets torn off. And if a player re-enters the rider position during these 5 secs, we just change bTearOff back to false & it becomes net relevant again.

A further complication is when a player exits a rider pawn, we need to introduce a very short delay before setting bTearOff on server, so a 0.5 sec timer is used. This is necessary to allow properties updated on exit (e.g. Owner, Driver & PRI all none) to replicate to clients before shutting down all net traffic.

Changes in other classes: slight modifications to functions NumPassengers in DH_ROTreadCraft & DrawVehicleIcon in DHHud, to work with new system & avoid errors.

Comments (1)

  1. Log in to comment