Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

gne.h

Go to the documentation of this file.
00001 #ifndef _GNE_H_
00002 #define _GNE_H_
00003 
00004 #define _WINSOCKAPI_
00005 #include <windows.h>
00006 #include "playerlist.h"
00007 #include "packet.h"
00008 #include "Connection.h"
00009 #include "../util/log.h"
00010 #include "MessageQueue.h"
00011 #include "Event.h"
00012 #include "EventQueue.h"
00013 
00014 #define VERSION_ID 10002
00015 #define STD_PORT 22560
00016 
00017 #define MAX_MSG 100
00018 
00019 class Gne{
00020 private:
00021         bool isserver;
00022         bool playerInfoSelfIsSet;
00023         bool isrunning;
00024         int port;
00025         int latestThread;
00026         int latestPlayerID;
00027         MessageQueue *msgQueue;
00028         EventQueue *eventQueue;
00029 
00030         PlayerList *playerlist;
00031         Player *self;
00032         HANDLE hThreadListen;
00033         HANDLE hThreadClient;
00034         HANDLE *hThreadTCP;
00035         bool *freeSlotsThreads;
00036         int *playerIdSlots;
00037         
00038         Connection *connection;
00039         Connection **clients;
00040         int *idlist;
00041 
00042         DWORD hThreadListenID;
00043         DWORD hThreadClientID;
00044 
00045         static DWORD WINAPI listen(LPVOID arg);
00046         static DWORD WINAPI aPlayer(LPVOID arg);
00047         static DWORD WINAPI clientThread(LPVOID arg);
00048 
00049         int addPlayer(Player *p);
00050         int getFreeThread();
00051         void setFreeThread(int nr);
00052 
00053         int sendChatMsg(msgstruct msg);
00054 
00055         int sendPlayer(Connection *conn, Player *p);
00056         int sendPlayerToAll(Player *p, int exeption);
00057 
00058         int sendDisconnectToAll(packetDisconnect pkt);
00059         void sendPlayerPosToAll(packetPlayerPosition ppp, int nt);
00060         void setPlayerIdSelf(int id);
00061 
00062         int getNextPlayerID();
00063 
00064 
00065 public:
00066         Gne();
00067         virtual ~Gne();
00068         int init(bool isserver);
00069         bool isServer();
00070         bool isRunning();
00071         int setMaxPlayers(int n);
00072         int getMaxPlayers();
00073         int getNumPlayers();
00074         
00075         int setPlayerInfoSelf(char *name);
00076         char *getPlayerNameSelf();
00077         int getPlayerIdSelf();
00078 
00079 
00080         Player *getPlayerById(int playerid);
00081         int removePlayerById(int playerid);
00082 
00083         int setPort(int port);
00084         int getPort();
00085 
00086         int startServer();
00087 
00088         //not working as it should.
00089         int stopServer();
00090 
00091         int joinServer(char *address);
00092         int disconnect();
00093 
00094 
00095         int sendChatMsg(char *msg);
00096         bool isMessagePending();
00097         msgstruct getNextMessage();
00098 
00099         void setPlayerPos(int id, int rotation, int move, float x, float y, float angle);
00100         void sendAttack(int playerid, int type, float x, float y, float z, float dx, float dy, float dz);
00101         void sendAttackNT(int playerid, int type, float x, float y, float z, float dx, float dy, float dz, int nt);
00102 
00103         void setPlayerState(int playerid, int state);
00104 
00105         void setPlayerScore(int playerID, int frags, int kills, int deaths);
00106         void setPlayerActionNT(int playerID, int action, int nt);
00107         void setPlayerAction(int playerID, int action);
00108         void setPlayerDeath(int playerID, int killerID);
00109         void setPlayerExtras(int playerID, int extras, int value);
00110         void dealExtras(int type, float x, float y, int flag);
00111         int setPlayerName(int playerID, const char *name, int flag);
00112         int setName(const char *name, int flag);
00113         void sendInfo(int playerid, int valA, int valB, int valC);
00114 
00115         int nextEventPending();
00116         void *getNextEvent();
00117 
00118         int updatePlayersFromServer();
00119 };
00120 
00121 #endif

Generated on Sun Jun 5 15:47:04 2005 for Defacto by  doxygen 1.4.3