Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 4 and Version 5 of code/doc/network/Synchronisable


Ignore:
Timestamp:
Sep 29, 2008, 2:36:40 PM (11 years ago)
Author:
scheusso
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/network/Synchronisable

    v4 v5  
    1313 * network::direction::bidirectional (==0x3) sync in both directions
    1414
    15 Every object and every registered variable have a syncdirection (default: toclient).
     15Every object and every registered variable has a syncdirection (default: toclient).
    1616
    1717In order to synchronise a variable in a class, these steps must be done:
     
    6363
    6464=== Synchronisation Direction ===
    65 As mentioned above, the default direction of the Synchronisation is toclient. If you want to change this, you need to register the variable with either REGISTERDATA_WITHDIR or REGISTERSTRING_WITHDIR (normally per-class, see below). Additionally you have to set the global syncdirection (per-object, see below) to directional or toclient (again: not recommended
     65As mentioned above, the default direction of the Synchronisation is toclient. If you want to change this, you need to register the variable with either REGISTERDATA_WITHDIR or REGISTERSTRING_WITHDIR (normally per-class, see below). Additionally you have to set the global syncdirection (per-object, see below) to bidirectional or toclient (again: not recommended)
    6666{{{
    6767int SomeClass::syncback;
    68 REGISTERDATA_WITHDIR(i, network::direction::bidirectional); // put this inside registerAllVariables
     68REGISTERDATA_WITHDIR(syncback, network::direction::bidirectional); // put this inside registerAllVariables
    6969this->setObjectMode(network::direction::bidirectional); // put this wherever you want (it is possible to do this only for specific objects specified by objectID)
    7070}}}
     
    7373When synchronising an object the first time to a client (or server) the following steps occur:
    7474 * A new object gets created with the appropriate class
    75  * by calling the constructor of the class also registerAllVariables gets called (make sure this is in your constructor)
    76  * After construction of the object finished the data get updated (all variables previously registered by registerAllVariables)
     75 * By calling the constructor of the class registerAllVariables gets called (make sure this is in your constructor)
     76 * After construction of the object is finished the data gets updated (all variables previously registered by registerAllVariables)
    7777 * After that the create() function gets called.
    7878
    79 Because we don't have the data at construction time, all functions that need member variables (with data from the server) must be called inside create(). See example class for details.
     79Because we don't have the data at construction time, '''all functions that need member variables''' (with data from the server) '''must be called inside create()''' (instead of inside the constructor). See example class for details.
    8080
    8181== Preconditions ==