├── .gitattributes
├── .gitignore
├── .vs
└── LegendOfMir2_Server
│ └── v14
│ └── .suo
├── AdminCmd
├── AdminCmd.aps
├── AdminCmd.cpp
├── AdminCmd.dsp
├── AdminCmd.plg
├── AdminCmd.rc
├── AdminCmd.vcxproj
├── AdminCmd.vcxproj.filters
├── AdminCmd.vcxproj.user
├── StdAfx.cpp
├── StdAfx.h
├── resource.h
└── resource.h.bak
├── DBSvr
├── ConfigDlgFunc.cpp
├── DBSvr.aps
├── DBSvr.cpp
├── DBSvr.dsp
├── DBSvr.h
├── DBSvr.ncb
├── DBSvr.opt
├── DBSvr.plg
├── DBSvr.rc
├── DBSvr.vcxproj
├── DBSvr.vcxproj.filters
├── DBSvr.vcxproj.user
├── GameGateSockMsg.cpp
├── GateCommSockMsg.cpp
├── GateInfo.cpp
├── GlobalUserList.cpp
├── GlobalUserList.h
├── MainWndProc.cpp
├── ProcessDBMsg.cpp
├── ProcessDBMsg.h
├── ProcessGateMsg.cpp
├── ProcessServerMsg.cpp
├── Res
│ ├── MIR2.ICO
│ └── TOOLBAR.BMP
├── ServerCommSockMsg.cpp
├── StdAfx.cpp
├── StdAfx.h
├── TableList.cpp
├── TableList.h
└── resource.h
├── Def
├── DynamicArray.cpp
├── DynamicArray.h
├── EnDecode.cpp
├── EnDecode.h
├── List.cpp
├── List.h
├── Misc.cpp
├── Misc.h
├── Protocol.h
├── Queue.cpp
├── Queue.h
├── RegstryHandler.cpp
├── ServerSockHandler.cpp
├── ServerSockHandler.h
├── StaticArray.h
├── TableColumn.h
├── _OrzEx
│ ├── bstree.h
│ ├── database.cpp
│ ├── database.h
│ ├── datatype.h
│ ├── error.cpp
│ ├── error.h
│ ├── fsa.h
│ ├── indexmap.h
│ ├── list.h
│ ├── map.h
│ ├── pqueue.h
│ ├── prime.cpp
│ ├── prime.h
│ ├── queue.h
│ ├── stack.h
│ ├── streambf.h
│ ├── stringex.cpp
│ ├── stringex.h
│ ├── syncobj.cpp
│ ├── syncobj.h
│ ├── util.cpp
│ └── util.h
├── dbmgr.cpp
└── dbmgr.h
├── GameGate
├── Abusive.cpp
├── Abusive.h
├── ClientSockMsg.cpp
├── ConfigDlgFunc.cpp
├── GameGate.aps
├── GameGate.cpp
├── GameGate.dsp
├── GameGate.h
├── GameGate.ncb
├── GameGate.opt
├── GameGate.plg
├── GameGate.rc
├── GameGate.vcxproj
├── GameGate.vcxproj.filters
├── GameGate.vcxproj.user
├── MainWndProc.cpp
├── RES
│ ├── MIR2.ICO
│ └── TOOLBAR.BMP
├── ServerSockMsg.cpp
├── StdAfx.cpp
├── StdAfx.h
├── ThreadFuncForComm.cpp
├── ThreadFuncForMsg.cpp
├── ThreadFuncForMsg.cpp.bak
└── resource.h
├── GameSvr
├── ConfigDlgFunc.cpp
├── DataHandler.h
├── FrontEngine.h
├── GameSvr.aps
├── GameSvr.cpp
├── GameSvr.dsp
├── GameSvr.h
├── GameSvr.plg
├── GameSvr.positions
├── GameSvr.rc
├── GameSvr.vcxproj
├── GameSvr.vcxproj.filters
├── GameSvr.vcxproj.user
├── GateInfo.cpp
├── Global.cpp
├── Global.h
├── Handler_CommonDB.cpp
├── Handler_Item.cpp
├── Handler_Magic.cpp
├── Handler_Map.cpp
├── ItemHandler.h
├── MagicHandler.h
├── MainWndProc.cpp
├── ObjectEngine.cpp
├── ObjectEngine.h
├── ObjectEvent.cpp
├── ObjectEvent.h
├── ObjectMerchant.cpp
├── ObjectMonster.cpp
├── ObjectMonster.h
├── ObjectNPC.cpp
├── ObjectNPC.h
├── ObjectPlayer.cpp
├── ObjectPlayer.h
├── ObjectPlayerAdmin.cpp
├── ObjectPlayerAdminSaid.cpp
├── ObjectPlayerClone.cpp
├── ObjectPlayerClone.h
├── ObjectPlayerSaid.cpp
├── ObjectScripter.cpp
├── ObjectScripter.h
├── ProcessEvents.cpp
├── ProcessLogin.cpp
├── ProcessMerchants.cpp
├── ProcessMonster.cpp
├── ProcessNPC.cpp
├── ProcessUserHuman.cpp
├── ProcessUserMsg.cpp
├── Res
│ ├── MIR2.ICO
│ └── toolbar.bmp
├── SockMsg_DBSrv.cpp
├── SockMsg_GateComm.cpp
├── SockMsg_LogSvr.cpp
├── StdAfx.cpp
├── StdAfx.h
├── Tables.h
├── ThreadFuncForComm.cpp
├── UserInfo.cpp
├── map
│ └── 4.map
└── resource.h
├── LegendOfMir2_Server.ncb
├── LegendOfMir2_Server.opt
├── LegendOfMir2_Server.positions
├── LegendOfMir2_Server.sdf
├── LegendOfMir2_Server.sln
├── LegendOfMir2_Server.suo
├── LegendOfMir2_Server.v12.suo
├── LoginGate
├── ClientSockMsg.cpp
├── ConfigDlgFunc.cpp
├── IOCPFunc.cpp
├── IOCPFunc.h
├── LoginGate.aps
├── LoginGate.cpp
├── LoginGate.dsp
├── LoginGate.h
├── LoginGate.ncb
├── LoginGate.opt
├── LoginGate.plg
├── LoginGate.rc
├── LoginGate.vcxproj
├── LoginGate.vcxproj.filters
├── LoginGate.vcxproj.user
├── MainWndProc.cpp
├── RESOURCE.H
├── Res
│ ├── CONNECT.ICO
│ ├── ICON1.ICO
│ ├── MIR2.ICO
│ └── TOOLBAR.BMP
├── ServerSockMsg.cpp
├── StdAfx.cpp
├── StdAfx.h
├── ThreadFuncForComm.cpp
└── ThreadFuncForMsg.cpp
├── LoginSvr
├── AddSvrListFunc.cpp
├── ConfigDlgFunc.cpp
├── GateCommSockMsg.cpp
├── GateInfo.cpp
├── LoginSvr.aps
├── LoginSvr.cpp
├── LoginSvr.dsp
├── LoginSvr.h
├── LoginSvr.ncb
├── LoginSvr.opt
├── LoginSvr.plg
├── LoginSvr.rc
├── LoginSvr.vcxproj
├── LoginSvr.vcxproj.filters
├── LoginSvr.vcxproj.user
├── MainWndProc.cpp
├── Res
│ ├── MIR2.ICO
│ └── toolbar.bmp
├── ServerListProc.cpp
├── StdAfx.cpp
├── StdAfx.h
├── ThreadFuncForMsg.cpp
└── resource.h
├── ManConsole
├── .vs
│ └── ManConsole
│ │ └── v14
│ │ └── .suo
├── ConsoleSocket.cpp
├── ConsoleSocket.h
├── ManConsole.aps
├── ManConsole.clw
├── ManConsole.cpp
├── ManConsole.dsp
├── ManConsole.h
├── ManConsole.ncb
├── ManConsole.opt
├── ManConsole.plg
├── ManConsole.rc
├── ManConsole.sdf
├── ManConsole.sln
├── ManConsole.suo
├── ManConsole.vcxproj
├── ManConsole.vcxproj.filters
├── ManConsole.vcxproj.user
├── ManConsoleDlg.cpp
├── ManConsoleDlg.h
├── StdAfx.cpp
├── StdAfx.h
├── res
│ ├── ManConsole.ico
│ └── ManConsole.rc2
└── resource.h
└── SelGate
├── ClientSockMsg.cpp
├── ConfigDlgFunc.cpp
├── IOCPFunc.cpp
├── IOCPFunc.h
├── LoginGate.cpp
├── MainWndProc.cpp
├── RESOURCE.H
├── Res
├── MIR2.ICO
└── TOOLBAR.BMP
├── SelGate.aps
├── SelGate.cpp
├── SelGate.dsp
├── SelGate.h
├── SelGate.ncb
├── SelGate.opt
├── SelGate.plg
├── SelGate.rc
├── SelGate.vcxproj
├── SelGate.vcxproj.filters
├── SelGate.vcxproj.user
├── ServerSockMsg.cpp
├── StdAfx.cpp
├── StdAfx.h
├── ThreadFuncForComm.cpp
└── ThreadFuncForMsg.cpp
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 | Debug/
5 | *.txt
6 | *.sql
7 | _Bin/
8 | ipch/
9 | _Obj_Debug/
10 | Tools/
11 | Tec_Test/
12 | SQL_Scripts/
13 | VirtualClient/
14 | *.opendb
15 | *.dsw
16 | *.exe
17 | *.db
18 | *.htm
19 | # Folder config file
20 | Desktop.ini
21 |
22 | # Recycle Bin used on file shares
23 | $RECYCLE.BIN/
24 |
25 | # Windows Installer files
26 | *.cab
27 | *.msi
28 | *.msm
29 | *.msp
30 |
31 | # Windows shortcuts
32 | *.lnk
33 |
34 | # =========================
35 | # Operating System Files
36 | # =========================
37 |
38 | # OSX
39 | # =========================
40 |
41 | .DS_Store
42 | .AppleDouble
43 | .LSOverride
44 |
45 | # Thumbnails
46 | ._*
47 |
48 | # Files that might appear in the root of a volume
49 | .DocumentRevisions-V100
50 | .fseventsd
51 | .Spotlight-V100
52 | .TemporaryItems
53 | .Trashes
54 | .VolumeIcon.icns
55 |
56 | # Directories potentially created on remote AFP share
57 | .AppleDB
58 | .AppleDesktop
59 | Network Trash Folder
60 | Temporary Items
61 | .apdisk
62 |
--------------------------------------------------------------------------------
/.vs/LegendOfMir2_Server/v14/.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/.vs/LegendOfMir2_Server/v14/.suo
--------------------------------------------------------------------------------
/AdminCmd/AdminCmd.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/AdminCmd/AdminCmd.aps
--------------------------------------------------------------------------------
/AdminCmd/AdminCmd.cpp:
--------------------------------------------------------------------------------
1 | // AdminCmd.cpp : Defines the entry point for the DLL application.
2 | //
3 |
4 | #include "stdafx.h"
5 |
6 | BOOL APIENTRY DllMain( HANDLE hModule,
7 | DWORD ul_reason_for_call,
8 | LPVOID lpReserved
9 | )
10 | {
11 | return TRUE;
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/AdminCmd/AdminCmd.plg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Build Log
5 |
6 | --------------------Configuration: AdminCmd - Win32 Debug--------------------
7 |
8 | Command Lines
9 | Creating command line "rc.exe /l 0x412 /fo"../_Obj_Debug/AdminCmd/AdminCmd.res" /d "_DEBUG" "C:\Works.Wemade\LegendOfMir2_Server\AdminCmd\AdminCmd.rc""
10 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP178.tmp" with contents
11 | [
12 | /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ADMINCMD_EXPORTS" /Fp"../_Obj_Debug/AdminCmd/AdminCmd.pch" /Yu"stdafx.h" /Fo"../_Obj_Debug/AdminCmd/" /Fd"../_Obj_Debug/AdminCmd/" /FD /GZ /c
13 | "C:\Works.Wemade\LegendOfMir2_Server\AdminCmd\AdminCmd.cpp"
14 | ]
15 | Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP178.tmp"
16 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP179.tmp" with contents
17 | [
18 | /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ADMINCMD_EXPORTS" /Fp"../_Obj_Debug/AdminCmd/AdminCmd.pch" /Yc"stdafx.h" /Fo"../_Obj_Debug/AdminCmd/" /Fd"../_Obj_Debug/AdminCmd/" /FD /GZ /c
19 | "C:\Works.Wemade\LegendOfMir2_Server\AdminCmd\StdAfx.cpp"
20 | ]
21 | Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP179.tmp"
22 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP17A.tmp" with contents
23 | [
24 | kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:yes /pdb:"../_Bin/Debug/AdminCmd.pdb" /debug /machine:I386 /out:"../_Bin/Debug/AdminCmd.dll" /implib:"../_Bin/Debug/AdminCmd.lib" /pdbtype:sept
25 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\AdminCmd\AdminCmd.obj
26 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\AdminCmd\StdAfx.obj
27 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\AdminCmd\AdminCmd.res
28 | ]
29 | Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP17A.tmp"
30 | Output Window
31 | Compiling resources...
32 | Compiling...
33 | StdAfx.cpp
34 | Compiling...
35 | AdminCmd.cpp
36 | Linking...
37 |
38 |
39 |
40 | Results
41 | AdminCmd.dll - 0 error(s), 0 warning(s)
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/AdminCmd/AdminCmd.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/AdminCmd/AdminCmd.rc
--------------------------------------------------------------------------------
/AdminCmd/AdminCmd.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {e0ba6cb3-5761-4252-8612-ded8d31272a5}
6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat
7 |
8 |
9 | {887437de-8423-4ef0-bb6b-0657ce87c0c9}
10 | h;hpp;hxx;hm;inl
11 |
12 |
13 | {58685554-a79e-4410-9c6f-43e5b627cb27}
14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 |
26 |
27 | Source Files
28 |
29 |
30 |
31 |
32 | Header Files
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/AdminCmd/AdminCmd.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/AdminCmd/StdAfx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // AdminCmd.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/AdminCmd/StdAfx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #if !defined(AFX_STDAFX_H__992D6CF0_880B_46B1_BCEB_D67C69DF5AB4__INCLUDED_)
7 | #define AFX_STDAFX_H__992D6CF0_880B_46B1_BCEB_D67C69DF5AB4__INCLUDED_
8 |
9 | #if _MSC_VER > 1000
10 | #pragma once
11 | #endif // _MSC_VER > 1000
12 |
13 |
14 | // Insert your headers here
15 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
16 |
17 | #include
18 |
19 | // TODO: reference additional headers your program requires here
20 |
21 | //{{AFX_INSERT_LOCATION}}
22 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
23 |
24 | #endif // !defined(AFX_STDAFX_H__992D6CF0_880B_46B1_BCEB_D67C69DF5AB4__INCLUDED_)
25 |
--------------------------------------------------------------------------------
/AdminCmd/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Developer Studio generated include file.
3 | // Used by AdminCmd.rc
4 | //
5 | #define IDS_COMMAND_MONGEN 1
6 | #define IDS_COMMAND_INSPECTOR 2
7 | #define IDS_COMMAND_ADMIN 3
8 | #define IDS_COMMAND_INVINCIBILITY 4
9 | #define IDS_COMMAND_ATTACK 5
10 | #define IDS_COMMAND_MOVE 6
11 | #define IDS_COMMAND_CHANGELEVEL 7
12 | #define IDS_COMMAND_MOVEFREESTYLE 8
13 | #define IDS_COMMAND_MAP 9
14 | #define IDS_COMMAND_LEVEL 10
15 | #define IDS_COMMAND_MONLEVEL 11
16 | #define IDS_COMMAND_RECALL 12
17 | #define IDS_COMMAND_NUMOFMON 13
18 | #define IDS_COMMAND_NUMOFHUMAN 14
19 | #define IDS_COMMAND_SABUKMONEY 15
20 | #define IDS_COMMAND_KICK 16
21 | #define IDS_COMMAND_KICK2 17
22 | #define IDS_COMMAND_TING 18
23 | #define IDS_COMMAND_KINGTING 19
24 | #define IDS_COMMAND_LUCKYVALUE 20
25 | #define IDS_COMMANT_SHUTUP 21
26 | #define IDS_COMMAND_TALK 22
27 | #define IDS_COMMAND_SHUTUPMAN 23
28 | #define IDS_COMMAND_RELOADADMIN 24
29 | #define IDS_COMMAND_RELOADABUSIVE 25
30 | #define IDS_COMMAND_MOOTAEBO 26
31 | #define IDS_COMMAND_BACKWALK 27
32 | #define IDS_COMMAND_GAIN 28
33 | #define IDS_COMMAND_DELGOLD 29
34 | #define IDS_COMMAND_ADDGOLD 30
35 | #define IDS_COMMAND_GOOD 31
36 | #define IDS_COMMAND_OTHERDELGOLD 32
37 | #define IDS_COMMAND_OTHERADDGOLD 33
38 | #define IDS_COMMAND_OTHERLEVELUP 34
39 | #define IDS_COMMAND_OTHEREXPUP 35
40 | #define IDS_COMMAND_WEAPONDUR 36
41 | #define IDS_COMMAND_PARDON 37
42 | #define IDS_COMMAND_PKPOINT 38
43 | #define IDS_COMMAND_PKPOINTUP 39
44 | #define IDS_COMMAND_CHANGELUCKY 40
45 | #define IDS_COMMAND_SKILLUP 41
46 | #define IDS_COMMAND_OTHERSKILLUP 42
47 | #define IDS_COMMAND_DELSKILL 43
48 | #define IDS_COMMAND_OTHERDELSKILL 44
49 | #define IDS_COMMAND_CHGJOB 45
50 | #define IDS_COMMAND_CHGGENDER 46
51 | #define IDS_COMMAND_COLOR 47
52 | #define IDS_COMMAND_MONRECALL 48
53 | #define IDS_COMMAND_MISSION 49
54 | #define IDS_COMMAND_GENPOS 50
55 | #define IDS_COMMAND_TRANSPARENCY 51
56 | #define IDS_COMMAND_CIVILWAR 52
57 | #define IDS_COMMAND_DYEINGHAIR 53
58 | #define IDS_COMMAND_DYEINGWEAR 54
59 | #define IDS_COMMAND_SUSINOTICE 55
60 | #define IDS_COMMAND_GAMCHUNG 56
61 | #define IDS_COMMAND_CHOOLDOO 57
62 | #define IDS_COMMAND_RESERVED1 58
63 | #define IDS_COMMAND_RESERVED2 59
64 | #define IDS_COMMAND_RESERVED3 60
65 | #define IDS_COMMAND_RESERVED4 61
66 | #define IDS_COMMAND_RESERVED5 62
67 | #define IDS_COMMAND_RESERVED6 63
68 | #define IDS_COMMAND_RESERVED7 64
69 | #define IDS_COMMAND_RESERVED8 65
70 | #define IDS_COMMANT_RESERVED9 66
71 | #define IDS_COMMAND_RESERVED10 67
72 | #define IDS_COMMAND_RESERVED11 68
73 | #define IDS_COMMAND_RESERVED12 69
74 | #define IDS_COMMAND_RESERVED13 70
75 | #define IDS_COMMAND_HAIRSTYLE 71
76 |
77 | // Next default values for new objects
78 | //
79 | #ifdef APSTUDIO_INVOKED
80 | #ifndef APSTUDIO_READONLY_SYMBOLS
81 | #define _APS_NEXT_RESOURCE_VALUE 72
82 | #define _APS_NEXT_COMMAND_VALUE 40001
83 | #define _APS_NEXT_CONTROL_VALUE 1000
84 | #define _APS_NEXT_SYMED_VALUE 72
85 | #endif
86 | #endif
87 |
--------------------------------------------------------------------------------
/AdminCmd/resource.h.bak:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Developer Studio generated include file.
3 | // Used by AdminCmd.rc
4 | //
5 | #define IDS_COMMAND_MONGEN 23
6 | #define IDS_COMMAND_INSPECTOR 24
7 | #define IDS_COMMAND_ADMIN 25
8 | #define IDS_COMMAND_INVINCIBILITY 26
9 | #define IDS_COMMAND_ATTACK 27
10 | #define IDS_COMMAND_MOVE 28
11 | #define IDS_COMMAND_CHANGELEVEL 29
12 | #define IDS_COMMAND_MOVEFREESTYLE 30
13 | #define IDS_COMMAND_MAP 31
14 | #define IDS_COMMAND_LEVEL 32
15 | #define IDS_COMMAND_MONLEVEL 33
16 | #define IDS_COMMAND_RECALL 34
17 | #define IDS_COMMAND_NUMOFMON 35
18 | #define IDS_COMMAND_NUMOFHUMAN 36
19 | #define IDS_COMMAND_SABUKMONEY 37
20 | #define IDS_COMMAND_KICK 38
21 | #define IDS_COMMAND_KICK2 39
22 | #define IDS_COMMAND_TING 40
23 | #define IDS_COMMAND_KINGTING 41
24 | #define IDS_COMMAND_LUCKYVALUE 42
25 | #define IDS_COMMANT_SHUTUP 43
26 | #define IDS_COMMAND_TALK 44
27 | #define IDS_COMMAND_SHUTUPMAN 45
28 | #define IDS_COMMAND_RELOADADMIN 46
29 | #define IDS_COMMAND_RELOADABUSIVE 47
30 | #define IDS_COMMAND_MOOTAEBO 48
31 | #define IDS_COMMAND_BACKWALK 49
32 | #define IDS_COMMAND_GAIN 50
33 | #define IDS_COMMAND_DELGOLD 51
34 | #define IDS_COMMAND_ADDGOLD 52
35 | #define IDS_COMMAND_GOOD 53
36 | #define IDS_COMMAND_OTHERDELGOLD 54
37 | #define IDS_COMMAND_OTHERADDGOLD 55
38 | #define IDS_COMMAND_OTHERLEVELUP 56
39 | #define IDS_COMMAND_OTHEREXPUP 57
40 | #define IDS_COMMAND_WEAPONDUR 58
41 | #define IDS_COMMAND_PARDON 59
42 | #define IDS_COMMAND_PKPOINT 60
43 | #define IDS_COMMAND_PKPOINTUP 61
44 | #define IDS_COMMAND_CHANGELUCKY 62
45 | #define IDS_COMMAND_SKILLUP 63
46 | #define IDS_COMMAND_OTHERSKILLUP 64
47 | #define IDS_COMMAND_DELSKILL 65
48 | #define IDS_COMMAND_OTHERDELSKILL 66
49 | #define IDS_COMMAND_CHGJOB 67
50 | #define IDS_COMMAND_CHGGENDER 68
51 | #define IDS_COMMAND_COLOR 69
52 | #define IDS_COMMAND_MONRECALL 70
53 | #define IDS_COMMAND_MISSION 71
54 | #define IDS_COMMAND_GENPOS 72
55 | #define IDS_COMMAND_TRANSPARENCY 73
56 | #define IDS_COMMAND_CIVILWAR 75
57 | #define IDS_COMMAND_DYEINGHAIR 78
58 | #define IDS_COMMAND_DYEINGWEAR 79
59 | #define IDS_COMMAND_SUSINOTICE 80
60 | #define IDS_COMMAND_GAMCHUNG 81
61 | #define IDS_COMMAND_CHOOLDOO 82
62 | #define IDS_COMMAND_RESERVED1 83
63 | #define IDS_COMMAND_RESERVED2 84
64 | #define IDS_COMMAND_RESERVED3 85
65 | #define IDS_COMMAND_RESERVED4 86
66 | #define IDS_COMMAND_RESERVED5 87
67 | #define IDS_COMMAND_RESERVED6 88
68 | #define IDS_COMMAND_RESERVED7 89
69 | #define IDS_COMMAND_RESERVED8 90
70 | #define IDS_COMMANT_RESERVED9 91
71 | #define IDS_COMMAND_RESERVED10 92
72 | #define IDS_COMMAND_RESERVED11 93
73 | #define IDS_COMMAND_RESERVED12 94
74 | #define IDS_COMMAND_RESERVED13 95
75 | #define IDS_COMMAND_HAIRSTYLE 96
76 |
77 | // Next default values for new objects
78 | //
79 | #ifdef APSTUDIO_INVOKED
80 | #ifndef APSTUDIO_READONLY_SYMBOLS
81 | #define _APS_NEXT_RESOURCE_VALUE 101
82 | #define _APS_NEXT_COMMAND_VALUE 40001
83 | #define _APS_NEXT_CONTROL_VALUE 1000
84 | #define _APS_NEXT_SYMED_VALUE 101
85 | #endif
86 | #endif
87 |
--------------------------------------------------------------------------------
/DBSvr/ConfigDlgFunc.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | BOOL jRegSetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, DWORD dwFlags, LPBYTE pValue, DWORD nValueSize);
4 | BOOL jRegGetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, LPBYTE pValue);
5 |
6 | extern HWND g_hMainWnd;
7 |
8 | BOOL CALLBACK ConfigDlgFunc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
9 | {
10 | switch (uMsg)
11 | {
12 | case WM_INITDIALOG:
13 | {
14 | RECT rcMainWnd, rcDlg;
15 |
16 | GetWindowRect(g_hMainWnd, &rcMainWnd);
17 | GetWindowRect(hWndDlg, &rcDlg);
18 |
19 | MoveWindow(hWndDlg, rcMainWnd.left + (((rcMainWnd.right - rcMainWnd.left) - (rcDlg.right - rcDlg.left)) / 2),
20 | rcMainWnd.top + (((rcMainWnd.bottom - rcMainWnd.top) - (rcDlg.bottom - rcDlg.top)) / 2),
21 | (rcDlg.right - rcDlg.left), (rcDlg.bottom - rcDlg.top), FALSE);
22 |
23 | TCHAR szDatabase[256];
24 |
25 | ZeroMemory(szDatabase, sizeof(szDatabase));
26 |
27 | jRegGetKey(_DB_SERVER_REGISTRY, _TEXT("Device"), (LPBYTE)szDatabase);
28 | SetWindowText(GetDlgItem(hWndDlg, IDC_DBMS_DEVICE), szDatabase);
29 |
30 | break;
31 | }
32 | case WM_COMMAND:
33 | {
34 | switch (wParam)
35 | {
36 | case IDOK:
37 | {
38 | TCHAR szDatabase[256];
39 |
40 | BYTE btInstalled = 1;
41 |
42 | jRegSetKey(_DB_SERVER_REGISTRY, _TEXT("Installed"), REG_BINARY, (LPBYTE)&btInstalled, sizeof(BYTE));
43 |
44 | GetWindowText(GetDlgItem(hWndDlg, IDC_DBMS_DEVICE), szDatabase, sizeof(szDatabase));
45 | jRegSetKey(_DB_SERVER_REGISTRY, _TEXT("Device"), REG_SZ, (LPBYTE)szDatabase, sizeof(szDatabase)/sizeof(TCHAR));
46 | }
47 | case IDCANCEL:
48 | return EndDialog(hWndDlg, IDCANCEL);
49 | }
50 |
51 | break;
52 | }
53 | }
54 |
55 | return FALSE;
56 | }
57 |
--------------------------------------------------------------------------------
/DBSvr/DBSvr.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/DBSvr.aps
--------------------------------------------------------------------------------
/DBSvr/DBSvr.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/DBSvr.cpp
--------------------------------------------------------------------------------
/DBSvr/DBSvr.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/DBSvr.h
--------------------------------------------------------------------------------
/DBSvr/DBSvr.ncb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/DBSvr.ncb
--------------------------------------------------------------------------------
/DBSvr/DBSvr.opt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/DBSvr.opt
--------------------------------------------------------------------------------
/DBSvr/DBSvr.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/DBSvr.rc
--------------------------------------------------------------------------------
/DBSvr/DBSvr.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/DBSvr/GameGateSockMsg.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 |
--------------------------------------------------------------------------------
/DBSvr/GateCommSockMsg.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | extern HWND g_hMainWnd;
4 | extern HWND g_hStatusBar;
5 |
6 | CWHList g_xGateInfoList;
7 |
8 | // **************************************************************************************
9 | //
10 | //
11 | //
12 | // **************************************************************************************
13 |
14 | void UpdateStatusBarGateSession(BOOL fGrow)
15 | {
16 | static long nNumOfCurrGateSession = 0;
17 |
18 | TCHAR szText[20];
19 |
20 | (fGrow ? InterlockedIncrement(&nNumOfCurrGateSession) : InterlockedDecrement(&nNumOfCurrGateSession));
21 |
22 | wsprintf(szText, _TEXT("%d Sessions"), nNumOfCurrGateSession);
23 |
24 | SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(4, 0), (LPARAM)szText);
25 | }
26 |
27 | BOOL InitGateCommSocket(SOCKET &s, SOCKADDR_IN* addr, UINT nMsgID, int nPort, long lEvent)
28 | {
29 | if (s == INVALID_SOCKET)
30 | {
31 | s = socket(AF_INET, SOCK_STREAM, 0);
32 |
33 | addr->sin_family = AF_INET;
34 | addr->sin_port = htons(nPort);
35 | addr->sin_addr.s_addr = htonl(INADDR_ANY);
36 |
37 | if ((bind(s, (const struct sockaddr FAR*)addr, sizeof(SOCKADDR_IN))) == SOCKET_ERROR)
38 | return FALSE;
39 |
40 | if ((listen(s, 5)) == SOCKET_ERROR)
41 | return FALSE;
42 |
43 | if ((WSAAsyncSelect(s, g_hMainWnd, nMsgID, lEvent)) == SOCKET_ERROR)
44 | return FALSE;
45 | }
46 | else
47 | return FALSE;
48 |
49 | return TRUE;
50 | }
51 |
52 |
53 | LPARAM OnGateCommSockMsg(WPARAM wParam, LPARAM lParam)
54 | {
55 | switch (WSAGETSELECTEVENT(lParam))
56 | {
57 | case FD_ACCEPT:
58 | {
59 | CGateInfo* pGateInfo = new CGateInfo;
60 |
61 | if (pGateInfo)
62 | {
63 | pGateInfo->sock = accept(wParam, (struct sockaddr FAR *)NULL, NULL);
64 |
65 | WSAAsyncSelect(pGateInfo->sock, g_hMainWnd, _IDM_GATECOMMSOCK_MSG, FD_READ|FD_CLOSE);
66 |
67 | if (g_xGateInfoList.AddNewNode(pGateInfo))
68 | {
69 | int zero = 0;
70 |
71 | setsockopt(pGateInfo->sock, SOL_SOCKET, SO_SNDBUF, (char *)&zero, sizeof(zero) );
72 |
73 | UpdateStatusBarGateSession(TRUE);
74 | }
75 | }
76 |
77 | break;
78 | }
79 | case FD_CLOSE:
80 | {
81 | UpdateStatusBarGateSession(FALSE);
82 | break;
83 | }
84 | case FD_READ:
85 | {
86 | int nSocket = 0;
87 | char szTmp[DATA_BUFSIZE];
88 | UINT nRecv = 0;
89 |
90 | CGateInfo* pGateInfo;
91 | PLISTNODE pListNode = g_xGateInfoList.GetHead();
92 |
93 | while (pListNode)
94 | {
95 | pGateInfo = (CGateInfo*)g_xGateInfoList.GetData(pListNode);
96 |
97 | if (pGateInfo->sock == (SOCKET)wParam)
98 | break;
99 |
100 | pListNode = g_xGateInfoList.GetNext(pListNode);
101 | }
102 |
103 | nRecv = pGateInfo->Recv();
104 |
105 | if ( nRecv <= 0 )
106 | break;
107 |
108 | pGateInfo->bufLen += nRecv;
109 |
110 | while ( pGateInfo->HasCompletionPacket() )
111 | {
112 | memset( szTmp, 0, sizeof( szTmp ) );
113 | *(pGateInfo->ExtractPacket( szTmp ) - 1) = '\0';
114 |
115 | switch ( szTmp[1] )
116 | {
117 | case '-':
118 | pGateInfo->SendKeepAlivePacket();
119 | break;
120 | case 'A':
121 | pGateInfo->ReceiveSendUser(&szTmp[2]);
122 | break;
123 | case 'O':
124 | pGateInfo->ReceiveOpenUser(&szTmp[2]);
125 | break;
126 | case 'X':
127 | pGateInfo->ReceiveCloseUser(&szTmp[2]);
128 | break;
129 | }
130 | }
131 |
132 | break;
133 | }
134 | }
135 |
136 | return 0L;
137 | }
138 |
--------------------------------------------------------------------------------
/DBSvr/GateInfo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/GateInfo.cpp
--------------------------------------------------------------------------------
/DBSvr/GlobalUserList.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/GlobalUserList.cpp
--------------------------------------------------------------------------------
/DBSvr/GlobalUserList.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #pragma once
4 |
5 |
6 | #define GLOBALLIST_MAXLIST 20000
7 | #define GLOBALLIST_MAXBUCKET 1000
8 |
9 |
10 | #include "..\Def\_OrzEx\syncobj.h"
11 | #include "..\Def\_OrzEx\indexmap.h"
12 | #include "..\Def\_OrzEx\fsa.h"
13 |
14 |
15 | class CGlobalUserList : public CIntLock
16 | {
17 | public:
18 | class CUserInfo
19 | {
20 | public:
21 | enum { MAXID = 32, MAXIP = 32 };
22 |
23 | char szID[MAXID];
24 | char szIP[MAXIP];
25 |
26 | public:
27 | CUserInfo() { szID[0] = '\0'; szIP[0] = '\0'; }
28 | };
29 |
30 | public:
31 | CIndexMap< CUserInfo > m_listUser;
32 | CFixedSizeAllocator< CUserInfo > m_fixedMemory;
33 |
34 | public:
35 | CGlobalUserList();
36 | virtual ~CGlobalUserList();
37 |
38 | bool Insert( char *pID, char *pIP );
39 | CUserInfo * Search( char *pID );
40 | void Remove( char *pID );
41 |
42 | protected:
43 | static char * __cbGetKey( CUserInfo *pUser );
44 | };
45 |
46 |
47 | typedef CGlobalUserList::CUserInfo CGlobalUserInfo;
48 |
49 |
50 | CGlobalUserList * GetGlobalUserList();
51 |
--------------------------------------------------------------------------------
/DBSvr/MainWndProc.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/MainWndProc.cpp
--------------------------------------------------------------------------------
/DBSvr/ProcessDBMsg.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/ProcessDBMsg.cpp
--------------------------------------------------------------------------------
/DBSvr/ProcessDBMsg.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #pragma once
4 |
5 | static char g_szYesterDay[24];
6 | BOOL MakeNewItem(CServerInfo* pServerInfo, _LPTLOADHUMAN lpHumanLoad, _LPTMAKEITEMRCD lpMakeItemRcd, int nRecog);
--------------------------------------------------------------------------------
/DBSvr/ProcessGateMsg.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | extern CWHList g_xGateInfoList;
4 |
5 | UINT WINAPI ProcessGateMsg(LPVOID lpParameter)
6 | {
7 | _TDEFAULTMESSAGE DefaultMsg;
8 | char *pszBegin, *pszEnd;
9 | int nCount;
10 | _TCREATECHR tCreateChr;
11 | _TDELCHR tDelChr;
12 | PLISTNODE pListNode;
13 | CGateInfo* pGateInfo;
14 |
15 | while (TRUE)
16 | {
17 | if (g_xGateInfoList.GetCount())
18 | {
19 | pListNode = g_xGateInfoList.GetHead();
20 |
21 | while (pListNode)
22 | {
23 | pGateInfo = g_xGateInfoList.GetData(pListNode);
24 |
25 | if (pGateInfo)
26 | {
27 | nCount = pGateInfo->m_GateQ.GetCount();
28 |
29 | if (nCount)
30 | {
31 | for (int nLoop = 0; nLoop < nCount; nLoop++)
32 | {
33 | _LPTGATESENDBUFF pSendBuff = (_LPTGATESENDBUFF)pGateInfo->m_GateQ.PopQ();
34 |
35 | if (pSendBuff)
36 | {
37 | int nLen = memlen(pSendBuff->szData);
38 |
39 | if ((pszBegin = (char *)memchr(pSendBuff->szData, '#', nLen)) &&(pszEnd = (char *)memchr(pSendBuff->szData, '!', nLen)))
40 | {
41 | *pszEnd = '\0';
42 |
43 | fnDecodeMessageA(&DefaultMsg, (pszBegin + 1)); // 2 = "#?" ? = Check Code
44 |
45 | switch (DefaultMsg.wIdent)
46 | {
47 | case CM_QUERYCHR:
48 | pGateInfo->QueryCharacter(pSendBuff->sock, (pszBegin + _DEFBLOCKSIZE + 1));
49 | break;
50 | case CM_NEWCHR:case CM_NEWCHRA:
51 | fnDecode6BitBufA((pszBegin + _DEFBLOCKSIZE + 1), (char *)&tCreateChr, sizeof(_TCREATECHR));
52 | pGateInfo->MakeNewCharacter(pSendBuff->sock, &tCreateChr);
53 | break;
54 | case CM_DELCHR:case CM_DELCHRA:
55 | fnDecode6BitBufA((pszBegin + _DEFBLOCKSIZE + 1), (char *)&tDelChr, sizeof(_TDELCHR));
56 | pGateInfo->DeleteExistCharacter(pSendBuff->sock, &tDelChr);
57 | break;
58 | case CM_SELCHR:
59 | case CM_START:
60 | pGateInfo->GetSelectCharacter(pSendBuff->sock, (pszBegin + _DEFBLOCKSIZE + 1));
61 | break;
62 | }
63 | }
64 |
65 | delete pSendBuff;
66 | }
67 | }
68 | }
69 | }
70 |
71 | pListNode = g_xGateInfoList.GetNext(pListNode);
72 | }
73 | }
74 |
75 | SleepEx(1, TRUE);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/DBSvr/ProcessServerMsg.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
--------------------------------------------------------------------------------
/DBSvr/Res/MIR2.ICO:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/Res/MIR2.ICO
--------------------------------------------------------------------------------
/DBSvr/Res/TOOLBAR.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/DBSvr/Res/TOOLBAR.BMP
--------------------------------------------------------------------------------
/DBSvr/StdAfx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // DBSvr.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/DBSvr/StdAfx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
7 | #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
8 |
9 | #if _MSC_VER > 1000
10 | #pragma once
11 | #endif // _MSC_VER > 1000
12 |
13 | #define UNICODE
14 | #define _UNICODE
15 |
16 |
17 | #include
18 | #include
19 | #include
20 | #ifdef _DEBUG
21 | #include
22 | #endif
23 |
24 | // ORZ:
25 | #pragma warning( disable : 4146 )
26 | #pragma warning(disable:4786)
27 |
28 | #include
29 | #include
30 | #include
31 |
32 | #include "resource.h"
33 | #include
34 | #include
35 | class CItem;
36 | class CStdItem;
37 | class CStdItemSpecial;
38 | #include "..\Def\EnDecode.h"
39 | #include "..\Def\ServerSockHandler.h"
40 | #include "..\Def\Misc.h"
41 | #include "..\Def\Protocol.h"
42 | #include "..\Def\TableColumn.h"
43 | #include "..\Def\Queue.h"
44 | #include "..\Def\List.h"
45 |
46 | #include "DBSvr.h"
47 |
48 | #pragma comment (lib, "ws2_32.lib")
49 | #pragma comment (lib, "comctl32.lib")
50 |
51 | // **************************************************************************************
52 |
53 | #define _DB_SERVER_CLASS _TEXT("DatabaseServerClass")
54 | #define _DB_SERVER_TITLE _TEXT("Database Server - Legend of Mir II")
55 | #define _DB_SERVER_REGISTRY _TEXT("Software\\LegendOfMir\\DatabaseSvr")
56 | #define _DB_SERVERLIST_REGISTRY _TEXT("Software\\LegendOfMir\\DatabaseSvr\\Servers")
57 |
58 | #define _STATUS_HEIGHT 10
59 | #define _NUMOFMAX_STATUS_PARTS 4
60 |
61 | #define _IDM_GATECOMMSOCK_MSG WM_USER + 1000
62 |
63 | #define _IDW_TOOLBAR _IDM_GATECOMMSOCK_MSG + 2
64 | #define _IDW_STATUSBAR _IDM_GATECOMMSOCK_MSG + 3
65 |
66 | //{{AFX_INSERT_LOCATION}}
67 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
68 |
69 | #endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
70 |
--------------------------------------------------------------------------------
/DBSvr/TableList.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "stdafx.h"
4 | #include "tablelist.h"
5 | #include "../def/_orzex/stringex.h"
6 |
7 |
8 | static CTblStartPoint s_tblStartPoint;
9 |
10 |
11 | CTblStartPoint::CTblStartPoint()
12 | {
13 | m_list.SetCompareFunction( __cbCompare, NULL );
14 | }
15 |
16 |
17 | CTblStartPoint::~CTblStartPoint()
18 | {
19 | m_list.ClearAll();
20 | }
21 |
22 |
23 | bool CTblStartPoint::Init( CConnection *conn )
24 | {
25 | CRecordset *rec = conn->CreateRecordset();
26 | if ( !rec )
27 | return false;
28 |
29 | if ( rec->Execute( "SELECT * FROM TBL_STARTPOINT" ) )
30 | {
31 | while ( rec->Fetch() )
32 | {
33 | TABLE *node = new TABLE;
34 | if ( !node )
35 | break;
36 |
37 | node->index = atoi( rec->Get( "FLD_INDEX" ) );
38 | strcpy( node->mapName, rec->Get( "FLD_MAPNAME" ) );
39 | node->posX = atoi( rec->Get( "FLD_POSX" ) );
40 | node->posY = atoi( rec->Get( "FLD_POSY" ) );
41 | strcpy( node->desc, rec->Get( "FLD_DESCRIPTION" ) );
42 |
43 | _trim( node->mapName );
44 | _trim( node->desc );
45 |
46 | m_list.Insert( node );
47 | }
48 | }
49 |
50 | else MessageBox(NULL,_T("No such a table"),_T("Get StarPoint"),MB_OK);
51 |
52 | conn->DestroyRecordset( rec );
53 |
54 | return true;
55 | }
56 |
57 |
58 | CTblStartPoint::TABLE * CTblStartPoint::Get( char *mapName )
59 | {
60 | return m_list.Search( (TABLE *) mapName );
61 | }
62 |
63 |
64 | int CTblStartPoint::__cbCompare( void *arg, TABLE *n1, TABLE *n2 )
65 | {
66 | return strcmp( n1->mapName, n2->mapName );
67 | }
68 |
69 |
70 |
71 |
72 | CTblStartPoint * GetTblStartPoint()
73 | {
74 | return &s_tblStartPoint;
75 | }
--------------------------------------------------------------------------------
/DBSvr/TableList.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #pragma once
4 |
5 |
6 | #include "../def/dbmgr.h"
7 |
8 |
9 | class CTblStartPoint
10 | {
11 | public:
12 | struct TABLE
13 | {
14 | char mapName[15]; // search index
15 | int index; // sequence id
16 | int posX;
17 | int posY;
18 | char desc[101];
19 | };
20 |
21 | CList< TABLE > m_list;
22 |
23 | public:
24 | CTblStartPoint();
25 | virtual ~CTblStartPoint();
26 |
27 | bool Init( CConnection *conn );
28 | TABLE * Get( char *mapName );
29 |
30 | protected:
31 | static int __cbCompare( void *arg, TABLE *n1, TABLE *n2 );
32 | };
33 |
34 |
35 | CTblStartPoint * GetTblStartPoint();
--------------------------------------------------------------------------------
/DBSvr/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Developer Studio generated include file.
3 | // Used by DBSvr.rc
4 | //
5 | #define IDS_NOTWINNT 1
6 | #define IDS_LVS_LABEL1 2
7 | #define IDS_LVS_LABEL2 3
8 | #define IDS_LVS_LABEL3 4
9 | #define IDS_STARTSERVICE 5
10 | #define IDS_STOPSERVICE 6
11 | #define IDS_CONNECT_LOGINSERVER 7
12 | #define IDS_DISCONNECT_LOGINSERVER 8
13 | #define IDS_PROGRAM_QUIT 9
14 | #define IDS_PROGRAM_TITLE 10
15 | #define IDS_CANT_CONNECT 11
16 | #define IDS_CONFLVS_LABEL1 12
17 | #define IDS_CONFLVS_LABEL2 13
18 | #define IDS_CONFLVS_LABEL3 14
19 | #define IDS_CONFLVS_LABEL4 15
20 | #define IDS_CONFLVS_LABEL5 16
21 | #define IDS_TAB_LABEL1 17
22 | #define IDS_ACCEPT_GATESERVER 18
23 | #define IDS_OPEN_USER 19
24 | #define IDS_CLOSE_USER 20
25 | #define IDS_CONNECTDB 21
26 | #define IDS_LOADACCOUNTRECORDS 22
27 | #define IDS_BOUNDACCOUNTRECORDS 23
28 | #define IDS_COMPLETENEWUSER 24
29 | #define IDI_MIR2 101
30 | #define IDR_MAINMENU 101
31 | #define IDB_TOOLBAR 102
32 | #define IDD_CONFIGDLG 104
33 | #define IDC_DBSVR_IP 1003
34 | #define IDC_DBMS_IP 1008
35 | #define IDC_DBMS_PORT 1010
36 | #define IDC_DBMS_ID 1011
37 | #define IDC_DBMS_PASSWORD 1012
38 | #define IDC_DBMS_DEVICE 1013
39 | #define IDM_STARTSERVICE 40001
40 | #define IDM_STOPSERVICE 40002
41 | #define IDM_CONFIG 40003
42 | #define IDM_EXIT 40004
43 |
44 | // Next default values for new objects
45 | //
46 | #ifdef APSTUDIO_INVOKED
47 | #ifndef APSTUDIO_READONLY_SYMBOLS
48 | #define _APS_NEXT_RESOURCE_VALUE 101
49 | #define _APS_NEXT_COMMAND_VALUE 40001
50 | #define _APS_NEXT_CONTROL_VALUE 1000
51 | #define _APS_NEXT_SYMED_VALUE 101
52 | #endif
53 | #endif
54 |
--------------------------------------------------------------------------------
/Def/DynamicArray.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | CWHDynamicArray::CWHDynamicArray()
4 | {
5 | InitializeCriticalSection(&m_cs);
6 |
7 | m_nLastRemoveIndex = 0;
8 | m_nLastInsertIndex = 0;
9 |
10 | for (int i = 0; i < _MAX_USER_ARRAY; i++)
11 | m_Elements[i] = NULL;
12 | }
13 |
14 | CWHDynamicArray::~CWHDynamicArray()
15 | {
16 | DeleteCriticalSection(&m_cs);
17 | }
18 |
19 | int CWHDynamicArray::AttachData(VOID *pElement)
20 | {
21 | int nIndex = -1;
22 |
23 | EnterCriticalSection(&m_cs);
24 |
25 | __try
26 | {
27 | nIndex = m_nLastRemoveIndex;
28 |
29 | if (m_Elements[nIndex] == NULL)
30 | {
31 | m_Elements[nIndex] = pElement;
32 | __leave;
33 | }
34 |
35 | for (int i = m_nLastInsertIndex; i < _MAX_USER_ARRAY; i++)
36 | {
37 | if (m_Elements[nIndex] == NULL)
38 | {
39 | m_Elements[nIndex] = pElement;
40 | m_nLastInsertIndex = nIndex;
41 | __leave;
42 | }
43 | }
44 |
45 | for (i = 0; i < m_nLastInsertIndex; i++)
46 | {
47 | if (m_Elements[nIndex] == NULL)
48 | {
49 | m_Elements[nIndex] = pElement;
50 | m_nLastInsertIndex = nIndex;
51 | break;
52 | }
53 | }
54 | }
55 | __finally
56 | {
57 | LeaveCriticalSection(&m_cs);
58 | }
59 |
60 | return nIndex;
61 | }
62 |
63 | void CWHDynamicArray::DettachData(int nIndex)
64 | {
65 | EnterCriticalSection(&m_cs);
66 |
67 | __try
68 | {
69 | m_Elements[nIndex] = NULL;
70 | m_nLastRemoveIndex = nIndex;
71 | }
72 | __finally
73 | {
74 | LeaveCriticalSection(&m_cs);
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/Def/DynamicArray.h:
--------------------------------------------------------------------------------
1 | #define _MAX_USER_ARRAY 5000
2 | /*
3 | typedef struct tag_TDYNAMICARRAY
4 | {
5 | CSessionInfo* pInfo;
6 | } _TDYNAMICARRAY, *_LPTDYNAMICARRAY;
7 | */
8 |
9 | template class CWHDynamicArray
10 | {
11 | protected:
12 | T* m_Elements[_MAX_USER_ARRAY];
13 | BOOL m_IsAvElements[_MAX_USER_ARRAY];
14 |
15 | int m_nLastRemoveIndex;
16 | int m_nLastInsertIndex;
17 |
18 | public:
19 | CWHDynamicArray();
20 | ~CWHDynamicArray();
21 |
22 | int AttachData(T* pElement);
23 | void DettachData(int nIndex);
24 | int GetAvailablePosition();
25 | T* GetEmptyElement(int nIndex);
26 | BOOL SetEmptyElement(int nIndex, T* pElement);
27 |
28 | __inline T* GetData(int nIndex) { if (nIndex >= 0 && nIndex <= _MAX_USER_ARRAY) return m_Elements[nIndex]; return NULL; }
29 | };
30 |
31 | template CWHDynamicArray::CWHDynamicArray()
32 | {
33 | m_nLastRemoveIndex = 0;
34 | m_nLastInsertIndex = 0;
35 |
36 | for (int i = 0; i < _MAX_USER_ARRAY; i++)
37 | {
38 | m_Elements[i] = NULL;
39 | m_IsAvElements[i] = FALSE;
40 | }
41 | }
42 |
43 | template CWHDynamicArray::~CWHDynamicArray()
44 | {
45 | for (int i = 0; i < _MAX_USER_ARRAY; i++)
46 | {
47 | if (m_Elements[i])
48 | {
49 | delete m_Elements[i];
50 | m_Elements[i] = NULL;
51 | }
52 |
53 | m_IsAvElements[i] = FALSE;
54 | }
55 | }
56 |
57 | template int CWHDynamicArray::GetAvailablePosition()
58 | {
59 | int nIndex = -1;
60 |
61 | nIndex = m_nLastRemoveIndex;
62 |
63 | if (m_IsAvElements[nIndex] == FALSE)
64 | return nIndex;
65 |
66 | for (int i = m_nLastInsertIndex; i < _MAX_USER_ARRAY; i++)
67 | {
68 | if (m_IsAvElements[i] == FALSE)
69 | return i;
70 | }
71 |
72 | for (int i = 0; i < m_nLastInsertIndex; i++)
73 | {
74 | if (m_IsAvElements[i] == FALSE)
75 | return i;
76 | }
77 |
78 | return -1;
79 | }
80 |
81 | template T* CWHDynamicArray::GetEmptyElement(int nIndex)
82 | {
83 | if (m_IsAvElements[nIndex] == FALSE)
84 | {
85 | if (!m_Elements[nIndex])
86 | m_Elements[nIndex] = new T;
87 |
88 | m_IsAvElements[nIndex] = TRUE;
89 |
90 | return m_Elements[nIndex];
91 | }
92 |
93 | return NULL;
94 | }
95 |
96 | template BOOL CWHDynamicArray::SetEmptyElement(int nIndex, T* pElement)
97 | {
98 | if (m_IsAvElements[nIndex] == TRUE && m_Elements[nIndex] == pElement)
99 | {
100 | m_IsAvElements[nIndex] = FALSE;
101 |
102 | return TRUE;
103 | }
104 |
105 | return FALSE;
106 | }
107 |
108 | template int CWHDynamicArray::AttachData(T* pElement)
109 | {
110 | int nIndex = -1;
111 |
112 | nIndex = m_nLastRemoveIndex;
113 |
114 | if (m_Elements[nIndex] == NULL && m_IsAvElements[nIndex] == FALSE)
115 | {
116 | m_Elements[nIndex] = pElement;
117 | m_IsAvElements[nIndex] = TRUE;
118 |
119 | return nIndex;
120 | }
121 |
122 | for (int i = m_nLastInsertIndex; i < _MAX_USER_ARRAY; i++)
123 | {
124 | if (m_Elements[i] == NULL && m_IsAvElements[i] == FALSE)
125 | {
126 | m_Elements[i] = pElement;
127 | m_IsAvElements[i] = TRUE;
128 | m_nLastInsertIndex = i;
129 | nIndex = i;
130 |
131 | return nIndex;
132 | }
133 | }
134 |
135 | for (i = 0; i < m_nLastInsertIndex; i++)
136 | {
137 | if (m_Elements[i] == NULL && m_IsAvElements[i] == FALSE)
138 | {
139 | m_Elements[i] = pElement;
140 | m_IsAvElements[i] = TRUE;
141 | m_nLastInsertIndex = i;
142 | nIndex = i;
143 |
144 | return nIndex;
145 | }
146 | }
147 | }
148 |
149 | template void CWHDynamicArray::DettachData(int nIndex)
150 | {
151 | if (nIndex >= 0 && nIndex <= _MAX_USER_ARRAY)
152 | {
153 | m_Elements[nIndex] = NULL;
154 | m_IsAvElements[nIndex] = FALSE;
155 |
156 | m_nLastRemoveIndex = nIndex;
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/Def/EnDecode.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _LEGENDOFMIR_ENDECODE
3 | #define _LEGENDOFMIR_ENDECODE
4 |
5 | #define _DEFBLOCKSIZE 22
6 |
7 | typedef struct tag_TDEFAULTMESSAGE
8 | {
9 | int nLen;
10 | int nRecog;
11 | WORD wIdent;
12 | WORD wParam;
13 | WORD wTag;
14 | WORD wSeries;
15 | } _TDEFAULTMESSAGE, *_LPTDEFAULTMESSAGE;
16 |
17 | typedef struct tag_TMSGHEADER
18 | {
19 | int nCode;
20 | int nSocket;
21 | WORD wUserGateIndex;
22 | WORD wIdent;
23 | WORD wUserListIndex;
24 | WORD wTemp;
25 | int nLength;
26 | } _TMSGHEADER, *_LPTMSGHEADER;
27 |
28 | /*typedef struct tagTGateToSvrHeader
29 | {
30 | char szPrefix; // Always is '%'
31 | char szID; // Identifier.
32 | BYTE btGateIndex; // Gate server index.
33 | int nSocket; // Socket(owner of msg) in gate server.
34 | WORD wDataLength; // Length of msg that following header.
35 | } TGateToSvrHeader, *LPTGateToSvrHeader;
36 |
37 | #define GTS_HEADER_SIZE sizeof(TGateToSvrHeader) */
38 |
39 | //void WINAPI fnMakeDefMessage(_LPTDEFAULTMESSAGE lptdm, WORD wIdent, int nRecog, WORD wParam, WORD wTag, WORD wSeries);
40 | #ifdef _UNICODE
41 | #define fnEncode6BitBuf fnEncode6BitBufW
42 | #define fnDecode6BitBuf fnDecode6BitBufW
43 | #define fnEncodeMessage fnEncodeMessageW
44 | #define fnDecodeMessage fnDecodeMessageW
45 | #define fnMakeDefMessage fnMakeDefMessageW
46 | #else
47 | #define fnEncode6BitBuf fnEncode6BitBufA
48 | #define fnDecode6BitBuf fnDecode6BitBufA
49 | #define fnEncodeMessage fnEncodeMessageA
50 | #define fnDecodeMessage fnDecodeMessageA
51 | #define fnMakeDefMessage fnMakeDefMessageA
52 | #endif
53 |
54 | int WINAPI fnEncode6BitBufW(unsigned char *pszSrc, TCHAR *pszDest, int nSrcLen, int nDestLen);
55 | int WINAPI fnDecode6BitBufW(TCHAR *pwszSrc, char *pszDest, int nDestLen);
56 | int WINAPI fnEncodeMessageW(_LPTDEFAULTMESSAGE lptdm, TCHAR *pszBuf, int nLen);
57 | __inline void WINAPI fnDecodeMessageW(_LPTDEFAULTMESSAGE lptdm, TCHAR *pszBuf)
58 | { fnDecode6BitBufW(pszBuf, (char *)lptdm, sizeof(_TDEFAULTMESSAGE)); }
59 |
60 | __inline void WINAPI fnMakeDefMessageW(_LPTDEFAULTMESSAGE lptdm, WORD wIdent, int nRecog, WORD wParam, WORD wTag, WORD wSeries,int nlen=0)
61 | {
62 | lptdm->wIdent = wIdent; lptdm->nRecog = nRecog; lptdm->wParam = wParam; lptdm->wTag = wTag; lptdm->wSeries = wSeries; lptdm->nLen =_DEFBLOCKSIZE+nlen;
63 | }
64 |
65 | int WINAPI fnEncode6BitBufA(unsigned char *pszSrc, char *pszDest, int nSrcLen, int nDestLen);
66 | int WINAPI fnDecode6BitBufA(char *pwszSrc, char *pszDest, int nDestLen);
67 | int WINAPI fnEncodeMessageA(_LPTDEFAULTMESSAGE lptdm, char *pszBuf, int nLen);
68 | __inline void WINAPI fnDecodeMessageA(_LPTDEFAULTMESSAGE lptdm, char *pszBuf)
69 | { fnDecode6BitBufA(pszBuf, (char *)lptdm, sizeof(_TDEFAULTMESSAGE)); }
70 |
71 | __inline void WINAPI fnMakeDefMessageA(_LPTDEFAULTMESSAGE lptdm, WORD wIdent,int nLen, int nRecog, WORD wParam, WORD wTag, WORD wSeries)
72 | {
73 | lptdm->wIdent = wIdent; lptdm->nLen = nLen; lptdm->nRecog = nRecog; lptdm->wParam = wParam; lptdm->wTag = wTag; lptdm->wSeries = wSeries;
74 | }
75 |
76 | #endif //_LEGENDOFMIR_ENDECODE
--------------------------------------------------------------------------------
/Def/List.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/List.h
--------------------------------------------------------------------------------
/Def/Misc.h:
--------------------------------------------------------------------------------
1 | #ifndef _LEGENDOFMIR2_MISC_FUNC
2 | #define _LEGENDOFMIR2_MISC_FUNC
3 |
4 | void CenterDialog(HWND hParentWnd, HWND hWnd);
5 |
6 | __int64 FileTimeToQuadWord(PFILETIME pFileTime);
7 | void QuadTimeToFileTime(__int64 qw, PFILETIME pFileTime);
8 |
9 | int memlen(const char *str);
10 | int AnsiStrToVal(const char *nptr);
11 | char *ValToAnsiStr(unsigned long val, char *buf);
12 |
13 | void ChangeSpaceToNull(char *pszData);
14 |
15 | void GetDate(char *pszBuf);
16 | bool IsEmptyGuid(const GUID *guid);
17 | //char *ConvertLPWSTRToLPSTR(LPWSTR lpwszStrIn);
18 | GUID *GetGuid(GUID* guid=NULL);
19 | char *GetGuidSZ(char *szDest);
20 | char *GetGuidSZ(char *szDest, const GUID *guid);
21 | GUID *GetGuidTagFromString(const char *szSrc, GUID *guid);
22 | int GetTime();
23 |
24 | #endif
25 |
--------------------------------------------------------------------------------
/Def/Queue.cpp:
--------------------------------------------------------------------------------
1 | // **************************************************************************************
2 | //
3 | // Euyheon's Queue Class
4 | //
5 | // All written by Euy-heon, Jeong.
6 | // Copyright(C) 1999-2001 Euy-heon, Jeong. All rights reserved.
7 | //
8 | // Win32 Version : Compiled by Microsoft Visual C++ 6.0
9 | //
10 | // Problems & History
11 | // ------------------
12 | //
13 | // **************************************************************************************
14 |
15 | #include "stdafx.h"
16 |
17 | CWHQueue::CWHQueue()
18 | {
19 | // InitializeCriticalSection(&m_cs);
20 |
21 | m_btQPushPos = 0;
22 | m_btQPopPos = 0;
23 |
24 | m_btCount = 0;
25 | }
26 |
27 | CWHQueue::~CWHQueue()
28 | {
29 | // DeleteCriticalSection(&m_cs);
30 | }
31 |
32 | BOOL CWHQueue::PushQ(BYTE *lpbtQ)
33 | {
34 | BOOL fRet = TRUE;
35 |
36 | // EnterCriticalSection(&m_cs);
37 |
38 | __try
39 | {
40 | if (m_btQPushPos + 1 == m_btQPopPos || (m_btQPushPos + 1 == (unsigned) QUEUE_MAX && !m_btQPopPos))
41 | {
42 | fRet = FALSE;
43 | __leave; // Queue is full.
44 | }
45 |
46 | m_lpCircularQ[m_btQPushPos] = lpbtQ;
47 | m_btQPushPos++;
48 | m_btCount++;
49 |
50 | if (m_btQPushPos == (unsigned) QUEUE_MAX)
51 | m_btQPushPos = 0;
52 | }
53 | __finally
54 | {
55 | // LeaveCriticalSection(&m_cs);
56 | }
57 |
58 | return fRet;
59 | }
60 |
61 | BYTE *CWHQueue::PopQ()
62 | {
63 | BYTE *pbt = NULL;
64 |
65 | // EnterCriticalSection(&m_cs);
66 |
67 | __try
68 | {
69 | if (m_btQPopPos == (unsigned) QUEUE_MAX)
70 | m_btQPopPos = 0;
71 |
72 | if (m_btQPopPos == m_btQPushPos)
73 | __leave; // No event.
74 |
75 | m_btQPopPos++;
76 | m_btCount--;
77 |
78 | pbt = m_lpCircularQ[m_btQPopPos - 1];
79 | }
80 | __finally
81 | {
82 | // LeaveCriticalSection(&m_cs);
83 | }
84 |
85 | return pbt;
86 | }
87 |
--------------------------------------------------------------------------------
/Def/Queue.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #pragma once
4 |
5 | #include "../def/_orzex/queue.h"
6 | #include "../def/_orzex/syncobj.h"
7 |
8 | class CWHQueue : public CQueue< BYTE >, public CIntLock
9 | {
10 | public:
11 | virtual ~CWHQueue()
12 | {
13 | ClearAll();
14 | }
15 |
16 | bool PushQ( BYTE *lpbtQ )
17 | {
18 | Lock();
19 | bool bRet = Enqueue( lpbtQ );
20 | Unlock();
21 |
22 | return bRet;
23 | }
24 |
25 | BYTE * PopQ()
26 | {
27 | Lock();
28 | BYTE *pData = Dequeue();
29 | Unlock();
30 |
31 | return pData;
32 | }
33 | };
34 |
35 |
36 | /*
37 | #define QUEUE_MAX 1000000
38 |
39 |
40 | class CWHQueue : public CIntLock
41 | {
42 | protected:
43 | UINT m_btCount;
44 |
45 | UINT m_btQPushPos;
46 | UINT m_btQPopPos;
47 |
48 | BYTE *m_lpCircularQ[QUEUE_MAX];
49 |
50 | // CRITICAL_SECTION m_cs;
51 |
52 | public:
53 | CWHQueue();
54 | ~CWHQueue();
55 |
56 | BOOL PushQ(BYTE *lpbtQ);
57 | BYTE *PopQ();
58 |
59 | __inline UINT GetCurPushPos() { return m_btQPushPos; }
60 | __inline UINT GetCurPopPos() { return m_btQPopPos; }
61 |
62 | __inline UINT GetCount() { return m_btCount; }
63 | };
64 | */
--------------------------------------------------------------------------------
/Def/RegstryHandler.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/RegstryHandler.cpp
--------------------------------------------------------------------------------
/Def/ServerSockHandler.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef _DEFAULT_SOCKET_HANDLER
3 | #define _DEFAULT_SOCKET_HANDLER
4 |
5 | #define DATA_BUFSIZE 8192
6 |
7 | enum _OVERLAPPED_FLAG
8 | {
9 | OVERLAPPED_RECV,
10 | OVERLAPPED_SEND,
11 | } OVERLAPPED_FLAG;
12 |
13 | typedef struct tag_TCOMPLETIONPORT
14 | {
15 | OVERLAPPED Overlapped;
16 | WSABUF DataBuf;
17 | CHAR Buffer[DATA_BUFSIZE];
18 | INT nOvFlag;
19 | } _TCOMPLETIONPORT, * _LPTCOMPLETIONPORT;
20 |
21 | typedef struct tag_TOVERLAPPEDEX
22 | {
23 | CHAR Buffer[DATA_BUFSIZE];
24 | WSABUF DataBuf;
25 | SOCKET Socket;
26 | WSAOVERLAPPED Overlapped;
27 | DWORD BytesSEND;
28 | DWORD BytesRECV;
29 | INT nOvFlag;
30 | } _TOVERLAPPEDEX, * _LPTOVERLAPPEDEX;
31 |
32 | BOOL InitServerSocket(SOCKET &s, SOCKADDR_IN* addr, UINT nMsgID, int nPort, long lEvent = 2);
33 | BOOL ConnectToServer(SOCKET &s, SOCKADDR_IN* addr, UINT nMsgID, LPCTSTR lpServerIP, DWORD dwIP, int nPort, long lEvent);
34 | BOOL ClearSocket(SOCKET &s);
35 |
36 | BOOL CheckAvailableIOCP();
37 | INT CreateIOCPWorkerThread(HANDLE hCP, LPDWORD lpdwThreadID, LPTHREAD_START_ROUTINE WorkerThreadFunc);
38 |
39 | BOOL InitThread(LPTHREAD_START_ROUTINE lpRoutine);
40 |
41 | BOOL CheckSocketError(LPARAM lParam);
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/Def/StaticArray.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/StaticArray.h
--------------------------------------------------------------------------------
/Def/TableColumn.h:
--------------------------------------------------------------------------------
1 |
2 | #define FLD_ADDRESS1 _TEXT("FLD_ADDRESS1")
3 | #define FLD_ADDRESS2 _TEXT("FLD_ADDRESS2")
4 | #define FLD_ANSWER1 _TEXT("FLD_ANSWER1")
5 | #define FLD_ANSWER2 _TEXT("FLD_ANSWER2")
6 | #define FLD_BIRTHDAY _TEXT("FLD_BIRTHDAY")
7 | #define FLD_EMAIL _TEXT("FLD_EMAIL")
8 | #define FLD_LOGINID _TEXT("FLD_LOGINID")
9 | #define FLD_MOBILEPHONE _TEXT("FLD_MOBILEPHONE")
10 | #define FLD_PASSWORD _TEXT("FLD_PASSWORD")
11 | #define FLD_PHONE _TEXT("FLD_PHONE")
12 | #define FLD_QUIZ1 _TEXT("FLD_QUIZ1")
13 | #define FLD_QUIZ2 _TEXT("FLD_QUIZ2")
14 | #define FLD_SSNO _TEXT("FLD_SSNO")
15 | #define FLD_USERNAME _TEXT("FLD_USERNAME")
16 |
--------------------------------------------------------------------------------
/Def/_OrzEx/bstree.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/bstree.h
--------------------------------------------------------------------------------
/Def/_OrzEx/database.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/database.cpp
--------------------------------------------------------------------------------
/Def/_OrzEx/database.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/database.h
--------------------------------------------------------------------------------
/Def/_OrzEx/datatype.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ifndef __ORZ_DATA_TYPE__
4 | #define __ORZ_DATA_TYPE__
5 |
6 |
7 | typedef unsigned char byte;
8 | typedef unsigned short ushort;
9 | typedef unsigned int uint;
10 | typedef unsigned long ulong;
11 |
12 |
13 | #endif
--------------------------------------------------------------------------------
/Def/_OrzEx/error.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "stdafx.h"
4 | #include "error.h"
5 | #include
6 | #include
7 |
8 |
9 | CError::CError( char *pMsg )
10 | {
11 | strcpy( m_szMsg, pMsg );
12 | }
13 |
14 |
15 | CError::~CError()
16 | {
17 | }
18 |
19 |
20 | const char * CError::GetMsg()
21 | {
22 | return m_szMsg;
23 | }
24 |
--------------------------------------------------------------------------------
/Def/_OrzEx/error.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*
4 | C++ Exception Processing Class
5 |
6 | Date:
7 | 2001/10/09 (Last Updated: 2002/03/06)
8 | */
9 | #ifndef __ORZ_ERROR__
10 | #define __ORZ_ERROR__
11 |
12 |
13 | #define ERROR_MAXBUF 1024
14 |
15 |
16 | class CError
17 | {
18 | protected:
19 | char m_szMsg[ERROR_MAXBUF];
20 |
21 | public:
22 | CError( char *pMsg );
23 | virtual ~CError();
24 |
25 | const char * GetMsg();
26 | };
27 |
28 |
29 | #endif
--------------------------------------------------------------------------------
/Def/_OrzEx/fsa.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/fsa.h
--------------------------------------------------------------------------------
/Def/_OrzEx/indexmap.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/indexmap.h
--------------------------------------------------------------------------------
/Def/_OrzEx/list.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/list.h
--------------------------------------------------------------------------------
/Def/_OrzEx/map.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/map.h
--------------------------------------------------------------------------------
/Def/_OrzEx/pqueue.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/pqueue.h
--------------------------------------------------------------------------------
/Def/_OrzEx/prime.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "stdafx.h"
4 | #include "prime.h"
5 | #include
6 |
7 |
8 |
9 | bool CPrime::IsPrime( int nNumber )
10 | {
11 | int nSqr = (int) sqrt((float)nNumber);
12 |
13 | for ( int i = 2; i < nSqr; i++ )
14 | {
15 | if ( nNumber % i == 0 )
16 | return false;
17 | }
18 |
19 | return true;
20 | }
21 |
22 |
23 | int CPrime::RoundUp( int nNumber )
24 | {
25 | while ( IsPrime( nNumber ) == false )
26 | ++nNumber;
27 |
28 | return nNumber;
29 | }
30 |
31 |
32 | int CPrime::RoundDown( int nNumber )
33 | {
34 | while ( IsPrime( nNumber ) == false )
35 | --nNumber;
36 |
37 | return nNumber;
38 | }
--------------------------------------------------------------------------------
/Def/_OrzEx/prime.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/prime.h
--------------------------------------------------------------------------------
/Def/_OrzEx/queue.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*
4 | Queue
5 |
6 | Date:
7 | 2001/02/05
8 | */
9 | #ifndef __ORZ_DATASTRUCTURE_QUEUE__
10 | #define __ORZ_DATASTRUCTURE_QUEUE__
11 |
12 |
13 | #include "list.h"
14 |
15 |
16 | template< class T >
17 | class CQueue : public CList< T >
18 | {
19 | public:
20 | virtual bool Enqueue( T *pData );
21 | virtual bool EnqueueHead( T *pData );
22 | virtual T * Dequeue();
23 | };
24 |
25 |
26 | template< class T >
27 | bool CQueue< T >::Enqueue( T * pData )
28 | {
29 | return CList< T >::Insert( pData );
30 | }
31 |
32 |
33 | template< class T >
34 | bool CQueue< T >::EnqueueHead( T * pData )
35 | {
36 | return CList< T >::InsertHead( pData );
37 | }
38 |
39 |
40 | template< class T >
41 | T * CQueue< T >::Dequeue()
42 | {
43 | if ( IsEmpty() )
44 | return NULL;
45 | else
46 | return RemoveNode( m_pHead );
47 | }
48 |
49 |
50 | #endif
--------------------------------------------------------------------------------
/Def/_OrzEx/stack.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*
4 | Stack
5 |
6 | Date:
7 | 2001/02/05
8 | */
9 | #ifndef __ORZ_DATASTRUCTURE_STACK__
10 | #define __ORZ_DATASTRUCTURE_STACK__
11 |
12 |
13 | #include "list.h"
14 |
15 |
16 | template< class T >
17 | class CStack : public CList< T >
18 | {
19 | public:
20 | virtual bool Push( T *pData );
21 | virtual bool PushHead( T *pData );
22 | virtual T * Pop();
23 | };
24 |
25 |
26 | template< class T >
27 | bool CStack< T >::Push( T * pData )
28 | {
29 | return CList< T >::Insert( pData );
30 | }
31 |
32 |
33 | template< class T >
34 | bool CStack< T >::PushHead( T * pData )
35 | {
36 | return CList< T >::InsertHead( pData );
37 | }
38 |
39 |
40 | template< class T >
41 | T * CStack< T >::Pop()
42 | {
43 | if ( IsEmpty() )
44 | return NULL;
45 |
46 | return RemoveNode( m_pTail );
47 | }
48 |
49 |
50 | #endif
--------------------------------------------------------------------------------
/Def/_OrzEx/streambf.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/streambf.h
--------------------------------------------------------------------------------
/Def/_OrzEx/stringex.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/stringex.cpp
--------------------------------------------------------------------------------
/Def/_OrzEx/stringex.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ifndef __ORZ_STRING__
4 | #define __ORZ_STRING__
5 |
6 |
7 | #include
8 | #include
9 |
10 |
11 | /*
12 | string support class (binary string)
13 | */
14 | class bstr
15 | {
16 | public:
17 | char *ptr;
18 | int size;
19 |
20 | public:
21 | bstr();
22 | bstr( bstr &str );
23 | bstr( char *str );
24 | virtual ~bstr();
25 |
26 | bool alloc ( int len );
27 | bool expand( int len );
28 | bool assign( char *str, int len );
29 | bool assign( char *str );
30 | void cleanup();
31 |
32 | bool isassign();
33 | int length();
34 |
35 | operator char * () { return ptr; }
36 | operator const char * const () { return (const char *) ptr; }
37 |
38 | char * operator = ( char *str );
39 | char * operator = ( bstr &str );
40 | char * operator = ( int num );
41 | bool operator == ( char *str );
42 | bool operator != ( char *str );
43 | bstr & operator += ( char *str );
44 | bstr & operator += ( int num );
45 | friend bstr operator + ( bstr &str1, bstr &str2 );
46 | friend bstr operator + ( bstr &str1, char *str2 );
47 | friend bstr operator + ( char *str1, bstr &str2 );
48 | };
49 |
50 |
51 | /*
52 | C runtime function plus++
53 | */
54 | char * _memstr( char *buf, int buf_len, char *str );
55 | char * _memistr( char *buf, int buf_len, char *str );
56 |
57 |
58 | /*
59 | string manipulation
60 | */
61 | bool _isspace( char c );
62 | int _ltrim( char *str );
63 | int _rtrim( char *str );
64 | int _trim( char *str );
65 | int _linecopy( char *str, char *buf );
66 | int _linecopy( bstr *str, char *buf );
67 | bool _pickstring( char *str, char sep, int index, char *buf, int buf_len );
68 |
69 |
70 | #endif
71 |
--------------------------------------------------------------------------------
/Def/_OrzEx/syncobj.cpp:
--------------------------------------------------------------------------------
1 |
2 |
3 | #include "stdafx.h"
4 | #include "syncobj.h"
5 | #include "error.h"
6 |
7 |
8 | CCriticalSection::CCriticalSection()
9 | {
10 | InitializeCriticalSection( &m_csAccess );
11 | }
12 |
13 |
14 | CCriticalSection::~CCriticalSection()
15 | {
16 | DeleteCriticalSection( &m_csAccess );
17 | }
18 |
19 |
20 | void CCriticalSection::Lock()
21 | {
22 | EnterCriticalSection( &m_csAccess );
23 | }
24 |
25 |
26 | void CCriticalSection::Unlock()
27 | {
28 | LeaveCriticalSection( &m_csAccess );
29 | }
30 |
--------------------------------------------------------------------------------
/Def/_OrzEx/syncobj.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*
4 | Synchronization Objects
5 |
6 | Date:
7 | (Last Updated: 2002/03/06)
8 | */
9 | #ifndef __ORZ_THREAD_SYNCHRONIZATION_OBJECT__
10 | #define __ORZ_THREAD_SYNCHRONIZATION_OBJECT__
11 |
12 |
13 | #include
14 |
15 |
16 | class CCriticalSection
17 | {
18 | public:
19 | CRITICAL_SECTION m_csAccess;
20 |
21 | public:
22 | CCriticalSection();
23 | virtual ~CCriticalSection();
24 |
25 | void Lock();
26 | void Unlock();
27 | };
28 |
29 |
30 | typedef CCriticalSection CIntLock; // InterThread Lock
31 |
32 |
33 | #endif
--------------------------------------------------------------------------------
/Def/_OrzEx/util.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/_OrzEx/util.cpp
--------------------------------------------------------------------------------
/Def/_OrzEx/util.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | /*
4 | Utility Functions
5 |
6 | Date:
7 | 2001/02/15
8 | */
9 | #ifndef __ORZ_MISC_UTIL__
10 | #define __ORZ_MISC_UTIL__
11 |
12 |
13 | /*
14 | Useful Macros
15 | */
16 | #define _abs(a) (((a) < (0)) ? (-a) : (b))
17 | #define _swap(a, b) ((a) ^= (b) ^= (a) ^= (b))
18 |
19 |
20 | /*
21 | Number System Converting Functions
22 | */
23 | int _hextodec( char *hex, int len );
24 | void _dectohex( int dec, char *hex, int len );
25 |
26 |
27 | /*
28 | Number Maniplulation Functions
29 | */
30 | template< class TV, class TM >
31 | inline TV _rounddown( TV value, TM multiple )
32 | {
33 | return (value / multiple) * multiple;
34 | }
35 |
36 | template< class TV, class TM >
37 | inline TV _roundup( TV value, TM multiple )
38 | {
39 | return _rounddown( value, multiple ) + ((value % multiple) > 0 ? multiple : 0);
40 | }
41 |
42 |
43 | #endif
44 |
--------------------------------------------------------------------------------
/Def/dbmgr.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/Def/dbmgr.h
--------------------------------------------------------------------------------
/GameGate/Abusive.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | CWHAbusive::CWHAbusive()
4 | {
5 | }
6 |
7 | CWHAbusive::~CWHAbusive()
8 | {
9 | }
10 |
11 | BOOL CWHAbusive::LoadAbusiveList()
12 | {
13 | FILE *stream = fopen("Abusive.txt","r");
14 | m_nCount=0;
15 | if (stream)
16 | {
17 | while(!feof(stream))
18 | {
19 | fscanf(stream, "%s", m_szAbusiveList[m_nCount]);
20 | m_nCount++;
21 | }
22 | fclose(stream);
23 | InsertLogMsgParam(IDS_LOAD_ABUSIVE, &m_nCount, LOGPARAM_INT);
24 |
25 | return TRUE;
26 | }
27 | else
28 | InsertLogMsg(IDS_LOADFAIL_ABUSIVE);
29 |
30 | return FALSE;
31 | }
32 |
33 | void CWHAbusive::ChangeAbusiveText(char *pszText)
34 | {
35 | int nChange;
36 | char *pszSrc, *pszFilter;
37 |
38 | for (int i = 0; i < m_nCount; i++)
39 | {
40 | pszSrc = pszText;
41 | pszFilter = &m_szAbusiveList[i][0];
42 | nChange = 0;
43 |
44 | while (*pszSrc)
45 | {
46 | if (*pszSrc == *pszFilter)
47 | {
48 | nChange++;
49 |
50 | while (*pszFilter != 0)
51 | {
52 | if (*++pszSrc != *++pszFilter) break;
53 |
54 | nChange++;
55 | }
56 |
57 | if (*pszFilter == 0 && nChange >= (int)(memlen(&m_szAbusiveList[i][0]) - 1))
58 | {
59 | for (int nCnt = nChange; nCnt > 0; nCnt--)
60 | *(pszSrc - nCnt) = '*';
61 | }
62 |
63 | pszFilter = &m_szAbusiveList[i][0];
64 | nChange = 0;
65 | }
66 |
67 | pszSrc++;
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/GameGate/Abusive.h:
--------------------------------------------------------------------------------
1 | class CWHAbusive
2 | {
3 | protected:
4 | char m_szAbusiveList[100][10];
5 | int m_nCount;
6 |
7 | public:
8 | CWHAbusive();
9 | ~CWHAbusive();
10 |
11 | BOOL LoadAbusiveList();
12 | void ChangeAbusiveText(char *pszText);
13 |
14 | };
15 |
--------------------------------------------------------------------------------
/GameGate/ClientSockMsg.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameGate/ClientSockMsg.cpp
--------------------------------------------------------------------------------
/GameGate/ConfigDlgFunc.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | BOOL jRegSetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, DWORD dwFlags, LPBYTE pValue, DWORD nValueSize);
4 | BOOL jRegGetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, LPBYTE pValue);
5 |
6 | extern HWND g_hMainWnd;
7 |
8 | BOOL CALLBACK ConfigDlgFunc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
9 | {
10 | switch (uMsg)
11 | {
12 | case WM_INITDIALOG:
13 | {
14 | RECT rcMainWnd, rcDlg;
15 |
16 | GetWindowRect(g_hMainWnd, &rcMainWnd);
17 | GetWindowRect(hWndDlg, &rcDlg);
18 |
19 | MoveWindow(hWndDlg, rcMainWnd.left + (((rcMainWnd.right - rcMainWnd.left) - (rcDlg.right - rcDlg.left)) / 2),
20 | rcMainWnd.top + (((rcMainWnd.bottom - rcMainWnd.top) - (rcDlg.bottom - rcDlg.top)) / 2),
21 | (rcDlg.right - rcDlg.left), (rcDlg.bottom - rcDlg.top), FALSE);
22 |
23 | SendMessage(GetDlgItem(hWndDlg, IDC_LOGINSVR_PORT), EM_LIMITTEXT, (WPARAM)5, (LPARAM)0L);
24 | SendMessage(GetDlgItem(hWndDlg, IDC_LOCALPORT), EM_LIMITTEXT, (WPARAM)5, (LPARAM)0L);
25 |
26 | DWORD dwIP = 0;
27 | TCHAR szPort[24];
28 | int nPort = 0;
29 |
30 | jRegGetKey(_GAMEGATE_SERVER_REGISTRY, _TEXT("RemoteIP"), (LPBYTE)&dwIP);
31 | SendMessage(GetDlgItem(hWndDlg, IDC_LOGINSVR_IP), IPM_SETADDRESS, (WPARAM)0, (LPARAM)(DWORD)dwIP);
32 |
33 | jRegGetKey(_GAMEGATE_SERVER_REGISTRY, _TEXT("RemotePort"), (LPBYTE)&nPort);
34 | _itow(nPort, szPort, 10);
35 | SetWindowText(GetDlgItem(hWndDlg, IDC_LOGINSVR_PORT), szPort);
36 |
37 | jRegGetKey(_GAMEGATE_SERVER_REGISTRY, _TEXT("LocalPort"), (LPBYTE)&nPort);
38 | _itow(nPort, szPort, 10);
39 | SetWindowText(GetDlgItem(hWndDlg, IDC_LOCALPORT), szPort);
40 |
41 | break;
42 | }
43 | case WM_COMMAND:
44 | {
45 | switch (wParam)
46 | {
47 | case IDOK:
48 | {
49 | DWORD dwIP = 0;
50 | TCHAR szPort[24];
51 | int nRemotePort = 0, nLocalPort = 0;
52 | BYTE btInstalled = 1;
53 |
54 | jRegSetKey(_GAMEGATE_SERVER_REGISTRY, _TEXT("Installed"), REG_BINARY, (LPBYTE)&btInstalled, sizeof(BYTE));
55 |
56 | SendMessage(GetDlgItem(hWndDlg, IDC_LOGINSVR_IP), IPM_GETADDRESS, (WPARAM)0, (LPARAM)(LPDWORD)&dwIP);
57 |
58 | jRegSetKey(_GAMEGATE_SERVER_REGISTRY, _TEXT("RemoteIP"), REG_DWORD, (LPBYTE)&dwIP, sizeof(DWORD));
59 |
60 | GetWindowText(GetDlgItem(hWndDlg, IDC_LOGINSVR_PORT), szPort, sizeof(szPort));
61 | nRemotePort = _wtoi(szPort);
62 | GetWindowText(GetDlgItem(hWndDlg, IDC_LOCALPORT), szPort, sizeof(szPort));
63 | nLocalPort = _wtoi(szPort);
64 |
65 | jRegSetKey(_GAMEGATE_SERVER_REGISTRY, _TEXT("RemotePort"), REG_DWORD, (LPBYTE)&nRemotePort, sizeof(DWORD));
66 | jRegSetKey(_GAMEGATE_SERVER_REGISTRY, _TEXT("LocalPort"), REG_DWORD, (LPBYTE)&nLocalPort, sizeof(DWORD));
67 | }
68 | case IDCANCEL:
69 | return EndDialog(hWndDlg, IDCANCEL);
70 | }
71 | }
72 | }
73 |
74 | return FALSE;
75 | }
76 |
--------------------------------------------------------------------------------
/GameGate/GameGate.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameGate/GameGate.aps
--------------------------------------------------------------------------------
/GameGate/GameGate.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameGate/GameGate.cpp
--------------------------------------------------------------------------------
/GameGate/GameGate.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameGate/GameGate.h
--------------------------------------------------------------------------------
/GameGate/GameGate.ncb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameGate/GameGate.ncb
--------------------------------------------------------------------------------
/GameGate/GameGate.opt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameGate/GameGate.opt
--------------------------------------------------------------------------------
/GameGate/GameGate.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameGate/GameGate.rc
--------------------------------------------------------------------------------
/GameGate/GameGate.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {cf387721-f3f7-4535-981f-b571e8cd98ef}
6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat
7 |
8 |
9 | {dfd98762-0da0-498b-8ebf-162f377721f6}
10 | h;hpp;hxx;hm;inl
11 |
12 |
13 | {80d39402-0ce9-4cef-bbef-540bbcb30b23}
14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 | Source Files
35 |
36 |
37 | Source Files
38 |
39 |
40 | Source Files
41 |
42 |
43 | Source Files
44 |
45 |
46 | Source Files
47 |
48 |
49 | Source Files
50 |
51 |
52 | Source Files
53 |
54 |
55 | Source Files
56 |
57 |
58 | Source Files
59 |
60 |
61 |
62 |
63 | Source Files
64 |
65 |
66 |
67 |
68 | Header Files
69 |
70 |
71 | Header Files
72 |
73 |
74 | Header Files
75 |
76 |
77 | Header Files
78 |
79 |
80 | Header Files
81 |
82 |
83 | Header Files
84 |
85 |
86 | Header Files
87 |
88 |
89 | Header Files
90 |
91 |
92 | Header Files
93 |
94 |
95 | Header Files
96 |
97 |
98 | Header Files
99 |
100 |
101 |
102 |
103 | Resource Files
104 |
105 |
106 | Resource Files
107 |
108 |
109 | Resource Files
110 |
111 |
112 | Resource Files
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/GameGate/GameGate.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/GameGate/MainWndProc.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameGate/MainWndProc.cpp
--------------------------------------------------------------------------------
/GameGate/RES/MIR2.ICO:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameGate/RES/MIR2.ICO
--------------------------------------------------------------------------------
/GameGate/RES/TOOLBAR.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameGate/RES/TOOLBAR.BMP
--------------------------------------------------------------------------------
/GameGate/StdAfx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // GameGate.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/GameGate/StdAfx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
7 | #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
8 |
9 | #if _MSC_VER > 1000
10 | #pragma once
11 | #endif // _MSC_VER > 1000
12 |
13 | //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
14 | #define UNICODE
15 | #define _UNICODE
16 |
17 | #include
18 | #include
19 | #include
20 | #ifdef _DEBUG
21 | #include
22 | #endif
23 | #include
24 | #include
25 | #include
26 | #include
27 |
28 | #include "resource.h"
29 |
30 | class CItem;
31 | class CStdItem;
32 | class CStdItemSpecial;
33 | #include "..\Def\Queue.h"
34 | #include "..\Def\EnDecode.h"
35 | #include "..\Def\ServerSockHandler.h"
36 | #include "..\Def\Protocol.h"
37 | #include "..\Def\DynamicArray.h"
38 | #include "..\Def\Misc.h"
39 |
40 | #include "GameGate.h"
41 | #include "Abusive.h"
42 |
43 | #pragma comment (lib, "ws2_32.lib")
44 | #pragma comment (lib, "comctl32.lib")
45 |
46 | // **************************************************************************************
47 |
48 | #define _BMP_CX 16
49 | #define _BMP_CY 16
50 |
51 | #define _STATUS_HEIGHT 10
52 | #define _NUMOFMAX_STATUS_PARTS 6
53 |
54 | #define _GAMEGATE_SERVER_CLASS _TEXT("GameGateServerClass")
55 | #define _GAMEGATE_SERVER_TITLE _TEXT("Legend of Mir II - Game Gate Server")
56 | #define _GAMEGATE_SERVER_REGISTRY _TEXT("Software\\LegendOfMir\\GameGate")
57 |
58 | #define _IDM_SERVERSOCK_MSG WM_USER + 1000
59 | #define _IDM_CLIENTSOCK_MSG _IDM_SERVERSOCK_MSG + 1
60 |
61 | #define _IDW_TOOLBAR _IDM_SERVERSOCK_MSG + 2
62 | #define _IDW_STATUSBAR _IDM_SERVERSOCK_MSG + 3
63 |
64 | #define _ID_TIMER_KEEPALIVE _IDM_SERVERSOCK_MSG + 4
65 | #define _ID_TIMER_CONNECTSERVER _IDM_SERVERSOCK_MSG + 5
66 |
67 | //{{AFX_INSERT_LOCATION}}
68 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
69 |
70 | #endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
71 |
--------------------------------------------------------------------------------
/GameGate/ThreadFuncForComm.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameGate/ThreadFuncForComm.cpp
--------------------------------------------------------------------------------
/GameGate/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by GameGate.rc
4 | //
5 | #define IDS_NOTWINNT 1
6 | #define IDC_MYICON 2
7 | #define IDS_LVS_LABEL1 2
8 | #define IDS_LVS_LABEL2 3
9 | #define IDS_LVS_LABEL3 4
10 | #define IDS_STARTSERVICE 5
11 | #define IDS_STOPSERVICE 6
12 | #define IDS_CONNECT_LOGINSERVER 7
13 | #define IDS_DISCONNECT_LOGINSERVER 8
14 | #define IDS_PROGRAM_QUIT 9
15 | #define IDS_PROGRAM_TITLE 10
16 | #define IDS_CANT_CONNECT 11
17 | #define IDS_APPLY_RECONNECT 12
18 | #define IDS_LOAD_ABUSIVE 13
19 | #define IDS_LOADFAIL_ABUSIVE 14
20 | #define IDS_CONNECT_GAMESERVER 15
21 | #define IDS_DISCONNECT_GAMESERVER 16
22 | #define IDS_ENABLE_PORT 17
23 | #define IDS_CONNECT_GAMESERVER_TIMEOUT 18
24 | #define IDR_MAINMENU 101
25 | #define IDD_GAMEGATE_DIALOG 102
26 | #define IDI_MIR2 102
27 | #define IDD_ABOUTBOX 103
28 | #define IDS_APP_TITLE 103
29 | #define IDB_TOOLBAR 103
30 | #define IDM_ABOUT 104
31 | #define IDD_CONFIGDLG 104
32 | #define IDS_HELLO 106
33 | #define IDI_GAMEGATE 107
34 | #define IDI_SMALL 108
35 | #define IDC_GAMEGATE 109
36 | #define IDR_MAINFRAME 128
37 | #define IDC_LOGINSVR_IP 1003
38 | #define IDC_LOGINSVR_PORT 1004
39 | #define IDC_LOCALPORT 1005
40 | #define IDC_SERVERINDEX 1006
41 | #define IDM_STARTSERVICE 40001
42 | #define IDM_STOPSERVICE 40002
43 | #define IDM_CONFIG 40003
44 | #define IDM_EXIT 40004
45 | #define IDC_STATIC -1
46 |
47 | // Next default values for new objects
48 | //
49 | #ifdef APSTUDIO_INVOKED
50 | #ifndef APSTUDIO_READONLY_SYMBOLS
51 | #define _APS_NEXT_RESOURCE_VALUE 129
52 | #define _APS_NEXT_COMMAND_VALUE 32771
53 | #define _APS_NEXT_CONTROL_VALUE 1000
54 | #define _APS_NEXT_SYMED_VALUE 110
55 | #endif
56 | #endif
57 |
--------------------------------------------------------------------------------
/GameSvr/ConfigDlgFunc.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | BOOL jRegSetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, DWORD dwFlags, LPBYTE pValue, DWORD nValueSize);
4 | BOOL jRegGetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, LPBYTE pValue);
5 |
6 | BOOL CALLBACK ConfigDlgFunc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
7 | {
8 | switch (uMsg)
9 | {
10 | case WM_INITDIALOG:
11 | {
12 | RECT rcMainWnd, rcDlg;
13 |
14 | GetWindowRect(g_hMainWnd, &rcMainWnd);
15 | GetWindowRect(hWndDlg, &rcDlg);
16 |
17 | MoveWindow(hWndDlg, rcMainWnd.left + (((rcMainWnd.right - rcMainWnd.left) - (rcDlg.right - rcDlg.left)) / 2),
18 | rcMainWnd.top + (((rcMainWnd.bottom - rcMainWnd.top) - (rcDlg.bottom - rcDlg.top)) / 2),
19 | (rcDlg.right - rcDlg.left), (rcDlg.bottom - rcDlg.top), FALSE);
20 |
21 | SendMessage(GetDlgItem(hWndDlg, IDC_DBSRV_PORT), EM_LIMITTEXT, (WPARAM)5, (LPARAM)0L);
22 |
23 | DWORD dwIP = 0;
24 | TCHAR szPort[24];
25 | TCHAR szServer[24];
26 | TCHAR szPath[256];
27 | TCHAR szDatabase[256];
28 |
29 | int nPort = 0, nServerNum = 0;
30 |
31 | jRegGetKey(_GAME_SERVER_REGISTRY, _TEXT("DBServerIP"), (LPBYTE)&dwIP);
32 | SendMessage(GetDlgItem(hWndDlg, IDC_DBSVR_IP), IPM_SETADDRESS, (WPARAM)0, (LPARAM)(DWORD)dwIP);
33 |
34 | jRegGetKey(_GAME_SERVER_REGISTRY, _TEXT("DBServerPort"), (LPBYTE)&nPort);
35 | _itow(nPort, szPort, 10);
36 | SetWindowText(GetDlgItem(hWndDlg, IDC_DBSRV_PORT), szPort);
37 |
38 | jRegGetKey(_GAME_SERVER_REGISTRY, _TEXT("ServerNumber"), (LPBYTE)&nServerNum);
39 | _itow(nServerNum, szServer, 10);
40 | SetWindowText(GetDlgItem(hWndDlg, IDC_SRVNUMBER), szServer);
41 |
42 | jRegGetKey(_GAME_SERVER_REGISTRY, _TEXT("MapFileLoc"), (LPBYTE)szPath);
43 | SetWindowText(GetDlgItem(hWndDlg, IDC_MAPFILE_LOC), szPath);
44 |
45 | jRegGetKey(_GAME_SERVER_REGISTRY, _TEXT("Device"), (LPBYTE)szDatabase);
46 | SetWindowText(GetDlgItem(hWndDlg, IDC_DBMS_DEVICE), szDatabase);
47 |
48 | break;
49 | }
50 | case WM_COMMAND:
51 | {
52 | switch (wParam)
53 | {
54 | case IDOK:
55 | {
56 | DWORD dwIP = 0;
57 | TCHAR szPort[24];
58 | TCHAR szServer[24];
59 | TCHAR szPath[256];
60 | TCHAR szDatabase[256];
61 |
62 | int nRemotePort = 0, nServerNum = 0;
63 | BYTE btInstalled = 1;
64 |
65 | jRegSetKey(_GAME_SERVER_REGISTRY, _TEXT("Installed"), REG_BINARY, (LPBYTE)&btInstalled, sizeof(BYTE));
66 |
67 | GetWindowText(GetDlgItem(hWndDlg, IDC_SRVNUMBER), szServer, sizeof(szServer));
68 | nServerNum = _wtoi(szServer);
69 | jRegSetKey(_GAME_SERVER_REGISTRY, _TEXT("ServerNumber"), REG_DWORD, (LPBYTE)&nServerNum, sizeof(DWORD));
70 |
71 | SendMessage(GetDlgItem(hWndDlg, IDC_DBSVR_IP), IPM_GETADDRESS, (WPARAM)0, (LPARAM)(LPDWORD)&dwIP);
72 | jRegSetKey(_GAME_SERVER_REGISTRY, _TEXT("DBServerIP"), REG_DWORD, (LPBYTE)&dwIP, sizeof(DWORD));
73 |
74 | GetWindowText(GetDlgItem(hWndDlg, IDC_DBSRV_PORT), szPort, sizeof(szPort));
75 | nRemotePort = _wtoi(szPort);
76 | jRegSetKey(_GAME_SERVER_REGISTRY, _TEXT("DBServerPort"), REG_DWORD, (LPBYTE)&nRemotePort, sizeof(DWORD));
77 |
78 | GetWindowText(GetDlgItem(hWndDlg, IDC_MAPFILE_LOC), szPath, sizeof(szPath));
79 | jRegSetKey(_GAME_SERVER_REGISTRY, _TEXT("MapFileLoc"), REG_SZ, (LPBYTE)szPath, sizeof(szPath)/sizeof(TCHAR));
80 |
81 | GetWindowText(GetDlgItem(hWndDlg, IDC_DBMS_DEVICE), szDatabase, sizeof(szDatabase));
82 | jRegSetKey(_GAME_SERVER_REGISTRY, _TEXT("Device"), REG_SZ, (LPBYTE)szDatabase, sizeof(szDatabase)/sizeof(TCHAR));
83 |
84 | }
85 | case IDCANCEL:
86 | return EndDialog(hWndDlg, IDCANCEL);
87 | }
88 |
89 | break;
90 | }
91 | }
92 |
93 | return FALSE;
94 | }
95 |
--------------------------------------------------------------------------------
/GameSvr/DataHandler.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/DataHandler.h
--------------------------------------------------------------------------------
/GameSvr/FrontEngine.h:
--------------------------------------------------------------------------------
1 | class CReadyUserInfo
2 | {
3 | public:
4 | // char m_szUserID[10];
5 | // char m_szCharName[14];
6 | BOOL m_fStartNew;
7 | // int m_nCertification;
8 | // int m_nApprovalMode;
9 | // int m_nClientVersion;
10 |
11 | // SOCKET m_s;
12 |
13 | // int m_nUserGateIndex;
14 |
15 | // CGateInfo* m_pGateInfo;
16 | CUserInfo* m_pUserInfo;
17 |
18 | DWORD m_dwReadyStartTime;
19 | BOOL m_fClosed;
20 | };
21 |
22 | class CReadyUserInfo2
23 | {
24 | public:
25 | BOOL m_fStartNew;
26 | DWORD m_dwReadyStartTime;
27 |
28 | int m_nNumOfGenItem;
29 | int m_nNumOfItem;
30 | int m_nNumOfMagic;
31 |
32 | _THUMANRCD m_THumanRcd;
33 |
34 | char pszData[8096];
35 | };
36 |
37 | void LoadPlayer(CUserInfo* pUserInfo);
38 | BOOL LoadPlayer(CReadyUserInfo2* pReadyUserInfo, CUserInfo* pUserInfo);
39 |
--------------------------------------------------------------------------------
/GameSvr/GameSvr.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/GameSvr.aps
--------------------------------------------------------------------------------
/GameSvr/GameSvr.positions:
--------------------------------------------------------------------------------
1 | WndTabs Tab Positions File33C@ Workspace Output
--------------------------------------------------------------------------------
/GameSvr/GameSvr.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/GameSvr.rc
--------------------------------------------------------------------------------
/GameSvr/GameSvr.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/GameSvr/Global.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | extern HANDLE g_hIOCP; // Defined in /Def/ServerSockHandler.cpp
4 |
5 | extern HINSTANCE g_hInst;
6 | extern HWND g_hMainWnd;
7 | extern HWND g_hLogMsgWnd;
8 | extern HWND g_hToolBar;
9 |
10 | extern HWND g_hStatusBar;
11 | extern int g_nStatusPartsWidths[_NUMOFMAX_STATUS_PARTS];
12 |
13 | extern TBBUTTON tbButtons[5];
14 |
15 | extern CDatabase g_MirDB;
16 | extern CConnection *g_pConnCommon;
17 | extern CConnection *g_pConnGame;
18 |
19 | extern CWHList g_xAdminCommandList;
20 | extern CWHList g_xUserCommandList;
21 |
22 |
23 | extern CWHList g_xLoginOutUserInfo;
24 | extern CWHList g_xReadyList;
25 | extern CWHList g_xUserInfoList;
26 | extern CStaticArray g_xUserInfoArr;
27 | extern CStaticArray g_xPlayerObjectArr;
28 |
29 | extern CWHList g_xReadyUserInfoList;
30 | extern CWHList g_xReadyUserInfoList2;
31 |
32 | extern CWHList g_xEventList;
33 | extern CWHList g_xEventCloseList;
34 |
35 | extern CWHList g_xHolySeizeList;
36 |
37 | extern CWHList g_xMerchantObjList;
38 | extern BOOL g_fInitMerchant;
39 | extern CWHList g_xNPCObjList;
40 |
41 | extern CWHList g_xGateList;
42 |
43 | extern int g_nMirDayTime;
44 |
45 |
46 | // General Standard Data
47 | extern CWHList g_xMirMapList;
48 | extern CMoveMapEventInfo* g_pMoveMapEventInfo;
49 | extern int g_nNumOfMoveMapEventInfo;
50 | extern CMagicInfo* g_pMagicInfo;
51 | extern int g_nNumOfMagicInfo;
52 | extern CMonsterGenInfo* g_pMonGenInfo;
53 | extern int g_nNumOfMonGenInfo;
54 | extern CMonRaceInfo* g_pMonRaceInfo;
55 | extern int g_nNumOfMonRaceInfo;
56 | extern CStdItemSpecial* g_pStdItemSpecial;
57 | extern inline CStdItemSpecial * GetStdItemByIndex(WORD stdItemIndex );
58 | extern int g_nStdItemSpecial;
59 | extern CStdItem* g_pStdItemEtc;
60 | extern int g_nStdItemEtc;
61 | extern CMerchantInfo* g_pMerchantInfo;
62 | extern int g_nNumOfMurchantInfo;
63 | extern int g_nNumOfMapInfo;
64 |
65 | extern BOOL g_fTerminated;
66 |
67 | extern SOCKET g_ssock;
68 | extern SOCKADDR_IN g_saddr;
69 |
70 | extern SOCKET g_csock;
71 | extern SOCKADDR_IN g_caddr;
72 |
73 | extern SOCKET g_clsock;
74 | extern SOCKADDR_IN g_claddr;
75 |
76 | extern _TSEARCHTABLE g_SearchTable[_MAX_SEARCHTABLE];
77 |
78 | extern char g_szGoldName[8];
79 |
80 | extern DWORD NEEDEXPS[MAXLEVEL];
81 |
82 | extern HANDLE g_hThreadForComm;
83 | extern HANDLE g_hSvrMsgEvnt;
84 |
85 | extern CWHList g_xScripterList;
86 |
--------------------------------------------------------------------------------
/GameSvr/Handler_Item.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/Handler_Item.cpp
--------------------------------------------------------------------------------
/GameSvr/Handler_Magic.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | int CMagicInfo::GetPower13(int nPwr, int nLevel)
4 | {
5 | float p1, p2;
6 |
7 | p1 = (float)nPwr / 3;
8 | p2 = (float)nPwr - p1;
9 |
10 | if ((sDefMaxPower - sDefPower))
11 | return ROUND(p1 + p2 / (3/*MaxTrainLevel*/ + 1) * (nLevel + 1) + (sDefPower + rand() % (sDefMaxPower - sDefPower)));
12 | else
13 | return ROUND(p1 + p2 / (3/*MaxTrainLevel*/ + 1) * (nLevel + 1) + sDefPower);
14 | }
15 |
16 | BOOL CMagicInfo::CheckMagicLevelup(CCharObject *pCharObject, _LPTHUMANMAGICRCD lptMagicRcd)
17 | {
18 | int nLevel;
19 |
20 | if (lptMagicRcd->btLevel >= 0 && lptMagicRcd->btLevel <= 3/*MaxTrainLevel*/)
21 | nLevel = (int)lptMagicRcd->btLevel;
22 | else
23 | nLevel = 0;
24 |
25 | if (lptMagicRcd->btLevel < 3/*MaxTrainLevel*/)
26 | {
27 | if (lptMagicRcd->nCurrTrain >= sTrain[nLevel])
28 | {
29 | if (lptMagicRcd->btLevel < 3/*MaxTrainLevel*/)
30 | {
31 | lptMagicRcd->nCurrTrain -= sTrain[nLevel];
32 | lptMagicRcd->btLevel += 1;
33 |
34 | pCharObject->UpdateDelayProcessCheckParam1(pCharObject, RM_MAGIC_LVEXP, 0, lptMagicRcd->nCurrTrain, lptMagicRcd->btLevel, lptMagicRcd->btMagicID, NULL, 800);
35 | // CheckMagicSpecialAbility (pum);
36 | }
37 | else
38 | lptMagicRcd->nCurrTrain = sTrain[nLevel];
39 |
40 | return TRUE;
41 | }
42 | }
43 |
44 | return FALSE;
45 | }
46 |
--------------------------------------------------------------------------------
/GameSvr/ItemHandler.h:
--------------------------------------------------------------------------------
1 |
2 | #define _ITEM_WEAPON 0
3 | #define _ITEM_ARMOR 1
4 | #define _ITEM_ACCESSORY 2
5 | #define _ITEM_ETC 3
6 | #define _ITEM_GOLD 10
7 |
8 | class CMapItem
9 | {
10 | public:
11 | LONG pItem;
12 | char szName[41];
13 | WORD wLooks;
14 | BYTE btAniCount;
15 | int nCount;
16 | };
17 |
18 | class CItem
19 | {
20 | public:
21 | BYTE btType;
22 | BYTE btAniCount;
23 | WORD Index;
24 | char szName[20];
25 |
26 | WORD wStdMode;
27 | WORD wShape;
28 | WORD wWeight;
29 | WORD wDuraMax; // Val1
30 | DWORD dwLooks;
31 | DWORD wRSource; // Val2
32 |
33 | DWORD dwPrice;
34 | DWORD dwStock;
35 | public:
36 | int GetUpgrade(int nCount, int nRandom);
37 |
38 | virtual void GetStandardItem(_LPTCLIENTITEMRCD lpClientItemRcd) = 0;
39 | // virtual void UpgradeRandomItem(_LPTMAKEITEMRCD lpMakeItemRcd) = 0;
40 | virtual void GetUpgradeStdItem(_LPTCLIENTITEMRCD lpClientItemRcd, _LPTUSERITEMRCD lpUserItemRcd) = 0;
41 | };
42 |
43 | class CStdItem : public CItem
44 | {
45 | public:
46 | CStdItem() {};
47 |
48 | virtual void GetStandardItem(_LPTCLIENTITEMRCD lpClientItemRcd);
49 | // virtual void UpgradeRandomItem(_LPTMAKEITEMRCD lpMakeItemRcd) {};
50 | virtual void GetUpgradeStdItem(_LPTCLIENTITEMRCD lpClientItemRcd, _LPTUSERITEMRCD lpUserItemRcd) {};
51 | };
52 |
53 | class CStdItemSpecial : public CItem
54 | {
55 | public:
56 | //BYTE btType;
57 |
58 | //WORD wAniCount;
59 | //WORD wSource;
60 |
61 | WORD HP;
62 | WORD MP;
63 | BYTE AttackSpeed;
64 | BYTE Luck;
65 |
66 | BYTE wAC; // Defence
67 | BYTE wAC2; // Defence Max
68 | BYTE wMAC; // Magic Defence
69 | BYTE wMAC2; // Magic Defence Max
70 | BYTE wDC; // Attack
71 | BYTE wDC2; // Attack Max
72 | BYTE wMC; // Magic
73 | BYTE wMC2; // Magic Max
74 | BYTE wSC; //
75 | BYTE wSC2; // Max
76 |
77 | BYTE m_btWater;
78 | BYTE m_btWater2;
79 | BYTE m_btFire;
80 | BYTE m_btFire2;
81 | BYTE m_btWind;
82 | BYTE m_btWind2;
83 | BYTE m_btLight;
84 | BYTE m_btLight2;
85 | BYTE m_btEarth;
86 | BYTE m_btEarth2;
87 |
88 | WORD wNeed;
89 | WORD wNeedLevel;
90 |
91 | DWORD dwFeature;
92 | //char szPrefixName[20];
93 | public:
94 | CStdItemSpecial();
95 |
96 | void ApplyItemParameters(CObjectAddAbility *m_pAddAbility);
97 |
98 | void UpgradeRandomItem(BYTE* btValue, WORD &nDura, WORD &nDuraMax);//_LPTMAKEITEMRCD lpMakeItemRcd)
99 |
100 | virtual void GetStandardItem(_LPTCLIENTITEMRCD lpClientItemRcd);
101 | // virtual void UpgradeRandomItem(_LPTMAKEITEMRCD lpMakeItemRcd);
102 | virtual void GetUpgradeStdItem(_LPTCLIENTITEMRCD lpClientItemRcd, _LPTUSERITEMRCD lpUserItemRcd);
103 | };
104 |
--------------------------------------------------------------------------------
/GameSvr/MagicHandler.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/MagicHandler.h
--------------------------------------------------------------------------------
/GameSvr/MainWndProc.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/MainWndProc.cpp
--------------------------------------------------------------------------------
/GameSvr/ObjectEngine.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ObjectEngine.cpp
--------------------------------------------------------------------------------
/GameSvr/ObjectEngine.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ObjectEngine.h
--------------------------------------------------------------------------------
/GameSvr/ObjectEvent.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ObjectEvent.cpp
--------------------------------------------------------------------------------
/GameSvr/ObjectEvent.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ObjectEvent.h
--------------------------------------------------------------------------------
/GameSvr/ObjectMerchant.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | CMerchantObject::CMerchantObject() : CCharObject(NULL)
4 | {
5 | m_fHideMode = FALSE;
6 |
7 | m_dwRunTime = GetTickCount();
8 | m_dwSearchTime = GetTickCount();
9 |
10 | m_dwRunNextTick = 250;
11 | m_dwSearchTick = 2000 + rand() % 2000;
12 | }
13 |
14 | void CMerchantObject::RunRace()
15 | {
16 | if ((rand() % 40) == 0)
17 | TurnTo(rand() % 8);
18 | else if ((rand() % 50) == 0)
19 | AddRefMsg(RM_HIT, m_nDirection, m_nCurrX, m_nCurrY, 0, NULL);
20 | }
21 |
--------------------------------------------------------------------------------
/GameSvr/ObjectMonster.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ObjectMonster.cpp
--------------------------------------------------------------------------------
/GameSvr/ObjectMonster.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ObjectMonster.h
--------------------------------------------------------------------------------
/GameSvr/ObjectNPC.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | CNPCObject::CNPCObject() : CCharObject(NULL)
4 | {
5 | m_dwRunNextTick = 250;
6 | m_dwSearchTick = 3000;
7 |
8 | m_btLight = 6;
9 | }
10 |
--------------------------------------------------------------------------------
/GameSvr/ObjectNPC.h:
--------------------------------------------------------------------------------
1 |
2 | /*
3 | */
4 |
5 | class CNPCObject : public CCharObject
6 | {
7 | public:
8 | DWORD m_dwRunTime;
9 | DWORD m_dwRunNextTick;
10 |
11 | CNPCObject();
12 |
13 | virtual void GetCharName(char *pszCharName) { return; }
14 | };
15 |
16 | /*
17 | */
18 |
19 | class CMerchantObject : public CCharObject
20 | {
21 | public:
22 | DWORD m_dwRunTime;
23 | DWORD m_dwRunNextTick;
24 |
25 | int m_nIndex;
26 |
27 | CMerchantObject();
28 |
29 | void RunRace();
30 |
31 | virtual WORD GetThisCharColor() { return _CHAT_COLOR3; }
32 | virtual void GetCharName(char *pszCharName) { strcpy_s(pszCharName,sizeof(m_szName), m_szName); }
33 | };
34 |
--------------------------------------------------------------------------------
/GameSvr/ObjectPlayer.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ObjectPlayer.cpp
--------------------------------------------------------------------------------
/GameSvr/ObjectPlayer.h:
--------------------------------------------------------------------------------
1 |
2 |
3 | // ORZ:
4 | #include "../def/staticArray.h"
5 | #include "../def/_orzex/syncobj.h"
6 |
7 | class CPlayerObject : public CCharObject, public CIntLock, CStaticArray< CPlayerObject >::IArrayData
8 | {
9 | public:
10 | bool m_bEmpty;
11 | int m_nArrIndex;
12 | BOOL m_fIsAlive;
13 |
14 | BYTE m_btBright;
15 |
16 | BOOL m_fAdminMode;
17 |
18 | DWORD m_dwLastCryTime;
19 |
20 | CWHList m_xSlaveObjList;
21 |
22 | public:
23 | void Constructor();
24 | bool IsEmpty();
25 |
26 | CPlayerObject();
27 | CPlayerObject(CUserInfo* pUserInfo);
28 |
29 | void Initialize();
30 |
31 | virtual void Operate();
32 | BOOL DoRideHorse(int nDir, int fRideFlag);
33 |
34 | void MakeFeature();
35 |
36 | void HasLevelUp(int nPrevLevel);
37 |
38 | void WeightChanged();
39 |
40 | void RecalcHitSpeed();
41 | void RecalcAbilitys();
42 | void RecalcLevelAbilitys();
43 |
44 | void SendBagItems();
45 | void SendMyMagics();
46 |
47 | void SendMapName();
48 | void SendNewMap();
49 | void SendAddItem(_LPTUSERITEMRCD lpTItemRcd);
50 |
51 | BOOL EatItem(const GUID *pszMakeIndex);
52 | BOOL ReadBook(const GUID *pszMakeIndex);
53 | int GetMagicID(char *pszMakeIndex);
54 | BOOL ServerGetEatItem(int nItemIndex, const GUID *pszMakeIndex);
55 | BOOL PickUp();
56 |
57 | void Whisper(char *pszChar, char *pszMsg);
58 |
59 | int UpdateItemToDB(_LPTUSERITEMRCD lpMakeItemRcd, int nAction);
60 |
61 | BOOL CheckTakeOnItem(WORD wWhere, _LPTUSERITEMRCD lpTItemRcd);
62 | void ServerGetTakeOnGenItem(WORD wWhere, const GUID *pszItemIndex);
63 | void ServerGetTakeOnItem(WORD wWhere, const GUID *pszItemIndex);
64 | void ServerGetTakeOffItem(WORD wWhere, const GUID *pszItemIndex);
65 | void ServerGetButch(CCharObject* pCharObject, int nX, int nY, int nDir);
66 |
67 | void ServerGetMagicKeyChange(int nMagicID, int nUseKey);
68 |
69 | BYTE DayBright();
70 |
71 | int CalcGetExp(int nTagLevel, int nTagHP);
72 | void WinExp(int nExp);
73 | void GainExp(int nExp);
74 | void AddBodyLuck(double fLuck);
75 |
76 | BOOL ProcessForUserSaid(char *pszData);
77 |
78 | void TrainSkill(_LPTHUMANMAGICRCD lptMagicRcd, int nTrain);
79 | BOOL DoSpell(_LPTHUMANMAGICRCD lptMagicRcd, int TargetX, int TargetY, CCharObject* pTargetObject);
80 | BOOL SpellXY(int nKey, int nTargetX, int nTargetY, int nTargetObj);
81 |
82 | BOOL MakeSlave(int nMonRace, int nX, int nY, int nLevel, int nMax, DWORD dwRoyaltySec);
83 |
84 | virtual BOOL IsProperTarget(CCharObject* pCharObject);
85 |
86 | virtual void Run();
87 | virtual WORD GetThisCharColor();
88 | virtual void GetCharName(char *pszCharName);
89 |
90 | // For Administrator
91 | BOOL m_fIsCapture;
92 | FILE *m_hCaptureFile=NULL;
93 |
94 | protected:
95 | BOOL ProcessForAdminSaid(char *pszMsg);
96 |
97 | void CmdRandomSpaceMove(char *pszParam1);
98 | void CmdFreeSpaceMove(char *pszParam1, char *pszParam2, char *pszParam3);
99 | void CmdCallMakeMonster(char *pszParam1, char *pszParam2);
100 | void CmdCallMakeMonsterXY(char *pszParam1, char *pszParam2, char *pszParam3, char *pszParam4);
101 | void CmdMakeItem(char *pszParam1, char *pszParam2);
102 | void CmdDyeingHair(char *pszParam1);
103 | void CmdDyeingWear(char *pszParam1);
104 | void CmdHairStyle(char *pszParam1);
105 | BOOL CmdChangeJob(char *pszParam1);
106 | void CmdMakeFullSkill(char *pszParam1, char *pszParam2);
107 | void CmdSendMonsterLevelInfos();
108 | void CmdChangeItemPrefix(char *pszParam1, char *pszParam2);
109 | void CmdCallMakeSlaveMonster(char *pszParam1, char *pszParam2);
110 | };
111 |
--------------------------------------------------------------------------------
/GameSvr/ObjectPlayerAdminSaid.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ObjectPlayerAdminSaid.cpp
--------------------------------------------------------------------------------
/GameSvr/ObjectPlayerClone.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ObjectPlayerClone.cpp
--------------------------------------------------------------------------------
/GameSvr/ObjectPlayerClone.h:
--------------------------------------------------------------------------------
1 |
2 | class CPlayerCloneObject : public CPlayerObject
3 | {
4 | public:
5 | DWORD m_dwRunTime;
6 | DWORD m_dwRunNextTick;
7 |
8 | void Create(CPlayerObject* pPlayerObject);
9 |
10 | virtual void Operate();
11 | };
12 |
--------------------------------------------------------------------------------
/GameSvr/ObjectPlayerSaid.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | #define _MAX_USERCOMMAND_LIST (IDS_USERCMD_SABUKDOOR - IDS_USERCMD_NOWHISPER1 + 1)
4 |
5 | void CryCry(UINT wMsgType, CMirMap* pMap, int nX, int nY, int nWide, char *pszSaying);
6 |
7 | void InitUserCommandList()
8 | {
9 | TCHAR szCommand[64];
10 | int nLen;
11 | int i = 0;
12 | for (; i < _MAX_USERCOMMAND_LIST; i++)
13 | {
14 | LoadString(g_hInst, IDS_USERCMD_NOWHISPER1 + i, szCommand, sizeof(szCommand)/sizeof(TCHAR));
15 |
16 | nLen = lstrlen(szCommand) * sizeof(TCHAR) + 1;
17 |
18 | char *pszUserCommand = new char[nLen];
19 |
20 | if (pszUserCommand)
21 | {
22 | WideCharToMultiByte(CP_ACP, 0, szCommand, -1, pszUserCommand, nLen, NULL, NULL);
23 | g_xUserCommandList.AddNewNode(pszUserCommand);
24 | }
25 | }
26 |
27 | InsertLogMsgParam(IDS_LOAD_USERCOMMAND, &i, LOGPARAM_INT);
28 | }
29 |
30 | void UnInitUserCommandList()
31 | {
32 | PLISTNODE pListNode = g_xUserCommandList.GetHead();
33 |
34 | while (pListNode)
35 | {
36 | delete [] g_xUserCommandList.GetData(pListNode);
37 |
38 | pListNode = g_xUserCommandList.RemoveNode(pListNode);
39 | }
40 | }
41 |
42 | BOOL CPlayerObject::ProcessForUserSaid(char *pszData)
43 | {
44 | char szDecodeMsg[256];
45 | char szChatMsg[512];
46 |
47 | int nPos = fnDecode6BitBufA(pszData, szDecodeMsg, sizeof(szDecodeMsg));
48 |
49 | szDecodeMsg[nPos] = '\0';
50 |
51 | if (szDecodeMsg[0] == '@')
52 | {
53 | ProcessForAdminSaid(szDecodeMsg);
54 |
55 | return FALSE;
56 | }
57 | else
58 | {
59 | if (szDecodeMsg[0] == '!')
60 | {
61 | if (GetTickCount() - m_dwLastCryTime > 10 * 1000)
62 | {
63 | if (m_Ability.Level <= 7)
64 | {
65 | TCHAR wszMsg[128];
66 | char szMsg[128];
67 |
68 | LoadString(g_hInst, IDS_NOTENOUGHLEVEL_CRY, wszMsg, sizeof(wszMsg)/sizeof(TCHAR));
69 | WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, szMsg, sizeof(szMsg), NULL, NULL);
70 |
71 | SysMsg(szMsg, 1);
72 |
73 | return TRUE;
74 | }
75 | else
76 | {
77 | m_dwLastCryTime = GetTickCount();
78 |
79 | int nLen = memlen(m_pUserInfo->m_szCharName);
80 |
81 | memmove(szChatMsg, "(!)", 3);
82 | memmove(&szChatMsg[3], m_pUserInfo->m_szCharName, (nLen - 1));
83 | memmove(&szChatMsg[nLen - 1 + 3], " : ", 3);
84 | memmove(&szChatMsg[nLen + 2 + 3], &szDecodeMsg[1], memlen(&szDecodeMsg[1]));
85 |
86 | CryCry(RM_CRY, m_pMap, m_nCurrX, m_nCurrY, 50, szChatMsg);
87 |
88 | return TRUE;
89 | }
90 | }
91 | }
92 | else if (szDecodeMsg[0] == '/')
93 | {
94 | char *pszCharName = &szDecodeMsg[1];
95 |
96 | char *pszMsg = (char *)memchr(pszCharName, 0x20, memlen(pszCharName) - 1);
97 |
98 | if (pszMsg)
99 | {
100 | *pszMsg++ = '\0';
101 | Whisper(pszCharName, pszMsg);
102 |
103 | return TRUE;
104 | }
105 | }
106 | else
107 | {
108 | int nLen = memlen(m_szName);
109 |
110 | memmove(szChatMsg, m_szName, (nLen - 1));
111 | memmove(&szChatMsg[nLen - 1], " : ", 3);
112 | memmove(&szChatMsg[nLen + 2], szDecodeMsg, memlen(szDecodeMsg));
113 |
114 | AddRefMsg(RM_HEAR, 0, 0x0000, 0xFFFF, 0, szChatMsg);
115 |
116 | return TRUE;
117 | }
118 | }
119 |
120 | return FALSE;
121 | }
122 |
--------------------------------------------------------------------------------
/GameSvr/ObjectScripter.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ObjectScripter.cpp
--------------------------------------------------------------------------------
/GameSvr/ObjectScripter.h:
--------------------------------------------------------------------------------
1 |
2 | class CScripterObject : public CPlayerObject
3 | {
4 | protected:
5 | FILE* m_fScriptFile;
6 |
7 | public:
8 | DWORD m_dwRunTime;
9 | DWORD m_dwRunNextTick;
10 |
11 | void Create(int nX, int nY, CMirMap* pMap);
12 |
13 | virtual void Operate();
14 | };
15 |
--------------------------------------------------------------------------------
/GameSvr/ProcessEvents.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ProcessEvents.cpp
--------------------------------------------------------------------------------
/GameSvr/ProcessLogin.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ProcessLogin.cpp
--------------------------------------------------------------------------------
/GameSvr/ProcessMerchants.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | CMirMap* GetMap(char *pszMapName);
4 |
5 | /*
6 | void DoRunRace(CNPCObject* pNPCObject)
7 | {
8 | switch (pNPCObject->m_wObjectType)
9 | {
10 | case _OBJECT_NPC:
11 | ((CChickenObject*)pNPCObject)->RunRace();
12 | break;
13 | }
14 | }
15 | */
16 | void WINAPI ProcessMerchants()
17 | {
18 | DWORD dwCurrentTick;
19 |
20 | dwCurrentTick = GetTickCount();
21 |
22 | if (!g_fInitMerchant)
23 | {
24 | for (int i = 0; i < g_nNumOfMurchantInfo; i++)
25 | {
26 | CMirMap* pMap = GetMap(g_pMerchantInfo[i].szMapName);
27 |
28 | if (pMap)
29 | {
30 | CMerchantObject* pMerchantObject = new CMerchantObject;
31 |
32 | pMerchantObject->m_wObjectType = _OBJECT_NPC;
33 | pMerchantObject->m_nIndex = i;
34 |
35 | pMerchantObject->m_tFeature.btGender = 2;
36 | pMerchantObject->m_tFeature.btWear = (BYTE)g_pMerchantInfo[i].sBody;
37 |
38 | pMerchantObject->m_nCurrX = g_pMerchantInfo[i].nPosX;
39 | pMerchantObject->m_nCurrY = g_pMerchantInfo[i].nPosY;
40 | pMerchantObject->m_nDirection = g_pMerchantInfo[i].sFace;
41 | pMerchantObject->m_pMap = pMap;
42 |
43 | memcpy(pMerchantObject->m_szName, g_pMerchantInfo[i].szNPCName, memlen(g_pMerchantInfo[i].szNPCName));
44 |
45 | pMerchantObject->m_pMap->AddNewObject(pMerchantObject->m_nCurrX, pMerchantObject->m_nCurrY, OS_MOVINGOBJECT, pMerchantObject);
46 |
47 | // pMerchantObject->AddRefMsg(RM_TURN, pMerchantObject->m_nDirection, pMerchantObject->m_nCurrX, pMerchantObject->m_nCurrY, 0, pMerchantObject->m_szName);
48 |
49 | g_xMerchantObjList.AddNewNode(pMerchantObject);
50 | }
51 | }
52 |
53 | g_fInitMerchant = TRUE;
54 | }
55 |
56 | if (g_xMerchantObjList.GetCount())
57 | {
58 | PLISTNODE pListNode = g_xMerchantObjList.GetHead();
59 |
60 | while (pListNode)
61 | {
62 | CMerchantObject* pMerchantObject = g_xMerchantObjList.GetData(pListNode);
63 |
64 | if (dwCurrentTick - pMerchantObject->m_dwRunTime >= pMerchantObject->m_dwRunNextTick)
65 | {
66 | pMerchantObject->m_dwRunTime = dwCurrentTick;
67 |
68 | if (dwCurrentTick - pMerchantObject->m_dwSearchTime >= pMerchantObject->m_dwSearchTick)
69 | {
70 | pMerchantObject->m_dwSearchTime = dwCurrentTick;
71 | pMerchantObject->SearchViewRange();
72 | }
73 |
74 | // DoRunRace(pNPCObject);
75 | pMerchantObject->RunRace();
76 | }
77 |
78 | pListNode = g_xMerchantObjList.GetNext(pListNode);
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/GameSvr/ProcessMonster.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ProcessMonster.cpp
--------------------------------------------------------------------------------
/GameSvr/ProcessNPC.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/ProcessNPC.cpp
--------------------------------------------------------------------------------
/GameSvr/ProcessUserHuman.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | CPlayerObject* GetUserHuman(char *pszCharName)
4 | {
5 | if (g_xUserInfoList.GetCount())
6 | {
7 | PLISTNODE pListNode = g_xUserInfoList.GetHead();
8 |
9 | while (pListNode)
10 | {
11 | CUserInfo *pUserInfo = g_xUserInfoList.GetData(pListNode);
12 |
13 | if (pUserInfo)
14 | {
15 | if (pUserInfo->m_pxPlayerObject)
16 | {
17 | if (memcmp(pUserInfo->m_szCharName, pszCharName, memlen(pUserInfo->m_szCharName) - 1) == 0)
18 | {
19 | if (!pUserInfo->m_pxPlayerObject->m_fIsDead)
20 | return (CPlayerObject*)pUserInfo->m_pxPlayerObject;
21 | }
22 | }
23 | }
24 |
25 | pListNode = g_xUserInfoList.GetNext(pListNode);
26 | }
27 | }
28 |
29 | return NULL;
30 | }
31 |
32 | void CryCry(UINT wMsgType, CMirMap* pMap, int nX, int nY, int nWide, char *pszSaying)
33 | {
34 | if (g_xUserInfoList.GetCount())
35 | {
36 | PLISTNODE pListNode = g_xUserInfoList.GetHead();
37 |
38 | while (pListNode)
39 | {
40 | CUserInfo *pUserInfo = g_xUserInfoList.GetData(pListNode);
41 |
42 | if (pUserInfo)
43 | {
44 | if (pUserInfo->m_pxPlayerObject)
45 | {
46 | if ((pUserInfo->m_pxPlayerObject->m_pMap == pMap) && !pUserInfo->m_pxPlayerObject->m_fIsDead)
47 | {
48 | if ((abs(pUserInfo->m_pxPlayerObject->m_nCurrX - nX) < nWide) && (abs(pUserInfo->m_pxPlayerObject->m_nCurrY - nY) < nWide))
49 | pUserInfo->m_pxPlayerObject->AddProcess(NULL, wMsgType, 0, 0, 0, 0, pszSaying);
50 | }
51 | }
52 | }
53 |
54 | pListNode = g_xUserInfoList.GetNext(pListNode);
55 | }
56 | }
57 | }
58 |
59 | UINT WINAPI ProcessUserHuman(LPVOID lpParameter)
60 | {
61 | PLISTNODE pListNode = NULL;
62 |
63 | while (TRUE)
64 | {
65 | if (g_fTerminated)
66 | {
67 | if (g_xUserInfoList.GetCount())
68 | {
69 | pListNode = g_xUserInfoList.GetHead();
70 |
71 | while (pListNode)
72 | {
73 | CUserInfo *pUserInfo = g_xUserInfoList.GetData(pListNode);
74 |
75 | if (pUserInfo)
76 | pUserInfo->CloseUserHuman();
77 |
78 | pListNode = g_xUserInfoList.RemoveNode(pListNode);
79 | }
80 | }
81 |
82 | return 0L;
83 | }
84 |
85 | if (g_xUserInfoList.GetCount())
86 | {
87 | pListNode = g_xUserInfoList.GetHead();
88 |
89 | while (pListNode)
90 | {
91 | CUserInfo *pUserInfo = g_xUserInfoList.GetData(pListNode);
92 |
93 | if (pUserInfo)
94 | {
95 | if (pUserInfo->m_btCurrentMode == USERMODE_PLAYGAME)
96 | pUserInfo->Operate();
97 | }
98 |
99 | pListNode = g_xUserInfoList.GetNext(pListNode);
100 | } // while
101 | } // if g_xReadyUserInfoList.GetCount()
102 |
103 | if (g_xGateList.GetCount())
104 | {
105 | pListNode = g_xGateList.GetHead();
106 |
107 | while (pListNode)
108 | {
109 | CGateInfo *pGateInfo = g_xGateList.GetData(pListNode);
110 |
111 | if (pGateInfo)
112 | pGateInfo->xSend();
113 |
114 | pListNode = g_xUserInfoList.GetNext(pListNode);
115 | } // while
116 | }
117 |
118 | SleepEx(1, TRUE);
119 | }
120 |
121 | // return 0L;
122 | }
123 |
--------------------------------------------------------------------------------
/GameSvr/ProcessUserMsg.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | #define _MSG_GOOD "+GOOD/"
4 | #define _MSG_FAIL "+FAIL/"
5 |
--------------------------------------------------------------------------------
/GameSvr/Res/MIR2.ICO:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/Res/MIR2.ICO
--------------------------------------------------------------------------------
/GameSvr/Res/toolbar.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/Res/toolbar.bmp
--------------------------------------------------------------------------------
/GameSvr/SockMsg_DBSrv.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/SockMsg_DBSrv.cpp
--------------------------------------------------------------------------------
/GameSvr/SockMsg_GateComm.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/SockMsg_GateComm.cpp
--------------------------------------------------------------------------------
/GameSvr/SockMsg_LogSvr.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | BOOL jRegGetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, LPBYTE pValue);
4 |
5 | LPARAM OnLogSvrSockMsg(WPARAM wParam, LPARAM lParam)
6 | {
7 | switch (WSAGETSELECTEVENT(lParam))
8 | {
9 | case FD_CONNECT:
10 | {
11 | break;
12 | }
13 | case FD_CLOSE:
14 | {
15 | closesocket(g_clsock);
16 | g_clsock = INVALID_SOCKET;
17 |
18 | break;
19 | }
20 | case FD_READ:
21 | {
22 | char szPacket[1024];
23 |
24 | int nRecv = recv((SOCKET)wParam, szPacket, sizeof(szPacket), 0);
25 |
26 | szPacket[nRecv] = '\0';
27 |
28 | break;
29 | }
30 | }
31 |
32 | return 0L;
33 | }
34 |
--------------------------------------------------------------------------------
/GameSvr/StdAfx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // GameSvr.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/GameSvr/StdAfx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
7 | #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
8 |
9 | #if _MSC_VER > 1000
10 | #pragma once
11 | #endif // _MSC_VER > 1000
12 |
13 | //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
14 | #define UNICODE
15 | #define _UNICODE
16 |
17 | #include
18 | #include
19 | #include
20 | #ifdef _DEBUG
21 | #include
22 | #endif
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 |
29 | #include "resource.h"
30 | #include "..\AdminCmd\resource.h"
31 |
32 | #define ROUND(f) (int)(f + 0.5)
33 | #define _MAX(i, j) (i > j ? i : j)
34 | #define _MIN(i, j) (i > j ? j : i)
35 |
36 | // **************************************************************************************
37 |
38 | #define _STATUS_HEIGHT 10
39 | #define _NUMOFMAX_STATUS_PARTS 6
40 |
41 | #define MAXLEVEL 51
42 |
43 | #define _GAME_SERVER_CLASS _TEXT("MirGameServerClass")
44 | #define _GAME_SERVER_TITLE _TEXT("Game Server - Legend of Mir II")
45 | #define _GAME_SERVER_REGISTRY _TEXT("Software\\LegendOfMir\\GameServer")
46 |
47 | #define _IDM_SERVERSOCK_MSG WM_USER + 1000
48 | #define _IDM_CLIENTSOCK_MSG _IDM_SERVERSOCK_MSG + 1
49 | #define _IDM_LOGSVRSOCK_MSG _IDM_SERVERSOCK_MSG + 2
50 |
51 | #define _IDW_TOOLBAR _IDM_SERVERSOCK_MSG + 3
52 | #define _IDW_STATUSBAR _IDM_SERVERSOCK_MSG + 4
53 |
54 | #define _ID_TIMER_CONNECTSERVER _IDM_SERVERSOCK_MSG + 5
55 | #define _ID_TIMER_PROCESSUSERHUMAN _IDM_SERVERSOCK_MSG + 6
56 |
57 | typedef struct tag_TSEARCHTABLE
58 | {
59 | char x;
60 | char y;
61 | } _TSEARCHTABLE, *_LPTSEARCHTABLE;
62 |
63 | #define _MAX_SEARCHTABLE 960
64 |
65 | #define _ITEM_ACTION_CREATE 1
66 | #define _ITEM_ACTION_THROW 2
67 | #define _ITEM_ACTION_PICKUP 3
68 | #define _ITEM_ACTION_UPDATE 4
69 |
70 | // **************************************************************************************
71 | class CItem;
72 | class CStdItem;
73 | class CStdItemSpecial;
74 | #include "..\Def\EnDecode.h"
75 | #include "..\Def\Protocol.h"
76 | #include "..\Def\ServerSockHandler.h"
77 | #include "..\Def\Queue.h"
78 | #include "..\Def\List.h"
79 | #include "..\Def\StaticArray.h"
80 | #include "..\Def\Misc.h"
81 |
82 | #include "..\Def\_orzEx/database.h"
83 | #include "..\Def\_orzEx/syncobj.h"
84 | #include "..\Def\_orzEx/list.h"
85 |
86 | class CCharObject;
87 | class CAnimalObject;
88 | class CObjectAddAbility;
89 | class CEvent;
90 |
91 | class CMonRaceInfo;
92 |
93 | #include "MagicHandler.h"
94 | #include "ItemHandler.h"
95 | #include "ObjectEngine.h"
96 | #include "ObjectPlayer.h"
97 | #include "ObjectScripter.h"
98 | #include "ObjectPlayerClone.h"
99 | #include "ObjectNPC.h"
100 | #include "ObjectMonster.h"
101 | #include "Tables.h"
102 | #include "DataHandler.h"
103 | #include "GameSvr.h"
104 | #include "FrontEngine.h"
105 | #include "ObjectEvent.h"
106 |
107 | #include "global.h"
108 |
109 | #pragma comment (lib, "ws2_32.lib")
110 | #pragma comment (lib, "comctl32.lib")
111 |
112 | //{{AFX_INSERT_LOCATION}}
113 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
114 |
115 | #endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
116 |
--------------------------------------------------------------------------------
/GameSvr/Tables.h:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | class CMonItem
5 | {
6 | public:
7 | int m_nPoint;
8 | BYTE m_btItemType;
9 | WORD m_wItemIndex;
10 | WORD m_wCount;
11 | };
12 |
13 | class CMonRaceInfo
14 | {
15 | public:
16 | int nIndex;
17 |
18 | char szMonName[14];
19 | int nMonRace;
20 | int nAppear;
21 |
22 | BYTE btUndead;
23 |
24 | BYTE Level;
25 |
26 | WORD HP;
27 | WORD MP;
28 |
29 | WORD AC;
30 | WORD MAC;
31 | WORD DC;
32 | WORD MC;
33 |
34 | DWORD dwAttackSpeed;
35 | DWORD dwWalkSpeed;
36 |
37 | BYTE ViewRange;
38 |
39 | WORD Speed;
40 | WORD Hit;
41 |
42 | WORD wRaceIndex;
43 |
44 | WORD Exp;
45 |
46 | WORD wEscape;
47 |
48 | WORD m_wWater;
49 | WORD m_wFire;
50 | WORD m_wWind;
51 | WORD m_wLight;
52 | WORD m_wEarth;
53 |
54 | CWHList m_xMonItemList;
55 | };
56 |
57 | class CMonsterGenInfo
58 | {
59 | public:
60 | char szMapName[14];
61 |
62 | int nX;
63 | int nY;
64 |
65 | char szMonName[14];
66 | int nMonIndex;
67 |
68 | int nAreaX;
69 | int nAreaY;
70 | int nCount;
71 |
72 | DWORD dwZenTime;
73 | DWORD dwStartTime;
74 |
75 | CWHList xMonsterObjList; // MonList
76 |
77 | int nSmallZenRate;
78 | };
79 |
80 | typedef struct tag_TMONSTER
81 | {
82 | char szName[14];
83 |
84 | BYTE btRace;
85 | BYTE btRaceImg;
86 | WORD wAppr;
87 | BYTE btLevel;
88 | BYTE btLifeAttrib;
89 | WORD wExp;
90 | WORD wHP;
91 | BYTE btAC;
92 | BYTE btMAC;
93 | BYTE btDC;
94 | BYTE btMaxDC;
95 | BYTE btMC;
96 | BYTE btSC;
97 | BYTE btSpeed;
98 | BYTE btHit;
99 | WORD wWalkSpeed;
100 | WORD wAttackSpeed;
101 | //Item List
102 | } _TMONSTER, *_LPTMONSTER;
103 |
104 | class CMapInfo
105 | {
106 | public:
107 | char szMapFileName[14];
108 | char szMapName[40];
109 | DWORD dwAttribute;
110 |
111 | BYTE btMapSeries;
112 | BYTE btMapSeriesValue;
113 |
114 | USHORT mMiniMap;
115 | };
116 |
117 | class CMoveMapEventInfo
118 | {
119 | public:
120 | char szSMapFileName[14];
121 | int nSX;
122 | int nSY;
123 | char szDMapFileName[14];
124 | int nDX;
125 | int nDY;
126 |
127 | BOOL fIsOpen;
128 | };
129 |
130 | class CMerchantInfo
131 | {
132 | public:
133 | char szMapName[14];
134 | int nPosX;
135 | int nPosY;
136 | char szNPCName[40];
137 | short sFace;
138 | short sBody;
139 | short sGender;
140 | };
141 |
--------------------------------------------------------------------------------
/GameSvr/ThreadFuncForComm.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | BOOL jRegGetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, LPBYTE pValue);
4 |
5 | VOID WINAPI OnTimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
6 | {
7 | switch (idEvent)
8 | {
9 | case _ID_TIMER_CONNECTSERVER:
10 | {
11 | if (g_csock == INVALID_SOCKET)
12 | {
13 | DWORD dwIP = 0;
14 | int nPort = 0;
15 | TCHAR szPort[24];
16 |
17 | InsertLogMsg(IDS_APPLY_RECONNECT);
18 |
19 | jRegGetKey(_GAME_SERVER_REGISTRY, _TEXT("DBServerIP"), (LPBYTE)&dwIP);
20 | jRegGetKey(_GAME_SERVER_REGISTRY, _TEXT("DBServerPort"), (LPBYTE)&nPort);
21 | _itow(nPort, szPort, 10);
22 |
23 | ConnectToServer(g_csock, &g_caddr, _IDM_CLIENTSOCK_MSG, NULL, dwIP, nPort, FD_CONNECT|FD_READ|FD_CLOSE);
24 | }
25 |
26 | break;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/GameSvr/UserInfo.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/UserInfo.cpp
--------------------------------------------------------------------------------
/GameSvr/map/4.map:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/GameSvr/map/4.map
--------------------------------------------------------------------------------
/LegendOfMir2_Server.ncb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LegendOfMir2_Server.ncb
--------------------------------------------------------------------------------
/LegendOfMir2_Server.opt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LegendOfMir2_Server.opt
--------------------------------------------------------------------------------
/LegendOfMir2_Server.positions:
--------------------------------------------------------------------------------
1 | WndTabs Tab Positions File33C@ Workspace Output C:\...\SockMsg_GateComm.cpp C:\...\GameSvr\GateInfo.cpp C:\...\GameSvr\GameSvr.h
--------------------------------------------------------------------------------
/LegendOfMir2_Server.sdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LegendOfMir2_Server.sdf
--------------------------------------------------------------------------------
/LegendOfMir2_Server.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LegendOfMir2_Server.suo
--------------------------------------------------------------------------------
/LegendOfMir2_Server.v12.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LegendOfMir2_Server.v12.suo
--------------------------------------------------------------------------------
/LoginGate/ClientSockMsg.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | DWORD WINAPI ThreadFuncForMsg(LPVOID lpParameter);
4 |
5 | BOOL CheckSocketError(LPARAM lParam);
6 |
7 | VOID WINAPI OnTimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
8 |
9 | void OnCommand(WPARAM wParam, LPARAM lParam);
10 | BOOL InitThread(LPTHREAD_START_ROUTINE lpRoutine);
11 |
12 | extern SOCKET g_csock;
13 |
14 | extern HWND g_hMainWnd;
15 | extern HWND g_hStatusBar;
16 | extern HWND g_hToolBar;
17 |
18 | HANDLE g_hMsgThread = INVALID_HANDLE_VALUE;
19 |
20 | CWHQueue g_xMsgQueue;
21 |
22 | static char WorkBuff[8192];
23 | static int nWorkBuffLen;
24 |
25 | LPARAM OnClientSockMsg(WPARAM wParam, LPARAM lParam)
26 | {
27 | switch (WSAGETSELECTEVENT(lParam))
28 | {
29 | case FD_CONNECT:
30 | {
31 | DWORD dwThreadIDForMsg = 0;
32 |
33 | if (CheckSocketError(lParam))
34 | {
35 | dwThreadIDForMsg = 0;
36 |
37 | if (InitThread(ThreadFuncForMsg))
38 | {
39 | KillTimer(g_hMainWnd, _ID_TIMER_CONNECTSERVER);
40 |
41 | SetTimer(g_hMainWnd, _ID_TIMER_KEEPALIVE, 5000, (TIMERPROC)OnTimerProc);
42 |
43 | InsertLogMsg(IDS_CONNECT_LOGINSERVER);
44 | SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(1, 0), (LPARAM)_TEXT("Connected"));
45 | }
46 | }
47 | else
48 | {
49 | closesocket(g_csock);
50 | g_csock = INVALID_SOCKET;
51 |
52 | SetTimer(g_hMainWnd, _ID_TIMER_CONNECTSERVER, 10000, (TIMERPROC)OnTimerProc);
53 | }
54 |
55 | break;
56 | }
57 | case FD_CLOSE:
58 | {
59 | closesocket(g_csock);
60 | g_csock = INVALID_SOCKET;
61 |
62 | OnCommand(IDM_STOPSERVICE, 0);
63 |
64 | break;
65 | }
66 | case FD_READ:
67 | {
68 | int nSocket = 0;
69 | char *pszFirst = NULL, *pszEnd = NULL;
70 |
71 | UINT nRecv = 0;
72 |
73 | ioctlsocket((SOCKET)wParam, FIONREAD, (u_long *)&nRecv);
74 |
75 | if (nRecv)
76 | {
77 | char *pszPacket = new char[nRecv + 1];
78 |
79 | nRecv = recv((SOCKET)wParam, pszPacket, nRecv, 0);
80 |
81 | pszPacket[nRecv] = '\0';
82 |
83 | if (!(g_xMsgQueue.PushQ((BYTE *)pszPacket)))
84 | InsertLogMsg(_TEXT("[INFO] Not enough queue(g_xMsgQueue) buffer."));
85 | }
86 |
87 | break;
88 | }
89 | }
90 |
91 | return 0L;
92 | }
93 |
94 | void SendExToServer(char *pszPacket)
95 | {
96 | DWORD dwSendBytes;
97 | WSABUF buf;
98 |
99 | buf.len = memlen(pszPacket) - 1;
100 | buf.buf = pszPacket;
101 |
102 | if ( WSASend(g_csock, &buf, 1, &dwSendBytes, 0, NULL, NULL) == SOCKET_ERROR )
103 | {
104 | int nErr = WSAGetLastError();
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/LoginGate/ConfigDlgFunc.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | BOOL jRegSetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, DWORD dwFlags, LPBYTE pValue, DWORD nValueSize);
4 | BOOL jRegGetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, LPBYTE pValue);
5 |
6 | extern HWND g_hMainWnd;
7 |
8 | BOOL CALLBACK ConfigDlgFunc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
9 | {
10 | switch (uMsg)
11 | {
12 | case WM_INITDIALOG:
13 | {
14 | RECT rcMainWnd, rcDlg;
15 |
16 | GetWindowRect(g_hMainWnd, &rcMainWnd);
17 | GetWindowRect(hWndDlg, &rcDlg);
18 |
19 | MoveWindow(hWndDlg, rcMainWnd.left + (((rcMainWnd.right - rcMainWnd.left) - (rcDlg.right - rcDlg.left)) / 2),
20 | rcMainWnd.top + (((rcMainWnd.bottom - rcMainWnd.top) - (rcDlg.bottom - rcDlg.top)) / 2),
21 | (rcDlg.right - rcDlg.left), (rcDlg.bottom - rcDlg.top), FALSE);
22 |
23 | SendMessage(GetDlgItem(hWndDlg, IDC_LOGINSVR_PORT), EM_LIMITTEXT, (WPARAM)5, (LPARAM)0L);
24 | SendMessage(GetDlgItem(hWndDlg, IDC_LOCALPORT), EM_LIMITTEXT, (WPARAM)5, (LPARAM)0L);
25 |
26 | DWORD dwIP = 0;
27 | TCHAR szPort[24];
28 | int nPort = 0;
29 |
30 | jRegGetKey(_LOGINGATE_SERVER_REGISTRY, _TEXT("RemoteIP"), (LPBYTE)&dwIP);
31 | SendMessage(GetDlgItem(hWndDlg, IDC_LOGINSVR_IP), IPM_SETADDRESS, (WPARAM)0, (LPARAM)(DWORD)dwIP);
32 |
33 | jRegGetKey(_LOGINGATE_SERVER_REGISTRY, _TEXT("RemotePort"), (LPBYTE)&nPort);
34 | _itow(nPort, szPort, 10);
35 | SetWindowText(GetDlgItem(hWndDlg, IDC_LOGINSVR_PORT), szPort);
36 |
37 | jRegGetKey(_LOGINGATE_SERVER_REGISTRY, _TEXT("LocalPort"), (LPBYTE)&nPort);
38 | _itow(nPort, szPort, 10);
39 | SetWindowText(GetDlgItem(hWndDlg, IDC_LOCALPORT), szPort);
40 |
41 | break;
42 | }
43 | case WM_COMMAND:
44 | {
45 | switch (wParam)
46 | {
47 | case IDOK:
48 | {
49 | DWORD dwIP = 0;
50 | TCHAR szPort[24];
51 | int nRemotePort = 0, nLocalPort = 0;
52 | BYTE btInstalled = 1;
53 |
54 | jRegSetKey(_LOGINGATE_SERVER_REGISTRY, _TEXT("Installed"), REG_BINARY, (LPBYTE)&btInstalled, sizeof(BYTE));
55 |
56 | SendMessage(GetDlgItem(hWndDlg, IDC_LOGINSVR_IP), IPM_GETADDRESS, (WPARAM)0, (LPARAM)(LPDWORD)&dwIP);
57 |
58 | jRegSetKey(_LOGINGATE_SERVER_REGISTRY, _TEXT("RemoteIP"), REG_DWORD, (LPBYTE)&dwIP, sizeof(DWORD));
59 |
60 | GetWindowText(GetDlgItem(hWndDlg, IDC_LOGINSVR_PORT), szPort, sizeof(szPort));
61 | nRemotePort = _wtoi(szPort);
62 | GetWindowText(GetDlgItem(hWndDlg, IDC_LOCALPORT), szPort, sizeof(szPort));
63 | nLocalPort = _wtoi(szPort);
64 |
65 | jRegSetKey(_LOGINGATE_SERVER_REGISTRY, _TEXT("RemotePort"), REG_DWORD, (LPBYTE)&nRemotePort, sizeof(DWORD));
66 | jRegSetKey(_LOGINGATE_SERVER_REGISTRY, _TEXT("LocalPort"), REG_DWORD, (LPBYTE)&nLocalPort, sizeof(DWORD));
67 | }
68 | case IDCANCEL:
69 | return EndDialog(hWndDlg, IDCANCEL);
70 | }
71 | }
72 | }
73 |
74 | return FALSE;
75 | }
76 |
--------------------------------------------------------------------------------
/LoginGate/IOCPFunc.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | // **************************************************************************************
4 | //
5 | //
6 | //
7 | // **************************************************************************************
8 |
9 | BOOL CheckAvailableIOCP()
10 | {
11 | OSVERSIONINFO VersionInfo;
12 |
13 | GetVersionEx(&VersionInfo);
14 |
15 | if (VersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && VersionInfo.dwMajorVersion >= 5)
16 | return TRUE;
17 |
18 | return FALSE;
19 | }
20 |
21 | // **************************************************************************************
22 | //
23 | //
24 | //
25 | // **************************************************************************************
26 | /*
27 | INT CreateIOCPWorkerThread(HANDLE hCP, LPDWORD lpdwThreadID, LPTHREAD_START_ROUTINE WorkerThreadFunc)
28 | {
29 | if (CompletionPort != INVALID_HANDLE_VALUE)
30 | {
31 | SYSTEM_INFO SystemInfo;
32 |
33 | if ((hCP = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0)) == NULL)
34 | return -1;
35 |
36 | GetSystemInfo(&SystemInfo);
37 |
38 | for (UINT i = 0; i < SystemInfo.dwNumberOfProcessors * 2; i++)
39 | {
40 | HANDLE ThreadHandle;
41 |
42 | if ((ThreadHandle = CreateThread(NULL, 0, WorkerThreadFunc, hCP, 0, lpdwThreadID)) == NULL)
43 | return -1;
44 |
45 | CloseHandle(ThreadHandle);
46 | }
47 |
48 | return SystemInfo.dwNumberOfProcessors * 2;
49 | }
50 |
51 | return -1;
52 | }
53 | */
--------------------------------------------------------------------------------
/LoginGate/IOCPFunc.h:
--------------------------------------------------------------------------------
1 | BOOL CheckAvailableIOCP();
2 | INT CreateIOCPWorkerThread(HANDLE hCP, LPDWORD lpdwThreadID, LPTHREAD_START_ROUTINE WorkerThreadFunc);
3 |
4 |
5 |
--------------------------------------------------------------------------------
/LoginGate/LoginGate.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginGate/LoginGate.aps
--------------------------------------------------------------------------------
/LoginGate/LoginGate.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginGate/LoginGate.h
--------------------------------------------------------------------------------
/LoginGate/LoginGate.ncb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginGate/LoginGate.ncb
--------------------------------------------------------------------------------
/LoginGate/LoginGate.opt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginGate/LoginGate.opt
--------------------------------------------------------------------------------
/LoginGate/LoginGate.plg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Build Log
5 |
6 | --------------------Configuration: LoginGate - Win32 Debug--------------------
7 |
8 | Command Lines
9 | Creating command line "rc.exe /l 0x412 /fo"../_Obj_Debug/LoginGate/LoginGate.res" /d "_DEBUG" "C:\Works.Wemade\LegendOfMir2_Server\LoginGate\LoginGate.rc""
10 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP9D.tmp" with contents
11 | [
12 | /nologo /MDd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FR"../_Obj_Debug/LoginGate/" /Fp"../_Obj_Debug/LoginGate/LoginGate.pch" /Yu"stdafx.h" /Fo"../_Obj_Debug/LoginGate/" /Fd"../_Obj_Debug/LoginGate/" /FD /GZ /c
13 | "C:\Works.Wemade\LegendOfMir2_Server\LoginGate\ClientSockMsg.cpp"
14 | "C:\Works.Wemade\LegendOfMir2_Server\LoginGate\ConfigDlgFunc.cpp"
15 | "C:\Works.Wemade\LegendOfMir2_Server\LoginGate\LoginGate.cpp"
16 | "C:\Works.Wemade\LegendOfMir2_Server\LoginGate\MainWndProc.cpp"
17 | "C:\Works.Wemade\LegendOfMir2_Server\Def\Misc.cpp"
18 | "C:\Works.Wemade\LegendOfMir2_Server\Def\RegstryHandler.cpp"
19 | "C:\Works.Wemade\LegendOfMir2_Server\Def\ServerSockHandler.cpp"
20 | "C:\Works.Wemade\LegendOfMir2_Server\LoginGate\ServerSockMsg.cpp"
21 | "C:\Works.Wemade\LegendOfMir2_Server\Def\_OrzEx\syncobj.cpp"
22 | "C:\Works.Wemade\LegendOfMir2_Server\LoginGate\ThreadFuncForComm.cpp"
23 | "C:\Works.Wemade\LegendOfMir2_Server\LoginGate\ThreadFuncForMsg.cpp"
24 | ]
25 | Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP9D.tmp"
26 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP9E.tmp" with contents
27 | [
28 | /nologo /MDd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FR"../_Obj_Debug/LoginGate/" /Fp"../_Obj_Debug/LoginGate/LoginGate.pch" /Yc"stdafx.h" /Fo"../_Obj_Debug/LoginGate/" /Fd"../_Obj_Debug/LoginGate/" /FD /GZ /c
29 | "C:\Works.Wemade\LegendOfMir2_Server\LoginGate\StdAfx.cpp"
30 | ]
31 | Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP9E.tmp"
32 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP9F.tmp" with contents
33 | [
34 | kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:yes /pdb:"../_Bin/Debug/LoginGate.pdb" /debug /machine:I386 /out:"../_Bin/Debug/LoginGate.exe" /pdbtype:sept
35 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\ClientSockMsg.obj
36 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\ConfigDlgFunc.obj
37 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\LoginGate.obj
38 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\MainWndProc.obj
39 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\Misc.obj
40 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\RegstryHandler.obj
41 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\ServerSockHandler.obj
42 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\ServerSockMsg.obj
43 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\StdAfx.obj
44 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\syncobj.obj
45 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\ThreadFuncForComm.obj
46 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\ThreadFuncForMsg.obj
47 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\LoginGate\LoginGate.res
48 | ]
49 | Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP9F.tmp"
50 | Output Window
51 | Compiling resources...
52 | Compiling...
53 | StdAfx.cpp
54 | Compiling...
55 | ClientSockMsg.cpp
56 | ConfigDlgFunc.cpp
57 | LoginGate.cpp
58 | MainWndProc.cpp
59 | Misc.cpp
60 | RegstryHandler.cpp
61 | ServerSockHandler.cpp
62 | ServerSockMsg.cpp
63 | syncobj.cpp
64 | ThreadFuncForComm.cpp
65 | ThreadFuncForMsg.cpp
66 | Generating Code...
67 | Linking...
68 |
69 |
70 |
71 | Results
72 | LoginGate.exe - 0 error(s), 0 warning(s)
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/LoginGate/LoginGate.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginGate/LoginGate.rc
--------------------------------------------------------------------------------
/LoginGate/LoginGate.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {2c86f732-e187-451e-8629-031d6b98bff3}
6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat
7 |
8 |
9 | {04d4aa4b-6225-4eb7-89d7-70a1b38cac18}
10 | h;hpp;hxx;hm;inl
11 |
12 |
13 | {bbe89878-6feb-44ea-961e-d18f9ec8ee44}
14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 | Source Files
35 |
36 |
37 | Source Files
38 |
39 |
40 | Source Files
41 |
42 |
43 | Source Files
44 |
45 |
46 | Source Files
47 |
48 |
49 | Source Files
50 |
51 |
52 | Source Files
53 |
54 |
55 |
56 |
57 | Source Files
58 |
59 |
60 |
61 |
62 | Header Files
63 |
64 |
65 | Header Files
66 |
67 |
68 | Header Files
69 |
70 |
71 | Header Files
72 |
73 |
74 | Header Files
75 |
76 |
77 | Header Files
78 |
79 |
80 | Header Files
81 |
82 |
83 |
84 |
85 | Resource Files
86 |
87 |
88 | Resource Files
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/LoginGate/LoginGate.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/LoginGate/RESOURCE.H:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Developer Studio generated include file.
3 | // Used by LoginGate.rc
4 | //
5 | #define IDS_NOTWINNT 1
6 | #define IDS_LVS_LABEL1 2
7 | #define IDS_LVS_LABEL2 3
8 | #define IDS_LVS_LABEL3 4
9 | #define IDS_STARTSERVICE 5
10 | #define IDS_STOPSERVICE 6
11 | #define IDS_CONNECT_LOGINSERVER 7
12 | #define IDS_DISCONNECT_LOGINSERVER 8
13 | #define IDS_PROGRAM_QUIT 9
14 | #define IDS_PROGRAM_TITLE 10
15 | #define IDS_CANT_CONNECT 11
16 | #define IDS_APPLY_RECONNECT 12
17 | #define IDR_MAINMENU 101
18 | #define IDM_FONTCOLOR 101
19 | #define IDI_MIR2 102
20 | #define IDM_BACKCOLOR 102
21 | #define IDB_TOOLBAR 103
22 | #define IDD_CONFIGDLG 104
23 | #define IDC_LOGINSVR_IP 1003
24 | #define IDC_LOGINSVR_PORT 1004
25 | #define IDC_LOCALPORT 1005
26 | #define IDC_EDIT1 1006
27 | #define IDM_STARTSERVICE 40001
28 | #define IDM_STOPSERVICE 40002
29 | #define IDM_CONFIG 40003
30 | #define IDM_EXIT 40004
31 |
32 | // Next default values for new objects
33 | //
34 | #ifdef APSTUDIO_INVOKED
35 | #ifndef APSTUDIO_READONLY_SYMBOLS
36 | #define _APS_NEXT_RESOURCE_VALUE 107
37 | #define _APS_NEXT_COMMAND_VALUE 40005
38 | #define _APS_NEXT_CONTROL_VALUE 1007
39 | #define _APS_NEXT_SYMED_VALUE 103
40 | #endif
41 | #endif
42 |
--------------------------------------------------------------------------------
/LoginGate/Res/CONNECT.ICO:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginGate/Res/CONNECT.ICO
--------------------------------------------------------------------------------
/LoginGate/Res/ICON1.ICO:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginGate/Res/ICON1.ICO
--------------------------------------------------------------------------------
/LoginGate/Res/MIR2.ICO:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginGate/Res/MIR2.ICO
--------------------------------------------------------------------------------
/LoginGate/Res/TOOLBAR.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginGate/Res/TOOLBAR.BMP
--------------------------------------------------------------------------------
/LoginGate/ServerSockMsg.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginGate/ServerSockMsg.cpp
--------------------------------------------------------------------------------
/LoginGate/StdAfx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // LoginGate.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/LoginGate/StdAfx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
7 | #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
8 |
9 | #if _MSC_VER > 1000
10 | #pragma once
11 | #endif // _MSC_VER > 1000
12 |
13 | //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
14 | #define UNICODE
15 | #define _UNICODE
16 |
17 | #include
18 | #include
19 | #include
20 | #ifdef _DEBUG
21 | #include
22 | #endif
23 | #include
24 | #include
25 | #include
26 | #include "resource.h"
27 |
28 | #include "..\Def\EnDecode.h"
29 | #include "..\Def\ServerSockHandler.h"
30 | #include "..\Def\Queue.h"
31 | #include "..\Def\Misc.h"
32 |
33 | #include "LoginGate.h"
34 |
35 | #include "..\Def\List.h"
36 |
37 | #pragma comment (lib, "ws2_32.lib")
38 | #pragma comment (lib, "comctl32.lib")
39 |
40 | // **************************************************************************************
41 |
42 | #define _BMP_CX 16
43 | #define _BMP_CY 16
44 |
45 | #define _STATUS_HEIGHT 10
46 | #define _NUMOFMAX_STATUS_PARTS 5
47 |
48 | #define _LOGINGATE_SERVER_CLASS _TEXT("LoginGateServerClass")
49 | #define _LOGINGATE_SERVER_TITLE _TEXT("Legend of Mir II - Login Gate Server")
50 | #define _LOGINGATE_SERVER_REGISTRY _TEXT("Software\\LegendOfMir\\LoginGate")
51 |
52 | #define _IDM_SERVERSOCK_MSG WM_USER + 1000
53 | #define _IDM_CLIENTSOCK_MSG _IDM_SERVERSOCK_MSG + 1
54 |
55 | #define _IDW_TOOLBAR _IDM_SERVERSOCK_MSG + 2
56 | #define _IDW_STATUSBAR _IDM_SERVERSOCK_MSG + 3
57 |
58 | #define _ID_TIMER_KEEPALIVE _IDM_SERVERSOCK_MSG + 4
59 | #define _ID_TIMER_CONNECTSERVER _IDM_SERVERSOCK_MSG + 5
60 |
61 | extern BOOL g_fTerminated;
62 |
63 | //{{AFX_INSERT_LOCATION}}
64 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
65 |
66 | #endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
67 |
--------------------------------------------------------------------------------
/LoginGate/ThreadFuncForComm.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | #define PACKET_KEEPALIVE "%--$"
4 |
5 | extern HWND g_hToolBar;
6 | extern HWND g_hStatusBar;
7 |
8 | extern SOCKET g_csock;
9 | extern SOCKADDR_IN g_caddr;
10 |
11 | void SendExToServer(char *pszPacket);
12 |
13 | BOOL jRegGetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, LPBYTE pValue);
14 |
15 | VOID WINAPI OnTimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
16 | {
17 | switch (idEvent)
18 | {
19 | case _ID_TIMER_KEEPALIVE:
20 | {
21 | if (g_csock != INVALID_SOCKET)
22 | {
23 | SendExToServer(PACKET_KEEPALIVE);
24 | SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(2, 0), (LPARAM)_TEXT("Check Activity"));
25 | }
26 |
27 | break;
28 | }
29 | case _ID_TIMER_CONNECTSERVER:
30 | {
31 | if (g_csock == INVALID_SOCKET)
32 | {
33 | DWORD dwIP = 0;
34 | int nPort = 0;
35 |
36 | //InsertLogMsg(IDS_APPLY_RECONNECT);
37 |
38 | jRegGetKey(_LOGINGATE_SERVER_REGISTRY, _TEXT("RemoteIP"), (LPBYTE)&dwIP);
39 |
40 | if (!jRegGetKey(_LOGINGATE_SERVER_REGISTRY, _TEXT("RemotePort"), (LPBYTE)&nPort))
41 | nPort = 5500;
42 |
43 | TCHAR szSrvAddr[16];
44 | _stprintf(szSrvAddr, _T("%d.%d.%d.%d:%d"), g_caddr.sin_addr.s_net, g_caddr.sin_addr.s_host,
45 | g_caddr.sin_addr.s_lh, g_caddr.sin_addr.s_impno,nPort);
46 | InsertLogMsgParam(IDS_APPLY_RECONNECT, szSrvAddr, LOGPARAM_STR);
47 |
48 | ConnectToServer(g_csock, &g_caddr, _IDM_CLIENTSOCK_MSG, NULL, dwIP, nPort, FD_CONNECT|FD_READ|FD_CLOSE);
49 |
50 | }
51 |
52 | break;
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/LoginGate/ThreadFuncForMsg.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | extern HWND g_hStatusBar;
4 |
5 | extern SOCKET g_csock;
6 |
7 | extern CWHQueue g_xMsgQueue;
8 | extern CWHList g_xSessionList;
9 |
10 | DWORD WINAPI ThreadFuncForMsg(LPVOID lpParameter)
11 | {
12 | char szData[DATA_BUFSIZE];
13 | char szRemainData[DATA_BUFSIZE];
14 | char *pszData;
15 | char *pszFirst, *pszEnd;
16 | int nCount = 0, nDataPos = 0, nRemainDataLen = 0, nRemain = 0;
17 | int nLoop;
18 | int nSocket;
19 |
20 | FILETIME ftKernelTimeStart, ftKernelTimeEnd;
21 | FILETIME ftUserTimeStart, ftUserTimeEnd;
22 | FILETIME ftDummy, ftTotalTimeElapsed;
23 | __int64 qwKernelTimeElapsed, qwUserTimeElapsed, qwTotalTimeElapsed;
24 | TCHAR wszThreadTime[32];
25 |
26 | WSABUF Buf;
27 | DWORD dwSendBytes = 0;
28 |
29 | while (TRUE)
30 | {
31 | GetThreadTimes(GetCurrentThread(), &ftDummy, &ftDummy, &ftKernelTimeStart, &ftUserTimeStart);
32 |
33 | if (g_fTerminated)
34 | return 0;
35 |
36 | nCount = g_xMsgQueue.GetCount();
37 | nDataPos = 0;
38 | pszFirst = NULL;
39 |
40 | if (nCount)
41 | {
42 | if (nRemainDataLen)
43 | {
44 | memmove(szData, szRemainData, nRemainDataLen);
45 | nDataPos = nRemainDataLen;
46 | }
47 |
48 | for (nLoop = 0; nLoop < nCount; nLoop++)
49 | {
50 | pszData = (char *)g_xMsgQueue.PopQ();
51 |
52 | if (!pszData) continue;
53 |
54 | if (pszFirst)
55 | {
56 | nRemain = memlen(pszFirst);
57 |
58 | if (nRemain)
59 | {
60 | memmove(szData, pszFirst, nRemain);
61 | nDataPos = 0;
62 | }
63 | }
64 | else
65 | nDataPos = 0;
66 |
67 | memmove((szData + nDataPos), pszData, memlen(pszData));
68 |
69 | pszEnd = &szData[0];
70 |
71 | while (TRUE)
72 | {
73 | if ((pszFirst = (char *)memchr(pszEnd, '%', memlen(pszEnd))) && (pszEnd = (char *)memchr(pszFirst, '$', memlen(pszFirst))))
74 | {
75 | *pszEnd = '\0';
76 |
77 | if (*(pszFirst + 1) == '+')
78 | {
79 | if (*(pszFirst + 2) == '-')
80 | InsertLogMsg(_TEXT("Kick User."));
81 | else
82 | SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(2, 0), (LPARAM)_TEXT("Activation")); // Received keep alive check code from login server
83 | }
84 | else
85 | {
86 | if (pszEnd = strchr(pszFirst, '/'))
87 | {
88 | pszEnd++;
89 |
90 | if (nSocket = AnsiStrToVal(pszFirst + 1))
91 | {
92 | Buf.len = memlen(pszEnd) - 1;
93 | Buf.buf = pszEnd;
94 |
95 | WSASend((SOCKET)nSocket, &Buf, 1, &dwSendBytes, 0, NULL, NULL);
96 | }
97 | }
98 | }
99 | }
100 | else
101 | break;
102 | } // while loop
103 |
104 | delete [] pszData;
105 | } // for loop
106 |
107 | if (pszFirst)
108 | {
109 | nRemain = memlen(pszFirst);
110 |
111 | if (nRemain)
112 | {
113 | memmove(szRemainData, pszFirst, nRemain);
114 | nRemainDataLen = nRemain;
115 | }
116 | else
117 | nRemainDataLen = 0;
118 | }
119 | } // if (nCount)
120 |
121 | GetThreadTimes(GetCurrentThread(), &ftDummy, &ftDummy, &ftKernelTimeEnd, &ftUserTimeEnd);
122 |
123 | qwKernelTimeElapsed = FileTimeToQuadWord(&ftKernelTimeEnd) - FileTimeToQuadWord(&ftKernelTimeStart);
124 | qwUserTimeElapsed = FileTimeToQuadWord(&ftUserTimeEnd) - FileTimeToQuadWord(&ftUserTimeStart);
125 |
126 | qwTotalTimeElapsed = qwKernelTimeElapsed + qwUserTimeElapsed;
127 |
128 | QuadTimeToFileTime(qwTotalTimeElapsed, &ftTotalTimeElapsed);
129 |
130 | wsprintf(wszThreadTime, _TEXT("%u%u ns"), ftTotalTimeElapsed.dwHighDateTime, ftTotalTimeElapsed.dwLowDateTime);
131 |
132 | SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(4, 0), (LPARAM)wszThreadTime);
133 |
134 | SleepEx(1, TRUE);
135 | }
136 |
137 | return 0;
138 | }
139 |
--------------------------------------------------------------------------------
/LoginSvr/AddSvrListFunc.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | BOOL jRegSetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, DWORD dwFlags, LPBYTE pValue, DWORD nValueSize);
4 | BOOL jRegGetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, LPBYTE pValue);
5 |
6 | extern HWND g_hMainWnd;
7 |
8 | BOOL CALLBACK AddSvrListProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
9 | {
10 | switch (uMsg)
11 | {
12 | case WM_INITDIALOG:
13 | {
14 | CenterDialog(g_hMainWnd, hWndDlg);
15 |
16 | break;
17 | }
18 | case WM_COMMAND:
19 | {
20 | switch (wParam)
21 | {
22 | case IDC_ADD_GATELIST:
23 | {
24 |
25 | break;
26 | }
27 | case IDC_REMOVE_GATELIST:
28 | {
29 | int nSel = SendMessage(GetDlgItem(hWndDlg, IDC_GATELIST), LB_GETCURSEL, (WPARAM)0, (LPARAM)0L);
30 |
31 | if (nSel != LB_ERR)
32 | SendMessage(GetDlgItem(hWndDlg, IDC_GATELIST), LB_DELETESTRING, (WPARAM)nSel, (LPARAM)0L);
33 |
34 | break;
35 | }
36 | case IDOK:
37 | {
38 | TCHAR szKey[64];
39 | TCHAR szSubKey[32];
40 | TCHAR szTitle[64];
41 | TCHAR szGateList[32];
42 | DWORD dwPrivateIP = 0, dwPublicIP = 0;
43 | UINT nGateCount = 0;
44 |
45 | ZeroMemory(szKey, sizeof(szKey));
46 | ZeroMemory(szSubKey, sizeof(szSubKey));
47 | ZeroMemory(szTitle, sizeof(szTitle));
48 | ZeroMemory(szGateList, sizeof(szGateList));
49 |
50 | GetWindowText(GetDlgItem(hWndDlg, IDC_TITLE), szTitle, sizeof(szTitle));
51 |
52 | if (lstrlen(szTitle))
53 | {
54 | lstrcpy(szKey, _LOGIN_SERVER_REGISTRY);
55 | lstrcat(szKey, _T("\\Servers\\"));
56 | lstrcat(szKey, szTitle);
57 |
58 | jRegSetKey(szKey, _TEXT("Title"), REG_SZ, (LPBYTE)szTitle, _tcslen(szTitle) * sizeof(TCHAR));
59 |
60 | if (SendMessage(GetDlgItem(hWndDlg, IDC_IPADDRESS1), IPM_ISBLANK, (WPARAM)0, (LPARAM)0L) ||
61 | SendMessage(GetDlgItem(hWndDlg, IDC_IPADDRESS2), IPM_ISBLANK, (WPARAM)0, (LPARAM)0L))
62 | {
63 | MessageBox(hWndDlg, _TEXT("ERROR"), _T("Configuration"), MB_OK|MB_ICONSTOP);
64 | return FALSE;
65 | }
66 |
67 | SendMessage(GetDlgItem(hWndDlg, IDC_IPADDRESS1), IPM_GETADDRESS, (WPARAM)0, (LPARAM)(LPDWORD)&dwPrivateIP);
68 | SendMessage(GetDlgItem(hWndDlg, IDC_IPADDRESS2), IPM_GETADDRESS, (WPARAM)0, (LPARAM)(LPDWORD)&dwPublicIP);
69 |
70 | jRegSetKey(szKey, _TEXT("PrivateIP"), REG_DWORD, (LPBYTE)&dwPrivateIP, sizeof(DWORD));
71 | jRegSetKey(szKey, _TEXT("PublicIP"), REG_DWORD, (LPBYTE)&dwPublicIP, sizeof(DWORD));
72 |
73 | nGateCount = SendMessage(GetDlgItem(hWndDlg, IDC_GATELIST), LB_GETCOUNT, (WPARAM)0, (LPARAM)(LPDWORD)0L);
74 |
75 | jRegSetKey(szKey, _TEXT("NumberOfGate"), REG_DWORD, (LPBYTE)&nGateCount, sizeof(UINT));
76 |
77 | if (SendMessage(GetDlgItem(hWndDlg, IDC_IPADDRESS3), IPM_ISBLANK, (WPARAM)0, (LPARAM)0L) == 0)
78 | {
79 | DWORD dwIP = 0;
80 | TCHAR szPort[10];
81 |
82 | ZeroMemory(szPort, sizeof(szPort));
83 |
84 | SendMessage(GetDlgItem(hWndDlg, IDC_IPADDRESS3), IPM_GETADDRESS, (WPARAM)0, (LPARAM)(LPDWORD)&dwIP);
85 |
86 | GetWindowText(GetDlgItem(hWndDlg, IDC_PORT), szPort, sizeof(szPort));
87 |
88 | wsprintf(szGateList, _TEXT("%d.%d.%d.%d:%s"), FIRST_IPADDRESS(dwIP), SECOND_IPADDRESS(dwIP),
89 | THIRD_IPADDRESS(dwIP), FOURTH_IPADDRESS(dwIP), szPort);
90 |
91 | jRegSetKey(szKey, _TEXT("Gate"), REG_SZ, (LPBYTE)szGateList, _tcslen(szGateList) * sizeof(TCHAR));
92 | }
93 | }
94 | }
95 | case IDCANCEL:
96 | return EndDialog(hWndDlg, IDCANCEL);
97 | }
98 | }
99 | }
100 |
101 | return FALSE;
102 | }
103 |
--------------------------------------------------------------------------------
/LoginSvr/ConfigDlgFunc.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | BOOL jRegSetKey(LPCSTR pSubKeyName, LPCSTR pValueName, DWORD dwFlags, LPBYTE pValue, DWORD nValueSize);
4 | BOOL jRegGetKey(LPCSTR pSubKeyName, LPCSTR pValueName, LPBYTE pValue);
5 |
6 | extern HINSTANCE g_hInst;
7 | extern HWND g_hMainWnd;
8 |
9 | BOOL CALLBACK ConfigDlgFunc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
10 | {
11 | switch (uMsg)
12 | {
13 | case WM_INITDIALOG:
14 | {
15 | RECT rcMainWnd, rcDlg;
16 |
17 | GetWindowRect(g_hMainWnd, &rcMainWnd);
18 | GetWindowRect(hWndDlg, &rcDlg);
19 |
20 | MoveWindow(hWndDlg, rcMainWnd.left + (((rcMainWnd.right - rcMainWnd.left) - (rcDlg.right - rcDlg.left)) / 2),
21 | rcMainWnd.top + (((rcMainWnd.bottom - rcMainWnd.top) - (rcDlg.bottom - rcDlg.top)) / 2),
22 | (rcDlg.right - rcDlg.left), (rcDlg.bottom - rcDlg.top), FALSE);
23 |
24 | //
25 | LV_COLUMN lvc;
26 | TCHAR szText[64];
27 |
28 | lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
29 | lvc.fmt = LVCFMT_LEFT;
30 | lvc.cx = 100;
31 | lvc.pszText = szText;
32 |
33 | for (int i = 0; i < 5; i++)
34 | {
35 | lvc.iSubItem = i;
36 | LoadString((HINSTANCE)g_hInst, IDS_CONFLVS_LABEL1 + i, szText, sizeof(szText));
37 |
38 | ListView_InsertColumn(GetDlgItem(hWndDlg, IDC_SERVERINFO_LIST), i, &lvc);
39 | }
40 |
41 | /* TC_ITEM tie;
42 |
43 | tie.mask = TCIF_TEXT;
44 | tie.iImage = -1;
45 | tie.pszText = szText;
46 |
47 | LoadString((HINSTANCE)g_hInst, IDS_TAB_LABEL1, szText, sizeof(szText));
48 | TabCtrl_InsertItem(GetDlgItem(hWndDlg, IDC_CONFIG_TAB), 0, &tie);
49 | */
50 | break;
51 | }
52 | case WM_COMMAND:
53 | {
54 | switch (wParam)
55 | {
56 | case IDOK:
57 | case IDCANCEL:
58 | return EndDialog(hWndDlg, IDCANCEL);
59 | }
60 | }
61 | }
62 |
63 | return FALSE;
64 | }
65 |
--------------------------------------------------------------------------------
/LoginSvr/GateCommSockMsg.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | extern HWND g_hStatusBar;
4 |
5 | extern SOCKET g_gcSock;
6 |
7 | UINT WINAPI ThreadFuncForMsg(LPVOID lpParameter);
8 |
9 | extern HANDLE g_hIOCP;
10 | extern BOOL g_fTerminated;
11 |
12 | CWHList g_xGateList;
13 | CWHList g_xGameServerList;
14 | CWHList g_xGateServerList;
15 | char g_szServerList[1024];
16 |
17 | unsigned long g_hThreadForMsg = 0;
18 |
19 | void UpdateStatusBar(BOOL fGrow)
20 | {
21 | static long nNumOfCurrSession = 0;
22 |
23 | TCHAR szText[20];
24 |
25 | (fGrow ? InterlockedIncrement(&nNumOfCurrSession) : InterlockedDecrement(&nNumOfCurrSession));
26 |
27 | wsprintf(szText, _TEXT("%d Sessions"), nNumOfCurrSession);
28 |
29 | SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(3, 0), (LPARAM)szText);
30 | }
31 |
32 | BOOL InitServerThreadForMsg()
33 | {
34 | UINT dwThreadIDForMsg = 0;
35 |
36 | if (!g_hThreadForMsg)
37 | {
38 | g_hThreadForMsg = _beginthreadex(NULL, 0, ThreadFuncForMsg, NULL, 0, &dwThreadIDForMsg);
39 |
40 | if (g_hThreadForMsg)
41 | return TRUE;
42 | }
43 |
44 | return FALSE;
45 | }
46 |
47 | DWORD WINAPI AcceptThread(LPVOID lpParameter)
48 | {
49 | int nLen = sizeof(SOCKADDR_IN);
50 |
51 | SOCKET Accept;
52 | SOCKADDR_IN Address;
53 |
54 | while (TRUE)
55 | {
56 | Accept = accept(g_gcSock, (struct sockaddr FAR *)&Address, &nLen);
57 |
58 | if (g_fTerminated)
59 | return 0;
60 |
61 | CGateInfo* pGateInfo = new CGateInfo;
62 |
63 | if (pGateInfo)
64 | {
65 | pGateInfo->sock = Accept;
66 |
67 | CreateIoCompletionPort((HANDLE)pGateInfo->sock, g_hIOCP, (DWORD)pGateInfo, 0);
68 |
69 | if (g_xGateList.AddNewNode(pGateInfo))
70 | {
71 | int zero = 0;
72 |
73 | setsockopt(pGateInfo->sock, SOL_SOCKET, SO_SNDBUF, (char *)&zero, sizeof(zero) );
74 |
75 | pGateInfo->Recv();
76 |
77 | UpdateStatusBar(TRUE);
78 |
79 | #ifdef _DEBUG
80 | TCHAR szGateIP[256];
81 | wsprintf(szGateIP, _T("%d.%d.%d.%d:%d"), Address.sin_addr.s_net, Address.sin_addr.s_host,
82 | Address.sin_addr.s_lh, Address.sin_addr.s_impno,Address.sin_port);
83 |
84 | InsertLogMsgParam(IDS_ACCEPT_GATESERVER, szGateIP);
85 | #endif
86 | }
87 | }
88 | }
89 |
90 | return 0;
91 | }
92 |
93 | void CloseGate(CGateInfo* pGateInfo)
94 | {
95 | }
96 |
97 | DWORD WINAPI ServerWorkerThread(LPVOID CompletionPortID)
98 | {
99 | DWORD dwBytesTransferred = 0;
100 | CGateInfo* pGateInfo = NULL;
101 | LPOVERLAPPED lpOverlapped = NULL;
102 | char szTmp[DATA_BUFSIZE];
103 |
104 | while (TRUE)
105 | {
106 | if ( GetQueuedCompletionStatus(
107 | (HANDLE)CompletionPortID,
108 | &dwBytesTransferred,
109 | (LPDWORD)&pGateInfo,
110 | (LPOVERLAPPED *)&lpOverlapped,
111 | INFINITE) == 0 )
112 | {
113 | return 0;
114 | }
115 |
116 | if (g_fTerminated)
117 | {
118 | PLISTNODE pListNode;
119 |
120 | if (g_xGateList.GetCount())
121 | {
122 | pListNode = g_xGateList.GetHead();
123 |
124 | while (pListNode)
125 | {
126 | pGateInfo = g_xGateList.GetData(pListNode);
127 |
128 | if (pGateInfo) {
129 | pGateInfo->Close();
130 | UpdateStatusBar(false);
131 | }
132 |
133 | delete pGateInfo;
134 | pGateInfo = NULL;
135 |
136 | pListNode = g_xGateList.RemoveNode(pListNode);
137 | }
138 | }
139 |
140 | return 0;
141 | }
142 |
143 | if ( dwBytesTransferred == 0 )
144 | {
145 | pGateInfo->Close();
146 | UpdateStatusBar(false);
147 | continue;
148 | }
149 |
150 | pGateInfo->bufLen += dwBytesTransferred;
151 |
152 | while ( pGateInfo->HasCompletionPacket() )
153 | {
154 | *(pGateInfo->ExtractPacket( szTmp ) - 1) = '\0';
155 |
156 | switch ( szTmp[1] )
157 | {
158 | case '-':
159 | pGateInfo->SendKeepAlivePacket();
160 | break;
161 | case 'A':
162 | pGateInfo->ReceiveSendUser(&szTmp[2]);
163 | break;
164 | case 'O':
165 | pGateInfo->ReceiveOpenUser(&szTmp[2]);
166 | break;
167 | case 'X':
168 | pGateInfo->ReceiveCloseUser(&szTmp[2]);
169 | break;
170 | case 'S':
171 | pGateInfo->ReceiveServerMsg(&szTmp[2]);
172 | break;
173 | case 'M':
174 | pGateInfo->MakeNewUser(&szTmp[2]);
175 | break;
176 | }
177 | }
178 |
179 | if ( pGateInfo->Recv() == SOCKET_ERROR && WSAGetLastError() != ERROR_IO_PENDING )
180 | {
181 | InsertLogMsg(_TEXT("WSARecv() failed"));
182 | continue;
183 | }
184 | }
185 |
186 | return 0;
187 | }
188 |
--------------------------------------------------------------------------------
/LoginSvr/LoginSvr.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginSvr/LoginSvr.aps
--------------------------------------------------------------------------------
/LoginSvr/LoginSvr.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginSvr/LoginSvr.cpp
--------------------------------------------------------------------------------
/LoginSvr/LoginSvr.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginSvr/LoginSvr.h
--------------------------------------------------------------------------------
/LoginSvr/LoginSvr.ncb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginSvr/LoginSvr.ncb
--------------------------------------------------------------------------------
/LoginSvr/LoginSvr.opt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginSvr/LoginSvr.opt
--------------------------------------------------------------------------------
/LoginSvr/LoginSvr.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginSvr/LoginSvr.rc
--------------------------------------------------------------------------------
/LoginSvr/LoginSvr.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/LoginSvr/MainWndProc.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginSvr/MainWndProc.cpp
--------------------------------------------------------------------------------
/LoginSvr/Res/MIR2.ICO:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginSvr/Res/MIR2.ICO
--------------------------------------------------------------------------------
/LoginSvr/Res/toolbar.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/LoginSvr/Res/toolbar.bmp
--------------------------------------------------------------------------------
/LoginSvr/ServerListProc.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | extern HINSTANCE g_hInst;
4 | extern HWND g_hMainWnd;
5 |
6 | BOOL jRegGetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, LPBYTE pValue);
7 | LONG jRegEnumKey(LPCTSTR pSubKeyName, int nIndex, LPTSTR lpSubKey, int nSubkeyLen);
8 |
9 | BOOL CALLBACK AddSvrListProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
10 |
11 | void InitListView(HWND hWndDlg)
12 | {
13 | LV_ITEM lvi;
14 | TCHAR szText[64];
15 | UINT nCount = 0;
16 |
17 | TCHAR szKey[128];
18 | TCHAR szTitle[64];
19 | DWORD dwPrivateIP = 0, dwPublicIP = 0;
20 | UINT nNumberOfGate = 0;
21 |
22 | lvi.mask = LVIF_TEXT;
23 | lvi.iItem = nCount;
24 | lvi.iSubItem = 0;
25 |
26 | ZeroMemory(szText, sizeof(szText));
27 |
28 | while (jRegEnumKey(_LOGIN_SERVERLIST_REGISTRY, nCount, szText, sizeof(szText)) != ERROR_NO_MORE_ITEMS)
29 | {
30 | lvi.pszText = szText;
31 | ListView_InsertItem(GetDlgItem(hWndDlg, IDC_SERVERINFO_LIST), &lvi);
32 |
33 | lstrcpy(szKey, _LOGIN_SERVERLIST_REGISTRY);
34 | lstrcat(szKey, _TEXT("\\"));
35 | lstrcat(szKey, szText);
36 |
37 | jRegGetKey(szKey, _T("Title"), (LPBYTE)szTitle);
38 |
39 | ListView_SetItemText(GetDlgItem(hWndDlg, IDC_SERVERINFO_LIST), nCount, 1, szTitle);
40 |
41 | jRegGetKey(szKey, _T("PrivateIP"), (LPBYTE)dwPrivateIP);
42 | wsprintf(szText, _TEXT("%d.%d.%d.%d"), FIRST_IPADDRESS(dwPrivateIP), SECOND_IPADDRESS(dwPrivateIP),
43 | THIRD_IPADDRESS(dwPrivateIP), FOURTH_IPADDRESS(dwPrivateIP));
44 | ListView_SetItemText(GetDlgItem(hWndDlg, IDC_SERVERINFO_LIST), nCount, 2, szText);
45 |
46 | jRegGetKey(szKey, _T("PublicIP"), (LPBYTE)dwPublicIP);
47 | wsprintf(szText, _TEXT("%d.%d.%d.%d"), FIRST_IPADDRESS(dwPublicIP), SECOND_IPADDRESS(dwPublicIP),
48 | THIRD_IPADDRESS(dwPublicIP), FOURTH_IPADDRESS(dwPublicIP));
49 | ListView_SetItemText(GetDlgItem(hWndDlg, IDC_SERVERINFO_LIST), nCount, 2, szText);
50 |
51 | nCount++;
52 | }
53 |
54 | /* jRegGetKey(szKey, _T("NumberOfGate"), REG_DWORD, (LPBYTE)&nGateCount, sizeof(UINT));
55 |
56 | jRegSetKey(szKey, szSubKey, REG_SZ, (LPBYTE)szGateList, _tcslen(szGateList));
57 | */
58 | }
59 |
60 | BOOL CALLBACK ServerListProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
61 | {
62 | static PROPSHEETPAGE *ps;
63 |
64 | switch (uMsg)
65 | {
66 | case WM_INITDIALOG:
67 | {
68 | ps = (PROPSHEETPAGE *)lParam;
69 |
70 | LV_COLUMN lvc;
71 | TCHAR szText[64];
72 |
73 | lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
74 | lvc.fmt = LVCFMT_LEFT;
75 | lvc.cx = 100;
76 | lvc.pszText = szText;
77 |
78 | for (int i = 0; i < 5; i++)
79 | {
80 | lvc.iSubItem = i;
81 | LoadString((HINSTANCE)g_hInst, IDS_CONFLVS_LABEL1 + i, szText, sizeof(szText));
82 |
83 | ListView_InsertColumn(GetDlgItem(hWndDlg, IDC_SERVERINFO_LIST), i, &lvc);
84 | }
85 |
86 | ListView_DeleteAllItems(GetDlgItem(hWndDlg, IDC_SERVERINFO_LIST));
87 |
88 | BYTE btInstalled;
89 |
90 | if (jRegGetKey(_LOGIN_SERVER_REGISTRY, _T("Installed"), (LPBYTE)&btInstalled))
91 | InitListView(hWndDlg);
92 |
93 | return TRUE;
94 | }
95 | case WM_COMMAND:
96 | {
97 | case IDC_SVRLIST_ADD:
98 | DialogBox(g_hInst, MAKEINTRESOURCE(IDD_SVRLIST_ADD), hWndDlg, (DLGPROC)AddSvrListProc);
99 | break;
100 | }
101 | }
102 |
103 | return FALSE;
104 | }
105 |
--------------------------------------------------------------------------------
/LoginSvr/StdAfx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // LoginSvr.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/LoginSvr/StdAfx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
7 | #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
8 |
9 | #if _MSC_VER > 1000
10 | #pragma once
11 | #endif // _MSC_VER > 1000
12 |
13 | #define UNICODE
14 | #define _UNICODE
15 | //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
16 |
17 | #pragma warning( disable : 4146 )
18 |
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | class CItem;
27 | class CStdItem;
28 | class CStdItemSpecial;
29 |
30 | #include "resource.h"
31 |
32 | #include "..\Def\EnDecode.h"
33 | #include "..\Def\ServerSockHandler.h"
34 | #include "..\Def\Misc.h"
35 | #include "..\Def\Protocol.h"
36 | #include "..\Def\Queue.h"
37 | #include "..\Def\List.h"
38 |
39 | #include "LoginSvr.h"
40 |
41 | #pragma comment (lib, "ws2_32.lib")
42 | #pragma comment (lib, "comctl32.lib")
43 |
44 | // **************************************************************************************
45 |
46 | #define _LOGIN_SERVER_CLASS _TEXT("LoginServerClass")
47 | #define _LOGIN_SERVER_TITLE _TEXT("Login Server - Legend of Mir II")
48 | #define _LOGIN_SERVER_REGISTRY _TEXT("Software\\LegendOfMir\\LoginSvr")
49 | #define _LOGIN_SERVERLIST_REGISTRY _TEXT("Software\\LegendOfMir\\LoginSvr\\Servers")
50 |
51 | #define _STATUS_HEIGHT 10
52 | #define _NUMOFMAX_STATUS_PARTS 7
53 |
54 | #define _IDM_GATECOMMSOCK_MSG WM_USER + 1000
55 | #define _IDM_CLIENTSOCK_MSG _IDM_GATECOMMSOCK_MSG + 1
56 |
57 | #define _IDW_TOOLBAR _IDM_GATECOMMSOCK_MSG + 2
58 | #define _IDW_STATUSBAR _IDM_GATECOMMSOCK_MSG + 3
59 |
60 | //{{AFX_INSERT_LOCATION}}
61 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
62 |
63 | #endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
64 |
--------------------------------------------------------------------------------
/LoginSvr/ThreadFuncForMsg.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | extern HWND g_hStatusBar;
4 | extern CWHList g_xGateList;
5 |
6 | UINT WINAPI ThreadFuncForMsg(LPVOID lpParameter)
7 | {
8 | _TDEFAULTMESSAGE DefaultMsg;
9 | char *pszBegin, *pszEnd;
10 | int nCount;
11 | PLISTNODE pListNode;
12 | CGateInfo* pGateInfo;
13 |
14 | while (TRUE)
15 | {
16 | if (g_xGateList.GetCount())
17 | {
18 | pListNode = g_xGateList.GetHead();
19 |
20 | while (pListNode)
21 | {
22 | pGateInfo = g_xGateList.GetData(pListNode);
23 |
24 | if (pGateInfo)
25 | {
26 | nCount = pGateInfo->g_SendToGateQ.GetCount();
27 |
28 | if (nCount)
29 | {
30 | for (int nLoop = 0; nLoop < nCount; nLoop++)
31 | {
32 | _LPTSENDBUFF pSendBuff = (_LPTSENDBUFF)pGateInfo->g_SendToGateQ.PopQ();
33 |
34 | if (pSendBuff)
35 | {
36 | int nLen = memlen(pSendBuff->szData);
37 |
38 | if ((pszBegin = (char *)memchr(pSendBuff->szData, '#', nLen)) &&(pszEnd = (char *)memchr(pSendBuff->szData, '!', nLen)))
39 | {
40 | *pszEnd = '\0';
41 |
42 | fnDecodeMessageA(&DefaultMsg, (pszBegin + 1)); // 2 = "#?" ? = Check Code //new c#client 3="#|def packet size encode "
43 |
44 | switch (DefaultMsg.wIdent)
45 | {
46 | case CM_PROTOCOL:
47 | break;
48 | case CM_CLIENTVERSION:
49 | pGateInfo->ReceiveClientInfo(pSendBuff->sock);
50 | break;
51 | case CM_IDPASSWORD:case CM_LOGIN:
52 | pGateInfo->ProcLogin(pSendBuff->sock, pszBegin + DEFBLOCKSIZE+1);
53 | break;
54 | case CM_SELECTSERVER:
55 | pGateInfo->ProcSelectServer(pSendBuff->sock, DefaultMsg.wParam);
56 | break;
57 | case CM_ADDNEWUSER:
58 | pGateInfo->ProcAddUser(pSendBuff->sock, pszBegin+ DEFBLOCKSIZE);//2);
59 | //pGateInfo->MakeNewUser(pszBegin+2);
60 | break;
61 | case CM_UPDATEUSER:
62 | break;
63 | case CM_CHANGEPASSWORD:
64 | break;
65 | }
66 | }
67 |
68 | delete pSendBuff;
69 | pSendBuff = NULL;
70 | }
71 | }
72 | }
73 | }
74 |
75 | pListNode = g_xGateList.GetNext(pListNode);
76 | }
77 | }
78 |
79 | SleepEx(1, TRUE);
80 | }
81 |
82 | return 0;
83 | }
84 |
--------------------------------------------------------------------------------
/LoginSvr/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by LoginSvr.rc
4 | //
5 | #define IDS_NOTWINNT 1
6 | #define IDS_LVS_LABEL1 2
7 | #define IDS_LVS_LABEL2 3
8 | #define IDS_LVS_LABEL3 4
9 | #define IDS_STARTSERVICE 5
10 | #define IDS_STOPSERVICE 6
11 | #define IDS_CONNECT_LOGINSERVER 7
12 | #define IDS_DISCONNECT_LOGINSERVER 8
13 | #define IDS_PROGRAM_QUIT 9
14 | #define IDS_PROGRAM_TITLE 10
15 | #define IDS_CANT_CONNECT 11
16 | #define IDS_CONFLVS_LABEL1 12
17 | #define IDS_CONFLVS_LABEL2 13
18 | #define IDS_CONFLVS_LABEL3 14
19 | #define IDS_CONFLVS_LABEL4 15
20 | #define IDS_CONFLVS_LABEL5 16
21 | #define IDS_TAB_LABEL1 17
22 | #define IDS_ACCEPT_GATESERVER 18
23 | #define IDS_OPEN_USER 19
24 | #define IDS_CLOSE_USER 20
25 | #define IDS_CONNECTDB 21
26 | #define IDS_LOADACCOUNTRECORDS 22
27 | #define IDS_BOUNDACCOUNTRECORDS 23
28 | #define IDS_COMPLETENEWUSER 24
29 | #define IDS_OPEN_PORT 25
30 | #define IDI_ICON1 101
31 | #define IDI_MIR2 101
32 | #define IDR_MAINMENU 101
33 | #define IDM_FONTCOLOR 101
34 | #define IDB_TOOLBAR 102
35 | #define IDM_BACKCOLOR 102
36 | #define IDD_CONFIGDLG 103
37 | #define IDD_CONFIGDLG_SERVERLIST 104
38 | #define IDD_SVRLIST_ADD 105
39 | #define IDC_SERVERINFO_LIST 1000
40 | #define IDC_SVRLIST_ADD 1002
41 | #define IDC_SVRLIST_REMOVE 1003
42 | #define IDC_SVRLIST_EDIT 1004
43 | #define IDC_IPADDRESS1 1005
44 | #define IDC_IPADDRESS2 1006
45 | #define IDC_IPADDRESS3 1007
46 | #define IDC_TITLE 1009
47 | #define IDC_ADD_GATELIST 1011
48 | #define IDC_GATELIST 1013
49 | #define IDC_REMOVE_GATELIST 1014
50 | #define IDC_EDIT1 1016
51 | #define IDC_PORT 1016
52 | #define IDM_STARTSERVICE 40001
53 | #define IDM_STOPSERVICE 40002
54 | #define IDM_CONFIG 40003
55 | #define IDM_EXIT 40004
56 | #define IDM_SERVERSTAT 40005
57 |
58 | // Next default values for new objects
59 | //
60 | #ifdef APSTUDIO_INVOKED
61 | #ifndef APSTUDIO_READONLY_SYMBOLS
62 | #define _APS_NEXT_RESOURCE_VALUE 107
63 | #define _APS_NEXT_COMMAND_VALUE 40006
64 | #define _APS_NEXT_CONTROL_VALUE 1018
65 | #define _APS_NEXT_SYMED_VALUE 103
66 | #endif
67 | #endif
68 |
--------------------------------------------------------------------------------
/ManConsole/.vs/ManConsole/v14/.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/ManConsole/.vs/ManConsole/v14/.suo
--------------------------------------------------------------------------------
/ManConsole/ConsoleSocket.cpp:
--------------------------------------------------------------------------------
1 | // ConsoleSocket.cpp : implementation file
2 | //
3 |
4 | #include "stdafx.h"
5 | #include "ManConsole.h"
6 | #include "ConsoleSocket.h"
7 |
8 | #ifdef _DEBUG
9 | #define new DEBUG_NEW
10 | #undef THIS_FILE
11 | static char THIS_FILE[] = __FILE__;
12 | #endif
13 |
14 | /////////////////////////////////////////////////////////////////////////////
15 | // CConsoleSocket
16 |
17 | CConsoleSocket::CConsoleSocket()
18 | {
19 | }
20 |
21 | CConsoleSocket::~CConsoleSocket()
22 | {
23 | }
24 |
25 |
26 | // Do not edit the following lines, which are needed by ClassWizard.
27 | #if 0
28 | BEGIN_MESSAGE_MAP(CConsoleSocket, CAsyncSocket)
29 | //{{AFX_MSG_MAP(CConsoleSocket)
30 | //}}AFX_MSG_MAP
31 | END_MESSAGE_MAP()
32 | #endif // 0
33 |
34 | /////////////////////////////////////////////////////////////////////////////
35 | // CConsoleSocket member functions
36 |
--------------------------------------------------------------------------------
/ManConsole/ConsoleSocket.h:
--------------------------------------------------------------------------------
1 | #if !defined(AFX_CONSOLESOCKET_H__C2E973DB_90BA_4535_9633_38278EAB8EDB__INCLUDED_)
2 | #define AFX_CONSOLESOCKET_H__C2E973DB_90BA_4535_9633_38278EAB8EDB__INCLUDED_
3 |
4 | #if _MSC_VER > 1000
5 | #pragma once
6 | #endif // _MSC_VER > 1000
7 | // ConsoleSocket.h : header file
8 | //
9 |
10 |
11 |
12 | /////////////////////////////////////////////////////////////////////////////
13 | // CConsoleSocket command target
14 |
15 | class CConsoleSocket : public CAsyncSocket
16 | {
17 | // Attributes
18 | public:
19 |
20 | // Operations
21 | public:
22 | CConsoleSocket();
23 | virtual ~CConsoleSocket();
24 |
25 | // Overrides
26 | public:
27 | // ClassWizard generated virtual function overrides
28 | //{{AFX_VIRTUAL(CConsoleSocket)
29 | //}}AFX_VIRTUAL
30 |
31 | // Generated message map functions
32 | //{{AFX_MSG(CConsoleSocket)
33 | // NOTE - the ClassWizard will add and remove member functions here.
34 | //}}AFX_MSG
35 |
36 | // Implementation
37 | protected:
38 | };
39 |
40 | /////////////////////////////////////////////////////////////////////////////
41 |
42 | //{{AFX_INSERT_LOCATION}}
43 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
44 |
45 | #endif // !defined(AFX_CONSOLESOCKET_H__C2E973DB_90BA_4535_9633_38278EAB8EDB__INCLUDED_)
46 |
--------------------------------------------------------------------------------
/ManConsole/ManConsole.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/ManConsole/ManConsole.aps
--------------------------------------------------------------------------------
/ManConsole/ManConsole.clw:
--------------------------------------------------------------------------------
1 | ; CLW file contains information for the MFC ClassWizard
2 |
3 | [General Info]
4 | Version=1
5 | LastClass=CConsoleSocket
6 | LastTemplate=CAsyncSocket
7 | NewFileInclude1=#include "stdafx.h"
8 | NewFileInclude2=#include "ManConsole.h"
9 |
10 | ClassCount=4
11 | Class1=CManConsoleApp
12 | Class2=CManConsoleDlg
13 | Class3=CAboutDlg
14 |
15 | ResourceCount=3
16 | Resource1=IDD_ABOUTBOX
17 | Resource2=IDR_MAINFRAME
18 | Class4=CConsoleSocket
19 | Resource3=IDD_MANCONSOLE_DIALOG
20 |
21 | [CLS:CManConsoleApp]
22 | Type=0
23 | HeaderFile=ManConsole.h
24 | ImplementationFile=ManConsole.cpp
25 | Filter=N
26 |
27 | [CLS:CManConsoleDlg]
28 | Type=0
29 | HeaderFile=ManConsoleDlg.h
30 | ImplementationFile=ManConsoleDlg.cpp
31 | Filter=D
32 | LastObject=CManConsoleDlg
33 |
34 | [CLS:CAboutDlg]
35 | Type=0
36 | HeaderFile=ManConsoleDlg.h
37 | ImplementationFile=ManConsoleDlg.cpp
38 | Filter=D
39 |
40 | [DLG:IDD_ABOUTBOX]
41 | Type=1
42 | Class=CAboutDlg
43 | ControlCount=4
44 | Control1=IDC_STATIC,static,1342177283
45 | Control2=IDC_STATIC,static,1342308480
46 | Control3=IDC_STATIC,static,1342308352
47 | Control4=IDOK,button,1342373889
48 |
49 | [DLG:IDD_MANCONSOLE_DIALOG]
50 | Type=1
51 | Class=CManConsoleDlg
52 | ControlCount=4
53 | Control1=IDOK,button,1342242817
54 | Control2=IDCANCEL,button,1342242816
55 | Control3=IDC_LIST1,SysListView32,1350631425
56 | Control4=IDC_EDIT1,edit,1350631552
57 |
58 | [CLS:CConsoleSocket]
59 | Type=0
60 | HeaderFile=ConsoleSocket.h
61 | ImplementationFile=ConsoleSocket.cpp
62 | BaseClass=CAsyncSocket
63 | Filter=N
64 | LastObject=CConsoleSocket
65 |
66 |
--------------------------------------------------------------------------------
/ManConsole/ManConsole.cpp:
--------------------------------------------------------------------------------
1 | // ManConsole.cpp : Defines the class behaviors for the application.
2 | //
3 |
4 | #include "stdafx.h"
5 | #include "ManConsole.h"
6 | #include "ManConsoleDlg.h"
7 |
8 | #ifdef _DEBUG
9 | #define new DEBUG_NEW
10 | #undef THIS_FILE
11 | static char THIS_FILE[] = __FILE__;
12 | #endif
13 |
14 | /////////////////////////////////////////////////////////////////////////////
15 | // CManConsoleApp
16 |
17 | BEGIN_MESSAGE_MAP(CManConsoleApp, CWinApp)
18 | //{{AFX_MSG_MAP(CManConsoleApp)
19 | // NOTE - the ClassWizard will add and remove mapping macros here.
20 | // DO NOT EDIT what you see in these blocks of generated code!
21 | //}}AFX_MSG
22 | ON_COMMAND(ID_HELP, CWinApp::OnHelp)
23 | END_MESSAGE_MAP()
24 |
25 | /////////////////////////////////////////////////////////////////////////////
26 | // CManConsoleApp construction
27 |
28 | CManConsoleApp::CManConsoleApp()
29 | {
30 | // TODO: add construction code here,
31 | // Place all significant initialization in InitInstance
32 | }
33 |
34 | /////////////////////////////////////////////////////////////////////////////
35 | // The one and only CManConsoleApp object
36 |
37 | CManConsoleApp theApp;
38 |
39 | /////////////////////////////////////////////////////////////////////////////
40 | // CManConsoleApp initialization
41 |
42 | BOOL CManConsoleApp::InitInstance()
43 | {
44 | if (!AfxSocketInit())
45 | {
46 | AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
47 | return FALSE;
48 | }
49 |
50 | AfxEnableControlContainer();
51 |
52 | // Standard initialization
53 | // If you are not using these features and wish to reduce the size
54 | // of your final executable, you should remove from the following
55 | // the specific initialization routines you do not need.
56 |
57 | #ifdef _AFXDLL
58 | Enable3dControls(); // Call this when using MFC in a shared DLL
59 | #else
60 | Enable3dControlsStatic(); // Call this when linking to MFC statically
61 | #endif
62 |
63 | CManConsoleDlg dlg;
64 | m_pMainWnd = &dlg;
65 | int nResponse = dlg.DoModal();
66 | if (nResponse == IDOK)
67 | {
68 | // TODO: Place code here to handle when the dialog is
69 | // dismissed with OK
70 | }
71 | else if (nResponse == IDCANCEL)
72 | {
73 | // TODO: Place code here to handle when the dialog is
74 | // dismissed with Cancel
75 | }
76 |
77 | // Since the dialog has been closed, return FALSE so that we exit the
78 | // application, rather than start the application's message pump.
79 | return FALSE;
80 | }
81 |
--------------------------------------------------------------------------------
/ManConsole/ManConsole.h:
--------------------------------------------------------------------------------
1 | // ManConsole.h : main header file for the MANCONSOLE application
2 | //
3 |
4 | #if !defined(AFX_MANCONSOLE_H__F8877CC8_9C56_4B4D_970F_49791465A3D9__INCLUDED_)
5 | #define AFX_MANCONSOLE_H__F8877CC8_9C56_4B4D_970F_49791465A3D9__INCLUDED_
6 |
7 | #if _MSC_VER > 1000
8 | #pragma once
9 | #endif // _MSC_VER > 1000
10 |
11 | #ifndef __AFXWIN_H__
12 | #error include 'stdafx.h' before including this file for PCH
13 | #endif
14 |
15 | #include "resource.h" // main symbols
16 |
17 | /////////////////////////////////////////////////////////////////////////////
18 | // CManConsoleApp:
19 | // See ManConsole.cpp for the implementation of this class
20 | //
21 |
22 | class CManConsoleApp : public CWinApp
23 | {
24 | public:
25 | CManConsoleApp();
26 |
27 | // Overrides
28 | // ClassWizard generated virtual function overrides
29 | //{{AFX_VIRTUAL(CManConsoleApp)
30 | public:
31 | virtual BOOL InitInstance();
32 | //}}AFX_VIRTUAL
33 |
34 | // Implementation
35 |
36 | //{{AFX_MSG(CManConsoleApp)
37 | // NOTE - the ClassWizard will add and remove member functions here.
38 | // DO NOT EDIT what you see in these blocks of generated code !
39 | //}}AFX_MSG
40 | DECLARE_MESSAGE_MAP()
41 | };
42 |
43 |
44 | /////////////////////////////////////////////////////////////////////////////
45 |
46 | //{{AFX_INSERT_LOCATION}}
47 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
48 |
49 | #endif // !defined(AFX_MANCONSOLE_H__F8877CC8_9C56_4B4D_970F_49791465A3D9__INCLUDED_)
50 |
--------------------------------------------------------------------------------
/ManConsole/ManConsole.ncb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/ManConsole/ManConsole.ncb
--------------------------------------------------------------------------------
/ManConsole/ManConsole.opt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/ManConsole/ManConsole.opt
--------------------------------------------------------------------------------
/ManConsole/ManConsole.plg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Build Log
5 |
6 | --------------------Configuration: ManConsole - Win32 Debug--------------------
7 |
8 | Command Lines
9 | Creating command line "rc.exe /l 0x412 /fo"Debug/ManConsole.res" /d "_DEBUG" /d "_AFXDLL" "E:\Works.Wemade\LegendOfMir2_Server\ManConsole\ManConsole.rc""
10 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP7C.tmp" with contents
11 | [
12 | /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Fp"Debug/ManConsole.pch" /Yu"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
13 | "E:\Works.Wemade\LegendOfMir2_Server\ManConsole\ManConsole.cpp"
14 | "E:\Works.Wemade\LegendOfMir2_Server\ManConsole\ManConsoleDlg.cpp"
15 | ]
16 | Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP7C.tmp"
17 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP7D.tmp" with contents
18 | [
19 | /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Fp"Debug/ManConsole.pch" /Yc"stdafx.h" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
20 | "E:\Works.Wemade\LegendOfMir2_Server\ManConsole\StdAfx.cpp"
21 | ]
22 | Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP7D.tmp"
23 | Creating command line "link.exe /nologo /subsystem:windows /incremental:yes /pdb:"Debug/ManConsole.pdb" /debug /machine:I386 /out:"Debug/ManConsole.exe" /pdbtype:sept .\Debug\ManConsole.obj .\Debug\ManConsoleDlg.obj .\Debug\StdAfx.obj .\Debug\ManConsole.res "
24 | Output Window
25 | Compiling resources...
26 | Compiling...
27 | StdAfx.cpp
28 | Compiling...
29 | ManConsole.cpp
30 | ManConsoleDlg.cpp
31 | Generating Code...
32 | Linking...
33 |
34 |
35 |
36 | Results
37 | ManConsole.exe - 0 error(s), 0 warning(s)
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/ManConsole/ManConsole.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/ManConsole/ManConsole.rc
--------------------------------------------------------------------------------
/ManConsole/ManConsole.sdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/ManConsole/ManConsole.sdf
--------------------------------------------------------------------------------
/ManConsole/ManConsole.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ManConsole", "ManConsole.vcxproj", "{C635654C-0E8E-8943-E03C-8F95ED320D3C}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {C635654C-0E8E-8943-E03C-8F95ED320D3C}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {C635654C-0E8E-8943-E03C-8F95ED320D3C}.Debug|Win32.Build.0 = Debug|Win32
14 | {C635654C-0E8E-8943-E03C-8F95ED320D3C}.Release|Win32.ActiveCfg = Release|Win32
15 | {C635654C-0E8E-8943-E03C-8F95ED320D3C}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/ManConsole/ManConsole.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/ManConsole/ManConsole.suo
--------------------------------------------------------------------------------
/ManConsole/ManConsole.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {aaa3735d-cb27-41e3-8973-70862e4aed8a}
6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat
7 |
8 |
9 | {9c7a0505-57cb-4873-876d-98d230d35858}
10 | h;hpp;hxx;hm;inl
11 |
12 |
13 | {b82dd860-c022-4627-a2e4-3a716fea61c2}
14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 |
32 |
33 | Source Files
34 |
35 |
36 |
37 |
38 | Header Files
39 |
40 |
41 | Header Files
42 |
43 |
44 | Header Files
45 |
46 |
47 | Header Files
48 |
49 |
50 | Header Files
51 |
52 |
53 |
54 |
55 | Resource Files
56 |
57 |
58 | Resource Files
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/ManConsole/ManConsole.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/ManConsole/ManConsoleDlg.h:
--------------------------------------------------------------------------------
1 | // ManConsoleDlg.h : header file
2 | //
3 |
4 | #if !defined(AFX_MANCONSOLEDLG_H__5DD61023_2762_40C6_BDB1_0A4B6F393ECE__INCLUDED_)
5 | #define AFX_MANCONSOLEDLG_H__5DD61023_2762_40C6_BDB1_0A4B6F393ECE__INCLUDED_
6 |
7 | #if _MSC_VER > 1000
8 | #pragma once
9 | #endif // _MSC_VER > 1000
10 |
11 | /////////////////////////////////////////////////////////////////////////////
12 | // CManConsoleDlg dialog
13 |
14 | class CManConsoleDlg : public CDialog
15 | {
16 | // Construction
17 | public:
18 | CManConsoleDlg(CWnd* pParent = NULL); // standard constructor
19 |
20 | // Dialog Data
21 | //{{AFX_DATA(CManConsoleDlg)
22 | enum { IDD = IDD_MANCONSOLE_DIALOG };
23 | // NOTE: the ClassWizard will add data members here
24 | //}}AFX_DATA
25 |
26 | // ClassWizard generated virtual function overrides
27 | //{{AFX_VIRTUAL(CManConsoleDlg)
28 | protected:
29 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
30 | //}}AFX_VIRTUAL
31 |
32 | // Implementation
33 | protected:
34 | HICON m_hIcon;
35 |
36 | // Generated message map functions
37 | //{{AFX_MSG(CManConsoleDlg)
38 | virtual BOOL OnInitDialog();
39 | afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
40 | afx_msg void OnPaint();
41 | afx_msg HCURSOR OnQueryDragIcon();
42 | //}}AFX_MSG
43 | DECLARE_MESSAGE_MAP()
44 | };
45 |
46 | //{{AFX_INSERT_LOCATION}}
47 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
48 |
49 | #endif // !defined(AFX_MANCONSOLEDLG_H__5DD61023_2762_40C6_BDB1_0A4B6F393ECE__INCLUDED_)
50 |
--------------------------------------------------------------------------------
/ManConsole/StdAfx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // ManConsole.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ManConsole/StdAfx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #if !defined(AFX_STDAFX_H__D4BEEACE_E0B0_4C9B_BE8D_FF8618EF253F__INCLUDED_)
7 | #define AFX_STDAFX_H__D4BEEACE_E0B0_4C9B_BE8D_FF8618EF253F__INCLUDED_
8 |
9 | #if _MSC_VER > 1000
10 | #pragma once
11 | #endif // _MSC_VER > 1000
12 |
13 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
14 |
15 | #include // MFC core and standard components
16 | #include // MFC extensions
17 | #include // MFC Automation classes
18 | #include // MFC support for Internet Explorer 4 Common Controls
19 | #ifndef _AFX_NO_AFXCMN_SUPPORT
20 | #include // MFC support for Windows Common Controls
21 | #endif // _AFX_NO_AFXCMN_SUPPORT
22 |
23 | #include // MFC socket extensions
24 |
25 | //{{AFX_INSERT_LOCATION}}
26 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
27 |
28 | #endif // !defined(AFX_STDAFX_H__D4BEEACE_E0B0_4C9B_BE8D_FF8618EF253F__INCLUDED_)
29 |
--------------------------------------------------------------------------------
/ManConsole/res/ManConsole.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/ManConsole/res/ManConsole.ico
--------------------------------------------------------------------------------
/ManConsole/res/ManConsole.rc2:
--------------------------------------------------------------------------------
1 | //
2 | // MANCONSOLE.RC2 - resources Microsoft Visual C++ does not edit directly
3 | //
4 |
5 | #ifdef APSTUDIO_INVOKED
6 | #error this file is not editable by Microsoft Visual C++
7 | #endif //APSTUDIO_INVOKED
8 |
9 |
10 | /////////////////////////////////////////////////////////////////////////////
11 | // Add manually edited resources here...
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 |
--------------------------------------------------------------------------------
/ManConsole/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Developer Studio generated include file.
3 | // Used by ManConsole.rc
4 | //
5 | #define IDM_ABOUTBOX 0x0010
6 | #define IDD_ABOUTBOX 100
7 | #define IDS_ABOUTBOX 101
8 | #define IDD_MANCONSOLE_DIALOG 102
9 | #define IDP_SOCKETS_INIT_FAILED 103
10 | #define IDR_MAINFRAME 128
11 | #define IDC_LIST1 1000
12 | #define IDC_EDIT1 1001
13 |
14 | // Next default values for new objects
15 | //
16 | #ifdef APSTUDIO_INVOKED
17 | #ifndef APSTUDIO_READONLY_SYMBOLS
18 | #define _APS_NEXT_RESOURCE_VALUE 129
19 | #define _APS_NEXT_COMMAND_VALUE 32771
20 | #define _APS_NEXT_CONTROL_VALUE 1002
21 | #define _APS_NEXT_SYMED_VALUE 101
22 | #endif
23 | #endif
24 |
--------------------------------------------------------------------------------
/SelGate/ClientSockMsg.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | DWORD WINAPI ThreadFuncForMsg(LPVOID lpParameter);
4 |
5 | BOOL CheckSocketError(LPARAM lParam);
6 |
7 | VOID WINAPI OnTimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
8 |
9 | void OnCommand(WPARAM wParam, LPARAM lParam);
10 | BOOL InitThread(LPTHREAD_START_ROUTINE lpRoutine);
11 |
12 | extern SOCKET g_csock;
13 |
14 | extern HWND g_hMainWnd;
15 | extern HWND g_hStatusBar;
16 | extern HWND g_hToolBar;
17 |
18 | HANDLE g_hMsgThread = INVALID_HANDLE_VALUE;
19 |
20 | CWHQueue g_xMsgQueue;
21 |
22 | static char WorkBuff[8192];
23 | static int nWorkBuffLen;
24 |
25 | LPARAM OnClientSockMsg(WPARAM wParam, LPARAM lParam)
26 | {
27 | switch (WSAGETSELECTEVENT(lParam))
28 | {
29 | case FD_CONNECT:
30 | {
31 | DWORD dwThreadIDForMsg = 0;
32 |
33 | if (CheckSocketError(lParam))
34 | {
35 | dwThreadIDForMsg = 0;
36 |
37 | if (InitThread(ThreadFuncForMsg))
38 | // if ((g_hMsgThread = CreateThread(NULL, 0, ThreadFuncForMsg, NULL, 0, &dwThreadIDForMsg)) != INVALID_HANDLE_VALUE)
39 | {
40 | KillTimer(g_hMainWnd, _ID_TIMER_CONNECTSERVER);
41 |
42 | SetTimer(g_hMainWnd, _ID_TIMER_KEEPALIVE, 5000, (TIMERPROC)OnTimerProc);
43 |
44 | InsertLogMsg(IDS_CONNECT_LOGINSERVER);
45 | SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(1, 0), (LPARAM)_TEXT("Connected"));
46 | }
47 | }
48 | else
49 | {
50 | closesocket(g_csock);
51 | g_csock = INVALID_SOCKET;
52 |
53 | SetTimer(g_hMainWnd, _ID_TIMER_CONNECTSERVER, 10000, (TIMERPROC)OnTimerProc);
54 | }
55 |
56 | break;
57 | }
58 | case FD_CLOSE:
59 | {
60 | closesocket(g_csock);
61 | g_csock = INVALID_SOCKET;
62 |
63 | OnCommand(IDM_STOPSERVICE, 0);
64 |
65 | break;
66 | }
67 | case FD_READ:
68 | {
69 | int nSocket = 0;
70 | char *pszFirst = NULL, *pszEnd = NULL;
71 |
72 | UINT nRecv = 0;
73 |
74 | ioctlsocket((SOCKET)wParam, FIONREAD, (u_long *)&nRecv);
75 |
76 | if (nRecv)
77 | {
78 | char *pszPacket = new char[nRecv + 1];
79 |
80 | nRecv = recv((SOCKET)wParam, pszPacket, nRecv, 0);
81 |
82 | pszPacket[nRecv] = '\0';
83 |
84 | if (!(g_xMsgQueue.PushQ((BYTE *)pszPacket)))
85 | InsertLogMsg(_TEXT("[INFO] Not enough queue(g_xMsgQueue) buffer."));
86 | }
87 |
88 | break;
89 | }
90 | }
91 |
92 | return 0L;
93 | }
94 |
95 | void SendExToServer(char *pszPacket)
96 | {
97 | /* int nTotalSendBytes = 0;
98 |
99 | while (TRUE)
100 | {
101 | if ((nLen - nTotalSendBytes <= 0) || g_csock == INVALID_SOCKET)
102 | return;
103 |
104 | nTotalSendBytes += send(g_csock, pszData, nLen - nTotalSendBytes, 0);
105 |
106 | if (nTotalSendBytes < nLen)
107 | pszData += (nLen - nTotalSendBytes);
108 | else
109 | return;
110 | } */
111 |
112 | DWORD dwSendBytes;
113 | WSABUF buf;
114 |
115 | buf.len = memlen(pszPacket) - 1;
116 | buf.buf = pszPacket;
117 |
118 | WSASend(g_csock, &buf, 1, &dwSendBytes, 0, NULL, NULL);
119 | }
120 |
--------------------------------------------------------------------------------
/SelGate/ConfigDlgFunc.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | BOOL jRegSetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, DWORD dwFlags, LPBYTE pValue, DWORD nValueSize);
4 | BOOL jRegGetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, LPBYTE pValue);
5 |
6 | extern HWND g_hMainWnd;
7 |
8 | BOOL CALLBACK ConfigDlgFunc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
9 | {
10 | switch (uMsg)
11 | {
12 | case WM_INITDIALOG:
13 | {
14 | RECT rcMainWnd, rcDlg;
15 |
16 | GetWindowRect(g_hMainWnd, &rcMainWnd);
17 | GetWindowRect(hWndDlg, &rcDlg);
18 |
19 | MoveWindow(hWndDlg, rcMainWnd.left + (((rcMainWnd.right - rcMainWnd.left) - (rcDlg.right - rcDlg.left)) / 2),
20 | rcMainWnd.top + (((rcMainWnd.bottom - rcMainWnd.top) - (rcDlg.bottom - rcDlg.top)) / 2),
21 | (rcDlg.right - rcDlg.left), (rcDlg.bottom - rcDlg.top), FALSE);
22 |
23 | SendMessage(GetDlgItem(hWndDlg, IDC_LOGINSVR_PORT), EM_LIMITTEXT, (WPARAM)5, (LPARAM)0L);
24 | SendMessage(GetDlgItem(hWndDlg, IDC_LOCALPORT), EM_LIMITTEXT, (WPARAM)5, (LPARAM)0L);
25 |
26 | DWORD dwIP = 0;
27 | TCHAR szPort[24];
28 | int nPort = 0;
29 |
30 | jRegGetKey(_SELGATE_SERVER_REGISTRY, _TEXT("RemoteIP"), (LPBYTE)&dwIP);
31 | SendMessage(GetDlgItem(hWndDlg, IDC_LOGINSVR_IP), IPM_SETADDRESS, (WPARAM)0, (LPARAM)(DWORD)dwIP);
32 |
33 | jRegGetKey(_SELGATE_SERVER_REGISTRY, _TEXT("RemotePort"), (LPBYTE)&nPort);
34 | _itow(nPort, szPort, 10);
35 | SetWindowText(GetDlgItem(hWndDlg, IDC_LOGINSVR_PORT), szPort);
36 |
37 | jRegGetKey(_SELGATE_SERVER_REGISTRY, _TEXT("LocalPort"), (LPBYTE)&nPort);
38 | _itow(nPort, szPort, 10);
39 | SetWindowText(GetDlgItem(hWndDlg, IDC_LOCALPORT), szPort);
40 |
41 | break;
42 | }
43 | case WM_COMMAND:
44 | {
45 | switch (wParam)
46 | {
47 | case IDOK:
48 | {
49 | DWORD dwIP = 0;
50 | TCHAR szPort[24];
51 | int nRemotePort = 0, nLocalPort = 0;
52 | BYTE btInstalled = 1;
53 |
54 | jRegSetKey(_SELGATE_SERVER_REGISTRY, _TEXT("Installed"), REG_BINARY, (LPBYTE)&btInstalled, sizeof(BYTE));
55 |
56 | SendMessage(GetDlgItem(hWndDlg, IDC_LOGINSVR_IP), IPM_GETADDRESS, (WPARAM)0, (LPARAM)(LPDWORD)&dwIP);
57 |
58 | jRegSetKey(_SELGATE_SERVER_REGISTRY, _TEXT("RemoteIP"), REG_DWORD, (LPBYTE)&dwIP, sizeof(DWORD));
59 |
60 | GetWindowText(GetDlgItem(hWndDlg, IDC_LOGINSVR_PORT), szPort, sizeof(szPort));
61 | nRemotePort = _wtoi(szPort);
62 | GetWindowText(GetDlgItem(hWndDlg, IDC_LOCALPORT), szPort, sizeof(szPort));
63 | nLocalPort = _wtoi(szPort);
64 |
65 | jRegSetKey(_SELGATE_SERVER_REGISTRY, _TEXT("RemotePort"), REG_DWORD, (LPBYTE)&nRemotePort, sizeof(DWORD));
66 | jRegSetKey(_SELGATE_SERVER_REGISTRY, _TEXT("LocalPort"), REG_DWORD, (LPBYTE)&nLocalPort, sizeof(DWORD));
67 | }
68 | case IDCANCEL:
69 | return EndDialog(hWndDlg, IDCANCEL);
70 | }
71 | }
72 | }
73 |
74 | return FALSE;
75 | }
76 |
--------------------------------------------------------------------------------
/SelGate/IOCPFunc.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | // **************************************************************************************
4 | //
5 | //
6 | //
7 | // **************************************************************************************
8 |
9 | BOOL CheckAvailableIOCP()
10 | {
11 | OSVERSIONINFO VersionInfo;
12 |
13 | GetVersionEx(&VersionInfo);
14 |
15 | if (VersionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT && VersionInfo.dwMajorVersion >= 5)
16 | return TRUE;
17 |
18 | return FALSE;
19 | }
20 |
21 | // **************************************************************************************
22 | //
23 | //
24 | //
25 | // **************************************************************************************
26 | /*
27 | INT CreateIOCPWorkerThread(HANDLE hCP, LPDWORD lpdwThreadID, LPTHREAD_START_ROUTINE WorkerThreadFunc)
28 | {
29 | if (CompletionPort != INVALID_HANDLE_VALUE)
30 | {
31 | SYSTEM_INFO SystemInfo;
32 |
33 | if ((hCP = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0)) == NULL)
34 | return -1;
35 |
36 | GetSystemInfo(&SystemInfo);
37 |
38 | for (UINT i = 0; i < SystemInfo.dwNumberOfProcessors * 2; i++)
39 | {
40 | HANDLE ThreadHandle;
41 |
42 | if ((ThreadHandle = CreateThread(NULL, 0, WorkerThreadFunc, hCP, 0, lpdwThreadID)) == NULL)
43 | return -1;
44 |
45 | CloseHandle(ThreadHandle);
46 | }
47 |
48 | return SystemInfo.dwNumberOfProcessors * 2;
49 | }
50 |
51 | return -1;
52 | }
53 | */
--------------------------------------------------------------------------------
/SelGate/IOCPFunc.h:
--------------------------------------------------------------------------------
1 | BOOL CheckAvailableIOCP();
2 | INT CreateIOCPWorkerThread(HANDLE hCP, LPDWORD lpdwThreadID, LPTHREAD_START_ROUTINE WorkerThreadFunc);
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SelGate/RESOURCE.H:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Developer Studio generated include file.
3 | // Used by SelGate.rc
4 | //
5 | #define IDS_NOTWINNT 1
6 | #define IDS_LVS_LABEL1 2
7 | #define IDS_LVS_LABEL2 3
8 | #define IDS_LVS_LABEL3 4
9 | #define IDS_STARTSERVICE 5
10 | #define IDS_STOPSERVICE 6
11 | #define IDS_CONNECT_LOGINSERVER 7
12 | #define IDS_DISCONNECT_LOGINSERVER 8
13 | #define IDS_PROGRAM_QUIT 9
14 | #define IDS_PROGRAM_TITLE 10
15 | #define IDS_CANT_CONNECT 11
16 | #define IDS_APPLY_RECONNECT 12
17 | #define IDD_DIALOG1 101
18 | #define IDR_MAINMENU 101
19 | #define IDM_FONTCOLOR 101
20 | #define IDI_MIR2 102
21 | #define IDM_BACKCOLOR 102
22 | #define IDB_TOOLBAR 103
23 | #define IDD_CONFIGDLG 104
24 | #define IDC_LOGINSVR_IP 1003
25 | #define IDC_LOGINSVR_PORT 1004
26 | #define IDC_LOCALPORT 1005
27 | #define IDC_EDIT1 1006
28 | #define IDM_STARTSERVICE 40001
29 | #define IDM_STOPSERVICE 40002
30 | #define IDM_CONFIG 40003
31 | #define IDM_EXIT 40004
32 |
33 | // Next default values for new objects
34 | //
35 | #ifdef APSTUDIO_INVOKED
36 | #ifndef APSTUDIO_READONLY_SYMBOLS
37 | #define _APS_NEXT_RESOURCE_VALUE 102
38 | #define _APS_NEXT_COMMAND_VALUE 40001
39 | #define _APS_NEXT_CONTROL_VALUE 1000
40 | #define _APS_NEXT_SYMED_VALUE 103
41 | #endif
42 | #endif
43 |
--------------------------------------------------------------------------------
/SelGate/Res/MIR2.ICO:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/SelGate/Res/MIR2.ICO
--------------------------------------------------------------------------------
/SelGate/Res/TOOLBAR.BMP:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/SelGate/Res/TOOLBAR.BMP
--------------------------------------------------------------------------------
/SelGate/SelGate.aps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/SelGate/SelGate.aps
--------------------------------------------------------------------------------
/SelGate/SelGate.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/SelGate/SelGate.h
--------------------------------------------------------------------------------
/SelGate/SelGate.ncb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/SelGate/SelGate.ncb
--------------------------------------------------------------------------------
/SelGate/SelGate.opt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/SelGate/SelGate.opt
--------------------------------------------------------------------------------
/SelGate/SelGate.plg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Build Log
5 |
6 | --------------------Configuration: SelGate - Win32 Debug--------------------
7 |
8 | Command Lines
9 | Creating command line "rc.exe /l 0x412 /fo"../_Obj_Debug/SelGate/SelGate.res" /d "_DEBUG" "C:\Works.Wemade\LegendOfMir2_Server\SelGate\SelGate.rc""
10 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP17C.tmp" with contents
11 | [
12 | /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /Fp"../_Obj_Debug/SelGate/SelGate.pch" /Yu"stdafx.h" /Fo"../_Obj_Debug/SelGate/" /Fd"../_Obj_Debug/SelGate/" /FD /GZ /c
13 | "C:\Works.Wemade\LegendOfMir2_Server\SelGate\ClientSockMsg.cpp"
14 | "C:\Works.Wemade\LegendOfMir2_Server\SelGate\ConfigDlgFunc.cpp"
15 | "C:\Works.Wemade\LegendOfMir2_Server\SelGate\MainWndProc.cpp"
16 | "C:\Works.Wemade\LegendOfMir2_Server\Def\Misc.cpp"
17 | "C:\Works.Wemade\LegendOfMir2_Server\Def\RegstryHandler.cpp"
18 | "C:\Works.Wemade\LegendOfMir2_Server\SelGate\SelGate.cpp"
19 | "C:\Works.Wemade\LegendOfMir2_Server\Def\ServerSockHandler.cpp"
20 | "C:\Works.Wemade\LegendOfMir2_Server\SelGate\ServerSockMsg.cpp"
21 | "C:\Works.Wemade\LegendOfMir2_Server\Def\_OrzEx\syncobj.cpp"
22 | "C:\Works.Wemade\LegendOfMir2_Server\SelGate\ThreadFuncForComm.cpp"
23 | "C:\Works.Wemade\LegendOfMir2_Server\SelGate\ThreadFuncForMsg.cpp"
24 | ]
25 | Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP17C.tmp"
26 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP17D.tmp" with contents
27 | [
28 | /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /Fp"../_Obj_Debug/SelGate/SelGate.pch" /Yc"stdafx.h" /Fo"../_Obj_Debug/SelGate/" /Fd"../_Obj_Debug/SelGate/" /FD /GZ /c
29 | "C:\Works.Wemade\LegendOfMir2_Server\SelGate\StdAfx.cpp"
30 | ]
31 | Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP17D.tmp"
32 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP17E.tmp" with contents
33 | [
34 | kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:yes /pdb:"../_Bin/Debug/SelGate.pdb" /debug /machine:I386 /out:"../_Bin/Debug/SelGate.exe" /pdbtype:sept
35 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\ClientSockMsg.obj
36 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\ConfigDlgFunc.obj
37 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\MainWndProc.obj
38 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\Misc.obj
39 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\RegstryHandler.obj
40 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\SelGate.obj
41 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\ServerSockHandler.obj
42 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\ServerSockMsg.obj
43 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\StdAfx.obj
44 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\syncobj.obj
45 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\ThreadFuncForComm.obj
46 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\ThreadFuncForMsg.obj
47 | \Works.Wemade\LegendOfMir2_Server\_Obj_Debug\SelGate\SelGate.res
48 | ]
49 | Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP17E.tmp"
50 | Output Window
51 | Compiling resources...
52 | Compiling...
53 | StdAfx.cpp
54 | Compiling...
55 | ClientSockMsg.cpp
56 | ConfigDlgFunc.cpp
57 | MainWndProc.cpp
58 | Misc.cpp
59 | RegstryHandler.cpp
60 | SelGate.cpp
61 | ServerSockHandler.cpp
62 | ServerSockMsg.cpp
63 | syncobj.cpp
64 | ThreadFuncForComm.cpp
65 | ThreadFuncForMsg.cpp
66 | Generating Code...
67 | Linking...
68 |
69 |
70 |
71 | Results
72 | SelGate.exe - 0 error(s), 0 warning(s)
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/SelGate/SelGate.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hcscq/M2_Server/277ae9bf4ecbecbb2bb94b5e1152cec015f8fcb7/SelGate/SelGate.rc
--------------------------------------------------------------------------------
/SelGate/SelGate.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {508416e0-55df-4dbe-9368-64341ea2d0b9}
6 | cpp;c;cxx;rc;def;r;odl;idl;hpj;bat
7 |
8 |
9 | {677be8f5-d55a-48bc-81c9-3615d4eac459}
10 | h;hpp;hxx;hm;inl
11 |
12 |
13 | {d20e2634-f63a-4585-b43a-27a2a6e3b612}
14 | ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 | Source Files
35 |
36 |
37 | Source Files
38 |
39 |
40 | Source Files
41 |
42 |
43 | Source Files
44 |
45 |
46 | Source Files
47 |
48 |
49 | Source Files
50 |
51 |
52 | Source Files
53 |
54 |
55 |
56 |
57 | Source Files
58 |
59 |
60 |
61 |
62 | Header Files
63 |
64 |
65 | Header Files
66 |
67 |
68 | Header Files
69 |
70 |
71 | Header Files
72 |
73 |
74 | Header Files
75 |
76 |
77 | Header Files
78 |
79 |
80 |
81 |
82 | Resource Files
83 |
84 |
85 | Resource Files
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/SelGate/SelGate.vcxproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/SelGate/StdAfx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // LoginGate.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/SelGate/StdAfx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
7 | #define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
8 |
9 | #if _MSC_VER > 1000
10 | #pragma once
11 | #endif // _MSC_VER > 1000
12 |
13 | //#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
14 | #define UNICODE
15 | #define _UNICODE
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #ifdef _DEBUG
23 | #include
24 | #endif
25 |
26 | #pragma warning( disable : 4146 )
27 | #pragma warning(disable:4786)
28 | #include
29 | #include
30 |
31 | #include "resource.h"
32 |
33 | #include "..\Def\EnDecode.h"
34 | #include "..\Def\ServerSockHandler.h"
35 | #include "..\Def\Queue.h"
36 | #include "..\Def\Misc.h"
37 | #include "..\Def\List.h"
38 |
39 | #include "SelGate.h"
40 |
41 | #pragma comment (lib, "ws2_32.lib")
42 | #pragma comment (lib, "comctl32.lib")
43 |
44 | // **************************************************************************************
45 |
46 | #define _BMP_CX 16
47 | #define _BMP_CY 16
48 |
49 | #define _STATUS_HEIGHT 10
50 | #define _NUMOFMAX_STATUS_PARTS 4
51 |
52 | #define _SELGATE_SERVER_CLASS _T("SelGateServerClass")
53 | #define _SELGATE_SERVER_TITLE _T("Legend of Mir II - Select Gate Server")
54 | #define _SELGATE_SERVER_REGISTRY _T("Software\\LegendOfMir\\SelGate")
55 |
56 | #define _IDM_SERVERSOCK_MSG WM_USER + 1000
57 | #define _IDM_CLIENTSOCK_MSG _IDM_SERVERSOCK_MSG + 1
58 |
59 | #define _IDW_TOOLBAR _IDM_SERVERSOCK_MSG + 2
60 | #define _IDW_STATUSBAR _IDM_SERVERSOCK_MSG + 3
61 |
62 | #define _ID_TIMER_KEEPALIVE _IDM_SERVERSOCK_MSG + 4
63 | #define _ID_TIMER_CONNECTSERVER _IDM_SERVERSOCK_MSG + 5
64 |
65 | //{{AFX_INSERT_LOCATION}}
66 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
67 |
68 | #endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
69 |
--------------------------------------------------------------------------------
/SelGate/ThreadFuncForComm.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | #define PACKET_KEEPALIVE "%--$"
4 |
5 | extern HWND g_hToolBar;
6 | extern HWND g_hStatusBar;
7 |
8 | extern SOCKET g_csock;
9 | extern SOCKADDR_IN g_caddr;
10 |
11 | void SendExToServer(char *pszPacket);
12 |
13 | BOOL jRegGetKey(LPCTSTR pSubKeyName, LPCTSTR pValueName, LPBYTE pValue);
14 |
15 | VOID WINAPI OnTimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
16 | {
17 | switch (idEvent)
18 | {
19 | case _ID_TIMER_KEEPALIVE:
20 | {
21 | if (g_csock != INVALID_SOCKET)
22 | {
23 | SendExToServer(PACKET_KEEPALIVE);
24 | SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(2, 0), (LPARAM)_TEXT("Check Activity"));
25 | }
26 |
27 | break;
28 | }
29 | case _ID_TIMER_CONNECTSERVER:
30 | {
31 | if (g_csock == INVALID_SOCKET)
32 | {
33 | DWORD dwIP = 0;
34 | int nPort = 0;
35 |
36 | InsertLogMsg(IDS_APPLY_RECONNECT);
37 |
38 | jRegGetKey(_SELGATE_SERVER_REGISTRY, _TEXT("RemoteIP"), (LPBYTE)&dwIP);
39 |
40 | if (!jRegGetKey(_SELGATE_SERVER_REGISTRY, _TEXT("RemotePort"), (LPBYTE)&nPort))
41 | nPort = 5000;
42 |
43 | ConnectToServer(g_csock, &g_caddr, _IDM_CLIENTSOCK_MSG, NULL, dwIP, nPort, FD_CONNECT|FD_READ|FD_CLOSE);
44 | }
45 |
46 | break;
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/SelGate/ThreadFuncForMsg.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 |
3 | extern HWND g_hStatusBar;
4 |
5 | extern SOCKET g_csock;
6 |
7 | extern CWHQueue g_xMsgQueue;
8 | extern CWHList g_xSessionList;
9 |
10 | extern BOOL g_fTerminated;
11 |
12 | DWORD WINAPI ThreadFuncForMsg(LPVOID lpParameter)
13 | {
14 | char szData[DATA_BUFSIZE];
15 | char szRemainData[DATA_BUFSIZE];
16 | char *pszData;
17 | char *pszFirst, *pszEnd;
18 | int nCount = 0, nDataPos = 0, nRemainDataLen = 0, nRemain = 0;
19 | int nLoop;
20 | int nSocket;
21 |
22 | FILETIME ftKernelTimeStart, ftKernelTimeEnd;
23 | FILETIME ftUserTimeStart, ftUserTimeEnd;
24 | FILETIME ftDummy, ftTotalTimeElapsed;
25 | __int64 qwKernelTimeElapsed, qwUserTimeElapsed, qwTotalTimeElapsed;
26 | TCHAR wszThreadTime[32];
27 |
28 | WSABUF Buf;
29 | DWORD dwSendBytes = 0;
30 |
31 | while (TRUE)
32 | {
33 | GetThreadTimes(GetCurrentThread(), &ftDummy, &ftDummy, &ftKernelTimeStart, &ftUserTimeStart);
34 |
35 | if (g_fTerminated)
36 | return 0;
37 |
38 | nCount = g_xMsgQueue.GetCount();
39 | nDataPos = 0;
40 | pszFirst = NULL;
41 |
42 | if (nCount)
43 | {
44 | if (nRemainDataLen)
45 | {
46 | memmove(szData, szRemainData, nRemainDataLen);
47 | nDataPos = nRemainDataLen;
48 | }
49 |
50 | for (nLoop = 0; nLoop < nCount; nLoop++)
51 | {
52 | pszData = (char *)g_xMsgQueue.PopQ();
53 |
54 | if (!pszData) continue;
55 |
56 | if (pszFirst)
57 | {
58 | nRemain = memlen(pszFirst);
59 |
60 | if (nRemain)
61 | {
62 | memmove(szData, pszFirst, nRemain);
63 | nDataPos = 0;
64 | }
65 | }
66 | else
67 | nDataPos = 0;
68 |
69 | memmove((szData + nDataPos), pszData, memlen(pszData));
70 |
71 | pszEnd = &szData[0];
72 |
73 | while (TRUE)
74 | {
75 | if ((pszFirst = (char *)memchr(pszEnd, '%', memlen(pszEnd))) && (pszEnd = (char *)memchr(pszFirst, '$', memlen(pszFirst))))
76 | {
77 | *pszEnd = '\0';
78 |
79 | if (*(pszFirst + 1) == '+')
80 | {
81 | if (*(pszFirst + 2) == '-')
82 | InsertLogMsg(_TEXT("Kick User."));
83 | else
84 | SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(2, 0), (LPARAM)_TEXT("Activation")); // Received keep alive check code from login server
85 | }
86 | else
87 | {
88 | if (pszEnd = strchr(pszFirst, '/'))
89 | {
90 | pszEnd++;
91 |
92 | if (nSocket = AnsiStrToVal(pszFirst + 1))
93 | {
94 | Buf.len = memlen(pszEnd) - 1;
95 | Buf.buf = pszEnd;
96 |
97 | WSASend((SOCKET)nSocket, &Buf, 1, &dwSendBytes, 0, NULL, NULL);
98 | // send((SOCKET)nSocket, pszEnd, memlen(pszEnd) - 1, 0);
99 | }
100 | }
101 | }
102 | }
103 | else
104 | break;
105 | } // while loop
106 |
107 | delete [] pszData;
108 | } // for loop
109 |
110 | if (pszFirst)
111 | {
112 | nRemain = memlen(pszFirst);
113 |
114 | if (nRemain)
115 | {
116 | memmove(szRemainData, pszFirst, nRemain);
117 | nRemainDataLen = nRemain;
118 | }
119 | else
120 | nRemainDataLen = 0;
121 | }
122 | } // if (nCount)
123 |
124 | GetThreadTimes(GetCurrentThread(), &ftDummy, &ftDummy, &ftKernelTimeEnd, &ftUserTimeEnd);
125 |
126 | qwKernelTimeElapsed = FileTimeToQuadWord(&ftKernelTimeEnd) - FileTimeToQuadWord(&ftKernelTimeStart);
127 | qwUserTimeElapsed = FileTimeToQuadWord(&ftUserTimeEnd) - FileTimeToQuadWord(&ftUserTimeStart);
128 |
129 | qwTotalTimeElapsed = qwKernelTimeElapsed + qwUserTimeElapsed;
130 |
131 | QuadTimeToFileTime(qwTotalTimeElapsed, &ftTotalTimeElapsed);
132 |
133 | wsprintf(wszThreadTime, _TEXT("%u%u ns"), ftTotalTimeElapsed.dwHighDateTime, ftTotalTimeElapsed.dwLowDateTime);
134 |
135 | SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(4, 0), (LPARAM)wszThreadTime);
136 |
137 | SleepEx(1, TRUE);
138 | }
139 |
140 | return 0;
141 | }
142 |
--------------------------------------------------------------------------------