Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 1775 was 1775, checked in by scheusso, 16 years ago

we have a new gamestate concept now: dont transmit synchronisable header of objects, that dont get updated that tick. transmit objectids of deleted objects to delete them on the client too

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