aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/updates/7134_world_command.sql9
-rw-r--r--sql/updates/7134_world_trinity_string.sql11
-rw-r--r--sql/world.sql14
-rw-r--r--src/game/Chat.cpp14
-rw-r--r--src/game/Chat.h8
-rw-r--r--src/game/DBCStructure.h2
-rw-r--r--src/game/DBCfmt.h2
-rw-r--r--src/game/Language.h10
-rw-r--r--src/game/Level1.cpp36
-rw-r--r--src/game/Level2.cpp302
-rw-r--r--src/game/Level3.cpp4
11 files changed, 368 insertions, 44 deletions
diff --git a/sql/updates/7134_world_command.sql b/sql/updates/7134_world_command.sql
new file mode 100644
index 00000000000..442bced945a
--- /dev/null
+++ b/sql/updates/7134_world_command.sql
@@ -0,0 +1,9 @@
+DELETE FROM command where name IN ('character titles','modify titles','titles add','titles current','titles remove','lookup title');
+
+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'),
+('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.'); \ No newline at end of file
diff --git a/sql/updates/7134_world_trinity_string.sql b/sql/updates/7134_world_trinity_string.sql
new file mode 100644
index 00000000000..32b0887888d
--- /dev/null
+++ b/sql/updates/7134_world_trinity_string.sql
@@ -0,0 +1,11 @@
+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/world.sql b/sql/world.sql
index ff6cd6cdcdf..3235d76a1dd 100644
--- a/sql/world.sql
+++ b/sql/world.sql
@@ -352,6 +352,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.'),
('cometome','3','SYntax: .cometome $parameter\nMake selected creature come to your current location (new position not saved to DB).'),
('commands','0','Syntax: .commands\r\n\r\nDisplay a list of available commands for your account level.'),
@@ -493,7 +494,6 @@ INSERT INTO `command` VALUES
('modify spell','1','TODO'),
('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 50.'),
-('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 [$reason]\r\n\r\nDisible chat messaging for any character from account of character $playerName (or currently selected) at $timeInMinutes minutes. Player can be offline.'),
@@ -672,6 +672,10 @@ INSERT INTO `command` VALUES
('ticket unassign','3','Usage: .ticket unassign $ticketid.\r\nUnassigns the specified ticket from the current assigned Game Master.'),
('ticket viewid','1','Usage: .ticket viewid $ticketid.\r\nReturns details about specified ticket. Ticket must be open and not deleted.'),
('ticket viewname','1','Usage: .ticket viewname $creatorname. \r\nReturns details about specified ticket. Ticket must be open and not deleted.'),
+('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','3','Syntax: .unban $subcommand\nType .unban to see the list of possible subcommands or .help unban $subcommand to see info on subcommands'),
('unban account','3','Syntax: .unban account $Name\r\nUnban accounts for account name pattern.'),
@@ -7138,6 +7142,14 @@ INSERT INTO `trinity_string` (`entry`,`content_default`,`content_loc1`,`content_
(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/src/game/Chat.cpp b/src/game/Chat.cpp
index a56129b509c..a5cf781864e 100644
--- a/src/game/Chat.cpp
+++ b/src/game/Chat.cpp
@@ -58,6 +58,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;
@@ -126,6 +127,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 }
};
@@ -317,6 +319,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 },
{ "map", SEC_ADMINISTRATOR, true, &ChatHandler::HandleLookupMapCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
@@ -339,7 +342,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 },
@@ -598,6 +600,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 },
@@ -647,6 +658,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 fb359155bfa..efde05f8c94 100644
--- a/src/game/Chat.h
+++ b/src/game/Chat.h
@@ -137,6 +137,7 @@ class TRINITY_DLL_SPEC 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);
@@ -264,8 +265,8 @@ class TRINITY_DLL_SPEC ChatHandler
bool HandleLookupTaxiNodeCommand(const char * args);
bool HandleLookupTeleCommand(const char * args);
bool HandleLookupMapCommand(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);
@@ -459,6 +460,11 @@ class TRINITY_DLL_SPEC 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 f2d364716c8..1c80fdd2819 100644
--- a/src/game/DBCStructure.h
+++ b/src/game/DBCStructure.h
@@ -625,7 +625,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 e48a4b03cd9..aede5bf3838 100644
--- a/src/game/DBCfmt.h
+++ b/src/game/DBCfmt.h
@@ -32,7 +32,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 8a0338e7dad..6558908d302 100644
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -330,7 +330,15 @@ enum TrinityStrings
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 a158572590f..d31cf17b567 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -1074,42 +1074,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 f0f89f01a67..8d22191b25e 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -20,6 +20,7 @@
#include "Common.h"
#include "Database/DatabaseEnv.h"
+#include "DBCStores.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "Item.h"
@@ -4242,3 +4243,304 @@ bool ChatHandler::HandleNpcSetLinkCommand(const char* args)
PSendSysMessage("LinkGUID '%u' added to creature with DBTableGUID: '%u'", linkguid, pCreature->GetDBTableGUIDLow());
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) ? GetTrinityString(LANG_KNOWN) : "";
+
+ char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE)==titleInfo->bit_index
+ ? GetTrinityString(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 = GetTrinityString(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
+ ? GetTrinityString(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 f437eb5116c..2a01fbb2a2c 100644
--- a/src/game/Level3.cpp
+++ b/src/game/Level3.cpp
@@ -1612,7 +1612,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;
}
@@ -1623,7 +1623,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;
}