KWorldMsg.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:2k
源码类别:

模拟服务器

开发平台:

C/C++

  1. #ifndef KWorldMsgH
  2. #define KWorldMsgH
  3. #include "KCore.h"
  4. #include "KNode.h"
  5. enum WORLDMSG // param1, param2, param3
  6. {
  7. GWM_MAP_BEGIN = 0,
  8. GWM_NPC_BEGIN = 1000,
  9. GWM_NPC_DEL, // npcidx
  10. GWM_NPC_CHANGE_REGION, // srcregion, desregion, npcidx
  11. // zroc 说明:src dest 在 server 上用 idx,在客户端用 ID
  12. GWM_OBJ_BEGIN = 2000,
  13. GWM_OBJ_DEL,
  14. GWM_OBJ_CHANGE_REGION, // srcregion, desregion, objidx
  15. GWM_ITEM_BEGIN = 3000,
  16. GWM_MISSLE_BEGIN = 4000,
  17. GWM_MISSLE_DEL,
  18. GWM_MISSLE_CHANGE_REGION, // srcregion, desregion, misidx
  19. GWM_PLAYER_BEGIN = 5000,
  20. GWM_PLAYER_SKILL,
  21. GWM_PLAYER_WALKTO,
  22. GWM_PLAYER_RUNTO,
  23. GWM_PLAYER_JUMPTO,
  24. GWM_PLAYER_CHANGE_REGION,
  25. };
  26. enum WORLDRETURN
  27. {
  28. GWR_SUCCESS,
  29. GWR_FALSE,
  30. GWR_SKILL_NOTENOUGHMANA,
  31. GWR_SKILL_NOTENOUGHLIFE,
  32. GWR_SKILL_NOTENOUGHSTAMINA,
  33. GWR_SKILL_NOTENOUGHMONEY,
  34. GWR_SKILL_HAVENOSKILL,
  35. GWR_SKILL_GTMAXTIMES, //该技能目前发出的数量过多,请等一会
  36. GWR_SKILL_LTPERCASTTIME, //无法发该技能需要等待一会时间
  37. };
  38. class KWorldMsgNode : public KNode
  39. {
  40. public:
  41. DWORD m_dwMsgType;
  42. int m_nParam[3];
  43. };
  44. #ifndef TOOLVERSION
  45. class KWorldMsg
  46. #else
  47. class CORE_API KWorldMsg
  48. #endif
  49. {
  50. private:
  51. KList m_LocalMsgQueue;
  52. public:
  53. BOOL Send(DWORD dwMsgType, int nParam1 = 0, int nParam2 = 0, int nParam3 = 0);
  54. BOOL Send(KWorldMsgNode *pMsg);
  55. BOOL Peek(KWorldMsgNode *pMsg, DWORD nNext = 0);
  56. BOOL Get(KWorldMsgNode *pMsg);
  57. void Clear();
  58. };
  59. inline BOOL KWorldMsg::Send(DWORD dwMsgType, int nParam1, int nParam2, int nParam3)
  60. {
  61. KWorldMsgNode *pNode = NULL;
  62. pNode = new KWorldMsgNode;
  63. if (!pNode)
  64. return FALSE;
  65. pNode->m_dwMsgType = dwMsgType;
  66. pNode->m_nParam[0] = nParam1;
  67. pNode->m_nParam[1] = nParam2;
  68. pNode->m_nParam[2] = nParam3;
  69. m_LocalMsgQueue.AddTail(pNode);
  70. return TRUE;
  71. }
  72. inline BOOL KWorldMsg::Send(KWorldMsgNode *pMsg)
  73. {
  74. if (!pMsg)
  75. return FALSE;
  76. m_LocalMsgQueue.AddTail(pMsg);
  77. return TRUE;
  78. }
  79. extern void g_MessageToChar(int Id, WORLDRETURN rt);
  80. extern void g_MessageToAll(WORLDRETURN rt);
  81. extern void g_MessageToCamp(int nCampId, WORLDRETURN rt);
  82. extern void g_MessageToChar(int nId, char * szMessage);
  83. extern void g_MessageToAll(char * szMessage);
  84. extern void g_MessageToCamp(int nCampId, char * szMessage);
  85. extern char* g_GWR2Message(WORLDRETURN gwrMessage);
  86. //extern KWorldMsg g_WorldMsg;
  87. #endif