From 77b52da44b263df4884be2f35f885d8edccbb6fa Mon Sep 17 00:00:00 2001 From: boris Date: Wed, 19 Dec 2018 00:13:24 +1300 Subject: added new loader project :) merry christmas --- .../UserExperience/MoneybotShared/util.hpp | 85 ++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 csgo-loader/csgo-client/UserExperience/MoneybotShared/util.hpp (limited to 'csgo-loader/csgo-client/UserExperience/MoneybotShared/util.hpp') diff --git a/csgo-loader/csgo-client/UserExperience/MoneybotShared/util.hpp b/csgo-loader/csgo-client/UserExperience/MoneybotShared/util.hpp new file mode 100644 index 0000000..f3d2ae3 --- /dev/null +++ b/csgo-loader/csgo-client/UserExperience/MoneybotShared/util.hpp @@ -0,0 +1,85 @@ +#pragma once +#include +#include +#include + +#define xors( s ) s + +#define NAMESPACE_REGION( x ) namespace x { +#define END_REGION } + +extern int TIME_TO_TICKS( float dt ); +extern float TICKS_TO_TIME( int tick ); +extern float TICK_INTERVAL( ); + +//WEE WOO WEE WOO ITS THE DWORD POLICE +using ulong_t = unsigned long; +using uword_t = unsigned short; + +class IClientEntity; +class CTraceFilter; +class CGameTrace; +class vec3_t; +class vec2_t; + +NAMESPACE_REGION( util ) + +typedef std::unique_ptr< void, void( ) > unique_handle; + +template < typename t > +struct reverse_iterable { + reverse_iterable( t&& it ) : + iterable( it ) { } + + t& iterable; + inline auto begin( ) { + return std::rbegin( iterable ); + } + + inline auto end( ) { + return std::rend( iterable ); + } +}; + +template< typename t > +reverse_iterable< t > +reverse_iterator( t&& iter ) { + return reverse_iterable< t >{ iter }; +} + +template < typename fn > __forceinline fn get_vfunc( void* classbase, int index ) { + if( !classbase ) return fn{ }; + return ( fn )( *( uintptr_t** )classbase )[ index ]; +} + +template < size_t index, typename ret, class ... args_ > +__forceinline ret get_vfunc( void* thisptr, args_... args ) { + using fn = ret( __thiscall* )( void*, args_... ); + + auto fn_ptr = ( fn )( *( uintptr_t** )thisptr )[ index ]; + return fn_ptr( thisptr, args... ); +} + +__forceinline std::string unicode_to_ascii( const std::wstring& unicode ) { + std::string ascii_str( unicode.begin( ), unicode.end( ) ); + return ascii_str; +} + +__forceinline std::wstring ascii_to_unicode( const std::string& ascii ) { + std::wstring unicode_str( ascii.begin( ), ascii.end( ) ); + return unicode_str; +} + +template < typename integer > +__forceinline auto to_hex_str( const integer& w, + size_t hex_len = sizeof( integer ) << 1 ) { + constexpr char* hex_digits = xors( "0123456789abcdef" ); + std::string rc( hex_len, 0 ); + + for( size_t i{ }, j{ ( hex_len - 1 ) * 4 }; i < hex_len; ++i, j -= 4 ) + rc[ i ] = hex_digits[ ( w >> j ) & 0x0f ]; + + return rc; +} + +END_REGION \ No newline at end of file -- cgit v1.2.3