fsside.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include "pch.h"
  2. /*-------------------------------------------------------------------------
  3. * CFSSide::CFSSide()
  4. *-------------------------------------------------------------------------
  5. */
  6. CFSSide::CFSSide(TRef<IsideIGC> pSide, CFSMission * pfsmission) :
  7. m_pIsideIGC(pSide),
  8. m_pfsmission(pfsmission)
  9. {
  10. m_pgrpSide = g.fm.CreateGroup(ZString(pSide->GetName()));
  11. m_pIsideIGC->SetPrivateData((DWORD)this); // link to IGC side
  12. }
  13. /*-------------------------------------------------------------------------
  14. * CFSSide::~CFSSide()
  15. *-------------------------------------------------------------------------
  16. */
  17. CFSSide::~CFSSide()
  18. {
  19. g.fm.DeleteGroup(m_pgrpSide);
  20. m_pIsideIGC->SetPrivateData((DWORD)NULL); // unlink from IGC Side
  21. }
  22. /*-------------------------------------------------------------------------
  23. * CFSSide::IsInvited()
  24. *-------------------------------------------------------------------------
  25. */
  26. bool CFSSide::IsInvited(CFSPlayer * pfsPlayer)
  27. {
  28. if(m_pfsmission->IsSquadGame())
  29. {
  30. for (std::vector<ZString>::iterator i(m_Invitations.begin()); i != m_Invitations.end(); ++i)
  31. {
  32. //
  33. // Iterate through each squad that the player is on
  34. //
  35. int nNumSquads = pfsPlayer->GetSquadMembershipList()->n();
  36. SquadMembershipLink* pSquadLink = pfsPlayer->GetSquadMembershipList()->first();
  37. for (int iSquad = 0; iSquad < nNumSquads; ++iSquad, pSquadLink = pSquadLink->next())
  38. {
  39. SquadMembership* psquadmembership = (pSquadLink->data());
  40. if (_stricmp(psquadmembership->GetName(), PCC(static_cast<ZString>(*i))) == 0)
  41. return true;
  42. }
  43. }
  44. }
  45. else
  46. {
  47. for (std::vector<ZString>::iterator i(m_Invitations.begin()); i != m_Invitations.end(); ++i)
  48. {
  49. if (_stricmp(PCC(static_cast<ZString>(*i)), pfsPlayer->GetName()) == 0)
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. /*-------------------------------------------------------------------------
  56. * CFSSide::AddInvitation()
  57. *-------------------------------------------------------------------------
  58. */
  59. void CFSSide::AddInvitation(const char * szSubjectName)
  60. {
  61. if (m_pfsmission->IsSquadGame())
  62. {
  63. if(m_Invitations.size() > 0)
  64. m_Invitations.clear();
  65. m_pfsmission->SetSideName(m_pIsideIGC->GetObjectID(), szSubjectName);
  66. }
  67. m_Invitations.push_back(ZString(szSubjectName));
  68. }
  69. /*-------------------------------------------------------------------------
  70. * CFSSide::GetInvitedSquadName()
  71. *-------------------------------------------------------------------------
  72. */
  73. const char* CFSSide::GetInvitedSquadName()
  74. {
  75. if (m_Invitations.size() == 0)
  76. return NULL;
  77. return *(m_Invitations.begin());
  78. }