Clone of Akilla's ac2d @ https://github.com/deregtd/AC2D

cClient.cpp 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include "stdafx.h"
  2. #include "cClient.h"
  3. #include "cPortal.h"
  4. cPortal *m_Portal = 0;
  5. cCellManager *m_Cell = 0;
  6. cInterface *m_GInterface = 0;
  7. cClient::cClient(HINSTANCE hInst, HWND hWnd)
  8. {
  9. m_hInst = hInst;
  10. m_hWnd = hWnd;
  11. //Initialize (Global) Portal and Cell
  12. m_Portal = new cPortal();
  13. m_Cell = new cCellManager();
  14. m_bInit = false;
  15. }
  16. cClient::~cClient()
  17. {
  18. //Shut down graphics
  19. m_Graphics->Stop();
  20. m_Network->Stop();
  21. // while (!m_Graphics->GetStopped())
  22. while (!GetStopped())
  23. Sleep(1);
  24. while (!m_Network->GetStopped())
  25. Sleep(1);
  26. delete m_ObjectDB;
  27. delete m_CharInfo;
  28. delete m_Interface;
  29. delete m_Graphics;
  30. delete m_Network;
  31. delete m_Portal;
  32. }
  33. void cClient::Run()
  34. {
  35. //Initialize Classes
  36. m_Graphics = new cGraphics(m_hWnd);
  37. m_Interface = new cInterface();
  38. m_ObjectDB = new cObjectDB();
  39. m_CharInfo = new cCharInfo();
  40. m_Network = new cNetwork();
  41. //Testing this out
  42. m_GInterface = m_Interface;
  43. //Setup event interfaces
  44. m_Interface->SetNetwork(m_Network);
  45. m_Network->SetInterface(m_Interface);
  46. m_Graphics->SetInterface(m_Interface);
  47. //Setup ObjectDB interfaces
  48. m_Interface->SetObjectDB(m_ObjectDB);
  49. m_Network->SetObjectDB(m_ObjectDB);
  50. m_Interface->SetCharInfo(m_CharInfo);
  51. m_Network->SetCharInfo(m_CharInfo);
  52. //Start the connection
  53. #ifndef TerrainOnly
  54. m_Network->Start();
  55. m_Network->Connect();
  56. #endif
  57. m_bInit = true;
  58. //Run graphics.
  59. m_Graphics->Run();
  60. }
  61. void cClient::Resize()
  62. {
  63. //Called when the window gets a WM_SIZE
  64. m_Graphics->Resize();
  65. }
  66. void cClient::WindowsMessage(UINT Message, WPARAM wParam, LPARAM lParam)
  67. {
  68. m_Interface->WindowsMessage(Message, wParam, lParam);
  69. }
  70. bool cClient::Initted()
  71. {
  72. return m_bInit;
  73. }