LogisticsMech.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #define LOGISTICSMECH_CPP
  2. /*************************************************************************************************\
  3. LogisticsMech.cpp : Implementation of the LogisticsMech component.
  4. //---------------------------------------------------------------------------//
  5. // Copyright (C) Microsoft Corporation. All rights reserved. //
  6. //===========================================================================//
  7. \*************************************************************************************************/
  8. #include "LogisticsMech.h"
  9. #include "LogisticsData.h"
  10. #include "IniFile.h"
  11. LogisticsMech::LogisticsMech( LogisticsVariant* pVar, int Count ) : pVariant( pVar )
  12. {
  13. ID = (Count << 24 | pVar->getID() );
  14. pilot = 0;
  15. forceGroup = 0;
  16. }
  17. LogisticsMech::~LogisticsMech()
  18. {
  19. if ( pilot )
  20. pilot->setUsed( 0 );
  21. pilot = NULL;
  22. }
  23. void LogisticsMech::setPilot( LogisticsPilot* pPilot )
  24. {
  25. if ( pilot )
  26. pilot->setUsed( 0 );
  27. pilot = pPilot;
  28. if ( pilot )
  29. pilot->setUsed( 1 );
  30. }
  31. void LogisticsMech::setVariant( LogisticsVariant* pVar )
  32. {
  33. pVariant = pVar;
  34. ID = ( LogisticsData::instance->createInstanceID( pVar ) << 24 | pVar->getID() );
  35. }
  36. long LogisticsMech::save( FitIniFile& file, long counter )
  37. {
  38. char tmp[256];
  39. sprintf( tmp, "Inventory%ld", counter );
  40. file.writeBlock( tmp );
  41. file.writeIdString( "Chassis", pVariant->getFileName() );
  42. file.writeIdString( "Variant", pVariant->getName() );
  43. if ( pilot )
  44. file.writeIdString( "Pilot", pilot->getFileName() );
  45. file.writeIdBoolean( "Designer", pVariant->isDesignerMech() );
  46. return 0;
  47. }
  48. void LogisticsMech::setColors( unsigned long base, unsigned long high1, unsigned long high2 )
  49. {
  50. baseColor = base;
  51. highlightColor1 = high1;
  52. highlightColor2 = high2;
  53. }
  54. void LogisticsMech::getColors( unsigned long& base, unsigned long& high1, unsigned long& high2 ) const
  55. {
  56. base = baseColor;
  57. high1 = highlightColor1;
  58. high2 = highlightColor2;
  59. }
  60. //*************************************************************************************************
  61. // end of file ( LogisticsMech.cpp )