From e8ada1ac886b3012be35d4576d422840a27ee042 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Mon, 19 Feb 2007 21:55:10 +0000 Subject: [PATCH] Added setImmediate(), made it so that old un-recompiled games are essentially calling setImmediate() when they call set(), since set() used to be immediate. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@197 c613c5cb-e716-0410-b11b-feb51c14d237 --- src/as/com/threerings/ezgame/EZGameControl.as | 16 +++++++++++++++- .../ezgame/client/GameControlBackend.as | 14 +++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/as/com/threerings/ezgame/EZGameControl.as b/src/as/com/threerings/ezgame/EZGameControl.as index 58807548..5109bc58 100644 --- a/src/as/com/threerings/ezgame/EZGameControl.as +++ b/src/as/com/threerings/ezgame/EZGameControl.as @@ -157,7 +157,21 @@ public class EZGameControl extends EventDispatcher */ public function set (propName :String, value :Object, index :int = -1) :void { - callEZCode("setProperty_v1", propName, value, index); + callEZCode("setProperty_v1", propName, value, index, false); + } + + /** + * Set a property, but have this client immediately set the value so that + * it can be re-read. The property change event will still arrive and + * will be your clue as to when the other clients will see the newly + * set value. Be careful with this method, as it can allow data + * inconsistency: two clients may see different values for a property + * if one of them recently set it immediately, and the resultant + * PropertyChangedEvent's oldValue also may not be consistent. + */ + public function setImmediate (propName :String, value :Object, index :int = -1) :void + { + callEZCode("setProperty_v1", propName, value, index, true); } /** diff --git a/src/as/com/threerings/ezgame/client/GameControlBackend.as b/src/as/com/threerings/ezgame/client/GameControlBackend.as index f7d6cae8..46c01e05 100644 --- a/src/as/com/threerings/ezgame/client/GameControlBackend.as +++ b/src/as/com/threerings/ezgame/client/GameControlBackend.as @@ -164,8 +164,17 @@ public class GameControlBackend o["getPlayers_v1"] = getPlayers_v1; } + /** + * Set a property. + * + * Note: immediate defaults to true, even though immediate=false is + * the general case. We are providing some backwards compatibility + * to old versions of setProperty_v1() that assumed immediate and did + * not pass a 4th value. + * All callers should now specify that value explicitely. + */ public function setProperty_v1 ( - propName :String, value :Object, index :int) :void + propName :String, value :Object, index :int, immediate :Boolean = true) :void { validatePropertyChange(propName, value, index); @@ -173,6 +182,9 @@ public class GameControlBackend _ezObj.ezGameService.setProperty( _ctx.getClient(), propName, encoded, index, false, null, createLoggingConfirmListener("setProperty")); + if (immediate) { + _ezObj.applyPropertySet(propName, value, index); + } } public function testAndSetProperty_v1 (