void DoC2SMailSend( CMessage *pMsg ) { CPlayer *pPlayer = pMsg->GetPlayer(); if (NULL == pPlayer) { return; } //玩家在交易或摆摊中不能交易 if (pPlayer->GetCurrentProgress()==CPlayer::PROGRESS_OPEN_STALL || pPlayer->GetCurrentProgress()==CPlayer::PROGRESS_TRADING ) { return; } CGUID NpcGuid = NULL_GUID; pMsg->GetGUID(NpcGuid); CServerRegion *pRegion = pMsg->GetRegion(); if (NULL==pRegion) { return; } CBaseObject *pShape = pRegion->FindChildObject(TYPE_MONSTER,NpcGuid); CMonster *pMailNpc = dynamic_cast<CMonster*>(pShape); //if (pMailNpc && strcmp(pMailNpc->GetOriginName(),"10000Email")==0 && pMailNpc->Distance( pPlayer ) < 8)// --attention //{ tagMailParam *pMailParam = OBJ_CREATE(tagMailParam); long lReceiver = pMsg->GetLong(); //收信人个数 if (lReceiver > 100) { return; } for (int i=0; i<lReceiver; ++i) { char strReceiver[128]; pMsg->GetStr(strReceiver,GlobalSetup::GetSetup()->lMaxName+1); if (lstrlen(strReceiver)>=GlobalSetup::GetSetup()->lMaxName) { GameManager::GetInstance()->GetMailManager()->SendMailFailedToClient(pPlayer->GetExID(),MAIL_SENDING_FAILED_INVALID_MAXNAME); continue; } list<string>::iterator it= find((pMailParam->strReceiverList).begin(),(pMailParam->strReceiverList).end(),strReceiver);// (pMailParam->strReceiverList).f if (it==(pMailParam->strReceiverList).end()) { (pMailParam->strReceiverList).push_back(strReceiver); } } char strTemp[2048]; pMsg->GetStr(strTemp,GlobalSetup::GetSetup()->lMaxSubject+1); //主题 if (lstrlen(strTemp)>=GlobalSetup::GetSetup()->lMaxSubject) { GameManager::GetInstance()->GetMailManager()->SendMailFailedToClient(pPlayer->GetExID(),MAIL_SENDING_FAILED_INVALID_MAXSUBJECT); return; } pMailParam->strSubject = strTemp; pMsg->GetStr(strTemp,GlobalSetup::GetSetup()->lMaxText+1); //内容 if (lstrlen(strTemp)>=GlobalSetup::GetSetup()->lMaxText) { GameManager::GetInstance()->GetMailManager()->SendMailFailedToClient(pPlayer->GetExID(),MAIL_SENDING_FAILED_INVALID_MAXTEXT); return; } pMailParam->strText = strTemp; pMailParam->lGold = pMsg->GetLong(); //金币 pMailParam->lType = pMsg->GetByte(); //类型 ////普通物品 long lCGoodNum = pMsg->GetLong(); if (lCGoodNum>MAXGOODNUM) { char pszGuid[50]=""; pPlayer->GetExID().tostring(pszGuid); Log4c::Warn(ROOT_MODULE,FormatText("GS_GOODS_91",pPlayer->GetName(),pszGuid,lCGoodNum));//%s(ID:%s) 玩家发送物品的数量:%d超过限制(此玩家利用非常规方式发送消息) OBJ_RELEASE(tagMailParam, pMailParam); return; } for (int i=0; i<lCGoodNum; ++i) { listGoods *ptgGoods = OBJ_CREATE(listGoods); pMsg->GetGUID(ptgGoods->goodsguid); ptgGoods->lNum = pMsg->GetLong(); ptgGoods->lContainerID = pMsg->GetDWord(); ptgGoods->lPos = pMsg->GetDWord(); pMailParam->Goodslist.push_back(ptgGoods); } //} pMailParam->strWriter = pPlayer->GetName(); pMailParam->WriterGuid = pPlayer->GetExID(); pMailParam->bReject = 1; //! 发信 CMail *pMail = OBJ_CREATE_PVOID(CMail, (void*)pMailParam); if (pMail->GetType()==SYSTEM_MAIL || pMail->GetGold()<0 || pMail->GetType()>=SENDGOLD_MAIL) { pMail->DeleteMailGoods(); OBJ_RELEASE(CMail, pMail); return; } GameManager::GetInstance()->GetMailManager()->AddMail(pMail,pPlayer);//“在这里发送 MSG_S2W_MAIL_SEND 消息给 worldserver // } }