Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2110 was 2087, checked in by landauf, 16 years ago

merged objecthierarchy branch back to trunk

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