Skip to content

Commit

Permalink
[12148] Improve AreaTrigger teleport requirement checks
Browse files Browse the repository at this point in the history
Implement AreaLockStatus concept by rsa

Also drop basicly unneeded `areatrigger_teleport`.required_failed_text field.
This concept is still in testing phase, please feedback results of some glitches that might exist!

TODO: Use Player::GetAreaLockStatus or GetAreaTriggerLockStatus for other "CanEnter" checks as well.

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
  • Loading branch information
cyberium authored and Salja committed Sep 15, 2012
1 parent 7c68dc9 commit 6fdd69c
Show file tree
Hide file tree
Showing 22 changed files with 297 additions and 155 deletions.
4 changes: 2 additions & 2 deletions sql/mangos.sql
Expand Up @@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0',
`required_12113_01_mangos_spell_template` bit(1) default NULL
`required_12148_02_mangos_mangos_string` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';

--
Expand Down Expand Up @@ -141,7 +141,6 @@ CREATE TABLE `areatrigger_teleport` (
`heroic_key2` mediumint(8) unsigned NOT NULL default '0',
`required_quest_done` int(11) unsigned NOT NULL default '0',
`required_quest_done_heroic` int(11) unsigned NOT NULL default '0',
`required_failed_text` text,
`target_map` smallint(5) unsigned NOT NULL default '0',
`target_position_x` float NOT NULL default '0',
`target_position_y` float NOT NULL default '0',
Expand Down Expand Up @@ -3932,6 +3931,7 @@ INSERT INTO `mangos_string` VALUES
(815,'Initiate',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(816,'Your body is too exhausted to travel to the Spectral Realm.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(817,'Warning: You\'ve entered a no-fly zone and are about to be dismounted!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(818,'You can\'t enter Black Morass until you rescue Thrall from Durnholde Keep.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1000,'Exiting daemon...',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1001,'Account deleted: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1002,'Account %s NOT deleted (probably sql file format was updated)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
Expand Down
3 changes: 3 additions & 0 deletions sql/updates/12148_01_mangos_areatrigger_teleport.sql
@@ -0,0 +1,3 @@
ALTER TABLE db_version CHANGE COLUMN required_12113_01_mangos_spell_template required_12148_01_mangos_areatrigger_teleport bit;

ALTER TABLE areatrigger_teleport DROP COLUMN required_failed_text;
5 changes: 5 additions & 0 deletions sql/updates/12148_02_mangos_mangos_string.sql
@@ -0,0 +1,5 @@
ALTER TABLE db_version CHANGE COLUMN required_12148_01_mangos_areatrigger_teleport required_12148_02_mangos_mangos_string bit;

DELETE FROM mangos_string WHERE entry=818;
INSERT INTO mangos_string VALUES
(818,'You can\'t enter Black Morass until you rescue Thrall from Durnholde Keep.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
8 changes: 3 additions & 5 deletions src/game/DBCStores.cpp
Expand Up @@ -123,7 +123,6 @@ DBCStorage <LockEntry> sLockStore(LockEntryfmt);
DBCStorage <MailTemplateEntry> sMailTemplateStore(MailTemplateEntryfmt);
DBCStorage <MapEntry> sMapStore(MapEntryfmt);

// DBC used only for initialization sMapDifficultyMap at startup.
DBCStorage <MapDifficultyEntry> sMapDifficultyStore(MapDifficultyEntryfmt); // only for loading
MapDifficultyMap sMapDifficultyMap;

Expand Down Expand Up @@ -463,8 +462,7 @@ void LoadDBCStores(const std::string& dataPath)
// fill data
for (uint32 i = 1; i < sMapDifficultyStore.GetNumRows(); ++i)
if (MapDifficultyEntry const* entry = sMapDifficultyStore.LookupEntry(i))
sMapDifficultyMap[MAKE_PAIR32(entry->MapId, entry->Difficulty)] = MapDifficulty(entry->resetTime, entry->maxPlayers);
sMapDifficultyStore.Clear();
sMapDifficultyMap[MAKE_PAIR32(entry->MapId, entry->Difficulty)] = entry;

LoadDBC(availableDbcLocales, bar, bad_dbc_files, sMovieStore, dbcPath, "Movie.dbc");
LoadDBC(availableDbcLocales, bar, bad_dbc_files, sOverrideSpellDataStore, dbcPath, "OverrideSpellData.dbc");
Expand Down Expand Up @@ -874,10 +872,10 @@ bool Map2ZoneCoordinates(float& x, float& y, uint32 zone)
return true;
}

MapDifficulty const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
MapDifficultyEntry const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
{
MapDifficultyMap::const_iterator itr = sMapDifficultyMap.find(MAKE_PAIR32(mapId, difficulty));
return itr != sMapDifficultyMap.end() ? &itr->second : NULL;
return itr != sMapDifficultyMap.end() ? itr->second : NULL;
}

PvPDifficultyEntry const* GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Expand Down
4 changes: 2 additions & 2 deletions src/game/DBCStores.h
Expand Up @@ -61,8 +61,8 @@ bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredT
bool Zone2MapCoordinates(float& x, float& y, uint32 zone);
bool Map2ZoneCoordinates(float& x, float& y, uint32 zone);

typedef std::map < uint32/*pair32(map,diff)*/, MapDifficulty > MapDifficultyMap;
MapDifficulty const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty);
typedef std::map<uint32/*pair32(map,diff)*/, MapDifficultyEntry const*> MapDifficultyMap;
MapDifficultyEntry const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty);

// natural order for difficulties up-down iteration
// difficulties for dungeons/battleground ordered in normal way
Expand Down
9 changes: 0 additions & 9 deletions src/game/DBCStructure.h
Expand Up @@ -2105,15 +2105,6 @@ typedef std::set<uint32> PetFamilySpellsSet;
typedef std::map<uint32, PetFamilySpellsSet > PetFamilySpellsStore;

// Structures not used for casting to loaded DBC data and not required then packing
struct MapDifficulty
{
MapDifficulty() : resetTime(0), maxPlayers(0) {}
MapDifficulty(uint32 _resetTime, uint32 _maxPlayers) : resetTime(_resetTime), maxPlayers(_maxPlayers) {}

uint32 resetTime; // in secs, 0 if no fixed reset time
uint32 maxPlayers; // some heroic dungeons have 0 when expect same value as in normal dificulty case
};

struct TalentSpellPos
{
TalentSpellPos() : talent_id(0), rank(0) {}
Expand Down
4 changes: 2 additions & 2 deletions src/game/Group.cpp
Expand Up @@ -1779,7 +1779,7 @@ InstanceGroupBind* Group::GetBoundInstance(uint32 mapid, Player* player)
Difficulty difficulty = player->GetDifficulty(mapEntry->IsRaid());

// some instances only have one difficulty
MapDifficulty const* mapDiff = GetMapDifficultyData(mapid, difficulty);
MapDifficultyEntry const* mapDiff = GetMapDifficultyData(mapid, difficulty);
if (!mapDiff)
difficulty = DUNGEON_DIFFICULTY_NORMAL;

Expand All @@ -1793,7 +1793,7 @@ InstanceGroupBind* Group::GetBoundInstance(uint32 mapid, Player* player)
InstanceGroupBind* Group::GetBoundInstance(Map* aMap, Difficulty difficulty)
{
// some instances only have one difficulty
MapDifficulty const* mapDiff = GetMapDifficultyData(aMap->GetId(), difficulty);
MapDifficultyEntry const* mapDiff = GetMapDifficultyData(aMap->GetId(), difficulty);
if (!mapDiff)
return NULL;

Expand Down
3 changes: 2 additions & 1 deletion src/game/Language.h
Expand Up @@ -809,7 +809,8 @@ enum MangosStrings
LANG_GUILD_INITIATE = 815,
LANG_FAIL_ENTER_SPECTRAL_REALM = 816,
LANG_NO_FLY_ZONE = 817,
// Room for in-game strings 818-999 not used
LANG_TELEREQ_QUEST_BLACK_MORASS = 818,
// Room for in-game strings 819-999 not used

// Level 4 (CLI only commands)
LANG_COMMAND_EXIT = 1000,
Expand Down
6 changes: 3 additions & 3 deletions src/game/Map.cpp
Expand Up @@ -824,21 +824,21 @@ void Map::UnloadAll(bool pForce)
}
}

MapDifficulty const* Map::GetMapDifficulty() const
MapDifficultyEntry const* Map::GetMapDifficulty() const
{
return GetMapDifficultyData(GetId(), GetDifficulty());
}

uint32 Map::GetMaxPlayers() const
{
if (MapDifficulty const* mapDiff = GetMapDifficulty())
if (MapDifficultyEntry const* mapDiff = GetMapDifficulty())
{
if (mapDiff->maxPlayers || IsRegularDifficulty()) // Normal case (expect that regular difficulty always have correct maxplayers)
return mapDiff->maxPlayers;
else // DBC have 0 maxplayers for heroic instances with expansion < 2
{
// The heroic entry exists, so we don't have to check anything, simply return normal max players
MapDifficulty const* normalDiff = GetMapDifficultyData(i_id, REGULAR_DIFFICULTY);
MapDifficultyEntry const* normalDiff = GetMapDifficultyData(i_id, REGULAR_DIFFICULTY);
return normalDiff ? normalDiff->maxPlayers : 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/game/Map.h
Expand Up @@ -183,7 +183,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
bool IsRegularDifficulty() const { return GetDifficulty() == REGULAR_DIFFICULTY; }
uint32 GetMaxPlayers() const; // dependent from map difficulty
uint32 GetMaxResetDelay() const; // dependent from map difficulty
MapDifficulty const* GetMapDifficulty() const; // dependent from map difficulty
MapDifficultyEntry 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
Expand Down
2 changes: 1 addition & 1 deletion src/game/MapManager.cpp
Expand Up @@ -182,7 +182,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player)
}

// The player has a heroic mode and tries to enter into instance which has no a heroic mode
MapDifficulty const* mapDiff = GetMapDifficultyData(entry->MapID, player->GetDifficulty(entry->map_type == MAP_RAID));
MapDifficultyEntry const* mapDiff = GetMapDifficultyData(entry->MapID, player->GetDifficulty(entry->map_type == MAP_RAID));
if (!mapDiff)
{
bool isRegularTargetMap = player->GetDifficulty(entry->IsRaid()) == REGULAR_DIFFICULTY;
Expand Down
10 changes: 5 additions & 5 deletions src/game/MapPersistentStateMgr.cpp
Expand Up @@ -319,7 +319,7 @@ bool BattleGroundPersistentState::CanBeUnload() const

//== DungeonResetScheduler functions ======================

uint32 DungeonResetScheduler::GetMaxResetTimeFor(MapDifficulty const* mapDiff)
uint32 DungeonResetScheduler::GetMaxResetTimeFor(MapDifficultyEntry const* mapDiff)
{
if (!mapDiff || !mapDiff->resetTime)
return 0;
Expand All @@ -332,7 +332,7 @@ uint32 DungeonResetScheduler::GetMaxResetTimeFor(MapDifficulty const* mapDiff)
return delay;
}

time_t DungeonResetScheduler::CalculateNextResetTime(MapDifficulty const* mapDiff, time_t prevResetTime)
time_t DungeonResetScheduler::CalculateNextResetTime(MapDifficultyEntry const* mapDiff, time_t prevResetTime)
{
uint32 diff = sWorld.getConfig(CONFIG_UINT32_INSTANCE_RESET_TIME_HOUR) * HOUR;
uint32 period = GetMaxResetTimeFor(mapDiff);
Expand Down Expand Up @@ -450,7 +450,7 @@ void DungeonResetScheduler::LoadResetTimes()
uint32 map_diff_pair = itr->first;
uint32 mapid = PAIR32_LOPART(map_diff_pair);
Difficulty difficulty = Difficulty(PAIR32_HIPART(map_diff_pair));
MapDifficulty const* mapDiff = &itr->second;
MapDifficultyEntry const* mapDiff = itr->second;

// skip mapDiff without global reset time
if (!mapDiff->resetTime)
Expand Down Expand Up @@ -552,7 +552,7 @@ void DungeonResetScheduler::Update()
{
// re-schedule the next/new global reset/warning
// calculate the next reset time
MapDifficulty const* mapDiff = GetMapDifficultyData(event.mapid, event.difficulty);
MapDifficultyEntry const* mapDiff = GetMapDifficultyData(event.mapid, event.difficulty);
MANGOS_ASSERT(mapDiff);

time_t next_reset = DungeonResetScheduler::CalculateNextResetTime(mapDiff, resetTime);
Expand Down Expand Up @@ -857,7 +857,7 @@ void MapPersistentStateManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficu

if (!warn)
{
MapDifficulty const* mapDiff = GetMapDifficultyData(mapid, difficulty);
MapDifficultyEntry const* mapDiff = GetMapDifficultyData(mapid, difficulty);
if (!mapDiff || !mapDiff->resetTime)
{
sLog.outError("MapPersistentStateManager::ResetOrWarnAll: not valid difficulty or no reset delay for map %d", mapid);
Expand Down
6 changes: 3 additions & 3 deletions src/game/MapPersistentStateMgr.h
Expand Up @@ -34,7 +34,7 @@

struct InstanceTemplate;
struct MapEntry;
struct MapDifficulty;
struct MapDifficultyEntry;
struct GameObjectData;
struct CreatureData;

Expand Down Expand Up @@ -304,8 +304,8 @@ class DungeonResetScheduler
return itr != m_resetTimeByMapDifficulty.end() ? itr->second : 0;
}

static uint32 GetMaxResetTimeFor(MapDifficulty const* mapDiff);
static time_t CalculateNextResetTime(MapDifficulty const* mapDiff, time_t prevResetTime);
static uint32 GetMaxResetTimeFor(MapDifficultyEntry const* mapDiff);
static time_t CalculateNextResetTime(MapDifficultyEntry const* mapDiff, time_t prevResetTime);
public: // modifiers
void SetResetTimeFor(uint32 mapid, Difficulty d, time_t t)
{
Expand Down

0 comments on commit 6fdd69c

Please sign in to comment.