REDRIVER2/src_rebuild/GAME/REVERSING.H
Ilya Shurumov ff59bb90ea - [Psy-X] resolve macro conflicts
- [Psy-X] change debug keyboard controls
2020-11-23 14:50:50 +06:00

51 lines
2.0 KiB
C++

#ifndef REVERSING_H
#define REVERSING_H
// reverse engineering stuff
//----------------------------------------
// byte swapped short
#define SW_SHORT(a,b) (((a) << 8) | (b))
// byte swapped int
#define SW_INT(a,b) (((a) << 16) | (b))
//---------------------------------------
#if !defined( __TYPEINFOGEN__ ) && !defined( _lint ) && defined(_WIN32) // pcLint has problems with assert_offsetof()
template<bool> struct compile_time_assert_failed;
template<> struct compile_time_assert_failed<true> {};
template<int x> struct compile_time_assert_test {};
#define compile_time_assert_join2( a, b ) a##b
#define compile_time_assert_join( a, b ) compile_time_assert_join2(a,b)
#define compile_time_assert( x ) typedef compile_time_assert_test<sizeof(compile_time_assert_failed<(bool)(x)>)> compile_time_assert_join(compile_time_assert_typedef_, __LINE__)
#define assert_sizeof( type, size ) compile_time_assert( sizeof( type ) == size )
#define assert_sizeof_8_byte_multiple( type ) compile_time_assert( ( sizeof( type ) & 7 ) == 0 )
#define assert_sizeof_16_byte_multiple( type ) compile_time_assert( ( sizeof( type ) & 15 ) == 0 )
#define assert_offsetof( type, field, offset ) compile_time_assert( offsetof( type, field ) == offset )
#define assert_offsetof_8_byte_multiple( type, field ) compile_time_assert( ( offsetof( type, field ) & 7 ) == 0 )
#define assert_offsetof_16_byte_multiple( type, field ) compile_time_assert( ( offsetof( type, field ) & 15 ) == 0 )
#else
#define compile_time_assert( x )
#define assert_sizeof( type, size )
#define assert_sizeof_8_byte_multiple( type )
#define assert_sizeof_16_byte_multiple( type )
#define assert_offsetof( type, field, offset )
#define assert_offsetof_8_byte_multiple( type, field )
#define assert_offsetof_16_byte_multiple( type, field )
#endif
#undef eprintf
#define eprintf(fmt, ...) printMsg("[GAME] " fmt, ##__VA_ARGS__)
#define UNIMPLEMENTED() { static bool _stop = false; if(!_stop) eprintf("Unimplemented!\n"); _stop = true; }
//----------------------------------------
#endif // REVERSTING_H