[1168] | 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) 2007 |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | // |
---|
| 30 | // C++ Interface: synchronisable |
---|
| 31 | // |
---|
| 32 | // Description: |
---|
| 33 | // |
---|
| 34 | // |
---|
| 35 | // Author: Oliver Scheuss, (C) 2007 |
---|
| 36 | // |
---|
| 37 | // Copyright: See COPYING file that comes with this distribution |
---|
| 38 | // |
---|
| 39 | // |
---|
| 40 | #ifndef _Synchronisable_H__ |
---|
| 41 | #define _Synchronisable_H__ |
---|
| 42 | |
---|
| 43 | #include "NetworkPrereqs.h" |
---|
| 44 | |
---|
| 45 | #include <list> |
---|
| 46 | #include "core/OrxonoxClass.h" |
---|
| 47 | |
---|
| 48 | namespace network |
---|
| 49 | { |
---|
| 50 | enum variableType{ |
---|
| 51 | DATA, |
---|
| 52 | STRING, |
---|
| 53 | }; |
---|
| 54 | |
---|
| 55 | struct syncData{ |
---|
| 56 | int length; |
---|
| 57 | int objectID; |
---|
| 58 | int classID; |
---|
| 59 | unsigned char *data; |
---|
| 60 | }; |
---|
| 61 | |
---|
| 62 | typedef struct synchronisableVariable{ |
---|
| 63 | int size; |
---|
[1232] | 64 | int mode; // this determines in which direction the variable gets synchronised |
---|
[1180] | 65 | void *var; |
---|
[1168] | 66 | variableType type; |
---|
| 67 | }SYNCVAR; |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | /** |
---|
| 71 | * This class is the base class of all the Objects in the universe that need to be synchronised over the network |
---|
[1232] | 72 | * Every class, t |
---|
| 73 | int mode;hat inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. Additionally it also has to provide a Constructor, that takes exactly the variables in this linked list. |
---|
[1168] | 74 | * @author Oliver Scheuss |
---|
| 75 | */ |
---|
| 76 | class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{ |
---|
| 77 | public: |
---|
| 78 | |
---|
| 79 | virtual ~Synchronisable(); |
---|
| 80 | int objectID; |
---|
| 81 | int classID; |
---|
| 82 | |
---|
[1232] | 83 | void registerVar(void *var, int size, variableType t, int mode=1); |
---|
[1168] | 84 | // syncData getData(); |
---|
| 85 | syncData getData(unsigned char *mem); |
---|
| 86 | int getSize(); |
---|
| 87 | bool updateData(syncData vars); |
---|
[1232] | 88 | void setBacksync(bool sync); |
---|
| 89 | bool getBacksync(); |
---|
[1168] | 90 | virtual void registerAllVariables()=0; |
---|
| 91 | virtual bool create()=0; |
---|
[1232] | 92 | static void setClient(bool b); |
---|
[1168] | 93 | protected: |
---|
| 94 | Synchronisable(); |
---|
| 95 | private: |
---|
| 96 | /* bool removeObject(Iterator<Synchronisable> it);*/ |
---|
| 97 | |
---|
| 98 | std::list<synchronisableVariable *> *syncList; |
---|
| 99 | int datasize; |
---|
[1232] | 100 | static int state_; // detemines wheter we are server (default) or client |
---|
| 101 | bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server) |
---|
[1168] | 102 | }; |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | #endif /* _Synchronisable_H__ */ |
---|