Various Cleanups (game N-O)

This commit is contained in:
Schmoozerd 2012-07-19 21:51:08 +02:00
parent 8d0c106aa4
commit 94795f2bff
14 changed files with 1560 additions and 1519 deletions

View file

@ -45,12 +45,12 @@ enum StableResultCode
STABLE_ERR_EXOTIC = 0x0C, // "you are unable to control exotic creatures" STABLE_ERR_EXOTIC = 0x0C, // "you are unable to control exotic creatures"
}; };
void WorldSession::HandleTabardVendorActivateOpcode( WorldPacket & recv_data ) void WorldSession::HandleTabardVendorActivateOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
recv_data >> guid; recv_data >> guid;
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TABARDDESIGNER); Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TABARDDESIGNER);
if (!unit) if (!unit)
{ {
DEBUG_LOG("WORLD: HandleTabardVendorActivateOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); DEBUG_LOG("WORLD: HandleTabardVendorActivateOpcode - %s not found or you can't interact with him.", guid.GetString().c_str());
@ -58,7 +58,7 @@ void WorldSession::HandleTabardVendorActivateOpcode( WorldPacket & recv_data )
} }
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
SendTabardVendorActivate(guid); SendTabardVendorActivate(guid);
@ -66,12 +66,12 @@ void WorldSession::HandleTabardVendorActivateOpcode( WorldPacket & recv_data )
void WorldSession::SendTabardVendorActivate(ObjectGuid guid) void WorldSession::SendTabardVendorActivate(ObjectGuid guid)
{ {
WorldPacket data( MSG_TABARDVENDOR_ACTIVATE, 8 ); WorldPacket data(MSG_TABARDVENDOR_ACTIVATE, 8);
data << ObjectGuid(guid); data << ObjectGuid(guid);
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleBankerActivateOpcode( WorldPacket & recv_data ) void WorldSession::HandleBankerActivateOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
@ -83,7 +83,7 @@ void WorldSession::HandleBankerActivateOpcode( WorldPacket & recv_data )
return; return;
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
SendShowBank(guid); SendShowBank(guid);
@ -103,7 +103,7 @@ void WorldSession::SendShowMailBox(ObjectGuid guid)
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleTrainerListOpcode( WorldPacket & recv_data ) void WorldSession::HandleTrainerListOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
@ -142,9 +142,9 @@ static void SendTrainerSpellHelper(WorldPacket& data, TrainerSpell const* tSpell
void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle) void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
{ {
DEBUG_LOG( "WORLD: SendTrainerList" ); DEBUG_LOG("WORLD: SendTrainerList");
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TRAINER); Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid,UNIT_NPC_FLAG_TRAINER);
if (!unit) if (!unit)
{ {
DEBUG_LOG("WORLD: SendTrainerList - %s not found or you can't interact with him.", guid.GetString().c_str()); DEBUG_LOG("WORLD: SendTrainerList - %s not found or you can't interact with him.", guid.GetString().c_str());
@ -159,7 +159,7 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
if (!unit->IsTrainerOf(_player,true)) if (!unit->IsTrainerOf(_player,true))
return; return;
CreatureInfo const *ci = unit->GetCreatureInfo(); CreatureInfo const* ci = unit->GetCreatureInfo();
if (!ci) if (!ci)
return; return;
@ -175,7 +175,7 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
uint32 maxcount = (cSpells ? cSpells->spellList.size() : 0) + (tSpells ? tSpells->spellList.size() : 0); uint32 maxcount = (cSpells ? cSpells->spellList.size() : 0) + (tSpells ? tSpells->spellList.size() : 0);
uint32 trainer_type = cSpells && cSpells->trainerType ? cSpells->trainerType : (tSpells ? tSpells->trainerType : 0); uint32 trainer_type = cSpells && cSpells->trainerType ? cSpells->trainerType : (tSpells ? tSpells->trainerType : 0);
WorldPacket data( SMSG_TRAINER_LIST, 8+4+4+maxcount*38 + strTitle.size()+1); WorldPacket data(SMSG_TRAINER_LIST, 8+4+4+maxcount*38 + strTitle.size()+1);
data << ObjectGuid(guid); data << ObjectGuid(guid);
data << uint32(trainer_type); data << uint32(trainer_type);
@ -190,12 +190,12 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
if (cSpells) if (cSpells)
{ {
for(TrainerSpellMap::const_iterator itr = cSpells->spellList.begin(); itr != cSpells->spellList.end(); ++itr) for (TrainerSpellMap::const_iterator itr = cSpells->spellList.begin(); itr != cSpells->spellList.end(); ++itr)
{ {
TrainerSpell const* tSpell = &itr->second; TrainerSpell const* tSpell = &itr->second;
uint32 reqLevel = 0; uint32 reqLevel = 0;
if(!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell, &reqLevel)) if (!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell, &reqLevel))
continue; continue;
reqLevel = tSpell->isProvidedReqLevel ? tSpell->reqLevel : std::max(reqLevel, tSpell->reqLevel); reqLevel = tSpell->isProvidedReqLevel ? tSpell->reqLevel : std::max(reqLevel, tSpell->reqLevel);
@ -210,12 +210,12 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
if (tSpells) if (tSpells)
{ {
for(TrainerSpellMap::const_iterator itr = tSpells->spellList.begin(); itr != tSpells->spellList.end(); ++itr) for (TrainerSpellMap::const_iterator itr = tSpells->spellList.begin(); itr != tSpells->spellList.end(); ++itr)
{ {
TrainerSpell const* tSpell = &itr->second; TrainerSpell const* tSpell = &itr->second;
uint32 reqLevel = 0; uint32 reqLevel = 0;
if(!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell, &reqLevel)) if (!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell, &reqLevel))
continue; continue;
reqLevel = tSpell->isProvidedReqLevel ? tSpell->reqLevel : std::max(reqLevel, tSpell->reqLevel); reqLevel = tSpell->isProvidedReqLevel ? tSpell->reqLevel : std::max(reqLevel, tSpell->reqLevel);
@ -234,7 +234,7 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recv_data)
{ {
ObjectGuid guid; ObjectGuid guid;
uint32 spellId = 0; uint32 spellId = 0;
@ -242,7 +242,7 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data )
recv_data >> guid >> spellId; recv_data >> guid >> spellId;
DEBUG_LOG("WORLD: Received CMSG_TRAINER_BUY_SPELL Trainer: %s, learn spell id is: %u", guid.GetString().c_str(), spellId); DEBUG_LOG("WORLD: Received CMSG_TRAINER_BUY_SPELL Trainer: %s, learn spell id is: %u", guid.GetString().c_str(), spellId);
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER); Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER);
if (!unit) if (!unit)
{ {
DEBUG_LOG("WORLD: HandleTrainerBuySpellOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); DEBUG_LOG("WORLD: HandleTrainerBuySpellOpcode - %s not found or you can't interact with him.", guid.GetString().c_str());
@ -276,7 +276,7 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data )
// can't be learn, cheat? Or double learn with lags... // can't be learn, cheat? Or double learn with lags...
uint32 reqLevel = 0; uint32 reqLevel = 0;
if(!_player->IsSpellFitByClassAndRace(trainer_spell->learnedSpell, &reqLevel)) if (!_player->IsSpellFitByClassAndRace(trainer_spell->learnedSpell, &reqLevel))
return; return;
reqLevel = trainer_spell->isProvidedReqLevel ? trainer_spell->reqLevel : std::max(reqLevel, trainer_spell->reqLevel); reqLevel = trainer_spell->isProvidedReqLevel ? trainer_spell->reqLevel : std::max(reqLevel, trainer_spell->reqLevel);
@ -287,10 +287,10 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data )
uint32 nSpellCost = uint32(floor(trainer_spell->spellCost * _player->GetReputationPriceDiscount(unit))); uint32 nSpellCost = uint32(floor(trainer_spell->spellCost * _player->GetReputationPriceDiscount(unit)));
// check money requirement // check money requirement
if(_player->GetMoney() < nSpellCost ) if (_player->GetMoney() < nSpellCost)
return; return;
_player->ModifyMoney( -int32(nSpellCost) ); _player->ModifyMoney(-int32(nSpellCost));
WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); // visual effect on trainer WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); // visual effect on trainer
data << ObjectGuid(guid); data << ObjectGuid(guid);
@ -303,7 +303,7 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data )
SendPacket(&data); SendPacket(&data);
// learn explicitly or cast explicitly // learn explicitly or cast explicitly
if(trainer_spell->IsCastable()) if (trainer_spell->IsCastable())
_player->CastSpell(_player, trainer_spell->spell, true); _player->CastSpell(_player, trainer_spell->spell, true);
else else
_player->learnSpell(spellId, false); _player->learnSpell(spellId, false);
@ -314,14 +314,14 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data )
SendPacket(&data); SendPacket(&data);
} }
void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data) void WorldSession::HandleGossipHelloOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Received CMSG_GOSSIP_HELLO"); DEBUG_LOG("WORLD: Received CMSG_GOSSIP_HELLO");
ObjectGuid guid; ObjectGuid guid;
recv_data >> guid; recv_data >> guid;
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
if (!pCreature) if (!pCreature)
{ {
DEBUG_LOG("WORLD: HandleGossipHelloOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); DEBUG_LOG("WORLD: HandleGossipHelloOpcode - %s not found or you can't interact with him.", guid.GetString().c_str());
@ -345,7 +345,7 @@ void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data)
} }
} }
void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_GOSSIP_SELECT_OPTION"); DEBUG_LOG("WORLD: CMSG_GOSSIP_SELECT_OPTION");
@ -371,7 +371,7 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data )
if (guid.IsAnyTypeCreature()) if (guid.IsAnyTypeCreature())
{ {
Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
if (!pCreature) if (!pCreature)
{ {
@ -384,7 +384,7 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data )
} }
else if (guid.IsGameObject()) else if (guid.IsGameObject())
{ {
GameObject *pGo = GetPlayer()->GetGameObjectIfCanInteractWith(guid); GameObject* pGo = GetPlayer()->GetGameObjectIfCanInteractWith(guid);
if (!pGo) if (!pGo)
{ {
@ -397,7 +397,7 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data )
} }
} }
void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data ) void WorldSession::HandleSpiritHealerActivateOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_SPIRIT_HEALER_ACTIVATE"); DEBUG_LOG("WORLD: CMSG_SPIRIT_HEALER_ACTIVATE");
@ -405,10 +405,10 @@ void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data )
recv_data >> guid; recv_data >> guid;
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_SPIRITHEALER); Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_SPIRITHEALER);
if (!unit) if (!unit)
{ {
DEBUG_LOG( "WORLD: HandleSpiritHealerActivateOpcode - %s not found or you can't interact with him.", guid.GetString().c_str()); DEBUG_LOG("WORLD: HandleSpiritHealerActivateOpcode - %s not found or you can't interact with him.", guid.GetString().c_str());
return; return;
} }
@ -426,22 +426,22 @@ void WorldSession::SendSpiritResurrect()
_player->DurabilityLossAll(0.25f,true); _player->DurabilityLossAll(0.25f,true);
// get corpse nearest graveyard // get corpse nearest graveyard
WorldSafeLocsEntry const *corpseGrave = NULL; WorldSafeLocsEntry const* corpseGrave = NULL;
Corpse *corpse = _player->GetCorpse(); Corpse* corpse = _player->GetCorpse();
if(corpse) if (corpse)
corpseGrave = sObjectMgr.GetClosestGraveYard( corpseGrave = sObjectMgr.GetClosestGraveYard(
corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeam()); corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeam());
// now can spawn bones // now can spawn bones
_player->SpawnCorpseBones(); _player->SpawnCorpseBones();
// teleport to nearest from corpse graveyard, if different from nearest to player ghost // teleport to nearest from corpse graveyard, if different from nearest to player ghost
if(corpseGrave) if (corpseGrave)
{ {
WorldSafeLocsEntry const *ghostGrave = sObjectMgr.GetClosestGraveYard( WorldSafeLocsEntry const* ghostGrave = sObjectMgr.GetClosestGraveYard(
_player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeam()); _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeam());
if(corpseGrave != ghostGrave) if (corpseGrave != ghostGrave)
_player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation()); _player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation());
// or update at original position // or update at original position
else else
@ -458,15 +458,15 @@ void WorldSession::SendSpiritResurrect()
} }
} }
void WorldSession::HandleBinderActivateOpcode( WorldPacket & recv_data ) void WorldSession::HandleBinderActivateOpcode(WorldPacket& recv_data)
{ {
ObjectGuid npcGuid; ObjectGuid npcGuid;
recv_data >> npcGuid; recv_data >> npcGuid;
if(!GetPlayer()->IsInWorld() || !GetPlayer()->isAlive()) if (!GetPlayer()->IsInWorld() || !GetPlayer()->isAlive())
return; return;
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(npcGuid,UNIT_NPC_FLAG_INNKEEPER); Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(npcGuid,UNIT_NPC_FLAG_INNKEEPER);
if (!unit) if (!unit)
{ {
DEBUG_LOG("WORLD: HandleBinderActivateOpcode - %s not found or you can't interact with him.", npcGuid.GetString().c_str()); DEBUG_LOG("WORLD: HandleBinderActivateOpcode - %s not found or you can't interact with him.", npcGuid.GetString().c_str());
@ -474,30 +474,30 @@ void WorldSession::HandleBinderActivateOpcode( WorldPacket & recv_data )
} }
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
SendBindPoint(unit); SendBindPoint(unit);
} }
void WorldSession::SendBindPoint(Creature *npc) void WorldSession::SendBindPoint(Creature* npc)
{ {
// prevent set homebind to instances in any case // prevent set homebind to instances in any case
if(GetPlayer()->GetMap()->Instanceable()) if (GetPlayer()->GetMap()->Instanceable())
return; return;
// send spell for bind 3286 bind magic // send spell for bind 3286 bind magic
npc->CastSpell(_player, 3286, true); // Bind npc->CastSpell(_player, 3286, true); // Bind
WorldPacket data( SMSG_TRAINER_BUY_SUCCEEDED, (8+4)); WorldPacket data(SMSG_TRAINER_BUY_SUCCEEDED, (8+4));
data << npc->GetObjectGuid(); data << npc->GetObjectGuid();
data << uint32(3286); // Bind data << uint32(3286); // Bind
SendPacket( &data ); SendPacket(&data);
_player->PlayerTalkClass->CloseGossip(); _player->PlayerTalkClass->CloseGossip();
} }
void WorldSession::HandleListStabledPetsOpcode( WorldPacket & recv_data ) void WorldSession::HandleListStabledPetsOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Recv MSG_LIST_STABLED_PETS"); DEBUG_LOG("WORLD: Recv MSG_LIST_STABLED_PETS");
ObjectGuid npcGUID; ObjectGuid npcGUID;
@ -511,20 +511,20 @@ void WorldSession::HandleListStabledPetsOpcode( WorldPacket & recv_data )
} }
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
SendStablePet(npcGUID); SendStablePet(npcGUID);
} }
void WorldSession::SendStablePet( ObjectGuid guid ) void WorldSession::SendStablePet(ObjectGuid guid)
{ {
DEBUG_LOG("WORLD: Recv MSG_LIST_STABLED_PETS Send."); DEBUG_LOG("WORLD: Recv MSG_LIST_STABLED_PETS Send.");
WorldPacket data(MSG_LIST_STABLED_PETS, 200); // guess size WorldPacket data(MSG_LIST_STABLED_PETS, 200); // guess size
data << guid; data << guid;
Pet *pet = _player->GetPet(); Pet* pet = _player->GetPet();
size_t wpos = data.wpos(); size_t wpos = data.wpos();
data << uint8(0); // place holder for slot show number data << uint8(0); // place holder for slot show number
@ -534,7 +534,7 @@ void WorldSession::SendStablePet( ObjectGuid guid )
uint8 num = 0; // counter for place holder uint8 num = 0; // counter for place holder
// not let move dead pet in slot // not let move dead pet in slot
if(pet && pet->isAlive() && pet->getPetType()==HUNTER_PET) if (pet && pet->isAlive() && pet->getPetType()==HUNTER_PET)
{ {
data << uint32(pet->GetCharmInfo()->GetPetNumber()); data << uint32(pet->GetCharmInfo()->GetPetNumber());
data << uint32(pet->GetEntry()); data << uint32(pet->GetEntry());
@ -546,13 +546,13 @@ void WorldSession::SendStablePet( ObjectGuid guid )
// 0 1 2 3 4 // 0 1 2 3 4
QueryResult* result = CharacterDatabase.PQuery("SELECT owner, id, entry, level, name FROM character_pet WHERE owner = '%u' AND slot >= '%u' AND slot <= '%u' ORDER BY slot", QueryResult* result = CharacterDatabase.PQuery("SELECT owner, id, entry, level, name FROM character_pet WHERE owner = '%u' AND slot >= '%u' AND slot <= '%u' ORDER BY slot",
_player->GetGUIDLow(),PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT); _player->GetGUIDLow(),PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT);
if(result) if (result)
{ {
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
data << uint32(fields[1].GetUInt32()); // petnumber data << uint32(fields[1].GetUInt32()); // petnumber
data << uint32(fields[2].GetUInt32()); // creature entry data << uint32(fields[2].GetUInt32()); // creature entry
@ -561,7 +561,8 @@ void WorldSession::SendStablePet( ObjectGuid guid )
data << uint8(2); // 1 = current, 2/3 = in stable (any from 4,5,... create problems with proper show) data << uint8(2); // 1 = current, 2/3 = in stable (any from 4,5,... create problems with proper show)
++num; ++num;
}while( result->NextRow() ); }
while (result->NextRow());
delete result; delete result;
} }
@ -602,14 +603,14 @@ bool WorldSession::CheckStableMaster(ObjectGuid guid)
return true; return true;
} }
void WorldSession::HandleStablePet( WorldPacket & recv_data ) void WorldSession::HandleStablePet(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Recv CMSG_STABLE_PET"); DEBUG_LOG("WORLD: Recv CMSG_STABLE_PET");
ObjectGuid npcGUID; ObjectGuid npcGUID;
recv_data >> npcGUID; recv_data >> npcGUID;
if(!GetPlayer()->isAlive()) if (!GetPlayer()->isAlive())
{ {
SendStableResult(STABLE_ERR_STABLE); SendStableResult(STABLE_ERR_STABLE);
return; return;
@ -622,13 +623,13 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data )
} }
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
Pet *pet = _player->GetPet(); Pet* pet = _player->GetPet();
// can't place in stable dead pet // can't place in stable dead pet
if(!pet||!pet->isAlive()||pet->getPetType()!=HUNTER_PET) if (!pet||!pet->isAlive()||pet->getPetType()!=HUNTER_PET)
{ {
SendStableResult(STABLE_ERR_STABLE); SendStableResult(STABLE_ERR_STABLE);
return; return;
@ -636,28 +637,29 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data )
uint32 free_slot = 1; uint32 free_slot = 1;
QueryResult *result = CharacterDatabase.PQuery("SELECT owner,slot,id FROM character_pet WHERE owner = '%u' AND slot >= '%u' AND slot <= '%u' ORDER BY slot ", QueryResult* result = CharacterDatabase.PQuery("SELECT owner,slot,id FROM character_pet WHERE owner = '%u' AND slot >= '%u' AND slot <= '%u' ORDER BY slot ",
_player->GetGUIDLow(),PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT); _player->GetGUIDLow(),PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT);
if(result) if (result)
{ {
do do
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
uint32 slot = fields[1].GetUInt32(); uint32 slot = fields[1].GetUInt32();
// slots ordered in query, and if not equal then free // slots ordered in query, and if not equal then free
if(slot!=free_slot) if (slot!=free_slot)
break; break;
// this slot not free, skip // this slot not free, skip
++free_slot; ++free_slot;
}while( result->NextRow() ); }
while (result->NextRow());
delete result; delete result;
} }
if( free_slot > 0 && free_slot <= GetPlayer()->m_stableSlots) if (free_slot > 0 && free_slot <= GetPlayer()->m_stableSlots)
{ {
pet->Unsummon(PetSaveMode(free_slot), _player); pet->Unsummon(PetSaveMode(free_slot), _player);
SendStableResult(STABLE_SUCCESS_STABLE); SendStableResult(STABLE_SUCCESS_STABLE);
@ -666,7 +668,7 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data )
SendStableResult(STABLE_ERR_STABLE); SendStableResult(STABLE_ERR_STABLE);
} }
void WorldSession::HandleUnstablePet( WorldPacket & recv_data ) void WorldSession::HandleUnstablePet(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Recv CMSG_UNSTABLE_PET."); DEBUG_LOG("WORLD: Recv CMSG_UNSTABLE_PET.");
ObjectGuid npcGUID; ObjectGuid npcGUID;
@ -681,30 +683,30 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
} }
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
uint32 creature_id = 0; uint32 creature_id = 0;
{ {
QueryResult *result = CharacterDatabase.PQuery("SELECT entry FROM character_pet WHERE owner = '%u' AND id = '%u' AND slot >='%u' AND slot <= '%u'", QueryResult* result = CharacterDatabase.PQuery("SELECT entry FROM character_pet WHERE owner = '%u' AND id = '%u' AND slot >='%u' AND slot <= '%u'",
_player->GetGUIDLow(),petnumber,PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT); _player->GetGUIDLow(),petnumber,PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT);
if(result) if (result)
{ {
Field *fields = result->Fetch(); Field* fields = result->Fetch();
creature_id = fields[0].GetUInt32(); creature_id = fields[0].GetUInt32();
delete result; delete result;
} }
} }
if(!creature_id) if (!creature_id)
{ {
SendStableResult(STABLE_ERR_STABLE); SendStableResult(STABLE_ERR_STABLE);
return; return;
} }
CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creature_id); CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creature_id);
if(!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets())) if (!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets()))
{ {
// if problem in exotic pet // if problem in exotic pet
if (creatureInfo && creatureInfo->isTameable(true)) if (creatureInfo && creatureInfo->isTameable(true))
@ -715,18 +717,18 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
} }
Pet* pet = _player->GetPet(); Pet* pet = _player->GetPet();
if(pet && pet->isAlive()) if (pet && pet->isAlive())
{ {
SendStableResult(STABLE_ERR_STABLE); SendStableResult(STABLE_ERR_STABLE);
return; return;
} }
// delete dead pet // delete dead pet
if(pet) if (pet)
pet->Unsummon(PET_SAVE_AS_DELETED, _player); pet->Unsummon(PET_SAVE_AS_DELETED, _player);
Pet *newpet = new Pet(HUNTER_PET); Pet* newpet = new Pet(HUNTER_PET);
if(!newpet->LoadPetFromDB(_player,creature_id,petnumber)) if (!newpet->LoadPetFromDB(_player,creature_id,petnumber))
{ {
delete newpet; delete newpet;
newpet = NULL; newpet = NULL;
@ -737,7 +739,7 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data )
SendStableResult(STABLE_SUCCESS_UNSTABLE); SendStableResult(STABLE_SUCCESS_UNSTABLE);
} }
void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data ) void WorldSession::HandleBuyStableSlot(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Recv CMSG_BUY_STABLE_SLOT."); DEBUG_LOG("WORLD: Recv CMSG_BUY_STABLE_SLOT.");
ObjectGuid npcGUID; ObjectGuid npcGUID;
@ -751,13 +753,13 @@ void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data )
} }
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
if(GetPlayer()->m_stableSlots < MAX_PET_STABLES) if (GetPlayer()->m_stableSlots < MAX_PET_STABLES)
{ {
StableSlotPricesEntry const *SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots+1); StableSlotPricesEntry const* SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots+1);
if(_player->GetMoney() >= SlotPrice->Price) if (_player->GetMoney() >= SlotPrice->Price)
{ {
++GetPlayer()->m_stableSlots; ++GetPlayer()->m_stableSlots;
_player->ModifyMoney(-int32(SlotPrice->Price)); _player->ModifyMoney(-int32(SlotPrice->Price));
@ -770,12 +772,12 @@ void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data )
SendStableResult(STABLE_ERR_STABLE); SendStableResult(STABLE_ERR_STABLE);
} }
void WorldSession::HandleStableRevivePet( WorldPacket &/* recv_data */) void WorldSession::HandleStableRevivePet(WorldPacket& /* recv_data */)
{ {
DEBUG_LOG("HandleStableRevivePet: Not implemented"); DEBUG_LOG("HandleStableRevivePet: Not implemented");
} }
void WorldSession::HandleStableSwapPet( WorldPacket & recv_data ) void WorldSession::HandleStableSwapPet(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: Recv CMSG_STABLE_SWAP_PET."); DEBUG_LOG("WORLD: Recv CMSG_STABLE_SWAP_PET.");
ObjectGuid npcGUID; ObjectGuid npcGUID;
@ -790,41 +792,41 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
} }
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
Pet* pet = _player->GetPet(); Pet* pet = _player->GetPet();
if(!pet || pet->getPetType()!=HUNTER_PET) if (!pet || pet->getPetType()!=HUNTER_PET)
{ {
SendStableResult(STABLE_ERR_STABLE); SendStableResult(STABLE_ERR_STABLE);
return; return;
} }
// find swapped pet slot in stable // find swapped pet slot in stable
QueryResult *result = CharacterDatabase.PQuery("SELECT slot,entry FROM character_pet WHERE owner = '%u' AND id = '%u'", QueryResult* result = CharacterDatabase.PQuery("SELECT slot,entry FROM character_pet WHERE owner = '%u' AND id = '%u'",
_player->GetGUIDLow(),pet_number); _player->GetGUIDLow(),pet_number);
if(!result) if (!result)
{ {
SendStableResult(STABLE_ERR_STABLE); SendStableResult(STABLE_ERR_STABLE);
return; return;
} }
Field *fields = result->Fetch(); Field* fields = result->Fetch();
uint32 slot = fields[0].GetUInt32(); uint32 slot = fields[0].GetUInt32();
uint32 creature_id = fields[1].GetUInt32(); uint32 creature_id = fields[1].GetUInt32();
delete result; delete result;
if(!creature_id) if (!creature_id)
{ {
SendStableResult(STABLE_ERR_STABLE); SendStableResult(STABLE_ERR_STABLE);
return; return;
} }
CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creature_id); CreatureInfo const* creatureInfo = ObjectMgr::GetCreatureTemplate(creature_id);
if(!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets())) if (!creatureInfo || !creatureInfo->isTameable(_player->CanTameExoticPets()))
{ {
// if problem in exotic pet // if problem in exotic pet
if (creatureInfo && creatureInfo->isTameable(true)) if (creatureInfo && creatureInfo->isTameable(true))
@ -838,8 +840,8 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
pet->Unsummon(pet->isAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED, _player); pet->Unsummon(pet->isAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED, _player);
// summon unstabled pet // summon unstabled pet
Pet *newpet = new Pet; Pet* newpet = new Pet;
if(!newpet->LoadPetFromDB(_player,creature_id,pet_number)) if (!newpet->LoadPetFromDB(_player,creature_id,pet_number))
{ {
delete newpet; delete newpet;
SendStableResult(STABLE_ERR_STABLE); SendStableResult(STABLE_ERR_STABLE);
@ -848,7 +850,7 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data )
SendStableResult(STABLE_SUCCESS_UNSTABLE); SendStableResult(STABLE_SUCCESS_UNSTABLE);
} }
void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data ) void WorldSession::HandleRepairItemOpcode(WorldPacket& recv_data)
{ {
DEBUG_LOG("WORLD: CMSG_REPAIR_ITEM"); DEBUG_LOG("WORLD: CMSG_REPAIR_ITEM");
@ -858,15 +860,15 @@ void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data )
recv_data >> npcGuid >> itemGuid >> guildBank; recv_data >> npcGuid >> itemGuid >> guildBank;
Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(npcGuid, UNIT_NPC_FLAG_REPAIR); Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(npcGuid, UNIT_NPC_FLAG_REPAIR);
if (!unit) if (!unit)
{ {
DEBUG_LOG( "WORLD: HandleRepairItemOpcode - %s not found or you can't interact with him.", npcGuid.GetString().c_str()); DEBUG_LOG("WORLD: HandleRepairItemOpcode - %s not found or you can't interact with him.", npcGuid.GetString().c_str());
return; return;
} }
// remove fake death // remove fake death
if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);
// reputation discount // reputation discount
@ -879,7 +881,7 @@ void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data )
Item* item = _player->GetItemByGuid(itemGuid); Item* item = _player->GetItemByGuid(itemGuid);
if(item) if (item)
TotalCost= _player->DurabilityRepair(item->GetPos(), true, discountMod, (guildBank > 0)); TotalCost= _player->DurabilityRepair(item->GetPos(), true, discountMod, (guildBank > 0));
} }
else else

