diff options
author | Blaymoira <none@none> | 2009-01-24 20:04:43 +0100 |
---|---|---|
committer | Blaymoira <none@none> | 2009-01-24 20:04:43 +0100 |
commit | 6be2cfeeed14bbacaa19382485a7ef4fc739abcb (patch) | |
tree | cf172c69609e8488db2515c93bf847039f254386 /src | |
parent | 3129217dfad51525498b02a737b49de19e2c5ee5 (diff) |
*Moved CanUnload function to header files - by Zor
*Move flycheck under function - by Zor
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Map.cpp | 8 | ||||
-rw-r--r-- | src/game/Map.h | 10 | ||||
-rw-r--r-- | src/game/Player.cpp | 55 | ||||
-rw-r--r-- | src/game/Player.h | 4 | ||||
-rw-r--r-- | src/game/Spell.cpp | 27 |
5 files changed, 68 insertions, 36 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp index bef251bd880..7bf4c3fa83e 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -1642,14 +1642,6 @@ void Map::RemoveAllObjectsInRemoveList() //sLog.outDebug("Object remover 2 check."); } -bool Map::CanUnload(const uint32 &diff) -{ - if(!m_unloadTimer) return false; - if(m_unloadTimer < diff) return true; - m_unloadTimer -= diff; - return false; -} - uint32 Map::GetPlayersCountExceptGMs() const { uint32 count = 0; diff --git a/src/game/Map.h b/src/game/Map.h index 9c06ac3fa47..bcdf3ec8f6a 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -133,7 +133,15 @@ class TRINITY_DLL_SPEC Map : public GridRefManager<NGridType>, public Trinity::O virtual ~Map(); // currently unused for normal maps - virtual bool CanUnload(const uint32& diff); + bool CanUnload(uint32 diff) + { + if(!m_unloadTimer) + return false; + if(m_unloadTimer <= diff) + return true; + m_unloadTimer -= diff; + return false; + } virtual bool Add(Player *); virtual void Remove(Player *, bool); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 405d2a72c4f..533b9e68ac2 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -18753,8 +18753,7 @@ void Player::SetClientControl(Unit* target, uint8 allowMove) void Player::UpdateZoneDependentAuras( uint32 newZone ) { // remove new continent flight forms - if( !isGameMaster() && - GetVirtualMapForMapAndZone(GetMapId(),newZone) != 530) + if(!CanFlyInMap(GetVirtualMapForMapAndZone(GetMapId(),newZone))) { RemoveSpellsCausingAura(SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED); RemoveSpellsCausingAura(SPELL_AURA_FLY); @@ -19219,3 +19218,55 @@ void Player::UpdateCharmedAI() Attack(target, true); } } + +bool Player::CanFlyInMap(const uint32 mapID) const +{ + // we return false if the map doesn't even exist + MapEntry const *entry = sMapStore.LookupEntry(mapID); + if(!entry) + { + sLog.outDebug("Unknown mapID handed to Player::CanFlyInMap; disallowing flying."); + return false; + } + + // GMs can always fly + if( isGameMaster() ) + { + return true; + } + + // check whether we can fly here depending on map/config + switch(mapID) + { + // kalimdor/eastern kingdoms + case 0: + case 1: + { + return sWorld.getConfig(CONFIG_FLYING_MOUNTS_AZEROTH); + } + // outland + case 530: + { + return sWorld.getConfig(CONFIG_FLYING_MOUNTS_OUTLAND); + } + // all other maps + default: + { + return sWorld.getConfig(CONFIG_FLYING_MOUNTS_OTHERS); + } + } +} + +// this is just a dummy function that does the same as CanFlyInMap, but based on area ID +bool Player::CanFlyInArea(const uint32 areaID) const +{ + // we return false if the area doesn't even exist + AreaTableEntry const *entry = sAreaStore.LookupEntry(areaID); + if(!entry) + { + sLog.outDebug("Unknown areaID handed to Player::CanFlyInArea; disallowing flying."); + return false; + } + + return CanFlyInMap(entry->mapid); +} diff --git a/src/game/Player.h b/src/game/Player.h index cdf2005f111..90a0f29ab81 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -2036,6 +2036,10 @@ class TRINITY_DLL_SPEC Player : public Unit uint32 GetOldPetSpell() const { return m_oldpetspell; } void SetOldPetSpell(uint32 petspell) { m_oldpetspell = petspell; } + // check if player can fly in map/area according to config + bool CanFlyInMap(const uint32 mapID) const; + bool CanFlyInArea(const uint32 areaID) const; + /*********************************************************/ /*** INSTANCE SYSTEM ***/ /*********************************************************/ diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index f6b326b17d9..fb5662bfd7b 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4172,34 +4172,11 @@ uint8 Spell::CanCast(bool strict) case SPELL_AURA_MOD_INCREASE_FLIGHT_SPEED: case SPELL_AURA_FLY: { - // not allow cast fly spells at old maps by players (all spells is self target) if(m_caster->GetTypeId()==TYPEID_PLAYER) { - if(!((Player*)m_caster)->isGameMaster()) - { - uint32 v_map = GetVirtualMapForMapAndZone(m_caster->GetMapId(),m_caster->GetZoneId()); - switch(v_map) - { - case 0: - case 1: - { - if (!sWorld.getConfig(CONFIG_FLYING_MOUNTS_AZEROTH)) - return SPELL_FAILED_NOT_HERE; - } break; - case 530: - { - if (!sWorld.getConfig(CONFIG_FLYING_MOUNTS_OUTLAND)) - return SPELL_FAILED_NOT_HERE; - } break; - default: - { - if (!sWorld.getConfig(CONFIG_FLYING_MOUNTS_OTHERS)) - return SPELL_FAILED_NOT_HERE; - } break; - } - } + if(!((Player*)m_caster)->CanFlyInMap(GetVirtualMapForMapAndZone(m_caster->GetMapId(),m_caster->GetZoneId()))) + return SPELL_FAILED_NOT_HERE; } - break; } case SPELL_AURA_PERIODIC_MANA_LEECH: |