mirror of
https://github.com/azerothcore/mod-ale
synced 2025-12-01 21:15:19 +08:00
Remove bad string splitting
Thanks to Makpptfox at getmangos.eu for report
This commit is contained in:
@@ -42,31 +42,20 @@ void Eluna::OnLearnTalents(Player* pPlayer, uint32 talentId, uint32 talentRank,
|
|||||||
bool Eluna::OnCommand(Player* player, const char* text)
|
bool Eluna::OnCommand(Player* player, const char* text)
|
||||||
{
|
{
|
||||||
// If from console, player is NULL
|
// If from console, player is NULL
|
||||||
std::string fullcmd(text);
|
|
||||||
if (!player || player->GetSession()->GetSecurity() >= SEC_ADMINISTRATOR)
|
if (!player || player->GetSession()->GetSecurity() >= SEC_ADMINISTRATOR)
|
||||||
{
|
{
|
||||||
char* creload = strtok((char*)text, " ");
|
std::string reload = text;
|
||||||
char* celuna = strtok(NULL, "");
|
std::transform(reload.begin(), reload.end(), reload.begin(), ::tolower);
|
||||||
if (creload && celuna)
|
if (reload.find("reload eluna") == 0)
|
||||||
{
|
{
|
||||||
std::string reload(creload);
|
ReloadEluna();
|
||||||
std::string eluna(celuna);
|
return false;
|
||||||
std::transform(reload.begin(), reload.end(), reload.begin(), ::tolower);
|
|
||||||
if (reload == "reload")
|
|
||||||
{
|
|
||||||
std::transform(eluna.begin(), eluna.end(), eluna.begin(), ::tolower);
|
|
||||||
if (std::string("eluna").find(eluna) == 0)
|
|
||||||
{
|
|
||||||
ReloadEluna();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
START_HOOK_WITH_RETVAL(PLAYER_EVENT_ON_COMMAND, true);
|
START_HOOK_WITH_RETVAL(PLAYER_EVENT_ON_COMMAND, true);
|
||||||
Push(player);
|
Push(player);
|
||||||
Push(fullcmd);
|
Push(text);
|
||||||
return CallAllFunctionsBool(PlayerEventBindings, key, true);
|
return CallAllFunctionsBool(PlayerEventBindings, key, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,21 @@ bool Eluna::OnAddonMessage(Player* sender, uint32 type, std::string& msg, Player
|
|||||||
START_HOOK_WITH_RETVAL(ADDON_EVENT_ON_MESSAGE, true);
|
START_HOOK_WITH_RETVAL(ADDON_EVENT_ON_MESSAGE, true);
|
||||||
Push(sender);
|
Push(sender);
|
||||||
Push(type);
|
Push(type);
|
||||||
const char* c_msg = msg.c_str();
|
|
||||||
Push(strtok((char*)c_msg, "\t")); // prefix
|
auto delimeter_position = msg.find('\t');
|
||||||
Push(strtok(NULL, "")); // msg
|
if (delimeter_position == std::string::npos)
|
||||||
|
{
|
||||||
|
Push(msg); // prefix
|
||||||
|
Push(); // msg
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::string prefix = msg.substr(0, delimeter_position);
|
||||||
|
std::string content = msg.substr(delimeter_position + 1, std::string::npos);
|
||||||
|
Push(prefix);
|
||||||
|
Push(content);
|
||||||
|
}
|
||||||
|
|
||||||
if (receiver)
|
if (receiver)
|
||||||
Push(receiver);
|
Push(receiver);
|
||||||
else if (guild)
|
else if (guild)
|
||||||
|
|||||||
Reference in New Issue
Block a user