Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/network/packet/Gamestate.h @ 1742

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

compressing and diffing works now (also shipCache on client). server can't move while client connected. preparations for synchronise frequency of synchronisables

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