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/packet
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/network/packet/Chat.cc

    r3280 r3301  
    5151  *(unsigned int *)(data_ + _PLAYERID ) = playerID;
    5252  *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_;
    53   memcpy( data_+_MESSAGE, (void *)message.c_str(), messageLength_ );
     53  memcpy( data_+_MESSAGE, static_cast<void*>(const_cast<char*>(message.c_str())), messageLength_ );
    5454}
    5555
  • code/trunk/src/network/packet/Packet.cc

    r3280 r3301  
    143143      // Assures we don't create a packet and destroy it right after in another thread
    144144      // without having a reference in the packetMap_
    145       packetMap_[(size_t)(void*)enetPacket_] = this;
     145      packetMap_[reinterpret_cast<size_t>(enetPacket_)] = this;
    146146    }
    147147  }
     
    172172Packet *Packet::createPacket(ENetPacket *packet, ENetPeer *peer){
    173173  uint8_t *data = packet->data;
    174   assert(ClientInformation::findClient(&peer->address)->getID() != (unsigned int)-2 || !Host::isServer());
     174  assert(ClientInformation::findClient(&peer->address)->getID() != static_cast<unsigned int>(-2) || !Host::isServer());
    175175  unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
    176176  Packet *p = 0;
     
    230230void Packet::deletePacket(ENetPacket *enetPacket){
    231231  // Get our Packet from a gloabal map with all Packets created in the send() method of Packet.
    232   std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket);
     232  std::map<size_t, Packet*>::iterator it = packetMap_.find(reinterpret_cast<size_t>(enetPacket));
    233233  assert(it != packetMap_.end());
    234234  // Make sure we don't delete it again in the destructor
Note: See TracChangeset for help on using the changeset viewer.