Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 17, 2008, 5:24:56 PM (16 years ago)
Author:
scheusso
Message:

chat works again now. some doxygen. small change according to playerid in Host

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/network/Synchronisable.cc

    r1775 r1793  
    5151namespace network
    5252{
     53 
    5354
    5455  std::map<unsigned int, Synchronisable *> Synchronisable::objectMap_;
     
    5960  /**
    6061  * Constructor:
    61   * calls registarAllVariables, that has to be implemented by the inheriting classID
     62  * Initializes all Variables and sets the right objectID
    6263  */
    6364  Synchronisable::Synchronisable(){
     
    7172  }
    7273
     74  /**
     75   * Destructor:
     76   * Delete all callback objects and remove objectID from the objectMap_
     77   */
    7378  Synchronisable::~Synchronisable(){
    7479    // delete callback function objects
     
    8186  }
    8287
     88  /**
     89   * This function gets called after all neccessary data has been passed to the object
     90   * Overload this function and recall the create function of the parent class
     91   * @return true/false
     92   */
    8393  bool Synchronisable::create(){
    8494    objectMap_[objectID]=this;
     
    90100
    91101 
     102  /**
     103   * This function sets the internal mode for synchronisation
     104   * @param b true if this object is located on a client or on a server
     105   */
    92106  void Synchronisable::setClient(bool b){
    93107    if(b) // client
     
    97111  }
    98112 
     113  /**
     114   * This function fabricated a new synchrnisable (and children of it), sets calls updateData and create
     115   * After calling this function the mem pointer will be increased by the size of the needed data
     116   * @param mem pointer to where the appropriate data is located
     117   * @param mode defines the mode, how the data should be loaded
     118   * @return pointer to the newly created synchronisable
     119   */
    99120  Synchronisable *Synchronisable::fabricate(unsigned char*& mem, int mode)
    100121  {
     
    119140
    120141 
     142  /**
     143   * Finds and deletes the Synchronisable with the appropriate objectID
     144   * @param objectID objectID of the Synchronisable
     145   * @return true/false
     146   */
    121147  bool Synchronisable::deleteObject(unsigned int objectID){
    122148    assert(getSynchronisable(objectID));
     
    126152  }
    127153 
     154  /**
     155   * This function looks up the objectID in the objectMap_ and returns a pointer to the right Synchronisable
     156   * @param objectID objectID of the Synchronisable
     157   * @return pointer to the Synchronisable with the objectID
     158   */
    128159  Synchronisable* Synchronisable::getSynchronisable(unsigned int objectID){
    129160    std::map<unsigned int, Synchronisable *>::iterator i = objectMap_.find(objectID);
     
    140171  * @param var pointer to the variable
    141172  * @param size size of the datatype the variable consists of
     173  * @param t the type of the variable (network::DATA or network::STRING
     174  * @param mode same as in getData
     175  * @param cb callback object that should get called, if the value of the variable changes
    142176  */
    143177  void Synchronisable::registerVar(void *var, int size, variableType t, int mode, NetworkCallbackBase *cb){
     
    158192 
    159193  /**
    160    * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct
    161    * Difference to the above function:
     194   * This function takes all SynchronisableVariables out of the Synchronisable and saves them together with the size, objectID and classID to the given memory
    162195   * takes a pointer to already allocated memory (must have at least getSize bytes length)
    163196   * structure of the bitstream:
    164    * (var1_size,var1,var2_size,var2,...)
    165    * varx_size: size = sizeof(int)
    166    * varx: size = varx_size
    167    * @return data containing all variables and their sizes
     197   * |totalsize,objectID,classID,var1,var2,string1_length,string1,var3,...|
     198   * length of varx: size saved int syncvarlist
     199   * @param mem pointer to allocated memory with enough size
     200   * @param id gamestateid of the gamestate to be saved (important for priorities)
     201   * @param mode defines the direction in which the data will be send/received
     202   *             0x1: server->client
     203   *             0x2: client->server (not recommended)
     204   *             0x3: bidirectional
     205   * @return true: if !isMyTick or if everything was successfully saved
    168206   */
    169207  bool Synchronisable::getData(unsigned char*& mem, unsigned int id, int mode){
     
    224262 
    225263  /**
    226    * This function takes a syncData struct and takes it to update the variables
    227    * @param vars data of the variables
     264   * This function takes a bytestream and loads the data into the registered variables
     265   * @param mem pointer to the bytestream
     266   * @param mode same as in getData
    228267   * @return true/false
    229268   */
     
    288327  /**
    289328  * This function returns the total amount of bytes needed by getData to save the whole content of the variables
     329  * @param id id of the gamestate
     330  * @param mode same as getData
    290331  * @return amount of bytes
    291332  */
     
    316357
    317358  /**
    318    *
    319    * @param id
    320    * @return
     359   * This function determines, wheter the object should be saved to the bytestream (according to its syncfrequency)
     360   * @param id gamestate id
     361   * @return true/false
    321362   */
    322363  bool Synchronisable::isMyTick(unsigned int id){
     
    325366  }
    326367 
     368  /**
     369   * This function looks at the header located in the bytestream and checks wheter objectID and classID match with the Synchronisables ones
     370   * @param mem pointer to the bytestream
     371   */
    327372  bool Synchronisable::isMyData(unsigned char* mem)
    328373  {
     
    339384  }
    340385 
     386  /**
     387   * This function sets the synchronisation mode of the object
     388   * If set to 0x1 variables will only be synchronised to the client
     389   * If set to 0x2 variables will only be synchronised to the server
     390   * If set to 0x3 variables will be synchronised bidirectionally (only if set so in registerVar)
     391   * @param mode same as in registerVar
     392   */
    341393  void Synchronisable::setObjectMode(int mode){
    342394    assert(mode==0x1 || mode==0x2 || mode==0x3);
Note: See TracChangeset for help on using the changeset viewer.