partTypeIGC.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. ** Copyright (C) 1996, 1997 Microsoft Corporation. All Rights Reserved.
  3. **
  4. ** File: partTypeIGC.cpp
  5. **
  6. ** Author:
  7. **
  8. ** Description:
  9. ** Implementation of the CpartTypeIGC class. This file was initially created by
  10. ** the ATL wizard for the core object.
  11. **
  12. ** History:
  13. */
  14. // partTypeIGC.cpp : Implementation of CpartTypeIGC
  15. #include "pch.h"
  16. #include "partTypeIGC.h"
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CpartTypeIGC
  19. HRESULT CpartTypeIGC::Initialize(ImissionIGC* pMission,
  20. Time now,
  21. const void* data,
  22. int dataSize)
  23. {
  24. assert (pMission);
  25. m_pMission = pMission;
  26. ZRetailAssert (data && (dataSize >= sizeof(DataPartTypeIGC)));
  27. {
  28. //Note ... we need to allocate & copy the DataHullTypeIGC + the variable length fields
  29. m_dataSize = dataSize;
  30. m_data = (DataPartTypeIGC*)(new char [m_dataSize]);
  31. assert (m_data);
  32. memcpy(m_data, data, m_dataSize);
  33. if (m_data->successorPartID != NA)
  34. {
  35. m_pptSuccessor = pMission->GetPartType(m_data->successorPartID);
  36. assert (m_pptSuccessor);
  37. }
  38. pMission->AddPartType(this);
  39. }
  40. return S_OK;
  41. }
  42. void CpartTypeIGC::Terminate(void)
  43. {
  44. m_pMission->DeletePartType(this);
  45. }
  46. int CpartTypeIGC::Export(void* data) const
  47. {
  48. if (data)
  49. memcpy(data, m_data, m_dataSize);
  50. return m_dataSize;
  51. }
  52. /////////////////////////////////////////////////////////////////////////////
  53. // IpartTypeIGC
  54. const char* IpartTypeIGC::GetEquipmentTypeName(EquipmentType et)
  55. {
  56. switch (et)
  57. {
  58. case ET_ChaffLauncher:
  59. return "chaff";
  60. case ET_Weapon:
  61. return "weapon";
  62. case ET_Magazine:
  63. return "missile";
  64. case ET_Dispenser:
  65. return "mine";
  66. case ET_Shield:
  67. return "shield";
  68. case ET_Cloak:
  69. return "cloak";
  70. case ET_Pack:
  71. return "ammo";
  72. case ET_Afterburner:
  73. return "afterburner";
  74. default:
  75. assert(false);
  76. return "";
  77. }
  78. }