Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 18, 2009, 4:03:59 PM (15 years ago)
Author:
rgrieder
Message:

Found even more casts. They sure aren't all of them, but I hope to have caught every pointer C-style cast because they can be very dangerous.
Note: I didn't do the pointer casts in the network library because that would have taken way too long.

Location:
code/trunk/src/network/synchronisable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/network/synchronisable/Synchronisable.h

    r3280 r3301  
    4444
    4545/*#define REGISTERDATA(varname, ...) \
    46     registerVariable((void*)&varname, sizeof(varname), DATA, __VA_ARGS__)
     46    registerVariable(static_cast<void*>(&varname), sizeof(varname), DATA, __VA_ARGS__)
    4747#define REGISTERSTRING(stringname, ...) \
    4848    registerVariable(&stringname, stringname.length()+1, STRING, __VA_ARGS__)*/
  • code/trunk/src/network/synchronisable/SynchronisableVariable.h

    r3280 r3301  
    3636#include <cstring>
    3737#include "util/Serialise.h"
     38#include "util/TemplateUtils.h"
    3839#include "core/GameMode.h"
    3940#include "network/synchronisable/NetworkCallbackManager.h"
     
    7879      virtual inline void putData(uint8_t*& mem, uint8_t mode, bool forceCallback = false);
    7980      virtual inline uint32_t getSize(uint8_t mode);
    80       virtual inline void* getReference(){ return (void *)&this->variable_; }
     81      virtual inline void* getReference(){ return static_cast<void*>(const_cast<typename TypeStripper<T>::RawType*>(&this->variable_)); }
    8182    protected:
    8283     
     
    178179        {
    179180          this->varReference_++;
    180           memcpy((void*)&this->varBuffer_, &this->variable_, sizeof(this->variable_));
     181          memcpy(static_cast<void*>(const_cast<typename TypeStripper<T>::RawType*>(&this->varBuffer_)), &this->variable_, sizeof(this->variable_));
    181182        }
    182183      }
     
    211212          {
    212213            mem += sizeof(varReference_);
    213             memcpy((void*)&this->varBuffer_, &this->variable_, sizeof(T));
     214            memcpy(static_cast<void*>(const_cast<typename TypeStripper<T>::RawType*>(&this->varBuffer_)), &this->variable_, sizeof(T));
    214215            if ( this->callback_ != 0 )
    215216              callback = true;
Note: See TracChangeset for help on using the changeset viewer.