Advertisement
Guest User

XRVesselCtrl check

a guest
Dec 14th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. // Returns true if the supplied vessel is an XR vessel that supports XRVesselCtrl 1.5 or later
  2. static bool IsXRVesselCtrl(const VESSEL *pVessel)
  3. {
  4.     // Let's figure out if the supplied vessel implements XRVesselCtrl.
  5.     // Since we can't rely on RTTI here to test vessel objects that do not contain RTTI, we instead check
  6.     // the status of an exported XRVesselCtrlFlag, if any.
  7.     bool retVal = false;  // assume not XRVesselCtrl
  8.     const HMODULE hDLL = GetModuleHandle(pVessel->GetClassName());
  9.     if (hDLL != NULL)
  10.     {
  11.         const bool *pFlag = reinterpret_cast<const bool *>(GetProcAddress(hDLL, "XRVesselCtrlFlag"));
  12.         if (pFlag != NULL)
  13.             retVal = *pFlag;  // will be 'true' for vessels that implement XRVesselCtrl
  14.         // Do not free hDLL handle here! GetModuleHandle does not increment the reference count.
  15.     }
  16.     return retVal;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement