ProcessMerchants.cpp
上传用户:szopptop
上传日期:2013-04-23
资源大小:1047k
文件大小:2k
源码类别:

模拟服务器

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. CMirMap* GetMap(char *pszMapName);
  3. /*
  4. void DoRunRace(CNPCObject* pNPCObject)
  5. {
  6. switch (pNPCObject->m_wObjectType)
  7. {
  8. case _OBJECT_NPC:
  9. ((CChickenObject*)pNPCObject)->RunRace();
  10. break;
  11. }
  12. }
  13. */
  14. void WINAPI ProcessMerchants()
  15. {
  16. DWORD dwCurrentTick;
  17. dwCurrentTick = GetTickCount();
  18. if (!g_fInitMerchant)
  19. {
  20. for (int i = 0; i < g_nNumOfMurchantInfo; i++)
  21. {
  22. CMirMap* pMap = GetMap(g_pMerchantInfo[i].szMapName);
  23. if (pMap)
  24. {
  25. CMerchantObject* pMerchantObject = new CMerchantObject;
  26. pMerchantObject->m_wObjectType = _OBJECT_NPC;
  27. pMerchantObject->m_nIndex = i;
  28. pMerchantObject->m_tFeature.btGender = 2;
  29. pMerchantObject->m_tFeature.btWear = (BYTE)g_pMerchantInfo[i].sBody;
  30. pMerchantObject->m_nCurrX = g_pMerchantInfo[i].nPosX;
  31. pMerchantObject->m_nCurrY = g_pMerchantInfo[i].nPosY;
  32. pMerchantObject->m_nDirection = g_pMerchantInfo[i].sFace;
  33. pMerchantObject->m_pMap = pMap;
  34. memcpy(pMerchantObject->m_szName, g_pMerchantInfo[i].szNPCName, memlen(g_pMerchantInfo[i].szNPCName));
  35. pMerchantObject->m_pMap->AddNewObject(pMerchantObject->m_nCurrX, pMerchantObject->m_nCurrY, OS_MOVINGOBJECT, pMerchantObject);
  36. // pMerchantObject->AddRefMsg(RM_TURN, pMerchantObject->m_nDirection, pMerchantObject->m_nCurrX, pMerchantObject->m_nCurrY, 0, pMerchantObject->m_szName);
  37. g_xMerchantObjList.AddNewNode(pMerchantObject);
  38. }
  39. }
  40. g_fInitMerchant = TRUE;
  41. }
  42. if (g_xMerchantObjList.GetCount())
  43. {
  44. PLISTNODE pListNode = g_xMerchantObjList.GetHead();
  45. while (pListNode)
  46. {
  47. CMerchantObject* pMerchantObject = g_xMerchantObjList.GetData(pListNode);
  48. if (dwCurrentTick - pMerchantObject->m_dwRunTime >= pMerchantObject->m_dwRunNextTick)
  49. {
  50. pMerchantObject->m_dwRunTime = dwCurrentTick;
  51. if (dwCurrentTick - pMerchantObject->m_dwSearchTime >= pMerchantObject->m_dwSearchTick)
  52. {
  53. pMerchantObject->m_dwSearchTime = dwCurrentTick;
  54. pMerchantObject->SearchViewRange();
  55. }
  56. // DoRunRace(pNPCObject);
  57. pMerchantObject->RunRace();
  58. }
  59. pListNode = g_xMerchantObjList.GetNext(pListNode);
  60. }
  61. }
  62. }