Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/network/packet/Packet.h @ 2961

Last change on this file since 2961 was 2773, checked in by rgrieder, 16 years ago

Removed all enet and boost includes from header files in the network library.

  • Reduces dependencies
  • Minimises problems with windows.h
  • Speeds up the compiling process a little bit (probably negligible)
  • Also removes ugly WIN32_LEAN_AND_MEAN declarations before every enet.h include in the network library.

Removed windows.h header from util/Sleep.h by adding Sleep.cc

  • Property svn:eol-style set to native
File size: 2.5 KB
RevLine 
[1701]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>, (C) 2008
24 *   Co-authors:
25 *      ...
26 *
27 */
28#ifndef NETWORKPACKET_H
29#define NETWORKPACKET_H
30
[2171]31#include "network/NetworkPrereqs.h"
[2087]32
[1711]33#include <map>
[1701]34
[2171]35namespace orxonox {
[1701]36
37namespace packet{
[2087]38
[1701]39namespace ENUM{
40  enum Direction{
41    Incoming,
42    Outgoing,
43    Bidirectional
44  };
45  enum Type{
46    Acknowledgement,
47    Gamestate,
48    ClassID,
[1705]49    Chat,
[1907]50    Welcome,
51    DeleteObjects
[1701]52  };
53}
[2087]54
[1701]55/**
56        @author Oliver Scheuss <scheusso [at] ee.ethz.ch>
57*/
[2087]58class _NetworkExport Packet{
[1701]59  public:
[1711]60    Packet(const Packet &p);
[1709]61    virtual ~Packet();
[1711]62    static Packet *createPacket(ENetPacket *packet, ENetPeer *peer);
63    static void deletePacket(ENetPacket *packet);
[2087]64
[1711]65    virtual unsigned char *getData(){ return data_; };
66    virtual unsigned int getSize() const =0;
67    virtual bool process()=0;
[2773]68    uint32_t getFlags()
[1711]69      { return flags_; }
70    int getClientID()
71      { return clientID_; }
72    void setClientID( int id )
73      { clientID_ = id; }
[2087]74
[1701]75    bool send();
76  protected:
[1711]77    Packet();
[1907]78    Packet(uint8_t *data, unsigned int clientID);
[1713]79//    Packet(ENetPacket *packet, ENetPeer *peer);
[2773]80    uint32_t flags_;
[1907]81    unsigned int clientID_;
[1751]82    ENUM::Direction packetDirection_;
[2087]83    /** Pointer to the data. Be careful when deleting it because it might
84        point to a location that was allocated by ENet.
85        See bDataENetAllocated_ */
[1907]86    uint8_t *data_;
[2087]87    /** Tells whether data_ was allocated by ENet or ourselves.
88        data_ might no correlate with enetPacket_->data. */
89    bool bDataENetAllocated_;
[1701]90  private:
[2171]91    static std::map<size_t, Packet *> packetMap_;
[1701]92    ENetPacket *enetPacket_;
93};
94
95} //namespace packet
96
[2171]97} //namespace orxonox
[1701]98
99#endif
Note: See TracBrowser for help on using the repository browser.