[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:
@@ -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);
|
||||
|
||||
|
||||
+465
-362
File diff suppressed because it is too large
Load Diff
+61
-11
@@ -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
|
||||
|
||||
+71
-20
@@ -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
|
||||
|
||||
+38
-16
@@ -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;
|
||||
}
|
||||
|
||||
+34
-26
@@ -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())
|
||||
|
||||
+98
-55
@@ -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;
|
||||
}
|
||||
|
||||
+1038
-415
File diff suppressed because it is too large
Load Diff
@@ -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);
|
||||
|
||||
+79
-52
@@ -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;
|
||||
}
|
||||
|
||||
+12
-3
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+45
-51
@@ -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()
|
||||
|
||||
+19
-41
@@ -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();
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
+139
-1052
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
/// @}
|
||||
|
||||
Reference in New Issue
Block a user