Browse Source

Merge branch 'master' of zombie343/MultiSend into master

master
Thorny 7 years ago committed by Gogs
parent
commit
e7a0372108
  1. 2
      README.md
  2. BIN
      release/plugins/MultiSend.dll
  3. 29
      src/MultiSend/Commands.cpp
  4. 5
      src/MultiSend/IO.cpp
  5. 5
      src/MultiSend/Main.cpp
  6. 8
      src/MultiSend/MultiSend.h
  7. 21
      src/MultiSend/Substitute.cpp

2
README.md

@ -17,6 +17,8 @@ Commands are as follows(all can be prefixed with /ms or /multisend): @@ -17,6 +17,8 @@ Commands are as follows(all can be prefixed with /ms or /multisend):
/ms debug on/off - When enabled, all received commands are printed to log and any character with followme updated will spam log with position updates. For debug purposes, obviously.
/ms safemode on/off - When enabled, '/echo' will be inserted for commands missing the leading '/' to prevent chatlog spam
/ms reload - Will reload groups xml.
/ms help - Print an ingame reference.

BIN
release/plugins/MultiSend.dll

Binary file not shown.

29
src/MultiSend/Commands.cpp

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
#include "MultiSend.h"
#include "MultiSend.h"
bool MultiSend::HandleCommand(const char* command, int32_t type)
{
@ -202,6 +202,32 @@ bool MultiSend::HandleCommand(const char* command, int32_t type) @@ -202,6 +202,32 @@ bool MultiSend::HandleCommand(const char* command, int32_t type)
return true;
}
else if (_stricmp(arg.c_str(), "safemode") == 0)
{
if (strlen(com) < 2) return true;
com++;
com += GetArg(com, &arg);
if (_stricmp(arg.c_str(), "on") == 0)
{
_SafeMode = true;
m_AshitaCore->GetChatManager()->Write("MultiSend: Safe mode enabled.");
}
else if (_stricmp(arg.c_str(), "off") == 0)
{
_SafeMode = false;
m_AshitaCore->GetChatManager()->Write("MultiSend: Safe mode disabled.");
}
else
{
m_AshitaCore->GetChatManager()->Writef("MultiSend: Safe mode currently %s.", _SafeMode ? "enabled" : "disabled");
}
return true;
}
else if (_stricmp(arg.c_str(), "reload") == 0)
{
LoadGroups();
@ -219,6 +245,7 @@ bool MultiSend::HandleCommand(const char* command, int32_t type) @@ -219,6 +245,7 @@ bool MultiSend::HandleCommand(const char* command, int32_t type)
m_AshitaCore->GetChatManager()->Write("/ms reload - Reloads group file without reloading MultiSend.");
m_AshitaCore->GetChatManager()->Write("/ms ignoreself on/off - When enabled, send and sendgroup commands sent by this character will not execute on this character.");
m_AshitaCore->GetChatManager()->Write("/ms debug on/off - When enabled, debug prints will be visible.");
m_AshitaCore->GetChatManager()->Write("/ms safemode on/off - When enabled, '/echo' will be inserted for commands missing the leading '/' to prevent chatlog spam.");
return true;
}

5
src/MultiSend/IO.cpp

@ -57,8 +57,9 @@ void MultiSend::SendCommand(uint32_t ID, const char* Command) @@ -57,8 +57,9 @@ void MultiSend::SendCommand(uint32_t ID, const char* Command)
char* Text = new char[248];
memset((void*)Text, 0, 248);
memcpy(Text, Command, strlen(Command));
SubValues(Text);
if (_SafeMode)
SanitizeCommand(Text);
SubValues(Text);
Claim(&(MMF_Pointer->Command.ProcessID), 0);
int NextPosition = MMF_Pointer->Command.Position + 1;

5
src/MultiSend/Main.cpp

@ -84,6 +84,9 @@ bool MultiSend::Initialize(IAshitaCore* core, ILogManager* log, uint32_t id) @@ -84,6 +84,9 @@ bool MultiSend::Initialize(IAshitaCore* core, ILogManager* log, uint32_t id)
}
_Debug = false;
//SafeMode enabled by Default (to avoid accidental chatlog spam):
//Allows for prepend of "/echo " to commands that are missing a leading "/".
_SafeMode = true;
this->Start();
@ -116,7 +119,7 @@ __declspec(dllexport) void __stdcall CreatePluginInfo(plugininfo_t* lpBuffer) @@ -116,7 +119,7 @@ __declspec(dllexport) void __stdcall CreatePluginInfo(plugininfo_t* lpBuffer)
strcpy_s(g_PluginInfo->Author, sizeof(g_PluginInfo->Author), "Thorny");
g_PluginInfo->InterfaceVersion = ASHITA_INTERFACE_VERSION;
g_PluginInfo->PluginVersion = 1.03f;
g_PluginInfo->PluginVersion = 1.04f;
g_PluginInfo->Priority = 0;
}

8
src/MultiSend/MultiSend.h

@ -6,10 +6,10 @@ @@ -6,10 +6,10 @@
#endif
#define SAFE_DELETE(p) if(p) { delete p; p = NULL; }
#include "C:\Ashita 3\Plugins\ADK\Ashita.h"
#include "C:\Ashita 3\Plugins\ADK\Ashita.h"
#include "Structs.h"
#include "..\..\pluginheaders\Utilities.h"
#include "..\..\pluginheaders\rapidxml.hpp"
#include "..\..\pluginheaders\Utilities.h"
#include "..\..\pluginheaders\rapidxml.hpp"
#include <time.h>
#include <list>
#include <map>
@ -70,6 +70,7 @@ class MultiSend : IPlugin, Ashita::Threading::AS_Thread @@ -70,6 +70,7 @@ class MultiSend : IPlugin, Ashita::Threading::AS_Thread
volatile bool IgnoreSelf;
volatile bool _Debug;
volatile bool _SafeMode;
public:
MultiSend(void);
@ -91,6 +92,7 @@ public: @@ -91,6 +92,7 @@ public:
bool ReadCommand();
void SetFollow(bool Active);
void SendCommand(uint32_t ID, const char* Command);
void SanitizeCommand(char* Input);
std::string SubValues(std::string Input);
void SubValues(char* Input);
void UpdateName(std::string Name);

21
src/MultiSend/Substitute.cpp

@ -65,4 +65,23 @@ void MultiSend::SubValues(char* Input) @@ -65,4 +65,23 @@ void MultiSend::SubValues(char* 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.");
}
}

Loading…
Cancel
Save