home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 15 / Example 15.1 / network_messages.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-05-31  |  1.3 KB  |  75 lines

  1. #include <windows.h>
  2. #include <dplay8.h>     // directplay
  3. #include <vector>
  4. #include "debug.h"
  5.  
  6. #define GAME_MSG_TEXT 0
  7. #define GAME_MSG_COMMAND 1
  8. #define GAME_MSG_PLAYER 2
  9.  
  10. struct SESSION
  11. {
  12.     SESSION(char _name[], DPN_APPLICATION_DESC _desc, IDirectPlay8Address *_address)
  13.     {
  14.         name = _name;
  15.         desc = _desc;
  16.         if(_address != NULL)_address->Duplicate(&address);
  17.     }
  18.  
  19.     std::string name;
  20.     DPN_APPLICATION_DESC desc;
  21.     IDirectPlay8Address *address;
  22. };
  23.  
  24. struct DP_PLAYER
  25. {
  26.     DP_PLAYER(){}
  27.     DP_PLAYER(DPNID _id, char _name[])
  28.     {
  29.         id = _id;
  30.         strcpy(name, _name);
  31.     }
  32.  
  33.     DPNID id;
  34.     char name[64];
  35. };
  36.  
  37. struct RTS_MSG
  38. {
  39.     DWORD type;
  40. };
  41.  
  42. struct MSG_COMMAND : public RTS_MSG        //Game command
  43. {
  44.     MSG_COMMAND(DWORD cmd, DWORD att){command = cmd; attribute = att; type = GAME_MSG_COMMAND;}
  45.     DWORD command;        //0 = Ask for Name, 
  46.     DWORD attribute;
  47. };
  48.  
  49. struct MSG_TEXT : public RTS_MSG        //Text Message
  50. {
  51.     MSG_TEXT(char txt[])
  52.     {
  53.         //copy text
  54.         strcpy(text, txt);
  55.  
  56.         //Set message type
  57.         type = GAME_MSG_TEXT;
  58.     }
  59.  
  60.     char text[100];
  61. };
  62.  
  63. struct MSG_PLAYER : RTS_MSG                //Player Message
  64. {
  65.     MSG_PLAYER(DP_PLAYER dpp, BYTE _operation)
  66.     {
  67.         player = dpp;
  68.         operation = _operation;            //0 = Add Player, 1 = Remove Player, 2 = Get Name
  69.         type = GAME_MSG_PLAYER;
  70.     }
  71.  
  72.     DP_PLAYER player;
  73.     BYTE operation;
  74. };
  75.