📄 party.cpp
字号:
//////////////////////////////////////////////////////////////////////////////// Filename : PartyInvite.cpp// Written by : excel96// Description ://////////////////////////////////////////////////////////////////////////////#include "Party.h"#include "CreatureUtil.h"#include "StringStream.h"#include "GamePlayer.h"#include "Zone.h"#include "Slayer.h"#include "Vampire.h"#include "Ousters.h"#include "StringStream.h"#include "Effect.h"#include "EffectManager.h"#include "PCFinder.h"#include "Item.h"#include "PacketUtil.h"#include <list>#include "skill/SkillUtil.h"#include "skill/EffectRevealer.h"#include "skill/EffectDetectHidden.h"#include "skill/EffectDetectInvisibility.h"#include "skill/EffectExpansion.h"#include "skill/EffectActivation.h"#include "skill/EffectGnomesWhisper.h"#include "skill/EffectHolyArmor.h"#include "Gpackets/GCPartyLeave.h"#include "Gpackets/GCPartyInvite.h"#include "Gpackets/GCPartyJoined.h"#include "Gpackets/GCAddEffect.h"#include "Gpackets/GCModifyInformation.h"#include "Gpackets/GCStatusCurrentHP.h"#include "Gpackets/GCOtherModifyInfo.h"#include "Gpackets/GCOtherGuildName.h"//////////////////////////////////////////////////////////////////////////////// global varible //////////////////////////////////////////////////////////////////////////////GlobalPartyManager* g_pGlobalPartyManager = NULL;////////////////////////////////////////////////////////////////////////////////// class PartyInviteInfo member methods////////////////////////////////////////////////////////////////////////////////string PartyInviteInfo::toString(void) const throw(){ __BEGIN_TRY StringStream msg; msg << "PartyInviteInfo(" << "Host:" << m_HostName << ",Guest:" << m_GuestName << ")"; return msg.toString(); __END_CATCH}////////////////////////////////////////////////////////////////////////////////// class PartyInviteInfoManager member methods////////////////////////////////////////////////////////////////////////////////PartyInviteInfoManager::PartyInviteInfoManager() throw(){ __BEGIN_TRY m_Mutex.setName("PartyInviteInfoManager"); __END_CATCH}PartyInviteInfoManager::~PartyInviteInfoManager() throw(){ __BEGIN_TRY hash_map<string, PartyInviteInfo*>::iterator itr = m_InfoMap.begin(); for (; itr != m_InfoMap.end(); itr++) { PartyInviteInfo* pInfo = itr->second; SAFE_DELETE(pInfo); } m_InfoMap.clear(); __END_CATCH}bool PartyInviteInfoManager::hasInviteInfo(const string& HostName) throw (Error){ __BEGIN_TRY hash_map<string, PartyInviteInfo*>::iterator itr = m_InfoMap.find(HostName); if (itr == m_InfoMap.end()) { return false; } return true; __END_CATCH}bool PartyInviteInfoManager::canInvite(Creature* pHost, Creature* pGuest) throw (Error){ __BEGIN_TRY Assert(pHost != NULL && pGuest != NULL); // 荤恩尝府 檬措甫 秦具 茄促. if (!pHost->isPC() || !pGuest->isPC()) return false; // 促弗 辆练尝府绰 檬措且 荐 绝促. if (!isSameRace(pHost, pGuest)) return false; // 捞固 穿焙啊甫 檬措窍绊 乐芭唱, 檬措罐绊 乐促搁 檬措且 荐 绝促. PartyInviteInfo* pHostInfo = getInviteInfo(pHost->getName()); PartyInviteInfo* pGuestInfo = getInviteInfo(pGuest->getName()); if (pHostInfo != NULL || pGuestInfo != NULL) return false; // 霸胶飘啊 捞固 颇萍俊 啊涝登绢 乐促搁 檬措且 荐 绝促. //if (pGuest->getPartyID() != 0) return false; return true; __END_CATCH}bool PartyInviteInfoManager::isInviting(Creature* pHost, Creature* pGuest) throw (Error){ __BEGIN_TRY Assert(pHost != NULL && pGuest != NULL); PartyInviteInfo* pHostInfo = getInviteInfo(pHost->getName()); PartyInviteInfo* pGuestInfo = getInviteInfo(pGuest->getName()); if (pHostInfo == NULL || pGuestInfo == NULL) return false; // 辑肺啊 街规氢栏肺 惑措甫 啊府虐绊 乐绢具 茄促. // A(Host) | B(Guest) // Host : shit | Host : fuck // Guest : fuck | Guest : shit if ((pHostInfo->getGuestName() == pGuestInfo->getHostName()) && (pGuestInfo->getGuestName() == pHostInfo->getHostName())) return true; return false; __END_CATCH}void PartyInviteInfoManager::initInviteInfo(Creature* pHost, Creature* pGuest) throw (Error){ __BEGIN_TRY if (hasInviteInfo(pHost->getName()) || hasInviteInfo(pGuest->getName())) { // 咯扁辑 公攫啊 吝酶 泅惑捞 老绢车菌促. 弊矾聪鳖, CGPartyInvite // 菩哦俊 狼秦辑 颇萍 檬措 沥焊啊 檬扁拳登妨绰 矫痢牢单, 捞固 // 檬措 沥焊啊 粮犁茄促绰 富捞促. 盔贰绰 俊矾甫 带廉具 窍绰单, // 盔牢阑 舅 荐啊 绝绢辑, 傲 街规狼 沥焊甫 秒家秦 滚府档废 函版沁促. cancelInvite(pHost, pGuest); return; } PartyInviteInfo* pHostInfo = new PartyInviteInfo; pHostInfo->setHostName(pHost->getName()); pHostInfo->setGuestName(pGuest->getName()); if (!addInviteInfo(pHostInfo)) { delete pHostInfo; } PartyInviteInfo* pGuestInfo = new PartyInviteInfo; pGuestInfo->setHostName(pGuest->getName()); pGuestInfo->setGuestName(pHost->getName()); if (!addInviteInfo(pGuestInfo)) { delete pHostInfo; } __END_CATCH}void PartyInviteInfoManager::cancelInvite(Creature* pHost, Creature* pGuest) throw (Error){ __BEGIN_TRY Assert(pHost != NULL && pGuest != NULL); int nCondition = 0; // 笛 促 荤恩捞 酒聪扼搁 帮鄂茄促. if (!pHost->isPC() || !pGuest->isPC()) nCondition = 1; if (!isSameRace(pHost, pGuest)) nCondition = 2; if (!isInviting(pHost, pGuest)) nCondition = 4; if (nCondition != 0) { cerr << "PartyInviteInfoManager::cancelInvite() : Error = " << nCondition << endl; // initInviteInfo()俊辑 老绢唱绰 泅惑苞 付蛮啊瘤肺 咯扁俊辑档 // 弊 馆措狼 泅惑捞 老绢唱辑, 林籍贸府秦 滚啡促. //throw Error("PartyInviteInfoManager::cancelInvite()"); } deleteInviteInfo(pHost->getName()); deleteInviteInfo(pGuest->getName()); __END_CATCH}void PartyInviteInfoManager::cancelInvite(Creature* pCreature) throw (Error){ __BEGIN_TRY Assert(pCreature != NULL); PartyInviteInfo* pInfo = getInviteInfo(pCreature->getName()); if (pInfo != NULL) { Zone* pZone = pCreature->getZone(); // if 观俊 乐带吧 颗辫. by sigi. 2002.5.8 const string& HostName = pInfo->getHostName(); // &眠啊. by sigi. 2002.5.8 const string& GuestName = pInfo->getGuestName(); Creature* pTargetCreature = NULL; /* try { pTargetCreature = pZone->getCreature(GuestName); } catch (NoSuchElementException) { pTargetCreature = NULL; } */ // NoSuch.. 力芭. by sigi. 2002.5.2 pTargetCreature = pZone->getCreature(GuestName); // 颇萍 檬措 惑措啊 鞍篮 粮俊 粮犁且 版快, 惑措规俊霸 檬措啊 // 芭何登菌促绰 沥焊甫 朝妨霖促. GCPartyInvite gcPartyInvite; gcPartyInvite.setTargetObjectID(pCreature->getObjectID()); gcPartyInvite.setCode(GC_PARTY_INVITE_REJECT); if (pTargetCreature != NULL) { Player* pTargetPlayer = pTargetCreature->getPlayer(); Assert(pTargetPlayer != NULL); pTargetPlayer->sendPacket(&gcPartyInvite); } deleteInviteInfo(HostName); deleteInviteInfo(GuestName); } /* else { cerr << "PartyInviteInfoManager::cancelInvite() : Error" << endl; throw ("PartyInviteInfoManager::cancelInvite() : Error"); } */ __END_CATCH}bool PartyInviteInfoManager::addInviteInfo(PartyInviteInfo* pInfo) throw (Error){ __BEGIN_TRY hash_map<string, PartyInviteInfo*>::iterator itr = m_InfoMap.find(pInfo->getHostName()); if (itr != m_InfoMap.end()) { cerr << "PartyInviteInfoManager::addInviteInfo() : DuplicatedException" << endl; //throw DuplicatedException("PartyInviteInfoManager::addInviteInfo() : DuplicatedException"); // Exception力芭. by sigi. 2002.5.9 return false; } m_InfoMap[pInfo->getHostName()] = pInfo; return true; __END_CATCH} void PartyInviteInfoManager::deleteInviteInfo(const string& HostName) throw (NoSuchElementException, Error){ __BEGIN_TRY hash_map<string, PartyInviteInfo*>::iterator itr = m_InfoMap.find(HostName); if (itr != m_InfoMap.end()) { m_InfoMap.erase(itr); } /* cerr << "PartyInviteInfoManager::deleteInviteInfo() : NoSuchElementException" << endl; throw NoSuchElementException("PartyInviteInfoManager::deleteInviteInfo() : NoSuchElementException"); */ __END_CATCH} PartyInviteInfo* PartyInviteInfoManager::getInviteInfo(const string& HostName) throw (NoSuchElementException, Error){ __BEGIN_TRY hash_map<string, PartyInviteInfo*>::iterator itr = m_InfoMap.find(HostName); if (itr == m_InfoMap.end()) { return NULL; } /* { cerr << "PartyInviteInfoManager::getInviteInfo() : NoSuchElementException" << endl; throw NoSuchElementException("PartyInviteInfoManager::getInviteInfo() : NoSuchElementException"); } */ return itr->second; __END_CATCH}////////////////////////////////////////////////////////////////////////////////// class Party member methods////////////////////////////////////////////////////////////////////////////////Party::Party(Creature::CreatureClass CClass) throw(){ __BEGIN_TRY // 颇萍俊 加且 荐 乐绰 农府媚 努贰胶甫 沥秦林绊... m_CreatureClass = CClass; m_bFamilyPay = false; // 孤咆胶俊 捞抚阑 技泼茄促. (叼滚彪侩) m_Mutex.setName("Party"); __END_CATCH}Party::~Party() throw(){ __BEGIN_TRY __ENTER_CRITICAL_SECTION(m_Mutex) m_MemberMap.clear(); __LEAVE_CRITICAL_SECTION(m_Mutex) __END_CATCH}// 捞抚栏肺 颇萍俊 糕滚甫 茫酒辑 府畔茄促.Creature* Party::getMember(const string& name) const throw (NoSuchElementException, Error){ __BEGIN_TRY //cout << "Party::getMember() : BEGIN" << endl; Creature* pCreature = NULL; __ENTER_CRITICAL_SECTION(m_Mutex) hash_map<string, Creature*>::const_iterator itr = m_MemberMap.find(name); if (itr == m_MemberMap.end()) { cerr << "Party::getMember() : NoSuchElementException" << endl; throw NoSuchElementException("Party::getMember() : NoSuchElementException"); } pCreature = itr->second; __LEAVE_CRITICAL_SECTION(m_Mutex) //cout << "Party::getMember() : END" << endl; return pCreature; __END_CATCH}// 糕滚甫 歹茄促.void Party::addMember(Creature* pCreature) throw (DuplicatedException, Error){ __BEGIN_TRY //cout << "Party::addMember() : BEGIN" << endl; // 颇萍俊 加且 荐 乐绰 辆练捞 酒聪扼搁... if (pCreature->getCreatureClass() != m_CreatureClass) { cerr << "Party::addMember() : Invalid Creature Class" << endl; throw Error("Party::addMember() : Invalid Creature Class"); } __ENTER_CRITICAL_SECTION(m_Mutex) hash_map<string, Creature*>::iterator itr = m_MemberMap.find(pCreature->getName()); if (itr == m_MemberMap.end()) { m_MemberMap[pCreature->getName()] = pCreature; } else { /* cerr << "Party::addMember() : DuplicatedException" << endl; throw DuplicatedException("Party::addMember() : DuplicatedException"); */ } __LEAVE_CRITICAL_SECTION(m_Mutex) //cout << "Party::addMember() : END" << endl; __END_CATCH}// 颇萍俊辑 糕滚甫 昏力茄促.void Party::deleteMember(const string& name) throw (NoSuchElementException, Error){ __BEGIN_TRY //cout << "Party::deleteMember() : BEGIN" << endl; __ENTER_CRITICAL_SECTION(m_Mutex) hash_map<string, Creature*>::iterator itr = m_MemberMap.find(name); if (itr == m_MemberMap.end()) { //cerr << "Party::deleteMember() : NoSuchElementException" << endl; //throw NoSuchElementException("Party::deleteMember() : NoSuchElementException"); m_Mutex.unlock(); return; } m_MemberMap.erase(itr); __LEAVE_CRITICAL_SECTION(m_Mutex) //cout << "Party::deleteMember() : END" << endl; __END_CATCH}// 颇萍俊 漂沥 捞抚阑 啊柳 糕滚啊 乐绰瘤 炼荤茄促.bool Party::hasMember(const string& name) const throw (){ __BEGIN_TRY //cout << "Party::hasMember() : BEGIN" << endl; __ENTER_CRITICAL_SECTION(m_Mutex) hash_map<string, Creature*>::const_iterator itr = m_MemberMap.find(name); if (itr == m_MemberMap.end()) { //cout << "Party::hasMember() : END" << endl; m_Mutex.unlock(); return false; } __LEAVE_CRITICAL_SECTION(m_Mutex) //cout << "Party::hasMember() : END" << endl; return true; __END_CATCH}// 臂肺国 颇萍 概聪历俊辑父 荤侩茄促...// 颇萍甫 秦眉窍扁 傈俊 颇萍 糕滚甸狼 颇萍 ID甫 0栏肺 父甸绊,// 肺拿 颇萍 概聪历俊辑 秦寸 ID甫 啊柳 颇萍甫 昏力茄促.void Party::destroyParty(void) throw(){ __BEGIN_TRY //cout << "Party::destroyParty() : BEGIN" << endl;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -