diff --git a/src/game/Chat/Chat.cpp b/src/game/Chat/Chat.cpp index 445132d3eea..4f9d22c0f69 100644 --- a/src/game/Chat/Chat.cpp +++ b/src/game/Chat/Chat.cpp @@ -78,6 +78,7 @@ ChatCommand* ChatHandler::getCommandTable() { "addon", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAccountSetAddonCommand, "", nullptr }, { "gmlevel", SEC_CONSOLE, true, &ChatHandler::HandleAccountSetGmLevelCommand, "", nullptr }, { "password", SEC_CONSOLE, true, &ChatHandler::HandleAccountSetPasswordCommand, "", nullptr }, + { "edition", SEC_ADMINISTRATOR, true, &ChatHandler::HandleAccountSetEditionCommand, "", nullptr }, { nullptr, 0, false, nullptr, "", nullptr } }; diff --git a/src/game/Chat/Chat.h b/src/game/Chat/Chat.h index b2bd5a6aace..d9ad1318a44 100644 --- a/src/game/Chat/Chat.h +++ b/src/game/Chat/Chat.h @@ -212,6 +212,7 @@ class ChatHandler bool HandleAccountSetAddonCommand(char* args); bool HandleAccountSetGmLevelCommand(char* args); bool HandleAccountSetPasswordCommand(char* args); + bool HandleAccountSetEditionCommand(char* args); #ifdef BUILD_AHBOT bool HandleAHBotRebuildCommand(char* args); diff --git a/src/game/Chat/Level3.cpp b/src/game/Chat/Level3.cpp index 808134c52aa..0d5a21d46d3 100644 --- a/src/game/Chat/Level3.cpp +++ b/src/game/Chat/Level3.cpp @@ -1284,6 +1284,58 @@ bool ChatHandler::HandleAccountSetPasswordCommand(char* args) return false; } +// Set collector's edition +bool ::ChatHandler::HandleAccountSetEditionCommand(char* args) +{ + char* accountStr = ExtractOptNotLastArg(&args); + + std::string targetAccountName; + Player* targetPlayer = nullptr; + uint32 targetAccountId = ExtractAccountId(&accountStr, &targetAccountName, &targetPlayer); + if (!targetAccountId) + return false; + + bool value; + if (!ExtractOnOff(&args, value)) + { + SendSysMessage(LANG_USE_BOL); + SetSentErrorMessage(true); + return false; + } + + if (value) + { + if (targetPlayer && targetPlayer->GetSession()->HasAccountFlag(ACCOUNT_FLAG_COLLECTOR_CLASSIC | ACCOUNT_FLAG_COLLECTOR_TBC | ACCOUNT_FLAG_COLLECTOR_WRATH)) + { + SendSysMessage("Target account already has Collector's Edition enabled"); + return false; + } + if (targetPlayer) + targetPlayer->GetSession()->AddAccountFlag(ACCOUNT_FLAG_COLLECTOR_CLASSIC | ACCOUNT_FLAG_COLLECTOR_TBC | ACCOUNT_FLAG_COLLECTOR_WRATH); + + LoginDatabase.PExecute("UPDATE account SET flags = flags | 0x%x WHERE id = %u", targetAccountId, ACCOUNT_FLAG_COLLECTOR_CLASSIC | ACCOUNT_FLAG_COLLECTOR_TBC | ACCOUNT_FLAG_COLLECTOR_WRATH); + SendSysMessage("Target account Collector's Edition enabled"); + return true; + } + else + { + if (targetPlayer && !targetPlayer->GetSession()->HasAccountFlag(ACCOUNT_FLAG_COLLECTOR_CLASSIC | ACCOUNT_FLAG_COLLECTOR_TBC | ACCOUNT_FLAG_COLLECTOR_WRATH)) + { + SendSysMessage("Target account does not have Collector's Edition enabled"); + return false; + } + if (targetPlayer) + targetPlayer->GetSession()->AddAccountFlag(ACCOUNT_FLAG_COLLECTOR_CLASSIC | ACCOUNT_FLAG_COLLECTOR_TBC | ACCOUNT_FLAG_COLLECTOR_WRATH); + + LoginDatabase.PExecute("UPDATE account SET flags = flags & ~0x%x WHERE id = %u", targetAccountId, ACCOUNT_FLAG_COLLECTOR_CLASSIC | ACCOUNT_FLAG_COLLECTOR_TBC | ACCOUNT_FLAG_COLLECTOR_WRATH); + SendSysMessage("Target account Collector's Edition disabled"); + return true; + } + + //PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, GetNameLink(target).c_str(), args); + return true; +} + void ChatHandler::ShowAchievementCriteriaListHelper(AchievementCriteriaEntry const* criEntry, AchievementEntry const* achEntry, LocaleConstant loc, Player* target /*= nullptr*/) { std::ostringstream ss; diff --git a/src/game/Entities/CharacterHandler.cpp b/src/game/Entities/CharacterHandler.cpp index 4c54d07c73c..ba0aae4496b 100644 --- a/src/game/Entities/CharacterHandler.cpp +++ b/src/game/Entities/CharacterHandler.cpp @@ -40,6 +40,7 @@ #include "Calendar/Calendar.h" #include "AI/ScriptDevAI/ScriptDevAIMgr.h" #include "Anticheat/Anticheat.hpp" +#include "Mail.h" #include "AI/ScriptDevAI/scripts/custom/Transmogrification.h" #ifdef BUILD_PLAYERBOT @@ -1043,6 +1044,169 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder) if (pCurrChar->HasAtLoginFlag(AT_LOGIN_FIRST)) pCurrChar->RemoveAtLoginFlag(AT_LOGIN_FIRST); + // add collector to all accounts if enabled + if (sWorld.getConfig(CONFIG_BOOL_COLLECTORS_EDITION) && !(HasAccountFlag(ACCOUNT_FLAG_COLLECTOR_CLASSIC) && HasAccountFlag(ACCOUNT_FLAG_COLLECTOR_TBC) && HasAccountFlag(ACCOUNT_FLAG_COLLECTOR_WRATH))) + { + AddAccountFlag(ACCOUNT_FLAG_COLLECTOR_CLASSIC | ACCOUNT_FLAG_COLLECTOR_TBC | ACCOUNT_FLAG_COLLECTOR_WRATH); + LoginDatabase.PExecute("UPDATE account SET flags = flags | 0x%x WHERE id = %u", GetAccountId(), ACCOUNT_FLAG_COLLECTOR_CLASSIC | ACCOUNT_FLAG_COLLECTOR_TBC | ACCOUNT_FLAG_COLLECTOR_WRATH); + } + + // create collector's edition reward (tbc) + if (HasAccountFlag(ACCOUNT_FLAG_COLLECTOR_TBC) && !(pCurrChar->HasItemCount(25535, 1, true) || pCurrChar->HasSpell(32298))) + { + bool hasPetReward = false; + // check if already has in mail + for (PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr) + { + // skip deleted mails + if ((*itr)->state == MAIL_STATE_DELETED) + continue; + + uint8 item_count = uint8((*itr)->items.size()); + for (uint8 i = 0; i < item_count; ++i) + { + Item* item = _player->GetMItem((*itr)->items[i].item_guid); + if (item->GetEntry() == 25535) + { + hasPetReward = true; + break; + } + } + } + + if (!hasPetReward) + { + ostringstream body; + body << "Hello, " << pCurrChar->GetName() << ",\n\n"; + body << "Welcome to the World of Warcraft!\n\n"; + body << "As special thanks for purchasing the World of Warcraft: The Burning Crusade Collector's Edition we send you a gift: a little companion to join you on your quest for adventure and glory.\n\n"; + body << "Thanks again, and enjoy your stay in the World of Warcraft!"; + + MailDraft draft; + draft.SetSubjectAndBody("Collector's Edition Gift", body.str()); + + Item* gift = Item::CreateItem(25535, 1, nullptr); + gift->SaveToDB(); + draft.AddItem(gift); + + MailSender sender(MAIL_NORMAL, (uint32)0, MAIL_STATIONERY_GM); + draft.SendMailTo(MailReceiver(pCurrChar, pCurrChar->GetObjectGuid()), sender); + } + } + + // create collector's edition reward (tbc) + if (HasAccountFlag(ACCOUNT_FLAG_COLLECTOR_WRATH) && !(pCurrChar->HasItemCount(39286, 1, true) || pCurrChar->HasSpell(52615))) + { + bool hasPetReward = false; + // check if already has in mail + for (PlayerMails::iterator itr = _player->GetMailBegin(); itr != _player->GetMailEnd(); ++itr) + { + // skip deleted mails + if ((*itr)->state == MAIL_STATE_DELETED) + continue; + + uint8 item_count = uint8((*itr)->items.size()); + for (uint8 i = 0; i < item_count; ++i) + { + Item* item = _player->GetMItem((*itr)->items[i].item_guid); + if (item->GetEntry() == 39286) + { + hasPetReward = true; + break; + } + } + } + + if (!hasPetReward) + { + ostringstream body; + body << "Hello, " << pCurrChar->GetName() << ",\n\n"; + body << "Welcome to the World of Warcraft!\n\n"; + body << "As special thanks for purchasing the World of Warcraft: Wrath of the Lich King Collector's Edition we send you a gift: a little companion to join you on your quest for adventure and glory.\n\n"; + body << "Thanks again, and enjoy your stay in the World of Warcraft!"; + + MailDraft draft; + draft.SetSubjectAndBody("Collector's Edition Gift", body.str()); + + Item* gift = Item::CreateItem(39286, 1, nullptr); + gift->SaveToDB(); + draft.AddItem(gift); + + MailSender sender(MAIL_NORMAL, (uint32)0, MAIL_STATIONERY_GM); + draft.SendMailTo(MailReceiver(pCurrChar, pCurrChar->GetObjectGuid()), sender); + } + } + + // create collector's edition reward (vanilla) + if (HasAccountFlag(ACCOUNT_FLAG_COLLECTOR_CLASSIC)) + { + uint32 itemid = 0; + uint32 questid = 0; + switch (pCurrChar->getRace()) + { + case RACE_HUMAN: + itemid = 14646; + questid = 5805; + break; + case RACE_ORC: + case RACE_TROLL: + itemid = 14649; + questid = 5843; + break; + case RACE_DWARF: + case RACE_GNOME: + itemid = 14647; + questid = 5843; + break; + case RACE_NIGHTELF: + itemid = 14648; + questid = 5842; + break; + case RACE_UNDEAD: + itemid = 14651; + questid = 5847; + break; + case RACE_TAUREN: + itemid = 14650; + questid = 5844; + break; + } + + if (itemid && questid) + { + if (!pCurrChar->HasQuest(questid) && !pCurrChar->HasItemCount(itemid, 1, true) && !pCurrChar->GetQuestRewardStatus(questid)) + { + ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid); + if (pProto) + { + uint32 noSpaceForCount = 0; + ItemPosCountVec dest; + uint8 msg = pCurrChar->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, 1, &noSpaceForCount); + if (msg != EQUIP_ERR_OK) + { + ostringstream body; + body << "Hello, " << pCurrChar->GetName() << ",\n\n"; + body << "Welcome to the World of Warcraft!\n\n"; + body << "As special thanks for purchasing the World of Warcraft Collector's Edition we send you a gift: a little companion to join you on your quest for adventure and glory.\n\n"; + body << "Thanks again, and enjoy your stay in the World of Warcraft!"; + + MailDraft draft; + draft.SetSubjectAndBody("Collector's Edition Gift", body.str()); + + Item* gift = Item::CreateItem(itemid, 1, nullptr); + gift->SaveToDB(); + draft.AddItem(gift); + + MailSender sender(MAIL_NORMAL, (uint32)0, MAIL_STATIONERY_GM); + draft.SendMailTo(MailReceiver(pCurrChar, pCurrChar->GetObjectGuid()), sender); + } + else + Item* item = pCurrChar->StoreNewItem(dest, itemid, true); + } + } + } + } + // show time before shutdown if shutdown planned. if (sWorld.IsShutdowning()) sWorld.ShutdownMsg(true, pCurrChar); diff --git a/src/game/Server/WorldSession.h b/src/game/Server/WorldSession.h index 5f099472235..86a0b4fc298 100644 --- a/src/game/Server/WorldSession.h +++ b/src/game/Server/WorldSession.h @@ -192,6 +192,9 @@ enum AccountFlags ACCOUNT_FLAG_SILENCED = 0x02, ACCOUNT_FLAG_SHOW_ANTISPAM = 0x04, ACCOUNT_FLAG_HIDDEN = 0x08, + ACCOUNT_FLAG_COLLECTOR_CLASSIC = 0x10, + ACCOUNT_FLAG_COLLECTOR_TBC = 0x20, + ACCOUNT_FLAG_COLLECTOR_WRATH = 0x40, }; // class to deal with packet processing diff --git a/src/game/World/World.cpp b/src/game/World/World.cpp index 5778ff3bb07..930736300c2 100644 --- a/src/game/World/World.cpp +++ b/src/game/World/World.cpp @@ -580,6 +580,8 @@ void World::LoadConfigSettings(bool reload) setConfigMinMax(CONFIG_UINT32_START_ARENA_POINTS, "StartArenaPoints", 0, 0, getConfig(CONFIG_UINT32_MAX_ARENA_POINTS)); + setConfig(CONFIG_BOOL_COLLECTORS_EDITION, "Custom.CollectorsEdition", true); + setConfig(CONFIG_BOOL_ALWAYS_SHOW_QUEST_GREETING, "AlwaysShowQuestGreeting", false); setConfig(CONFIG_BOOL_TAXI_FLIGHT_CHAT_FIX, "TaxiFlightChatFix", false); diff --git a/src/game/World/World.h b/src/game/World/World.h index 2f1268ea144..e7824083c91 100644 --- a/src/game/World/World.h +++ b/src/game/World/World.h @@ -306,6 +306,7 @@ enum eConfigUInt32Values CONFIG_UINT32_HALLSOFREFLECTION_LEVEL, CONFIG_UINT32_CHAMBEROFASPECTSRED_LEVEL, //End Solocraft Defines + CONFIG_BOOL_COLLECTORS_EDITION, CONFIG_UINT32_VALUE_COUNT };