Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9250 was 9248, checked in by patrick, 18 years ago

starting switch to multiple server states (proxy, master, client,..)

File size: 2.2 KB
Line 
1/*!
2 * @file entity_manager.h
3 *  Manages creation and destruction of entities
4 */
5
6#ifndef _NETWORK_GAME_MANGER
7#define _NETWORK_GAME_MANAGER
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"
14#include "playable.h"
15#include "message_manager.h"
16
17
18class TiXmlElement;
19class PNode;
20
21typedef enum NetworkGameManagerProtocol {
22  NET_CREATE_ENTITY = 0,
23  NET_REMOVE_ENTITY,
24  NET_CREATE_ENTITY_LIST,
25  NET_REMOVE_ENTITY_LIST,
26  NET_REQUEST_CREATE,
27  NET_REQUEST_REMOVE,
28  NET_YOU_ARE_ENTITY,
29  NET_REQUEST_ENTITY_LIST,
30  NET_REQUEST_PNODE_PATH,
31  NET_SEND_PNODE_PATH,
32
33  NET_NUMBER
34};
35
36struct clientBuffer
37{
38  int length;
39  int maxLength;
40  byte * buffer;
41};
42
43/*!
44 * a class that can create and remove entities over the network
45 */
46class NetworkGameManager: public Synchronizeable
47{
48
49  public:
50    virtual ~NetworkGameManager();
51
52    static NetworkGameManager* NetworkGameManager::getInstance()
53    { if (!NetworkGameManager::singletonRef) NetworkGameManager::singletonRef = new NetworkGameManager(); return NetworkGameManager::singletonRef; }
54
55
56    bool signalNewPlayer( int userId );
57    bool signalLeftPlayer( int userID );
58
59    void prefereTeam( int teamId );
60
61
62    inline void setGameState( int gameState ){ this->gameState = gameState; }
63    inline int getGameState(){ return this->gameState; }
64
65    void tick( float ds );
66
67    void removeSynchronizeable( int uniqueId );
68    void sendChatMessage( const std::string & message, int messageType );
69
70
71  private:
72    NetworkGameManager();
73
74    static bool delSynchronizeableHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
75    static bool preferedTeamHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
76    static bool chatMessageHandler( MessageId messageId, byte * data, int dataLength, void * someData, int userId );
77
78    void setPreferedTeam( int userId, int teamId );
79
80
81  private:
82    static NetworkGameManager*    singletonRef;
83
84    int                           gameState;
85
86    std::list<Playable*>          playablesToDelete;
87};
88
89#endif /*_ENTITY_MANGER*/
Note: See TracBrowser for help on using the repository browser.