⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 castleinfomanager.cpp

📁 天之炼狱1服务器端源文件游戏服务端不完整
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	if (guildID==SlayerCommon 		|| guildID==VampireCommon		|| guildID==OustersCommon		)	{		return NULL;	}	hash_map<ZoneID_t, CastleInfo*>::const_iterator itr = m_CastleInfos.begin();	for (; itr!=m_CastleInfos.end(); itr++)	{		CastleInfo* pCastleInfo = itr->second;				if (pCastleInfo->getGuildID()==guildID)		{			return pCastleInfo;		}	}		return NULL;	__END_CATCH}list<CastleInfo*> CastleInfoManager::getGuildCastleInfos( GuildID_t guildID ) const	throw(Error){	__BEGIN_TRY	list<CastleInfo*> castleList;	if (guildID==SlayerCommon 		|| guildID==VampireCommon		|| guildID==OustersCommon		)	{		return castleList;	}	hash_map<ZoneID_t, CastleInfo*>::const_iterator itr = m_CastleInfos.begin();	for (; itr!=m_CastleInfos.end(); itr++)	{		CastleInfo* pCastleInfo = itr->second;				if (pCastleInfo->getGuildID()==guildID)		{			castleList.push_back(pCastleInfo);		}	}		return castleList;	__END_CATCH}bool CastleInfoManager::getResurrectPosition( PlayerCreature* pPC, ZONE_COORD& zoneCoord ) 	throw (Error){	CastleInfo::ResurrectPriority resurrectPriority = CastleInfo::CASTLE_RESURRECT_PRIORITY_SECOND;	ZoneID_t castleZoneID;	bool isCastleZone = g_pCastleInfoManager->getCastleZoneID( pPC->getResurrectZoneID(), castleZoneID );	if (!isCastleZone)		return false;	CastleInfo* pCastleInfo = getCastleInfo( castleZoneID );	if ( pCastleInfo != NULL )	{		if ( pCastleInfo->getZoneID() != pPC->getResurrectZoneID() || g_pWarSystem->hasCastleActiveWar( castleZoneID ) )		{			// 何劝困摹啊 己观栏肺 登绢 乐绰 版快			// 何劝困摹啊 己俊 叠赴 带怜栏肺 登绢 乐栏搁 己观俊 何劝困摹甫 瘤沥茄 巴栏肺 牢侥茄促.			// 鞘混 窍靛 内爹. 粮俊 何劝 困摹甫 窍唱观俊 瘤沥且 荐 绝绢辑 捞犯霸 内爹茄促.			// 酒淬狼 己瘤 辑率捞唱 悼率 鞍篮 版快俊 牢辟茄 滴 己狼 己观 何劝困摹甫 葛滴 瘤沥且 荐 绝促.ぱぱ;			// 肚, 泅犁 己捞 傈里 吝捞扼搁 己观俊辑 何劝窍档废 茄促.			if ( isCastleMember( castleZoneID, pPC ) )				resurrectPriority = CastleInfo::CASTLE_RESURRECT_PRIORITY_SECOND;			else				resurrectPriority = CastleInfo::CASTLE_RESURRECT_PRIORITY_THIRD;		}		else		{			// 何劝困摹啊 己救栏肺 登绢 乐绰 版快			// 辨靛盔捞 酒聪搁 夸陛阑 罐绰促. 夸陛捞 葛磊扼搁 己观俊 何劝 矫挪促.			if ( isCastleMember( castleZoneID, pPC ) )				resurrectPriority = CastleInfo::CASTLE_RESURRECT_PRIORITY_FIRST;			else			{				Gold_t fee = pCastleInfo->getEntranceFee();				Gold_t remain = pPC->getGold();				if ( remain < fee )				{					// 夸陛捞 何练茄 版快 己观俊 何劝 矫挪促.					resurrectPriority = CastleInfo::CASTLE_RESURRECT_PRIORITY_THIRD;				}				else				{					// 夸陛捞 乐促搁 夸陛阑 罐绊 己救俊 何劝 矫挪促.					pPC->decreaseGoldEx( fee );					increaseTaxBalance( pCastleInfo->getZoneID(), fee );					GCModifyInformation gcMI;					gcMI.addLongData( MODIFY_GOLD, pPC->getGold() );					GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPC->getPlayer());					if ( pGamePlayer->getPlayerStatus() == GPS_NORMAL )						pGamePlayer->sendPacket( &gcMI );					resurrectPriority = CastleInfo::CASTLE_RESURRECT_PRIORITY_FIRST;				}			}		}	}	else	{		return false;	}	pCastleInfo->getResurrectPosition( resurrectPriority, zoneCoord );	return true;}bool CastleInfoManager::tinysave( ZoneID_t zoneID, const string& query )	throw(Error){	__BEGIN_TRY	CastleInfo* pCastleInfo = getCastleInfo( zoneID );	if( pCastleInfo == NULL ) return false;	Statement* pStmt = NULL;	bool isAffected = false;	BEGIN_DB	{		// create statement		pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement();		pStmt->executeQuery(			"UPDATE CastleInfo SET %s WHERE ZoneID=%d AND ServerID=%d",			query.c_str(), pCastleInfo->getZoneID(), g_pConfig->getPropertyInt("ServerID") );		if( pStmt->getAffectedRowCount() > 0 )			isAffected = true;		SAFE_DELETE(pStmt);	} 	END_DB(pStmt)	return isAffected;	__END_CATCH}void    CastleInfoManager::deleteAllNPCs() 	throw (Error){	__BEGIN_TRY	hash_map<ZoneID_t, CastleInfo*>::const_iterator itr = m_CastleInfos.begin();	for (; itr!=m_CastleInfos.end(); itr++)	{		CastleInfo* pCastleInfo = itr->second;				Zone* pZone = getZoneByZoneID( pCastleInfo->getZoneID() );		Assert( pZone != NULL );		__ENTER_CRITICAL_SECTION( (*pZone) )		// NPC甫 葛滴 瘤款促.		pZone->deleteNPCs( RACE_SLAYER );		pZone->deleteNPCs( RACE_VAMPIRE );		__LEAVE_CRITICAL_SECTION( (*pZone) )	}	__END_CATCH}void    CastleInfoManager::releaseAllSafeZone() 	throw (Error){	__BEGIN_TRY	hash_map<ZoneID_t, CastleInfo*>::const_iterator itr = m_CastleInfos.begin();	for (; itr!=m_CastleInfos.end(); itr++)	{		CastleInfo* pCastleInfo = itr->second;				Zone* pZone = getZoneByZoneID( pCastleInfo->getZoneID() );		Assert( pZone != NULL );		__ENTER_CRITICAL_SECTION( (*pZone) )		pZone->releaseSafeZone();		__LEAVE_CRITICAL_SECTION( (*pZone) )	}	__END_CATCH}void    CastleInfoManager::resetAllSafeZone() 	throw (Error){	__BEGIN_TRY	hash_map<ZoneID_t, CastleInfo*>::const_iterator itr = m_CastleInfos.begin();	for (; itr!=m_CastleInfos.end(); itr++)	{		CastleInfo* pCastleInfo = itr->second;				Zone* pZone = getZoneByZoneID( pCastleInfo->getZoneID() );		Assert( pZone != NULL );		__ENTER_CRITICAL_SECTION( (*pZone) )		pZone->resetSafeZone();		__LEAVE_CRITICAL_SECTION( (*pZone) )	}	__END_CATCH}void	CastleInfoManager::transportAllOtherRace()	throw (Error){		__BEGIN_TRY	hash_map<ZoneID_t, CastleInfo*>::const_iterator itr = m_CastleInfos.begin();	for (; itr!=m_CastleInfos.end(); itr++)	{		CastleInfo* pCastleInfo = itr->second;				// 己苞 包访等 葛电 ZoneID甫 殿废茄促.		const list<ZoneID_t>& zoneIDs = pCastleInfo->getZoneIDList();		list<ZoneID_t>::const_iterator iZoneID = zoneIDs.begin();		for (; iZoneID!=zoneIDs.end(); iZoneID++)		{			ZoneID_t zoneID = *iZoneID;			Zone* pZone = getZoneByZoneID( zoneID );			Assert( pZone != NULL );			__ENTER_CRITICAL_SECTION( (*pZone) )			// 辆练傈里狼 菩硅磊甸篮 何劝 困摹肺 葛滴 卵酒焊辰促.			Race_t otherRace = (pCastleInfo->getRace()==RACE_SLAYER? RACE_VAMPIRE : RACE_SLAYER);			ZONE_COORD zoneCoord;			pCastleInfo->getResurrectPosition( CastleInfo::CASTLE_RESURRECT_PRIORITY_SECOND, zoneCoord);			PCManager* pPCManager = (PCManager*)(pZone->getPCManager());			pPCManager->transportAllCreatures( zoneCoord.id, zoneCoord.x, zoneCoord.y, otherRace );			__LEAVE_CRITICAL_SECTION( (*pZone) )		}	}	__END_CATCH}void	CastleInfoManager::loadAllNPCs()	throw (Error){		__BEGIN_TRY	hash_map<ZoneID_t, CastleInfo*>::const_iterator itr = m_CastleInfos.begin();	for (; itr!=m_CastleInfos.end(); itr++)	{		CastleInfo* pCastleInfo = itr->second;				Zone* pZone = getZoneByZoneID( pCastleInfo->getZoneID() );		Assert( pZone != NULL );		__ENTER_CRITICAL_SECTION( (*pZone) )		// NPC 肺靛		pZone->loadNPCs( pCastleInfo->getRace() );		__LEAVE_CRITICAL_SECTION( (*pZone) )	}	__END_CATCH}ZoneID_t    CastleInfoManager::getCastleZoneID(ShrineID_t shrineID) const	throw (Error){	__BEGIN_TRY	hash_map<ZoneID_t, CastleInfo*>::const_iterator itr = m_CastleInfos.begin();	for (; itr!=m_CastleInfos.end(); itr++)	{		CastleInfo* pCastleInfo = itr->second;				if (pCastleInfo->getShrineID()==shrineID)		{			return pCastleInfo->getZoneID();		}	}	StringStream msg;	msg << "弊繁 ShrineID(" << (int)shrineID << ")啊 绝嚼聪促.";	throw Error(msg.toString());	return 0;	__END_CATCH}void CastleInfoManager::broadcastShrinePacket(ShrineID_t shrineID, Packet* pPacket) const	throw (Error){	__BEGIN_TRY	ZoneID_t castleZoneID = getCastleZoneID( shrineID );	const CastleInfo* pCastleInfo = getCastleInfo( castleZoneID );	Assert(pCastleInfo!=NULL);	pCastleInfo->broadcast( pPacket );	__END_CATCH}bool CastleInfoManager::isCastleZone(ZoneID_t castleZoneID, ZoneID_t targetZoneID) const	throw (Error){	__BEGIN_TRY	const CastleInfo* pCastleInfo = getCastleInfo( castleZoneID );	Assert(pCastleInfo!=NULL);	return pCastleInfo->isCastleZone( targetZoneID );	__END_CATCH}void  CastleInfoManager::clearCastleZoneIDs()	throw (Error){	__BEGIN_TRY	m_CastleZoneIDs.clear();	__END_CATCH}bool CastleInfoManager::getCastleZoneID(ZoneID_t zoneID, ZoneID_t &castleZoneID) const	throw (Error){	__BEGIN_TRY	hash_map<ZoneID_t, ZoneID_t>::const_iterator itr = m_CastleZoneIDs.find( zoneID );	if (itr!=m_CastleZoneIDs.end())	{		castleZoneID = itr->second;		return true;	}	return false;	__END_CATCH}void  CastleInfoManager::setCastleZoneID(ZoneID_t zoneID, ZoneID_t castleZoneID)	throw (Error){	__BEGIN_TRY	m_CastleZoneIDs[zoneID] = castleZoneID;	__END_CATCH}bool        CastleInfoManager::isSameCastleZone(ZoneID_t zoneID1, ZoneID_t zoneID2) const 	throw (Error){	__BEGIN_TRY	ZoneID_t castleZoneID1, castleZoneID2;	bool isCastle1 = getCastleZoneID(zoneID1, castleZoneID1);	bool isCastle2 = getCastleZoneID(zoneID2, castleZoneID2);	// 茄 焙单扼档 己捞 酒聪搁 鞍篮 己俊 加茄 粮捞 酒聪促.	if (!isCastle1 || !isCastle2)		return false;	return castleZoneID1==castleZoneID2;	__END_CATCH}SkillType_t CastleInfoManager::getCastleSkillType( ZoneID_t zoneID, GuildID_t guildID ) const	throw (Error){	__BEGIN_TRY    const CastleInfo* pCastleInfo = getCastleInfo( zoneID );    if (pCastleInfo != NULL)    {        GuildID_t   OwnerGuildID = pCastleInfo->getGuildID();		// 己狼 家蜡 辨靛啊 酒聪搁 绝促.        if ( guildID == SlayerCommon             || guildID == VampireCommon             || guildID == OustersCommon             || guildID != OwnerGuildID )        {            return SKILL_MAX;        }		// 己捞 辨靛 傈里 吝捞扼搁 绝促.		if ( g_pWarSystem->hasCastleActiveWar( zoneID ) )		{			return SKILL_MAX;		}		return g_pCastleSkillInfoManager->getSkillType( zoneID );    }    return SKILL_MAX;	__END_CATCH}// global variable definitionCastleInfoManager* g_pCastleInfoManager = NULL;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -