Skip to content

Commit

Permalink
[12952] Move hardcoded map IDs from core to DB
Browse files Browse the repository at this point in the history
(based on cmangos/mangos-wotlk@929ac11c7)

Signed-off-by: Xfurry <xfurry.cmangos@outlook.com>
  • Loading branch information
boxa authored and xfurry committed Dec 10, 2017
1 parent 38e83fa commit 22239d7
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 22 deletions.
112 changes: 110 additions & 2 deletions sql/base/mangos.sql
Expand Up @@ -2,7 +2,7 @@
--
-- Host: localhost Database: mangos
-- ------------------------------------------------------
-- Server version 5.5.32
-- Server version 5.5.32

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
Expand All @@ -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_12951_01_mangos_item_template` bit(1) DEFAULT NULL
`required_12952_01_mangos_instance_template` bit(1) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Used DB version notes';

--
Expand Down Expand Up @@ -2134,6 +2134,7 @@ CREATE TABLE `instance_template` (
`levelMin` tinyint(3) unsigned NOT NULL DEFAULT '0',
`levelMax` tinyint(3) unsigned NOT NULL DEFAULT '0',
`ScriptName` varchar(128) NOT NULL DEFAULT '',
`mountAllowed` tinyint(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`map`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Expand All @@ -2143,6 +2144,113 @@ CREATE TABLE `instance_template` (

LOCK TABLES `instance_template` WRITE;
/*!40000 ALTER TABLE `instance_template` DISABLE KEYS */;
INSERT INTO `instance_template` (`map`, `parent`, `levelMin`, `levelMax`, `ScriptName`, `mountAllowed`) VALUES
(30, 0, 10, 0, '', 0),
(33, 0, 10, 0, '', 0),
(34, 0, 15, 0, '', 0),
(36, 0, 10, 0, '', 1),
(43, 0, 10, 0, '', 0),
(44, 0, 1, 0, '', 0),
(47, 0, 15, 0, '', 0),
(48, 0, 10, 0, '', 0),
(70, 0, 30, 0, '', 0),
(90, 0, 15, 0, '', 0),
(109, 0, 35, 0, '', 0),
(129, 0, 25, 0, '', 0),
(169, 0, 1, 0, '', 0),
(189, 0, 20, 0, '', 0),
(209, 0, 35, 0, '', 1),
(229, 0, 45, 0, '', 0),
(230, 0, 40, 0, '', 0),
(249, 0, 80, 0, '', 0),
(269, 0, 66, 0, '', 1),
(289, 0, 45, 0, '', 0),
(309, 0, 50, 0, '', 1),
(329, 0, 45, 0, '', 0),
(349, 0, 30, 0, '', 0),
(389, 0, 8, 0, '', 0),
(409, 0, 50, 0, '', 0),
(429, 0, 45, 0, '', 0),
(469, 0, 60, 0, '', 0),
(489, 0, 10, 0, '', 0),
(509, 0, 60, 0, '', 1),
(529, 0, 10, 0, '', 0),
(531, 0, 60, 0, '', 0),
(532, 0, 68, 0, '', 0),
(533, 0, 80, 0, '', 0),
(534, 0, 70, 0, '', 1),
(540, 0, 55, 0, '', 0),
(542, 0, 55, 0, '', 0),
(543, 0, 55, 0, '', 0),
(544, 0, 65, 0, '', 0),
(545, 0, 55, 0, '', 0),
(546, 0, 55, 0, '', 0),
(547, 0, 55, 0, '', 0),
(548, 0, 70, 0, '', 0),
(550, 0, 70, 0, '', 0),
(552, 0, 68, 0, '', 0),
(553, 0, 68, 0, '', 0),
(554, 0, 68, 0, '', 0),
(555, 0, 65, 0, '', 0),
(556, 0, 55, 0, '', 0),
(557, 0, 55, 0, '', 0),
(558, 0, 55, 0, '', 0),
(559, 0, 10, 0, '', 0),
(560, 0, 66, 0, '', 1),
(562, 0, 10, 0, '', 0),
(564, 0, 70, 0, '', 1),
(565, 0, 65, 0, '', 0),
(566, 0, 10, 0, '', 0),
(568, 0, 70, 0, '', 1),
(572, 0, 10, 0, '', 0),
(574, 0, 70, 72, '', 0),
(575, 0, 80, 80, '', 0),
(576, 0, 70, 72, '', 0),
(578, 0, 80, 80, '', 1),
(580, 0, 70, 0, '', 1),
(585, 0, 70, 0, '', 0),
(595, 0, 74, 80, '', 1),
(598, 0, 0, 0, '', 0),
(599, 0, 70, 0, '', 0),
(600, 0, 70, 0, '', 0),
(601, 0, 80, 80, '', 0),
(602, 0, 70, 0, '', 0),
(603, 0, 80, 0, '', 1),
(604, 0, 71, 80, '', 0),
(607, 0, 71, 0, '', 0),
(608, 0, 70, 80, '', 0),
(615, 0, 80, 0, '', 1),
(616, 0, 80, 0, '', 1),
(617, 0, 80, 80, '', 0),
(618, 0, 80, 80, '', 0),
(619, 0, 68, 80, '', 0),
(624, 0, 80, 0, '', 0),
(631, 0, 80, 0, '', 1),
(632, 0, 75, 0, '', 0),
(649, 0, 80, 0, '', 0),
(650, 0, 75, 0, '', 0),
(658, 0, 75, 0, '', 1),
(668, 0, 75, 0, '', 0),
(724, 0, 80, 80, '', 1),
(643, 0, 77, 0, '', 0),
(644, 0, 83, 0, '', 1),
(645, 0, 77, 0, '', 0),
(657, 0, 80, 0, '', 0),
(669, 0, 85, 0, '', 0),
(670, 0, 83, 0, '', 0),
(671, 0, 85, 0, '', 0),
(720, 0, 85, 0, '', 1),
(721, 0, 85, 0, '', 1),
(725, 0, 80, 0, '', 0),
(734, 0, 80, 0, '', 1),
(754, 0, 85, 0, '', 0),
(755, 0, 83, 0, '', 1),
(757, 0, 85, 0, '', 0),
(859, 0, 85, 0, '', 1),
(938, 0, 85, 0, '', 1),
(939, 0, 85, 0, '', 1),
(940, 0, 85, 0, '', 1),
(967, 0, 85, 0, '', 1);
/*!40000 ALTER TABLE `instance_template` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down
9 changes: 9 additions & 0 deletions sql/updates/mangos/12952_01_mangos_instance_template.sql
@@ -0,0 +1,9 @@
ALTER TABLE db_version CHANGE COLUMN required_12951_01_mangos_item_template required_12952_01_mangos_instance_template bit;

ALTER TABLE instance_template
ADD COLUMN mountAllowed tinyint(3) UNSIGNED NOT NULL DEFAULT 0 AFTER ScriptName;

UPDATE instance_template SET mountAllowed = 1 WHERE map IN
(
36, 209, 269, 309, 509, 534, 560, 564, 568, 578, 580, 595, 603, 615, 616, 631, 644, 658, 720, 721, 724, 734, 755, 859, 938, 939, 940, 967
);
14 changes: 0 additions & 14 deletions src/game/DBCStructure.h
Expand Up @@ -1378,20 +1378,6 @@ struct MapEntry
bool IsBattleArena() const { return map_type == MAP_ARENA; }
bool IsBattleGroundOrArena() const { return map_type == MAP_BATTLEGROUND || map_type == MAP_ARENA; }

bool IsMountAllowed() const
{
return !IsDungeon() ||
MapID==209 || MapID==269 || MapID==309 || // TanarisInstance, CavernsOfTime, Zul'gurub
MapID==509 || MapID==534 || MapID==560 || // AhnQiraj, HyjalPast, HillsbradPast
MapID==564 || MapID==568 || MapID==580 || // Black Temple, ZulAman, Sunwell Plateau,
MapID==595 || MapID==603 || MapID==615 || // Ulduar, The Obsidian Sanctum, Culling of Stratholme
MapID==616 || MapID==631 || MapID==658 || // Icecrown Citadel, Pit of Saron, The Eye Of Eternity
MapID==724 || MapID==644 || MapID==720 || // Halls of Origination, Ruby Sanctum, Firelands
MapID==721 || MapID==734 || MapID==755 || // Ahn'Qiraj Terrace, Lost City of Tol'Vir, Firelands
MapID==859 || MapID==938 || MapID==939 || // End Time, Well of Eternity, Zul'Gurub
MapID==940 || MapID==967; // Dragon SoulHour of Twilight
}

bool IsContinent() const
{
return MapID == 0 || MapID == 1 || MapID == 530 || MapID == 571;
Expand Down
11 changes: 11 additions & 0 deletions src/game/Map.cpp
Expand Up @@ -2284,3 +2284,14 @@ bool Map::GetReachableRandomPosition(Unit* unit, float& x, float& y, float& z, f

return false;
}

bool Map::IsMountAllowed() const
{
if (!IsDungeon())
return true;

if (InstanceTemplate const* data = ObjectMgr::GetInstanceTemplate(GetId()))
return data->mountAllowed;

return true;
}
4 changes: 3 additions & 1 deletion src/game/Map.h
Expand Up @@ -64,10 +64,11 @@ struct InstanceTemplate
{
uint32 map; // instance map
uint32 parent; // non-continent parent instance (for instance with entrance in another instances)
// or 0 (not related to continent 0 map id)
// or 0 (not related to continent 0 map id)
uint32 levelMin;
uint32 levelMax;
uint32 script_id;
bool mountAllowed;
};

struct WorldTemplate
Expand Down Expand Up @@ -192,6 +193,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
bool IsBattleArena() const { return i_mapEntry && i_mapEntry->IsBattleArena(); }
bool IsBattleGroundOrArena() const { return i_mapEntry && i_mapEntry->IsBattleGroundOrArena(); }
bool IsContinent() const { return i_mapEntry && i_mapEntry->IsContinent(); }
bool IsMountAllowed() const;

// can't be nullptr for loaded map
MapPersistentState* GetPersistentState() const { return m_persistentState; }
Expand Down
1 change: 0 additions & 1 deletion src/game/MovementHandler.cpp
Expand Up @@ -183,7 +183,6 @@ void WorldSession::HandleMoveWorldportAckOpcode()
}
}
}
}

// mount allow check
if (!mEntry->IsMountAllowed())
Expand Down
4 changes: 2 additions & 2 deletions src/game/SQLStorages.cpp
Expand Up @@ -30,8 +30,8 @@ const char GameObjectInfodstfmt[] = "iiissssiiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
const char ItemPrototypesrcfmt[] = "iiiisiiiiffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiifiiisiifiiiii";
const char ItemPrototypedstfmt[] = "iiiisiiiiffiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiifiiiiiifiiiii";
const char PageTextfmt[] = "isi";
const char InstanceTemplatesrcfmt[] = "iiiis";
const char InstanceTemplatedstfmt[] = "iiiii";
const char InstanceTemplatesrcfmt[] = "iiiisl";
const char InstanceTemplatedstfmt[] = "iiiiil";
const char WorldTemplatesrcfmt[] = "is";
const char WorldTemplatedstfmt[] = "ii";
const char ConditionsSrcFmt[] = "iiii";
Expand Down
7 changes: 6 additions & 1 deletion src/game/Spell.cpp
Expand Up @@ -6517,8 +6517,13 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_NOT_HERE;

// Ignore map check if spell have AreaId. AreaId already checked and this prevent special mount spells
if (m_caster->GetTypeId() == TYPEID_PLAYER && !sMapStore.LookupEntry(m_caster->GetMapId())->IsMountAllowed() && !m_IsTriggeredSpell && !m_spellInfo->GetAreaGroupId())
if (m_caster->GetTypeId() == TYPEID_PLAYER &&
!m_IsTriggeredSpell &&
!m_spellInfo->GetAreaGroupId() &&
(m_caster->GetMap() && !m_caster->GetMap()->IsMountAllowed()))
{
return SPELL_FAILED_NO_MOUNTS_ALLOWED;
}

if (m_caster->IsInDisallowedMountForm())
return SPELL_FAILED_NOT_SHAPESHIFT;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_sql.h
Expand Up @@ -2,5 +2,5 @@
#define __REVISION_SQL_H__
#define REVISION_DB_REALMD "required_c12484_02_realmd_account_access"
#define REVISION_DB_CHARACTERS "required_12949_01_characters_mangle_cleanup"
#define REVISION_DB_MANGOS "required_12951_01_mangos_item_template"
#define REVISION_DB_MANGOS "required_12952_01_mangos_instance_template"
#endif // __REVISION_SQL_H__

0 comments on commit 22239d7

Please sign in to comment.