| [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 | |
|---|
| [2531] | 33 | #include "network/NetworkPrereqs.h" |
|---|
| [2087] | 34 | |
|---|
| [1710] | 35 | #include "Packet.h" |
|---|
| [2531] | 36 | #include "network/TrafficControl.h" |
|---|
| 37 | #include "core/CoreIncludes.h" |
|---|
| [1907] | 38 | #include <map> |
|---|
| [2531] | 39 | #include <list> |
|---|
| [1751] | 40 | #ifndef NDEBUG |
|---|
| 41 | #include "util/CRC32.h" |
|---|
| 42 | #endif |
|---|
| [1701] | 43 | |
|---|
| [2171] | 44 | namespace orxonox { |
|---|
| [1701] | 45 | |
|---|
| 46 | namespace packet { |
|---|
| [1747] | 47 | |
|---|
| [2087] | 48 | struct _NetworkExport GamestateHeader{ |
|---|
| [1710] | 49 | ENUM::Type packetType; |
|---|
| [1907] | 50 | int32_t id; // id of the gamestate |
|---|
| 51 | uint32_t compsize; |
|---|
| 52 | uint32_t datasize; |
|---|
| 53 | int32_t base_id; // id of the base-gamestate diffed from |
|---|
| 54 | bool diffed:1; // wheter diffed or not |
|---|
| 55 | bool complete:1; // wheter it is a complete gamestate or only partial |
|---|
| 56 | bool compressed:1; |
|---|
| [1751] | 57 | #ifndef NDEBUG |
|---|
| 58 | uint32_t crc32; |
|---|
| 59 | #endif |
|---|
| [1701] | 60 | }; |
|---|
| 61 | |
|---|
| 62 | /** |
|---|
| [1907] | 63 | @author Oliver Scheuss |
|---|
| [1701] | 64 | */ |
|---|
| [2087] | 65 | class _NetworkExport Gamestate: public Packet{ |
|---|
| [1701] | 66 | public: |
|---|
| 67 | Gamestate(); |
|---|
| [1907] | 68 | Gamestate(uint8_t *data, unsigned int clientID); |
|---|
| 69 | Gamestate(uint8_t *data); |
|---|
| [1747] | 70 | |
|---|
| [1701] | 71 | ~Gamestate(); |
|---|
| [1747] | 72 | |
|---|
| [2171] | 73 | bool collectData(int id, uint8_t mode=0x0); |
|---|
| 74 | bool spreadData( uint8_t mode=0x0); |
|---|
| [1705] | 75 | int getID(); |
|---|
| [1712] | 76 | bool isDiffed(); |
|---|
| [1751] | 77 | bool isCompressed(); |
|---|
| [1712] | 78 | int getBaseID(); |
|---|
| [1705] | 79 | Gamestate *diff(Gamestate *base); |
|---|
| [1907] | 80 | Gamestate* intelligentDiff(Gamestate *base, unsigned int clientID); |
|---|
| [1705] | 81 | Gamestate *undiff(Gamestate *base); |
|---|
| [1907] | 82 | Gamestate* intelligentUnDiff(Gamestate *base); |
|---|
| [2531] | 83 | Gamestate* doSelection(unsigned int clientID, unsigned int targetSize); |
|---|
| [1705] | 84 | bool compressData(); |
|---|
| 85 | bool decompressData(); |
|---|
| [1747] | 86 | |
|---|
| [1711] | 87 | // Packet functions |
|---|
| [1907] | 88 | private: |
|---|
| [2531] | 89 | virtual uint32_t getSize() const; |
|---|
| [1701] | 90 | virtual bool process(); |
|---|
| 91 | |
|---|
| [1751] | 92 | bool operator ==(packet::Gamestate gs); |
|---|
| [1701] | 93 | private: |
|---|
| [2531] | 94 | uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0); |
|---|
| [2171] | 95 | void removeObject(ObjectListIterator<Synchronisable> &it); |
|---|
| [2531] | 96 | std::list<obj> dataMap_; |
|---|
| [2532] | 97 | // static TrafficControl *trafficControl_; |
|---|
| [1701] | 98 | }; |
|---|
| 99 | |
|---|
| 100 | } |
|---|
| 101 | |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | #endif |
|---|