From 90a518f4d6b61800e7cc0259509728edc66761dd Mon Sep 17 00:00:00 2001 From: Arthur Dene Ice Date: Wed, 7 May 2014 20:13:11 -0700 Subject: [PATCH] lots of conversions to bool (with performance penalty) doing it explicityl. --- zone/bonuses.cpp | 2 +- zone/bot.cpp | 10 +++++----- zone/client.cpp | 2 +- zone/client_mods.cpp | 6 +++--- zone/client_packet.cpp | 10 +++++----- zone/client_process.cpp | 4 ++-- zone/command.cpp | 2 +- zone/corpse.cpp | 2 +- zone/embparser_api.cpp | 4 ++-- zone/loottables.cpp | 2 +- zone/npc.cpp | 6 +++--- zone/pathing.cpp | 4 ++-- zone/pets.cpp | 4 ++-- zone/raids.cpp | 8 ++++---- zone/tasks.cpp | 8 ++++---- zone/trading.cpp | 2 +- zone/worldserver.cpp | 2 +- zone/zonedb.cpp | 8 ++++---- 18 files changed, 43 insertions(+), 43 deletions(-) diff --git a/zone/bonuses.cpp b/zone/bonuses.cpp index db0f81115..7acf52c4c 100644 --- a/zone/bonuses.cpp +++ b/zone/bonuses.cpp @@ -3952,7 +3952,7 @@ void Mob::NegateSpellsBonuses(uint16 spell_id) break; case SE_DistanceRemoval: - spellbonuses.DistanceRemoval = effect_value; + spellbonuses.DistanceRemoval = effect_value != 0; break; case SE_ImprovedTaunt: diff --git a/zone/bot.cpp b/zone/bot.cpp index 9ebd6d55e..bb5015b6e 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1291,7 +1291,7 @@ void Bot::GenerateArmorClass() uint16 Bot::GetPrimarySkillValue() { SkillUseTypes skill = HIGHEST_SKILL; //because nullptr == 0, which is 1H Slashing, & we want it to return 0 from GetSkill - bool equiped = m_inv.GetItem(SLOT_PRIMARY); + bool equiped = m_inv.GetItem(SLOT_PRIMARY) != nullptr; if(!equiped) { @@ -5070,7 +5070,7 @@ bool Bot::DoesBotGroupNameExist(std::string botGroupName) { std::string tempBotGroupName = std::string(DataRow[1]); if(botGroupName == tempBotGroupName) { - result = tempBotGroupId; + result = tempBotGroupId != 0; break; } } @@ -7861,7 +7861,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) if(damage > 0 && (aabonuses.ShieldBlock || spellbonuses.ShieldBlock || itembonuses.ShieldBlock) && (!other->BehindMob(this, other->GetX(), other->GetY()) || bShieldBlockFromRear)) { - bool equiped = GetBotItem(SLOT_SECONDARY); + bool equiped = GetBotItem(SLOT_SECONDARY) != nullptr; if(equiped) { uint8 shield = GetBotItem(SLOT_SECONDARY)->GetItem()->ItemType; float bonusShieldBlock = 0.0f; @@ -7876,7 +7876,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) if(damage > 0 && (aabonuses.TwoHandBluntBlock || spellbonuses.TwoHandBluntBlock || itembonuses.TwoHandBluntBlock) && (!other->BehindMob(this, other->GetX(), other->GetY()) || bShieldBlockFromRear)) { - bool equiped2 = GetBotItem(SLOT_PRIMARY); + bool equiped2 = GetBotItem(SLOT_PRIMARY) != nullptr; if(equiped2) { uint8 TwoHandBlunt = GetBotItem(SLOT_PRIMARY)->GetItem()->ItemType; float bonusStaffBlock = 0.0f; @@ -10477,7 +10477,7 @@ void Bot::CalcRestState() { int32 Bot::LevelRegen() { int level = GetLevel(); - bool bonus = GetRaceBitmask(_baseRace) & RuleI(Character, BaseHPRegenBonusRaces); + bool bonus = GetRaceBitmask(_baseRace) & RuleI(Character, BaseHPRegenBonusRaces) != 0; uint8 multiplier1 = bonus ? 2 : 1; int32 hp = 0; diff --git a/zone/client.cpp b/zone/client.cpp index c172f2b5e..61164e605 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -4136,7 +4136,7 @@ void Client::UpdateLFP() { uint16 Client::GetPrimarySkillValue() { SkillUseTypes skill = HIGHEST_SKILL; //because nullptr == 0, which is 1H Slashing, & we want it to return 0 from GetSkill - bool equiped = m_inv.GetItem(13); + bool equiped = m_inv.GetItem(13) != nullptr; if (!equiped) skill = SkillHandtoHand; diff --git a/zone/client_mods.cpp b/zone/client_mods.cpp index 8c29f05eb..371c52a76 100644 --- a/zone/client_mods.cpp +++ b/zone/client_mods.cpp @@ -155,7 +155,7 @@ int32 Client::LevelRegen() bool sitting = IsSitting(); bool feigned = GetFeigned(); int level = GetLevel(); - bool bonus = GetRaceBitmask(GetBaseRace()) & RuleI(Character, BaseHPRegenBonusRaces); + bool bonus = GetRaceBitmask(GetBaseRace()) & RuleI(Character, BaseHPRegenBonusRaces) != 0; uint8 multiplier1 = bonus ? 2 : 1; int32 hp = 0; @@ -873,7 +873,7 @@ int16 Client::CalcAC() { // Shield AC bonus for HeroicSTR if(itembonuses.HeroicSTR) { - bool equiped = CastToClient()->m_inv.GetItem(14); + bool equiped = CastToClient()->m_inv.GetItem(14) != nullptr; if(equiped) { uint8 shield = CastToClient()->m_inv.GetItem(14)->GetItem()->ItemType; if(shield == ItemTypeShield) @@ -903,7 +903,7 @@ int16 Client::GetACMit() { // Shield AC bonus for HeroicSTR if(itembonuses.HeroicSTR) { - bool equiped = CastToClient()->m_inv.GetItem(14); + bool equiped = CastToClient()->m_inv.GetItem(14) != nullptr; if(equiped) { uint8 shield = CastToClient()->m_inv.GetItem(14)->GetItem()->ItemType; if(shield == ItemTypeShield) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 1a9420dd7..9927c7e68 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -4010,7 +4010,7 @@ void Client::Handle_OP_GuildManageBanker(const EQApplicationPacket *app) bool NewBankerStatus = gmb->enabled & 0x01; - bool NewAltStatus = gmb->enabled & 0x02; + bool NewAltStatus = gmb->enabled & 0x02 != 0; if((IsCurrentlyABanker != NewBankerStatus) && !guild_mgr.IsGuildLeader(GuildID(), CharacterID())) { @@ -11685,8 +11685,8 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app) strn0cpy(TimeOfDeath, Row[5], sizeof(TimeOfDeath)); - bool CorpseRezzed = atoi(Row[6]); - bool CorpseBuried = atoi(Row[7]); + bool CorpseRezzed = atoi(Row[6]) != 0; + bool CorpseBuried = atoi(Row[7]) != 0; sprintf(Buffer, "%s%s%8.0f%8.0f%8.0f%s%s%s", CharName, StaticGetZoneName(ZoneID), CorpseX, CorpseY, CorpseZ, TimeOfDeath, @@ -12331,7 +12331,7 @@ void Client::Handle_OP_ClearBlockedBuffs(const EQApplicationPacket *app) return; } - bool Pet = app->pBuffer[0]; + bool Pet = app->pBuffer[0] != 0; if(Pet) PetBlockedBuffs.clear(); @@ -13302,7 +13302,7 @@ void Client::Handle_OP_XTargetAutoAddHaters(const EQApplicationPacket *app) return; } - XTargetAutoAddHaters = app->ReadUInt8(0); + XTargetAutoAddHaters = app->ReadUInt8(0) != 0; } void Client::Handle_OP_ItemPreview(const EQApplicationPacket *app) diff --git a/zone/client_process.cpp b/zone/client_process.cpp index c28affd28..2960d5d08 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -699,7 +699,7 @@ bool Client::Process() { { while(ret && (app = (EQApplicationPacket *)eqs->PopPacket())) { if(app) - ret = HandlePacket(app); + ret = HandlePacket(app) != 0; safe_delete(app); } } @@ -1182,7 +1182,7 @@ void Client::OPTGB(const EQApplicationPacket *app) if(tgb_flag == 2) Message_StringID(0, TGB() ? TGB_ON : TGB_OFF); else - tgb = tgb_flag; + tgb = tgb_flag != 0; } void Client::OPMemorizeSpell(const EQApplicationPacket* app) diff --git a/zone/command.cpp b/zone/command.cpp index d15d7db21..d9924bb8a 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -6472,7 +6472,7 @@ void command_revoke(Client *c, const Seperator *sep) RevokeStruct* revoke = (RevokeStruct*)outapp->pBuffer; strn0cpy(revoke->adminname, c->GetName(), 64); strn0cpy(revoke->name, sep->arg[1], 64); - revoke->toggle = flag; + revoke->toggle = flag != 0; worldserver.SendPacket(outapp); safe_delete(outapp); } diff --git a/zone/corpse.cpp b/zone/corpse.cpp index 992649c03..aadc8aad9 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -1894,7 +1894,7 @@ bool ZoneDatabase::LoadPlayerCorpses(uint32 iZoneID, uint16 iInstanceID) { safe_delete_array(query); while ((row = mysql_fetch_row(result))) { lengths = mysql_fetch_lengths(result); - entity_list.AddCorpse(Corpse::LoadFromDBData(atoi(row[0]), atoi(row[1]), row[2], (uchar*) row[7], lengths[7], atof(row[3]), atoi(row[4]), atoi(row[5]), atoi(row[6]), row[8],atoi(row[9])==1, atoi(row[10]))); + entity_list.AddCorpse(Corpse::LoadFromDBData(atoi(row[0]), atoi(row[1]), row[2], (uchar*) row[7], lengths[7], atof(row[3]), atoi(row[4]), atoi(row[5]), atoi(row[6]), row[8],atoi(row[9])==1, atoi(row[10]) != 0)); } mysql_free_result(result); } diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 91b6d1836..ad4cb81ef 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -399,7 +399,7 @@ XS(XS__addloot) if (items > 1) charges = (uint16)SvUV(ST(1)); if (items > 2) - equipitem = (bool)SvTRUE(ST(2)); + equipitem = SvTRUE(ST(2)) != 0; quest_manager.addloot(itemid, charges, equipitem); @@ -1388,7 +1388,7 @@ XS(XS__moveto) h = 0; if(items > 4) - saveguard = (bool)SvTRUE(ST(4)); + saveguard = SvTRUE(ST(4)) != 0; else saveguard = false; diff --git a/zone/loottables.cpp b/zone/loottables.cpp index e7adaff7e..516d019ad 100644 --- a/zone/loottables.cpp +++ b/zone/loottables.cpp @@ -146,7 +146,7 @@ void ZoneDatabase::AddLootDropToNPC(NPC* npc,uint32 lootdrop_id, ItemList* iteml uint32 itemid = lds->Entries[item].item_id; const Item_Struct* dbitem = GetItem(itemid); - npc->AddLootDrop(dbitem, itemlist, lds->Entries[item].item_charges, lds->Entries[item].minlevel, lds->Entries[item].maxlevel, lds->Entries[item].equip_item, false); + npc->AddLootDrop(dbitem, itemlist, lds->Entries[item].item_charges, lds->Entries[item].minlevel, lds->Entries[item].maxlevel, lds->Entries[item].equip_item != 0, false); pickedcharges++; } } diff --git a/zone/npc.cpp b/zone/npc.cpp index e43270a92..77ddad72e 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -1927,7 +1927,7 @@ void NPC::ModifyNPCStat(const char *identifier, const char *newValue) if(id == "trackable") { - trackable = atoi(val.c_str()); + trackable = atoi(val.c_str()) != 0; return; } @@ -1957,7 +1957,7 @@ void NPC::ModifyNPCStat(const char *identifier, const char *newValue) if(id == "see_invis_undead") { - see_invis_undead = atoi(val.c_str()); + see_invis_undead = atoi(val.c_str()) != 0; return; } @@ -1969,7 +1969,7 @@ void NPC::ModifyNPCStat(const char *identifier, const char *newValue) if(id == "see_improved_hide") { - see_improved_hide = atoi(val.c_str()); + see_improved_hide = atoi(val.c_str()) != 0; return; } diff --git a/zone/pathing.cpp b/zone/pathing.cpp index f8bbd53da..3f28729a3 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -281,7 +281,7 @@ std::list PathManager::FindRoute(int startID, int endID) AStarEntry.Parent = CurrentNode.PathNodeID; - AStarEntry.Teleport = PathNodes[CurrentNode.PathNodeID].Neighbours[i].Teleport; + AStarEntry.Teleport = PathNodes[CurrentNode.PathNodeID].Neighbours[i].Teleport != 0; // HCost is the estimated cost to get from this node to the end. AStarEntry.HCost = VertexDistance(PathNodes[PathNodes[CurrentNode.PathNodeID].Neighbours[i].id].v, @@ -317,7 +317,7 @@ std::list PathManager::FindRoute(int startID, int endID) (*OpenListIterator).GCost = GCostToNode; - (*OpenListIterator).Teleport = PathNodes[CurrentNode.PathNodeID].Neighbours[i].Teleport; + (*OpenListIterator).Teleport = PathNodes[CurrentNode.PathNodeID].Neighbours[i].Teleport != 0; } break; } diff --git a/zone/pets.cpp b/zone/pets.cpp index d5946ce58..9c6ba2bf9 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -473,11 +473,11 @@ bool ZoneDatabase::GetPoweredPetEntry(const char *pet_type, int16 petpower, PetR row = mysql_fetch_row(result); into->npc_type = atoi(row[0]); - into->temporary = atoi(row[1]); + into->temporary = atoi(row[1]) != 0; into->petpower = atoi(row[2]); into->petcontrol = atoi(row[3]); into->petnaming = atoi(row[4]); - into->monsterflag = atoi(row[5]); + into->monsterflag = atoi(row[5]) != 0; into->equipmentset = atoi(row[6]); mysql_free_result(result); diff --git a/zone/raids.cpp b/zone/raids.cpp index bf6f76d5c..11d56bd2f 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -1319,7 +1319,7 @@ void Raid::GetRaidDetails() } row = mysql_fetch_row(result); if(row){ - locked = atoi(row[0]); + locked = atoi(row[0]) != 0; LootType = atoi(row[1]); } mysql_free_result(result); @@ -1354,9 +1354,9 @@ bool Raid::LearnMembers() members[i].GroupNumber = GroupNum; members[i]._class = atoi(row[2]); members[i].level = atoi(row[3]); - members[i].IsGroupLeader = atoi(row[4]); - members[i].IsRaidLeader = atoi(row[5]); - members[i].IsLooter = atoi(row[6]); + members[i].IsGroupLeader = atoi(row[4]) != 0; + members[i].IsRaidLeader = atoi(row[5]) != 0; + members[i].IsLooter = atoi(row[6]) != 0; i++; } mysql_free_result(result); diff --git a/zone/tasks.cpp b/zone/tasks.cpp index 221085d4e..464be5cf0 100644 --- a/zone/tasks.cpp +++ b/zone/tasks.cpp @@ -207,7 +207,7 @@ bool TaskManager::LoadTasks(int SingleTask) { Tasks[TaskID]->StartZone = atoi(row[9]); Tasks[TaskID]->MinLevel = atoi(row[10]); Tasks[TaskID]->MaxLevel = atoi(row[11]); - Tasks[TaskID]->Repeatable = atoi(row[12]); + Tasks[TaskID]->Repeatable = atoi(row[12]) != 0; Tasks[TaskID]->ActivityCount = 0; Tasks[TaskID]->SequenceMode = ActivitiesSequential; Tasks[TaskID]->LastStep = 0; @@ -297,7 +297,7 @@ bool TaskManager::LoadTasks(int SingleTask) { Tasks[TaskID]->Activity[Tasks[TaskID]->ActivityCount].GoalCount = atoi(row[9]); Tasks[TaskID]->Activity[Tasks[TaskID]->ActivityCount].DeliverToNPC = atoi(row[10]); Tasks[TaskID]->Activity[Tasks[TaskID]->ActivityCount].ZoneID = atoi(row[11]); - Tasks[TaskID]->Activity[Tasks[TaskID]->ActivityCount].Optional = atoi(row[12]); + Tasks[TaskID]->Activity[Tasks[TaskID]->ActivityCount].Optional = atoi(row[12]) != 0; _log(TASKS__GLOBALLOAD, "Activity Slot %2i: ID %i for Task %5i. Type: %3i, GoalID: %8i, " "GoalMethod: %i, GoalCount: %3i, ZoneID:%3i", @@ -638,7 +638,7 @@ bool TaskManager::LoadClientState(Client *c, ClientTaskState *state) { } int DoneCount = atoi(row[2]); - bool Completed = atoi(row[3]); + bool Completed = atoi(row[3]) != 0; state->ActiveTasks[ActiveTaskIndex].Activity[ActivityID].ActivityID = ActivityID; state->ActiveTasks[ActiveTaskIndex].Activity[ActivityID].DoneCount = DoneCount; if(Completed) state->ActiveTasks[ActiveTaskIndex].Activity[ActivityID].State = ActivityCompleted; @@ -1617,7 +1617,7 @@ bool ClientTaskState::UpdateTasksOnSpeakWith(Client *c, int NPCTypeID) { bool ClientTaskState::UpdateTasksByNPC(Client *c, int ActivityType, int NPCTypeID) { - int Ret = false; + bool Ret = false; _log(TASKS__UPDATE, "ClientTaskState::UpdateTasks for NPCTypeID: %d", NPCTypeID); diff --git a/zone/trading.cpp b/zone/trading.cpp index 0ce4ff9ee..3c699572f 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -1619,7 +1619,7 @@ void Client::SendBazaarResults(uint32 TraderID, uint32 Class_, uint32 Race, uint VARSTRUCT_ENCODE_TYPE(uint32, bufptr, Cost); StatValue = atoi(Row[8]); VARSTRUCT_ENCODE_TYPE(uint32, bufptr, StatValue); - bool Stackable = atoi(Row[10]); + bool Stackable = atoi(Row[10]) != 0; if(Stackable) { int Charges = atoi(Row[9]); sprintf(Name, "%s(%i)", Row[7], Charges); diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index edadc94f3..bd0f15767 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -787,7 +787,7 @@ void WorldServer::Process() { break; } case ServerOP_OOCMute: { - oocmuted = *(pack->pBuffer); + oocmuted = *(pack->pBuffer) != 0; break; } case ServerOP_Revoke: { diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 2178a15c9..d779809bb 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -389,9 +389,9 @@ bool ZoneDatabase::GetAccountInfoForLogin_result(MYSQL_RES* result, int16* admin if (gmspeed) *gmspeed = atoi(row[3]); if (revoked) - *revoked = atoi(row[4]); + *revoked = atoi(row[4]) != 0; if(gmhideme) - *gmhideme = atoi(row[5]); + *gmhideme = atoi(row[5]) != 0; if(account_creation) *account_creation = atoul(row[6]); @@ -961,10 +961,10 @@ bool ZoneDatabase::GetCharacterInfoForLogin_result(MYSQL_RES* result, *level = atoi(row[10]); if(LFP) - *LFP = atoi(row[11]); + *LFP = atoi(row[11]) != 0; if(LFG) - *LFG = atoi(row[12]); + *LFG = atoi(row[12]) != 0; if(NumXTargets) {