Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/network/packet/Gamestate.h @ 1997

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

merged network branch back to trunk

  • 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, (C) 2008
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "Packet.h"
30#include "network/Synchronisable.h"
31#include <map>
32#ifndef NDEBUG
33#include "util/CRC32.h"
34#endif
35
36
37#ifndef NETWORK_PACKETGAMESTATE_H
38#define NETWORK_PACKETGAMESTATE_H
39
40namespace network {
41
42namespace packet {
43
44struct GamestateHeader{
45  ENUM::Type packetType;
46  int32_t id; // id of the gamestate
47  uint32_t compsize;
48  uint32_t datasize;
49  int32_t base_id; // id of the base-gamestate diffed from
50  bool diffed:1; // wheter diffed or not
51  bool complete:1; // wheter it is a complete gamestate or only partial
52  bool compressed:1;
53#ifndef NDEBUG
54  uint32_t crc32;
55#endif
56};
57
58/**
59        @author Oliver Scheuss
60*/
61class Gamestate: public Packet{
62  public:
63    Gamestate();
64    Gamestate(uint8_t *data, unsigned int clientID);
65    Gamestate(uint8_t *data);
66
67    ~Gamestate();
68
69    bool collectData(int id, int mode=0x0);
70    bool spreadData(int mode=0x0);
71    int getID();
72    bool isDiffed();
73    bool isCompressed();
74    int getBaseID();
75    Gamestate *diff(Gamestate *base);
76    Gamestate* intelligentDiff(Gamestate *base, unsigned int clientID);
77    Gamestate *undiff(Gamestate *base);
78    Gamestate* intelligentUnDiff(Gamestate *base);
79    Gamestate* doSelection(unsigned int clientID);
80    bool compressData();
81    bool decompressData();
82
83    // Packet functions
84  private:
85    virtual unsigned int getSize() const;
86    virtual bool process();
87
88    bool operator ==(packet::Gamestate gs);
89  private:
90    unsigned int calcGamestateSize(unsigned int id, int mode=0x0);
91    void removeObject(orxonox::ObjectListIterator<Synchronisable> &it);
92    std::map<unsigned int, Synchronisable*> dataMap_;
93};
94
95}
96
97}
98
99#endif
Note: See TracBrowser for help on using the repository browser.