Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

synchronizeable: added sender parameter to writeBytes
network_stream: creates now a network_game_manager
network_game_manager: implemented some functions

File size: 2.1 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"
14
[6111]15
16
17/**
18 * protocol definition
19 *
[6190]20 *  CREATE_ENTITY:       CLASS_ID, UNIQUE_ID, OWNER
21 *  REMOVE_ENTITY:       UNIQUE_ID
[6111]22 *
[6190]23 *  CREATE_ENTITY_LIST:  NUMBER, [CLASS_ID, UNIQUE_ID, OWNER][0..NUMBER]
24 *  REMOVE_ENTITY_LIST:  NUMBER, [UNIQUE_ID][0..NUMBER]
[6111]25 *
[6190]26 *  REQUEST_CREATE:      CLASS_ID
27 *  REQUEST_REMOVE:      UNIQUE_ID
[6111]28 *
[6190]29 *  REQUEST_CREATE_LIST: NUMBER, [CLASS_ID][0..NUMBER]
30 *  REQUEST_CREATE_LIST: NUMBER, [UNIQUE_ID][0..NUMBER]
[6111]31 *
[6190]32 *  REQUEST_SYNC:        UNIQUE_ID
33 *  REQUEST_SYNC_LIST:   NUMBER, [UNIQUE_ID][0..NUMBER]
[6111]34 *
[6190]35 *
[6111]36 */
37
[6190]38typedef enum NetworkGameManagerProtocol{
39  CREATE_ENTITY = 0,
40  REMOVE_ENTITY,
41  REQUEST_CREATE,
42  REQUEST_SYNC
43};
[6111]44
[6190]45struct clientBuffer
46{
47  int length;
48  int maxLength;
49  byte * buffer;
50};
[6111]51
[6067]52/*!
53 * a class that can create and remove entities
54 */
[6116]55class NetworkGameManager: public Synchronizeable
[6067]56{
57  public:
[6116]58    NetworkGameManager();
59    ~NetworkGameManager();
[6111]60
[6190]61    virtual void writeBytes(const byte* data, int length, int sender);
[6067]62    virtual int readBytes(byte* data, int maxLength, int * reciever);
63    virtual void writeDebug() const;
64    virtual void readDebug() const;
[6111]65
[6067]66    void createEntity(int classID);
67    void removeEntity(int uniqueID);
[6111]68
69    void sync(int uniqueID);
70
[6190]71    void sendEntityList(int userID);
[6111]72
[6067]73  private:
74    void requestCreateEntity(int classID);
[6111]75    void executeCreateEntity(int classID);
76
[6067]77    void requestRemoveEntity(int uniqueID);
78    void executeRemoveEntity(int uniqueID);
[6111]79
[6190]80    void doCreateEntity(ClassID classID, int uniqueID, int owner);
81    void doRemoveEntity(int uniqueID);
82    void doRequestSync(int uniqueID, int userID);
[6111]83
[6067]84    bool canCreateEntity(int classID);
[6111]85
[6190]86    void resizeBufferVector(int n);
[6111]87
88  private:
[6190]89    std::vector<clientBuffer>     inBuffer;
90    std::vector<clientBuffer>     outBuffer;
[6067]91};
92
93#endif /*_ENTITY_MANGER*/
Note: See TracBrowser for help on using the repository browser.