From 6ef88699d12d9e454db9a7a766381cdffcf7ba0e Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Fri, 9 Apr 2010 21:25:05 +0400 Subject: [PATCH] [9710] Add gm possibilities reset talents for all specs. * At login reset '.reset all talents' will reset all spec talents. * New command '.reset specs' will reset its online/offline. * Command '.reset talents' now not support offline player case. --- sql/mangos.sql | 5 +-- sql/updates/9710_01_mangos_command.sql | 6 ++++ sql/updates/Makefile.am | 2 ++ src/game/CharacterHandler.cpp | 2 +- src/game/Chat.cpp | 1 + src/game/Chat.h | 1 + src/game/Level3.cpp | 45 ++++++++++++++++++++------ src/game/Player.cpp | 33 +++++++++++++++++-- src/game/Player.h | 2 +- src/shared/revision_nr.h | 2 +- src/shared/revision_sql.h | 2 +- 11 files changed, 83 insertions(+), 18 deletions(-) create mode 100644 sql/updates/9710_01_mangos_command.sql diff --git a/sql/mangos.sql b/sql/mangos.sql index 99a9422f4..10af84566 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_9704_01_mangos_achievement_reward` bit(1) default NULL + `required_9710_01_mangos_command` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -731,7 +731,8 @@ INSERT INTO `command` VALUES ('reset level',3,'Syntax: .reset level [Playername]\r\n Reset level to 1 including reset stats and talents. Equipped items with greater level requirement can be lost.'), ('reset spells',3,'Syntax: .reset spells [Playername]\r\n Removes all non-original spells from spellbook.\r\n. Playername can be name of offline character.'), ('reset stats',3,'Syntax: .reset stats [Playername]\r\n Resets(recalculate) all stats of the targeted player to their original VALUESat current level.'), -('reset talents',3,'Syntax: .reset talents [Playername]\r\n Removes all talents of the targeted player or pet or named player. Playername can be name of offline character. With player talents also will be reset talents for all character\'s pets if any.'), +('reset specs',3,'Syntax: .reset specs [Playername]\r\n Removes all talents (for all specs) of the targeted player or named player. Playername can be name of offline character. With player talents also will be reset talents for all character\'s pets if any.'), +('reset talents',3,'Syntax: .reset talents [Playername]\r\n Removes all talents (current spec) of the targeted player or pet or named player. With player talents also will be reset talents for all character\'s pets if any.'), ('respawn',3,'Syntax: .respawn\r\n\r\nRespawn selected creature or respawn all nearest creatures (if none selected) and GO without waiting respawn time expiration.'), ('revive',3,'Syntax: .revive\r\n\r\nRevive the selected player. If no player is selected, it will revive you.'), ('save',0,'Syntax: .save\r\n\r\nSaves your character.'), diff --git a/sql/updates/9710_01_mangos_command.sql b/sql/updates/9710_01_mangos_command.sql new file mode 100644 index 000000000..b3957a489 --- /dev/null +++ b/sql/updates/9710_01_mangos_command.sql @@ -0,0 +1,6 @@ +ALTER TABLE db_version CHANGE COLUMN required_9704_01_mangos_achievement_reward required_9710_01_mangos_command bit; + +DELETE FROM command WHERE name IN ('reset specs','reset talents'); +INSERT INTO command VALUES +('reset specs',3,'Syntax: .reset specs [Playername]\r\n Removes all talents (for all specs) of the targeted player or named player. Playername can be name of offline character. With player talents also will be reset talents for all character\'s pets if any.'), +('reset talents',3,'Syntax: .reset talents [Playername]\r\n Removes all talents (current spec) of the targeted player or pet or named player. With player talents also will be reset talents for all character\'s pets if any.'); diff --git a/sql/updates/Makefile.am b/sql/updates/Makefile.am index 7dbf29ebf..f918bd367 100644 --- a/sql/updates/Makefile.am +++ b/sql/updates/Makefile.am @@ -111,6 +111,7 @@ pkgdata_DATA = \ 9692_03_mangos_spell_proc_event.sql \ 9702_01_characters_item.sql \ 9704_01_mangos_achievement_reward.sql \ + 9710_01_mangos_command.sql \ README ## Additional files to include when running 'make dist' @@ -202,4 +203,5 @@ EXTRA_DIST = \ 9692_03_mangos_spell_proc_event.sql \ 9702_01_characters_item.sql \ 9704_01_mangos_achievement_reward.sql \ + 9710_01_mangos_command.sql \ README diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 87b10639c..ae7e3f166 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -768,7 +768,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder) if(pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS)) { - pCurrChar->resetTalents(true); + pCurrChar->resetTalents(true,true); pCurrChar->SendTalentsInfoData(false); // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state SendNotification(LANG_RESET_TALENTS); // we can use SMSG_TALENTS_INVOLUNTARILY_RESET here } diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index c410d2e31..11b298e1f 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -484,6 +484,7 @@ ChatCommand * ChatHandler::getCommandTable() { "achievements", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetAchievementsCommand, "", NULL }, { "honor", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetHonorCommand, "", NULL }, { "level", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetLevelCommand, "", NULL }, + { "specs", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetSpecsCommand, "", NULL }, { "spells", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetSpellsCommand, "", NULL }, { "stats", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetStatsCommand, "", NULL }, { "talents", SEC_ADMINISTRATOR, true, &ChatHandler::HandleResetTalentsCommand, "", NULL }, diff --git a/src/game/Chat.h b/src/game/Chat.h index 10979cfe8..bea9f9efb 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -402,6 +402,7 @@ class ChatHandler bool HandleResetAllCommand(const char * args); bool HandleResetHonorCommand(const char * args); bool HandleResetLevelCommand(const char * args); + bool HandleResetSpecsCommand(const char * args); bool HandleResetSpellsCommand(const char * args); bool HandleResetStatsCommand(const char * args); bool HandleResetTalentsCommand(const char * args); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index 23bacd559..68c319a81 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -4534,12 +4534,47 @@ bool ChatHandler::HandleResetSpellsCommand(const char * args) return true; } -bool ChatHandler::HandleResetTalentsCommand(const char * args) +bool ChatHandler::HandleResetSpecsCommand(const char * args) { Player* target; uint64 target_guid; std::string target_name; if (!extractPlayerTarget((char*)args, &target, &target_guid, &target_name)) + return false; + + if (target) + { + target->resetTalents(true,true); + target->SendTalentsInfoData(false); + ChatHandler(target).SendSysMessage(LANG_RESET_TALENTS); + if (!m_session || m_session->GetPlayer() != target) + PSendSysMessage(LANG_RESET_TALENTS_ONLINE,GetNameLink(target).c_str()); + + Pet* pet = target->GetPet(); + Pet::resetTalentsForAllPetsOf(target, pet); + if(pet) + target->SendTalentsInfoData(true); + return true; + } + else if (target_guid) + { + uint32 at_flags = AT_LOGIN_RESET_TALENTS | AT_LOGIN_RESET_PET_TALENTS; + CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'", at_flags, GUID_LOPART(target_guid) ); + std::string nameLink = playerLink(target_name); + PSendSysMessage(LANG_RESET_TALENTS_OFFLINE, nameLink.c_str()); + return true; + } + + SendSysMessage(LANG_NO_CHAR_SELECTED); + SetSentErrorMessage(true); + return false; +} + +bool ChatHandler::HandleResetTalentsCommand(const char * args) +{ + Player* target; + std::string target_name; + if (!extractPlayerTarget((char*)args, &target, NULL, &target_name)) { // Try reset talents as Hunter Pet Creature* creature = getSelectedCreature(); @@ -4577,14 +4612,6 @@ bool ChatHandler::HandleResetTalentsCommand(const char * args) target->SendTalentsInfoData(true); return true; } - else if (target_guid) - { - uint32 at_flags = AT_LOGIN_RESET_PET_TALENTS; - CharacterDatabase.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'", at_flags, GUID_LOPART(target_guid) ); - std::string nameLink = playerLink(target_name); - PSendSysMessage(LANG_RESET_TALENTS_OFFLINE, nameLink.c_str()); - return true; - } SendSysMessage(LANG_NO_CHAR_SELECTED); SetSentErrorMessage(true); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 3f7c7733e..5a248aa78 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -3666,13 +3666,13 @@ uint32 Player::resetTalentsCost() const } } -bool Player::resetTalents(bool no_cost) +bool Player::resetTalents(bool no_cost, bool all_specs) { // not need after this call - if(HasAtLoginFlag(AT_LOGIN_RESET_TALENTS)) + if(HasAtLoginFlag(AT_LOGIN_RESET_TALENTS) && all_specs) RemoveAtLoginFlag(AT_LOGIN_RESET_TALENTS,true); - if (m_usedTalentCount == 0) + if (m_usedTalentCount == 0 && !all_specs) { UpdateFreeTalentPoints(false); // for fix if need counter return false; @@ -3730,6 +3730,33 @@ bool Player::resetTalents(bool no_cost) iter = m_talents[m_activeSpec].begin(); } + // for not current spec just mark removed all saved to DB case and drop not saved + if (all_specs) + { + for (uint8 spec = 0; spec < MAX_TALENT_SPEC_COUNT; ++spec) + { + if (spec == m_activeSpec) + continue; + + for (PlayerTalentMap::iterator iter = m_talents[spec].begin(); iter != m_talents[spec].end();) + { + switch (iter->second.state) + { + case PLAYERSPELL_REMOVED: + ++iter; + break; + case PLAYERSPELL_NEW: + m_talents[spec].erase(iter++); + break; + default: + iter->second.state = PLAYERSPELL_REMOVED; + ++iter; + break; + } + } + } + } + UpdateFreeTalentPoints(false); if(!no_cost) diff --git a/src/game/Player.h b/src/game/Player.h index b6e6f30bf..97ebe75ac 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1570,7 +1570,7 @@ class MANGOS_DLL_SPEC Player : public Unit uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); } void SetFreeTalentPoints(uint32 points) { SetUInt32Value(PLAYER_CHARACTER_POINTS1,points); } void UpdateFreeTalentPoints(bool resetIfNeed = true); - bool resetTalents(bool no_cost = false); + bool resetTalents(bool no_cost = false, bool all_specs = false); uint32 resetTalentsCost() const; void InitTalentForLevel(); void BuildPlayerTalentsInfoData(WorldPacket *data); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 1a19c3998..67ed7223a 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 "9709" + #define REVISION_NR "9710" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index f6e9c710d..2c85aa594 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_9702_01_characters_item" - #define REVISION_DB_MANGOS "required_9704_01_mangos_achievement_reward" + #define REVISION_DB_MANGOS "required_9710_01_mangos_command" #define REVISION_DB_REALMD "required_9010_01_realmd_realmlist" #endif // __REVISION_SQL_H__