CGem * CGemM::findGem(DWORD dwCountryID) { struct execAll : public execEntry<CGem> { DWORD _dwCountryID; CGem *_gem; execAll(DWORD dwCountryID) { _dwCountryID = dwCountryID; _gem = NULL; } ~execAll() {} bool exec(CGem *pGem) { if (pGem) { if (pGem->dwCountryID == _dwCountryID) { _gem = pGem; return false; } } return true; } }; execAll myList(dwCountryID); execEveryOne(myList); return myList._gem; }
CRelation* CRelationManager::getMarryRelation() { struct findall : public execEntry<CRelation> { CRelation* _pRelation; findall() { _pRelation = NULL; } ~findall(){} bool exec(CRelation* pRelation) { if (pRelation && pRelation->type == Cmd::RELATION_TYPE_LOVE) { _pRelation = pRelation; return false; } return true; } }; findall find_marry; execEveryOne(find_marry); return find_marry._pRelation; }
CRelation* CRelationManager::getRelationByType(int relationType) { struct findall : public execEntry<CRelation> { CRelation* _pRelation; int _relationType; findall(int relationType):_relationType(relationType) { _pRelation = NULL; } ~findall(){} bool exec(CRelation* pRelation) { if (pRelation && pRelation->type == _relationType) { _pRelation = pRelation; return false; } return true; } }; findall find_marry(relationType); execEveryOne(find_marry); return find_marry._pRelation; }
void CGemM::forceEnd() { struct execAll : public execEntry<CGem> { std::vector<CGem *> _removeList; execAll() {} void removeList() { std::vector<CGem *>::iterator tIterator; for (tIterator = _removeList.begin(); tIterator != _removeList.end(); tIterator++) { CGem *cd = *tIterator; CGemM::getMe().removeEntry(cd); SAFE_DELETE(cd); } _removeList.clear(); } ~execAll() {} bool exec(CGem *pGem) { pGem->setReadyOverState(); if (pGem->state == CGem::GEM_OVER) { // TODO 结束处理 _removeList.push_back(pGem); } return true; } }; execAll myList; execEveryOne(myList); myList.removeList(); }
bool TeamManager::canPutSkill() { SceneUser *leader = SceneUserManager::getMe().getUserByTempID(getLeader()); if (leader) { CheckAllInOneScreenExec exec(leader); execEveryOne(exec); if (!exec.isOk) { if (!giveupstatus) { giveupstatus = true; giveuptime.now(); giveuptime.addDelay(120000); return true; } else { if (SceneTimeTick::currentTime.msecs() > giveuptime.msecs()) { giveupstatus = false;///将状态初始化回去。 return false; } else return true; } } else { giveupstatus = false; return true; } } return false; }
void CGemM::timer() { struct execAll : public execEntry<CGem> { std::vector<CGem *> _removeList; execAll() {} void removeList() { std::vector<CGem *>::iterator tIterator; for (tIterator = _removeList.begin(); tIterator != _removeList.end(); tIterator++) { CGem *cd = *tIterator; CGemM::getMe().removeEntry(cd); SAFE_DELETE(cd); } _removeList.clear(); } ~execAll() {} bool exec(CGem *pGem) { if (!pGem->isActivePeriod()) { pGem->setReadyOverState(); } if (pGem->state == CGem::GEM_OVER) { // TODO 结束处理 _removeList.push_back(pGem); } return true; } }; if (0) { //护宝任务不开放 execAll myList; execEveryOne(myList); myList.removeList(); struct tm tv1; time_t timValue = time(NULL); zRTime::getLocalTime(tv1,timValue); if (tv1.tm_hour==8 && tv1.tm_min>=0 && tv1.tm_min<2) { CCountryM::getMe().beginGem(); } if (tv1.tm_hour==14 && tv1.tm_min>=0 && tv1.tm_min<2) { CCountryM::getMe().beginGem(); } if (tv1.tm_hour==20 && tv1.tm_min>=0 && tv1.tm_min<2) { CCountryM::getMe().beginGem(); } } }
/** * \brief 发送消息给组队 * \param user 消息发送者 * \param cmd 消息体 * \param cmdLen 消息长度 */ void TeamManager::sendCmdToTeam(SceneUser *user,void *cmd,DWORD cmdLen) { SendCmdExec exec(cmd,cmdLen); execEveryOne(exec); }