diff --git a/zone/aggro.cpp b/zone/aggro.cpp index cc537662a..bf74f4b4d 100644 --- a/zone/aggro.cpp +++ b/zone/aggro.cpp @@ -550,8 +550,8 @@ faster, but I'm doing it this way to make it readable and easy to modify bool Mob::IsAttackAllowed(Mob *target, bool isSpellAttack) { - Mob *mob1, *mob2, *tempmob; - Client *c1, *c2, *becomenpc; + Mob *mob1 = nullptr, *mob2 = nullptr, *tempmob = nullptr; + Client *c1 = nullptr, *c2 = nullptr, *becomenpc = nullptr; // NPC *npc1, *npc2; int reverse; @@ -767,8 +767,8 @@ type', in which case, the answer is yes. // also goes for their pets bool Mob::IsBeneficialAllowed(Mob *target) { - Mob *mob1, *mob2, *tempmob; - Client *c1, *c2; + Mob *mob1 = nullptr, *mob2 = nullptr, *tempmob = nullptr; + Client *c1 = nullptr, *c2 = nullptr; int reverse; if(!target) diff --git a/zone/attack.cpp b/zone/attack.cpp index b0c056b30..5cd5aebae 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -1268,7 +1268,7 @@ bool Client::Attack(Mob* other, int Hand, bool bRiposte, bool IsStrikethrough, b if (GetFeigned()) return false; // Rogean: How can you attack while feigned? Moved up from Aggro Code. - EQEmu::ItemInstance* weapon; + EQEmu::ItemInstance* weapon = nullptr; if (Hand == EQEmu::inventory::slotSecondary){ // Kaiyodo - Pick weapon from the attacking hand weapon = GetInv().GetItem(EQEmu::inventory::slotSecondary); OffHandAtk(true); diff --git a/zone/bot.cpp b/zone/bot.cpp index 6ce4210b3..00bb96bfc 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1896,12 +1896,12 @@ void Bot::BotRangedAttack(Mob* other) { } EQEmu::ItemInstance* rangedItem = GetBotItem(EQEmu::inventory::slotRange); - const EQEmu::ItemData* RangeWeapon = 0; + const EQEmu::ItemData* RangeWeapon = nullptr; if(rangedItem) RangeWeapon = rangedItem->GetItem(); EQEmu::ItemInstance* ammoItem = GetBotItem(EQEmu::inventory::slotAmmo); - const EQEmu::ItemData* Ammo = 0; + const EQEmu::ItemData* Ammo = nullptr; if(ammoItem) Ammo = ammoItem->GetItem(); @@ -2008,7 +2008,7 @@ void Bot::ApplySpecialAttackMod(EQEmu::skills::SkillType skill, int32 &dmg, int3 if (item_slot >= EQEmu::legacy::EQUIPMENT_BEGIN){ const EQEmu::ItemInstance* inst = GetBotItem(item_slot); - const EQEmu::ItemData* botweapon = 0; + const EQEmu::ItemData* botweapon = nullptr; if(inst) botweapon = inst->GetItem(); @@ -2456,7 +2456,7 @@ void Bot::AI_Process() { //now off hand if(GetTarget() && attack_dw_timer.Check() && CanThisClassDualWield()) { const EQEmu::ItemInstance* instweapon = GetBotItem(EQEmu::inventory::slotSecondary); - const EQEmu::ItemData* weapon = 0; + const EQEmu::ItemData* weapon = nullptr; //can only dual wield without a weapon if you're a monk if(instweapon || (botClass == MONK)) { if(instweapon) @@ -2928,8 +2928,8 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { ns->spawn.light = m_Light.Type[EQEmu::lightsource::LightActive]; ns->spawn.helm = helmtexture; //(GetShowHelm() ? helmtexture : 0); //0xFF; ns->spawn.equip_chest2 = texture; //0xFF; - const EQEmu::ItemData* item = 0; - const EQEmu::ItemInstance* inst = 0; + const EQEmu::ItemData* item = nullptr; + const EQEmu::ItemInstance* inst = nullptr; uint32 spawnedbotid = 0; spawnedbotid = this->GetBotID(); for (int i = EQEmu::textures::textureBegin; i < EQEmu::textures::weaponPrimary; i++) { @@ -4357,9 +4357,9 @@ int32 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) { //Check if item focus effect exists for the client. if (itembonuses.FocusEffects[bottype]) { - const EQEmu::ItemData* TempItem = 0; - const EQEmu::ItemData* UsedItem = 0; - const EQEmu::ItemInstance* TempInst = 0; + const EQEmu::ItemData* TempItem = nullptr; + const EQEmu::ItemData* UsedItem = nullptr; + const EQEmu::ItemInstance* TempInst = nullptr; uint16 UsedFocusID = 0; int32 Total = 0; int32 focus_max = 0; @@ -5031,7 +5031,7 @@ void Bot::DoSpecialAttackDamage(Mob *who, EQEmu::skills::SkillType skill, int32 if (skill == EQEmu::skills::SkillBash) { const EQEmu::ItemInstance* inst = GetBotItem(EQEmu::inventory::slotSecondary); - const EQEmu::ItemData* botweapon = 0; + const EQEmu::ItemData* botweapon = nullptr; if(inst) botweapon = inst->GetItem(); @@ -5372,7 +5372,7 @@ FACTION_VALUE Bot::GetReverseFactionCon(Mob* iOther) { } Mob* Bot::GetOwnerOrSelf() { - Mob* Result = 0; + Mob* Result = nullptr; if(this->GetBotOwner()) Result = GetBotOwner(); else @@ -5382,7 +5382,7 @@ Mob* Bot::GetOwnerOrSelf() { } Mob* Bot::GetOwner() { - Mob* Result = 0; + Mob* Result = nullptr; Result = GetBotOwner(); if(!Result) this->SetBotOwner(0); @@ -5438,8 +5438,8 @@ bool Bot::IsBotAttackAllowed(Mob* attacker, Mob* target, bool& hasRuleDefined) { void Bot::EquipBot(std::string* errorMessage) { GetBotItems(m_inv, errorMessage); - const EQEmu::ItemInstance* inst = 0; - const EQEmu::ItemData* item = 0; + const EQEmu::ItemInstance* inst = nullptr; + const EQEmu::ItemData* item = nullptr; for (int i = EQEmu::legacy::EQUIPMENT_BEGIN; i <= EQEmu::legacy::EQUIPMENT_END; ++i) { inst = GetBotItem(i); if(inst) { @@ -7235,7 +7235,7 @@ bool Bot::CanHeal() { } Bot* Bot::GetBotByBotClientOwnerAndBotName(Client* c, std::string botName) { - Bot* Result = 0; + Bot* Result = nullptr; if(c) { std::list BotList = entity_list.GetBotsByBotOwnerCharacterID(c->CharacterID()); if(!BotList.empty()) { @@ -7275,7 +7275,7 @@ void Bot::ProcessBotGroupInvite(Client* c, std::string botName) { // Processes a group disband request from a Client for a Bot. void Bot::ProcessBotGroupDisband(Client* c, std::string botName) { if(c) { - Bot* tempBot = 0; + Bot* tempBot = nullptr; if(botName.empty()) tempBot = GetFirstBotInGroup(c->GetGroup()); @@ -7318,7 +7318,7 @@ void Bot::ProcessClientZoneChange(Client* botOwner) { // Finds and returns the first Bot object found in specified group Bot* Bot::GetFirstBotInGroup(Group* group) { - Bot* Result = 0; + Bot* Result = nullptr; if(group) { for(int Counter = 0; Counter < MAX_GROUP_MEMBERS; Counter++) { @@ -7344,8 +7344,8 @@ void Bot::ProcessBotInspectionRequest(Bot* inspectedBot, Client* client) { insr->TargetID = inspectedBot->GetNPCTypeID(); insr->playerid = inspectedBot->GetID(); - const EQEmu::ItemData* item = 0; - const EQEmu::ItemInstance* inst = 0; + const EQEmu::ItemData* item = nullptr; + const EQEmu::ItemInstance* inst = nullptr; // Modded to display power source items (will only show up on SoF+ client inspect windows though.) // I don't think bots are currently coded to use them..but, you'll have to use '#bot inventory list' @@ -7396,7 +7396,7 @@ void Bot::ProcessBotInspectionRequest(Bot* inspectedBot, Client* client) { void Bot::CalcItemBonuses(StatBonuses* newbon) { - const EQEmu::ItemData* itemtmp = 0; + const EQEmu::ItemData* itemtmp = nullptr; for (int i = EQEmu::legacy::EQUIPMENT_BEGIN; i <= (EQEmu::legacy::EQUIPMENT_END + 1); ++i) { const EQEmu::ItemInstance* item = GetBotItem((i == 22 ? 9999 : i)); @@ -7989,7 +7989,7 @@ bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, fl Mob* EntityList::GetMobByBotID(uint32 botID) { - Mob* Result = 0; + Mob* Result = nullptr; if(botID > 0) { auto it = mob_list.begin(); for (auto it = mob_list.begin(); it != mob_list.end(); ++it) { @@ -8006,7 +8006,7 @@ Mob* EntityList::GetMobByBotID(uint32 botID) { } Bot* EntityList::GetBotByBotID(uint32 botID) { - Bot* Result = 0; + Bot* Result = nullptr; if(botID > 0) { for(std::list::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); ++botListItr) { Bot* tempBot = *botListItr; @@ -8020,7 +8020,7 @@ Bot* EntityList::GetBotByBotID(uint32 botID) { } Bot* EntityList::GetBotByBotName(std::string botName) { - Bot* Result = 0; + Bot* Result = nullptr; if(!botName.empty()) { for(std::list::iterator botListItr = bot_list.begin(); botListItr != bot_list.end(); ++botListItr) { Bot* tempBot = *botListItr; @@ -8197,7 +8197,7 @@ void EntityList::ShowSpawnWindow(Client* client, int Distance, bool NamedOnly) { uint8 Bot::GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets) { uint8 needHealed = 0; - Group *g; + Group *g = nullptr; if(this->HasGroup()) { g = this->GetGroup(); if(g) { @@ -8237,8 +8237,8 @@ int Bot::GetRawACNoShield(int &shield_ac) { } uint32 Bot::CalcCurrentWeight() { - const EQEmu::ItemData* TempItem = 0; - EQEmu::ItemInstance* inst; + const EQEmu::ItemData* TempItem = nullptr; + EQEmu::ItemInstance* inst = nullptr; uint32 Total = 0; for (int i = EQEmu::legacy::EQUIPMENT_BEGIN; i <= EQEmu::legacy::EQUIPMENT_END; ++i) { inst = GetBotItem(i); diff --git a/zone/client.cpp b/zone/client.cpp index 23a7213a3..fa683a267 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -717,7 +717,7 @@ bool Client::AddPacket(EQApplicationPacket** pApp, bool bAckreq) { c->ack_req = bAckreq; c->app = *pApp; - *pApp = 0; + *pApp = nullptr; clientpackets.Append(c); return true; @@ -726,7 +726,7 @@ bool Client::AddPacket(EQApplicationPacket** pApp, bool bAckreq) { bool Client::SendAllPackets() { LinkedListIterator iterator(clientpackets); - CLIENTPACKET* cp = 0; + CLIENTPACKET* cp = nullptr; iterator.Reset(); while(iterator.MoreElements()) { cp = iterator.GetData(); @@ -772,7 +772,7 @@ void Client::FastQueuePacket(EQApplicationPacket** app, bool ack_req, CLIENT_CON eqs->FastQueuePacket((EQApplicationPacket **)app, ack_req); else if (app && (*app)) delete *app; - *app = 0; + *app = nullptr; } return; } @@ -2038,7 +2038,7 @@ void Client::ReadBook(BookRequest_Struct *book) { read_from_slot = book->invslot -1; } - const EQEmu::ItemInstance *inst = 0; + const EQEmu::ItemInstance *inst = nullptr; if (read_from_slot <= EQEmu::legacy::SLOT_PERSONAL_BAGS_END) { @@ -4046,7 +4046,7 @@ bool Client::KeyRingCheck(uint32 item_id) void Client::KeyRingList() { Message(4,"Keys on Keyring:"); - const EQEmu::ItemData *item = 0; + const EQEmu::ItemData *item = nullptr; for (auto iter = keyring.begin(); iter != keyring.end(); ++iter) { if ((item = database.GetItem(*iter))!=nullptr) { Message(4,item->Name); @@ -4659,7 +4659,7 @@ void Client::SendRespawnBinds() uint32 PacketLength = 17 + (26 * num_options); //Header size + per-option invariant size std::list::iterator itr; - RespawnOption* opt; + RespawnOption* opt = nullptr; //Find string size for each option for (itr = respawn_options.begin(); itr != respawn_options.end(); ++itr) @@ -8385,7 +8385,7 @@ bool Client::RemoveRespawnOption(std::string option_name) if (IsHoveringForRespawn() || respawn_options.empty()) { return false; } bool had = false; - RespawnOption* opt; + RespawnOption* opt = nullptr; std::list::iterator itr; for (itr = respawn_options.begin(); itr != respawn_options.end(); ++itr) { @@ -8432,7 +8432,7 @@ bool Client::RemoveRespawnOption(uint8 position) void Client::SetHunger(int32 in_hunger) { - EQApplicationPacket *outapp; + EQApplicationPacket *outapp = nullptr; outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct)); Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer; sta->food = in_hunger; @@ -8446,7 +8446,7 @@ void Client::SetHunger(int32 in_hunger) void Client::SetThirst(int32 in_thirst) { - EQApplicationPacket *outapp; + EQApplicationPacket *outapp = nullptr; outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct)); Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer; sta->food = m_pp.hunger_level > 6000 ? 6000 : m_pp.hunger_level; @@ -8460,7 +8460,7 @@ void Client::SetThirst(int32 in_thirst) void Client::SetConsumption(int32 in_hunger, int32 in_thirst) { - EQApplicationPacket *outapp; + EQApplicationPacket *outapp = nullptr; outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct)); Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer; sta->food = in_hunger; diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index 3d3a1d529..e97aa026c 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -1211,8 +1211,8 @@ int32 Client::CalcManaRegenCap() uint32 Client::CalcCurrentWeight() { - const EQEmu::ItemData* TempItem = 0; - EQEmu::ItemInstance* ins; + const EQEmu::ItemData* TempItem = nullptr; + EQEmu::ItemInstance* ins = nullptr; uint32 Total = 0; int x; for (x = EQEmu::legacy::EQUIPMENT_BEGIN; x <= EQEmu::inventory::slotCursor; x++) { // include cursor or not? diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 4b3817e9a..1616ac687 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1074,7 +1074,7 @@ void Client::Handle_Connect_OP_ReqNewZone(const EQApplicationPacket *app) { conn_state = NewZoneRequested; - EQApplicationPacket* outapp; + EQApplicationPacket* outapp = nullptr; ///////////////////////////////////// // New Zone Packet @@ -1240,12 +1240,12 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) } uint32 pplen = 0; - EQApplicationPacket* outapp = 0; - MYSQL_RES* result = 0; + EQApplicationPacket* outapp = nullptr; + MYSQL_RES* result = nullptr; bool loaditems = 0; uint32 i; std::string query; - unsigned long* lengths; + unsigned long* lengths = nullptr; uint32 cid = CharacterID(); character_id = cid; /* Global character_id reference */ @@ -2062,7 +2062,7 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app) merchantid = tmp->CastToNPC()->MerchantType; tmp->CastToNPC()->FaceTarget(this->CastToMob()); - const EQEmu::ItemData *item = 0; + const EQEmu::ItemData *item = nullptr; std::list merlist = zone->merchanttable[merchantid]; std::list::const_iterator itr; for (itr = merlist.begin(); itr != merlist.end() && count<255; ++itr){ @@ -4867,7 +4867,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app) { if (m_pp.hunger_level > 6000) { - EQApplicationPacket *outapp; + EQApplicationPacket *outapp = nullptr; outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct)); Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer; sta->food = m_pp.hunger_level > 6000 ? 6000 : m_pp.hunger_level; @@ -4882,7 +4882,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app) { if (m_pp.thirst_level > 6000) { - EQApplicationPacket *outapp; + EQApplicationPacket *outapp = nullptr; outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct)); Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer; sta->food = m_pp.hunger_level > 6000 ? 6000 : m_pp.hunger_level; @@ -4915,7 +4915,7 @@ void Client::Handle_OP_Consume(const EQApplicationPacket *app) m_pp.hunger_level = 50000; if (m_pp.thirst_level > 50000) m_pp.thirst_level = 50000; - EQApplicationPacket *outapp; + EQApplicationPacket *outapp = nullptr; outapp = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct)); Stamina_Struct* sta = (Stamina_Struct*)outapp->pBuffer; sta->food = m_pp.hunger_level > 6000 ? 6000 : m_pp.hunger_level; @@ -5903,7 +5903,7 @@ void Client::Handle_OP_GMEmoteZone(const EQApplicationPacket *app) return; } GMEmoteZone_Struct* gmez = (GMEmoteZone_Struct*)app->pBuffer; - char* newmessage = 0; + char* newmessage = nullptr; if (strstr(gmez->text, "^") == 0) entity_list.Message(0, 15, gmez->text); else{ @@ -8259,7 +8259,7 @@ void Client::Handle_OP_ItemName(const EQApplicationPacket *app) return; } ItemNamePacket_Struct *p = (ItemNamePacket_Struct*)app->pBuffer; - const EQEmu::ItemData *item = 0; + const EQEmu::ItemData *item = nullptr; if ((item = database.GetItem(p->item_id)) != nullptr) { auto outapp = new EQApplicationPacket(OP_ItemName, sizeof(ItemNamePacket_Struct)); p = (ItemNamePacket_Struct*)outapp->pBuffer; @@ -8466,7 +8466,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) target_id = request->target; - EQApplicationPacket *outapp; + EQApplicationPacket *outapp = nullptr; outapp = new EQApplicationPacket(OP_ItemVerifyReply, sizeof(ItemVerifyReply_Struct)); ItemVerifyReply_Struct* reply = (ItemVerifyReply_Struct*)outapp->pBuffer; reply->slot = slot_id; @@ -8540,8 +8540,8 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) int r; bool tryaug = false; - EQEmu::ItemInstance* clickaug = 0; - EQEmu::ItemData* augitem = 0; + EQEmu::ItemInstance* clickaug = nullptr; + EQEmu::ItemData* augitem = nullptr; for (r = EQEmu::inventory::socketBegin; r < EQEmu::inventory::SocketCount; r++) { const EQEmu::ItemInstance* aug_i = inst->GetAugment(r); @@ -8670,7 +8670,7 @@ void Client::Handle_OP_ItemVerifyRequest(const EQApplicationPacket *app) if (m_pp.thirst_level > 6000) m_pp.thirst_level = 6000; - EQApplicationPacket *outapp2; + EQApplicationPacket *outapp2 = nullptr; outapp2 = new EQApplicationPacket(OP_Stamina, sizeof(Stamina_Struct)); Stamina_Struct* sta = (Stamina_Struct*)outapp2->pBuffer; sta->food = m_pp.hunger_level; @@ -9195,7 +9195,7 @@ void Client::Handle_OP_LootItem(const EQApplicationPacket *app) return; } - EQApplicationPacket* outapp = 0; + EQApplicationPacket* outapp = nullptr; Entity* entity = entity_list.GetID(*((uint16*)app->pBuffer)); if (entity == 0) { Message(13, "Error: OP_LootItem: Corpse not found (ent = 0)"); @@ -12022,7 +12022,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) else zoneid = atoi(row[0]); - char* name; + char* name = nullptr; database.GetZoneLongName(database.GetZoneName(zoneid), &name); Message(15, "%d - %s", zoneid, name); } diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 2bfa8a055..57ed6283c 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -210,7 +210,7 @@ bool Client::Process() { if (bardsong_timer.Check() && bardsong != 0) { //NOTE: this is kinda a heavy-handed check to make sure the mob still exists before //doing the next pulse on them... - Mob *song_target; + Mob *song_target = nullptr; if(bardsong_target_id == GetID()) { song_target = this; } else { @@ -838,7 +838,7 @@ void Client::BulkSendMerchantInventory(int merchant_id, int npcid) { if (m_ClientVersionBit & EQEmu::versions::bit_RoFAndLater) { // RoF+ can send 200 items numItemSlots = 200; } - const EQEmu::ItemData *item; + const EQEmu::ItemData *item = nullptr; std::list merlist = zone->merchanttable[merchant_id]; std::list::const_iterator itr; Mob* merch = entity_list.GetMobByNpcTypeID(npcid); diff --git a/zone/corpse.cpp b/zone/corpse.cpp index a1cc8c69d..1bfc4ef10 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -82,7 +82,7 @@ Corpse* Corpse::LoadCharacterCorpseEntity(uint32 in_dbid, uint32 in_charid, std: /* Load Items */ ItemList itemlist; - ServerLootItem_Struct* tmp = 0; + ServerLootItem_Struct* tmp = nullptr; for (unsigned int i = 0; i < pcs->itemcount; i++) { tmp = new ServerLootItem_Struct; memcpy(tmp, &pcs->items[i], sizeof(player_lootitem::ServerLootItem_Struct)); @@ -267,7 +267,7 @@ Corpse::Corpse(Client* client, int32 in_rezexp) : Mob ( int i; PlayerProfile_Struct *pp = &client->GetPP(); - EQEmu::ItemInstance *item; + EQEmu::ItemInstance *item = nullptr; /* Check if Zone has Graveyard First */ if(!zone->HasGraveyard()) { @@ -671,7 +671,7 @@ void Corpse::AddItem(uint32 itemnum, uint16 charges, int16 slot, uint32 aug1, ui } ServerLootItem_Struct* Corpse::GetItem(uint16 lootslot, ServerLootItem_Struct** bag_item_data) { - ServerLootItem_Struct *sitem = 0, *sitem2; + ServerLootItem_Struct *sitem = nullptr, *sitem2 = nullptr; ItemList::iterator cur,end; cur = itemlist.begin(); @@ -993,7 +993,7 @@ void Corpse::MakeLootRequestPackets(Client* client, const EQApplicationPacket* a } int i = 0; - const EQEmu::ItemData* item = 0; + const EQEmu::ItemData* item = nullptr; ItemList::iterator cur,end; cur = itemlist.begin(); end = itemlist.end(); @@ -1116,9 +1116,9 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app) return; } - const EQEmu::ItemData *item = 0; - EQEmu::ItemInstance *inst = 0; - ServerLootItem_Struct *item_data = nullptr, *bag_item_data[10]; + const EQEmu::ItemData *item = nullptr; + EQEmu::ItemInstance *inst = nullptr; + ServerLootItem_Struct *item_data = nullptr, *bag_item_data[10] = {}; memset(bag_item_data, 0, sizeof(bag_item_data)); if (GetPlayerKillItem() > 1) { @@ -1437,7 +1437,7 @@ uint32 Corpse::GetEquipment(uint8 material_slot) const { } uint32 Corpse::GetEquipmentColor(uint8 material_slot) const { - const EQEmu::ItemData *item; + const EQEmu::ItemData *item = nullptr; if (material_slot > EQEmu::textures::LastTexture) { return 0; diff --git a/zone/effects.cpp b/zone/effects.cpp index 400bae1fa..202ca6237 100644 --- a/zone/effects.cpp +++ b/zone/effects.cpp @@ -747,7 +747,7 @@ void EntityList::AETaunt(Client* taunter, float range, int32 bonus_hate) // NPC spells will only affect other NPCs with compatible faction void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_caster, int16 resist_adjust) { - Mob *curmob; + Mob *curmob = nullptr; float dist = caster->GetAOERange(spell_id); float dist2 = dist * dist; @@ -847,7 +847,7 @@ void EntityList::AESpell(Mob *caster, Mob *center, uint16 spell_id, bool affect_ void EntityList::MassGroupBuff(Mob *caster, Mob *center, uint16 spell_id, bool affect_caster) { - Mob *curmob; + Mob *curmob = nullptr; float dist = caster->GetAOERange(spell_id); float dist2 = dist * dist; @@ -888,7 +888,7 @@ void EntityList::MassGroupBuff(Mob *caster, Mob *center, uint16 spell_id, bool a // NPC spells will only affect other NPCs with compatible faction void EntityList::AEBardPulse(Mob *caster, Mob *center, uint16 spell_id, bool affect_caster) { - Mob *curmob; + Mob *curmob = nullptr; float dist = caster->GetAOERange(spell_id); float dist2 = dist * dist; @@ -940,7 +940,7 @@ void EntityList::AEBardPulse(Mob *caster, Mob *center, uint16 spell_id, bool aff //NPCs handle it differently in Mob::Rampage void EntityList::AEAttack(Mob *attacker, float dist, int Hand, int count, bool IsFromSpell) { //Dook- Will need tweaking, currently no pets or players or horses - Mob *curmob; + Mob *curmob = nullptr; float dist2 = dist * dist; diff --git a/zone/merc.cpp b/zone/merc.cpp index 5f8ea59ea..6a1957d45 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -2183,7 +2183,7 @@ bool Merc::AICastSpell(int8 iChance, uint32 iSpellTypes) { } if(castedSpell) { - char* gmsg = 0; + char* gmsg = nullptr; if(tar != this) { //we don't need spam of bots healing themselves @@ -2606,8 +2606,8 @@ int16 Merc::GetFocusEffect(focusType type, uint16 spell_id) { //Check if item focus effect exists for the client. if (itembonuses.FocusEffects[type]){ - const EQEmu::ItemData* TempItem = 0; - const EQEmu::ItemData* UsedItem = 0; + const EQEmu::ItemData* TempItem = nullptr; + const EQEmu::ItemData* UsedItem = nullptr; uint16 UsedFocusID = 0; int16 Total = 0; int16 focus_max = 0; @@ -4556,7 +4556,7 @@ void Merc::SetTarget(Mob* mob) { } Mob* Merc::GetOwnerOrSelf() { - Mob* Result = 0; + Mob* Result = nullptr; if(this->GetMercOwner()) Result = GetMercOwner(); @@ -4591,7 +4591,7 @@ bool Merc::Death(Mob* killerMob, int32 damage, uint16 spell, EQEmu::skills::Skil } Client* Merc::GetMercOwner() { - Client* mercOwner = 0; + Client* mercOwner = nullptr; if(GetOwner()) { @@ -4605,7 +4605,7 @@ Client* Merc::GetMercOwner() { } Mob* Merc::GetOwner() { - Mob* Result = 0; + Mob* Result = nullptr; Result = entity_list.GetMob(GetOwnerID()); diff --git a/zone/mob.cpp b/zone/mob.cpp index e7b248dd5..9bde2cc0e 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -1292,7 +1292,7 @@ void Mob::CreateHPPacket(EQApplicationPacket* app) void Mob::SendHPUpdate(bool skip_self) { EQApplicationPacket hp_app; - Group *group; + Group *group = nullptr; // destructor will free the pBuffer CreateHPPacket(&hp_app); @@ -2787,7 +2787,7 @@ void Mob::SendArmorAppearance(Client *one_client) { if (!IsClient()) { - const EQEmu::ItemData *item; + const EQEmu::ItemData *item = nullptr; for (int i = 0; i < 7; ++i) { item = database.GetItem(GetEquipment(i)); @@ -2905,7 +2905,7 @@ int32 Mob::GetEquipmentMaterial(uint8 material_slot) const { uint32 equipmaterial = 0; int32 ornamentationAugtype = RuleI(Character, OrnamentationAugmentType); - const EQEmu::ItemData *item; + const EQEmu::ItemData *item = nullptr; item = database.GetItem(GetEquipment(material_slot)); if (item != 0) @@ -2958,7 +2958,7 @@ int32 Mob::GetHerosForgeModel(uint8 material_slot) const if (material_slot >= 0 && material_slot < EQEmu::textures::weaponPrimary) { uint32 ornamentationAugtype = RuleI(Character, OrnamentationAugmentType); - const EQEmu::ItemData *item; + const EQEmu::ItemData *item = nullptr; item = database.GetItem(GetEquipment(material_slot)); int16 invslot = EQEmu::InventoryProfile::CalcSlotFromMaterial(material_slot); @@ -3012,7 +3012,7 @@ int32 Mob::GetHerosForgeModel(uint8 material_slot) const uint32 Mob::GetEquipmentColor(uint8 material_slot) const { - const EQEmu::ItemData *item; + const EQEmu::ItemData *item = nullptr; if (armor_tint.Slot[material_slot].Color) { @@ -3028,7 +3028,7 @@ uint32 Mob::GetEquipmentColor(uint8 material_slot) const uint32 Mob::IsEliteMaterialItem(uint8 material_slot) const { - const EQEmu::ItemData *item; + const EQEmu::ItemData *item = nullptr; item = database.GetItem(GetEquipment(material_slot)); if(item != 0) diff --git a/zone/pets.cpp b/zone/pets.cpp index b9ccafe38..a73f6b54d 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -425,7 +425,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, // like the special back items some focused pets may receive. uint32 petinv[EQEmu::legacy::EQUIPMENT_SIZE]; memset(petinv, 0, sizeof(petinv)); - const EQEmu::ItemData *item = 0; + const EQEmu::ItemData *item = nullptr; if (database.GetBasePetItems(record.equipmentset, petinv)) { for (int i = 0; i < EQEmu::legacy::EQUIPMENT_SIZE; i++) diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 40d85123f..b6a3d835d 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -438,7 +438,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove { float x, y, z, heading; - const char *target_zone; + const char *target_zone = nullptr; x = static_cast(spell.base[1]); y = static_cast(spell.base[0]); @@ -510,7 +510,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove case SE_Teleport2: { float x, y, z, heading; - const char *target_zone; + const char *target_zone = nullptr; x = static_cast(spell.base[1]); y = static_cast(spell.base[0]); @@ -1723,7 +1723,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove #endif // can only summon corpses of clients if(!IsNPC()) { - Client* TargetClient = 0; + Client* TargetClient = nullptr; if(this->GetTarget()) TargetClient = this->GetTarget()->CastToClient(); else @@ -5177,7 +5177,7 @@ uint16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { //item focus if (itembonuses.FocusEffects[type]){ - const EQEmu::ItemData* TempItem = 0; + const EQEmu::ItemData* TempItem = nullptr; for (int x = EQEmu::legacy::EQUIPMENT_BEGIN; x <= EQEmu::legacy::EQUIPMENT_END; x++) { @@ -5306,8 +5306,8 @@ int16 Client::GetFocusEffect(focusType type, uint16 spell_id) //Check if item focus effect exists for the client. if (itembonuses.FocusEffects[type]){ - const EQEmu::ItemData* TempItem = 0; - const EQEmu::ItemData* UsedItem = 0; + const EQEmu::ItemData* TempItem = nullptr; + const EQEmu::ItemData* UsedItem = nullptr; uint16 UsedFocusID = 0; int16 Total = 0; int16 focus_max = 0; @@ -5578,8 +5578,8 @@ int16 NPC::GetFocusEffect(focusType type, uint16 spell_id) { if (RuleB(Spells, NPC_UseFocusFromItems) && itembonuses.FocusEffects[type]){ - const EQEmu::ItemData* TempItem = 0; - const EQEmu::ItemData* UsedItem = 0; + const EQEmu::ItemData* TempItem = nullptr; + const EQEmu::ItemData* UsedItem = nullptr; uint16 UsedFocusID = 0; int16 Total = 0; int16 focus_max = 0; diff --git a/zone/spells.cpp b/zone/spells.cpp index af09c14a3..e3ec41f30 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -826,7 +826,7 @@ void Mob::InterruptSpell(uint16 spellid) // color not used right now void Mob::InterruptSpell(uint16 message, uint16 color, uint16 spellid) { - EQApplicationPacket *outapp; + EQApplicationPacket *outapp = nullptr; uint16 message_other; bool bard_song_mode = false; //has the bard song gone to auto repeat mode if (spellid == SPELL_UNKNOWN) { @@ -1267,7 +1267,7 @@ void Mob::CastedSpellFinished(uint16 spell_id, uint32 target_id, CastingSlot slo { bool fromaug = false; const EQEmu::ItemInstance* inst = CastToClient()->GetInv()[inventory_slot]; - EQEmu::ItemData* augitem = 0; + EQEmu::ItemData* augitem = nullptr; uint32 recastdelay = 0; uint32 recasttype = 0; @@ -3428,7 +3428,7 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r } } - EQApplicationPacket *action_packet, *message_packet; + EQApplicationPacket *action_packet = nullptr, *message_packet = nullptr; float spell_effectiveness; if(!IsValidSpell(spell_id)) @@ -3621,19 +3621,19 @@ bool Mob::SpellOnTarget(uint16 spell_id, Mob *spelltar, bool reflect, bool use_r spelltar != this) { - Client* pClient = 0; - Raid* pRaid = 0; - Group* pBasicGroup = 0; + Client* pClient = nullptr; + Raid* pRaid = nullptr; + Group* pBasicGroup = nullptr; uint32 nGroup = 0; //raid group - Client* pClientTarget = 0; - Raid* pRaidTarget = 0; - Group* pBasicGroupTarget = 0; + Client* pClientTarget = nullptr; + Raid* pRaidTarget = nullptr; + Group* pBasicGroupTarget = nullptr; uint32 nGroupTarget = 0; //raid group - Client* pClientTargetPet = 0; - Raid* pRaidTargetPet = 0; - Group* pBasicGroupTargetPet = 0; + Client* pClientTargetPet = nullptr; + Raid* pRaidTargetPet = nullptr; + Group* pBasicGroupTargetPet = nullptr; uint32 nGroupTargetPet = 0; //raid group const uint32 cnWTF = 0xFFFFFFFF + 1; //this should be zero unless on 64bit? forced uint64? @@ -4936,7 +4936,7 @@ void Mob::Mesmerize() void Client::MakeBuffFadePacket(uint16 spell_id, int slot_id, bool send_message) { - EQApplicationPacket* outapp; + EQApplicationPacket* outapp = nullptr; outapp = new EQApplicationPacket(OP_Buff, sizeof(SpellBuffPacket_Struct)); SpellBuffPacket_Struct* sbf = (SpellBuffPacket_Struct*) outapp->pBuffer; @@ -5416,7 +5416,7 @@ void Mob::_StopSong() //be used for other things as well void Client::SendBuffDurationPacket(Buffs_Struct &buff, int slot) { - EQApplicationPacket* outapp; + EQApplicationPacket* outapp = nullptr; outapp = new EQApplicationPacket(OP_Buff, sizeof(SpellBuffPacket_Struct)); SpellBuffPacket_Struct* sbf = (SpellBuffPacket_Struct*) outapp->pBuffer; @@ -5452,7 +5452,7 @@ void Client::SendBuffNumHitPacket(Buffs_Struct &buff, int slot) // UF+ use this packet if (ClientVersion() < EQEmu::versions::ClientVersion::UF) return; - EQApplicationPacket *outapp; + EQApplicationPacket *outapp = nullptr; outapp = new EQApplicationPacket(OP_BuffCreate, sizeof(BuffIcon_Struct) + sizeof(BuffIconEntry_Struct)); BuffIcon_Struct *bi = (BuffIcon_Struct *)outapp->pBuffer; bi->entity_id = GetID(); diff --git a/zone/zone.cpp b/zone/zone.cpp index ab0a9b6e4..599e5e802 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -290,7 +290,7 @@ bool Zone::LoadGroundSpawns() { Log.Out(Logs::General, Logs::Status, "Loading Ground Spawns from DB..."); database.LoadGroundSpawns(zoneid, GetInstanceVersion(), &groundspawn); uint32 ix=0; - char* name=0; + char* name = nullptr; uint32 gsnumber=0; for(gsindex=0;gsindex<50;gsindex++){ if(groundspawn.spawn[gsindex].item>0 && groundspawn.spawn[gsindex].item iterator(zone_point_list); - ZonePoint* closest_zp = 0; + ZonePoint* closest_zp = nullptr; float closest_dist = FLT_MAX; float max_distance2 = max_distance * max_distance; iterator.Reset(); @@ -1625,7 +1625,7 @@ ZonePoint* Zone::GetClosestZonePoint(const glm::vec3& location, const char* to_n ZonePoint* Zone::GetClosestZonePointWithoutZone(float x, float y, float z, Client* client, float max_distance) { LinkedListIterator iterator(zone_point_list); - ZonePoint* closest_zp = 0; + ZonePoint* closest_zp = nullptr; float closest_dist = FLT_MAX; float max_distance2 = max_distance*max_distance; iterator.Reset(); diff --git a/zone/zoning.cpp b/zone/zoning.cpp index 30dc4d81f..677dd3d18 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -297,7 +297,7 @@ void Client::SendZoneCancel(ZoneChange_Struct *zc) { //effectively zone them right back to where they were //unless we find a better way to stop the zoning process. SetPortExemption(true); - EQApplicationPacket *outapp; + EQApplicationPacket *outapp = nullptr; outapp = new EQApplicationPacket(OP_ZoneChange, sizeof(ZoneChange_Struct)); ZoneChange_Struct *zc2 = (ZoneChange_Struct*)outapp->pBuffer; strcpy(zc2->char_name, zc->char_name); @@ -316,7 +316,7 @@ void Client::SendZoneError(ZoneChange_Struct *zc, int8 err) SetPortExemption(true); - EQApplicationPacket *outapp; + EQApplicationPacket *outapp = nullptr; outapp = new EQApplicationPacket(OP_ZoneChange, sizeof(ZoneChange_Struct)); ZoneChange_Struct *zc2 = (ZoneChange_Struct*)outapp->pBuffer; strcpy(zc2->char_name, zc->char_name);