There are three versions of all the weapons - 'UTComp_Weapon', 'NewNet_Weapon', and 'Forward_Weapon'. The hierarchy is 'Weapon -> UTComp_Weapon -> NewNet_Weapon -> Forward_Weapon'. I deleted all of the forward weapons so we can forget about those.
The mutator replaces all of the regular weapons with the 'NewNet' version.
In each NewNet weapon's Fire() method, it checks if the player has disabled enhanced net code, if so it calls super.Fire() and returns. This calls the UTComp_Weapon version of fire. All that does is record stats and then calls super.Fire() so that it calls the base regular weapon's fire method.
For the link gun, I modified both NewNet_LinkGun and UTComp_LinkGun to do the scoring changes we wanted, but otherwise they all work the same. NewNet_Weapon is the weapon you get, but if you turned it off in your F5 menu then it calls super.Fire() and you get the UTComp_Weapon Fire() instead.
The main problem is if you turned off EnhancedNetCode on the server, it doesn't replace any weapons at all. Ideally it would replace the regular weapons with the UTComp_Weapon classes.
There is some code around the 'StatsEnabled' flag. If true, it does e.g
Code: Select all
...
class'xWeapons.LinkGun'.default.FireModeClass[0] = Class'UTComp_LinkAltFire';
class'xWeapons.LinkGun'.default.FireModeClass[1] = Class'UTComp_LinkFire';
...
Today I'm going to add some code that will replace the weapons with the UTComp_Weapon classes when the server has the NewNet flag turned off, and remove that buggy StatsEnabled code.
I'll probably also make it so that if the flag is turned on in the server , the default for the players is still off in the F5 menu, this way if we do turn it on in the server, the players will have to check the box in their F5 menu also to get the newnet code. I really liked it myself but I know other players like leon and enyo did not. Probably better to make it opt-in than opt-out.
Optimizing it will be more difficult. There are a lot of ForEach loops I could probably remove. A lot of classes have code like
Code: Select all
if(M == none)
forEach DynamicActors(class'MutUTComp', M)
break;
For every pawn/player it makes a copy pawn and a copy collision actor to go along with it. It uses this to do the ping compensation and detect when hits happen. I'm not sure there is a way around that. It's the way it's designed from the core. The copies do minimal work but it's still like there is double the load on the server. If 24 players are playing, the server is doing the work of 48 players. I'm hoping I can tweak some values to reduce that.