diff options
author | Gyx <2359980687@qq.com> | 2012-03-28 20:00:29 +0800 |
---|---|---|
committer | Gyx <2359980687@qq.com> | 2012-03-28 20:00:29 +0800 |
commit | 1544b208da2c2c8522e711db38a598f08105fe51 (patch) | |
tree | f04ad31e6d5dc15df534194398652e4dd81a7f7c | |
parent | 72cdcbfcedafe223837c5011431373ef852a9c8b (diff) |
Core/Game: Code style again.
Signed-off-by: Gyx <2359980687@qq.com>
20 files changed, 233 insertions, 137 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 4cf438da5a4..2ff25544b2c 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -73,7 +73,9 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c) void SmartAI::UpdateDespawn(const uint32 diff) { - if (mDespawnState <= 1 || mDespawnState > 3) return; + if (mDespawnState <= 1 || mDespawnState > 3) + return; + if (mDespawnTime < diff) { if (mDespawnState == 2) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 05a2910e7a7..5eaa1577642 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1954,7 +1954,8 @@ void SmartScript::InstallTemplate(SmartScriptHolder const& e) } case SMARTAI_TEMPLATE_CAGED_NPC_PART: { - if (!me) return; + if (!me) + return; //store cage as id1 AddEvent(SMART_EVENT_DATA_SET, 0, 0, 0, 0, 0, SMART_ACTION_STORE_TARGET_LIST, 1, 0, 0, 0, 0, 0, SMART_TARGET_CLOSEST_GAMEOBJECT, e.action.installTtemplate.param1, 10, 0, 0); @@ -1976,7 +1977,8 @@ void SmartScript::InstallTemplate(SmartScriptHolder const& e) } case SMARTAI_TEMPLATE_CAGED_GO_PART: { - if (!go) return; + if (!go) + return; //store hostage as id1 AddEvent(SMART_EVENT_GOSSIP_HELLO, 0, 0, 0, 0, 0, SMART_ACTION_STORE_TARGET_LIST, 1, 0, 0, 0, 0, 0, SMART_TARGET_CLOSEST_CREATURE, e.action.installTtemplate.param1, 10, 0, 0); //store invoker as id2 @@ -2839,8 +2841,12 @@ void SmartScript::InstallEvents() bool SmartScript::ConditionValid(Unit* u, int32 c, int32 v1, int32 v2, int32 v3) { - if (c == 0) return true; - if (!u || !u->ToPlayer()) return false; + if (c == 0) + return true; + + if (!u || !u->ToPlayer()) + return false; + Condition cond; cond.ConditionType = ConditionTypes(uint32(c)); cond.ConditionValue1 = uint32(v1); @@ -3007,7 +3013,9 @@ void SmartScript::OnMoveInLineOfSight(Unit* who) { ProcessEventsFor(SMART_EVENT_OOC_LOS, who); - if (!me) return; + if (!me) + return; + if (me->getVictim()) return; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index e3264adc310..b0f1fcb8ede 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -337,8 +337,11 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) if (e.GetScriptType() == SMART_SCRIPT_TYPE_TIMED_ACTIONLIST) { e.event.type = SMART_EVENT_UPDATE_OOC;//force default OOC, can change when calling the script! - if (!IsMinMaxValid(e, e.event.minMaxRepeat.min, e.event.minMaxRepeat.max)) return false; - if (!IsMinMaxValid(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax)) return false; + if (!IsMinMaxValid(e, e.event.minMaxRepeat.min, e.event.minMaxRepeat.max)) + return false; + + if (!IsMinMaxValid(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax)) + return false; } else { @@ -356,8 +359,11 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) case SMART_EVENT_DAMAGED: case SMART_EVENT_DAMAGED_TARGET: case SMART_EVENT_RECEIVE_HEAL: - if (!IsMinMaxValid(e, e.event.minMaxRepeat.min, e.event.minMaxRepeat.max)) return false; - if (!IsMinMaxValid(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax)) return false; + if (!IsMinMaxValid(e, e.event.minMaxRepeat.min, e.event.minMaxRepeat.max)) + return false; + + if (!IsMinMaxValid(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax)) + return false; break; case SMART_EVENT_SPELLHIT: case SMART_EVENT_SPELLHIT_TARGET: @@ -375,11 +381,13 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) return false; } } - if (!IsMinMaxValid(e, e.event.spellHit.cooldownMin, e.event.spellHit.cooldownMax)) return false; + if (!IsMinMaxValid(e, e.event.spellHit.cooldownMin, e.event.spellHit.cooldownMax)) + return false; break; case SMART_EVENT_OOC_LOS: case SMART_EVENT_IC_LOS: - if (!IsMinMaxValid(e, e.event.los.cooldownMin, e.event.los.cooldownMax)) return false; + if (!IsMinMaxValid(e, e.event.los.cooldownMin, e.event.los.cooldownMax)) + return false; break; case SMART_EVENT_RESPAWN: if (e.event.respawn.type == SMART_SCRIPT_RESPAWN_CONDITION_MAP && !sMapStore.LookupEntry(e.event.respawn.map)) @@ -394,32 +402,48 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) } break; case SMART_EVENT_FRIENDLY_HEALTH: - if (!NotNULL(e, e.event.friendlyHealt.radius)) return false; - if (!IsMinMaxValid(e, e.event.friendlyHealt.repeatMin, e.event.friendlyHealt.repeatMax)) return false; + if (!NotNULL(e, e.event.friendlyHealt.radius)) + return false; + + if (!IsMinMaxValid(e, e.event.friendlyHealt.repeatMin, e.event.friendlyHealt.repeatMax)) + return false; break; case SMART_EVENT_FRIENDLY_IS_CC: - if (!IsMinMaxValid(e, e.event.friendlyCC.repeatMin, e.event.friendlyCC.repeatMax)) return false; + if (!IsMinMaxValid(e, e.event.friendlyCC.repeatMin, e.event.friendlyCC.repeatMax)) + return false; break; case SMART_EVENT_FRIENDLY_MISSING_BUFF: { - if (!IsSpellValid(e, e.event.missingBuff.spell)) return false; - if (!NotNULL(e, e.event.missingBuff.radius)) return false; - if (!IsMinMaxValid(e, e.event.missingBuff.repeatMin, e.event.missingBuff.repeatMax)) return false; + if (!IsSpellValid(e, e.event.missingBuff.spell)) + return false; + + if (!NotNULL(e, e.event.missingBuff.radius)) + return false; + + if (!IsMinMaxValid(e, e.event.missingBuff.repeatMin, e.event.missingBuff.repeatMax)) + return false; break; } case SMART_EVENT_KILL: - if (!IsMinMaxValid(e, e.event.kill.cooldownMin, e.event.kill.cooldownMax)) return false; - if (e.event.kill.creature && !IsCreatureValid(e, e.event.kill.creature)) return false; + if (!IsMinMaxValid(e, e.event.kill.cooldownMin, e.event.kill.cooldownMax)) + return false; + + if (e.event.kill.creature && !IsCreatureValid(e, e.event.kill.creature)) + return false; break; case SMART_EVENT_TARGET_CASTING: case SMART_EVENT_PASSENGER_BOARDED: case SMART_EVENT_PASSENGER_REMOVED: - if (!IsMinMaxValid(e, e.event.minMax.repeatMin, e.event.minMax.repeatMax)) return false; + if (!IsMinMaxValid(e, e.event.minMax.repeatMin, e.event.minMax.repeatMax)) + return false; break; case SMART_EVENT_SUMMON_DESPAWNED: case SMART_EVENT_SUMMONED_UNIT: - if (e.event.summoned.creature && !IsCreatureValid(e, e.event.summoned.creature)) return false; - if (!IsMinMaxValid(e, e.event.summoned.cooldownMin, e.event.summoned.cooldownMax)) return false; + if (e.event.summoned.creature && !IsCreatureValid(e, e.event.summoned.creature)) + return false; + + if (!IsMinMaxValid(e, e.event.summoned.cooldownMin, e.event.summoned.cooldownMax)) + return false; break; case SMART_EVENT_ACCEPTED_QUEST: case SMART_EVENT_REWARD_QUEST: @@ -428,20 +452,27 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) break; case SMART_EVENT_RECEIVE_EMOTE: { - if (e.event.emote.emote && !IsTextEmoteValid(e, e.event.emote.emote)) return false; - if (!IsMinMaxValid(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax)) return false; + if (e.event.emote.emote && !IsTextEmoteValid(e, e.event.emote.emote)) + return false; + + if (!IsMinMaxValid(e, e.event.emote.cooldownMin, e.event.emote.cooldownMax)) + return false; break; } case SMART_EVENT_HAS_AURA: case SMART_EVENT_TARGET_BUFFED: { - if (!IsSpellValid(e, e.event.aura.spell)) return false; - if (!IsMinMaxValid(e, e.event.aura.repeatMin, e.event.aura.repeatMax)) return false; + if (!IsSpellValid(e, e.event.aura.spell)) + return false; + + if (!IsMinMaxValid(e, e.event.aura.repeatMin, e.event.aura.repeatMax)) + return false; break; } case SMART_EVENT_TRANSPORT_ADDCREATURE: { - if (e.event.transportAddCreature.creature && !IsCreatureValid(e, e.event.transportAddCreature.creature)) return false; + if (e.event.transportAddCreature.creature && !IsCreatureValid(e, e.event.transportAddCreature.creature)) + return false; break; } case SMART_EVENT_MOVEMENTINFORM: @@ -455,12 +486,14 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) } case SMART_EVENT_DATA_SET: { - if (!IsMinMaxValid(e, e.event.dataSet.cooldownMin, e.event.dataSet.cooldownMax)) return false; + if (!IsMinMaxValid(e, e.event.dataSet.cooldownMin, e.event.dataSet.cooldownMax)) + return false; break; } case SMART_EVENT_AREATRIGGER_ONTRIGGER: { - if (e.event.areatrigger.id && !IsAreaTriggerValid(e, e.event.areatrigger.id)) return false; + if (e.event.areatrigger.id && !IsAreaTriggerValid(e, e.event.areatrigger.id)) + return false; break; } case SMART_EVENT_TEXT_OVER: @@ -476,8 +509,11 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) break; } case SMART_EVENT_DUMMY_EFFECT: - if (!IsSpellValid(e, e.event.dummy.spell)) return false; - if (e.event.dummy.effIndex > EFFECT_2) return false; + if (!IsSpellValid(e, e.event.dummy.spell)) + return false; + + if (e.event.dummy.effIndex > EFFECT_2) + return false; break; case SMART_EVENT_IS_BEHIND_TARGET: if (!IsMinMaxValid(e, e.event.behindTarget.cooldownMin, e.event.behindTarget.cooldownMax)) @@ -574,11 +610,13 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) break; case SMART_ACTION_SET_EMOTE_STATE: case SMART_ACTION_PLAY_EMOTE: - if (!IsEmoteValid(e, e.action.emote.emote)) return false; + if (!IsEmoteValid(e, e.action.emote.emote)) + return false; break; case SMART_ACTION_FAIL_QUEST: case SMART_ACTION_ADD_QUEST: - if (!e.action.quest.quest || !IsQuestValid(e, e.action.quest.quest)) return false; + if (!e.action.quest.quest || !IsQuestValid(e, e.action.quest.quest)) + return false; break; case SMART_ACTION_ACTIVATE_TAXI: { @@ -590,17 +628,29 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) break; } case SMART_ACTION_RANDOM_EMOTE: - if (e.action.randomEmote.emote1 && !IsEmoteValid(e, e.action.randomEmote.emote1)) return false; - if (e.action.randomEmote.emote2 && !IsEmoteValid(e, e.action.randomEmote.emote2)) return false; - if (e.action.randomEmote.emote3 && !IsEmoteValid(e, e.action.randomEmote.emote3)) return false; - if (e.action.randomEmote.emote4 && !IsEmoteValid(e, e.action.randomEmote.emote4)) return false; - if (e.action.randomEmote.emote5 && !IsEmoteValid(e, e.action.randomEmote.emote5)) return false; - if (e.action.randomEmote.emote6 && !IsEmoteValid(e, e.action.randomEmote.emote6)) return false; + if (e.action.randomEmote.emote1 && !IsEmoteValid(e, e.action.randomEmote.emote1)) + return false; + + if (e.action.randomEmote.emote2 && !IsEmoteValid(e, e.action.randomEmote.emote2)) + return false; + + if (e.action.randomEmote.emote3 && !IsEmoteValid(e, e.action.randomEmote.emote3)) + return false; + + if (e.action.randomEmote.emote4 && !IsEmoteValid(e, e.action.randomEmote.emote4)) + return false; + + if (e.action.randomEmote.emote5 && !IsEmoteValid(e, e.action.randomEmote.emote5)) + return false; + + if (e.action.randomEmote.emote6 && !IsEmoteValid(e, e.action.randomEmote.emote6)) + return false; break; case SMART_ACTION_ADD_AURA: case SMART_ACTION_CAST: case SMART_ACTION_INVOKER_CAST: - if (!IsSpellValid(e, e.action.cast.spell)) return false; + if (!IsSpellValid(e, e.action.cast.spell)) + return false; break; case SMART_ACTION_CALL_AREAEXPLOREDOREVENTHAPPENS: case SMART_ACTION_CALL_GROUPEVENTHAPPENS: @@ -619,8 +669,11 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) } break; case SMART_ACTION_SEND_CASTCREATUREORGO: - if (!IsQuestValid(e, e.action.castCreatureOrGO.quest)) return false; - if (!IsSpellValid(e, e.action.castCreatureOrGO.spell)) return false; + if (!IsQuestValid(e, e.action.castCreatureOrGO.quest)) + return false; + + if (!IsSpellValid(e, e.action.castCreatureOrGO.spell)) + return false; break; @@ -644,11 +697,15 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) } break; case SMART_ACTION_CALL_CASTEDCREATUREORGO: - if (!IsCreatureValid(e, e.action.castedCreatureOrGO.creature)) return false; - if (!IsSpellValid(e, e.action.castedCreatureOrGO.spell)) return false; + if (!IsCreatureValid(e, e.action.castedCreatureOrGO.creature)) + return false; + + if (!IsSpellValid(e, e.action.castedCreatureOrGO.spell)) + return false; break; case SMART_ACTION_REMOVEAURASFROMSPELL: - if (!IsSpellValid(e, e.action.removeAura.spell)) return false; + if (!IsSpellValid(e, e.action.removeAura.spell)) + return false; break; case SMART_ACTION_RANDOM_PHASE: { @@ -672,11 +729,13 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u attempts to set invalid phase, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType()); return false; } - if (!IsMinMaxValid(e, e.action.randomPhaseRange.phaseMin, e.action.randomPhaseRange.phaseMax)) return false; + if (!IsMinMaxValid(e, e.action.randomPhaseRange.phaseMin, e.action.randomPhaseRange.phaseMax)) + return false; break; } case SMART_ACTION_SUMMON_CREATURE: - if (!IsCreatureValid(e, e.action.summonCreature.creature)) return false; + if (!IsCreatureValid(e, e.action.summonCreature.creature)) + return false; if (e.action.summonCreature.type < TEMPSUMMON_TIMED_OR_DEAD_DESPAWN || e.action.summonCreature.type > TEMPSUMMON_MANUAL_DESPAWN) { sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses incorrect TempSummonType %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.action.summonCreature.type); @@ -684,10 +743,12 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) } break; case SMART_ACTION_CALL_KILLEDMONSTER: - if (!IsCreatureValid(e, e.action.killedMonster.creature)) return false; + if (!IsCreatureValid(e, e.action.killedMonster.creature)) + return false; break; case SMART_ACTION_UPDATE_TEMPLATE: - if (e.action.updateTemplate.creature && !IsCreatureValid(e, e.action.updateTemplate.creature)) return false; + if (e.action.updateTemplate.creature && !IsCreatureValid(e, e.action.updateTemplate.creature)) + return false; break; case SMART_ACTION_SET_SHEATH: if (e.action.setSheath.sheath && e.action.setSheath.sheath >= MAX_SHEATH_STATE) @@ -706,12 +767,16 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) break; } case SMART_ACTION_SUMMON_GO: - if (!IsGameObjectValid(e, e.action.summonGO.entry)) return false; + if (!IsGameObjectValid(e, e.action.summonGO.entry)) + return false; break; case SMART_ACTION_ADD_ITEM: case SMART_ACTION_REMOVE_ITEM: - if (!IsItemValid(e, e.action.item.entry)) return false; - if (!NotNULL(e, e.action.item.count)) return false; + if (!IsItemValid(e, e.action.item.entry)) + return false; + + if (!NotNULL(e, e.action.item.count)) + return false; break; case SMART_ACTION_TELEPORT: if (!sMapStore.LookupEntry(e.action.teleport.mapID)) @@ -728,7 +793,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) } break; case SMART_ACTION_WP_STOP: - if (e.action.wpStop.quest && !IsQuestValid(e, e.action.wpStop.quest)) return false; + if (e.action.wpStop.quest && !IsQuestValid(e, e.action.wpStop.quest)) + return false; break; case SMART_ACTION_WP_START: { @@ -737,7 +803,8 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) sLog->outErrorDb("SmartAIMgr: Creature %d Event %u Action %u uses non-existent WaypointPath id %u, skipped.", e.entryOrGuid, e.event_id, e.GetActionType(), e.action.wpStart.pathID); return false; } - if (e.action.wpStart.quest && !IsQuestValid(e, e.action.wpStart.quest)) return false; + if (e.action.wpStart.quest && !IsQuestValid(e, e.action.wpStart.quest)) + return false; if (e.action.wpStart.reactState > REACT_AGGRESSIVE) { sLog->outErrorDb("SmartAIMgr: Creature %d Event %u Action %u uses invalid React State %u, skipped.", e.entryOrGuid, e.event_id, e.GetActionType(), e.action.wpStart.reactState); @@ -747,8 +814,11 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) } case SMART_ACTION_CREATE_TIMED_EVENT: { - if (!IsMinMaxValid(e, e.action.timeEvent.min, e.action.timeEvent.max)) return false; - if (!IsMinMaxValid(e, e.action.timeEvent.repeatMin, e.action.timeEvent.repeatMax)) return false; + if (!IsMinMaxValid(e, e.action.timeEvent.min, e.action.timeEvent.max)) + return false; + + if (!IsMinMaxValid(e, e.action.timeEvent.repeatMin, e.action.timeEvent.repeatMax)) + return false; break; } case SMART_ACTION_FOLLOW: diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 36da0e9a97e..1a5f3412459 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -21,7 +21,6 @@ #include "ArenaTeamMgr.h" #include "World.h" #include "WorldPacket.h" - #include "ArenaTeam.h" #include "Battleground.h" #include "BattlegroundMgr.h" @@ -259,9 +258,7 @@ void Battleground::Update(uint32 diff) { case STATUS_WAIT_JOIN: if (GetPlayersSize()) - { _ProcessJoin(diff); - } break; case STATUS_IN_PROGRESS: _ProcessOfflineQueue(); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index b864376e3a6..d2cbab2be54 100755 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -1481,7 +1481,7 @@ void BattlegroundAV::ResetBGSubclass() { for (uint8 j=0; j<9; j++) m_Team_QuestStatus[i][j]=0; - m_Team_Scores[i]=BG_AV_SCORE_INITIAL_POINTS; + m_Team_Scores[i]=BG_AV_SCORE_INITIAL_POINTS; m_IsInformedNearVictory[i]=false; m_CaptainAlive[i] = true; m_CaptainBuffTimer[i] = 120000 + urand(0, 4)* 60; //as far as i could see, the buff is randomly so i make 2minutes (thats the duration of the buff itself) + 0-4minutes TODO get the right times @@ -1502,7 +1502,6 @@ void BattlegroundAV::ResetBGSubclass() for (uint16 i = 0; i < AV_CPLACE_MAX+AV_STATICCPLACE_MAX; i++) if (BgCreatures[i]) DelCreature(i); - } bool BattlegroundAV::IsBothMinesControlledByTeam(uint32 team) const @@ -1562,4 +1561,4 @@ bool BattlegroundAV::IsAllTowersControlledAndCaptainAlive(uint32 team) const } return false; -}
\ No newline at end of file +} diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index dff0efd5197..f100d391698 100755 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -338,7 +338,9 @@ struct VendorItemData VendorItem* GetItem(uint32 slot) const { - if (slot >= m_items.size()) return NULL; + if (slot >= m_items.size()) + return NULL; + return m_items[slot]; } bool Empty() const { return m_items.empty(); } diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 910e9c86b42..1fe83023976 100755 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -840,7 +840,9 @@ bool GameObject::IsTransport() const { // If something is marked as a transport, don't transmit an out of range packet for it. GameObjectTemplate const* gInfo = GetGOInfo(); - if (!gInfo) return false; + if (!gInfo) + return false; + return gInfo->type == GAMEOBJECT_TYPE_TRANSPORT || gInfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT; } @@ -849,7 +851,9 @@ bool GameObject::IsDynTransport() const { // If something is marked as a transport, don't transmit an out of range packet for it. GameObjectTemplate const* gInfo = GetGOInfo(); - if (!gInfo) return false; + if (!gInfo) + return false; + return gInfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT || (gInfo->type == GAMEOBJECT_TYPE_TRANSPORT && !gInfo->transport.pause); } diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index bde8780e78f..a8035043543 100755 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -730,7 +730,9 @@ class GameObject : public WorldObject, public GridObject<GameObject> bool IsInSkillupList(uint32 PlayerGuidLow) const { for (std::list<uint32>::const_iterator i = m_SkillupList.begin(); i != m_SkillupList.end(); ++i) - if (*i == PlayerGuidLow) return true; + if (*i == PlayerGuidLow) + return true; + return false; } void ClearSkillupList() { m_SkillupList.clear(); } diff --git a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp index 0236e9450f5..ee809243107 100755 --- a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp +++ b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp @@ -102,7 +102,8 @@ uint32 GetItemEnchantMod(int32 entry) { fCount += ench_iter->chance; - if (fCount > dRoll) return ench_iter->ench; + if (fCount > dRoll) + return ench_iter->ench; } //we could get here only if sum of all enchantment chances is lower than 100% @@ -113,7 +114,8 @@ uint32 GetItemEnchantMod(int32 entry) { fCount += ench_iter->chance; - if (fCount > dRoll) return ench_iter->ench; + if (fCount > dRoll) + return ench_iter->ench; } return 0; diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index fe89a346911..2291675c36d 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1457,7 +1457,9 @@ void Position::GetPositionOffsetTo(const Position & endPos, Position & retOffset float Position::GetAngle(const Position* obj) const { - if (!obj) return 0; + if (!obj) + return 0; + return GetAngle(obj->GetPositionX(), obj->GetPositionY()); } diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 972be794464..f6bd31f7dc6 100755 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -227,7 +227,9 @@ class Object bool HasFlag(uint16 index, uint32 flag) const { - if (index >= m_valuesCount && !PrintIndexError(index, false)) return false; + if (index >= m_valuesCount && !PrintIndexError(index, false)) + return false; + return (m_uint32Values[index] & flag) != 0; } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index a0aad893893..f25d90855d4 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -23259,7 +23259,8 @@ void Player::SendCorpseReclaimDelay(bool load) else delay = GetCorpseReclaimDelay(pvp); - if (!delay) return; + if (!delay) + return; //! corpse reclaim delay 30 * 1000ms or longer at often deaths WorldPacket data(SMSG_CORPSE_RECLAIM_DELAY, 4); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 80b6ddbbf56..30be1a854d0 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -457,7 +457,8 @@ void Unit::resetAttackTimer(WeaponAttackType type) bool Unit::IsWithinCombatRange(const Unit* obj, float dist2compare) const { - if (!obj || !IsInMap(obj)) return false; + if (!obj || !IsInMap(obj)) + return false; float dx = GetPositionX() - obj->GetPositionX(); float dy = GetPositionY() - obj->GetPositionY(); @@ -472,7 +473,8 @@ bool Unit::IsWithinCombatRange(const Unit* obj, float dist2compare) const bool Unit::IsWithinMeleeRange(const Unit* obj, float dist) const { - if (!obj || !IsInMap(obj)) return false; + if (!obj || !IsInMap(obj)) + return false; float dx = GetPositionX() - obj->GetPositionX(); float dy = GetPositionY() - obj->GetPositionY(); @@ -2878,7 +2880,8 @@ void Unit::SetCurrentCastedSpell(Spell* pSpell) CurrentSpellTypes CSpellType = pSpell->GetCurrentContainer(); - if (pSpell == m_currentSpells[CSpellType]) return; // avoid breaking self + if (pSpell == m_currentSpells[CSpellType]) // avoid breaking self + return; // break same type spell if it is not delayed InterruptSpell(CSpellType, false); @@ -4619,7 +4622,9 @@ GameObject* Unit::GetGameObject(uint32 spellId) const void Unit::AddGameObject(GameObject* gameObj) { - if (!gameObj || !gameObj->GetOwnerGUID() == 0) return; + if (!gameObj || !gameObj->GetOwnerGUID() == 0) + return; + m_gameObj.push_back(gameObj); gameObj->SetOwnerGUID(GetGUID()); @@ -11879,7 +11884,9 @@ float Unit::GetWeaponProcChance() const float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM, const SpellInfo* spellProto) const { // proc per minute chance calculation - if (PPM <= 0) return 0.0f; + if (PPM <= 0) + return 0.0f; + // Apply chance modifer aura if (spellProto) if (Player* modOwner = GetSpellModOwner()) diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index d8107576ee4..aab1fc96521 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -8598,10 +8598,13 @@ uint32 ObjectMgr::GetScriptId(const char *name) { // use binary search to find the script name in the sorted vector // assume "" is the first element - if (!name) return 0; - ScriptNameContainer::const_iterator itr = - std::lower_bound(_scriptNamesStore.begin(), _scriptNamesStore.end(), name); - if (itr == _scriptNamesStore.end() || *itr != name) return 0; + if (!name) + return 0; + + ScriptNameContainer::const_iterator itr = std::lower_bound(_scriptNamesStore.begin(), _scriptNamesStore.end(), name); + if (itr == _scriptNamesStore.end() || *itr != name) + return 0; + return uint32(itr - _scriptNamesStore.begin()); } @@ -8610,6 +8613,7 @@ void ObjectMgr::CheckScripts(ScriptsType type, std::set<int32>& ids) ScriptMapMap* scripts = GetScriptsMapByType(type); if (!scripts) return; + for (ScriptMapMap::const_iterator itrMM = scripts->begin(); itrMM != scripts->end(); ++itrMM) { for (ScriptMap::const_iterator itrM = itrMM->second.begin(); itrM != itrMM->second.end(); ++itrM) diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index 637025c7d9e..de8dc2b90f6 100755 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -248,8 +248,9 @@ void WorldSession::HandleGroupDeclineOpcode(WorldPacket & /*recv_data*/) { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_GROUP_DECLINE"); - Group *group = GetPlayer()->GetGroupInvite(); - if (!group) return; + Group* group = GetPlayer()->GetGroupInvite(); + if (!group) + return; // Remember leader if online (group pointer will be invalid if group gets disbanded) Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID()); diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index c977a967162..7efd600baa8 100755 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -512,7 +512,9 @@ QuestItemList* Loot::FillFFALoot(Player* player) QuestItemList* Loot::FillQuestLoot(Player* player) { - if (items.size() == MAX_NR_LOOT_ITEMS) return NULL; + if (items.size() == MAX_NR_LOOT_ITEMS) + return NULL; + QuestItemList* ql = new QuestItemList(); for (uint8 i = 0; i < quest_items.size(); ++i) diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index d0f99610262..766e3d23f93 100755 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -245,8 +245,12 @@ class Map : public GridRefManager<NGridType> // currently unused for normal maps bool CanUnload(uint32 diff) { - if (!m_unloadTimer) return false; - if (m_unloadTimer <= diff) return true; + if (!m_unloadTimer) + return false; + + if (m_unloadTimer <= diff) + return true; + m_unloadTimer -= diff; return false; } diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 312b79e3e7a..52a2f1f9da8 100755 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -6262,9 +6262,12 @@ SpellCastResult Spell::CheckItems() case SPELL_EFFECT_WEAPON_DAMAGE: case SPELL_EFFECT_WEAPON_DAMAGE_NOSCHOOL: { - if (m_caster->GetTypeId() != TYPEID_PLAYER) return SPELL_FAILED_TARGET_NOT_PLAYER; + if (m_caster->GetTypeId() != TYPEID_PLAYER) + return SPELL_FAILED_TARGET_NOT_PLAYER; + if (m_attackType != RANGED_ATTACK) break; + Item* pItem = m_caster->ToPlayer()->GetWeaponForAttack(m_attackType); if (!pItem || pItem->IsBroken()) return SPELL_FAILED_EQUIPPED_ITEM; @@ -6276,7 +6279,8 @@ SpellCastResult Spell::CheckItems() uint32 ammo = pItem->GetEntry(); if (!m_caster->ToPlayer()->HasItemCount(ammo, 1)) return SPELL_FAILED_NO_AMMO; - }; break; + }; + break; case ITEM_SUBCLASS_WEAPON_GUN: case ITEM_SUBCLASS_WEAPON_BOW: case ITEM_SUBCLASS_WEAPON_CROSSBOW: diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 2330461256b..37d79225169 100755 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -1140,11 +1140,6 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 return true; } -void SpellMgr::LoadSpellInfos() -{ - -} - void SpellMgr::LoadSpellRanks() { uint32 oldMSTime = getMSTime(); @@ -1160,13 +1155,12 @@ void SpellMgr::LoadSpellRanks() if (!result) { - sLog->outString(">> Loaded 0 spell rank records"); + sLog->outString(">> Loaded 0 spell rank records. DB table `spell_ranks` is empty."); sLog->outString(); - sLog->outErrorDb("`spell_ranks` table is empty!"); return; } - uint32 rows = 0; + uint32 count = 0; bool finished = false; do @@ -1237,7 +1231,7 @@ void SpellMgr::LoadSpellRanks() std::list<std::pair<int32, int32> >::iterator itr = rankChain.begin(); do { - ++rows; + ++count; int32 addedSpell = itr->first; mSpellChains[addedSpell].first = GetSpellInfo(lastSpell); mSpellChains[addedSpell].last = GetSpellInfo(rankChain.back().first); @@ -1257,7 +1251,7 @@ void SpellMgr::LoadSpellRanks() while (true); } while (!finished); - sLog->outString(">> Loaded %u spell rank records in %u ms", rows, GetMSTimeDiffToNow(oldMSTime)); + sLog->outString(">> Loaded %u spell rank records in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); sLog->outString(); } @@ -1273,19 +1267,19 @@ void SpellMgr::LoadSpellRequired() if (!result) { - sLog->outString(">> Loaded 0 spell required records"); + sLog->outString(">> Loaded 0 spell required records. DB table `spell_required` is empty."); sLog->outString(); - sLog->outErrorDb("`spell_required` table is empty!"); return; } - uint32 rows = 0; + uint32 count = 0; do { Field* fields = result->Fetch(); uint32 spell_id = fields[0].GetUInt32(); uint32 spell_req = fields[1].GetUInt32(); + // check if chain is made with valid first spell SpellInfo const* spell = GetSpellInfo(spell_id); if (!spell) @@ -1293,17 +1287,20 @@ void SpellMgr::LoadSpellRequired() sLog->outErrorDb("spell_id %u in `spell_required` table is not found in dbcs, skipped", spell_id); continue; } + SpellInfo const* req_spell = GetSpellInfo(spell_req); if (!req_spell) { sLog->outErrorDb("req_spell %u in `spell_required` table is not found in dbcs, skipped", spell_req); continue; } + if (GetFirstSpellInChain(spell_id) == GetFirstSpellInChain(spell_req)) { sLog->outErrorDb("req_spell %u and spell_id %u in `spell_required` table are ranks of the same spell, entry not needed, skipped", spell_req, spell_id); continue; } + if (IsSpellRequiringSpell(spell_id, spell_req)) { sLog->outErrorDb("duplicated entry of req_spell %u and spell_id %u in `spell_required`, skipped", spell_req, spell_id); @@ -1312,10 +1309,10 @@ void SpellMgr::LoadSpellRequired() mSpellReq.insert (std::pair<uint32, uint32>(spell_id, spell_req)); mSpellsReqSpell.insert (std::pair<uint32, uint32>(spell_req, spell_id)); - ++rows; + ++count; } while (result->NextRow()); - sLog->outString(">> Loaded %u spell required records in %u ms", rows, GetMSTimeDiffToNow(oldMSTime)); + sLog->outString(">> Loaded %u spell required records in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); sLog->outString(); } @@ -1367,14 +1364,12 @@ void SpellMgr::LoadSpellLearnSpells() QueryResult result = WorldDatabase.Query("SELECT entry, SpellID, Active FROM spell_learn_spell"); if (!result) { - sLog->outString(">> Loaded 0 spell learn spells"); + sLog->outString(">> Loaded 0 spell learn spells. DB table `spell_learn_spell` is empty."); sLog->outString(); - sLog->outErrorDb("`spell_learn_spell` table is empty!"); return; } uint32 count = 0; - do { Field* fields = result->Fetch(); @@ -1382,9 +1377,9 @@ void SpellMgr::LoadSpellLearnSpells() uint32 spell_id = fields[0].GetUInt16(); SpellLearnSpellNode node; - node.spell = fields[1].GetUInt16(); - node.active = fields[2].GetBool(); - node.autoLearned= false; + node.spell = fields[1].GetUInt16(); + node.active = fields[2].GetBool(); + node.autoLearned = false; if (!GetSpellInfo(spell_id)) { @@ -1478,7 +1473,6 @@ void SpellMgr::LoadSpellTargetPositions() } uint32 count = 0; - do { Field* fields = result->Fetch(); @@ -1590,19 +1584,17 @@ void SpellMgr::LoadSpellGroups() mSpellSpellGroup.clear(); // need for reload case mSpellGroupSpell.clear(); - uint32 count = 0; - // 0 1 QueryResult result = WorldDatabase.Query("SELECT id, spell_id FROM spell_group"); if (!result) { + sLog->outString(">> Loaded 0 spell group definitions. DB table `spell_group` is empty."); sLog->outString(); - sLog->outString(">> Loaded %u spell group definitions", count); return; } std::set<uint32> groups; - + uint32 count = 0; do { Field* fields = result->Fetch(); @@ -1673,17 +1665,16 @@ void SpellMgr::LoadSpellGroupStackRules() mSpellGroupStack.clear(); // need for reload case - uint32 count = 0; - // 0 1 QueryResult result = WorldDatabase.Query("SELECT group_id, stack_rule FROM spell_group_stack_rules"); if (!result) { - sLog->outString(">> Loaded 0 spell group stack rules"); + sLog->outString(">> Loaded 0 spell group stack rules. DB table `spell_group_stack_rules` is empty."); sLog->outString(); return; } + uint32 count = 0; do { Field* fields = result->Fetch(); @@ -1719,17 +1710,16 @@ void SpellMgr::LoadSpellProcEvents() mSpellProcEventMap.clear(); // need for reload case - uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 9 10 QueryResult result = WorldDatabase.Query("SELECT entry, SchoolMask, SpellFamilyName, SpellFamilyMask0, SpellFamilyMask1, SpellFamilyMask2, procFlags, procEx, ppmRate, CustomChance, Cooldown FROM spell_proc_event"); if (!result) { - sLog->outString(">> Loaded %u spell proc event conditions", count); + sLog->outString(">> Loaded 0 spell proc event conditions. DB table `spell_proc_event` is empty."); sLog->outString(); return; } + uint32 count = 0; uint32 customProc = 0; do { @@ -1784,17 +1774,16 @@ void SpellMgr::LoadSpellProcs() mSpellProcMap.clear(); // need for reload case - uint32 count = 0; - // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 QueryResult result = WorldDatabase.Query("SELECT spellId, schoolMask, spellFamilyName, spellFamilyMask0, spellFamilyMask1, spellFamilyMask2, typeMask, spellTypeMask, spellPhaseMask, hitMask, attributesMask, ratePerMinute, chance, cooldown, charges FROM spell_proc"); if (!result) { - sLog->outString(">> Loaded %u spell proc conditions and data", count); + sLog->outString(">> Loaded 0 spell proc conditions and data. DB table `spell_proc` is empty."); sLog->outString(); return; } + uint32 count = 0; do { Field* fields = result->Fetch(); @@ -1925,16 +1914,17 @@ void SpellMgr::LoadSpellBonusess() uint32 oldMSTime = getMSTime(); mSpellBonusMap.clear(); // need for reload case - uint32 count = 0; + // 0 1 2 3 4 QueryResult result = WorldDatabase.Query("SELECT entry, direct_bonus, dot_bonus, ap_bonus, ap_dot_bonus FROM spell_bonus_data"); if (!result) { - sLog->outString(">> Loaded %u spell bonus data", count); + sLog->outString(">> Loaded 0 spell bonus data. DB table `spell_bonus_data` is empty."); sLog->outString(); return; } + uint32 count = 0; do { Field* fields = result->Fetch(); @@ -1966,17 +1956,16 @@ void SpellMgr::LoadSpellThreats() mSpellThreatMap.clear(); // need for reload case - uint32 count = 0; - // 0 1 2 3 QueryResult result = WorldDatabase.Query("SELECT entry, flatMod, pctMod, apPctMod FROM spell_threat"); if (!result) { - sLog->outString(">> Loaded 0 aggro generating spells"); + sLog->outString(">> Loaded 0 aggro generating spells. DB table `spell_threat` is empty."); sLog->outString(); return; } + uint32 count = 0; do { Field* fields = result->Fetch(); @@ -2040,7 +2029,6 @@ void SpellMgr::LoadSpellPetAuras() } uint32 count = 0; - do { Field* fields = result->Fetch(); @@ -2095,11 +2083,10 @@ void SpellMgr::LoadEnchantCustomAttr() uint32 size = sSpellItemEnchantmentStore.GetNumRows(); mEnchantCustomAttr.resize(size); - uint32 count = 0; - for (uint32 i = 0; i < size; ++i) mEnchantCustomAttr[i] = 0; + uint32 count = 0; for (uint32 i = 0; i < GetSpellInfoStoreSize(); ++i) { SpellInfo const* spellInfo = GetSpellInfo(i); @@ -2135,17 +2122,16 @@ void SpellMgr::LoadSpellEnchantProcData() mSpellEnchantProcEventMap.clear(); // need for reload case - uint32 count = 0; - // 0 1 2 3 QueryResult result = WorldDatabase.Query("SELECT entry, customChance, PPMChance, procEx FROM spell_enchant_proc_data"); if (!result) { - sLog->outString(">> Loaded %u spell enchant proc event conditions", count); + sLog->outString(">> Loaded 0 spell enchant proc event conditions. DB table `spell_enchant_proc_data` is empty."); sLog->outString(); return; } + uint32 count = 0; do { Field* fields = result->Fetch(); @@ -2190,7 +2176,6 @@ void SpellMgr::LoadSpellLinked() } uint32 count = 0; - do { Field* fields = result->Fetch(); @@ -2435,7 +2420,6 @@ void SpellMgr::LoadSpellAreas() } uint32 count = 0; - do { Field* fields = result->Fetch(); diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index 9fffd474651..521070f7879 100755 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -693,7 +693,6 @@ class SpellMgr public: // Loading data at server startup - void LoadSpellInfos(); void LoadSpellRanks(); void LoadSpellRequired(); void LoadSpellLearnSkills(); |