|
|
|
#include "MultiSend.h"
|
|
|
|
|
|
|
|
std::string MultiSend::SubValues(std::string Input)
|
|
|
|
{
|
|
|
|
std::string Working = Input;
|
|
|
|
|
|
|
|
size_t find = Working.find("[me]");
|
|
|
|
if (find != string::npos)
|
|
|
|
{
|
|
|
|
Working.replace(find, 4, std::string(m_AshitaCore->GetDataManager()->GetParty()->GetMemberName(0)));
|
|
|
|
}
|
|
|
|
|
|
|
|
find = Working.find("[p0]");
|
|
|
|
if (find != string::npos)
|
|
|
|
{
|
|
|
|
Working.replace(find, 4, std::string(m_AshitaCore->GetDataManager()->GetParty()->GetMemberName(0)));
|
|
|
|
}
|
|
|
|
|
|
|
|
find = Working.find("[p1]");
|
|
|
|
if (find != string::npos)
|
|
|
|
{
|
|
|
|
Working.replace(find, 4, std::string(m_AshitaCore->GetDataManager()->GetParty()->GetMemberName(1)));
|
|
|
|
}
|
|
|
|
|
|
|
|
find = Working.find("[p2]");
|
|
|
|
if (find != string::npos)
|
|
|
|
{
|
|
|
|
Working.replace(find, 4, std::string(m_AshitaCore->GetDataManager()->GetParty()->GetMemberName(2)));
|
|
|
|
}
|
|
|
|
|
|
|
|
find = Working.find("[p3]");
|
|
|
|
if (find != string::npos)
|
|
|
|
{
|
|
|
|
Working.replace(find, 4, std::string(m_AshitaCore->GetDataManager()->GetParty()->GetMemberName(3)));
|
|
|
|
}
|
|
|
|
|
|
|
|
find = Working.find("[p4]");
|
|
|
|
if (find != string::npos)
|
|
|
|
{
|
|
|
|
Working.replace(find, 4, std::string(m_AshitaCore->GetDataManager()->GetParty()->GetMemberName(4)));
|
|
|
|
}
|
|
|
|
|
|
|
|
find = Working.find("[p5]");
|
|
|
|
if (find != string::npos)
|
|
|
|
{
|
|
|
|
Working.replace(find, 4, std::string(m_AshitaCore->GetDataManager()->GetParty()->GetMemberName(5)));
|
|
|
|
}
|
|
|
|
|
|
|
|
find = Working.find("[t]");
|
|
|
|
if (find != string::npos)
|
|
|
|
{
|
|
|
|
unsigned int TargetIndex = m_AshitaCore->GetDataManager()->GetTarget()->GetTargetIndex();
|
|
|
|
if (m_AshitaCore->GetDataManager()->GetTarget()->GetSubTargetActive())
|
|
|
|
{
|
|
|
|
TargetIndex = m_AshitaCore->GetDataManager()->GetTarget()->GetSubTargetIndex();
|
|
|
|
}
|
|
|
|
Working.replace(find, 3, std::to_string(m_AshitaCore->GetDataManager()->GetEntity()->GetServerId(TargetIndex)));
|
|
|
|
}
|
|
|
|
return Working;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiSend::SubValues(char* Input)
|
|
|
|
{
|
|
|
|
std::string Working = SubValues(std::string(Input));
|
|
|
|
const char* base = Working.c_str();
|
|
|
|
memset(Input, 0, 248);
|
|
|
|
memcpy(Input, base, strlen(base));
|
|
|
|
}
|
|
|
|
|
|
|
|
void MultiSend::SanitizeCommand(char* Input)
|
|
|
|
{
|
|
|
|
if (Input[0] != '/')
|
|
|
|
{
|
|
|
|
if (_Debug)
|
|
|
|
m_AshitaCore->GetChatManager()->Write("Detected command without leading '/'. Prepending '/echo'...");
|
|
|
|
char* prepend = "/echo ";
|
|
|
|
size_t plen = strlen(prepend);
|
|
|
|
memmove(Input + plen, Input, strlen(Input) + 1);
|
|
|
|
memcpy(Input, prepend, strlen(prepend));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (_Debug)
|
|
|
|
m_AshitaCore->GetChatManager()->Write("No Sanitization Needed.");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|