Changeset 11083 for code/trunk/src/libraries
- Timestamp:
- Jan 21, 2016, 1:59:04 PM (9 years ago)
- Location:
- code/trunk/src/libraries
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/libraries/core/GUIManager.cc
r11071 r11083 104 104 #include "util/OrxAssert.h" 105 105 #include "util/output/BaseWriter.h" 106 #include "util/StringUtils.h" 107 #include "util/SubString.h" 106 108 #include "config/ConfigValueIncludes.h" 107 109 #include "Core.h" -
code/trunk/src/libraries/core/class/SubclassIdentifier.h
r11071 r11083 92 92 public: 93 93 /// Constructor: Automaticaly assigns the Identifier of the given class. 94 SubclassIdentifier() 94 SubclassIdentifier() : identifier_(nullptr) 95 95 { 96 96 this->identifier_ = ClassIdentifier<T>::getIdentifier(); … … 98 98 99 99 /// Constructor: Assigns the given Identifier. 100 SubclassIdentifier(Identifier* identifier) 100 SubclassIdentifier(Identifier* identifier) : identifier_(nullptr) 101 101 { 102 102 this->operator=(identifier); … … 105 105 /// Copyconstructor: Assigns the identifier of another SubclassIdentifier. 106 106 template <class O> 107 SubclassIdentifier(const SubclassIdentifier<O>& identifier) 107 SubclassIdentifier(const SubclassIdentifier<O>& identifier) : identifier_(nullptr) 108 108 { 109 109 this->operator=(identifier.getIdentifier()); -
code/trunk/src/libraries/core/input/KeyBinder.cc
r11071 r11083 67 67 for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++) 68 68 { 69 const std::string &keyname = KeyCode::ByString[i];69 const std::string keyname = KeyCode::ByString[i]; 70 70 if (!keyname.empty()) 71 71 keys_[i].name_ = std::string("Key") + keyname; -
code/trunk/src/libraries/network/MasterServer.cc
r11071 r11083 253 253 /* convert to string */ 254 254 std::string ip = std::string( addrconv ); 255 /* output debug info about the data that has come */ 256 helper_output_debug(event, addrconv); 255 257 /* delete addrconv */ 256 258 if( addrconv ) free( addrconv ); … … 259 261 char * packetdata = (char *)event->packet->data; 260 262 261 /* output debug info about the data that has come */262 helper_output_debug( event, addrconv );263 263 264 264 /* GAME SERVER OR CLIENT CONNECTION? */ … … 332 332 { 333 333 /***** ENTER MAIN LOOP *****/ 334 ENetEvent *event = (ENetEvent *)calloc( sizeof(ENetEvent), sizeof(char));334 ENetEvent *event = (ENetEvent *)calloc(1, sizeof(ENetEvent)); 335 335 if( event == nullptr ) 336 336 { -
code/trunk/src/libraries/network/packet/Gamestate.cc
r11071 r11083 489 489 Gamestate* Gamestate::diffVariables(Gamestate *base) 490 490 { 491 assert( this &&base); assert(data_ && base->data_);491 assert(base); assert(data_ && base->data_); 492 492 assert(!header_.isCompressed() && !base->header_.isCompressed()); 493 493 assert(!header_.isDiffed()); -
code/trunk/src/libraries/network/packet/ServerInformation.cc
r11071 r11083 55 55 // Save ACK 56 56 uint8_t* temp = event->packet->data; 57 char* ack = n ew char[strlen(LAN_DISCOVERY_ACK)+1];57 char* ack = nullptr; 58 58 loadAndIncrease((char*&)ack, temp); 59 59 … … 64 64 // Save Server Name 65 65 loadAndIncrease(this->serverName_, temp); 66 delete[] ack; 66 67 } 67 68 … … 74 75 { 75 76 std::string payload = this->serverName_ + Ogre::StringConverter::toString(this->clientNumber_); 76 uint32_t size = returnSize( (char*&)LAN_DISCOVERY_ACK) + returnSize(payload);77 uint32_t size = returnSize(LAN_DISCOVERY_ACK) + returnSize(payload); 77 78 uint8_t* temp = new uint8_t[size]; 78 79 uint8_t* temp2 = temp; 79 saveAndIncrease( (char*&)LAN_DISCOVERY_ACK, temp2);80 saveAndIncrease(LAN_DISCOVERY_ACK, temp2); 80 81 saveAndIncrease(payload, temp2); 81 82 ENetPacket* packet = enet_packet_create( temp, size, 0 ); -
code/trunk/src/libraries/util/Serialise.h
r11071 r11083 48 48 template <class T> inline uint32_t returnSize( const T& variable ); 49 49 /** @brief loads the value of a variable out of the bytestream and increases the mem pointer */ 50 template <class T> inline void loadAndIncrease( constT& variable, uint8_t*& mem );50 template <class T> inline void loadAndIncrease( T& variable, uint8_t*& mem ); 51 51 /** @brief saves the value of a variable into the bytestream and increases the mem pointer */ 52 52 template <class T> inline void saveAndIncrease( const T& variable, uint8_t*& mem ); … … 57 57 // =========== char* 58 58 59 inline uint32_t returnSize( char*& variable )59 inline uint32_t returnSize(const char*& variable ) 60 60 { 61 61 return strlen(variable)+1; 62 62 } 63 63 64 inline void saveAndIncrease( char*& variable, uint8_t*& mem )64 inline void saveAndIncrease(const char*& variable, uint8_t*& mem ) 65 65 { 66 strcpy((char*)mem, variable); 67 mem += returnSize(variable); 66 uint32_t len = returnSize(variable); 67 std::memcpy(mem, variable, len); 68 mem += len; 68 69 } 69 70 … … 72 73 if( variable ) 73 74 delete variable; 74 uint32_t len = strlen((char*)mem)+1;75 uint32_t len = returnSize((const char*&)mem); 75 76 variable = new char[len]; 76 st rcpy((char*)variable, (char*)mem);77 std::memcpy(variable, mem, len); 77 78 mem += len; 78 79 } … … 92 93 } 93 94 94 template <> inline void loadAndIncrease( constbool& variable, uint8_t*& mem )95 template <> inline void loadAndIncrease( bool& variable, uint8_t*& mem ) 95 96 { 96 97 *(uint8_t*)( &variable ) = *static_cast<uint8_t*>(mem); … … 116 117 } 117 118 118 template <> inline void loadAndIncrease( c onst char& variable, uint8_t*& mem )119 template <> inline void loadAndIncrease( char& variable, uint8_t*& mem ) 119 120 { 120 121 *(uint8_t*)( &variable ) = *static_cast<uint8_t*>(mem); … … 140 141 } 141 142 142 template <> inline void loadAndIncrease( constunsigned char& variable, uint8_t*& mem )143 template <> inline void loadAndIncrease( unsigned char& variable, uint8_t*& mem ) 143 144 { 144 145 *(uint8_t*)( &variable ) = *static_cast<uint8_t*>(mem); … … 164 165 } 165 166 166 template <> inline void loadAndIncrease( constshort& variable, uint8_t*& mem )167 template <> inline void loadAndIncrease( short& variable, uint8_t*& mem ) 167 168 { 168 169 *(short*)( &variable ) = *(int16_t*)(mem); … … 188 189 } 189 190 190 template <> inline void loadAndIncrease( constunsigned short& variable, uint8_t*& mem )191 template <> inline void loadAndIncrease( unsigned short& variable, uint8_t*& mem ) 191 192 { 192 193 *(unsigned short*)( &variable ) = *(uint16_t*)(mem); … … 212 213 } 213 214 214 template <> inline void loadAndIncrease( constint& variable, uint8_t*& mem )215 template <> inline void loadAndIncrease( int& variable, uint8_t*& mem ) 215 216 { 216 217 *(int *)( &variable ) = *(int32_t*)(mem); … … 236 237 } 237 238 238 template <> inline void loadAndIncrease( constunsigned int& variable, uint8_t*& mem )239 template <> inline void loadAndIncrease( unsigned int& variable, uint8_t*& mem ) 239 240 { 240 241 *(unsigned int*)( &variable ) = *(uint32_t*)(mem); … … 260 261 } 261 262 262 template <> inline void loadAndIncrease( constlong& variable, uint8_t*& mem )263 template <> inline void loadAndIncrease( long& variable, uint8_t*& mem ) 263 264 { 264 265 *(long*)( &variable ) = *(int32_t*)(mem); … … 284 285 } 285 286 286 template <> inline void loadAndIncrease( constunsigned long& variable, uint8_t*& mem )287 template <> inline void loadAndIncrease( unsigned long& variable, uint8_t*& mem ) 287 288 { 288 289 *(unsigned long*)( &variable ) = *(uint32_t*)(mem); … … 308 309 } 309 310 310 template <> inline void loadAndIncrease( constlong long& variable, uint8_t*& mem )311 template <> inline void loadAndIncrease( long long& variable, uint8_t*& mem ) 311 312 { 312 313 *(long long*)( &variable ) = *(int64_t*)(mem); … … 332 333 } 333 334 334 template <> inline void loadAndIncrease( constunsigned long long& variable, uint8_t*& mem )335 template <> inline void loadAndIncrease( unsigned long long& variable, uint8_t*& mem ) 335 336 { 336 337 *(unsigned long long*)( &variable ) = *(uint64_t*)(mem); … … 356 357 } 357 358 358 template <> inline void loadAndIncrease( constfloat& variable, uint8_t*& mem )359 template <> inline void loadAndIncrease( float& variable, uint8_t*& mem ) 359 360 { 360 361 *(uint32_t*)( &variable ) = *(uint32_t*)(mem); … … 380 381 } 381 382 382 template <> inline void loadAndIncrease( constdouble& variable, uint8_t*& mem )383 template <> inline void loadAndIncrease( double& variable, uint8_t*& mem ) 383 384 { 384 385 *(uint64_t*)( &variable ) = *(uint64_t*)(mem); … … 404 405 } 405 406 406 template <> inline void loadAndIncrease( constlong double& variable, uint8_t*& mem )407 template <> inline void loadAndIncrease( long double& variable, uint8_t*& mem ) 407 408 { 408 409 double temp; … … 438 439 } 439 440 440 template <> inline void loadAndIncrease( conststd::string& variable, uint8_t*& mem )441 template <> inline void loadAndIncrease( std::string& variable, uint8_t*& mem ) 441 442 { 442 443 *(std::string*)( &variable ) = (const char *)mem; … … 464 465 } 465 466 466 template <> inline void loadAndIncrease( constDegree& variable, uint8_t*& mem )467 template <> inline void loadAndIncrease( Degree& variable, uint8_t*& mem ) 467 468 { 468 469 Ogre::Real* r = (Ogre::Real*)mem; … … 491 492 } 492 493 493 template <> inline void loadAndIncrease( constRadian& variable, uint8_t*& mem )494 template <> inline void loadAndIncrease( Radian& variable, uint8_t*& mem ) 494 495 { 495 496 Ogre::Real* r = (Ogre::Real*)mem; … … 517 518 } 518 519 519 template <> inline void loadAndIncrease( constVector2& variable, uint8_t*& mem )520 template <> inline void loadAndIncrease( Vector2& variable, uint8_t*& mem ) 520 521 { 521 522 loadAndIncrease( variable.x, mem ); … … 542 543 } 543 544 544 template <> inline void loadAndIncrease( constVector3& variable, uint8_t*& mem )545 template <> inline void loadAndIncrease( Vector3& variable, uint8_t*& mem ) 545 546 { 546 547 loadAndIncrease( variable.x, mem ); … … 570 571 } 571 572 572 template <> inline void loadAndIncrease( constVector4& variable, uint8_t*& mem )573 template <> inline void loadAndIncrease( Vector4& variable, uint8_t*& mem ) 573 574 { 574 575 loadAndIncrease( variable.w, mem ); … … 600 601 } 601 602 602 template <> inline void loadAndIncrease( constQuaternion& variable, uint8_t*& mem )603 template <> inline void loadAndIncrease( Quaternion& variable, uint8_t*& mem ) 603 604 { 604 605 loadAndIncrease( variable.w, mem ); … … 630 631 } 631 632 632 template <> inline void loadAndIncrease( constColourValue& variable, uint8_t*& mem )633 template <> inline void loadAndIncrease( ColourValue& variable, uint8_t*& mem ) 633 634 { 634 635 loadAndIncrease( variable.r, mem ); … … 657 658 } 658 659 659 template <> inline void loadAndIncrease( constmbool& variable, uint8_t*& mem )660 template <> inline void loadAndIncrease( mbool& variable, uint8_t*& mem ) 660 661 { 661 662 loadAndIncrease( (unsigned char&)((mbool&)variable).getMemory(), mem );
Note: See TracChangeset
for help on using the changeset viewer.