📄 warsystem.cpp
字号:
list<ActiveWarInfo>::const_iterator itr = find( m_ActiveWars.begin(), m_ActiveWars.end(), ActiveWarInfo(zoneID) ); if (itr!=m_ActiveWars.end()) { bHasCastleActiveWar = true; guildID = (*itr).AttackGuildID; } __LEAVE_CRITICAL_SECTION(m_MutexActiveWars) return bHasCastleActiveWar; __END_CATCH}bool WarSystem::hasCastleActiveWar( ZoneID_t zoneID ) const throw(Error){ __BEGIN_TRY bool bHasCastleActiveWar = false; __ENTER_CRITICAL_SECTION(m_MutexActiveWars) list<ActiveWarInfo>::const_iterator itr = find( m_ActiveWars.begin(), m_ActiveWars.end(), ActiveWarInfo(zoneID) ); if (itr!=m_ActiveWars.end()) { bHasCastleActiveWar = true; } __LEAVE_CRITICAL_SECTION(m_MutexActiveWars) /* // deadlock(Zone狼 EffectHasBloodBible::affect(Item)俊辑, 谍单档 乐摆瘤父 -_-;) 巩力肺 牢窍咯 // 角青吝牢 傈里俊 措茄 府胶飘甫 蝶肺 爱绊 贸府茄促. __ENTER_CRITICAL_SECTION(m_Mutex) const RecentSchedules::container_type& schedules = m_RecentSchedules.getSchedules(); RecentSchedules::const_iterator itr = schedules.begin(); for( ; itr != schedules.end(); itr++ ) { War* pWar = dynamic_cast<War*>( (*itr)->getWork() ); if( pWar == NULL ) continue; if( pWar->getCastleZoneID() == zoneID ) { m_Mutex.unlock(); return true; } } __LEAVE_CRITICAL_SECTION(m_Mutex) */ return bHasCastleActiveWar; __END_CATCH}WarSchedule* WarSystem::getActiveWarSchedule( ZoneID_t zoneID ) throw(Error){ __BEGIN_TRY WarSchedule* pWarSchedule = NULL; __ENTER_CRITICAL_SECTION(m_Mutex) pWarSchedule = getActiveWarSchedule_LOCKED( zoneID ); __LEAVE_CRITICAL_SECTION(m_Mutex) return pWarSchedule; __END_CATCH} WarSchedule* WarSystem::getActiveWarSchedule_LOCKED( ZoneID_t zoneID ) throw(Error){ __BEGIN_TRY const RecentSchedules::container_type& schedules = m_RecentSchedules.getSchedules(); RecentSchedules::const_iterator itr = schedules.begin(); for( ; itr != schedules.end(); itr++ ) { WarSchedule* pWarSchedule = dynamic_cast<WarSchedule*>(*itr); Assert(pWarSchedule!=NULL); War* pWar = dynamic_cast<War*>( pWarSchedule->getWork() ); if( pWar == NULL ) { cout << "WarSystem俊 甸绢乐绰 Schedule狼 Work按眉啊 War啊 酒聪芭唱 NULL涝聪促. 火龙火龙~~~~" << endl; continue; } if (pWar->getWarType()==WAR_GUILD) { GuildWar* pGuildWar = dynamic_cast<GuildWar*>(pWar); Assert(pGuildWar!=NULL); if( pGuildWar->getCastleZoneID() == zoneID ) { return pWarSchedule; } } } return NULL; __END_CATCH}War* WarSystem::getActiveWar( ZoneID_t zoneID ) const throw(Error){ __BEGIN_TRY __ENTER_CRITICAL_SECTION(m_Mutex) const RecentSchedules::container_type& schedules = m_RecentSchedules.getSchedules(); RecentSchedules::const_iterator itr = schedules.begin(); for( ; itr != schedules.end(); itr++ ) { War* pWar = dynamic_cast<War*>( (*itr)->getWork() ); if( pWar == NULL ) continue; if (pWar->getWarType()==WAR_GUILD) { GuildWar* pGuildWar = dynamic_cast<GuildWar*>(pWar); Assert(pGuildWar!=NULL); if( pGuildWar->getCastleZoneID() == zoneID ) { m_Mutex.unlock(); return pWar; } } } __LEAVE_CRITICAL_SECTION(m_Mutex) return NULL; __END_CATCH}bool WarSystem::isEndCondition(Item* pItem, MonsterCorpse* pMonsterCorpse) throw (Error){ __BEGIN_TRY Assert(pItem!=NULL); Assert(pMonsterCorpse!=NULL); // pItem苞 pMonsterCorpse狼 娄捞 嘎绰啊? // return pBloodBibleItem->getBibleMonsterType()==pMonsterCorpse->getMonter()->getMonsterType() return true; __END_CATCH}bool WarSystem::isModifyCastleOwner( ZoneID_t castleZoneID, PlayerCreature* pPC ) throw (Error){ __BEGIN_TRY War* pWar = getActiveWar( castleZoneID ); Assert(pWar!=NULL); return pWar->isModifyCastleOwner(pPC); __END_CATCH}// pPC啊 castleZoneID客 包访等 傈里俊 铰府沁促.bool WarSystem::endWar(PlayerCreature* pPC, ZoneID_t castleZoneID) throw (Error){ __BEGIN_TRY Assert(pPC!=NULL); bool bEndWar = false; __ENTER_CRITICAL_SECTION(m_Mutex) WarSchedule* pWarSchedule = getActiveWarSchedule_LOCKED( castleZoneID ); if (pWarSchedule!=NULL) { Work* pWork = pWarSchedule->getWork(); Assert(pWork!=NULL); War* pWar = dynamic_cast<War*>(pWork); Assert(pWar!=NULL); if (pWar->endWar(pPC)) { // 傈里 力芭( 矫埃 荐沥栏肺 磊悼栏肺 狐瘤档废 窍磊) pWarSchedule->setScheduledTime( VSDateTime::currentDateTime() ); // heap阑 促矫 备己秦具 茄促. m_RecentSchedules.arrange(); bEndWar = true; } } __LEAVE_CRITICAL_SECTION(m_Mutex) return bEndWar; __END_CATCH}// castleZoneID狼 柳青吝牢 傈里阑 力芭茄促.bool WarSystem::removeWar(ZoneID_t castleZoneID) throw (Error){ __BEGIN_TRY bool bRemoved = false; __ENTER_CRITICAL_SECTION(m_Mutex) WarSchedule* pWarSchedule = getActiveWarSchedule_LOCKED( castleZoneID ); if (pWarSchedule!=NULL) { // 傈里 力芭( 矫埃 荐沥栏肺 磊悼栏肺 狐瘤档废 窍磊) pWarSchedule->setScheduledTime( VSDateTime::currentDateTime() ); // heap阑 促矫 备己秦具 茄促. m_RecentSchedules.arrange(); bRemoved = true; } __LEAVE_CRITICAL_SECTION(m_Mutex) return bRemoved; __END_CATCH}// castleZoneID狼 柳青吝牢 傈里阑 力芭茄促.bool WarSystem::removeRaceWar() throw (Error){ __BEGIN_TRY bool bRemoved = false; __ENTER_CRITICAL_SECTION(m_Mutex) const RecentSchedules::container_type& schedules = m_RecentSchedules.getSchedules(); RecentSchedules::const_iterator itr = schedules.begin(); for( ; itr != schedules.end(); itr++ ) { Schedule* pSchedule = *itr; War* pWar = dynamic_cast<War*>( pSchedule->getWork() ); if( pWar == NULL ) continue; if( pWar->getWarType() == WAR_RACE ) { // 傈里 力芭( 矫埃 荐沥栏肺 磊悼栏肺 狐瘤档废 窍磊) pSchedule->setScheduledTime( VSDateTime::currentDateTime() ); // heap阑 促矫 备己秦具 茄促. m_RecentSchedules.arrange(); bRemoved = true; } } __LEAVE_CRITICAL_SECTION(m_Mutex) return bRemoved; __END_CATCH}// 漂沥茄 敲饭捞绢俊霸 泅犁 柳青吝牢 傈里狼 府胶飘甫 焊郴霖促.void WarSystem::broadcastWarList( GamePlayer* pGamePlayer ) const throw (Error){ __BEGIN_TRY __ENTER_CRITICAL_SECTION(m_Mutex) const RecentSchedules::container_type& schedules = m_RecentSchedules.getSchedules(); RecentSchedules::const_iterator itr = schedules.begin(); GCSystemMessage gcSystemMessage; bool warExist = false; if ( isEmpty() ) { gcSystemMessage.setMessage( g_pStringPool->getString( STRID_NO_WAR_IN_ACTIVE ) ); pGamePlayer->sendPacket( &gcSystemMessage ); m_Mutex.unlock(); return; } for( ; itr != schedules.end(); itr++ ) { WarSchedule* pSchedule = dynamic_cast<WarSchedule*>( *itr ); if( pSchedule == NULL ) continue; War* pWar = dynamic_cast<War*>( pSchedule->getWork() ); if( pWar == NULL ) continue; warExist = true;/* StringStream msg; msg << pWar->getWarName() << "捞 " << ( pSchedule->getScheduledTime() ).toString() << " 鳖瘤 柳青邓聪促.";*/ char msg[100]; sprintf( msg, g_pStringPool->c_str( STRID_WAR_STATUS ), pWar->getWarName().c_str(), ( pSchedule->getScheduledTime() ).toString().c_str() ); gcSystemMessage.setMessage( msg ); pGamePlayer->sendPacket( &gcSystemMessage ); } if ( !warExist ) { gcSystemMessage.setMessage( g_pStringPool->getString( STRID_NO_WAR_IN_ACTIVE ) ); pGamePlayer->sendPacket( &gcSystemMessage ); } __LEAVE_CRITICAL_SECTION(m_Mutex) __END_CATCH}War* WarSystem::getActiveRaceWar() const throw(Error){ __BEGIN_TRY War* pWar = NULL; __ENTER_CRITICAL_SECTION( m_Mutex ) pWar = getActiveRaceWarAtSameThread(); __LEAVE_CRITICAL_SECTION( m_Mutex ) return pWar; __END_CATCH}bool WarSystem::startRaceWar() throw(Error){ __BEGIN_TRY if ( hasActiveRaceWar() ) return false; __ENTER_CRITICAL_SECTION( m_Mutex ); if (m_pRaceWarSchedule!=NULL) { m_pRaceWarSchedule->setScheduledTime( VSDateTime::currentDateTime() ); checkStartRaceWar(); } __LEAVE_CRITICAL_SECTION( m_Mutex ); return true; __END_CATCH}War* WarSystem::getActiveRaceWarAtSameThread() const throw(Error){ __BEGIN_TRY const RecentSchedules::container_type& schedules = m_RecentSchedules.getSchedules(); RecentSchedules::const_iterator itr = schedules.begin(); for( ; itr != schedules.end(); itr++ ) { War* pWar = dynamic_cast<War*>( (*itr)->getWork() ); if( pWar == NULL ) continue; if( pWar->getWarType() == WAR_RACE ) { return pWar; } } return NULL; __END_CATCH}bool WarSystem::addRaceWarScheduleInfo(WarScheduleInfo* pWSI) throw (Error){ __BEGIN_TRY if (m_pRaceWarSchedule==NULL) return false; Assert(pWSI!=NULL); __ENTER_CRITICAL_SECTION( m_Mutex ); const VSDateTime& DT = m_pRaceWarSchedule->getScheduledTime(); Work* pWork = m_pRaceWarSchedule->getWork(); Assert(pWork!=NULL); War* pWar = dynamic_cast<War*>(pWork); Assert(pWar!=NULL); pWar->makeWarScheduleInfo( pWSI ); pWSI->year = DT.date().year(); pWSI->month = DT.date().month(); pWSI->day = DT.date().day(); pWSI->hour = DT.time().hour(); __LEAVE_CRITICAL_SECTION( m_Mutex ); return true; __END_CATCH}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -