Changeset 2949
- Timestamp:
- May 2, 2009, 4:19:43 PM (16 years ago)
- Location:
- code/branches/netp2/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp2/src/network/FunctionCallManager.cc
r2945 r2949 34 34 std::map<uint32_t, packet::FunctionCalls*> FunctionCallManager::clientMap_; 35 35 36 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, MultiType* mt1, MultiType* mt2, MultiType* mt3, MultiType* mt4, MultiType* mt5) 36 // Static calls 37 38 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID) 37 39 { 38 40 if(clientMap_.find(clientID)==clientMap_.end()) … … 41 43 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 42 44 } 43 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, mt1, mt2, mt3, mt4, mt5); 45 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID); 46 } 47 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1) 48 { 49 if(clientMap_.find(clientID)==clientMap_.end()) 50 { 51 FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 52 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 53 } 54 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1); 55 } 56 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2) 57 { 58 if(clientMap_.find(clientID)==clientMap_.end()) 59 { 60 FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 61 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 62 } 63 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2); 64 } 65 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) 66 { 67 if(clientMap_.find(clientID)==clientMap_.end()) 68 { 69 FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 70 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 71 } 72 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3); 73 } 74 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) 75 { 76 if(clientMap_.find(clientID)==clientMap_.end()) 77 { 78 FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 79 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 80 } 81 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4); 82 } 83 void FunctionCallManager::addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 84 { 85 if(clientMap_.find(clientID)==clientMap_.end()) 86 { 87 FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 88 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 89 } 90 FunctionCallManager:: clientMap_[clientID]->addCallStatic(functionID, &mt1, &mt2, &mt3, &mt4, &mt5); 44 91 } 45 92 46 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, MultiType* mt1, MultiType* mt2, MultiType* mt3, MultiType* mt4, MultiType* mt5) 93 94 // MemberCalls 95 96 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID) 47 97 { 48 98 if(clientMap_.find(clientID)==clientMap_.end()) … … 51 101 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 52 102 } 53 FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID , mt1, mt2, mt3, mt4, mt5);103 FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID); 54 104 } 105 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1) 106 { 107 if(clientMap_.find(clientID)==clientMap_.end()) 108 { 109 FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 110 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 111 } 112 FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1); 113 } 114 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2) 115 { 116 if(clientMap_.find(clientID)==clientMap_.end()) 117 { 118 FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 119 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 120 } 121 FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2); 122 } 123 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3) 124 { 125 if(clientMap_.find(clientID)==clientMap_.end()) 126 { 127 FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 128 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 129 } 130 FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3); 131 } 132 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4) 133 { 134 if(clientMap_.find(clientID)==clientMap_.end()) 135 { 136 FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 137 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 138 } 139 FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4); 140 } 141 void FunctionCallManager::addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5) 142 { 143 if(clientMap_.find(clientID)==clientMap_.end()) 144 { 145 FunctionCallManager::clientMap_[clientID] = new packet::FunctionCalls; 146 FunctionCallManager::clientMap_[clientID]->setClientID(clientID); 147 } 148 FunctionCallManager::clientMap_[clientID]->addCallMember(functionID, objectID, &mt1, &mt2, &mt3, &mt4, &mt5); 149 } 150 151 // Send calls 55 152 56 153 void FunctionCallManager::sendCalls() -
code/branches/netp2/src/network/FunctionCallManager.h
r2937 r2949 18 18 { 19 19 public: 20 static void addCallStatic(uint32_t functionID, uint32_t clientID, MultiType* mt1=0, MultiType* mt2=0, MultiType* mt3=0, MultiType* mt4=0, MultiType* mt5=0); 21 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, MultiType* mt1=0, MultiType* mt2=0, MultiType* mt3=0, MultiType* mt4=0, MultiType* mt5=0); 20 static void addCallStatic(uint32_t functionID, uint32_t clientID); 21 static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1); 22 static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2); 23 static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3); 24 static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4); 25 static void addCallStatic(uint32_t functionID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5); 26 27 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID); 28 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1); 29 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2); 30 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3); 31 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4); 32 static void addCallMember(uint32_t functionID, uint32_t objectID, uint32_t clientID, const MultiType& mt1, const MultiType& mt2, const MultiType& mt3, const MultiType& mt4, const MultiType& mt5); 33 22 34 static void sendCalls(); 23 35 -
code/branches/netp2/src/network/Server.cc
r2944 r2949 351 351 // now synchronise functionIDs 352 352 packet::FunctionIDs *fIDs = new packet::FunctionIDs(); 353 fIDs->setClientID(clientID); 353 354 bool b = fIDs->send(); 354 355 assert(b); -
code/branches/netp2/src/network/packet/FunctionCalls.cc
r2945 r2949 171 171 } 172 172 173 void FunctionCalls::addCallStatic( uint32_t networkID, MultiType* mt1, MultiType* mt2, MultiType* mt3, MultiType* mt4,MultiType* mt5){173 void FunctionCalls::addCallStatic( uint32_t networkID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){ 174 174 assert(!isDataENetAllocated()); 175 175 … … 245 245 } 246 246 247 void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, MultiType* mt1, MultiType* mt2, MultiType* mt3, MultiType* mt4,MultiType* mt5){247 void FunctionCalls::addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1, const MultiType* mt2, const MultiType* mt3, const MultiType* mt4, const MultiType* mt5){ 248 248 assert(!isDataENetAllocated()); 249 249 -
code/branches/netp2/src/network/packet/FunctionCalls.h
r2938 r2949 32 32 bool process(); 33 33 34 void addCallStatic( uint32_t networkID, MultiType* mt1=0, MultiType* mt2=0, MultiType* mt3=0, MultiType* mt4=0,MultiType* mt5=0);35 void addCallMember( uint32_t networkID, uint32_t objectID, MultiType* mt1=0, MultiType* mt2=0, MultiType* mt3=0, MultiType* mt4=0,MultiType* mt5=0);34 void addCallStatic( uint32_t networkID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0); 35 void addCallMember( uint32_t networkID, uint32_t objectID, const MultiType* mt1=0, const MultiType* mt2=0, const MultiType* mt3=0, const MultiType* mt4=0, const MultiType* mt5=0); 36 36 private: 37 37 uint32_t nrOfCalls_; -
code/branches/netp2/src/orxonox/objects/Test.cc
r2948 r2949 33 33 #include "network/NetworkFunction.h" 34 34 #include "Test.h" 35 #include "util/MultiType.h" 35 36 36 37 namespace orxonox … … 43 44 SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User); 44 45 SetConsoleCommand(Test, call, true).accessLevel(AccessLevel::User); 46 SetConsoleCommand(Test, call2, true).accessLevel(AccessLevel::User); 45 47 46 48 … … 51 53 registerStaticNetworkFunction( &Test::printV1 ); 52 54 registerMemberNetworkFunction( Test, checkU1 ); 55 registerMemberNetworkFunction( Test, printBlaBla ); 53 56 54 57 Test* Test::instance_ = 0; … … 102 105 } 103 106 107 void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4) 108 { 109 callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 ); 110 } 111 104 112 void Test::tick(float dt) 105 113 { 114 // std::string str1 = "blub"; 115 // //MultiType mt1(std::string("blub")); 116 // MultiType mt1(str1); 117 // uint8_t* mem = new uint8_t[mt1.getNetworkSize()]; 118 // uint8_t* temp = mem; 119 // mt1.exportData( temp ); 120 // assert( temp-mem == mt1.getNetworkSize() ); 121 // MultiType mt2; 122 // temp = mem; 123 // mt2.importData( temp ); 124 // assert( temp-mem == mt1.getNetworkSize() ); 125 // COUT(0) << mt2 << endl; 106 126 if(!Core::isMaster()) 107 callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 ); 108 // callMemberNetworkFunction( &Test::printV1, this->getObjectID(), 0); 127 call2(0, "bal", "a", "n", "ce"); 128 // callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 ); 129 } 130 131 void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5) 132 { 133 COUT(0) << s1 << s2 << s3 << s4 << s5 << endl; 109 134 } 110 135 -
code/branches/netp2/src/orxonox/objects/Test.h
r2948 r2949 52 52 53 53 static void call(unsigned int clientID); 54 void call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4); 54 55 virtual void tick(float dt); 55 56 … … 79 80 static void printV3(){ instance_->checkU3(); } 80 81 static void printV4(){ instance_->checkU4(); } 82 83 void printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5); 81 84 82 85 private: -
code/branches/netp2/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2836 r2949 39 39 #include "objects/worldentities/ParticleSpawner.h" 40 40 #include "objects/worldentities/ExplosionChunk.h" 41 #include "network/NetworkFunction.h" 41 42 42 43 namespace orxonox 43 44 { 44 45 CreateFactory(Pawn); 46 47 registerMemberNetworkFunction( Pawn, doFire ); 45 48 46 49 Pawn::Pawn(BaseObject* creator) : ControllableEntity(creator) … … 117 120 SUPER(Pawn, tick, dt); 118 121 119 if (this->weaponSystem_)120 {121 if (this->fire_ & WeaponMode::fire)122 this->weaponSystem_->fire(WeaponMode::fire);123 if (this->fire_ & WeaponMode::altFire)124 this->weaponSystem_->fire(WeaponMode::altFire);125 if (this->fire_ & WeaponMode::altFire2)126 this->weaponSystem_->fire(WeaponMode::altFire2);127 }128 this->fire_ = this->firehack_;129 this->firehack_ = 0x0;122 // if (this->weaponSystem_) 123 // { 124 // if (this->fire_ & WeaponMode::fire) 125 // this->weaponSystem_->fire(WeaponMode::fire); 126 // if (this->fire_ & WeaponMode::altFire) 127 // this->weaponSystem_->fire(WeaponMode::altFire); 128 // if (this->fire_ & WeaponMode::altFire2) 129 // this->weaponSystem_->fire(WeaponMode::altFire2); 130 // } 131 // this->fire_ = this->firehack_; 132 // this->firehack_ = 0x0; 130 133 131 134 if (Core::isMaster()) … … 256 259 void Pawn::fire(WeaponMode::Enum fireMode) 257 260 { 258 this->firehack_ |= fireMode; 261 doFire(fireMode); 262 } 263 264 void Pawn::doFire(uint8_t fireMode) 265 { 266 if(Core::isMaster()) 267 { 268 if (this->weaponSystem_) 269 this->weaponSystem_->fire((WeaponMode::Enum)fireMode); 270 } 271 else 272 { 273 callMemberNetworkFunction( Pawn, doFire, this->getObjectID(), 0, ((uint8_t)fireMode)); 274 if (this->weaponSystem_) 275 this->weaponSystem_->fire((WeaponMode::Enum)fireMode); 276 } 259 277 } 260 278 -
code/branches/netp2/src/orxonox/objects/worldentities/pawns/Pawn.h
r2826 r2949 80 80 81 81 virtual void fire(WeaponMode::Enum fireMode); 82 virtual void doFire(uint8_t fireMode); 82 83 virtual void postSpawn(); 83 84 -
code/branches/netp2/src/util/MultiType.h
r2937 r2949 80 80 enum MT_Type 81 81 { 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 106 106 }; 107 107 … … 326 326 327 327 /** @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); } 329 329 /** @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); } 331 331 /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */ 332 332 inline uint8_t*& operator << (uint8_t*& mem) { importData(mem); return mem; } 333 333 /** @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); } 336 336 337 337 /** @brief Checks whether the value is a default one. */
Note: See TracChangeset
for help on using the changeset viewer.