Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core3/src/network/Synchronisable.h @ 1996

Last change on this file since 1996 was 1591, checked in by landauf, 16 years ago

Again some heavy changes in ObjectList and Iterator:
there are now two types of iterators:

Iterator<ClassName> can iterate through any objectlist, either given by ObjectList<AnyClassName>::begin() or anyidentifier→getObjects()→begin(). Important note Iterator<ClassName> uses dynamic_cast.
And yes, it's possible to do this: Iterator<WorldEntity> it = ObjectList<SpaceShip>::begin()

ObjectList<ClassName>::iterator is the second iterator - it uses the ObjectList in a templated manner and therefore doesn't need dynamic_cast. But the only thing you can do is iterating through exactly the right ObjectList: ObjectList<ClassName>::iterator it = ObjectList<ClassName>::begin(). Anything else fails.

Those changes bring, at my system, something around +12% FPS compared with trunk and +25% FPS compared with the last revision of core3. Although I have to admit the FPS gain is only that high because iterating through objects is the main thing we're doing ingame right now. It would look totally different with physics, sound, AI, scripts, triggers and so on.

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
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#ifndef _Synchronisable_H__
30#define _Synchronisable_H__
31
32#include "NetworkPrereqs.h"
33
34#include <list>
35#include "core/OrxonoxClass.h"
36#include "NetworkCallback.h"
37
38namespace network
39{
40  enum variableType{
41    DATA,
42    STRING,
43  };
44
45  struct syncData{
46    int length;
47    int objectID;
48    int classID;
49    unsigned char *data;
50  };
51
52  typedef struct synchronisableVariable{
53    int size;
54    int mode; // this determines in which direction the variable gets synchronised
55    void *var;
56    variableType type;
57    NetworkCallbackBase *callback;
58  }SYNCVAR;
59
60
61  /**
62  * This class is the base class of all the Objects in the universe that need to be synchronised over the network
63   * Every class, t
64  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.
65  * @author Oliver Scheuss
66  */
67  class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{
68  public:
69
70    virtual ~Synchronisable();
71    int objectID;
72    int classID;
73
74    void registerVar(void *var, int size, variableType t, int mode=1, NetworkCallbackBase *cb=0);
75    //  syncData getData();
76    syncData getData(unsigned char *mem, int mode=0x0);
77    int getSize(int mode=0x0);
78    bool updateData(syncData vars, int mode=0x0);
79    void setBacksync(bool sync);
80    bool getBacksync();
81    virtual void registerAllVariables()=0;
82    virtual bool create();
83    static void setClient(bool b);
84  protected:
85    Synchronisable();
86  private:
87    /*  bool removeObject(ObjectList<Synchronisable>::iterator it);*/
88
89    std::list<synchronisableVariable *> *syncList;
90    int datasize;
91    static int state_; // detemines wheter we are server (default) or client
92    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
93  };
94}
95
96#endif /* _Synchronisable_H__ */
Note: See TracBrowser for help on using the repository browser.