refactor(Core/Misc): remove the ternary operator when used improperly (#3327)

This commit is contained in:
Stefano Borzì
2020-09-10 12:29:23 +02:00
committed by GitHub
parent 207512a0f5
commit 51330f54d8
19 changed files with 67 additions and 67 deletions

View File

@@ -853,7 +853,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
// Activate
// xinef: wtf is this shit?
(*itr)->ToGameObject()->SetLootState(GO_READY);
(*itr)->ToGameObject()->UseDoorOrButton(0, e.action.activateObject.alternative ? true : false, unit);
(*itr)->ToGameObject()->UseDoorOrButton(0, !!e.action.activateObject.alternative, unit);
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_ACTIVATE_GOBJECT. Gameobject %u (entry: %u) activated",
(*itr)->GetGUIDLow(), (*itr)->GetEntry());
@@ -1507,7 +1507,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
if (IsUnit(*itr))
(*itr)->ToUnit()->SetVisible(e.action.visibility.state ? true : false);
(*itr)->ToUnit()->SetVisible(!!e.action.visibility.state);
delete targets;
break;
@@ -1519,7 +1519,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
break;
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
(*itr)->setActive(e.action.setActive.state ? true : false);
(*itr)->setActive(!!e.action.setActive.state);
delete targets;
break;

View File

@@ -240,7 +240,7 @@ namespace AccountMgr
stmt->setString(1, CalculateShaPassHash(username, password));
PreparedQueryResult result = LoginDatabase.Query(stmt);
return (result) ? true : false;
return !!result;
}
uint32 GetCharactersCount(uint32 accountId)

View File

