[0169] Implemented vendors selling currencies.

Also fix crash from recent master merge.

Signed-off-by: Yaki Khadafi <ElSolDolLo@gmail.com>
This commit is contained in:
Yaki Khadafi 2012-08-24 15:09:34 +03:00 committed by Antz
parent d4af997fbd
commit 6dd0ba1d14
23 changed files with 550 additions and 194 deletions

View file

@ -45,6 +45,7 @@
// |color|Hareatrigger_target:id|h[name]|h|r
// |color|Hcreature:creature_guid|h[name]|h|r
// |color|Hcreature_entry:creature_id|h[name]|h|r
// |color|Hcurrency:currency_id||h[name]|h|r
// |color|Henchant:recipe_spell_id|h[prof_name: recipe_name]|h|r - client, at shift click in recipes list dialog
// |color|Hgameevent:id|h[name]|h|r
// |color|Hgameobject:go_guid|h[name]|h|r
@ -438,6 +439,7 @@ ChatCommand* ChatHandler::getCommandTable()
static ChatCommand npcCommandTable[] =
{
{ "add", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddCommand, "", NULL },
{ "addcurrency", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddVendorCurrencyCommand,"", NULL },
{ "additem", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddVendorItemCommand, "", NULL },
{ "addmove", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAddMoveCommand, "", NULL },
{ "aiinfo", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcAIInfoCommand, "", NULL },
@ -445,6 +447,7 @@ ChatCommand* ChatHandler::getCommandTable()
{ "changeentry", SEC_ADMINISTRATOR, false, &ChatHandler::HandleNpcChangeEntryCommand, "", NULL },
{ "changelevel", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcChangeLevelCommand, "", NULL },
{ "delete", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcDeleteCommand, "", NULL },
{ "delcurrency", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcDelVendorCurrencyCommand,"", NULL },
{ "delitem", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcDelVendorItemCommand, "", NULL },
{ "factionid", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcFactionIdCommand, "", NULL },
{ "flag", SEC_GAMEMASTER, false, &ChatHandler::HandleNpcFlagCommand, "", NULL },
@ -1447,6 +1450,7 @@ bool ChatHandler::isValidChatMessage(const char* message)
/*
valid examples:
|cff00aa00|Hcurrency:391|h[Ðåêîìåíäàòåëüíûé çíà÷îê Òîë Áàðàäà]|h|r
|cffa335ee|Hitem:812:0:0:0:0:0:0:0:70|h[Glowing Brightwood Staff]|h|r
|cff808080|Hquest:2278:47|h[The Platinum Discs]|h|r
|cffffd000|Htrade:4037:1:150:1:6AAAAAAAAAAAAAAAAAAAAAAOAADAAAAAAAAAAAAAAAAIAAAAAAAAA|h[Engineering]|h|r
@ -1506,6 +1510,7 @@ bool ChatHandler::isValidChatMessage(const char* message)
uint32 color = 0;
CurrencyTypesEntry const* linkedCurrency = NULL;
ItemPrototype const* linkedItem = NULL;
Quest const* linkedQuest = NULL;
SpellEntry const* linkedSpell = NULL;
@ -1517,6 +1522,7 @@ bool ChatHandler::isValidChatMessage(const char* message)
{
if (validSequence == validSequenceIterator)
{
linkedCurrency = NULL;
linkedItem = NULL;
linkedQuest = NULL;
linkedSpell = NULL;
@ -1606,7 +1612,26 @@ bool ChatHandler::isValidChatMessage(const char* message)
if (reader.eof()) // : must be
return false;
if (strcmp(buffer, "item") == 0)
if (strcmp(buffer, "currency") == 0)
{
if (color != CHAT_LINK_COLOR_CURRENCY)
return false;
uint32 currencyEntry = 0;
// read currency entry
char c = reader.peek();
while (c >= '0' && c <= '9')
{
reader.ignore(1);
currencyEntry *= 10;
currencyEntry += c - '0';
c = reader.peek();
}
linkedCurrency = sCurrencyTypesStore.LookupEntry(currencyEntry);
if (!linkedCurrency)
return false;
}
else if (strcmp(buffer, "item") == 0)
{
// read item entry
reader.getline(buffer, 256, ':');
@ -1886,7 +1911,24 @@ bool ChatHandler::isValidChatMessage(const char* message)
return false;
// verify the link name
if (linkedSpell)
if (linkedCurrency)
{
if (linkedCurrency->ID == CURRENCY_CONQUEST_ARENA_META || linkedCurrency->ID == CURRENCY_CONQUEST_BG_META)
return false;
bool foundName = false;
for (uint8 i = 0; i < MAX_LOCALE; ++i)
{
if (*linkedCurrency->name[i] && strcmp(linkedCurrency->name[i], buffer) == 0)
{
foundName = true;
break;
}
}
if (!foundName)
return false;
}
else if (linkedSpell)
{
// spells with that flag have a prefix of "$PROFESSION: "
if (linkedSpell->HasAttribute(SPELL_ATTR_TRADESPELL))