From 94795f2bff58ebfde9f1f69350aa7996b7a31a3f Mon Sep 17 00:00:00 2001 From: Schmoozerd Date: Thu, 19 Jul 2012 21:51:08 +0200 Subject: [PATCH] Various Cleanups (game N-O) --- src/game/NPCHandler.cpp | 202 ++-- src/game/NPCHandler.h | 2 +- src/game/NullCreatureAI.h | 10 +- src/game/Object.cpp | 336 +++--- src/game/Object.h | 216 ++-- src/game/ObjectAccessor.cpp | 56 +- src/game/ObjectAccessor.h | 22 +- src/game/ObjectGridLoader.cpp | 88 +- src/game/ObjectGridLoader.h | 44 +- src/game/ObjectGuid.cpp | 6 +- src/game/ObjectGuid.h | 42 +- src/game/ObjectMgr.cpp | 1938 ++++++++++++++++---------------- src/game/ObjectMgr.h | 105 +- src/game/ObjectPosSelector.cpp | 12 +- 14 files changed, 1560 insertions(+), 1519 deletions(-) diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index 23916e9ad..a34974870 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -45,12 +45,12 @@ enum StableResultCode 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; recv_data >> guid; - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TABARDDESIGNER); + Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TABARDDESIGNER); if (!unit) { 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 - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); SendTabardVendorActivate(guid); @@ -66,12 +66,12 @@ void WorldSession::HandleTabardVendorActivateOpcode( WorldPacket & recv_data ) void WorldSession::SendTabardVendorActivate(ObjectGuid guid) { - WorldPacket data( MSG_TABARDVENDOR_ACTIVATE, 8 ); + WorldPacket data(MSG_TABARDVENDOR_ACTIVATE, 8); data << ObjectGuid(guid); SendPacket(&data); } -void WorldSession::HandleBankerActivateOpcode( WorldPacket & recv_data ) +void WorldSession::HandleBankerActivateOpcode(WorldPacket& recv_data) { ObjectGuid guid; @@ -83,7 +83,7 @@ void WorldSession::HandleBankerActivateOpcode( WorldPacket & recv_data ) return; // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); SendShowBank(guid); @@ -103,7 +103,7 @@ void WorldSession::SendShowMailBox(ObjectGuid guid) SendPacket(&data); } -void WorldSession::HandleTrainerListOpcode( WorldPacket & recv_data ) +void WorldSession::HandleTrainerListOpcode(WorldPacket& recv_data) { ObjectGuid guid; @@ -142,9 +142,9 @@ static void SendTrainerSpellHelper(WorldPacket& data, TrainerSpell const* tSpell 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) { 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)) return; - CreatureInfo const *ci = unit->GetCreatureInfo(); + CreatureInfo const* ci = unit->GetCreatureInfo(); if (!ci) 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 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 << uint32(trainer_type); @@ -190,12 +190,12 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle) 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; uint32 reqLevel = 0; - if(!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell, &reqLevel)) + if (!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell, &reqLevel)) continue; 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) { - 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; uint32 reqLevel = 0; - if(!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell, &reqLevel)) + if (!_player->IsSpellFitByClassAndRace(tSpell->learnedSpell, &reqLevel)) continue; 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); } -void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) +void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recv_data) { ObjectGuid guid; uint32 spellId = 0; @@ -242,7 +242,7 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) recv_data >> guid >> 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) { 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... uint32 reqLevel = 0; - if(!_player->IsSpellFitByClassAndRace(trainer_spell->learnedSpell, &reqLevel)) + if (!_player->IsSpellFitByClassAndRace(trainer_spell->learnedSpell, &reqLevel)) return; 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))); // check money requirement - if(_player->GetMoney() < nSpellCost ) + if (_player->GetMoney() < nSpellCost) return; - _player->ModifyMoney( -int32(nSpellCost) ); + _player->ModifyMoney(-int32(nSpellCost)); WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); // visual effect on trainer data << ObjectGuid(guid); @@ -303,7 +303,7 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) SendPacket(&data); // learn explicitly or cast explicitly - if(trainer_spell->IsCastable()) + if (trainer_spell->IsCastable()) _player->CastSpell(_player, trainer_spell->spell, true); else _player->learnSpell(spellId, false); @@ -314,14 +314,14 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data ) SendPacket(&data); } -void WorldSession::HandleGossipHelloOpcode(WorldPacket & recv_data) +void WorldSession::HandleGossipHelloOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Received CMSG_GOSSIP_HELLO"); ObjectGuid guid; recv_data >> guid; - Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); + Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); if (!pCreature) { 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"); @@ -371,7 +371,7 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) if (guid.IsAnyTypeCreature()) { - Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); + Creature* pCreature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE); if (!pCreature) { @@ -384,7 +384,7 @@ void WorldSession::HandleGossipSelectOptionOpcode( WorldPacket & recv_data ) } else if (guid.IsGameObject()) { - GameObject *pGo = GetPlayer()->GetGameObjectIfCanInteractWith(guid); + GameObject* pGo = GetPlayer()->GetGameObjectIfCanInteractWith(guid); 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"); @@ -405,10 +405,10 @@ void WorldSession::HandleSpiritHealerActivateOpcode( WorldPacket & recv_data ) recv_data >> guid; - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_SPIRITHEALER); + Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_SPIRITHEALER); 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; } @@ -426,22 +426,22 @@ void WorldSession::SendSpiritResurrect() _player->DurabilityLossAll(0.25f,true); // get corpse nearest graveyard - WorldSafeLocsEntry const *corpseGrave = NULL; - Corpse *corpse = _player->GetCorpse(); - if(corpse) + WorldSafeLocsEntry const* corpseGrave = NULL; + Corpse* corpse = _player->GetCorpse(); + if (corpse) 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 _player->SpawnCorpseBones(); // teleport to nearest from corpse graveyard, if different from nearest to player ghost - if(corpseGrave) + if (corpseGrave) { - WorldSafeLocsEntry const *ghostGrave = sObjectMgr.GetClosestGraveYard( - _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeam()); + WorldSafeLocsEntry const* ghostGrave = sObjectMgr.GetClosestGraveYard( + _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()); // or update at original position else @@ -458,15 +458,15 @@ void WorldSession::SendSpiritResurrect() } } -void WorldSession::HandleBinderActivateOpcode( WorldPacket & recv_data ) +void WorldSession::HandleBinderActivateOpcode(WorldPacket& recv_data) { ObjectGuid npcGuid; recv_data >> npcGuid; - if(!GetPlayer()->IsInWorld() || !GetPlayer()->isAlive()) + if (!GetPlayer()->IsInWorld() || !GetPlayer()->isAlive()) return; - Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(npcGuid,UNIT_NPC_FLAG_INNKEEPER); + Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(npcGuid,UNIT_NPC_FLAG_INNKEEPER); if (!unit) { 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 - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); SendBindPoint(unit); } -void WorldSession::SendBindPoint(Creature *npc) +void WorldSession::SendBindPoint(Creature* npc) { // prevent set homebind to instances in any case - if(GetPlayer()->GetMap()->Instanceable()) + if (GetPlayer()->GetMap()->Instanceable()) return; // send spell for bind 3286 bind magic 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 << uint32(3286); // Bind - SendPacket( &data ); + SendPacket(&data); _player->PlayerTalkClass->CloseGossip(); } -void WorldSession::HandleListStabledPetsOpcode( WorldPacket & recv_data ) +void WorldSession::HandleListStabledPetsOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recv MSG_LIST_STABLED_PETS"); ObjectGuid npcGUID; @@ -511,20 +511,20 @@ void WorldSession::HandleListStabledPetsOpcode( WorldPacket & recv_data ) } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); SendStablePet(npcGUID); } -void WorldSession::SendStablePet( ObjectGuid guid ) +void WorldSession::SendStablePet(ObjectGuid guid) { DEBUG_LOG("WORLD: Recv MSG_LIST_STABLED_PETS Send."); WorldPacket data(MSG_LIST_STABLED_PETS, 200); // guess size data << guid; - Pet *pet = _player->GetPet(); + Pet* pet = _player->GetPet(); size_t wpos = data.wpos(); 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 // 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->GetEntry()); @@ -546,13 +546,13 @@ void WorldSession::SendStablePet( ObjectGuid guid ) // 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", - _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 { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); data << uint32(fields[1].GetUInt32()); // petnumber 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) ++num; - }while( result->NextRow() ); + } + while (result->NextRow()); delete result; } @@ -602,14 +603,14 @@ bool WorldSession::CheckStableMaster(ObjectGuid guid) return true; } -void WorldSession::HandleStablePet( WorldPacket & recv_data ) +void WorldSession::HandleStablePet(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recv CMSG_STABLE_PET"); ObjectGuid npcGUID; recv_data >> npcGUID; - if(!GetPlayer()->isAlive()) + if (!GetPlayer()->isAlive()) { SendStableResult(STABLE_ERR_STABLE); return; @@ -622,13 +623,13 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data ) } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); - Pet *pet = _player->GetPet(); + Pet* pet = _player->GetPet(); // 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); return; @@ -636,28 +637,29 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data ) 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 ", - _player->GetGUIDLow(),PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT); - if(result) + 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); + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 slot = fields[1].GetUInt32(); // slots ordered in query, and if not equal then free - if(slot!=free_slot) + if (slot!=free_slot) break; // this slot not free, skip ++free_slot; - }while( result->NextRow() ); + } + while (result->NextRow()); 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); SendStableResult(STABLE_SUCCESS_STABLE); @@ -666,7 +668,7 @@ void WorldSession::HandleStablePet( WorldPacket & recv_data ) SendStableResult(STABLE_ERR_STABLE); } -void WorldSession::HandleUnstablePet( WorldPacket & recv_data ) +void WorldSession::HandleUnstablePet(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recv CMSG_UNSTABLE_PET."); ObjectGuid npcGUID; @@ -681,30 +683,30 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data ) } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); 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'", - _player->GetGUIDLow(),petnumber,PET_SAVE_FIRST_STABLE_SLOT,PET_SAVE_LAST_STABLE_SLOT); - if(result) + 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); + if (result) { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); creature_id = fields[0].GetUInt32(); delete result; } } - if(!creature_id) + if (!creature_id) { SendStableResult(STABLE_ERR_STABLE); return; } 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 (creatureInfo && creatureInfo->isTameable(true)) @@ -715,18 +717,18 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data ) } Pet* pet = _player->GetPet(); - if(pet && pet->isAlive()) + if (pet && pet->isAlive()) { SendStableResult(STABLE_ERR_STABLE); return; } // delete dead pet - if(pet) + if (pet) pet->Unsummon(PET_SAVE_AS_DELETED, _player); - Pet *newpet = new Pet(HUNTER_PET); - if(!newpet->LoadPetFromDB(_player,creature_id,petnumber)) + Pet* newpet = new Pet(HUNTER_PET); + if (!newpet->LoadPetFromDB(_player,creature_id,petnumber)) { delete newpet; newpet = NULL; @@ -737,7 +739,7 @@ void WorldSession::HandleUnstablePet( WorldPacket & recv_data ) SendStableResult(STABLE_SUCCESS_UNSTABLE); } -void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data ) +void WorldSession::HandleBuyStableSlot(WorldPacket& recv_data) { DEBUG_LOG("WORLD: Recv CMSG_BUY_STABLE_SLOT."); ObjectGuid npcGUID; @@ -751,13 +753,13 @@ void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data ) } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) 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); - if(_player->GetMoney() >= SlotPrice->Price) + StableSlotPricesEntry const* SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots+1); + if (_player->GetMoney() >= SlotPrice->Price) { ++GetPlayer()->m_stableSlots; _player->ModifyMoney(-int32(SlotPrice->Price)); @@ -770,12 +772,12 @@ void WorldSession::HandleBuyStableSlot( WorldPacket & recv_data ) SendStableResult(STABLE_ERR_STABLE); } -void WorldSession::HandleStableRevivePet( WorldPacket &/* recv_data */) +void WorldSession::HandleStableRevivePet(WorldPacket& /* recv_data */) { 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."); ObjectGuid npcGUID; @@ -790,41 +792,41 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data ) } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); Pet* pet = _player->GetPet(); - if(!pet || pet->getPetType()!=HUNTER_PET) + if (!pet || pet->getPetType()!=HUNTER_PET) { SendStableResult(STABLE_ERR_STABLE); return; } // find swapped pet slot in stable - QueryResult *result = CharacterDatabase.PQuery("SELECT slot,entry FROM character_pet WHERE owner = '%u' AND id = '%u'", - _player->GetGUIDLow(),pet_number); - if(!result) + QueryResult* result = CharacterDatabase.PQuery("SELECT slot,entry FROM character_pet WHERE owner = '%u' AND id = '%u'", + _player->GetGUIDLow(),pet_number); + if (!result) { SendStableResult(STABLE_ERR_STABLE); return; } - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 slot = fields[0].GetUInt32(); uint32 creature_id = fields[1].GetUInt32(); delete result; - if(!creature_id) + if (!creature_id) { SendStableResult(STABLE_ERR_STABLE); return; } 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 (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); // summon unstabled pet - Pet *newpet = new Pet; - if(!newpet->LoadPetFromDB(_player,creature_id,pet_number)) + Pet* newpet = new Pet; + if (!newpet->LoadPetFromDB(_player,creature_id,pet_number)) { delete newpet; SendStableResult(STABLE_ERR_STABLE); @@ -848,7 +850,7 @@ void WorldSession::HandleStableSwapPet( WorldPacket & recv_data ) SendStableResult(STABLE_SUCCESS_UNSTABLE); } -void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data ) +void WorldSession::HandleRepairItemOpcode(WorldPacket& recv_data) { DEBUG_LOG("WORLD: CMSG_REPAIR_ITEM"); @@ -858,15 +860,15 @@ void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data ) 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) { - 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; } // remove fake death - if(GetPlayer()->hasUnitState(UNIT_STAT_DIED)) + if (GetPlayer()->hasUnitState(UNIT_STAT_DIED)) GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); // reputation discount @@ -879,7 +881,7 @@ void WorldSession::HandleRepairItemOpcode( WorldPacket & recv_data ) Item* item = _player->GetItemByGuid(itemGuid); - if(item) + if (item) TotalCost= _player->DurabilityRepair(item->GetPos(), true, discountMod, (guildBank > 0)); } else diff --git a/src/game/NPCHandler.h b/src/game/NPCHandler.h index 719f16b05..5c7571cdb 100644 --- a/src/game/NPCHandler.h +++ b/src/game/NPCHandler.h @@ -29,7 +29,7 @@ struct PageText { uint32 Page_ID; - char * Text; + char* Text; uint32 Next_Page; }; diff --git a/src/game/NullCreatureAI.h b/src/game/NullCreatureAI.h index 1a336754f..990cd2239 100644 --- a/src/game/NullCreatureAI.h +++ b/src/game/NullCreatureAI.h @@ -28,14 +28,14 @@ class MANGOS_DLL_DECL NullCreatureAI : public CreatureAI explicit NullCreatureAI(Creature* c) : CreatureAI(c) {} ~NullCreatureAI(); - void MoveInLineOfSight(Unit *) {} - void AttackStart(Unit *) {} - void AttackedBy( Unit *) {} + void MoveInLineOfSight(Unit*) {} + void AttackStart(Unit*) {} + void AttackedBy(Unit*) {} void EnterEvadeMode() {} - bool IsVisible(Unit *) const { return false; } + bool IsVisible(Unit*) const { return false; } void UpdateAI(const uint32) {} - static int Permissible(const Creature *) { return PERMIT_BASE_IDLE; } + static int Permissible(const Creature*) { return PERMIT_BASE_IDLE; } }; #endif diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 970528500..ba487ee97 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -43,7 +43,7 @@ #include "TemporarySummon.h" #include "movement/packet_builder.h" -Object::Object( ) +Object::Object() { m_objectTypeId = TYPEID_OBJECT; m_objectType = TYPEMASK_OBJECT; @@ -56,22 +56,22 @@ Object::Object( ) 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 sLog.outError("Object::~Object (GUID: %u TypeId: %u) deleted but still in world!!", GetGUIDLow(), GetTypeId()); 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()); MANGOS_ASSERT(false); } - if(m_uint32Values) + if (m_uint32Values) { //DEBUG_LOG("Object desctr 1 check (%p)",(void*)this); delete [] m_uint32Values; @@ -93,7 +93,7 @@ void Object::_InitValues() void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh) { - if(!m_uint32Values) + if (!m_uint32Values) _InitValues(); ObjectGuid guid = ObjectGuid(guidhigh, entry, guidlow); @@ -118,7 +118,7 @@ void Object::SendForcedObjectUpdate() RemoveFromClientUpdateList(); 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->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); @@ -138,19 +138,19 @@ void Object::BuildMovementUpdateBlock(UpdateData * data, uint16 flags ) const data->AddUpdateBlock(buf); } -void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const +void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const { - if(!target) + if (!target) return; uint8 updatetype = UPDATETYPE_CREATE_OBJECT; uint16 updateFlags = m_updateFlag; /** lower flag1 **/ - if(target == this) // building packet for yourself + if (target == this) // building packet for yourself updateFlags |= UPDATEFLAG_SELF; - if(updateFlags & UPDATEFLAG_HAS_POSITION) + if (updateFlags & UPDATEFLAG_HAS_POSITION) { // UPDATETYPE_CREATE_OBJECT2 dynamic objects, corpses... 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... if (isType(TYPEMASK_GAMEOBJECT)) { - switch(((GameObject*)this)->GetGoType()) + switch (((GameObject*)this)->GetGoType()) { case GAMEOBJECT_TYPE_TRAP: 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; } } @@ -213,7 +213,7 @@ void Object::SendCreateUpdateToPlayer(Player* player) player->GetSession()->SendPacket(&packet); } -void Object::BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target) const +void Object::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) const { ByteBuffer buf(500); @@ -229,12 +229,12 @@ void Object::BuildValuesUpdateBlockForPlayer(UpdateData *data, Player *target) c data->AddUpdateBlock(buf); } -void Object::BuildOutOfRangeUpdateBlock(UpdateData * data) const +void Object::BuildOutOfRangeUpdateBlock(UpdateData* data) const { data->AddOutOfRangeGUID(GetObjectGuid()); } -void Object::DestroyForPlayer( Player *target, bool anim ) const +void Object::DestroyForPlayer(Player* target, bool anim) const { MANGOS_ASSERT(target); @@ -244,7 +244,7 @@ void Object::DestroyForPlayer( Player *target, bool anim ) const 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); @@ -253,12 +253,12 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const // 0x20 if (updateFlags & UPDATEFLAG_LIVING) { - Unit *unit = ((Unit*)this); + Unit* unit = ((Unit*)this); if (GetTypeId() == TYPEID_PLAYER) { - Player *player = ((Player*)unit); - if(player->GetTransport()) + Player* player = ((Player*)unit); + if (player->GetTransport()) player->m_movementInfo.AddMovementFlag(MOVEFLAG_ONTRANSPORT); else player->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ONTRANSPORT); @@ -286,7 +286,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const } else { - if(updateFlags & UPDATEFLAG_POSITION) + if (updateFlags & UPDATEFLAG_POSITION) { *data << uint8(0); // unk PGUID! *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)->GetOrientation()); - if(GetTypeId() == TYPEID_CORPSE) + if (GetTypeId() == TYPEID_CORPSE) *data << float(((WorldObject*)this)->GetOrientation()); else *data << float(0); @@ -308,28 +308,28 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const if (updateFlags & UPDATEFLAG_HAS_POSITION) { // 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(((WorldObject *)this)->GetOrientation()); + *data << float(((WorldObject*)this)->GetOrientation()); } else { - *data << float(((WorldObject *)this)->GetPositionX()); - *data << float(((WorldObject *)this)->GetPositionY()); - *data << float(((WorldObject *)this)->GetPositionZ()); - *data << float(((WorldObject *)this)->GetOrientation()); + *data << float(((WorldObject*)this)->GetPositionX()); + *data << float(((WorldObject*)this)->GetPositionY()); + *data << float(((WorldObject*)this)->GetPositionZ()); + *data << float(((WorldObject*)this)->GetOrientation()); } } } } // 0x8 - if(updateFlags & UPDATEFLAG_LOWGUID) + if (updateFlags & UPDATEFLAG_LOWGUID) { - switch(GetTypeId()) + switch (GetTypeId()) { case TYPEID_OBJECT: case TYPEID_ITEM: @@ -343,7 +343,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const *data << uint32(0x0000000B); // unk, can be 0xB or 0xC break; case TYPEID_PLAYER: - if(updateFlags & UPDATEFLAG_SELF) + if (updateFlags & UPDATEFLAG_SELF) *data << uint32(0x0000002F); // unk, can be 0x15 or 0x22 else *data << uint32(0x00000008); // unk, can be 0x7 or 0x8 @@ -355,9 +355,9 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const } // 0x10 - if(updateFlags & UPDATEFLAG_HIGHGUID) + if (updateFlags & UPDATEFLAG_HIGHGUID) { - switch(GetTypeId()) + switch (GetTypeId()) { case TYPEID_OBJECT: case TYPEID_ITEM: @@ -371,7 +371,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const *data << uint32(0x0000000B); // unk, can be 0xB or 0xC break; case TYPEID_PLAYER: - if(updateFlags & UPDATEFLAG_SELF) + if (updateFlags & UPDATEFLAG_SELF) *data << uint32(0x0000002F); // unk, can be 0x15 or 0x22 else *data << uint32(0x00000008); // unk, can be 0x7 or 0x8 @@ -383,7 +383,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const } // 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()) *data << ((Unit*)this)->getVictim()->GetPackGUID(); @@ -392,7 +392,7 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const } // 0x2 - if(updateFlags & UPDATEFLAG_TRANSPORT) + if (updateFlags & UPDATEFLAG_TRANSPORT) { *data << uint32(WorldTimer::getMSTime()); // ms time } @@ -405,13 +405,13 @@ void Object::BuildMovementUpdate(ByteBuffer * data, uint16 updateFlags) const } // 0x200 - if(updateFlags & UPDATEFLAG_ROTATION) + if (updateFlags & UPDATEFLAG_ROTATION) { *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) return; @@ -465,7 +465,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask * // 2 specialized loops for speed optimization in non-unit 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)) { @@ -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 else if ((index >= UNIT_FIELD_NEGSTAT0 && index <= UNIT_FIELD_NEGSTAT4) || - (index >= UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + 6)) || - (index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) || - (index >= UNIT_FIELD_POSSTAT0 && index <= UNIT_FIELD_POSSTAT4)) + (index >= UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE + 6)) || + (index >= UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE && index <= (UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE + 6)) || + (index >= UNIT_FIELD_POSSTAT0 && index <= UNIT_FIELD_POSSTAT4)) { *data << uint32(m_floatValues[index]); } @@ -551,7 +551,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask * } 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)) { @@ -563,7 +563,7 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask * if (IsActivateToQuest) { - switch(((GameObject*)this)->GetGoType()) + switch (((GameObject*)this)->GetGoType()) { case GAMEOBJECT_TYPE_QUESTGIVER: // 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) { - for(uint16 index = 0; index < m_valuesCount; ++index) + for (uint16 index = 0; index < m_valuesCount; ++index) { if (updateMask->GetBit(index)) { @@ -611,18 +611,18 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask * 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]; } } - if(m_objectUpdated) + if (m_objectUpdated) { - if(remove) + if (remove) RemoveFromClientUpdateList(); m_objectUpdated = false; } @@ -630,11 +630,11 @@ void Object::ClearUpdateMask(bool remove) bool Object::LoadValues(const char* data) { - if(!m_uint32Values) _InitValues(); + if (!m_uint32Values) _InitValues(); Tokens tokens = StrSplit(data, " "); - if(tokens.size() != m_valuesCount) + if (tokens.size() != m_valuesCount) return false; Tokens::iterator iter; @@ -647,50 +647,50 @@ bool Object::LoadValues(const char* data) 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); } } -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); } } -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; 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; 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 ) ); - if(*((uint64*)&(m_uint32Values[ index ])) != value) + MANGOS_ASSERT(index + 1 < m_valuesCount || PrintIndexError(index, true)); + if (*((uint64*)&(m_uint32Values[ index ])) != value) { m_uint32Values[ index ] = *((uint32*)&value); 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; 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); 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(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); 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(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; 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; SetUInt32Value(index, uint32(value)); @@ -765,7 +765,7 @@ void Object::ApplyModUInt32Value(uint16 index, int32 val, bool apply) { int32 cur = GetUInt32Value(index); cur += (apply ? val : -val); - if(cur < 0) + if (cur < 0) cur = 0; SetUInt32Value(index, cur); } @@ -788,65 +788,65 @@ void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply) { float cur = GetFloatValue(index); cur += (apply ? val : -val); - if(cur < 0) + if (cur < 0) cur = 0; 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 newval = oldval | newFlag; - if(oldval != newval) + if (oldval != newval) { m_uint32Values[ index ] = newval; 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 newval = oldval & ~oldFlag; - if(oldval != newval) + if (oldval != newval) { m_uint32Values[ index ] = newval; 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); 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)); 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); 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)); MarkForClientUpdate(); @@ -898,7 +898,7 @@ void Object::BuildUpdateDataForPlayer(Player* pl, UpdateDataMapType& update_play if (iter == update_players.end()) { - std::pair p = update_players.insert( UpdateDataMapType::value_type(pl, UpdateData()) ); + std::pair p = update_players.insert(UpdateDataMapType::value_type(pl, UpdateData())); MANGOS_ASSERT(p.second); iter = p.first; } @@ -918,7 +918,7 @@ void Object::RemoveFromClientUpdateList() 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); MANGOS_ASSERT(false); @@ -926,9 +926,9 @@ void Object::BuildUpdateData( UpdateDataMapType& /*update_players */) void Object::MarkForClientUpdate() { - if(m_inWorld) + if (m_inWorld) { - if(!m_objectUpdated) + if (!m_objectUpdated) { AddToClientUpdateList(); m_objectUpdated = true; @@ -946,7 +946,7 @@ void WorldObject::CleanupsBeforeDelete() RemoveFromWorld(); } -void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 phaseMask ) +void WorldObject::_Create(uint32 guidlow, HighGuid guidhigh, uint32 phaseMask) { Object::_Create(guidlow, 0, guidhigh); m_phaseMask = phaseMask; @@ -1001,7 +1001,7 @@ InstanceData* WorldObject::GetInstanceData() const return GetMap()->GetInstanceData(); } - //slow +//slow float WorldObject::GetDistance(const WorldObject* obj) const { float dx = GetPositionX() - obj->GetPositionX(); @@ -1009,7 +1009,7 @@ float WorldObject::GetDistance(const WorldObject* obj) const float dz = GetPositionZ() - obj->GetPositionZ(); float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); 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 @@ -1018,7 +1018,7 @@ float WorldObject::GetDistance2d(float x, float y) const float dy = GetPositionY() - y; float sizefactor = GetObjectBoundingRadius(); 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 @@ -1028,7 +1028,7 @@ float WorldObject::GetDistance(float x, float y, float z) const float dz = GetPositionZ() - z; float sizefactor = GetObjectBoundingRadius(); 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 @@ -1037,7 +1037,7 @@ float WorldObject::GetDistance2d(const WorldObject* obj) const float dy = GetPositionY() - obj->GetPositionY(); float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); 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 @@ -1045,7 +1045,7 @@ float WorldObject::GetDistanceZ(const WorldObject* obj) const float dz = fabs(GetPositionZ() - obj->GetPositionZ()); float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); 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 @@ -1078,7 +1078,7 @@ bool WorldObject::_IsWithinDist(WorldObject const* obj, float dist2compare, bool float dx = GetPositionX() - obj->GetPositionX(); float dy = GetPositionY() - obj->GetPositionY(); float distsq = dx*dx + dy*dy; - if(is3D) + if (is3D) { float dz = GetPositionZ() - obj->GetPositionZ(); distsq += dz*dz; @@ -1094,7 +1094,7 @@ bool WorldObject::IsWithinLOSInMap(const WorldObject* obj) const if (!IsInMap(obj)) return false; float 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 @@ -1109,7 +1109,7 @@ bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* o float dx1 = GetPositionX() - obj1->GetPositionX(); float dy1 = GetPositionY() - obj1->GetPositionY(); float distsq1 = dx1*dx1 + dy1*dy1; - if(is3D) + if (is3D) { float dz1 = GetPositionZ() - obj1->GetPositionZ(); distsq1 += dz1*dz1; @@ -1118,7 +1118,7 @@ bool WorldObject::GetDistanceOrder(WorldObject const* obj1, WorldObject const* o float dx2 = GetPositionX() - obj2->GetPositionX(); float dy2 = GetPositionY() - obj2->GetPositionY(); float distsq2 = dx2*dx2 + dy2*dy2; - if(is3D) + if (is3D) { float dz2 = GetPositionZ() - obj2->GetPositionZ(); distsq2 += dz2*dz2; @@ -1132,7 +1132,7 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan float dx = GetPositionX() - obj->GetPositionX(); float dy = GetPositionY() - obj->GetPositionY(); float distsq = dx*dx + dy*dy; - if(is3D) + if (is3D) { float dz = GetPositionZ() - obj->GetPositionZ(); distsq += dz*dz; @@ -1141,10 +1141,10 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan float sizefactor = GetObjectBoundingRadius() + obj->GetObjectBoundingRadius(); // check only for real range - if(minRange > 0.0f) + if (minRange > 0.0f) { float mindist = minRange + sizefactor; - if(distsq < mindist * mindist) + if (distsq < mindist * mindist) return false; } @@ -1161,10 +1161,10 @@ bool WorldObject::IsInRange2d(float x, float y, float minRange, float maxRange) float sizefactor = GetObjectBoundingRadius(); // check only for real range - if(minRange > 0.0f) + if (minRange > 0.0f) { float mindist = minRange + sizefactor; - if(distsq < mindist * mindist) + if (distsq < mindist * mindist) return false; } @@ -1182,10 +1182,10 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m float sizefactor = GetObjectBoundingRadius(); // check only for real range - if(minRange > 0.0f) + if (minRange > 0.0f) { float mindist = minRange + sizefactor; - if(distsq < mindist * mindist) + if (distsq < mindist * mindist) 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 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 { - 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 { - 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 { - 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 { - 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_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 } -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); - 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 } -void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const +void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z) const { switch (GetTypeId()) { @@ -1306,8 +1306,8 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const bool canSwim = ((Creature const*)this)->CanSwim(); float ground_z = z; float max_z = canSwim - ? GetTerrain()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK)) - : ((ground_z = GetTerrain()->GetHeight(x, y, z, true))); + ? GetTerrain()->GetWaterOrGroundLevel(x, y, z, &ground_z, !((Unit const*)this)->HasAuraType(SPELL_AURA_WATER_WALK)) + : ((ground_z = GetTerrain()->GetHeight(x, y, z, true))); if (max_z > INVALID_HEIGHT) { if (z > max_z) @@ -1350,7 +1350,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const default: { float ground_z = GetTerrain()->GetHeight(x, y, z, true); - if(ground_z > INVALID_HEIGHT) + if (ground_z > INVALID_HEIGHT) z = ground_z; break; } @@ -1380,7 +1380,7 @@ void WorldObject::MonsterTextEmote(const char* text, Unit* target, bool IsBossEm { WorldPacket data(SMSG_MESSAGECHAT, 200); 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); } @@ -1391,7 +1391,7 @@ void WorldObject::MonsterWhisper(const char* text, Unit* target, bool IsBossWhis WorldPacket data(SMSG_MESSAGECHAT, 200); 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); } @@ -1444,8 +1444,8 @@ void WorldObject::MonsterYellToZone(int32 textId, uint32 language, Unit* target) uint32 zoneid = GetZoneId(); Map::PlayerList const& pList = GetMap()->GetPlayers(); - for(Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) - if(itr->getSource()->GetZoneId()==zoneid) + for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr) + if (itr->getSource()->GetZoneId()==zoneid) say_do(itr->getSource()); } @@ -1469,12 +1469,12 @@ void WorldObject::MonsterWhisper(int32 textId, Unit* target, bool IsBossWhisper) WorldPacket data(SMSG_MESSAGECHAT, 200); 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); } -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 << uint32(language); @@ -1493,21 +1493,21 @@ void WorldObject::BuildMonsterChat(WorldPacket *data, ObjectGuid senderGuid, uin *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 (IsInWorld()) 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 (IsInWorld()) 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 (IsInWorld()) @@ -1532,7 +1532,7 @@ void WorldObject::SendGameObjectCustomAnim(ObjectGuid guid, uint32 animId /*= 0* SendMessageToSet(&data, true); } -void WorldObject::SetMap(Map * map) +void WorldObject::SetMap(Map* map) { MANGOS_ASSERT(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) { - CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(id); - if(!cinfo) + CreatureInfo const* cinfo = ObjectMgr::GetCreatureTemplate(id); + if (!cinfo) { sLog.outErrorDb("WorldObject::SummonCreature: Creature (Entry: %u) not existed for summoner: %s. ", id, GetGuidStr().c_str()); return NULL; @@ -1585,7 +1585,7 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa pCreature->Summon(spwtype, despwtime); - if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->AI()) + if (GetTypeId()==TYPEID_UNIT && ((Creature*)this)->AI()) ((Creature*)this)->AI()->JustSummoned(pCreature); // 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 if (dist2d < i_selector.m_searcherDist - delta || - dist2d >= i_selector.m_searcherDist + delta) + dist2d >= i_selector.m_searcherDist + delta) return; 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); y = GetPositionY() + (GetObjectBoundingRadius() + distance2d) * sin(absAngle); @@ -1679,13 +1679,13 @@ void WorldObject::GetNearPoint2D(float &x, float &y, float distance2d, float abs 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); const float init_z = z = GetPositionZ(); // if detection disabled, return first point - if(!sWorld.getConfig(CONFIG_BOOL_DETECT_POS_COLLISION)) + if (!sWorld.getConfig(CONFIG_BOOL_DETECT_POS_COLLISION)) { if (searcher) 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; - if(update && IsInWorld()) + if (update && IsInWorld()) 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); data << uint32(sound_id); data << GetObjectGuid(); if (target) - target->SendDirectMessage( &data ); + target->SendDirectMessage(&data); 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); data << uint32(sound_id); if (target) - target->SendDirectMessage( &data ); + target->SendDirectMessage(&data); else - SendMessageToSet( &data, true ); + SendMessageToSet(&data, true); } void WorldObject::UpdateVisibilityAndView() @@ -1844,30 +1844,30 @@ void WorldObject::RemoveFromClientUpdateList() struct WorldObjectChangeAccumulator { - UpdateDataMapType &i_updateDatas; - WorldObject &i_object; - WorldObjectChangeAccumulator(WorldObject &obj, UpdateDataMapType &d) : i_updateDatas(d), i_object(obj) + UpdateDataMapType& i_updateDatas; + WorldObject& i_object; + WorldObjectChangeAccumulator(WorldObject& obj, UpdateDataMapType& d) : i_updateDatas(d), i_object(obj) { // 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 - if(i_object.isType(TYPEMASK_PLAYER)) + if (i_object.isType(TYPEMASK_PLAYER)) 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(); - if(owner != &i_object && owner->HaveAtClient(&i_object)) + if (owner != &i_object && owner->HaveAtClient(&i_object)) i_object.BuildUpdateDataForPlayer(owner, i_updateDatas); } } - template void Visit(GridRefManager &) {} + template void Visit(GridRefManager&) {} }; -void WorldObject::BuildUpdateData( UpdateDataMapType & update_players) +void WorldObject::BuildUpdateData(UpdateDataMapType& update_players) { WorldObjectChangeAccumulator notifier(*this, update_players); Cell::VisitWorldObjects(this, notifier, GetMap()->GetVisibilityDistance()); diff --git a/src/game/Object.h b/src/game/Object.h index be7465b61..fdd276e1f 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -89,7 +89,7 @@ struct WorldLocation float orientation; 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) {} - 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) {} }; @@ -103,7 +103,7 @@ class WorldUpdateCounter time_t timeElapsed() { - if(!m_tmStart) + if (!m_tmStart) m_tmStart = WorldTimer::tickPrevTime(); return WorldTimer::getMSTimeDiff(m_tmStart, WorldTimer::tickTime()); @@ -118,12 +118,12 @@ class WorldUpdateCounter class MANGOS_DLL_SPEC Object { public: - virtual ~Object ( ); + virtual ~Object(); const bool& IsInWorld() const { return m_inWorld; } virtual void AddToWorld() { - if(m_inWorld) + if (m_inWorld) return; m_inWorld = true; @@ -156,7 +156,7 @@ class MANGOS_DLL_SPEC Object uint8 GetTypeId() const { return m_objectTypeId; } 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); // must be overwrite in appropriate subclasses (WorldObject, Item currently), or will crash @@ -166,93 +166,93 @@ class MANGOS_DLL_SPEC Object void MarkForClientUpdate(); void SendForcedObjectUpdate(); - void BuildValuesUpdateBlockForPlayer( UpdateData *data, Player *target ) const; - void BuildOutOfRangeUpdateBlock( UpdateData *data ) const; - void BuildMovementUpdateBlock( UpdateData * data, uint16 flags = 0 ) const; + void BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) const; + void BuildOutOfRangeUpdateBlock(UpdateData* data) 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 ]; } - 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 ]; } - 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 ])); } - 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 ]; } - uint8 GetByteValue( uint16 index, uint8 offset) const + uint8 GetByteValue(uint16 index, uint8 offset) const { - MANGOS_ASSERT( index < m_valuesCount || PrintIndexError( index , false) ); - MANGOS_ASSERT( offset < 4 ); + MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false)); + MANGOS_ASSERT(offset < 4); 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( offset < 2 ); + MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false)); + MANGOS_ASSERT(offset < 2); return *(((uint16*)&m_uint32Values[ index ])+offset); } - ObjectGuid const& GetGuidValue( uint16 index ) const { return *reinterpret_cast(&GetUInt64Value(index)); } + ObjectGuid const& GetGuidValue(uint16 index) const { return *reinterpret_cast(&GetUInt64Value(index)); } - void SetInt32Value( uint16 index, int32 value ); - void SetUInt32Value( uint16 index, uint32 value ); - void SetUInt64Value( uint16 index, const uint64 &value ); - void SetFloatValue( uint16 index, float value ); - void SetByteValue( uint16 index, uint8 offset, uint8 value ); - void SetUInt16Value( uint16 index, uint8 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 SetStatFloatValue( uint16 index, float value); - void SetStatInt32Value( uint16 index, int32 value); + void SetInt32Value(uint16 index, int32 value); + void SetUInt32Value(uint16 index, uint32 value); + void SetUInt64Value(uint16 index, const uint64& value); + void SetFloatValue(uint16 index, float value); + void SetByteValue(uint16 index, uint8 offset, uint8 value); + void SetUInt16Value(uint16 index, uint8 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 SetStatFloatValue(uint16 index, float value); + void SetStatInt32Value(uint16 index, int32 value); void ApplyModUInt32Value(uint16 index, int32 val, bool apply); void ApplyModInt32Value(uint16 index, int32 val, bool apply); void ApplyModUInt64Value(uint16 index, int32 val, bool apply); - void ApplyModPositiveFloatValue( uint16 index, float val, bool apply); - void ApplyModSignedFloatValue( uint16 index, float val, bool apply); + void ApplyModPositiveFloatValue(uint16 index, float val, bool apply); + void ApplyModSignedFloatValue(uint16 index, float val, bool apply); void ApplyPercentModFloatValue(uint16 index, float val, bool apply) { 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 RemoveFlag( uint16 index, uint32 oldFlag ); + void SetFlag(uint16 index, uint32 newFlag); + 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); else 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; } - void ApplyModFlag( uint16 index, uint32 flag, bool apply) + void ApplyModFlag(uint16 index, uint32 flag, bool apply) { if (apply) SetFlag(index, flag); @@ -260,10 +260,10 @@ class MANGOS_DLL_SPEC Object RemoveFlag(index, flag); } - void SetByteFlag( uint16 index, uint8 offset, uint8 newFlag ); - void RemoveByteFlag( uint16 index, uint8 offset, uint8 newFlag ); + void SetByteFlag(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)) RemoveByteFlag(index, offset, flag); @@ -271,14 +271,14 @@ class MANGOS_DLL_SPEC Object 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( offset < 4 ); + MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false)); + MANGOS_ASSERT(offset < 4); 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) SetByteFlag(index, offset, flag); @@ -289,7 +289,7 @@ class MANGOS_DLL_SPEC Object void SetShortFlag(uint16 index, bool highpart, uint16 newFlag); 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)) RemoveShortFlag(index, highpart, flag); @@ -297,13 +297,13 @@ class MANGOS_DLL_SPEC Object 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; } - void ApplyModShortFlag( uint16 index, bool highpart, uint32 flag, bool apply) + void ApplyModShortFlag(uint16 index, bool highpart, uint32 flag, bool apply) { if (apply) SetShortFlag(index, highpart, flag); @@ -311,21 +311,21 @@ class MANGOS_DLL_SPEC Object RemoveShortFlag(index, highpart, flag); } - void SetFlag64( uint16 index, uint64 newFlag ) + void SetFlag64(uint16 index, uint64 newFlag) { uint64 oldval = GetUInt64Value(index); uint64 newval = oldval | newFlag; SetUInt64Value(index,newval); } - void RemoveFlag64( uint16 index, uint64 oldFlag ) + void RemoveFlag64(uint16 index, uint64 oldFlag) { uint64 oldval = GetUInt64Value(index); uint64 newval = oldval & ~oldFlag; SetUInt64Value(index,newval); } - void ToggleFlag64( uint16 index, uint64 flag) + void ToggleFlag64(uint16 index, uint64 flag) { if (HasFlag64(index, flag)) RemoveFlag64(index, flag); @@ -333,13 +333,13 @@ class MANGOS_DLL_SPEC Object 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 ) ); - return (GetUInt64Value( index ) & flag) != 0; + MANGOS_ASSERT(index < m_valuesCount || PrintIndexError(index , false)); + return (GetUInt64Value(index) & flag) != 0; } - void ApplyModFlag64( uint16 index, uint64 flag, bool apply) + void ApplyModFlag64(uint16 index, uint64 flag, bool apply) { if (apply) SetFlag64(index, flag); @@ -359,17 +359,17 @@ class MANGOS_DLL_SPEC Object virtual bool HasInvolvedQuest(uint32 /* quest_id */) const { return false; } protected: - Object ( ); + Object(); 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 BuildValuesUpdate(uint8 updatetype, ByteBuffer *data, UpdateMask *updateMask, Player *target ) const; + void BuildMovementUpdate(ByteBuffer* data, uint16 updateFlags) const; + void BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* updateMask, Player* target) const; void BuildUpdateDataForPlayer(Player* pl, UpdateDataMapType& update_players); uint16 m_objectType; @@ -379,12 +379,12 @@ class MANGOS_DLL_SPEC Object union { - int32 *m_int32Values; - uint32 *m_uint32Values; - float *m_floatValues; + int32* m_int32Values; + uint32* m_uint32Values; + float* m_floatValues; }; - uint32 *m_uint32Values_mirror; + uint32* m_uint32Values_mirror; uint16 m_valuesCount; @@ -408,7 +408,7 @@ struct WorldObjectChangeAccumulator; class MANGOS_DLL_SPEC WorldObject : public Object { - friend struct WorldObjectChangeAccumulator; + friend struct WorldObjectChangeAccumulator; public: @@ -417,49 +417,49 @@ class MANGOS_DLL_SPEC WorldObject : public Object class MANGOS_DLL_SPEC UpdateHelper { public: - explicit UpdateHelper(WorldObject * obj) : m_obj(obj) {} + explicit UpdateHelper(WorldObject* obj) : m_obj(obj) {} ~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(); } private: - UpdateHelper( const UpdateHelper& ); - UpdateHelper& operator=( const UpdateHelper& ); + UpdateHelper(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*/) {} - 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); void SetOrientation(float orientation); - float GetPositionX( ) const { return m_position.x; } - float GetPositionY( ) const { return m_position.y; } - float GetPositionZ( ) const { return m_position.z; } - void GetPosition( float &x, float &y, float &z ) const - { x = m_position.x; y = m_position.y; z = m_position.z; } - void GetPosition( WorldLocation &loc ) const - { loc.mapid = m_mapId; GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); } - float GetOrientation( ) const { return m_position.o; } - 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 GetClosePoint(float &x, float &y, float &z, float bounding_radius, float distance2d = 0, float angle = 0, const WorldObject* obj = NULL ) const + float GetPositionX() const { return m_position.x; } + float GetPositionY() const { return m_position.y; } + float GetPositionZ() const { return m_position.z; } + void GetPosition(float& x, float& y, float& z) const + { x = m_position.x; y = m_position.y; z = m_position.z; } + void GetPosition(WorldLocation& loc) const + { loc.mapid = m_mapId; GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); } + float GetOrientation() const { return m_position.o; } + 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 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 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` 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; } bool IsPositionValid() const; - void UpdateGroundPositionZ(float x, float y, float &z) const; - void UpdateAllowedPositionZ(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 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 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(); } - float GetDistance( const WorldObject* obj ) const; + float GetDistance(const WorldObject* obj) const; float GetDistance(float x, float y, float z) const; float GetDistance2d(const WorldObject* obj) 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 IsInRange3d(float x, float y, float z, float minRange, float maxRange) const; - float GetAngle( const WorldObject* obj ) const; - float GetAngle( const float x, const float y ) const; - bool HasInArc( const float arcangle, const WorldObject* obj ) const; + float GetAngle(const WorldObject* obj) const; + float GetAngle(const float x, const float y) const; + bool HasInArc(const float arcangle, const WorldObject* obj) 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 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 SendMessageToSet(WorldPacket *data, bool self); - virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self); - void SendMessageToSetExcept(WorldPacket *data, Player const* skipped_receiver); + virtual void SendMessageToSet(WorldPacket* data, bool self); + virtual void SendMessageToSetInRange(WorldPacket* data, float dist, bool self); + void SendMessageToSetExcept(WorldPacket* data, Player const* skipped_receiver); void MonsterSay(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 MonsterWhisper(int32 textId, Unit* receiver, bool IsBossWhisper = false); 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 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 virtual bool isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const = 0; - void SetMap(Map * map); - Map * GetMap() const { MANGOS_ASSERT(m_currMap); return m_currMap; } + void SetMap(Map* map); + Map* GetMap() const { MANGOS_ASSERT(m_currMap); return m_currMap; } //used to check all object's GetMap() calls when object is not in world! void ResetMap() { m_currMap = NULL; } @@ -579,7 +579,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object void AddToClientUpdateList(); 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); @@ -607,7 +607,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object std::string m_name; 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_InstanceId; // in map copy with instance id diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index 0a48efe9b..dfb390e98 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -40,7 +40,7 @@ INSTANTIATE_CLASS_MUTEX(ObjectAccessor, ACE_Thread_Mutex); 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(); delete itr->second; @@ -48,7 +48,7 @@ ObjectAccessor::~ObjectAccessor() } Unit* -ObjectAccessor::GetUnit(WorldObject const &u, ObjectGuid guid) +ObjectAccessor::GetUnit(WorldObject const& u, ObjectGuid guid) { if (!guid) return NULL; @@ -64,7 +64,7 @@ ObjectAccessor::GetUnit(WorldObject const &u, ObjectGuid guid) Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid) { - Corpse * ret = HashMapHolder::Find(guid); + Corpse* ret = HashMapHolder::Find(guid); if (!ret) return NULL; if (ret->GetMapId() != mapid) @@ -85,12 +85,12 @@ Player* ObjectAccessor::FindPlayer(ObjectGuid guid, bool inWorld /*= true*/) return plr; } -Player* ObjectAccessor::FindPlayerByName(const char *name) +Player* ObjectAccessor::FindPlayerByName(const char* name) { HashMapHolder::ReadGuard g(HashMapHolder::GetLock()); HashMapHolder::MapType& m = sObjectAccessor.GetPlayers(); for (HashMapHolder::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 NULL; @@ -130,13 +130,13 @@ ObjectAccessor::GetCorpseForPlayerGUID(ObjectGuid guid) } void -ObjectAccessor::RemoveCorpse(Corpse *corpse) +ObjectAccessor::RemoveCorpse(Corpse* corpse) { MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES); Guard guard(i_corpseGuard); Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGuid()); - if( iter == i_player2corpse.end() ) + if (iter == i_player2corpse.end()) return; // build mapid*cellid -> guid_set map @@ -150,7 +150,7 @@ ObjectAccessor::RemoveCorpse(Corpse *corpse) } void -ObjectAccessor::AddCorpse(Corpse *corpse) +ObjectAccessor::AddCorpse(Corpse* corpse) { MANGOS_ASSERT(corpse && corpse->GetType() != CORPSE_BONES); @@ -169,29 +169,29 @@ void ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* map) { Guard guard(i_corpseGuard); - for(Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter) - if(iter->second->GetGrid() == gridpair) - { - // verify, if the corpse in our instance (add only corpses which are) - if (map->Instanceable()) + for (Player2CorpsesMapType::iterator iter = i_player2corpse.begin(); iter != i_player2corpse.end(); ++iter) + if (iter->second->GetGrid() == gridpair) { - 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); } } - else - { - grid.AddWorldObject(iter->second); - } - } } Corpse* ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia) { - Corpse *corpse = GetCorpseForPlayerGUID(player_guid); - if(!corpse) + Corpse* corpse = GetCorpseForPlayerGUID(player_guid); + if (!corpse) { //in fact this function is called from several places //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) // 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) map->Remove(corpse, false); // remove corpse from DB 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 // ignore bones creating option in case insignia if (map && (insignia || - (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->IsBattleGroundOrArena() ? sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_BG_OR_ARENA) : sWorld.getConfig(CONFIG_BOOL_DEATH_BONES_WORLD))) && + !map->IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY())) { // Create bones, don't change Corpse bones = new Corpse; @@ -239,7 +239,7 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia) 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); } @@ -257,12 +257,12 @@ void ObjectAccessor::RemoveOldCorpses() { time_t now = time(NULL); 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; - if(!itr->second->IsExpired(now)) + if (!itr->second->IsExpired(now)) continue; ConvertCorpseForPlayer(itr->first); diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index f35296219..047f814e6 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -85,12 +85,12 @@ class HashMapHolder class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton > { - friend class MaNGOS::OperatorNew; + friend class MaNGOS::OperatorNew; - ObjectAccessor(); - ~ObjectAccessor(); - ObjectAccessor(const ObjectAccessor &); - ObjectAccessor& operator=(const ObjectAccessor &); + ObjectAccessor(); + ~ObjectAccessor(); + ObjectAccessor(const ObjectAccessor&); + ObjectAccessor& operator=(const ObjectAccessor&); public: typedef UNORDERED_MAP Player2CorpsesMapType; @@ -101,7 +101,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton::MapType& GetPlayers() @@ -114,17 +114,17 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton::Insert(object); } - void AddObject(Player *object) { HashMapHolder::Insert(object); } - void RemoveObject(Corpse *object) { HashMapHolder::Remove(object); } - void RemoveObject(Player *object) { HashMapHolder::Remove(object); } + void AddObject(Corpse* object) { HashMapHolder::Insert(object); } + void AddObject(Player* object) { HashMapHolder::Insert(object); } + void RemoveObject(Corpse* object) { HashMapHolder::Remove(object); } + void RemoveObject(Player* object) { HashMapHolder::Remove(object); } private: diff --git a/src/game/ObjectGridLoader.cpp b/src/game/ObjectGridLoader.cpp index ac3c58979..c6444e52d 100644 --- a/src/game/ObjectGridLoader.cpp +++ b/src/game/ObjectGridLoader.cpp @@ -33,30 +33,30 @@ class MANGOS_DLL_DECL ObjectGridRespawnMover public: ObjectGridRespawnMover() {} - void Move(GridType &grid); + void Move(GridType& grid); - template void Visit(GridRefManager &) {} - void Visit(CreatureMapType &m); + template void Visit(GridRefManager&) {} + void Visit(CreatureMapType& m); }; void -ObjectGridRespawnMover::Move(GridType &grid) +ObjectGridRespawnMover::Move(GridType& grid) { TypeContainerVisitor mover(*this); grid.Visit(mover); } void -ObjectGridRespawnMover::Visit(CreatureMapType &m) +ObjectGridRespawnMover::Visit(CreatureMapType& m) { // 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 // 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; - Creature * c = iter->getSource(); + Creature* c = iter->getSource(); 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); Cell resp_cell(resp_val); - if(cur_cell.DiffGrid(resp_cell)) + if (cur_cell.DiffGrid(resp_cell)) { c->GetMap()->CreatureRespawnRelocation(c); // false result ignored: will be unload with other creatures at grid @@ -80,16 +80,16 @@ class ObjectWorldLoader { public: 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 void Visit(GridRefManager&) { } private: Cell i_cell; - NGridType &i_grid; + NGridType& i_grid; Map* i_map; public: uint32 i_corpses; @@ -99,7 +99,7 @@ template 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); @@ -107,17 +107,17 @@ template<> void addUnitState(Creature *obj, CellPair const& cell_pair) } template -void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager &m, uint32 &count, Map* map, GridType& grid) +void LoadHelper(CellGuidSet const& guid_set, CellPair& cell, GridRefManager& m, uint32& count, Map* map, GridType& grid) { 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; T* obj = new T; //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; continue; @@ -128,7 +128,7 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager & addUnitState(obj,cell); obj->SetMap(map); obj->AddToWorld(); - if(obj->isActiveObject()) + if (obj->isActiveObject()) map->AddToActive(obj); obj->GetViewPoint().Event_AddedToWorld(&grid); @@ -140,19 +140,19 @@ void LoadHelper(CellGuidSet const& guid_set, CellPair &cell, GridRefManager & } } -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; - 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; 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) continue; @@ -169,7 +169,7 @@ void LoadHelper(CellCorpseSet const& cell_corpses, CellPair &cell, CorpseMapType } void -ObjectGridLoader::Visit(GameObjectMapType &m) +ObjectGridLoader::Visit(GameObjectMapType& m) { uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); 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); - 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(i_map->GetPersistentState()->GetCellObjectGuids(cell_id).gameobjects, cell_pair, m, i_gameObjects, i_map, grid); } void -ObjectGridLoader::Visit(CreatureMapType &m) +ObjectGridLoader::Visit(CreatureMapType& m) { uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); 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); - 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(i_map->GetPersistentState()->GetCellObjectGuids(cell_id).creatures, cell_pair, m, i_creatures, i_map, grid); } void -ObjectWorldLoader::Visit(CorpseMapType &m) +ObjectWorldLoader::Visit(CorpseMapType& m) { uint32 x = (i_cell.GridX()*MAX_NUMBER_OF_CELLS) + i_cell.CellX(); 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 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); } void -ObjectGridLoader::Load(GridType &grid) +ObjectGridLoader::Load(GridType& grid) { { TypeContainerVisitor loader(*this); @@ -232,10 +232,10 @@ void ObjectGridLoader::LoadN(void) { i_gameObjects = 0; i_creatures = 0; i_corpses = 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; - 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; GridLoader loader; @@ -247,9 +247,9 @@ void ObjectGridLoader::LoadN(void) 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; mover.Move(i_grid(x, y)); @@ -258,7 +258,7 @@ void ObjectGridUnloader::MoveToRespawnN() } void -ObjectGridUnloader::Unload(GridType &grid) +ObjectGridUnloader::Unload(GridType& grid) { TypeContainerVisitor unloader(*this); grid.Visit(unloader); @@ -266,17 +266,17 @@ ObjectGridUnloader::Unload(GridType &grid) template void -ObjectGridUnloader::Visit(GridRefManager &m) +ObjectGridUnloader::Visit(GridRefManager& m) { // remove all cross-reference before deleting - for(typename GridRefManager::iterator iter=m.begin(); iter != m.end(); ++iter) + for (typename GridRefManager::iterator iter=m.begin(); iter != m.end(); ++iter) 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(!sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY)) + if (!sWorld.getConfig(CONFIG_BOOL_SAVE_RESPAWN_TIME_IMMEDIATELY)) obj->SaveRespawnTime(); ///- object must be out of world before delete obj->RemoveFromWorld(); @@ -286,17 +286,17 @@ ObjectGridUnloader::Visit(GridRefManager &m) } void -ObjectGridStoper::Stop(GridType &grid) +ObjectGridStoper::Stop(GridType& grid) { TypeContainerVisitor stoper(*this); grid.Visit(stoper); } void -ObjectGridStoper::Visit(CreatureMapType &m) +ObjectGridStoper::Visit(CreatureMapType& m) { // 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()->DeleteThreatList(); @@ -304,5 +304,5 @@ ObjectGridStoper::Visit(CreatureMapType &m) } } -template void ObjectGridUnloader::Visit(GameObjectMapType &); -template void ObjectGridUnloader::Visit(DynamicObjectMapType &); +template void ObjectGridUnloader::Visit(GameObjectMapType&); +template void ObjectGridUnloader::Visit(DynamicObjectMapType&); diff --git a/src/game/ObjectGridLoader.h b/src/game/ObjectGridLoader.h index 5cd13ed5c..bbfb15e11 100644 --- a/src/game/ObjectGridLoader.h +++ b/src/game/ObjectGridLoader.h @@ -30,17 +30,17 @@ class ObjectWorldLoader; class MANGOS_DLL_DECL ObjectGridLoader { - friend class ObjectWorldLoader; + friend class ObjectWorldLoader; public: - 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) - {} + 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) + {} - void Load(GridType &grid); - void Visit(GameObjectMapType &m); - void Visit(CreatureMapType &m); - void Visit(CorpseMapType &) {} + void Load(GridType& grid); + void Visit(GameObjectMapType& m); + void Visit(CreatureMapType& m); + void Visit(CorpseMapType&) {} void Visit(DynamicObjectMapType&) { } @@ -48,7 +48,7 @@ class MANGOS_DLL_DECL ObjectGridLoader private: Cell i_cell; - NGridType &i_grid; + NGridType& i_grid; Map* i_map; uint32 i_gameObjects; uint32 i_creatures; @@ -58,14 +58,14 @@ class MANGOS_DLL_DECL ObjectGridLoader class MANGOS_DLL_DECL ObjectGridUnloader { public: - ObjectGridUnloader(NGridType &grid) : i_grid(grid) {} + ObjectGridUnloader(NGridType& grid) : i_grid(grid) {} void MoveToRespawnN(); 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 loader; loader.Unload(i_grid(x, y), *this); @@ -73,23 +73,23 @@ class MANGOS_DLL_DECL ObjectGridUnloader } } - void Unload(GridType &grid); - template void Visit(GridRefManager &m); + void Unload(GridType& grid); + template void Visit(GridRefManager& m); private: - NGridType &i_grid; + NGridType& i_grid; }; class MANGOS_DLL_DECL ObjectGridStoper { public: - ObjectGridStoper(NGridType &grid) : i_grid(grid) {} + ObjectGridStoper(NGridType& grid) : i_grid(grid) {} void MoveToRespawnN(); 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 loader; loader.Stop(i_grid(x, y), *this); @@ -97,12 +97,12 @@ class MANGOS_DLL_DECL ObjectGridStoper } } - void Stop(GridType &grid); - void Visit(CreatureMapType &m); + void Stop(GridType& grid); + void Visit(CreatureMapType& m); - template void Visit(GridRefManager &) {} + template void Visit(GridRefManager&) {} private: - NGridType &i_grid; + NGridType& i_grid; }; typedef GridLoader GridLoaderType; diff --git a/src/game/ObjectGuid.cpp b/src/game/ObjectGuid.cpp index c6aec8953..6cc5ee2e1 100644 --- a/src/game/ObjectGuid.cpp +++ b/src/game/ObjectGuid.cpp @@ -25,7 +25,7 @@ char const* ObjectGuid::GetTypeName(HighGuid high) { - switch(high) + switch (high) { case HIGHGUID_ITEM: return "Item"; case HIGHGUID_PLAYER: return "Player"; @@ -80,7 +80,7 @@ ByteBuffer& operator<< (ByteBuffer& buf, ObjectGuid const& guid) return buf; } -ByteBuffer &operator>>(ByteBuffer& buf, ObjectGuid& guid) +ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid) { guid.Set(buf.read()); return buf; @@ -92,7 +92,7 @@ ByteBuffer& operator<< (ByteBuffer& buf, PackedGuid const& guid) return buf; } -ByteBuffer &operator>>(ByteBuffer& buf, PackedGuidReader const& guid) +ByteBuffer& operator>>(ByteBuffer& buf, PackedGuidReader const& guid) { guid.m_guidPtr->Set(buf.readPackGUID()); return buf; diff --git a/src/game/ObjectGuid.h b/src/game/ObjectGuid.h index 4c5b5ca4e..78c239cbd 100644 --- a/src/game/ObjectGuid.h +++ b/src/game/ObjectGuid.h @@ -62,8 +62,8 @@ enum HighGuid HIGHGUID_ITEM = 0x470, // blizz 470 HIGHGUID_CONTAINER = 0x470, // blizz 470 HIGHGUID_PLAYER = 0x000, // blizz 070 (temporary reverted back to 0 high guid - // in result unknown source visibility player with - // player problems. please reapply only after its resolve) + // in result unknown source visibility player with + // player problems. please reapply only after its resolve) HIGHGUID_GAMEOBJECT = 0xF11, // blizz F11/F51 HIGHGUID_TRANSPORT = 0xF12, // blizz F12/F52 (for GAMEOBJECT_TYPE_TRANSPORT) HIGHGUID_UNIT = 0xF13, // blizz F13/F53 @@ -113,15 +113,15 @@ class MANGOS_DLL_SPEC ObjectGuid uint32 GetCounter() const { return HasEntry() - ? uint32(m_guid & UI64LIT(0x0000000000FFFFFF)) - : uint32(m_guid & UI64LIT(0x00000000FFFFFFFF)); + ? uint32(m_guid & UI64LIT(0x0000000000FFFFFF)) + : uint32(m_guid & UI64LIT(0x00000000FFFFFFFF)); } static uint32 GetMaxCounter(HighGuid high) { return HasEntry(high) - ? uint32(0x00FFFFFF) - : uint32(0xFFFFFFFF); + ? uint32(0x00FFFFFF) + : uint32(0xFFFFFFFF); } uint32 GetMaxCounter() const { return GetMaxCounter(GetHigh()); } @@ -146,10 +146,10 @@ class MANGOS_DLL_SPEC ObjectGuid static TypeID GetTypeId(HighGuid high) { - switch(high) + switch (high) { 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_PET: return TYPEID_UNIT; case HIGHGUID_PLAYER: return TYPEID_PLAYER; @@ -158,7 +158,7 @@ class MANGOS_DLL_SPEC ObjectGuid case HIGHGUID_CORPSE: return TYPEID_CORPSE; case HIGHGUID_MO_TRANSPORT: return TYPEID_GAMEOBJECT; case HIGHGUID_VEHICLE: return TYPEID_UNIT; - // unknown + // unknown case HIGHGUID_INSTANCE: case HIGHGUID_GROUP: default: return TYPEID_OBJECT; @@ -167,7 +167,7 @@ class MANGOS_DLL_SPEC ObjectGuid 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(); } @@ -180,7 +180,7 @@ class MANGOS_DLL_SPEC ObjectGuid private: // internal functions static bool HasEntry(HighGuid high) { - switch(high) + switch (high) { case HIGHGUID_ITEM: case HIGHGUID_PLAYER: @@ -216,7 +216,7 @@ typedef std::vector GuidVector; class PackedGuid { - friend ByteBuffer& operator<< (ByteBuffer& buf, PackedGuid const& guid); + friend ByteBuffer& operator<< (ByteBuffer& buf, PackedGuid const& guid); public: // constructors 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 - template<> - class hash - { - public: +template<> +class hash +{ + public: - size_t operator() (ObjectGuid const& key) const - { - return hash()(key.GetRawValue()); - } - }; + size_t operator()(ObjectGuid const& key) const + { + return hash()(key.GetRawValue()); + } +}; HASH_NAMESPACE_END diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 4d1d91b48..e271df041 100755 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -52,20 +52,20 @@ INSTANTIATE_SINGLETON_1(ObjectMgr); bool normalizePlayerName(std::string& name) { - if(name.empty()) + if (name.empty()) return false; wchar_t wstr_buf[MAX_INTERNAL_PLAYER_NAME+1]; size_t wstr_len = MAX_INTERNAL_PLAYER_NAME; - if(!Utf8toWStr(name,&wstr_buf[0],wstr_len)) + if (!Utf8toWStr(name,&wstr_buf[0],wstr_len)) return false; wstr_buf[0] = wcharToUpper(wstr_buf[0]); - for(size_t i = 1; i < wstr_len; ++i) + for (size_t i = 1; i < wstr_len; ++i) wstr_buf[i] = wcharToLower(wstr_buf[i]); - if(!WStrToUtf8(wstr_buf,wstr_len,name)) + if (!WStrToUtf8(wstr_buf,wstr_len,name)) return false; return true; @@ -96,9 +96,9 @@ LanguageDesc lang_description[LANGUAGES_COUNT] = LanguageDesc const* GetLanguageDescByID(uint32 lang) { - for(int i = 0; i < LANGUAGES_COUNT; ++i) + for (int i = 0; i < LANGUAGES_COUNT; ++i) { - if(uint32(lang_description[i].lang_id) == lang) + if (uint32(lang_description[i].lang_id) == lang) return &lang_description[i]; } @@ -107,17 +107,17 @@ LanguageDesc const* GetLanguageDescByID(uint32 lang) bool SpellClickInfo::IsFitToRequirements(Player const* player) const { - if(questStart) + if (questStart) { // not in expected required quest state if (!player || ((!questStartCanActive || !player->IsActiveQuest(questStart)) && !player->GetQuestRewardStatus(questStart))) return false; } - if(questEnd) + if (questEnd) { // not in expected forbidden quest state - if(!player || player->GetQuestRewardStatus(questEnd)) + if (!player || player->GetQuestRewardStatus(questEnd)) return false; } @@ -155,10 +155,10 @@ ObjectMgr::ObjectMgr() : ObjectMgr::~ObjectMgr() { - for( QuestMap::iterator i = mQuestTemplates.begin( ); i != mQuestTemplates.end( ); ++i ) + for (QuestMap::iterator i = mQuestTemplates.begin(); i != mQuestTemplates.end(); ++i) delete i->second; - for(PetLevelInfoMap::iterator i = petInfo.begin( ); i != petInfo.end( ); ++i ) + for (PetLevelInfoMap::iterator i = petInfo.begin(); i != petInfo.end(); ++i) delete[] i->second; // free only if loaded @@ -206,7 +206,7 @@ ArenaTeam* ObjectMgr::GetArenaTeamById(uint32 arenateamid) const ArenaTeam* ObjectMgr::GetArenaTeamByName(const std::string& arenateamname) const { - for(ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr) + for (ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr) if (itr->second->GetName() == arenateamname) return itr->second; @@ -215,7 +215,7 @@ ArenaTeam* ObjectMgr::GetArenaTeamByName(const std::string& arenateamname) const ArenaTeam* ObjectMgr::GetArenaTeamByCaptain(ObjectGuid guid) const { - for(ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr) + for (ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr) if (itr->second->GetCaptainGuid() == guid) return itr->second; @@ -226,7 +226,7 @@ void ObjectMgr::LoadCreatureLocales() { mCreatureLocaleMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,subname_loc1,name_loc2,subname_loc2,name_loc3,subname_loc3,name_loc4,subname_loc4,name_loc5,subname_loc5,name_loc6,subname_loc6,name_loc7,subname_loc7,name_loc8,subname_loc8 FROM locales_creature"); + QueryResult* result = WorldDatabase.Query("SELECT entry,name_loc1,subname_loc1,name_loc2,subname_loc2,name_loc3,subname_loc3,name_loc4,subname_loc4,name_loc5,subname_loc5,name_loc6,subname_loc6,name_loc7,subname_loc7,name_loc8,subname_loc8 FROM locales_creature"); if (!result) { @@ -243,7 +243,7 @@ void ObjectMgr::LoadCreatureLocales() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); @@ -256,51 +256,52 @@ void ObjectMgr::LoadCreatureLocales() CreatureLocale& data = mCreatureLocaleMap[entry]; - for(int i = 1; i < MAX_LOCALE; ++i) + for (int i = 1; i < MAX_LOCALE; ++i) { std::string str = fields[1+2*(i-1)].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.Name.size() <= idx) + if ((int32)data.Name.size() <= idx) data.Name.resize(idx+1); data.Name[idx] = str; } } str = fields[1+2*(i-1)+1].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.SubName.size() <= idx) + if ((int32)data.SubName.size() <= idx) data.SubName.resize(idx+1); data.SubName[idx] = str; } } } - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %lu creature locale strings", (unsigned long)mCreatureLocaleMap.size() ); + sLog.outString(">> Loaded %lu creature locale strings", (unsigned long)mCreatureLocaleMap.size()); } void ObjectMgr::LoadGossipMenuItemsLocales() { mGossipMenuItemsLocaleMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT menu_id,id," - "option_text_loc1,box_text_loc1,option_text_loc2,box_text_loc2," - "option_text_loc3,box_text_loc3,option_text_loc4,box_text_loc4," - "option_text_loc5,box_text_loc5,option_text_loc6,box_text_loc6," - "option_text_loc7,box_text_loc7,option_text_loc8,box_text_loc8 " - "FROM locales_gossip_menu_option"); + QueryResult* result = WorldDatabase.Query("SELECT menu_id,id," + "option_text_loc1,box_text_loc1,option_text_loc2,box_text_loc2," + "option_text_loc3,box_text_loc3,option_text_loc4,box_text_loc4," + "option_text_loc5,box_text_loc5,option_text_loc6,box_text_loc6," + "option_text_loc7,box_text_loc7,option_text_loc8,box_text_loc8 " + "FROM locales_gossip_menu_option"); if (!result) { @@ -317,7 +318,7 @@ void ObjectMgr::LoadGossipMenuItemsLocales() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint16 menuId = fields[0].GetUInt16(); @@ -346,46 +347,47 @@ void ObjectMgr::LoadGossipMenuItemsLocales() GossipMenuItemsLocale& data = mGossipMenuItemsLocaleMap[MAKE_PAIR32(menuId,id)]; - for(int i = 1; i < MAX_LOCALE; ++i) + for (int i = 1; i < MAX_LOCALE; ++i) { std::string str = fields[2+2*(i-1)].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.OptionText.size() <= idx) + if ((int32)data.OptionText.size() <= idx) data.OptionText.resize(idx+1); data.OptionText[idx] = str; } } str = fields[2+2*(i-1)+1].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.BoxText.size() <= idx) + if ((int32)data.BoxText.size() <= idx) data.BoxText.resize(idx+1); data.BoxText[idx] = str; } } } - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %lu gossip_menu_option locale strings", (unsigned long)mGossipMenuItemsLocaleMap.size() ); + sLog.outString(">> Loaded %lu gossip_menu_option locale strings", (unsigned long)mGossipMenuItemsLocaleMap.size()); } void ObjectMgr::LoadPointOfInterestLocales() { mPointOfInterestLocaleMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT entry,icon_name_loc1,icon_name_loc2,icon_name_loc3,icon_name_loc4,icon_name_loc5,icon_name_loc6,icon_name_loc7,icon_name_loc8 FROM locales_points_of_interest"); + QueryResult* result = WorldDatabase.Query("SELECT entry,icon_name_loc1,icon_name_loc2,icon_name_loc3,icon_name_loc4,icon_name_loc5,icon_name_loc6,icon_name_loc7,icon_name_loc8 FROM locales_points_of_interest"); if (!result) { @@ -402,7 +404,7 @@ void ObjectMgr::LoadPointOfInterestLocales() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); @@ -415,22 +417,23 @@ void ObjectMgr::LoadPointOfInterestLocales() PointOfInterestLocale& data = mPointOfInterestLocaleMap[entry]; - for(int i = 1; i < MAX_LOCALE; ++i) + for (int i = 1; i < MAX_LOCALE; ++i) { std::string str = fields[i].GetCppString(); - if(str.empty()) + if (str.empty()) continue; int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.IconName.size() <= idx) + if ((int32)data.IconName.size() <= idx) data.IconName.resize(idx+1); data.IconName[idx] = str; } } - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -441,7 +444,7 @@ void ObjectMgr::LoadPointOfInterestLocales() struct SQLCreatureLoader : public SQLStorageLoaderBase { template - void convert_from_str(uint32 /*field_pos*/, char const *src, D &dst) + void convert_from_str(uint32 /*field_pos*/, char const* src, D& dst) { dst = D(sScriptMgr.GetScriptId(src)); } @@ -452,14 +455,14 @@ void ObjectMgr::LoadCreatureTemplates() SQLCreatureLoader loader; loader.Load(sCreatureStorage); - sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount ); + sLog.outString(">> Loaded %u creature definitions", sCreatureStorage.RecordCount); sLog.outString(); std::set difficultyEntries[MAX_DIFFICULTY - 1]; // already loaded difficulty 1 value in creatures std::set hasDifficultyEntries[MAX_DIFFICULTY - 1]; // already loaded creatures with difficulty 1 values // check data correctness - for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) + for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) { CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i); if (!cInfo) @@ -476,7 +479,7 @@ void ObjectMgr::LoadCreatureTemplates() if (!difficultyInfo) { sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_%u`=%u but creature entry %u not exist.", - i, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff]); + i, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff]); continue; } @@ -499,7 +502,7 @@ void ObjectMgr::LoadCreatureTemplates() if (hasDifficultyEntries[diff2].find(cInfo->DifficultyEntry[diff]) != hasDifficultyEntries[diff2].end()) { sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_%u`=%u but creature entry %u have difficulty %u entry also.", - i, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff], diff2 + 1); + i, diff + 1, cInfo->DifficultyEntry[diff], cInfo->DifficultyEntry[diff], diff2 + 1); continue; } ok2 = true; @@ -510,7 +513,7 @@ void ObjectMgr::LoadCreatureTemplates() if (cInfo->unit_class != difficultyInfo->unit_class) { sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in difficulty %u mode (Entry: %u, class %u).", - i, cInfo->unit_class, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->unit_class); + i, cInfo->unit_class, diff + 1, cInfo->DifficultyEntry[diff], difficultyInfo->unit_class); continue; } @@ -547,14 +550,14 @@ void ObjectMgr::LoadCreatureTemplates() if (difficultyInfo->AIName && *difficultyInfo->AIName) { sLog.outErrorDb("Difficulty %u mode creature (Entry: %u) has `AIName`, but in any case will used difficulty 0 mode creature (Entry: %u) AIName.", - diff + 1, cInfo->DifficultyEntry[diff], i); + diff + 1, cInfo->DifficultyEntry[diff], i); continue; } if (difficultyInfo->ScriptID) { sLog.outErrorDb("Difficulty %u mode creature (Entry: %u) has `ScriptName`, but in any case will used difficulty 0 mode creature (Entry: %u) ScriptName.", - diff + 1, cInfo->DifficultyEntry[diff], i); + diff + 1, cInfo->DifficultyEntry[diff], i); continue; } @@ -573,11 +576,11 @@ void ObjectMgr::LoadCreatureTemplates() if (!factionTemplate) sLog.outErrorDb("Creature (Entry: %u) has nonexistent faction_H template (%u)", cInfo->Entry, cInfo->faction_H); - for(int k = 0; k < MAX_KILL_CREDIT; ++k) + for (int k = 0; k < MAX_KILL_CREDIT; ++k) { - if(cInfo->KillCredit[k]) + if (cInfo->KillCredit[k]) { - if(!GetCreatureTemplate(cInfo->KillCredit[k])) + if (!GetCreatureTemplate(cInfo->KillCredit[k])) { sLog.outErrorDb("Creature (Entry: %u) has nonexistent creature entry in `KillCredit%d` (%u)",cInfo->Entry,k+1,cInfo->KillCredit[k]); const_cast(cInfo)->KillCredit[k] = 0; @@ -588,17 +591,17 @@ void ObjectMgr::LoadCreatureTemplates() // used later for scale CreatureDisplayInfoEntry const* displayScaleEntry = NULL; - for(int i = 0; i < MAX_CREATURE_MODEL; ++i) + for (int i = 0; i < MAX_CREATURE_MODEL; ++i) { if (cInfo->ModelId[i]) { CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->ModelId[i]); - if(!displayEntry) + if (!displayEntry) { sLog.outErrorDb("Creature (Entry: %u) has nonexistent modelid_%d (%u), can crash client", cInfo->Entry, i+1, cInfo->ModelId[i]); const_cast(cInfo)->ModelId[i] = 0; } - else if(!displayScaleEntry) + else if (!displayScaleEntry) displayScaleEntry = displayEntry; CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(cInfo->ModelId[i]); @@ -616,63 +619,63 @@ void ObjectMgr::LoadCreatureTemplates() else if (((1 << (cInfo->unit_class-1)) & CLASSMASK_ALL_CREATURES) == 0) sLog.outErrorDb("Creature (Entry: %u) has invalid unit_class(%u) for creature_template", cInfo->Entry, cInfo->unit_class); - if(cInfo->dmgschool >= MAX_SPELL_SCHOOL) + if (cInfo->dmgschool >= MAX_SPELL_SCHOOL) { sLog.outErrorDb("Creature (Entry: %u) has invalid spell school value (%u) in `dmgschool`",cInfo->Entry,cInfo->dmgschool); const_cast(cInfo)->dmgschool = SPELL_SCHOOL_NORMAL; } - if(cInfo->baseattacktime == 0) + if (cInfo->baseattacktime == 0) const_cast(cInfo)->baseattacktime = BASE_ATTACK_TIME; - if(cInfo->rangeattacktime == 0) + if (cInfo->rangeattacktime == 0) const_cast(cInfo)->rangeattacktime = BASE_ATTACK_TIME; - if(cInfo->npcflag & UNIT_NPC_FLAG_SPELLCLICK) + if (cInfo->npcflag & UNIT_NPC_FLAG_SPELLCLICK) { sLog.outErrorDb("Creature (Entry: %u) has dynamic flag UNIT_NPC_FLAG_SPELLCLICK (%u) set, it expect to be set by code base at `npc_spellclick_spells` content.",cInfo->Entry,UNIT_NPC_FLAG_SPELLCLICK); const_cast(cInfo)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK; } - if((cInfo->npcflag & UNIT_NPC_FLAG_TRAINER) && cInfo->trainer_type >= MAX_TRAINER_TYPE) + if ((cInfo->npcflag & UNIT_NPC_FLAG_TRAINER) && cInfo->trainer_type >= MAX_TRAINER_TYPE) sLog.outErrorDb("Creature (Entry: %u) has wrong trainer type %u",cInfo->Entry,cInfo->trainer_type); - if(cInfo->type && !sCreatureTypeStore.LookupEntry(cInfo->type)) + if (cInfo->type && !sCreatureTypeStore.LookupEntry(cInfo->type)) { sLog.outErrorDb("Creature (Entry: %u) has invalid creature type (%u) in `type`",cInfo->Entry,cInfo->type); const_cast(cInfo)->type = CREATURE_TYPE_HUMANOID; } // must exist or used hidden but used in data horse case - if(cInfo->family && !sCreatureFamilyStore.LookupEntry(cInfo->family) && cInfo->family != CREATURE_FAMILY_HORSE_CUSTOM ) + if (cInfo->family && !sCreatureFamilyStore.LookupEntry(cInfo->family) && cInfo->family != CREATURE_FAMILY_HORSE_CUSTOM) { sLog.outErrorDb("Creature (Entry: %u) has invalid creature family (%u) in `family`",cInfo->Entry,cInfo->family); const_cast(cInfo)->family = 0; } - if(cInfo->InhabitType <= 0 || cInfo->InhabitType > INHABIT_ANYWHERE) + if (cInfo->InhabitType <= 0 || cInfo->InhabitType > INHABIT_ANYWHERE) { sLog.outErrorDb("Creature (Entry: %u) has wrong value (%u) in `InhabitType`, creature will not correctly walk/swim/fly",cInfo->Entry,cInfo->InhabitType); const_cast(cInfo)->InhabitType = INHABIT_ANYWHERE; } - if(cInfo->PetSpellDataId) + if (cInfo->PetSpellDataId) { CreatureSpellDataEntry const* spellDataId = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId); - if(!spellDataId) + if (!spellDataId) sLog.outErrorDb("Creature (Entry: %u) has non-existing PetSpellDataId (%u)", cInfo->Entry, cInfo->PetSpellDataId); } - for(int j = 0; j < CREATURE_MAX_SPELLS; ++j) + for (int j = 0; j < CREATURE_MAX_SPELLS; ++j) { - if(cInfo->spells[j] && !sSpellStore.LookupEntry(cInfo->spells[j])) + if (cInfo->spells[j] && !sSpellStore.LookupEntry(cInfo->spells[j])) { sLog.outErrorDb("Creature (Entry: %u) has non-existing Spell%d (%u), set to 0", cInfo->Entry, j+1,cInfo->spells[j]); const_cast(cInfo)->spells[j] = 0; } } - if(cInfo->MovementType >= MAX_DB_MOTION_TYPE) + if (cInfo->MovementType >= MAX_DB_MOTION_TYPE) { sLog.outErrorDb("Creature (Entry: %u) has wrong movement generator type (%u), ignore and set to IDLE.",cInfo->Entry,cInfo->MovementType); const_cast(cInfo)->MovementType = IDLE_MOTION_TYPE; @@ -684,25 +687,25 @@ void ObjectMgr::LoadCreatureTemplates() const_cast(cInfo)->vehicleId = 0; } - if(cInfo->equipmentId > 0) // 0 no equipment + if (cInfo->equipmentId > 0) // 0 no equipment { - if(!GetEquipmentInfo(cInfo->equipmentId)) + if (!GetEquipmentInfo(cInfo->equipmentId)) { sLog.outErrorDb("Table `creature_template` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", cInfo->Entry, cInfo->equipmentId); const_cast(cInfo)->equipmentId = 0; } } - if(cInfo->vendorId > 0) + if (cInfo->vendorId > 0) { - if(!(cInfo->npcflag & UNIT_NPC_FLAG_VENDOR)) + if (!(cInfo->npcflag & UNIT_NPC_FLAG_VENDOR)) sLog.outErrorDb("Table `creature_template` have creature (Entry: %u) with vendor_id %u but not have flag UNIT_NPC_FLAG_VENDOR (%u), vendor items will ignored.", cInfo->Entry, cInfo->vendorId, UNIT_NPC_FLAG_VENDOR); } /// if not set custom creature scale then load scale from CreatureDisplayInfo.dbc - if(cInfo->scale <= 0.0f) + if (cInfo->scale <= 0.0f) { - if(displayScaleEntry) + if (displayScaleEntry) const_cast(cInfo)->scale = displayScaleEntry->scale; else const_cast(cInfo)->scale = DEFAULT_OBJECT_SCALE; @@ -713,10 +716,10 @@ void ObjectMgr::LoadCreatureTemplates() void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr) { // Now add the auras, format "spell1 spell2 ..." - char *p,*s; + char* p,*s; std::vector val; s=p=(char*)reinterpret_cast(addon->auras); - if(p) + if (p) { while (p[0]!=0) { @@ -731,11 +734,11 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* val.push_back(atoi(s)); // free char* loaded memory - delete[] (char*)reinterpret_cast(addon->auras); + delete[](char*)reinterpret_cast(addon->auras); } // empty list - if(val.empty()) + if (val.empty()) { addon->auras = NULL; return; @@ -745,12 +748,12 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* const_cast(addon->auras) = new uint32[val.size()+1]; uint32 i = 0; - for(uint32 j = 0; j < val.size(); ++j) + for (uint32 j = 0; j < val.size(); ++j) { uint32& cAura = const_cast(addon->auras[i]); cAura = uint32(val[j]); - SpellEntry const *AdditionalSpellInfo = sSpellStore.LookupEntry(cAura); + SpellEntry const* AdditionalSpellInfo = sSpellStore.LookupEntry(cAura); if (!AdditionalSpellInfo) { sLog.outErrorDb("Creature (%s: %u) has wrong spell %u defined in `auras` field in `%s`.", guidEntryStr, addon->guidOrEntry, cAura,table); @@ -778,10 +781,10 @@ void ObjectMgr::LoadCreatureAddons(SQLStorage& creatureaddons, char const* entry sLog.outString(); // check data correctness and convert 'auras' - for(uint32 i = 1; i < creatureaddons.MaxEntry; ++i) + for (uint32 i = 1; i < creatureaddons.MaxEntry; ++i) { CreatureDataAddon const* addon = creatureaddons.LookupEntry(i); - if(!addon) + if (!addon) continue; if (addon->mount) @@ -811,17 +814,17 @@ void ObjectMgr::LoadCreatureAddons() LoadCreatureAddons(sCreatureInfoAddonStorage,"Entry","creature template addons"); // check entry ids - for(uint32 i = 1; i < sCreatureInfoAddonStorage.MaxEntry; ++i) - if(CreatureDataAddon const* addon = sCreatureInfoAddonStorage.LookupEntry(i)) - if(!sCreatureStorage.LookupEntry(addon->guidOrEntry)) + for (uint32 i = 1; i < sCreatureInfoAddonStorage.MaxEntry; ++i) + if (CreatureDataAddon const* addon = sCreatureInfoAddonStorage.LookupEntry(i)) + if (!sCreatureStorage.LookupEntry(addon->guidOrEntry)) sLog.outErrorDb("Creature (Entry: %u) does not exist but has a record in `%s`",addon->guidOrEntry, sCreatureInfoAddonStorage.GetTableName()); LoadCreatureAddons(sCreatureDataAddonStorage,"GUID","creature addons"); // check entry ids - for(uint32 i = 1; i < sCreatureDataAddonStorage.MaxEntry; ++i) - if(CreatureDataAddon const* addon = sCreatureDataAddonStorage.LookupEntry(i)) - if(mCreatureDataMap.find(addon->guidOrEntry)==mCreatureDataMap.end()) + for (uint32 i = 1; i < sCreatureDataAddonStorage.MaxEntry; ++i) + if (CreatureDataAddon const* addon = sCreatureDataAddonStorage.LookupEntry(i)) + if (mCreatureDataMap.find(addon->guidOrEntry)==mCreatureDataMap.end()) sLog.outErrorDb("Creature (GUID: %u) does not exist but has a record in `creature_addon`",addon->guidOrEntry); } @@ -829,19 +832,19 @@ void ObjectMgr::LoadEquipmentTemplates() { sEquipmentStorage.Load(); - for(uint32 i=0; i < sEquipmentStorage.MaxEntry; ++i) + for (uint32 i=0; i < sEquipmentStorage.MaxEntry; ++i) { EquipmentInfo const* eqInfo = sEquipmentStorage.LookupEntry(i); if (!eqInfo) continue; - for(uint8 j = 0; j < 3; ++j) + for (uint8 j = 0; j < 3; ++j) { if (!eqInfo->equipentry[j]) continue; - ItemEntry const *dbcitem = sItemStore.LookupEntry(eqInfo->equipentry[j]); + ItemEntry const* dbcitem = sItemStore.LookupEntry(eqInfo->equipentry[j]); if (!dbcitem) { sLog.outErrorDb("Unknown item (entry=%u) in creature_equip_template.equipentry%u for entry = %u, forced to 0.", eqInfo->equipentry[j], j+1, i); @@ -850,15 +853,15 @@ void ObjectMgr::LoadEquipmentTemplates() } if (dbcitem->InventoryType != INVTYPE_WEAPON && - dbcitem->InventoryType != INVTYPE_SHIELD && - dbcitem->InventoryType != INVTYPE_RANGED && - dbcitem->InventoryType != INVTYPE_2HWEAPON && - dbcitem->InventoryType != INVTYPE_WEAPONMAINHAND && - dbcitem->InventoryType != INVTYPE_WEAPONOFFHAND && - dbcitem->InventoryType != INVTYPE_HOLDABLE && - dbcitem->InventoryType != INVTYPE_THROWN && - dbcitem->InventoryType != INVTYPE_RANGEDRIGHT && - dbcitem->InventoryType != INVTYPE_RELIC) + dbcitem->InventoryType != INVTYPE_SHIELD && + dbcitem->InventoryType != INVTYPE_RANGED && + dbcitem->InventoryType != INVTYPE_2HWEAPON && + dbcitem->InventoryType != INVTYPE_WEAPONMAINHAND && + dbcitem->InventoryType != INVTYPE_WEAPONOFFHAND && + dbcitem->InventoryType != INVTYPE_HOLDABLE && + dbcitem->InventoryType != INVTYPE_THROWN && + dbcitem->InventoryType != INVTYPE_RANGEDRIGHT && + dbcitem->InventoryType != INVTYPE_RELIC) { sLog.outErrorDb("Item (entry=%u) in creature_equip_template.equipentry%u for entry = %u is not equipable in a hand, forced to 0.", eqInfo->equipentry[j], j+1, i); const_cast(eqInfo)->equipentry[j] = 0; @@ -866,7 +869,7 @@ void ObjectMgr::LoadEquipmentTemplates() } } - sLog.outString( ">> Loaded %u equipment template", sEquipmentStorage.RecordCount ); + sLog.outString(">> Loaded %u equipment template", sEquipmentStorage.RecordCount); sLog.outString(); } @@ -907,14 +910,14 @@ uint32 ObjectMgr::GetModelForRace(uint32 sourceModelId, uint32 racemask) CreatureModelRaceMapBounds bounds = m_mCreatureModelRaceMap.equal_range(sourceModelId); - for(CreatureModelRaceMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) + for (CreatureModelRaceMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { if (!(itr->second.racemask & racemask)) continue; if (itr->second.creature_entry) { - const CreatureInfo *cInfo = GetCreatureTemplate(itr->second.creature_entry); + const CreatureInfo* cInfo = GetCreatureTemplate(itr->second.creature_entry); modelId = Creature::ChooseDisplayId(cInfo); } else @@ -931,9 +934,9 @@ void ObjectMgr::LoadCreatureModelInfo() sCreatureModelStorage.Load(); // post processing - for(uint32 i = 1; i < sCreatureModelStorage.MaxEntry; ++i) + for (uint32 i = 1; i < sCreatureModelStorage.MaxEntry; ++i) { - CreatureModelInfo const *minfo = sCreatureModelStorage.LookupEntry(i); + CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry(i); if (!minfo) continue; @@ -976,7 +979,7 @@ void ObjectMgr::LoadCreatureModelInfo() } // character races expected have model info data in table - for(uint32 race = 1; race < sChrRacesStore.GetNumRows(); ++race) + for (uint32 race = 1; race < sChrRacesStore.GetNumRows(); ++race) { ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(race); if (!raceEntry) @@ -985,7 +988,7 @@ void ObjectMgr::LoadCreatureModelInfo() if (!((1 << (race-1)) & RACEMASK_ALL_PLAYABLE)) continue; - if (CreatureModelInfo const *minfo = GetCreatureModelInfo(raceEntry->model_f)) + if (CreatureModelInfo const* minfo = GetCreatureModelInfo(raceEntry->model_f)) { if (minfo->gender != GENDER_FEMALE) sLog.outErrorDb("Table `creature_model_info` have wrong gender %u for character race %u female model id %u", minfo->gender, race, raceEntry->model_f); @@ -1008,7 +1011,7 @@ void ObjectMgr::LoadCreatureModelInfo() else sLog.outErrorDb("Table `creature_model_info` expect have data for character race %u female model id %u", race, raceEntry->model_f); - if (CreatureModelInfo const *minfo = GetCreatureModelInfo(raceEntry->model_m)) + if (CreatureModelInfo const* minfo = GetCreatureModelInfo(raceEntry->model_m)) { if (minfo->gender != GENDER_MALE) sLog.outErrorDb("Table `creature_model_info` have wrong gender %u for character race %u male model id %u", minfo->gender, race, raceEntry->model_m); @@ -1033,7 +1036,7 @@ void ObjectMgr::LoadCreatureModelInfo() } - sLog.outString( ">> Loaded %u creature model based info", sCreatureModelStorage.RecordCount ); + sLog.outString(">> Loaded %u creature model based info", sCreatureModelStorage.RecordCount); sLog.outString(); } @@ -1148,29 +1151,29 @@ void ObjectMgr::LoadCreatureModelRace() ++count; } - while(result->NextRow()); + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u creature_model_race entries", count); + sLog.outString(">> Loaded %u creature_model_race entries", count); } void ObjectMgr::LoadCreatures() { uint32 count = 0; // 0 1 2 3 - QueryResult *result = WorldDatabase.Query("SELECT creature.guid, creature.id, map, modelid," - // 4 5 6 7 8 9 10 11 - "equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint," - // 12 13 14 15 16 17 18 - "curhealth, curmana, DeathState, MovementType, spawnMask, phaseMask, event," - // 19 20 - "pool_creature.pool_entry, pool_creature_template.pool_entry " - "FROM creature " - "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid " - "LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid " - "LEFT OUTER JOIN pool_creature_template ON creature.id = pool_creature_template.id"); + QueryResult* result = WorldDatabase.Query("SELECT creature.guid, creature.id, map, modelid," + // 4 5 6 7 8 9 10 11 + "equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint," + // 12 13 14 15 16 17 18 + "curhealth, curmana, DeathState, MovementType, spawnMask, phaseMask, event," + // 19 20 + "pool_creature.pool_entry, pool_creature_template.pool_entry " + "FROM creature " + "LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid " + "LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid " + "LEFT OUTER JOIN pool_creature_template ON creature.id = pool_creature_template.id"); if (!result) { @@ -1193,9 +1196,9 @@ void ObjectMgr::LoadCreatures() // build single time for check spawnmask std::map spawnMasks; - for(uint32 i = 0; i < sMapStore.GetNumRows(); ++i) - if(sMapStore.LookupEntry(i)) - for(int k = 0; k < MAX_DIFFICULTY; ++k) + for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i) + if (sMapStore.LookupEntry(i)) + for (int k = 0; k < MAX_DIFFICULTY; ++k) if (GetMapDifficultyData(i,Difficulty(k))) spawnMasks[i] |= (1 << k); @@ -1203,7 +1206,7 @@ void ObjectMgr::LoadCreatures() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 guid = fields[ 0].GetUInt32(); @@ -1240,14 +1243,14 @@ void ObjectMgr::LoadCreatures() int16 EntryPoolId = fields[20].GetInt16(); MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid); - if(!mapEntry) + if (!mapEntry) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u) that spawned at nonexistent map (Id: %u), skipped.",guid, data.mapid ); + sLog.outErrorDb("Table `creature` have creature (GUID: %u) that spawned at nonexistent map (Id: %u), skipped.",guid, data.mapid); continue; } if (data.spawnMask & ~spawnMasks[data.mapid]) - sLog.outErrorDb("Table `creature` have creature (GUID: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u).",guid, data.spawnMask, data.mapid ); + sLog.outErrorDb("Table `creature` have creature (GUID: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u).",guid, data.spawnMask, data.mapid); bool ok = true; for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff) @@ -1255,7 +1258,7 @@ void ObjectMgr::LoadCreatures() if (difficultyCreatures[diff].find(data.id) != difficultyCreatures[diff].end()) { sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as difficulty %u template (entry: %u) in `creature_template`, skipped.", - guid, diff + 1, data.id ); + guid, diff + 1, data.id); ok = false; } } @@ -1268,66 +1271,66 @@ void ObjectMgr::LoadCreatures() data.modelid_override = 0; } - if(data.equipmentId > 0) // -1 no equipment, 0 use default + if (data.equipmentId > 0) // -1 no equipment, 0 use default { - if(!GetEquipmentInfo(data.equipmentId)) + if (!GetEquipmentInfo(data.equipmentId)) { sLog.outErrorDb("Table `creature` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", data.id, data.equipmentId); data.equipmentId = -1; } } - if(cInfo->RegenHealth && data.curhealth < cInfo->minhealth) + if (cInfo->RegenHealth && data.curhealth < cInfo->minhealth) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`RegenHealth`=1 and low current health (%u), `creature_template`.`minhealth`=%u.",guid,data.id,data.curhealth, cInfo->minhealth ); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`RegenHealth`=1 and low current health (%u), `creature_template`.`minhealth`=%u.",guid,data.id,data.curhealth, cInfo->minhealth); data.curhealth = cInfo->minhealth; } - if(cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) + if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) { - if(!mapEntry || !mapEntry->IsDungeon()) + if (!mapEntry || !mapEntry->IsDungeon()) sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND (%u) but creature are not in instance.", - guid, data.id, CREATURE_FLAG_EXTRA_INSTANCE_BIND); + guid, data.id, CREATURE_FLAG_EXTRA_INSTANCE_BIND); } - if(cInfo->flags_extra & CREATURE_FLAG_EXTRA_AGGRO_ZONE) + if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_AGGRO_ZONE) { - if(!mapEntry || !mapEntry->IsDungeon()) + if (!mapEntry || !mapEntry->IsDungeon()) sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_AGGRO_ZONE (%u) but creature are not in instance.", - guid, data.id, CREATURE_FLAG_EXTRA_AGGRO_ZONE); + guid, data.id, CREATURE_FLAG_EXTRA_AGGRO_ZONE); } - if(data.curmana < cInfo->minmana) + if (data.curmana < cInfo->minmana) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with low current mana (%u), `creature_template`.`minmana`=%u.",guid,data.id,data.curmana, cInfo->minmana ); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with low current mana (%u), `creature_template`.`minmana`=%u.",guid,data.id,data.curmana, cInfo->minmana); data.curmana = cInfo->minmana; } - if(data.spawndist < 0.0f) + if (data.spawndist < 0.0f) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.",guid,data.id ); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.",guid,data.id); data.spawndist = 0.0f; } - else if(data.movementType == RANDOM_MOTION_TYPE) + else if (data.movementType == RANDOM_MOTION_TYPE) { - if(data.spawndist == 0.0f) + if (data.spawndist == 0.0f) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).",guid,data.id ); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).",guid,data.id); data.movementType = IDLE_MOTION_TYPE; } } - else if(data.movementType == IDLE_MOTION_TYPE) + else if (data.movementType == IDLE_MOTION_TYPE) { - if(data.spawndist != 0.0f) + if (data.spawndist != 0.0f) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `spawndist`<>0, set to 0.",guid,data.id ); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `spawndist`<>0, set to 0.",guid,data.id); data.spawndist = 0.0f; } } - if(data.phaseMask==0) + if (data.phaseMask==0) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.",guid,data.id ); + sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.",guid,data.id); data.phaseMask = 1; } @@ -1336,20 +1339,21 @@ void ObjectMgr::LoadCreatures() ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %lu creatures", (unsigned long)mCreatureDataMap.size() ); + sLog.outString(">> Loaded %lu creatures", (unsigned long)mCreatureDataMap.size()); } void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) { uint8 mask = data->spawnMask; - for(uint8 i = 0; mask != 0; i++, mask >>= 1) + for (uint8 i = 0; mask != 0; i++, mask >>= 1) { - if(mask & 1) + if (mask & 1) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; @@ -1363,9 +1367,9 @@ void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data) void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data) { uint8 mask = data->spawnMask; - for(uint8 i = 0; mask != 0; i++, mask >>= 1) + for (uint8 i = 0; mask != 0; i++, mask >>= 1) { - if(mask & 1) + if (mask & 1) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; @@ -1381,15 +1385,15 @@ void ObjectMgr::LoadGameObjects() uint32 count = 0; // 0 1 2 3 4 5 6 - QueryResult *result = WorldDatabase.Query("SELECT gameobject.guid, gameobject.id, map, position_x, position_y, position_z, orientation," - // 7 8 9 10 11 12 13 14 15 16 - "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, event," - // 17 18 - "pool_gameobject.pool_entry, pool_gameobject_template.pool_entry " - "FROM gameobject " - "LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid " - "LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid " - "LEFT OUTER JOIN pool_gameobject_template ON gameobject.id = pool_gameobject_template.id"); + QueryResult* result = WorldDatabase.Query("SELECT gameobject.guid, gameobject.id, map, position_x, position_y, position_z, orientation," + // 7 8 9 10 11 12 13 14 15 16 + "rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, event," + // 17 18 + "pool_gameobject.pool_entry, pool_gameobject_template.pool_entry " + "FROM gameobject " + "LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid " + "LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid " + "LEFT OUTER JOIN pool_gameobject_template ON gameobject.id = pool_gameobject_template.id"); if (!result) { @@ -1404,9 +1408,9 @@ void ObjectMgr::LoadGameObjects() // build single time for check spawnmask std::map spawnMasks; - for(uint32 i = 0; i < sMapStore.GetNumRows(); ++i) - if(sMapStore.LookupEntry(i)) - for(int k = 0; k < MAX_DIFFICULTY; ++k) + for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i) + if (sMapStore.LookupEntry(i)) + for (int k = 0; k < MAX_DIFFICULTY; ++k) if (GetMapDifficultyData(i,Difficulty(k))) spawnMasks[i] |= (1 << k); @@ -1414,7 +1418,7 @@ void ObjectMgr::LoadGameObjects() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 guid = fields[ 0].GetUInt32(); @@ -1429,9 +1433,9 @@ void ObjectMgr::LoadGameObjects() if (!gInfo->displayId) { - switch(gInfo->type) + switch (gInfo->type) { - // can be invisible always and then not req. display id in like case + // can be invisible always and then not req. display id in like case case GAMEOBJECT_TYPE_TRAP: case GAMEOBJECT_TYPE_SPELL_FOCUS: break; @@ -1530,12 +1534,13 @@ void ObjectMgr::LoadGameObjects() ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %lu gameobjects", (unsigned long)mGameObjectDataMap.size()); + sLog.outString(">> Loaded %lu gameobjects", (unsigned long)mGameObjectDataMap.size()); } void ObjectMgr::LoadGameObjectAddon() @@ -1545,7 +1550,7 @@ void ObjectMgr::LoadGameObjectAddon() sLog.outString(">> Loaded %u gameobject addons", sGameObjectDataAddonStorage.RecordCount); sLog.outString(); - for(uint32 i = 1; i < sGameObjectDataAddonStorage.MaxEntry; ++i) + for (uint32 i = 1; i < sGameObjectDataAddonStorage.MaxEntry; ++i) { GameObjectDataAddon const* addon = sGameObjectDataAddonStorage.LookupEntry(i); if (!addon) @@ -1568,9 +1573,9 @@ void ObjectMgr::LoadGameObjectAddon() void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) { uint8 mask = data->spawnMask; - for(uint8 i = 0; mask != 0; i++, mask >>= 1) + for (uint8 i = 0; mask != 0; i++, mask >>= 1) { - if(mask & 1) + if (mask & 1) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; @@ -1584,9 +1589,9 @@ void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data) void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data) { uint8 mask = data->spawnMask; - for(uint8 i = 0; mask != 0; i++, mask >>= 1) + for (uint8 i = 0; mask != 0; i++, mask >>= 1) { - if(mask & 1) + if (mask & 1) { CellPair cell_pair = MaNGOS::ComputeCellPair(data->posX, data->posY); uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord; @@ -1605,7 +1610,7 @@ ObjectGuid ObjectMgr::GetPlayerGuidByName(std::string name) const CharacterDatabase.escape_string(name); // Player name safe to sending to DB (checked at login) and this function using - QueryResult *result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE name = '%s'", name.c_str()); + QueryResult* result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE name = '%s'", name.c_str()); if (result) { guid = ObjectGuid(HIGHGUID_PLAYER, (*result)[0].GetUInt32()); @@ -1616,10 +1621,10 @@ ObjectGuid ObjectMgr::GetPlayerGuidByName(std::string name) const return guid; } -bool ObjectMgr::GetPlayerNameByGUID(ObjectGuid guid, std::string &name) const +bool ObjectMgr::GetPlayerNameByGUID(ObjectGuid guid, std::string& name) const { // prevent DB access for online player - if(Player* player = GetPlayer(guid)) + if (Player* player = GetPlayer(guid)) { name = player->GetName(); return true; @@ -1627,9 +1632,9 @@ bool ObjectMgr::GetPlayerNameByGUID(ObjectGuid guid, std::string &name) const uint32 lowguid = guid.GetCounter(); - QueryResult *result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = '%u'", lowguid); + QueryResult* result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = '%u'", lowguid); - if(result) + if (result) { name = (*result)[0].GetCppString(); delete result; @@ -1647,7 +1652,7 @@ Team ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const uint32 lowguid = guid.GetCounter(); - QueryResult *result = CharacterDatabase.PQuery("SELECT race FROM characters WHERE guid = '%u'", lowguid); + QueryResult* result = CharacterDatabase.PQuery("SELECT race FROM characters WHERE guid = '%u'", lowguid); if (result) { @@ -1665,12 +1670,12 @@ uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const return 0; // prevent DB access for online player - if(Player* player = GetPlayer(guid)) + if (Player* player = GetPlayer(guid)) return player->GetSession()->GetAccountId(); uint32 lowguid = guid.GetCounter(); - QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE guid = '%u'", lowguid); + QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE guid = '%u'", lowguid); if (result) { uint32 acc = (*result)[0].GetUInt32(); @@ -1683,8 +1688,8 @@ uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const uint32 ObjectMgr::GetPlayerAccountIdByPlayerName(const std::string& name) const { - QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", name.c_str()); - if(result) + QueryResult* result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", name.c_str()); + if (result) { uint32 acc = (*result)[0].GetUInt32(); delete result; @@ -1698,7 +1703,7 @@ void ObjectMgr::LoadItemLocales() { mItemLocaleMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,description_loc1,name_loc2,description_loc2,name_loc3,description_loc3,name_loc4,description_loc4,name_loc5,description_loc5,name_loc6,description_loc6,name_loc7,description_loc7,name_loc8,description_loc8 FROM locales_item"); + QueryResult* result = WorldDatabase.Query("SELECT entry,name_loc1,description_loc1,name_loc2,description_loc2,name_loc3,description_loc3,name_loc4,description_loc4,name_loc5,description_loc5,name_loc6,description_loc6,name_loc7,description_loc7,name_loc8,description_loc8 FROM locales_item"); if (!result) { @@ -1715,7 +1720,7 @@ void ObjectMgr::LoadItemLocales() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); @@ -1728,15 +1733,15 @@ void ObjectMgr::LoadItemLocales() ItemLocale& data = mItemLocaleMap[entry]; - for(int i = 1; i < MAX_LOCALE; ++i) + for (int i = 1; i < MAX_LOCALE; ++i) { std::string str = fields[1+2*(i-1)].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.Name.size() <= idx) + if ((int32)data.Name.size() <= idx) data.Name.resize(idx+1); data.Name[idx] = str; @@ -1744,30 +1749,31 @@ void ObjectMgr::LoadItemLocales() } str = fields[1+2*(i-1)+1].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.Description.size() <= idx) + if ((int32)data.Description.size() <= idx) data.Description.resize(idx+1); data.Description[idx] = str; } } } - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %lu Item locale strings", (unsigned long)mItemLocaleMap.size() ); + sLog.outString(">> Loaded %lu Item locale strings", (unsigned long)mItemLocaleMap.size()); } struct SQLItemLoader : public SQLStorageLoaderBase { template - void convert_from_str(uint32 /*field_pos*/, char const *src, D &dst) + void convert_from_str(uint32 /*field_pos*/, char const* src, D& dst) { dst = D(sScriptMgr.GetScriptId(src)); } @@ -1777,15 +1783,15 @@ void ObjectMgr::LoadItemPrototypes() { SQLItemLoader loader; loader.Load(sItemStorage); - sLog.outString( ">> Loaded %u item prototypes", sItemStorage.RecordCount ); + sLog.outString(">> Loaded %u item prototypes", sItemStorage.RecordCount); sLog.outString(); // check data correctness - for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i) + for (uint32 i = 1; i < sItemStorage.MaxEntry; ++i) { ItemPrototype const* proto = sItemStorage.LookupEntry(i); - ItemEntry const *dbcitem = sItemStore.LookupEntry(i); - if(!proto) + ItemEntry const* dbcitem = sItemStore.LookupEntry(i); + if (!proto) { /* to many errors, and possible not all items really used in game if (dbcitem) @@ -1794,9 +1800,9 @@ void ObjectMgr::LoadItemPrototypes() continue; } - if(dbcitem) + if (dbcitem) { - if(proto->Class != dbcitem->Class) + if (proto->Class != dbcitem->Class) { sLog.outErrorDb("Item (Entry: %u) not correct class %u, must be %u (still using DB value).",i,proto->Class,dbcitem->Class); // It safe let use Class from DB @@ -1810,30 +1816,30 @@ void ObjectMgr::LoadItemPrototypes() } */ - if(proto->Unk0 != dbcitem->Unk0) + if (proto->Unk0 != dbcitem->Unk0) { sLog.outErrorDb("Item (Entry: %u) not correct %i Unk0, must be %i (still using DB value).",i,proto->Unk0,dbcitem->Unk0); // It safe let use Unk0 from DB } - if(proto->Material != dbcitem->Material) + if (proto->Material != dbcitem->Material) { sLog.outErrorDb("Item (Entry: %u) not correct %i material, must be %i (still using DB value).",i,proto->Material,dbcitem->Material); // It safe let use Material from DB } - if(proto->InventoryType != dbcitem->InventoryType) + if (proto->InventoryType != dbcitem->InventoryType) { sLog.outErrorDb("Item (Entry: %u) not correct %u inventory type, must be %u (still using DB value).",i,proto->InventoryType,dbcitem->InventoryType); // It safe let use InventoryType from DB } - if(proto->DisplayInfoID != dbcitem->DisplayId) + if (proto->DisplayInfoID != dbcitem->DisplayId) { sLog.outErrorDb("Item (Entry: %u) not correct %u display id, must be %u (using it).",i,proto->DisplayInfoID,dbcitem->DisplayId); const_cast(proto)->DisplayInfoID = dbcitem->DisplayId; } - if(proto->Sheath != dbcitem->Sheath) + if (proto->Sheath != dbcitem->Sheath) { sLog.outErrorDb("Item (Entry: %u) not correct %u sheath, must be %u (using it).",i,proto->Sheath,dbcitem->Sheath); const_cast(proto)->Sheath = dbcitem->Sheath; @@ -1844,19 +1850,19 @@ void ObjectMgr::LoadItemPrototypes() sLog.outErrorDb("Item (Entry: %u) not correct (not listed in list of existing items).",i); } - if(proto->Class >= MAX_ITEM_CLASS) + if (proto->Class >= MAX_ITEM_CLASS) { sLog.outErrorDb("Item (Entry: %u) has wrong Class value (%u)",i,proto->Class); const_cast(proto)->Class = ITEM_CLASS_MISC; } - if(proto->SubClass >= MaxItemSubclassValues[proto->Class]) + if (proto->SubClass >= MaxItemSubclassValues[proto->Class]) { sLog.outErrorDb("Item (Entry: %u) has wrong Subclass value (%u) for class %u",i,proto->SubClass,proto->Class); const_cast(proto)->SubClass = 0;// exist for all item classes } - if(proto->Quality >= MAX_ITEM_QUALITY) + if (proto->Quality >= MAX_ITEM_QUALITY) { sLog.outErrorDb("Item (Entry: %u) has wrong Quality value (%u)",i,proto->Quality); const_cast(proto)->Quality = ITEM_QUALITY_NORMAL; @@ -1867,27 +1873,27 @@ void ObjectMgr::LoadItemPrototypes() if (FactionEntry const* faction = sFactionStore.LookupEntry(HORDE)) if ((proto->AllowableRace & faction->BaseRepRaceMask[0]) == 0) sLog.outErrorDb("Item (Entry: %u) have in `AllowableRace` races (%u) only not compatible with ITEM_FLAG2_HORDE_ONLY (%u) in Flags field, item any way will can't be equipped or use by this races.", - i, proto->AllowableRace, ITEM_FLAG2_HORDE_ONLY); + i, proto->AllowableRace, ITEM_FLAG2_HORDE_ONLY); if (proto->Flags2 & ITEM_FLAG2_ALLIANCE_ONLY) sLog.outErrorDb("Item (Entry: %u) have in `Flags2` flags ITEM_FLAG2_ALLIANCE_ONLY (%u) and ITEM_FLAG2_HORDE_ONLY (%u) in Flags field, this is wrong combination.", - i, ITEM_FLAG2_ALLIANCE_ONLY, ITEM_FLAG2_HORDE_ONLY); + i, ITEM_FLAG2_ALLIANCE_ONLY, ITEM_FLAG2_HORDE_ONLY); } else if (proto->Flags2 & ITEM_FLAG2_ALLIANCE_ONLY) { if (FactionEntry const* faction = sFactionStore.LookupEntry(ALLIANCE)) if ((proto->AllowableRace & faction->BaseRepRaceMask[0]) == 0) sLog.outErrorDb("Item (Entry: %u) have in `AllowableRace` races (%u) only not compatible with ITEM_FLAG2_ALLIANCE_ONLY (%u) in Flags field, item any way will can't be equipped or use by this races.", - i, proto->AllowableRace, ITEM_FLAG2_ALLIANCE_ONLY); + i, proto->AllowableRace, ITEM_FLAG2_ALLIANCE_ONLY); } - if(proto->BuyCount <= 0) + if (proto->BuyCount <= 0) { sLog.outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",i,proto->BuyCount); const_cast(proto)->BuyCount = 1; } - if(proto->InventoryType >= MAX_INVTYPE) + if (proto->InventoryType >= MAX_INVTYPE) { sLog.outErrorDb("Item (Entry: %u) has wrong InventoryType value (%u)",i,proto->InventoryType); const_cast(proto)->InventoryType = INVTYPE_NON_EQUIP; @@ -1895,19 +1901,19 @@ void ObjectMgr::LoadItemPrototypes() if (proto->InventoryType != INVTYPE_NON_EQUIP) { - if(proto->Flags & ITEM_FLAG_LOOTABLE) + if (proto->Flags & ITEM_FLAG_LOOTABLE) { sLog.outErrorDb("Item container (Entry: %u) has not allowed for containers flag ITEM_FLAG_LOOTABLE (%u), flag removed.", i, ITEM_FLAG_LOOTABLE); const_cast(proto)->Flags &= ~ITEM_FLAG_LOOTABLE; } - if(proto->Flags & ITEM_FLAG_MILLABLE) + if (proto->Flags & ITEM_FLAG_MILLABLE) { sLog.outErrorDb("Item container (Entry: %u) has not allowed for containers flag ITEM_FLAG_MILLABLE (%u), flag removed.", i, ITEM_FLAG_MILLABLE); const_cast(proto)->Flags &= ~ITEM_FLAG_MILLABLE; } - if(proto->Flags & ITEM_FLAG_PROSPECTABLE) + if (proto->Flags & ITEM_FLAG_PROSPECTABLE) { sLog.outErrorDb("Item container (Entry: %u) has not allowed for containers flag ITEM_FLAG_PROSPECTABLE (%u), flag removed.", i, ITEM_FLAG_PROSPECTABLE); const_cast(proto)->Flags &= ~ITEM_FLAG_PROSPECTABLE; @@ -1922,7 +1928,7 @@ void ObjectMgr::LoadItemPrototypes() } } - if(proto->RequiredSkill >= MAX_SKILL_TYPE) + if (proto->RequiredSkill >= MAX_SKILL_TYPE) { sLog.outErrorDb("Item (Entry: %u) has wrong RequiredSkill value (%u)",i,proto->RequiredSkill); const_cast(proto)->RequiredSkill = 0; @@ -1931,11 +1937,11 @@ void ObjectMgr::LoadItemPrototypes() { // can be used in equip slot, as page read use in inventory, or spell casting at use bool req = proto->InventoryType!=INVTYPE_NON_EQUIP || proto->PageText; - if(!req) + if (!req) { for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j) { - if(proto->Spells[j].SpellId) + if (proto->Spells[j].SpellId) { req = true; break; @@ -1943,56 +1949,56 @@ void ObjectMgr::LoadItemPrototypes() } } - if(req) + if (req) { - if(!(proto->AllowableClass & CLASSMASK_ALL_PLAYABLE)) + if (!(proto->AllowableClass & CLASSMASK_ALL_PLAYABLE)) sLog.outErrorDb("Item (Entry: %u) not have in `AllowableClass` any playable classes (%u) and can't be equipped or use.",i,proto->AllowableClass); - if(!(proto->AllowableRace & RACEMASK_ALL_PLAYABLE)) + if (!(proto->AllowableRace & RACEMASK_ALL_PLAYABLE)) sLog.outErrorDb("Item (Entry: %u) not have in `AllowableRace` any playable races (%u) and can't be equipped or use.",i,proto->AllowableRace); } } - if(proto->RequiredSpell && !sSpellStore.LookupEntry(proto->RequiredSpell)) + if (proto->RequiredSpell && !sSpellStore.LookupEntry(proto->RequiredSpell)) { sLog.outErrorDb("Item (Entry: %u) have wrong (nonexistent) spell in RequiredSpell (%u)",i,proto->RequiredSpell); const_cast(proto)->RequiredSpell = 0; } - if(proto->RequiredReputationRank >= MAX_REPUTATION_RANK) + if (proto->RequiredReputationRank >= MAX_REPUTATION_RANK) sLog.outErrorDb("Item (Entry: %u) has wrong reputation rank in RequiredReputationRank (%u), item can't be used.",i,proto->RequiredReputationRank); - if(proto->RequiredReputationFaction) + if (proto->RequiredReputationFaction) { - if(!sFactionStore.LookupEntry(proto->RequiredReputationFaction)) + if (!sFactionStore.LookupEntry(proto->RequiredReputationFaction)) { sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) faction in RequiredReputationFaction (%u)",i,proto->RequiredReputationFaction); const_cast(proto)->RequiredReputationFaction = 0; } - if(proto->RequiredReputationRank == MIN_REPUTATION_RANK) + if (proto->RequiredReputationRank == MIN_REPUTATION_RANK) sLog.outErrorDb("Item (Entry: %u) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.",i); } - else if(proto->RequiredReputationRank > MIN_REPUTATION_RANK) + else if (proto->RequiredReputationRank > MIN_REPUTATION_RANK) sLog.outErrorDb("Item (Entry: %u) has RequiredReputationFaction ==0 but RequiredReputationRank > 0, rank setting is useless.",i); - if(proto->MaxCount < -1) + if (proto->MaxCount < -1) { sLog.outErrorDb("Item (Entry: %u) has too large negative in maxcount (%i), replace by value (-1) no storing limits.",i,proto->MaxCount); const_cast(proto)->MaxCount = -1; } - if(proto->Stackable == 0) + if (proto->Stackable == 0) { sLog.outErrorDb("Item (Entry: %u) has wrong value in stackable (%i), replace by default 1.",i,proto->Stackable); const_cast(proto)->Stackable = 1; } - else if(proto->Stackable < -1) + else if (proto->Stackable < -1) { sLog.outErrorDb("Item (Entry: %u) has too large negative in stackable (%i), replace by value (-1) no stacking limits.",i,proto->Stackable); const_cast(proto)->Stackable = -1; } - else if(proto->Stackable > 1000) + else if (proto->Stackable > 1000) { sLog.outErrorDb("Item (Entry: %u) has too large value in stackable (%u), replace by hardcoded upper limit (1000).",i,proto->Stackable); const_cast(proto)->Stackable = 1000; @@ -2007,7 +2013,7 @@ void ObjectMgr::LoadItemPrototypes() } } - if(proto->StatsCount > MAX_ITEM_PROTO_STATS) + if (proto->StatsCount > MAX_ITEM_PROTO_STATS) { sLog.outErrorDb("Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).",i,proto->StatsCount,MAX_ITEM_PROTO_STATS); const_cast(proto)->StatsCount = MAX_ITEM_PROTO_STATS; @@ -2016,13 +2022,13 @@ void ObjectMgr::LoadItemPrototypes() for (int j = 0; j < MAX_ITEM_PROTO_STATS; ++j) { // for ItemStatValue != 0 - if(proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD) + if (proto->ItemStat[j].ItemStatValue && proto->ItemStat[j].ItemStatType >= MAX_ITEM_MOD) { sLog.outErrorDb("Item (Entry: %u) has wrong stat_type%d (%u)",i,j+1,proto->ItemStat[j].ItemStatType); const_cast(proto)->ItemStat[j].ItemStatType = 0; } - switch(proto->ItemStat[j].ItemStatType) + switch (proto->ItemStat[j].ItemStatType) { case ITEM_MOD_SPELL_HEALING_DONE: case ITEM_MOD_SPELL_DAMAGE_DONE: @@ -2035,7 +2041,7 @@ void ObjectMgr::LoadItemPrototypes() for (int j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j) { - if(proto->Damage[j].DamageType >= MAX_SPELL_SCHOOL) + if (proto->Damage[j].DamageType >= MAX_SPELL_SCHOOL) { sLog.outErrorDb("Item (Entry: %u) has wrong dmg_type%d (%u)",i,j+1,proto->Damage[j].DamageType); const_cast(proto)->Damage[j].DamageType = 0; @@ -2043,10 +2049,10 @@ void ObjectMgr::LoadItemPrototypes() } // special format - if((proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN) || (proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN_PET)) + if ((proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN) || (proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN_PET)) { // spell_1 - if(proto->Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) + if (proto->Spells[0].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) { sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format",i,0+1,proto->Spells[0].SpellTrigger); const_cast(proto)->Spells[0].SpellId = 0; @@ -2056,14 +2062,14 @@ void ObjectMgr::LoadItemPrototypes() } // spell_2 have learning spell - if(proto->Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID) + if (proto->Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID) { sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u) for special learning format.",i,1+1,proto->Spells[1].SpellTrigger); const_cast(proto)->Spells[0].SpellId = 0; const_cast(proto)->Spells[1].SpellId = 0; const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } - else if(!proto->Spells[1].SpellId) + else if (!proto->Spells[1].SpellId) { sLog.outErrorDb("Item (Entry: %u) not has expected spell in spellid_%d in special learning format.",i,1+1); const_cast(proto)->Spells[0].SpellId = 0; @@ -2072,7 +2078,7 @@ void ObjectMgr::LoadItemPrototypes() else { SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[1].SpellId); - if(!spellInfo) + if (!spellInfo) { sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId); const_cast(proto)->Spells[0].SpellId = 0; @@ -2080,7 +2086,7 @@ void ObjectMgr::LoadItemPrototypes() const_cast(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } // allowed only in special format - else if((proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN_PET)) + else if ((proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[1].SpellId==SPELL_ID_GENERIC_LEARN_PET)) { sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,1+1,proto->Spells[1].SpellId); const_cast(proto)->Spells[0].SpellId = 0; @@ -2092,13 +2098,13 @@ void ObjectMgr::LoadItemPrototypes() // spell_3*,spell_4*,spell_5* is empty for (int j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j) { - if(proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) + if (proto->Spells[j].SpellTrigger != ITEM_SPELLTRIGGER_ON_USE) { sLog.outErrorDb("Item (Entry: %u) has wrong item spell trigger value in spelltrigger_%d (%u)",i,j+1,proto->Spells[j].SpellTrigger); const_cast(proto)->Spells[j].SpellId = 0; const_cast(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE; } - else if(proto->Spells[j].SpellId != 0) + else if (proto->Spells[j].SpellId != 0) { sLog.outErrorDb("Item (Entry: %u) has wrong spell in spellid_%d (%u) for learning special format",i,j+1,proto->Spells[j].SpellId); const_cast(proto)->Spells[j].SpellId = 0; @@ -2119,20 +2125,20 @@ void ObjectMgr::LoadItemPrototypes() // on hit can be sued only at weapon else if (proto->Spells[j].SpellTrigger == ITEM_SPELLTRIGGER_CHANCE_ON_HIT) { - if(proto->Class != ITEM_CLASS_WEAPON) + if (proto->Class != ITEM_CLASS_WEAPON) sLog.outErrorDb("Item (Entry: %u) isn't weapon (Class: %u) but has on hit spelltrigger_%d (%u), it will not triggered.",i,proto->Class,j+1,proto->Spells[j].SpellTrigger); } - if(proto->Spells[j].SpellId) + if (proto->Spells[j].SpellId) { SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[j].SpellId); - if(!spellInfo) + if (!spellInfo) { sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId); const_cast(proto)->Spells[j].SpellId = 0; } // allowed only in special format - else if((proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN_PET)) + else if ((proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN) || (proto->Spells[j].SpellId==SPELL_ID_GENERIC_LEARN_PET)) { sLog.outErrorDb("Item (Entry: %u) has broken spell in spellid_%d (%u)",i,j+1,proto->Spells[j].SpellId); const_cast(proto)->Spells[j].SpellId = 0; @@ -2175,7 +2181,7 @@ void ObjectMgr::LoadItemPrototypes() if (proto->RandomProperty && proto->RandomSuffix) { sLog.outErrorDb("Item (Entry: %u) have RandomProperty==%u and RandomSuffix==%u, but must have one from field = 0", - proto->ItemId, proto->RandomProperty, proto->RandomSuffix); + proto->ItemId, proto->RandomProperty, proto->RandomSuffix); const_cast(proto)->RandomSuffix = 0; } @@ -2245,14 +2251,14 @@ void ObjectMgr::LoadItemPrototypes() if (proto->Quality > ITEM_QUALITY_EPIC || proto->Quality < ITEM_QUALITY_UNCOMMON) { ERROR_DB_STRICT_LOG("Item (Entry: %u) has unexpected RequiredDisenchantSkill (%u) for non-disenchantable quality (%u), reset it.", - i, proto->RequiredDisenchantSkill, proto->Quality); + i, proto->RequiredDisenchantSkill, proto->Quality); const_cast(proto)->RequiredDisenchantSkill = -1; } else if (proto->Class != ITEM_CLASS_WEAPON && proto->Class != ITEM_CLASS_ARMOR) { // some wrong data in wdb for unused items ERROR_DB_STRICT_LOG("Item (Entry: %u) has unexpected RequiredDisenchantSkill (%u) for non-disenchantable item class (%u), reset it.", - i, proto->RequiredDisenchantSkill, proto->Class); + i, proto->RequiredDisenchantSkill, proto->Class); const_cast(proto)->RequiredDisenchantSkill = -1; } } @@ -2310,7 +2316,7 @@ void ObjectMgr::LoadItemPrototypes() bool can_be_need = false; for (int j = 0; j < MAX_ITEM_PROTO_SPELLS; ++j) { - if(proto->Spells[j].SpellCharges < 0) + if (proto->Spells[j].SpellCharges < 0) { can_be_need = true; break; @@ -2366,7 +2372,7 @@ void ObjectMgr::LoadItemConverts() uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT entry,item FROM item_convert"); + QueryResult* result = WorldDatabase.Query("SELECT entry,item FROM item_convert"); if (!result) { @@ -2383,7 +2389,7 @@ void ObjectMgr::LoadItemConverts() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 itemEntry = fields[0].GetUInt32(); @@ -2406,8 +2412,8 @@ void ObjectMgr::LoadItemConverts() // 2 cases when item convert used // Boa item with reputation requirement if ((!(pItemEntryProto->Flags & ITEM_FLAG_BOA) || !pItemEntryProto->RequiredReputationFaction) && - // convertion to another team/race - (pItemTargetProto->AllowableRace & pItemEntryProto->AllowableRace)) + // convertion to another team/race + (pItemTargetProto->AllowableRace & pItemEntryProto->AllowableRace)) { sLog.outErrorDb("Table `item_convert` not appropriate item %u conversion to %u. Table can be used for BoA items requirement drop or for conversion to another race/team use.", itemEntry, itemTargetId); continue; @@ -2416,7 +2422,8 @@ void ObjectMgr::LoadItemConverts() m_ItemConvert[itemEntry] = itemTargetId; ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -2430,7 +2437,7 @@ void ObjectMgr::LoadItemExpireConverts() uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT entry,item FROM item_expire_convert"); + QueryResult* result = WorldDatabase.Query("SELECT entry,item FROM item_expire_convert"); if (!result) { @@ -2447,7 +2454,7 @@ void ObjectMgr::LoadItemExpireConverts() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 itemEntry = fields[0].GetUInt32(); @@ -2477,7 +2484,8 @@ void ObjectMgr::LoadItemExpireConverts() m_ItemExpireConvert[itemEntry] = itemTargetId; ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -2491,7 +2499,7 @@ void ObjectMgr::LoadItemRequiredTarget() uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT entry,type,targetEntry FROM item_required_target"); + QueryResult* result = WorldDatabase.Query("SELECT entry,type,targetEntry FROM item_required_target"); if (!result) { @@ -2508,7 +2516,7 @@ void ObjectMgr::LoadItemRequiredTarget() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 uiItemId = fields[0].GetUInt32(); @@ -2525,7 +2533,7 @@ void ObjectMgr::LoadItemRequiredTarget() bool bIsItemSpellValid = false; - for(int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) + for (int i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i) { if (SpellEntry const* pSpellInfo = sSpellStore.LookupEntry(pItemProto->Spells[i].SpellId)) { @@ -2538,9 +2546,9 @@ void ObjectMgr::LoadItemRequiredTarget() for (int j = 0; j < MAX_EFFECT_INDEX; ++j) { if (pSpellInfo->EffectImplicitTargetA[j] == TARGET_CHAIN_DAMAGE || - pSpellInfo->EffectImplicitTargetB[j] == TARGET_CHAIN_DAMAGE || - pSpellInfo->EffectImplicitTargetA[j] == TARGET_DUELVSPLAYER || - pSpellInfo->EffectImplicitTargetB[j] == TARGET_DUELVSPLAYER) + pSpellInfo->EffectImplicitTargetB[j] == TARGET_CHAIN_DAMAGE || + pSpellInfo->EffectImplicitTargetA[j] == TARGET_DUELVSPLAYER || + pSpellInfo->EffectImplicitTargetB[j] == TARGET_DUELVSPLAYER) { bIsItemSpellValid = true; break; @@ -2579,7 +2587,8 @@ void ObjectMgr::LoadItemRequiredTarget() m_ItemRequiredTarget.insert(ItemRequiredTargetMap::value_type(uiItemId,ItemRequiredTarget(ItemRequiredTargetType(uiType),uiTargetEntry))); ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -2592,7 +2601,7 @@ void ObjectMgr::LoadPetLevelInfo() // Loading levels data { // 0 1 2 3 4 5 6 7 8 9 - QueryResult *result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor FROM pet_levelstats"); + QueryResult* result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor FROM pet_levelstats"); uint32 count = 0; @@ -2621,9 +2630,9 @@ void ObjectMgr::LoadPetLevelInfo() } uint32 current_level = fields[1].GetUInt32(); - if(current_level > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + if (current_level > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) { - if(current_level > STRONG_MAX_LEVEL) // hardcoded level maximum + if (current_level > STRONG_MAX_LEVEL) // hardcoded level maximum sLog.outErrorDb("Wrong (> %u) level %u in `pet_levelstats` table, ignoring.",STRONG_MAX_LEVEL,current_level); else { @@ -2632,7 +2641,7 @@ void ObjectMgr::LoadPetLevelInfo() } continue; } - else if(current_level < 1) + else if (current_level < 1) { sLog.outErrorDb("Wrong (<1) level %u in `pet_levelstats` table, ignoring.",current_level); continue; @@ -2640,7 +2649,7 @@ void ObjectMgr::LoadPetLevelInfo() PetLevelInfo*& pInfoMapEntry = petInfo[creature_id]; - if(pInfoMapEntry==NULL) + if (pInfoMapEntry==NULL) pInfoMapEntry = new PetLevelInfo[sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)]; // data for level 1 stored in [0] array element, ... @@ -2663,7 +2672,7 @@ void ObjectMgr::LoadPetLevelInfo() delete result; sLog.outString(); - sLog.outString( ">> Loaded %u level pet stats definitions", count ); + sLog.outString(">> Loaded %u level pet stats definitions", count); } // Fill gaps and check integrity @@ -2672,7 +2681,7 @@ void ObjectMgr::LoadPetLevelInfo() PetLevelInfo* pInfo = itr->second; // fatal error if no level 1 data - if(!pInfo || pInfo[0].health == 0 ) + if (!pInfo || pInfo[0].health == 0) { sLog.outErrorDb("Creature %u does not have pet stats data for Level 1!",itr->first); Log::WaitBeforeContinueIfNeed(); @@ -2682,7 +2691,7 @@ void ObjectMgr::LoadPetLevelInfo() // fill level gaps for (uint32 level = 1; level < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); ++level) { - if(pInfo[level].health == 0) + if (pInfo[level].health == 0) { sLog.outErrorDb("Creature %u has no data for Level %i pet stats data, using data of Level %i.",itr->first,level+1, level); pInfo[level] = pInfo[level-1]; @@ -2693,11 +2702,11 @@ void ObjectMgr::LoadPetLevelInfo() PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint32 level) const { - if(level > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + if (level > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) level = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); PetLevelInfoMap::const_iterator itr = petInfo.find(creature_id); - if(itr == petInfo.end()) + if (itr == petInfo.end()) return NULL; return &itr->second[level-1]; // data for level 1 stored in [0] array element, ... @@ -2708,7 +2717,7 @@ void ObjectMgr::LoadPlayerInfo() // Load playercreate { // 0 1 2 3 4 5 6 - QueryResult *result = WorldDatabase.Query("SELECT race, class, map, zone, position_x, position_y, position_z, orientation FROM playercreateinfo"); + QueryResult* result = WorldDatabase.Query("SELECT race, class, map, zone, position_x, position_y, position_z, orientation FROM playercreateinfo"); uint32 count = 0; @@ -2717,8 +2726,8 @@ void ObjectMgr::LoadPlayerInfo() BarGoLink bar(1); sLog.outString(); - sLog.outString( ">> Loaded %u player create definitions", count ); - sLog.outErrorDb( "Error loading `playercreateinfo` table or empty table."); + sLog.outString(">> Loaded %u player create definitions", count); + sLog.outErrorDb("Error loading `playercreateinfo` table or empty table."); Log::WaitBeforeContinueIfNeed(); exit(1); } @@ -2739,27 +2748,27 @@ void ObjectMgr::LoadPlayerInfo() float orientation = fields[7].GetFloat(); ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race); - if(!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE)) + if (!rEntry || !((1 << (current_race-1)) & RACEMASK_ALL_PLAYABLE)) { sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.",current_race); continue; } ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class); - if(!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE)) + if (!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE)) { sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.",current_class); continue; } // accept DB data only for valid position (and non instanceable) - if( !MapManager::IsValidMapCoord(mapId,positionX,positionY,positionZ, orientation) ) + if (!MapManager::IsValidMapCoord(mapId,positionX,positionY,positionZ, orientation)) { sLog.outErrorDb("Wrong home position for class %u race %u pair in `playercreateinfo` table, ignoring.",current_class,current_race); continue; } - if( sMapStore.LookupEntry(mapId)->Instanceable() ) + if (sMapStore.LookupEntry(mapId)->Instanceable()) { sLog.outErrorDb("Home position in instanceable map for class %u race %u pair in `playercreateinfo` table, ignoring.",current_class,current_race); continue; @@ -2785,13 +2794,13 @@ void ObjectMgr::LoadPlayerInfo() delete result; sLog.outString(); - sLog.outString( ">> Loaded %u player create definitions", count ); + sLog.outString(">> Loaded %u player create definitions", count); } // Load playercreate items { // 0 1 2 3 - QueryResult *result = WorldDatabase.Query("SELECT race, class, itemid, amount FROM playercreateinfo_item"); + QueryResult* result = WorldDatabase.Query("SELECT race, class, itemid, amount FROM playercreateinfo_item"); uint32 count = 0; @@ -2802,7 +2811,7 @@ void ObjectMgr::LoadPlayerInfo() bar.step(); sLog.outString(); - sLog.outString( ">> Loaded %u custom player create items", count ); + sLog.outString(">> Loaded %u custom player create items", count); } else { @@ -2847,24 +2856,24 @@ void ObjectMgr::LoadPlayerInfo() continue; } - pInfo->item.push_back(PlayerCreateInfoItem( item_id, amount)); + pInfo->item.push_back(PlayerCreateInfoItem(item_id, amount)); bar.step(); ++count; } - while(result->NextRow()); + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u custom player create items", count ); + sLog.outString(">> Loaded %u custom player create items", count); } } // Load playercreate spells { // 0 1 2 - QueryResult *result = WorldDatabase.Query("SELECT race, class, Spell FROM playercreateinfo_spell"); + QueryResult* result = WorldDatabase.Query("SELECT race, class, Spell FROM playercreateinfo_spell"); uint32 count = 0; @@ -2873,8 +2882,8 @@ void ObjectMgr::LoadPlayerInfo() BarGoLink bar(1); sLog.outString(); - sLog.outString( ">> Loaded %u player create spells", count ); - sLog.outErrorDb( "Error loading `playercreateinfo_spell` table or empty table."); + sLog.outString(">> Loaded %u player create spells", count); + sLog.outErrorDb("Error loading `playercreateinfo_spell` table or empty table."); } else { @@ -2895,7 +2904,7 @@ void ObjectMgr::LoadPlayerInfo() } ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(current_class); - if(!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE)) + if (!cEntry || !((1 << (current_class-1)) & CLASSMASK_ALL_PLAYABLE)) { sLog.outErrorDb("Wrong class %u in `playercreateinfo_spell` table, ignoring.",current_class); continue; @@ -2914,19 +2923,19 @@ void ObjectMgr::LoadPlayerInfo() bar.step(); ++count; } - while( result->NextRow() ); + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u player create spells", count ); + sLog.outString(">> Loaded %u player create spells", count); } } // Load playercreate actions { // 0 1 2 3 4 - QueryResult *result = WorldDatabase.Query("SELECT race, class, button, action, type FROM playercreateinfo_action"); + QueryResult* result = WorldDatabase.Query("SELECT race, class, button, action, type FROM playercreateinfo_action"); uint32 count = 0; @@ -2976,19 +2985,19 @@ void ObjectMgr::LoadPlayerInfo() bar.step(); ++count; } - while( result->NextRow() ); + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u player create actions", count ); + sLog.outString(">> Loaded %u player create actions", count); } } // Loading levels data (class only dependent) { // 0 1 2 3 - QueryResult *result = WorldDatabase.Query("SELECT class, level, basehp, basemana FROM player_classlevelstats"); + QueryResult* result = WorldDatabase.Query("SELECT class, level, basehp, basemana FROM player_classlevelstats"); uint32 count = 0; @@ -2997,8 +3006,8 @@ void ObjectMgr::LoadPlayerInfo() BarGoLink bar(1); sLog.outString(); - sLog.outString( ">> Loaded %u level health/mana definitions", count ); - sLog.outErrorDb( "Error loading `player_classlevelstats` table or empty table."); + sLog.outString(">> Loaded %u level health/mana definitions", count); + sLog.outErrorDb("Error loading `player_classlevelstats` table or empty table."); Log::WaitBeforeContinueIfNeed(); exit(1); } @@ -3052,20 +3061,20 @@ void ObjectMgr::LoadPlayerInfo() delete result; sLog.outString(); - sLog.outString( ">> Loaded %u level health/mana definitions", count ); + sLog.outString(">> Loaded %u level health/mana definitions", count); } // Fill gaps and check integrity for (int class_ = 0; class_ < MAX_CLASSES; ++class_) { // skip nonexistent classes - if(!sChrClassesStore.LookupEntry(class_)) + if (!sChrClassesStore.LookupEntry(class_)) continue; PlayerClassInfo* pClassInfo = &playerClassInfo[class_]; // fatal error if no level 1 data - if(!pClassInfo->levelInfo || pClassInfo->levelInfo[0].basehealth == 0 ) + if (!pClassInfo->levelInfo || pClassInfo->levelInfo[0].basehealth == 0) { sLog.outErrorDb("Class %i Level 1 does not have health/mana data!",class_); Log::WaitBeforeContinueIfNeed(); @@ -3075,7 +3084,7 @@ void ObjectMgr::LoadPlayerInfo() // fill level gaps for (uint32 level = 1; level < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); ++level) { - if(pClassInfo->levelInfo[level].basehealth == 0) + if (pClassInfo->levelInfo[level].basehealth == 0) { sLog.outErrorDb("Class %i Level %i does not have health/mana data. Using stats data of level %i.",class_,level+1, level); pClassInfo->levelInfo[level] = pClassInfo->levelInfo[level-1]; @@ -3086,7 +3095,7 @@ void ObjectMgr::LoadPlayerInfo() // Loading levels data (class/race dependent) { // 0 1 2 3 4 5 6 7 - QueryResult *result = WorldDatabase.Query("SELECT race, class, level, str, agi, sta, inte, spi FROM player_levelstats"); + QueryResult* result = WorldDatabase.Query("SELECT race, class, level, str, agi, sta, inte, spi FROM player_levelstats"); uint32 count = 0; @@ -3155,26 +3164,26 @@ void ObjectMgr::LoadPlayerInfo() delete result; sLog.outString(); - sLog.outString( ">> Loaded %u level stats definitions", count ); + sLog.outString(">> Loaded %u level stats definitions", count); } // Fill gaps and check integrity for (int race = 0; race < MAX_RACES; ++race) { // skip nonexistent races - if(!((1 << (race-1)) & RACEMASK_ALL_PLAYABLE) || !sChrRacesStore.LookupEntry(race)) + if (!((1 << (race-1)) & RACEMASK_ALL_PLAYABLE) || !sChrRacesStore.LookupEntry(race)) continue; for (int class_ = 0; class_ < MAX_CLASSES; ++class_) { // skip nonexistent classes - if(!((1 << (class_-1)) & CLASSMASK_ALL_PLAYABLE) || !sChrClassesStore.LookupEntry(class_)) + if (!((1 << (class_-1)) & CLASSMASK_ALL_PLAYABLE) || !sChrClassesStore.LookupEntry(class_)) continue; PlayerInfo* pInfo = &playerInfo[race][class_]; // skip non loaded combinations - if(!pInfo->displayId_m || !pInfo->displayId_f) + if (!pInfo->displayId_m || !pInfo->displayId_f) continue; // skip expansion races if not playing with expansion @@ -3186,7 +3195,7 @@ void ObjectMgr::LoadPlayerInfo() continue; // fatal error if no level 1 data - if(!pInfo->levelInfo || pInfo->levelInfo[0].stats[0] == 0 ) + if (!pInfo->levelInfo || pInfo->levelInfo[0].stats[0] == 0) { sLog.outErrorDb("Race %i Class %i Level 1 does not have stats data!",race,class_); Log::WaitBeforeContinueIfNeed(); @@ -3196,7 +3205,7 @@ void ObjectMgr::LoadPlayerInfo() // fill level gaps for (uint32 level = 1; level < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); ++level) { - if(pInfo->levelInfo[level].stats[0] == 0) + if (pInfo->levelInfo[level].stats[0] == 0) { sLog.outErrorDb("Race %i Class %i Level %i does not have stats data. Using stats data of level %i.",race,class_,level+1, level); pInfo->levelInfo[level] = pInfo->levelInfo[level-1]; @@ -3212,7 +3221,7 @@ void ObjectMgr::LoadPlayerInfo() mPlayerXPperLevel[level] = 0; // 0 1 - QueryResult *result = WorldDatabase.Query("SELECT lvl, xp_for_next_level FROM player_xp_for_level"); + QueryResult* result = WorldDatabase.Query("SELECT lvl, xp_for_next_level FROM player_xp_for_level"); uint32 count = 0; @@ -3263,7 +3272,7 @@ void ObjectMgr::LoadPlayerInfo() // fill level gaps for (uint32 level = 1; level < sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); ++level) { - if( mPlayerXPperLevel[level] == 0) + if (mPlayerXPperLevel[level] == 0) { sLog.outErrorDb("Level %i does not have XP for level data. Using data of level [%i] + 100.",level+1, level); mPlayerXPperLevel[level] = mPlayerXPperLevel[level-1]+100; @@ -3273,12 +3282,12 @@ void ObjectMgr::LoadPlayerInfo() void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint32 level, PlayerClassLevelInfo* info) const { - if(level < 1 || class_ >= MAX_CLASSES) + if (level < 1 || class_ >= MAX_CLASSES) return; PlayerClassInfo const* pInfo = &playerClassInfo[class_]; - if(level > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + if (level > sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) level = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); *info = pInfo->levelInfo[level-1]; @@ -3286,14 +3295,14 @@ void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint32 level, PlayerClass void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const { - if(level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES) + if (level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES) return; PlayerInfo const* pInfo = &playerInfo[race][class_]; - if(pInfo->displayId_m==0 || pInfo->displayId_f==0) + if (pInfo->displayId_m==0 || pInfo->displayId_f==0) return; - if(level <= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) + if (level <= sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)) *info = pInfo->levelInfo[level-1]; else BuildPlayerLevelInfo(race,class_,level,info); @@ -3304,9 +3313,9 @@ void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, Play // base data (last known level) *info = playerInfo[race][_class].levelInfo[sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)-1]; - for(int lvl = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)-1; lvl < level; ++lvl) + for (int lvl = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL)-1; lvl < level; ++lvl) { - switch(_class) + switch (_class) { case CLASS_WARRIOR: info->stats[STAT_STRENGTH] += (lvl > 23 ? 2: (lvl > 1 ? 1: 0)); @@ -3397,10 +3406,10 @@ void ObjectMgr::LoadArenaTeams() uint32 count = 0; // 0 1 2 3 4 5 - QueryResult *result = CharacterDatabase.Query( "SELECT arena_team.arenateamid,name,captainguid,type,BackgroundColor,EmblemStyle," - // 6 7 8 9 10 11 12 13 14 - "EmblemColor,BorderStyle,BorderColor, rating,games_week,wins_week,games_season,wins_season,rank " - "FROM arena_team LEFT JOIN arena_team_stats ON arena_team.arenateamid = arena_team_stats.arenateamid ORDER BY arena_team.arenateamid ASC" ); + QueryResult* result = CharacterDatabase.Query("SELECT arena_team.arenateamid,name,captainguid,type,BackgroundColor,EmblemStyle," + // 6 7 8 9 10 11 12 13 14 + "EmblemColor,BorderStyle,BorderColor, rating,games_week,wins_week,games_season,wins_season,rank " + "FROM arena_team LEFT JOIN arena_team_stats ON arena_team.arenateamid = arena_team_stats.arenateamid ORDER BY arena_team.arenateamid ASC"); if (!result) { @@ -3415,10 +3424,10 @@ void ObjectMgr::LoadArenaTeams() } // load arena_team members - QueryResult *arenaTeamMembersResult = CharacterDatabase.Query( - // 0 1 2 3 4 5 6 7 8 - "SELECT arenateamid,member.guid,played_week,wons_week,played_season,wons_season,personal_rating,name,class " - "FROM arena_team_member member LEFT JOIN characters chars on member.guid = chars.guid ORDER BY member.arenateamid ASC"); + QueryResult* arenaTeamMembersResult = CharacterDatabase.Query( + // 0 1 2 3 4 5 6 7 8 + "SELECT arenateamid,member.guid,played_week,wons_week,played_season,wons_season,personal_rating,name,class " + "FROM arena_team_member member LEFT JOIN characters chars on member.guid = chars.guid ORDER BY member.arenateamid ASC"); BarGoLink bar(result->GetRowCount()); @@ -3428,16 +3437,17 @@ void ObjectMgr::LoadArenaTeams() bar.step(); ++count; - ArenaTeam *newArenaTeam = new ArenaTeam; + ArenaTeam* newArenaTeam = new ArenaTeam; if (!newArenaTeam->LoadArenaTeamFromDB(result) || - !newArenaTeam->LoadMembersFromDB(arenaTeamMembersResult)) + !newArenaTeam->LoadMembersFromDB(arenaTeamMembersResult)) { newArenaTeam->Disband(NULL); delete newArenaTeam; continue; } AddArenaTeam(newArenaTeam); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; delete arenaTeamMembersResult; @@ -3451,7 +3461,7 @@ void ObjectMgr::LoadGroups() // -- loading groups -- uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - QueryResult *result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, groupType, difficulty, raiddifficulty, leaderGuid, groupId FROM groups"); + QueryResult* result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, groupType, difficulty, raiddifficulty, leaderGuid, groupId FROM groups"); if (!result) { @@ -3469,9 +3479,9 @@ void ObjectMgr::LoadGroups() do { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); ++count; - Group *group = new Group; + Group* group = new Group; if (!group->LoadGroupFromDB(fields)) { group->Disband(); @@ -3479,12 +3489,13 @@ void ObjectMgr::LoadGroups() continue; } AddGroup(group); - }while( result->NextRow() ); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u group definitions", count ); + sLog.outString(">> Loaded %u group definitions", count); // -- loading members -- count = 0; @@ -3503,7 +3514,7 @@ void ObjectMgr::LoadGroups() do { bar2.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); count++; uint32 memberGuidlow = fields[0].GetUInt32(); @@ -3517,7 +3528,7 @@ void ObjectMgr::LoadGroups() if (!group) { sLog.outErrorDb("Incorrect entry in group_member table : no group with Id %d for member %s!", - groupId, memberGuid.GetString().c_str()); + groupId, memberGuid.GetString().c_str()); CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%u'", memberGuidlow); continue; } @@ -3526,10 +3537,11 @@ void ObjectMgr::LoadGroups() if (!group->LoadMemberFromDB(memberGuidlow, subgroup, assistent)) { sLog.outErrorDb("Incorrect entry in group_member table : member %s cannot be added to group (Id: %u)!", - memberGuid.GetString().c_str(), groupId); + memberGuid.GetString().c_str(), groupId); CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%u'", memberGuidlow); } - }while( result->NextRow() ); + } + while (result->NextRow()); delete result; } @@ -3550,14 +3562,14 @@ void ObjectMgr::LoadGroups() // -- loading instances -- count = 0; result = CharacterDatabase.Query( - // 0 1 2 3 4 5 - "SELECT group_instance.leaderGuid, map, instance, permanent, instance.difficulty, resettime, " - // 6 - "(SELECT COUNT(*) FROM character_instance WHERE guid = group_instance.leaderGuid AND instance = group_instance.instance AND permanent = 1 LIMIT 1), " - // 7 8 - " groups.groupId, instance.encountersMask " - "FROM group_instance LEFT JOIN instance ON instance = id LEFT JOIN groups ON groups.leaderGUID = group_instance.leaderGUID ORDER BY leaderGuid" - ); + // 0 1 2 3 4 5 + "SELECT group_instance.leaderGuid, map, instance, permanent, instance.difficulty, resettime, " + // 6 + "(SELECT COUNT(*) FROM character_instance WHERE guid = group_instance.leaderGuid AND instance = group_instance.instance AND permanent = 1 LIMIT 1), " + // 7 8 + " groups.groupId, instance.encountersMask " + "FROM group_instance LEFT JOIN instance ON instance = id LEFT JOIN groups ON groups.leaderGUID = group_instance.leaderGUID ORDER BY leaderGuid" + ); if (!result) { @@ -3572,7 +3584,7 @@ void ObjectMgr::LoadGroups() do { bar2.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); count++; uint32 leaderGuidLow = fields[0].GetUInt32(); @@ -3604,23 +3616,24 @@ void ObjectMgr::LoadGroups() diff = REGULAR_DIFFICULTY; // default for both difficaly types } - DungeonPersistentState *state = (DungeonPersistentState*)sMapPersistentStateMgr.AddPersistentState(mapEntry, fields[2].GetUInt32(), Difficulty(diff), (time_t)fields[5].GetUInt64(), (fields[6].GetUInt32() == 0), true, true, fields[8].GetUInt32()); + DungeonPersistentState* state = (DungeonPersistentState*)sMapPersistentStateMgr.AddPersistentState(mapEntry, fields[2].GetUInt32(), Difficulty(diff), (time_t)fields[5].GetUInt64(), (fields[6].GetUInt32() == 0), true, true, fields[8].GetUInt32()); group->BindToInstance(state, fields[3].GetBool(), true); - }while( result->NextRow() ); + } + while (result->NextRow()); delete result; } sLog.outString(); - sLog.outString( ">> Loaded %u group-instance binds total", count ); + sLog.outString(">> Loaded %u group-instance binds total", count); sLog.outString(); - sLog.outString( ">> Loaded %u group members total", count ); + sLog.outString(">> Loaded %u group members total", count); } void ObjectMgr::LoadQuests() { // For reload case - for(QuestMap::const_iterator itr=mQuestTemplates.begin(); itr != mQuestTemplates.end(); ++itr) + for (QuestMap::const_iterator itr=mQuestTemplates.begin(); itr != mQuestTemplates.end(); ++itr) delete itr->second; mQuestTemplates.clear(); @@ -3628,48 +3641,48 @@ void ObjectMgr::LoadQuests() m_ExclusiveQuestGroups.clear(); // 0 1 2 3 4 5 6 7 8 9 - QueryResult *result = WorldDatabase.Query("SELECT entry, Method, ZoneOrSort, MinLevel, QuestLevel, Type, RequiredClasses, RequiredRaces, RequiredSkill, RequiredSkillValue," - // 10 11 12 13 14 15 16 17 - "RepObjectiveFaction, RepObjectiveValue, RequiredMinRepFaction, RequiredMinRepValue, RequiredMaxRepFaction, RequiredMaxRepValue, SuggestedPlayers, LimitTime," - // 18 19 20 21 22 23 24 25 26 - "QuestFlags, SpecialFlags, CharTitleId, PlayersSlain, BonusTalents, PrevQuestId, NextQuestId, ExclusiveGroup, NextQuestInChain," - // 27 28 29 30 - "RewXPId, SrcItemId, SrcItemCount, SrcSpell," - // 31 32 33 34 35 36 37 38 39 40 41 - "Title, Details, Objectives, OfferRewardText, RequestItemsText, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4," - // 42 43 44 45 46 47 48 49 50 51 52 53 - "ReqItemId1, ReqItemId2, ReqItemId3, ReqItemId4, ReqItemId5, ReqItemId6, ReqItemCount1, ReqItemCount2, ReqItemCount3, ReqItemCount4, ReqItemCount5, ReqItemCount6," - // 54 55 56 57 58 59 60 61 - "ReqSourceId1, ReqSourceId2, ReqSourceId3, ReqSourceId4, ReqSourceCount1, ReqSourceCount2, ReqSourceCount3, ReqSourceCount4," - // 62 63 64 65 66 67 68 69 - "ReqCreatureOrGOId1, ReqCreatureOrGOId2, ReqCreatureOrGOId3, ReqCreatureOrGOId4, ReqCreatureOrGOCount1, ReqCreatureOrGOCount2, ReqCreatureOrGOCount3, ReqCreatureOrGOCount4," - // 70 71 72 73 - "ReqSpellCast1, ReqSpellCast2, ReqSpellCast3, ReqSpellCast4," - // 74 75 76 77 78 79 - "RewChoiceItemId1, RewChoiceItemId2, RewChoiceItemId3, RewChoiceItemId4, RewChoiceItemId5, RewChoiceItemId6," - // 80 81 82 83 84 85 - "RewChoiceItemCount1, RewChoiceItemCount2, RewChoiceItemCount3, RewChoiceItemCount4, RewChoiceItemCount5, RewChoiceItemCount6," - // 86 87 88 89 90 91 92 93 - "RewItemId1, RewItemId2, RewItemId3, RewItemId4, RewItemCount1, RewItemCount2, RewItemCount3, RewItemCount4," - // 94 95 96 97 98 - "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5," - // 99 100 101 102 103 - "RewRepValueId1, RewRepValueId2, RewRepValueId3, RewRepValueId4, RewRepValueId5," - // 104 105 106 107 108 - "RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5," - // 109 110 111 112 113 114 - "RewHonorAddition, RewHonorMultiplier, RewOrReqMoney, RewMoneyMaxLevel, RewSpell, RewSpellCast," - // 115 116 117 118 119 120 - "RewMailTemplateId, RewMailDelaySecs, PointMapId, PointX, PointY, PointOpt," - // 121 122 123 124 125 126 127 128 - "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4, DetailsEmoteDelay1, DetailsEmoteDelay2, DetailsEmoteDelay3, DetailsEmoteDelay4," - // 129 130 131 132 133 134 - "IncompleteEmote, CompleteEmote, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4," - // 135 136 137 138 - "OfferRewardEmoteDelay1, OfferRewardEmoteDelay2, OfferRewardEmoteDelay3, OfferRewardEmoteDelay4," - // 139 140 - "StartScript, CompleteScript" - " FROM quest_template"); + QueryResult* result = WorldDatabase.Query("SELECT entry, Method, ZoneOrSort, MinLevel, QuestLevel, Type, RequiredClasses, RequiredRaces, RequiredSkill, RequiredSkillValue," + // 10 11 12 13 14 15 16 17 + "RepObjectiveFaction, RepObjectiveValue, RequiredMinRepFaction, RequiredMinRepValue, RequiredMaxRepFaction, RequiredMaxRepValue, SuggestedPlayers, LimitTime," + // 18 19 20 21 22 23 24 25 26 + "QuestFlags, SpecialFlags, CharTitleId, PlayersSlain, BonusTalents, PrevQuestId, NextQuestId, ExclusiveGroup, NextQuestInChain," + // 27 28 29 30 + "RewXPId, SrcItemId, SrcItemCount, SrcSpell," + // 31 32 33 34 35 36 37 38 39 40 41 + "Title, Details, Objectives, OfferRewardText, RequestItemsText, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4," + // 42 43 44 45 46 47 48 49 50 51 52 53 + "ReqItemId1, ReqItemId2, ReqItemId3, ReqItemId4, ReqItemId5, ReqItemId6, ReqItemCount1, ReqItemCount2, ReqItemCount3, ReqItemCount4, ReqItemCount5, ReqItemCount6," + // 54 55 56 57 58 59 60 61 + "ReqSourceId1, ReqSourceId2, ReqSourceId3, ReqSourceId4, ReqSourceCount1, ReqSourceCount2, ReqSourceCount3, ReqSourceCount4," + // 62 63 64 65 66 67 68 69 + "ReqCreatureOrGOId1, ReqCreatureOrGOId2, ReqCreatureOrGOId3, ReqCreatureOrGOId4, ReqCreatureOrGOCount1, ReqCreatureOrGOCount2, ReqCreatureOrGOCount3, ReqCreatureOrGOCount4," + // 70 71 72 73 + "ReqSpellCast1, ReqSpellCast2, ReqSpellCast3, ReqSpellCast4," + // 74 75 76 77 78 79 + "RewChoiceItemId1, RewChoiceItemId2, RewChoiceItemId3, RewChoiceItemId4, RewChoiceItemId5, RewChoiceItemId6," + // 80 81 82 83 84 85 + "RewChoiceItemCount1, RewChoiceItemCount2, RewChoiceItemCount3, RewChoiceItemCount4, RewChoiceItemCount5, RewChoiceItemCount6," + // 86 87 88 89 90 91 92 93 + "RewItemId1, RewItemId2, RewItemId3, RewItemId4, RewItemCount1, RewItemCount2, RewItemCount3, RewItemCount4," + // 94 95 96 97 98 + "RewRepFaction1, RewRepFaction2, RewRepFaction3, RewRepFaction4, RewRepFaction5," + // 99 100 101 102 103 + "RewRepValueId1, RewRepValueId2, RewRepValueId3, RewRepValueId4, RewRepValueId5," + // 104 105 106 107 108 + "RewRepValue1, RewRepValue2, RewRepValue3, RewRepValue4, RewRepValue5," + // 109 110 111 112 113 114 + "RewHonorAddition, RewHonorMultiplier, RewOrReqMoney, RewMoneyMaxLevel, RewSpell, RewSpellCast," + // 115 116 117 118 119 120 + "RewMailTemplateId, RewMailDelaySecs, PointMapId, PointX, PointY, PointOpt," + // 121 122 123 124 125 126 127 128 + "DetailsEmote1, DetailsEmote2, DetailsEmote3, DetailsEmote4, DetailsEmoteDelay1, DetailsEmoteDelay2, DetailsEmoteDelay3, DetailsEmoteDelay4," + // 129 130 131 132 133 134 + "IncompleteEmote, CompleteEmote, OfferRewardEmote1, OfferRewardEmote2, OfferRewardEmote3, OfferRewardEmote4," + // 135 136 137 138 + "OfferRewardEmoteDelay1, OfferRewardEmoteDelay2, OfferRewardEmoteDelay3, OfferRewardEmoteDelay4," + // 139 140 + "StartScript, CompleteScript" + " FROM quest_template"); if (!result) { BarGoLink bar(1); @@ -3688,11 +3701,12 @@ void ObjectMgr::LoadQuests() do { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); - Quest * newQuest = new Quest(fields); + Quest* newQuest = new Quest(fields); mQuestTemplates[newQuest->GetQuestId()] = newQuest; - } while( result->NextRow() ); + } + while (result->NextRow()); delete result; @@ -3702,7 +3716,7 @@ void ObjectMgr::LoadQuests() for (QuestMap::iterator iter = mQuestTemplates.begin(); iter != mQuestTemplates.end(); ++iter) { - Quest * qinfo = iter->second; + Quest* qinfo = iter->second; // additional quest integrity checks (GO, creature_template and item_template must be loaded already) @@ -3752,12 +3766,12 @@ void ObjectMgr::LoadQuests() if (qinfo->HasQuestFlag(QUEST_FLAGS_AUTO_REWARDED)) { // at auto-reward can be rewarded only RewChoiceItemId[0] - for(int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j ) + for (int j = 1; j < QUEST_REWARD_CHOICES_COUNT; ++j) { if (uint32 id = qinfo->RewChoiceItemId[j]) { sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item from `RewChoiceItemId%d` can't be rewarded with quest flag QUEST_FLAGS_AUTO_REWARDED.", - qinfo->GetQuestId(),j+1,id,j+1); + qinfo->GetQuestId(),j+1,id,j+1); // no changes, quest ignore this data } } @@ -3769,7 +3783,7 @@ void ObjectMgr::LoadQuests() if (!GetAreaEntryByAreaID(qinfo->ZoneOrSort)) { sLog.outErrorDb("Quest %u has `ZoneOrSort` = %u (zone case) but zone with this id does not exist.", - qinfo->GetQuestId(),qinfo->ZoneOrSort); + qinfo->GetQuestId(),qinfo->ZoneOrSort); // no changes, quest not dependent from this value but can have problems at client } } @@ -3780,7 +3794,7 @@ void ObjectMgr::LoadQuests() if (!qSort) { sLog.outErrorDb("Quest %u has `ZoneOrSort` = %i (sort case) but quest sort with this id does not exist.", - qinfo->GetQuestId(),qinfo->ZoneOrSort); + qinfo->GetQuestId(),qinfo->ZoneOrSort); // no changes, quest not dependent from this value but can have problems at client (note some may be 0, we must allow this so no check) } } @@ -3811,7 +3825,7 @@ void ObjectMgr::LoadQuests() if (!sSkillLineStore.LookupEntry(qinfo->RequiredSkill)) { sLog.outErrorDb("Quest %u has `RequiredSkill` = %u but this skill does not exist", - qinfo->GetQuestId(), qinfo->RequiredSkill); + qinfo->GetQuestId(), qinfo->RequiredSkill); } } @@ -3820,7 +3834,7 @@ void ObjectMgr::LoadQuests() if (qinfo->RequiredSkillValue > sWorld.GetConfigMaxSkillValue()) { sLog.outErrorDb("Quest %u has `RequiredSkillValue` = %u but max possible skill is %u, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredSkillValue,sWorld.GetConfigMaxSkillValue()); + qinfo->GetQuestId(),qinfo->RequiredSkillValue,sWorld.GetConfigMaxSkillValue()); // no changes, quest can't be done for this requirement } } @@ -3829,63 +3843,63 @@ void ObjectMgr::LoadQuests() if (qinfo->RepObjectiveFaction && !sFactionStore.LookupEntry(qinfo->RepObjectiveFaction)) { sLog.outErrorDb("Quest %u has `RepObjectiveFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->RepObjectiveFaction,qinfo->RepObjectiveFaction); + qinfo->GetQuestId(),qinfo->RepObjectiveFaction,qinfo->RepObjectiveFaction); // no changes, quest can't be done for this requirement } if (qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction)) { sLog.outErrorDb("Quest %u has `RequiredMinRepFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMinRepFaction,qinfo->RequiredMinRepFaction); + qinfo->GetQuestId(),qinfo->RequiredMinRepFaction,qinfo->RequiredMinRepFaction); // no changes, quest can't be done for this requirement } if (qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction)) { sLog.outErrorDb("Quest %u has `RequiredMaxRepFaction` = %u but faction template %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMaxRepFaction,qinfo->RequiredMaxRepFaction); + qinfo->GetQuestId(),qinfo->RequiredMaxRepFaction,qinfo->RequiredMaxRepFaction); // no changes, quest can't be done for this requirement } if (qinfo->RequiredMinRepValue && qinfo->RequiredMinRepValue > ReputationMgr::Reputation_Cap) { sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but max reputation is %u, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMinRepValue,ReputationMgr::Reputation_Cap); + qinfo->GetQuestId(),qinfo->RequiredMinRepValue,ReputationMgr::Reputation_Cap); // no changes, quest can't be done for this requirement } if (qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue) { sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d and `RequiredMinRepValue` = %d, quest can't be done.", - qinfo->GetQuestId(),qinfo->RequiredMaxRepValue,qinfo->RequiredMinRepValue); + qinfo->GetQuestId(),qinfo->RequiredMaxRepValue,qinfo->RequiredMinRepValue); // no changes, quest can't be done for this requirement } - if (!qinfo->RepObjectiveFaction && qinfo->RepObjectiveValue > 0 ) + if (!qinfo->RepObjectiveFaction && qinfo->RepObjectiveValue > 0) { sLog.outErrorDb("Quest %u has `RepObjectiveValue` = %d but `RepObjectiveFaction` is 0, value has no effect", - qinfo->GetQuestId(),qinfo->RepObjectiveValue); + qinfo->GetQuestId(),qinfo->RepObjectiveValue); // warning } - if (!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue > 0 ) + if (!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue > 0) { sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but `RequiredMinRepFaction` is 0, value has no effect", - qinfo->GetQuestId(),qinfo->RequiredMinRepValue); + qinfo->GetQuestId(),qinfo->RequiredMinRepValue); // warning } - if (!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue > 0 ) + if (!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue > 0) { sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d but `RequiredMaxRepFaction` is 0, value has no effect", - qinfo->GetQuestId(),qinfo->RequiredMaxRepValue); + qinfo->GetQuestId(),qinfo->RequiredMaxRepValue); // warning } if (qinfo->CharTitleId && !sCharTitlesStore.LookupEntry(qinfo->CharTitleId)) { sLog.outErrorDb("Quest %u has `CharTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.", - qinfo->GetQuestId(),qinfo->GetCharTitleId(),qinfo->GetCharTitleId()); + qinfo->GetQuestId(),qinfo->GetCharTitleId(),qinfo->GetCharTitleId()); qinfo->CharTitleId = 0; // quest can't reward this title } @@ -3895,20 +3909,20 @@ void ObjectMgr::LoadQuests() if (!sItemStorage.LookupEntry(qinfo->SrcItemId)) { sLog.outErrorDb("Quest %u has `SrcItemId` = %u but item with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->SrcItemId,qinfo->SrcItemId); + qinfo->GetQuestId(),qinfo->SrcItemId,qinfo->SrcItemId); qinfo->SrcItemId = 0; // quest can't be done for this requirement } else if (qinfo->SrcItemCount==0) { sLog.outErrorDb("Quest %u has `SrcItemId` = %u but `SrcItemCount` = 0, set to 1 but need fix in DB.", - qinfo->GetQuestId(),qinfo->SrcItemId); + qinfo->GetQuestId(),qinfo->SrcItemId); qinfo->SrcItemCount = 1; // update to 1 for allow quest work for backward compatibility with DB } } else if (qinfo->SrcItemCount>0) { sLog.outErrorDb("Quest %u has `SrcItemId` = 0 but `SrcItemCount` = %u, useless value.", - qinfo->GetQuestId(),qinfo->SrcItemCount); + qinfo->GetQuestId(),qinfo->SrcItemCount); qinfo->SrcItemCount=0; // no quest work changes in fact } @@ -3918,25 +3932,25 @@ void ObjectMgr::LoadQuests() if (!spellInfo) { sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u doesn't exist, quest can't be done.", - qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); + qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); qinfo->SrcSpell = 0; // quest can't be done for this requirement } else if (!SpellMgr::IsSpellValid(spellInfo)) { sLog.outErrorDb("Quest %u has `SrcSpell` = %u but spell %u is broken, quest can't be done.", - qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); + qinfo->GetQuestId(),qinfo->SrcSpell,qinfo->SrcSpell); qinfo->SrcSpell = 0; // quest can't be done for this requirement } } - for(int j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j ) + for (int j = 0; j < QUEST_ITEM_OBJECTIVES_COUNT; ++j) { if (uint32 id = qinfo->ReqItemId[j]) { if (qinfo->ReqItemCount[j] == 0) { sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but `ReqItemCount%d` = 0, quest can't be done.", - qinfo->GetQuestId(), j+1, id, j+1); + qinfo->GetQuestId(), j+1, id, j+1); // no changes, quest can't be done for this requirement } @@ -3945,26 +3959,26 @@ void ObjectMgr::LoadQuests() if (!sItemStorage.LookupEntry(id)) { sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but item with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(), j+1, id, id); + qinfo->GetQuestId(), j+1, id, id); qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest } } else if (qinfo->ReqItemCount[j] > 0) { sLog.outErrorDb("Quest %u has `ReqItemId%d` = 0 but `ReqItemCount%d` = %u, quest can't be done.", - qinfo->GetQuestId(), j+1, j+1, qinfo->ReqItemCount[j]); + qinfo->GetQuestId(), j+1, j+1, qinfo->ReqItemCount[j]); qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest } } - for(int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j ) + for (int j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j) { if (uint32 id = qinfo->ReqSourceId[j]) { if (!sItemStorage.LookupEntry(id)) { sLog.outErrorDb("Quest %u has `ReqSourceId%d` = %u but item with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,id); + qinfo->GetQuestId(),j+1,id,id); // no changes, quest can't be done for this requirement } } @@ -3973,13 +3987,13 @@ void ObjectMgr::LoadQuests() if (qinfo->ReqSourceCount[j]>0) { sLog.outErrorDb("Quest %u has `ReqSourceId%d` = 0 but `ReqSourceCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->ReqSourceCount[j]); + qinfo->GetQuestId(),j+1,j+1,qinfo->ReqSourceCount[j]); // no changes, quest ignore this data } } } - for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j ) + for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { if (uint32 id = qinfo->ReqSpell[j]) { @@ -3987,17 +4001,17 @@ void ObjectMgr::LoadQuests() if (!spellInfo) { sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u but spell %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,id); + qinfo->GetQuestId(),j+1,id,id); continue; } if (!qinfo->ReqCreatureOrGOId[j]) { bool found = false; - for(int k = 0; k < MAX_EFFECT_INDEX; ++k) + for (int k = 0; k < MAX_EFFECT_INDEX; ++k) { if ((spellInfo->Effect[k] == SPELL_EFFECT_QUEST_COMPLETE && uint32(spellInfo->EffectMiscValue[k]) == qinfo->QuestId) || - spellInfo->Effect[k] == SPELL_EFFECT_SEND_EVENT) + spellInfo->Effect[k] == SPELL_EFFECT_SEND_EVENT) { found = true; break; @@ -4017,27 +4031,27 @@ void ObjectMgr::LoadQuests() else { sLog.outErrorDb("Quest %u has `ReqSpellCast%d` = %u and ReqCreatureOrGOId%d = 0 but spell %u does not have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT effect for this quest, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1,id); + qinfo->GetQuestId(),j+1,id,j+1,id); // no changes, quest can't be done for this requirement } } } } - for(int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j ) + for (int j = 0; j < QUEST_OBJECTIVES_COUNT; ++j) { int32 id = qinfo->ReqCreatureOrGOId[j]; if (id < 0 && !sGOStorage.LookupEntry(-id)) { sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but gameobject %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,uint32(-id)); + qinfo->GetQuestId(),j+1,id,uint32(-id)); qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement } if (id > 0 && !sCreatureStorage.LookupEntry(id)) { sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but creature with entry %u does not exist, quest can't be done.", - qinfo->GetQuestId(),j+1,id,uint32(id)); + qinfo->GetQuestId(),j+1,id,uint32(id)); qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement } @@ -4050,27 +4064,27 @@ void ObjectMgr::LoadQuests() if (!qinfo->ReqCreatureOrGOCount[j]) { sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %u but `ReqCreatureOrGOCount%d` = 0, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1); + qinfo->GetQuestId(),j+1,id,j+1); // no changes, quest can be incorrectly done, but we already report this } } else if (qinfo->ReqCreatureOrGOCount[j]>0) { sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = 0 but `ReqCreatureOrGOCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->ReqCreatureOrGOCount[j]); + qinfo->GetQuestId(),j+1,j+1,qinfo->ReqCreatureOrGOCount[j]); // no changes, quest ignore this data } } bool choice_found = false; - for(int j = QUEST_REWARD_CHOICES_COUNT-1; j >=0; --j ) + for (int j = QUEST_REWARD_CHOICES_COUNT-1; j >=0; --j) { if (uint32 id = qinfo->RewChoiceItemId[j]) { if (!sItemStorage.LookupEntry(id)) { sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", - qinfo->GetQuestId(),j+1,id,id); + qinfo->GetQuestId(),j+1,id,id); qinfo->RewChoiceItemId[j] = 0; // no changes, quest will not reward this } else @@ -4079,14 +4093,14 @@ void ObjectMgr::LoadQuests() if (!qinfo->RewChoiceItemCount[j]) { sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but `RewChoiceItemCount%d` = 0, quest can't be done.", - qinfo->GetQuestId(),j+1,id,j+1); + qinfo->GetQuestId(),j+1,id,j+1); // no changes, quest can't be done } } else if (choice_found) // client crash if have gap in item reward choices { sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemId%d` = %u, client can crash at like data.", - qinfo->GetQuestId(),j+1,j+2,qinfo->RewChoiceItemId[j+1]); + qinfo->GetQuestId(),j+1,j+2,qinfo->RewChoiceItemId[j+1]); // fill gap by clone later filled choice qinfo->RewChoiceItemId[j] = qinfo->RewChoiceItemId[j+1]; qinfo->RewChoiceItemCount[j] = qinfo->RewChoiceItemCount[j+1]; @@ -4094,38 +4108,38 @@ void ObjectMgr::LoadQuests() else if (qinfo->RewChoiceItemCount[j]>0) { sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = 0 but `RewChoiceItemCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->RewChoiceItemCount[j]); + qinfo->GetQuestId(),j+1,j+1,qinfo->RewChoiceItemCount[j]); // no changes, quest ignore this data } } - for(int j = 0; j < QUEST_REWARDS_COUNT; ++j ) + for (int j = 0; j < QUEST_REWARDS_COUNT; ++j) { if (uint32 id = qinfo->RewItemId[j]) { if (!sItemStorage.LookupEntry(id)) { sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but item with entry %u does not exist, quest will not reward this item.", - qinfo->GetQuestId(),j+1,id,id); + qinfo->GetQuestId(),j+1,id,id); qinfo->RewItemId[j] = 0; // no changes, quest will not reward this item } if (!qinfo->RewItemCount[j]) { sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but `RewItemCount%d` = 0, quest will not reward this item.", - qinfo->GetQuestId(),j+1,id,j+1); + qinfo->GetQuestId(),j+1,id,j+1); // no changes } } else if (qinfo->RewItemCount[j]>0) { sLog.outErrorDb("Quest %u has `RewItemId%d` = 0 but `RewItemCount%d` = %u.", - qinfo->GetQuestId(),j+1,j+1,qinfo->RewItemCount[j]); + qinfo->GetQuestId(),j+1,j+1,qinfo->RewItemCount[j]); // no changes, quest ignore this data } } - for(int j = 0; j < QUEST_REPUTATIONS_COUNT; ++j) + for (int j = 0; j < QUEST_REPUTATIONS_COUNT; ++j) { if (qinfo->RewRepFaction[j]) { @@ -4135,14 +4149,14 @@ void ObjectMgr::LoadQuests() if (!sFactionStore.LookupEntry(qinfo->RewRepFaction[j])) { sLog.outErrorDb("Quest %u has `RewRepFaction%d` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.", - qinfo->GetQuestId(),j+1,qinfo->RewRepFaction[j] ,qinfo->RewRepFaction[j]); + qinfo->GetQuestId(),j+1,qinfo->RewRepFaction[j] ,qinfo->RewRepFaction[j]); qinfo->RewRepFaction[j] = 0; // quest will not reward this } } else if (qinfo->RewRepValue[j] != 0) { sLog.outErrorDb("Quest %u has `RewRepFaction%d` = 0 but `RewRepValue%d` = %i.", - qinfo->GetQuestId(),j+1,j+1,qinfo->RewRepValue[j]); + qinfo->GetQuestId(),j+1,j+1,qinfo->RewRepValue[j]); // no changes, quest ignore this data } } @@ -4154,19 +4168,19 @@ void ObjectMgr::LoadQuests() if (!spellInfo) { sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u does not exist, spell removed as display reward.", - qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); + qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); qinfo->RewSpell = 0; // no spell reward will display for this quest } else if (!SpellMgr::IsSpellValid(spellInfo)) { sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is broken, quest will not have a spell reward.", - qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); + qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); qinfo->RewSpell = 0; // no spell reward will display for this quest } else if (GetTalentSpellCost(qinfo->RewSpell)) { sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.", - qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); + qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell); qinfo->RewSpell = 0; // no spell reward will display for this quest } } @@ -4178,19 +4192,19 @@ void ObjectMgr::LoadQuests() if (!spellInfo) { sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.", - qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); + qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); qinfo->RewSpellCast = 0; // no spell will be casted on player } else if (!SpellMgr::IsSpellValid(spellInfo)) { sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u is broken, quest will not have a spell reward.", - qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); + qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); qinfo->RewSpellCast = 0; // no spell will be casted on player } else if (GetTalentSpellCost(qinfo->RewSpellCast)) { sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.", - qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); + qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast); qinfo->RewSpellCast = 0; // no spell will be casted on player } } @@ -4200,7 +4214,7 @@ void ObjectMgr::LoadQuests() if (!sMailTemplateStore.LookupEntry(qinfo->RewMailTemplateId)) { sLog.outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u does not exist, quest will not have a mail reward.", - qinfo->GetQuestId(),qinfo->RewMailTemplateId,qinfo->RewMailTemplateId); + qinfo->GetQuestId(),qinfo->RewMailTemplateId,qinfo->RewMailTemplateId); qinfo->RewMailTemplateId = 0; // no mail will send to player qinfo->RewMailDelaySecs = 0; // no mail will send to player } @@ -4208,7 +4222,7 @@ void ObjectMgr::LoadQuests() { std::map::const_iterator used_mt_itr = usedMailTemplates.find(qinfo->RewMailTemplateId); sLog.outErrorDb("Quest %u has `RewMailTemplateId` = %u but mail template %u already used for quest %u, quest will not have a mail reward.", - qinfo->GetQuestId(),qinfo->RewMailTemplateId,qinfo->RewMailTemplateId,used_mt_itr->second); + qinfo->GetQuestId(),qinfo->RewMailTemplateId,qinfo->RewMailTemplateId,used_mt_itr->second); qinfo->RewMailTemplateId = 0; // no mail will send to player qinfo->RewMailDelaySecs = 0; // no mail will send to player } @@ -4222,7 +4236,7 @@ void ObjectMgr::LoadQuests() if (qNextItr == mQuestTemplates.end()) { sLog.outErrorDb("Quest %u has `NextQuestInChain` = %u but quest %u does not exist, quest chain will not work.", - qinfo->GetQuestId(),qinfo->NextQuestInChain ,qinfo->NextQuestInChain ); + qinfo->GetQuestId(),qinfo->NextQuestInChain ,qinfo->NextQuestInChain); qinfo->NextQuestInChain = 0; } else @@ -4266,11 +4280,11 @@ void ObjectMgr::LoadQuests() // check QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i) { - SpellEntry const *spellInfo = sSpellStore.LookupEntry(i); + SpellEntry const* spellInfo = sSpellStore.LookupEntry(i); if (!spellInfo) continue; - for(int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) { if (spellInfo->Effect[j] != SPELL_EFFECT_QUEST_COMPLETE) continue; @@ -4297,24 +4311,24 @@ void ObjectMgr::LoadQuests() } sLog.outString(); - sLog.outString( ">> Loaded %lu quests definitions", (unsigned long)mQuestTemplates.size() ); + sLog.outString(">> Loaded %lu quests definitions", (unsigned long)mQuestTemplates.size()); } void ObjectMgr::LoadQuestLocales() { mQuestLocaleMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT entry," - "Title_loc1,Details_loc1,Objectives_loc1,OfferRewardText_loc1,RequestItemsText_loc1,EndText_loc1,CompletedText_loc1,ObjectiveText1_loc1,ObjectiveText2_loc1,ObjectiveText3_loc1,ObjectiveText4_loc1," - "Title_loc2,Details_loc2,Objectives_loc2,OfferRewardText_loc2,RequestItemsText_loc2,EndText_loc2,CompletedText_loc2,ObjectiveText1_loc2,ObjectiveText2_loc2,ObjectiveText3_loc2,ObjectiveText4_loc2," - "Title_loc3,Details_loc3,Objectives_loc3,OfferRewardText_loc3,RequestItemsText_loc3,EndText_loc3,CompletedText_loc3,ObjectiveText1_loc3,ObjectiveText2_loc3,ObjectiveText3_loc3,ObjectiveText4_loc3," - "Title_loc4,Details_loc4,Objectives_loc4,OfferRewardText_loc4,RequestItemsText_loc4,EndText_loc4,CompletedText_loc4,ObjectiveText1_loc4,ObjectiveText2_loc4,ObjectiveText3_loc4,ObjectiveText4_loc4," - "Title_loc5,Details_loc5,Objectives_loc5,OfferRewardText_loc5,RequestItemsText_loc5,EndText_loc5,CompletedText_loc5,ObjectiveText1_loc5,ObjectiveText2_loc5,ObjectiveText3_loc5,ObjectiveText4_loc5," - "Title_loc6,Details_loc6,Objectives_loc6,OfferRewardText_loc6,RequestItemsText_loc6,EndText_loc6,CompletedText_loc6,ObjectiveText1_loc6,ObjectiveText2_loc6,ObjectiveText3_loc6,ObjectiveText4_loc6," - "Title_loc7,Details_loc7,Objectives_loc7,OfferRewardText_loc7,RequestItemsText_loc7,EndText_loc7,CompletedText_loc7,ObjectiveText1_loc7,ObjectiveText2_loc7,ObjectiveText3_loc7,ObjectiveText4_loc7," - "Title_loc8,Details_loc8,Objectives_loc8,OfferRewardText_loc8,RequestItemsText_loc8,EndText_loc8,CompletedText_loc8,ObjectiveText1_loc8,ObjectiveText2_loc8,ObjectiveText3_loc8,ObjectiveText4_loc8" - " FROM locales_quest" - ); + QueryResult* result = WorldDatabase.Query("SELECT entry," + "Title_loc1,Details_loc1,Objectives_loc1,OfferRewardText_loc1,RequestItemsText_loc1,EndText_loc1,CompletedText_loc1,ObjectiveText1_loc1,ObjectiveText2_loc1,ObjectiveText3_loc1,ObjectiveText4_loc1," + "Title_loc2,Details_loc2,Objectives_loc2,OfferRewardText_loc2,RequestItemsText_loc2,EndText_loc2,CompletedText_loc2,ObjectiveText1_loc2,ObjectiveText2_loc2,ObjectiveText3_loc2,ObjectiveText4_loc2," + "Title_loc3,Details_loc3,Objectives_loc3,OfferRewardText_loc3,RequestItemsText_loc3,EndText_loc3,CompletedText_loc3,ObjectiveText1_loc3,ObjectiveText2_loc3,ObjectiveText3_loc3,ObjectiveText4_loc3," + "Title_loc4,Details_loc4,Objectives_loc4,OfferRewardText_loc4,RequestItemsText_loc4,EndText_loc4,CompletedText_loc4,ObjectiveText1_loc4,ObjectiveText2_loc4,ObjectiveText3_loc4,ObjectiveText4_loc4," + "Title_loc5,Details_loc5,Objectives_loc5,OfferRewardText_loc5,RequestItemsText_loc5,EndText_loc5,CompletedText_loc5,ObjectiveText1_loc5,ObjectiveText2_loc5,ObjectiveText3_loc5,ObjectiveText4_loc5," + "Title_loc6,Details_loc6,Objectives_loc6,OfferRewardText_loc6,RequestItemsText_loc6,EndText_loc6,CompletedText_loc6,ObjectiveText1_loc6,ObjectiveText2_loc6,ObjectiveText3_loc6,ObjectiveText4_loc6," + "Title_loc7,Details_loc7,Objectives_loc7,OfferRewardText_loc7,RequestItemsText_loc7,EndText_loc7,CompletedText_loc7,ObjectiveText1_loc7,ObjectiveText2_loc7,ObjectiveText3_loc7,ObjectiveText4_loc7," + "Title_loc8,Details_loc8,Objectives_loc8,OfferRewardText_loc8,RequestItemsText_loc8,EndText_loc8,CompletedText_loc8,ObjectiveText1_loc8,ObjectiveText2_loc8,ObjectiveText3_loc8,ObjectiveText4_loc8" + " FROM locales_quest" + ); if (!result) { @@ -4331,7 +4345,7 @@ void ObjectMgr::LoadQuestLocales() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); @@ -4344,101 +4358,101 @@ void ObjectMgr::LoadQuestLocales() QuestLocale& data = mQuestLocaleMap[entry]; - for(int i = 1; i < MAX_LOCALE; ++i) + for (int i = 1; i < MAX_LOCALE; ++i) { std::string str = fields[1+11*(i-1)].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.Title.size() <= idx) + if ((int32)data.Title.size() <= idx) data.Title.resize(idx+1); data.Title[idx] = str; } } str = fields[1+11*(i-1)+1].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.Details.size() <= idx) + if ((int32)data.Details.size() <= idx) data.Details.resize(idx+1); data.Details[idx] = str; } } str = fields[1+11*(i-1)+2].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.Objectives.size() <= idx) + if ((int32)data.Objectives.size() <= idx) data.Objectives.resize(idx+1); data.Objectives[idx] = str; } } str = fields[1+11*(i-1)+3].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.OfferRewardText.size() <= idx) + if ((int32)data.OfferRewardText.size() <= idx) data.OfferRewardText.resize(idx+1); data.OfferRewardText[idx] = str; } } str = fields[1+11*(i-1)+4].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.RequestItemsText.size() <= idx) + if ((int32)data.RequestItemsText.size() <= idx) data.RequestItemsText.resize(idx+1); data.RequestItemsText[idx] = str; } } str = fields[1+11*(i-1)+5].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.EndText.size() <= idx) + if ((int32)data.EndText.size() <= idx) data.EndText.resize(idx+1); data.EndText[idx] = str; } } str = fields[1+11*(i-1)+6].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.CompletedText.size() <= idx) + if ((int32)data.CompletedText.size() <= idx) data.CompletedText.resize(idx+1); data.CompletedText[idx] = str; } } - for(int k = 0; k < 4; ++k) + for (int k = 0; k < 4; ++k) { str = fields[1+11*(i-1)+7+k].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.ObjectiveText[k].size() <= idx) + if ((int32)data.ObjectiveText[k].size() <= idx) data.ObjectiveText[k].resize(idx+1); data.ObjectiveText[k][idx] = str; @@ -4446,12 +4460,13 @@ void ObjectMgr::LoadQuestLocales() } } } - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %lu Quest locale strings", (unsigned long)mQuestLocaleMap.size() ); + sLog.outString(">> Loaded %lu Quest locale strings", (unsigned long)mQuestLocaleMap.size()); } void ObjectMgr::LoadPageTexts() @@ -4459,17 +4474,17 @@ void ObjectMgr::LoadPageTexts() sPageTextStore.Free(); // for reload case sPageTextStore.Load(); - sLog.outString( ">> Loaded %u page texts", sPageTextStore.RecordCount ); + sLog.outString(">> Loaded %u page texts", sPageTextStore.RecordCount); sLog.outString(); - for(uint32 i = 1; i < sPageTextStore.MaxEntry; ++i) + for (uint32 i = 1; i < sPageTextStore.MaxEntry; ++i) { // check data correctness PageText const* page = sPageTextStore.LookupEntry(i); - if(!page) + if (!page) continue; - if(page->Next_Page && !sPageTextStore.LookupEntry(page->Next_Page)) + if (page->Next_Page && !sPageTextStore.LookupEntry(page->Next_Page)) { sLog.outErrorDb("Page text (Id: %u) has not existing next page (Id:%u)", i,page->Next_Page); continue; @@ -4477,19 +4492,19 @@ void ObjectMgr::LoadPageTexts() // detect circular reference std::set checkedPages; - for(PageText const* pageItr = page; pageItr; pageItr = sPageTextStore.LookupEntry(pageItr->Next_Page)) + for (PageText const* pageItr = page; pageItr; pageItr = sPageTextStore.LookupEntry(pageItr->Next_Page)) { - if(!pageItr->Next_Page) + if (!pageItr->Next_Page) break; checkedPages.insert(pageItr->Page_ID); - if(checkedPages.find(pageItr->Next_Page)!=checkedPages.end()) + if (checkedPages.find(pageItr->Next_Page)!=checkedPages.end()) { std::ostringstream ss; ss<< "The text page(s) "; - for (std::set::iterator itr= checkedPages.begin();itr!=checkedPages.end(); ++itr) + for (std::set::iterator itr= checkedPages.begin(); itr!=checkedPages.end(); ++itr) ss << *itr << " "; ss << "create(s) a circular reference, which can cause the server to freeze. Changing Next_Page of page " - << pageItr->Page_ID <<" to 0"; + << pageItr->Page_ID <<" to 0"; sLog.outErrorDb("%s", ss.str().c_str()); const_cast(pageItr)->Next_Page = 0; break; @@ -4502,7 +4517,7 @@ void ObjectMgr::LoadPageTextLocales() { mPageTextLocaleMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text"); + QueryResult* result = WorldDatabase.Query("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text"); if (!result) { @@ -4519,7 +4534,7 @@ void ObjectMgr::LoadPageTextLocales() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); @@ -4532,28 +4547,29 @@ void ObjectMgr::LoadPageTextLocales() PageTextLocale& data = mPageTextLocaleMap[entry]; - for(int i = 1; i < MAX_LOCALE; ++i) + for (int i = 1; i < MAX_LOCALE; ++i) { std::string str = fields[i].GetCppString(); - if(str.empty()) + if (str.empty()) continue; int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.Text.size() <= idx) + if ((int32)data.Text.size() <= idx) data.Text.resize(idx+1); data.Text[idx] = str; } } - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %lu PageText locale strings", (unsigned long)mPageTextLocaleMap.size() ); + sLog.outString(">> Loaded %lu PageText locale strings", (unsigned long)mPageTextLocaleMap.size()); } void ObjectMgr::LoadInstanceEncounters() @@ -4577,7 +4593,7 @@ void ObjectMgr::LoadInstanceEncounters() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); @@ -4621,18 +4637,19 @@ void ObjectMgr::LoadInstanceEncounters() m_DungeonEncounters.insert(DungeonEncounterMap::value_type(creditEntry, new DungeonEncounter(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon))); - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %lu Instance Encounters", (unsigned long)m_DungeonEncounters.size() ); + sLog.outString(">> Loaded %lu Instance Encounters", (unsigned long)m_DungeonEncounters.size()); } struct SQLInstanceLoader : public SQLStorageLoaderBase { template - void convert_from_str(uint32 /*field_pos*/, char const *src, D &dst) + void convert_from_str(uint32 /*field_pos*/, char const* src, D& dst) { dst = D(sScriptMgr.GetScriptId(src)); } @@ -4643,7 +4660,7 @@ void ObjectMgr::LoadInstanceTemplate() SQLInstanceLoader loader; loader.Load(sInstanceTemplate); - for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++) + for (uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++) { InstanceTemplate const* temp = GetInstanceTemplate(i); if (!temp) @@ -4671,7 +4688,7 @@ void ObjectMgr::LoadInstanceTemplate() if (!parentEntry) { sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: bad parent map id %u for instance template %d template!", - parentEntry->MapID, temp->map); + parentEntry->MapID, temp->map); const_cast(temp)->parent = 0; continue; } @@ -4679,21 +4696,21 @@ void ObjectMgr::LoadInstanceTemplate() if (parentEntry->IsContinent()) { sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: parent point to continent map id %u for instance template %d template, ignored, need be set only for non-continent parents!", - parentEntry->MapID,temp->map); + parentEntry->MapID,temp->map); const_cast(temp)->parent = 0; continue; } } } - sLog.outString( ">> Loaded %u Instance Template definitions", sInstanceTemplate.RecordCount ); + sLog.outString(">> Loaded %u Instance Template definitions", sInstanceTemplate.RecordCount); sLog.outString(); } struct SQLWorldLoader : public SQLStorageLoaderBase { template - void convert_from_str(uint32 /*field_pos*/, char const *src, D &dst) + void convert_from_str(uint32 /*field_pos*/, char const* src, D& dst) { dst = D(sScriptMgr.GetScriptId(src)); } @@ -4726,7 +4743,7 @@ void ObjectMgr::LoadWorldTemplate() } } - sLog.outString( ">> Loaded %u World Template definitions", sWorldTemplate.RecordCount); + sLog.outString(">> Loaded %u World Template definitions", sWorldTemplate.RecordCount); sLog.outString(); } @@ -4749,24 +4766,24 @@ void ObjectMgr::LoadConditions() } } - sLog.outString( ">> Loaded %u Condition definitions", sConditionStorage.RecordCount); + sLog.outString(">> Loaded %u Condition definitions", sConditionStorage.RecordCount); sLog.outString(); } -GossipText const *ObjectMgr::GetGossipText(uint32 Text_ID) const +GossipText const* ObjectMgr::GetGossipText(uint32 Text_ID) const { GossipTextMap::const_iterator itr = mGossipText.find(Text_ID); - if(itr != mGossipText.end()) + if (itr != mGossipText.end()) return &itr->second; return NULL; } void ObjectMgr::LoadGossipText() { - QueryResult *result = WorldDatabase.Query( "SELECT * FROM npc_text" ); + QueryResult* result = WorldDatabase.Query("SELECT * FROM npc_text"); int count = 0; - if( !result ) + if (!result) { BarGoLink bar(1); bar.step(); @@ -4785,7 +4802,7 @@ void ObjectMgr::LoadGossipText() ++count; cic = 0; - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); @@ -4812,7 +4829,8 @@ void ObjectMgr::LoadGossipText() gText.Options[i].Emotes[j]._Emote = fields[cic++].GetUInt32(); } } - } while(result->NextRow()); + } + while (result->NextRow()); sLog.outString(); sLog.outString(">> Loaded %u npc texts", count); @@ -4823,18 +4841,18 @@ void ObjectMgr::LoadGossipTextLocales() { mNpcTextLocaleMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT entry," - "Text0_0_loc1,Text0_1_loc1,Text1_0_loc1,Text1_1_loc1,Text2_0_loc1,Text2_1_loc1,Text3_0_loc1,Text3_1_loc1,Text4_0_loc1,Text4_1_loc1,Text5_0_loc1,Text5_1_loc1,Text6_0_loc1,Text6_1_loc1,Text7_0_loc1,Text7_1_loc1," - "Text0_0_loc2,Text0_1_loc2,Text1_0_loc2,Text1_1_loc2,Text2_0_loc2,Text2_1_loc2,Text3_0_loc2,Text3_1_loc1,Text4_0_loc2,Text4_1_loc2,Text5_0_loc2,Text5_1_loc2,Text6_0_loc2,Text6_1_loc2,Text7_0_loc2,Text7_1_loc2," - "Text0_0_loc3,Text0_1_loc3,Text1_0_loc3,Text1_1_loc3,Text2_0_loc3,Text2_1_loc3,Text3_0_loc3,Text3_1_loc1,Text4_0_loc3,Text4_1_loc3,Text5_0_loc3,Text5_1_loc3,Text6_0_loc3,Text6_1_loc3,Text7_0_loc3,Text7_1_loc3," - "Text0_0_loc4,Text0_1_loc4,Text1_0_loc4,Text1_1_loc4,Text2_0_loc4,Text2_1_loc4,Text3_0_loc4,Text3_1_loc1,Text4_0_loc4,Text4_1_loc4,Text5_0_loc4,Text5_1_loc4,Text6_0_loc4,Text6_1_loc4,Text7_0_loc4,Text7_1_loc4," - "Text0_0_loc5,Text0_1_loc5,Text1_0_loc5,Text1_1_loc5,Text2_0_loc5,Text2_1_loc5,Text3_0_loc5,Text3_1_loc1,Text4_0_loc5,Text4_1_loc5,Text5_0_loc5,Text5_1_loc5,Text6_0_loc5,Text6_1_loc5,Text7_0_loc5,Text7_1_loc5," - "Text0_0_loc6,Text0_1_loc6,Text1_0_loc6,Text1_1_loc6,Text2_0_loc6,Text2_1_loc6,Text3_0_loc6,Text3_1_loc1,Text4_0_loc6,Text4_1_loc6,Text5_0_loc6,Text5_1_loc6,Text6_0_loc6,Text6_1_loc6,Text7_0_loc6,Text7_1_loc6," - "Text0_0_loc7,Text0_1_loc7,Text1_0_loc7,Text1_1_loc7,Text2_0_loc7,Text2_1_loc7,Text3_0_loc7,Text3_1_loc1,Text4_0_loc7,Text4_1_loc7,Text5_0_loc7,Text5_1_loc7,Text6_0_loc7,Text6_1_loc7,Text7_0_loc7,Text7_1_loc7, " - "Text0_0_loc8,Text0_1_loc8,Text1_0_loc8,Text1_1_loc8,Text2_0_loc8,Text2_1_loc8,Text3_0_loc8,Text3_1_loc1,Text4_0_loc8,Text4_1_loc8,Text5_0_loc8,Text5_1_loc8,Text6_0_loc8,Text6_1_loc8,Text7_0_loc8,Text7_1_loc8 " - " FROM locales_npc_text"); + QueryResult* result = WorldDatabase.Query("SELECT entry," + "Text0_0_loc1,Text0_1_loc1,Text1_0_loc1,Text1_1_loc1,Text2_0_loc1,Text2_1_loc1,Text3_0_loc1,Text3_1_loc1,Text4_0_loc1,Text4_1_loc1,Text5_0_loc1,Text5_1_loc1,Text6_0_loc1,Text6_1_loc1,Text7_0_loc1,Text7_1_loc1," + "Text0_0_loc2,Text0_1_loc2,Text1_0_loc2,Text1_1_loc2,Text2_0_loc2,Text2_1_loc2,Text3_0_loc2,Text3_1_loc1,Text4_0_loc2,Text4_1_loc2,Text5_0_loc2,Text5_1_loc2,Text6_0_loc2,Text6_1_loc2,Text7_0_loc2,Text7_1_loc2," + "Text0_0_loc3,Text0_1_loc3,Text1_0_loc3,Text1_1_loc3,Text2_0_loc3,Text2_1_loc3,Text3_0_loc3,Text3_1_loc1,Text4_0_loc3,Text4_1_loc3,Text5_0_loc3,Text5_1_loc3,Text6_0_loc3,Text6_1_loc3,Text7_0_loc3,Text7_1_loc3," + "Text0_0_loc4,Text0_1_loc4,Text1_0_loc4,Text1_1_loc4,Text2_0_loc4,Text2_1_loc4,Text3_0_loc4,Text3_1_loc1,Text4_0_loc4,Text4_1_loc4,Text5_0_loc4,Text5_1_loc4,Text6_0_loc4,Text6_1_loc4,Text7_0_loc4,Text7_1_loc4," + "Text0_0_loc5,Text0_1_loc5,Text1_0_loc5,Text1_1_loc5,Text2_0_loc5,Text2_1_loc5,Text3_0_loc5,Text3_1_loc1,Text4_0_loc5,Text4_1_loc5,Text5_0_loc5,Text5_1_loc5,Text6_0_loc5,Text6_1_loc5,Text7_0_loc5,Text7_1_loc5," + "Text0_0_loc6,Text0_1_loc6,Text1_0_loc6,Text1_1_loc6,Text2_0_loc6,Text2_1_loc6,Text3_0_loc6,Text3_1_loc1,Text4_0_loc6,Text4_1_loc6,Text5_0_loc6,Text5_1_loc6,Text6_0_loc6,Text6_1_loc6,Text7_0_loc6,Text7_1_loc6," + "Text0_0_loc7,Text0_1_loc7,Text1_0_loc7,Text1_1_loc7,Text2_0_loc7,Text2_1_loc7,Text3_0_loc7,Text3_1_loc1,Text4_0_loc7,Text4_1_loc7,Text5_0_loc7,Text5_1_loc7,Text6_0_loc7,Text6_1_loc7,Text7_0_loc7,Text7_1_loc7, " + "Text0_0_loc8,Text0_1_loc8,Text1_0_loc8,Text1_1_loc8,Text2_0_loc8,Text2_1_loc8,Text3_0_loc8,Text3_1_loc1,Text4_0_loc8,Text4_1_loc8,Text5_0_loc8,Text5_1_loc8,Text6_0_loc8,Text6_1_loc8,Text7_0_loc8,Text7_1_loc8 " + " FROM locales_npc_text"); - if(!result) + if (!result) { BarGoLink bar(1); @@ -4849,7 +4867,7 @@ void ObjectMgr::LoadGossipTextLocales() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); @@ -4862,29 +4880,29 @@ void ObjectMgr::LoadGossipTextLocales() NpcTextLocale& data = mNpcTextLocaleMap[entry]; - for(int i=1; i= 0) + if (idx >= 0) { - if((int32)data.Text_0[j].size() <= idx) + if ((int32)data.Text_0[j].size() <= idx) data.Text_0[j].resize(idx+1); data.Text_0[j][idx] = str0; } } std::string str1 = fields[1+8*2*(i-1)+2*j+1].GetCppString(); - if(!str1.empty()) + if (!str1.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.Text_1[j].size() <= idx) + if ((int32)data.Text_1[j].size() <= idx) data.Text_1[j].resize(idx+1); data.Text_1[j][idx] = str1; @@ -4892,12 +4910,13 @@ void ObjectMgr::LoadGossipTextLocales() } } } - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %lu NpcText locale strings", (unsigned long)mNpcTextLocaleMap.size() ); + sLog.outString(">> Loaded %lu NpcText locale strings", (unsigned long)mNpcTextLocaleMap.size()); } //not very fast function but it is called only once a day, or on starting-up @@ -4926,14 +4945,14 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) BarGoLink bar(result->GetRowCount()); uint32 count = 0; - Field *fields; + Field* fields; do { bar.step(); fields = result->Fetch(); - Mail *m = new Mail; + Mail* m = new Mail; m->messageID = fields[0].GetUInt32(); m->messageType = fields[1].GetUInt8(); m->sender = fields[2].GetUInt32(); @@ -4945,11 +4964,12 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) m->checked = fields[7].GetUInt32(); m->mailTemplateId = fields[8].GetInt16(); - Player *pl = 0; + Player* pl = 0; if (serverUp) pl = GetPlayer(m->receiverGuid); if (pl) - { //this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail + { + //this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail //his in mailbox and he has already listed his mails ) delete m; continue; @@ -4957,12 +4977,12 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) //delete or return mail: if (has_items) { - QueryResult *resultItems = CharacterDatabase.PQuery("SELECT item_guid,item_template FROM mail_items WHERE mail_id='%u'", m->messageID); - if(resultItems) + QueryResult* resultItems = CharacterDatabase.PQuery("SELECT item_guid,item_template FROM mail_items WHERE mail_id='%u'", m->messageID); + if (resultItems) { do { - Field *fields2 = resultItems->Fetch(); + Field* fields2 = resultItems->Fetch(); uint32 item_guid_low = fields2[0].GetUInt32(); uint32 item_template = fields2[1].GetUInt32(); @@ -4977,14 +4997,14 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) if (m->messageType != MAIL_NORMAL || (m->checked & (MAIL_CHECK_MASK_COD_PAYMENT | MAIL_CHECK_MASK_RETURNED))) { // mail open and then not returned - for(MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) + for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", itr2->item_guid); } else { // mail will be returned: CharacterDatabase.PExecute("UPDATE mail SET sender = '%u', receiver = '%u', expire_time = '" UI64FMTD "', deliver_time = '" UI64FMTD "',cod = '0', checked = '%u' WHERE id = '%u'", - m->receiverGuid.GetCounter(), m->sender, (uint64)(basetime + 30*DAY), (uint64)basetime, MAIL_CHECK_MASK_RETURNED, m->messageID); + m->receiverGuid.GetCounter(), m->sender, (uint64)(basetime + 30*DAY), (uint64)basetime, MAIL_CHECK_MASK_RETURNED, m->messageID); for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2) { // update receiver in mail items for its proper delivery, and in instance_item for avoid lost item at sender delete @@ -5001,18 +5021,19 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", m->messageID); delete m; ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u mails", count ); + sLog.outString(">> Loaded %u mails", count); } void ObjectMgr::LoadQuestAreaTriggers() { mQuestAreaTriggerMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query( "SELECT id,quest FROM areatrigger_involvedrelation" ); + QueryResult* result = WorldDatabase.Query("SELECT id,quest FROM areatrigger_involvedrelation"); uint32 count = 0; @@ -5033,7 +5054,7 @@ void ObjectMgr::LoadQuestAreaTriggers() ++count; bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 trigger_ID = fields[0].GetUInt32(); uint32 quest_ID = fields[1].GetUInt32(); @@ -5064,19 +5085,20 @@ void ObjectMgr::LoadQuestAreaTriggers() mQuestAreaTriggerMap[trigger_ID] = quest_ID; - } while( result->NextRow() ); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u quest trigger points", count ); + sLog.outString(">> Loaded %u quest trigger points", count); } void ObjectMgr::LoadTavernAreaTriggers() { mTavernAreaTriggerSet.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT id FROM areatrigger_tavern"); + QueryResult* result = WorldDatabase.Query("SELECT id FROM areatrigger_tavern"); uint32 count = 0; @@ -5097,7 +5119,7 @@ void ObjectMgr::LoadTavernAreaTriggers() ++count; bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 Trigger_ID = fields[0].GetUInt32(); @@ -5109,37 +5131,38 @@ void ObjectMgr::LoadTavernAreaTriggers() } mTavernAreaTriggerSet.insert(Trigger_ID); - } while( result->NextRow() ); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u tavern triggers", count ); + sLog.outString(">> Loaded %u tavern triggers", count); } -uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid, Team team ) +uint32 ObjectMgr::GetNearestTaxiNode(float x, float y, float z, uint32 mapid, Team team) { bool found = false; float dist; uint32 id = 0; - for(uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) + for (uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i) { TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i); - if(!node || node->map_id != mapid || !node->MountCreatureID[team == ALLIANCE ? 1 : 0]) + if (!node || node->map_id != mapid || !node->MountCreatureID[team == ALLIANCE ? 1 : 0]) continue; uint8 field = (uint8)((i - 1) / 32); uint32 submask = 1<<((i-1)%32); // skip not taxi network nodes - if((sTaxiNodesMask[field] & submask)==0) + if ((sTaxiNodesMask[field] & submask)==0) continue; float dist2 = (node->x - x)*(node->x - x)+(node->y - y)*(node->y - y)+(node->z - z)*(node->z - z); - if(found) + if (found) { - if(dist2 < dist) + if (dist2 < dist) { dist = dist2; id = i; @@ -5156,10 +5179,10 @@ uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid, T return id; } -void ObjectMgr::GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost) +void ObjectMgr::GetTaxiPath(uint32 source, uint32 destination, uint32& path, uint32& cost) { TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source); - if(src_i==sTaxiPathSetBySource.end()) + if (src_i==sTaxiPathSetBySource.end()) { path = 0; cost = 0; @@ -5169,7 +5192,7 @@ void ObjectMgr::GetTaxiPath( uint32 source, uint32 destination, uint32 &path, ui TaxiPathSetForSource& pathSet = src_i->second; TaxiPathSetForSource::iterator dest_i = pathSet.find(destination); - if(dest_i==pathSet.end()) + if (dest_i==pathSet.end()) { path = 0; cost = 0; @@ -5180,30 +5203,30 @@ void ObjectMgr::GetTaxiPath( uint32 source, uint32 destination, uint32 &path, ui path = dest_i->second.ID; } -uint32 ObjectMgr::GetTaxiMountDisplayId( uint32 id, Team team, bool allowed_alt_team /* = false */) +uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, Team team, bool allowed_alt_team /* = false */) { uint16 mount_entry = 0; // select mount creature id TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id); - if(node) + if (node) { if (team == ALLIANCE) { mount_entry = node->MountCreatureID[1]; - if(!mount_entry && allowed_alt_team) + if (!mount_entry && allowed_alt_team) mount_entry = node->MountCreatureID[0]; } else if (team == HORDE) { mount_entry = node->MountCreatureID[0]; - if(!mount_entry && allowed_alt_team) + if (!mount_entry && allowed_alt_team) mount_entry = node->MountCreatureID[1]; } } - CreatureInfo const *mount_info = GetCreatureTemplate(mount_entry); + CreatureInfo const* mount_info = GetCreatureTemplate(mount_entry); if (!mount_info) return 0; @@ -5211,7 +5234,7 @@ uint32 ObjectMgr::GetTaxiMountDisplayId( uint32 id, Team team, bool allowed_alt_ if (!mount_id) return 0; - CreatureModelInfo const *minfo = GetCreatureModelRandomGender(mount_id); + CreatureModelInfo const* minfo = GetCreatureModelRandomGender(mount_id); if (minfo) mount_id = minfo->modelid; @@ -5222,7 +5245,7 @@ void ObjectMgr::LoadGraveyardZones() { mGraveYardMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT id,ghost_zone,faction FROM game_graveyard_zone"); + QueryResult* result = WorldDatabase.Query("SELECT id,ghost_zone,faction FROM game_graveyard_zone"); uint32 count = 0; @@ -5243,7 +5266,7 @@ void ObjectMgr::LoadGraveyardZones() ++count; bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 safeLocId = fields[0].GetUInt32(); uint32 zoneId = fields[1].GetUInt32(); @@ -5256,7 +5279,7 @@ void ObjectMgr::LoadGraveyardZones() continue; } - AreaTableEntry const *areaEntry = GetAreaEntryByAreaID(zoneId); + AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(zoneId); if (!areaEntry) { sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing zone id (%u), skipped.", zoneId); @@ -5275,17 +5298,18 @@ void ObjectMgr::LoadGraveyardZones() continue; } - if(!AddGraveYardLink(safeLocId, zoneId, Team(team), false)) + if (!AddGraveYardLink(safeLocId, zoneId, Team(team), false)) sLog.outErrorDb("Table `game_graveyard_zone` has a duplicate record for Graveyard (ID: %u) and Zone (ID: %u), skipped.", safeLocId, zoneId); - } while( result->NextRow() ); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u graveyard-zone links", count ); + sLog.outString(">> Loaded %u graveyard-zone links", count); } -WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, Team team) +WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, Team team) { // search for zone associated closest graveyard uint32 zoneId = sTerrainMgr.GetZoneId(MapId, x, y, z); @@ -5320,7 +5344,7 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float MapEntry const* mapEntry = sMapStore.LookupEntry(MapId); - for(GraveYardMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) + for (GraveYardMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { GraveYardData const& data = itr->second; @@ -5334,13 +5358,13 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float continue; // find now nearest graveyard at other (continent) map - if(MapId != entry->map_id) + if (MapId != entry->map_id) { // if find graveyard at different map from where entrance placed (or no entrance data), use any first if (!mapEntry || - mapEntry->ghost_entrance_map < 0 || - uint32(mapEntry->ghost_entrance_map) != entry->map_id || - (mapEntry->ghost_entrance_x == 0 && mapEntry->ghost_entrance_y == 0)) + mapEntry->ghost_entrance_map < 0 || + uint32(mapEntry->ghost_entrance_map) != entry->map_id || + (mapEntry->ghost_entrance_x == 0 && mapEntry->ghost_entrance_y == 0)) { // not have any coordinates for check distance anyway entryFar = entry; @@ -5349,10 +5373,10 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float // at entrance map calculate distance (2D); float dist2 = (entry->x - mapEntry->ghost_entrance_x)*(entry->x - mapEntry->ghost_entrance_x) - +(entry->y - mapEntry->ghost_entrance_y)*(entry->y - mapEntry->ghost_entrance_y); - if(foundEntr) + +(entry->y - mapEntry->ghost_entrance_y)*(entry->y - mapEntry->ghost_entrance_y); + if (foundEntr) { - if(dist2 < distEntr) + if (dist2 < distEntr) { distEntr = dist2; entryEntr = entry; @@ -5369,9 +5393,9 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float else { float dist2 = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y)+(entry->z - z)*(entry->z - z); - if(foundNear) + if (foundNear) { - if(dist2 < distNear) + if (dist2 < distNear) { distNear = dist2; entryNear = entry; @@ -5386,10 +5410,10 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float } } - if(entryNear) + if (entryNear) return entryNear; - if(entryEntr) + if (entryEntr) return entryEntr; return entryFar; @@ -5399,7 +5423,7 @@ GraveYardData const* ObjectMgr::FindGraveYardData(uint32 id, uint32 zoneId) cons { GraveYardMapBounds bounds = mGraveYardMap.equal_range(zoneId); - for(GraveYardMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) + for (GraveYardMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { if (itr->second.safeLocId == id) return &itr->second; @@ -5458,7 +5482,7 @@ void ObjectMgr::LoadAreaTriggerTeleports() uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 - QueryResult *result = WorldDatabase.Query("SELECT id, required_level, required_item, required_item2, heroic_key, heroic_key2, required_quest_done, required_quest_done_heroic, required_failed_text, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport"); + QueryResult* result = WorldDatabase.Query("SELECT id, required_level, required_item, required_item2, heroic_key, heroic_key2, required_quest_done, required_quest_done_heroic, required_failed_text, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport"); if (!result) { @@ -5475,7 +5499,7 @@ void ObjectMgr::LoadAreaTriggerTeleports() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); @@ -5508,7 +5532,7 @@ void ObjectMgr::LoadAreaTriggerTeleports() if (at.requiredItem) { - ItemPrototype const *pProto = GetItemPrototype(at.requiredItem); + ItemPrototype const* pProto = GetItemPrototype(at.requiredItem); if (!pProto) { sLog.outError("Table `areatrigger_teleport` has nonexistent key item %u for trigger %u, removing key requirement.", at.requiredItem, Trigger_ID); @@ -5518,8 +5542,8 @@ void ObjectMgr::LoadAreaTriggerTeleports() if (at.requiredItem2) { - ItemPrototype const *pProto = GetItemPrototype(at.requiredItem2); - if(!pProto) + ItemPrototype const* pProto = GetItemPrototype(at.requiredItem2); + if (!pProto) { sLog.outError("Table `areatrigger_teleport` has nonexistent second key item %u for trigger %u, remove key requirement.", at.requiredItem2, Trigger_ID); at.requiredItem2 = 0; @@ -5528,7 +5552,7 @@ void ObjectMgr::LoadAreaTriggerTeleports() if (at.heroicKey) { - ItemPrototype const *pProto = GetItemPrototype(at.heroicKey); + ItemPrototype const* pProto = GetItemPrototype(at.heroicKey); if (!pProto) { sLog.outError("Table `areatrigger_teleport` has nonexistent heroic key item %u for trigger %u, remove key requirement.", at.heroicKey, Trigger_ID); @@ -5538,7 +5562,7 @@ void ObjectMgr::LoadAreaTriggerTeleports() if (at.heroicKey2) { - ItemPrototype const *pProto = GetItemPrototype(at.heroicKey2); + ItemPrototype const* pProto = GetItemPrototype(at.heroicKey2); if (!pProto) { sLog.outError("Table `areatrigger_teleport` has nonexistent heroic second key item %u for trigger %u, remove key requirement.", at.heroicKey2, Trigger_ID); @@ -5581,12 +5605,13 @@ void ObjectMgr::LoadAreaTriggerTeleports() mAreaTriggers[Trigger_ID] = at; - } while( result->NextRow() ); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u area trigger teleport definitions", count ); + sLog.outString(">> Loaded %u area trigger teleport definitions", count); } /* @@ -5594,7 +5619,7 @@ void ObjectMgr::LoadAreaTriggerTeleports() */ AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 map_id) const { - const MapEntry *mapEntry = sMapStore.LookupEntry(map_id); + const MapEntry* mapEntry = sMapStore.LookupEntry(map_id); if (!mapEntry || mapEntry->ghost_entrance_map < 0) return NULL; @@ -5603,7 +5628,7 @@ AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 map_id) const if (itr->second.target_mapId == uint32(mapEntry->ghost_entrance_map)) { AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first); - if(atEntry && atEntry->mapid == map_id) + if (atEntry && atEntry->mapid == map_id) return &itr->second; } } @@ -5617,10 +5642,10 @@ AreaTrigger const* ObjectMgr::GetMapEntranceTrigger(uint32 Map) const { for (AreaTriggerMap::const_iterator itr = mAreaTriggers.begin(); itr != mAreaTriggers.end(); ++itr) { - if(itr->second.target_mapId == Map) + if (itr->second.target_mapId == Map) { AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first); - if(atEntry) + if (atEntry) return &itr->second; } } @@ -5637,12 +5662,12 @@ void ObjectMgr::PackGroupIds() // all valid ids are in the instance table // any associations to ids not in this table are assumed to be // cleaned already in CleanupInstances - QueryResult *result = CharacterDatabase.Query("SELECT groupId FROM groups"); - if( result ) + QueryResult* result = CharacterDatabase.Query("SELECT groupId FROM groups"); + if (result) { do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 id = fields[0].GetUInt32(); @@ -5681,35 +5706,35 @@ void ObjectMgr::PackGroupIds() bar.step(); } - sLog.outString( ">> Group Ids remapped, next group id is %u", groupId ); + sLog.outString(">> Group Ids remapped, next group id is %u", groupId); sLog.outString(); } void ObjectMgr::SetHighestGuids() { - QueryResult *result = CharacterDatabase.Query("SELECT MAX(guid) FROM characters"); - if( result ) + QueryResult* result = CharacterDatabase.Query("SELECT MAX(guid) FROM characters"); + if (result) { m_CharGuids.Set((*result)[0].GetUInt32()+1); delete result; } result = WorldDatabase.Query("SELECT MAX(guid) FROM creature"); - if( result ) + if (result) { m_FirstTemporaryCreatureGuid = (*result)[0].GetUInt32()+1; delete result; } - result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" ); - if( result ) + result = CharacterDatabase.Query("SELECT MAX(guid) FROM item_instance"); + if (result) { m_ItemGuids.Set((*result)[0].GetUInt32()+1); delete result; } - result = CharacterDatabase.Query( "SELECT MAX(id) FROM instance" ); - if( result ) + result = CharacterDatabase.Query("SELECT MAX(id) FROM instance"); + if (result) { m_InstanceGuids.Set((*result)[0].GetUInt32()+1); delete result; @@ -5723,29 +5748,29 @@ void ObjectMgr::SetHighestGuids() CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE item_guid >= '%u'", m_ItemGuids.GetNextAfterMaxUsed()); CharacterDatabase.CommitTransaction(); - result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject" ); - if( result ) + result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject"); + if (result) { m_FirstTemporaryGameObjectGuid = (*result)[0].GetUInt32()+1; delete result; } - result = CharacterDatabase.Query("SELECT MAX(id) FROM auction" ); - if( result ) + result = CharacterDatabase.Query("SELECT MAX(id) FROM auction"); + if (result) { m_AuctionIds.Set((*result)[0].GetUInt32()+1); delete result; } - result = CharacterDatabase.Query( "SELECT MAX(id) FROM mail" ); - if( result ) + result = CharacterDatabase.Query("SELECT MAX(id) FROM mail"); + if (result) { m_MailIds.Set((*result)[0].GetUInt32()+1); delete result; } - result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" ); - if( result ) + result = CharacterDatabase.Query("SELECT MAX(guid) FROM corpse"); + if (result) { m_CorpseGuids.Set((*result)[0].GetUInt32()+1); delete result; @@ -5765,14 +5790,14 @@ void ObjectMgr::SetHighestGuids() delete result; } - result = CharacterDatabase.Query( "SELECT MAX(guildid) FROM guild" ); + result = CharacterDatabase.Query("SELECT MAX(guildid) FROM guild"); if (result) { m_GuildIds.Set((*result)[0].GetUInt32()+1); delete result; } - result = CharacterDatabase.Query( "SELECT MAX(groupId) FROM groups" ); + result = CharacterDatabase.Query("SELECT MAX(groupId) FROM groups"); if (result) { m_GroupGuids.Set((*result)[0].GetUInt32()+1); @@ -5791,12 +5816,12 @@ void ObjectMgr::LoadGameObjectLocales() { mGameObjectLocaleMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT entry," - "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8," - "castbarcaption_loc1,castbarcaption_loc2,castbarcaption_loc3,castbarcaption_loc4," - "castbarcaption_loc5,castbarcaption_loc6,castbarcaption_loc7,castbarcaption_loc8 FROM locales_gameobject"); + QueryResult* result = WorldDatabase.Query("SELECT entry," + "name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8," + "castbarcaption_loc1,castbarcaption_loc2,castbarcaption_loc3,castbarcaption_loc4," + "castbarcaption_loc5,castbarcaption_loc6,castbarcaption_loc7,castbarcaption_loc8 FROM locales_gameobject"); - if(!result) + if (!result) { BarGoLink bar(1); @@ -5811,7 +5836,7 @@ void ObjectMgr::LoadGameObjectLocales() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 entry = fields[0].GetUInt32(); @@ -5824,15 +5849,15 @@ void ObjectMgr::LoadGameObjectLocales() GameObjectLocale& data = mGameObjectLocaleMap[entry]; - for(int i = 1; i < MAX_LOCALE; ++i) + for (int i = 1; i < MAX_LOCALE; ++i) { std::string str = fields[i].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.Name.size() <= idx) + if ((int32)data.Name.size() <= idx) data.Name.resize(idx+1); data.Name[idx] = str; @@ -5840,15 +5865,15 @@ void ObjectMgr::LoadGameObjectLocales() } } - for(int i = 1; i < MAX_LOCALE; ++i) + for (int i = 1; i < MAX_LOCALE; ++i) { std::string str = fields[i+(MAX_LOCALE-1)].GetCppString(); - if(!str.empty()) + if (!str.empty()) { int idx = GetOrNewIndexForLocale(LocaleConstant(i)); - if(idx >= 0) + if (idx >= 0) { - if((int32)data.CastBarCaption.size() <= idx) + if ((int32)data.CastBarCaption.size() <= idx) data.CastBarCaption.resize(idx+1); data.CastBarCaption[idx] = str; @@ -5856,18 +5881,19 @@ void ObjectMgr::LoadGameObjectLocales() } } - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %lu gameobject locale strings", (unsigned long)mGameObjectLocaleMap.size() ); + sLog.outString(">> Loaded %lu gameobject locale strings", (unsigned long)mGameObjectLocaleMap.size()); } struct SQLGameObjectLoader : public SQLStorageLoaderBase { template - void convert_from_str(uint32 /*field_pos*/, char const *src, D &dst) + void convert_from_str(uint32 /*field_pos*/, char const* src, D& dst) { dst = D(sScriptMgr.GetScriptId(src)); } @@ -5879,7 +5905,7 @@ inline void CheckGOLockId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N) return; sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but lock (Id: %u) not found.", - goInfo->id,goInfo->type,N,dataN,dataN); + goInfo->id,goInfo->type,N,dataN,dataN); } inline void CheckGOLinkedTrapId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N) @@ -5888,12 +5914,12 @@ inline void CheckGOLinkedTrapId(GameObjectInfo const* goInfo,uint32 dataN,uint32 { if (trapInfo->type!=GAMEOBJECT_TYPE_TRAP) sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but GO (Entry %u) have not GAMEOBJECT_TYPE_TRAP (%u) type.", - goInfo->id,goInfo->type,N,dataN,dataN,GAMEOBJECT_TYPE_TRAP); + goInfo->id,goInfo->type,N,dataN,dataN,GAMEOBJECT_TYPE_TRAP); } else // too many error reports about nonexistent trap templates ERROR_DB_STRICT_LOG("Gameobject (Entry: %u GoType: %u) have data%d=%u but trap GO (Entry %u) not exist in `gameobject_template`.", - goInfo->id,goInfo->type,N,dataN,dataN); + goInfo->id,goInfo->type,N,dataN,dataN); } inline void CheckGOSpellId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N) @@ -5902,16 +5928,16 @@ inline void CheckGOSpellId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N) return; sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but Spell (Entry %u) not exist.", - goInfo->id,goInfo->type,N,dataN,dataN); + goInfo->id,goInfo->type,N,dataN,dataN); } inline void CheckAndFixGOChairHeightId(GameObjectInfo const* goInfo,uint32 const& dataN,uint32 N) { - if (dataN <= (UNIT_STAND_STATE_SIT_HIGH_CHAIR-UNIT_STAND_STATE_SIT_LOW_CHAIR) ) + if (dataN <= (UNIT_STAND_STATE_SIT_HIGH_CHAIR-UNIT_STAND_STATE_SIT_LOW_CHAIR)) return; sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but correct chair height in range 0..%i.", - goInfo->id,goInfo->type,N,dataN,UNIT_STAND_STATE_SIT_HIGH_CHAIR-UNIT_STAND_STATE_SIT_LOW_CHAIR); + goInfo->id,goInfo->type,N,dataN,UNIT_STAND_STATE_SIT_HIGH_CHAIR-UNIT_STAND_STATE_SIT_LOW_CHAIR); // prevent client and server unexpected work const_cast(dataN) = 0; @@ -5924,7 +5950,7 @@ inline void CheckGONoDamageImmuneId(GameObjectInfo const* goInfo,uint32 dataN,ui return; sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but expected boolean (0/1) noDamageImmune field value.", - goInfo->id,goInfo->type,N,dataN); + goInfo->id,goInfo->type,N,dataN); } inline void CheckGOConsumable(GameObjectInfo const* goInfo,uint32 dataN,uint32 N) @@ -5934,7 +5960,7 @@ inline void CheckGOConsumable(GameObjectInfo const* goInfo,uint32 dataN,uint32 N return; sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but expected boolean (0/1) consumable field value.", - goInfo->id,goInfo->type,N,dataN); + goInfo->id,goInfo->type,N,dataN); } inline void CheckAndFixGOCaptureMinTime(GameObjectInfo const* goInfo, uint32 const& dataN, uint32 N) @@ -5943,7 +5969,7 @@ inline void CheckAndFixGOCaptureMinTime(GameObjectInfo const* goInfo, uint32 con return; sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) has data%d=%u but minTime field value must be > 0.", - goInfo->id, goInfo->type, N, dataN); + goInfo->id, goInfo->type, N, dataN); // prevent division through 0 exception const_cast(dataN) = 1; @@ -5955,7 +5981,7 @@ void ObjectMgr::LoadGameobjectInfo() loader.Load(sGOStorage); // some checks - for(uint32 id = 1; id < sGOStorage.MaxEntry; id++) + for (uint32 id = 1; id < sGOStorage.MaxEntry; id++) { GameObjectInfo const* goInfo = sGOStorage.LookupEntry(id); if (!goInfo) @@ -5965,13 +5991,13 @@ void ObjectMgr::LoadGameobjectInfo() if (goInfo->size <= 0.0f) // prevent use too small scales { ERROR_DB_STRICT_LOG("Gameobject (Entry: %u GoType: %u) have too small size=%f", - goInfo->id, goInfo->type, goInfo->size); + goInfo->id, goInfo->type, goInfo->size); const_cast(goInfo)->size = DEFAULT_OBJECT_SCALE; } // some GO types have unused go template, check goInfo->displayId at GO spawn data loading or ignore - switch(goInfo->type) + switch (goInfo->type) { case GAMEOBJECT_TYPE_DOOR: //0 { @@ -6026,7 +6052,7 @@ void ObjectMgr::LoadGameobjectInfo() { if (!sSpellFocusObjectStore.LookupEntry(goInfo->spellFocus.focusId)) sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data0=%u but SpellFocus (Id: %u) not exist.", - id,goInfo->type,goInfo->spellFocus.focusId,goInfo->spellFocus.focusId); + id,goInfo->type,goInfo->spellFocus.focusId,goInfo->spellFocus.focusId); } if (goInfo->spellFocus.linkedTrapId) // linked trap @@ -6044,7 +6070,7 @@ void ObjectMgr::LoadGameobjectInfo() { if (!sPageTextStore.LookupEntry(goInfo->goober.pageId)) sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data7=%u but PageText (Entry %u) not exist.", - id,goInfo->type,goInfo->goober.pageId,goInfo->goober.pageId); + id,goInfo->type,goInfo->goober.pageId,goInfo->goober.pageId); } /* disable check for while, too many nonexistent spells if (goInfo->goober.spellId) // spell @@ -6073,7 +6099,7 @@ void ObjectMgr::LoadGameobjectInfo() { if (goInfo->moTransport.taxiPathId >= sTaxiPathNodesByPath.size() || sTaxiPathNodesByPath[goInfo->moTransport.taxiPathId].empty()) sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data0=%u but TaxiPath (Id: %u) not exist.", - id,goInfo->type,goInfo->moTransport.taxiPathId,goInfo->moTransport.taxiPathId); + id,goInfo->type,goInfo->moTransport.taxiPathId,goInfo->moTransport.taxiPathId); } break; } @@ -6122,14 +6148,14 @@ void ObjectMgr::LoadGameobjectInfo() } } - sLog.outString( ">> Loaded %u game object templates", sGOStorage.RecordCount ); + sLog.outString(">> Loaded %u game object templates", sGOStorage.RecordCount); sLog.outString(); } void ObjectMgr::LoadExplorationBaseXP() { uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT level,basexp FROM exploration_basexp"); + QueryResult* result = WorldDatabase.Query("SELECT level,basexp FROM exploration_basexp"); if (!result) { @@ -6148,7 +6174,7 @@ void ObjectMgr::LoadExplorationBaseXP() { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 level = fields[0].GetUInt32(); uint32 basexp = fields[1].GetUInt32(); mBaseXPTable[level] = basexp; @@ -6159,7 +6185,7 @@ void ObjectMgr::LoadExplorationBaseXP() delete result; sLog.outString(); - sLog.outString( ">> Loaded %u BaseXP definitions", count ); + sLog.outString(">> Loaded %u BaseXP definitions", count); } uint32 ObjectMgr::GetBaseXP(uint32 level) const @@ -6178,7 +6204,7 @@ uint32 ObjectMgr::GetXPForLevel(uint32 level) const void ObjectMgr::LoadPetNames() { uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT word,entry,half FROM pet_name_generation"); + QueryResult* result = WorldDatabase.Query("SELECT word,entry,half FROM pet_name_generation"); if (!result) { @@ -6197,7 +6223,7 @@ void ObjectMgr::LoadPetNames() { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); std::string word = fields[0].GetString(); uint32 entry = fields[1].GetUInt32(); bool half = fields[2].GetBool(); @@ -6211,15 +6237,15 @@ void ObjectMgr::LoadPetNames() delete result; sLog.outString(); - sLog.outString( ">> Loaded %u pet name parts", count ); + sLog.outString(">> Loaded %u pet name parts", count); } void ObjectMgr::LoadPetNumber() { QueryResult* result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet"); - if(result) + if (result) { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); m_PetNumbers.Set(fields[0].GetUInt32()+1); delete result; } @@ -6233,12 +6259,12 @@ void ObjectMgr::LoadPetNumber() std::string ObjectMgr::GeneratePetName(uint32 entry) { - std::vector & list0 = PetHalfName0[entry]; - std::vector & list1 = PetHalfName1[entry]; + std::vector& list0 = PetHalfName0[entry]; + std::vector& list1 = PetHalfName1[entry]; if (list0.empty() || list1.empty()) { - CreatureInfo const *cinfo = GetCreatureTemplate(entry); + CreatureInfo const* cinfo = GetCreatureTemplate(entry); char const* petname = GetPetName(cinfo->family, sWorld.GetDefaultDbcLocale()); if (!petname) petname = cinfo->Name; @@ -6252,11 +6278,11 @@ void ObjectMgr::LoadCorpses() { uint32 count = 0; // 0 1 2 3 4 5 6 - QueryResult *result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map, " - // 7 8 9 10 11 12 13 14 15 16 17 18 - "time, corpse_type, instance, phaseMask, gender, race, class, playerBytes, playerBytes2, equipmentCache, guildId, playerFlags FROM corpse " - "JOIN characters ON player = characters.guid " - "LEFT JOIN guild_member ON player=guild_member.guid WHERE corpse_type <> 0"); + QueryResult* result = CharacterDatabase.Query("SELECT corpse.guid, player, corpse.position_x, corpse.position_y, corpse.position_z, corpse.orientation, corpse.map, " + // 7 8 9 10 11 12 13 14 15 16 17 18 + "time, corpse_type, instance, phaseMask, gender, race, class, playerBytes, playerBytes2, equipmentCache, guildId, playerFlags FROM corpse " + "JOIN characters ON player = characters.guid " + "LEFT JOIN guild_member ON player=guild_member.guid WHERE corpse_type <> 0"); if (!result) { @@ -6275,11 +6301,11 @@ void ObjectMgr::LoadCorpses() { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 guid = fields[0].GetUInt32(); - Corpse *corpse = new Corpse; + Corpse* corpse = new Corpse; if (!corpse->LoadFromDB(guid,fields)) { delete corpse; @@ -6294,7 +6320,7 @@ void ObjectMgr::LoadCorpses() delete result; sLog.outString(); - sLog.outString( ">> Loaded %u corpses", count ); + sLog.outString(">> Loaded %u corpses", count); } void ObjectMgr::LoadReputationRewardRate() @@ -6302,7 +6328,7 @@ void ObjectMgr::LoadReputationRewardRate() m_RepRewardRateMap.clear(); // for reload case uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT faction, quest_rate, creature_rate, spell_rate FROM reputation_reward_rate"); + QueryResult* result = WorldDatabase.Query("SELECT faction, quest_rate, creature_rate, spell_rate FROM reputation_reward_rate"); if (!result) { @@ -6321,7 +6347,7 @@ void ObjectMgr::LoadReputationRewardRate() { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 factionId = fields[0].GetUInt32(); @@ -6331,7 +6357,7 @@ void ObjectMgr::LoadReputationRewardRate() repRate.creature_rate = fields[2].GetFloat(); repRate.spell_rate = fields[3].GetFloat(); - FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionId); + FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId); if (!factionEntry) { sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_reward_rate`", factionId); @@ -6373,10 +6399,10 @@ void ObjectMgr::LoadReputationOnKill() uint32 count = 0; // 0 1 2 - QueryResult *result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2," - // 3 4 5 6 7 8 9 - "IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent " - "FROM creature_onkill_reputation"); + QueryResult* result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2," + // 3 4 5 6 7 8 9 + "IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent " + "FROM creature_onkill_reputation"); if (!result) { @@ -6393,7 +6419,7 @@ void ObjectMgr::LoadReputationOnKill() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 creature_id = fields[0].GetUInt32(); @@ -6409,26 +6435,26 @@ void ObjectMgr::LoadReputationOnKill() repOnKill.repvalue2 = fields[8].GetInt32(); repOnKill.team_dependent = fields[9].GetUInt8(); - if(!GetCreatureTemplate(creature_id)) + if (!GetCreatureTemplate(creature_id)) { sLog.outErrorDb("Table `creature_onkill_reputation` have data for nonexistent creature entry (%u), skipped",creature_id); continue; } - if(repOnKill.repfaction1) + if (repOnKill.repfaction1) { - FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(repOnKill.repfaction1); - if(!factionEntry1) + FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repOnKill.repfaction1); + if (!factionEntry1) { sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction1); continue; } } - if(repOnKill.repfaction2) + if (repOnKill.repfaction2) { - FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(repOnKill.repfaction2); - if(!factionEntry2) + FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repOnKill.repfaction2); + if (!factionEntry2) { sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `creature_onkill_reputation`",repOnKill.repfaction2); continue; @@ -6438,7 +6464,8 @@ void ObjectMgr::LoadReputationOnKill() mRepOnKill[creature_id] = repOnKill; ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -6451,7 +6478,7 @@ void ObjectMgr::LoadReputationSpilloverTemplate() m_RepSpilloverTemplateMap.clear(); // for reload case uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT faction, faction1, rate_1, rank_1, faction2, rate_2, rank_2, faction3, rate_3, rank_3, faction4, rate_4, rank_4 FROM reputation_spillover_template"); + QueryResult* result = WorldDatabase.Query("SELECT faction, faction1, rate_1, rank_1, faction2, rate_2, rank_2, faction3, rate_3, rank_3, faction4, rate_4, rank_4 FROM reputation_spillover_template"); if (!result) { @@ -6470,7 +6497,7 @@ void ObjectMgr::LoadReputationSpilloverTemplate() { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 factionId = fields[0].GetUInt32(); @@ -6489,7 +6516,7 @@ void ObjectMgr::LoadReputationSpilloverTemplate() repTemplate.faction_rate[3] = fields[11].GetFloat(); repTemplate.faction_rank[3] = fields[12].GetUInt32(); - FactionEntry const *factionEntry = sFactionStore.LookupEntry(factionId); + FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId); if (!factionEntry) { @@ -6507,7 +6534,7 @@ void ObjectMgr::LoadReputationSpilloverTemplate() { if (repTemplate.faction[i]) { - FactionEntry const *factionSpillover = sFactionStore.LookupEntry(repTemplate.faction[i]); + FactionEntry const* factionSpillover = sFactionStore.LookupEntry(repTemplate.faction[i]); if (!factionSpillover) { @@ -6529,25 +6556,25 @@ void ObjectMgr::LoadReputationSpilloverTemplate() } } - FactionEntry const *factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]); + FactionEntry const* factionEntry0 = sFactionStore.LookupEntry(repTemplate.faction[0]); if (repTemplate.faction[0] && !factionEntry0) { sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[0]); continue; } - FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]); + FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(repTemplate.faction[1]); if (repTemplate.faction[1] && !factionEntry1) { sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[1]); continue; } - FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]); + FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(repTemplate.faction[2]); if (repTemplate.faction[2] && !factionEntry2) { sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[2]); continue; } - FactionEntry const *factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]); + FactionEntry const* factionEntry3 = sFactionStore.LookupEntry(repTemplate.faction[3]); if (repTemplate.faction[3] && !factionEntry3) { sLog.outErrorDb("Faction (faction.dbc) %u does not exist but is used in `reputation_spillover_template`", repTemplate.faction[3]); @@ -6573,7 +6600,7 @@ void ObjectMgr::LoadPointsOfInterest() uint32 count = 0; // 0 1 2 3 4 5 - QueryResult *result = WorldDatabase.Query("SELECT entry, x, y, icon, flags, data, icon_name FROM points_of_interest"); + QueryResult* result = WorldDatabase.Query("SELECT entry, x, y, icon, flags, data, icon_name FROM points_of_interest"); if (!result) { @@ -6590,7 +6617,7 @@ void ObjectMgr::LoadPointsOfInterest() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 point_id = fields[0].GetUInt32(); @@ -6603,7 +6630,7 @@ void ObjectMgr::LoadPointsOfInterest() POI.data = fields[5].GetUInt32(); POI.icon_name = fields[6].GetCppString(); - if(!MaNGOS::IsValidMapCoord(POI.x,POI.y)) + if (!MaNGOS::IsValidMapCoord(POI.x,POI.y)) { sLog.outErrorDb("Table `points_of_interest` (Entry: %u) have invalid coordinates (X: %f Y: %f), ignored.",point_id,POI.x,POI.y); continue; @@ -6612,7 +6639,8 @@ void ObjectMgr::LoadPointsOfInterest() mPointsOfInterest[point_id] = POI; ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -6627,7 +6655,7 @@ void ObjectMgr::LoadQuestPOI() uint32 count = 0; // 0 1 2 3 4 5 6 7 - QueryResult *result = WorldDatabase.Query("SELECT questId, poiId, objIndex, mapId, mapAreaId, floorId, unk3, unk4 FROM quest_poi"); + QueryResult* result = WorldDatabase.Query("SELECT questId, poiId, objIndex, mapId, mapAreaId, floorId, unk3, unk4 FROM quest_poi"); if (!result) { @@ -6644,7 +6672,7 @@ void ObjectMgr::LoadQuestPOI() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 questId = fields[0].GetUInt32(); @@ -6661,17 +6689,18 @@ void ObjectMgr::LoadQuestPOI() mQuestPOIMap[questId].push_back(POI); ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; - QueryResult *points = WorldDatabase.Query("SELECT questId, poiId, x, y FROM quest_poi_points"); + QueryResult* points = WorldDatabase.Query("SELECT questId, poiId, x, y FROM quest_poi_points"); if (points) { do { - Field *pointFields = points->Fetch(); + Field* pointFields = points->Fetch(); uint32 questId = pointFields[0].GetUInt32(); uint32 poiId = pointFields[1].GetUInt32(); @@ -6680,7 +6709,7 @@ void ObjectMgr::LoadQuestPOI() QuestPOIVector& vect = mQuestPOIMap[questId]; - for(QuestPOIVector::iterator itr = vect.begin(); itr != vect.end(); ++itr) + for (QuestPOIVector::iterator itr = vect.begin(); itr != vect.end(); ++itr) { if (itr->PoiId != poiId) continue; @@ -6689,7 +6718,8 @@ void ObjectMgr::LoadQuestPOI() itr->points.push_back(point); break; } - } while (points->NextRow()); + } + while (points->NextRow()); delete points; } @@ -6704,7 +6734,7 @@ void ObjectMgr::LoadNPCSpellClickSpells() mSpellClickInfoMap.clear(); // 0 1 2 3 4 5 - QueryResult *result = WorldDatabase.Query("SELECT npc_entry, spell_id, quest_start, quest_start_active, quest_end, cast_flags FROM npc_spellclick_spells"); + QueryResult* result = WorldDatabase.Query("SELECT npc_entry, spell_id, quest_start, quest_start_active, quest_end, cast_flags FROM npc_spellclick_spells"); if (!result) { @@ -6721,7 +6751,7 @@ void ObjectMgr::LoadNPCSpellClickSpells() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 npc_entry = fields[0].GetUInt32(); @@ -6733,7 +6763,7 @@ void ObjectMgr::LoadNPCSpellClickSpells() } uint32 spellid = fields[1].GetUInt32(); - SpellEntry const *spellinfo = sSpellStore.LookupEntry(spellid); + SpellEntry const* spellinfo = sSpellStore.LookupEntry(spellid); if (!spellinfo) { sLog.outErrorDb("Table npc_spellclick_spells references unknown spellid %u. Skipping entry.", spellid); @@ -6745,7 +6775,7 @@ void ObjectMgr::LoadNPCSpellClickSpells() // quest might be 0 to enable spellclick independent of any quest if (quest_start) { - if(mQuestTemplates.find(quest_start) == mQuestTemplates.end()) + if (mQuestTemplates.find(quest_start) == mQuestTemplates.end()) { sLog.outErrorDb("Table npc_spellclick_spells references unknown start quest %u. Skipping entry.", quest_start); continue; @@ -6759,7 +6789,7 @@ void ObjectMgr::LoadNPCSpellClickSpells() // quest might be 0 to enable spellclick active infinity after start quest if (quest_end) { - if(mQuestTemplates.find(quest_end) == mQuestTemplates.end()) + if (mQuestTemplates.find(quest_end) == mQuestTemplates.end()) { sLog.outErrorDb("Table npc_spellclick_spells references unknown end quest %u. Skipping entry.", quest_end); continue; @@ -6780,7 +6810,8 @@ void ObjectMgr::LoadNPCSpellClickSpells() const_cast(cInfo)->npcflag |= UNIT_NPC_FLAG_SPELLCLICK; ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -6793,7 +6824,7 @@ static char* SERVER_SIDE_SPELL = "MaNGOS server-side spell"; struct SQLSpellLoader : public SQLStorageLoaderBase { template - void default_fill(uint32 field_pos, S src, D &dst) + void default_fill(uint32 field_pos, S src, D& dst) { if (field_pos == LOADED_SPELLDBC_FIELD_POS_EQUIPPED_ITEM_CLASS) dst = D(-1); @@ -6801,7 +6832,7 @@ struct SQLSpellLoader : public SQLStorageLoaderBase dst = D(src); } - void default_fill_to_str(uint32 field_pos, char const* /*src*/, char * & dst) + void default_fill_to_str(uint32 field_pos, char const* /*src*/, char*& dst) { if (field_pos == LOADED_SPELLDBC_FIELD_POS_SPELLNAME_0) { @@ -6846,7 +6877,7 @@ void ObjectMgr::LoadWeatherZoneChances() uint32 count = 0; // 0 1 2 3 4 5 6 7 8 9 10 11 12 - QueryResult *result = WorldDatabase.Query("SELECT zone, spring_rain_chance, spring_snow_chance, spring_storm_chance, summer_rain_chance, summer_snow_chance, summer_storm_chance, fall_rain_chance, fall_snow_chance, fall_storm_chance, winter_rain_chance, winter_snow_chance, winter_storm_chance FROM game_weather"); + QueryResult* result = WorldDatabase.Query("SELECT zone, spring_rain_chance, spring_snow_chance, spring_storm_chance, summer_rain_chance, summer_snow_chance, summer_storm_chance, fall_rain_chance, fall_snow_chance, fall_storm_chance, winter_rain_chance, winter_snow_chance, winter_storm_chance FROM game_weather"); if (!result) { @@ -6863,32 +6894,32 @@ void ObjectMgr::LoadWeatherZoneChances() do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 zone_id = fields[0].GetUInt32(); WeatherZoneChances& wzc = mWeatherZoneMap[zone_id]; - for(int season = 0; season < WEATHER_SEASONS; ++season) + for (int season = 0; season < WEATHER_SEASONS; ++season) { wzc.data[season].rainChance = fields[season * (MAX_WEATHER_TYPE-1) + 1].GetUInt32(); wzc.data[season].snowChance = fields[season * (MAX_WEATHER_TYPE-1) + 2].GetUInt32(); wzc.data[season].stormChance = fields[season * (MAX_WEATHER_TYPE-1) + 3].GetUInt32(); - if(wzc.data[season].rainChance > 100) + if (wzc.data[season].rainChance > 100) { wzc.data[season].rainChance = 25; sLog.outErrorDb("Weather for zone %u season %u has wrong rain chance > 100%%",zone_id,season); } - if(wzc.data[season].snowChance > 100) + if (wzc.data[season].snowChance > 100) { wzc.data[season].snowChance = 25; sLog.outErrorDb("Weather for zone %u season %u has wrong snow chance > 100%%",zone_id,season); } - if(wzc.data[season].stormChance > 100) + if (wzc.data[season].stormChance > 100) { wzc.data[season].stormChance = 25; sLog.outErrorDb("Weather for zone %u season %u has wrong storm chance > 100%%",zone_id,season); @@ -6896,7 +6927,8 @@ void ObjectMgr::LoadWeatherZoneChances() } ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -6908,7 +6940,7 @@ void ObjectMgr::DeleteCreatureData(uint32 guid) { // remove mapid*cellid -> guid_set map CreatureData const* data = GetCreatureData(guid); - if(data) + if (data) RemoveCreatureFromGrid(guid, data); mCreatureDataMap.erase(guid); @@ -6918,7 +6950,7 @@ void ObjectMgr::DeleteGOData(uint32 guid) { // remove mapid*cellid -> guid_set map GameObjectData const* data = GetGOData(guid); - if(data) + if (data) RemoveGameobjectFromGrid(guid, data); mGameObjectDataMap.erase(guid); @@ -6944,7 +6976,7 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, char const* tab uint32 count = 0; - QueryResult *result = WorldDatabase.PQuery("SELECT id,quest FROM %s",table); + QueryResult* result = WorldDatabase.PQuery("SELECT id,quest FROM %s",table); if (!result) { @@ -6961,7 +6993,7 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, char const* tab do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); uint32 id = fields[0].GetUInt32(); @@ -6976,7 +7008,8 @@ void ObjectMgr::LoadQuestRelationsHelper(QuestRelationsMap& map, char const* tab map.insert(QuestRelationsMap::value_type(id, quest)); ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; @@ -6988,7 +7021,7 @@ void ObjectMgr::LoadGameobjectQuestRelations() { LoadQuestRelationsHelper(m_GOQuestRelations, "gameobject_questrelation"); - for(QuestRelationsMap::iterator itr = m_GOQuestRelations.begin(); itr != m_GOQuestRelations.end(); ++itr) + for (QuestRelationsMap::iterator itr = m_GOQuestRelations.begin(); itr != m_GOQuestRelations.end(); ++itr) { GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first); if (!goInfo) @@ -7002,7 +7035,7 @@ void ObjectMgr::LoadGameobjectInvolvedRelations() { LoadQuestRelationsHelper(m_GOQuestInvolvedRelations, "gameobject_involvedrelation"); - for(QuestRelationsMap::iterator itr = m_GOQuestInvolvedRelations.begin(); itr != m_GOQuestInvolvedRelations.end(); ++itr) + for (QuestRelationsMap::iterator itr = m_GOQuestInvolvedRelations.begin(); itr != m_GOQuestInvolvedRelations.end(); ++itr) { GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first); if (!goInfo) @@ -7016,7 +7049,7 @@ void ObjectMgr::LoadCreatureQuestRelations() { LoadQuestRelationsHelper(m_CreatureQuestRelations, "creature_questrelation"); - for(QuestRelationsMap::iterator itr = m_CreatureQuestRelations.begin(); itr != m_CreatureQuestRelations.end(); ++itr) + for (QuestRelationsMap::iterator itr = m_CreatureQuestRelations.begin(); itr != m_CreatureQuestRelations.end(); ++itr) { CreatureInfo const* cInfo = GetCreatureTemplate(itr->first); if (!cInfo) @@ -7030,7 +7063,7 @@ void ObjectMgr::LoadCreatureInvolvedRelations() { LoadQuestRelationsHelper(m_CreatureQuestInvolvedRelations, "creature_involvedrelation"); - for(QuestRelationsMap::iterator itr = m_CreatureQuestInvolvedRelations.begin(); itr != m_CreatureQuestInvolvedRelations.end(); ++itr) + for (QuestRelationsMap::iterator itr = m_CreatureQuestInvolvedRelations.begin(); itr != m_CreatureQuestInvolvedRelations.end(); ++itr) { CreatureInfo const* cInfo = GetCreatureTemplate(itr->first); if (!cInfo) @@ -7044,7 +7077,7 @@ void ObjectMgr::LoadReservedPlayersNames() { m_ReservedNames.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT name FROM reserved_name"); + QueryResult* result = WorldDatabase.Query("SELECT name FROM reserved_name"); uint32 count = 0; @@ -7068,9 +7101,9 @@ void ObjectMgr::LoadReservedPlayersNames() std::string name= fields[0].GetCppString(); std::wstring wstr; - if (!Utf8toWStr (name,wstr)) + if (!Utf8toWStr(name,wstr)) { - sLog.outError("Table `reserved_name` have invalid name: %s", name.c_str() ); + sLog.outError("Table `reserved_name` have invalid name: %s", name.c_str()); continue; } @@ -7078,18 +7111,19 @@ void ObjectMgr::LoadReservedPlayersNames() m_ReservedNames.insert(wstr); ++count; - } while ( result->NextRow() ); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u reserved player names", count ); + sLog.outString(">> Loaded %u reserved player names", count); } -bool ObjectMgr::IsReservedName( const std::string& name ) const +bool ObjectMgr::IsReservedName(const std::string& name) const { std::wstring wstr; - if(!Utf8toWStr (name,wstr)) + if (!Utf8toWStr(name,wstr)) return false; wstrToLower(wstr); @@ -7108,7 +7142,7 @@ enum LanguageType static LanguageType GetRealmLanguageType(bool create) { - switch(sWorld.getConfig(CONFIG_UINT32_REALM_ZONE)) + switch (sWorld.getConfig(CONFIG_UINT32_REALM_ZONE)) { case REALM_ZONE_UNKNOWN: // any language case REALM_ZONE_DEVELOPMENT: @@ -7136,71 +7170,71 @@ static LanguageType GetRealmLanguageType(bool create) bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create = false) { - if(strictMask==0) // any language, ignore realm + if (strictMask==0) // any language, ignore realm { - if(isExtendedLatinString(wstr,numericOrSpace)) + if (isExtendedLatinString(wstr,numericOrSpace)) return true; - if(isCyrillicString(wstr,numericOrSpace)) + if (isCyrillicString(wstr,numericOrSpace)) return true; - if(isEastAsianString(wstr,numericOrSpace)) + if (isEastAsianString(wstr,numericOrSpace)) return true; return false; } - if(strictMask & 0x2) // realm zone specific + if (strictMask & 0x2) // realm zone specific { LanguageType lt = GetRealmLanguageType(create); - if(lt & LT_EXTENDEN_LATIN) - if(isExtendedLatinString(wstr,numericOrSpace)) + if (lt & LT_EXTENDEN_LATIN) + if (isExtendedLatinString(wstr,numericOrSpace)) return true; - if(lt & LT_CYRILLIC) - if(isCyrillicString(wstr,numericOrSpace)) + if (lt & LT_CYRILLIC) + if (isCyrillicString(wstr,numericOrSpace)) return true; - if(lt & LT_EAST_ASIA) - if(isEastAsianString(wstr,numericOrSpace)) + if (lt & LT_EAST_ASIA) + if (isEastAsianString(wstr,numericOrSpace)) return true; } - if(strictMask & 0x1) // basic Latin + if (strictMask & 0x1) // basic Latin { - if(isBasicLatinString(wstr,numericOrSpace)) + if (isBasicLatinString(wstr,numericOrSpace)) return true; } return false; } -uint8 ObjectMgr::CheckPlayerName( const std::string& name, bool create ) +uint8 ObjectMgr::CheckPlayerName(const std::string& name, bool create) { std::wstring wname; - if(!Utf8toWStr(name,wname)) + if (!Utf8toWStr(name,wname)) return CHAR_NAME_INVALID_CHARACTER; - if(wname.size() > MAX_PLAYER_NAME) + if (wname.size() > MAX_PLAYER_NAME) return CHAR_NAME_TOO_LONG; uint32 minName = sWorld.getConfig(CONFIG_UINT32_MIN_PLAYER_NAME); - if(wname.size() < minName) + if (wname.size() < minName) return CHAR_NAME_TOO_SHORT; uint32 strictMask = sWorld.getConfig(CONFIG_UINT32_STRICT_PLAYER_NAMES); - if(!isValidString(wname,strictMask,false,create)) + if (!isValidString(wname,strictMask,false,create)) return CHAR_NAME_MIXED_LANGUAGES; return CHAR_NAME_SUCCESS; } -bool ObjectMgr::IsValidCharterName( const std::string& name ) +bool ObjectMgr::IsValidCharterName(const std::string& name) { std::wstring wname; - if(!Utf8toWStr(name,wname)) + if (!Utf8toWStr(name,wname)) return false; - if(wname.size() > MAX_CHARTER_NAME) + if (wname.size() > MAX_CHARTER_NAME) return false; uint32 minName = sWorld.getConfig(CONFIG_UINT32_MIN_CHARTER_NAME); - if(wname.size() < minName) + if (wname.size() < minName) return false; uint32 strictMask = sWorld.getConfig(CONFIG_UINT32_STRICT_CHARTER_NAMES); @@ -7208,33 +7242,33 @@ bool ObjectMgr::IsValidCharterName( const std::string& name ) return isValidString(wname,strictMask,true); } -PetNameInvalidReason ObjectMgr::CheckPetName( const std::string& name ) +PetNameInvalidReason ObjectMgr::CheckPetName(const std::string& name) { std::wstring wname; - if(!Utf8toWStr(name,wname)) + if (!Utf8toWStr(name,wname)) return PET_NAME_INVALID; - if(wname.size() > MAX_PET_NAME) + if (wname.size() > MAX_PET_NAME) return PET_NAME_TOO_LONG; uint32 minName = sWorld.getConfig(CONFIG_UINT32_MIN_PET_NAME); - if(wname.size() < minName) + if (wname.size() < minName) return PET_NAME_TOO_SHORT; uint32 strictMask = sWorld.getConfig(CONFIG_UINT32_STRICT_PET_NAMES); - if(!isValidString(wname,strictMask,false)) + if (!isValidString(wname,strictMask,false)) return PET_NAME_MIXED_LANGUAGES; return PET_NAME_SUCCESS; } -int ObjectMgr::GetIndexForLocale( LocaleConstant loc ) +int ObjectMgr::GetIndexForLocale(LocaleConstant loc) { - if(loc==LOCALE_enUS) + if (loc==LOCALE_enUS) return -1; - for(size_t i=0;i < m_LocalForIndex.size(); ++i) - if(m_LocalForIndex[i]==loc) + for (size_t i=0; i < m_LocalForIndex.size(); ++i) + if (m_LocalForIndex[i]==loc) return i; return -1; @@ -7248,13 +7282,13 @@ LocaleConstant ObjectMgr::GetLocaleForIndex(int i) return m_LocalForIndex[i]; } -int ObjectMgr::GetOrNewIndexForLocale( LocaleConstant loc ) +int ObjectMgr::GetOrNewIndexForLocale(LocaleConstant loc) { - if(loc==LOCALE_enUS) + if (loc==LOCALE_enUS) return -1; - for(size_t i=0;i < m_LocalForIndex.size(); ++i) - if(m_LocalForIndex[i]==loc) + for (size_t i=0; i < m_LocalForIndex.size(); ++i) + if (m_LocalForIndex[i]==loc) return i; m_LocalForIndex.push_back(loc); @@ -7285,12 +7319,12 @@ void ObjectMgr::LoadGameObjectForQuests() if (!goInfo) continue; - switch(goInfo->type) + switch (goInfo->type) { case GAMEOBJECT_TYPE_QUESTGIVER: { if (m_GOQuestRelations.find(go_entry) != m_GOQuestRelations.end() || - m_GOQuestInvolvedRelations.find(go_entry) != m_GOQuestInvolvedRelations.end()) + m_GOQuestInvolvedRelations.find(go_entry) != m_GOQuestInvolvedRelations.end()) { mGameObjectForQuestSet.insert(go_entry); ++count; @@ -7344,7 +7378,7 @@ void ObjectMgr::LoadGameObjectForQuests() } sLog.outString(); - sLog.outString( ">> Loaded %u GameObjects for quests", count ); + sLog.outString(">> Loaded %u GameObjects for quests", count); } bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value) @@ -7375,7 +7409,7 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min } // cleanup affected map part for reloading case - for(MangosStringLocaleMap::iterator itr = mMangosStringLocaleMap.begin(); itr != mMangosStringLocaleMap.end();) + for (MangosStringLocaleMap::iterator itr = mMangosStringLocaleMap.begin(); itr != mMangosStringLocaleMap.end();) { if (itr->first >= start_value && itr->first < end_value) mMangosStringLocaleMap.erase(itr++); @@ -7383,7 +7417,7 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min ++itr; } - QueryResult *result = db.PQuery("SELECT entry,content_default,content_loc1,content_loc2,content_loc3,content_loc4,content_loc5,content_loc6,content_loc7,content_loc8 FROM %s",table); + QueryResult* result = db.PQuery("SELECT entry,content_default,content_loc1,content_loc2,content_loc3,content_loc4,content_loc5,content_loc6,content_loc7,content_loc8 FROM %s",table); if (!result) { @@ -7405,7 +7439,7 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min do { - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); bar.step(); int32 entry = fields[0].GetInt32(); @@ -7435,7 +7469,7 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min // 0 -> default, idx in to idx+1 data.Content[0] = fields[1].GetCppString(); - for(int i = 1; i < MAX_LOCALE; ++i) + for (int i = 1; i < MAX_LOCALE; ++i) { std::string str = fields[i+1].GetCppString(); if (!str.empty()) @@ -7451,36 +7485,37 @@ bool ObjectMgr::LoadMangosStrings(DatabaseType& db, char const* table, int32 min } } } - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); if (min_value == MIN_MANGOS_STRING_ID) - sLog.outString( ">> Loaded %u MaNGOS strings from table %s", count,table); + sLog.outString(">> Loaded %u MaNGOS strings from table %s", count,table); else - sLog.outString( ">> Loaded %u string templates from %s", count,table); + sLog.outString(">> Loaded %u string templates from %s", count,table); return true; } -const char *ObjectMgr::GetMangosString(int32 entry, int locale_idx) const +const char* ObjectMgr::GetMangosString(int32 entry, int locale_idx) const { // locale_idx==-1 -> default, locale_idx >= 0 in to idx+1 // Content[0] always exist if exist MangosStringLocale - if(MangosStringLocale const *msl = GetMangosStringLocale(entry)) + if (MangosStringLocale const* msl = GetMangosStringLocale(entry)) { - if((int32)msl->Content.size() > locale_idx+1 && !msl->Content[locale_idx+1].empty()) + if ((int32)msl->Content.size() > locale_idx+1 && !msl->Content[locale_idx+1].empty()) return msl->Content[locale_idx+1].c_str(); else return msl->Content[0].c_str(); } - if(entry > MIN_DB_SCRIPT_STRING_ID) + if (entry > MIN_DB_SCRIPT_STRING_ID) sLog.outErrorDb("Entry %i not found in `db_script_string` table.",entry); - else if(entry > 0) + else if (entry > 0) sLog.outErrorDb("Entry %i not found in `mangos_string` table.",entry); - else if(entry > MAX_CREATURE_AI_TEXT_STRING_ID) + else if (entry > MAX_CREATURE_AI_TEXT_STRING_ID) sLog.outErrorDb("Entry %i not found in `creature_ai_texts` table.",entry); else sLog.outErrorDb("Mangos string entry %i not found in DB.",entry); @@ -7492,7 +7527,7 @@ void ObjectMgr::LoadFishingBaseSkillLevel() mFishingBaseForArea.clear(); // for reload case uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT entry,skill FROM skill_fishing_base_level"); + QueryResult* result = WorldDatabase.Query("SELECT entry,skill FROM skill_fishing_base_level"); if (!result) { @@ -7511,7 +7546,7 @@ void ObjectMgr::LoadFishingBaseSkillLevel() { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 entry = fields[0].GetUInt32(); int32 skill = fields[1].GetInt32(); @@ -7535,7 +7570,7 @@ void ObjectMgr::LoadFishingBaseSkillLevel() // Searches for the same condition already in Conditions store // Returns Id if found, else adds it to Conditions and returns Id -uint16 ObjectMgr::GetConditionId( ConditionType condition, uint32 value1, uint32 value2 ) +uint16 ObjectMgr::GetConditionId(ConditionType condition, uint32 value1, uint32 value2) { PlayerCondition lc = PlayerCondition(0, condition, value1, value2); for (uint16 i=0; i < mConditions.size(); ++i) @@ -7546,7 +7581,7 @@ uint16 ObjectMgr::GetConditionId( ConditionType condition, uint32 value1, uint32 mConditions.push_back(lc); - if(mConditions.size() > 0xFFFF) + if (mConditions.size() > 0xFFFF) { sLog.outError("Conditions store overflow! Current and later loaded conditions will ignored!"); return 0; @@ -7567,22 +7602,22 @@ bool ObjectMgr::IsPlayerMeetToNEWCondition(Player const* pPlayer, uint16 conditi return false; } -bool ObjectMgr::CheckDeclinedNames( std::wstring mainpart, DeclinedName const& names ) +bool ObjectMgr::CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names) { - for(int i =0; i < MAX_DECLINED_NAME_CASES; ++i) + for (int i =0; i < MAX_DECLINED_NAME_CASES; ++i) { std::wstring wname; - if(!Utf8toWStr(names.name[i],wname)) + if (!Utf8toWStr(names.name[i],wname)) return false; - if(mainpart!=GetMainPartOfName(wname,i+1)) + if (mainpart!=GetMainPartOfName(wname,i+1)) return false; } return true; } // Checks if player meets the condition -bool PlayerCondition::Meets(Player const * player) const +bool PlayerCondition::Meets(Player const* player) const { if (!player) return false; // player not present, return false @@ -7641,7 +7676,7 @@ bool PlayerCondition::Meets(Player const * player) const return sGameEventMgr.IsActiveEvent(m_value1); case CONDITION_AREA_FLAG: { - if (AreaTableEntry const *pAreaEntry = GetAreaEntryByAreaID(player->GetAreaId())) + if (AreaTableEntry const* pAreaEntry = GetAreaEntryByAreaID(player->GetAreaId())) { if ((!m_value1 || (pAreaEntry->flags & m_value1)) && (!m_value2 || !(pAreaEntry->flags & m_value2))) return true; @@ -7654,7 +7689,7 @@ bool PlayerCondition::Meets(Player const * player) const return false; case CONDITION_LEVEL: { - switch(m_value2) + switch (m_value2) { case 0: return player->getLevel() == m_value1; case 1: return player->getLevel() >= m_value1; @@ -7666,7 +7701,7 @@ bool PlayerCondition::Meets(Player const * player) const return !player->HasItemCount(m_value1, m_value2); case CONDITION_SPELL: { - switch(m_value2) + switch (m_value2) { case 0: return player->HasSpell(m_value1); case 1: return !player->HasSpell(m_value1); @@ -7691,7 +7726,7 @@ bool PlayerCondition::Meets(Player const * player) const } case CONDITION_ACHIEVEMENT: { - switch(m_value2) + switch (m_value2) { case 0: return player->GetAchievementMgr().HasAchievement(m_value1); case 1: return !player->GetAchievementMgr().HasAchievement(m_value1); @@ -7701,7 +7736,7 @@ bool PlayerCondition::Meets(Player const * player) const case CONDITION_ACHIEVEMENT_REALM: { AchievementEntry const* ach = sAchievementStore.LookupEntry(m_value1); - switch(m_value2) + switch (m_value2) { case 0: return sAchievementMgr.IsRealmCompleted(ach); case 1: return !sAchievementMgr.IsRealmCompleted(ach); @@ -7744,7 +7779,7 @@ bool PlayerCondition::Meets(Player const * player) const SkillLineAbilityMapBounds bounds = sSpellMgr.GetSkillLineAbilityMapBounds(m_value1); - for(SkillLineAbilityMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) + for (SkillLineAbilityMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr) { const SkillLineAbilityEntry* skillInfo = itr->second; @@ -7857,7 +7892,7 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu case CONDITION_ITEM_WITH_BANK: case CONDITION_NOITEM_WITH_BANK: { - ItemPrototype const *proto = ObjectMgr::GetItemPrototype(value1); + ItemPrototype const* proto = ObjectMgr::GetItemPrototype(value1); if (!proto) { sLog.outErrorDb("Item condition (entry %u, type %u) requires to have non existing item (%u), skipped", entry, condition, value1); @@ -7873,7 +7908,7 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu } case CONDITION_ITEM_EQUIPPED: { - ItemPrototype const *proto = ObjectMgr::GetItemPrototype(value1); + ItemPrototype const* proto = ObjectMgr::GetItemPrototype(value1); if (!proto) { sLog.outErrorDb("ItemEquipped condition (entry %u, type %u) requires to have non existing item (%u) equipped, skipped", entry, condition, value1); @@ -7926,13 +7961,13 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu case CONDITION_SKILL: case CONDITION_SKILL_BELOW: { - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(value1); + SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(value1); if (!pSkill) { sLog.outErrorDb("Skill condition (entry %u, type %u) specifies non-existing skill (%u), skipped", entry, condition, value1); return false; } - if (value2 < 1 || value2 > sWorld.GetConfigMaxSkillValue() ) + if (value2 < 1 || value2 > sWorld.GetConfigMaxSkillValue()) { sLog.outErrorDb("Skill condition (entry %u, type %u) specifies invalid skill value (%u), skipped", entry, condition, value2); return false; @@ -7944,7 +7979,7 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu case CONDITION_QUESTAVAILABLE: case CONDITION_QUEST_NONE: { - Quest const *Quest = sObjectMgr.GetQuestTemplate(value1); + Quest const* Quest = sObjectMgr.GetQuestTemplate(value1); if (!Quest) { sLog.outErrorDb("Quest condition (entry %u, type %u) specifies non-existing quest (%u), skipped", entry, condition, value1); @@ -8099,7 +8134,7 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu if (value2) { - ItemPrototype const *proto = ObjectMgr::GetItemPrototype(value2); + ItemPrototype const* proto = ObjectMgr::GetItemPrototype(value2); if (!proto) { sLog.outErrorDb("Learnable ability conditon (entry %u, type %u) has item entry %u defined but item does not exist, skipping.", entry, condition, value2); @@ -8118,28 +8153,28 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu return true; } -SkillRangeType GetSkillRangeType(SkillLineEntry const *pSkill, bool racial) +SkillRangeType GetSkillRangeType(SkillLineEntry const* pSkill, bool racial) { - switch(pSkill->categoryId) + switch (pSkill->categoryId) { case SKILL_CATEGORY_LANGUAGES: return SKILL_RANGE_LANGUAGE; case SKILL_CATEGORY_WEAPON: - if(pSkill->id!=SKILL_FIST_WEAPONS) + if (pSkill->id!=SKILL_FIST_WEAPONS) return SKILL_RANGE_LEVEL; else return SKILL_RANGE_MONO; case SKILL_CATEGORY_ARMOR: case SKILL_CATEGORY_CLASS: - if(pSkill->id != SKILL_LOCKPICKING) + if (pSkill->id != SKILL_LOCKPICKING) return SKILL_RANGE_MONO; else return SKILL_RANGE_LEVEL; case SKILL_CATEGORY_SECONDARY: case SKILL_CATEGORY_PROFESSION: // not set skills for professions and racial abilities - if(IsProfessionSkill(pSkill->id)) + if (IsProfessionSkill(pSkill->id)) return SKILL_RANGE_RANK; - else if(racial) + else if (racial) return SKILL_RANGE_NONE; else return SKILL_RANGE_MONO; @@ -8155,7 +8190,7 @@ void ObjectMgr::LoadGameTele() m_GameTeleMap.clear(); // for reload case uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele"); + QueryResult* result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele"); if (!result) { @@ -8174,7 +8209,7 @@ void ObjectMgr::LoadGameTele() { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint32 id = fields[0].GetUInt32(); @@ -8199,7 +8234,7 @@ void ObjectMgr::LoadGameTele() continue; } - wstrToLower( gt.wnameLow ); + wstrToLower(gt.wnameLow); m_GameTeleMap[id] = gt; @@ -8216,16 +8251,16 @@ GameTele const* ObjectMgr::GetGameTele(const std::string& name) const { // explicit name case std::wstring wname; - if(!Utf8toWStr(name,wname)) + if (!Utf8toWStr(name,wname)) return NULL; // converting string that we try to find to lower case - wstrToLower( wname ); + wstrToLower(wname); // Alternative first GameTele what contains wnameLow as substring in case no GameTele location found const GameTele* alt = NULL; - for(GameTeleMap::const_iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) - if(itr->second.wnameLow == wname) + for (GameTeleMap::const_iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) + if (itr->second.wnameLow == wname) return &itr->second; else if (alt == NULL && itr->second.wnameLow.find(wname) != std::wstring::npos) alt = &itr->second; @@ -8254,25 +8289,25 @@ bool ObjectMgr::AddGameTele(GameTele& tele) WorldDatabase.escape_string(safeName); return WorldDatabase.PExecuteLog("INSERT INTO game_tele " - "(id,position_x,position_y,position_z,orientation,map,name) " - "VALUES (%u,%f,%f,%f,%f,%u,'%s')", - new_id, tele.position_x, tele.position_y, tele.position_z, - tele.orientation, tele.mapId, safeName.c_str()); + "(id,position_x,position_y,position_z,orientation,map,name) " + "VALUES (%u,%f,%f,%f,%f,%u,'%s')", + new_id, tele.position_x, tele.position_y, tele.position_z, + tele.orientation, tele.mapId, safeName.c_str()); } bool ObjectMgr::DeleteGameTele(const std::string& name) { // explicit name case std::wstring wname; - if(!Utf8toWStr(name,wname)) + if (!Utf8toWStr(name,wname)) return false; // converting string that we try to find to lower case - wstrToLower( wname ); + wstrToLower(wname); - for(GameTeleMap::iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) + for (GameTeleMap::iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr) { - if(itr->second.wnameLow == wname) + if (itr->second.wnameLow == wname) { WorldDatabase.PExecuteLog("DELETE FROM game_tele WHERE name = '%s'",itr->second.name.c_str()); m_GameTeleMap.erase(itr); @@ -8288,7 +8323,7 @@ void ObjectMgr::LoadMailLevelRewards() m_mailLevelRewardMap.clear(); // for reload case uint32 count = 0; - QueryResult *result = WorldDatabase.Query("SELECT level, raceMask, mailTemplateId, senderEntry FROM mail_level_reward"); + QueryResult* result = WorldDatabase.Query("SELECT level, raceMask, mailTemplateId, senderEntry FROM mail_level_reward"); if (!result) { @@ -8307,32 +8342,32 @@ void ObjectMgr::LoadMailLevelRewards() { bar.step(); - Field *fields = result->Fetch(); + Field* fields = result->Fetch(); uint8 level = fields[0].GetUInt8(); uint32 raceMask = fields[1].GetUInt32(); uint32 mailTemplateId = fields[2].GetUInt32(); uint32 senderEntry = fields[3].GetUInt32(); - if(level > MAX_LEVEL) + if (level > MAX_LEVEL) { sLog.outErrorDb("Table `mail_level_reward` have data for level %u that more supported by client (%u), ignoring.",level,MAX_LEVEL); continue; } - if(!(raceMask & RACEMASK_ALL_PLAYABLE)) + if (!(raceMask & RACEMASK_ALL_PLAYABLE)) { sLog.outErrorDb("Table `mail_level_reward` have raceMask (%u) for level %u that not include any player races, ignoring.",raceMask,level); continue; } - if(!sMailTemplateStore.LookupEntry(mailTemplateId)) + if (!sMailTemplateStore.LookupEntry(mailTemplateId)) { sLog.outErrorDb("Table `mail_level_reward` have invalid mailTemplateId (%u) for level %u that invalid not include any player races, ignoring.",mailTemplateId,level); continue; } - if(!GetCreatureTemplate(senderEntry)) + if (!GetCreatureTemplate(senderEntry)) { sLog.outErrorDb("Table `mail_level_reward` have nonexistent sender creature entry (%u) for level %u that invalid not include any player races, ignoring.",senderEntry,level); continue; @@ -8346,7 +8381,7 @@ void ObjectMgr::LoadMailLevelRewards() delete result; sLog.outString(); - sLog.outString( ">> Loaded %u level dependent mail rewards,", count ); + sLog.outString(">> Loaded %u level dependent mail rewards,", count); } void ObjectMgr::LoadTrainers(char const* tableName, bool isTemplates) @@ -8360,7 +8395,7 @@ void ObjectMgr::LoadTrainers(char const* tableName, bool isTemplates) std::set skip_trainers; - QueryResult *result = WorldDatabase.PQuery("SELECT entry, spell,spellcost,reqskill,reqskillvalue,reqlevel FROM %s", tableName); + QueryResult* result = WorldDatabase.PQuery("SELECT entry, spell,spellcost,reqskill,reqskillvalue,reqlevel FROM %s", tableName); if (!result) { @@ -8387,7 +8422,7 @@ void ObjectMgr::LoadTrainers(char const* tableName, bool isTemplates) uint32 entry = fields[0].GetUInt32(); uint32 spell = fields[1].GetUInt32(); - SpellEntry const *spellinfo = sSpellStore.LookupEntry(spell); + SpellEntry const* spellinfo = sSpellStore.LookupEntry(spell); if (!spellinfo) { sLog.outErrorDb("Table `%s` (Entry: %u ) has non existing spell %u, ignore", tableName, entry, spell); @@ -8453,13 +8488,13 @@ void ObjectMgr::LoadTrainers(char const* tableName, bool isTemplates) // calculate learned spell for profession case when stored cast-spell trainerSpell.learnedSpell = spell; - for(int i = 0; i < MAX_EFFECT_INDEX; ++i) + for (int i = 0; i < MAX_EFFECT_INDEX; ++i) { if (spellinfo->Effect[i] == SPELL_EFFECT_LEARN_SPELL && - SpellMgr::IsProfessionOrRidingSpell(spellinfo->EffectTriggerSpell[i])) + SpellMgr::IsProfessionOrRidingSpell(spellinfo->EffectTriggerSpell[i])) { // prof spells sometime only additions to main spell learn that have level data - for(int j = 0; j < MAX_EFFECT_INDEX; ++j) + for (int j = 0; j < MAX_EFFECT_INDEX; ++j) { if (spellinfo->Effect[j] == SPELL_EFFECT_LEARN_SPELL) { @@ -8502,11 +8537,12 @@ void ObjectMgr::LoadTrainers(char const* tableName, bool isTemplates) ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %d trainer %sspells", count, isTemplates ? "template " : "" ); + sLog.outString(">> Loaded %d trainer %sspells", count, isTemplates ? "template " : ""); } void ObjectMgr::LoadTrainerTemplates() @@ -8516,10 +8552,10 @@ void ObjectMgr::LoadTrainerTemplates() // post loading check std::set trainer_ids; - for(CacheTrainerSpellMap::const_iterator tItr = m_mCacheTrainerTemplateSpellMap.begin(); tItr != m_mCacheTrainerTemplateSpellMap.end(); ++tItr) + for (CacheTrainerSpellMap::const_iterator tItr = m_mCacheTrainerTemplateSpellMap.begin(); tItr != m_mCacheTrainerTemplateSpellMap.end(); ++tItr) trainer_ids.insert(tItr->first); - for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) + for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) { if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) { @@ -8533,7 +8569,7 @@ void ObjectMgr::LoadTrainerTemplates() } } - for(std::set::const_iterator tItr = trainer_ids.begin(); tItr != trainer_ids.end(); ++tItr) + for (std::set::const_iterator tItr = trainer_ids.begin(); tItr != trainer_ids.end(); ++tItr) sLog.outErrorDb("Table `npc_trainer_template` has trainer template %u not used by any trainers ", *tItr); } @@ -8548,7 +8584,7 @@ void ObjectMgr::LoadVendors(char const* tableName, bool isTemplates) std::set skip_vendors; - QueryResult *result = WorldDatabase.PQuery("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM %s", tableName); + QueryResult* result = WorldDatabase.PQuery("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM %s", tableName); if (!result) { BarGoLink bar(1); @@ -8582,11 +8618,12 @@ void ObjectMgr::LoadVendors(char const* tableName, bool isTemplates) vList.AddItem(item_id, maxcount, incrtime, ExtendedCost); ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u vendor %sitems", count, isTemplates ? "template " : ""); + sLog.outString(">> Loaded %u vendor %sitems", count, isTemplates ? "template " : ""); } @@ -8597,10 +8634,10 @@ void ObjectMgr::LoadVendorTemplates() // post loading check std::set vendor_ids; - for(CacheVendorItemMap::const_iterator vItr = m_mCacheVendorTemplateItemMap.begin(); vItr != m_mCacheVendorTemplateItemMap.end(); ++vItr) + for (CacheVendorItemMap::const_iterator vItr = m_mCacheVendorTemplateItemMap.begin(); vItr != m_mCacheVendorTemplateItemMap.end(); ++vItr) vendor_ids.insert(vItr->first); - for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) + for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) { if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) { @@ -8614,7 +8651,7 @@ void ObjectMgr::LoadVendorTemplates() } } - for(std::set::const_iterator vItr = vendor_ids.begin(); vItr != vendor_ids.end(); ++vItr) + for (std::set::const_iterator vItr = vendor_ids.begin(); vItr != vendor_ids.end(); ++vItr) sLog.outErrorDb("Table `npc_vendor_template` has vendor template %u not used by any vendors ", *vItr); } @@ -8624,7 +8661,7 @@ void ObjectMgr::LoadNpcGossips() m_mCacheNpcTextIdMap.clear(); QueryResult* result = WorldDatabase.Query("SELECT npc_guid, textid FROM npc_gossip"); - if( !result ) + if (!result) { BarGoLink bar(1); @@ -8662,11 +8699,12 @@ void ObjectMgr::LoadNpcGossips() m_mCacheNpcTextIdMap[guid] = textid ; ++count; - } while (result->NextRow()); + } + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %d NpcTextId ", count ); + sLog.outString(">> Loaded %d NpcTextId ", count); } void ObjectMgr::LoadGossipMenu(std::set& gossipScriptSet) @@ -8674,8 +8712,8 @@ void ObjectMgr::LoadGossipMenu(std::set& gossipScriptSet) m_mGossipMenusMap.clear(); // 0 1 2 QueryResult* result = WorldDatabase.Query("SELECT entry, text_id, script_id, " - // 3 4 5 6 7 8 9 - "cond_1, cond_1_val_1, cond_1_val_2, cond_2, cond_2_val_1, cond_2_val_2, condition_id FROM gossip_menu"); + // 3 4 5 6 7 8 9 + "cond_1, cond_1_val_1, cond_1_val_2, cond_2, cond_2_val_1, cond_2_val_2, condition_id FROM gossip_menu"); if (!result) { @@ -8761,21 +8799,21 @@ void ObjectMgr::LoadGossipMenu(std::set& gossipScriptSet) ++count; } - while(result->NextRow()); + while (result->NextRow()); delete result; sLog.outString(); - sLog.outString( ">> Loaded %u gossip_menu entries", count); + sLog.outString(">> Loaded %u gossip_menu entries", count); // post loading tests - for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) + for (uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) if (CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) if (cInfo->GossipMenuId) if (m_mGossipMenusMap.find(cInfo->GossipMenuId) == m_mGossipMenusMap.end()) sLog.outErrorDb("Creature (Entry: %u) has gossip_menu_id = %u for nonexistent menu", cInfo->Entry, cInfo->GossipMenuId); - for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i) + for (uint32 i = 1; i < sGOStorage.MaxEntry; ++i) if (GameObjectInfo const* gInfo = sGOStorage.LookupEntry(i)) if (uint32 menuid = gInfo->GetGossipMenuId()) if (m_mGossipMenusMap.find(menuid) == m_mGossipMenusMap.end()) @@ -8786,13 +8824,13 @@ void ObjectMgr::LoadGossipMenuItems(std::set& gossipScriptSet) { m_mGossipMenuItemsMap.clear(); - QueryResult *result = WorldDatabase.Query( - "SELECT menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, " - "action_menu_id, action_poi_id, action_script_id, box_coded, box_money, box_text, " - "cond_1, cond_1_val_1, cond_1_val_2, " - "cond_2, cond_2_val_1, cond_2_val_2, " - "cond_3, cond_3_val_1, cond_3_val_2, condition_id " - "FROM gossip_menu_option"); + QueryResult* result = WorldDatabase.Query( + "SELECT menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, " + "action_menu_id, action_poi_id, action_script_id, box_coded, box_money, box_text, " + "cond_1, cond_1_val_1, cond_1_val_2, " + "cond_2, cond_2_val_1, cond_2_val_2, " + "cond_3, cond_3_val_1, cond_3_val_2, condition_id " + "FROM gossip_menu_option"); if (!result) { @@ -8973,13 +9011,13 @@ void ObjectMgr::LoadGossipMenuItems(std::set& gossipScriptSet) ++count; } - while(result->NextRow()); + while (result->NextRow()); delete result; if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK)) { - for(std::set::const_iterator itr = menu_ids.begin(); itr != menu_ids.end(); ++itr) + for (std::set::const_iterator itr = menu_ids.begin(); itr != menu_ids.end(); ++itr) sLog.outErrorDb("Table `gossip_menu` contain unused (in creature or GO or menu options) menu id %u.", *itr); } @@ -8995,16 +9033,16 @@ void ObjectMgr::LoadGossipMenus() gossipScriptSet.insert(itr->first); // Load gossip_menu and gossip_menu_option data - sLog.outString( "(Re)Loading Gossip menus..." ); + sLog.outString("(Re)Loading Gossip menus..."); LoadGossipMenu(gossipScriptSet); - sLog.outString( "(Re)Loading Gossip menu options..." ); + sLog.outString("(Re)Loading Gossip menu options..."); LoadGossipMenuItems(gossipScriptSet); for (std::set::const_iterator itr = gossipScriptSet.begin(); itr != gossipScriptSet.end(); ++itr) sLog.outErrorDb("Table `gossip_scripts` contains unused script, id %u.", *itr); } -void ObjectMgr::AddVendorItem( uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 extendedcost ) +void ObjectMgr::AddVendorItem(uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 extendedcost) { VendorItemData& vList = m_mCacheVendorItemMap[entry]; vList.AddItem(item,maxcount,incrtime,extendedcost); @@ -9012,20 +9050,20 @@ void ObjectMgr::AddVendorItem( uint32 entry,uint32 item, uint32 maxcount, uint32 WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')",entry, item, maxcount,incrtime,extendedcost); } -bool ObjectMgr::RemoveVendorItem( uint32 entry,uint32 item ) +bool ObjectMgr::RemoveVendorItem(uint32 entry,uint32 item) { CacheVendorItemMap::iterator iter = m_mCacheVendorItemMap.find(entry); - if(iter == m_mCacheVendorItemMap.end()) + if (iter == m_mCacheVendorItemMap.end()) return false; - if(!iter->second.RemoveItem(item)) + if (!iter->second.RemoveItem(item)) return false; WorldDatabase.PExecuteLog("DELETE FROM npc_vendor WHERE entry='%u' AND item='%u'",entry, item); return true; } -bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 vendor_entry, uint32 item_id, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl, std::set* skip_vendors ) const +bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 vendor_entry, uint32 item_id, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl, std::set* skip_vendors) const { char const* idStr = isTemplate ? "vendor template" : "vendor"; CreatureInfo const* cInfo = NULL; @@ -9035,7 +9073,7 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 cInfo = GetCreatureTemplate(vendor_entry); if (!cInfo) { - if(pl) + if (pl) ChatHandler(pl).SendSysMessage(LANG_COMMAND_VENDORSELECTION); else sLog.outErrorDb("Table `%s` has data for nonexistent creature (Entry: %u), ignoring", tableName, vendor_entry); @@ -9064,7 +9102,7 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 ChatHandler(pl).PSendSysMessage(LANG_ITEM_NOT_FOUND, item_id); else sLog.outErrorDb("Table `%s` for %s %u contain nonexistent item (%u), ignoring", - tableName, idStr, vendor_entry, item_id); + tableName, idStr, vendor_entry, item_id); return false; } @@ -9074,7 +9112,7 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 ChatHandler(pl).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST,ExtendedCost); else sLog.outErrorDb("Table `%s` contain item (Entry: %u) with wrong ExtendedCost (%u) for %s %u, ignoring", - tableName, item_id, ExtendedCost, idStr, vendor_entry); + tableName, item_id, ExtendedCost, idStr, vendor_entry); return false; } @@ -9083,8 +9121,8 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 if (pl) ChatHandler(pl).PSendSysMessage("MaxCount!=0 (%u) but IncrTime==0", maxcount); else - sLog.outErrorDb( "Table `%s` has `maxcount` (%u) for item %u of %s %u but `incrtime`=0, ignoring", - tableName, maxcount, item_id, idStr, vendor_entry); + sLog.outErrorDb("Table `%s` has `maxcount` (%u) for item %u of %s %u but `incrtime`=0, ignoring", + tableName, maxcount, item_id, idStr, vendor_entry); return false; } else if (maxcount==0 && incrtime > 0) @@ -9092,8 +9130,8 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 if (pl) ChatHandler(pl).PSendSysMessage("MaxCount==0 but IncrTime<>=0"); else - sLog.outErrorDb( "Table `%s` has `maxcount`=0 for item %u of %s %u but `incrtime`<>0, ignoring", - tableName, item_id, idStr, vendor_entry); + sLog.outErrorDb("Table `%s` has `maxcount`=0 for item %u of %s %u but `incrtime`<>0, ignoring", + tableName, item_id, idStr, vendor_entry); return false; } @@ -9108,8 +9146,8 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 if (pl) ChatHandler(pl).PSendSysMessage(LANG_ITEM_ALREADY_IN_LIST, item_id, ExtendedCost); else - sLog.outErrorDb( "Table `%s` has duplicate items %u (with extended cost %u) for %s %u, ignoring", - tableName, item_id, ExtendedCost, idStr, vendor_entry); + sLog.outErrorDb("Table `%s` has duplicate items %u (with extended cost %u) for %s %u, ignoring", + tableName, item_id, ExtendedCost, idStr, vendor_entry); return false; } @@ -9122,11 +9160,11 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 else { if (!cInfo->vendorId) - sLog.outErrorDb( "Table `%s` has duplicate items %u (with extended cost %u) for %s %u, ignoring", - tableName, item_id, ExtendedCost, idStr, vendor_entry); + sLog.outErrorDb("Table `%s` has duplicate items %u (with extended cost %u) for %s %u, ignoring", + tableName, item_id, ExtendedCost, idStr, vendor_entry); else - sLog.outErrorDb( "Table `%s` has duplicate items %u (with extended cost %u) for %s %u (or possible in vendor template %u), ignoring", - tableName, item_id, ExtendedCost, idStr, vendor_entry, cInfo->vendorId); + sLog.outErrorDb("Table `%s` has duplicate items %u (with extended cost %u) for %s %u (or possible in vendor template %u), ignoring", + tableName, item_id, ExtendedCost, idStr, vendor_entry, cInfo->vendorId); } return false; } @@ -9140,30 +9178,30 @@ bool ObjectMgr::IsVendorItemValid(bool isTemplate, char const* tableName, uint32 if (pl) ChatHandler(pl).SendSysMessage(LANG_COMMAND_ADDVENDORITEMITEMS); else - sLog.outErrorDb( "Table `%s` has too many items (%u >= %i) for %s %u, ignoring", - tableName, countItems, MAX_VENDOR_ITEMS, idStr, vendor_entry); + sLog.outErrorDb("Table `%s` has too many items (%u >= %i) for %s %u, ignoring", + tableName, countItems, MAX_VENDOR_ITEMS, idStr, vendor_entry); return false; } return true; } -void ObjectMgr::AddGroup( Group* group ) +void ObjectMgr::AddGroup(Group* group) { mGroupMap[group->GetId()] = group ; } -void ObjectMgr::RemoveGroup( Group* group ) +void ObjectMgr::RemoveGroup(Group* group) { mGroupMap.erase(group->GetId()); } -void ObjectMgr::AddArenaTeam( ArenaTeam* arenaTeam ) +void ObjectMgr::AddArenaTeam(ArenaTeam* arenaTeam) { mArenaTeamMap[arenaTeam->GetId()] = arenaTeam; } -void ObjectMgr::RemoveArenaTeam( uint32 Id ) +void ObjectMgr::RemoveArenaTeam(uint32 Id) { mArenaTeamMap.erase(Id); } @@ -9173,7 +9211,7 @@ void ObjectMgr::GetCreatureLocaleStrings(uint32 entry, int32 loc_idx, char const { if (loc_idx >= 0) { - if (CreatureLocale const *il = GetCreatureLocale(entry)) + if (CreatureLocale const* il = GetCreatureLocale(entry)) { if (namePtr && il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) *namePtr = il->Name[loc_idx].c_str(); @@ -9188,7 +9226,7 @@ void ObjectMgr::GetItemLocaleStrings(uint32 entry, int32 loc_idx, std::string* n { if (loc_idx >= 0) { - if(ItemLocale const *il = GetItemLocale(entry)) + if (ItemLocale const* il = GetItemLocale(entry)) { if (namePtr && il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty()) *namePtr = il->Name[loc_idx]; @@ -9203,7 +9241,7 @@ void ObjectMgr::GetQuestLocaleStrings(uint32 entry, int32 loc_idx, std::string* { if (loc_idx >= 0) { - if(QuestLocale const *il = GetQuestLocale(entry)) + if (QuestLocale const* il = GetQuestLocale(entry)) { if (titlePtr && il->Title.size() > size_t(loc_idx) && !il->Title[loc_idx].empty()) *titlePtr = il->Title[loc_idx]; @@ -9215,7 +9253,7 @@ void ObjectMgr::GetNpcTextLocaleStringsAll(uint32 entry, int32 loc_idx, ObjectMg { if (loc_idx >= 0) { - if (NpcTextLocale const *nl = GetNpcTextLocale(entry)) + if (NpcTextLocale const* nl = GetNpcTextLocale(entry)) { if (text0_Ptr) for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) @@ -9234,7 +9272,7 @@ void ObjectMgr::GetNpcTextLocaleStrings0(uint32 entry, int32 loc_idx, std::strin { if (loc_idx >= 0) { - if (NpcTextLocale const *nl = GetNpcTextLocale(entry)) + if (NpcTextLocale const* nl = GetNpcTextLocale(entry)) { if (text0_0_Ptr) if (nl->Text_0[0].size() > (size_t)loc_idx && !nl->Text_0[0][loc_idx].empty()) @@ -9271,7 +9309,7 @@ Quest const* GetQuestTemplateStore(uint32 entry) return sObjectMgr.GetQuestTemplate(entry); } -bool FindCreatureData::operator()( CreatureDataPair const& dataPair ) +bool FindCreatureData::operator()(CreatureDataPair const& dataPair) { // skip wrong entry ids if (i_id && dataPair.second.id != i_id) @@ -9321,7 +9359,7 @@ CreatureDataPair const* FindCreatureData::GetResult() const return i_anyData; } -bool FindGOData::operator()( GameObjectDataPair const& dataPair ) +bool FindGOData::operator()(GameObjectDataPair const& dataPair) { // skip wrong entry ids if (i_id && dataPair.second.id != i_id) diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index f44e7ca10..697603577 100755 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -123,7 +123,7 @@ class FindCreatureData 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) {} - bool operator() (CreatureDataPair const& dataPair); + bool operator()(CreatureDataPair const& dataPair); CreatureDataPair const* GetResult() const; private: @@ -146,7 +146,7 @@ class FindGOData 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) {} - bool operator() (GameObjectDataPair const& dataPair); + bool operator()(GameObjectDataPair const& dataPair); GameObjectDataPair const* GetResult() const; private: @@ -180,7 +180,7 @@ typedef std::pair GraveYardMap; typedef std::pair GraveYardMapBounds; 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_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 @@ -370,12 +371,12 @@ enum ConditionType 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_LEARNABLE_ABILITY = 28, // spell_id 0 or item_id - // 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. - // When player has spell or has item (when defined), condition return false. + // 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. + // When player has spell or has item (when defined), condition return false. 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) - // If skill_value == 1, then true if player has not skill skill_id + // 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 CONDITION_REPUTATION_RANK_MAX = 30, // faction_id max_rank }; @@ -422,7 +423,7 @@ enum SkillRangeType 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_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 { - friend class PlayerDumpReader; + friend class PlayerDumpReader; public: ObjectMgr(); @@ -488,7 +489,7 @@ class ObjectMgr typedef UNORDERED_MAP WeatherZoneMap; void LoadGameobjectInfo(); - void AddGameobjectInfo(GameObjectInfo *goinfo); + void AddGameobjectInfo(GameObjectInfo* goinfo); void PackGroupIds(); Group* GetGroupById(uint32 id) const; @@ -510,30 +511,30 @@ class ObjectMgr PlayerClassInfo const* GetPlayerClassInfo(uint32 class_) const { - if(class_ >= MAX_CLASSES) return NULL; + if (class_ >= MAX_CLASSES) return NULL; return &playerClassInfo[class_]; } void GetPlayerClassLevelInfo(uint32 class_,uint32 level, PlayerClassLevelInfo* info) const; PlayerInfo const* GetPlayerInfo(uint32 race, uint32 class_) const { - if(race >= MAX_RACES) return NULL; - if(class_ >= MAX_CLASSES) return NULL; + if (race >= MAX_RACES) return NULL; + if (class_ >= MAX_CLASSES) return NULL; 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; } void GetPlayerLevelInfo(uint32 race, uint32 class_,uint32 level, PlayerLevelInfo* info) 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; uint32 GetPlayerAccountIdByGUID(ObjectGuid guid) const; uint32 GetPlayerAccountIdByPlayerName(const std::string& name) const; - uint32 GetNearestTaxiNode( float x, float y, float z, uint32 mapid, Team team ); - void GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost); - uint32 GetTaxiMountDisplayId( uint32 id, Team team, bool allowed_alt_team = false); + uint32 GetNearestTaxiNode(float x, float y, float z, uint32 mapid, Team team); + void GetTaxiPath(uint32 source, uint32 destination, uint32& path, uint32& cost); + uint32 GetTaxiMountDisplayId(uint32 id, Team team, bool allowed_alt_team = false); Quest const* GetQuestTemplate(uint32 quest_id) const { @@ -545,7 +546,7 @@ class ObjectMgr uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const { QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID); - if(itr != mQuestAreaTriggerMap.end()) + if (itr != mQuestAreaTriggerMap.end()) return itr->second; return 0; } @@ -569,8 +570,8 @@ class ObjectMgr AreaTrigger const* GetAreaTrigger(uint32 trigger) const { - AreaTriggerMap::const_iterator itr = mAreaTriggers.find( trigger ); - if( itr != mAreaTriggers.end( ) ) + AreaTriggerMap::const_iterator itr = mAreaTriggers.find(trigger); + if (itr != mAreaTriggers.end()) return &itr->second; return NULL; } @@ -590,7 +591,7 @@ class ObjectMgr ReputationOnKillEntry const* GetReputationOnKillEntry(uint32 id) const { RepOnKillMap::const_iterator itr = mRepOnKill.find(id); - if(itr != mRepOnKill.end()) + if (itr != mRepOnKill.end()) return &itr->second; return NULL; } @@ -607,7 +608,7 @@ class ObjectMgr PointOfInterest const* GetPointOfInterest(uint32 id) const { PointOfInterestMap::const_iterator itr = mPointsOfInterest.find(id); - if(itr != mPointsOfInterest.end()) + if (itr != mPointsOfInterest.end()) return &itr->second; return NULL; } @@ -615,7 +616,7 @@ class ObjectMgr QuestPOIVector const* GetQuestPOIVector(uint32 questId) { QuestPOIMap::const_iterator itr = mQuestPOIMap.find(questId); - if(itr != mQuestPOIMap.end()) + if (itr != mQuestPOIMap.end()) return &itr->second; return NULL; } @@ -759,7 +760,7 @@ class ObjectMgr if (map_itr == m_mailLevelRewardMap.end()) 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) return &*set_itr; @@ -769,7 +770,7 @@ class ObjectMgr WeatherZoneChances const* GetWeatherChances(uint32 zone_id) const { WeatherZoneMap::const_iterator itr = mWeatherZoneMap.find(zone_id); - if(itr != mWeatherZoneMap.end()) + if (itr != mWeatherZoneMap.end()) return &itr->second; else return NULL; @@ -778,7 +779,7 @@ class ObjectMgr CreatureDataPair const* GetCreatureDataPair(uint32 guid) const { CreatureDataMap::const_iterator itr = mCreatureDataMap.find(guid); - if(itr==mCreatureDataMap.end()) return NULL; + if (itr==mCreatureDataMap.end()) return NULL; return &*itr; } @@ -802,7 +803,7 @@ class ObjectMgr CreatureLocale const* GetCreatureLocale(uint32 entry) const { CreatureLocaleMap::const_iterator itr = mCreatureLocaleMap.find(entry); - if(itr==mCreatureLocaleMap.end()) return NULL; + if (itr==mCreatureLocaleMap.end()) return NULL; return &itr->second; } @@ -811,14 +812,14 @@ class ObjectMgr GameObjectLocale const* GetGameObjectLocale(uint32 entry) const { GameObjectLocaleMap::const_iterator itr = mGameObjectLocaleMap.find(entry); - if(itr==mGameObjectLocaleMap.end()) return NULL; + if (itr==mGameObjectLocaleMap.end()) return NULL; return &itr->second; } ItemLocale const* GetItemLocale(uint32 entry) const { ItemLocaleMap::const_iterator itr = mItemLocaleMap.find(entry); - if(itr==mItemLocaleMap.end()) return NULL; + if (itr==mItemLocaleMap.end()) return NULL; return &itr->second; } @@ -827,7 +828,7 @@ class ObjectMgr QuestLocale const* GetQuestLocale(uint32 entry) const { QuestLocaleMap::const_iterator itr = mQuestLocaleMap.find(entry); - if(itr==mQuestLocaleMap.end()) return NULL; + if (itr==mQuestLocaleMap.end()) return NULL; return &itr->second; } @@ -836,39 +837,39 @@ class ObjectMgr NpcTextLocale const* GetNpcTextLocale(uint32 entry) const { NpcTextLocaleMap::const_iterator itr = mNpcTextLocaleMap.find(entry); - if(itr==mNpcTextLocaleMap.end()) return NULL; + if (itr==mNpcTextLocaleMap.end()) return NULL; return &itr->second; } 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; PageTextLocale const* GetPageTextLocale(uint32 entry) const { PageTextLocaleMap::const_iterator itr = mPageTextLocaleMap.find(entry); - if(itr==mPageTextLocaleMap.end()) return NULL; + if (itr==mPageTextLocaleMap.end()) return NULL; return &itr->second; } GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const { GossipMenuItemsLocaleMap::const_iterator itr = mGossipMenuItemsLocaleMap.find(entry); - if(itr==mGossipMenuItemsLocaleMap.end()) return NULL; + if (itr==mGossipMenuItemsLocaleMap.end()) return NULL; return &itr->second; } PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const { PointOfInterestLocaleMap::const_iterator itr = mPointOfInterestLocaleMap.find(poi_id); - if(itr==mPointOfInterestLocaleMap.end()) return NULL; + if (itr==mPointOfInterestLocaleMap.end()) return NULL; return &itr->second; } GameObjectDataPair const* GetGODataPair(uint32 guid) const { GameObjectDataMap::const_iterator itr = mGameObjectDataMap.find(guid); - if(itr==mGameObjectDataMap.end()) return NULL; + if (itr==mGameObjectDataMap.end()) return NULL; return &*itr; } @@ -892,12 +893,12 @@ class ObjectMgr MangosStringLocale const* GetMangosStringLocale(int32 entry) const { MangosStringLocaleMap::const_iterator itr = mMangosStringLocaleMap.find(entry); - if(itr==mMangosStringLocaleMap.end()) return NULL; + if (itr==mMangosStringLocaleMap.end()) return NULL; return &itr->second; } - const char *GetMangosString(int32 entry, int locale_idx) const; - const char *GetMangosStringForDBCLocale(int32 entry) const { return GetMangosString(entry,DBCLocaleIndex); } + const char* GetMangosString(int32 entry, int locale_idx) const; + const char* GetMangosStringForDBCLocale(int32 entry) const { return GetMangosString(entry,DBCLocaleIndex); } int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; } void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); } @@ -921,9 +922,9 @@ class ObjectMgr bool IsReservedName(const std::string& name) const; // name with valid structure and symbols - static uint8 CheckPlayerName( const std::string& name, bool create = false ); - static PetNameInvalidReason CheckPetName( const std::string& name ); - static bool IsValidCharterName( const std::string& name ); + static uint8 CheckPlayerName(const std::string& name, bool create = false); + static PetNameInvalidReason CheckPetName(const std::string& name); + static bool IsValidCharterName(const std::string& name); static bool CheckDeclinedNames(std::wstring mainpart, DeclinedName const& names); @@ -934,7 +935,7 @@ class ObjectMgr uint16 GetConditionId(ConditionType condition, uint32 value1, uint32 value2); bool IsPlayerMeetToCondition(Player const* player, uint16 condition_id) const { - if(condition_id >= mConditions.size()) + if (condition_id >= mConditions.size()) return false; return mConditions[condition_id].Meets(player); @@ -946,7 +947,7 @@ class ObjectMgr GameTele const* GetGameTele(uint32 id) const { 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; } @@ -958,7 +959,7 @@ class ObjectMgr uint32 GetNpcGossip(uint32 entry) const { CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry); - if(iter == m_mCacheNpcTextIdMap.end()) + if (iter == m_mCacheNpcTextIdMap.end()) return 0; return iter->second; @@ -967,7 +968,7 @@ class ObjectMgr TrainerSpellData const* GetNpcTrainerSpells(uint32 entry) const { CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry); - if(iter == m_mCacheTrainerSpellMap.end()) + if (iter == m_mCacheTrainerSpellMap.end()) return NULL; return &iter->second; @@ -976,7 +977,7 @@ class ObjectMgr TrainerSpellData const* GetNpcTrainerTemplateSpells(uint32 entry) const { CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerTemplateSpellMap.find(entry); - if(iter == m_mCacheTrainerTemplateSpellMap.end()) + if (iter == m_mCacheTrainerTemplateSpellMap.end()) return NULL; return &iter->second; @@ -985,7 +986,7 @@ class ObjectMgr VendorItemData const* GetNpcVendorItemList(uint32 entry) const { CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry); - if(iter == m_mCacheVendorItemMap.end()) + if (iter == m_mCacheVendorItemMap.end()) return NULL; return &iter->second; @@ -994,7 +995,7 @@ class ObjectMgr VendorItemData const* GetNpcVendorTemplateItemList(uint32 entry) const { CacheVendorItemMap::const_iterator iter = m_mCacheVendorTemplateItemMap.find(entry); - if(iter == m_mCacheVendorTemplateItemMap.end()) + if (iter == m_mCacheVendorTemplateItemMap.end()) return NULL; return &iter->second; diff --git a/src/game/ObjectPosSelector.cpp b/src/game/ObjectPosSelector.cpp index 3c54aee4e..7c85fa05e 100644 --- a/src/game/ObjectPosSelector.cpp +++ b/src/game/ObjectPosSelector.cpp @@ -103,7 +103,7 @@ bool ObjectPosSelector::CheckOriginalAngle() const { // 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)) && - (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) { // loop until both side fail and leave 0..PI - for(;;) + for (;;) { // ++ direction less updated 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 * */ -bool ObjectPosSelector::NextSideAngle(UsedAreaSide side, float &angle ) +bool ObjectPosSelector::NextSideAngle(UsedAreaSide side, float& angle) { // next possible angle m_stepAngle[side] += (m_searcherHalfSize + 0.01); @@ -254,13 +254,13 @@ bool ObjectPosSelector::NextSideAngle(UsedAreaSide side, float &angle ) bool ObjectPosSelector::NextUsedAngle(float& angle) { 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; // ++ direction less updated 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_PLUS]->first <= m_nextUsedAreaItr[USED_POS_MINUS]->first)) + (m_nextUsedAreaItr[USED_POS_MINUS] == m_UsedAreaLists[USED_POS_MINUS].end() || + m_nextUsedAreaItr[USED_POS_PLUS]->first <= m_nextUsedAreaItr[USED_POS_MINUS]->first)) { angle = m_nextUsedAreaItr[USED_POS_PLUS]->first * SignOf(USED_POS_PLUS); ++m_nextUsedAreaItr[USED_POS_PLUS];