View file

@ -29,7 +29,7 @@
struct PageText struct PageText
{ {
uint32 Page_ID; uint32 Page_ID;
char * Text; char* Text;
uint32 Next_Page; uint32 Next_Page;
}; };

View file

@ -28,14 +28,14 @@ class MANGOS_DLL_DECL NullCreatureAI : public CreatureAI
explicit NullCreatureAI(Creature* c) : CreatureAI(c) {} explicit NullCreatureAI(Creature* c) : CreatureAI(c) {}
~NullCreatureAI(); ~NullCreatureAI();
void MoveInLineOfSight(Unit *) {} void MoveInLineOfSight(Unit*) {}
void AttackStart(Unit *) {} void AttackStart(Unit*) {}
void AttackedBy( Unit *) {} void AttackedBy(Unit*) {}
void EnterEvadeMode() {} void EnterEvadeMode() {}
bool IsVisible(Unit *) const { return false; } bool IsVisible(Unit*) const { return false; }
void UpdateAI(const uint32) {} void UpdateAI(const uint32) {}
static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; } static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; }
}; };
#endif #endif

View file

@ -43,7 +43,7 @@
#include "TemporarySummon.h" #include "TemporarySummon.h"
#include "movement/packet_builder.h" #include "movement/packet_builder.h"
Object::Object( ) Object::Object()
{ {
m_objectTypeId = TYPEID_OBJECT; m_objectTypeId = TYPEID_OBJECT;
m_objectType = TYPEMASK_OBJECT; m_objectType = TYPEMASK_OBJECT;
@ -56,22 +56,22 @@ Object::Object( )
m_objectUpdated = false; m_objectUpdated = false;
} }
Object::~Object( ) Object::~Object()
{ {
if(IsInWorld()) if (IsInWorld())
{ {
///- Do NOT call RemoveFromWorld here, if the object is a player it will crash ///- Do NOT call RemoveFromWorld here, if the object is a player it will crash
sLog.outError("Object::~Object (GUID: %u TypeId: %u) deleted but still in world!!", GetGUIDLow(), GetTypeId()); sLog.outError("Object::~Object (GUID: %u TypeId: %u) deleted but still in world!!", GetGUIDLow(), GetTypeId());
MANGOS_ASSERT(false); MANGOS_ASSERT(false);
} }
if(m_objectUpdated) if (m_objectUpdated)
{ {
sLog.outError("Object::~Object (GUID: %u TypeId: %u) deleted but still have updated status!!", GetGUIDLow(), GetTypeId()); sLog.outError("Object::~Object (GUID: %u TypeId: %u) deleted but still have updated status!!", GetGUIDLow(), GetTypeId());
MANGOS_ASSERT(false); MANGOS_ASSERT(false);
} }
if(m_uint32Values) if (m_uint32Values)
{ {
//DEBUG_LOG("Object desctr 1 check (%p)",(void*)this); //DEBUG_LOG("Object desctr 1 check (%p)",(void*)this);
delete [] m_uint32Values; delete [] m_uint32Values;
@ -93,7 +93,7 @@ void Object::_InitValues()
void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh) void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
{ {
if(!m_uint32Values) if (!m_uint32Values)
_InitValues(); _InitValues();
ObjectGuid guid = ObjectGuid(guidhigh, entry, guidlow); ObjectGuid guid = ObjectGuid(guidhigh, entry, guidlow);
@ -118,7 +118,7 @@ void Object::SendForcedObjectUpdate()
RemoveFromClientUpdateList(); RemoveFromClientUpdateList();
WorldPacket packet; // here we allocate a std::vector with a size of 0x10000 WorldPacket packet; // here we allocate a std::vector with a size of 0x10000
for(UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter) for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
{ {
iter->second.BuildPacket(&packet); iter->second.BuildPacket(&packet);
iter->first->GetSession()->SendPacket(&packet); iter->first->GetSession()->SendPacket(&packet);
@ -126,7 +126,7 @@ void Object::SendForcedObjectUpdate()
} }
} }
void Object::BuildMovementUpdateBlock(UpdateData * data, uint16 flags ) const void Object::BuildMovementUpdateBlock(UpdateData* data, uint16 flags) const
{ {
ByteBuffer buf(500); ByteBuffer buf(500);
@ -138,19 +138,19 @@ void Object::BuildMovementUpdateBlock(UpdateData * data, uint16 flags ) const
data->AddUpdateBlock(buf); data->AddUpdateBlock(buf);
} }
void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const
{ {
if(!target) if (!target)
return; return;
uint8 updatetype = UPDATETYPE_CREATE_OBJECT; uint8 updatetype = UPDATETYPE_CREATE_OBJECT;
uint16 updateFlags = m_updateFlag; uint16 updateFlags = m_updateFlag;
/** lower flag1 **/ /** lower flag1 **/
if(target == this) // building packet for yourself if (target == this) // building packet for yourself
updateFlags |= UPDATEFLAG_SELF; updateFlags |= UPDATEFLAG_SELF;
if(updateFlags & UPDATEFLAG_HAS_POSITION) if (updateFlags & UPDATEFLAG_HAS_POSITION)
{ {
// UPDATETYPE_CREATE_OBJECT2 dynamic objects, corpses... // UPDATETYPE_CREATE_OBJECT2 dynamic objects, corpses...
if (isType(TYPEMASK_DYNAMICOBJECT) || isType(TYPEMASK_CORPSE) || isType(TYPEMASK_PLAYER)) if (isType(TYPEMASK_DYNAMICOBJECT) || isType(TYPEMASK_CORPSE) || isType(TYPEMASK_PLAYER))
@ -163,7 +163,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) c
// UPDATETYPE_CREATE_OBJECT2 for some gameobject types... // UPDATETYPE_CREATE_OBJECT2 for some gameobject types...
if (isType(TYPEMASK_GAMEOBJECT)) if (isType(TYPEMASK_GAMEOBJECT))
{ {
switch(((GameObject*)this)->GetGoType()) switch (((GameObject*)this)->GetGoType())
{ {
case GAMEOBJECT_TYPE_TRAP: case GAMEOBJECT_TYPE_TRAP:
case GAMEOBJECT_TYPE_DUEL_ARBITER: case GAMEOBJECT_TYPE_DUEL_ARBITER:
@ -179,9 +179,9 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) c
} }
} }
if(isType(TYPEMASK_UNIT)) if (isType(TYPEMASK_UNIT))
{ {
if(((Unit*)this)->getVictim()) if (((Unit*)this)->getVictim())
updateFlags |= UPDATEFLAG_HAS_ATTACKING_TARGET; updateFlags |= UPDATEFLAG_HAS_ATTACKING_TARGET;
} }
} }
@ -213,7 +213,7 @@ void Object::SendCreateUpdateToPlayer(Player* player)
player->GetSession()->SendPacket(&packet); player->GetSession()->SendPacket(&packet);
} }
void Object::BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target) const void Object::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) const
{ {
ByteBuffer buf(500); ByteBuffer buf(500);
@ -229,12 +229,12 @@ void Object::BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target) c
data->AddUpdateBlock(buf); data->AddUpdateBlock(buf);
} }
void Object::BuildOutOfRangeUpdateBlock(UpdateData * data) const void Object::BuildOutOfRangeUpdateBlock(UpdateData* data) const
{ {
data->AddOutOfRangeGUID(GetObjectGuid()); data->AddOutOfRangeGUID(GetObjectGuid());
} }
void Object::DestroyForPlayer( Player *target, bool anim ) const void Object::DestroyForPlayer(Player* target, bool anim) const
{ {
MANGOS_ASSERT(target); MANGOS_ASSERT(target);
@ -244,7 +244,7 @@ void Object::DestroyForPlayer( Player *target, bool anim ) const
target->GetSession()->SendPacket(&data); target->GetSession()->SendPacket(&data);
} }
void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const void Object::BuildMovementUpdate(ByteBuffer* data, uint16 updateFlags) const
{ {
//uint16 moveFlags2 = (isType(TYPEMASK_UNIT) ? ((Unit*)this)->m_movementInfo.GetMovementFlags2() : MOVEFLAG2_NONE); //uint16 moveFlags2 = (isType(TYPEMASK_UNIT) ? ((Unit*)this)->m_movementInfo.GetMovementFlags2() : MOVEFLAG2_NONE);
@ -253,12 +253,12 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
// 0x20 // 0x20
if (updateFlags & UPDATEFLAG_LIVING) if (updateFlags & UPDATEFLAG_LIVING)
{ {
Unit *unit = ((Unit*)this); Unit* unit = ((Unit*)this);
if (GetTypeId() == TYPEID_PLAYER) if (GetTypeId() == TYPEID_PLAYER)
{ {
Player *player = ((Player*)unit); Player* player = ((Player*)unit);
if(player->GetTransport()) if (player->GetTransport())
player->m_movementInfo.AddMovementFlag(MOVEFLAG_ONTRANSPORT); player->m_movementInfo.AddMovementFlag(MOVEFLAG_ONTRANSPORT);
else else
player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ONTRANSPORT); player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ONTRANSPORT);
@ -286,7 +286,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
} }
else else
{ {
if(updateFlags & UPDATEFLAG_POSITION) if (updateFlags & UPDATEFLAG_POSITION)
{ {
*data << uint8(0); // unk PGUID! *data << uint8(0); // unk PGUID!
*data << float(((WorldObject*)this)->GetPositionX()); *data << float(((WorldObject*)this)->GetPositionX());
@ -297,7 +297,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
*data << float(((WorldObject*)this)->GetPositionZ()); *data << float(((WorldObject*)this)->GetPositionZ());
*data << float(((WorldObject*)this)->GetOrientation()); *data << float(((WorldObject*)this)->GetOrientation());
if(GetTypeId() == TYPEID_CORPSE) if (GetTypeId() == TYPEID_CORPSE)
*data << float(((WorldObject*)this)->GetOrientation()); *data << float(((WorldObject*)this)->GetOrientation());
else else
*data << float(0); *data << float(0);
@ -308,28 +308,28 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
if (updateFlags & UPDATEFLAG_HAS_POSITION) if (updateFlags & UPDATEFLAG_HAS_POSITION)
{ {
// 0x02 // 0x02
if(updateFlags & UPDATEFLAG_TRANSPORT && ((GameObject*)this)->GetGoType() == GAMEOBJECT_TYPE_MO_TRANSPORT) if (updateFlags & UPDATEFLAG_TRANSPORT && ((GameObject*)this)->GetGoType() == GAMEOBJECT_TYPE_MO_TRANSPORT)
{ {
*data << float(0); *data << float(0);
*data << float(0); *data << float(0);
*data << float(0); *data << float(0);
*data << float(((WorldObject *)this)->GetOrientation()); *data << float(((WorldObject*)this)->GetOrientation());
} }
else else
{ {
*data << float(((WorldObject *)this)->GetPositionX()); *data << float(((WorldObject*)this)->GetPositionX());
*data << float(((WorldObject *)this)->GetPositionY()); *data << float(((WorldObject*)this)->GetPositionY());
*data << float(((WorldObject *)this)->GetPositionZ()); *data << float(((WorldObject*)this)->GetPositionZ());
*data << float(((WorldObject *)this)->GetOrientation()); *data << float(((WorldObject*)this)->GetOrientation());
} }
} }
} }
} }
// 0x8 // 0x8
if(updateFlags & UPDATEFLAG_LOWGUID) if (updateFlags & UPDATEFLAG_LOWGUID)
{ {
switch(GetTypeId()) switch (GetTypeId())
{ {
case TYPEID_OBJECT: case TYPEID_OBJECT:
case TYPEID_ITEM: case TYPEID_ITEM:
@ -343,7 +343,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
*data << uint32(0x0000000B); // unk, can be 0xB or 0xC *data << uint32(0x0000000B); // unk, can be 0xB or 0xC
break; break;
case TYPEID_PLAYER: case TYPEID_PLAYER:
if(updateFlags & UPDATEFLAG_SELF) if (updateFlags & UPDATEFLAG_SELF)
*data << uint32(0x0000002F); // unk, can be 0x15 or 0x22 *data << uint32(0x0000002F); // unk, can be 0x15 or 0x22
else else
*data << uint32(0x00000008); // unk, can be 0x7 or 0x8 *data << uint32(0x00000008); // unk, can be 0x7 or 0x8
@ -355,9 +355,9 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
} }
// 0x10 // 0x10
if(updateFlags & UPDATEFLAG_HIGHGUID) if (updateFlags & UPDATEFLAG_HIGHGUID)
{ {
switch(GetTypeId()) switch (GetTypeId())
{ {
case TYPEID_OBJECT: case TYPEID_OBJECT:
case TYPEID_ITEM: case TYPEID_ITEM:
@ -371,7 +371,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
*data << uint32(0x0000000B); // unk, can be 0xB or 0xC *data << uint32(0x0000000B); // unk, can be 0xB or 0xC
break; break;
case TYPEID_PLAYER: case TYPEID_PLAYER:
if(updateFlags & UPDATEFLAG_SELF) if (updateFlags & UPDATEFLAG_SELF)
*data << uint32(0x0000002F); // unk, can be 0x15 or 0x22 *data << uint32(0x0000002F); // unk, can be 0x15 or 0x22
else else
*data << uint32(0x00000008); // unk, can be 0x7 or 0x8 *data << uint32(0x00000008); // unk, can be 0x7 or 0x8
@ -383,7 +383,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
} }
// 0x4 // 0x4
if(updateFlags & UPDATEFLAG_HAS_ATTACKING_TARGET) // packed guid (current target guid) if (updateFlags & UPDATEFLAG_HAS_ATTACKING_TARGET) // packed guid (current target guid)
{ {
if (((Unit*)this)->getVictim()) if (((Unit*)this)->getVictim())
*data << ((Unit*)this)->getVictim()->GetPackGUID(); *data << ((Unit*)this)->getVictim()->GetPackGUID();
@ -392,7 +392,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
} }
// 0x2 // 0x2
if(updateFlags & UPDATEFLAG_TRANSPORT) if (updateFlags & UPDATEFLAG_TRANSPORT)
{ {
*data << uint32(WorldTimer::getMSTime()); // ms time *data << uint32(WorldTimer::getMSTime()); // ms time
} }
@ -405,13 +405,13 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const
} }
// 0x200 // 0x200
if(updateFlags & UPDATEFLAG_ROTATION) if (updateFlags & UPDATEFLAG_ROTATION)
{ {
*data << int64(((GameObject*)this)->GetPackedWorldRotation()); *data << int64(((GameObject*)this)->GetPackedWorldRotation());
} }
} }
void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *updateMask, Player *target) const void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* updateMask, Player* target) const
{ {
if (!target) if (!target)
return; return;
@ -465,7 +465,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
// 2 specialized loops for speed optimization in non-unit case // 2 specialized loops for speed optimization in non-unit case
if (isType(TYPEMASK_UNIT)) // unit (creature/player) case if (isType(TYPEMASK_UNIT)) // unit (creature/player) case
{ {
for(uint16 index = 0; index < m_valuesCount; ++index) for (uint16 index = 0; index < m_valuesCount; ++index)
{ {
if (updateMask->GetBit(index)) if (updateMask->GetBit(index))
{ {
@ -515,9 +515,9 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
// there are some float values which may be negative or can't get negative due to other checks // there are some float values which may be negative or can't get negative due to other checks
else if ((index >= UNIT_FIELD_NEGSTAT0 && index <= UNIT_FIELD_NEGSTAT4) || else if ((index >= UNIT_FIELD_NEGSTAT0 && index <= UNIT_FIELD_NEGSTAT4) ||
(index >= UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + 6)) || (index >= UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + 6)) ||
(index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) || (index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) ||
(index >= UNIT_FIELD_POSSTAT0 && index <= UNIT_FIELD_POSSTAT4)) (index >= UNIT_FIELD_POSSTAT0 && index <= UNIT_FIELD_POSSTAT4))
{ {
*data << uint32(m_floatValues[index]); *data << uint32(m_floatValues[index]);
} }
@ -551,7 +551,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
} }
else if (isType(TYPEMASK_GAMEOBJECT)) // gameobject case else if (isType(TYPEMASK_GAMEOBJECT)) // gameobject case
{ {
for(uint16 index = 0; index < m_valuesCount; ++index) for (uint16 index = 0; index < m_valuesCount; ++index)
{ {
if (updateMask->GetBit(index)) if (updateMask->GetBit(index))
{ {
@ -563,7 +563,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
if (IsActivateToQuest) if (IsActivateToQuest)
{ {
switch(((GameObject*)this)->GetGoType()) switch (((GameObject*)this)->GetGoType())
{ {
case GAMEOBJECT_TYPE_QUESTGIVER: case GAMEOBJECT_TYPE_QUESTGIVER:
// GO also seen with GO_DYNFLAG_LO_SPARKLE explicit, relation/reason unclear (192861) // GO also seen with GO_DYNFLAG_LO_SPARKLE explicit, relation/reason unclear (192861)
@ -598,7 +598,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
} }
else // other objects case (no special index checks) else // other objects case (no special index checks)
{ {
for(uint16 index = 0; index < m_valuesCount; ++index) for (uint16 index = 0; index < m_valuesCount; ++index)
{ {
if (updateMask->GetBit(index)) if (updateMask->GetBit(index))
{ {
@ -611,18 +611,18 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask *
void Object::ClearUpdateMask(bool remove) void Object::ClearUpdateMask(bool remove)
{ {
if(m_uint32Values) if (m_uint32Values)
{ {
for( uint16 index = 0; index < m_valuesCount; ++index ) for (uint16 index = 0; index < m_valuesCount; ++index)
{ {
if(m_uint32Values_mirror[index]!= m_uint32Values[index]) if (m_uint32Values_mirror[index]!= m_uint32Values[index])
m_uint32Values_mirror[index] = m_uint32Values[index]; m_uint32Values_mirror[index] = m_uint32Values[index];
} }
} }
if(m_objectUpdated) if (m_objectUpdated)
{ {
if(remove) if (remove)
RemoveFromClientUpdateList(); RemoveFromClientUpdateList();
m_objectUpdated = false; m_objectUpdated = false;
} }
@ -630,11 +630,11 @@ void Object::ClearUpdateMask(bool remove)
bool Object::LoadValues(const char* data) bool Object::LoadValues(const char* data)
{ {
if(!m_uint32Values) _InitValues(); if (!m_uint32Values) _InitValues();
Tokens tokens = StrSplit(data, " "); Tokens tokens = StrSplit(data, " ");
if(tokens.size() != m_valuesCount) if (tokens.size() != m_valuesCount)
return false; return false;
Tokens::iterator iter; Tokens::iterator iter;
@ -647,50 +647,50 @@ bool Object::LoadValues(const char* data)
return true; return true;
} }
void Object::_SetUpdateBits(UpdateMask *updateMask, Player* /*target*/) const void Object::_SetUpdateBits(UpdateMask* updateMask, Player* /*target*/) const
{ {
for( uint16 index = 0; index < m_valuesCount; ++index ) for (uint16 index = 0; index < m_valuesCount; ++index)
{ {
if(m_uint32Values_mirror[index]!= m_uint32Values[index]) if (m_uint32Values_mirror[index]!= m_uint32Values[index])
updateMask->SetBit(index); updateMask->SetBit(index);
} }
} }
void Object::_SetCreateBits(UpdateMask *updateMask, Player* /*target*/) const void Object::_SetCreateBits(UpdateMask* updateMask, Player* /*target*/) const
{ {
for( uint16 index = 0; index < m_valuesCount; ++index ) for (uint16 index = 0; index < m_valuesCount; ++index)
{ {
if(GetUInt32Value(index) != 0) if (GetUInt32Value(index) != 0)
updateMask->SetBit(index); updateMask->SetBit(index);
} }
} }
void Object::SetInt32Value( uint16 index, int32 value ) void Object::SetInt32Value(uint16 index, int32 value)
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
if(m_int32Values[ index ] != value) if (m_int32Values[ index ] != value)
{ {
m_int32Values[ index ] = value; m_int32Values[ index ] = value;
MarkForClientUpdate(); MarkForClientUpdate();
} }
} }
void Object::SetUInt32Value( uint16 index, uint32 value ) void Object::SetUInt32Value(uint16 index, uint32 value)
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
if(m_uint32Values[ index ] != value) if (m_uint32Values[ index ] != value)
{ {
m_uint32Values[ index ] = value; m_uint32Values[ index ] = value;
MarkForClientUpdate(); MarkForClientUpdate();
} }
} }
void Object::SetUInt64Value( uint16 index, const uint64 &value ) void Object::SetUInt64Value(uint16 index, const uint64& value)
{ {
MANGOS_ASSERT( index + 1 < m_valuesCount || PrintIndexError( index, true ) ); MANGOS_ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true));
if(*((uint64*)&(m_uint32Values[ index ])) != value) if (*((uint64*)&(m_uint32Values[ index ])) != value)
{ {
m_uint32Values[ index ] = *((uint32*)&value); m_uint32Values[ index ] = *((uint32*)&value);
m_uint32Values[ index + 1 ] = *(((uint32*)&value) + 1); m_uint32Values[ index + 1 ] = *(((uint32*)&value) + 1);
@ -698,28 +698,28 @@ void Object::SetUInt64Value( uint16 index, const uint64 &value )
} }
} }
void Object::SetFloatValue( uint16 index, float value ) void Object::SetFloatValue(uint16 index, float value)
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
if(m_floatValues[ index ] != value) if (m_floatValues[ index ] != value)
{ {
m_floatValues[ index ] = value; m_floatValues[ index ] = value;
MarkForClientUpdate(); MarkForClientUpdate();
} }
} }
void Object::SetByteValue( uint16 index, uint8 offset, uint8 value ) void Object::SetByteValue(uint16 index, uint8 offset, uint8 value)
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
if(offset > 4) if (offset > 4)
{ {
sLog.outError("Object::SetByteValue: wrong offset %u", offset); sLog.outError("Object::SetByteValue: wrong offset %u", offset);
return; return;
} }
if(uint8(m_uint32Values[ index ] >> (offset * 8)) != value) if (uint8(m_uint32Values[ index ] >> (offset * 8)) != value)
{ {
m_uint32Values[ index ] &= ~uint32(uint32(0xFF) << (offset * 8)); m_uint32Values[ index ] &= ~uint32(uint32(0xFF) << (offset * 8));
m_uint32Values[ index ] |= uint32(uint32(value) << (offset * 8)); m_uint32Values[ index ] |= uint32(uint32(value) << (offset * 8));
@ -727,17 +727,17 @@ void Object::SetByteValue( uint16 index, uint8 offset, uint8 value )
} }
} }
void Object::SetUInt16Value( uint16 index, uint8 offset, uint16 value ) void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value)
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
if(offset > 2) if (offset > 2)
{ {
sLog.outError("Object::SetUInt16Value: wrong offset %u", offset); sLog.outError("Object::SetUInt16Value: wrong offset %u", offset);
return; return;
} }
if(uint16(m_uint32Values[ index ] >> (offset * 16)) != value) if (uint16(m_uint32Values[ index ] >> (offset * 16)) != value)
{ {
m_uint32Values[ index ] &= ~uint32(uint32(0xFFFF) << (offset * 16)); m_uint32Values[ index ] &= ~uint32(uint32(0xFFFF) << (offset * 16));
m_uint32Values[ index ] |= uint32(uint32(value) << (offset * 16)); m_uint32Values[ index ] |= uint32(uint32(value) << (offset * 16));
@ -745,17 +745,17 @@ void Object::SetUInt16Value( uint16 index, uint8 offset, uint16 value )
} }
} }
void Object::SetStatFloatValue( uint16 index, float value) void Object::SetStatFloatValue(uint16 index, float value)
{ {
if(value < 0) if (value < 0)
value = 0.0f; value = 0.0f;
SetFloatValue(index, value); SetFloatValue(index, value);
} }
void Object::SetStatInt32Value( uint16 index, int32 value) void Object::SetStatInt32Value(uint16 index, int32 value)
{ {
if(value < 0) if (value < 0)
value = 0; value = 0;
SetUInt32Value(index, uint32(value)); SetUInt32Value(index, uint32(value));
@ -765,7 +765,7 @@ void Object::ApplyModUInt32Value(uint16 index, int32 val, bool apply)
{ {
int32 cur = GetUInt32Value(index); int32 cur = GetUInt32Value(index);
cur += (apply ? val : -val); cur += (apply ? val : -val);
if(cur < 0) if (cur < 0)
cur = 0; cur = 0;
SetUInt32Value(index, cur); SetUInt32Value(index, cur);
} }
@ -788,65 +788,65 @@ void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply)
{ {
float cur = GetFloatValue(index); float cur = GetFloatValue(index);
cur += (apply ? val : -val); cur += (apply ? val : -val);
if(cur < 0) if (cur < 0)
cur = 0; cur = 0;
SetFloatValue(index, cur); SetFloatValue(index, cur);
} }
void Object::SetFlag( uint16 index, uint32 newFlag ) void Object::SetFlag(uint16 index, uint32 newFlag)
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
uint32 oldval = m_uint32Values[ index ]; uint32 oldval = m_uint32Values[ index ];
uint32 newval = oldval | newFlag; uint32 newval = oldval | newFlag;
if(oldval != newval) if (oldval != newval)
{ {
m_uint32Values[ index ] = newval; m_uint32Values[ index ] = newval;
MarkForClientUpdate(); MarkForClientUpdate();
} }
} }
void Object::RemoveFlag( uint16 index, uint32 oldFlag ) void Object::RemoveFlag(uint16 index, uint32 oldFlag)
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
uint32 oldval = m_uint32Values[ index ]; uint32 oldval = m_uint32Values[ index ];
uint32 newval = oldval & ~oldFlag; uint32 newval = oldval & ~oldFlag;
if(oldval != newval) if (oldval != newval)
{ {
m_uint32Values[ index ] = newval; m_uint32Values[ index ] = newval;
MarkForClientUpdate(); MarkForClientUpdate();
} }
} }
void Object::SetByteFlag( uint16 index, uint8 offset, uint8 newFlag ) void Object::SetByteFlag(uint16 index, uint8 offset, uint8 newFlag)
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
if(offset > 4) if (offset > 4)
{ {
sLog.outError("Object::SetByteFlag: wrong offset %u", offset); sLog.outError("Object::SetByteFlag: wrong offset %u", offset);
return; return;
} }
if(!(uint8(m_uint32Values[ index ] >> (offset * 8)) & newFlag)) if (!(uint8(m_uint32Values[ index ] >> (offset * 8)) & newFlag))
{ {
m_uint32Values[ index ] |= uint32(uint32(newFlag) << (offset * 8)); m_uint32Values[ index ] |= uint32(uint32(newFlag) << (offset * 8));
MarkForClientUpdate(); MarkForClientUpdate();
} }
} }
void Object::RemoveByteFlag( uint16 index, uint8 offset, uint8 oldFlag ) void Object::RemoveByteFlag(uint16 index, uint8 offset, uint8 oldFlag)
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index, true ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index, true));
if(offset > 4) if (offset > 4)
{ {
sLog.outError("Object::RemoveByteFlag: wrong offset %u", offset); sLog.outError("Object::RemoveByteFlag: wrong offset %u", offset);
return; return;
} }
if(uint8(m_uint32Values[ index ] >> (offset * 8)) & oldFlag) if (uint8(m_uint32Values[ index ] >> (offset * 8)) & oldFlag)
{ {
m_uint32Values[ index ] &= ~uint32(uint32(oldFlag) << (offset * 8)); m_uint32Values[ index ] &= ~uint32(uint32(oldFlag) << (offset * 8));
MarkForClientUpdate(); MarkForClientUpdate();
@ -898,7 +898,7 @@ void Object::BuildUpdateDataForPlayer(Player* pl, UpdateDataMapType& update_play
if (iter == update_players.end()) if (iter == update_players.end())
{ {
std::pair<UpdateDataMapType::iterator, bool> p = update_players.insert( UpdateDataMapType::value_type(pl, UpdateData()) ); std::pair<UpdateDataMapType::iterator, bool> p = update_players.insert(UpdateDataMapType::value_type(pl, UpdateData()));
MANGOS_ASSERT(p.second); MANGOS_ASSERT(p.second);
iter = p.first; iter = p.first;
} }
@ -918,7 +918,7 @@ void Object::RemoveFromClientUpdateList()
MANGOS_ASSERT(false); MANGOS_ASSERT(false);
} }
void Object::BuildUpdateData( UpdateDataMapType& /*update_players */) void Object::BuildUpdateData(UpdateDataMapType& /*update_players */)
{ {
sLog.outError("Unexpected call of Object::BuildUpdateData for object (TypeId: %u Update fields: %u)",GetTypeId(), m_valuesCount); sLog.outError("Unexpected call of Object::BuildUpdateData for object (TypeId: %u Update fields: %u)",GetTypeId(), m_valuesCount);
MANGOS_ASSERT(false); MANGOS_ASSERT(false);
@ -926,9 +926,9 @@ void Object::BuildUpdateData( UpdateDataMapType& /*update_players */)
void Object::MarkForClientUpdate() void Object::MarkForClientUpdate()
{ {
if(m_inWorld) if (m_inWorld)
{ {
if(!m_objectUpdated) if (!m_objectUpdated)
{ {
AddToClientUpdateList(); AddToClientUpdateList();
m_objectUpdated = true; m_objectUpdated = true;
@ -946,7 +946,7 @@ void WorldObject::CleanupsBeforeDelete()
RemoveFromWorld(); RemoveFromWorld();
} }
void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 phaseMask ) void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask)
{ {
Object::_Create(guidlow, 0, guidhigh); Object::_Create(guidlow, 0, guidhigh);
m_phaseMask = phaseMask; m_phaseMask = phaseMask;
@ -1001,7 +1001,7 @@ InstanceData* WorldObject::GetInstanceData() const
return GetMap()->GetInstanceData(); return GetMap()->GetInstanceData();
} }
//slow //slow
float WorldObject::GetDistance(const WorldObject* obj) const float WorldObject::GetDistance(const WorldObject* obj) const
{ {
float dx = GetPositionX() - obj->GetPositionX(); float dx = GetPositionX() - obj->GetPositionX();
@ -1009,7 +1009,7 @@ float WorldObject::GetDistance(const WorldObject* obj) const
float dz = GetPositionZ() - obj->GetPositionZ(); float dz = GetPositionZ() - obj->GetPositionZ();
float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius();
float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - sizefactor; float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - sizefactor;
return ( dist > 0 ? dist : 0); return (dist > 0 ? dist : 0);
} }
float WorldObject::GetDistance2d(float x, float y) const float WorldObject::GetDistance2d(float x, float y) const
@ -1018,7 +1018,7 @@ float WorldObject::GetDistance2d(float x, float y) const
float dy = GetPositionY() - y; float dy = GetPositionY() - y;
float sizefactor = GetObjectBoundingRadius(); float sizefactor = GetObjectBoundingRadius();
float dist = sqrt((dx*dx) + (dy*dy)) - sizefactor; float dist = sqrt((dx*dx) + (dy*dy)) - sizefactor;
return ( dist > 0 ? dist : 0); return (dist > 0 ? dist : 0);
} }
float WorldObject::GetDistance(float x, float y, float z) const float WorldObject::GetDistance(float x, float y, float z) const
@ -1028,7 +1028,7 @@ float WorldObject::GetDistance(float x, float y, float z) const
float dz = GetPositionZ() - z; float dz = GetPositionZ() - z;
float sizefactor = GetObjectBoundingRadius(); float sizefactor = GetObjectBoundingRadius();
float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - sizefactor; float dist = sqrt((dx*dx) + (dy*dy) + (dz*dz)) - sizefactor;
return ( dist > 0 ? dist : 0); return (dist > 0 ? dist : 0);
} }
float WorldObject::GetDistance2d(const WorldObject* obj) const float WorldObject::GetDistance2d(const WorldObject* obj) const
@ -1037,7 +1037,7 @@ float WorldObject::GetDistance2d(const WorldObject* obj) const
float dy = GetPositionY() - obj->GetPositionY(); float dy = GetPositionY() - obj->GetPositionY();
float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius();
float dist = sqrt((dx*dx) + (dy*dy)) - sizefactor; float dist = sqrt((dx*dx) + (dy*dy)) - sizefactor;
return ( dist > 0 ? dist : 0); return (dist > 0 ? dist : 0);
} }
float WorldObject::GetDistanceZ(const WorldObject* obj) const float WorldObject::GetDistanceZ(const WorldObject* obj) const
@ -1045,7 +1045,7 @@ float WorldObject::GetDistanceZ(const WorldObject* obj) const
float dz = fabs(GetPositionZ() - obj->GetPositionZ()); float dz = fabs(GetPositionZ() - obj->GetPositionZ());
float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius();
float dist = dz - sizefactor; float dist = dz - sizefactor;
return ( dist > 0 ? dist : 0); return (dist > 0 ? dist : 0);
} }
bool WorldObject::IsWithinDist3d(float x, float y, float z, float dist2compare) const bool WorldObject::IsWithinDist3d(float x, float y, float z, float dist2compare) const
@ -1078,7 +1078,7 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool
float dx = GetPositionX() - obj->GetPositionX(); float dx = GetPositionX() - obj->GetPositionX();
float dy = GetPositionY() - obj->GetPositionY(); float dy = GetPositionY() - obj->GetPositionY();
float distsq = dx*dx + dy*dy; float distsq = dx*dx + dy*dy;
if(is3D) if (is3D)
{ {
float dz = GetPositionZ() - obj->GetPositionZ(); float dz = GetPositionZ() - obj->GetPositionZ();
distsq += dz*dz; distsq += dz*dz;
@ -1094,7 +1094,7 @@ bool WorldObject::IsWithinLOSInMap(const WorldObject* obj) const
if (!IsInMap(obj)) return false; if (!IsInMap(obj)) return false;
float ox,oy,oz; float ox,oy,oz;
obj->GetPosition(ox,oy,oz); obj->GetPosition(ox,oy,oz);
return(IsWithinLOS(ox, oy, oz )); return(IsWithinLOS(ox, oy, oz));
} }
bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const
@ -1109,7 +1109,7 @@ bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* o
float dx1 = GetPositionX() - obj1->GetPositionX(); float dx1 = GetPositionX() - obj1->GetPositionX();
float dy1 = GetPositionY() - obj1->GetPositionY(); float dy1 = GetPositionY() - obj1->GetPositionY();
float distsq1 = dx1*dx1 + dy1*dy1; float distsq1 = dx1*dx1 + dy1*dy1;
if(is3D) if (is3D)
{ {
float dz1 = GetPositionZ() - obj1->GetPositionZ(); float dz1 = GetPositionZ() - obj1->GetPositionZ();
distsq1 += dz1*dz1; distsq1 += dz1*dz1;
@ -1118,7 +1118,7 @@ bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* o
float dx2 = GetPositionX() - obj2->GetPositionX(); float dx2 = GetPositionX() - obj2->GetPositionX();
float dy2 = GetPositionY() - obj2->GetPositionY(); float dy2 = GetPositionY() - obj2->GetPositionY();
float distsq2 = dx2*dx2 + dy2*dy2; float distsq2 = dx2*dx2 + dy2*dy2;
if(is3D) if (is3D)
{ {
float dz2 = GetPositionZ() - obj2->GetPositionZ(); float dz2 = GetPositionZ() - obj2->GetPositionZ();
distsq2 += dz2*dz2; distsq2 += dz2*dz2;
@ -1132,7 +1132,7 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan
float dx = GetPositionX() - obj->GetPositionX(); float dx = GetPositionX() - obj->GetPositionX();
float dy = GetPositionY() - obj->GetPositionY(); float dy = GetPositionY() - obj->GetPositionY();
float distsq = dx*dx + dy*dy; float distsq = dx*dx + dy*dy;
if(is3D) if (is3D)
{ {
float dz = GetPositionZ() - obj->GetPositionZ(); float dz = GetPositionZ() - obj->GetPositionZ();
distsq += dz*dz; distsq += dz*dz;
@ -1141,10 +1141,10 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan
float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius();
// check only for real range // check only for real range
if(minRange > 0.0f) if (minRange > 0.0f)
{ {
float mindist = minRange + sizefactor; float mindist = minRange + sizefactor;
if(distsq < mindist * mindist) if (distsq < mindist * mindist)
return false; return false;
} }
@ -1161,10 +1161,10 @@ bool WorldObject::IsInRange2d(float x, float y, float minRange, float maxRange)
float sizefactor = GetObjectBoundingRadius(); float sizefactor = GetObjectBoundingRadius();
// check only for real range // check only for real range
if(minRange > 0.0f) if (minRange > 0.0f)
{ {
float mindist = minRange + sizefactor; float mindist = minRange + sizefactor;
if(distsq < mindist * mindist) if (distsq < mindist * mindist)
return false; return false;
} }
@ -1182,10 +1182,10 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
float sizefactor = GetObjectBoundingRadius(); float sizefactor = GetObjectBoundingRadius();
// check only for real range // check only for real range
if(minRange > 0.0f) if (minRange > 0.0f)
{ {
float mindist = minRange + sizefactor; float mindist = minRange + sizefactor;
if(distsq < mindist * mindist) if (distsq < mindist * mindist)
return false; return false;
} }
@ -1240,32 +1240,32 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const
float lborder = -1 * (arc/2.0f); // in range -pi..0 float lborder = -1 * (arc/2.0f); // in range -pi..0
float rborder = (arc/2.0f); // in range 0..pi float rborder = (arc/2.0f); // in range 0..pi
return (( angle >= lborder ) && ( angle <= rborder )); return ((angle >= lborder) && (angle <= rborder));
} }
bool WorldObject::isInFrontInMap(WorldObject const* target, float distance, float arc) const bool WorldObject::isInFrontInMap(WorldObject const* target, float distance, float arc) const
{ {
return IsWithinDistInMap(target, distance) && HasInArc( arc, target ); return IsWithinDistInMap(target, distance) && HasInArc(arc, target);
} }
bool WorldObject::isInBackInMap(WorldObject const* target, float distance, float arc) const bool WorldObject::isInBackInMap(WorldObject const* target, float distance, float arc) const
{ {
return IsWithinDistInMap(target, distance) && !HasInArc( 2 * M_PI_F - arc, target ); return IsWithinDistInMap(target, distance) && !HasInArc(2 * M_PI_F - arc, target);
} }
bool WorldObject::isInFront(WorldObject const* target, float distance, float arc) const bool WorldObject::isInFront(WorldObject const* target, float distance, float arc) const
{ {
return IsWithinDist(target, distance) && HasInArc( arc, target ); return IsWithinDist(target, distance) && HasInArc(arc, target);
} }
bool WorldObject::isInBack(WorldObject const* target, float distance, float arc) const bool WorldObject::isInBack(WorldObject const* target, float distance, float arc) const
{ {
return IsWithinDist(target, distance) && !HasInArc( 2 * M_PI_F - arc, target ); return IsWithinDist(target, distance) && !HasInArc(2 * M_PI_F - arc, target);
} }
void WorldObject::GetRandomPoint( float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z) const void WorldObject::GetRandomPoint(float x, float y, float z, float distance, float& rand_x, float& rand_y, float& rand_z) const
{ {
if(distance == 0) if (distance == 0)
{ {
rand_x = x; rand_x = x;
rand_y = y; rand_y = y;
@ -1286,14 +1286,14 @@ void WorldObject::GetRandomPoint( float x, float y, float z, float distance, flo
UpdateGroundPositionZ(rand_x,rand_y,rand_z); // update to LOS height if available UpdateGroundPositionZ(rand_x,rand_y,rand_z); // update to LOS height if available
} }
void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const void WorldObject::UpdateGroundPositionZ(float x, float y, float& z) const
{ {
float new_z = GetTerrain()->GetHeight(x,y,z,true); float new_z = GetTerrain()->GetHeight(x,y,z,true);
if(new_z > INVALID_HEIGHT) if (new_z > INVALID_HEIGHT)
z = new_z+ 0.05f; // just to be sure that we are not a few pixel under the surface z = new_z+ 0.05f; // just to be sure that we are not a few pixel under the surface
} }
void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const
{ {
switch (GetTypeId()) switch (GetTypeId())
{ {
@ -1306,8 +1306,8 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
bool canSwim = ((Creature const*)this)->CanSwim(); bool canSwim = ((Creature const*)this)->CanSwim();
float ground_z = z; float ground_z = z;
float max_z = canSwim float max_z = canSwim
? GetTerrain()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK)) ? GetTerrain()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK))
: ((ground_z = GetTerrain()->GetHeight(x, y, z, true))); : ((ground_z = GetTerrain()->GetHeight(x, y, z, true)));
if (max_z > INVALID_HEIGHT) if (max_z > INVALID_HEIGHT)
{ {
if (z > max_z) if (z > max_z)
@ -1350,7 +1350,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
default: default:
{ {
float ground_z = GetTerrain()->GetHeight(x, y, z, true); float ground_z = GetTerrain()->GetHeight(x, y, z, true);
if(ground_z > INVALID_HEIGHT) if (ground_z > INVALID_HEIGHT)
z = ground_z; z = ground_z;
break; break;
} }
@ -1380,7 +1380,7 @@ void WorldObject::MonsterTextEmote(const char* text, Unit* target, bool IsBossEm
{ {
WorldPacket data(SMSG_MESSAGECHAT, 200); WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildMonsterChat(&data, GetObjectGuid(), IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, text, LANG_UNIVERSAL, BuildMonsterChat(&data, GetObjectGuid(), IsBossEmote ? CHAT_MSG_RAID_BOSS_EMOTE : CHAT_MSG_MONSTER_EMOTE, text, LANG_UNIVERSAL,
GetName(), target ? target->GetObjectGuid() : ObjectGuid(), target ? target->GetName() : ""); GetName(), target ? target->GetObjectGuid() : ObjectGuid(), target ? target->GetName() : "");
SendMessageToSetInRange(&data, sWorld.getConfig(IsBossEmote ? CONFIG_FLOAT_LISTEN_RANGE_YELL : CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE), true); SendMessageToSetInRange(&data, sWorld.getConfig(IsBossEmote ? CONFIG_FLOAT_LISTEN_RANGE_YELL : CONFIG_FLOAT_LISTEN_RANGE_TEXTEMOTE), true);
} }
@ -1391,7 +1391,7 @@ void WorldObject::MonsterWhisper(const char* text, Unit* target, bool IsBossWhis
WorldPacket data(SMSG_MESSAGECHAT, 200); WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildMonsterChat(&data, GetObjectGuid(), IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, BuildMonsterChat(&data, GetObjectGuid(), IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL,
GetName(), target->GetObjectGuid(), target->GetName()); GetName(), target->GetObjectGuid(), target->GetName());
((Player*)target)->GetSession()->SendPacket(&data); ((Player*)target)->GetSession()->SendPacket(&data);
} }
@ -1444,8 +1444,8 @@ void WorldObject::MonsterYellToZone(int32 textId, uint32 language, Unit* target)
uint32 zoneid = GetZoneId(); uint32 zoneid = GetZoneId();
Map::PlayerList const& pList = GetMap()->GetPlayers(); Map::PlayerList const& pList = GetMap()->GetPlayers();
for(Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
if(itr->getSource()->GetZoneId()==zoneid) if (itr->getSource()->GetZoneId()==zoneid)
say_do(itr->getSource()); say_do(itr->getSource());
} }
@ -1469,12 +1469,12 @@ void WorldObject::MonsterWhisper(int32 textId, Unit* target, bool IsBossWhisper)
WorldPacket data(SMSG_MESSAGECHAT, 200); WorldPacket data(SMSG_MESSAGECHAT, 200);
BuildMonsterChat(&data, GetObjectGuid(), IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, BuildMonsterChat(&data, GetObjectGuid(), IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL,
GetNameForLocaleIdx(loc_idx), target->GetObjectGuid(), ""); GetNameForLocaleIdx(loc_idx), target->GetObjectGuid(), "");
((Player*)target)->GetSession()->SendPacket(&data); ((Player*)target)->GetSession()->SendPacket(&data);
} }
void WorldObject::BuildMonsterChat(WorldPacket *data, ObjectGuid senderGuid, uint8 msgtype, char const* text, uint32 language, char const* name, ObjectGuid targetGuid, char const* targetName) void WorldObject::BuildMonsterChat(WorldPacket* data, ObjectGuid senderGuid, uint8 msgtype, char const* text, uint32 language, char const* name, ObjectGuid targetGuid, char const* targetName)
{ {
*data << uint8(msgtype); *data << uint8(msgtype);
*data << uint32(language); *data << uint32(language);
@ -1493,21 +1493,21 @@ void WorldObject::BuildMonsterChat(WorldPacket *data, ObjectGuid senderGuid, uin
*data << uint8(0); // ChatTag *data << uint8(0); // ChatTag
} }
void WorldObject::SendMessageToSet(WorldPacket *data, bool /*bToSelf*/) void WorldObject::SendMessageToSet(WorldPacket* data, bool /*bToSelf*/)
{ {
//if object is in world, map for it already created! //if object is in world, map for it already created!
if (IsInWorld()) if (IsInWorld())
GetMap()->MessageBroadcast(this, data); GetMap()->MessageBroadcast(this, data);
} }
void WorldObject::SendMessageToSetInRange(WorldPacket *data, float dist, bool /*bToSelf*/) void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*bToSelf*/)
{ {
//if object is in world, map for it already created! //if object is in world, map for it already created!
if (IsInWorld()) if (IsInWorld())
GetMap()->MessageDistBroadcast(this, data, dist); GetMap()->MessageDistBroadcast(this, data, dist);
} }
void WorldObject::SendMessageToSetExcept(WorldPacket *data, Player const* skipped_receiver) void WorldObject::SendMessageToSetExcept(WorldPacket* data, Player const* skipped_receiver)
{ {
//if object is in world, map for it already created! //if object is in world, map for it already created!
if (IsInWorld()) if (IsInWorld())
@ -1532,7 +1532,7 @@ void WorldObject::SendGameObjectCustomAnim(ObjectGuid guid, uint32 animId /*= 0*
SendMessageToSet(&data, true); SendMessageToSet(&data, true);
} }
void WorldObject::SetMap(Map * map) void WorldObject::SetMap(Map* map)
{ {
MANGOS_ASSERT(map); MANGOS_ASSERT(map);
m_currMap = map; m_currMap = map;
@ -1554,8 +1554,8 @@ void WorldObject::AddObjectToRemoveList()
Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime, bool asActiveObject) Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime, bool asActiveObject)
{ {
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(id); CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(id);
if(!cinfo) if (!cinfo)
{ {
sLog.outErrorDb("WorldObject::SummonCreature: Creature (Entry: %u) not existed for summoner: %s. ", id, GetGuidStr().c_str()); sLog.outErrorDb("WorldObject::SummonCreature: Creature (Entry: %u) not existed for summoner: %s. ", id, GetGuidStr().c_str());
return NULL; return NULL;
@ -1585,7 +1585,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
pCreature->Summon(spwtype, despwtime); pCreature->Summon(spwtype, despwtime);
if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->AI()) if (GetTypeId()==TYPEID_UNIT && ((Creature*)this)->AI())
((Creature*)this)->AI()->JustSummoned(pCreature); ((Creature*)this)->AI()->JustSummoned(pCreature);
// return the creature therewith the summoner has access to it // return the creature therewith the summoner has access to it
@ -1647,7 +1647,7 @@ namespace MaNGOS
// u is too nearest/far away to i_object // u is too nearest/far away to i_object
if (dist2d < i_selector.m_searcherDist - delta || if (dist2d < i_selector.m_searcherDist - delta ||
dist2d >= i_selector.m_searcherDist + delta) dist2d >= i_selector.m_searcherDist + delta)
return; return;
float angle = i_object.GetAngle(u) - i_absAngle; float angle = i_object.GetAngle(u) - i_absAngle;
@ -1670,7 +1670,7 @@ namespace MaNGOS
//=================================================================================================== //===================================================================================================
void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float absAngle ) const void WorldObject::GetNearPoint2D(float& x, float& y, float distance2d, float absAngle) const
{ {
x = GetPositionX() + (GetObjectBoundingRadius() + distance2d) * cos(absAngle); x = GetPositionX() + (GetObjectBoundingRadius() + distance2d) * cos(absAngle);
y = GetPositionY() + (GetObjectBoundingRadius() + distance2d) * sin(absAngle); y = GetPositionY() + (GetObjectBoundingRadius() + distance2d) * sin(absAngle);
@ -1679,13 +1679,13 @@ void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float abs
MaNGOS::NormalizeMapCoord(y); MaNGOS::NormalizeMapCoord(y);
} }
void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_bounding_radius, float distance2d, float absAngle) const void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y, float& z, float searcher_bounding_radius, float distance2d, float absAngle) const
{ {
GetNearPoint2D(x, y, distance2d + searcher_bounding_radius, absAngle); GetNearPoint2D(x, y, distance2d + searcher_bounding_radius, absAngle);
const float init_z = z = GetPositionZ(); const float init_z = z = GetPositionZ();
// if detection disabled, return first point // if detection disabled, return first point
if(!sWorld.getConfig(CONFIG_BOOL_DETECT_POS_COLLISION)) if (!sWorld.getConfig(CONFIG_BOOL_DETECT_POS_COLLISION))
{ {
if (searcher) if (searcher)
searcher->UpdateAllowedPositionZ(x, y, z); // update to LOS height if available searcher->UpdateAllowedPositionZ(x, y, z); // update to LOS height if available
@ -1792,29 +1792,29 @@ void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
{ {
m_phaseMask = newPhaseMask; m_phaseMask = newPhaseMask;
if(update && IsInWorld()) if (update && IsInWorld())
UpdateVisibilityAndView(); UpdateVisibilityAndView();
} }
void WorldObject::PlayDistanceSound( uint32 sound_id, Player* target /*= NULL*/ ) void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= NULL*/)
{ {
WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8); WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8);
data << uint32(sound_id); data << uint32(sound_id);
data << GetObjectGuid(); data << GetObjectGuid();
if (target) if (target)
target->SendDirectMessage( &data ); target->SendDirectMessage(&data);
else else
SendMessageToSet( &data, true ); SendMessageToSet(&data, true);
} }
void WorldObject::PlayDirectSound( uint32 sound_id, Player* target /*= NULL*/ ) void WorldObject::PlayDirectSound(uint32 sound_id, Player* target /*= NULL*/)
{ {
WorldPacket data(SMSG_PLAY_SOUND, 4); WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(sound_id); data << uint32(sound_id);
if (target) if (target)
target->SendDirectMessage( &data ); target->SendDirectMessage(&data);
else else
SendMessageToSet( &data, true ); SendMessageToSet(&data, true);
} }
void WorldObject::UpdateVisibilityAndView() void WorldObject::UpdateVisibilityAndView()
@ -1844,30 +1844,30 @@ void WorldObject::RemoveFromClientUpdateList()
struct WorldObjectChangeAccumulator struct WorldObjectChangeAccumulator
{ {
UpdateDataMapType &i_updateDatas; UpdateDataMapType& i_updateDatas;
WorldObject &i_object; WorldObject& i_object;
WorldObjectChangeAccumulator(WorldObject &obj, UpdateDataMapType &d) : i_updateDatas(d), i_object(obj) WorldObjectChangeAccumulator(WorldObject& obj, UpdateDataMapType& d) : i_updateDatas(d), i_object(obj)
{ {
// send self fields changes in another way, otherwise // send self fields changes in another way, otherwise
// with new camera system when player's camera too far from player, camera wouldn't receive packets and changes from player // with new camera system when player's camera too far from player, camera wouldn't receive packets and changes from player
if(i_object.isType(TYPEMASK_PLAYER)) if (i_object.isType(TYPEMASK_PLAYER))
i_object.BuildUpdateDataForPlayer((Player*)&i_object, i_updateDatas); i_object.BuildUpdateDataForPlayer((Player*)&i_object, i_updateDatas);
} }
void Visit(CameraMapType &m) void Visit(CameraMapType& m)
{ {
for(CameraMapType::iterator iter = m.begin(); iter != m.end(); ++iter) for (CameraMapType::iterator iter = m.begin(); iter != m.end(); ++iter)
{ {
Player* owner = iter->getSource()->GetOwner(); Player* owner = iter->getSource()->GetOwner();
if(owner != &i_object && owner->HaveAtClient(&i_object)) if (owner != &i_object && owner->HaveAtClient(&i_object))
i_object.BuildUpdateDataForPlayer(owner, i_updateDatas); i_object.BuildUpdateDataForPlayer(owner, i_updateDatas);
} }
} }
template<class SKIP> void Visit(GridRefManager<SKIP> &) {} template<class SKIP> void Visit(GridRefManager<SKIP>&) {}
}; };
void WorldObject::BuildUpdateData( UpdateDataMapType & update_players) void WorldObject::BuildUpdateData(UpdateDataMapType& update_players)
{ {
WorldObjectChangeAccumulator notifier(*this, update_players); WorldObjectChangeAccumulator notifier(*this, update_players);
Cell::VisitWorldObjects(this, notifier, GetMap()->GetVisibilityDistance()); Cell::VisitWorldObjects(this, notifier, GetMap()->GetVisibilityDistance());

View file

@ -89,7 +89,7 @@ struct WorldLocation
float orientation; float orientation;
explicit WorldLocation(uint32 _mapid = 0, float _x = 0, float _y = 0, float _z = 0, float _o = 0) explicit WorldLocation(uint32 _mapid = 0, float _x = 0, float _y = 0, float _z = 0, float _o = 0)
: mapid(_mapid), coord_x(_x), coord_y(_y), coord_z(_z), orientation(_o) {} : mapid(_mapid), coord_x(_x), coord_y(_y), coord_z(_z), orientation(_o) {}
WorldLocation(WorldLocation const &loc) WorldLocation(WorldLocation const& loc)
: mapid(loc.mapid), coord_x(loc.coord_x), coord_y(loc.coord_y), coord_z(loc.coord_z), orientation(loc.orientation) {} : mapid(loc.mapid), coord_x(loc.coord_x), coord_y(loc.coord_y), coord_z(loc.coord_z), orientation(loc.orientation) {}
}; };
@ -103,7 +103,7 @@ class WorldUpdateCounter
time_t timeElapsed() time_t timeElapsed()
{ {
if(!m_tmStart) if (!m_tmStart)
m_tmStart = WorldTimer::tickPrevTime(); m_tmStart = WorldTimer::tickPrevTime();
return WorldTimer::getMSTimeDiff(m_tmStart, WorldTimer::tickTime()); return WorldTimer::getMSTimeDiff(m_tmStart, WorldTimer::tickTime());
@ -118,12 +118,12 @@ class WorldUpdateCounter
class MANGOS_DLL_SPEC Object class MANGOS_DLL_SPEC Object
{ {
public: public:
virtual ~Object ( ); virtual ~Object();
const bool& IsInWorld() const { return m_inWorld; } const bool& IsInWorld() const { return m_inWorld; }
virtual void AddToWorld() virtual void AddToWorld()
{ {
if(m_inWorld) if (m_inWorld)
return; return;
m_inWorld = true; m_inWorld = true;
@ -156,7 +156,7 @@ class MANGOS_DLL_SPEC Object
uint8 GetTypeId() const { return m_objectTypeId; } uint8 GetTypeId() const { return m_objectTypeId; }
bool isType(TypeMask mask) const { return (mask & m_objectType); } bool isType(TypeMask mask) const { return (mask & m_objectType); }
virtual void BuildCreateUpdateBlockForPlayer( UpdateData *data, Player *target ) const; virtual void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const;
void SendCreateUpdateToPlayer(Player* player); void SendCreateUpdateToPlayer(Player* player);
// must be overwrite in appropriate subclasses (WorldObject, Item currently), or will crash // must be overwrite in appropriate subclasses (WorldObject, Item currently), or will crash
@ -166,93 +166,93 @@ class MANGOS_DLL_SPEC Object
void MarkForClientUpdate(); void MarkForClientUpdate();
void SendForcedObjectUpdate(); void SendForcedObjectUpdate();
void BuildValuesUpdateBlockForPlayer( UpdateData *data, Player *target ) const; void BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) const;
void BuildOutOfRangeUpdateBlock( UpdateData *data ) const; void BuildOutOfRangeUpdateBlock(UpdateData* data) const;
void BuildMovementUpdateBlock( UpdateData * data, uint16 flags = 0 ) const; void BuildMovementUpdateBlock(UpdateData* data, uint16 flags = 0) const;
virtual void DestroyForPlayer( Player *target, bool anim = false ) const; virtual void DestroyForPlayer(Player* target, bool anim = false) const;
const int32& GetInt32Value( uint16 index ) const const int32& GetInt32Value(uint16 index) const
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index , false) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false));
return m_int32Values[ index ]; return m_int32Values[ index ];
} }
const uint32& GetUInt32Value( uint16 index ) const const uint32& GetUInt32Value(uint16 index) const
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index , false) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false));
return m_uint32Values[ index ]; return m_uint32Values[ index ];
} }
const uint64& GetUInt64Value( uint16 index ) const const uint64& GetUInt64Value(uint16 index) const
{ {
MANGOS_ASSERT( index + 1 < m_valuesCount || PrintIndexError( index , false) ); MANGOS_ASSERT(index + 1 < m_valuesCount || PrintIndexError(index , false));
return *((uint64*)&(m_uint32Values[ index ])); return *((uint64*)&(m_uint32Values[ index ]));
} }
const float& GetFloatValue( uint16 index ) const const float& GetFloatValue(uint16 index) const
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index , false ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false));
return m_floatValues[ index ]; return m_floatValues[ index ];
} }
uint8 GetByteValue( uint16 index, uint8 offset) const uint8 GetByteValue(uint16 index, uint8 offset) const
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index , false) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false));
MANGOS_ASSERT( offset < 4 ); MANGOS_ASSERT(offset < 4);
return *(((uint8*)&m_uint32Values[ index ])+offset); return *(((uint8*)&m_uint32Values[ index ])+offset);
} }
uint16 GetUInt16Value( uint16 index, uint8 offset) const uint16 GetUInt16Value(uint16 index, uint8 offset) const
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index , false) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false));
MANGOS_ASSERT( offset < 2 ); MANGOS_ASSERT(offset < 2);
return *(((uint16*)&m_uint32Values[ index ])+offset); return *(((uint16*)&m_uint32Values[ index ])+offset);
} }
ObjectGuid const& GetGuidValue( uint16 index ) const { return *reinterpret_cast<ObjectGuid const*>(&GetUInt64Value(index)); } ObjectGuid const& GetGuidValue(uint16 index) const { return *reinterpret_cast<ObjectGuid const*>(&GetUInt64Value(index)); }
void SetInt32Value( uint16 index, int32 value ); void SetInt32Value(uint16 index, int32 value);
void SetUInt32Value( uint16 index, uint32 value ); void SetUInt32Value(uint16 index, uint32 value);
void SetUInt64Value( uint16 index, const uint64 &value ); void SetUInt64Value(uint16 index, const uint64& value);
void SetFloatValue( uint16 index, float value ); void SetFloatValue(uint16 index, float value);
void SetByteValue( uint16 index, uint8 offset, uint8 value ); void SetByteValue(uint16 index, uint8 offset, uint8 value);
void SetUInt16Value( uint16 index, uint8 offset, uint16 value ); void SetUInt16Value(uint16 index, uint8 offset, uint16 value);
void SetInt16Value( uint16 index, uint8 offset, int16 value ) { SetUInt16Value(index,offset,(uint16)value); } void SetInt16Value(uint16 index, uint8 offset, int16 value) { SetUInt16Value(index,offset,(uint16)value); }
void SetGuidValue( uint16 index, ObjectGuid const& value ) { SetUInt64Value(index, value.GetRawValue()); } void SetGuidValue(uint16 index, ObjectGuid const& value) { SetUInt64Value(index, value.GetRawValue()); }
void SetStatFloatValue( uint16 index, float value); void SetStatFloatValue(uint16 index, float value);
void SetStatInt32Value( uint16 index, int32 value); void SetStatInt32Value(uint16 index, int32 value);
void ApplyModUInt32Value(uint16 index, int32 val, bool apply); void ApplyModUInt32Value(uint16 index, int32 val, bool apply);
void ApplyModInt32Value(uint16 index, int32 val, bool apply); void ApplyModInt32Value(uint16 index, int32 val, bool apply);
void ApplyModUInt64Value(uint16 index, int32 val, bool apply); void ApplyModUInt64Value(uint16 index, int32 val, bool apply);
void ApplyModPositiveFloatValue( uint16 index, float val, bool apply); void ApplyModPositiveFloatValue(uint16 index, float val, bool apply);
void ApplyModSignedFloatValue( uint16 index, float val, bool apply); void ApplyModSignedFloatValue(uint16 index, float val, bool apply);
void ApplyPercentModFloatValue(uint16 index, float val, bool apply) void ApplyPercentModFloatValue(uint16 index, float val, bool apply)
{ {
val = val != -100.0f ? val : -99.9f ; val = val != -100.0f ? val : -99.9f ;
SetFloatValue(index, GetFloatValue(index) * (apply?(100.0f+val)/100.0f : 100.0f / (100.0f+val)) ); SetFloatValue(index, GetFloatValue(index) * (apply?(100.0f+val)/100.0f : 100.0f / (100.0f+val)));
} }
void SetFlag( uint16 index, uint32 newFlag ); void SetFlag(uint16 index, uint32 newFlag);
void RemoveFlag( uint16 index, uint32 oldFlag ); void RemoveFlag(uint16 index, uint32 oldFlag);
void ToggleFlag( uint16 index, uint32 flag) void ToggleFlag(uint16 index, uint32 flag)
{ {
if(HasFlag(index, flag)) if (HasFlag(index, flag))
RemoveFlag(index, flag); RemoveFlag(index, flag);
else else
SetFlag(index, flag); SetFlag(index, flag);
} }
bool HasFlag( uint16 index, uint32 flag ) const bool HasFlag(uint16 index, uint32 flag) const
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index , false ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false));
return (m_uint32Values[ index ] & flag) != 0; return (m_uint32Values[ index ] & flag) != 0;
} }
void ApplyModFlag( uint16 index, uint32 flag, bool apply) void ApplyModFlag(uint16 index, uint32 flag, bool apply)
{ {
if (apply) if (apply)
SetFlag(index, flag); SetFlag(index, flag);
@ -260,10 +260,10 @@ class MANGOS_DLL_SPEC Object
RemoveFlag(index, flag); RemoveFlag(index, flag);
} }
void SetByteFlag( uint16 index, uint8 offset, uint8 newFlag ); void SetByteFlag(uint16 index, uint8 offset, uint8 newFlag);
void RemoveByteFlag( uint16 index, uint8 offset, uint8 newFlag ); void RemoveByteFlag(uint16 index, uint8 offset, uint8 newFlag);
void ToggleByteFlag( uint16 index, uint8 offset, uint8 flag ) void ToggleByteFlag(uint16 index, uint8 offset, uint8 flag)
{ {
if (HasByteFlag(index, offset, flag)) if (HasByteFlag(index, offset, flag))
RemoveByteFlag(index, offset, flag); RemoveByteFlag(index, offset, flag);
@ -271,14 +271,14 @@ class MANGOS_DLL_SPEC Object
SetByteFlag(index, offset, flag); SetByteFlag(index, offset, flag);
} }
bool HasByteFlag( uint16 index, uint8 offset, uint8 flag ) const bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index , false ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false));
MANGOS_ASSERT( offset < 4 ); MANGOS_ASSERT(offset < 4);
return (((uint8*)&m_uint32Values[index])[offset] & flag) != 0; return (((uint8*)&m_uint32Values[index])[offset] & flag) != 0;
} }
void ApplyModByteFlag( uint16 index, uint8 offset, uint32 flag, bool apply) void ApplyModByteFlag(uint16 index, uint8 offset, uint32 flag, bool apply)
{ {
if (apply) if (apply)
SetByteFlag(index, offset, flag); SetByteFlag(index, offset, flag);
@ -289,7 +289,7 @@ class MANGOS_DLL_SPEC Object
void SetShortFlag(uint16 index, bool highpart, uint16 newFlag); void SetShortFlag(uint16 index, bool highpart, uint16 newFlag);
void RemoveShortFlag(uint16 index, bool highpart, uint16 oldFlag); void RemoveShortFlag(uint16 index, bool highpart, uint16 oldFlag);
void ToggleShortFlag( uint16 index, bool highpart, uint8 flag ) void ToggleShortFlag(uint16 index, bool highpart, uint8 flag)
{ {
if (HasShortFlag(index, highpart, flag)) if (HasShortFlag(index, highpart, flag))
RemoveShortFlag(index, highpart, flag); RemoveShortFlag(index, highpart, flag);
@ -297,13 +297,13 @@ class MANGOS_DLL_SPEC Object
SetShortFlag(index, highpart, flag); SetShortFlag(index, highpart, flag);
} }
bool HasShortFlag( uint16 index, bool highpart, uint8 flag ) const bool HasShortFlag(uint16 index, bool highpart, uint8 flag) const
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index , false ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false));
return (((uint16*)&m_uint32Values[index])[highpart ? 1 : 0] & flag) != 0; return (((uint16*)&m_uint32Values[index])[highpart ? 1 : 0] & flag) != 0;
} }
void ApplyModShortFlag( uint16 index, bool highpart, uint32 flag, bool apply) void ApplyModShortFlag(uint16 index, bool highpart, uint32 flag, bool apply)
{ {
if (apply) if (apply)
SetShortFlag(index, highpart, flag); SetShortFlag(index, highpart, flag);
@ -311,21 +311,21 @@ class MANGOS_DLL_SPEC Object
RemoveShortFlag(index, highpart, flag); RemoveShortFlag(index, highpart, flag);
} }
void SetFlag64( uint16 index, uint64 newFlag ) void SetFlag64(uint16 index, uint64 newFlag)
{ {
uint64 oldval = GetUInt64Value(index); uint64 oldval = GetUInt64Value(index);
uint64 newval = oldval | newFlag; uint64 newval = oldval | newFlag;
SetUInt64Value(index,newval); SetUInt64Value(index,newval);
} }
void RemoveFlag64( uint16 index, uint64 oldFlag ) void RemoveFlag64(uint16 index, uint64 oldFlag)
{ {
uint64 oldval = GetUInt64Value(index); uint64 oldval = GetUInt64Value(index);
uint64 newval = oldval & ~oldFlag; uint64 newval = oldval & ~oldFlag;
SetUInt64Value(index,newval); SetUInt64Value(index,newval);
} }
void ToggleFlag64( uint16 index, uint64 flag) void ToggleFlag64(uint16 index, uint64 flag)
{ {
if (HasFlag64(index, flag)) if (HasFlag64(index, flag))
RemoveFlag64(index, flag); RemoveFlag64(index, flag);
@ -333,13 +333,13 @@ class MANGOS_DLL_SPEC Object
SetFlag64(index, flag); SetFlag64(index, flag);
} }
bool HasFlag64( uint16 index, uint64 flag ) const bool HasFlag64(uint16 index, uint64 flag) const
{ {
MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index , false ) ); MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false));
return (GetUInt64Value( index ) & flag) != 0; return (GetUInt64Value(index) & flag) != 0;
} }
void ApplyModFlag64( uint16 index, uint64 flag, bool apply) void ApplyModFlag64(uint16 index, uint64 flag, bool apply)
{ {
if (apply) if (apply)
SetFlag64(index, flag); SetFlag64(index, flag);
@ -359,17 +359,17 @@ class MANGOS_DLL_SPEC Object
virtual bool HasInvolvedQuest(uint32 /* quest_id */) const { return false; } virtual bool HasInvolvedQuest(uint32 /* quest_id */) const { return false; }
protected: protected:
Object ( ); Object();
void _InitValues(); void _InitValues();
void _Create (uint32 guidlow, uint32 entry, HighGuid guidhigh); void _Create(uint32 guidlow, uint32 entry, HighGuid guidhigh);
virtual void _SetUpdateBits(UpdateMask *updateMask, Player *target) const; virtual void _SetUpdateBits(UpdateMask* updateMask, Player* target) const;
virtual void _SetCreateBits(UpdateMask *updateMask, Player *target) const; virtual void _SetCreateBits(UpdateMask* updateMask, Player* target) const;
void BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const; void BuildMovementUpdate(ByteBuffer* data, uint16 updateFlags) const;
void BuildValuesUpdate(uint8 updatetype, ByteBuffer *data, UpdateMask *updateMask, Player *target ) const; void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* updateMask, Player* target) const;
void BuildUpdateDataForPlayer(Player* pl, UpdateDataMapType& update_players); void BuildUpdateDataForPlayer(Player* pl, UpdateDataMapType& update_players);
uint16 m_objectType; uint16 m_objectType;
@ -379,12 +379,12 @@ class MANGOS_DLL_SPEC Object
union union
{ {
int32 *m_int32Values; int32* m_int32Values;
uint32 *m_uint32Values; uint32* m_uint32Values;
float *m_floatValues; float* m_floatValues;
}; };
uint32 *m_uint32Values_mirror; uint32* m_uint32Values_mirror;
uint16 m_valuesCount; uint16 m_valuesCount;
@ -408,7 +408,7 @@ struct WorldObjectChangeAccumulator;
class MANGOS_DLL_SPEC WorldObject : public Object class MANGOS_DLL_SPEC WorldObject : public Object
{ {
friend struct WorldObjectChangeAccumulator; friend struct WorldObjectChangeAccumulator;
public: public:
@ -417,49 +417,49 @@ class MANGOS_DLL_SPEC WorldObject : public Object
class MANGOS_DLL_SPEC UpdateHelper class MANGOS_DLL_SPEC UpdateHelper
{ {
public: public:
explicit UpdateHelper(WorldObject * obj) : m_obj(obj) {} explicit UpdateHelper(WorldObject* obj) : m_obj(obj) {}
~UpdateHelper() { } ~UpdateHelper() { }
void Update( uint32 time_diff ) void Update(uint32 time_diff)
{ {
m_obj->Update( m_obj->m_updateTracker.timeElapsed(), time_diff); m_obj->Update(m_obj->m_updateTracker.timeElapsed(), time_diff);
m_obj->m_updateTracker.Reset(); m_obj->m_updateTracker.Reset();
} }
private: private:
UpdateHelper( const UpdateHelper& ); UpdateHelper(const UpdateHelper&);
UpdateHelper& operator=( const UpdateHelper& ); UpdateHelper& operator=(const UpdateHelper&);
WorldObject * const m_obj; WorldObject* const m_obj;
}; };
virtual ~WorldObject ( ) {} virtual ~WorldObject() {}
virtual void Update(uint32 /*update_diff*/, uint32 /*time_diff*/) {} virtual void Update(uint32 /*update_diff*/, uint32 /*time_diff*/) {}
void _Create( uint32 guidlow, HighGuid guidhigh, uint32 phaseMask); void _Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask);
void Relocate(float x, float y, float z, float orientation); void Relocate(float x, float y, float z, float orientation);
void Relocate(float x, float y, float z); void Relocate(float x, float y, float z);
void SetOrientation(float orientation); void SetOrientation(float orientation);
float GetPositionX( ) const { return m_position.x; } float GetPositionX() const { return m_position.x; }
float GetPositionY( ) const { return m_position.y; } float GetPositionY() const { return m_position.y; }
float GetPositionZ( ) const { return m_position.z; } float GetPositionZ() const { return m_position.z; }
void GetPosition( float &x, float &y, float &z ) const void GetPosition(float& x, float& y, float& z) const
{ x = m_position.x; y = m_position.y; z = m_position.z; } { x = m_position.x; y = m_position.y; z = m_position.z; }
void GetPosition( WorldLocation &loc ) const void GetPosition(WorldLocation& loc) const
{ loc.mapid = m_mapId; GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); } { loc.mapid = m_mapId; GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); }
float GetOrientation( ) const { return m_position.o; } float GetOrientation() const { return m_position.o; }
void GetNearPoint2D( float &x, float &y, float distance, float absAngle) const; void GetNearPoint2D(float& x, float& y, float distance, float absAngle) const;
void GetNearPoint(WorldObject const* searcher, float &x, float &y, float &z, float searcher_bounding_radius, float distance2d, float absAngle) const; void GetNearPoint(WorldObject const* searcher, float& x, float& y, float& z, float searcher_bounding_radius, float distance2d, float absAngle) const;
void GetClosePoint(float &x, float &y, float &z, float bounding_radius, float distance2d = 0, float angle = 0, const WorldObject* obj = NULL ) const void GetClosePoint(float& x, float& y, float& z, float bounding_radius, float distance2d = 0, float angle = 0, const WorldObject* obj = NULL) const
{ {
// angle calculated from current orientation // angle calculated from current orientation
GetNearPoint(obj, x, y, z, bounding_radius, distance2d, GetOrientation() + angle); GetNearPoint(obj, x, y, z, bounding_radius, distance2d, GetOrientation() + angle);
} }
void GetContactPoint( const WorldObject* obj, float &x, float &y, float &z, float distance2d = CONTACT_DISTANCE) const void GetContactPoint(const WorldObject* obj, float& x, float& y, float& z, float distance2d = CONTACT_DISTANCE) const
{ {
// angle to face `obj` to `this` using distance includes size of `obj` // angle to face `obj` to `this` using distance includes size of `obj`
GetNearPoint(obj, x, y, z, obj->GetObjectBoundingRadius(), distance2d, GetAngle(obj)); GetNearPoint(obj, x, y, z, obj->GetObjectBoundingRadius(), distance2d, GetAngle(obj));
@ -468,10 +468,10 @@ class MANGOS_DLL_SPEC WorldObject : public Object
virtual float GetObjectBoundingRadius() const { return DEFAULT_WORLD_OBJECT_SIZE; } virtual float GetObjectBoundingRadius() const { return DEFAULT_WORLD_OBJECT_SIZE; }
bool IsPositionValid() const; bool IsPositionValid() const;
void UpdateGroundPositionZ(float x, float y, float &z) const; void UpdateGroundPositionZ(float x, float y, float& z) const;
void UpdateAllowedPositionZ(float x, float y, float &z) const; void UpdateAllowedPositionZ(float x, float y, float& z) const;
void GetRandomPoint( float x, float y, float z, float distance, float &rand_x, float &rand_y, float &rand_z ) const; void GetRandomPoint(float x, float y, float z, float distance, float& rand_x, float& rand_y, float& rand_z) const;
uint32 GetMapId() const { return m_mapId; } uint32 GetMapId() const { return m_mapId; }
uint32 GetInstanceId() const { return m_InstanceId; } uint32 GetInstanceId() const { return m_InstanceId; }
@ -492,7 +492,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
virtual const char* GetNameForLocaleIdx(int32 /*locale_idx*/) const { return GetName(); } virtual const char* GetNameForLocaleIdx(int32 /*locale_idx*/) const { return GetName(); }
float GetDistance( const WorldObject* obj ) const; float GetDistance(const WorldObject* obj) const;
float GetDistance(float x, float y, float z) const; float GetDistance(float x, float y, float z) const;
float GetDistance2d(const WorldObject* obj) const; float GetDistance2d(const WorldObject* obj) const;
float GetDistance2d(float x, float y) const; float GetDistance2d(float x, float y) const;
@ -522,9 +522,9 @@ class MANGOS_DLL_SPEC WorldObject : public Object
bool IsInRange2d(float x, float y, float minRange, float maxRange) const; bool IsInRange2d(float x, float y, float minRange, float maxRange) const;
bool IsInRange3d(float x, float y, float z, float minRange, float maxRange) const; bool IsInRange3d(float x, float y, float z, float minRange, float maxRange) const;
float GetAngle( const WorldObject* obj ) const; float GetAngle(const WorldObject* obj) const;
float GetAngle( const float x, const float y ) const; float GetAngle(const float x, const float y) const;
bool HasInArc( const float arcangle, const WorldObject* obj ) const; bool HasInArc(const float arcangle, const WorldObject* obj) const;
bool isInFrontInMap(WorldObject const* target,float distance, float arc = M_PI) const; bool isInFrontInMap(WorldObject const* target,float distance, float arc = M_PI) const;
bool isInBackInMap(WorldObject const* target, float distance, float arc = M_PI) const; bool isInBackInMap(WorldObject const* target, float distance, float arc = M_PI) const;
bool isInFront(WorldObject const* target,float distance, float arc = M_PI) const; bool isInFront(WorldObject const* target,float distance, float arc = M_PI) const;
@ -532,9 +532,9 @@ class MANGOS_DLL_SPEC WorldObject : public Object
virtual void CleanupsBeforeDelete(); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units virtual void CleanupsBeforeDelete(); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units
virtual void SendMessageToSet(WorldPacket *data, bool self); virtual void SendMessageToSet(WorldPacket* data, bool self);
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self); virtual void SendMessageToSetInRange(WorldPacket* data, float dist, bool self);
void SendMessageToSetExcept(WorldPacket *data, Player const* skipped_receiver); void SendMessageToSetExcept(WorldPacket* data, Player const* skipped_receiver);
void MonsterSay(const char* text, uint32 language, Unit* target = NULL); void MonsterSay(const char* text, uint32 language, Unit* target = NULL);
void MonsterYell(const char* text, uint32 language, Unit* target = NULL); void MonsterYell(const char* text, uint32 language, Unit* target = NULL);
@ -545,7 +545,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
void MonsterTextEmote(int32 textId, Unit* target, bool IsBossEmote = false); void MonsterTextEmote(int32 textId, Unit* target, bool IsBossEmote = false);
void MonsterWhisper(int32 textId, Unit* receiver, bool IsBossWhisper = false); void MonsterWhisper(int32 textId, Unit* receiver, bool IsBossWhisper = false);
void MonsterYellToZone(int32 textId, uint32 language, Unit* target); void MonsterYellToZone(int32 textId, uint32 language, Unit* target);
static void BuildMonsterChat(WorldPacket *data, ObjectGuid senderGuid, uint8 msgtype, char const* text, uint32 language, char const* name, ObjectGuid targetGuid, char const* targetName); static void BuildMonsterChat(WorldPacket* data, ObjectGuid senderGuid, uint8 msgtype, char const* text, uint32 language, char const* name, ObjectGuid targetGuid, char const* targetName);
void PlayDistanceSound(uint32 sound_id, Player* target = NULL); void PlayDistanceSound(uint32 sound_id, Player* target = NULL);
void PlayDirectSound(uint32 sound_id, Player* target = NULL); void PlayDirectSound(uint32 sound_id, Player* target = NULL);
@ -569,8 +569,8 @@ class MANGOS_DLL_SPEC WorldObject : public Object
// low level function for visibility change code, must be define in all main world object subclasses // low level function for visibility change code, must be define in all main world object subclasses
virtual bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const = 0; virtual bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const = 0;
void SetMap(Map * map); void SetMap(Map* map);
Map * GetMap() const { MANGOS_ASSERT(m_currMap); return m_currMap; } Map* GetMap() const { MANGOS_ASSERT(m_currMap); return m_currMap; }
//used to check all object's GetMap() calls when object is not in world! //used to check all object's GetMap() calls when object is not in world!
void ResetMap() { m_currMap = NULL; } void ResetMap() { m_currMap = NULL; }
@ -579,7 +579,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
void AddToClientUpdateList(); void AddToClientUpdateList();
void RemoveFromClientUpdateList(); void RemoveFromClientUpdateList();
void BuildUpdateData(UpdateDataMapType &); void BuildUpdateData(UpdateDataMapType&);
Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime, bool asActiveObject = false); Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime, bool asActiveObject = false);
@ -607,7 +607,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
std::string m_name; std::string m_name;
private: private:
Map * m_currMap; //current object's Map location Map* m_currMap; //current object's Map location
uint32 m_mapId; // object at map with map_id uint32 m_mapId; // object at map with map_id
uint32 m_InstanceId; // in map copy with instance id uint32 m_InstanceId; // in map copy with instance id

