mainwnd.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:8k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. // MainWnd.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "XmudOS.h"
  5. #include "MainWnd.h"
  6. #include "ShowMsg.h"
  7. #include "CmdPlayerLogon.h"
  8. #include "mapMapInfo.h"
  9. #include "CommandCheck.h"
  10. #include "CmdEmote.h"
  11. #include "Fight.h"
  12. #include "goodsgoodsGoods.h"
  13. #include "npcNpc.h"
  14. #include "wgscommon.h"
  15. #include "wgsDS_API.h"
  16. #include "skillskillskill.h"
  17. #include "hash.h"
  18. extern rmfullglobals myglobs;
  19. extern char g_tszPathName[256];
  20. extern char szDSHostName[32];
  21. extern int g_iActiveClientNum;
  22. extern SOCKET hPlayerServerSock;
  23. ShowMsg m_ShowMsg;
  24. CList <CBaseMap*,CBaseMap*>maplist;
  25. CList <TAdminConData *,TAdminConData* >adminsocketlist;
  26. CList <TClientConData *,TClientConData* >playersocketlist;
  27. CList <TDataUser*,TDataUser*>userlist;
  28. CList <TChatChannel*,TChatChannel*>chatchannellist;
  29. CList <CFight*,CFight*>killlist;
  30. CList <CFight*,CFight*>fightlist;
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CMainWnd
  33. CMainWnd::CMainWnd()
  34. {
  35. }
  36. CMainWnd::~CMainWnd()
  37. {
  38. }
  39. BEGIN_MESSAGE_MAP(CMainWnd, CWnd)
  40. //{{AFX_MSG_MAP(CMainWnd)
  41. ON_WM_CREATE()
  42. ON_WM_CLOSE()
  43. ON_WM_DESTROY()
  44. ON_WM_SIZE()
  45. ON_COMMAND(ID_APP_EXIT, OnAppExit)
  46. ON_COMMAND(ID_APP_SHUTDOWN, OnAppShutdown)
  47. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  48. ON_WM_TIMER()
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CMainWnd message handlers
  53. int CMainWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  54. {
  55. if (CWnd::OnCreate(lpCreateStruct) == -1)
  56. return -1;
  57. myglobs.hWndMain = m_hWnd;
  58. srand( (unsigned)time( NULL ) );
  59. /*
  60. CIPAddressCtrl m_IPAddressCtrl;
  61. RECT rcTmp;
  62. SetRect(&rcTmp,0,0,0,0);
  63. m_IPAddressCtrl.Create(WS_CHILD,rcTmp,this,9999);
  64. m_IPAddressCtrl.SetAddress(192,168,0,251);
  65. */
  66. InitializeCriticalSection(&myglobs.csAdminSocket);
  67. InitializeCriticalSection(&myglobs.csPlayerSocket);
  68. InitializeCriticalSection(&myglobs.csSentCliMsg);
  69. InitializeCriticalSection(&myglobs.csUserlist);
  70. InitializeCriticalSection(&myglobs.csMaplist);
  71. InitializeCriticalSection(&myglobs.csChatChannel);
  72. InitializeCriticalSection(&myglobs.csFightlist);
  73. InitializeCriticalSection(&myglobs.csRecordMsg);
  74. InitializeCriticalSection(&myglobs.csTalkMsg);
  75. InitializeCriticalSection(&myglobs.csPlayerData);
  76. InitializeCriticalSection(&myglobs.csUserLog);
  77. InitializeCriticalSection(&myglobs.csSockDataLog);
  78. GetClientRect(&myglobs.rcWinSize);
  79. m_ShowMsg.Create(ES_AUTOHSCROLL|ES_AUTOVSCROLL
  80. |ES_MULTILINE
  81. |ES_READONLY
  82. |ES_LEFT
  83. |WS_CHILD
  84. |WS_BORDER
  85. |WS_VSCROLL
  86. |WS_HSCROLL,
  87. myglobs.rcWinSize,
  88. this,
  89. IDC_EDIT_SHOWINFO);
  90. m_ShowMsg.ShowWindow(SW_SHOW);
  91. m_ShowMsg.UpdateWindow();
  92. FILE * cfg;
  93. char szFile[256];
  94. CTime Now=CTime::GetCurrentTime();
  95. sprintf(szFile,"%s\log\Info%s.log", g_tszPathName, Now.Format("%Y%m%d%H"));
  96. myglobs.flog = fopen(szFile,"a");
  97. if (myglobs.flog == NULL) {
  98. AfxMessageBox("Open Infolog file fail");
  99. exit(1);
  100. }else
  101. fprintf(myglobs.flog, "Emprise Server Started!n");
  102. //andy_re
  103. {
  104. char buf1[256];
  105. sprintf( buf1, "%s\playersave", g_tszPathName);
  106. if( CreateDir( buf1)  == FALSE )
  107. return -1;
  108. }
  109. //弄