//向WS发送取金钱消息 void CMailManager::SendGetGoldFromMailToWS(CGUID &guid,CPlayer *pPlayer) { if (pPlayer) { CMail* pMail = GetMail(guid); if (pMail && (pMail->GetType()==AFFIX_MAIL || pMail->GetType()==SYSTEM_MAIL)) { long lGold = pMail->GetGold(); if(pPlayer->GetMoney()+lGold>CGlobeSetup::GetSetup()->dwGoldCoinLimit || lGold<=0) { char* strRes=CStringReading::LoadString(21,38); if(strRes) { pPlayer->SendNotifyMessage(strRes); } return ; } //向WS发送取金钱消息 CMessage OperaGoldmsg(MSG_S2W_MAIL_OPERA_GOLD); OperaGoldmsg.Add(guid); OperaGoldmsg.Send(); } } }
nsresult nsPop3Service::GetNewMail(nsIMsgWindow *aMsgWindow, nsIUrlListener * aUrlListener, nsIMsgFolder *aInbox, nsIPop3IncomingServer *aPopServer, nsIURI ** aURL) { return GetMail(PR_TRUE /* download */, aMsgWindow, aUrlListener, aInbox, aPopServer, aURL); }
NS_IMETHODIMP nsPop3Service::CheckForNewMail(nsIMsgWindow* aMsgWindow, nsIUrlListener * aUrlListener, nsIMsgFolder *aInbox, nsIPop3IncomingServer *aPopServer, nsIURI ** aURL) { return GetMail(PR_FALSE /* don't download, just check */, aMsgWindow, aUrlListener, aInbox, aPopServer, aURL); }
//从邮箱取物品放到背包 void CMailManager::GetGoodsFromMail(CGUID &guid,CPlayer *pPlayer,long lIndex) { CMail *pMail = GetMail(guid); if (pMail && pPlayer && pMail->GetType()!=PAYGOLD_MAIL && pMail->GetReceiverGuid()==pPlayer->GetExID())//strcmp(pMail->GetReceiver().c_str(),pPlayer->GetName())==0 { pMail->SendGetGoodsMsg(pPlayer,lIndex); } }
//发送取物品给客户端 void CMailManager::SendGetGoodsGSToClient(CGUID &MailGuid,CGUID &PlayerGuid,long lIndex) { CMail *pMail = GetMail(MailGuid); CPlayer *pPlayer = GetGame()->FindPlayer(PlayerGuid); if (pMail && pPlayer) { pMail->GetGoodsFromContainer(pPlayer,lIndex); } }
//从邮箱中取金钱 void CMailManager::GetGoldFromMail(CGUID &guid,CPlayer *pPlayer) { if (pPlayer) { CMail* pMail = GetMail(guid); if (pMail && (pMail->GetType()==AFFIX_MAIL || pMail->GetType()==SYSTEM_MAIL)) { long lGold = pMail->GetGold(); if(pPlayer->GetMoney()+lGold>CGlobeSetup::GetSetup()->dwGoldCoinLimit || lGold<=0) { char* strRes=CStringReading::LoadString(21,38); if(strRes) { pPlayer->SendNotifyMessage(strRes); } return ; } if (pPlayer->SetMoney(lGold+pPlayer->GetMoney(),2)) { pMail->SetReject(0); pMail->SetGold(0); if (pMail->GetMGoodsContainer().size()==0 && pMail->GetSGood().size()==0 && pMail->GetType()!=SYSTEM_MAIL && pMail->GetType()<MAX_MAIL) { pMail->SetType(COMMON_MAIL); } } else { CMessage msg(MSG_S2C_MAIL_GET_GOLD_RESULT); msg.Add(guid); msg.Add((BYTE)0); msg.SendToPlayer(pPlayer->GetExID()); return; } //取金钱日志 long lGoodsNum = 0; for (vector<CGoods*>::iterator it=pMail->GetMGoodsContainer().begin(); it!=pMail->GetMGoodsContainer().end(); ++it) { lGoodsNum += (*it)->GetAmount(); } GetGameLogInterface()->logT603_GetGold_mail_log(pMail->GetExID(),pMail->GetReceiver().c_str(),pMail->GetWriter().c_str(),pMail->GetType(),lGold, lGoodsNum,pMail->GetSGood().size()); CMessage msg(MSG_S2C_MAIL_GET_GOLD_RESULT); msg.Add(guid); msg.Add((BYTE)1); msg.SendToPlayer(pPlayer->GetExID()); } } }
/* PPROGRAM: printer_task This task creates a mailbox and receives strings, which then prints to the terminal. Conceptually, this is a "service", started by boot_task and ending when boot_task asks it to quit. */ int printer_task(int argl, void* args) { int ok; Message m; ok = CreateMailBox("printer"); assert(ok==0); // synchronize with my parent, he waited for me to create my mailbox SendPort(GetPPid(), 0L); // print loop while(1) { GetMail("printer", &m); if(m.type == PRINTER_PRINT) printf("Process %d: %s",m.sender,(char*)(m.data)); else if(m.type == PRINTER_QUIT) { /* only if parent says so! */ if(m.sender==GetPPid()) break; } /* else ignore */ } return 0; }
bool MailBox::GetMail(DWORD canID, MailItem& mailItem) { return GetMail(canID, (BYTE)0, (BYTE)0, mailItem); }