void CExchangeGoods::ExchgLoseStatus() { CPlayer *pPlayer = static_cast<CPlayer *>(this); if (!pPlayer) return; // 首先看看是否在等待交易回应 if (pPlayer->m_ChxSentOut.size()) { for (CPlayer::CHXQuestList::iterator it = pPlayer->m_ChxSentOut.begin(); it != pPlayer->m_ChxSentOut.end(); ++it) { CPlayer *pDestPlayer = (CPlayer *)GetPlayerByGID(it->first)->DynamicCast(IID_PLAYER); if (!pDestPlayer) continue; MY_ASSERT(pDestPlayer->m_CurHp); pDestPlayer->m_ChxGetIn.erase(pPlayer->GetGID()); } pPlayer->m_ChxSentOut.clear(); } // 是否在等待响应交易请求 if (pPlayer->m_ChxGetIn.size()) { CPlayer::CHXQuestList tempCopy(pPlayer->m_ChxGetIn); for (CPlayer::CHXQuestList::iterator it = tempCopy.begin(); it != tempCopy.end(); ++it) { CPlayer *pQuest = (CPlayer *)GetPlayerByGID(it->first)->DynamicCast(IID_PLAYER); if (pQuest) { MY_ASSERT(pQuest->m_CurHp); // 超时,拒绝 SQQuestExchangeMsg rejectMsg; rejectMsg.bAccept = false; rejectMsg.dnidClient = 0; rejectMsg.dwDestGID = pPlayer->GetGID(); rejectMsg.dwSrcGID = it->first; RecvQuestExchangeMsg(&rejectMsg, true); } else { MY_ASSERT(0); pPlayer->m_ChxGetIn.erase(it->first); } } MY_ASSERT(pPlayer->m_ChxGetIn.empty()); } // 是否处于交易中 if (pPlayer->InExchange()) { CExchangeGoods::TheEnd(); } }
void conversation(BigBoss *snake) { // BigBoss *tempCopy = new BigBoss(*snake); nao funcionara, pois nao criara o objeto certo. My_unique_ptr<BigBoss> tempCopy(snake->clone()); // RAII example... tempCopy->speak(); // no need to delete tempCopy }