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