Last change
on this file since fd9cdb5 was fd9cdb5, checked in by dportnoy <dmp1488@…>, 10 years ago |
Add new player profile screen, accessible from the lobby, which shows the game history and other information.
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[46d6469] | 1 | #ifndef _MESSAGE_CONTAINER_H
|
---|
| 2 | #define _MESSAGE_CONTAINER_H
|
---|
| 3 |
|
---|
[b35b2b2] | 4 | #include <string>
|
---|
| 5 |
|
---|
[e6c26b8] | 6 | #include "Compiler.h"
|
---|
[46d6469] | 7 |
|
---|
[e6c26b8] | 8 | #if defined WINDOWS
|
---|
| 9 | #include <winsock2.h>
|
---|
| 10 | #elif defined LINUX
|
---|
[373089e] | 11 | #include <netinet/in.h>
|
---|
[34bd549] | 12 | #elif defined MAC
|
---|
| 13 | #include <netinet/in.h>
|
---|
[373089e] | 14 | #endif
|
---|
| 15 |
|
---|
[b35b2b2] | 16 | using namespace std;
|
---|
| 17 |
|
---|
[06fc7f7] | 18 | enum MessageType {
|
---|
| 19 | MSG_TYPE_ACK = 1,
|
---|
| 20 | MSG_TYPE_REGISTER,
|
---|
| 21 | MSG_TYPE_LOGIN,
|
---|
| 22 | MSG_TYPE_LOGOUT,
|
---|
| 23 | MSG_TYPE_CHAT,
|
---|
| 24 | MSG_TYPE_PLAYER,
|
---|
| 25 | MSG_TYPE_PLAYER_MOVE,
|
---|
| 26 | MSG_TYPE_OBJECT,
|
---|
| 27 | MSG_TYPE_REMOVE_OBJECT,
|
---|
| 28 | MSG_TYPE_PICKUP_FLAG,
|
---|
| 29 | MSG_TYPE_DROP_FLAG,
|
---|
| 30 | MSG_TYPE_SCORE,
|
---|
| 31 | MSG_TYPE_ATTACK,
|
---|
| 32 | MSG_TYPE_PROJECTILE,
|
---|
| 33 | MSG_TYPE_REMOVE_PROJECTILE,
|
---|
[fd9cdb5] | 34 | MSG_TYPE_PROFILE,
|
---|
[06fc7f7] | 35 | MSG_TYPE_CREATE_GAME,
|
---|
| 36 | MSG_TYPE_JOIN_GAME,
|
---|
| 37 | MSG_TYPE_LEAVE_GAME,
|
---|
| 38 | MSG_TYPE_GAME_INFO,
|
---|
| 39 | MSG_TYPE_JOIN_GAME_SUCCESS,
|
---|
| 40 | MSG_TYPE_JOIN_GAME_FAILURE,
|
---|
| 41 | MSG_TYPE_JOIN_GAME_ACK,
|
---|
| 42 | MSG_TYPE_PLAYER_JOIN_GAME,
|
---|
[e98426d] | 43 | MSG_TYPE_FINISH_GAME,
|
---|
[cb5a021] | 44 | MSG_TYPE_JOIN_TEAM,
|
---|
| 45 | MSG_TYPE_START_GAME
|
---|
[06fc7f7] | 46 | };
|
---|
[46d6469] | 47 |
|
---|
| 48 | typedef struct
|
---|
| 49 | {
|
---|
| 50 | unsigned int id;
|
---|
| 51 | unsigned short type;
|
---|
| 52 | char buffer[256];
|
---|
| 53 | } NETWORK_MSG;
|
---|
| 54 |
|
---|
| 55 | class MessageContainer {
|
---|
| 56 | private:
|
---|
| 57 | NETWORK_MSG msg;
|
---|
| 58 | struct sockaddr_in clientAddr;
|
---|
| 59 | bool isAcked;
|
---|
| 60 | unsigned long long timeAcked;
|
---|
| 61 |
|
---|
| 62 | public:
|
---|
| 63 | MessageContainer();
|
---|
| 64 | MessageContainer(const MessageContainer& mc);
|
---|
| 65 | MessageContainer(NETWORK_MSG msg, struct sockaddr_in clientAddr);
|
---|
| 66 | ~MessageContainer();
|
---|
| 67 |
|
---|
| 68 | bool getAcked();
|
---|
| 69 | unsigned long long getTimeAcked();
|
---|
| 70 | NETWORK_MSG* getMessage();
|
---|
| 71 |
|
---|
| 72 | void setAcked(bool acked);
|
---|
| 73 | void setTimeAcked(unsigned long long time);
|
---|
[b35b2b2] | 74 |
|
---|
[06fc7f7] | 75 | static string getMsgTypeString(int msgType);
|
---|
[46d6469] | 76 | };
|
---|
| 77 |
|
---|
| 78 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.