mission.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*-------------------------------------------------------------------------
  2. mission.h
  3. Per mission stuff on lobby side
  4. Owner:
  5. Copyright 1986-2000 Microsoft Corporation, All Rights Reserved
  6. *-----------------------------------------------------------------------*/
  7. #ifndef _MISSION_H_
  8. #define _MISSION_H_
  9. class CFLServer;
  10. class CFLClient;
  11. class CFLMission : public IObject
  12. {
  13. public:
  14. CFLMission(CFLServer * pServer, CFLClient * pClientCreator);
  15. ~CFLMission();
  16. bool IsValidThisPtr() // this
  17. {
  18. bool fValid = this &&
  19. !IsBadReadPtr(this, sizeof(*this)) &&
  20. IMPLIES(m_plmi, (!IsBadReadPtr(m_plmi, sizeof(m_plmi)) && !IsBadReadPtr(m_plmi, sizeof(m_plmi->cbmsg)))) &&
  21. (c_dwID == m_dwID);
  22. // this should only be false if a hacked client or timing issue
  23. return fValid;
  24. }
  25. DWORD GetCookie()
  26. {
  27. return (DWORD) this;
  28. }
  29. FMD_LS_LOBBYMISSIONINFO * GetMissionInfo()
  30. {
  31. return m_plmi;
  32. }
  33. CFLServer * GetServer()
  34. {
  35. return m_pServer;
  36. }
  37. void SetLobbyInfo(FMD_LS_LOBBYMISSIONINFO * plmi);
  38. int GetPlayerCount()
  39. {
  40. return m_cPlayers;
  41. }
  42. void AddPlayer();
  43. void RemovePlayer();
  44. CFLClient * GetCreator()
  45. {
  46. return m_pClientCreator;
  47. }
  48. void NotifyCreator();
  49. static CFLMission * FromCookie(DWORD dwCookie)
  50. {
  51. CFLMission * pMission = (CFLMission*) dwCookie;
  52. if (pMission->IsValidThisPtr())
  53. return pMission;
  54. else
  55. return NULL;
  56. }
  57. private:
  58. static const DWORD c_dwID;
  59. FMD_LS_LOBBYMISSIONINFO * m_plmi;
  60. CFLServer * m_pServer;
  61. CFLClient * m_pClientCreator; // to notify them when the game is ready to go
  62. bool m_fNotifiedCreator;
  63. DWORD m_dwID;
  64. int m_cPlayers;
  65. };
  66. typedef TList<CFLMission*> MissionList;
  67. #endif