struct.h
上传用户:sycq158
上传日期:2008-10-22
资源大小:15361k
文件大小:1k
源码类别:

游戏

开发平台:

Visual C++

  1. #ifndef _PLAYER_H
  2. #define _PLAYER_H
  3. #define OP_READ 0
  4. #define OP_WRITE 1
  5. #define OP_ACCEPT 2
  6. #define DEFBUFFERSIZE 64
  7. #define MAXTABLE 2
  8. #define MAXPLAYER 4
  9. #define SAFE_DELETE(p)       { if(p) { delete (p);     (p)=NULL; } }
  10. #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)= NULL; } }
  11. #define INCSCOPE(x,min,max) (++(x)>=(max))?((x)=(min)):(x)
  12. #define DESSCOPE(x,min,max) (--(x)<=(min))?((x)=(max)):(x)
  13. // JUDGE
  14. // PLAYER
  15. typedef struct _PLAYER {
  16. DWORD status;
  17. SOCKET socket;
  18. // _PLAYER *prev;
  19. _PLAYER *next;
  20. LPVOID table;
  21. int seat;
  22. } PLAYER, * LPPLAYER;
  23. // OVERLAPPEDEX
  24. typedef struct _OVERLAPPEDEX {
  25.     OVERLAPPED      ol;
  26.     SOCKET          socket;
  27.     int             op;
  28.     WSABUF          wbuf;
  29. char  buf[DEFBUFFERSIZE];
  30. DWORD           bytes;
  31. LPPLAYER ppla;
  32. } OVERLAPPEDEX, * LPOVERLAPPEDEX;
  33. // FOOD
  34. typedef struct _FOOD {
  35. bool exsit;
  36. DWORD existnum;
  37. DWORD notexistnum;
  38. DWORD counter;
  39. } FOOD, * LPFOOD;
  40. // GROUP
  41. typedef struct _GAMETABLE {
  42. DWORD status;
  43. PLAYER *players[MAXPLAYER];
  44. FOOD food;
  45. int max;
  46. int current;
  47. int counter;
  48. } GAMETABLE, * LPGAMETABLE;
  49. #define DEFFOODEXFRAME 450 // 30fps * 15sec
  50. #define DEFFOODNOTEXFRAME 150 // 30fps * 5sec
  51. enum FoodType { FOOD_SHIP, FOOD_KEEPBASE, FOOD_POWERUP, FOOD_BLOODUP,
  52. FOOD_SPEEDUP, FOOD_MAX };
  53. #endif // _PLAYER_H