Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 1 and Version 2 of code/howto/Synchronisable


Ignore:
Timestamp:
Sep 25, 2008, 9:24:37 PM (16 years ago)
Author:
scheusso
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/howto/Synchronisable

    v1 v2  
    11= Howt to make an object class Synchronisable =
     2This is a step-by-step guide to make a class XYZ synchronisable.
     3 * Synchronisable classes are registered to the network engine to be transfered/synched between client and server.
     4 * If you want your class to get transfered, you have to ''register'' every important variable to the network (e.g. position, speed, health, ...). But only register variables that are absolutely neccessary (e.g. no local variables).
     5 * The default transfer ''direction'' of variables (and objects) is from server to the clients only. If you want to change this for a certain variable (and object), call REGISTERDATA_WITHDIR(varname, direction) or REGISTERSTRING_WITHDIR(stringname, direction) instead of REGISTERDATA or REGISTERSTRING.[[br]]
    26See also [wiki:network/Synchronisable] for more information.
    37== Basic steps ==
     
    2731}
    2832}}}
     33== Multidirectional synchronisation ==
     34If you want to have a variable synchronised back to the server, follow these steps (additional to/instead of the above):
     35 1. register the variable with REGISTERDATA_WITHDIR:
     36{{{
     37void XYZ::registerAllVariables(){
     38  REGISTERDATA_WITHDIR(someVar_, network::direction::bidirectional); // synchronises in both directions
     39  REGISTERSTRING_WITHDIR(someString_, network::direction::toserver); // only transfers from client to server (not recommended)
     40}
     41}}}
     42 2. Change the default object synchronisation direction in order to enable the above variables to get transfered to the server:
     43{{{
     44XYZ::XYZ(){
     45  registerAllVariables();
     46  setObjectMode(network::direction::bidirectional);
     47  ...
     48}
     49}}}