From 55e715dddd477b4193ce95107877982a73c0074d Mon Sep 17 00:00:00 2001 From: Splinter Date: Tue, 17 Nov 2009 08:38:15 +0300 Subject: [PATCH 01/17] [8824] Implement 3.2.x changes for spell 5308 and ranks. Signed-off-by: VladimirMangos --- src/game/SpellEffects.cpp | 18 +++++++++++++----- src/shared/revision_nr.h | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index 3069f06a8..8a89bc197 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1399,14 +1399,22 @@ void Spell::EffectDummy(uint32 i) return; uint32 rage = m_caster->GetPower(POWER_RAGE); - // Glyph of Execution bonus - if (Aura *aura = m_caster->GetDummyAura(58367)) - rage+=aura->GetModifier()->m_amount; - int32 basePoints0 = damage+int32(rage * m_spellInfo->DmgMultiplier[i] + + // up to max 30 rage cost + if(rage > 30) + rage = 30; + + // Glyph of Execution bonus + uint32 rage_modified = rage; + + if (Aura *aura = m_caster->GetDummyAura(58367)) + rage_modified += aura->GetModifier()->m_amount; + + int32 basePoints0 = damage+int32(rage_modified * m_spellInfo->DmgMultiplier[i] + m_caster->GetTotalAttackPowerValue(BASE_ATTACK)*0.2f); + m_caster->CastCustomSpell(unitTarget, 20647, &basePoints0, NULL, NULL, true, 0); - m_caster->SetPower(POWER_RAGE, 0); + m_caster->SetPower(POWER_RAGE, m_caster->GetPower(POWER_RAGE)-rage); return; } // Slam diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index d5fdb2f5f..4578afef2 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 "8823" + #define REVISION_NR "8824" #endif // __REVISION_NR_H__ From bc5fb40867a1f1c2e9bb4e7933e3ccb5f43c1f79 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Tue, 17 Nov 2009 12:38:13 +0300 Subject: [PATCH 02/17] [8825] At fail start db connections stop all started db connection threads. This will restore state before start Db function call and prevent crashes at delayed access to log singleton in case outdated DB structure detection. --- src/mangosd/Master.cpp | 34 ++++++++++++++++++++++++++++++++++ src/realmd/Main.cpp | 4 ++++ src/shared/revision_nr.h | 2 +- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/mangosd/Master.cpp b/src/mangosd/Master.cpp index 56dd504d6..8e4daa9b4 100644 --- a/src/mangosd/Master.cpp +++ b/src/mangosd/Master.cpp @@ -414,12 +414,19 @@ bool Master::_StartDB() } if(!WorldDatabase.CheckRequiredField("db_version",REVISION_DB_MANGOS)) + { + ///- Wait for already started DB delay threads to end + WorldDatabase.HaltDelayThread(); return false; + } dbstring = sConfig.GetStringDefault("CharacterDatabaseInfo", ""); if(dbstring.empty()) { sLog.outError("Character Database not specified in configuration file"); + + ///- Wait for already started DB delay threads to end + WorldDatabase.HaltDelayThread(); return false; } sLog.outString("Character Database: %s", dbstring.c_str()); @@ -428,17 +435,29 @@ bool Master::_StartDB() if(!CharacterDatabase.Initialize(dbstring.c_str())) { sLog.outError("Cannot connect to Character database %s",dbstring.c_str()); + + ///- Wait for already started DB delay threads to end + WorldDatabase.HaltDelayThread(); return false; } if(!CharacterDatabase.CheckRequiredField("character_db_version",REVISION_DB_CHARACTERS)) + { + ///- Wait for already started DB delay threads to end + WorldDatabase.HaltDelayThread(); + CharacterDatabase.HaltDelayThread(); return false; + } ///- Get login database info from configuration file dbstring = sConfig.GetStringDefault("LoginDatabaseInfo", ""); if(dbstring.empty()) { sLog.outError("Login database not specified in configuration file"); + + ///- Wait for already started DB delay threads to end + WorldDatabase.HaltDelayThread(); + CharacterDatabase.HaltDelayThread(); return false; } @@ -447,17 +466,32 @@ bool Master::_StartDB() if(!loginDatabase.Initialize(dbstring.c_str())) { sLog.outError("Cannot connect to login database %s",dbstring.c_str()); + + ///- Wait for already started DB delay threads to end + WorldDatabase.HaltDelayThread(); + CharacterDatabase.HaltDelayThread(); return false; } if(!loginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD)) + { + ///- Wait for already started DB delay threads to end + WorldDatabase.HaltDelayThread(); + CharacterDatabase.HaltDelayThread(); + loginDatabase.HaltDelayThread(); return false; + } ///- Get the realm Id from the configuration file realmID = sConfig.GetIntDefault("RealmID", 0); if(!realmID) { sLog.outError("Realm ID not defined in configuration file"); + + ///- Wait for already started DB delay threads to end + WorldDatabase.HaltDelayThread(); + CharacterDatabase.HaltDelayThread(); + loginDatabase.HaltDelayThread(); return false; } diff --git a/src/realmd/Main.cpp b/src/realmd/Main.cpp index c25d827d1..c1be328c9 100644 --- a/src/realmd/Main.cpp +++ b/src/realmd/Main.cpp @@ -332,7 +332,11 @@ bool StartDB() } if(!loginDatabase.CheckRequiredField("realmd_db_version",REVISION_DB_REALMD)) + { + ///- Wait for already started DB delay threads to end + loginDatabase.HaltDelayThread(); return false; + } return true; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 4578afef2..8dad645a8 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 "8824" + #define REVISION_NR "8825" #endif // __REVISION_NR_H__ From 84432d8459bf09d296bb0875cf48ca93ec7e63de Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Tue, 17 Nov 2009 15:40:24 +0100 Subject: [PATCH 03/17] [8826] Set creatures PvP state flag based on creature faction and rename related enum Condition with custom flag civilian and player team only is not sufficient. This update also disallow use *_addon -table (second byte of bytes2) to set flag manually (small chance it may be needed) Signed-off-by: NoFantasy --- src/game/Creature.cpp | 17 ++++++++--------- src/game/DBCEnums.h | 3 ++- src/game/Unit.h | 2 +- src/shared/revision_nr.h | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 812def559..b5903a6ed 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -306,14 +306,13 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData *data ) SetCanModifyStats(true); UpdateAllStats(); - FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(GetCreatureInfo()->faction_A); - if (factionTemplate) // check and error show at loading templates + // checked and error show at loading templates + if (FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(GetCreatureInfo()->faction_A)) { - FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction); - if (factionEntry) - if( !(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_CIVILIAN) && - (factionEntry->team == ALLIANCE || factionEntry->team == HORDE) ) - SetPvP(true); + if (factionTemplate->factionFlags & FACTION_TEMPLATE_FLAG_PVP) + SetPvP(true); + else + SetPvP(false); } for(int i=0; i < CREATURE_MAX_SPELLS; ++i) @@ -1971,12 +1970,12 @@ bool Creature::LoadCreaturesAddon(bool reload) if (cainfo->bytes2 != 0) { // 0 SheathState - // 1 Bytes2Flags + // 1 UnitPVPStateFlags Set at Creature::UpdateEntry (SetPvp()) // 2 UnitRename Pet only, so always 0 for default creature // 3 ShapeshiftForm Must be determined/set by shapeshift spell/aura SetByteValue(UNIT_FIELD_BYTES_2, 0, uint8(cainfo->bytes2 & 0xFF)); - SetByteValue(UNIT_FIELD_BYTES_2, 1, uint8((cainfo->bytes2 >> 8) & 0xFF)); + //SetByteValue(UNIT_FIELD_BYTES_2, 1, uint8((cainfo->bytes2 >> 8) & 0xFF)); //SetByteValue(UNIT_FIELD_BYTES_2, 2, uint8((cainfo->bytes2 >> 16) & 0xFF)); SetByteValue(UNIT_FIELD_BYTES_2, 2, 0); //SetByteValue(UNIT_FIELD_BYTES_2, 3, uint8((cainfo->bytes2 >> 24) & 0xFF)); diff --git a/src/game/DBCEnums.h b/src/game/DBCEnums.h index d56cb7e14..9eae1082d 100644 --- a/src/game/DBCEnums.h +++ b/src/game/DBCEnums.h @@ -268,7 +268,8 @@ enum SpawnMask enum FactionTemplateFlags { - FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats + FACTION_TEMPLATE_FLAG_PVP = 0x00000800, // flagged for PvP + FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats }; enum FactionMasks diff --git a/src/game/Unit.h b/src/game/Unit.h index cfba59cd7..04ba5ec70 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -195,7 +195,7 @@ enum SheathState #define MAX_SHEATH_STATE 3 // byte (1 from 0..3) of UNIT_FIELD_BYTES_2 -enum UnitBytes2_Flags +enum UnitPVPStateFlags { UNIT_BYTE2_FLAG_PVP = 0x01, UNIT_BYTE2_FLAG_UNK1 = 0x02, diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8dad645a8..ba758ebda 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 "8825" + #define REVISION_NR "8826" #endif // __REVISION_NR_H__ From 70fb82b262d6558f7e6885cd9ad197cf1e635384 Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Tue, 17 Nov 2009 17:39:37 +0100 Subject: [PATCH 04/17] [8827] Add a missing stand_state definition (and fill in with a few unknown) Signed-off-by: NoFantasy --- src/game/Unit.h | 8 +++++++- src/shared/revision_nr.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/game/Unit.h b/src/game/Unit.h index 04ba5ec70..aa1d5fce2 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -137,13 +137,18 @@ enum UnitStandStateType UNIT_STAND_STATE_SIT_MEDIUM_CHAIR = 5, UNIT_STAND_STATE_SIT_HIGH_CHAIR = 6, UNIT_STAND_STATE_DEAD = 7, - UNIT_STAND_STATE_KNEEL = 8 + UNIT_STAND_STATE_KNEEL = 8, + UNIT_STAND_STATE_SUBMERGED = 9 }; // byte flag value (UNIT_FIELD_BYTES_1,2) enum UnitStandFlags { + UNIT_STAND_FLAGS_UNK1 = 0x01, UNIT_STAND_FLAGS_CREEP = 0x02, + UNIT_STAND_FLAGS_UNK3 = 0x04, + UNIT_STAND_FLAGS_UNK4 = 0x08, + UNIT_STAND_FLAGS_UNK5 = 0x10, UNIT_STAND_FLAGS_ALL = 0xFF }; @@ -151,6 +156,7 @@ enum UnitStandFlags enum UnitBytes1_Flags { UNIT_BYTE1_FLAG_ALWAYS_STAND = 0x01, + UNIT_BYTE1_FLAG_UNK_2 = 0x02, UNIT_BYTE1_FLAG_UNTRACKABLE = 0x04, UNIT_BYTE1_FLAG_ALL = 0xFF }; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ba758ebda..b62b615b2 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 "8826" + #define REVISION_NR "8827" #endif // __REVISION_NR_H__ From 37ba6623bbdbeb2fbd75d9e334b240b072a1e304 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 18 Nov 2009 09:58:10 +0300 Subject: [PATCH 05/17] [8828] Independent instance reset time for different difficulties. * Store reset time for map/difficulty pairs. * Use DBC data for reset time and max players instead `instance_template` fields (dropped) for each existed map/difficulty pair. * Fix some "heroic" related checks in spells/etc. --- sql/characters.sql | 5 +- sql/mangos.sql | 5 +- .../8828_01_characters_instance_reset.sql | 6 + .../8828_02_mangos_instance_template.sql | 6 + sql/updates/Makefile.am | 4 + src/game/DBCEnums.h | 4 +- src/game/DBCStores.cpp | 1 - src/game/DBCStores.h | 2 + src/game/InstanceSaveMgr.cpp | 113 +++++++++++------- src/game/InstanceSaveMgr.h | 27 +++-- src/game/Map.cpp | 23 ++-- src/game/Map.h | 10 +- src/game/MovementHandler.cpp | 17 +-- src/game/ObjectMgr.cpp | 36 +----- src/game/SpellAuras.cpp | 2 +- src/game/Unit.cpp | 2 +- src/shared/Database/SQLStorage.cpp | 4 +- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 4 +- 19 files changed, 149 insertions(+), 124 deletions(-) create mode 100644 sql/updates/8828_01_characters_instance_reset.sql create mode 100644 sql/updates/8828_02_mangos_instance_template.sql diff --git a/sql/characters.sql b/sql/characters.sql index aed3b1d0f..6d4debeef 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -21,7 +21,7 @@ DROP TABLE IF EXISTS `character_db_version`; CREATE TABLE `character_db_version` ( - `required_8721_01_characters_guild` bit(1) default NULL + `required_8828_01_characters_instance_reset` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; -- @@ -1170,8 +1170,9 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `instance_reset`; CREATE TABLE `instance_reset` ( `mapid` int(11) unsigned NOT NULL default '0', + `difficulty` tinyint(1) unsigned NOT NULL default '0', `resettime` bigint(40) NOT NULL default '0', - PRIMARY KEY (`mapid`) + PRIMARY KEY (`mapid`,`difficulty`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- diff --git a/sql/mangos.sql b/sql/mangos.sql index d8c98dae7..377f82e32 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_8818_01_mangos_mangos_string` bit(1) default NULL + `required_8828_02_mangos_instance_template` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -1904,9 +1904,6 @@ CREATE TABLE `instance_template` ( `parent` int(10) unsigned NOT NULL, `levelMin` tinyint(3) unsigned NOT NULL default '0', `levelMax` tinyint(3) unsigned NOT NULL default '0', - `maxPlayers` tinyint(3) unsigned NOT NULL default '0', - `maxPlayersHeroic` tinyint(3) unsigned NOT NULL default '0', - `reset_delay` int(10) unsigned NOT NULL default '0', `startLocX` float default NULL, `startLocY` float default NULL, `startLocZ` float default NULL, diff --git a/sql/updates/8828_01_characters_instance_reset.sql b/sql/updates/8828_01_characters_instance_reset.sql new file mode 100644 index 000000000..0fb87f4c7 --- /dev/null +++ b/sql/updates/8828_01_characters_instance_reset.sql @@ -0,0 +1,6 @@ +ALTER TABLE character_db_version CHANGE COLUMN required_8721_01_characters_guild required_8828_01_characters_instance_reset bit; + +ALTER TABLE instance_reset + ADD COLUMN difficulty tinyint(1) unsigned NOT NULL default '0' AFTER mapid, + DROP PRIMARY KEY, + ADD PRIMARY KEY (`mapid`,`difficulty`); diff --git a/sql/updates/8828_02_mangos_instance_template.sql b/sql/updates/8828_02_mangos_instance_template.sql new file mode 100644 index 000000000..c5f1815b9 --- /dev/null +++ b/sql/updates/8828_02_mangos_instance_template.sql @@ -0,0 +1,6 @@ +ALTER TABLE db_version CHANGE COLUMN required_8818_01_mangos_mangos_string required_8828_02_mangos_instance_template bit; + +ALTER TABLE instance_template + DROP COLUMN maxPlayers, + DROP COLUMN maxPlayersHeroic, + DROP COLUMN reset_delay; diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index ecb0c3202..f27eb879d 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -158,6 +158,8 @@ pkgdata_DATA = \ 8803_02_mangos_playercreateinfo_action.sql \ 8815_01_mangos_mangos_string.sql \ 8818_01_mangos_mangos_string.sql \ + 8828_01_characters_instance_reset.sql \ + 8828_02_mangos_instance_template.sql \ README ## Additional files to include when running 'make dist' @@ -296,4 +298,6 @@ EXTRA_DIST = \ 8803_02_mangos_playercreateinfo_action.sql \ 8815_01_mangos_mangos_string.sql \ 8818_01_mangos_mangos_string.sql \ + 8828_01_characters_instance_reset.sql \ + 8828_02_mangos_instance_template.sql \ README diff --git a/src/game/DBCEnums.h b/src/game/DBCEnums.h index 9eae1082d..8b0833859 100644 --- a/src/game/DBCEnums.h +++ b/src/game/DBCEnums.h @@ -234,6 +234,8 @@ enum AreaFlags enum Difficulty { + DIFFICULTY_DEFAULT = 0, + DUNGEON_DIFFICULTY_NORMAL = 0, DUNGEON_DIFFICULTY_HEROIC = 1, @@ -249,7 +251,7 @@ enum Difficulty enum SpawnMask { - SPAWNMASK_CONTINENT = 1, // any any maps without spawn modes + SPAWNMASK_CONTINENT = (1 << DIFFICULTY_DEFAULT),// any any maps without spawn modes SPAWNMASK_DUNGEON_NORMAL = (1 << DUNGEON_DIFFICULTY_NORMAL), SPAWNMASK_DUNGEON_HEROIC = (1 << DUNGEON_DIFFICULTY_HEROIC), diff --git a/src/game/DBCStores.cpp b/src/game/DBCStores.cpp index 6d09018e1..743c79552 100644 --- a/src/game/DBCStores.cpp +++ b/src/game/DBCStores.cpp @@ -100,7 +100,6 @@ DBCStorage sMapStore(MapEntryfmt); // DBC used only for initialization sMapDifficultyMap at startup. DBCStorage sMapDifficultyStore(MapDifficultyEntryfmt); // only for loading -typedef std::map MapDifficultyMap; MapDifficultyMap sMapDifficultyMap; DBCStorage sMovieStore(MovieEntryfmt); diff --git a/src/game/DBCStores.h b/src/game/DBCStores.h index 046cfc6b5..691c4354c 100644 --- a/src/game/DBCStores.h +++ b/src/game/DBCStores.h @@ -55,6 +55,7 @@ bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredT void Zone2MapCoordinates(float& x,float& y,uint32 zone); void Map2ZoneCoordinates(float& x,float& y,uint32 zone); +typedef std::map MapDifficultyMap; MapDifficulty const* GetMapDifficultyData(uint32 mapId, Difficulty difficulty); uint32 const* /*[3]*/ GetTalentTabPages(uint32 cls); @@ -113,6 +114,7 @@ extern DBCStorage sLockStore; extern DBCStorage sMailTemplateStore; extern DBCStorage sMapStore; //extern DBCStorage sMapDifficultyStore; -- use GetMapDifficultyData insteed +extern MapDifficultyMap sMapDifficultyMap; extern DBCStorage sMovieStore; extern DBCStorage sQuestSortStore; extern DBCStorage sRandomPropertiesPointsStore; diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp index 8963de3f5..ea713d95a 100644 --- a/src/game/InstanceSaveMgr.cpp +++ b/src/game/InstanceSaveMgr.cpp @@ -100,13 +100,13 @@ InstanceSave* InstanceSaveManager::AddInstanceSave(uint32 mapId, uint32 instance { // initialize reset time // for normal instances if no creatures are killed the instance will reset in two hours - if(entry->map_type == MAP_RAID || difficulty == DUNGEON_DIFFICULTY_HEROIC) - resetTime = GetResetTimeFor(mapId); + if(entry->map_type == MAP_RAID || difficulty > DUNGEON_DIFFICULTY_NORMAL) + resetTime = GetResetTimeFor(mapId,difficulty); else { resetTime = time(NULL) + 2 * HOUR; // normally this will be removed soon after in InstanceMap::Add, prevent error - ScheduleReset(true, resetTime, InstResetEvent(0, mapId, instanceId)); + ScheduleReset(true, resetTime, InstResetEvent(0, mapId, difficulty, instanceId)); } } @@ -378,18 +378,26 @@ void InstanceSaveManager::LoadResetTimes() // get the current reset times for normal instances (these may need to be updated) // these are only kept in memory for InstanceSaves that are loaded later // resettime = 0 in the DB for raid/heroic instances so those are skipped - typedef std::map > ResetTimeMapType; - ResetTimeMapType InstResetTime; - QueryResult *result = CharacterDatabase.Query("SELECT id, map, resettime FROM instance WHERE resettime > 0"); + typedef std::pair ResetTimeMapDiffType; + typedef std::map InstResetTimeMapDiffType; + InstResetTimeMapDiffType instResetTime; + + // index instance ids by map/difficulty pairs for fast reset warning send + typedef std::multimap ResetTimeMapDiffInstances; + ResetTimeMapDiffInstances mapDiffResetInstances; + + QueryResult *result = CharacterDatabase.Query("SELECT id, map, difficulty, resettime FROM instance WHERE resettime > 0"); if( result ) { do { - if(time_t resettime = time_t((*result)[2].GetUInt64())) + if(time_t resettime = time_t((*result)[3].GetUInt64())) { uint32 id = (*result)[0].GetUInt32(); uint32 mapid = (*result)[1].GetUInt32(); - InstResetTime[id] = std::pair(mapid, resettime); + uint32 difficulty = (*result)[2].GetUInt32(); + instResetTime[id] = ResetTimeMapDiffType(MAKE_PAIR32(mapid,difficulty), resettime); + mapDiffResetInstances.insert(ResetTimeMapDiffInstances::value_type(MAKE_PAIR32(mapid,difficulty),id)); } } while (result->NextRow()); @@ -404,8 +412,8 @@ void InstanceSaveManager::LoadResetTimes() Field *fields = result->Fetch(); uint32 instance = fields[1].GetUInt32(); time_t resettime = time_t(fields[0].GetUInt64() + 2 * HOUR); - ResetTimeMapType::iterator itr = InstResetTime.find(instance); - if(itr != InstResetTime.end() && itr->second.second != resettime) + InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance); + if(itr != instResetTime.end() && itr->second.second != resettime) { CharacterDatabase.DirectPExecute("UPDATE instance SET resettime = '"UI64FMTD"' WHERE id = '%u'", uint64(resettime), instance); itr->second.second = resettime; @@ -416,59 +424,65 @@ void InstanceSaveManager::LoadResetTimes() } // schedule the reset times - for(ResetTimeMapType::iterator itr = InstResetTime.begin(); itr != InstResetTime.end(); ++itr) + for(InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr) if(itr->second.second > now) - ScheduleReset(true, itr->second.second, InstResetEvent(0, itr->second.first, itr->first)); + ScheduleReset(true, itr->second.second, InstResetEvent(0, PAIR32_LOPART(itr->second.first),Difficulty(PAIR32_HIPART(itr->second.first)),itr->first)); } // load the global respawn times for raid/heroic instances uint32 diff = sWorld.getConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR; - m_resetTimeByMapId.resize(sMapStore.GetNumRows()+1); - result = CharacterDatabase.Query("SELECT mapid, resettime FROM instance_reset"); + result = CharacterDatabase.Query("SELECT mapid, difficulty, resettime FROM instance_reset"); if(result) { do { Field *fields = result->Fetch(); uint32 mapid = fields[0].GetUInt32(); - if(!ObjectMgr::GetInstanceTemplate(mapid)) + Difficulty difficulty = Difficulty(fields[1].GetUInt32()); + uint64 oldresettime = fields[2].GetUInt64(); + + MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,difficulty); + if(!mapDiff) { - sLog.outError("InstanceSaveManager::LoadResetTimes: invalid mapid %u in instance_reset!", mapid); - CharacterDatabase.DirectPExecute("DELETE FROM instance_reset WHERE mapid = '%u'", mapid); + sLog.outError("InstanceSaveManager::LoadResetTimes: invalid mapid(%u)/difficulty(%u) pair in instance_reset!", mapid, difficulty); + CharacterDatabase.DirectPExecute("DELETE FROM instance_reset WHERE mapid = '%u' AND difficulty = '%u'", mapid,difficulty); continue; } // update the reset time if the hour in the configs changes - uint64 oldresettime = fields[1].GetUInt64(); uint64 newresettime = (oldresettime / DAY) * DAY + diff; if(oldresettime != newresettime) - CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u'", newresettime, mapid); + CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty = '%u'", newresettime, mapid, difficulty); - m_resetTimeByMapId[mapid] = newresettime; + SetResetTimeFor(mapid,difficulty,newresettime); } while(result->NextRow()); delete result; } // clean expired instances, references to them will be deleted in CleanupInstances // must be done before calculating new reset times - _DelHelper(CharacterDatabase, "id, map, difficulty", "instance", "LEFT JOIN instance_reset ON mapid = map WHERE (instance.resettime < '"UI64FMTD"' AND instance.resettime > '0') OR (NOT instance_reset.resettime IS NULL AND instance_reset.resettime < '"UI64FMTD"')", (uint64)now, (uint64)now); + _DelHelper(CharacterDatabase, "id, map, instance.difficulty", "instance", "LEFT JOIN instance_reset ON mapid = map AND instance.difficulty = instance_reset.difficulty WHERE (instance.resettime < '"UI64FMTD"' AND instance.resettime > '0') OR (NOT instance_reset.resettime IS NULL AND instance_reset.resettime < '"UI64FMTD"')", (uint64)now, (uint64)now); // calculate new global reset times for expired instances and those that have never been reset yet // add the global reset times to the priority queue - for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++) + for(MapDifficultyMap::const_iterator itr = sMapDifficultyMap.begin(); itr != sMapDifficultyMap.end(); ++itr) { - InstanceTemplate const* temp = ObjectMgr::GetInstanceTemplate(i); - if(!temp || temp->reset_delay == 0) + 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; + if (!mapDiff->resetTime) continue; - uint32 period = temp->reset_delay * DAY; - assert(period != 0); - time_t t = m_resetTimeByMapId[temp->map]; + // the reset_delay must be at least one day + uint32 period = (mapDiff->resetTime / DAY * sWorld.getRate(RATE_INSTANCE_RESET_TIME)) * DAY; + + time_t t = GetResetTimeFor(mapid,difficulty); if(!t) { // initialize the reset time t = today + period + diff; - CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u','"UI64FMTD"')", i, (uint64)t); + CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u','%u','"UI64FMTD"')", mapid, difficulty, (uint64)t); } if(t < now) @@ -477,17 +491,23 @@ void InstanceSaveManager::LoadResetTimes() // calculate the next reset time t = (t / DAY) * DAY; t += ((today - t) / period + 1) * period + diff; - CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u'", (uint64)t, i); + CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%u' AND difficulty= '%u'", (uint64)t, mapid, difficulty); } - m_resetTimeByMapId[temp->map] = t; + SetResetTimeFor(mapid,difficulty,t); // schedule the global reset/warning uint8 type = 1; static int tim[4] = {3600, 900, 300, 60}; for(; type < 4; type++) - if(t - tim[type-1] > now) break; - ScheduleReset(true, t - tim[type-1], InstResetEvent(type, i)); + if(t - tim[type-1] > now) + break; + + for(ResetTimeMapDiffInstances::const_iterator in_itr = mapDiffResetInstances.lower_bound(map_diff_pair); + in_itr != mapDiffResetInstances.upper_bound(map_diff_pair); ++in_itr) + { + ScheduleReset(true, t - tim[type-1], InstResetEvent(type, mapid, difficulty, in_itr->second)); + } } } @@ -528,8 +548,8 @@ void InstanceSaveManager::Update() else { // global reset/warning for a certain map - time_t resetTime = GetResetTimeFor(event.mapid); - _ResetOrWarnAll(event.mapid, event.type != 4, resetTime - now); + time_t resetTime = GetResetTimeFor(event.mapid,event.difficulty); + _ResetOrWarnAll(event.mapid, event.difficulty, event.type != 4, resetTime - now); if(event.type != 4) { // schedule the next warning/reset @@ -580,29 +600,28 @@ void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId) else sObjectMgr.DeleteRespawnTimeForInstance(instanceId); // even if map is not loaded } -void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLeft) +void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool warn, uint32 timeLeft) { // global reset for all instances of the given map - // note: this isn't fast but it's meant to be executed very rarely - Map const *map = sMapMgr.CreateBaseMap(mapid); - if(!map->Instanceable()) + MapEntry const *mapEntry = sMapStore.LookupEntry(mapid); + if (!mapEntry->Instanceable()) return; + uint64 now = (uint64)time(NULL); - if(!warn) + if (!warn) { - // this is called one minute before the reset time - InstanceTemplate const* temp = ObjectMgr::GetInstanceTemplate(mapid); - if(!temp || !temp->reset_delay) + MapDifficulty const* mapDiff = GetMapDifficultyData(mapid,difficulty); + if (!mapDiff || !mapDiff->resetTime) { - sLog.outError("InstanceSaveManager::ResetOrWarnAll: no instance template or reset delay for map %d", mapid); + sLog.outError("InstanceSaveManager::ResetOrWarnAll: not valid difficulty or no reset delay for map %d", mapid); return; } // remove all binds to instances of the given map for(InstanceSaveHashMap::iterator itr = m_instanceSaveById.begin(); itr != m_instanceSaveById.end();) { - if(itr->second->GetMapId() == mapid) + if (itr->second->GetMapId() == mapid && itr->second->GetDifficulty() == difficulty) _ResetSave(itr); else ++itr; @@ -617,12 +636,14 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLe // calculate the next reset time uint32 diff = sWorld.getConfig(CONFIG_INSTANCE_RESET_TIME_HOUR) * HOUR; - uint32 period = temp->reset_delay * DAY; + uint32 period = mapDiff->resetTime * DAY; uint64 next_reset = ((now + timeLeft + MINUTE) / DAY * DAY) + period + diff; // update it in the DB - CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%d'", next_reset, mapid); + CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%d' AND difficulty = '%d'", next_reset, mapid, difficulty); } + // note: this isn't fast but it's meant to be executed very rarely + Map const *map = sMapMgr.CreateBaseMap(mapid); // _not_ include difficulty MapInstanced::InstancedMaps &instMaps = ((MapInstanced*)map)->GetInstancedMaps(); MapInstanced::InstancedMaps::iterator mitr; for(mitr = instMaps.begin(); mitr != instMaps.end(); ++mitr) diff --git a/src/game/InstanceSaveMgr.h b/src/game/InstanceSaveMgr.h index c080fd5da..f457fe3de 100644 --- a/src/game/InstanceSaveMgr.h +++ b/src/game/InstanceSaveMgr.h @@ -118,28 +118,39 @@ class MANGOS_DLL_DECL InstanceSaveManager : public MaNGOS::Singleton InstanceSaveMap; typedef UNORDERED_MAP InstanceSaveHashMap; - typedef std::map InstanceSaveMapMap; + typedef UNORDERED_MAP InstanceSaveMapMap; /* resetTime is a global propery of each (raid/heroic) map all instances of that map reset at the same time */ struct InstResetEvent { uint8 type; + Difficulty difficulty:8; uint16 mapid; uint16 instanceId; - InstResetEvent(uint8 t = 0, uint16 m = 0, uint16 i = 0) : type(t), mapid(m), instanceId(i) {} + + InstResetEvent() : type(0), difficulty(DUNGEON_DIFFICULTY_NORMAL), mapid(0), instanceId(0) {} + InstResetEvent(uint8 t, uint32 _mapid, Difficulty d, uint16 _instanceid) + : type(t), difficulty(d), mapid(_mapid), instanceId(_instanceid) {} bool operator == (const InstResetEvent& e) { return e.instanceId == instanceId; } }; typedef std::multimap ResetTimeQueue; - typedef std::vector ResetTimeVector; + typedef UNORDERED_MAP ResetTimeByMapDifficultyMap; void CleanupInstances(); void PackInstances(); void LoadResetTimes(); - time_t GetResetTimeFor(uint32 mapid) { return m_resetTimeByMapId[mapid]; } + time_t GetResetTimeFor(uint32 mapid, Difficulty d) const + { + ResetTimeByMapDifficultyMap::const_iterator itr = m_resetTimeByMapDifficulty.find(MAKE_PAIR32(mapid,d)); + return itr != m_resetTimeByMapDifficulty.end() ? itr->second : 0; + } + void SetResetTimeFor(uint32 mapid, Difficulty d, time_t t) + { + m_resetTimeByMapDifficulty[MAKE_PAIR32(mapid,d)] = t; + } void ScheduleReset(bool add, time_t time, InstResetEvent event); void Update(); @@ -156,7 +167,7 @@ class MANGOS_DLL_DECL InstanceSaveManager : public MaNGOS::SingletonGetResetTime(), InstanceSaveManager::InstResetEvent(0, GetId(), GetInstanceId())); + else sInstanceSaveMgr.ScheduleReset(on, save->GetResetTime(), InstanceSaveManager::InstResetEvent(0, GetId(), Difficulty(GetSpawnMode()), GetInstanceId())); } } +MapDifficulty const* InstanceMap::GetMapDifficulty() const +{ + return GetMapDifficultyData(GetId(),GetDifficulty()); +} + uint32 InstanceMap::GetMaxPlayers() const { - InstanceTemplate const* iTemplate = ObjectMgr::GetInstanceTemplate(GetId()); - if(!iTemplate) - return 0; - return IsHeroic() ? iTemplate->maxPlayersHeroic : iTemplate->maxPlayers; + MapDifficulty const* mapDiff = GetMapDifficulty(); + return mapDiff ? mapDiff->maxPlayers : 0; } +uint32 InstanceMap::GetMaxResetDelay() const +{ + MapDifficulty const* mapDiff = GetMapDifficulty(); + return mapDiff ? mapDiff->resetTime : 0; +} + + /* ******* Battleground Instance Maps ******* */ BattleGroundMap::BattleGroundMap(uint32 id, time_t expiry, uint32 InstanceId, Map* _parent, uint8 spawnMode) @@ -3560,4 +3570,3 @@ uint32 Map::GenerateLocalLowGuid(HighGuid guidhigh) ASSERT(0); return 0; } - diff --git a/src/game/Map.h b/src/game/Map.h index 849efcb8b..428d182c9 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -227,9 +227,6 @@ struct InstanceTemplate uint32 parent; uint32 levelMin; uint32 levelMax; - uint32 maxPlayers; - uint32 maxPlayersHeroic; - uint32 reset_delay; // FIX ME: now exist normal/heroic raids with possible different time of reset. float startLocX; float startLocY; float startLocZ; @@ -373,7 +370,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj // NOTE: this duplicate of Instanceable(), but Instanceable() can be changed when BG also will be instanceable bool IsDungeon() const { return i_mapEntry && i_mapEntry->IsDungeon(); } bool IsRaid() const { return i_mapEntry && i_mapEntry->IsRaid(); } - bool IsHeroic() const { return IsRaid() ? i_spawnMode >= RAID_DIFFICULTY_10MAN_HEROIC : i_spawnMode >= DUNGEON_DIFFICULTY_HEROIC; } + bool IsRaidOrHeroicDungeon() const { return IsRaid() || i_spawnMode > DUNGEON_DIFFICULTY_NORMAL; } bool IsBattleGround() const { return i_mapEntry && i_mapEntry->IsBattleGround(); } bool IsBattleArena() const { return i_mapEntry && i_mapEntry->IsBattleArena(); } bool IsBattleGroundOrArena() const { return i_mapEntry && i_mapEntry->IsBattleGroundOrArena(); } @@ -599,7 +596,12 @@ class MANGOS_DLL_SPEC InstanceMap : public Map bool CanEnter(Player* player); void SendResetWarnings(uint32 timeLeft) const; void SetResetSchedule(bool on); + + // have meaning only for instanced map (that have set real difficulty) + Difficulty GetDifficulty() const { return Difficulty(GetSpawnMode()); } uint32 GetMaxPlayers() const; + uint32 GetMaxResetDelay() const; + MapDifficulty const* GetMapDifficulty() const; virtual void InitVisibilityDistance(); private: diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index 99f8abc12..5853824ef 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -141,20 +141,13 @@ void WorldSession::HandleMoveWorldportAckOpcode() } } - if (mInstance) + if (mInstance && mEntry->IsDungeon()) { - if(mEntry->IsRaid()) + Difficulty diff = GetPlayer()->GetDifficulty(mEntry->IsRaid()); + if (uint32 timeReset = sInstanceSaveMgr.GetResetTimeFor(GetPlayer()->GetMapId(),diff)) { - uint32 timeleft = sInstanceSaveMgr.GetResetTimeFor(GetPlayer()->GetMapId()) - time(NULL); - GetPlayer()->SendInstanceResetWarning(GetPlayer()->GetMapId(), GetPlayer()->GetRaidDifficulty(), timeleft); - } - else if(mEntry->IsNonRaidDungeon() && GetPlayer()->GetDungeonDifficulty() > DUNGEON_DIFFICULTY_NORMAL) - { - if(MapDifficulty const* mapDiff = GetMapDifficultyData(mEntry->MapID,GetPlayer()->GetDungeonDifficulty())) - { - uint32 timeleft = sInstanceSaveMgr.GetResetTimeFor(GetPlayer()->GetMapId()) - time(NULL); - GetPlayer()->SendInstanceResetWarning(GetPlayer()->GetMapId(), GetPlayer()->GetDungeonDifficulty(), timeleft); - } + uint32 timeleft = timeReset - time(NULL); + GetPlayer()->SendInstanceResetWarning(GetPlayer()->GetMapId(), diff, timeleft); } } diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 11b577fdd..b466f121e 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -4593,42 +4593,14 @@ void ObjectMgr::LoadInstanceTemplate() if(!temp) continue; - const MapEntry* entry = sMapStore.LookupEntry(temp->map); - if(!entry) - { + if(!MapManager::IsValidMAP(temp->map)) sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: bad mapid %d for template!", temp->map); - continue; - } - //FIXME: now exist heroic instance, normal/heroic raid instances - // entry->resetTimeHeroic store reset time for both heroic mode instance (raid and non-raid) - // entry->resetTimeRaid store reset time for normal raid only - // for current state entry->resetTimeRaid == entry->resetTimeHeroic in case raid instances with heroic mode. - // but at some point wee need implement reset time dependent from raid instance mode - if(temp->reset_delay == 0) + if(!MapManager::IsValidMapCoord(temp->parent,temp->startLocX,temp->startLocY,temp->startLocZ,temp->startLocO)) { - MapDifficulty const* mapDiffNorm = GetMapDifficultyData(temp->map,DUNGEON_DIFFICULTY_NORMAL); - MapDifficulty const* mapDiffHeroic = GetMapDifficultyData(temp->map,DUNGEON_DIFFICULTY_HEROIC); - - // no reset time - if ((!mapDiffNorm || mapDiffNorm->resetTime == 0) && - (!mapDiffHeroic || mapDiffHeroic->resetTime == 0)) - continue; - - // use defaults from the DBC - if(mapDiffHeroic && mapDiffHeroic->resetTime) // for both raid and non raids, read above - { - temp->reset_delay = mapDiffHeroic->resetTime / DAY; - } - else if (mapDiffNorm && mapDiffNorm->resetTime && entry->map_type == MAP_RAID) - // for normal raid only - { - temp->reset_delay = mapDiffNorm->resetTime / DAY; - } + sLog.outErrorDb("ObjectMgr::LoadInstanceTemplate: bad parent entrance coordinates for map id %d template!", temp->map); + temp->parent = 0; // will have wrong continent 0 parent, at least existed } - - // the reset_delay must be at least one day - temp->reset_delay = std::max((uint32)1, (uint32)(temp->reset_delay * sWorld.getRate(RATE_INSTANCE_RESET_TIME))); } sLog.outString( ">> Loaded %u Instance Template definitions", sInstanceTemplate.RecordCount ); diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index a1cb8d774..4294cb87e 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -2319,7 +2319,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { if (m_target->GetMap()->IsDungeon()) { - uint32 spellId = m_target->GetMap()->IsHeroic() ? 46163 : 44190; + uint32 spellId = ((InstanceMap*)m_target->GetMap())->GetDifficulty() == DIFFICULTY_DEFAULT ? 44190 : 46163; m_target->CastSpell(m_target, spellId, true, NULL, this); } diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 03e4dbefe..f08534bcf 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -683,7 +683,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa if(m->IsDungeon() && creditedPlayer) { - if(m->IsRaid() || m->IsHeroic()) + if (m->IsRaidOrHeroicDungeon()) { if(cVictim->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND) ((InstanceMap *)m)->PermBindAllPlayers(creditedPlayer); diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp index e48f45cf9..0a16e71e0 100644 --- a/src/shared/Database/SQLStorage.cpp +++ b/src/shared/Database/SQLStorage.cpp @@ -36,8 +36,8 @@ const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii"; const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiii"; const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiii"; const char PageTextfmt[]="isi"; -const char InstanceTemplatesrcfmt[]="iiiiiiiffffs"; -const char InstanceTemplatedstfmt[]="iiiiiiiffffi"; +const char InstanceTemplatesrcfmt[]="iiiiffffs"; +const char InstanceTemplatedstfmt[]="iiiiffffi"; SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","creature_template"); SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon"); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index b62b615b2..14a833449 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 "8827" + #define REVISION_NR "8828" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 968f55826..bec923d2d 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_8818_01_mangos_mangos_string" + #define REVISION_DB_CHARACTERS "required_8828_01_characters_instance_reset" + #define REVISION_DB_MANGOS "required_8828_02_mangos_instance_template" #define REVISION_DB_REALMD "required_8728_01_realmd_account" #endif // __REVISION_SQL_H__ From 7a2764e0fe66d4df6bfb865567f8e06012b61a50 Mon Sep 17 00:00:00 2001 From: balrok Date: Wed, 18 Nov 2009 18:53:47 +0100 Subject: [PATCH 06/17] [8829] some more places where we call redundant SaveToDB i also added now my assert with which i've found them.. maybe someone want's to look at other cases too :) --- src/game/Level3.cpp | 3 +-- src/game/MiscHandler.cpp | 3 +-- src/game/Player.cpp | 6 ++++-- src/game/WorldSession.cpp | 4 +++- src/game/WorldSession.h | 3 +++ src/shared/revision_nr.h | 2 +- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 55fd52b9e..245c252ce 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -3511,7 +3511,6 @@ bool ChatHandler::HandleReviveCommand(const char* args) { target->ResurrectPlayer(0.5f); target->SpawnCorpseBones(); - target->SaveToDB(); } else // will resurrected at login without corpse @@ -6394,4 +6393,4 @@ bool ChatHandler::HandleModifyGenderCommand(const char *args) ChatHandler(player).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, GetNameLink().c_str()); return true; -} \ No newline at end of file +} diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index e3f2865f5..ee528e602 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -669,8 +669,7 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket & recv_data) if(!GetPlayer()->isRessurectRequestedBy(guid)) return; - GetPlayer()->ResurectUsingRequestData(); - GetPlayer()->SaveToDB(); + GetPlayer()->ResurectUsingRequestData(); // will call spawncorpsebones } void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 247f2b7f8..558a9d5e4 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -4319,7 +4319,8 @@ void Player::CreateCorpse() void Player::SpawnCorpseBones() { if(sObjectAccessor.ConvertCorpseForPlayer(GetGUID())) - SaveToDB(); // prevent loading as ghost without corpse + if (!GetSession()->PlayerLogoutWithSave()) // at logout we will already store the player + SaveToDB(); // prevent loading as ghost without corpse } Corpse* Player::GetCorpse() const @@ -15619,6 +15620,7 @@ bool Player::_LoadHomeBind(QueryResult *result) void Player::SaveToDB() { + // we should assure this: assert((m_nextSave != sWorld.getConfig(CONFIG_INTERVAL_SAVE))); // delay auto save at any saves (manual, in code, or autosave) m_nextSave = sWorld.getConfig(CONFIG_INTERVAL_SAVE); @@ -20766,4 +20768,4 @@ void Player::SendDuelCountdown(uint32 counter) WorldPacket data(SMSG_DUEL_COUNTDOWN, 4); data << uint32(counter); // seconds GetSession()->SendPacket(&data); -} \ No newline at end of file +} diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 10d9c19b8..ca6b6efd0 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -42,7 +42,7 @@ WorldSession::WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 LookingForGroup_auto_join(false), LookingForGroup_auto_add(false), m_muteTime(mute_time), _player(NULL), m_Socket(sock),_security(sec), _accountId(id), m_expansion(expansion), m_sessionDbcLocale(sWorld.GetAvailableDbcLocale(locale)), m_sessionDbLocaleIndex(sObjectMgr.GetIndexForLocale(locale)), -_logoutTime(0), m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), +_logoutTime(0), m_inQueue(false), m_playerLoading(false), m_playerLogout(false), m_playerRecentlyLogout(false), m_playerSave(false), m_latency(0), m_TutorialsChanged(false) { if (sock) @@ -292,6 +292,7 @@ void WorldSession::LogoutPlayer(bool Save) HandleMoveWorldportAckOpcode(); m_playerLogout = true; + m_playerSave = Save; if (_player) { @@ -454,6 +455,7 @@ void WorldSession::LogoutPlayer(bool Save) } m_playerLogout = false; + m_playerSave = false; m_playerRecentlyLogout = true; LogoutRequest(0); } diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index db5766707..03899d068 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -113,6 +113,8 @@ class MANGOS_DLL_SPEC WorldSession bool PlayerLoading() const { return m_playerLoading; } bool PlayerLogout() const { return m_playerLogout; } + bool PlayerLogoutWithSave() const { return m_playerLogout && m_playerSave; } + void SizeError(WorldPacket const& packet, uint32 size) const; @@ -748,6 +750,7 @@ class MANGOS_DLL_SPEC WorldSession bool m_playerLoading; // code processed in LoginPlayer bool m_playerLogout; // code processed in LogoutPlayer bool m_playerRecentlyLogout; + bool m_playerSave; LocaleConstant m_sessionDbcLocale; int m_sessionDbLocaleIndex; uint32 m_latency; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 14a833449..303e3e9b9 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 "8828" + #define REVISION_NR "8829" #endif // __REVISION_NR_H__ From fe1fae46ee640b7a91bdc8b9af038c54470d3903 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 18 Nov 2009 23:36:08 +0300 Subject: [PATCH 07/17] [8830] Restore build at *nix. Make MAKE_PAIR* users includes explicit. Comment for recently added field also. --- src/game/AccountMgr.cpp | 1 + src/game/ArenaTeam.cpp | 1 + src/game/AuctionHouseHandler.cpp | 1 + src/game/AuctionHouseMgr.cpp | 1 + src/game/BattleGround.cpp | 1 + src/game/CharacterHandler.cpp | 1 + src/game/Chat.cpp | 1 + src/game/Corpse.cpp | 1 + src/game/Creature.cpp | 1 + src/game/GMTicketMgr.cpp | 1 + src/game/GameEventMgr.cpp | 1 + src/game/Group.cpp | 1 + src/game/Guild.h | 2 ++ src/game/InstanceSaveMgr.h | 1 + src/game/Item.cpp | 1 + src/game/Level2.cpp | 1 + src/game/LootHandler.cpp | 1 + src/game/Mail.cpp | 1 + src/game/MiscHandler.cpp | 1 + src/game/Object.cpp | 1 + src/game/ObjectMgr.cpp | 1 + src/game/PetitionsHandler.cpp | 1 + src/game/Player.cpp | 1 + src/game/PoolManager.cpp | 1 + src/game/QueryHandler.cpp | 1 + src/game/SocialMgr.cpp | 1 + src/game/Transports.cpp | 1 + src/game/Unit.cpp | 1 + src/game/WorldSession.h | 2 +- src/game/debugcmds.cpp | 1 + src/shared/revision_nr.h | 2 +- 31 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/game/AccountMgr.cpp b/src/game/AccountMgr.cpp index 1bb61b006..163477409 100644 --- a/src/game/AccountMgr.cpp +++ b/src/game/AccountMgr.cpp @@ -19,6 +19,7 @@ #include "AccountMgr.h" #include "Database/DatabaseEnv.h" #include "ObjectAccessor.h" +#include "ObjectDefines.h" #include "Player.h" #include "Policies/SingletonImp.h" #include "Util.h" diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp index 4464eef96..f33bb9da3 100644 --- a/src/game/ArenaTeam.cpp +++ b/src/game/ArenaTeam.cpp @@ -18,6 +18,7 @@ #include "WorldPacket.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "ArenaTeam.h" #include "World.h" diff --git a/src/game/AuctionHouseHandler.cpp b/src/game/AuctionHouseHandler.cpp index 7c131a1d7..565ba130f 100644 --- a/src/game/AuctionHouseHandler.cpp +++ b/src/game/AuctionHouseHandler.cpp @@ -22,6 +22,7 @@ #include "Log.h" #include "World.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "Player.h" #include "UpdateMask.h" #include "AuctionHouseMgr.h" diff --git a/src/game/AuctionHouseMgr.cpp b/src/game/AuctionHouseMgr.cpp index 83fe25ef3..7243dd426 100644 --- a/src/game/AuctionHouseMgr.cpp +++ b/src/game/AuctionHouseMgr.cpp @@ -28,6 +28,7 @@ #include "Language.h" #include "Log.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "Player.h" #include "World.h" #include "WorldPacket.h" diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index 46a889f1a..903485384 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -27,6 +27,7 @@ #include "ArenaTeam.h" #include "World.h" #include "Group.h" +#include "ObjectDefines.h" #include "ObjectMgr.h" #include "WorldPacket.h" #include "Util.h" diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 815a48c5e..69cd034c5 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -25,6 +25,7 @@ #include "Log.h" #include "World.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "Player.h" #include "Guild.h" #include "UpdateMask.h" diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 90c883152..aba9ae072 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -25,6 +25,7 @@ #include "Log.h" #include "World.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "Player.h" #include "UpdateMask.h" #include "Chat.h" diff --git a/src/game/Corpse.cpp b/src/game/Corpse.cpp index e31a2d94f..572cb7bfc 100644 --- a/src/game/Corpse.cpp +++ b/src/game/Corpse.cpp @@ -21,6 +21,7 @@ #include "Player.h" #include "UpdateMask.h" #include "ObjectAccessor.h" +#include "ObjectDefines.h" #include "Database/DatabaseEnv.h" #include "Opcodes.h" #include "GossipDef.h" diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index b5903a6ed..416ef1912 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -21,6 +21,7 @@ #include "WorldPacket.h" #include "World.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "SpellMgr.h" #include "Creature.h" #include "QuestDef.h" diff --git a/src/game/GMTicketMgr.cpp b/src/game/GMTicketMgr.cpp index 17ed65c7b..50e88ebf6 100644 --- a/src/game/GMTicketMgr.cpp +++ b/src/game/GMTicketMgr.cpp @@ -21,6 +21,7 @@ #include "Database/SQLStorage.h" #include "GMTicketMgr.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "ProgressBar.h" #include "Policies/SingletonImp.h" #include "Player.h" diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp index 71557ad24..a29c48644 100644 --- a/src/game/GameEventMgr.cpp +++ b/src/game/GameEventMgr.cpp @@ -19,6 +19,7 @@ #include "GameEventMgr.h" #include "World.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "PoolManager.h" #include "ProgressBar.h" #include "Language.h" diff --git a/src/game/Group.cpp b/src/game/Group.cpp index 3656ea0d0..389884326 100644 --- a/src/game/Group.cpp +++ b/src/game/Group.cpp @@ -23,6 +23,7 @@ #include "Player.h" #include "World.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "Group.h" #include "Formulas.h" #include "ObjectAccessor.h" diff --git a/src/game/Guild.h b/src/game/Guild.h index ead843981..f75a86ae3 100644 --- a/src/game/Guild.h +++ b/src/game/Guild.h @@ -22,7 +22,9 @@ #define WITHDRAW_MONEY_UNLIMITED 0xFFFFFFFF #define WITHDRAW_SLOT_UNLIMITED 0xFFFFFFFF +#include "Common.h" #include "Item.h" +#include "ObjectDefines.h" class Item; diff --git a/src/game/InstanceSaveMgr.h b/src/game/InstanceSaveMgr.h index f457fe3de..1b5799092 100644 --- a/src/game/InstanceSaveMgr.h +++ b/src/game/InstanceSaveMgr.h @@ -27,6 +27,7 @@ #include "Utilities/UnorderedMap.h" #include "Database/DatabaseEnv.h" #include "DBCEnums.h" +#include "ObjectDefines.h" struct InstanceTemplate; struct MapEntry; diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 00bbe883b..2f5621414 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -19,6 +19,7 @@ #include "Common.h" #include "Item.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "WorldPacket.h" #include "Database/DatabaseEnv.h" #include "ItemEnchantmentMgr.h" diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index bc75ce542..38b1b883c 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -19,6 +19,7 @@ #include "Common.h" #include "Database/DatabaseEnv.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "Player.h" #include "Item.h" #include "GameObject.h" diff --git a/src/game/LootHandler.cpp b/src/game/LootHandler.cpp index f607775f1..d96aef44e 100644 --- a/src/game/LootHandler.cpp +++ b/src/game/LootHandler.cpp @@ -23,6 +23,7 @@ #include "GameObject.h" #include "Player.h" #include "ObjectAccessor.h" +#include "ObjectDefines.h" #include "WorldSession.h" #include "LootMgr.h" #include "Object.h" diff --git a/src/game/Mail.cpp b/src/game/Mail.cpp index 061bfbb99..e49e13a04 100644 --- a/src/game/Mail.cpp +++ b/src/game/Mail.cpp @@ -23,6 +23,7 @@ #include "Log.h" #include "World.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "Player.h" #include "UpdateMask.h" #include "Unit.h" diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index ee528e602..f21a0bcee 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -26,6 +26,7 @@ #include "Player.h" #include "World.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "WorldSession.h" #include "Auth/BigNumber.h" #include "Auth/Sha1.h" diff --git a/src/game/Object.cpp b/src/game/Object.cpp index c1e724804..72399164b 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -27,6 +27,7 @@ #include "Player.h" #include "Vehicle.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "UpdateData.h" #include "UpdateMask.h" #include "Util.h" diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index b466f121e..3407fd9ce 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -25,6 +25,7 @@ #include "Log.h" #include "MapManager.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "SpellMgr.h" #include "UpdateMask.h" #include "World.h" diff --git a/src/game/PetitionsHandler.cpp b/src/game/PetitionsHandler.cpp index b6b6e2476..41fe2b12c 100644 --- a/src/game/PetitionsHandler.cpp +++ b/src/game/PetitionsHandler.cpp @@ -22,6 +22,7 @@ #include "WorldSession.h" #include "World.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "Log.h" #include "Opcodes.h" #include "Guild.h" diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 558a9d5e4..8cc3a5bc7 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -42,6 +42,7 @@ #include "CellImpl.h" #include "ObjectMgr.h" #include "ObjectAccessor.h" +#include "ObjectDefines.h" #include "CreatureAI.h" #include "Formulas.h" #include "Group.h" diff --git a/src/game/PoolManager.cpp b/src/game/PoolManager.cpp index 7ea09abd8..f1c41ca11 100644 --- a/src/game/PoolManager.cpp +++ b/src/game/PoolManager.cpp @@ -18,6 +18,7 @@ #include "PoolManager.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "ProgressBar.h" #include "Log.h" #include "MapManager.h" diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index 657ab2e27..89a72a476 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -26,6 +26,7 @@ #include "Log.h" #include "World.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "Player.h" #include "UpdateMask.h" #include "NPCHandler.h" diff --git a/src/game/SocialMgr.cpp b/src/game/SocialMgr.cpp index e4811f1df..d05546035 100644 --- a/src/game/SocialMgr.cpp +++ b/src/game/SocialMgr.cpp @@ -23,6 +23,7 @@ #include "WorldPacket.h" #include "Player.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "World.h" #include "Util.h" diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 9494d86f9..e876e341b 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -21,6 +21,7 @@ #include "Transports.h" #include "MapManager.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "Path.h" #include "WorldPacket.h" diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index f08534bcf..b5eab8dfe 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -23,6 +23,7 @@ #include "WorldSession.h" #include "World.h" #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "SpellMgr.h" #include "Unit.h" #include "QuestDef.h" diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 03899d068..d8e2eb07c 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -750,7 +750,7 @@ class MANGOS_DLL_SPEC WorldSession bool m_playerLoading; // code processed in LoginPlayer bool m_playerLogout; // code processed in LogoutPlayer bool m_playerRecentlyLogout; - bool m_playerSave; + bool m_playerSave; // code processed in LogoutPlayer with save request LocaleConstant m_sessionDbcLocale; int m_sessionDbLocaleIndex; uint32 m_latency; diff --git a/src/game/debugcmds.cpp b/src/game/debugcmds.cpp index 66a30084a..2d66fd18b 100644 --- a/src/game/debugcmds.cpp +++ b/src/game/debugcmds.cpp @@ -30,6 +30,7 @@ #include "BattleGroundMgr.h" #include #include "ObjectMgr.h" +#include "ObjectDefines.h" #include "SpellMgr.h" bool ChatHandler::HandleDebugSendSpellFailCommand(const char* args) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 303e3e9b9..ffaa521b8 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 "8829" + #define REVISION_NR "8830" #endif // __REVISION_NR_H__ From 398ca010cacb66703f17fedd9a4eb6f0c964ef7b Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 19 Nov 2009 03:01:35 +0300 Subject: [PATCH 08/17] [8831] Helper function add and move for diffficulties. * Use regular naming for 0 spwanmode/difficulty for clean consistence names (used at well known wiki) * Move difficulty related data access from InstancedMap to Map class. --- src/game/AchievementMgr.cpp | 2 +- src/game/DBCEnums.h | 4 ++-- src/game/Map.cpp | 35 +++++++++++++++++------------------ src/game/Map.h | 18 +++++++++++------- src/game/SpellAuras.cpp | 2 +- src/shared/revision_nr.h | 2 +- 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/game/AchievementMgr.cpp b/src/game/AchievementMgr.cpp index dc96eea42..8c51fc020 100644 --- a/src/game/AchievementMgr.cpp +++ b/src/game/AchievementMgr.cpp @@ -923,7 +923,7 @@ void AchievementMgr::UpdateAchievementCriteria(AchievementCriteriaTypes type, ui continue; //FIXME: work only for instances where max==min for players - if(((InstanceMap*)map)->GetMaxPlayers() != achievementCriteria->death_in_dungeon.manLimit) + if (map->GetMaxPlayers() != achievementCriteria->death_in_dungeon.manLimit) continue; SetCriteriaProgress(achievementCriteria, 1, PROGRESS_ACCUMULATE); break; diff --git a/src/game/DBCEnums.h b/src/game/DBCEnums.h index 8b0833859..2e28ff0e6 100644 --- a/src/game/DBCEnums.h +++ b/src/game/DBCEnums.h @@ -234,7 +234,7 @@ enum AreaFlags enum Difficulty { - DIFFICULTY_DEFAULT = 0, + REGULAR_DEFAULT = 0, DUNGEON_DIFFICULTY_NORMAL = 0, DUNGEON_DIFFICULTY_HEROIC = 1, @@ -251,7 +251,7 @@ enum Difficulty enum SpawnMask { - SPAWNMASK_CONTINENT = (1 << DIFFICULTY_DEFAULT),// any any maps without spawn modes + SPAWNMASK_REGULAR = (1 << REGULAR_DEFAULT), // any any maps without spawn modes (continents/subway) or in minimal spawnmode SPAWNMASK_DUNGEON_NORMAL = (1 << DUNGEON_DIFFICULTY_NORMAL), SPAWNMASK_DUNGEON_HEROIC = (1 << DUNGEON_DIFFICULTY_HEROIC), diff --git a/src/game/Map.cpp b/src/game/Map.cpp index bbec9b77e..59ed9dd11 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -1127,6 +1127,23 @@ void Map::UnloadAll(bool pForce) } } +MapDifficulty const* Map::GetMapDifficulty() const +{ + return GetMapDifficultyData(GetId(),GetDifficulty()); +} + +uint32 Map::GetMaxPlayers() const +{ + MapDifficulty const* mapDiff = GetMapDifficulty(); + return mapDiff ? mapDiff->maxPlayers : 0; +} + +uint32 Map::GetMaxResetDelay() const +{ + MapDifficulty const* mapDiff = GetMapDifficulty(); + return mapDiff ? mapDiff->resetTime : 0; +} + //***************************** // Grid function //***************************** @@ -2618,24 +2635,6 @@ void InstanceMap::SetResetSchedule(bool on) } } -MapDifficulty const* InstanceMap::GetMapDifficulty() const -{ - return GetMapDifficultyData(GetId(),GetDifficulty()); -} - -uint32 InstanceMap::GetMaxPlayers() const -{ - MapDifficulty const* mapDiff = GetMapDifficulty(); - return mapDiff ? mapDiff->maxPlayers : 0; -} - -uint32 InstanceMap::GetMaxResetDelay() const -{ - MapDifficulty const* mapDiff = GetMapDifficulty(); - return mapDiff ? mapDiff->resetTime : 0; -} - - /* ******* Battleground Instance Maps ******* */ BattleGroundMap::BattleGroundMap(uint32 id, time_t expiry, uint32 InstanceId, Map* _parent, uint8 spawnMode) diff --git a/src/game/Map.h b/src/game/Map.h index 428d182c9..d824d22d7 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -362,10 +362,20 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj bool CheckGridIntegrity(Creature* c, bool moved) const; uint32 GetInstanceId() const { return i_InstanceId; } - uint8 GetSpawnMode() const { return (i_spawnMode); } virtual bool CanEnter(Player* /*player*/) { return true; } const char* GetMapName() const; + // have meaning only for instanced map (that have set real difficulty), NOT USE its for BaseMap + // _currently_ spawnmode == difficulty, but this can be changes later, so use appropriate spawmmode/difficult functions + // for simplify later code support + // regular difficulty = continent/dungeon normal/first raid normal difficulty + uint8 GetSpawnMode() const { return (i_spawnMode); } + Difficulty GetDifficulty() const { return Difficulty(GetSpawnMode()); } + bool IsRegularDifficulty() const { return GetDifficulty() == REGULAR_DEFAULT; } + uint32 GetMaxPlayers() const; // dependent from map difficulty + uint32 GetMaxResetDelay() const; // dependent from map difficulty + MapDifficulty const* GetMapDifficulty() const; // dependent from map difficulty + bool Instanceable() const { return i_mapEntry && i_mapEntry->Instanceable(); } // NOTE: this duplicate of Instanceable(), but Instanceable() can be changed when BG also will be instanceable bool IsDungeon() const { return i_mapEntry && i_mapEntry->IsDungeon(); } @@ -597,12 +607,6 @@ class MANGOS_DLL_SPEC InstanceMap : public Map void SendResetWarnings(uint32 timeLeft) const; void SetResetSchedule(bool on); - // have meaning only for instanced map (that have set real difficulty) - Difficulty GetDifficulty() const { return Difficulty(GetSpawnMode()); } - uint32 GetMaxPlayers() const; - uint32 GetMaxResetDelay() const; - MapDifficulty const* GetMapDifficulty() const; - virtual void InitVisibilityDistance(); private: bool m_resetAfterUnload; diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 4294cb87e..3065fcd18 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -2319,7 +2319,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { if (m_target->GetMap()->IsDungeon()) { - uint32 spellId = ((InstanceMap*)m_target->GetMap())->GetDifficulty() == DIFFICULTY_DEFAULT ? 44190 : 46163; + uint32 spellId = m_target->GetMap()->IsRegularDifficulty() ? 44190 : 46163; m_target->CastSpell(m_target, spellId, true, NULL, this); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ffaa521b8..21931b450 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 "8830" + #define REVISION_NR "8831" #endif // __REVISION_NR_H__ From f66f0a0914d9367c43b38ebb9c18f5b7a0de5a8a Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 19 Nov 2009 03:49:00 +0300 Subject: [PATCH 09/17] [8832] Fixed typo in difficulty name --- src/game/DBCEnums.h | 4 ++-- src/game/Map.h | 4 ++-- src/game/MapManager.cpp | 8 +++----- src/game/MiscHandler.cpp | 10 ++++------ src/shared/revision_nr.h | 2 +- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/game/DBCEnums.h b/src/game/DBCEnums.h index 2e28ff0e6..229ebd004 100644 --- a/src/game/DBCEnums.h +++ b/src/game/DBCEnums.h @@ -234,7 +234,7 @@ enum AreaFlags enum Difficulty { - REGULAR_DEFAULT = 0, + REGULAR_DIFFICULTY = 0, DUNGEON_DIFFICULTY_NORMAL = 0, DUNGEON_DIFFICULTY_HEROIC = 1, @@ -251,7 +251,7 @@ enum Difficulty enum SpawnMask { - SPAWNMASK_REGULAR = (1 << REGULAR_DEFAULT), // any any maps without spawn modes (continents/subway) or in minimal spawnmode + SPAWNMASK_REGULAR = (1 << REGULAR_DIFFICULTY),// any any maps without spawn modes (continents/subway) or in minimal spawnmode SPAWNMASK_DUNGEON_NORMAL = (1 << DUNGEON_DIFFICULTY_NORMAL), SPAWNMASK_DUNGEON_HEROIC = (1 << DUNGEON_DIFFICULTY_HEROIC), diff --git a/src/game/Map.h b/src/game/Map.h index d824d22d7..d63cb51ab 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -371,7 +371,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj // regular difficulty = continent/dungeon normal/first raid normal difficulty uint8 GetSpawnMode() const { return (i_spawnMode); } Difficulty GetDifficulty() const { return Difficulty(GetSpawnMode()); } - bool IsRegularDifficulty() const { return GetDifficulty() == REGULAR_DEFAULT; } + 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 @@ -380,7 +380,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj // NOTE: this duplicate of Instanceable(), but Instanceable() can be changed when BG also will be instanceable bool IsDungeon() const { return i_mapEntry && i_mapEntry->IsDungeon(); } bool IsRaid() const { return i_mapEntry && i_mapEntry->IsRaid(); } - bool IsRaidOrHeroicDungeon() const { return IsRaid() || i_spawnMode > DUNGEON_DIFFICULTY_NORMAL; } + bool IsRaidOrHeroicDungeon() const { return IsRaid() || GetDifficulty() > DUNGEON_DIFFICULTY_NORMAL; } bool IsBattleGround() const { return i_mapEntry && i_mapEntry->IsBattleGround(); } bool IsBattleArena() const { return i_mapEntry && i_mapEntry->IsBattleArena(); } bool IsBattleGroundOrArena() const { return i_mapEntry && i_mapEntry->IsBattleGroundOrArena(); } diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index 8059c59d4..94055bfb5 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -118,7 +118,7 @@ MapManager::_createBaseMap(uint32 id) } else { - m = new Map(id, i_gridCleanUpDelay, 0, DUNGEON_DIFFICULTY_NORMAL); + m = new Map(id, i_gridCleanUpDelay, 0, REGULAR_DIFFICULTY); } i_maps[id] = m; } @@ -184,13 +184,11 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) MapDifficulty const* mapDiff = GetMapDifficultyData(entry->MapID,player->GetDifficulty(entry->map_type == MAP_RAID)); if (!mapDiff) { - bool isNormalTargetMap = entry->map_type == MAP_RAID - ? (player->GetRaidDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL) - : (player->GetDungeonDifficulty() == DUNGEON_DIFFICULTY_NORMAL); + bool isRegularTargetMap = player->GetDifficulty(entry->IsRaid()) == REGULAR_DIFFICULTY; //Send aborted message // FIX ME: what about absent normal/heroic mode with specific players limit... - player->SendTransferAborted(mapid, TRANSFER_ABORT_DIFFICULTY, isNormalTargetMap ? DUNGEON_DIFFICULTY_NORMAL : DUNGEON_DIFFICULTY_HEROIC); + player->SendTransferAborted(mapid, TRANSFER_ABORT_DIFFICULTY, isRegularTargetMap ? DUNGEON_DIFFICULTY_NORMAL : DUNGEON_DIFFICULTY_HEROIC); return false; } diff --git a/src/game/MiscHandler.cpp b/src/game/MiscHandler.cpp index f21a0bcee..fa882341a 100644 --- a/src/game/MiscHandler.cpp +++ b/src/game/MiscHandler.cpp @@ -810,12 +810,10 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) if(!mapEntry) return; - bool isNormalTargetMap = mapEntry->IsRaid() - ? (GetPlayer()->GetRaidDifficulty() == RAID_DIFFICULTY_10MAN_NORMAL) - : (GetPlayer()->GetDungeonDifficulty() == DUNGEON_DIFFICULTY_NORMAL); + bool isRegularTargetMap = GetPlayer()->GetDifficulty(mapEntry->IsRaid()) == REGULAR_DIFFICULTY; uint32 missingKey = 0; - if (!isNormalTargetMap) + if (!isRegularTargetMap) { if(at->heroicKey) { @@ -828,7 +826,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) } uint32 missingQuest = 0; - if (!isNormalTargetMap) + if (!isRegularTargetMap) { if (at->requiredQuestHeroic && !GetPlayer()->GetQuestRewardStatus(at->requiredQuestHeroic)) missingQuest = at->requiredQuestHeroic; @@ -845,7 +843,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data) if(missingItem) SendAreaTriggerMessage(GetMangosString(LANG_LEVEL_MINREQUIRED_AND_ITEM), at->requiredLevel, ObjectMgr::GetItemPrototype(missingItem)->Name1); else if(missingKey) - GetPlayer()->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_DIFFICULTY, isNormalTargetMap ? DUNGEON_DIFFICULTY_NORMAL : DUNGEON_DIFFICULTY_HEROIC); + GetPlayer()->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_DIFFICULTY, isRegularTargetMap ? DUNGEON_DIFFICULTY_NORMAL : DUNGEON_DIFFICULTY_HEROIC); else if(missingQuest) SendAreaTriggerMessage(at->requiredFailedText.c_str()); else if(missingLevel) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 21931b450..550b75e02 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 "8831" + #define REVISION_NR "8832" #endif // __REVISION_NR_H__ From b5980f061aacf969357b349b43275924e38555d1 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 19 Nov 2009 07:11:43 +0300 Subject: [PATCH 10/17] [8833] Implement new commands for add/remove/lookup titles. Inspired by patch suggested by LordJZ. --- sql/mangos.sql | 16 +- sql/updates/8833_01_mangos_mangos_string.sql | 13 + sql/updates/8833_02_mangos_command.sql | 10 + sql/updates/Makefile.am | 4 + src/game/Chat.cpp | 14 +- src/game/Chat.h | 8 +- src/game/DBCStructure.h | 2 +- src/game/DBCfmt.h | 2 +- src/game/Language.h | 10 +- src/game/Level1.cpp | 36 --- src/game/Level2.cpp | 301 +++++++++++++++++++ src/game/Level3.cpp | 4 +- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 14 files changed, 377 insertions(+), 47 deletions(-) create mode 100644 sql/updates/8833_01_mangos_mangos_string.sql create mode 100644 sql/updates/8833_02_mangos_command.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 377f82e32..91803ae79 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_8828_02_mangos_instance_template` bit(1) default NULL + `required_8833_02_mangos_command` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -541,6 +541,7 @@ INSERT INTO `command` VALUES ('character level',3,'Syntax: .character level [$playername] [#level]\r\n\r\nSet the level of character with $playername (or the selected if not name provided) by #numberoflevels Or +1 if no #numberoflevels provided). If #numberoflevels is omitted, the level will be increase by 1. If #numberoflevels is 0, the same level will be restarted. If no character is selected and name not provided, increase your level. Command can be used for offline character. All stats and dependent values recalculated. At level decrease talents can be reset if need. Also at level decrease equipped items with greater level requirement can be lost.'), ('character rename',2,'Syntax: .character rename [$name]\r\n\r\nMark selected in game or by $name in command character for rename at next login.'), ('character reputation',2,'Syntax: .character reputation [$player_name]\r\n\r\nShow reputation information for selected player or player find by $player_name.'), +('character titles',2,'Syntax: .character titles [$player_name]\r\n\r\nShow known titles list for selected player or player find by $player_name.'), ('combatstop',2,'Syntax: .combatstop [$playername]\r\nStop combat for selected character. If selected non-player then command applied to self. If $playername provided then attempt applied to online player $playername.'), ('commands',0,'Syntax: .commands\r\n\r\nDisplay a list of available commands for your account level.'), ('cooldown',3,'Syntax: .cooldown [#spell_id]\r\n\r\nRemove all (if spell_id not provided) or #spel_id spell cooldown from selected character or you (if no selection).'), @@ -665,7 +666,6 @@ INSERT INTO `command` VALUES ('modify spell',1,''), ('modify standstate',2,'Syntax: .modify standstate #emoteid\r\n\r\nChange the emote of your character while standing to #emoteid.'), ('modify swim',1,'Syntax: .modify swim #rate\r\n\r\nModify the swim speed of the selected player to \"normal swim speed\"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 10.'), -('modify titles',1,'Syntax: .modify titles #mask\r\n\r\nAllows user to use all titles from #mask.\r\n\r\n #mask=0 disables the title-choose-field'), ('modify tp',1,'Syntax: .modify tp #amount\r\n\r\nSet free talent pointes for selected character or character\'s pet. It will be reset to default expected at next levelup/login/quest reward.'), ('movegens',3,'Syntax: .movegens\r\n Show movement generators stack for selected creature or player.'), ('mute',1,'Syntax: .mute [$playerName] $timeInMinutes\r\n\r\nDisible chat messaging for any character from account of character $playerName (or currently selected) at $timeInMinutes minutes. Player can be offline.'), @@ -753,6 +753,10 @@ INSERT INTO `command` VALUES ('tele group',1,'Syntax: .tele group#location\r\n\r\nTeleport a selected player and his group members to a given location.'), ('tele name',1,'Syntax: .tele name [#playername] #location\r\n\r\nTeleport the given character to a given location. Character can be offline.'), ('ticket',2,'Syntax: .ticket on\r\n .ticket off\r\n .ticket #num\r\n .ticket $character_name\r\n\r\non/off for GMs to show or not a new ticket directly, $character_name to show ticket of this character, #num to show ticket #num.'), +('titles add',2,'Syntax: .titles add #title\r\nAdd title #title (id or shift-link) to known titles list for selected player.'), +('titles current',2,'Syntax: .titles current #title\r\nSet title #title (id or shift-link) as current selected titl for selected player. If title not in known title list for player then it will be added to list.'), +('titles remove',2,'Syntax: .titles remove #title\r\nRemove title #title (id or shift-link) from known titles list for selected player.'), +('titles setmask',2,'Syntax: .titles setmask #mask\r\n\r\nAllows user to use all titles from #mask.\r\n\r\n #mask=0 disables the title-choose-field'), ('unaura',3,'Syntax: .unaura #spellid\r\n\r\nRemove aura due to spell #spellid from the selected Unit.'), ('unban account',3,'Syntax: .unban account $Name\r\nUnban accounts for account name pattern.'), ('unban character',3,'Syntax: .unban character $Name\r\nUnban accounts for character name pattern.'), @@ -3067,6 +3071,14 @@ INSERT INTO `mangos_string` VALUES (346,'Forced customize for player %s (GUID #%u) will be requested at next login.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (347,'TaxiNode ID %u not found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (348,'Game Object (Entry: %u) have invalid data and can\'t be spawned',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(349,'%d (idx:%d) - |cffffffff|Htitle:%d|h[%s %s]|h|r %s %s ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(350,'%d (idx:%d) - [%s %s] %s %s ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(351,'No titles found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(352,'Invalid title id: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(353,'Title %u (%s) added to known titles list for player %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(354,'Title %u (%s) removed from known titles list for player %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(355,'Title %u (%s) set as current seelcted title for player %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), +(356,'Current selected title for player %s reset as not known now.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (400,'|cffff0000[System Message]:|rScripts reloaded',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (401,'You change security level of account %s to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (402,'%s changed your security level to %i.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), diff --git a/sql/updates/8833_01_mangos_mangos_string.sql b/sql/updates/8833_01_mangos_mangos_string.sql new file mode 100644 index 000000000..2c9b69a61 --- /dev/null +++ b/sql/updates/8833_01_mangos_mangos_string.sql @@ -0,0 +1,13 @@ +ALTER TABLE db_version CHANGE COLUMN required_8828_02_mangos_instance_template required_8833_01_mangos_mangos_string bit; + +DELETE FROM mangos_string WHERE entry in (349, 350, 351, 352, 353, 354, 355, 356); + +INSERT INTO mangos_string VALUES + (349,'%d (idx:%d) - |cffffffff|Htitle:%d|h[%s %s]|h|r %s %s ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), + (350,'%d (idx:%d) - [%s %s] %s %s ',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), + (351,'No titles found!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), + (352,'Invalid title id: %u',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), + (353,'Title %u (%s) added to known titles list for player %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), + (354,'Title %u (%s) removed from known titles list for player %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), + (355,'Title %u (%s) set as current seelcted title for player %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), + (356,'Current selected title for player %s reset as not known now.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); diff --git a/sql/updates/8833_02_mangos_command.sql b/sql/updates/8833_02_mangos_command.sql new file mode 100644 index 000000000..75fee0fef --- /dev/null +++ b/sql/updates/8833_02_mangos_command.sql @@ -0,0 +1,10 @@ +ALTER TABLE db_version CHANGE COLUMN required_8833_01_mangos_mangos_string required_8833_02_mangos_command bit; + +DELETE FROM command where name IN ('character titles','modify titles','titles add','titles current','titles remove'); + +INSERT INTO `command` VALUES +('character titles',2,'Syntax: .character titles [$player_name]\r\n\r\nShow known titles list for selected player or player find by $player_name.'), +('titles add',2,'Syntax: .titles add #title\r\nAdd title #title (id or shift-link) to known titles list for selected player.'), +('titles current',2,'Syntax: .titles current #title\r\nSet title #title (id or shift-link) as current selected titl for selected player. If title not in known title list for player then it will be added to list.'), +('titles remove',2,'Syntax: .titles remove #title\r\nRemove title #title (id or shift-link) from known titles list for selected player.'), +('titles setmask',2,'Syntax: .titles setmask #mask\r\n\r\nAllows user to use all titles from #mask.\r\n\r\n #mask=0 disables the title-choose-field'); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index f27eb879d..e41e92437 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -160,6 +160,8 @@ pkgdata_DATA = \ 8818_01_mangos_mangos_string.sql \ 8828_01_characters_instance_reset.sql \ 8828_02_mangos_instance_template.sql \ + 8833_01_mangos_mangos_string.sql \ + 8833_02_mangos_command.sql \ README ## Additional files to include when running 'make dist' @@ -300,4 +302,6 @@ EXTRA_DIST = \ 8818_01_mangos_mangos_string.sql \ 8828_01_characters_instance_reset.sql \ 8828_02_mangos_instance_template.sql \ + 8833_01_mangos_mangos_string.sql \ + 8833_02_mangos_command.sql \ README diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index aba9ae072..4c2654697 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -55,6 +55,7 @@ // |color|Htalent:talent_id,rank|h[name]|h|r - client, talent icon shift-click // |color|Htaxinode:id|h[name]|h|r // |color|Htele:id|h[name]|h|r +// |color|Htitle:id|h[name]|h|r // |color|Htrade:spell_id,cur_value,max_value,unk3int,unk3str|h[name]|h|r - client, spellbook profession icon shift-click bool ChatHandler::load_command_table = true; @@ -122,6 +123,7 @@ ChatCommand * ChatHandler::getCommandTable() { "level", SEC_ADMINISTRATOR, true, &ChatHandler::HandleCharacterLevelCommand, "", NULL }, { "rename", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterRenameCommand, "", NULL }, { "reputation", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterReputationCommand, "", NULL }, + { "titles", SEC_GAMEMASTER, true, &ChatHandler::HandleCharacterTitlesCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; @@ -294,6 +296,7 @@ ChatCommand * ChatHandler::getCommandTable() { "spell", SEC_ADMINISTRATOR, true, &ChatHandler::HandleLookupSpellCommand, "", NULL }, { "taxinode", SEC_ADMINISTRATOR, true, &ChatHandler::HandleLookupTaxiNodeCommand, "", NULL }, { "tele", SEC_MODERATOR, true, &ChatHandler::HandleLookupTeleCommand, "", NULL }, + { "title", SEC_GAMEMASTER, true, &ChatHandler::HandleLookupTitleCommand, "", NULL }, { NULL, 0, false, NULL, "", NULL } }; @@ -315,7 +318,6 @@ ChatCommand * ChatHandler::getCommandTable() { "faction", SEC_MODERATOR, false, &ChatHandler::HandleModifyFactionCommand, "", NULL }, { "spell", SEC_MODERATOR, false, &ChatHandler::HandleModifySpellCommand, "", NULL }, { "tp", SEC_MODERATOR, false, &ChatHandler::HandleModifyTalentCommand, "", NULL }, - { "titles", SEC_MODERATOR, false, &ChatHandler::HandleModifyKnownTitlesCommand, "", NULL }, { "mount", SEC_MODERATOR, false, &ChatHandler::HandleModifyMountCommand, "", NULL }, { "honor", SEC_MODERATOR, false, &ChatHandler::HandleModifyHonorCommand, "", NULL }, { "rep", SEC_GAMEMASTER, false, &ChatHandler::HandleModifyRepCommand, "", NULL }, @@ -552,6 +554,15 @@ ChatCommand * ChatHandler::getCommandTable() { NULL, 0, false, NULL, "", NULL } }; + static ChatCommand titlesCommandTable[] = + { + { "add", SEC_GAMEMASTER, false, &ChatHandler::HandleTitlesAddCommand, "", NULL }, + { "current", SEC_GAMEMASTER, false, &ChatHandler::HandleTitlesCurrentCommand, "", NULL }, + { "remove", SEC_GAMEMASTER, false, &ChatHandler::HandleTitlesRemoveCommand, "", NULL }, + { "setmask", SEC_GAMEMASTER, false, &ChatHandler::HandleTitlesSetMaskCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } + }; + static ChatCommand unbanCommandTable[] = { { "account", SEC_ADMINISTRATOR, true, &ChatHandler::HandleUnBanAccountCommand, "", NULL }, @@ -585,6 +596,7 @@ ChatCommand * ChatHandler::getCommandTable() { "gobject", SEC_GAMEMASTER, false, NULL, "", gobjectCommandTable }, { "honor", SEC_GAMEMASTER, false, NULL, "", honorCommandTable }, { "wp", SEC_GAMEMASTER, false, NULL, "", wpCommandTable }, + { "titles", SEC_GAMEMASTER, false, NULL, "", titlesCommandTable }, { "quest", SEC_ADMINISTRATOR, false, NULL, "", questCommandTable }, { "reload", SEC_ADMINISTRATOR, true, NULL, "", reloadCommandTable }, { "list", SEC_ADMINISTRATOR, true, NULL, "", listCommandTable }, diff --git a/src/game/Chat.h b/src/game/Chat.h index b12f06f06..a96dce943 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -126,6 +126,7 @@ class ChatHandler bool HandleCharacterLevelCommand(const char* args); bool HandleCharacterRenameCommand(const char * args); bool HandleCharacterReputationCommand(const char* args); + bool HandleCharacterTitlesCommand(const char* args); bool HandleDebugAnimCommand(const char* args); bool HandleDebugArenaCommand(const char * args); @@ -238,8 +239,8 @@ class ChatHandler bool HandleLookupSpellCommand(const char* args); bool HandleLookupTaxiNodeCommand(const char * args); bool HandleLookupTeleCommand(const char * args); + bool HandleLookupTitleCommand(const char * args); - bool HandleModifyKnownTitlesCommand(const char* args); bool HandleModifyHPCommand(const char* args); bool HandleModifyManaCommand(const char* args); bool HandleModifyRageCommand(const char* args); @@ -420,6 +421,11 @@ class ChatHandler bool HandleTeleGroupCommand(const char* args); bool HandleTeleNameCommand(const char* args); + bool HandleTitlesAddCommand(const char* args); + bool HandleTitlesCurrentCommand(const char* args); + bool HandleTitlesRemoveCommand(const char* args); + bool HandleTitlesSetMaskCommand(const char* args); + bool HandleUnBanAccountCommand(const char* args); bool HandleUnBanCharacterCommand(const char* args); bool HandleUnBanIPCommand(const char* args); diff --git a/src/game/DBCStructure.h b/src/game/DBCStructure.h index d26ba051a..e799e993a 100644 --- a/src/game/DBCStructure.h +++ b/src/game/DBCStructure.h @@ -597,7 +597,7 @@ struct CharTitlesEntry { uint32 ID; // 0, title ids, for example in Quest::GetCharTitleId() //uint32 unk1; // 1 flags? - //char* name[16]; // 2-17, unused + char* name[16]; // 2-17 // 18 string flag, unused //char* name2[16]; // 19-34, unused // 35 string flag, unused diff --git a/src/game/DBCfmt.h b/src/game/DBCfmt.h index e1f8f1a21..aa5105066 100644 --- a/src/game/DBCfmt.h +++ b/src/game/DBCfmt.h @@ -29,7 +29,7 @@ const char BankBagSlotPricesEntryfmt[]="ni"; const char BarberShopStyleEntryfmt[]="nixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiii"; const char BattlemasterListEntryfmt[]="niiiiiiiiiiiixxxssssssssssssssssxxx"; const char CharStartOutfitEntryfmt[]="diiiiiiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; -const char CharTitlesEntryfmt[]="nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi"; +const char CharTitlesEntryfmt[]="nxssssssssssssssssxxxxxxxxxxxxxxxxxxi"; const char ChatChannelsEntryfmt[]="iixssssssssssssssssxxxxxxxxxxxxxxxxxx"; // ChatChannelsEntryfmt, index not used (more compact store) const char ChrClassesEntryfmt[]="nxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii"; diff --git a/src/game/Language.h b/src/game/Language.h index 3412200ae..bc8aa8668 100644 --- a/src/game/Language.h +++ b/src/game/Language.h @@ -332,7 +332,15 @@ enum MangosStrings LANG_CUSTOMIZE_PLAYER_GUID = 346, LANG_COMMAND_GOTAXINODENOTFOUND = 347, LANG_GAMEOBJECT_HAVE_INVALID_DATA = 348, - // Room for more level 2 349-399 not used + LANG_TITLE_LIST_CHAT = 349, + LANG_TITLE_LIST_CONSOLE = 350, + LANG_COMMAND_NOTITLEFOUND = 351, + LANG_INVALID_TITLE_ID = 352, + LANG_TITLE_ADD_RES = 353, + LANG_TITLE_REMOVE_RES = 354, + LANG_TITLE_CURRENT_RES = 355, + LANG_CURRENT_TITLE_RESET = 356, + // Room for more level 2 357-399 not used // level 3 chat LANG_SCRIPTS_RELOADED = 400, diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index eb4af753a..2c3faefb7 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -637,42 +637,6 @@ bool ChatHandler::HandleRecallCommand(const char* args) return true; } -//Edit Player KnownTitles -bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args) -{ - if(!*args) - return false; - - uint64 titles = 0; - - sscanf((char*)args, UI64FMTD, &titles); - - Player *chr = getSelectedPlayer(); - if (!chr) - { - SendSysMessage(LANG_NO_CHAR_SELECTED); - SetSentErrorMessage(true); - return false; - } - - // check online security - if (HasLowerSecurity(chr, 0)) - return false; - - uint64 titles2 = titles; - - for(uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i) - if(CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) - titles2 &= ~(uint64(1) << tEntry->bit_index); - - titles &= ~titles2; // remove not existed titles - - chr->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles); - SendSysMessage(LANG_DONE); - - return true; -} - //Edit Player HP bool ChatHandler::HandleModifyHPCommand(const char* args) { diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index 38b1b883c..ca2cc96b7 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -18,6 +18,7 @@ #include "Common.h" #include "Database/DatabaseEnv.h" +#include "DBCStores.h" #include "ObjectMgr.h" #include "ObjectDefines.h" #include "Player.h" @@ -4203,3 +4204,303 @@ bool ChatHandler::HandleWaterwalkCommand(const char* args) return true; } +bool ChatHandler::HandleLookupTitleCommand(const char* args) +{ + if(!*args) + return false; + + // can be NULL in console call + Player* target = getSelectedPlayer(); + + // title name have single string arg for player name + char const* targetName = target ? target->GetName() : "NAME"; + + std::string namepart = args; + std::wstring wnamepart; + + if(!Utf8toWStr(namepart,wnamepart)) + return false; + + // converting string that we try to find to lower case + wstrToLower( wnamepart ); + + uint32 counter = 0; // Counter for figure out that we found smth. + + // Search in CharTitles.dbc + for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++) + { + CharTitlesEntry const *titleInfo = sCharTitlesStore.LookupEntry(id); + if(titleInfo) + { + int loc = GetSessionDbcLocale(); + std::string name = titleInfo->name[loc]; + if(name.empty()) + continue; + + if (!Utf8FitTo(name, wnamepart)) + { + loc = 0; + for(; loc < MAX_LOCALE; ++loc) + { + if(loc==GetSessionDbcLocale()) + continue; + + name = titleInfo->name[loc]; + if(name.empty()) + continue; + + if (Utf8FitTo(name, wnamepart)) + break; + } + } + + if(loc < MAX_LOCALE) + { + char const* knownStr = target && target->HasTitle(titleInfo) ? GetMangosString(LANG_KNOWN) : ""; + + char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE)==titleInfo->bit_index + ? GetMangosString(LANG_ACTIVE) + : ""; + + char titleNameStr[80]; + snprintf(titleNameStr,80,name.c_str(),targetName); + + // send title in "id (idx:idx) - [namedlink locale]" format + if (m_session) + PSendSysMessage(LANG_TITLE_LIST_CHAT,id,titleInfo->bit_index,id,titleNameStr,localeNames[loc],knownStr,activeStr); + else + PSendSysMessage(LANG_TITLE_LIST_CONSOLE,id,titleInfo->bit_index,titleNameStr,localeNames[loc],knownStr,activeStr); + + ++counter; + } + } + } + if (counter == 0) // if counter == 0 then we found nth + SendSysMessage(LANG_COMMAND_NOTITLEFOUND); + return true; +} + +bool ChatHandler::HandleTitlesAddCommand(const char* args) +{ + // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r + char* id_p = extractKeyFromLink((char*)args,"Htitle"); + if(!id_p) + return false; + + int32 id = atoi(id_p); + if (id <= 0) + { + PSendSysMessage(LANG_INVALID_TITLE_ID, id); + SetSentErrorMessage(true); + return false; + } + + Player * target = getSelectedPlayer(); + if(!target) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + // check online security + if (HasLowerSecurity(target, 0)) + return false; + + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); + if(!titleInfo) + { + PSendSysMessage(LANG_INVALID_TITLE_ID, id); + SetSentErrorMessage(true); + return false; + } + + std::string tNameLink = GetNameLink(target); + + char const* targetName = target->GetName(); + char titleNameStr[80]; + snprintf(titleNameStr,80,titleInfo->name[GetSessionDbcLocale()],targetName); + + target->SetTitle(titleInfo); + PSendSysMessage(LANG_TITLE_ADD_RES, id, titleNameStr, tNameLink.c_str()); + + return true; +} + +bool ChatHandler::HandleTitlesRemoveCommand(const char* args) +{ + // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r + char* id_p = extractKeyFromLink((char*)args,"Htitle"); + if(!id_p) + return false; + + int32 id = atoi(id_p); + if (id <= 0) + { + PSendSysMessage(LANG_INVALID_TITLE_ID, id); + SetSentErrorMessage(true); + return false; + } + + Player * target = getSelectedPlayer(); + if(!target) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + // check online security + if (HasLowerSecurity(target, 0)) + return false; + + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); + if(!titleInfo) + { + PSendSysMessage(LANG_INVALID_TITLE_ID, id); + SetSentErrorMessage(true); + return false; + } + + target->SetTitle(titleInfo,true); + + std::string tNameLink = GetNameLink(target); + + char const* targetName = target->GetName(); + char titleNameStr[80]; + snprintf(titleNameStr,80,titleInfo->name[GetSessionDbcLocale()],targetName); + + PSendSysMessage(LANG_TITLE_REMOVE_RES, id, titleNameStr, tNameLink.c_str()); + + if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) + { + target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); + PSendSysMessage(LANG_CURRENT_TITLE_RESET, tNameLink.c_str()); + } + + return true; +} + +//Edit Player KnownTitles +bool ChatHandler::HandleTitlesSetMaskCommand(const char* args) +{ + if(!*args) + return false; + + uint64 titles = 0; + + sscanf((char*)args, UI64FMTD, &titles); + + Player *target = getSelectedPlayer(); + if (!target) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + // check online security + if (HasLowerSecurity(target, 0)) + return false; + + uint64 titles2 = titles; + + for(uint32 i = 1; i < sCharTitlesStore.GetNumRows(); ++i) + if(CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i)) + titles2 &= ~(uint64(1) << tEntry->bit_index); + + titles &= ~titles2; // remove not existed titles + + target->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles); + SendSysMessage(LANG_DONE); + + if (!target->HasTitle(target->GetInt32Value(PLAYER_CHOSEN_TITLE))) + { + target->SetUInt32Value(PLAYER_CHOSEN_TITLE,0); + PSendSysMessage(LANG_CURRENT_TITLE_RESET,GetNameLink(target).c_str()); + } + + return true; +} + +bool ChatHandler::HandleCharacterTitlesCommand(const char* args) +{ + Player* target; + if(!extractPlayerTarget((char*)args,&target)) + return false; + + LocaleConstant loc = GetSessionDbcLocale(); + char const* targetName = target->GetName(); + char const* knownStr = GetMangosString(LANG_KNOWN); + + // Search in CharTitles.dbc + for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++) + { + CharTitlesEntry const *titleInfo = sCharTitlesStore.LookupEntry(id); + if (titleInfo && target->HasTitle(titleInfo)) + { + std::string name = titleInfo->name[loc]; + if(name.empty()) + continue; + + char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE)==titleInfo->bit_index + ? GetMangosString(LANG_ACTIVE) + : ""; + + char titleNameStr[80]; + snprintf(titleNameStr,80,name.c_str(),targetName); + + // send title in "id (idx:idx) - [namedlink locale]" format + if (m_session) + PSendSysMessage(LANG_TITLE_LIST_CHAT,id,titleInfo->bit_index,id,titleNameStr,localeNames[loc],knownStr,activeStr); + else + PSendSysMessage(LANG_TITLE_LIST_CONSOLE,id,titleInfo->bit_index,name.c_str(),localeNames[loc],knownStr,activeStr); + } + } + return true; +} + +bool ChatHandler::HandleTitlesCurrentCommand(const char* args) +{ + // number or [name] Shift-click form |color|Htitle:title_id|h[name]|h|r + char* id_p = extractKeyFromLink((char*)args,"Htitle"); + if(!id_p) + return false; + + int32 id = atoi(id_p); + if (id <= 0) + { + PSendSysMessage(LANG_INVALID_TITLE_ID, id); + SetSentErrorMessage(true); + return false; + } + + Player * target = getSelectedPlayer(); + if(!target) + { + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; + } + + // check online security + if (HasLowerSecurity(target, 0)) + return false; + + CharTitlesEntry const* titleInfo = sCharTitlesStore.LookupEntry(id); + if(!titleInfo) + { + PSendSysMessage(LANG_INVALID_TITLE_ID, id); + SetSentErrorMessage(true); + return false; + } + + std::string tNameLink = GetNameLink(target); + + target->SetTitle(titleInfo); // to be sure that title now known + target->SetUInt32Value(PLAYER_CHOSEN_TITLE,titleInfo->bit_index); + + PSendSysMessage(LANG_TITLE_CURRENT_RES, id, titleInfo->name[GetSessionDbcLocale()], tNameLink.c_str()); + + return true; +} diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 245c252ce..94413af32 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -1048,7 +1048,7 @@ bool ChatHandler::HandleSetSkillCommand(const char* args) if(!target->GetSkillValue(skill)) { - PSendSysMessage(LANG_SET_SKILL_ERROR, tNameLink.c_str(), skill, sl->name[0]); + PSendSysMessage(LANG_SET_SKILL_ERROR, tNameLink.c_str(), skill, sl->name[GetSessionDbcLocale()]); SetSentErrorMessage(true); return false; } @@ -1059,7 +1059,7 @@ bool ChatHandler::HandleSetSkillCommand(const char* args) return false; target->SetSkill(skill, level, max); - PSendSysMessage(LANG_SET_SKILL, skill, sl->name[0], tNameLink.c_str(), level, max); + PSendSysMessage(LANG_SET_SKILL, skill, sl->name[GetSessionDbcLocale()], tNameLink.c_str(), level, max); return true; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 550b75e02..1f66354d6 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 "8832" + #define REVISION_NR "8833" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index bec923d2d..e60821a61 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_8828_01_characters_instance_reset" - #define REVISION_DB_MANGOS "required_8828_02_mangos_instance_template" + #define REVISION_DB_MANGOS "required_8833_02_mangos_command" #define REVISION_DB_REALMD "required_8728_01_realmd_account" #endif // __REVISION_SQL_H__ From 876eb401adc27e194eff0a68f8749bf897411217 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 19 Nov 2009 07:37:48 +0300 Subject: [PATCH 11/17] [8834] Small fix for sql update remove part. --- sql/updates/8833_02_mangos_command.sql | 2 +- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/updates/8833_02_mangos_command.sql b/sql/updates/8833_02_mangos_command.sql index 75fee0fef..d93695ab6 100644 --- a/sql/updates/8833_02_mangos_command.sql +++ b/sql/updates/8833_02_mangos_command.sql @@ -1,6 +1,6 @@ ALTER TABLE db_version CHANGE COLUMN required_8833_01_mangos_mangos_string required_8833_02_mangos_command bit; -DELETE FROM command where name IN ('character titles','modify titles','titles add','titles current','titles remove'); +DELETE FROM command where name IN ('character titles','modify titles','titles add','titles current','titles remove','titles setmask'); INSERT INTO `command` VALUES ('character titles',2,'Syntax: .character titles [$player_name]\r\n\r\nShow known titles list for selected player or player find by $player_name.'), diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 1f66354d6..8b80dc849 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 "8833" + #define REVISION_NR "8834" #endif // __REVISION_NR_H__ From d27f889b2bc94e0692093dfa345372edff8927fd Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 19 Nov 2009 08:22:23 +0300 Subject: [PATCH 12/17] [8835] .lookup title command DB description for prev commits. --- sql/mangos.sql | 3 ++- sql/updates/8835_01_mangos_command.sql | 6 ++++++ sql/updates/Makefile.am | 2 ++ src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 sql/updates/8835_01_mangos_command.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 91803ae79..396fcee7b 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_8833_02_mangos_command` bit(1) default NULL + `required_8835_01_mangos_command` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -642,6 +642,7 @@ INSERT INTO `command` VALUES ('lookup spell',3,'Syntax: .lookup spell $namepart\r\n\r\nLooks up a spell by $namepart, and returns all matches with their spell ID\'s.'), ('lookup taxinode',3,'Syntax: .lookup taxinode $substring\r\n\r\nSearch and output all taxinodes with provide $substring in name.'), ('lookup tele',1,'Syntax: .lookup tele $substring\r\n\r\nSearch and output all .tele command locations with provide $substring in name.'), +('lookup title',2,'Syntax: .lookup title $$namepart\r\n\r\nLooks up a title by $namepart, and returns all matches with their title ID\'s and index\'s.'), ('maxskill',3,'Syntax: .maxskill\r\nSets all skills of the targeted player to their maximum VALUESfor its current level.'), ('modify arena',1,'Syntax: .modify arena #value\r\nAdd $amount arena points to the selected player.'), ('modify aspeed',1,'Syntax: .modify aspeed #rate\r\n\r\nModify all speeds -run,swim,run back,swim back- of the selected player to \"normalbase speed for this move type\"*rate. If no player is selected, modify your speed.\r\n\r\n #rate may range from 0.1 to 10.'), diff --git a/sql/updates/8835_01_mangos_command.sql b/sql/updates/8835_01_mangos_command.sql new file mode 100644 index 000000000..78ab2cddd --- /dev/null +++ b/sql/updates/8835_01_mangos_command.sql @@ -0,0 +1,6 @@ +ALTER TABLE db_version CHANGE COLUMN required_8833_02_mangos_command required_8835_01_mangos_command bit; + +DELETE FROM command where name IN ('lookup title'); + +INSERT INTO `command` VALUES +('lookup title',2,'Syntax: .lookup title $$namepart\r\n\r\nLooks up a title by $namepart, and returns all matches with their title ID\'s and index\'s.'); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index e41e92437..37a0a79cb 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -162,6 +162,7 @@ pkgdata_DATA = \ 8828_02_mangos_instance_template.sql \ 8833_01_mangos_mangos_string.sql \ 8833_02_mangos_command.sql \ + 8835_01_mangos_command.sql \ README ## Additional files to include when running 'make dist' @@ -304,4 +305,5 @@ EXTRA_DIST = \ 8828_02_mangos_instance_template.sql \ 8833_01_mangos_mangos_string.sql \ 8833_02_mangos_command.sql \ + 8835_01_mangos_command.sql \ README diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8b80dc849..dec3d11cd 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 "8834" + #define REVISION_NR "8835" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index e60821a61..047698b3f 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_8828_01_characters_instance_reset" - #define REVISION_DB_MANGOS "required_8833_02_mangos_command" + #define REVISION_DB_MANGOS "required_8835_01_mangos_command" #define REVISION_DB_REALMD "required_8728_01_realmd_account" #endif // __REVISION_SQL_H__ From 120719c56422ffa0176377812bbbd14e3a5e85bd Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 19 Nov 2009 11:05:05 +0300 Subject: [PATCH 13/17] [8836] Include revision_sql.h in src/shared makefile and VC project --- src/shared/Makefile.am | 1 + src/shared/revision_nr.h | 2 +- win/VC100/shared.vcxproj | 1 + win/VC80/shared.vcproj | 4 ++++ win/VC90/shared.vcproj | 4 ++++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/shared/Makefile.am b/src/shared/Makefile.am index 4f5912045..fe77ef9c3 100644 --- a/src/shared/Makefile.am +++ b/src/shared/Makefile.am @@ -48,6 +48,7 @@ libmangosshared_a_SOURCES = \ Util.h \ WorldPacket.h \ revision_nr.h \ + revision_sql.h \ revision.h # Get revision (git or svn) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index dec3d11cd..5c9fc19b0 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 "8835" + #define REVISION_NR "8836" #endif // __REVISION_NR_H__ diff --git a/win/VC100/shared.vcxproj b/win/VC100/shared.vcxproj index c0e1ef747..97cd0264c 100644 --- a/win/VC100/shared.vcxproj +++ b/win/VC100/shared.vcxproj @@ -497,6 +497,7 @@ + diff --git a/win/VC80/shared.vcproj b/win/VC80/shared.vcproj index 0a7a79081..74c4c1c9b 100644 --- a/win/VC80/shared.vcproj +++ b/win/VC80/shared.vcproj @@ -913,6 +913,10 @@ RelativePath="..\..\src\shared\revision_nr.h" > + + diff --git a/win/VC90/shared.vcproj b/win/VC90/shared.vcproj index 65de0fcdd..9c3b297a8 100644 --- a/win/VC90/shared.vcproj +++ b/win/VC90/shared.vcproj @@ -941,6 +941,10 @@ RelativePath="..\..\src\shared\revision_nr.h" > + + From 754c1fed45fadf7fda656ddc76bbcb3143739150 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 19 Nov 2009 13:21:03 +0300 Subject: [PATCH 14/17] [8837] Fixed client side visual bug with login in "combat" mode. --- src/game/Player.cpp | 2 ++ src/shared/revision_nr.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 8cc3a5bc7..bec98618a 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -14473,6 +14473,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // clear charm/summon related fields SetCharm(NULL); SetPet(NULL); + SetTargetGUID(0); + SetChannelObjectGUID(0); SetCharmerGUID(0); SetOwnerGUID(0); SetCreatorGUID(0); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 5c9fc19b0..48fc9d6c2 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 "8836" + #define REVISION_NR "8837" #endif // __REVISION_NR_H__ From 2f3f0f20d84bbe72622e30f9669af73eb0a86e78 Mon Sep 17 00:00:00 2001 From: klightspeed Date: Thu, 19 Nov 2009 14:03:05 +0300 Subject: [PATCH 15/17] [8838] Avoid attempts to install tbb libraries without honouring $DESTDIR Signed-off-by: VladimirMangos --- dep/tbb/Makefile.am | 2 +- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dep/tbb/Makefile.am b/dep/tbb/Makefile.am index 98027104a..d85e69268 100644 --- a/dep/tbb/Makefile.am +++ b/dep/tbb/Makefile.am @@ -49,7 +49,7 @@ tbbmalloc: $(MAKE) -r -f $(tbb_root)/build/Makefile.tbbmalloc cfg=release malloc tbb_root=$(tbb_root) install-exec-local: - $(INSTALL) $(work_dir)/lib*.so* $(libdir) + $(INSTALL) $(work_dir)/lib*.so* $(DESTDIR)$(libdir) clean-local: -rm -f *.d *.o diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 48fc9d6c2..a0d0213ef 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 "8837" + #define REVISION_NR "8838" #endif // __REVISION_NR_H__ From 9ccf3ffc0fbbb166e6f55a18df8bb6591ea5c549 Mon Sep 17 00:00:00 2001 From: XTZGZoReX Date: Thu, 19 Nov 2009 12:43:24 +0100 Subject: [PATCH 16/17] [8839] Correct "outdated OpenSSL" warning message. --- src/mangosd/Main.cpp | 2 +- src/realmd/Main.cpp | 2 +- src/shared/revision_nr.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mangosd/Main.cpp b/src/mangosd/Main.cpp index 24c372b4e..a662dd56d 100644 --- a/src/mangosd/Main.cpp +++ b/src/mangosd/Main.cpp @@ -163,7 +163,7 @@ extern int main(int argc, char **argv) sLog.outDetail("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); if (SSLeay() < 0x009080bfL ) { - sLog.outDetail("WARNING: Outdated version of OpenSSL lib. Logins to server impossible!"); + sLog.outDetail("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!"); sLog.outDetail("WARNING: Minimal required version [OpenSSL 0.9.8k]"); } diff --git a/src/realmd/Main.cpp b/src/realmd/Main.cpp index c1be328c9..38ea7f515 100644 --- a/src/realmd/Main.cpp +++ b/src/realmd/Main.cpp @@ -167,7 +167,7 @@ extern int main(int argc, char **argv) sLog.outDetail("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); if (SSLeay() < 0x009080bfL ) { - sLog.outDetail("WARNING: Outdated version of OpenSSL lib. Logins to server impossible!"); + sLog.outDetail("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!"); sLog.outDetail("WARNING: Minimal required version [OpenSSL 0.9.8k]"); } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index a0d0213ef..89c537650 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 "8838" + #define REVISION_NR "8839" #endif // __REVISION_NR_H__ From ea28a5cfcb037f70a61a34af2cbeb9a328ad52f7 Mon Sep 17 00:00:00 2001 From: Splinter Date: Thu, 19 Nov 2009 15:30:17 +0300 Subject: [PATCH 17/17] [8840] Correct proc flags for 53601. Spell have in dbc wrong flags because copy its for dummy aura from triggred spell for client use. Signed-off-by: VladimirMangos --- sql/mangos.sql | 4 ++-- sql/updates/8840_01_mangos_spell_proc_event.sql | 6 ++++++ sql/updates/Makefile.am | 2 ++ src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 sql/updates/8840_01_mangos_spell_proc_event.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 396fcee7b..3d1b1a674 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_8835_01_mangos_command` bit(1) default NULL + `required_8840_01_mangos_spell_proc_event` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -18244,7 +18244,7 @@ INSERT INTO `spell_proc_event` VALUES (53553, 0x00000000, 10, 0x00001000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), (53569, 0x00000000, 10, 0x00200000, 0x00010000, 0x00000000, 0x00000000, 0x00000002, 0.000000, 0.000000, 0), (53576, 0x00000000, 10, 0x00200000, 0x00010000, 0x00000000, 0x00000000, 0x00000002, 0.000000, 0.000000, 0), -(53601, 0x00000000, 0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 6), +(53601, 0x00000000, 0, 0x00000000, 0x00000000, 0x00000000, 0x000A02A8, 0x00000000, 0.000000, 0.000000, 6), (53646, 0x00000000, 0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0.000000, 0.000000, 0), (53671, 0x00000000, 10, 0x00800000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), (53673, 0x00000000, 10, 0x00800000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0.000000, 0.000000, 0), diff --git a/sql/updates/8840_01_mangos_spell_proc_event.sql b/sql/updates/8840_01_mangos_spell_proc_event.sql new file mode 100644 index 000000000..4087c484a --- /dev/null +++ b/sql/updates/8840_01_mangos_spell_proc_event.sql @@ -0,0 +1,6 @@ +ALTER TABLE db_version CHANGE COLUMN required_8835_01_mangos_command required_8840_01_mangos_spell_proc_event bit; + +DELETE FROM `spell_proc_event` WHERE `entry`=53601; + +INSERT INTO spell_proc_event VALUES +(53601, 0x00000000, 0, 0x00000000, 0x00000000, 0x00000000, 0x000A02A8, 0x00000000, 0.000000, 0.000000, 6); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 37a0a79cb..2cd538c3e 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -163,6 +163,7 @@ pkgdata_DATA = \ 8833_01_mangos_mangos_string.sql \ 8833_02_mangos_command.sql \ 8835_01_mangos_command.sql \ + 8840_01_mangos_spell_proc_event.sql \ README ## Additional files to include when running 'make dist' @@ -306,4 +307,5 @@ EXTRA_DIST = \ 8833_01_mangos_mangos_string.sql \ 8833_02_mangos_command.sql \ 8835_01_mangos_command.sql \ + 8840_01_mangos_spell_proc_event.sql \ README diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 89c537650..ae0e67afb 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 "8839" + #define REVISION_NR "8840" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 047698b3f..122f4e8a5 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_8828_01_characters_instance_reset" - #define REVISION_DB_MANGOS "required_8835_01_mangos_command" + #define REVISION_DB_MANGOS "required_8840_01_mangos_spell_proc_event" #define REVISION_DB_REALMD "required_8728_01_realmd_account" #endif // __REVISION_SQL_H__