[svn] * Merge CLI Commands with regular commands and give them level4 access. sec_console. Source mangos - thanks to ogeraisi for the amalgamated patch.

* Redid/Fixed/Added some lang strings.
* As usual remember this is a trunk rev so stability only guaranteed on northern countries of Mars and western parts of Pluto. No warranties outside the solar system, sorry :( . Check with your local government or dictator on regulations regarding export.

--HG--
branch : trunk
This commit is contained in:
KingPin
2008-10-26 13:32:42 -05:00
parent 6f2e0ee48a
commit a0f843a3eb
22 changed files with 2303 additions and 2126 deletions

View File

162
sql/updates/120_world.sql Normal file
View File

@@ -0,0 +1,162 @@
-- Add/Edit/Move lang strings
DELETE FROM `trinity_string` WHERE `entry` IN (25,52,54,55,56,171,401,413,438,593,594,595,596,597,598,599,614,615,636,637,638,809,1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1100,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118);
DELETE FROM `trinity_string` WHERE `entry` BETWEEN '667' AND '687';
DELETE FROM `trinity_string` WHERE `entry` BETWEEN '711' AND '716';
DELETE FROM `trinity_string` WHERE `entry` BETWEEN '730' AND '747';
DELETE FROM `trinity_string` WHERE `entry` BETWEEN '5000' AND '5006';
INSERT INTO trinity_string VALUES
('25','Password not changed (unknown error)!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
('52', 'Invaid item count (%u) for item %u', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('54','The new passwords do not match',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
('55','Your password can\'t be longer than 16 characters (client limit), password not changed!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
('56','Current Message of the day: \r\n%s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(171,'You are being teleported by server console command.',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),
(413,'Account not exist: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(438,'Found items %u: %u ( inventory %u mail %u auction %u guild %u)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(593,'Currently Banned Accounts:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(594,'| Account | BanDate | UnbanDate | Banned By | Ban Reason |',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(595,'Currently Banned IPs:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(596,'| IP | BanDate | UnbanDate | Banned By | Ban Reason |',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(597,'Current gamemasters:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(598,'| Account | GM |',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(599,'No gamemasters.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
('614', 'The Alliance flag has been respawned!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('615', 'The Horde flag has been respawned!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('636', 'The Battle for Eye of the Storm begins in 1 minute.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('637', 'The Battle for Eye of the Storm begins in 30 seconds.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('638', 'The Battle for Eye of the Storm has begun!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('667', 'The Alliance has taken control of the Mage Tower!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('668', 'The Horde has taken control of the Mage Tower!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('669', 'The Alliance has taken control of the Draenei Ruins!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('670', 'The Horde has taken control of the Draenei Ruins!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('671', 'The Alliance has taken control of the Blood Elf Tower!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('672', 'The Horde has taken control of the Blood Elf Tower!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('673', 'The Alliance has taken control of the Fel Reaver Ruins!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('674', 'The Horde has taken control of the Fel Reaver Ruins!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('675', 'The Alliance has lost control of the Mage Tower!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('676', 'The Horde has lost control of the Mage Tower!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('677', 'The Alliance has lost control of the Draenei Ruins!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('678', 'The Horde has lost control of the Draenei Ruins!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('679', 'The Alliance has lost control of the Blood Elf Tower!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('680', 'The Horde has lost control of the Blood Elf Tower!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('681', 'The Alliance has lost control of the Fel Reaver Ruins!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('682', 'The Horde has lost control of the Fel Reaver Ruins!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('683', '$N has taken the flag!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('684', 'The Alliance has captured the flag!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('685', 'The Horde has captured the flag!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('686', 'The Flag has been dropped!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('687', 'The flag has been reset', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('711', 'Your group is too large for this battleground. Please regroup to join.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('712', 'Your group is too large for this arena. Please regroup to join.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('713', 'You must be level %u to join an arena team!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('714', '%s is not high enough level to join your team', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('715', 'You don\'t meet Battleground level requirements', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('716', 'Your arena team is full, %s cannot join it.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('730', 'Your group has members not in your arena team. Please regroup to join.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('731', 'Your group does not have enough players to join this match.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('732', 'The Gold Team wins!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('733', 'The Green Team wins!', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('734', 'There aren\'t enough players in this battleground. It will end soon unless some more players join to balance the fight.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('735', 'Your group has an offline member. Please remove him before joining.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('736', 'Your group has players from the opposing faction. You can\'t join the battleground as a group.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('737', 'Your group has players from different battleground brakets. You can\'t join as group.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('738', 'Someone in your party is already in this battleground queue. (S)he must leave it before joining as group.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('739', 'Someone in your party is Deserter. You can\'t join as group.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('740', 'Someone in your party is already in three battleground queues. You cannot join as group.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('741', 'You cannot teleport to a battleground or arena map.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('742', 'You cannot summon players to a battleground or arena map.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('743', 'You must be in GM mode to teleport to a player in a battleground.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('744', 'You cannot teleport to a battleground from another battleground. Please leave the current battleground first.', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('745', 'Arena testing turned %s', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('746','|cffff0000[Automatic]:|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('747','|cffffff00[|c1f40af20Announce by|r |cffff0000%s|cffffff00]:|r %s|r', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
('809','Account for character %s not found',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
('1000','Exiting daemon...',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
('1001','Account deleted: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
('1002','Account %s NOT deleted (probably sql file format was updated)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
('1003','Account %s NOT deleted (unknown error)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
('1004','Account created: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
('1005','Account name can\'t be longer than 16 characters (client limit), account not created!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1006,'Account with this name already exist!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1007,'Account %s NOT created (probably sql file format was updated)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1008,'Account %s NOT created (unknown error)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1009,'Player %s (Guid: %u) Account %s (Id: %u) deleted.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1010,'| Account | Character | IP | GM | TBC |',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1011,'|<Error> | %20s |<Error> |<Er>|<Err>|',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1100,'Account %s (Id: %u) have up to %u expansion allowed now.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1101,'Message of the day changed to:\r\n%s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1102,'Message sent to %s: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1103,'%d - %s %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1104,'%d - %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1105,'%d - %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1106,'%d - %s %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1107,'%d - %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1108,'%d - %s %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1109,'%d - %s %s %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1110,'%d - %s X:%f Y:%f Z:%f MapId:%d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1111,'%d - %s X:%f Y:%f Z:%f MapId:%d',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1112,'Failed to open file: %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1113,'Account %s (%u) have max amount allowed characters (client limit)',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1114,'Dump file has broken data!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1115,'Invalid character name!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1116,'Invalid character guid!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1117,'Character guid %u in use!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(1118,'%d - guild: %s (guid: %u) %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(5000,'You froze player %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(5001,'It might be amusing but no... you cant freeze yourself!',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(5002,'Invalid input check the name of target.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(5003,'You unfroze player %s.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(5004,'There are no frozen players.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(5005,'Following players are frozen on the server:',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),
(5006,'- %s',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
-- cleanup command syntax
DELETE FROM command WHERE name IN (
'gm ingame','gm online',
'ban','ban account','ban character','ban ip',
'baninfo','baninfo account','baninfo character','baninfo ip','pdump load',
'banlist','banlist account','banlist character','banlist ip','help','transport',
'unban','unban account','unban character','unban ip','list item','pdump write',
'acct','account','account create','account delete','account onlinelist',
'account set addon','account set gmlevel','account set password',
'chardelete','gm list','gm online','sendmessage','server corpses','server exit','server motd',
'server set loglevel','server set motd','security'
);
INSERT INTO command VALUES
('gm ingame',0,'Syntax: .gm ingame\r\n\r\nDisplay a list of available in game Game Masters.'),
('ban account',3,'Syntax is: ban account $Name $bantime $reason\r\nBan account kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),
('ban character',3,'Syntax is: ban character $Name $bantime $reason\r\nBan account and kick player.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),
('ban ip',3,'Syntax is: ban ip $Ip $bantime $reason\r\nBan IP.\r\n$bantime: negative value leads to permban, otherwise use a timestring like \"4d20h3s\".'),
('baninfo account',3,'Syntax is: baninfo account\r\nWatch full information about a specific ban.'),
('baninfo character',3,'Syntax is: baninfo character\r\nWatch full information about a specific ban.'),
('baninfo ip',3,'Syntax is: baninfo ip\r\nWatch full information about a specific ban.'),
('banlist account',3,'Syntax is: banlist account [$Name]\r\nSearches the banlist for a account name pattern or show full list account bans.'),
('banlist character',3,'Syntax is: banlist character $Name\r\nSearches the banlist for a character name pattern. Pattern required.'),
('banlist ip',3,'Syntax is: banlist ip [$Ip]\r\nSearches the banlist for a IP pattern or show full list of IP bans.'),
('unban account',3,'Syntax is: unban account $Name\r\nUnban accounts for account name pattern.'),
('unban character',3,'Syntax is: unban character $Name\r\nUnban accounts for character name pattern.'),
('unban ip',3,'Syntax is: unban ip $Ip\r\nUnban accounts for IP pattern.'),
('pdump write',3,'Syntax is: pdump write $filename $playerNameOrGUID\r\nWrite character dump with name/guid $playerNameOrGUID to file $filename.'),
('pdump load',3,'Syntax is: pdump load $filename $account [$newname] [$newguid]\r\nLoad character dump from dump file into character list of $account with saved or $newname, with saved (or first free) or $newguid guid.'),
('list item',3,'Syntax: .list item #item_id [#max_count]\r\n\r\nOutput items with item id #item_id found in all character inventories, mails, auctions, and guild banks. Output item guids, item owner guid, owner account and owner name (guild name and guid in case guild bank). Will be output maximum #max_count items. If #max_count not provided use 10 as default value.'),
('help',0,'Syntax: .help [$command]\r\n\r\nDisplay usage instructions for the given $command. If no $command provided show list available commands.'),
('account',0,'Syntax: .account\r\n\r\nDisplay the access level of your account.'),
('account create',4,'Syntax: .account create $account $password\r\n\r\nCreate account and set password to it.'),
('account delete',4,'Syntax: .account delete $account\r\n\r\nDelete account with all characters.'),
('account onlinelist',4,'Syntax: .account onlinelist\r\n\r\nShow list of online accounts.'),
('account set addon',3,'Syntax: .account set addon [$account] #addon\r\n\r\nSet user (posible targeted) expansion addon level allowed. Addon values: 0 - normal, 1 - tbc, 2 - wotlk.'),
('account set gmlevel',4,'Syntax: .account set gmlevel [$account] #level\r\n\r\nSet the security level for targeted player (can''t be used at self) or for account $name to a level of #level.\r\n\r\n#level may range from 0 to 3.'),
('account set password',4,'Syntax: .account set password $account $password $password\r\n\r\nSet password for account.'),
('chardelete',4,'Syntax: .chardelete $charactername\r\n\r\nDelete character.'),
('gm list',3,'Syntax: .gm list\r\n\r\nDisplay a list of all Game Masters accounts and security levels.'),
('gm online',0,'Syntax: .gm online\r\n\r\nDisplay a list of available Game Masters.'),
('sendmessage',3,'Syntax: .sendmessage $playername $message\r\n\r\nSend screen message to player from ADMINISTRATOR.'),
('server corpses',2,'Syntax: .server corpses\r\n\r\nTriggering corpses expire check in world.'),
('server exit',4,'Syntax: .server exit\r\n\r\nTerminate Trinity NOW.'),
('server motd',0,'Syntax: .server motd\r\n\r\nShow server Message of the day.'),
('server set loglevel',4,'Syntax: .server set loglevel #level\r\n\r\nSet server log level (0 - errors only, 1 - basic, 2 - detail, 3 - debug).'),
('server set motd',3,'Syntax: .server set motd $MOTD\r\n\r\nSet server Message of the day.');

View File

@@ -50,7 +50,6 @@ class AccountMgr
bool CheckPassword(uint32 accid, std::string passwd);
uint32 GetId(std::string username);
uint32 GetIdByGUID(const uint64 &guid) const;
uint32 GetSecurity(uint32 acc_id);
bool GetName(uint32 acc_id, std::string &name);

File diff suppressed because it is too large Load Diff

View File

@@ -35,6 +35,7 @@ class ChatCommand
public:
const char * Name;
uint32 SecurityLevel; // function pointer required correct align (use uint32)
bool AllowConsole;
bool (ChatHandler::*Handler)(const char* args);
std::string Help;
ChatCommand * ChildCommands;
@@ -61,9 +62,9 @@ class ChatHandler
static char* LineFromMessage(char*& pos) { char* start = strtok(pos,"\n"); pos = NULL; return start; }
const char *GetTrinityString(int32 entry);
virtual const char *GetTrinityString(int32 entry) const;
void SendSysMessage( const char *str);
virtual void SendSysMessage( const char *str);
void SendSysMessage( int32 entry);
void PSendSysMessage( const char *format, ...) ATTR_PRINTF(2,3);
void PSendSysMessage( int32 entry, ... );
@@ -71,7 +72,12 @@ class ChatHandler
int ParseCommands(const char* text);
protected:
explicit ChatHandler() : m_session(NULL) {} // for CLI subclass
bool hasStringAbbr(const char* name, const char* part);
virtual bool isAvailable(ChatCommand const& cmd) const;
void SendGlobalSysMessage(const char *str);
bool ExecuteCommandInTable(ChatCommand *table, const char* text, std::string fullcommand);
@@ -80,14 +86,22 @@ class ChatHandler
ChatCommand* getCommandTable();
bool HandleAccountCommand(const char* args);
bool HandleAccountCreateCommand(const char* args);
bool HandleAccountDeleteCommand(const char* args);
bool HandleAccountOnlineListCommand(const char* args);
bool HandleAccountSetAddonCommand(const char* args);
bool HandleAccountSetGmLevelCommand(const char* args);
bool HandleAccountSetPasswordCommand(const char* args);
bool HandleHelpCommand(const char* args);
bool HandleCommandsCommand(const char* args);
bool HandleAcctCommand(const char* args);
bool HandleStartCommand(const char* args);
bool HandleInfoCommand(const char* args);
bool HandleDismountCommand(const char* args);
bool HandleSaveCommand(const char* args);
bool HandleGMListCommand(const char* args);
bool HandleGMListIngameCommand(const char* args);
bool HandleGMListFullCommand(const char* args);
bool HandleNamegoCommand(const char* args);
bool HandleGonameCommand(const char* args);
@@ -208,6 +222,12 @@ class ChatHandler
bool HandleInstanceStatsCommand(const char* args);
bool HandleInstanceSaveDataCommand(const char * args);
bool HandleServerCorpsesCommand(const char* args);
bool HandleServerExitCommand(const char* args);
bool HandleServerMotdCommand(const char* args);
bool HandleServerSetMotdCommand(const char* args);
bool HandleServerSetLogLevelCommand(const char* args);
bool HandleAddHonorCommand(const char* args);
bool HandleHonorAddKillCommand(const char* args);
bool HandleUpdateHonorFieldsCommand(const char* args);
@@ -257,10 +277,19 @@ class ChatHandler
bool HandleUnFreezeCommand(const char *args);
bool HandleListFreezeCommand(const char* args);
bool HandleBanCommand(const char* args);
bool HandleUnBanCommand(const char* args);
bool HandleBanInfoCommand(const char* args);
bool HandleBanListCommand(const char* args);
bool HandleCharacterDeleteCommand(const char* args);
bool HandleBanAccountCommand(const char* args);
bool HandleBanCharacterCommand(const char* args);
bool HandleBanIPCommand(const char* args);
bool HandleUnBanAccountCommand(const char* args);
bool HandleUnBanCharacterCommand(const char* args);
bool HandleUnBanIPCommand(const char* args);
bool HandleBanInfoAccountCommand(const char* args);
bool HandleBanInfoCharacterCommand(const char* args);
bool HandleBanInfoIPCommand(const char* args);
bool HandleBanListAccountCommand(const char* args);
bool HandleBanListCharacterCommand(const char* args);
bool HandleBanListIPCommand(const char* args);
bool HandleIdleRestartCommand(const char* args);
bool HandleIdleShutDownCommand(const char* args);
bool HandleShutDownCommand(const char* args);
@@ -387,6 +416,7 @@ class ChatHandler
bool HandleCastTargetCommand(const char *args);
bool HandleComeToMeCommand(const char *args);
bool HandleCombatStopCommand(const char *args);
bool HandleSendMessageCommand(const char * args);
bool HandleFlushArenaPointsCommand(const char *args);
//! Development Commands
@@ -415,19 +445,39 @@ class ChatHandler
GameObject* GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry);
WorldSession * m_session;
// Utility methods for commands
void ShowTicket(uint64 guid, char const* text, char const* time);
uint32 GetTicketIDByNum(uint32 num);
bool LookupPlayerSearchCommand(QueryResult* result, int32 limit);
bool HandleBanListHelper(QueryResult* result);
bool HandleBanHelper(BanMode mode,char const* args);
bool HandleBanInfoHelper(uint32 accountid, char const* accountname);
bool HandleUnBanHelper(BanMode mode,char const* args);
void SetSentErrorMessage(bool val){ sentErrorMessage = val;};
private:
WorldSession * m_session; // != NULL for chat command call and NULL for CLI command
// common global flag
static bool load_command_table;
bool sentErrorMessage;
};
#endif
class CliHandler : public ChatHandler
{
public:
typedef void Print(char const*);
explicit CliHandler(Print* zprint) : m_print(zprint) {}
// overwrite functions
const char *GetTrinityString(int32 entry) const;
bool isAvailable(ChatCommand const& cmd) const;
void SendSysMessage(const char *str);
private:
Print* m_print;
};
char const *fmtstring( char const *format, ... );
#endif

View File

@@ -79,7 +79,10 @@ enum TrinityStrings
LANG_NPC_TAINER_HELLO = 51,
LANG_COMMAND_INVALID_ITEM_COUNT = 52,
LANG_COMMAND_MAIL_ITEMS_LIMIT = 53,
// Room for more level 0 54-99 not used
LANG_NEW_PASSWORDS_NOT_MATCH = 54,
LANG_PASSWORD_TOO_LONG = 55,
LANG_MOTD_CURRENT = 56,
// Room for more level 0 57-99 not used
// level 1 chat
LANG_GLOBAL_NOTIFY = 100,
@@ -163,7 +166,8 @@ enum TrinityStrings
LANG_MAIL_SENT = 169,
LANG_SOUND_NOT_EXIST = 170,
// Room for more level 1 171-199 not used
LANG_TELEPORTED_TO_BY_CONSOLE = 171,
// Room for more level 1 172-199 not used
// level 2 chat
LANG_NO_SELECTION = 200,
@@ -331,7 +335,8 @@ enum TrinityStrings
LANG_UNBAN_UNBANNED = 411,
LANG_UNBAN_ERROR = 412,
LANG_BANINFO_NOACCOUNT = 413,
LANG_ACCOUNT_NOT_EXIST = 413,
LANG_BANINFO_NOCHARACTER = 414,
LANG_BANINFO_NOIP = 415,
LANG_BANINFO_NOACCOUNTBAN = 416,
@@ -444,16 +449,16 @@ enum TrinityStrings
LANG_ITEMLIST_AUCTION = 510,
LANG_WRONG_LINK_TYPE = 511,
LANG_ITEM_LIST = 512,
LANG_QUEST_LIST = 513,
LANG_CREATURE_ENTRY_LIST = 514,
LANG_CREATURE_LIST = 515,
LANG_GO_ENTRY_LIST = 516,
LANG_GO_LIST = 517,
LANG_ITEMSET_LIST = 518,
LANG_ITEM_LIST_CHAT = 512,
LANG_QUEST_LIST_CHAT = 513,
LANG_CREATURE_ENTRY_LIST_CHAT = 514,
LANG_CREATURE_LIST_CHAT = 515,
LANG_GO_ENTRY_LIST_CHAT = 516,
LANG_GO_LIST_CHAT = 517,
LANG_ITEMSET_LIST_CHAT = 518,
LANG_TELE_LIST = 519,
LANG_SPELL_LIST = 520,
LANG_SKILL_LIST = 521,
LANG_SKILL_LIST_CHAT = 521,
LANG_GAMEOBJECT_NOT_EXIST = 522,
@@ -526,7 +531,7 @@ enum TrinityStrings
LANG_COMMAND_NEAROBJMESSAGE = 581,
LANG_COMMAND_RAWPAWNTIMES = 582,
LANG_EVENT_ENTRY_LIST = 583,
LANG_EVENT_ENTRY_LIST_CHAT = 583,
LANG_NOEVENTFOUND = 584,
LANG_EVENT_NOT_EXIST = 585,
LANG_EVENT_INFO = 586,
@@ -538,6 +543,14 @@ enum TrinityStrings
LANG_MOVEGENS_DISTRACT = 591,
LANG_COMMAND_LEARN_ALL_RECIPES = 592,
LANG_BANLIST_ACCOUNTS = 593,
LANG_BANLIST_ACCOUNTS_HEADER = 594,
LANG_BANLIST_IPS = 595,
LANG_BANLIST_IPS_HEADER = 596,
LANG_GMLIST = 597,
LANG_GMLIST_HEADER = 598,
LANG_GMLIST_EMPTY = 599,
// End Level 3 list, continued at 1100
// Battleground
LANG_BG_A_WINS = 600,
@@ -658,14 +671,52 @@ enum TrinityStrings
LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND = 809,
// Room for in-game strings 810-999 not used
// FREE IDS 1000-9999
LANG_COMMAND_FREEZE = 1000,
LANG_COMMAND_FREEZE_ERROR = 1001,
LANG_COMMAND_FREEZE_WRONG = 1002,
LANG_COMMAND_UNFREEZE = 1003,
LANG_COMMAND_NO_FROZEN_PLAYERS = 1004,
LANG_COMMAND_LIST_FREEZE = 1005,
LANG_COMMAND_FROZEN_PLAYERS = 1006,
// Level 4 (CLI only commands)
LANG_COMMAND_EXIT = 1000,
LANG_ACCOUNT_DELETED = 1001,
LANG_ACCOUNT_NOT_DELETED_SQL_ERROR = 1002,
LANG_ACCOUNT_NOT_DELETED = 1003,
LANG_ACCOUNT_CREATED = 1004,
LANG_ACCOUNT_TOO_LONG = 1005,
LANG_ACCOUNT_ALREADY_EXIST = 1006,
LANG_ACCOUNT_NOT_CREATED_SQL_ERROR = 1007,
LANG_ACCOUNT_NOT_CREATED = 1008,
LANG_CHARACTER_DELETED = 1009,
LANG_ACCOUNT_LIST_HEADER = 1010,
LANG_ACCOUNT_LIST_ERROR = 1011,
// Room for more level 4 1012-1099 not used
// Level 3 (continue)
LANG_MOTD_NEW = 1100,
LANG_ACCOUNT_SETADDON = 1101,
LANG_SENDMESSAGE = 1102,
LANG_EVENT_ENTRY_LIST_CONSOLE = 1103,
LANG_CREATURE_ENTRY_LIST_CONSOLE = 1104,
LANG_ITEM_LIST_CONSOLE = 1105,
LANG_ITEMSET_LIST_CONSOLE = 1106,
LANG_GO_ENTRY_LIST_CONSOLE = 1107,
LANG_QUEST_LIST_CONSOLE = 1108,
LANG_SKILL_LIST_CONSOLE = 1109,
LANG_CREATURE_LIST_CONSOLE = 1110,
LANG_GO_LIST_CONSOLE = 1111,
LANG_FILE_OPEN_FAIL = 1112,
LANG_ACCOUNT_CHARACTER_LIST_FULL = 1113,
LANG_DUMP_BROKEN = 1114,
LANG_INVALID_CHARACTER_NAME = 1115,
LANG_INVALID_CHARACTER_GUID = 1116,
LANG_CHARACTER_GUID_IN_USE = 1117,
LANG_ITEMLIST_GUILD = 1118,
// Room for more level 3 1119-1199 not used
// Trinity custom patches 5000-9999
LANG_COMMAND_FREEZE = 5000,
LANG_COMMAND_FREEZE_ERROR = 5001,
LANG_COMMAND_FREEZE_WRONG = 5002,
LANG_COMMAND_UNFREEZE = 5003,
LANG_COMMAND_NO_FROZEN_PLAYERS = 5004,
LANG_COMMAND_LIST_FREEZE = 5005,
LANG_COMMAND_FROZEN_PLAYERS = 5006,
// Room for more Trinity custom patches 5007-9999
// Use for not-in-svn patches 10000-10999
// opvp hp

View File

@@ -35,15 +35,17 @@
bool ChatHandler::HandleHelpCommand(const char* args)
{
if(!*args)
return false;
char* cmd = strtok((char*)args, " ");
char* cmd = strtok((char*)args, " ");
if(!cmd)
return false;
if(!ShowHelpForCommand(getCommandTable(), cmd))
SendSysMessage(LANG_NO_HELP_CMD);
{
ShowHelpForCommand(getCommandTable(), "help");
ShowHelpForCommand(getCommandTable(), "");
}
else
{
if(!ShowHelpForCommand(getCommandTable(), cmd))
SendSysMessage(LANG_NO_HELP_CMD);
}
return true;
}
@@ -54,7 +56,7 @@ bool ChatHandler::HandleCommandsCommand(const char* args)
return true;
}
bool ChatHandler::HandleAcctCommand(const char* /*args*/)
bool ChatHandler::HandleAccountCommand(const char* /*args*/)
{
uint32 gmlevel = m_session->GetSecurity();
PSendSysMessage(LANG_ACCOUNT_LEVEL, gmlevel);
@@ -141,7 +143,7 @@ bool ChatHandler::HandleSaveCommand(const char* /*args*/)
return true;
}
bool ChatHandler::HandleGMListCommand(const char* /*args*/)
bool ChatHandler::HandleGMListIngameCommand(const char* /*args*/)
{
bool first = true;
@@ -149,8 +151,9 @@ bool ChatHandler::HandleGMListCommand(const char* /*args*/)
HashMapHolder<Player>::MapType::iterator itr = m.begin();
for(; itr != m.end(); ++itr)
{
if( itr->second->GetSession()->GetSecurity() && (itr->second->isGameMaster() || sWorld.getConfig(CONFIG_GM_IN_GM_LIST) ) &&
itr->second->IsVisibleGloballyFor(m_session->GetPlayer()) )
if (itr->second->GetSession()->GetSecurity() &&
(itr->second->isGameMaster() || sWorld.getConfig(CONFIG_GM_IN_GM_LIST)) &&
(!m_session || itr->second->IsVisibleGloballyFor(m_session->GetPlayer())) )
{
if(first)
{
@@ -177,17 +180,24 @@ bool ChatHandler::HandlePasswordCommand(const char* args)
char *new_pass = strtok (NULL, " ");
char *new_pass_c = strtok (NULL, " ");
if( !old_pass || !new_pass || !new_pass_c )
if (!old_pass || !new_pass || !new_pass_c)
return false;
std::string password_old = old_pass;
std::string password_new = new_pass;
std::string password_new_c = new_pass_c;
if(!accmgr.CheckPassword(m_session->GetAccountId(), password_old) || password_new != password_new_c)
if (password_new != password_new_c)
{
SendSysMessage(LANG_COMMAND_WRONGOLDPASSWORD);
SetSentErrorMessage(true);
SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH);
SetSentErrorMessage (true);
return false;
}
if (!accmgr.CheckPassword (m_session->GetAccountId(), password_old))
{
SendSysMessage (LANG_COMMAND_WRONGOLDPASSWORD);
SetSentErrorMessage (true);
return false;
}
@@ -198,6 +208,11 @@ bool ChatHandler::HandlePasswordCommand(const char* args)
case AOR_OK:
SendSysMessage(LANG_COMMAND_PASSWORD);
break;
case AOR_PASS_TOO_LONG:
SendSysMessage(LANG_PASSWORD_TOO_LONG);
SetSentErrorMessage(true);
return false;
case AOR_NAME_NOT_EXIST: // not possible case, don't want get account name for output
default:
SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD);
SetSentErrorMessage(true);
@@ -233,3 +248,10 @@ bool ChatHandler::HandleLockAccountCommand(const char* args)
SendSysMessage(LANG_USE_BOL);
return true;
}
/// Display the 'Message of the day' for the realm
bool ChatHandler::HandleServerMotdCommand(const char* /*args*/)
{
PSendSysMessage(LANG_MOTD_CURRENT, sWorld.GetMotd());
return true;
}

View File

@@ -1692,62 +1692,65 @@ bool ChatHandler::HandleTeleCommand(const char * args)
bool ChatHandler::HandleLookupAreaCommand(const char* args)
{
if(!*args)
if (!*args)
return false;
std::string namepart = args;
std::wstring wnamepart;
if(!Utf8toWStr(namepart,wnamepart))
if (!Utf8toWStr (namepart,wnamepart))
return false;
uint32 counter = 0; // Counter for figure out that we found smth.
// converting string that we try to find to lower case
wstrToLower( wnamepart );
wstrToLower (wnamepart);
// Search in AreaTable.dbc
for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows(); ++areaflag)
for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows (); ++areaflag)
{
AreaTableEntry const *areaEntry = sAreaStore.LookupEntry(areaflag);
if(areaEntry)
AreaTableEntry const *areaEntry = sAreaStore.LookupEntry (areaflag);
if (areaEntry)
{
int loc = m_session->GetSessionDbcLocale();
int loc = m_session ? m_session->GetSessionDbcLocale () : sWorld.GetDefaultDbcLocale();
std::string name = areaEntry->area_name[loc];
if(name.empty())
if (name.empty())
continue;
if(!Utf8FitTo(name, wnamepart))
if (!Utf8FitTo (name, wnamepart))
{
loc = 0;
for(; loc < MAX_LOCALE; ++loc)
{
if(loc==m_session->GetSessionDbcLocale())
if (m_session && loc==m_session->GetSessionDbcLocale ())
continue;
name = areaEntry->area_name[loc];
if(name.empty())
if (name.empty ())
continue;
if (Utf8FitTo(name, wnamepart))
if (Utf8FitTo (name, wnamepart))
break;
}
}
if(loc < MAX_LOCALE)
if (loc < MAX_LOCALE)
{
// send area in "id - [name]" format
std::ostringstream ss;
ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc]<< "]|h|r";
if (m_session)
ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc]<< "]|h|r";
else
ss << areaEntry->ID << " - " << name << " " << localeNames[loc];
SendSysMessage(ss.str().c_str());
SendSysMessage (ss.str ().c_str());
++counter;
}
}
}
if (counter == 0) // if counter == 0 then we found nth
SendSysMessage(LANG_COMMAND_NOAREAFOUND);
if (counter == 0) // if counter == 0 then we found nth
SendSysMessage (LANG_COMMAND_NOAREAFOUND);
return true;
}
@@ -1760,6 +1763,7 @@ bool ChatHandler::HandleLookupTeleCommand(const char * args)
SetSentErrorMessage(true);
return false;
}
char const* str = strtok((char*)args, " ");
if(!str)
return false;
@@ -1773,9 +1777,9 @@ bool ChatHandler::HandleLookupTeleCommand(const char * args)
// converting string that we try to find to lower case
wstrToLower( wnamepart );
GameTeleMap const & teleMap = objmgr.GetGameTeleMap();
std::ostringstream reply;
GameTeleMap const & teleMap = objmgr.GetGameTeleMap();
for(GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr)
{
GameTele const* tele = &itr->second;
@@ -1783,11 +1787,10 @@ bool ChatHandler::HandleLookupTeleCommand(const char * args)
if(tele->wnameLow.find(wnamepart) == std::wstring::npos)
continue;
reply << " |cffffffff|Htele:";
reply << itr->first;
reply << "|h[";
reply << tele->name;
reply << "]|h|r\n";
if (m_session)
reply << " |cffffffff|Htele:" << itr->first << "|h[" << tele->name << "]|h|r\n";
else
reply << " " << itr->first << " " << tele->name << "\n";
}
if(reply.str().empty())
@@ -2072,8 +2075,13 @@ bool ChatHandler::HandleNameTeleCommand(const char * args)
PSendSysMessage(LANG_TELEPORTING_TO, chr->GetName(),"", tele->name.c_str());
if (m_session->GetPlayer()->IsVisibleGloballyFor(chr))
ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName());
if (m_session)
{
if(m_session->GetPlayer()->IsVisibleGloballyFor(chr))
ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, m_session->GetPlayer()->GetName());
}
else
ChatHandler(chr).SendSysMessage(LANG_TELEPORTED_TO_BY_CONSOLE);
// stop flight if need
if(chr->isInFlight())

View File

@@ -42,6 +42,7 @@
#include <iostream>
#include <fstream>
#include <map>
#include "GlobalEvents.h"
static uint32 ReputationRankStrIndex[MAX_REPUTATION_RANK] =
{
@@ -99,7 +100,7 @@ bool ChatHandler::HandleMuteCommand(const char* args)
security = accmgr.GetSecurity(account_id);
}
if(security >= m_session->GetSecurity())
if(m_session && security >= m_session->GetSecurity())
{
SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
SetSentErrorMessage(true);
@@ -165,7 +166,7 @@ bool ChatHandler::HandleUnmuteCommand(const char* args)
security = accmgr.GetSecurity(account_id);
}
if(security >= m_session->GetSecurity())
if(m_session && security >= m_session->GetSecurity())
{
SendSysMessage(LANG_YOURS_SECURITY_IS_LOW);
SetSentErrorMessage(true);
@@ -555,38 +556,37 @@ bool ChatHandler::HandleGUIDCommand(const char* /*args*/)
bool ChatHandler::HandleLookupFactionCommand(const char* args)
{
if(!*args)
if (!*args)
return false;
Player *target = getSelectedPlayer();
if (!target)
{
SendSysMessage(LANG_NO_CHAR_SELECTED);
SetSentErrorMessage(true);
return false;
}
// Can be NULL at console call
Player *target = getSelectedPlayer ();
std::string namepart = args;
std::wstring wnamepart;
if(!Utf8toWStr(namepart,wnamepart))
if (!Utf8toWStr (namepart,wnamepart))
return false;
// converting string that we try to find to lower case
wstrToLower( wnamepart );
wstrToLower (wnamepart);
uint32 counter = 0; // Counter for figure out that we found smth.
for (uint32 id = 0; id < sFactionStore.GetNumRows(); id++)
//for(FactionStateList::const_iterator itr = target->m_factions.begin(); itr != target->m_factions.end(); ++itr)
for (uint32 id = 0; id < sFactionStore.GetNumRows(); ++id)
{
FactionEntry const *factionEntry = sFactionStore.LookupEntry(id);
//FactionEntry const *factionEntry = sFactionStore.LookupEntry(itr->second.ID);
FactionEntry const *factionEntry = sFactionStore.LookupEntry (id);
if (factionEntry)
{
FactionStateList::const_iterator repItr = target->m_factions.find(factionEntry->reputationListID);
FactionState const* repState = NULL;
if(target)
{
FactionStateList::const_iterator repItr = target->m_factions.find (factionEntry->reputationListID);
if(repItr != target->m_factions.end())
repState = &repItr->second;
}
int loc = m_session->GetSessionDbcLocale();
int loc = m_session ? m_session->GetSessionDbcLocale() : sWorld.GetDefaultDbcLocale();
std::string name = factionEntry->name[loc];
if(name.empty())
continue;
@@ -596,7 +596,7 @@ bool ChatHandler::HandleLookupFactionCommand(const char* args)
loc = 0;
for(; loc < MAX_LOCALE; ++loc)
{
if(loc==m_session->GetSessionDbcLocale())
if(m_session && loc==m_session->GetSessionDbcLocale())
continue;
name = factionEntry->name[loc];
@@ -613,26 +613,29 @@ bool ChatHandler::HandleLookupFactionCommand(const char* args)
// send faction in "id - [faction] rank reputation [visible] [at war] [own team] [unknown] [invisible] [inactive]" format
// or "id - [faction] [no reputation]" format
std::ostringstream ss;
ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r";
if (m_session)
ss << id << " - |cffffffff|Hfaction:" << id << "|h[" << name << " " << localeNames[loc] << "]|h|r";
else
ss << id << " - " << name << " " << localeNames[loc];
if (repItr != target->m_factions.end())
if (repState) // and then target!=NULL also
{
ReputationRank rank = target->GetReputationRank(factionEntry);
std::string rankName = GetTrinityString(ReputationRankStrIndex[rank]);
ss << " " << rankName << "|h|r (" << target->GetReputation(factionEntry) << ")";
if(repItr->second.Flags & FACTION_FLAG_VISIBLE)
if(repState->Flags & FACTION_FLAG_VISIBLE)
ss << GetTrinityString(LANG_FACTION_VISIBLE);
if(repItr->second.Flags & FACTION_FLAG_AT_WAR)
if(repState->Flags & FACTION_FLAG_AT_WAR)
ss << GetTrinityString(LANG_FACTION_ATWAR);
if(repItr->second.Flags & FACTION_FLAG_PEACE_FORCED)
if(repState->Flags & FACTION_FLAG_PEACE_FORCED)
ss << GetTrinityString(LANG_FACTION_PEACE_FORCED);
if(repItr->second.Flags & FACTION_FLAG_HIDDEN)
if(repState->Flags & FACTION_FLAG_HIDDEN)
ss << GetTrinityString(LANG_FACTION_HIDDEN);
if(repItr->second.Flags & FACTION_FLAG_INVISIBLE_FORCED)
if(repState->Flags & FACTION_FLAG_INVISIBLE_FORCED)
ss << GetTrinityString(LANG_FACTION_INVISIBLE_FORCED);
if(repItr->second.Flags & FACTION_FLAG_INACTIVE)
if(repState->Flags & FACTION_FLAG_INACTIVE)
ss << GetTrinityString(LANG_FACTION_INACTIVE);
}
else
@@ -1702,7 +1705,7 @@ bool ChatHandler::HandleKickPlayerCommand(const char *args)
return false;
}
if(name==m_session->GetPlayer()->GetName())
if(m_session && name==m_session->GetPlayer()->GetName())
{
SendSysMessage(LANG_COMMAND_KICKSELF);
SetSentErrorMessage(true);
@@ -1809,7 +1812,8 @@ bool ChatHandler::HandlePInfoCommand(const char* args)
Field* fields = result->Fetch();
username = fields[0].GetCppString();
security = fields[1].GetUInt32();
if(m_session->GetSecurity() >= security)
if(!m_session || m_session->GetSecurity() >= security)
{
last_ip = fields[2].GetCppString();
last_login = fields[3].GetCppString();
@@ -1891,6 +1895,13 @@ bool ChatHandler::HandleTicketCommand(const char* args)
// ticket<end>
if (!px)
{
if(!m_session)
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
size_t count;
QueryResult *result = CharacterDatabase.Query("SELECT COUNT(ticket_id) FROM character_ticket");
if(result)
@@ -1901,13 +1912,22 @@ bool ChatHandler::HandleTicketCommand(const char* args)
else
count = 0;
PSendSysMessage(LANG_COMMAND_TICKETCOUNT, count, m_session->GetPlayer()->isAcceptTickets() ? GetTrinityString(LANG_ON) : GetTrinityString(LANG_OFF));
bool accept = m_session->GetPlayer()->isAcceptTickets();
PSendSysMessage(LANG_COMMAND_TICKETCOUNT, count, accept ? GetTrinityString(LANG_ON) : GetTrinityString(LANG_OFF));
return true;
}
// ticket on
if(strncmp(px,"on",3) == 0)
{
if(!m_session)
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
m_session->GetPlayer()->SetAcceptTicket(true);
SendSysMessage(LANG_COMMAND_TICKETON);
return true;
@@ -1916,6 +1936,13 @@ bool ChatHandler::HandleTicketCommand(const char* args)
// ticket off
if(strncmp(px,"off",4) == 0)
{
if(!m_session)
{
SendSysMessage(LANG_PLAYER_NOT_FOUND);
SetSentErrorMessage(true);
return false;
}
m_session->GetPlayer()->SetAcceptTicket(false);
SendSysMessage(LANG_COMMAND_TICKETOFF);
return true;
@@ -3590,7 +3617,12 @@ bool ChatHandler::HandleLookupEventCommand(const char* args)
if (Utf8FitTo(descr, wnamepart))
{
char const* active = activeEvents.find(id) != activeEvents.end() ? GetTrinityString(LANG_ACTIVE) : "";
PSendSysMessage(LANG_EVENT_ENTRY_LIST,id,id,descr.c_str(),active );
if(m_session)
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,id,id,eventData.description.c_str(),active );
else
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,id,eventData.description.c_str(),active );
++counter;
}
}
@@ -3615,7 +3647,11 @@ bool ChatHandler::HandleEventActiveListCommand(const char* args)
uint32 event_id = *itr;
GameEventData const& eventData = events[event_id];
PSendSysMessage(LANG_EVENT_ENTRY_LIST,event_id,event_id,eventData.description.c_str(),active );
if(m_session)
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT,event_id,event_id,eventData.description.c_str(),active );
else
PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE,event_id,eventData.description.c_str(),active );
++counter;
}
@@ -3848,7 +3884,7 @@ bool ChatHandler::HandleLearnAllRecipesCommand(const char* args)
return false;
}
if(!*args)
if (!*args)
return false;
std::wstring wnamepart;
@@ -3916,54 +3952,54 @@ bool ChatHandler::HandleLearnAllRecipesCommand(const char* args)
bool ChatHandler::HandleLookupPlayerIpCommand(const char* args)
{
if(!*args)
if (!*args)
return false;
std::string ip = strtok((char*)args, " ");
char* limit_str = strtok(NULL, " ");
int32 limit = limit_str ? atoi(limit_str) : -1;
std::string ip = strtok ((char*)args, " ");
char* limit_str = strtok (NULL, " ");
int32 limit = limit_str ? atoi (limit_str) : -1;
loginDatabase.escape_string(ip);
loginDatabase.escape_string (ip);
QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE last_ip = '%s'", ip.c_str());
QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE last_ip = '%s'", ip.c_str ());
return LookupPlayerSearchCommand(result,limit);
return LookupPlayerSearchCommand (result,limit);
}
bool ChatHandler::HandleLookupPlayerAccountCommand(const char* args)
{
if(!*args)
if (!*args)
return false;
std::string account = strtok((char*)args, " ");
char* limit_str = strtok(NULL, " ");
int32 limit = limit_str ? atoi(limit_str) : -1;
std::string account = strtok ((char*)args, " ");
char* limit_str = strtok (NULL, " ");
int32 limit = limit_str ? atoi (limit_str) : -1;
if(!AccountMgr::normilizeString(account))
if (!AccountMgr::normilizeString (account))
return false;
loginDatabase.escape_string(account);
loginDatabase.escape_string (account);
QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE username = '%s'", account.c_str());
QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE username = '%s'", account.c_str ());
return LookupPlayerSearchCommand(result,limit);
return LookupPlayerSearchCommand (result,limit);
}
bool ChatHandler::HandleLookupPlayerEmailCommand(const char* args)
{
if(!*args)
if (!*args)
return false;
std::string email = strtok((char*)args, " ");
char* limit_str = strtok(NULL, " ");
int32 limit = limit_str ? atoi(limit_str) : -1;
std::string email = strtok ((char*)args, " ");
char* limit_str = strtok (NULL, " ");
int32 limit = limit_str ? atoi (limit_str) : -1;
loginDatabase.escape_string(email);
loginDatabase.escape_string (email);
QueryResult* result = loginDatabase.PQuery("SELECT id,username FROM account WHERE email = '%s'", email.c_str());
QueryResult* result = loginDatabase.PQuery ("SELECT id,username FROM account WHERE email = '%s'", email.c_str ());
return LookupPlayerSearchCommand(result,limit);
return LookupPlayerSearchCommand (result,limit);
}
bool ChatHandler::LookupPlayerSearchCommand(QueryResult* result, int32 limit)
@@ -4009,3 +4045,10 @@ bool ChatHandler::LookupPlayerSearchCommand(QueryResult* result, int32 limit)
return true;
}
/// Triggering corpses expire check in world
bool ChatHandler::HandleServerCorpsesCommand(const char* /*args*/)
{
CorpsesErase();
return true;
}

File diff suppressed because it is too large Load Diff

View File

@@ -680,6 +680,7 @@ class ObjectMgr
}
const char *GetTrinityString(int32 entry, int locale_idx) const;
const char *GetTrinityStringForDBCLocale(int32 entry) const { return GetTrinityString(entry,DBCLocaleIndex); }
int32 GetDBCLocaleIndex() const { return DBCLocaleIndex; }
void SetDBCLocaleIndex(uint32 lang) { DBCLocaleIndex = GetIndexForLocale(LocaleConstant(lang)); }
void AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance);

View File

@@ -26,7 +26,7 @@
#include "ObjectMgr.h"
// Character Dump tables
#define DUMP_TABLE_COUNT 20
#define DUMP_TABLE_COUNT 19
struct DumpTable
{
@@ -258,11 +258,8 @@ void StoreGUID(QueryResult *result,uint32 data,uint32 field, std::set<uint32>& g
}
// Writing - High-level functions
bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type)
void PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type)
{
if (!tableFrom || !tableTo)
return false;
GUIDs const* guids = NULL;
char const* fieldname = NULL;
@@ -280,7 +277,7 @@ bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl
// for guid set stop if set is empty
if(guids && guids->empty())
return true; // nothing to do
return; // nothing to do
// setup for guids case start position
GUIDs::const_iterator guids_itr;
@@ -298,7 +295,7 @@ bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl
QueryResult *result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str());
if(!result)
return false;
return;
do
{
@@ -328,8 +325,6 @@ bool PlayerDumpWriter::DumpTable(std::string& dump, uint32 guid, char const*tabl
delete result;
}
while(guids && guids_itr != guids->end()); // not set case iterate single time, set case iterate for all guids
return true;
}
std::string PlayerDumpWriter::GetDump(uint32 guid)
@@ -338,28 +333,29 @@ std::string PlayerDumpWriter::GetDump(uint32 guid)
for(int i = 0; i < DUMP_TABLE_COUNT; i++)
DumpTable(dump, guid, dumpTables[i].name, dumpTables[i].name, dumpTables[i].type);
// TODO: Add instance/group/gifts..
// TODO: Add instance/group..
// TODO: Add a dump level option to skip some non-important tables
return dump;
}
bool PlayerDumpWriter::WriteDump(std::string file, uint32 guid)
DumpReturn PlayerDumpWriter::WriteDump(std::string file, uint32 guid)
{
FILE *fout = fopen(file.c_str(), "w");
if (!fout) { sLog.outError("Failed to open file!\r\n"); return false; }
if (!fout)
return DUMP_FILE_OPEN_ERROR;
std::string dump = GetDump(guid);
fprintf(fout,"%s\n",dump.c_str());
fclose(fout);
return true;
return DUMP_SUCCESS;
}
// Reading - High-level functions
#define ROLLBACK {CharacterDatabase.RollbackTransaction(); fclose(fin); return false;}
#define ROLLBACK(DR) {CharacterDatabase.RollbackTransaction(); fclose(fin); return (DR);}
bool PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string name, uint32 guid)
DumpReturn PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string name, uint32 guid)
{
// check character count
{
@@ -372,13 +368,12 @@ bool PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string na
delete result;
if (charcount >= 10)
{
return false;
}
return DUMP_TOO_MANY_CHARS;
}
}
FILE *fin = fopen(file.c_str(), "r");
if(!fin) return false;
if(!fin)
return DUMP_FILE_OPEN_ERROR;
QueryResult * result = NULL;
char newguid[20], chraccount[20], newpetid[20], currpetid[20], lastpetid[20];
@@ -434,8 +429,7 @@ bool PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string na
if(!fgets(buf, 32000, fin))
{
if(feof(fin)) break;
sLog.outError("LoadPlayerDump: File read error!");
ROLLBACK;
ROLLBACK(DUMP_FILE_BROKEN);
}
std::string line; line.assign(buf);
@@ -449,7 +443,7 @@ bool PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string na
if(tn.empty())
{
sLog.outError("LoadPlayerDump: Can't extract table name from line: '%s'!", line.c_str());
ROLLBACK;
ROLLBACK(DUMP_FILE_BROKEN);
}
DumpTableType type;
@@ -466,27 +460,37 @@ bool PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string na
if (i == DUMP_TABLE_COUNT)
{
sLog.outError("LoadPlayerDump: Unknown table: '%s'!", tn.c_str());
ROLLBACK;
ROLLBACK(DUMP_FILE_BROKEN);
}
// change the data to server values
switch(type)
{
case DTT_CHAR_TABLE:
if(!changenth(line, 1, newguid)) ROLLBACK;
if(!changenth(line, 1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
case DTT_CHARACTER: // character t.
{
if(!changenth(line, 1, newguid)) ROLLBACK;
if(!changenth(line, 1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
// guid, data field:guid, items
if(!changenth(line, 2, chraccount)) ROLLBACK;
if(!changenth(line, 2, chraccount))
ROLLBACK(DUMP_FILE_BROKEN);
std::string vals = getnth(line, 3);
if(!changetoknth(vals, OBJECT_FIELD_GUID+1, newguid)) ROLLBACK;
if(!changetoknth(vals, OBJECT_FIELD_GUID+1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
for(uint16 field = PLAYER_FIELD_INV_SLOT_HEAD; field < PLAYER_FARSIGHT; field++)
if(!changetokGuid(vals, field+1, items, objmgr.m_hiItemGuid, true)) ROLLBACK;
if(!changenth(line, 3, vals.c_str())) ROLLBACK;
if(!changetokGuid(vals, field+1, items, objmgr.m_hiItemGuid, true))
ROLLBACK(DUMP_FILE_BROKEN);
if(!changenth(line, 3, vals.c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
if (name == "")
{
// check if the original name already exists
@@ -498,38 +502,51 @@ bool PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string na
{
delete result;
// rename on login: `at_login` field 30 in raw field list
if(!changenth(line, 30, "1")) ROLLBACK;
if(!changenth(line, 30, "1"))
ROLLBACK(DUMP_FILE_BROKEN);
}
}
else if(!changenth(line, 4, name.c_str())) ROLLBACK;
else if(!changenth(line, 4, name.c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_INVENTORY: // character_inventory t.
{
if(!changenth(line, 1, newguid)) ROLLBACK;
if(!changenth(line, 1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
// bag, item
if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid, true)) ROLLBACK;
if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid)) ROLLBACK;
if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid, true))
ROLLBACK(DUMP_FILE_BROKEN);
if(!changeGuid(line, 4, items, objmgr.m_hiItemGuid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_ITEM: // item_instance t.
{
// item, owner, data field:item, owner guid
if(!changeGuid(line, 1, items, objmgr.m_hiItemGuid)) ROLLBACK;
if(!changenth(line, 2, newguid)) ROLLBACK;
if(!changeGuid(line, 1, items, objmgr.m_hiItemGuid))
ROLLBACK(DUMP_FILE_BROKEN);
if(!changenth(line, 2, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
std::string vals = getnth(line,3);
if(!changetokGuid(vals, OBJECT_FIELD_GUID+1, items, objmgr.m_hiItemGuid)) ROLLBACK;
if(!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid)) ROLLBACK;
if(!changenth(line, 3, vals.c_str())) ROLLBACK;
if(!changetokGuid(vals, OBJECT_FIELD_GUID+1, items, objmgr.m_hiItemGuid))
ROLLBACK(DUMP_FILE_BROKEN);
if(!changetoknth(vals, ITEM_FIELD_OWNER+1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
if(!changenth(line, 3, vals.c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_ITEM_GIFT: // character_gift
{
// guid,item_guid,
if(!changenth(line, 1, newguid)) ROLLBACK;
if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid)) ROLLBACK;
if(!changenth(line, 1, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_PET: // character_pet t
@@ -551,8 +568,10 @@ bool PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string na
}
// item, entry, owner, ...
if(!changenth(line, 1, newpetid)) ROLLBACK;
if(!changenth(line, 3, newguid)) ROLLBACK;
if(!changenth(line, 1, newpetid))
ROLLBACK(DUMP_FILE_BROKEN);
if(!changenth(line, 3, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
@@ -562,27 +581,34 @@ bool PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string na
// lookup currpetid and match to new inserted pet id
std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid));
if(petids_iter == petids.end()) ROLLBACK; // couldn't find new inserted id
if(petids_iter == petids.end()) // couldn't find new inserted id
ROLLBACK(DUMP_FILE_BROKEN);
snprintf(newpetid, 20, "%d", petids_iter->second);
if(!changenth(line, 1, newpetid)) ROLLBACK;
if(!changenth(line, 1, newpetid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_MAIL: // mail
{
// id,messageType,stationery,sender,receiver
if(!changeGuid(line, 1, mails, objmgr.m_mailid)) ROLLBACK;
if(!changenth(line, 5, newguid)) ROLLBACK;
if(!changeGuid(line, 1, mails, objmgr.m_mailid))
ROLLBACK(DUMP_FILE_BROKEN);
if(!changenth(line, 5, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
case DTT_MAIL_ITEM: // mail_items
{
// mail_id,item_guid,item_template,receiver
if(!changeGuid(line, 1, mails, objmgr.m_mailid)) ROLLBACK;
if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid)) ROLLBACK;
if(!changenth(line, 4, newguid)) ROLLBACK;
if(!changeGuid(line, 1, mails, objmgr.m_mailid))
ROLLBACK(DUMP_FILE_BROKEN);
if(!changeGuid(line, 2, items, objmgr.m_hiItemGuid))
ROLLBACK(DUMP_FILE_BROKEN);
if(!changenth(line, 4, newguid))
ROLLBACK(DUMP_FILE_BROKEN);
break;
}
default:
@@ -590,7 +616,8 @@ bool PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string na
break;
}
if(!CharacterDatabase.Execute(line.c_str())) ROLLBACK;
if(!CharacterDatabase.Execute(line.c_str()))
ROLLBACK(DUMP_FILE_BROKEN);
}
CharacterDatabase.CommitTransaction();
@@ -603,5 +630,5 @@ bool PlayerDumpReader::LoadDump(std::string file, uint32 account, std::string na
fclose(fin);
return true;
return DUMP_SUCCESS;
}

View File

@@ -73,6 +73,15 @@ enum DumpTableType
DTT_ITEM_TEXT, // <- item_text // item_text
};
enum DumpReturn
{
DUMP_SUCCESS,
DUMP_FILE_OPEN_ERROR,
DUMP_TOO_MANY_CHARS,
DUMP_UNEXPECTED_END,
DUMP_FILE_BROKEN,
};
class PlayerDump
{
protected:
@@ -85,11 +94,11 @@ class PlayerDumpWriter : public PlayerDump
PlayerDumpWriter() {}
std::string GetDump(uint32 guid);
bool WriteDump(std::string file, uint32 guid);
DumpReturn WriteDump(std::string file, uint32 guid);
private:
typedef std::set<uint32> GUIDs;
bool DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type);
void DumpTable(std::string& dump, uint32 guid, char const*tableFrom, char const*tableTo, DumpTableType type);
std::string GenerateWhereStr(char const* field, GUIDs const& guids, GUIDs::const_iterator& itr);
std::string GenerateWhereStr(char const* field, uint32 guid);
@@ -104,7 +113,7 @@ class PlayerDumpReader : public PlayerDump
public:
PlayerDumpReader() {}
bool LoadDump(std::string file, uint32 account, std::string name, uint32 guid);
DumpReturn LoadDump(std::string file, uint32 account, std::string name, uint32 guid);
};
#endif

View File

@@ -2167,4 +2167,20 @@ enum ResponseCodes
CHAR_NAME_RUSSIAN_SILENT_CHARACTER_AT_BEGINNING_OR_END = 0x59,
CHAR_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME = 0x5A,
};
/// Ban function modes
enum BanMode
{
BAN_ACCOUNT,
BAN_CHARACTER,
BAN_IP
};
/// Ban function return codes
enum BanReturn
{
BAN_SUCCESS,
BAN_SYNTAX_ERROR,
BAN_NOTFOUND
};
#endif

View File

@@ -2264,45 +2264,43 @@ bool World::KickPlayer(std::string playerName)
}
/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban
uint8 World::BanAccount(std::string type, std::string nameOrIP, std::string duration, std::string reason, std::string author)
BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author)
{
loginDatabase.escape_string(nameOrIP);
loginDatabase.escape_string(reason);
std::string safe_author=author;
loginDatabase.escape_string(safe_author);
if(type != "ip" && !normalizePlayerName(nameOrIP))
return BAN_NOTFOUND; // Nobody to ban
uint32 duration_secs = TimeStringToSecs(duration);
QueryResult *resultAccounts = NULL; //used for kicking
///- Update the database with ban information
if(type=="ip")
switch(mode)
{
//No SQL injection as strings are escaped
resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'",nameOrIP.c_str());
loginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')",nameOrIP.c_str(),duration_secs,safe_author.c_str(),reason.c_str());
case BAN_IP:
//No SQL injection as strings are escaped
resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE last_ip = '%s'",nameOrIP.c_str());
loginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+%u,'%s','%s')",nameOrIP.c_str(),duration_secs,safe_author.c_str(),reason.c_str());
break;
case BAN_ACCOUNT:
//No SQL injection as string is escaped
resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str());
break;
case BAN_CHARACTER:
//No SQL injection as string is escaped
resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'",nameOrIP.c_str());
break;
default:
return BAN_SYNTAX_ERROR;
}
else if(type=="account")
{
//No SQL injection as string is escaped
resultAccounts = loginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'",nameOrIP.c_str());
}
else if(type=="character")
{
//No SQL injection as string is escaped
resultAccounts = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'",nameOrIP.c_str());
}
else
return BAN_SYNTAX_ERROR; //Syntax problem
if(!resultAccounts)
if(type=="ip")
return BAN_SUCCESS; // ip correctly banned but nobody affected (yet)
else
return BAN_NOTFOUND; // Nobody to ban
if(!resultAccounts)
{
if(mode==BAN_IP)
return BAN_SUCCESS;
else
return BAN_NOTFOUND; // Nobody to ban
}
///- Disconnect all affected players (for IP it can be several)
do
@@ -2310,13 +2308,14 @@ uint8 World::BanAccount(std::string type, std::string nameOrIP, std::string dura
Field* fieldsAccount = resultAccounts->Fetch();
uint32 account = fieldsAccount->GetUInt32();
if(type != "ip")
if(mode!=BAN_IP)
{
//No SQL injection as strings are escaped
loginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u', UNIX_TIMESTAMP(), UNIX_TIMESTAMP()+%u, '%s', '%s', '1')",
account,duration_secs,safe_author.c_str(),reason.c_str());
}
WorldSession* sess = FindSession(account);
if( sess )
if (WorldSession* sess = FindSession(account))
if(std::string(sess->GetPlayerName()) != author)
sess->KickPlayer();
}
@@ -2327,9 +2326,9 @@ uint8 World::BanAccount(std::string type, std::string nameOrIP, std::string dura
}
/// Remove a ban from an account or IP address
bool World::RemoveBanAccount(std::string type, std::string nameOrIP)
bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP)
{
if(type == "ip")
if (mode == BAN_IP)
{
loginDatabase.escape_string(nameOrIP);
loginDatabase.PExecute("DELETE FROM ip_banned WHERE ip = '%s'",nameOrIP.c_str());
@@ -2337,20 +2336,11 @@ bool World::RemoveBanAccount(std::string type, std::string nameOrIP)
else
{
uint32 account=0;
if(type == "account")
{
if (!AccountMgr::normilizeString (nameOrIP))
return false;
if (mode == BAN_ACCOUNT)
account = accmgr.GetId (nameOrIP);
}
else if(type == "character")
{
if(!normalizePlayerName(nameOrIP))
return false;
else if (mode == BAN_CHARACTER)
account = objmgr.GetPlayerAccountIdByPlayerName (nameOrIP);
}
if(!account)
return false;
@@ -2503,20 +2493,24 @@ void World::UpdateSessions( time_t diff )
// This handles the issued and queued CLI commands
void World::ProcessCliCommands()
{
if (cliCmdQueue.empty()) return;
if (cliCmdQueue.empty())
return;
CliCommandHolder *command;
pPrintf p_zprintf;
CliCommandHolder::Print* zprint;
while (!cliCmdQueue.empty())
{
sLog.outDebug("CLI command under processing...");
command = cliCmdQueue.next();
command->Execute();
p_zprintf=command->GetOutputMethod();
CliCommandHolder *command = cliCmdQueue.next();
zprint = command->m_print;
CliHandler(zprint).ParseCommands(command->m_command);
delete command;
}
// print the console message here so it looks right
p_zprintf("TC> ");
zprint("TC> ");
}
void World::InitResultQueue()

View File

@@ -28,6 +28,7 @@
#include "Common.h"
#include "Timer.h"
#include "Policies/Singleton.h"
#include "SharedDefines.h"
#include <map>
#include <set>
@@ -40,7 +41,6 @@ class Player;
class Weather;
struct ScriptAction;
struct ScriptInfo;
class CliCommandHolder;
class SqlResultQueue;
class QueryResult;
class WorldSocket;
@@ -296,14 +296,6 @@ enum RealmZone
REALM_ZONE_CN9 = 29 // basic-Latin at create, any at login
};
/// Ban function return codes
enum BanReturn
{
BAN_SUCCESS,
BAN_SYNTAX_ERROR,
BAN_NOTFOUND
};
// DB scripting commands
#define SCRIPT_COMMAND_TALK 0 // source = unit, target=any, datalong ( 0=say, 1=whisper, 2=yell, 3=emote text)
#define SCRIPT_COMMAND_EMOTE 1 // source = unit, datalong = anim_id
@@ -321,37 +313,23 @@ enum BanReturn
#define SCRIPT_COMMAND_REMOVE_AURA 14 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id
#define SCRIPT_COMMAND_CAST_SPELL 15 // source (datalong2!=0) or target (datalong==0) unit, datalong = spell_id
/// CLI related stuff, define here to prevent cyclic dependancies
typedef int(* pPrintf)(const char*,...);
typedef void(* pCliFunc)(char *,pPrintf);
/// Command Template class
struct CliCommand
{
char const * cmd;
pCliFunc Func;
char const * description;
};
/// Storage class for commands issued for delayed execution
class CliCommandHolder
struct CliCommandHolder
{
private:
const CliCommand *cmd;
char *args;
pPrintf m_zprintf;
public:
CliCommandHolder(const CliCommand *command, const char *arguments, pPrintf p_zprintf)
: cmd(command), m_zprintf(p_zprintf)
{
size_t len = strlen(arguments)+1;
args = new char[len];
memcpy(args, arguments, len);
}
~CliCommandHolder() { delete[] args; }
void Execute() const { cmd->Func(args, m_zprintf); }
pPrintf GetOutputMethod() const {return (m_zprintf);}
typedef void Print(const char*);
char *m_command;
Print* m_print;
CliCommandHolder(const char *command, Print* zprint)
: m_print(zprint)
{
size_t len = strlen(command)+1;
m_command = new char[len];
memcpy(m_command, command, len);
}
~CliCommandHolder() { delete[] m_command; }
};
/// The World
@@ -474,8 +452,8 @@ class World
void KickAll();
void KickAllLess(AccountTypes sec);
void KickAllQueued();
uint8 BanAccount(std::string type, std::string nameOrIP, std::string duration, std::string reason, std::string author);
bool RemoveBanAccount(std::string type, std::string nameOrIP);
BanReturn BanAccount(BanMode mode, std::string nameOrIP, std::string duration, std::string reason, std::string author);
bool RemoveBanAccount(BanMode mode, std::string nameOrIP);
void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target);
void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target);
@@ -492,7 +470,7 @@ class World
static float GetVisibleObjectGreyDistance() { return m_VisibleObjectGreyDistance; }
void ProcessCliCommands();
void QueueCliCommand(CliCommandHolder* command) { cliCmdQueue.add(command); }
void QueueCliCommand( CliCommandHolder::Print* zprintf, char const* input ) { cliCmdQueue.add(new CliCommandHolder(input, zprintf)); }
void UpdateResultQueue();
void InitResultQueue();

View File

@@ -466,7 +466,7 @@ void WorldSession::SendNotification(int32 string_id,...)
}
}
const char * WorldSession::GetTrinityString( int32 entry )
const char * WorldSession::GetTrinityString( int32 entry ) const
{
return objmgr.GetTrinityString(entry,GetSessionDbLocaleIndex());
}

View File

@@ -194,9 +194,9 @@ class TRINITY_DLL_SPEC WorldSession
time_t m_muteTime;
// Locales
LocaleConstant GetSessionDbcLocale() { return m_sessionDbcLocale; }
int GetSessionDbLocaleIndex() { return m_sessionDbLocaleIndex; }
const char *GetTrinityString(int32 entry);
LocaleConstant GetSessionDbcLocale() const { return m_sessionDbcLocale; }
int GetSessionDbLocaleIndex() const { return m_sessionDbLocaleIndex; }
const char *GetTrinityString(int32 entry) const;
uint32 GetLatency() const { return m_latency; }
void SetLatency(uint32 latency) { m_latency = latency; }

View File

@@ -169,7 +169,8 @@ enum AccountTypes
SEC_PLAYER = 0,
SEC_MODERATOR = 1,
SEC_GAMEMASTER = 2,
SEC_ADMINISTRATOR = 3
SEC_ADMINISTRATOR = 3,
SEC_CONSOLE = 4 // must be always last in list, accounts must have less security level always also
};
enum LocaleConstant

File diff suppressed because it is too large Load Diff

View File

@@ -44,7 +44,7 @@ unsigned int iUsers=0; ///< Number of activ
typedef int(* pPrintf)(const char*,...);
void ParseCommand(pPrintf zprintf, char*command);
void ParseCommand(CliCommandHolder::Print*, char*command);
/// RASocket constructor
RASocket::RASocket(ISocketHandler &h): TcpSocket(h)
@@ -222,7 +222,7 @@ void RASocket::OnRead()
if(strlen(buff))
{
sLog.outRALog("Got '%s' cmd.\n",buff);
ParseCommand(&RASocket::zprintf , buff);
sWorld.QueueCliCommand(&RASocket::zprint , buff);
}
else
Sendf("TC>");
@@ -234,20 +234,23 @@ void RASocket::OnRead()
}
/// Output function
int RASocket::zprintf( const char * szText, ... )
void RASocket::zprint( const char * szText )
{
if( !szText ) return 0;
va_list ap;
va_start(ap, szText);
/// \todo Remove buffer length here. Can be >1024 (e.g. list of users)
char *megabuffer=new char[1024];
unsigned int sz=vsnprintf(megabuffer,1024,szText,ap);
#ifdef RA_CRYPT
Encrypt(megabuffer,sz);
#endif
if( !szText )
return;
send(r,megabuffer,sz,0);
#ifdef RA_CRYPT
char *megabuffer=strdup(szText);
unsigned int sz=strlen(megabuffer);
Encrypt(megabuffer,sz);
send(r,megabuffer,sz,0);
delete [] megabuffer;
va_end(ap);
return 0;
#else
unsigned int sz=strlen(szText);
send(r,szText,sz,0);
#endif
}

View File

@@ -61,7 +61,7 @@ class RASocket: public TcpSocket
OK, //both login and pass were given, and they are correct and user have enough priv.
}stage;
static int zprintf( const char * szText, ... );
static void zprint( const char * szText );
};
#endif
/// @}