client.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*-------------------------------------------------------------------------
  2. client.h
  3. Per client stuff on lobby side
  4. Owner:
  5. Copyright 1986-2000 Microsoft Corporation, All Rights Reserved
  6. *-----------------------------------------------------------------------*/
  7. #ifndef _CLIENT_H_
  8. #define _CLIENT_H_
  9. // There shld be a one-to-one mapping between connections on the servers session and CFLServer objects,
  10. // but there's not, since each connection can (for now) actually support more than one game).
  11. // CFLServer is more of a server "game" than a server "connection"
  12. class CFLClient : public IObject
  13. {
  14. public:
  15. CFLClient(CFMConnection * pcnxn) :
  16. m_dwID(c_dwID),
  17. m_pcnxn(pcnxn)
  18. {
  19. assert(pcnxn);
  20. m_pcnxn->SetPrivateData((DWORD) this); // set up two-way link between connection and this
  21. }
  22. ~CFLClient()
  23. {
  24. m_pcnxn->SetPrivateData(0); // disconnect two-way link between connection and this
  25. }
  26. bool IsValidThisPtr() // this
  27. {
  28. bool fValid = this && (c_dwID == m_dwID);
  29. assert (fValid); // this should only be false if either a bug in the client, or hacked client
  30. return fValid;
  31. }
  32. static CFLClient * FromConnection(CFMConnection & cnxn)
  33. {
  34. return (CFLClient *)cnxn.GetPrivateData();
  35. }
  36. CFMConnection * GetConnection()
  37. {
  38. return m_pcnxn;
  39. }
  40. private:
  41. static const DWORD c_dwID;
  42. static const int c_cMaxPlayers;
  43. CFMConnection * m_pcnxn;
  44. DWORD m_dwID;
  45. };
  46. #endif