From 3d412a4b30a9f7c7f51ea6562e694315948bd3da Mon Sep 17 00:00:00 2001 From: boris Date: Wed, 28 Nov 2018 16:00:02 +1300 Subject: cleaned up in short, the cheat and loader are now separate solutions. unused stuff was moved into the legacy solution in case anyone wants to compile it or whatever. i can change this back if you want to. also, i configured the loader to compile in x64, and have separate build types for linux and win64 --- cheat/tf2/dt_common.h | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 cheat/tf2/dt_common.h (limited to 'cheat/tf2/dt_common.h') diff --git a/cheat/tf2/dt_common.h b/cheat/tf2/dt_common.h new file mode 100644 index 0000000..7f86418 --- /dev/null +++ b/cheat/tf2/dt_common.h @@ -0,0 +1,127 @@ +#pragma once + +#define MAX_DATATABLES 1024 // must be a power of 2. +#define MAX_DATATABLE_PROPS 4096 +#define MAX_ARRAY_ELEMENTS 2048 // a network array should have more that 1024 elements + +#define HIGH_DEFAULT -121121.121121f + +#define BITS_FULLRES -1 // Use the full resolution of the type being encoded. +#define BITS_WORLDCOORD -2 // Encode as a world coordinate. + +#define DT_MAX_STRING_BITS 9 +#define DT_MAX_STRING_BUFFERSIZE (1 << DT_MAX_STRING_BITS) // Maximum length of a string that can be sent. + +#define STRINGBUFSIZE(className, varName) sizeof(((className*)0)->varName) + +// Gets the size of a variable in a class. +#define PROPSIZEOF(className, varName) sizeof(((className*)0)->varName) + +// SendProp::m_Flags. +enum SPROP_FLAGS +{ + SPROP_UNSIGNED = (1<<0), // Unsigned integer data. + SPROP_COORD = (1<<1), // If this is set, the float/vector is treated like a world coordinate. + // Note that the bit count is ignored in this case. + SPROP_NOSCALE = (1<<2), // For floating point, don't scale into range, just take value as is. + SPROP_ROUNDDOWN = (1<<3), // For floating point, limit high value to range minus one bit unit + SPROP_ROUNDUP = (1<<4), // For floating point, limit low value to range minus one bit unit + SPROP_NORMAL = (1<<5), // If this is set, the vector is treated like a normal (only valid for vectors), + SPROP_EXCLUDE = (1<<6), // This is an exclude prop (not excludED, but it points at another prop to be excluded),. + SPROP_XYZE = (1<<7), // Use XYZ/Exponent encoding for vectors. + SPROP_INSIDEARRAY = (1<<8), // This tells us that the property is inside an array, so it shouldn't be put into the + // flattened property list. Its array will point at it when it needs to. + SPROP_PROXY_ALWAYS_YES = (1<<9), // Set for datatable props using one of the default datatable proxies like + // SendProxy_DataTableToDataTable that always send the data to all clients. + SPROP_CHANGES_OFTEN = (1<<10), // this is an often changed field, moved to head of sendtable so it gets a small index + SPROP_IS_A_VECTOR_ELEM = (1<<11), // Set automatically if SPROP_VECTORELEM is used. + SPROP_COLLAPSIBLE = (1<<12), // Set automatically if it's a datatable with an offset of 0 that doesn't change the pointer + // (ie: for all automatically-chained base classes),. + // In this case, it can get rid of this SendPropDataTable altogether and spare the + // trouble of walking the hierarchy more than necessary. + SPROP_COORD_MP = (1<<13), // Like SPROP_COORD, but special handling for multiplayer games + SPROP_COORD_MP_LOWPRECISION = (1<<14), // Like SPROP_COORD, but special handling for multiplayer games where the fractional component only gets a 3 bits instead of 5 + SPROP_COORD_MP_INTEGRAL = (1<<15), // SPROP_COORD_MP, but coordinates are rounded to integral boundaries + + // This is server side only, it's used to mark properties whose SendProxy_* functions encode against gpGlobals->tickcount (the only ones that currently do this are + // m_flAnimTime and m_flSimulationTime. MODs shouldn't need to mess with this probably + SPROP_ENCODED_AGAINST_TICKCOUNT = (1<<16), +}; + +#define SPROP_NUMFLAGBITS_NETWORKED 16 + +#define SPROP_NUMFLAGBITS 17 + +// Used by the SendProp and RecvProp functions to disable debug checks on type sizes. +#define SIZEOF_IGNORE -1 + +// Use this to extern send and receive datatables, and reference them. +#define EXTERN_SEND_TABLE(tableName) namespace tableName {extern SendTable g_SendTable;} +#define EXTERN_RECV_TABLE(tableName) namespace tableName {extern RecvTable g_RecvTable;} + +#define REFERENCE_SEND_TABLE(tableName) tableName::g_SendTable +#define REFERENCE_RECV_TABLE(tableName) tableName::g_RecvTable + +class SendProp; + +typedef enum +{ + DPT_Int = 0, + DPT_Float, + DPT_Vector, + DPT_VectorXY, + DPT_String, + DPT_Array, // An array of the base types (can't be of datatables). + DPT_DataTable, + DPT_NUMSendPropTypes +} SendPropType; + +/* +class DVariant +{ +public: + union + { + float m_Float; + long m_Int; + char* m_pString; + void* m_pData; // For DataTables. + float m_Vector[3]; + }; + + SendPropType m_Type; + + DVariant() { m_Type = DPT_Float; } + + DVariant(float val) + { + m_Type = DPT_Float; + m_Float = val; + } +}; +*/ + +struct DVariant { + union { + float m_Float; + long m_Int; + char* m_pString; + void* m_pData; + float m_Vector[3]; + __int64 m_Int64; + }; + + int m_Type; +}; + +// This can be used to set the # of bits used to transmit a number between 0 and nMaxElements-1. +inline int NumBitsForCount(int nMaxElements) +{ + int nBits = 0; + while(nMaxElements > 0) + { + ++nBits; + nMaxElements >>= 1; + } + return nBits; +} -- cgit v1.2.3