Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/toonshader/src/network/packet/Packet.h @ 3158

Last change on this file since 3158 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
Line 
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
31#include "network/NetworkPrereqs.h"
32
33#include <map>
34
35namespace orxonox {
36
37namespace packet{
38
39namespace ENUM{
40  enum Direction{
41    Incoming,
42    Outgoing,
43    Bidirectional
44  };
45  enum Type{
46    Acknowledgement,
47    Gamestate,
48    ClassID,
49    Chat,
50    Welcome,
51    DeleteObjects
52  };
53}
54
55/**
56        @author Oliver Scheuss <scheusso [at] ee.ethz.ch>
57*/
58class _NetworkExport Packet{
59  public:
60    Packet(const Packet &p);
61    virtual ~Packet();
62    static Packet *createPacket(ENetPacket *packet, ENetPeer *peer);
63    static void deletePacket(ENetPacket *packet);
64
65    virtual unsigned char *getData(){ return data_; };
66    virtual unsigned int getSize() const =0;
67    virtual bool process()=0;
68    uint32_t getFlags()
69      { return flags_; }
70    int getClientID()
71      { return clientID_; }
72    void setClientID( int id )
73      { clientID_ = id; }
74
75    bool send();
76  protected:
77    Packet();
78    Packet(uint8_t *data, unsigned int clientID);
79//    Packet(ENetPacket *packet, ENetPeer *peer);
80    uint32_t flags_;
81    unsigned int clientID_;
82    ENUM::Direction packetDirection_;
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_ */
86    uint8_t *data_;
87    /** Tells whether data_ was allocated by ENet or ourselves.
88        data_ might no correlate with enetPacket_->data. */
89    bool bDataENetAllocated_;
90  private:
91    static std::map<size_t, Packet *> packetMap_;
92    ENetPacket *enetPacket_;
93};
94
95} //namespace packet
96
97} //namespace orxonox
98
99#endif
Note: See TracBrowser for help on using the repository browser.