improved punkbuster

This commit is contained in:
logsol 2014-06-07 17:52:33 +02:00
parent e7052754c3
commit a4120f6ff5
4 changed files with 19 additions and 5 deletions

View file

@ -53,11 +53,20 @@ function(Parent, Nc, Parser, Settings) {
}
if(difference.x < Settings.PUNKBUSTER_DIFFERENCE_METERS
|| difference.y < Settings.PUNKBUSTER_DIFFERENCE_METERS) {
&& difference.y < Settings.PUNKBUSTER_DIFFERENCE_METERS) {
this.player.doll.updatePositionState(update);
} else {
// HARD UPDATE FOR SELF
console.log(this.player.user.options.nickname + ' is cheating.')
var body = this.player.doll.body;
var options = {
p: body.GetPosition(),
lv: body.GetLinearVelocity()
};
Nc.trigger(Nc.ns.channel.to.client.user.gameCommand.send + this.player.id, 'positionStateReset', options);
}
};

View file

@ -18,14 +18,10 @@ function(Parent, Nc, ProtocolHelper, ProtocolParser) {
self.sendControlCommand("joinSuccess", options);
});
Nc.on(Nc.ns.channel.events.controlCommand.user + this.id, function(message) {
ProtocolHelper.applyCommand(message.data, self);
});
Nc.on(Nc.ns.channel.to.client.user.gameCommand.send + this.id, function(command, options) {
self.sendGameCommand(command, options);
});

View file

@ -217,6 +217,10 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, reque
player.kill(killedByPlayer, options.ragDollId);
};
GameController.prototype.onPositionStateReset = function(options) {
this.me.resetPositionState(options);
};
GameController.prototype.onRemoveGameObject = function(options) {
var object = null;
for (var i = 0; i < this.gameObjects[options.type].length; i++) {

View file

@ -56,6 +56,11 @@ function (Parent, Settings) {
return this.doll.isAnotherPlayerNearby();
};
Me.prototype.resetPositionState = function(options) {
this.doll.body.SetPosition(options.p);
this.doll.body.SetLinearVelocity(options.lv);
};
return Me;
});