Skip to content

Commit

Permalink
Makign SetHeldTool a predicted command.
Browse files Browse the repository at this point in the history
  • Loading branch information
benvanik committed Dec 30, 2012
1 parent 19cb005 commit 991b6a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/blk/sim/commands/setheldtoolcommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ goog.provide('blk.sim.commands.SetHeldToolCommand');
goog.require('blk.sim');
goog.require('blk.sim.commands.CommandType');
goog.require('gf.sim');
goog.require('gf.sim.Command');
goog.require('gf.sim.PredictedCommand');



Expand All @@ -32,7 +32,7 @@ goog.require('gf.sim.Command');
* Sent from the client to the server to request tool changes.
*
* @constructor
* @extends {gf.sim.Command}
* @extends {gf.sim.PredictedCommand}
* @param {!gf.sim.CommandFactory} commandFactory Command factory.
*/
blk.sim.commands.SetHeldToolCommand = function(commandFactory) {
Expand All @@ -42,9 +42,9 @@ blk.sim.commands.SetHeldToolCommand = function(commandFactory) {
* Tool entity ID.
* @type {number}
*/
this.tool = 0;
this.toolId = 0;
};
goog.inherits(blk.sim.commands.SetHeldToolCommand, gf.sim.Command);
goog.inherits(blk.sim.commands.SetHeldToolCommand, gf.sim.PredictedCommand);


/**
Expand All @@ -53,7 +53,7 @@ goog.inherits(blk.sim.commands.SetHeldToolCommand, gf.sim.Command);
blk.sim.commands.SetHeldToolCommand.prototype.read = function(reader) {
goog.base(this, 'read', reader);

this.tool = reader.readUint32();
this.toolId = reader.readUint32();
};


Expand All @@ -63,7 +63,7 @@ blk.sim.commands.SetHeldToolCommand.prototype.read = function(reader) {
blk.sim.commands.SetHeldToolCommand.prototype.write = function(writer) {
goog.base(this, 'write', writer);

writer.writeUint32(this.tool);
writer.writeUint32(this.toolId);
};


Expand All @@ -81,4 +81,4 @@ blk.sim.commands.SetHeldToolCommand.ID = gf.sim.createTypeId(
* @const
* @type {number}
*/
blk.sim.commands.SetHeldToolCommand.FLAGS = 0;
blk.sim.commands.SetHeldToolCommand.FLAGS = gf.sim.PredictedCommand.FLAG;
4 changes: 2 additions & 2 deletions src/blk/sim/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ blk.sim.Inventory.prototype.executeCommand = function(command) {

if (command instanceof blk.sim.commands.SetHeldToolCommand) {
var target = this.getTarget();
var newTool = this.getChild(command.tool);
var newTool = this.getChild(command.toolId);
if (newTool) {
target.setHeldTool(newTool);
}
Expand Down Expand Up @@ -163,7 +163,7 @@ if (gf.CLIENT) {
var cmd = /** @type {!blk.sim.commands.SetHeldToolCommand} */ (
this.createCommand(blk.sim.commands.SetHeldToolCommand.ID));
var newTool = this.getChildAtIndex(newHeldIndex);
cmd.tool = newTool.getId();
cmd.toolId = newTool.getId();
this.simulator.sendCommand(cmd);

if (gf.CLIENT) {
Expand Down

0 comments on commit 991b6a2

Please sign in to comment.