From a4120f6ff5855488f96f41d5858fc0bd28a9c305 Mon Sep 17 00:00:00 2001 From: logsol Date: Sat, 7 Jun 2014 17:52:33 +0200 Subject: [PATCH] improved punkbuster --- app/Game/Channel/Control/PlayerController.js | 11 ++++++++++- app/Game/Channel/User.js | 4 ---- app/Game/Client/GameController.js | 4 ++++ app/Game/Client/Me.js | 5 +++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/app/Game/Channel/Control/PlayerController.js b/app/Game/Channel/Control/PlayerController.js index ad745d0..c8e5c6e 100755 --- a/app/Game/Channel/Control/PlayerController.js +++ b/app/Game/Channel/Control/PlayerController.js @@ -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); } }; diff --git a/app/Game/Channel/User.js b/app/Game/Channel/User.js index d852619..1bc4b60 100755 --- a/app/Game/Channel/User.js +++ b/app/Game/Channel/User.js @@ -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); }); diff --git a/app/Game/Client/GameController.js b/app/Game/Client/GameController.js index 6121033..33167ae 100755 --- a/app/Game/Client/GameController.js +++ b/app/Game/Client/GameController.js @@ -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++) { diff --git a/app/Game/Client/Me.js b/app/Game/Client/Me.js index 8a9e24b..e0555ae 100644 --- a/app/Game/Client/Me.js +++ b/app/Game/Client/Me.js @@ -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; }); \ No newline at end of file