📄 guildwar.cpp
字号:
///////////////////////////////////////////////////////////////////// 傈里俊 措茄 傈馆利牢 沥焊 棺 傈里 矫累 棺 辆丰矫 贸府风凭 备泅///////////////////////////////////////////////////////////////////#include <stdio.h>#include "Guild.h"#include "GuildManager.h"#include "GuildWar.h"#include "Mutex.h"#include "WarSystem.h"#include "Properties.h"#include "DB.h"#include "Assert.h"#include "ZoneGroupManager.h"#include "HolyLandRaceBonus.h"#include "Zone.h"#include "ZoneGroup.h"#include "ZoneUtil.h"#include "CastleInfoManager.h"#include "CastleShrineInfoManager.h"#include "ZoneInfoManager.h"#include "PCManager.h"#include "StringStream.h"#include "Gpackets/GCSystemMessage.h"#include "Gpackets/GCNoticeEvent.h"#include "Gpackets/GCWarScheduleList.h"#include "Cpackets/CGSay.h"#include "GuildWarInfo.h"//--------------------------------------------------------------------------------//// constructor / destructor////--------------------------------------------------------------------------------GuildWar::GuildWar( ZoneID_t castleZoneID, GuildID_t challenger, WarState warState, WarID_t warID ): War( warState, warID ), m_CastleZoneID(castleZoneID), m_ChallangerGuildID( challenger ), m_RegistrationFee( 0 ){ m_bModifyCastleOwner = false;}GuildWar::~GuildWar(){}//--------------------------------------------------------------------------------//// executeStart////--------------------------------------------------------------------------------// 傈里捞 矫累窍绰 矫痢俊辑 贸府秦具 瞪 巴甸//// (!) Zone俊 嘿绢乐绰 WarScheduler俊辑 角青登绰 何盒捞骨肺 // 磊脚狼 Zone(己)俊 措茄 贸府绰 lock捞 鞘夸绝促.//--------------------------------------------------------------------------------void GuildWar::executeStart() throw (Error){ __BEGIN_TRY sendWarStartMessage(); // 己 救狼 救傈瘤措甫 馋促. ZoneID_t guardShrineZoneID = g_pCastleShrineInfoManager->getGuardShrineZoneID( m_CastleZoneID ); Zone* pZone = getZoneByZoneID( guardShrineZoneID ); Assert( pZone != NULL ); /* // NPC甫 葛滴 瘤款促. pZone->deleteNPCs( RACE_SLAYER ); pZone->deleteNPCs( RACE_VAMPIRE ); pZone->releaseSafeZone(); */ // 捞 何盒篮 唱吝俊~~ CastleInfo肺 持绰霸 炒摆促. CastleInfo* pCastleInfo = g_pCastleInfoManager->getCastleInfo( m_CastleZoneID ); Assert(pCastleInfo!=NULL); GuildID_t OwnerGuildID = pCastleInfo->getGuildID(); // 傍侩己捞 酒囱 版快父 阁胶磐甫 绝局霖促. if (OwnerGuildID!=SlayerCommon && OwnerGuildID!=VampireCommon) { const list<ZoneID_t>& zoneIDs = pCastleInfo->getZoneIDList(); list<ZoneID_t>::const_iterator itr = zoneIDs.begin(); for (; itr!=zoneIDs.end(); itr++) { ZoneID_t targetZoneID = *itr; Zone* pTargetZone = getZoneByZoneID( targetZoneID ); // 己捞 酒聪绊.. 带傈 甘牢 版快.. if (targetZoneID!=m_CastleZoneID) { pTargetZone->killAllMonsters(); } } } g_pCastleShrineInfoManager->removeShrineShield( pZone ); // GuildWarHistory Table 俊 扁废 recordGuildWarStart(); __END_CATCH}void GuildWar::recordGuildWarStart() throw (Error){ __BEGIN_TRY Statement* pStmt = NULL; CastleInfo* pCastleInfo = g_pCastleInfoManager->getCastleInfo( m_CastleZoneID ); // NULL 老府档 绝瘤父 趣矫唱 窍绰 妇俊 -_-; if ( pCastleInfo == NULL ) return; BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pStmt->executeQuery("INSERT IGNORE INTO GuildWarHistory (WarID, GuildWarID, ServerID, CastleName, DefenseGuildID, DefenseGuildName, AttackGuildID, AttackGuildName) VALUES (%d, '%s', %d, '%s', %d, '%s', %d, '%s')", (int)getWarID(), getWarStartTime().toStringforWeb().c_str(), g_pConfig->getPropertyInt("ServerID"), pCastleInfo->getName().c_str(), (int)pCastleInfo->getGuildID(), g_pGuildManager->getGuildName( pCastleInfo->getGuildID() ).c_str(), getChallangerGuildID(), g_pGuildManager->getGuildName( getChallangerGuildID() ).c_str() ); } END_DB(pStmt) __END_CATCH}//--------------------------------------------------------------------------------//// executeEnd////--------------------------------------------------------------------------------// 傈里捞 场唱绰 矫痢俊辑 贸府秦具 瞪 巴甸//--------------------------------------------------------------------------------void GuildWar::executeEnd() throw (Error){ __BEGIN_TRY //---------------------------------------------------------------------------- // 傈里 场车促绰 吧 舅赴促. //---------------------------------------------------------------------------- sendWarEndMessage(); //---------------------------------------------------------------------------- // 己 林牢 函版 //---------------------------------------------------------------------------- if (m_bModifyCastleOwner) { g_pCastleInfoManager->modifyCastleOwner(m_CastleZoneID, m_WinnerRace, m_WinnerGuildID); if ( g_pConfig->getPropertyInt("IsNetMarble") == 1 ) { char sCommand[100]; sprintf( sCommand, "*world *command setCastleOwnerGuild %u %u", m_CastleZoneID, m_WinnerGuildID ); CGSayHandler::opworld( NULL, sCommand, 0, true ); } } else { // WinnerGuildID 甫 瘤陛 林牢栏肺 悸泼秦霖促 CastleInfo* pCastleInfo = g_pCastleInfoManager->getCastleInfo( m_CastleZoneID ); m_WinnerGuildID = pCastleInfo->getGuildID(); } //---------------------------------------------------------------------------- // 己 惑隆阑 登倒妨霖促. //---------------------------------------------------------------------------- g_pCastleShrineInfoManager->returnAllCastleSymbol( m_CastleZoneID ); //---------------------------------------------------------------------------- // 己 救 救傈瘤措 汗备 //---------------------------------------------------------------------------- // 捞 窃荐绰 ClientManager客 鞍篮 胶饭靛俊辑 倒酒啊绰 WarSystem俊辑 阂矾林骨肺 // 己捞 器窃等 Zone狼 遏阑 吧绢拎具 等促. ZoneID_t guardShrineZoneID = g_pCastleShrineInfoManager->getGuardShrineZoneID( m_CastleZoneID ); Zone* pZone = getZoneByZoneID( guardShrineZoneID ); Assert(pZone!=NULL); /* CastleInfo* pCastleInfo = g_pCastleInfoManager->getCastleInfo( m_CastleZoneID ); Assert(pCastleInfo!=NULL); __ENTER_CRITICAL_SECTION( (*pZone) ) pZone->resetSafeZone(); pZone->loadNPCs( pCastleInfo->getRace() ); g_pShrineInfoManager->addShrineShield_LOCKED( pZone ); __LEAVE_CRITICAL_SECTION( (*pZone) ) */ g_pCastleShrineInfoManager->addShrineShield( pZone ); //---------------------------------------------------------------------------- // 傈里 脚没陛阑 己俊 阶绰促. // (快急 傈里 搬苞俊 蝶扼辑 己狼 林牢捞 官差菌促绊 啊沥茄促.) //---------------------------------------------------------------------------- g_pCastleInfoManager->increaseTaxBalance( m_CastleZoneID, m_RegistrationFee ); m_RegistrationFee = 0; //tinysave("傈里脚没陛=0") <-- 且 鞘夸 乐阑鳖? // GuildWarHistory Table 俊 扁废 recordGuildWarEnd(); __END_CATCH}void GuildWar::recordGuildWarEnd() throw (Error){ __BEGIN_TRY Statement* pStmt = NULL; BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pStmt->executeQuery("UPDATE GuildWarHistory SET WinnerGuildID = %d , WinnerGuildName = '%s' WHERE WarID = %d", (int)m_WinnerGuildID, g_pGuildManager->getGuildName( m_WinnerGuildID ).c_str(), (int)getWarID() ); } END_DB(pStmt) // script 倒府扁 ぱ.,ぱ system 窃荐甫 静霸 瞪 临捞具 !_! char cmd[100]; sprintf(cmd, "/home/darkeden/vs/bin/script/recordGuildWarHistory.py %d %d %d ", (int)getWarID(), g_pConfig->getPropertyInt("Dimension"), g_pConfig->getPropertyInt("WorldID") ); filelog("script.log", cmd); system(cmd); __END_CATCH}string GuildWar::getWarName() const throw (Error){ __BEGIN_TRY ZoneInfo* pZoneInfo = NULL; Guild* pGuild = NULL; try { pGuild = g_pGuildManager->getGuild( m_ChallangerGuildID ); pZoneInfo = g_pZoneInfoManager->getZoneInfo( m_CastleZoneID ); if (pGuild==NULL || pZoneInfo==NULL) return "辨靛 傈里"; } catch (Throwable& t) { return "辨靛 傈里"; } Assert(pZoneInfo!=NULL); Assert(pGuild!=NULL); StringStream msg; msg << pGuild->getName() << "辨靛啊 "; msg << pZoneInfo->getFullName() << "阑 傍拜窍绰 辨靛 傈里"; return msg.toString(); __END_CATCH}//--------------------------------------------------------------------------------//// isModifyCastleOwner( PlayerCreature* pPC )////--------------------------------------------------------------------------------// 己狼 林牢捞 官差绰 版快//--------------------------------------------------------------------------------boolGuildWar::isModifyCastleOwner( PlayerCreature* pPC ) throw (Error){ __BEGIN_TRY Assert(pPC!=NULL); CastleInfo* pCastleInfo = g_pCastleInfoManager->getCastleInfo( m_CastleZoneID ); Assert(pCastleInfo!=NULL); // 傍侩己 : 傍拜辨靛 --> 傍拜辨靛己 // 傍侩己 : 老馆 --> 盔贰 磊府肺 // 辨靛己 : 傍拜辨靛 --> 傍拜辨靛己 // 辨靛己 : 荐厚辨靛 --> 盔贰 磊府肺 // 辨靛己 : 老馆 --> 傍侩己 // 辨靛傈里牢 版快 : 傈里 脚没茄 辨靛捞芭唱 // 辨靛己牢 版快绰 老馆牢 if (pPC->getGuildID() == m_ChallangerGuildID || !pCastleInfo->isCommon() && pPC->getCommonGuildID()==pPC->getGuildID()) { return true; } return false; __END_CATCH}//--------------------------------------------------------------------------------//// getWinnerGuildID( PlayerCreature* pPC ) ////--------------------------------------------------------------------------------// 傈里俊 铰府茄 辨靛狼 GuildID甫 逞败霖促.//--------------------------------------------------------------------------------GuildID_t GuildWar::getWinnerGuildID( PlayerCreature* pPC ) throw(Error){ __BEGIN_TRY Assert(pPC!=NULL); // 辨靛傈里牢 版快 : 傈里脚没 辨靛客 pPC狼 辨靛啊 鞍栏搁 pPC狼 GuildID // 酒聪搁 盔贰 己林牢狼 辨靛ID客 鞍栏搁 盔贰 己林牢 GuildID // 酒聪搁 COMMON_GUILD_ID CastleInfo* pCastleInfo = g_pCastleInfoManager->getCastleInfo( m_CastleZoneID ); Assert( pCastleInfo!=NULL ); if (m_ChallangerGuildID==pPC->getGuildID() || pPC->getGuildID()==pCastleInfo->getGuildID()) { return pPC->getGuildID(); } return pPC->getCommonGuildID(); __END_CATCH}bool GuildWar::endWar(PlayerCreature* pPC) throw(Error){ __BEGIN_TRY Assert(pPC!=NULL); // < 己 林牢 函版 > if (isModifyCastleOwner( pPC )) { m_WinnerRace = pPC->getRace(); m_WinnerGuildID = getWinnerGuildID( pPC ); m_bModifyCastleOwner = true; return true; } return false; __END_CATCH}//--------------------------------------------------------------------------------// 傈里 场朝 锭//--------------------------------------------------------------------------------void GuildWar::sendWarEndMessage() const throw (ProtocolException, Error){ __BEGIN_TRY War::sendWarEndMessage(); // 救傈瘤措 秦力 犬牢? 菩哦 GCNoticeEvent gcNoticeEvent; gcNoticeEvent.setCode( NOTICE_EVENT_WAR_OVER ); gcNoticeEvent.setParameter( m_CastleZoneID ); g_pZoneGroupManager->broadcast( &gcNoticeEvent ); __END_CATCH}void GuildWar::makeWarScheduleInfo( WarScheduleInfo* pWSI ) const throw(Error){ __BEGIN_TRY pWSI->warType = getWarType(); pWSI->challengerGuildID = getChallangerGuildID(); pWSI->challengerGuildName = g_pGuildManager->getGuildName( getChallangerGuildID() ); __END_CATCH}void GuildWar::makeWarInfo(WarInfo* pWarInfo) const throw (Error){ __BEGIN_TRY Assert(pWarInfo!=NULL); Assert(pWarInfo->getWarType()==WAR_GUILD); GuildWarInfo* pGuildWarInfo = dynamic_cast<GuildWarInfo*>(pWarInfo); Assert(pGuildWarInfo!=NULL); //--------------------------------------------------- // 泅犁 己 林牢 备窍扁 //--------------------------------------------------- CastleInfo* pCastleInfo = g_pCastleInfoManager->getCastleInfo( getCastleZoneID() ); if (pCastleInfo==NULL) { filelog("WarError.log", "CastleInfo啊 绝促(%d)", getCastleZoneID()); return; } GuildID_t ownGuildID = pCastleInfo->getGuildID(); GuildID_t challangerGuildID = getChallangerGuildID(); pGuildWarInfo->addJoinGuild( ownGuildID ); // 泅犁 己 林牢 pGuildWarInfo->addJoinGuild( challangerGuildID ); // 己俊 傍拜窍绰 辨靛 pGuildWarInfo->setCastleID( getCastleZoneID() ); // 傍拜 辨靛 捞抚 static const string commonSlayerGuild("绝澜"); static const string commonVampireGuild("绝澜"); string attackGuildName; string defenseGuildName; if ( challangerGuildID==SlayerCommon ) attackGuildName = commonSlayerGuild; else if ( challangerGuildID==VampireCommon ) attackGuildName = commonVampireGuild; else attackGuildName = g_pGuildManager->getGuildName( getChallangerGuildID() ); if ( ownGuildID==SlayerCommon ) defenseGuildName = commonSlayerGuild; else if ( ownGuildID==VampireCommon ) defenseGuildName = commonVampireGuild; else defenseGuildName = g_pGuildManager->getGuildName( ownGuildID ); pGuildWarInfo->setAttackGuildName( attackGuildName ); pGuildWarInfo->setDefenseGuildName( defenseGuildName ); __END_CATCH}string GuildWar::toString() const throw (Error){ __BEGIN_TRY StringStream msg; msg << "GuildWar(" << "WarID:" << (int)getWarID() << ",State:" << (int)getState() << ",CastleZoneID:" << (int)m_CastleZoneID << ",WarType:" << getWarType2DBString() << ",ChallengerGuildID:" << (int)m_ChallangerGuildID << ",RegistrationFee:" << (int)m_RegistrationFee << ")"; return msg.toString(); __END_CATCH}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -