Noisemaker spam!!
This commit is contained in:
parent
6493073fd3
commit
04018bee13
2
makefile
2
makefile
@ -1,5 +1,5 @@
|
||||
CXX=$(shell sh -c "which g++-6 || which g++")
|
||||
CXXFLAGS=-std=gnu++14 -D_GLIBCXX_USE_CXX11_ABI=0 -D_POSIX=1 -DRAD_TELEMETRY_DISABLED -DLINUX=1 -D_LINUX=1 -DPOSIX=1 -DGNUC=1 -D_DEVELOPER=1 -DNO_MALLOC_OVERRIDE -O3 -g3 -ggdb -w -shared -Wall -Wno-unknown-pragmas -fmessage-length=0 -m32 -fvisibility=hidden -fPIC
|
||||
CXXFLAGS=-std=gnu++14 -D_GLIBCXX_USE_CXX11_ABI=0 -D_POSIX=1 -DRAD_TELEMETRY_DISABLED -DLINUX=1 -DUSE_SDL -D_LINUX=1 -DPOSIX=1 -DGNUC=1 -D_DEVELOPER=1 -DNO_MALLOC_OVERRIDE -O3 -g3 -ggdb -w -shared -Wall -Wno-unknown-pragmas -fmessage-length=0 -m32 -fvisibility=hidden -fPIC
|
||||
SDKFOLDER=$(realpath source-sdk-2013/mp/src)
|
||||
SIMPLE_IPC_DIR = $(realpath simple-ipc/src/include)
|
||||
INCLUDES=-I$(SIMPLE_IPC_DIR) -I$(SDKFOLDER)/public -I$(SDKFOLDER)/mathlib -I$(SDKFOLDER)/common -I$(SDKFOLDER)/public/tier1 -I$(SDKFOLDER)/public/tier0 -I$(SDKFOLDER)
|
||||
|
@ -35,7 +35,11 @@ CatCommand::CatCommand(std::string name, std::string help, FnCommandCallbackVoid
|
||||
void CatCommand::Register() {
|
||||
char* name_c = new char[256];
|
||||
char* help_c = new char[256];
|
||||
strncpy(name_c, (CON_PREFIX + name).c_str(), 255);
|
||||
if (name.at(0) == '+' || name.at(0) == '-') {
|
||||
strncpy(name_c, (name).c_str(), 255);
|
||||
} else {
|
||||
strncpy(name_c, (CON_PREFIX + name).c_str(), 255);
|
||||
}
|
||||
strncpy(help_c, help.c_str(), 255);
|
||||
if (callback) cmd = new ConCommand(name_c, callback, help_c);
|
||||
else if (callback_void) cmd = new ConCommand(name_c, callback_void, help_c);
|
||||
|
@ -41,10 +41,30 @@ int IN_KeyEvent_hook(void* thisptr, int eventcode, int keynum, const char* pszCu
|
||||
|
||||
static CatVar log_sent(CV_SWITCH, "debug_log_sent_messages", "0", "Log sent messages");
|
||||
|
||||
static CatCommand plus_use_action_slot_item_server("+cat_use_action_slot_item_server", "use_action_slot_item_server", []() {
|
||||
KeyValues* kv = new KeyValues("+use_action_slot_item_server");
|
||||
g_IEngine->ServerCmdKeyValues(kv);
|
||||
});
|
||||
|
||||
static CatCommand minus_use_action_slot_item_server("-cat_use_action_slot_item_server", "use_action_slot_item_server", []() {
|
||||
KeyValues* kv = new KeyValues("-use_action_slot_item_server");
|
||||
g_IEngine->ServerCmdKeyValues(kv);
|
||||
});
|
||||
|
||||
bool SendNetMsg_hook(void* thisptr, INetMessage& msg, bool bForceReliable = false, bool bVoice = false) {
|
||||
SEGV_BEGIN;
|
||||
if (log_sent) {
|
||||
if (log_sent && msg.GetType() != 3 && msg.GetType() != 9) {
|
||||
logging::Info("=> %s [%i] %s", msg.GetName(), msg.GetType(), msg.ToString());
|
||||
unsigned char buf[4096];
|
||||
bf_write buffer("cathook_debug_buffer", buf, 4096);
|
||||
logging::Info("Writing %i", msg.WriteToBuffer(buffer));
|
||||
std::string bytes = "";
|
||||
constexpr char h2c[] = "0123456789abcdef";
|
||||
for (int i = 0; i < buffer.GetNumBytesWritten(); i++) {
|
||||
//bytes += format(h2c[(buf[i] & 0xF0) >> 4], h2c[(buf[i] & 0xF)], ' ');
|
||||
bytes += format((unsigned short)buf[i], ' ');
|
||||
}
|
||||
logging::Info("%i bytes => %s", buffer.GetNumBytesWritten(), bytes.c_str());
|
||||
}
|
||||
//logging::Info("Sending NetMsg! %i", msg.GetType());
|
||||
if (hacks::shared::airstuck::IsStuck() && cathook && !g_Settings.bInvalid) {
|
||||
|
@ -8,6 +8,202 @@
|
||||
#include "netmessage.h"
|
||||
#include "logging.h"
|
||||
|
||||
bf_write::bf_write()
|
||||
{
|
||||
m_pData = NULL;
|
||||
m_nDataBytes = 0;
|
||||
m_nDataBits = -1; // set to -1 so we generate overflow on any operation
|
||||
m_iCurBit = 0;
|
||||
m_bOverflow = false;
|
||||
m_bAssertOnOverflow = true;
|
||||
m_pDebugName = NULL;
|
||||
}
|
||||
|
||||
unsigned long g_LittleBits[32];
|
||||
|
||||
// Precalculated bit masks for WriteUBitLong. Using these tables instead of
|
||||
// doing the calculations gives a 33% speedup in WriteUBitLong.
|
||||
unsigned long g_BitWriteMasks[32][33];
|
||||
|
||||
// (1 << i) - 1
|
||||
unsigned long g_ExtraMasks[33];
|
||||
|
||||
#include "bitvec.h"
|
||||
|
||||
inline int BitForBitnum(int bitnum)
|
||||
{
|
||||
return GetBitForBitnum(bitnum);
|
||||
}
|
||||
|
||||
class CBitWriteMasksInit
|
||||
{
|
||||
public:
|
||||
CBitWriteMasksInit()
|
||||
{
|
||||
for( unsigned int startbit=0; startbit < 32; startbit++ )
|
||||
{
|
||||
for( unsigned int nBitsLeft=0; nBitsLeft < 33; nBitsLeft++ )
|
||||
{
|
||||
unsigned int endbit = startbit + nBitsLeft;
|
||||
g_BitWriteMasks[startbit][nBitsLeft] = BitForBitnum(startbit) - 1;
|
||||
if(endbit < 32)
|
||||
g_BitWriteMasks[startbit][nBitsLeft] |= ~(BitForBitnum(endbit) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
for ( unsigned int maskBit=0; maskBit < 32; maskBit++ )
|
||||
g_ExtraMasks[maskBit] = BitForBitnum(maskBit) - 1;
|
||||
g_ExtraMasks[32] = ~0ul;
|
||||
|
||||
for ( unsigned int littleBit=0; littleBit < 32; littleBit++ )
|
||||
StoreLittleDWord( &g_LittleBits[littleBit], 0, 1u<<littleBit );
|
||||
}
|
||||
};
|
||||
static CBitWriteMasksInit g_BitWriteMasksInit;
|
||||
|
||||
bf_write::bf_write( const char *pDebugName, void *pData, int nBytes, int nBits )
|
||||
{
|
||||
m_bAssertOnOverflow = true;
|
||||
m_pDebugName = pDebugName;
|
||||
StartWriting( pData, nBytes, 0, nBits );
|
||||
}
|
||||
|
||||
bf_write::bf_write( void *pData, int nBytes, int nBits )
|
||||
{
|
||||
m_bAssertOnOverflow = true;
|
||||
m_pDebugName = NULL;
|
||||
StartWriting( pData, nBytes, 0, nBits );
|
||||
}
|
||||
|
||||
bool bf_write::WriteBytes( const void *pBuf, int nBytes )
|
||||
{
|
||||
return WriteBits(pBuf, nBytes << 3);
|
||||
}
|
||||
|
||||
bool bf_write::WriteBits(const void *pInData, int nBits)
|
||||
{
|
||||
#if defined( BB_PROFILING )
|
||||
VPROF( "bf_write::WriteBits" );
|
||||
#endif
|
||||
|
||||
unsigned char *pOut = (unsigned char*)pInData;
|
||||
int nBitsLeft = nBits;
|
||||
|
||||
// Bounds checking..
|
||||
if ( (m_iCurBit+nBits) > m_nDataBits )
|
||||
{
|
||||
SetOverflowFlag();
|
||||
CallErrorHandler( BITBUFERROR_BUFFER_OVERRUN, GetDebugName() );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Align output to dword boundary
|
||||
while (((unsigned long)pOut & 3) != 0 && nBitsLeft >= 8)
|
||||
{
|
||||
|
||||
WriteUBitLong( *pOut, 8, false );
|
||||
++pOut;
|
||||
nBitsLeft -= 8;
|
||||
}
|
||||
|
||||
if ( IsPC() && (nBitsLeft >= 32) && (m_iCurBit & 7) == 0 )
|
||||
{
|
||||
// current bit is byte aligned, do block copy
|
||||
int numbytes = nBitsLeft >> 3;
|
||||
int numbits = numbytes << 3;
|
||||
|
||||
Q_memcpy( (char*)m_pData+(m_iCurBit>>3), pOut, numbytes );
|
||||
pOut += numbytes;
|
||||
nBitsLeft -= numbits;
|
||||
m_iCurBit += numbits;
|
||||
}
|
||||
|
||||
// X360TBD: Can't write dwords in WriteBits because they'll get swapped
|
||||
if ( IsPC() && nBitsLeft >= 32 )
|
||||
{
|
||||
unsigned long iBitsRight = (m_iCurBit & 31);
|
||||
unsigned long iBitsLeft = 32 - iBitsRight;
|
||||
unsigned long bitMaskLeft = g_BitWriteMasks[iBitsRight][32];
|
||||
unsigned long bitMaskRight = g_BitWriteMasks[0][iBitsRight];
|
||||
|
||||
unsigned long *pData = &m_pData[m_iCurBit>>5];
|
||||
|
||||
// Read dwords.
|
||||
while(nBitsLeft >= 32)
|
||||
{
|
||||
unsigned long curData = *(unsigned long*)pOut;
|
||||
pOut += sizeof(unsigned long);
|
||||
|
||||
*pData &= bitMaskLeft;
|
||||
*pData |= curData << iBitsRight;
|
||||
|
||||
pData++;
|
||||
|
||||
if ( iBitsLeft < 32 )
|
||||
{
|
||||
curData >>= iBitsLeft;
|
||||
*pData &= bitMaskRight;
|
||||
*pData |= curData;
|
||||
}
|
||||
|
||||
nBitsLeft -= 32;
|
||||
m_iCurBit += 32;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// write remaining bytes
|
||||
while ( nBitsLeft >= 8 )
|
||||
{
|
||||
WriteUBitLong( *pOut, 8, false );
|
||||
++pOut;
|
||||
nBitsLeft -= 8;
|
||||
}
|
||||
|
||||
// write remaining bits
|
||||
if ( nBitsLeft )
|
||||
{
|
||||
WriteUBitLong( *pOut, nBitsLeft, false );
|
||||
}
|
||||
|
||||
return !IsOverflowed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void bf_write::StartWriting( void *pData, int nBytes, int iStartBit, int nBits )
|
||||
{
|
||||
// Make sure it's dword aligned and padded.
|
||||
Assert( (nBytes % 4) == 0 );
|
||||
Assert(((unsigned long)pData & 3) == 0);
|
||||
|
||||
// The writing code will overrun the end of the buffer if it isn't dword aligned, so truncate to force alignment
|
||||
nBytes &= ~3;
|
||||
|
||||
m_pData = (unsigned long*)pData;
|
||||
m_nDataBytes = nBytes;
|
||||
|
||||
if ( nBits == -1 )
|
||||
{
|
||||
m_nDataBits = nBytes << 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert( nBits <= nBytes*8 );
|
||||
m_nDataBits = nBits;
|
||||
}
|
||||
|
||||
m_iCurBit = iStartBit;
|
||||
m_bOverflow = false;
|
||||
}
|
||||
|
||||
void bf_write::Reset()
|
||||
{
|
||||
m_iCurBit = 0;
|
||||
m_bOverflow = false;
|
||||
}
|
||||
|
||||
|
||||
bool bf_write::WriteString(const char *pStr)
|
||||
{
|
||||
if(pStr)
|
||||
|
Reference in New Issue
Block a user