Sfoglia il codice sorgente

1.04 - Adding safemode feature to prevent accidental chatlog spam.

master
zombie343 3 anni fa
parent
commit
e4e4f65868
6 ha cambiato i file con 62 aggiunte e 7 eliminazioni
  1. +2
    -0
      README.md
  2. +28
    -1
      src/MultiSend/Commands.cpp
  3. +3
    -1
      src/MultiSend/IO.cpp
  4. +4
    -1
      src/MultiSend/Main.cpp
  5. +5
    -3
      src/MultiSend/MultiSend.h
  6. +20
    -1
      src/MultiSend/Substitute.cpp

+ 2
- 0
README.md Vedi File

@ -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.


+ 28
- 1
src/MultiSend/Commands.cpp Vedi File

@ -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)
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)
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;
}


+ 3
- 1
src/MultiSend/IO.cpp Vedi File

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


+ 4
- 1
src/MultiSend/Main.cpp Vedi File

@ -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)
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;
}


+ 5
- 3
src/MultiSend/MultiSend.h Vedi File

@ -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:\Ashita3\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
volatile bool IgnoreSelf;
volatile bool _Debug;
volatile bool _SafeMode;
public:
MultiSend(void);
@ -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);


+ 20
- 1
src/MultiSend/Substitute.cpp Vedi File

@ -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.");
}
}

Caricamento…
Annulla
Salva