View file

@ -40,7 +40,7 @@ INSTANTIATE_CLASS_MUTEX(ObjectAccessor, ACE_Thread_Mutex);
ObjectAccessor::ObjectAccessor() {} ObjectAccessor::ObjectAccessor() {}
ObjectAccessor::~ObjectAccessor() ObjectAccessor::~ObjectAccessor()
{ {
for(Player2CorpsesMapType::const_iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); ++itr) for (Player2CorpsesMapType::const_iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); ++itr)
{ {
itr->second->RemoveFromWorld(); itr->second->RemoveFromWorld();
delete itr->second; delete itr->second;
@ -48,7 +48,7 @@ ObjectAccessor::~ObjectAccessor()
} }
Unit* Unit*
ObjectAccessor::GetUnit(WorldObject const &u, ObjectGuid guid) ObjectAccessor::GetUnit(WorldObject const& u, ObjectGuid guid)
{ {
if (!guid) if (!guid)
return NULL; return NULL;
@ -64,7 +64,7 @@ ObjectAccessor::GetUnit(WorldObject const &u, ObjectGuid guid)
Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid) Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid)
{ {
Corpse * ret = HashMapHolder<Corpse>::Find(guid); Corpse* ret = HashMapHolder<Corpse>::Find(guid);
if (!ret) if (!ret)
return NULL; return NULL;
if (ret->GetMapId() != mapid) if (ret->GetMapId() != mapid)
@ -85,12 +85,12 @@ Player* ObjectAccessor::FindPlayer(ObjectGuid guid, bool inWorld /*= true*/)
return plr; return plr;
} }
Player* ObjectAccessor::FindPlayerByName(const char *name) Player* ObjectAccessor::FindPlayerByName(const char* name)
{ {
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock()); HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers(); HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter) for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->second->IsInWorld() && ( ::strcmp(name, iter->second->GetName()) == 0 )) if (iter->second->IsInWorld() && (::strcmp(name, iter->second->GetName()) == 0))
return iter->second; return iter->second;
return NULL; return NULL;
@ -130,13 +130,13 @@ ObjectAccessor::GetCorpseForPlayerGUID(ObjectGuid guid)
} }
void void
ObjectAccessor::RemoveCorpse(Corpse *corpse) ObjectAccessor::RemoveCorpse(Corpse* corpse)
{ {
MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES); MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
Guard guard(i_corpseGuard); Guard guard(i_corpseGuard);
Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGuid()); Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGuid());
if( iter == i_player2corpse.end() ) if (iter == i_player2corpse.end())
return; return;
// build mapid*cellid -> guid_set map // build mapid*cellid -> guid_set map
@ -150,7 +150,7 @@ ObjectAccessor::RemoveCorpse(Corpse *corpse)
} }
void void
ObjectAccessor::AddCorpse(Corpse *corpse) ObjectAccessor::AddCorpse(Corpse* corpse)
{ {
MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES); MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES);
@ -169,29 +169,29 @@ void
ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map) ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map)
{ {
Guard guard(i_corpseGuard); Guard guard(i_corpseGuard);
for(Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter) for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter)
if(iter->second->GetGrid() == gridpair) if (iter->second->GetGrid() == gridpair)
{
// verify, if the corpse in our instance (add only corpses which are)
if (map->Instanceable())
{ {
if (iter->second->GetInstanceId() == map->GetInstanceId()) // verify, if the corpse in our instance (add only corpses which are)
if (map->Instanceable())
{
if (iter->second->GetInstanceId() == map->GetInstanceId())
{
grid.AddWorldObject(iter->second);
}
}
else
{ {
grid.AddWorldObject(iter->second); grid.AddWorldObject(iter->second);
} }
} }
else
{
grid.AddWorldObject(iter->second);
}
}
} }
Corpse* Corpse*
ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia) ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
{ {
Corpse *corpse = GetCorpseForPlayerGUID(player_guid); Corpse* corpse = GetCorpseForPlayerGUID(player_guid);
if(!corpse) if (!corpse)
{ {
//in fact this function is called from several places //in fact this function is called from several places
//even when player doesn't have a corpse, not an error //even when player doesn't have a corpse, not an error
@ -206,19 +206,19 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
// remove resurrectable corpse from grid object registry (loaded state checked into call) // remove resurrectable corpse from grid object registry (loaded state checked into call)
// do not load the map if it's not loaded // do not load the map if it's not loaded
Map *map = sMapMgr.FindMap(corpse->GetMapId(), corpse->GetInstanceId()); Map* map = sMapMgr.FindMap(corpse->GetMapId(), corpse->GetInstanceId());
if (map) if (map)
map->Remove(corpse, false); map->Remove(corpse, false);
// remove corpse from DB // remove corpse from DB
corpse->DeleteFromDB(); corpse->DeleteFromDB();
Corpse *bones = NULL; Corpse* bones = NULL;
// create the bones only if the map and the grid is loaded at the corpse's location // create the bones only if the map and the grid is loaded at the corpse's location
// ignore bones creating option in case insignia // ignore bones creating option in case insignia
if (map && (insignia || if (map && (insignia ||
(map->IsBattleGroundOrArena() ? sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_BG_OR_ARENA) : sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_WORLD))) && (map->IsBattleGroundOrArena() ? sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_BG_OR_ARENA) : sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_WORLD))) &&
!map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY())) !map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY()))
{ {
// Create bones, don't change Corpse // Create bones, don't change Corpse
bones = new Corpse; bones = new Corpse;
@ -239,7 +239,7 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
for (int i = 0; i < EQUIPMENT_SLOT_END; ++i) for (int i = 0; i < EQUIPMENT_SLOT_END; ++i)
{ {
if(corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i)) if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0); bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
} }
@ -257,12 +257,12 @@ void ObjectAccessor::RemoveOldCorpses()
{ {
time_t now = time(NULL); time_t now = time(NULL);
Player2CorpsesMapType::iterator next; Player2CorpsesMapType::iterator next;
for(Player2CorpsesMapType::iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); itr = next) for (Player2CorpsesMapType::iterator itr = i_player2corpse.begin(); itr != i_player2corpse.end(); itr = next)
{ {
next = itr; next = itr;
++next; ++next;
if(!itr->second->IsExpired(now)) if (!itr->second->IsExpired(now))
continue; continue;
ConvertCorpseForPlayer(itr->first); ConvertCorpseForPlayer(itr->first);

View file

@ -85,12 +85,12 @@ class HashMapHolder
class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor, MaNGOS::ClassLevelLockable<ObjectAccessor, ACE_Thread_Mutex> > class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor, MaNGOS::ClassLevelLockable<ObjectAccessor, ACE_Thread_Mutex> >
{ {
friend class MaNGOS::OperatorNew<ObjectAccessor>; friend class MaNGOS::OperatorNew<ObjectAccessor>;
ObjectAccessor(); ObjectAccessor();
~ObjectAccessor(); ~ObjectAccessor();
ObjectAccessor(const ObjectAccessor &); ObjectAccessor(const ObjectAccessor&);
ObjectAccessor& operator=(const ObjectAccessor &); ObjectAccessor& operator=(const ObjectAccessor&);
public: public:
typedef UNORDERED_MAP<ObjectGuid, Corpse*> Player2CorpsesMapType; typedef UNORDERED_MAP<ObjectGuid, Corpse*> Player2CorpsesMapType;
@ -101,7 +101,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
// Player access // Player access
static Player* FindPlayer(ObjectGuid guid, bool inWorld = true);// if need player at specific map better use Map::GetPlayer static Player* FindPlayer(ObjectGuid guid, bool inWorld = true);// if need player at specific map better use Map::GetPlayer
static Player* FindPlayerByName(const char *name); static Player* FindPlayerByName(const char* name);
static void KickPlayer(ObjectGuid guid); static void KickPlayer(ObjectGuid guid);
HashMapHolder<Player>::MapType& GetPlayers() HashMapHolder<Player>::MapType& GetPlayers()
@ -114,17 +114,17 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
// Corpse access // Corpse access
Corpse* GetCorpseForPlayerGUID(ObjectGuid guid); Corpse* GetCorpseForPlayerGUID(ObjectGuid guid);
static Corpse* GetCorpseInMap(ObjectGuid guid, uint32 mapid); static Corpse* GetCorpseInMap(ObjectGuid guid, uint32 mapid);
void RemoveCorpse(Corpse *corpse); void RemoveCorpse(Corpse* corpse);
void AddCorpse(Corpse* corpse); void AddCorpse(Corpse* corpse);
void AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map); void AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map);
Corpse* ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia = false); Corpse* ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia = false);
void RemoveOldCorpses(); void RemoveOldCorpses();
// For call from Player/Corpse AddToWorld/RemoveFromWorld only // For call from Player/Corpse AddToWorld/RemoveFromWorld only
void AddObject(Corpse *object) { HashMapHolder<Corpse>::Insert(object); } void AddObject(Corpse* object) { HashMapHolder<Corpse>::Insert(object); }
void AddObject(Player *object) { HashMapHolder<Player>::Insert(object); } void AddObject(Player* object) { HashMapHolder<Player>::Insert(object); }
void RemoveObject(Corpse *object) { HashMapHolder<Corpse>::Remove(object); } void RemoveObject(Corpse* object) { HashMapHolder<Corpse>::Remove(object); }
void RemoveObject(Player *object) { HashMapHolder<Player>::Remove(object); } void RemoveObject(Player* object) { HashMapHolder<Player>::Remove(object); }
private: private:

View file

@ -33,30 +33,30 @@ class MANGOS_DLL_DECL ObjectGridRespawnMover
public: public:
ObjectGridRespawnMover() {} ObjectGridRespawnMover() {}
void Move(GridType &grid); void Move(GridType& grid);
template<class T> void Visit(GridRefManager<T> &) {} template<class T> void Visit(GridRefManager<T>&) {}
void Visit(CreatureMapType &m); void Visit(CreatureMapType& m);
}; };
void void
ObjectGridRespawnMover::Move(GridType &grid) ObjectGridRespawnMover::Move(GridType& grid)
{ {
TypeContainerVisitor<ObjectGridRespawnMover, GridTypeMapContainer > mover(*this); TypeContainerVisitor<ObjectGridRespawnMover, GridTypeMapContainer > mover(*this);
grid.Visit(mover); grid.Visit(mover);
} }
void void
ObjectGridRespawnMover::Visit(CreatureMapType &m) ObjectGridRespawnMover::Visit(CreatureMapType& m)
{ {
// creature in unloading grid can have respawn point in another grid // creature in unloading grid can have respawn point in another grid
// if it will be unloaded then it will not respawn in original grid until unload/load original grid // if it will be unloaded then it will not respawn in original grid until unload/load original grid
// move to respawn point to prevent this case. For player view in respawn grid this will be normal respawn. // move to respawn point to prevent this case. For player view in respawn grid this will be normal respawn.
for(CreatureMapType::iterator iter=m.begin(), next; iter != m.end(); iter = next) for (CreatureMapType::iterator iter=m.begin(), next; iter != m.end(); iter = next)
{ {
next = iter; ++next; next = iter; ++next;
Creature * c = iter->getSource(); Creature* c = iter->getSource();
MANGOS_ASSERT(!c->IsPet() && "ObjectGridRespawnMover don't must be called for pets"); MANGOS_ASSERT(!c->IsPet() && "ObjectGridRespawnMover don't must be called for pets");
@ -67,7 +67,7 @@ ObjectGridRespawnMover::Visit(CreatureMapType &m)
CellPair resp_val = MaNGOS::ComputeCellPair(resp_x, resp_y); CellPair resp_val = MaNGOS::ComputeCellPair(resp_x, resp_y);
Cell resp_cell(resp_val); Cell resp_cell(resp_val);
if(cur_cell.DiffGrid(resp_cell)) if (cur_cell.DiffGrid(resp_cell))
{ {
c->GetMap()->CreatureRespawnRelocation(c); c->GetMap()->CreatureRespawnRelocation(c);
// false result ignored: will be unload with other creatures at grid // false result ignored: will be unload with other creatures at grid
@ -80,16 +80,16 @@ class ObjectWorldLoader
{ {
public: public:
explicit ObjectWorldLoader(ObjectGridLoader& gloader) explicit ObjectWorldLoader(ObjectGridLoader& gloader)
: i_cell(gloader.i_cell), i_grid(gloader.i_grid), i_map(gloader.i_map), i_corpses (0) : i_cell(gloader.i_cell), i_grid(gloader.i_grid), i_map(gloader.i_map), i_corpses(0)
{} {}
void Visit(CorpseMapType &m); void Visit(CorpseMapType& m);
template<class T> void Visit(GridRefManager<T>&) { } template<class T> void Visit(GridRefManager<T>&) { }
private: private:
Cell i_cell; Cell i_cell;
NGridType &i_grid; NGridType& i_grid;
Map* i_map; Map* i_map;
public: public:
uint32 i_corpses; uint32 i_corpses;
@ -99,7 +99,7 @@ template<class T> void addUnitState(T* /*obj*/, CellPair const& /*cell_pair*/)
{ {
} }
template<> void addUnitState(Creature *obj, CellPair const& cell_pair) template<> void addUnitState(Creature* obj, CellPair const& cell_pair)
{ {
Cell cell(cell_pair); Cell cell(cell_pair);
@ -107,17 +107,17 @@ template<> void addUnitState(Creature *obj, CellPair const& cell_pair)
} }
template <class T> template <class T>
void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> &m, uint32 &count, Map* map, GridType& grid) void LoadHelper(CellGuidSet const& guid_set, CellPair& cell, GridRefManager<T>& m, uint32& count, Map* map, GridType& grid)
{ {
BattleGround* bg = map->IsBattleGroundOrArena() ? ((BattleGroundMap*)map)->GetBG() : NULL; BattleGround* bg = map->IsBattleGroundOrArena() ? ((BattleGroundMap*)map)->GetBG() : NULL;
for(CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid) for (CellGuidSet::const_iterator i_guid = guid_set.begin(); i_guid != guid_set.end(); ++i_guid)
{ {
uint32 guid = *i_guid; uint32 guid = *i_guid;
T* obj = new T; T* obj = new T;
//sLog.outString("DEBUG: LoadHelper from table: %s for (guid: %u) Loading",table,guid); //sLog.outString("DEBUG: LoadHelper from table: %s for (guid: %u) Loading",table,guid);
if(!obj->LoadFromDB(guid, map)) if (!obj->LoadFromDB(guid, map))
{ {
delete obj; delete obj;
continue; continue;
@ -128,7 +128,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> &
addUnitState(obj,cell); addUnitState(obj,cell);
obj->SetMap(map); obj->SetMap(map);
obj->AddToWorld(); obj->AddToWorld();
if(obj->isActiveObject()) if (obj->isActiveObject())
map->AddToActive(obj); map->AddToActive(obj);
obj->GetViewPoint().Event_AddedToWorld(&grid); obj->GetViewPoint().Event_AddedToWorld(&grid);
@ -140,19 +140,19 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager<T> &
} }
} }
void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType &m, uint32 &count, Map* map, GridType& grid) void LoadHelper(CellCorpseSet const& cell_corpses, CellPair& cell, CorpseMapType& m, uint32& count, Map* map, GridType& grid)
{ {
if(cell_corpses.empty()) if (cell_corpses.empty())
return; return;
for(CellCorpseSet::const_iterator itr = cell_corpses.begin(); itr != cell_corpses.end(); ++itr) for (CellCorpseSet::const_iterator itr = cell_corpses.begin(); itr != cell_corpses.end(); ++itr)
{ {
if(itr->second != map->GetInstanceId()) if (itr->second != map->GetInstanceId())
continue; continue;
uint32 player_lowguid = itr->first; uint32 player_lowguid = itr->first;
Corpse *obj = sObjectAccessor.GetCorpseForPlayerGUID(ObjectGuid(HIGHGUID_PLAYER, player_lowguid)); Corpse* obj = sObjectAccessor.GetCorpseForPlayerGUID(ObjectGuid(HIGHGUID_PLAYER, player_lowguid));
if (!obj) if (!obj)
continue; continue;
@ -169,7 +169,7 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType
} }
void void
ObjectGridLoader::Visit(GameObjectMapType &m) ObjectGridLoader::Visit(GameObjectMapType& m)
{ {
uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX();
uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY();
@ -178,13 +178,13 @@ ObjectGridLoader::Visit(GameObjectMapType &m)
CellObjectGuids const& cell_guids = sObjectMgr.GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id); CellObjectGuids const& cell_guids = sObjectMgr.GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id);
GridType& grid = (*i_map->getNGrid(i_cell.GridX(),i_cell.GridY())) (i_cell.CellX(),i_cell.CellY()); GridType& grid = (*i_map->getNGrid(i_cell.GridX(),i_cell.GridY()))(i_cell.CellX(),i_cell.CellY());
LoadHelper(cell_guids.gameobjects, cell_pair, m, i_gameObjects, i_map, grid); LoadHelper(cell_guids.gameobjects, cell_pair, m, i_gameObjects, i_map, grid);
LoadHelper(i_map->GetPersistentState()->GetCellObjectGuids(cell_id).gameobjects, cell_pair, m, i_gameObjects, i_map, grid); LoadHelper(i_map->GetPersistentState()->GetCellObjectGuids(cell_id).gameobjects, cell_pair, m, i_gameObjects, i_map, grid);
} }
void void
ObjectGridLoader::Visit(CreatureMapType &m) ObjectGridLoader::Visit(CreatureMapType& m)
{ {
uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX();
uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY();
@ -193,13 +193,13 @@ ObjectGridLoader::Visit(CreatureMapType &m)
CellObjectGuids const& cell_guids = sObjectMgr.GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id); CellObjectGuids const& cell_guids = sObjectMgr.GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cell_id);
GridType& grid = (*i_map->getNGrid(i_cell.GridX(),i_cell.GridY())) (i_cell.CellX(),i_cell.CellY()); GridType& grid = (*i_map->getNGrid(i_cell.GridX(),i_cell.GridY()))(i_cell.CellX(),i_cell.CellY());
LoadHelper(cell_guids.creatures, cell_pair, m, i_creatures, i_map, grid); LoadHelper(cell_guids.creatures, cell_pair, m, i_creatures, i_map, grid);
LoadHelper(i_map->GetPersistentState()->GetCellObjectGuids(cell_id).creatures, cell_pair, m, i_creatures, i_map, grid); LoadHelper(i_map->GetPersistentState()->GetCellObjectGuids(cell_id).creatures, cell_pair, m, i_creatures, i_map, grid);
} }
void void
ObjectWorldLoader::Visit(CorpseMapType &m) ObjectWorldLoader::Visit(CorpseMapType& m)
{ {
uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX();
uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY(); uint32 y = (i_cell.GridY()*MAX_NUMBER_OF_CELLS) + i_cell.CellY();
@ -208,12 +208,12 @@ ObjectWorldLoader::Visit(CorpseMapType &m)
// corpses are always added to spawn mode 0 and they are spawned by their instance id // corpses are always added to spawn mode 0 and they are spawned by their instance id
CellObjectGuids const& cell_guids = sObjectMgr.GetCellObjectGuids(i_map->GetId(), 0, cell_id); CellObjectGuids const& cell_guids = sObjectMgr.GetCellObjectGuids(i_map->GetId(), 0, cell_id);
GridType& grid = (*i_map->getNGrid(i_cell.GridX(),i_cell.GridY())) (i_cell.CellX(),i_cell.CellY()); GridType& grid = (*i_map->getNGrid(i_cell.GridX(),i_cell.GridY()))(i_cell.CellX(),i_cell.CellY());
LoadHelper(cell_guids.corpses, cell_pair, m, i_corpses, i_map, grid); LoadHelper(cell_guids.corpses, cell_pair, m, i_corpses, i_map, grid);
} }
void void
ObjectGridLoader::Load(GridType &grid) ObjectGridLoader::Load(GridType& grid)
{ {
{ {
TypeContainerVisitor<ObjectGridLoader, GridTypeMapContainer > loader(*this); TypeContainerVisitor<ObjectGridLoader, GridTypeMapContainer > loader(*this);
@ -232,10 +232,10 @@ void ObjectGridLoader::LoadN(void)
{ {
i_gameObjects = 0; i_creatures = 0; i_corpses = 0; i_gameObjects = 0; i_creatures = 0; i_corpses = 0;
i_cell.data.Part.cell_y = 0; i_cell.data.Part.cell_y = 0;
for(unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x)
{ {
i_cell.data.Part.cell_x = x; i_cell.data.Part.cell_x = x;
for(unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y)
{ {
i_cell.data.Part.cell_y = y; i_cell.data.Part.cell_y = y;
GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader; GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader;
@ -247,9 +247,9 @@ void ObjectGridLoader::LoadN(void)
void ObjectGridUnloader::MoveToRespawnN() void ObjectGridUnloader::MoveToRespawnN()
{ {
for(unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x)
{ {
for(unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y)
{ {
ObjectGridRespawnMover mover; ObjectGridRespawnMover mover;
mover.Move(i_grid(x, y)); mover.Move(i_grid(x, y));
@ -258,7 +258,7 @@ void ObjectGridUnloader::MoveToRespawnN()
} }
void void
ObjectGridUnloader::Unload(GridType &grid) ObjectGridUnloader::Unload(GridType& grid)
{ {
TypeContainerVisitor<ObjectGridUnloader, GridTypeMapContainer > unloader(*this); TypeContainerVisitor<ObjectGridUnloader, GridTypeMapContainer > unloader(*this);
grid.Visit(unloader); grid.Visit(unloader);
@ -266,17 +266,17 @@ ObjectGridUnloader::Unload(GridType &grid)
template<class T> template<class T>
void void
ObjectGridUnloader::Visit(GridRefManager<T> &m) ObjectGridUnloader::Visit(GridRefManager<T>& m)
{ {
// remove all cross-reference before deleting // remove all cross-reference before deleting
for(typename GridRefManager<T>::iterator iter=m.begin(); iter != m.end(); ++iter) for (typename GridRefManager<T>::iterator iter=m.begin(); iter != m.end(); ++iter)
iter->getSource()->CleanupsBeforeDelete(); iter->getSource()->CleanupsBeforeDelete();
while(!m.isEmpty()) while (!m.isEmpty())
{ {
T *obj = m.getFirst()->getSource(); T* obj = m.getFirst()->getSource();
// if option set then object already saved at this moment // if option set then object already saved at this moment
if(!sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY)) if (!sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY))
obj->SaveRespawnTime(); obj->SaveRespawnTime();
///- object must be out of world before delete ///- object must be out of world before delete
obj->RemoveFromWorld(); obj->RemoveFromWorld();
@ -286,17 +286,17 @@ ObjectGridUnloader::Visit(GridRefManager<T> &m)
} }
void void
ObjectGridStoper::Stop(GridType &grid) ObjectGridStoper::Stop(GridType& grid)
{ {
TypeContainerVisitor<ObjectGridStoper, GridTypeMapContainer > stoper(*this); TypeContainerVisitor<ObjectGridStoper, GridTypeMapContainer > stoper(*this);
grid.Visit(stoper); grid.Visit(stoper);
} }
void void
ObjectGridStoper::Visit(CreatureMapType &m) ObjectGridStoper::Visit(CreatureMapType& m)
{ {
// stop any fights at grid de-activation and remove dynobjects created at cast by creatures // stop any fights at grid de-activation and remove dynobjects created at cast by creatures
for(CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter) for (CreatureMapType::iterator iter=m.begin(); iter != m.end(); ++iter)
{ {
iter->getSource()->CombatStop(); iter->getSource()->CombatStop();
iter->getSource()->DeleteThreatList(); iter->getSource()->DeleteThreatList();
@ -304,5 +304,5 @@ ObjectGridStoper::Visit(CreatureMapType &m)
} }
} }
template void ObjectGridUnloader::Visit(GameObjectMapType &); template void ObjectGridUnloader::Visit(GameObjectMapType&);
template void ObjectGridUnloader::Visit(DynamicObjectMapType &); template void ObjectGridUnloader::Visit(DynamicObjectMapType&);

View file

@ -30,17 +30,17 @@ class ObjectWorldLoader;
class MANGOS_DLL_DECL ObjectGridLoader class MANGOS_DLL_DECL ObjectGridLoader
{ {
friend class ObjectWorldLoader; friend class ObjectWorldLoader;
public: public:
ObjectGridLoader(NGridType &grid, Map* map, const Cell &cell) ObjectGridLoader(NGridType& grid, Map* map, const Cell& cell)
: i_cell(cell), i_grid(grid), i_map(map), i_gameObjects(0), i_creatures(0), i_corpses (0) : i_cell(cell), i_grid(grid), i_map(map), i_gameObjects(0), i_creatures(0), i_corpses(0)
{} {}
void Load(GridType &grid); void Load(GridType& grid);
void Visit(GameObjectMapType &m); void Visit(GameObjectMapType& m);
void Visit(CreatureMapType &m); void Visit(CreatureMapType& m);
void Visit(CorpseMapType &) {} void Visit(CorpseMapType&) {}
void Visit(DynamicObjectMapType&) { } void Visit(DynamicObjectMapType&) { }
@ -48,7 +48,7 @@ class MANGOS_DLL_DECL ObjectGridLoader
private: private:
Cell i_cell; Cell i_cell;
NGridType &i_grid; NGridType& i_grid;
Map* i_map; Map* i_map;
uint32 i_gameObjects; uint32 i_gameObjects;
uint32 i_creatures; uint32 i_creatures;
@ -58,14 +58,14 @@ class MANGOS_DLL_DECL ObjectGridLoader
class MANGOS_DLL_DECL ObjectGridUnloader class MANGOS_DLL_DECL ObjectGridUnloader
{ {
public: public:
ObjectGridUnloader(NGridType &grid) : i_grid(grid) {} ObjectGridUnloader(NGridType& grid) : i_grid(grid) {}
void MoveToRespawnN(); void MoveToRespawnN();
void UnloadN() void UnloadN()
{ {
for(unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x)
{ {
for(unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y)
{ {
GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader; GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader;
loader.Unload(i_grid(x, y), *this); loader.Unload(i_grid(x, y), *this);
@ -73,23 +73,23 @@ class MANGOS_DLL_DECL ObjectGridUnloader
} }
} }
void Unload(GridType &grid); void Unload(GridType& grid);
template<class T> void Visit(GridRefManager<T> &m); template<class T> void Visit(GridRefManager<T>& m);
private: private:
NGridType &i_grid; NGridType& i_grid;
}; };
class MANGOS_DLL_DECL ObjectGridStoper class MANGOS_DLL_DECL ObjectGridStoper
{ {
public: public:
ObjectGridStoper(NGridType &grid) : i_grid(grid) {} ObjectGridStoper(NGridType& grid) : i_grid(grid) {}
void MoveToRespawnN(); void MoveToRespawnN();
void StopN() void StopN()
{ {
for(unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x) for (unsigned int x=0; x < MAX_NUMBER_OF_CELLS; ++x)
{ {
for(unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y) for (unsigned int y=0; y < MAX_NUMBER_OF_CELLS; ++y)
{ {
GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader; GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> loader;
loader.Stop(i_grid(x, y), *this); loader.Stop(i_grid(x, y), *this);
@ -97,12 +97,12 @@ class MANGOS_DLL_DECL ObjectGridStoper
} }
} }
void Stop(GridType &grid); void Stop(GridType& grid);
void Visit(CreatureMapType &m); void Visit(CreatureMapType& m);
template<class NONACTIVE> void Visit(GridRefManager<NONACTIVE> &) {} template<class NONACTIVE> void Visit(GridRefManager<NONACTIVE>&) {}
private: private:
NGridType &i_grid; NGridType& i_grid;
}; };
typedef GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> GridLoaderType; typedef GridLoader<Player, AllWorldObjectTypes, AllGridObjectTypes> GridLoaderType;

View file

@ -25,7 +25,7 @@
char const* ObjectGuid::GetTypeName(HighGuid high) char const* ObjectGuid::GetTypeName(HighGuid high)
{ {
switch(high) switch (high)
{ {
case HIGHGUID_ITEM: return "Item"; case HIGHGUID_ITEM: return "Item";
case HIGHGUID_PLAYER: return "Player"; case HIGHGUID_PLAYER: return "Player";
@ -80,7 +80,7 @@ ByteBuffer& operator<< (ByteBuffer& buf, ObjectGuid const& guid)
return buf; return buf;
} }
ByteBuffer &operator>>(ByteBuffer& buf, ObjectGuid& guid) ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid)
{ {
guid.Set(buf.read<uint64>()); guid.Set(buf.read<uint64>());
return buf; return buf;
@ -92,7 +92,7 @@ ByteBuffer& operator<< (ByteBuffer& buf, PackedGuid const& guid)
return buf; return buf;
} }
ByteBuffer &operator>>(ByteBuffer& buf, PackedGuidReader const& guid) ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid)
{ {
guid.m_guidPtr->Set(buf.readPackGUID()); guid.m_guidPtr->Set(buf.readPackGUID());
return buf; return buf;

View file

@ -62,8 +62,8 @@ enum HighGuid
HIGHGUID_ITEM = 0x470, // blizz 470 HIGHGUID_ITEM = 0x470, // blizz 470
HIGHGUID_CONTAINER = 0x470, // blizz 470 HIGHGUID_CONTAINER = 0x470, // blizz 470
HIGHGUID_PLAYER = 0x000, // blizz 070 (temporary reverted back to 0 high guid HIGHGUID_PLAYER = 0x000, // blizz 070 (temporary reverted back to 0 high guid
// in result unknown source visibility player with // in result unknown source visibility player with
// player problems. please reapply only after its resolve) // player problems. please reapply only after its resolve)
HIGHGUID_GAMEOBJECT = 0xF11, // blizz F11/F51 HIGHGUID_GAMEOBJECT = 0xF11, // blizz F11/F51
HIGHGUID_TRANSPORT = 0xF12, // blizz F12/F52 (for GAMEOBJECT_TYPE_TRANSPORT) HIGHGUID_TRANSPORT = 0xF12, // blizz F12/F52 (for GAMEOBJECT_TYPE_TRANSPORT)
HIGHGUID_UNIT = 0xF13, // blizz F13/F53 HIGHGUID_UNIT = 0xF13, // blizz F13/F53
@ -113,15 +113,15 @@ class MANGOS_DLL_SPEC ObjectGuid
uint32 GetCounter() const uint32 GetCounter() const
{ {
return HasEntry() return HasEntry()
? uint32(m_guid & UI64LIT(0x0000000000FFFFFF)) ? uint32(m_guid & UI64LIT(0x0000000000FFFFFF))
: uint32(m_guid & UI64LIT(0x00000000FFFFFFFF)); : uint32(m_guid & UI64LIT(0x00000000FFFFFFFF));
} }
static uint32 GetMaxCounter(HighGuid high) static uint32 GetMaxCounter(HighGuid high)
{ {
return HasEntry(high) return HasEntry(high)
? uint32(0x00FFFFFF) ? uint32(0x00FFFFFF)
: uint32(0xFFFFFFFF); : uint32(0xFFFFFFFF);
} }
uint32 GetMaxCounter() const { return GetMaxCounter(GetHigh()); } uint32 GetMaxCounter() const { return GetMaxCounter(GetHigh()); }
@ -146,10 +146,10 @@ class MANGOS_DLL_SPEC ObjectGuid
static TypeID GetTypeId(HighGuid high) static TypeID GetTypeId(HighGuid high)
{ {
switch(high) switch (high)
{ {
case HIGHGUID_ITEM: return TYPEID_ITEM; case HIGHGUID_ITEM: return TYPEID_ITEM;
//case HIGHGUID_CONTAINER: return TYPEID_CONTAINER; HIGHGUID_CONTAINER==HIGHGUID_ITEM currently //case HIGHGUID_CONTAINER: return TYPEID_CONTAINER; HIGHGUID_CONTAINER==HIGHGUID_ITEM currently
case HIGHGUID_UNIT: return TYPEID_UNIT; case HIGHGUID_UNIT: return TYPEID_UNIT;
case HIGHGUID_PET: return TYPEID_UNIT; case HIGHGUID_PET: return TYPEID_UNIT;
case HIGHGUID_PLAYER: return TYPEID_PLAYER; case HIGHGUID_PLAYER: return TYPEID_PLAYER;
@ -158,7 +158,7 @@ class MANGOS_DLL_SPEC ObjectGuid
case HIGHGUID_CORPSE: return TYPEID_CORPSE; case HIGHGUID_CORPSE: return TYPEID_CORPSE;
case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT; case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT;
case HIGHGUID_VEHICLE: return TYPEID_UNIT; case HIGHGUID_VEHICLE: return TYPEID_UNIT;
// unknown // unknown
case HIGHGUID_INSTANCE: case HIGHGUID_INSTANCE:
case HIGHGUID_GROUP: case HIGHGUID_GROUP:
default: return TYPEID_OBJECT; default: return TYPEID_OBJECT;
@ -167,7 +167,7 @@ class MANGOS_DLL_SPEC ObjectGuid
TypeID GetTypeId() const { return GetTypeId(GetHigh()); } TypeID GetTypeId() const { return GetTypeId(GetHigh()); }
bool operator! () const { return IsEmpty(); } bool operator!() const { return IsEmpty(); }
bool operator== (ObjectGuid const& guid) const { return GetRawValue() == guid.GetRawValue(); } bool operator== (ObjectGuid const& guid) const { return GetRawValue() == guid.GetRawValue(); }
bool operator!= (ObjectGuid const& guid) const { return GetRawValue() != guid.GetRawValue(); } bool operator!= (ObjectGuid const& guid) const { return GetRawValue() != guid.GetRawValue(); }
bool operator< (ObjectGuid const& guid) const { return GetRawValue() < guid.GetRawValue(); } bool operator< (ObjectGuid const& guid) const { return GetRawValue() < guid.GetRawValue(); }
@ -180,7 +180,7 @@ class MANGOS_DLL_SPEC ObjectGuid
private: // internal functions private: // internal functions
static bool HasEntry(HighGuid high) static bool HasEntry(HighGuid high)
{ {
switch(high) switch (high)
{ {
case HIGHGUID_ITEM: case HIGHGUID_ITEM:
case HIGHGUID_PLAYER: case HIGHGUID_PLAYER:
@ -216,7 +216,7 @@ typedef std::vector<ObjectGuid> GuidVector;
class PackedGuid class PackedGuid
{ {
friend ByteBuffer& operator<< (ByteBuffer& buf, PackedGuid const& guid); friend ByteBuffer& operator<< (ByteBuffer& buf, PackedGuid const& guid);
public: // constructors public: // constructors
explicit PackedGuid() : m_packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { m_packedGuid.appendPackGUID(0); } explicit PackedGuid() : m_packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { m_packedGuid.appendPackGUID(0); }
@ -261,16 +261,16 @@ inline PackedGuid ObjectGuid::WriteAsPacked() const { return PackedGuid(*this);
HASH_NAMESPACE_START HASH_NAMESPACE_START
template<> template<>
class hash<ObjectGuid> class hash<ObjectGuid>
{ {
public: public:
size_t operator() (ObjectGuid const& key) const size_t operator()(ObjectGuid const& key) const
{ {
return hash<uint64>()(key.GetRawValue()); return hash<uint64>()(key.GetRawValue());
} }
}; };
HASH_NAMESPACE_END HASH_NAMESPACE_END

File diff suppressed because it is too large Load diff

View file

@ -123,7 +123,7 @@ class FindCreatureData
FindCreatureData(uint32 id, Player* player) : i_id(id), i_player(player), FindCreatureData(uint32 id, Player* player) : i_id(id), i_player(player),
i_anyData(NULL), i_mapData(NULL), i_mapDist(0.0f), i_spawnedData(NULL), i_spawnedDist(0.0f) {} i_anyData(NULL), i_mapData(NULL), i_mapDist(0.0f), i_spawnedData(NULL), i_spawnedDist(0.0f) {}
bool operator() (CreatureDataPair const& dataPair); bool operator()(CreatureDataPair const& dataPair);
CreatureDataPair const* GetResult() const; CreatureDataPair const* GetResult() const;
private: private:
@ -146,7 +146,7 @@ class FindGOData
FindGOData(uint32 id, Player* player) : i_id(id), i_player(player), FindGOData(uint32 id, Player* player) : i_id(id), i_player(player),
i_anyData(NULL), i_mapData(NULL), i_mapDist(0.0f), i_spawnedData(NULL), i_spawnedDist(0.0f) {} i_anyData(NULL), i_mapData(NULL), i_mapDist(0.0f), i_spawnedData(NULL), i_spawnedDist(0.0f) {}
bool operator() (GameObjectDataPair const& dataPair); bool operator()(GameObjectDataPair const& dataPair);
GameObjectDataPair const* GetResult() const; GameObjectDataPair const* GetResult() const;
private: private:
@ -180,7 +180,7 @@ typedef std::pair<QuestRelationsMap::const_iterator, QuestRelationsMap::const_it
struct PetLevelInfo struct PetLevelInfo
{ {
PetLevelInfo() : health(0), mana(0) { for(int i=0; i < MAX_STATS; ++i ) stats[i] = 0; } PetLevelInfo() : health(0), mana(0) { for (int i=0; i < MAX_STATS; ++i) stats[i] = 0; }
uint16 stats[MAX_STATS]; uint16 stats[MAX_STATS];
uint16 health; uint16 health;
@ -337,7 +337,8 @@ typedef std::multimap<uint32 /*zoneId*/, GraveYardData> GraveYardMap;
typedef std::pair<GraveYardMap::const_iterator, GraveYardMap::const_iterator> GraveYardMapBounds; typedef std::pair<GraveYardMap::const_iterator, GraveYardMap::const_iterator> GraveYardMapBounds;
enum ConditionType enum ConditionType
{ // value1 value2 for the Condition enumed {
// value1 value2 for the Condition enumed
CONDITION_NOT = -3, // cond-id-1 0 returns !cond-id-1 CONDITION_NOT = -3, // cond-id-1 0 returns !cond-id-1
CONDITION_OR = -2, // cond-id-1 cond-id-2 returns cond-id-1 OR cond-id-2 CONDITION_OR = -2, // cond-id-1 cond-id-2 returns cond-id-1 OR cond-id-2
CONDITION_AND = -1, // cond-id-1 cond-id-2 returns cond-id-1 AND cond-id-2 CONDITION_AND = -1, // cond-id-1 cond-id-2 returns cond-id-1 AND cond-id-2
@ -370,12 +371,12 @@ enum ConditionType
CONDITION_ACTIVE_HOLIDAY = 26, // holiday_id 0 preferred use instead CONDITION_ACTIVE_GAME_EVENT when possible CONDITION_ACTIVE_HOLIDAY = 26, // holiday_id 0 preferred use instead CONDITION_ACTIVE_GAME_EVENT when possible
CONDITION_NOT_ACTIVE_HOLIDAY = 27, // holiday_id 0 preferred use instead CONDITION_NOT_ACTIVE_GAME_EVENT when possible CONDITION_NOT_ACTIVE_HOLIDAY = 27, // holiday_id 0 preferred use instead CONDITION_NOT_ACTIVE_GAME_EVENT when possible
CONDITION_LEARNABLE_ABILITY = 28, // spell_id 0 or item_id CONDITION_LEARNABLE_ABILITY = 28, // spell_id 0 or item_id
// True when player can learn ability (using min skill value from SkillLineAbility). // True when player can learn ability (using min skill value from SkillLineAbility).
// Item_id can be defined in addition, to check if player has one (1) item in inventory or bank. // Item_id can be defined in addition, to check if player has one (1) item in inventory or bank.
// When player has spell or has item (when defined), condition return false. // When player has spell or has item (when defined), condition return false.
CONDITION_SKILL_BELOW = 29, // skill_id skill_value CONDITION_SKILL_BELOW = 29, // skill_id skill_value
// True if player has skill skill_id and skill less than (and not equal) skill_value (for skill_value > 1) // True if player has skill skill_id and skill less than (and not equal) skill_value (for skill_value > 1)
// If skill_value == 1, then true if player has not skill skill_id // If skill_value == 1, then true if player has not skill skill_id
CONDITION_REPUTATION_RANK_MAX = 30, // faction_id max_rank CONDITION_REPUTATION_RANK_MAX = 30, // faction_id max_rank
}; };
@ -422,7 +423,7 @@ enum SkillRangeType
SKILL_RANGE_NONE, // 0..0 always SKILL_RANGE_NONE, // 0..0 always
}; };
SkillRangeType GetSkillRangeType(SkillLineEntry const *pSkill, bool racial); SkillRangeType GetSkillRangeType(SkillLineEntry const* pSkill, bool racial);
#define MAX_PLAYER_NAME 12 // max allowed by client name length #define MAX_PLAYER_NAME 12 // max allowed by client name length
#define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length ( > MAX_PLAYER_NAME for support declined names ) #define MAX_INTERNAL_PLAYER_NAME 15 // max server internal player name length ( > MAX_PLAYER_NAME for support declined names )
@ -463,7 +464,7 @@ class IdGenerator
class ObjectMgr class ObjectMgr
{ {
friend class PlayerDumpReader; friend class PlayerDumpReader;
public: public:
ObjectMgr(); ObjectMgr();
@ -488,7 +489,7 @@ class ObjectMgr
typedef UNORDERED_MAP<uint32, WeatherZoneChances> WeatherZoneMap; typedef UNORDERED_MAP<uint32, WeatherZoneChances> WeatherZoneMap;
void LoadGameobjectInfo(); void LoadGameobjectInfo();
void AddGameobjectInfo(GameObjectInfo *goinfo); void AddGameobjectInfo(GameObjectInfo* goinfo);
void PackGroupIds(); void PackGroupIds();
Group* GetGroupById(uint32 id) const; Group* GetGroupById(uint32 id) const;
@ -510,30 +511,30 @@ class ObjectMgr
PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const
{ {
if(class_ >= MAX_CLASSES) return NULL; if (class_ >= MAX_CLASSES) return NULL;
return &playerClassInfo[class_]; return &playerClassInfo[class_];
} }
void GetPlayerClassLevelInfo(uint32 class_,uint32 level, PlayerClassLevelInfo* info) const; void GetPlayerClassLevelInfo(uint32 class_,uint32 level, PlayerClassLevelInfo* info) const;
PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const
{ {
if(race >= MAX_RACES) return NULL; if (race >= MAX_RACES) return NULL;
if(class_ >= MAX_CLASSES) return NULL; if (class_ >= MAX_CLASSES) return NULL;
PlayerInfo const* info = &playerInfo[race][class_]; PlayerInfo const* info = &playerInfo[race][class_];
if(info->displayId_m==0 || info->displayId_f==0) return NULL; if (info->displayId_m==0 || info->displayId_f==0) return NULL;
return info; return info;
} }
void GetPlayerLevelInfo(uint32 race, uint32 class_,uint32 level, PlayerLevelInfo* info) const; void GetPlayerLevelInfo(uint32 race, uint32 class_,uint32 level, PlayerLevelInfo* info) const;
ObjectGuid GetPlayerGuidByName(std::string name) const; ObjectGuid GetPlayerGuidByName(std::string name) const;
bool GetPlayerNameByGUID(ObjectGuid guid, std::string &name) const; bool GetPlayerNameByGUID(ObjectGuid guid, std::string& name) const;
Team GetPlayerTeamByGUID(ObjectGuid guid) const; Team GetPlayerTeamByGUID(ObjectGuid guid) const;
uint32 GetPlayerAccountIdByGUID(ObjectGuid guid) const; uint32 GetPlayerAccountIdByGUID(ObjectGuid guid) const;
uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const; uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const;
uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid, Team team ); uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, Team team);
void GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost); void GetTaxiPath(uint32 source, uint32 destination, uint32& path, uint32& cost);
uint32 GetTaxiMountDisplayId( uint32 id, Team team, bool allowed_alt_team = false); uint32 GetTaxiMountDisplayId(uint32 id, Team team, bool allowed_alt_team = false);
Quest const* GetQuestTemplate(uint32 quest_id) const Quest const* GetQuestTemplate(uint32 quest_id) const
{ {
@ -545,7 +546,7 @@ class ObjectMgr
uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const
{ {
QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID); QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID);
if(itr != mQuestAreaTriggerMap.end()) if (itr != mQuestAreaTriggerMap.end())
return itr->second; return itr->second;
return 0; return 0;
} }
@ -569,8 +570,8 @@ class ObjectMgr
AreaTrigger const* GetAreaTrigger(uint32 trigger) const AreaTrigger const* GetAreaTrigger(uint32 trigger) const
{ {
AreaTriggerMap::const_iterator itr = mAreaTriggers.find( trigger ); AreaTriggerMap::const_iterator itr = mAreaTriggers.find(trigger);
if( itr != mAreaTriggers.end( ) ) if (itr != mAreaTriggers.end())
return &itr->second; return &itr->second;
return NULL; return NULL;
} }
@ -590,7 +591,7 @@ class ObjectMgr
ReputationOnKillEntry const* GetReputationOnKillEntry(uint32 id) const ReputationOnKillEntry const* GetReputationOnKillEntry(uint32 id) const
{ {
RepOnKillMap::const_iterator itr = mRepOnKill.find(id); RepOnKillMap::const_iterator itr = mRepOnKill.find(id);
if(itr != mRepOnKill.end()) if (itr != mRepOnKill.end())
return &itr->second; return &itr->second;
return NULL; return NULL;
} }
@ -607,7 +608,7 @@ class ObjectMgr
PointOfInterest const* GetPointOfInterest(uint32 id) const PointOfInterest const* GetPointOfInterest(uint32 id) const
{ {
PointOfInterestMap::const_iterator itr = mPointsOfInterest.find(id); PointOfInterestMap::const_iterator itr = mPointsOfInterest.find(id);
if(itr != mPointsOfInterest.end()) if (itr != mPointsOfInterest.end())
return &itr->second; return &itr->second;
return NULL; return NULL;
} }
@ -615,7 +616,7 @@ class ObjectMgr
QuestPOIVector const* GetQuestPOIVector(uint32 questId) QuestPOIVector const* GetQuestPOIVector(uint32 questId)
{ {
QuestPOIMap::const_iterator itr = mQuestPOIMap.find(questId); QuestPOIMap::const_iterator itr = mQuestPOIMap.find(questId);
if(itr != mQuestPOIMap.end()) if (itr != mQuestPOIMap.end())
return &itr->second; return &itr->second;
return NULL; return NULL;
} }
@ -759,7 +760,7 @@ class ObjectMgr
if (map_itr == m_mailLevelRewardMap.end()) if (map_itr == m_mailLevelRewardMap.end())
return NULL; return NULL;
for(MailLevelRewardList::const_iterator set_itr = map_itr->second.begin(); set_itr != map_itr->second.end(); ++set_itr) for (MailLevelRewardList::const_iterator set_itr = map_itr->second.begin(); set_itr != map_itr->second.end(); ++set_itr)
if (set_itr->raceMask & raceMask) if (set_itr->raceMask & raceMask)
return &*set_itr; return &*set_itr;
@ -769,7 +770,7 @@ class ObjectMgr
WeatherZoneChances const* GetWeatherChances(uint32 zone_id) const WeatherZoneChances const* GetWeatherChances(uint32 zone_id) const
{ {
WeatherZoneMap::const_iterator itr = mWeatherZoneMap.find(zone_id); WeatherZoneMap::const_iterator itr = mWeatherZoneMap.find(zone_id);
if(itr != mWeatherZoneMap.end()) if (itr != mWeatherZoneMap.end())
return &itr->second; return &itr->second;
else else
return NULL; return NULL;
@ -778,7 +779,7 @@ class ObjectMgr
CreatureDataPair const* GetCreatureDataPair(uint32 guid) const CreatureDataPair const* GetCreatureDataPair(uint32 guid) const
{ {
CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid); CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid);
if(itr==mCreatureDataMap.end()) return NULL; if (itr==mCreatureDataMap.end()) return NULL;
return &*itr; return &*itr;
} }
@ -802,7 +803,7 @@ class ObjectMgr
CreatureLocale const* GetCreatureLocale(uint32 entry) const CreatureLocale const* GetCreatureLocale(uint32 entry) const
{ {
CreatureLocaleMap::const_iterator itr = mCreatureLocaleMap.find(entry); CreatureLocaleMap::const_iterator itr = mCreatureLocaleMap.find(entry);
if(itr==mCreatureLocaleMap.end()) return NULL; if (itr==mCreatureLocaleMap.end()) return NULL;
return &itr->second; return &itr->second;
} }
@ -811,14 +812,14 @@ class ObjectMgr
GameObjectLocale const* GetGameObjectLocale(uint32 entry) const GameObjectLocale const* GetGameObjectLocale(uint32 entry) const
{ {
GameObjectLocaleMap::const_iterator itr = mGameObjectLocaleMap.find(entry); GameObjectLocaleMap::const_iterator itr = mGameObjectLocaleMap.find(entry);
if(itr==mGameObjectLocaleMap.end()) return NULL; if (itr==mGameObjectLocaleMap.end()) return NULL;
return &itr->second; return &itr->second;
} }
ItemLocale const* GetItemLocale(uint32 entry) const ItemLocale const* GetItemLocale(uint32 entry) const
{ {
ItemLocaleMap::const_iterator itr = mItemLocaleMap.find(entry); ItemLocaleMap::const_iterator itr = mItemLocaleMap.find(entry);
if(itr==mItemLocaleMap.end()) return NULL; if (itr==mItemLocaleMap.end()) return NULL;
return &itr->second; return &itr->second;
} }
@ -827,7 +828,7 @@ class ObjectMgr
QuestLocale const* GetQuestLocale(uint32 entry) const QuestLocale const* GetQuestLocale(uint32 entry) const
{ {
QuestLocaleMap::const_iterator itr = mQuestLocaleMap.find(entry); QuestLocaleMap::const_iterator itr = mQuestLocaleMap.find(entry);
if(itr==mQuestLocaleMap.end()) return NULL; if (itr==mQuestLocaleMap.end()) return NULL;
return &itr->second; return &itr->second;
} }
@ -836,39 +837,39 @@ class ObjectMgr
NpcTextLocale const* GetNpcTextLocale(uint32 entry) const NpcTextLocale const* GetNpcTextLocale(uint32 entry) const
{ {
NpcTextLocaleMap::const_iterator itr = mNpcTextLocaleMap.find(entry); NpcTextLocaleMap::const_iterator itr = mNpcTextLocaleMap.find(entry);
if(itr==mNpcTextLocaleMap.end()) return NULL; if (itr==mNpcTextLocaleMap.end()) return NULL;
return &itr->second; return &itr->second;
} }
typedef std::string NpcTextArray[MAX_GOSSIP_TEXT_OPTIONS]; typedef std::string NpcTextArray[MAX_GOSSIP_TEXT_OPTIONS];
void GetNpcTextLocaleStringsAll(uint32 entry, int32 loc_idx, NpcTextArray *text0_Ptr, NpcTextArray* text1_Ptr) const; void GetNpcTextLocaleStringsAll(uint32 entry, int32 loc_idx, NpcTextArray* text0_Ptr, NpcTextArray* text1_Ptr) const;
void GetNpcTextLocaleStrings0(uint32 entry, int32 loc_idx, std::string* text0_0_Ptr, std::string* text1_0_Ptr) const; void GetNpcTextLocaleStrings0(uint32 entry, int32 loc_idx, std::string* text0_0_Ptr, std::string* text1_0_Ptr) const;
PageTextLocale const* GetPageTextLocale(uint32 entry) const PageTextLocale const* GetPageTextLocale(uint32 entry) const
{ {
PageTextLocaleMap::const_iterator itr = mPageTextLocaleMap.find(entry); PageTextLocaleMap::const_iterator itr = mPageTextLocaleMap.find(entry);
if(itr==mPageTextLocaleMap.end()) return NULL; if (itr==mPageTextLocaleMap.end()) return NULL;
return &itr->second; return &itr->second;
} }
GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const
{ {
GossipMenuItemsLocaleMap::const_iterator itr = mGossipMenuItemsLocaleMap.find(entry); GossipMenuItemsLocaleMap::const_iterator itr = mGossipMenuItemsLocaleMap.find(entry);
if(itr==mGossipMenuItemsLocaleMap.end()) return NULL; if (itr==mGossipMenuItemsLocaleMap.end()) return NULL;
return &itr->second; return &itr->second;
} }
PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const
{ {
PointOfInterestLocaleMap::const_iterator itr = mPointOfInterestLocaleMap.find(poi_id); PointOfInterestLocaleMap::const_iterator itr = mPointOfInterestLocaleMap.find(poi_id);
if(itr==mPointOfInterestLocaleMap.end()) return NULL; if (itr==mPointOfInterestLocaleMap.end()) return NULL;
return &itr->second; return &itr->second;
} }
GameObjectDataPair const* GetGODataPair(uint32 guid) const GameObjectDataPair const* GetGODataPair(uint32 guid) const
{ {
GameObjectDataMap::const_iterator itr = mGameObjectDataMap.find(guid); GameObjectDataMap::const_iterator itr = mGameObjectDataMap.find(guid);
if(itr==mGameObjectDataMap.end()) return NULL; if (itr==mGameObjectDataMap.end()) return NULL;
return &*itr; return &*itr;
} }
@ -892,12 +893,12 @@ class ObjectMgr
MangosStringLocale const* GetMangosStringLocale(int32 entry) const MangosStringLocale const* GetMangosStringLocale(int32 entry) const
{ {
MangosStringLocaleMap::const_iterator itr = mMangosStringLocaleMap.find(entry); MangosStringLocaleMap::const_iterator itr = mMangosStringLocaleMap.find(entry);
if(itr==mMangosStringLocaleMap.end()) return NULL; if (itr==mMangosStringLocaleMap.end()) return NULL;
return &itr->second; return &itr->second;
} }
const char *GetMangosString(int32 entry, int locale_idx) const; const char* GetMangosString(int32 entry, int locale_idx) const;
const char *GetMangosStringForDBCLocale(int32 entry) const { return GetMangosString(entry,DBCLocaleIndex); } const char* GetMangosStringForDBCLocale(int32 entry) const { return GetMangosString(entry,DBCLocaleIndex); }
int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; } int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; }
void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); } void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); }
@ -921,9 +922,9 @@ class ObjectMgr
bool IsReservedName(const std::string& name) const; bool IsReservedName(const std::string& name) const;
// name with valid structure and symbols // name with valid structure and symbols
static uint8 CheckPlayerName( const std::string& name, bool create = false ); static uint8 CheckPlayerName(const std::string& name, bool create = false);
static PetNameInvalidReason CheckPetName( const std::string& name ); static PetNameInvalidReason CheckPetName(const std::string& name);
static bool IsValidCharterName( const std::string& name ); static bool IsValidCharterName(const std::string& name);
static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names); static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names);
@ -934,7 +935,7 @@ class ObjectMgr
uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2); uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2);
bool IsPlayerMeetToCondition(Player const* player, uint16 condition_id) const bool IsPlayerMeetToCondition(Player const* player, uint16 condition_id) const
{ {
if(condition_id >= mConditions.size()) if (condition_id >= mConditions.size())
return false; return false;
return mConditions[condition_id].Meets(player); return mConditions[condition_id].Meets(player);
@ -946,7 +947,7 @@ class ObjectMgr
GameTele const* GetGameTele(uint32 id) const GameTele const* GetGameTele(uint32 id) const
{ {
GameTeleMap::const_iterator itr = m_GameTeleMap.find(id); GameTeleMap::const_iterator itr = m_GameTeleMap.find(id);
if(itr==m_GameTeleMap.end()) return NULL; if (itr==m_GameTeleMap.end()) return NULL;
return &itr->second; return &itr->second;
} }
@ -958,7 +959,7 @@ class ObjectMgr
uint32 GetNpcGossip(uint32 entry) const uint32 GetNpcGossip(uint32 entry) const
{ {
CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry); CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry);
if(iter == m_mCacheNpcTextIdMap.end()) if (iter == m_mCacheNpcTextIdMap.end())
return 0; return 0;
return iter->second; return iter->second;
@ -967,7 +968,7 @@ class ObjectMgr
TrainerSpellData const* GetNpcTrainerSpells(uint32 entry) const TrainerSpellData const* GetNpcTrainerSpells(uint32 entry) const
{ {
CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry); CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry);
if(iter == m_mCacheTrainerSpellMap.end()) if (iter == m_mCacheTrainerSpellMap.end())
return NULL; return NULL;
return &iter->second; return &iter->second;
@ -976,7 +977,7 @@ class ObjectMgr
TrainerSpellData const* GetNpcTrainerTemplateSpells(uint32 entry) const TrainerSpellData const* GetNpcTrainerTemplateSpells(uint32 entry) const
{ {
CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerTemplateSpellMap.find(entry); CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerTemplateSpellMap.find(entry);
if(iter == m_mCacheTrainerTemplateSpellMap.end()) if (iter == m_mCacheTrainerTemplateSpellMap.end())
return NULL; return NULL;
return &iter->second; return &iter->second;
@ -985,7 +986,7 @@ class ObjectMgr
VendorItemData const* GetNpcVendorItemList(uint32 entry) const VendorItemData const* GetNpcVendorItemList(uint32 entry) const
{ {
CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry); CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry);
if(iter == m_mCacheVendorItemMap.end()) if (iter == m_mCacheVendorItemMap.end())
return NULL; return NULL;
return &iter->second; return &iter->second;
@ -994,7 +995,7 @@ class ObjectMgr
VendorItemData const* GetNpcVendorTemplateItemList(uint32 entry) const VendorItemData const* GetNpcVendorTemplateItemList(uint32 entry) const
{ {
CacheVendorItemMap::const_iterator iter = m_mCacheVendorTemplateItemMap.find(entry); CacheVendorItemMap::const_iterator iter = m_mCacheVendorTemplateItemMap.find(entry);
if(iter == m_mCacheVendorTemplateItemMap.end()) if (iter == m_mCacheVendorTemplateItemMap.end())
return NULL; return NULL;
return &iter->second; return &iter->second;

View file

@ -103,7 +103,7 @@ bool ObjectPosSelector::CheckOriginalAngle() const
{ {
// check first left/right used angles if exists // check first left/right used angles if exists
return (m_UsedAreaLists[USED_POS_PLUS].empty() || CheckAngle(*m_UsedAreaLists[USED_POS_PLUS].begin(), USED_POS_PLUS, 0.0f)) && return (m_UsedAreaLists[USED_POS_PLUS].empty() || CheckAngle(*m_UsedAreaLists[USED_POS_PLUS].begin(), USED_POS_PLUS, 0.0f)) &&
(m_UsedAreaLists[USED_POS_MINUS].empty() || CheckAngle(*m_UsedAreaLists[USED_POS_MINUS].begin(), USED_POS_MINUS, 0.0f)); (m_UsedAreaLists[USED_POS_MINUS].empty() || CheckAngle(*m_UsedAreaLists[USED_POS_MINUS].begin(), USED_POS_MINUS, 0.0f));
} }
/** /**
@ -180,7 +180,7 @@ void ObjectPosSelector::UpdateNextAreaStart(UsedAreaSide side)
bool ObjectPosSelector::NextAngle(float& angle) bool ObjectPosSelector::NextAngle(float& angle)
{ {
// loop until both side fail and leave 0..PI // loop until both side fail and leave 0..PI
for(;;) for (;;)
{ {
// ++ direction less updated // ++ direction less updated
if (m_stepAngle[USED_POS_PLUS] < M_PI_F && m_stepAngle[USED_POS_PLUS] <= m_stepAngle[USED_POS_MINUS]) if (m_stepAngle[USED_POS_PLUS] < M_PI_F && m_stepAngle[USED_POS_PLUS] <= m_stepAngle[USED_POS_MINUS])
@ -212,7 +212,7 @@ bool ObjectPosSelector::NextAngle(float& angle)
* @return true, if angle found * @return true, if angle found
* *
*/ */
bool ObjectPosSelector::NextSideAngle(UsedAreaSide side, float &angle ) bool ObjectPosSelector::NextSideAngle(UsedAreaSide side, float& angle)
{ {
// next possible angle // next possible angle
m_stepAngle[side] += (m_searcherHalfSize + 0.01); m_stepAngle[side] += (m_searcherHalfSize + 0.01);
@ -254,13 +254,13 @@ bool ObjectPosSelector::NextSideAngle(UsedAreaSide side, float &angle )
bool ObjectPosSelector::NextUsedAngle(float& angle) bool ObjectPosSelector::NextUsedAngle(float& angle)
{ {
if (m_nextUsedAreaItr[USED_POS_PLUS] == m_UsedAreaLists[USED_POS_PLUS].end() && if (m_nextUsedAreaItr[USED_POS_PLUS] == m_UsedAreaLists[USED_POS_PLUS].end() &&
m_nextUsedAreaItr[USED_POS_MINUS] == m_UsedAreaLists[USED_POS_MINUS].end()) m_nextUsedAreaItr[USED_POS_MINUS] == m_UsedAreaLists[USED_POS_MINUS].end())
return false; return false;
// ++ direction less updated // ++ direction less updated
if (m_nextUsedAreaItr[USED_POS_PLUS] != m_UsedAreaLists[USED_POS_PLUS].end() && if (m_nextUsedAreaItr[USED_POS_PLUS] != m_UsedAreaLists[USED_POS_PLUS].end() &&
(m_nextUsedAreaItr[USED_POS_MINUS] == m_UsedAreaLists[USED_POS_MINUS].end() || (m_nextUsedAreaItr[USED_POS_MINUS] == m_UsedAreaLists[USED_POS_MINUS].end() ||
m_nextUsedAreaItr[USED_POS_PLUS]->first <= m_nextUsedAreaItr[USED_POS_MINUS]->first)) m_nextUsedAreaItr[USED_POS_PLUS]->first <= m_nextUsedAreaItr[USED_POS_MINUS]->first))
{ {
angle = m_nextUsedAreaItr[USED_POS_PLUS]->first * SignOf(USED_POS_PLUS); angle = m_nextUsedAreaItr[USED_POS_PLUS]->first * SignOf(USED_POS_PLUS);
++m_nextUsedAreaItr[USED_POS_PLUS]; ++m_nextUsedAreaItr[USED_POS_PLUS];