Topic: mGetClassType() returns the wrong values - here is the fix for it  (Read 3034 times)

0 Members and 1 Guest are viewing this topic.

Offline FPF-SCM_TraceyG_XC

  • Empress of the Empire
  • Commander
  • *
  • Posts: 2543
  • Gender: Female
In the OP API, the class tShipInfo contains a method called mGetClassType(). It is supposed to return an enumerated value of eClassTypes.

eg. eClassTypes fHullClass = Ship->mGetClassType();

The returned value, however, is incorrect in the OP API (although I believe it works normally in EAW).

Fortunately there is a fix for it. I have used the following function to 'restores' the value returned from above to its correct value.

eClassTypes mDebugGetClassType(eClassTypes hullclass)
{
   switch(hullclass)
   {
   case kClassShuttle :
      return kClassShuttle;
      break;
   case kClassPseudoFighter :
      return kClassPseudoFighter;
      break;
   case kClassFreighter :
      return kClassFreighter;
      break;
   case kClassFrigate :
      return kClassCarrier;
      break;
   case kClassDestroyer :
      return kClassFrigate;
      break;
   case kClassWarDestroyer :
      return kClassDestroyer;
      break;
   case kClassLightCruiser :
      return kClassWarDestroyer;
      break;
   case kClassHeavyCruiser :
      return kClassLightCruiser;
      break;
   case kClassNewHeavyCruiser :
      return kClassNewHeavyCruiser;
      break;
   case kClassHeavyBattlecruiser :
      return kClassHeavyCruiser;
      break;
   case kClassCarrier :
      return kClassHeavyBattlecruiser;
      break;
   case kClassDreadnought :
      return kClassDreadnought;
      break;
   case kClassBattleship :
      return kClassBattleship;
      break;
   case kClassListeningPost :
      return kClassListeningPost;
      break;
   case kClassBaseStation :
      return kClassBaseStation;
      break;
   case kClassBattleStation :
      return kClassBattleStation;
      break;
   case kClassStarBase :
      return kClassStarBase;
      break;
   case kClassMonster :
      return kClassMonster;
      break;
   case kClassPlanets :
      return kClassPlanets;
      break;
   case kClassSpecial :
      return kClassSpecial;
      break;
   default :
      return kClassShuttle;
      break;
   }
}

I have declared this as a global function simply by placing it into my CommonDefs.cpp file (with appropriate prototype in Commondefs.h) but it can be placed anywhere.

In the above example, the code would now look like this:

eClassTypes fHullClass = Ship->mGetClassType();
fHullClass = mDebugGetClassType(fHullClass);

The above function must be called whenever mGetClassType() is used (until we can correct the source code).
Feel free to use the above code.
Captain FPF-TraceyG, Federation Protection Fleet


SFC2.net Admin member
SFC3.net Admin member
Voting member of the DGA
Member of XenoCorp, Squadron Commodore

Centauri Vaughn

  • Guest
Re: mGetClassType() returns the wrong values - here is the fix for it
« Reply #1 on: December 23, 2004, 11:23:45 am »

Hey TraceyG,

MagnumMan's ShipList library will save you from going through all this trouble.

Feel free to contact me if you intend to use it.

Offline FPF-SCM_TraceyG_XC

  • Empress of the Empire
  • Commander
  • *
  • Posts: 2543
  • Gender: Female
Re: mGetClassType() returns the wrong values - here is the fix for it
« Reply #2 on: December 23, 2004, 12:19:52 pm »
Thanks for that CV. Unfortunately Magnum Man's shiplist library was not designed for custom shiplists and will not work properly if the shiplist is heavily modded. For this reason I have avoided using it until we can rewrite it so it will work with any shiplist.
Captain FPF-TraceyG, Federation Protection Fleet


SFC2.net Admin member
SFC3.net Admin member
Voting member of the DGA
Member of XenoCorp, Squadron Commodore

Centauri Vaughn

  • Guest
Re: mGetClassType() returns the wrong values - here is the fix for it
« Reply #3 on: December 24, 2004, 07:18:35 am »
Quote
Unfortunately Magnum Man's shiplist library was not designed for custom shiplists and will not work properly if the shiplist is heavily modded. For this reason I have avoided using it until we can rewrite it so it will work with any shiplist.

I have used MagnumMan's library for heavily modded shiplist. FleetPick, for example, could have not been created w/o it. The only draw back is the load time but there are a few lines of code you can add to take care of that.[/b]

Offline FPF-SCM_TraceyG_XC

  • Empress of the Empire
  • Commander
  • *
  • Posts: 2543
  • Gender: Female
Re: mGetClassType() returns the wrong values - here is the fix for it
« Reply #4 on: December 24, 2004, 08:55:05 pm »
I heard that if you do not have the Federation listed first in the shiplist, then it doesn't work properly. Also, Firesoul is working on a new shiplist API that should remedy that (along with a few other additions). Magnum Man's shiplist scripting tool is certainly very useful though and opens up new possibilities. I also heard that the load time is increased for a mission, as you say. Coop ace also uses the it, (I think) and the mission runs fine on GSA, although Dave Wessels said he tried using it for D2 missions and it caused an increased incidence of player drops. I will certainly look you up if I have any questions  :)
Captain FPF-TraceyG, Federation Protection Fleet


SFC2.net Admin member
SFC3.net Admin member
Voting member of the DGA
Member of XenoCorp, Squadron Commodore