@@ -443,7 +443,7 @@ void AuctionHouseObject::AddAuction(AuctionEntry* auction)
bool AuctionHouseObject::RemoveAuction(AuctionEntry* auction)
{
bool wasInMap = AuctionsMap.erase(auction->Id) ? true : false;
bool wasInMap = !!AuctionsMap.erase(auction->Id);
sScriptMgr->OnAuctionRemove(this, auction);

View File

@@ -381,7 +381,7 @@ void BattlegroundIC::FillInitialWorldStates(WorldPacket& data)
for (uint8 i = 0; i < MAX_FORTRESS_GATES_SPAWNS; ++i)
{
uint32 uws = GetWorldStateFromGateEntry(BG_IC_ObjSpawnlocs[i].entry, (GateStatus[GetGateIDFromEntry(BG_IC_ObjSpawnlocs[i].entry)] == BG_IC_GATE_DESTROYED ? true : false));
uint32 uws = GetWorldStateFromGateEntry(BG_IC_ObjSpawnlocs[i].entry, (GateStatus[GetGateIDFromEntry(BG_IC_ObjSpawnlocs[i].entry)] == BG_IC_GATE_DESTROYED));
data << uint32(uws) << uint32(1);
}
@@ -515,9 +515,9 @@ void BattlegroundIC::HandleKillUnit(Creature* unit, Player* killer)
if (unit->IsVehicle())
{
killer->CastSpell(killer, SPELL_DESTROYED_VEHICLE_ACHIEVEMENT, true);
// Xinef: Add to respawn list
if (entry == NPC_DEMOLISHER || entry == NPC_SIEGE_ENGINE_H || entry == NPC_SIEGE_ENGINE_A ||
if (entry == NPC_DEMOLISHER || entry == NPC_SIEGE_ENGINE_H || entry == NPC_SIEGE_ENGINE_A ||
entry == NPC_GLAIVE_THROWER_A || entry == NPC_GLAIVE_THROWER_H || entry == NPC_CATAPULT)
respawnMap[unit->GetGUIDLow()] = time(nullptr) + VEHICLE_RESPAWN_TIME;
}
@@ -562,15 +562,15 @@ void BattlegroundIC::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb
// Prevent capturing of keep if none of gates was destroyed
if (nodePoint[i].gameobject_entry == GO_ALLIANCE_BANNER)
{
if (GateStatus[BG_IC_A_FRONT] != BG_IC_GATE_DESTROYED &&
GateStatus[BG_IC_A_WEST] != BG_IC_GATE_DESTROYED &&
if (GateStatus[BG_IC_A_FRONT] != BG_IC_GATE_DESTROYED &&
GateStatus[BG_IC_A_WEST] != BG_IC_GATE_DESTROYED &&
GateStatus[BG_IC_A_EAST] != BG_IC_GATE_DESTROYED)
return;
}
else if (nodePoint[i].gameobject_entry == GO_HORDE_BANNER)
{
if (GateStatus[BG_IC_H_FRONT] != BG_IC_GATE_DESTROYED &&
GateStatus[BG_IC_H_WEST] != BG_IC_GATE_DESTROYED &&
if (GateStatus[BG_IC_H_FRONT] != BG_IC_GATE_DESTROYED &&
GateStatus[BG_IC_H_WEST] != BG_IC_GATE_DESTROYED &&
GateStatus[BG_IC_H_EAST] != BG_IC_GATE_DESTROYED)
return;
}

View File

@@ -49,7 +49,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
{
// don't allow 0 items (it's checked during table load)
ASSERT(ConditionValue2);
bool checkBank = ConditionValue3 ? true : false;
bool checkBank = !!ConditionValue3;
condMeets = player->HasItemCount(ConditionValue1, ConditionValue2, checkBank);
}
break;
@@ -207,12 +207,12 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
}
case CONDITION_NEAR_CREATURE:
{
condMeets = GetClosestCreatureWithEntry(object, ConditionValue1, (float)ConditionValue2, !ConditionValue3) ? true : false;
condMeets = !!GetClosestCreatureWithEntry(object, ConditionValue1, (float)ConditionValue2, !ConditionValue3);
break;
}
case CONDITION_NEAR_GAMEOBJECT:
{
condMeets = GetClosestGameObjectWithEntry(object, ConditionValue1, (float)ConditionValue2) ? true : false;
condMeets = !!GetClosestGameObjectWithEntry(object, ConditionValue1, (float)ConditionValue2);
break;
}
case CONDITION_OBJECT_ENTRY_GUID:

View File

@@ -22585,13 +22585,13 @@ bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot)
switch (Condition->Comparator[i])
{
case 2: // requires less <color> than (<value> || <comparecolor>) gems
activate &= (_cur_gem < _cmp_gem) ? true : false;
activate &= (_cur_gem < _cmp_gem);
break;
case 3: // requires more <color> than (<value> || <comparecolor>) gems
activate &= (_cur_gem > _cmp_gem) ? true : false;
activate &= (_cur_gem > _cmp_gem);
break;
case 5: // requires at least <color> than (<value> || <comparecolor>) gems
activate &= (_cur_gem >= _cmp_gem) ? true : false;
activate &= (_cur_gem >= _cmp_gem);
break;
}
}

View File

@@ -1704,7 +1704,7 @@ class Player : public Unit, public GridObject<Player>
bool RemoveMItem(uint32 id)
{
return mMitems.erase(id) ? true : false;
return !!mMitems.erase(id);
}
void PetSpellInitialize();
@@ -2539,7 +2539,7 @@ class Player : public Unit, public GridObject<Player>
void SetLastUsedRune(RuneType type) { m_runes->lastUsedRune = type; }
void SetBaseRune(uint8 index, RuneType baseRune) { m_runes->runes[index].BaseRune = baseRune; }
void SetCurrentRune(uint8 index, RuneType currentRune) { m_runes->runes[index].CurrentRune = currentRune; }
void SetRuneCooldown(uint8 index, uint32 cooldown) { m_runes->runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0) ? true : false); }
void SetRuneCooldown(uint8 index, uint32 cooldown) { m_runes->runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0)); }
void SetGracePeriod(uint8 index, uint32 period) { m_runes->runes[index].GracePeriod = period; }
void SetRuneConvertAura(uint8 index, AuraEffect const* aura) { m_runes->runes[index].ConvertAura = aura; }
void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura) { SetRuneConvertAura(index, aura); ConvertRune(index, newType); }

View File

@@ -121,13 +121,13 @@ void InstanceScript::UpdateDoorState(GameObject* door)
switch (info.type)
{
case DOOR_TYPE_ROOM:
open &= (info.bossInfo->state != IN_PROGRESS) ? true : false;
open &= (info.bossInfo->state != IN_PROGRESS);
break;
case DOOR_TYPE_PASSAGE:
open &= (info.bossInfo->state == DONE) ? true : false;
open &= (info.bossInfo->state == DONE);
break;
case DOOR_TYPE_SPAWN_HOLE:
open &= (info.bossInfo->state == IN_PROGRESS) ? true : false;
open &= (info.bossInfo->state == IN_PROGRESS);
break;
default:
break;

View File

@@ -318,7 +318,7 @@ bool MapManager::IsValidMAP(uint32 mapid, bool startUp)
MapEntry const* mEntry = sMapStore.LookupEntry(mapid);
if (startUp)
return mEntry ? true : false;
return !!mEntry;
else
return mEntry && (!mEntry->IsDungeon() || sObjectMgr->GetInstanceTemplate(mapid));