cmdgivedroppick.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:12k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #include "XMudOS.h"
  3. #include "CommandCheck.h"
  4. #include "CmdPlayerLogon.h"
  5. #include "mapMapInfo.h"
  6. #include "npcNpc.h"
  7. #include "common.h"
  8. #include "hash.h"
  9. extern rmfullglobals myglobs;
  10. extern CList <TClientConData *,TClientConData* >playersocketlist;
  11. extern CList <CBaseMap*,CBaseMap*>maplist;
  12. void CCommandCheck::GiveProc(LPVOID pvPlayer,char *szWho,char * szGoods,char *szAmount,char *Result)
  13. {
  14. CBaseMap * lpDataMap;
  15. CPlayerInfo *lpPlayerInfo,*lpOtherPlayerInfo;
  16. CNpc * lpNpc;
  17. CGoods *lpGoods = NULL,*lpGiveGoods=NULL,*lpOppEquip=NULL;
  18. BOOL bFindOppPlayer = FALSE;
  19. BOOL bFindOppNPC = FALSE;
  20. CString szRet;
  21. CString szStatus;
  22. int nAmount = 0;
  23. int nWeight=0;
  24. POSITION pos,lastpos;
  25. BOOL bFindGoods = FALSE;
  26. BOOL bmore = FALSE;
  27. lpPlayerInfo = (CPlayerInfo*)pvPlayer;
  28. if (lpPlayerInfo->nStatus != AOS_none) return;
  29. POSITION pMapPosite = lpPlayerInfo->pMapPosite;
  30. lpDataMap = maplist.GetAt(lpPlayerInfo->pMapPosite);
  31. EnterCriticalSection(&myglobs.csMaplist);
  32. EnterCriticalSection(&myglobs.csPlayerData);
  33. pos = lpDataMap->listplayer.GetHeadPosition();
  34. while(pos != NULL){
  35. lastpos = pos;
  36. lpOtherPlayerInfo = lpDataMap->listplayer.GetNext(pos);
  37. if (lpOtherPlayerInfo == NULL) {
  38. AddRecordMsg("ERROR NULL pointer in GiveProc, lpOtherPlayerInfo");
  39. lpDataMap->listplayer.RemoveAt(lastpos);
  40. continue;
  41. }
  42. if (strcmp(lpOtherPlayerInfo->szCheck, SZAOBJCHECK)) {
  43. AddRecordMsg("ERROR Bad data in GiveProc, lpOtherPlayerInfo");
  44. lpDataMap->listplayer.RemoveAt(lastpos);
  45. continue;
  46. }
  47. if((!strcmp(lpOtherPlayerInfo->szEName,szWho) || 
  48.    !strcmp(lpOtherPlayerInfo->szCName,szWho)) &&
  49. (lpOtherPlayerInfo->nStatus != AOS_dead)){
  50. bFindOppPlayer = TRUE;
  51. break;
  52. }
  53. }
  54. if(!bFindOppPlayer){
  55. pos = lpDataMap->listNpc.GetHeadPosition();
  56. while(pos != NULL){
  57. lpNpc = lpDataMap->listNpc.GetNext(pos);
  58. if((!strcmp(lpNpc->szEName,szWho) || 
  59.    !strcmp(lpNpc->szCName,szWho))
  60. && (lpNpc->nStatus!=AOS_dead)){
  61. bFindOppNPC = TRUE;
  62. break;
  63. }
  64. }
  65. if(!bFindOppNPC){
  66. szRet.Format("%s FAIL 癸よ