Changeset 06fc7f7 in network-game for common


Ignore:
Timestamp:
Jan 22, 2014, 3:36:37 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
e70b66b
Parents:
0678d60
Message:

getMsgTypeString is now defined in MessageContainer.cpp and the message types have been converted to an enum

Location:
common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • common/MessageContainer.cpp

    r0678d60 r06fc7f7  
    4343}
    4444
     45
    4546void MessageContainer::setTimeAcked(unsigned long long time) {
    4647   this->timeAcked = time;
    4748}
    4849
    49 /*
    50 string getMsgTypeString(int msgType) {
     50string MessageContainer::getMsgTypeString(int msgType) {
    5151   switch(msgType) {
    5252      case MSG_TYPE_ACK: return "MSG_TYPE_ACK";
     
    6060      case MSG_TYPE_REMOVE_OBJECT: return "MSG_TYPE_REMOVE_OBJECT";
    6161      case MSG_TYPE_PICKUP_FLAG: return "MSG_TYPE_PICKUP_FLAG";
    62       caseMSG_TYPE_DROP_FLAG: return "MSG_TYPE_DROP_FLAG";
     62      case MSG_TYPE_DROP_FLAG: return "MSG_TYPE_DROP_FLAG";
    6363      case MSG_TYPE_SCORE: return "MSG_TYPE_SCORE";
    64       case MSG_TYPE_START_ATTACK: return "MSG_TYPE_START_ATACK";
    6564      case MSG_TYPE_ATTACK: return "MSG_TYPE_ATTACK";
    6665      case MSG_TYPE_PROJECTILE: return "MSG_TYPE_PROJECTILE";
    6766      case MSG_TYPE_REMOVE_PROJECTILE: return "MSG_TYPE_REMOVE_PROJECTILE";
     67      case MSG_TYPE_CREATE_GAME: return "MSG_TYPE_CREATE_GAME";
     68      case MSG_TYPE_JOIN_GAME: return "MSG_TYPE_JOIN_GAME";
     69      case MSG_TYPE_LEAVE_GAME: return "MSG_TYPE_LEAVE_GAME";
     70      case MSG_TYPE_GAME_INFO: return "MSG_TYPE_GAME_INFO";
     71      case MSG_TYPE_JOIN_GAME_SUCCESS: return "MSG_TYPE_JOIN_GAME_SUCCESS";
     72      case MSG_TYPE_JOIN_GAME_FAILURE: return "MSG_TYPE_JOIN_GAME_FAILURE";
     73      case MSG_TYPE_JOIN_GAME_ACK: return "MSG_TYPE_JOIN_GAME_ACK";
     74      case MSG_TYPE_PLAYER_JOIN_GAME: return "MSG_TYPE_PLAYER_JOIN_GAME";
     75      case MSG_TYPE_FINISH_GAME: return "MSG_TYPE_FINISH_GAME";
    6876      default: return "Unknown";
    6977   }
    7078}
    71 */
  • common/MessageContainer.h

    r0678d60 r06fc7f7  
    1414using namespace std;
    1515
    16 #define MSG_TYPE_ACK               1
    17 #define MSG_TYPE_REGISTER          2
    18 #define MSG_TYPE_LOGIN             3
    19 #define MSG_TYPE_LOGOUT            4
    20 #define MSG_TYPE_CHAT              5
    21 #define MSG_TYPE_PLAYER            6  // server sends this to update player positions
    22 #define MSG_TYPE_PLAYER_MOVE       7  // client sends this when a player wants to move
    23 #define MSG_TYPE_OBJECT            8
    24 #define MSG_TYPE_REMOVE_OBJECT     9
    25 #define MSG_TYPE_PICKUP_FLAG       10
    26 #define MSG_TYPE_DROP_FLAG         11
    27 #define MSG_TYPE_SCORE             12
    28 #define MSG_TYPE_ATTACK            13
    29 #define MSG_TYPE_PROJECTILE        14
    30 #define MSG_TYPE_REMOVE_PROJECTILE 15
    31 #define MSG_TYPE_CREATE_GAME       16
    32 #define MSG_TYPE_JOIN_GAME         17
    33 #define MSG_TYPE_LEAVE_GAME        18
    34 #define MSG_TYPE_GAME_INFO         19
    35 #define MSG_TYPE_JOIN_GAME_SUCCESS 20
    36 #define MSG_TYPE_JOIN_GAME_FAILURE 21
    37 #define MSG_TYPE_JOIN_GAME_ACK     22
    38 #define MSG_TYPE_PLAYER_JOIN_GAME  23
    39 #define MSG_TYPE_FINISH_GAME       24
     16enum MessageType {
     17   MSG_TYPE_ACK = 1,
     18   MSG_TYPE_REGISTER,
     19   MSG_TYPE_LOGIN,
     20   MSG_TYPE_LOGOUT,
     21   MSG_TYPE_CHAT,
     22   MSG_TYPE_PLAYER,
     23   MSG_TYPE_PLAYER_MOVE,
     24   MSG_TYPE_OBJECT,
     25   MSG_TYPE_REMOVE_OBJECT,
     26   MSG_TYPE_PICKUP_FLAG,
     27   MSG_TYPE_DROP_FLAG,
     28   MSG_TYPE_SCORE,
     29   MSG_TYPE_ATTACK,
     30   MSG_TYPE_PROJECTILE,
     31   MSG_TYPE_REMOVE_PROJECTILE,
     32   MSG_TYPE_CREATE_GAME,
     33   MSG_TYPE_JOIN_GAME,
     34   MSG_TYPE_LEAVE_GAME,
     35   MSG_TYPE_GAME_INFO,
     36   MSG_TYPE_JOIN_GAME_SUCCESS,
     37   MSG_TYPE_JOIN_GAME_FAILURE,
     38   MSG_TYPE_JOIN_GAME_ACK,
     39   MSG_TYPE_PLAYER_JOIN_GAME,
     40   MSG_TYPE_FINISH_GAME
     41};
    4042
    4143typedef struct
     
    6668   void setTimeAcked(unsigned long long time);
    6769
    68    static string getMsgTypeString(int msgType) {
    69       switch(msgType) {
    70          case MSG_TYPE_ACK: return "MSG_TYPE_ACK";
    71          case MSG_TYPE_REGISTER: return "MSG_TYPE_REGISTER";
    72          case MSG_TYPE_LOGIN: return "MSG_TYPE_LOGIN";
    73          case MSG_TYPE_LOGOUT: return "MSG_TYPE_LOGOUT";
    74          case MSG_TYPE_CHAT: return "MSG_TYPE_CHAT";
    75          case MSG_TYPE_PLAYER: return "MSG_TYPE_PLAYER";
    76          case MSG_TYPE_PLAYER_MOVE: return "MSG_TYPE_PLAYER_MOVE";
    77          case MSG_TYPE_OBJECT: return "MSG_TYPE_OBJECT";
    78          case MSG_TYPE_REMOVE_OBJECT: return "MSG_TYPE_REMOVE_OBJECT";
    79          case MSG_TYPE_PICKUP_FLAG: return "MSG_TYPE_PICKUP_FLAG";
    80          case MSG_TYPE_DROP_FLAG: return "MSG_TYPE_DROP_FLAG";
    81          case MSG_TYPE_SCORE: return "MSG_TYPE_SCORE";
    82          case MSG_TYPE_ATTACK: return "MSG_TYPE_ATTACK";
    83          case MSG_TYPE_PROJECTILE: return "MSG_TYPE_PROJECTILE";
    84          case MSG_TYPE_REMOVE_PROJECTILE: return "MSG_TYPE_REMOVE_PROJECTILE";
    85          case MSG_TYPE_CREATE_GAME: return "MSG_TYPE_CREATE_GAME";
    86          case MSG_TYPE_JOIN_GAME: return "MSG_TYPE_JOIN_GAME";
    87          case MSG_TYPE_LEAVE_GAME: return "MSG_TYPE_LEAVE_GAME";
    88          case MSG_TYPE_GAME_INFO: return "MSG_TYPE_GAME_INFO";
    89          case MSG_TYPE_JOIN_GAME_SUCCESS: return "MSG_TYPE_JOIN_GAME_SUCCESS";
    90          case MSG_TYPE_JOIN_GAME_FAILURE: return "MSG_TYPE_JOIN_GAME_FAILURE";
    91          case MSG_TYPE_JOIN_GAME_ACK: return "MSG_TYPE_JOIN_GAME_ACK";
    92          case MSG_TYPE_PLAYER_JOIN_GAME: return "MSG_TYPE_PLAYER_JOIN_GAME";
    93          case MSG_TYPE_FINISH_GAME: return "MSG_TYPE_FINISH_GAME";
    94          default: return "Unknown";
    95       }
    96    }
     70   static string getMsgTypeString(int msgType);
    9771};
    9872
Note: See TracChangeset for help on using the changeset viewer.