Changeset 3214 for code/trunk/src/network/packet
- Timestamp:
- Jun 23, 2009, 6:02:25 PM (15 years ago)
- Location:
- code/trunk/src/network/packet
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/network/packet/Acknowledgement.cc
r3198 r3214 27 27 */ 28 28 29 #include "Acknowledgement.h" 29 30 30 #include "Acknowledgement.h" 31 #include "network/Host.h" 31 #include "util/Debug.h" 32 32 #include "network/GamestateHandler.h" 33 #include "core/CoreIncludes.h"34 33 35 34 namespace orxonox { -
code/trunk/src/network/packet/Acknowledgement.h
r2662 r3214 26 26 * 27 27 */ 28 #ifndef NETWORKACKNOLEDGEMENT_H29 #define NETWORKACKNOLEDGEMENT_H30 28 31 #include "../NetworkPrereqs.h" 29 #ifndef _Acknowledgement_H__ 30 #define _Acknowledgement_H__ 31 32 #include "network/NetworkPrereqs.h" 32 33 #include "Packet.h" 33 34 35 namespace orxonox { 34 36 const unsigned int ACKID_NACK = 0; 35 36 namespace orxonox {37 37 namespace packet { 38 38 /** … … 56 56 } //namespace orxonox 57 57 58 #endif 58 #endif /* _Acknowledgement_H__ */ -
code/trunk/src/network/packet/Chat.cc
r2773 r3214 29 29 #include "Chat.h" 30 30 31 #include < enet/enet.h>32 #include < cassert>31 #include <cstring> 32 #include <string> 33 33 #include "network/Host.h" 34 34 … … 36 36 namespace packet { 37 37 38 #define PACKET_FLAGS_CHAT ENET_PACKET_FLAG_RELIABLE38 #define PACKET_FLAGS_CHAT PacketFlag::Reliable 39 39 #define _PACKETID 0 40 40 const int _PLAYERID = _PACKETID + sizeof(ENUM::Type); … … 42 42 #define _MESSAGE _MESSAGELENGTH + sizeof(uint32_t) 43 43 44 Chat::Chat( std::stringmessage, unsigned int playerID )44 Chat::Chat( const std::string& message, unsigned int playerID ) 45 45 : Packet() 46 46 { -
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 */ 1 28 2 #ifndef NETWORKCHAT_H3 #define NETWORKCHAT_H29 #ifndef _NETWORK_Chat_H__ 30 #define _NETWORK_Chat_H__ 4 31 5 #include "../NetworkPrereqs.h" 6 7 #include <string> 8 #include <cstring> 9 32 #include "network/NetworkPrereqs.h" 10 33 #include "Packet.h" 11 34 … … 18 41 { 19 42 public: 20 Chat( std::stringmessage, unsigned int playerID );43 Chat( const std::string& message, unsigned int playerID ); 21 44 Chat( uint8_t* data, unsigned int clientID ); 22 45 ~Chat(); … … 35 58 } //namespace orxonox 36 59 37 #endif 60 #endif /* _NETWORK_Chat_H__ */ -
code/trunk/src/network/packet/ClassID.cc
r3084 r3214 27 27 */ 28 28 29 #include "ClassID.h" 29 30 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> 35 33 #include <cstring> 36 #include <string>37 #include <cassert>38 34 #include <map> 39 35 #include <queue> 36 #include <string> 37 38 #include "core/CoreIncludes.h" 40 39 41 40 namespace orxonox { … … 43 42 44 43 45 #define PACKET_FLAGS_CLASSID ENET_PACKET_FLAG_RELIABLE44 #define PACKET_FLAGS_CLASSID PacketFlag::Reliable 46 45 #define _PACKETID 0 47 46 -
code/trunk/src/network/packet/ClassID.h
r2759 r3214 26 26 * 27 27 */ 28 #ifndef NETWORKCLASSID_H29 #define NETWORKCLASSID_H30 28 31 #include "../NetworkPrereqs.h" 29 #ifndef _NETWORK_ClassID_H__ 30 #define _NETWORK_ClassID_H__ 32 31 33 #include <string> 34 32 #include "network/NetworkPrereqs.h" 35 33 #include "Packet.h" 36 34 … … 58 56 } //namespace orxonox 59 57 60 #endif 58 #endif /* _NETWORK_ClassID_H__ */ -
code/trunk/src/network/packet/DeleteObjects.cc
r2773 r3214 29 29 30 30 #include "DeleteObjects.h" 31 #include <enet/enet.h> 31 32 #include <cassert> 33 #include "util/Debug.h" 32 34 #include "network/synchronisable/Synchronisable.h" 33 #include "core/CoreIncludes.h"34 #include <cassert>35 35 36 36 namespace orxonox { 37 37 namespace packet { 38 38 39 #define PACKET_FLAG_DELETE ENET_PACKET_FLAG_RELIABLE39 #define PACKET_FLAG_DELETE PacketFlag::Reliable 40 40 #define _PACKETID 0 41 41 #define _QUANTITY _PACKETID + sizeof(ENUM::Type) … … 90 90 Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) ); 91 91 } 92 delete this; 92 93 return true; 93 94 } -
code/trunk/src/network/packet/DeleteObjects.h
r2171 r3214 26 26 * 27 27 */ 28 #ifndef NETWORKPACKETDELETEOBJECTS_H29 #define NETWORKPACKETDELETEOBJECTS_H28 #ifndef _DeleteObjects_H__ 29 #define _DeleteObjects_H__ 30 30 31 #include "../NetworkPrereqs.h" 32 31 #include "network/NetworkPrereqs.h" 33 32 #include "Packet.h" 34 35 33 36 34 namespace orxonox { … … 57 55 } //namespace orxonox 58 56 59 #endif 57 #endif /* _DeleteObjects_H__ */ -
code/trunk/src/network/packet/FunctionCalls.cc
r3084 r3214 29 29 #include "FunctionCalls.h" 30 30 31 #include <enet/enet.h>32 31 #include <cassert> 33 32 #include <cstring> 34 #include " network/Host.h"33 #include "util/MultiType.h" 35 34 #include "network/NetworkFunction.h" 36 #include "util/MultiType.h"37 35 38 36 namespace orxonox { 39 37 namespace packet { 40 38 41 #define PACKET_FLAGS_FUNCTIONCALLS ENET_PACKET_FLAG_RELIABLE39 #define PACKET_FLAGS_FUNCTIONCALLS PacketFlag::Reliable 42 40 #define _PACKETID 0 43 41 const 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 */ 1 28 2 #ifndef NETWORKFUNCTIONCALLS_H3 #define NETWORKFUNCTIONCALLS_H29 #ifndef _FunctionCalls_H__ 30 #define _FunctionCalls_H__ 4 31 5 #include " ../NetworkPrereqs.h"32 #include "network/NetworkPrereqs.h" 6 33 7 #include <string> 8 #include <cstring> 9 34 #include <cassert> 35 #include "util/UtilPrereqs.h" 10 36 #include "Packet.h" 11 #include <cassert>12 37 13 38 namespace orxonox { 14 15 class MultiType;16 39 17 40 namespace packet { … … 44 67 } //namespace orxonox 45 68 46 #endif 69 #endif /* _FunctionCalls_H__ */ -
code/trunk/src/network/packet/FunctionIDs.cc
r3084 r3214 27 27 */ 28 28 29 #include "FunctionIDs.h" 29 30 31 #include <cassert> 32 #include <cstring> 33 #include <queue> 34 #include <string> 30 35 31 #include "FunctionIDs.h" 36 #include "util/Debug.h" 37 #include "core/ObjectList.h" 32 38 #include "network/NetworkFunction.h" 33 #include <enet/enet.h>34 #include "core/CoreIncludes.h"35 #include <string>36 #include <cassert>37 #include <queue>38 39 39 40 namespace orxonox { … … 41 42 42 43 43 #define PACKET_FLAGS_FUNCTIONIDS ENET_PACKET_FLAG_RELIABLE44 #define PACKET_FLAGS_FUNCTIONIDS PacketFlag::Reliable 44 45 #define _PACKETID 0 45 46 -
code/trunk/src/network/packet/FunctionIDs.h
r3084 r3214 26 26 * 27 27 */ 28 #ifndef NETWORKFUNCTIONIDS_H29 #define NETWORKFUNCTIONIDS_H30 28 31 #include "../NetworkPrereqs.h" 29 #ifndef _FunctionIDs_H__ 30 #define _FunctionIDs_H__ 32 31 33 #include <string> 34 32 #include "network/NetworkPrereqs.h" 35 33 #include "Packet.h" 36 34 … … 58 56 } //namespace orxonox 59 57 60 #endif 58 #endif /* _FunctionIDs_H__ */ -
code/trunk/src/network/packet/Gamestate.cc
r3198 r3214 28 28 29 29 #include "Gamestate.h" 30 #include <enet/enet.h> 30 31 31 #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" 36 34 #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" 41 38 42 39 namespace orxonox { … … 46 43 #define GAMESTATE_START(data) (data + GamestateHeader::getSize()) 47 44 48 #define PACKET_FLAG_GAMESTATE ENET_PACKET_FLAG_RELIABLE45 #define PACKET_FLAG_GAMESTATE PacketFlag::Reliable 49 46 50 47 -
code/trunk/src/network/packet/Gamestate.h
r3198 r3214 28 28 29 29 30 #ifndef NETWORK_PACKETGAMESTATE_H31 #define NETWORK_PACKETGAMESTATE_H30 #ifndef _Gamestate_H__ 31 #define _Gamestate_H__ 32 32 33 33 #include "network/NetworkPrereqs.h" 34 34 35 #include <cassert> 36 #include <cstring> 37 #include <list> 38 39 #include "util/CRC32.h" 40 #include "network/TrafficControl.h" 35 41 #include "Packet.h" 36 #include "network/TrafficControl.h"37 #include <string.h>38 #include <map>39 #include <vector>40 #include <cassert>41 #ifndef NDEBUG42 #include "util/CRC32.h"43 #endif44 42 45 43 namespace orxonox { … … 138 136 } 139 137 140 #endif 138 #endif /* _Gamestate_H__ */ -
code/trunk/src/network/packet/Packet.cc
r3097 r3214 31 31 32 32 #include <cassert> 33 #include <cstring> 33 34 #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" 40 38 #include "Acknowledgement.h" 41 #include "DeleteObjects.h"42 39 #include "Chat.h" 43 40 #include "ClassID.h" 41 #include "DeleteObjects.h" 44 42 #include "FunctionCalls.h" 45 43 #include "FunctionIDs.h" … … 47 45 #include "Welcome.h" 48 46 #include "network/Host.h" 49 #include " core/CoreIncludes.h"47 #include "network/ClientInformation.h" 50 48 51 49 namespace orxonox{ … … 53 51 namespace packet{ 54 52 55 #define PACKET_FLAG_DEFAULT ENET_PACKET_FLAG_NO_ALLOCATE 53 // Make sure we assume the right values 54 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Reliable) == static_cast<int>(ENET_PACKET_FLAG_RELIABLE)); 55 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::Unsequence) == static_cast<int>(ENET_PACKET_FLAG_UNSEQUENCED)); 56 BOOST_STATIC_ASSERT(static_cast<int>(PacketFlag::NoAllocate) == static_cast<int>(ENET_PACKET_FLAG_NO_ALLOCATE)); 57 58 #define PACKET_FLAG_DEFAULT PacketFlag::NoAllocate 56 59 #define _PACKETID 0 57 60 58 61 std::map<size_t, Packet *> Packet::packetMap_; 59 //! Static mutex for any packetMap_ access60 static boost::recursive_mutex packetMap_mutex_g;61 62 62 63 Packet::Packet(){ … … 108 109 } 109 110 else if (this->data_) { 110 // This destructor was probably called as a consequence toENet executing our callback.111 // This destructor was probably called as a consequence of ENet executing our callback. 111 112 // It simply serves us to be able to deallocate the packet content (data_) ourselves since 112 113 // we have created it in the first place. … … 142 143 // Assures we don't create a packet and destroy it right after in another thread 143 144 // without having a reference in the packetMap_ 144 boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g);145 145 packetMap_[(size_t)(void*)enetPacket_] = this; 146 146 } … … 218 218 // Data was created by ENet 219 219 p->bDataENetAllocated_ = true; 220 p->enetPacket_ = packet; 220 221 221 222 return p; … … 228 229 */ 229 230 void Packet::deletePacket(ENetPacket *enetPacket){ 230 boost::recursive_mutex::scoped_lock lock(packetMap_mutex_g);231 231 // Get our Packet from a gloabal map with all Packets created in the send() method of Packet. 232 232 std::map<size_t, Packet*>::iterator it = packetMap_.find((size_t)enetPacket); … … 236 236 delete it->second; 237 237 packetMap_.erase(it); 238 COUT( 4) << "PacketMap size: " << packetMap_.size() << std::endl;238 COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl; 239 239 } 240 240 -
code/trunk/src/network/packet/Packet.h
r3084 r3214 26 26 * 27 27 */ 28 #ifndef NETWORKPACKET_H29 #define NETWORKPACKET_H28 #ifndef _NETWORK_Packet_H__ 29 #define _NETWORK_Packet_H__ 30 30 31 31 #include "network/NetworkPrereqs.h" 32 33 32 #include <map> 34 33 … … 102 101 } //namespace orxonox 103 102 104 #endif 103 #endif /* _NETWORK_Packet_H__ */ -
code/trunk/src/network/packet/Welcome.cc
r2773 r3214 29 29 */ 30 30 31 #include "Welcome.h" 31 32 32 #include "Welcome.h"33 #include <enet/enet.h>34 33 #include <cassert> 34 #include "util/Debug.h" 35 35 #include "network/Host.h" 36 36 #include "network/synchronisable/Synchronisable.h" 37 #include "core/CoreIncludes.h"38 37 39 38 namespace orxonox { 40 39 namespace packet { 41 40 42 #define PACKET_FLAGS_CLASSID ENET_PACKET_FLAG_RELIABLE41 #define PACKET_FLAGS_CLASSID PacketFlag::Reliable 43 42 #define _PACKETID 0 44 43 #define _CLIENTID _PACKETID + sizeof(ENUM::Type) -
code/trunk/src/network/packet/Welcome.h
r2662 r3214 26 26 * 27 27 */ 28 #ifndef NETWORKWELCOME_H29 #define NETWORKWELCOME_H28 #ifndef _NETWORK_Welcome_H__ 29 #define _NETWORK_Welcome_H__ 30 30 31 #include "../NetworkPrereqs.h" 32 31 #include "network/NetworkPrereqs.h" 33 32 #include "Packet.h" 34 33 … … 56 55 } //namespace orxonox 57 56 58 #endif 57 #endif /* _NETWORK_Welcome_H__ */
Note: See TracChangeset
for help on using the changeset viewer.