diff --git a/doc/EventAI.txt b/doc/EventAI.txt index cf385643b..12bda31a6 100644 --- a/doc/EventAI.txt +++ b/doc/EventAI.txt @@ -787,13 +787,13 @@ Below is the list of current Event Flags that EventAI can handle. Event flags ar (bit# Decimal Internal Name Discription) 0 1 EFLAG_REPEATABLE Event repeats (Does not repeat if this flag is not set) -1 2 EFLAG_NORMAL Event occurs in Normal instance difficulty (will not occur in Normal if not set) -2 4 EFLAG_HEROIC Event occurs in Heroic instance difficulty (will not occur in Heroic if not set) -3 8 -4 16 +1 2 EFLAG_DIFFICULTY_0 Event occurs in instance difficulty 0 (will not occur if not set) +2 4 EFLAG_DIFFICULTY_1 Event occurs in instance difficulty 1 (will not occur if not set) +3 8 EFLAG_DIFFICULTY_2 Event occurs in instance difficulty 2 (will not occur if not set) +4 16 EFLAG_DIFFICULTY_3 Event occurs in instance difficulty 3 (will not occur if not set) 5 32 6 64 -7 128 EFLAG_DEBUG_ONLY Prevents events from occuring on Release builds. Useful for testing new features. +7 128 EFLAG_DEBUG_ONLY Prevents events from occuring on Release builds. Useful for testing new features. NOTE: You can add the numbers in the decimal column to combine flags. diff --git a/sql/mangos.sql b/sql/mangos.sql index 07f85514e..37ba033a7 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -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_8720_01_mangos_quest_template` bit(1) default NULL + `required_8731_01_mangos_creature_template` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -39,11 +39,11 @@ INSERT INTO `db_version` VALUES UNLOCK TABLES; -- --- Table structure for table `achievement_criteria_data` +-- Table structure for table `achievement_criteria_requirement` -- -DROP TABLE IF EXISTS `achievement_criteria_data`; -CREATE TABLE `achievement_criteria_data` ( +DROP TABLE IF EXISTS `achievement_criteria_requirement`; +CREATE TABLE `achievement_criteria_requirement` ( `criteria_id` mediumint(8) NOT NULL, `type` tinyint(3) unsigned NOT NULL DEFAULT '0', `value1` mediumint(8) unsigned NOT NULL DEFAULT '0', @@ -52,12 +52,12 @@ CREATE TABLE `achievement_criteria_data` ( ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Achievment system'; -- --- Dumping data for table `achievement_criteria_data` +-- Dumping data for table `achievement_criteria_requirement` -- -LOCK TABLES `achievement_criteria_data` WRITE; -/*!40000 ALTER TABLE `achievement_criteria_data` DISABLE KEYS */; -/*!40000 ALTER TABLE `achievement_criteria_data` ENABLE KEYS */; +LOCK TABLES `achievement_criteria_requirement` WRITE; +/*!40000 ALTER TABLE `achievement_criteria_requirement` DISABLE KEYS */; +/*!40000 ALTER TABLE `achievement_criteria_requirement` ENABLE KEYS */; UNLOCK TABLES; -- @@ -1061,7 +1061,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `creature_template`; CREATE TABLE `creature_template` ( `entry` mediumint(8) unsigned NOT NULL default '0', - `heroic_entry` mediumint(8) unsigned NOT NULL default '0', + `difficulty_entry_1` mediumint(8) unsigned NOT NULL default '0', `KillCredit1` int(11) unsigned NOT NULL default '0', `KillCredit2` int(11) unsigned NOT NULL default '0', `modelid_A` mediumint(8) unsigned NOT NULL default '0', @@ -18325,6 +18325,7 @@ INSERT INTO `spell_proc_event` VALUES (61356, 0x00000000, 0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0.000000, 0.000000, 0), (61846, 0x00000000, 0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000010, 0.000000, 0.000000, 0), (61847, 0x00000000, 0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000010, 0.000000, 0.000000, 0), +(62600, 0x00000000, 7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0.000000, 0.000000, 0), (63108, 0x00000000, 5, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), (63156, 0x00000000, 0, 0x00000001, 0x00000040, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), (63245, 0x00000000, 5, 0x00000100, 0x00800000, 0x00000000, 0x00000000, 0x00000002, 0.000000, 0.000000, 0), diff --git a/sql/realmd.sql b/sql/realmd.sql index 9809f7043..2b8bc64a3 100644 --- a/sql/realmd.sql +++ b/sql/realmd.sql @@ -21,7 +21,7 @@ DROP TABLE IF EXISTS `realmd_db_version`; CREATE TABLE `realmd_db_version` ( - `required_8332_01_realmd_realmcharacters` bit(1) default NULL + `required_8728_01_realmd_account` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; -- @@ -54,7 +54,7 @@ CREATE TABLE `account` ( `failed_logins` int(11) unsigned NOT NULL default '0', `locked` tinyint(3) unsigned NOT NULL default '0', `last_login` timestamp NOT NULL default '0000-00-00 00:00:00', - `online` tinyint(4) NOT NULL default '0', + `active_realm_id` int(11) unsigned NOT NULL default '0', `expansion` tinyint(3) unsigned NOT NULL default '0', `mutetime` bigint(40) unsigned NOT NULL default '0', `locale` tinyint(3) unsigned NOT NULL default '0', diff --git a/sql/updates/8723_01_mangos_achievement_criteria_requirement.sql b/sql/updates/8723_01_mangos_achievement_criteria_requirement.sql new file mode 100644 index 000000000..83d7a155a --- /dev/null +++ b/sql/updates/8723_01_mangos_achievement_criteria_requirement.sql @@ -0,0 +1,3 @@ +ALTER TABLE db_version CHANGE COLUMN required_8720_01_mangos_quest_template required_8723_01_mangos_achievement_criteria_requirement bit; + +RENAME TABLE achievement_criteria_data TO achievement_criteria_requirement; diff --git a/sql/updates/8726_01_mangos_spell_proc_event.sql b/sql/updates/8726_01_mangos_spell_proc_event.sql new file mode 100644 index 000000000..5bb255557 --- /dev/null +++ b/sql/updates/8726_01_mangos_spell_proc_event.sql @@ -0,0 +1,4 @@ +ALTER TABLE db_version CHANGE COLUMN required_8723_01_mangos_achievement_criteria_requirement required_8726_01_mangos_spell_proc_event bit; + +DELETE FROM spell_proc_event WHERE entry = 62600; +INSERT INTO spell_proc_event VALUES (62600, 0x00000000, 7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0.000000, 0.000000, 0); \ No newline at end of file diff --git a/sql/updates/8728_01_realmd_account.sql b/sql/updates/8728_01_realmd_account.sql new file mode 100644 index 000000000..9f1ee1329 --- /dev/null +++ b/sql/updates/8728_01_realmd_account.sql @@ -0,0 +1,5 @@ +ALTER TABLE realmd_db_version CHANGE COLUMN required_8332_01_realmd_realmcharacters required_8728_01_realmd_account bit; + +ALTER TABLE account + DROP COLUMN online, + ADD COLUMN active_realm_id int(11) unsigned NOT NULL default '0' AFTER last_login; diff --git a/sql/updates/8731_01_mangos_creature_template.sql b/sql/updates/8731_01_mangos_creature_template.sql new file mode 100644 index 000000000..ee1849f07 --- /dev/null +++ b/sql/updates/8731_01_mangos_creature_template.sql @@ -0,0 +1,4 @@ +ALTER TABLE db_version CHANGE COLUMN required_8726_01_mangos_spell_proc_event required_8731_01_mangos_creature_template bit; + +ALTER TABLE creature_template + CHANGE COLUMN heroic_entry difficulty_entry_1 mediumint(8) unsigned NOT NULL default '0'; diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index bf439cca0..86d301969 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -141,6 +141,10 @@ pkgdata_DATA = \ 8702_01_characters_character_reputation.sql \ 8720_01_mangos_quest_template.sql \ 8721_01_characters_guild.sql \ + 8723_01_mangos_achievement_criteria_requirement.sql \ + 8726_01_mangos_spell_proc_event.sql \ + 8728_01_realmd_account.sql \ + 8731_01_mangos_creature_template.sql \ README ## Additional files to include when running 'make dist' @@ -262,4 +266,8 @@ EXTRA_DIST = \ 8702_01_characters_character_reputation.sql \ 8720_01_mangos_quest_template.sql \ 8721_01_characters_guild.sql \ + 8723_01_mangos_achievement_criteria_requirement.sql \ + 8726_01_mangos_spell_proc_event.sql \ + 8728_01_realmd_account.sql \ + 8731_01_mangos_creature_template.sql \ README diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index 3e8d99e61..efcec8b1f 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -71,11 +71,11 @@ namespace MaNGOS } // namespace MaNGOS -bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria) +bool AchievementCriteriaRequirement::IsValid(AchievementCriteriaEntry const* criteria) { - if(dataType >= MAX_ACHIEVEMENT_CRITERIA_DATA_TYPE) + if(requirementType >= MAX_ACHIEVEMENT_CRITERIA_REQUIREMENT_TYPE) { - sLog.outErrorDb( "Table `achievement_criteria_data` for criteria (Entry: %u) have wrong data type (%u), ignore.", criteria->ID,dataType); + sLog.outErrorDb( "Table `achievement_criteria_requirement` for criteria (Entry: %u) have wrong requirement type (%u), ignore.", criteria->ID,requirementType); return false; } @@ -93,168 +93,168 @@ bool AchievementCriteriaData::IsValid(AchievementCriteriaEntry const* criteria) case ACHIEVEMENT_CRITERIA_TYPE_CAST_SPELL2: break; default: - sLog.outErrorDb( "Table `achievement_criteria_data` have data for not supported criteria type (Entry: %u Type: %u), ignore.", criteria->ID, criteria->requiredType); + sLog.outErrorDb( "Table `achievement_criteria_requirement` have data for not supported criteria type (Entry: %u Type: %u), ignore.", criteria->ID, criteria->requiredType); return false; } - switch(dataType) + switch(requirementType) { - case ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE: - case ACHIEVEMENT_CRITERIA_DATA_TYPE_VALUE: - case ACHIEVEMENT_CRITERIA_DATA_TYPE_DISABLED: + case ACHIEVEMENT_CRITERIA_REQUIRE_NONE: + case ACHIEVEMENT_CRITERIA_REQUIRE_VALUE: + case ACHIEVEMENT_CRITERIA_REQUIRE_DISABLED: return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_CREATURE: if (!creature.id || !objmgr.GetCreatureTemplate(creature.id)) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_CREATURE (%u) have not existed creature id in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,creature.id); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have not existed creature id in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,creature.id); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_CLASS_RACE: if (!classRace.class_id && !classRace.race_id) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_PLAYER_CLASS_RACE (%u) must have not 0 in one from value fields, ignore.", - criteria->ID, criteria->requiredType,dataType); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_PLAYER_CLASS_RACE (%u) must have not 0 in one from value fields, ignore.", + criteria->ID, criteria->requiredType,requirementType); return false; } if (classRace.class_id && ((1 << (classRace.class_id-1)) & CLASSMASK_ALL_PLAYABLE)==0) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_CREATURE (%u) have not existed class in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,classRace.class_id); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have not existed class in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,classRace.class_id); return false; } if (classRace.race_id && ((1 << (classRace.race_id-1)) & RACEMASK_ALL_PLAYABLE)==0) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_CREATURE (%u) have not existed race in value2 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,classRace.race_id); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_CREATURE (%u) have not existed race in value2 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,classRace.race_id); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_LESS_HEALTH: if (health.percent < 1 || health.percent > 100) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_PLAYER_LESS_HEALTH (%u) have wrong percent value in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,health.percent); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_PLAYER_LESS_HEALTH (%u) have wrong percent value in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,health.percent); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD: if (player_dead.own_team_flag > 1) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD (%u) have wrong boolean value1 (%u).", - criteria->ID, criteria->requiredType,dataType,player_dead.own_team_flag); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD (%u) have wrong boolean value1 (%u).", + criteria->ID, criteria->requiredType,requirementType,player_dead.own_team_flag); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA: - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA: + case ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA: { SpellEntry const* spellEntry = sSpellStore.LookupEntry(aura.spell_id); if (!spellEntry) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type %s (%u) have wrong spell id in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,(dataType==ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA?"ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA":"ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA"),dataType,aura.spell_id); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have wrong spell id in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.spell_id); return false; } if (aura.effect_idx >= 3) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type %s (%u) have wrong spell effect index in value2 (%u), ignore.", - criteria->ID, criteria->requiredType,(dataType==ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA?"ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA":"ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA"),dataType,aura.effect_idx); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have wrong spell effect index in value2 (%u), ignore.", + criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.effect_idx); return false; } if (!spellEntry->EffectApplyAuraName[aura.effect_idx]) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type %s (%u) have non-aura spell effect (ID: %u Effect: %u), ignore.", - criteria->ID, criteria->requiredType,(dataType==ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA?"ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA":"ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA"),dataType,aura.spell_id,aura.effect_idx); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement %s (%u) have non-aura spell effect (ID: %u Effect: %u), ignore.", + criteria->ID, criteria->requiredType,(requirementType==ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA?"ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA":"ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA"),requirementType,aura.spell_id,aura.effect_idx); return false; } return true; } - case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AREA: + case ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA: if (!GetAreaEntryByAreaID(area.id)) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AREA (%u) have wrong area id in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,area.id); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA (%u) have wrong area id in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,area.id); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL: if (level.minlevel < 0 || level.minlevel > STRONG_MAX_LEVEL) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL (%u) have wrong minlevel in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,level.minlevel); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL (%u) have wrong minlevel in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,level.minlevel); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_GENDER: if (gender.gender > GENDER_NONE) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER (%u) have wrong gender in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,gender.gender); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_GENDER (%u) have wrong gender in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,gender.gender); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY: + case ACHIEVEMENT_CRITERIA_REQUIRE_MAP_DIFFICULTY: if (difficulty.difficulty >= MAX_DIFFICULTY) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY (%u) have wrong difficulty in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,difficulty.difficulty); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_MAP_DIFFICULTY (%u) have wrong difficulty in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,difficulty.difficulty); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT: + case ACHIEVEMENT_CRITERIA_REQUIRE_MAP_PLAYER_COUNT: if (map_players.maxcount <= 0) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT (%u) have wrong max players count in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,map_players.maxcount); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_MAP_PLAYER_COUNT (%u) have wrong max players count in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,map_players.maxcount); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_TEAM: if (team.team != ALLIANCE && team.team != HORDE) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM (%u) have unknown team in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,team.team); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_T_TEAM (%u) have unknown team in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,team.team); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_DRUNK: + case ACHIEVEMENT_CRITERIA_REQUIRE_S_DRUNK: if(drunk.state >= MAX_DRUNKEN) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_S_DRUNK (%u) have unknown drunken state in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,drunk.state); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_S_DRUNK (%u) have unknown drunken state in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,drunk.state); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_HOLIDAY: + case ACHIEVEMENT_CRITERIA_REQUIRE_HOLIDAY: if (!sHolidaysStore.LookupEntry(holiday.id)) { - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) for data type ACHIEVEMENT_CRITERIA_DATA_TYPE_HOLIDAY (%u) have unknown holiday in value1 (%u), ignore.", - criteria->ID, criteria->requiredType,dataType,holiday.id); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) for requirement ACHIEVEMENT_CRITERIA_REQUIRE_HOLIDAY (%u) have unknown holiday in value1 (%u), ignore.", + criteria->ID, criteria->requiredType,requirementType,holiday.id); return false; } return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_BG_LOSS_TEAM_SCORE: + case ACHIEVEMENT_CRITERIA_REQUIRE_BG_LOSS_TEAM_SCORE: return true; // not check correctness node indexes default: - sLog.outErrorDb( "Table `achievement_criteria_data` (Entry: %u Type: %u) have data for not supported data type (%u), ignore.", criteria->ID, criteria->requiredType,dataType); + sLog.outErrorDb( "Table `achievement_criteria_requirement` (Entry: %u Type: %u) have data for not supported data type (%u), ignore.", criteria->ID, criteria->requiredType,requirementType); return false; } return false; } -bool AchievementCriteriaData::Meets(Player const* source, Unit const* target, uint32 miscvalue1 /*= 0*/) const +bool AchievementCriteriaRequirement::Meets(Player const* source, Unit const* target, uint32 miscvalue1 /*= 0*/) const { - switch(dataType) + switch(requirementType) { - case ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE: + case ACHIEVEMENT_CRITERIA_REQUIRE_NONE: return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_CREATURE: if (!target || target->GetTypeId()!=TYPEID_UNIT) return false; return target->GetEntry() == creature.id; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_CLASS_RACE: if (!target || target->GetTypeId()!=TYPEID_PLAYER) return false; if(classRace.class_id && classRace.class_id != ((Player*)target)->getClass()) @@ -262,50 +262,50 @@ bool AchievementCriteriaData::Meets(Player const* source, Unit const* target, ui if(classRace.race_id && classRace.race_id != ((Player*)target)->getRace()) return false; return true; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_LESS_HEALTH: if (!target || target->GetTypeId()!=TYPEID_PLAYER) return false; return target->GetHealth()*100 <= health.percent*target->GetMaxHealth(); - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD: if (!target || target->GetTypeId() != TYPEID_PLAYER || target->isAlive() || ((Player*)target)->GetDeathTimer() == 0) return false; // flag set == must be same team, not set == different team return (((Player*)target)->GetTeam() == source->GetTeam()) == (player_dead.own_team_flag != 0); - case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA: + case ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA: return source->HasAura(aura.spell_id,aura.effect_idx); - case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AREA: + case ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA: { uint32 zone_id,area_id; source->GetZoneAndAreaId(zone_id,area_id); return area.id==zone_id || area.id==area_id; } - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA: return target && target->HasAura(aura.spell_id,aura.effect_idx); - case ACHIEVEMENT_CRITERIA_DATA_TYPE_VALUE: + case ACHIEVEMENT_CRITERIA_REQUIRE_VALUE: return miscvalue1 >= value.minvalue; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL: if (!target) return false; return target->getLevel() >= level.minlevel; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_GENDER: if (!target) return false; return target->getGender() == gender.gender; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_DISABLED: + case ACHIEVEMENT_CRITERIA_REQUIRE_DISABLED: return false; // always fail - case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY: + case ACHIEVEMENT_CRITERIA_REQUIRE_MAP_DIFFICULTY: return source->GetMap()->GetSpawnMode()==difficulty.difficulty; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT: + case ACHIEVEMENT_CRITERIA_REQUIRE_MAP_PLAYER_COUNT: return source->GetMap()->GetPlayersCountExceptGMs() <= map_players.maxcount; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM: + case ACHIEVEMENT_CRITERIA_REQUIRE_T_TEAM: if (!target || target->GetTypeId() != TYPEID_PLAYER) return false; return ((Player*)target)->GetTeam() == team.team; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_S_DRUNK: + case ACHIEVEMENT_CRITERIA_REQUIRE_S_DRUNK: return Player::GetDrunkenstateByValue(source->GetDrunkValue()) >= drunk.state; - case ACHIEVEMENT_CRITERIA_DATA_TYPE_HOLIDAY: + case ACHIEVEMENT_CRITERIA_REQUIRE_HOLIDAY: return IsHolidayActive(HolidayIds(holiday.id)); - case ACHIEVEMENT_CRITERIA_DATA_TYPE_BG_LOSS_TEAM_SCORE: + case ACHIEVEMENT_CRITERIA_REQUIRE_BG_LOSS_TEAM_SCORE: { BattleGround* bg = source->GetBattleGround(); if(!bg) @@ -316,7 +316,7 @@ bool AchievementCriteriaData::Meets(Player const* source, Unit const* target, ui return false; } -bool AchievementCriteriaDataSet::Meets(Player const* source, Unit const* target, uint32 miscvalue /*= 0*/) const +bool AchievementCriteriaRequirementSet::Meets(Player const* source, Unit const* target, uint32 miscvalue /*= 0*/) const { for(Storage::const_iterator itr = storage.begin(); itr != storage.end(); ++itr) if(!itr->Meets(source,target,miscvalue)) @@ -741,7 +741,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (achievementCriteria->win_bg.additionalRequirement1_type) { // those requirements couldn't be found in the dbc - AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria); + AchievementCriteriaRequirementSet const* data = achievementmgr.GetCriteriaRequirementSet(achievementCriteria); if (!data || !data->Meets(GetPlayer(),unit)) continue; } @@ -787,7 +787,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // those requirements couldn't be found in the dbc - AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria); + AchievementCriteriaRequirementSet const* data = achievementmgr.GetCriteriaRequirementSet(achievementCriteria); if(!data || !data->Meets(GetPlayer(),unit)) continue; @@ -955,7 +955,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // those requirements couldn't be found in the dbc - AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria); + AchievementCriteriaRequirementSet const* data = achievementmgr.GetCriteriaRequirementSet(achievementCriteria); if(!data || !data->Meets(GetPlayer(),unit)) continue; @@ -997,7 +997,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui case 1789: { // those requirements couldn't be found in the dbc - AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria); + AchievementCriteriaRequirementSet const* data = achievementmgr.GetCriteriaRequirementSet(achievementCriteria); if(!data || !data->Meets(GetPlayer(),unit)) continue; break; @@ -1023,7 +1023,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; // those requirements couldn't be found in the dbc - AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria); + AchievementCriteriaRequirementSet const* data = achievementmgr.GetCriteriaRequirementSet(achievementCriteria); if(!data) continue; @@ -1053,7 +1053,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if(achievementCriteria->loot_type.lootTypeCount==1) { // those requirements couldn't be found in the dbc - AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria); + AchievementCriteriaRequirementSet const* data = achievementmgr.GetCriteriaRequirementSet(achievementCriteria); if(!data || !data->Meets(GetPlayer(),unit)) continue; } @@ -1076,7 +1076,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if(achievementCriteria->win_rated_arena.flag==ACHIEVEMENT_CRITERIA_CONDITION_NO_LOOSE) { // those requirements couldn't be found in the dbc - AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria); + AchievementCriteriaRequirementSet const* data = achievementmgr.GetCriteriaRequirementSet(achievementCriteria); if(!data || !data->Meets(GetPlayer(),unit,miscvalue1)) { // reset the progress as we have a win without the requirement. @@ -1191,7 +1191,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if(achievementCriteria->do_emote.count) { // those requirements couldn't be found in the dbc - AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria); + AchievementCriteriaRequirementSet const* data = achievementmgr.GetCriteriaRequirementSet(achievementCriteria); if(!data || !data->Meets(GetPlayer(),unit)) continue; } @@ -1272,7 +1272,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui if (achievementCriteria->win_duel.duelCount) { // those requirements couldn't be found in the dbc - AchievementCriteriaDataSet const* data = achievementmgr.GetCriteriaDataSet(achievementCriteria); + AchievementCriteriaRequirementSet const* data = achievementmgr.GetCriteriaRequirementSet(achievementCriteria); if (!data) continue; @@ -1848,11 +1848,11 @@ void AchievementGlobalMgr::LoadAchievementReferenceList() sLog.outString(">> Loaded %u achievement references.",count); } -void AchievementGlobalMgr::LoadAchievementCriteriaData() +void AchievementGlobalMgr::LoadAchievementCriteriaRequirements() { - m_criteriaDataMap.clear(); // need for reload case + m_criteriaRequirementMap.clear(); // need for reload case - QueryResult *result = WorldDatabase.Query("SELECT criteria_id, type, value1, value2 FROM achievement_criteria_data"); + QueryResult *result = WorldDatabase.Query("SELECT criteria_id, type, value1, value2 FROM achievement_criteria_requirement"); if(!result) { @@ -1860,7 +1860,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData() bar.step(); sLog.outString(); - sLog.outString(">> Loaded 0 additional achievement criteria data. DB table `achievement_criteria_data` is empty."); + sLog.outString(">> Loaded 0 additional achievement criteria data. DB table `achievement_criteria_requirement` is empty."); return; } @@ -1877,11 +1877,11 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData() if (!criteria) { - sLog.outErrorDb( "Table `achievement_criteria_data` have data for not existed criteria (Entry: %u), ignore.", criteria_id); + sLog.outErrorDb( "Table `achievement_criteria_requirement` have data for not existed criteria (Entry: %u), ignore.", criteria_id); continue; } - AchievementCriteriaData data(fields[1].GetUInt32(),fields[2].GetUInt32(),fields[3].GetUInt32()); + AchievementCriteriaRequirement data(fields[1].GetUInt32(),fields[2].GetUInt32(),fields[3].GetUInt32()); if (!data.IsValid(criteria)) { @@ -1889,16 +1889,17 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData() } // this will allocate empty data set storage - AchievementCriteriaDataSet& dataSet = m_criteriaDataMap[criteria_id]; + AchievementCriteriaRequirementSet& dataSet = m_criteriaRequirementMap[criteria_id]; - if (data.dataType == ACHIEVEMENT_CRITERIA_DATA_TYPE_DISABLED) + // counting disable criteria requirements + if (data.requirementType == ACHIEVEMENT_CRITERIA_REQUIRE_DISABLED) ++disabled_count; - // add real data only for not NONE data types - if (data.dataType != ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE) + // add real data only for not NONE requirements + if (data.requirementType != ACHIEVEMENT_CRITERIA_REQUIRE_NONE) dataSet.Add(data); - // counting data by and data types + // counting requirements ++count; } while(result->NextRow()); @@ -1965,8 +1966,8 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData() continue; } - if(!GetCriteriaDataSet(criteria)) - sLog.outErrorDb( "Table `achievement_criteria_data` not have expected data for criteria (Entry: %u Type: %u) for achievement %u.", criteria->ID, criteria->requiredType, criteria->referredAchievement); + if(!GetCriteriaRequirementSet(criteria)) + sLog.outErrorDb( "Table `achievement_criteria_requirement` not have expected data for criteria (Entry: %u Type: %u) for achievement %u.", criteria->ID, criteria->requiredType, criteria->referredAchievement); } sLog.outString(); diff --git a/src/game/AchievementMgr.h b/src/game/AchievementMgr.h index eedd74700..caaf16659 100644 --- a/src/game/AchievementMgr.h +++ b/src/game/AchievementMgr.h @@ -40,114 +40,114 @@ struct CriteriaProgress bool changed; }; -enum AchievementCriteriaDataType +enum AchievementCriteriaRequirementType { // value1 value2 comment - ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE = 0, // 0 0 - ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE = 1, // creature_id 0 - ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE = 2, // class_id race_id - ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH= 3, // health_percent 0 - ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD = 4, // own_team 0 not corpse (not released body), own_team==false if enemy team expected - ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA = 5, // spell_id effect_idx - ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AREA = 6, // area id 0 - ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA = 7, // spell_id effect_idx - ACHIEVEMENT_CRITERIA_DATA_TYPE_VALUE = 8, // minvalue value provided with achievement update must be not less that limit - ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL = 9, // minlevel minlevel of target - ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER = 10,// gender 0=male; 1=female - ACHIEVEMENT_CRITERIA_DATA_TYPE_DISABLED = 11,// used to prevent achievement creteria complete if not all requirement implemented and listed in table - ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY = 12,// difficulty normal/heroic difficulty for current event map - ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT = 13,// count "with less than %u people in the zone" - ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM = 14,// team HORDE(67), ALLIANCE(469) - ACHIEVEMENT_CRITERIA_DATA_TYPE_S_DRUNK = 15,// drunken_state 0 (enum DrunkenState) of player - ACHIEVEMENT_CRITERIA_DATA_TYPE_HOLIDAY = 16,// holiday_id 0 event in holiday time - ACHIEVEMENT_CRITERIA_DATA_TYPE_BG_LOSS_TEAM_SCORE = 17,// min_score max_score player's team win bg and opposition team have team score in range + ACHIEVEMENT_CRITERIA_REQUIRE_NONE = 0, // 0 0 + ACHIEVEMENT_CRITERIA_REQUIRE_T_CREATURE = 1, // creature_id 0 + ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_CLASS_RACE = 2, // class_id race_id + ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_LESS_HEALTH= 3, // health_percent 0 + ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD = 4, // own_team 0 not corpse (not released body), own_team==false if enemy team expected + ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA = 5, // spell_id effect_idx + ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA = 6, // area id 0 + ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA = 7, // spell_id effect_idx + ACHIEVEMENT_CRITERIA_REQUIRE_VALUE = 8, // minvalue value provided with achievement update must be not less that limit + ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL = 9, // minlevel minlevel of target + ACHIEVEMENT_CRITERIA_REQUIRE_T_GENDER = 10, // gender 0=male; 1=female + ACHIEVEMENT_CRITERIA_REQUIRE_DISABLED = 11, // used to prevent achievement creteria complete if not all requirement implemented and listed in table + ACHIEVEMENT_CRITERIA_REQUIRE_MAP_DIFFICULTY = 12, // difficulty normal/heroic difficulty for current event map + ACHIEVEMENT_CRITERIA_REQUIRE_MAP_PLAYER_COUNT = 13, // count "with less than %u people in the zone" + ACHIEVEMENT_CRITERIA_REQUIRE_T_TEAM = 14, // team HORDE(67), ALLIANCE(469) + ACHIEVEMENT_CRITERIA_REQUIRE_S_DRUNK = 15, // drunken_state 0 (enum DrunkenState) of player + ACHIEVEMENT_CRITERIA_REQUIRE_HOLIDAY = 16, // holiday_id 0 event in holiday time + ACHIEVEMENT_CRITERIA_REQUIRE_BG_LOSS_TEAM_SCORE = 17, // min_score max_score player's team win bg and opposition team have team score in range }; -#define MAX_ACHIEVEMENT_CRITERIA_DATA_TYPE 18 // maximum value in AchievementCriteriaDataType enum +#define MAX_ACHIEVEMENT_CRITERIA_REQUIREMENT_TYPE 18 // maximum value in AchievementCriteriaRequirementType enum class Player; class Unit; -struct AchievementCriteriaData +struct AchievementCriteriaRequirement { - AchievementCriteriaDataType dataType; + AchievementCriteriaRequirementType requirementType; union { - // ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE = 0 (no data) - // ACHIEVEMENT_CRITERIA_DATA_TYPE_T_CREATURE = 1 + // ACHIEVEMENT_CRITERIA_REQUIRE_NONE = 0 (no data) + // ACHIEVEMENT_CRITERIA_REQUIRE_T_CREATURE = 1 struct { uint32 id; } creature; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_CLASS_RACE = 2 + // ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_CLASS_RACE = 2 struct { uint32 class_id; uint32 race_id; } classRace; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_LESS_HEALTH = 3 + // ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_LESS_HEALTH = 3 struct { uint32 percent; } health; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_T_PLAYER_DEAD = 4 + // ACHIEVEMENT_CRITERIA_REQUIRE_T_PLAYER_DEAD = 4 struct { uint32 own_team_flag; } player_dead; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AURA = 5 - // ACHIEVEMENT_CRITERIA_DATA_TYPE_T_AURA = 7 + // ACHIEVEMENT_CRITERIA_REQUIRE_S_AURA = 5 + // ACHIEVEMENT_CRITERIA_REQUIRE_T_AURA = 7 struct { uint32 spell_id; uint32 effect_idx; } aura; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_S_AREA = 6 + // ACHIEVEMENT_CRITERIA_REQUIRE_S_AREA = 6 struct { uint32 id; } area; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_VALUE = 8 + // ACHIEVEMENT_CRITERIA_REQUIRE_VALUE = 8 struct { uint32 minvalue; } value; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_T_LEVEL = 9 + // ACHIEVEMENT_CRITERIA_REQUIRE_T_LEVEL = 9 struct { uint32 minlevel; } level; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_T_GENDER = 10 + // ACHIEVEMENT_CRITERIA_REQUIRE_T_GENDER = 10 struct { uint32 gender; } gender; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_DISABLED = 11 (no data) - // ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY = 12 + // ACHIEVEMENT_CRITERIA_REQUIRE_DISABLED = 11 (no data) + // ACHIEVEMENT_CRITERIA_REQUIRE_MAP_DIFFICULTY = 12 struct { uint32 difficulty; } difficulty; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT = 13 + // ACHIEVEMENT_CRITERIA_REQUIRE_MAP_PLAYER_COUNT = 13 struct { uint32 maxcount; } map_players; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_T_TEAM = 14 + // ACHIEVEMENT_CRITERIA_REQUIRE_T_TEAM = 14 struct { uint32 team; } team; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_S_DRUNK = 15 + // ACHIEVEMENT_CRITERIA_REQUIRE_S_DRUNK = 15 struct { uint32 state; } drunk; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_HOLIDAY = 16 + // ACHIEVEMENT_CRITERIA_REQUIRE_HOLIDAY = 16 struct { uint32 id; } holiday; - // ACHIEVEMENT_CRITERIA_DATA_TYPE_BG_LOSS_TEAM_SCORE= 17 + // ACHIEVEMENT_CRITERIA_REQUIRE_BG_LOSS_TEAM_SCORE= 17 struct { uint32 min_score; @@ -161,13 +161,14 @@ struct AchievementCriteriaData } raw; }; - AchievementCriteriaData() : dataType(ACHIEVEMENT_CRITERIA_DATA_TYPE_NONE) + AchievementCriteriaRequirement() : requirementType(ACHIEVEMENT_CRITERIA_REQUIRE_NONE) { raw.value1 = 0; raw.value2 = 0; } - AchievementCriteriaData(uint32 _dataType, uint32 _value1, uint32 _value2) : dataType(AchievementCriteriaDataType(_dataType)) + AchievementCriteriaRequirement(uint32 reqType, uint32 _value1, uint32 _value2) + : requirementType(AchievementCriteriaRequirementType(reqType)) { raw.value1 = _value1; raw.value2 = _value2; @@ -177,17 +178,16 @@ struct AchievementCriteriaData bool Meets(Player const* source, Unit const* target, uint32 miscvalue1 = 0) const; }; -struct AchievementCriteriaDataSet +struct AchievementCriteriaRequirementSet { - typedef std::vector Storage; - void Add(AchievementCriteriaData const& data) { storage.push_back(data); } + typedef std::vector Storage; + void Add(AchievementCriteriaRequirement const& data) { storage.push_back(data); } bool Meets(Player const* source, Unit const* target, uint32 miscvalue = 0) const; private: Storage storage; }; - -typedef std::map AchievementCriteriaDataMap; +typedef std::map AchievementCriteriaRequirementMap; struct AchievementReward { @@ -284,10 +284,10 @@ class AchievementGlobalMgr return iter!=m_achievementRewardLocales.end() ? &iter->second : NULL; } - AchievementCriteriaDataSet const* GetCriteriaDataSet(AchievementCriteriaEntry const *achievementCriteria) + AchievementCriteriaRequirementSet const* GetCriteriaRequirementSet(AchievementCriteriaEntry const *achievementCriteria) { - AchievementCriteriaDataMap::const_iterator iter = m_criteriaDataMap.find(achievementCriteria->ID); - return iter!=m_criteriaDataMap.end() ? &iter->second : NULL; + AchievementCriteriaRequirementMap::const_iterator iter = m_criteriaRequirementMap.find(achievementCriteria->ID); + return iter!=m_criteriaRequirementMap.end() ? &iter->second : NULL; } bool IsRealmCompleted(AchievementEntry const* achievement) const @@ -301,13 +301,13 @@ class AchievementGlobalMgr } void LoadAchievementCriteriaList(); - void LoadAchievementCriteriaData(); + void LoadAchievementCriteriaRequirements(); void LoadAchievementReferenceList(); void LoadCompletedAchievements(); void LoadRewards(); void LoadRewardLocales(); private: - AchievementCriteriaDataMap m_criteriaDataMap; + AchievementCriteriaRequirementMap m_criteriaRequirementMap; // store achievement criterias by type to speed up lookup AchievementCriteriaEntryList m_AchievementCriteriasByType[ACHIEVEMENT_CRITERIA_TYPE_TOTAL]; diff --git a/src/game/ChannelMgr.cpp b/src/game/ChannelMgr.cpp index e3b54d346..5d8279696 100644 --- a/src/game/ChannelMgr.cpp +++ b/src/game/ChannelMgr.cpp @@ -46,18 +46,27 @@ ChannelMgr::~ChannelMgr() Channel *ChannelMgr::GetJoinChannel(std::string name, uint32 channel_id) { - if (channels.find(name) == channels.end()) + std::wstring wname; + Utf8toWStr(name,wname); + wstrToLower(wname); + + if (channels.find(wname) == channels.end()) { Channel *nchan = new Channel(name,channel_id); - channels[name] = nchan; + channels[wname] = nchan; + return nchan; } - return channels[name]; + return channels[wname]; } Channel *ChannelMgr::GetChannel(std::string name, Player *p, bool pkt) { - ChannelMap::const_iterator i = channels.find(name); + std::wstring wname; + Utf8toWStr(name,wname); + wstrToLower(wname); + + ChannelMap::const_iterator i = channels.find(wname); if(i == channels.end()) { @@ -76,7 +85,11 @@ Channel *ChannelMgr::GetChannel(std::string name, Player *p, bool pkt) void ChannelMgr::LeftChannel(std::string name) { - ChannelMap::const_iterator i = channels.find(name); + std::wstring wname; + Utf8toWStr(name,wname); + wstrToLower(wname); + + ChannelMap::const_iterator i = channels.find(wname); if(i == channels.end()) return; @@ -85,7 +98,7 @@ void ChannelMgr::LeftChannel(std::string name) if(channel->GetNumPlayers() == 0 && !channel->IsConstant()) { - channels.erase(name); + channels.erase(wname); delete channel; } } diff --git a/src/game/ChannelMgr.h b/src/game/ChannelMgr.h index 27c3dca3f..9b2dcc5c6 100644 --- a/src/game/ChannelMgr.h +++ b/src/game/ChannelMgr.h @@ -28,7 +28,7 @@ class ChannelMgr { public: - typedef std::map ChannelMap; + typedef std::map ChannelMap; ChannelMgr() {} ~ChannelMgr(); diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 20ac51d75..aa550947b 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -705,7 +705,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder) pCurrChar->SendInitialPacketsAfterAddToMap(); CharacterDatabase.PExecute("UPDATE characters SET online = 1 WHERE guid = '%u'", pCurrChar->GetGUIDLow()); - loginDatabase.PExecute("UPDATE account SET online = 1 WHERE id = '%u'", GetAccountId()); + loginDatabase.PExecute("UPDATE account SET active_realm_id = %d WHERE id = '%u'", realmID, GetAccountId()); pCurrChar->SetInGameTime( getMSTime() ); // announce group about member online (must be after add to player list to receive announce to self) diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 5c8afa6c5..17f586ad4 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -396,7 +396,7 @@ ChatCommand * ChatHandler::getCommandTable() { "config", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadConfigCommand, "", NULL }, - { "achievement_criteria_data", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAchievementCriteriaDataCommand, "", NULL }, + { "achievement_criteria_requirement",SEC_ADMINISTRATOR,true,&ChatHandler::HandleReloadAchievementCriteriaRequirementCommand,"",NULL }, { "achievement_reward", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAchievementRewardCommand, "", NULL }, { "areatrigger_involvedrelation",SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadQuestAreaTriggersCommand, "", NULL }, { "areatrigger_tavern", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadAreaTriggerTavernCommand, "", NULL }, diff --git a/src/game/Chat.h b/src/game/Chat.h index 6e7ee3e89..271640e6c 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -318,7 +318,7 @@ class ChatHandler bool HandleReloadConfigCommand(const char* args); - bool HandleReloadAchievementCriteriaDataCommand(const char* args); + bool HandleReloadAchievementCriteriaRequirementCommand(const char* args); bool HandleReloadAchievementRewardCommand(const char* args); bool HandleReloadAreaTriggerTavernCommand(const char* args); bool HandleReloadAreaTriggerTeleportCommand(const char* args); diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index f82474f83..a3c62b099 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -188,18 +188,19 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data ) return false; } - // get heroic mode entry + // get difficulty 1 mode entry uint32 actualEntry = Entry; CreatureInfo const *cinfo = normalInfo; - if(normalInfo->HeroicEntry) + if(normalInfo->DifficultyEntry1) { //we already have valid Map pointer for current creature! - if(GetMap()->IsHeroic()) + //FIXME: spawn modes 2-3 must have own case DifficultyEntryN + if(GetMap()->GetSpawnMode() > 0) { - cinfo = objmgr.GetCreatureTemplate(normalInfo->HeroicEntry); + cinfo = objmgr.GetCreatureTemplate(normalInfo->DifficultyEntry1); if(!cinfo) { - sLog.outErrorDb("Creature::UpdateEntry creature heroic entry %u does not exist.", actualEntry); + sLog.outErrorDb("Creature::UpdateEntry creature difficulty 1 entry %u does not exist.", actualEntry); return false; } } @@ -1928,7 +1929,7 @@ CreatureDataAddon const* Creature::GetCreatureAddon() const return addon; } - // dependent from heroic mode entry + // dependent from difficulty mode entry return ObjectMgr::GetCreatureTemplateAddon(GetCreatureInfo()->Entry); } diff --git a/src/game/Creature.h b/src/game/Creature.h index f0025a9c6..122af4d9f 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -158,7 +158,7 @@ enum CreatureFlagsExtra struct CreatureInfo { uint32 Entry; - uint32 HeroicEntry; + uint32 DifficultyEntry1; uint32 KillCredit[MAX_KILL_CREDIT]; uint32 DisplayID_A[2]; uint32 DisplayID_H[2]; @@ -742,7 +742,7 @@ class MANGOS_DLL_SPEC Creature : public Unit float CombatStartZ; private: GridReference m_gridRef; - CreatureInfo const* m_creatureInfo; // in heroic mode can different from ObjMgr::GetCreatureTemplate(GetEntry()) + CreatureInfo const* m_creatureInfo; // in difficulty mode > 0 can different from ObjMgr::GetCreatureTemplate(GetEntry()) bool m_isActiveObject; MonsterMovementFlags m_monsterMoveFlags; }; diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index 3e9c59e28..87edbf125 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -69,8 +69,7 @@ CreatureEventAI::CreatureEventAI(Creature *c ) : CreatureAI(c) #endif if (m_creature->GetMap()->IsDungeon()) { - if( (m_creature->GetMap()->IsHeroic() && (*i).event_flags & EFLAG_HEROIC) || - (!m_creature->GetMap()->IsHeroic() && (*i).event_flags & EFLAG_NORMAL)) + if ((1 << (m_creature->GetMap()->GetSpawnMode()+1)) & (*i).event_flags) { //event flagged for instance mode CreatureEventAIList.push_back(CreatureEventAIHolder(*i)); diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index 092ea1a67..5d942b6e7 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -150,13 +150,15 @@ enum CastFlags enum EventFlags { EFLAG_REPEATABLE = 0x01, //Event repeats - EFLAG_NORMAL = 0x02, //Event only occurs in Normal instance difficulty - EFLAG_HEROIC = 0x04, //Event only occurs in Heroic instance difficulty - EFLAG_RESERVED_3 = 0x08, - EFLAG_RESERVED_4 = 0x10, + EFLAG_DIFFICULTY_0 = 0x02, //Event only occurs in instance difficulty 0 + EFLAG_DIFFICULTY_1 = 0x04, //Event only occurs in instance difficulty 1 + EFLAG_DIFFICULTY_2 = 0x08, //Event only occurs in instance difficulty 2 + EFLAG_DIFFICULTY_3 = 0x10, //Event only occurs in instance difficulty 3 EFLAG_RESERVED_5 = 0x20, EFLAG_RESERVED_6 = 0x40, EFLAG_DEBUG_ONLY = 0x80, //Event only occurs in debug build + + EFLAG_DIFFICULTY_ALL = (EFLAG_DIFFICULTY_0|EFLAG_DIFFICULTY_1|EFLAG_DIFFICULTY_2|EFLAG_DIFFICULTY_3) }; enum SpawnedEventMode diff --git a/src/game/CreatureEventAIMgr.cpp b/src/game/CreatureEventAIMgr.cpp index aa3e219ea..5361073eb 100644 --- a/src/game/CreatureEventAIMgr.cpp +++ b/src/game/CreatureEventAIMgr.cpp @@ -716,14 +716,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts() sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); break; case ACTION_T_SET_INST_DATA: - if (!(temp.event_flags & EFLAG_NORMAL) && !(temp.event_flags & EFLAG_HEROIC)) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without event flags (normal/heroic).", i, j+1); + if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL)) + sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j+1); if (action.set_inst_data.value > 4/*SPECIAL*/) sLog.outErrorDb("CreatureEventAI: Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j+1); break; case ACTION_T_SET_INST_DATA64: - if (!(temp.event_flags & EFLAG_NORMAL) && !(temp.event_flags & EFLAG_HEROIC)) - sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without event flags (normal/heroic).", i, j+1); + if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL)) + sLog.outErrorDb("CreatureEventAI: Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j+1); if (action.set_inst_data64.target >= TARGET_T_END) sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses incorrect Target type", i, j+1); break; diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 1e09d4b61..c37723c22 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -76,7 +76,7 @@ bool ChatHandler::HandleReloadAllCommand(const char*) bool ChatHandler::HandleReloadAllAchievementCommand(const char*) { - HandleReloadAchievementCriteriaDataCommand(""); + HandleReloadAchievementCriteriaRequirementCommand(""); HandleReloadAchievementRewardCommand(""); return true; } @@ -196,11 +196,11 @@ bool ChatHandler::HandleReloadConfigCommand(const char* /*args*/) return true; } -bool ChatHandler::HandleReloadAchievementCriteriaDataCommand(const char*) +bool ChatHandler::HandleReloadAchievementCriteriaRequirementCommand(const char*) { - sLog.outString( "Re-Loading Additional Achievement Criteria Data..." ); - achievementmgr.LoadAchievementCriteriaData(); - SendGlobalSysMessage("DB table `achievement_criteria_data` reloaded."); + sLog.outString( "Re-Loading Additional Achievement Criteria Requirements Data..." ); + achievementmgr.LoadAchievementCriteriaRequirements(); + SendGlobalSysMessage("DB table `achievement_criteria_requirement` reloaded."); return true; } @@ -5910,9 +5910,9 @@ bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/) std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); if (const MapEntry* entry = sMapStore.LookupEntry(itr->first)) { - PSendSysMessage("map: %d (%s) inst: %d perm: %s diff: %s canReset: %s TTR: %s", + PSendSysMessage("map: %d (%s) inst: %d perm: %s diff: %d canReset: %s TTR: %s", itr->first, entry->name[m_session->GetSessionDbcLocale()], save->GetInstanceId(), itr->second.perm ? "yes" : "no", - save->GetDifficulty() == DUNGEON_DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); + save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str()); } else PSendSysMessage("bound for a nonexistant map %u", itr->first); @@ -5933,9 +5933,9 @@ bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/) std::string timeleft = GetTimeString(save->GetResetTime() - time(NULL)); if (const MapEntry* entry = sMapStore.LookupEntry(itr->first)) { - PSendSysMessage("map: %d (%s) inst: %d perm: %s diff: %s canReset: %s TTR: %s", + PSendSysMessage("map: %d (%s) inst: %d perm: %s diff: %d canReset: %s TTR: %s", itr->first, entry->name[m_session->GetSessionDbcLocale()], save->GetInstanceId(), itr->second.perm ? "yes" : "no", - save->GetDifficulty() == DUNGEON_DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); + save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str()); } else PSendSysMessage("bound for a nonexistant map %u", itr->first); @@ -5986,9 +5986,9 @@ bool ChatHandler::HandleInstanceUnbindCommand(const char* args) if (const MapEntry* entry = sMapStore.LookupEntry(itr->first)) { - PSendSysMessage("unbinding map: %d (%s) inst: %d perm: %s diff: %s canReset: %s TTR: %s", + PSendSysMessage("unbinding map: %d (%s) inst: %d perm: %s diff: %d canReset: %s TTR: %s", itr->first, entry->name[m_session->GetSessionDbcLocale()], save->GetInstanceId(), itr->second.perm ? "yes" : "no", - save->GetDifficulty() == DUNGEON_DIFFICULTY_NORMAL ? "normal" : "heroic", save->CanReset() ? "yes" : "no", timeleft.c_str()); + save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str()); } else PSendSysMessage("bound for a nonexistant map %u", itr->first); diff --git a/src/game/Map.cpp b/src/game/Map.cpp index c8ecdcf0c..b2d000aa4 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -735,9 +735,10 @@ void Map::Remove(Player *player, bool remove) { if(remove) player->CleanupsBeforeDelete(); + else + player->RemoveFromWorld(); // invalid coordinates - player->RemoveFromWorld(); player->ResetMap(); if( remove ) @@ -760,8 +761,9 @@ void Map::Remove(Player *player, bool remove) if(remove) player->CleanupsBeforeDelete(); + else + player->RemoveFromWorld(); - player->RemoveFromWorld(); RemoveFromGrid(player,grid,cell); SendRemoveTransports(player); @@ -830,7 +832,11 @@ Map::Remove(T *obj, bool remove) if(obj->isActiveObject()) RemoveFromActive(obj); - obj->RemoveFromWorld(); + if(remove) + obj->CleanupsBeforeDelete(); + else + obj->RemoveFromWorld(); + RemoveFromGrid(obj,grid,cell); UpdateObjectVisibility(obj,cell,p); @@ -2161,9 +2167,6 @@ void Map::RemoveAllObjectsInRemoveList() Remove((GameObject*)obj,true); break; case TYPEID_UNIT: - // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call - // make sure that like sources auras/etc removed before destructor start - ((Creature*)obj)->CleanupsBeforeDelete (); Remove((Creature*)obj,true); break; default: @@ -3487,8 +3490,6 @@ void Map::SendObjectUpdates() { Object* obj = *i_objectsToClientUpdate.begin(); i_objectsToClientUpdate.erase(i_objectsToClientUpdate.begin()); - if (!obj) - continue; obj->BuildUpdateData(update_players); } diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index 65157aedd..7e83ee061 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -184,13 +184,13 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) MapDifficulty const* mapDiff = GetMapDifficultyData(entry->MapID,player->GetDifficulty(entry->map_type == MAP_RAID)); if (!mapDiff) { - bool isHeroicTargetMap = entry->map_type == MAP_RAID - ? (player->GetRaidDifficulty() >= RAID_DIFFICULTY_10MAN_HEROIC) - : (player->GetDungeonDifficulty() >= DUNGEON_DIFFICULTY_HEROIC); + bool isNormalTargetMap = entry->map_type == MAP_RAID + ? (player->GetRaidDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL) + : (player->GetDungeonDifficulty() == DUNGEON_DIFFICULTY_NORMAL); //Send aborted message // FIX ME: what about absent normal/heroic mode with specific players limit... - player->SendTransferAborted(mapid, TRANSFER_ABORT_DIFFICULTY, isHeroicTargetMap ? DUNGEON_DIFFICULTY_HEROIC : DUNGEON_DIFFICULTY_NORMAL); + player->SendTransferAborted(mapid, TRANSFER_ABORT_DIFFICULTY, isNormalTargetMap ? DUNGEON_DIFFICULTY_NORMAL : DUNGEON_DIFFICULTY_HEROIC); return false; } diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index 14dc8be38..323074302 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -812,12 +812,12 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) if(!mapEntry) return; - bool isHeroicTargetMap = mapEntry->IsRaid() - ? (GetPlayer()->GetRaidDifficulty() >= RAID_DIFFICULTY_10MAN_HEROIC) - : (GetPlayer()->GetDungeonDifficulty() >= DUNGEON_DIFFICULTY_HEROIC); + bool isNormalTargetMap = mapEntry->IsRaid() + ? (GetPlayer()->GetRaidDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL) + : (GetPlayer()->GetDungeonDifficulty() == DUNGEON_DIFFICULTY_NORMAL); uint32 missingKey = 0; - if(isHeroicTargetMap) + if (!isNormalTargetMap) { if(at->heroicKey) { @@ -830,7 +830,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) } uint32 missingQuest = 0; - if(isHeroicTargetMap) + if (!isNormalTargetMap) { if (at->requiredQuestHeroic && !GetPlayer()->GetQuestRewardStatus(at->requiredQuestHeroic)) missingQuest = at->requiredQuestHeroic; @@ -847,7 +847,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) if(missingItem) SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED_AND_ITEM), at->requiredLevel, objmgr.GetItemPrototype(missingItem)->Name1); else if(missingKey) - GetPlayer()->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_DIFFICULTY, isHeroicTargetMap ? DUNGEON_DIFFICULTY_HEROIC : DUNGEON_DIFFICULTY_NORMAL); + GetPlayer()->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_DIFFICULTY, isNormalTargetMap ? DUNGEON_DIFFICULTY_NORMAL : DUNGEON_DIFFICULTY_HEROIC); else if(missingQuest) SendAreaTriggerMessage(at->requiredFailedText.c_str()); else if(missingLevel) diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 491c8f958..834680c17 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1112,6 +1112,7 @@ WorldObject::WorldObject() void WorldObject::CleanupsBeforeDelete() { + RemoveFromWorld(); } void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 phaseMask ) diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h index 9c58222f4..8377724a8 100644 --- a/src/game/ObjectAccessor.h +++ b/src/game/ObjectAccessor.h @@ -134,15 +134,13 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton static OBJECT* FindHelper(uint64 guid) { - OBJECT* ret = NULL; - std::list::const_iterator i = i_mapList.begin(); - while (i != i_mapList.end() && !ret) + for (std::list::const_iterator i = i_mapList.begin() ; i != i_mapList.end(); ++i) { - ret = (*i)->GetObjectsStore().find(guid, (OBJECT*)NULL); - ++i; + if (OBJECT* ret = (*i)->GetObjectsStore().find(guid, (OBJECT*)NULL)) + return ret; } - return ret; + return NULL; } static std::list i_mapList; diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index edfca2b95..358f12ab4 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -473,8 +473,8 @@ void ObjectMgr::LoadCreatureTemplates() sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount ); sLog.outString(); - std::set heroicEntries; // already loaded heroic value in creatures - std::set hasHeroicEntries; // already loaded creatures with heroic entry values + std::set difficultyEntries1; // already loaded difficulty 1 value in creatures + std::set hasDifficultyEntries1; // already loaded creatures with difficulty 1 values // check data correctness for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i) @@ -483,83 +483,83 @@ void ObjectMgr::LoadCreatureTemplates() if (!cInfo) continue; - if (cInfo->HeroicEntry) + if (cInfo->DifficultyEntry1) { - CreatureInfo const* heroicInfo = GetCreatureTemplate(cInfo->HeroicEntry); - if (!heroicInfo) + CreatureInfo const* difficultyInfo = GetCreatureTemplate(cInfo->DifficultyEntry1); + if (!difficultyInfo) { - sLog.outErrorDb("Creature (Entry: %u) have `heroic_entry`=%u but creature entry %u not exist.", i, cInfo->HeroicEntry, cInfo->HeroicEntry); + sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_1`=%u but creature entry %u not exist.", i, cInfo->DifficultyEntry1, cInfo->DifficultyEntry1); continue; } - if (heroicEntries.find(i)!=heroicEntries.end()) + if (difficultyEntries1.find(i)!=difficultyEntries1.end()) { - sLog.outErrorDb("Creature (Entry: %u) listed as heroic but have value in `heroic_entry`.",i); + sLog.outErrorDb("Creature (Entry: %u) listed as difficulty 1 but have value in `difficulty_entry_1`.",i); continue; } - if (heroicEntries.find(cInfo->HeroicEntry)!=heroicEntries.end()) + if (difficultyEntries1.find(cInfo->DifficultyEntry1)!=difficultyEntries1.end()) { - sLog.outErrorDb("Creature (Entry: %u) already listed as heroic for another entry.",cInfo->HeroicEntry); + sLog.outErrorDb("Creature (Entry: %u) already listed as difficulty 1 for another entry.",cInfo->DifficultyEntry1); continue; } - if (hasHeroicEntries.find(cInfo->HeroicEntry)!=hasHeroicEntries.end()) + if (hasDifficultyEntries1.find(cInfo->DifficultyEntry1)!=hasDifficultyEntries1.end()) { - sLog.outErrorDb("Creature (Entry: %u) have `heroic_entry`=%u but creature entry %u have heroic entry also.",i,cInfo->HeroicEntry,cInfo->HeroicEntry); + sLog.outErrorDb("Creature (Entry: %u) have `difficulty_entry_1`=%u but creature entry %u have difficulty 1 entry also.",i,cInfo->DifficultyEntry1,cInfo->DifficultyEntry1); continue; } - if (cInfo->unit_class != heroicInfo->unit_class) + if (cInfo->unit_class != difficultyInfo->unit_class) { - sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in heroic mode (Entry: %u, class %u).",i, cInfo->unit_class, cInfo->HeroicEntry, heroicInfo->unit_class); + sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in difficulty 1 mode (Entry: %u, class %u).",i, cInfo->unit_class, cInfo->DifficultyEntry1, difficultyInfo->unit_class); continue; } - if (cInfo->npcflag != heroicInfo->npcflag) + if (cInfo->npcflag != difficultyInfo->npcflag) { - sLog.outErrorDb("Creature (Entry: %u) has different `npcflag` in heroic mode (Entry: %u).",i,cInfo->HeroicEntry); + sLog.outErrorDb("Creature (Entry: %u) has different `npcflag` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1); continue; } - if (cInfo->trainer_class != heroicInfo->trainer_class) + if (cInfo->trainer_class != difficultyInfo->trainer_class) { - sLog.outErrorDb("Creature (Entry: %u) has different `trainer_class` in heroic mode (Entry: %u).",i,cInfo->HeroicEntry); + sLog.outErrorDb("Creature (Entry: %u) has different `trainer_class` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1); continue; } - if (cInfo->trainer_race != heroicInfo->trainer_race) + if (cInfo->trainer_race != difficultyInfo->trainer_race) { - sLog.outErrorDb("Creature (Entry: %u) has different `trainer_race` in heroic mode (Entry: %u).",i,cInfo->HeroicEntry); + sLog.outErrorDb("Creature (Entry: %u) has different `trainer_race` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1); continue; } - if (cInfo->trainer_type != heroicInfo->trainer_type) + if (cInfo->trainer_type != difficultyInfo->trainer_type) { - sLog.outErrorDb("Creature (Entry: %u) has different `trainer_type` in heroic mode (Entry: %u).",i,cInfo->HeroicEntry); + sLog.outErrorDb("Creature (Entry: %u) has different `trainer_type` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1); continue; } - if (cInfo->trainer_spell != heroicInfo->trainer_spell) + if (cInfo->trainer_spell != difficultyInfo->trainer_spell) { - sLog.outErrorDb("Creature (Entry: %u) has different `trainer_spell` in heroic mode (Entry: %u).",i,cInfo->HeroicEntry); + sLog.outErrorDb("Creature (Entry: %u) has different `trainer_spell` in difficulty 1 mode (Entry: %u).",i,cInfo->DifficultyEntry1); continue; } - if (heroicInfo->AIName && *heroicInfo->AIName) + if (difficultyInfo->AIName && *difficultyInfo->AIName) { - sLog.outErrorDb("Heroic mode creature (Entry: %u) has `AIName`, but in any case will used normal mode creature (Entry: %u) AIName.",cInfo->HeroicEntry,i); + sLog.outErrorDb("Difficulty 1 mode creature (Entry: %u) has `AIName`, but in any case will used difficulty 0 mode creature (Entry: %u) AIName.",cInfo->DifficultyEntry1,i); continue; } - if (heroicInfo->ScriptID) + if (difficultyInfo->ScriptID) { - sLog.outErrorDb("Heroic mode creature (Entry: %u) has `ScriptName`, but in any case will used normal mode creature (Entry: %u) ScriptName.",cInfo->HeroicEntry,i); + sLog.outErrorDb("Difficulty 1 mode creature (Entry: %u) has `ScriptName`, but in any case will used difficulty 0 mode creature (Entry: %u) ScriptName.",cInfo->DifficultyEntry1,i); continue; } - hasHeroicEntries.insert(i); - heroicEntries.insert(cInfo->HeroicEntry); + hasDifficultyEntries1.insert(i); + difficultyEntries1.insert(cInfo->DifficultyEntry1); } FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_A); @@ -1032,11 +1032,11 @@ void ObjectMgr::LoadCreatures() } // build single time for check creature data - std::set heroicCreatures; + std::set difficultyCreatures1; for(uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i) if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(i)) - if(cInfo->HeroicEntry) - heroicCreatures.insert(cInfo->HeroicEntry); + if(cInfo->DifficultyEntry1) + difficultyCreatures1.insert(cInfo->DifficultyEntry1); // build single time for check spawnmask std::map spawnMasks; @@ -1095,9 +1095,9 @@ void ObjectMgr::LoadCreatures() if (data.spawnMask & ~spawnMasks[data.mapid]) sLog.outErrorDb("Table `creature` have creature (GUID: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u).",guid, data.spawnMask, data.mapid ); - if(heroicCreatures.find(data.id)!=heroicCreatures.end()) + if(difficultyCreatures1.find(data.id)!=difficultyCreatures1.end()) { - sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as heroic template (entry: %u) in `creature_template`, skipped.",guid, data.id ); + sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as difficulty 1 template (entry: %u) in `creature_template`, skipped.",guid, data.id ); continue; } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 8e69128f1..6c2613417 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1757,11 +1757,12 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati } GetSession()->SendPacket( &data ); SendSavedInstances(); - - // remove from old map now - if(oldmap) oldmap->Remove(this, false); } + // remove from old map now + if(oldmap) + oldmap->Remove(this, false); + // new final coordinates float final_x = x; float final_y = y; diff --git a/src/game/Player.h b/src/game/Player.h index d2ef251de..e9f13ca18 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -161,7 +161,7 @@ struct ActionButton void SetActionAndType(uint32 action, ActionButtonType type) { uint32 newData = action | (uint32(type) << 24); - if (newData != packedData) + if (newData != packedData || uState == ACTIONBUTTON_DELETED) { packedData = newData; if (uState != ACTIONBUTTON_NEW) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 7cba1ea40..582946a67 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -4401,13 +4401,23 @@ void Aura::HandlePeriodicEnergize(bool apply, bool Real) if (!Real) return; - m_isPeriodic = apply; + if (apply) + { + switch (GetId()) + { + case 48391: // Owlkin Frenzy 2% base mana + m_modifier.m_amount = m_target->GetCreateMana() * 2 / 100; + break; + case 57669: // Replenishment (0.25% from max) + case 61782: // Infinite Replenishment + m_modifier.m_amount = m_target->GetMaxPower(POWER_MANA) * 25 / 10000; + break; + default: + break; + } + } - // Replenishment (0.25% from max) - // Infinite Replenishment - if (GetId() == 57669 || - GetId() == 61782) - m_modifier.m_amount = m_target->GetMaxPower(POWER_MANA) * 25 / 10000; + m_isPeriodic = apply; } void Aura::HandleAuraPowerBurn(bool apply, bool /*Real*/) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 268577939..bfe3eca10 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1760,13 +1760,25 @@ void Spell::EffectDummy(uint32 i) } case 31789: // Righteous Defense (step 1) { + if (m_caster->GetTypeId() != TYPEID_PLAYER) + { + SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT); + return; + } + // 31989 -> dummy effect (step 1) + dummy effect (step 2) -> 31709 (taunt like spell for each target) + Unit* friendTarget = !unitTarget || unitTarget->IsFriendlyTo(m_caster) ? unitTarget : unitTarget->getVictim(); + if (friendTarget) + { + Player* player = friendTarget->GetCharmerOrOwnerPlayerOrPlayerItself(); + if (!player || !player->IsInSameRaidWith((Player*)m_caster)) + friendTarget = NULL; + } // non-standard cast requirement check - if (!unitTarget || unitTarget->getAttackers().empty()) + if (!friendTarget || friendTarget->getAttackers().empty()) { - if (m_caster->GetTypeId()==TYPEID_PLAYER) - ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id,true); + ((Player*)m_caster)->RemoveSpellCooldown(m_spellInfo->Id,true); SendCastResult(SPELL_FAILED_TARGET_AFFECTING_COMBAT); return; } @@ -1776,18 +1788,16 @@ void Spell::EffectDummy(uint32 i) for(std::list::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) ihit->effectMask &= ~(1<<1); - // not empty (checked) - Unit::AttackerSet const& attackers = unitTarget->getAttackers(); + // not empty (checked), copy + Unit::AttackerSet attackers = friendTarget->getAttackers(); - // chance to be selected from list - float chance = 100.0f/attackers.size(); - uint32 count=0; - for(Unit::AttackerSet::const_iterator aItr = attackers.begin(); aItr != attackers.end() && count < 3; ++aItr) + // selected from list 3 + for(int i = 0; i < std::min(size_t(3),attackers.size()); ++i) { - if (!roll_chance_f(chance)) - continue; - ++count; + Unit::AttackerSet::iterator aItr = attackers.begin(); + std::advance(aItr, rand() % attackers.size()); AddUnitTarget((*aItr), 1); + attackers.erase(aItr); } // now let next effect cast spell at each target. @@ -5086,10 +5096,10 @@ void Spell::EffectScriptEffect(uint32 effIndex) // Emblazon Runeblade case 51770: { - if(!unitTarget) + if(!m_originalCaster) return; - unitTarget->CastSpell(unitTarget, 51771, false); + m_originalCaster->CastSpell(m_originalCaster, damage, false); break; } // Death Gate diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 309c09875..a282c96d1 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -11110,7 +11110,7 @@ void Unit::CleanupsBeforeDelete() RemoveAllDynObjects(); GetMotionMaster()->Clear(false); // remove different non-standard movement generators. } - RemoveFromWorld(); + WorldObject::CleanupsBeforeDelete(); } CharmInfo* Unit::InitCharmInfo(Unit *charm) diff --git a/src/game/World.cpp b/src/game/World.cpp index 6f19225e1..a2931c63b 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1354,7 +1354,7 @@ void World::SetInitialWorldSettings() sLog.outString(); achievementmgr.LoadAchievementReferenceList(); achievementmgr.LoadAchievementCriteriaList(); - achievementmgr.LoadAchievementCriteriaData(); + achievementmgr.LoadAchievementCriteriaRequirements(); achievementmgr.LoadRewards(); achievementmgr.LoadRewardLocales(); achievementmgr.LoadCompletedAchievements(); diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 78886e3dc..fbdf79e6a 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -375,7 +375,7 @@ void WorldSession::LogoutPlayer(bool Save) ///- Reset the online field in the account table // no point resetting online in character table here as Player::SaveToDB() will set it to 1 since player has not been removed from world at this stage //No SQL injection as AccountID is uint32 - loginDatabase.PExecute("UPDATE account SET online = 0 WHERE id = '%u'", GetAccountId()); + loginDatabase.PExecute("UPDATE account SET active_realm_id = 0 WHERE id = '%u'", GetAccountId()); ///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members Guild *guild = objmgr.GetGuildById(_player->GetGuildId()); diff --git a/src/mangosd/Master.cpp b/src/mangosd/Master.cpp index 68113ee7d..56dd504d6 100644 --- a/src/mangosd/Master.cpp +++ b/src/mangosd/Master.cpp @@ -460,6 +460,7 @@ bool Master::_StartDB() sLog.outError("Realm ID not defined in configuration file"); return false; } + sLog.outString("Realm running as realm ID %d", realmID); ///- Clean the database before starting @@ -477,9 +478,7 @@ void Master::clearOnlineAccounts() { // Cleanup online status for characters hosted at current realm /// \todo Only accounts with characters logged on *this* realm should have online status reset. Move the online column from 'account' to 'realmcharacters'? - loginDatabase.PExecute( - "UPDATE account SET online = 0 WHERE online > 0 " - "AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')",realmID); + loginDatabase.PExecute("UPDATE account SET active_realm_id = 0 WHERE active_realm_id = '%d'", realmID); CharacterDatabase.Execute("UPDATE characters SET online = 0 WHERE online<>0"); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index fcf402369..4b1ffe600 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8722" + #define REVISION_NR "8734" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 9f2da9b59..ed97f2ba0 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ #define REVISION_DB_CHARACTERS "required_8721_01_characters_guild" - #define REVISION_DB_MANGOS "required_8720_01_mangos_quest_template" - #define REVISION_DB_REALMD "required_8332_01_realmd_realmcharacters" + #define REVISION_DB_MANGOS "required_8731_01_mangos_creature_template" + #define REVISION_DB_REALMD "required_8728_01_realmd_account" #endif // __REVISION_SQL_H__