📄 shrineinfomanager.cpp
字号:
#include <stdio.h>#include "ShrineInfoManager.h"#include "StringStream.h"#include "DB.h"#include "ZoneItemPosition.h"#include "Zone.h"#include "ZoneUtil.h"#include "MonsterCorpse.h"#include "Item.h"#include "ItemFactoryManager.h"#include "EffectShrineGuard.h"#include "EffectShrineHoly.h"#include "EffectShrineShield.h"#include "War.h"#include "WarSystem.h"#include "RelicUtil.h"#include "CastleInfoManager.h"#include "GlobalItemPosition.h"#include "GlobalItemPositionLoader.h"#include "ZoneGroupManager.h"#include "Player.h"#include "PlayerCreature.h"#include "CreatureUtil.h"#include "BloodBibleBonusManager.h"#include "HolyLandManager.h"#include "ClientManager.h"#include "EffectHasRelic.h"#include "StringPool.h"#include "EventRefreshHolyLandPlayer.h"#include "Gpackets/GCSystemMessage.h"#include "Gpackets/GCRemoveEffect.h"#include "Gpackets/GCAddEffect.h"#include "Gpackets/GCAddEffectToTile.h"#include "Gpackets/GCDeleteInventoryItem.h"#include "Gpackets/GCBloodBibleStatus.h"#include "BloodBible.h"bool AddBible[] ={ true, //SHRINE_ARMEGA, // 0 false, //SHRINE_MIHOLE, // 1 false, //SHRINE_KIRO, // 2 false, //SHRINE_INI, // 3 false, //SHRINE_GREGORI, // 4 false, //SHRINE_CONCILIA, // 5 false, //SHRINE_LEGIOS, // 6 false, //SHRINE_HILLEL, // 7 false, //SHRINE_JAVE, // 8 true, //SHRINE_NEMA, // 9 false, //SHRINE_AROSA, // 10 false, //SHRINE_CHASPA // 11};string ShrineInfo::toString() const throw(){ StringStream msg; msg << "ShrineInfo(" << "MonsterType:" << (int)m_MonsterType << ",ShrineType:" << (m_ShrineType==SHRINE_GUARD?"GUARD":"HOLY") << ",ZoneID:" << (int)m_ZoneID << ",X:" << (int)m_X << ",Y:" << (int)m_Y << ",Name:" << m_Name << ")"; return msg.toString();}ShrineInfo& ShrineSet::getReturnGuardShrine() throw(Error){ __BEGIN_TRY switch ( m_OwnerRace ) { case RACE_SLAYER : return m_SlayerGuardShrine; break; case RACE_VAMPIRE : return m_VampireGuardShrine; break; case RACE_OUSTERS : return m_OustersGuardShrine; break; } // cannot reach here Assert( false ); return m_SlayerGuardShrine; __END_CATCH}ShrineSet::ShrineSet(){ m_Mutex.setName("ShrineSet"); m_pGCBBS = NULL;}ShrineSet::~ShrineSet(){ SAFE_DELETE( m_pGCBBS );}Item* ShrineSet::createBloodBibleInGuardShrine() throw(Error){ __BEGIN_TRY ShrineInfo* pShrineInfo = &getReturnGuardShrine(); Zone* pZone = getZoneByZoneID( pShrineInfo->getZoneID() ); Assert( pZone != NULL ); MonsterCorpse* pShrine = dynamic_cast<MonsterCorpse*>(pZone->getItem( pShrineInfo->getObjectID() )); Assert( pShrine != NULL ); list<OptionType_t> optionNULL; Item* pItem = g_pItemFactoryManager->createItem( Item::ITEM_CLASS_BLOOD_BIBLE, m_ItemType, optionNULL ); Assert( pItem != NULL ); char strZoneID[10]; sprintf(strZoneID, "%d", (int)pZone->getZoneID()); pZone->registerObject( pItem ); pItem->create( strZoneID, STORAGE_CORPSE, pShrine->getObjectID(), 0, 0 ); pShrine->addTreasure( pItem ); return pItem; __END_CATCH}void ShrineSet::setOwnerRace( Race_t race ) throw(Error){ __BEGIN_TRY g_pBloodBibleBonusManager->setBloodBibleBonusRace( m_ShrineID, race ); m_OwnerRace = race; saveBloodBibleOwner(); __END_CATCH}void ShrineSet::setBloodBibleStatus( GCBloodBibleStatus* pGCBBS ) throw(Error){ __BEGIN_TRY __ENTER_CRITICAL_SECTION( m_Mutex ) SAFE_DELETE( m_pGCBBS ); m_pGCBBS = pGCBBS; __LEAVE_CRITICAL_SECTION( m_Mutex ); __END_CATCH}void ShrineSet::sendBloodBibleStatus( PlayerCreature* pPC ) throw(Error){ __BEGIN_TRY __ENTER_CRITICAL_SECTION( m_Mutex ) if ( m_pGCBBS != NULL ) pPC->getPlayer()->sendPacket( m_pGCBBS ); __LEAVE_CRITICAL_SECTION( m_Mutex ) __END_CATCH} void ShrineSet::broadcastBloodBibleStatus() throw(Error){ __BEGIN_TRY __ENTER_CRITICAL_SECTION( m_Mutex ) if ( m_pGCBBS != NULL ) g_pHolyLandManager->broadcast( m_pGCBBS ); __LEAVE_CRITICAL_SECTION( m_Mutex ) __END_CATCH}string ShrineSet::toString() const throw(){ __BEGIN_TRY StringStream msg; msg << "ShrineSet(" << "ShrineID:" << (int)m_ShrineID << "," << m_SlayerGuardShrine.toString() << "," << m_VampireGuardShrine.toString() << "," << m_OustersGuardShrine.toString() << "," << m_HolyShrine.toString() << ",ItemType:" << (int)m_ItemType << ")"; return msg.toString(); __END_CATCH}ShrineInfoManager::~ShrineInfoManager(){ clear();}void ShrineInfoManager::clear(){ HashMapShrineSetItor itr = m_ShrineSets.begin(); for ( ; itr != m_ShrineSets.end() ; itr++ ) { SAFE_DELETE( itr->second ); } m_ShrineSets.clear();}void ShrineInfoManager::init() throw (Error){ __BEGIN_TRY load(); addAllShrineToZone(); __END_CATCH}void ShrineInfoManager::load() throw (Error){ __BEGIN_TRY Statement* pStmt = NULL; Result* pResult = NULL; BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pResult = pStmt->executeQuery( "SELECT ID, Name, ItemType, SlayerGuardZoneID, SlayerGuardX, SlayerGuardY, SlayerGuardMType, VampireGuardZoneID, VampireGuardX, VampireGuardY, VampireGuardMType, OustersGuardZoneID, OustersGuardX, OustersGuardY, OustersGuardMType, HolyZoneID, HolyX, HolyY, HolyMType, OwnerRace FROM ShrineInfo" ); while ( pResult->next() ) { int i = 0; ShrineSet* pShrineSet = new ShrineSet(); ShrineInfo& SlayerGuardShrine = pShrineSet->getSlayerGuardShrine(); ShrineInfo& VampireGuardShrine = pShrineSet->getVampireGuardShrine(); ShrineInfo& OustersGuardShrine = pShrineSet->getOustersGuardShrine(); ShrineInfo& HolyShrine = pShrineSet->getHolyShrine(); pShrineSet->setShrineID( pResult->getInt( ++i ) ); SlayerGuardShrine. setName( pResult->getString( ++i ) ); VampireGuardShrine. setName( SlayerGuardShrine.getName() ); OustersGuardShrine. setName( SlayerGuardShrine.getName() ); HolyShrine. setName( SlayerGuardShrine.getName() ); pShrineSet->setBloodBibleItemType( pResult->getInt( ++i ) ); SlayerGuardShrine.setZoneID( pResult->getInt( ++i ) ); SlayerGuardShrine.setX( pResult->getInt( ++i ) ); SlayerGuardShrine.setY( pResult->getInt( ++i ) ); SlayerGuardShrine.setMonsterType( pResult->getInt( ++i ) ); VampireGuardShrine.setZoneID( pResult->getInt( ++i ) ); VampireGuardShrine.setX( pResult->getInt( ++i ) ); VampireGuardShrine.setY( pResult->getInt( ++i ) ); VampireGuardShrine.setMonsterType( pResult->getInt( ++i ) ); OustersGuardShrine.setZoneID( pResult->getInt( ++i ) ); OustersGuardShrine.setX( pResult->getInt( ++i ) ); OustersGuardShrine.setY( pResult->getInt( ++i ) ); OustersGuardShrine.setMonsterType( pResult->getInt( ++i ) ); HolyShrine.setZoneID( pResult->getInt( ++i ) ); HolyShrine.setX( pResult->getInt( ++i ) ); HolyShrine.setY( pResult->getInt( ++i ) ); HolyShrine.setMonsterType( pResult->getInt( ++i ) ); pShrineSet->setOwnerRace( (Race_t)pResult->getInt( ++i ) ); SlayerGuardShrine.setShrineType( ShrineInfo::SHRINE_GUARD ); VampireGuardShrine.setShrineType( ShrineInfo::SHRINE_GUARD ); OustersGuardShrine.setShrineType( ShrineInfo::SHRINE_GUARD ); HolyShrine.setShrineType( ShrineInfo::SHRINE_HOLY ); // ItemType苞 Shrine ID绰 鞍酒具 茄促. 鞍瘤 臼阑 版快 DB汲沥 坷幅肺 肺爹苞沥俊辑 阜绰促. if ( pShrineSet->getBloodBibleItemType() != pShrineSet->getShrineID() ) { cout << "ShrineID 客 ItemType捞 嘎瘤 臼嚼聪促. DB汲沥阑 痢八窍技夸." << endl; Assert( false ); } addShrineSet( pShrineSet ); } SAFE_DELETE(pStmt); } END_DB( pStmt ) __END_CATCH}// 捞芭绰 ClientManager thread俊辑 阂赴促. 谍单辑 何福搁 救等促~~void ShrineInfoManager::reloadOwner() throw (Error){ __BEGIN_TRY Statement* pStmt = NULL; Result* pResult = NULL; bool bOwnerChanged = false; BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pResult = pStmt->executeQuery( "SELECT ID, OwnerRace FROM ShrineInfo" ); while ( pResult->next() ) { int i = 0; ShrineID_t shrineID = pResult->getInt( ++i ); Race_t OwnerRace = (Race_t)pResult->getInt( ++i ); ShrineSet* pShrineSet = getShrineSet( shrineID ); if (pShrineSet->getOwnerRace() != OwnerRace) { pShrineSet->setOwnerRace( OwnerRace ); returnBloodBible( shrineID ); bOwnerChanged = true; } } SAFE_DELETE(pStmt); } END_DB( pStmt ) if (bOwnerChanged) { EventRefreshHolyLandPlayer* pEvent = new EventRefreshHolyLandPlayer(NULL); pEvent->setDeadline( 0 ); g_pClientManager->addEvent_LOCKED( pEvent ); } __END_CATCH}void ShrineInfoManager::addAllShrineToZone() throw(Error){ __BEGIN_TRY HashMapShrineSetItor itr = m_ShrineSets.begin(); for ( ; itr != m_ShrineSets.end() ; itr++ ) { ShrineSet* pShrineSet = itr->second; if ( pShrineSet == NULL ) continue; addShrineToZone( pShrineSet->getSlayerGuardShrine(), pShrineSet->getBloodBibleItemType() ); addShrineToZone( pShrineSet->getVampireGuardShrine(), pShrineSet->getBloodBibleItemType() ); addShrineToZone( pShrineSet->getOustersGuardShrine(), pShrineSet->getBloodBibleItemType() ); Item* pItem = pShrineSet->createBloodBibleInGuardShrine(); pShrineSet->setBloodBibleItemID( pItem->getItemID() ); addShrineToZone( pShrineSet->getHolyShrine(), pShrineSet->getBloodBibleItemType() ); } __END_CATCH}void ShrineInfoManager::addShrineToZone( ShrineInfo& shrineInfo, ItemType_t itemType ) throw(Error){ __BEGIN_TRY // Holy Shrine 篮 粮俊 眠啊窍瘤 臼绰促. if ( shrineInfo.getShrineType() == ShrineInfo::SHRINE_HOLY ) return; // 己窜阑 持阑 粮阑 啊廉柯促. Zone* pZone = getZoneByZoneID( shrineInfo.getZoneID() ); Assert( pZone != NULL ); MonsterCorpse* pShrine = new MonsterCorpse( shrineInfo.getMonsterType(), shrineInfo.getName(), 2 ); Assert( pShrine != NULL ); pShrine->setShrine( true ); pShrine->setZone( pZone ); pZone->getObjectRegistry().registerObject( pShrine ); shrineInfo.setObjectID( pShrine->getObjectID() ); cout << "AddShrine[" << (int)shrineInfo.getZoneID() << "] " << (shrineInfo.getShrineType()==ShrineInfo::SHRINE_GUARD? "Guard":"Holy") << ", mtype=" << shrineInfo.getMonsterType() << ", oid=" << pShrine->getObjectID() << endl; if ( shrineInfo.getShrineType() == ShrineInfo::SHRINE_GUARD ) { pShrine->setFlag( Effect::EFFECT_CLASS_SHRINE_GUARD ); EffectShrineGuard* pEffect = new EffectShrineGuard(pShrine); pEffect->setShrineID( itemType ); pEffect->setTick( 60 * 10 ); pShrine->getEffectManager().addEffect( pEffect ); } /* else if ( shrineInfo.getShrineType() == ShrineInfo::SHRINE_HOLY )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -