Advertisement
Guest User

SOWWL@Unit@SpritesBounds

a guest
Aug 29th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. namespace msvcrt80 {
  2.  
  3. #pragma pack(push)
  4. #pragma pack(1)
  5.  
  6.     // This is just a legacy MSVCRT80 optimization on double types that doesn't match modern compilers
  7.     struct double_t { // size = 0x08 bytes
  8.         double _underlyingData;        
  9.         static_assert(sizeof(_underlyingData) == 8, "Size mismatch");
  10.  
  11.         inline operator double(void) const {
  12.             return _underlyingData / *reinterpret_cast<const double *>(std::address_of(static_cast<const std::uint64_t &&>(UINT64_C(0x0000000010000000))));
  13.         }
  14.     };
  15.  
  16. #pragma pack(pop)
  17.  
  18. } // msvcrt80
  19.  
  20. namespace War3D {
  21.  
  22.     namespace Battle {
  23.  
  24. #pragma pack(push)
  25. #pragma pack(1)
  26.  
  27.         struct Unit { // size = 0x5F8 bytes
  28.  
  29.             std::uint8_t __padding000[0x328]; // 0x000
  30.            
  31.             enum class SpritesBoundsType { LEFT = 0U, BOTTOM, TOP, RIGHT };
  32.             msvcrt80::double_t spritesBounds[4][2]; // 0x328, [l,b,t,r][x,y] -> left/bottom/top/right-most registered position of a non-dead sprite instance
  33.            
  34.             std::uint8_t __padding368[0x290]; // 0x368
  35.  
  36.         };
  37.  
  38. #pragma pack(pop)
  39.  
  40.     } // namespace Battle
  41.  
  42. } // War3D
  43.  
  44.  
  45. const auto *unit = static_cast<const War3D::Battle::Unit *>(unitAsOpaque); // unitAsOpaque obtained from CXUnit::operator const CUnit *()
  46. const float min_x = unit->spritesBounds[SpritesBoundsType::LEFT][0].operator double();
  47. const float min_y = unit->spritesBounds[SpritesBoundsType::BOTTOM][1].operator double();
  48. const float max_x = unit->spritesBounds[SpritesBoundsType::RIGHT][0].operator double();
  49. const float max_y = unit->spritesBounds[SpritesBoundsType::TOP][1].operator double();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement