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