Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/network/packet/Packet.h @ 2019

Last change on this file since 2019 was 1916, checked in by landauf, 16 years ago

removed WorldEntity, SpaceShip and several other objects
removed SpaceShip-related hacks in network and other places

  • Property svn:eol-style set to native
File size: 2.3 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
[1916]31#include "../NetworkPrereqs.h"
32
[1711]33#include <map>
[1701]34#include <enet/enet.h>
35
[1907]36#include "util/Integers.h"
37
[1701]38namespace network {
39
40namespace packet{
[1916]41
[1701]42namespace ENUM{
43  enum Direction{
44    Incoming,
45    Outgoing,
46    Bidirectional
47  };
48  enum Type{
49    Acknowledgement,
50    Gamestate,
51    ClassID,
[1705]52    Chat,
[1907]53    Welcome,
54    DeleteObjects
[1701]55  };
56}
[1916]57
[1701]58/**
59        @author Oliver Scheuss <scheusso [at] ee.ethz.ch>
60*/
[1916]61class _NetworkExport Packet{
[1701]62  public:
[1711]63    Packet(const Packet &p);
[1709]64    virtual ~Packet();
[1711]65    static Packet *createPacket(ENetPacket *packet, ENetPeer *peer);
66    static void deletePacket(ENetPacket *packet);
[1916]67
[1711]68    virtual unsigned char *getData(){ return data_; };
69    virtual unsigned int getSize() const =0;
70    virtual bool process()=0;
71    enet_uint32 getFlags()
72      { return flags_; }
73    int getClientID()
74      { return clientID_; }
75    void setClientID( int id )
76      { clientID_ = id; }
[1916]77
[1701]78    bool send();
79  protected:
[1711]80    Packet();
[1907]81    Packet(uint8_t *data, unsigned int clientID);
[1713]82//    Packet(ENetPacket *packet, ENetPeer *peer);
[1711]83    enet_uint32 flags_;
[1907]84    unsigned int clientID_;
[1751]85    ENUM::Direction packetDirection_;
[1907]86    uint8_t *data_;
[1701]87  private:
[1711]88    static std::map<ENetPacket *, Packet *> packetMap_;
[1701]89    ENetPacket *enetPacket_;
90};
91
92} //namespace packet
93
94} //namespace network
95
96#endif
Note: See TracBrowser for help on using the repository browser.