[8831] Helper function add and move for diffficulties.

* Use regular naming for 0 spwanmode/difficulty for clean consistence names (used at well known wiki)
* Move difficulty related data access from InstancedMap to Map class.
This commit is contained in:
VladimirMangos 2009-11-19 03:01:35 +03:00
parent fe1fae46ee
commit 398ca010ca
6 changed files with 33 additions and 30 deletions

View file

@ -923,7 +923,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui
continue;
//FIXME: work only for instances where max==min for players
if(((InstanceMap*)map)->GetMaxPlayers() != achievementCriteria->death_in_dungeon.manLimit)
if (map->GetMaxPlayers() != achievementCriteria->death_in_dungeon.manLimit)
continue;
SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE);
break;

View file

@ -234,7 +234,7 @@ enum AreaFlags
enum Difficulty
{
DIFFICULTY_DEFAULT = 0,
REGULAR_DEFAULT = 0,
DUNGEON_DIFFICULTY_NORMAL = 0,
DUNGEON_DIFFICULTY_HEROIC = 1,
@ -251,7 +251,7 @@ enum Difficulty
enum SpawnMask
{
SPAWNMASK_CONTINENT = (1 << DIFFICULTY_DEFAULT),// any any maps without spawn modes
SPAWNMASK_REGULAR = (1 << REGULAR_DEFAULT), // any any maps without spawn modes (continents/subway) or in minimal spawnmode
SPAWNMASK_DUNGEON_NORMAL = (1 << DUNGEON_DIFFICULTY_NORMAL),
SPAWNMASK_DUNGEON_HEROIC = (1 << DUNGEON_DIFFICULTY_HEROIC),

View file

@ -1127,6 +1127,23 @@ void Map::UnloadAll(bool pForce)
}
}
MapDifficulty const* Map::GetMapDifficulty() const
{
return GetMapDifficultyData(GetId(),GetDifficulty());
}
uint32 Map::GetMaxPlayers() const
{
MapDifficulty const* mapDiff = GetMapDifficulty();
return mapDiff ? mapDiff->maxPlayers : 0;
}
uint32 Map::GetMaxResetDelay() const
{
MapDifficulty const* mapDiff = GetMapDifficulty();
return mapDiff ? mapDiff->resetTime : 0;
}
//*****************************
// Grid function
//*****************************
@ -2618,24 +2635,6 @@ void InstanceMap::SetResetSchedule(bool on)
}
}
MapDifficulty const* InstanceMap::GetMapDifficulty() const
{
return GetMapDifficultyData(GetId(),GetDifficulty());
}
uint32 InstanceMap::GetMaxPlayers() const
{
MapDifficulty const* mapDiff = GetMapDifficulty();
return mapDiff ? mapDiff->maxPlayers : 0;
}
uint32 InstanceMap::GetMaxResetDelay() const
{
MapDifficulty const* mapDiff = GetMapDifficulty();
return mapDiff ? mapDiff->resetTime : 0;
}
/* ******* Battleground Instance Maps ******* */
BattleGroundMap::BattleGroundMap(uint32 id, time_t expiry, uint32 InstanceId, Map* _parent, uint8 spawnMode)

View file

@ -362,10 +362,20 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
bool CheckGridIntegrity(Creature* c, bool moved) const;
uint32 GetInstanceId() const { return i_InstanceId; }
uint8 GetSpawnMode() const { return (i_spawnMode); }
virtual bool CanEnter(Player* /*player*/) { return true; }
const char* GetMapName() const;
// have meaning only for instanced map (that have set real difficulty), NOT USE its for BaseMap
// _currently_ spawnmode == difficulty, but this can be changes later, so use appropriate spawmmode/difficult functions
// for simplify later code support
// regular difficulty = continent/dungeon normal/first raid normal difficulty
uint8 GetSpawnMode() const { return (i_spawnMode); }
Difficulty GetDifficulty() const { return Difficulty(GetSpawnMode()); }
bool IsRegularDifficulty() const { return GetDifficulty() == REGULAR_DEFAULT; }
uint32 GetMaxPlayers() const; // dependent from map difficulty
uint32 GetMaxResetDelay() const; // dependent from map difficulty
MapDifficulty const* GetMapDifficulty() const; // dependent from map difficulty
bool Instanceable() const { return i_mapEntry && i_mapEntry->Instanceable(); }
// NOTE: this duplicate of Instanceable(), but Instanceable() can be changed when BG also will be instanceable
bool IsDungeon() const { return i_mapEntry && i_mapEntry->IsDungeon(); }
@ -597,12 +607,6 @@ class MANGOS_DLL_SPEC InstanceMap : public Map
void SendResetWarnings(uint32 timeLeft) const;
void SetResetSchedule(bool on);
// have meaning only for instanced map (that have set real difficulty)
Difficulty GetDifficulty() const { return Difficulty(GetSpawnMode()); }
uint32 GetMaxPlayers() const;
uint32 GetMaxResetDelay() const;
MapDifficulty const* GetMapDifficulty() const;
virtual void InitVisibilityDistance();
private:
bool m_resetAfterUnload;

View file

@ -2319,7 +2319,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
{
if (m_target->GetMap()->IsDungeon())
{
uint32 spellId = ((InstanceMap*)m_target->GetMap())->GetDifficulty() == DIFFICULTY_DEFAULT ? 44190 : 46163;
uint32 spellId = m_target->GetMap()->IsRegularDifficulty() ? 44190 : 46163;
m_target->CastSpell(m_target, spellId, true, NULL, this);
}

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8830"
#define REVISION_NR "8831"
#endif // __REVISION_NR_H__