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

模拟服务器

开发平台:

C/C++

  1. #include "KEngine.h"
  2. #include "KCore.h"
  3. #ifndef _STANDALONE
  4. #include "../../Headers/IClient.h"
  5. #else
  6. #include "IClient.h"
  7. #endif
  8. #include "KObjSet.h"
  9. #include "KNpcSet.h"
  10. #include "KPlayer.h"
  11. #include "KPlayerSet.h"
  12. #include "KPlayerTeam.h"
  13. #include "KPlayerFaction.h"
  14. #include "KNpc.h"
  15. #include "KSubWorld.h"
  16. #include "LuaFuns.h"
  17. #include "KNewProtocolProcess.h"
  18. #include "KSkills.h"
  19. #include "KItemSet.h"
  20. #include "KBuySell.h"
  21. #include "KSubWorldSet.h"
  22. //#include "MyAssert.h"
  23. #include "Scene/ObstacleDef.h"
  24. #include "KMath.h"
  25. #ifndef _STANDALONE
  26. #include "CoreShell.h"
  27. #include "......HeadersKGmProtocol.h"
  28. #else
  29. #include "KGmProtocol.h"
  30. #endif
  31. BOOL TextMsgProcessGMCmd(int nPlayerIdx, const char * pGMCmd, int nLen);
  32. void KNewProtocolProcess::P_ProcessGMExecute(IClient* pTransfer,
  33.  DWORD dwFromIP, DWORD dwFromRelayID,
  34.  int nPlayerIndex, BYTE* pData, int nDataSize)
  35. {
  36. _ASSERT(pf_gamemaster == *pData && gm_c2s_execute == *(pData + 1));
  37. GM_EXECUTE_COMMAND* pGMData = (GM_EXECUTE_COMMAND*)pData;
  38. TextMsgProcessGMCmd(nPlayerIndex, ((const char*)pData) + sizeof(GM_EXECUTE_COMMAND), pGMData->wLength);
  39. }
  40. void KNewProtocolProcess::P_ProcessGMFindPlayer(IClient* pTransfer,
  41. DWORD dwFromIP, DWORD dwFromRelayID,
  42. int nPlayerIndex, BYTE* pData, int nDataSize)
  43. {
  44. char szBuffer[sizeof(RELAY_ASKWAY_DATA) + sizeof(GM_GET_PLAYER_AT_GW_SYNC) + 64];
  45. _ASSERT(pf_gamemaster == *pData && gm_c2s_findplayer == *(pData + 1));
  46. if (nPlayerIndex <= 0 && nPlayerIndex >= MAX_PLAYER)
  47. return;
  48. int i = Player[nPlayerIndex].m_nNetConnectIdx;
  49. if (i >= 0)
  50. {
  51. if (Player[nPlayerIndex].m_dwID && !Player[nPlayerIndex].m_bExchangeServer)
  52. {
  53. RELAY_ASKWAY_DATA* pAskwayData = (RELAY_ASKWAY_DATA*)szBuffer;
  54. pAskwayData->ProtocolFamily = pf_relay;
  55. pAskwayData->ProtocolID = relay_c2c_askwaydata;
  56. pAskwayData->nFromIP = 0;
  57. pAskwayData->nFromRelayID = 0;
  58. pAskwayData->seekRelayCount = 0;
  59. pAskwayData->seekMethod = rm_gm;
  60. pAskwayData->wMethodDataLength = 0;
  61. pAskwayData->routeDateLength = sizeof(GM_GET_PLAYER_AT_GW_SYNC);
  62. GM_GET_PLAYER_AT_GW_SYNC* pGetPlayerData = (GM_GET_PLAYER_AT_GW_SYNC*)(pAskwayData + 1);
  63. strncpy(pGetPlayerData->AccountName, ((GM_HEADER*)pData)->AccountName, sizeof(pGetPlayerData->AccountName));
  64. strncpy(pGetPlayerData->szCurrentRoleName, Player[nPlayerIndex].m_PlayerName, sizeof(Player[nPlayerIndex].m_PlayerName));
  65. Npc[Player[nPlayerIndex].m_nIndex].GetMpsPos(&(pGetPlayerData->nX), &(pGetPlayerData->nY));
  66. pGetPlayerData->nX /= 32;
  67. pGetPlayerData->nY /= 32;
  68. pGetPlayerData->nWorldID = SubWorld[Npc[Player[nPlayerIndex].m_nIndex].m_SubWorldIndex].m_SubWorldID;
  69. pGetPlayerData->ProtocolFamily = pf_gamemaster;
  70. pGetPlayerData->ProtocolType = gm_s2c_findplayer;
  71. pTransfer->SendPackToServer(szBuffer, sizeof(RELAY_ASKWAY_DATA) + sizeof(GM_GET_PLAYER_AT_GW_SYNC));
  72. }
  73. }
  74. }
  75. void KNewProtocolProcess::ExecuteLocalServer(const void * const pData, const size_t datalength)
  76. {
  77. if (pData && datalength > 0)
  78. {
  79. if (pf_gamemaster == *(char*)pData && gm_c2s_execute == *((char*)pData + 1))
  80. {
  81. GM_EXECUTE_COMMAND* pGMData = (GM_EXECUTE_COMMAND*)pData;
  82. TextMsgProcessGMCmd(-1, ((const char*)pData) + sizeof(GM_EXECUTE_COMMAND), pGMData->wLength);
  83. }
  84. }
  85. }