Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/network/network_game_manager.h @ 7804

Last change on this file since 7804 was 7697, checked in by rennerc, 18 years ago

fixed spaceship permissions

File size: 3.7 KB
RevLine 
[6067]1/*!
2 * @file entity_manager.h
3 *  Manages creation and destruction of entities
4 */
[6111]5
[6116]6#ifndef _NETWORK_GAME_MANGER
7#define _NETWORK_GAME_MANAGER
[6067]8
9/* include this file, it contains some default definitions */
10#include "netdefs.h"
11
12/* include base_object.h since all classes are derived from this one */
13#include "synchronizeable.h"
[7693]14#include "message_manager.h"
[6067]15
[6111]16
[6341]17class TiXmlElement;
[6695]18class PNode;
[6111]19
[6695]20typedef enum NetworkGameManagerProtocol {
21  NET_CREATE_ENTITY = 0,
22  NET_REMOVE_ENTITY,
23  NET_CREATE_ENTITY_LIST,
24  NET_REMOVE_ENTITY_LIST,
25  NET_REQUEST_CREATE,
26  NET_REQUEST_REMOVE,
27  NET_YOU_ARE_ENTITY,
28  NET_REQUEST_ENTITY_LIST,
29  NET_REQUEST_PNODE_PATH,
30  NET_SEND_PNODE_PATH,
31
32  NET_NUMBER
[6341]33};
[6111]34
[6341]35struct clientBuffer
36{
37  int length;
38  int maxLength;
39  byte * buffer;
40};
[6111]41
[6067]42/*!
43 * a class that can create and remove entities
44 */
[6116]45class NetworkGameManager: public Synchronizeable
[6067]46{
47  public:
[6981]48    virtual ~NetworkGameManager();
[6111]49
[6341]50    static NetworkGameManager* NetworkGameManager::getInstance()
51    { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; }
52
[7567]53#if 0
[6341]54    virtual int writeBytes(const byte* data, int length, int sender);
[6067]55    virtual int readBytes(byte* data, int maxLength, int * reciever);
56    virtual void writeDebug() const;
57    virtual void readDebug() const;
[7567]58#endif
[6111]59
[6498]60    int createEntity( ClassID classID, int owner = 0 );
[6424]61    BaseObject* createEntity(const TiXmlElement* element);
[6341]62    void removeEntity( int uniqueID );
63    void sendYouAre( int uniqueID, int userID );
[6111]64
[7567]65#if 0
[6341]66    void sendEntityList(int userID);
[7567]67#endif
[6111]68
[6737]69    bool signalNewPlayer(int userId);
70    bool signalLeftPlayer(int userID);
[6695]71
[6737]72
[6067]73  private:
[6341]74    NetworkGameManager();
[7693]75   
76    static bool youAreHandler(MessageId messageId, byte * data, int dataLength, void * someData, int userId );
[6111]77
[6695]78
79    /* some network signal handlers */
80    bool handleRequestCreate( int& i, const byte* data, int length, int sender );
81    bool handleRequestRemove( int& i, const byte* data, int length, int sender );
82    bool handleCreateEntity( int& i, const byte* data, int length, int sender );
83    bool handleRemoveEntity( int& i, const byte* data, int length, int sender );
84    bool handleCreateEntityList( int& i, const byte* data, int length, int sender );
85    bool handleRemoveEntityList( int& i, const byte* data, int length, int sender );
86    bool handleYouAreEntity( int& i, const byte* data, int length, int sender );
87    bool handleRequestPNodePath(int& i, const byte* data, int length, int sender);
88    bool handleSendPNodePath(int& i, const byte* data, int length, int sender);
89
90
91    /* some network handlers helper functions */
[7567]92//    void requestCreateEntity(ClassID classID);
[6498]93    int executeCreateEntity(ClassID classID, int uniqueID = 0, int owner = 0);
[6695]94    BaseObject* doCreateEntity(ClassID classID, int uniqueID, int owner);
[6341]95
[7567]96//    void requestRemoveEntity(int uniqueID);
[6067]97    void executeRemoveEntity(int uniqueID);
[6695]98    void doRemoveEntity(int uniqueID);
[6111]99
[6341]100    void doYouAre( int uniqueID );
[6111]101
[7567]102//    void requestPNodePath(const PNode* node1, const PNode* node2);
[6695]103    void executeRequestPNodePath(const PNode* node2, const PNode* node2);
104    void doRequestPNodePath(const PNode* node1, const PNode* node2);
105
[6341]106    bool canCreateEntity(ClassID classID);
[7567]107#if 0
[6341]108    void resizeBufferVector(int n);
[6111]109
[7567]110
[6695]111    bool writeToClientBuffer( clientBuffer &cb, byte*data, int length );
112    bool writeToClientBuffer( clientBuffer &cb, byte b );
113    bool writeToClientBuffer( clientBuffer &cb, int i );
114    bool readFromClientBuffer( clientBuffer &cb, byte*data, int length );
[7567]115#endif
[6111]116
117  private:
[7567]118#if 0
[6341]119    std::vector<clientBuffer>     outBuffer;
[6634]120    //clientBuffer                  allOutBuffer;
[7567]121#endif
[6341]122    static NetworkGameManager*    singletonRef;
[6067]123};
124
125#endif /*_ENTITY_MANGER*/
Note: See TracBrowser for help on using the repository browser.