Skip to content

Commit

Permalink
Collector's Edition rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
celguar committed Aug 21, 2022
1 parent ac37698 commit a149bfb
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/game/Chat/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
};

Expand Down
1 change: 1 addition & 0 deletions src/game/Chat/Chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
52 changes: 52 additions & 0 deletions src/game/Chat/Level3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
164 changes: 164 additions & 0 deletions src/game/Entities/CharacterHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/game/Server/WorldSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/game/World/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/game/World/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down

0 comments on commit a149bfb

Please sign in to comment.