Dynaverse.net

Taldrenites => Starfleet Command Mission Scripting => Topic started by: FPF-SCM_TraceyG_XC on December 22, 2004, 11:05:14 am

Title: mGetShipBPV() does not work - here is the fix for it
Post by: FPF-SCM_TraceyG_XC on December 22, 2004, 11:05:14 am
ship->mGetShipBPV() always returns zero, however, the protected member fShipBPV is being initialised to the correct BPV.

Looking in shipinfo.cpp, we find that function does nothing and only has the one line that says "return 0". Since  fShipBPV is a protected member, we cannot access it outside of the class, nor do we have the source code to the API to make the correct change and recompile it.

However, we can write a new function and add it to shipinfo.h as part of the tShipInfo class by using an inline function

In order to access it, you must make the following changes to the OP API in ShipInfo.h, you will need to change the properties of the file first so it is not set to read only in order to save the chanes.

In  class tShipInfo   : public tActor find the section of code which looks like this:

   //
   //   BPV values
   //
   int32   mGetBPV( void );
   int32   mGetTotalBPV( void );


and change it to:

   //
   //   BPV values
   //
   int32   mGetBPV( void );

   inline int32 mGetRealBPV() // this function added by TraceyG
   {
      return fShipBPV;
   }

   int32   mGetTotalBPV( void );

This adds in a new inline function without the need to recompile ShipInfo.cpp

Once you have done this, you can then use the function ship->mGetRealBPV() just as you would have used mGetBPV(), only now it will return the correct value.
Title: Re: mGetShipBPV() does not work - here is the fix for it
Post by: FA Frey XC on December 22, 2004, 11:07:31 am
Nice work Tracey!
Title: Re: mGetShipBPV() does not work - here is the fix for it
Post by: FPF-SCM_TraceyG_XC on September 09, 2006, 06:16:47 am
Bump for Dave