Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 23, 2009, 6:02:25 PM (15 years ago)
Author:
scheusso
Message:

merged netp5 back to trunk

Location:
code/trunk/src/network/packet
Files:
18 edited

Legend:

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

    r3198 r3214  
    2727 */
    2828
     29#include "Acknowledgement.h"
    2930
    30 #include "Acknowledgement.h"
    31 #include "network/Host.h"
     31#include "util/Debug.h"
    3232#include "network/GamestateHandler.h"
    33 #include "core/CoreIncludes.h"
    3433
    3534namespace orxonox {
  • code/trunk/src/network/packet/Acknowledgement.h

    r2662 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKACKNOLEDGEMENT_H
    29 #define NETWORKACKNOLEDGEMENT_H
    3028
    31 #include "../NetworkPrereqs.h"
     29#ifndef _Acknowledgement_H__
     30#define _Acknowledgement_H__
     31
     32#include "network/NetworkPrereqs.h"
    3233#include "Packet.h"
    3334
     35namespace orxonox {
    3436const unsigned int ACKID_NACK = 0;
    35 
    36 namespace orxonox {
    3737namespace packet {
    3838/**
     
    5656} //namespace orxonox
    5757
    58 #endif
     58#endif /* _Acknowledgement_H__ */
  • code/trunk/src/network/packet/Chat.cc

    r2773 r3214  
    2929#include "Chat.h"
    3030
    31 #include <enet/enet.h>
    32 #include <cassert>
     31#include <cstring>
     32#include <string>
    3333#include "network/Host.h"
    3434
     
    3636namespace packet {
    3737 
    38 #define   PACKET_FLAGS_CHAT ENET_PACKET_FLAG_RELIABLE
     38#define   PACKET_FLAGS_CHAT PacketFlag::Reliable
    3939#define   _PACKETID         0
    4040const int _PLAYERID     =   _PACKETID + sizeof(ENUM::Type);
     
    4242#define   _MESSAGE          _MESSAGELENGTH + sizeof(uint32_t)
    4343
    44 Chat::Chat( std::string message, unsigned int playerID )
     44Chat::Chat( const std::string& message, unsigned int playerID )
    4545 : Packet()
    4646{
  • code/trunk/src/network/packet/Chat.h

    r2171 r3214  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
    128
    2 #ifndef NETWORKCHAT_H
    3 #define NETWORKCHAT_H
     29#ifndef _NETWORK_Chat_H__
     30#define _NETWORK_Chat_H__
    431
    5 #include "../NetworkPrereqs.h"
    6 
    7 #include <string>
    8 #include <cstring>
    9 
     32#include "network/NetworkPrereqs.h"
    1033#include "Packet.h"
    1134
     
    1841{
    1942public:
    20   Chat( std::string message, unsigned int playerID );
     43  Chat( const std::string& message, unsigned int playerID );
    2144  Chat( uint8_t* data, unsigned int clientID );
    2245  ~Chat();
     
    3558} //namespace orxonox
    3659
    37 #endif
     60#endif /* _NETWORK_Chat_H__ */
  • code/trunk/src/network/packet/ClassID.cc

    r3084 r3214  
    2727 */
    2828
     29#include "ClassID.h"
    2930
    30 
    31 #include "ClassID.h"
    32 #include <enet/enet.h>
    33 #include "core/CoreIncludes.h"
    34 #include "core/Factory.h"
     31#include <cassert>
     32#include <cstdlib>
    3533#include <cstring>
    36 #include <string>
    37 #include <cassert>
    3834#include <map>
    3935#include <queue>
     36#include <string>
     37
     38#include "core/CoreIncludes.h"
    4039
    4140namespace orxonox {
     
    4342
    4443
    45 #define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
     44#define PACKET_FLAGS_CLASSID  PacketFlag::Reliable
    4645#define _PACKETID             0
    4746
  • code/trunk/src/network/packet/ClassID.h

    r2759 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKCLASSID_H
    29 #define NETWORKCLASSID_H
    3028
    31 #include "../NetworkPrereqs.h"
     29#ifndef _NETWORK_ClassID_H__
     30#define _NETWORK_ClassID_H__
    3231
    33 #include <string>
    34 
     32#include "network/NetworkPrereqs.h"
    3533#include "Packet.h"
    3634
     
    5856} //namespace orxonox
    5957
    60 #endif
     58#endif /* _NETWORK_ClassID_H__ */
  • code/trunk/src/network/packet/DeleteObjects.cc

    r2773 r3214  
    2929
    3030#include "DeleteObjects.h"
    31 #include <enet/enet.h>
     31
     32#include <cassert>
     33#include "util/Debug.h"
    3234#include "network/synchronisable/Synchronisable.h"
    33 #include "core/CoreIncludes.h"
    34 #include <cassert>
    3535
    3636namespace orxonox {
    3737namespace packet {
    3838
    39 #define PACKET_FLAG_DELETE  ENET_PACKET_FLAG_RELIABLE
     39#define PACKET_FLAG_DELETE  PacketFlag::Reliable
    4040#define _PACKETID           0
    4141#define _QUANTITY           _PACKETID + sizeof(ENUM::Type)
     
    9090    Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) );
    9191  }
     92  delete this;
    9293  return true;
    9394}
  • code/trunk/src/network/packet/DeleteObjects.h

    r2171 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKPACKETDELETEOBJECTS_H
    29 #define NETWORKPACKETDELETEOBJECTS_H
     28#ifndef _DeleteObjects_H__
     29#define _DeleteObjects_H__
    3030
    31 #include "../NetworkPrereqs.h"
    32 
     31#include "network/NetworkPrereqs.h"
    3332#include "Packet.h"
    34 
    3533
    3634namespace orxonox {
     
    5755} //namespace orxonox
    5856
    59 #endif
     57#endif /* _DeleteObjects_H__ */
  • code/trunk/src/network/packet/FunctionCalls.cc

    r3084 r3214  
    2929#include "FunctionCalls.h"
    3030
    31 #include <enet/enet.h>
    3231#include <cassert>
    3332#include <cstring>
    34 #include "network/Host.h"
     33#include "util/MultiType.h"
    3534#include "network/NetworkFunction.h"
    36 #include "util/MultiType.h"
    3735
    3836namespace orxonox {
    3937namespace packet {
    4038 
    41 #define   PACKET_FLAGS_FUNCTIONCALLS ENET_PACKET_FLAG_RELIABLE
     39#define   PACKET_FLAGS_FUNCTIONCALLS PacketFlag::Reliable
    4240#define   _PACKETID         0
    4341const unsigned int FUNCTIONCALLS_MEM_ALLOCATION = 1000;
  • code/trunk/src/network/packet/FunctionCalls.h

    r3084 r3214  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Oliver Scheuss <scheusso [at] ee.ethz.ch>
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
    128
    2 #ifndef NETWORKFUNCTIONCALLS_H
    3 #define NETWORKFUNCTIONCALLS_H
     29#ifndef _FunctionCalls_H__
     30#define _FunctionCalls_H__
    431
    5 #include "../NetworkPrereqs.h"
     32#include "network/NetworkPrereqs.h"
    633
    7 #include <string>
    8 #include <cstring>
    9 
     34#include <cassert>
     35#include "util/UtilPrereqs.h"
    1036#include "Packet.h"
    11 #include <cassert>
    1237
    1338namespace orxonox {
    14 
    15 class MultiType;
    1639
    1740namespace packet {
     
    4467} //namespace orxonox
    4568
    46 #endif
     69#endif /* _FunctionCalls_H__ */
  • code/trunk/src/network/packet/FunctionIDs.cc

    r3084 r3214  
    2727 */
    2828
     29#include "FunctionIDs.h"
    2930
     31#include <cassert>
     32#include <cstring>
     33#include <queue>
     34#include <string>
    3035
    31 #include "FunctionIDs.h"
     36#include "util/Debug.h"
     37#include "core/ObjectList.h"
    3238#include "network/NetworkFunction.h"
    33 #include <enet/enet.h>
    34 #include "core/CoreIncludes.h"
    35 #include <string>
    36 #include <cassert>
    37 #include <queue>
    3839
    3940namespace orxonox {
     
    4142
    4243
    43 #define PACKET_FLAGS_FUNCTIONIDS  ENET_PACKET_FLAG_RELIABLE
     44#define PACKET_FLAGS_FUNCTIONIDS  PacketFlag::Reliable
    4445#define _PACKETID                 0
    4546
  • code/trunk/src/network/packet/FunctionIDs.h

    r3084 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKFUNCTIONIDS_H
    29 #define NETWORKFUNCTIONIDS_H
    3028
    31 #include "../NetworkPrereqs.h"
     29#ifndef _FunctionIDs_H__
     30#define _FunctionIDs_H__
    3231
    33 #include <string>
    34 
     32#include "network/NetworkPrereqs.h"
    3533#include "Packet.h"
    3634
     
    5856} //namespace orxonox
    5957
    60 #endif
     58#endif /* _FunctionIDs_H__ */
  • code/trunk/src/network/packet/Gamestate.cc

    r3198 r3214  
    2828
    2929#include "Gamestate.h"
    30 #include <enet/enet.h>
     30
    3131#include <zlib.h>
    32 #include <cassert>
    33 #include "../GamestateHandler.h"
    34 #include "../synchronisable/Synchronisable.h"
    35 #include "../TrafficControl.h"
     32
     33#include "util/Debug.h"
    3634#include "core/GameMode.h"
    37 #include "core/CoreIncludes.h"
    38 
    39 
    40 
     35#include "core/ObjectList.h"
     36#include "network/synchronisable/Synchronisable.h"
     37#include "network/GamestateHandler.h"
    4138
    4239namespace orxonox {
     
    4643#define GAMESTATE_START(data) (data + GamestateHeader::getSize())
    4744
    48 #define PACKET_FLAG_GAMESTATE  ENET_PACKET_FLAG_RELIABLE
     45#define PACKET_FLAG_GAMESTATE  PacketFlag::Reliable
    4946
    5047
  • code/trunk/src/network/packet/Gamestate.h

    r3198 r3214  
    2828
    2929
    30 #ifndef NETWORK_PACKETGAMESTATE_H
    31 #define NETWORK_PACKETGAMESTATE_H
     30#ifndef _Gamestate_H__
     31#define _Gamestate_H__
    3232
    3333#include "network/NetworkPrereqs.h"
    3434
     35#include <cassert>
     36#include <cstring>
     37#include <list>
     38
     39#include "util/CRC32.h"
     40#include "network/TrafficControl.h"
    3541#include "Packet.h"
    36 #include "network/TrafficControl.h"
    37 #include <string.h>
    38 #include <map>
    39 #include <vector>
    40 #include <cassert>
    41 #ifndef NDEBUG
    42 #include "util/CRC32.h"
    43 #endif
    4442
    4543namespace orxonox {
     
    138136}
    139137
    140 #endif
     138#endif /* _Gamestate_H__ */
  • code/trunk/src/network/packet/Packet.cc

    r3097 r3214  
    3131
    3232#include <cassert>
     33#include <cstring>
    3334#include <enet/enet.h>
    34 #include <boost/bind.hpp>
    35 #include <boost/thread/recursive_mutex.hpp>
    36 
    37 #include "network/ConnectionManager.h"
    38 #include "network/ClientInformation.h"
    39 
     35#include <boost/static_assert.hpp>
     36
     37#include "util/Debug.h"
    4038#include "Acknowledgement.h"
    41 #include "DeleteObjects.h"
    4239#include "Chat.h"
    4340#include "ClassID.h"
     41#include "DeleteObjects.h"
    4442#include "FunctionCalls.h"
    4543#include "FunctionIDs.h"
     
    4745#include "Welcome.h"
    4846#include "network/Host.h"
    49 #include "core/CoreIncludes.h"
     47#include "network/ClientInformation.h"
    5048
    5149namespace orxonox{
     
    5351namespace packet{
    5452
    55 #define PACKET_FLAG_DEFAULT ENET_PACKET_FLAG_NO_ALLOCATE
     53// Make sure we assume the right values
     54BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Reliable)   == static_cast<int>(ENET_PACKET_FLAG_RELIABLE));
     55BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Unsequence) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED));
     56BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::NoAllocate) == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE));
     57
     58#define PACKET_FLAG_DEFAULT PacketFlag::NoAllocate
    5659#define _PACKETID           0
    5760
    5861std::map<size_t, Packet *> Packet::packetMap_;
    59 //! Static mutex for any packetMap_ access
    60 static boost::recursive_mutex packetMap_mutex_g;
    6162
    6263Packet::Packet(){
     
    108109  }
    109110  else if (this->data_) {
    110     // This destructor was probably called as a consequence to ENet executing our callback.
     111    // This destructor was probably called as a consequence of ENet executing our callback.
    111112    // It simply serves us to be able to deallocate the packet content (data_) ourselves since
    112113    // we have created it in the first place.
     
    142143      // Assures we don't create a packet and destroy it right after in another thread
    143144      // without having a reference in the packetMap_
    144       boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g);
    145145      packetMap_[(size_t)(void*)enetPacket_] = this;
    146146    }
     
    218218  // Data was created by ENet
    219219  p->bDataENetAllocated_ = true;
     220  p->enetPacket_ = packet;
    220221
    221222  return p;
     
    228229*/
    229230void Packet::deletePacket(ENetPacket *enetPacket){
    230   boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g);
    231231  // Get our Packet from a gloabal map with all Packets created in the send() method of Packet.
    232232  std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket);
     
    236236  delete it->second;
    237237  packetMap_.erase(it);
    238   COUT(4) << "PacketMap size: " << packetMap_.size() << std::endl;
     238  COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl;
    239239}
    240240
  • code/trunk/src/network/packet/Packet.h

    r3084 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKPACKET_H
    29 #define NETWORKPACKET_H
     28#ifndef _NETWORK_Packet_H__
     29#define _NETWORK_Packet_H__
    3030
    3131#include "network/NetworkPrereqs.h"
    32 
    3332#include <map>
    3433
     
    102101} //namespace orxonox
    103102
    104 #endif
     103#endif /* _NETWORK_Packet_H__ */
  • code/trunk/src/network/packet/Welcome.cc

    r2773 r3214  
    2929 */
    3030
     31#include "Welcome.h"
    3132
    32 #include "Welcome.h"
    33 #include <enet/enet.h>
    3433#include <cassert>
     34#include "util/Debug.h"
    3535#include "network/Host.h"
    3636#include "network/synchronisable/Synchronisable.h"
    37 #include "core/CoreIncludes.h"
    3837
    3938namespace orxonox {
    4039namespace packet {
    4140
    42 #define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
     41#define PACKET_FLAGS_CLASSID  PacketFlag::Reliable
    4342#define _PACKETID             0
    4443#define _CLIENTID             _PACKETID + sizeof(ENUM::Type)
  • code/trunk/src/network/packet/Welcome.h

    r2662 r3214  
    2626 *
    2727 */
    28 #ifndef NETWORKWELCOME_H
    29 #define NETWORKWELCOME_H
     28#ifndef _NETWORK_Welcome_H__
     29#define _NETWORK_Welcome_H__
    3030
    31 #include "../NetworkPrereqs.h"
    32 
     31#include "network/NetworkPrereqs.h"
    3332#include "Packet.h"
    3433
     
    5655} //namespace orxonox
    5756
    58 #endif
     57#endif /* _NETWORK_Welcome_H__ */
Note: See TracChangeset for help on using the changeset viewer.