[8612] better error-check when getting bgTypeId from Battlemasterentry

This commit is contained in:
balrok 2009-10-10 01:35:58 +02:00
parent d7e01c3e16
commit caf4732e38
4 changed files with 13 additions and 2 deletions

View file

@ -50,6 +50,9 @@ void WorldSession::HandleBattlemasterHelloOpcode( WorldPacket & recv_data )
BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(unit->GetEntry()); BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(unit->GetEntry());
if (bgTypeId == BATTLEGROUND_TYPE_NONE)
return;
if (!_player->GetBGAccessByLevel(bgTypeId)) if (!_player->GetBGAccessByLevel(bgTypeId))
{ {
// temp, must be gossip message... // temp, must be gossip message...

View file

@ -235,7 +235,7 @@ class BattleGroundMgr
BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry); BattleMastersMap::const_iterator itr = mBattleMastersMap.find(entry);
if (itr != mBattleMastersMap.end()) if (itr != mBattleMastersMap.end())
return itr->second; return itr->second;
return BATTLEGROUND_WS; return BATTLEGROUND_TYPE_NONE;
} }
void LoadBattleEventIndexes(); void LoadBattleEventIndexes();

View file

@ -711,6 +711,9 @@ bool Creature::isCanInteractWithBattleMaster(Player* pPlayer, bool msg) const
return false; return false;
BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(GetEntry()); BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(GetEntry());
if (bgTypeId == BATTLEGROUND_TYPE_NONE)
return false;
if(!msg) if(!msg)
return pPlayer->GetBGAccessByLevel(bgTypeId); return pPlayer->GetBGAccessByLevel(bgTypeId);
@ -968,6 +971,11 @@ void Creature::OnGossipSelect(Player* player, uint32 option)
case GOSSIP_OPTION_BATTLEFIELD: case GOSSIP_OPTION_BATTLEFIELD:
{ {
BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(GetEntry()); BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(GetEntry());
if (bgTypeId == BATTLEGROUND_TYPE_NONE)
{
sLog.outError("a user (guid %u) requested battlegroundlist from a npc who is no battlemaster", player->GetGUIDLow());
return;
}
player->GetSession()->SendBattlegGroundList( GetGUID(), bgTypeId ); player->GetSession()->SendBattlegGroundList( GetGUID(), bgTypeId );
break; break;
} }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8611" #define REVISION_NR "8612"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__