Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 2, 2009, 4:19:43 PM (15 years ago)
Author:
scheusso
Message:

Network Function calls possible now (already used in Pawn::fire/doFire)

include "network/NetworkFunction.h"
register network functions like this:

registerStaticNetworkFunction( functionPointer ); this is for static (member) functions
registerMemberNetworkFunction( class, function );
this is for non-static member functions

call network functions like this:

callStaticNetworkFunction( functionPointer, clientID, arg1, … ); clientID is 0 for server
callMemberNetworkFunction( class, function, objectID, clientID, arg1, … );
objectID can be obtained by this→getObjectID() for synchronisables

arguments must be supported by MultiType !!
object must inherit from Synchronisable !!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp2/src/util/MultiType.h

    r2937 r2949  
    8080    enum MT_Type
    8181    {
    82         MT_null,
    83         MT_char,
    84         MT_uchar,
    85         MT_short,
    86         MT_ushort,
    87         MT_int,
    88         MT_uint,
    89         MT_long,
    90         MT_ulong,
    91         MT_longlong,
    92         MT_ulonglong,
    93         MT_float,
    94         MT_double,
    95         MT_longdouble,
    96         MT_bool,
    97         MT_void,
    98         MT_string,
    99         MT_vector2,
    100         MT_vector3,
    101         MT_vector4,
    102         MT_colourvalue,
    103         MT_quaternion,
    104         MT_radian,
    105         MT_degree
     82        MT_null=0,
     83        MT_char=1,
     84        MT_uchar=2,
     85        MT_short=3,
     86        MT_ushort=4,
     87        MT_int=5,
     88        MT_uint=6,
     89        MT_long=7,
     90        MT_ulong=8,
     91        MT_longlong=9,
     92        MT_ulonglong=10,
     93        MT_float=11,
     94        MT_double=12,
     95        MT_longdouble=13,
     96        MT_bool=14,
     97        MT_void=15,
     98        MT_string=16,
     99        MT_vector2=17,
     100        MT_vector3=18,
     101        MT_vector4=19,
     102        MT_colourvalue=20,
     103        MT_quaternion=21,
     104        MT_radian=22,
     105        MT_degree=23
    106106    };
    107107
     
    326326           
    327327            /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
    328             inline void                       importData(uint8_t*& mem) { assert(sizeof(MT_Type)<=8); *(uint8_t*)(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->importData(mem); }
     328            inline void                       exportData(uint8_t*& mem) const { assert(sizeof(MT_Type)<=8); *(uint8_t*)(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
    329329            /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */
    330             inline void                       exportData(uint8_t*& mem) { assert(sizeof(MT_Type)<=8); this->setType(*(uint8_t*)mem); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
     330            inline void                       importData(uint8_t*& mem) { assert(sizeof(MT_Type)<=8); this->setType(static_cast<MT_Type>(*(uint8_t*)mem)); mem+=sizeof(uint8_t); this->value_->importData(mem); }
    331331            /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
    332332            inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
    333333            /** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
    334             inline void                       operator >> (uint8_t*& mem) { exportData(mem); }
    335             inline uint32_t                   getNetworkSize() { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
     334            inline void                       operator >> (uint8_t*& mem) const { exportData(mem); }
     335            inline uint32_t                   getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
    336336
    337337            /** @brief Checks whether the value is a default one. */
Note: See TracChangeset for help on using the changeset viewer.