Skip to content
GitLab
Menu
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
sloongnet
engine
Commits
cfe163f4
Commit
cfe163f4
authored
9 years ago
by
wcb
Browse files
Options
Download
Email Patches
Plain Diff
fixed
#13
parent
5c305fd6
master
develop
feat/138_调试模式
next_gen
release_0.24.3
temp_for_c
v0.24.2
v0.24.1
v0.24.0
v0.23.5
v0.23.4
v0.23.3
v0.23.2
v0.23.1
v0.23.0
v0.22.5
v0.22.4
v0.22.3
v0.22.2
v0.22.1
v0.22.0
v0.21.9
v0.21.8
v0.21.7
v0.21.6
v0.21.5
v0.21.4
v0.21.3
v0.21.2
v0.21.1
v0.21.0
v0.20.2
v0.20.1
v0.20.0
v0.19.2
v0.19.1
v0.19.0
v0.18.8
v0.18.7
v0.18.6
v0.18.5
v0.18.4
v0.18.3
v0.18.2
v0.18.1
v0.18.0
v0.17.9
v0.17.8
v0.17.7
v0.17.6
v0.17.5
v0.17.4
v0.17.3
v0.17.2
v0.17.1
v0.17.0
v0.16.5
v0.16.4
v0.16.3
v0.16.2
v0.16.1
v0.16.0
v0.15.5
v0.15.4
v0.15.3
v0.15.2
v0.15.1
v0.15
v0.14.1
v0.14
v0.13.1
v0.13
v0.12
v0.11.1
v0.11
v0.10.2
v0.10.1
v0.10
v0.9.1
v0.9
v0.8.1
v0.8
v0.7.7
v0.7.6
v0.7.5
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.8
v0.6.7
v0.6.6
v0.6.5
v0.6.4
v0.6.2
v0.6.1
v0.6.0
v0.5.3
v0.5.2
No related merge requests found
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
sloongnet/dbproc.cpp
+4
-3
sloongnet/dbproc.cpp
sloongnet/dbproc.h
+2
-1
sloongnet/dbproc.h
sloongnet/globalfunction.cpp
+2
-2
sloongnet/globalfunction.cpp
sloongnet/globalfunction.h
+2
-1
sloongnet/globalfunction.h
sloongnet/msgproc.cpp
+3
-3
sloongnet/msgproc.cpp
sloongnet/msgproc.h
+2
-1
sloongnet/msgproc.h
sloongnet/serverconfig.cpp
+31
-0
sloongnet/serverconfig.cpp
sloongnet/serverconfig.h
+4
-0
sloongnet/serverconfig.h
sloongnet/sloongnet.vcxproj
+1
-0
sloongnet/sloongnet.vcxproj
sloongnet/sloongnet.vcxproj.filters
+3
-0
sloongnet/sloongnet.vcxproj.filters
sloongnet/structs.h
+19
-0
sloongnet/structs.h
sloongnet/userv.cpp
+1
-1
sloongnet/userv.cpp
with
74 additions
and
12 deletions
+74
-12
sloongnet/dbproc.cpp
+
4
-
3
View file @
cfe163f4
#include
<univ/univ.h>
#include
<univ/log.h>
#include
"dbproc.h"
#include
<mysql/mysql
.h
>
#include
"structs
.h
"
using
namespace
Sloong
;
using
namespace
Sloong
::
Universal
;
CDBProc
::
CDBProc
()
...
...
@@ -14,9 +14,10 @@ CDBProc::~CDBProc()
mysql_close
(
&
m_MySql
);
}
void
Sloong
::
CDBProc
::
Connect
(
string
ip
,
string
user
,
string
passwd
,
string
db
,
int
port
)
void
Sloong
::
CDBProc
::
Connect
(
MySQLConnectInfo
*
info
)
{
mysql_real_connect
(
&
m_MySql
,
ip
.
c_str
(),
user
.
c_str
(),
passwd
.
c_str
(),
db
.
c_str
(),
port
,
NULL
,
0
);
mysql_real_connect
(
&
m_MySql
,
info
->
Address
.
c_str
(),
info
->
User
.
c_str
(),
info
->
Password
.
c_str
(),
info
->
Database
.
c_str
(),
info
->
Port
,
NULL
,
0
);
mysql_set_character_set
(
&
m_MySql
,
"utf8"
);
}
...
...
This diff is collapsed.
Click to expand it.
sloongnet/dbproc.h
+
2
-
1
View file @
cfe163f4
...
...
@@ -4,13 +4,14 @@
#include
<mysql/mysql.h>
namespace
Sloong
{
struct
MySQLConnectInfo
;
class
CDBProc
{
public:
CDBProc
();
virtual
~
CDBProc
();
void
Connect
(
string
ip
,
string
user
,
string
passwd
,
string
db
,
int
port
);
void
Connect
(
MySQLConnectInfo
*
info
);
int
Modify
(
string
sqlCmd
);
int
Query
(
string
sqlCmd
,
vector
<
string
>&
vRes
);
...
...
This diff is collapsed.
Click to expand it.
sloongnet/globalfunction.cpp
+
2
-
2
View file @
cfe163f4
...
...
@@ -61,11 +61,11 @@ CGlobalFunction::~CGlobalFunction()
SAFE_DELETE_ARR
(
m_pReloadTagList
);
}
void
Sloong
::
CGlobalFunction
::
Initialize
(
CLog
*
plog
)
void
Sloong
::
CGlobalFunction
::
Initialize
(
CLog
*
plog
,
MySQLConnectInfo
*
info
)
{
m_pLog
=
plog
;
// connect to db
m_pDBProc
->
Connect
(
"localhost"
,
"root"
,
"sloong"
,
"sloong"
,
0
);
m_pDBProc
->
Connect
(
info
);
}
...
...
This diff is collapsed.
Click to expand it.
sloongnet/globalfunction.h
+
2
-
1
View file @
cfe163f4
...
...
@@ -18,13 +18,14 @@ namespace Sloong
using
namespace
Universal
;
class
CUtility
;
class
CDBProc
;
struct
MySQLConnectInfo
;
class
CGlobalFunction
{
public:
CGlobalFunction
();
~
CGlobalFunction
();
void
Initialize
(
CLog
*
plog
);
void
Initialize
(
CLog
*
plog
,
MySQLConnectInfo
*
info
);
void
InitLua
(
CLua
*
pLua
);
protected:
CUtility
*
m_pUtility
;
...
...
This diff is collapsed.
Click to expand it.
sloongnet/msgproc.cpp
+
3
-
3
View file @
cfe163f4
...
...
@@ -22,12 +22,12 @@ CMsgProc::~CMsgProc()
SAFE_DELETE
(
m_pGFunc
);
}
void
CMsgProc
::
Initialize
(
CLog
*
pLog
,
string
scriptFolder
)
void
CMsgProc
::
Initialize
(
CLog
*
pLog
,
string
scriptFolder
,
MySQLConnectInfo
*
info
)
{
m_pLog
=
pLog
;
m_strScriptFolder
=
scriptFolder
;
m_pGFunc
->
Initialize
(
m_pLog
);
m_pGFunc
->
Initialize
(
m_pLog
,
info
);
}
void
CMsgProc
::
InitLua
(
CLua
*
pLua
,
string
path
)
...
...
This diff is collapsed.
Click to expand it.
sloongnet/msgproc.h
+
2
-
1
View file @
cfe163f4
...
...
@@ -11,12 +11,13 @@ namespace Sloong
{
using
namespace
Universal
;
class
CGlobalFunction
;
struct
MySQLConnectInfo
;
class
CMsgProc
{
public:
CMsgProc
();
~
CMsgProc
();
void
Initialize
(
CLog
*
pLog
,
string
scriptFolder
);
void
Initialize
(
CLog
*
pLog
,
string
scriptFolder
,
MySQLConnectInfo
*
info
);
int
MsgProcess
(
int
id
,
CLuaPacket
*
pUInfo
,
string
&
msg
,
string
&
res
,
char
*&
pBuf
);
int
NewThreadInit
();
void
InitLua
(
CLua
*
pLua
,
string
folder
);
...
...
This diff is collapsed.
Click to expand it.
sloongnet/serverconfig.cpp
+
31
-
0
View file @
cfe163f4
...
...
@@ -7,6 +7,14 @@ using namespace Sloong;
using
namespace
Sloong
::
Universal
;
CServerConfig
::
CServerConfig
()
{
// DB init
m_oConnectInfo
.
Port
=
3306
;
m_oConnectInfo
.
Address
=
"localhost"
;
m_oConnectInfo
.
User
=
"root"
;
m_oConnectInfo
.
Password
=
"sloong"
;
m_oConnectInfo
.
Database
=
"sloong"
;
// Server init
m_nPort
=
9009
;
m_bDebug
=
true
;
m_strLogPath
=
"./log.log"
;
...
...
@@ -39,6 +47,29 @@ bool CServerConfig::LoadConfigFile(string path)
int
nRes
;
string
strRes
;
bool
bRes
;
// load connect info
nRes
=
g_key_file_get_integer
(
conf
,
"MySQL"
,
"Port"
,
&
err
);
if
(
!
err
)
m_oConnectInfo
.
Port
=
nRes
;
g_clear_error
(
&
err
);
strRes
=
g_key_file_get_string
(
conf
,
"MySQL"
,
"Address"
,
&
err
);
if
(
!
err
)
m_oConnectInfo
.
Address
=
strRes
;
g_clear_error
(
&
err
);
strRes
=
g_key_file_get_string
(
conf
,
"MySQL"
,
"User"
,
&
err
);
if
(
!
err
)
m_oConnectInfo
.
User
=
strRes
;
g_clear_error
(
&
err
);
strRes
=
g_key_file_get_string
(
conf
,
"MySQL"
,
"Password"
,
&
err
);
if
(
!
err
)
m_oConnectInfo
.
Password
=
strRes
;
g_clear_error
(
&
err
);
strRes
=
g_key_file_get_string
(
conf
,
"MySQL"
,
"Database"
,
&
err
);
if
(
!
err
)
m_oConnectInfo
.
Database
=
strRes
;
g_clear_error
(
&
err
);
nRes
=
g_key_file_get_integer
(
conf
,
"Server"
,
"Port"
,
&
err
);
if
(
!
err
)
m_nPort
=
nRes
;
...
...
This diff is collapsed.
Click to expand it.
sloongnet/serverconfig.h
+
4
-
0
View file @
cfe163f4
...
...
@@ -2,6 +2,7 @@
#define SERVERCONFIG_H
#include
<string>
#include
"structs.h"
using
namespace
std
;
namespace
Sloong
{
...
...
@@ -13,6 +14,9 @@ namespace Sloong
bool
LoadConfigFile
(
string
path
);
// DB config
MySQLConnectInfo
m_oConnectInfo
;
// Server config
int
m_nPort
;
string
m_strLogPath
;
...
...
This diff is collapsed.
Click to expand it.
sloongnet/sloongnet.vcxproj
+
1
-
0
View file @
cfe163f4
...
...
@@ -85,6 +85,7 @@
<ClInclude
Include=
"progressbar.h"
/>
<ClInclude
Include=
"serverconfig.h"
/>
<ClInclude
Include=
"sockinfo.h"
/>
<ClInclude
Include=
"structs.h"
/>
<ClInclude
Include=
"userv.h"
/>
<ClInclude
Include=
"utility.h"
/>
<ClInclude
Include=
"version.h"
/>
...
...
This diff is collapsed.
Click to expand it.
sloongnet/sloongnet.vcxproj.filters
+
3
-
0
View file @
cfe163f4
...
...
@@ -87,6 +87,9 @@
<ClInclude
Include=
"CmdProcess.h"
>
<Filter>
Header files
</Filter>
</ClInclude>
<ClInclude
Include=
"structs.h"
>
<Filter>
Header files
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"epollex.cpp"
>
...
...
This diff is collapsed.
Click to expand it.
sloongnet/structs.h
0 → 100644
+
19
-
0
View file @
cfe163f4
#ifndef STRUCTS_H
#define STRUCTS_H
#include
"main.h"
namespace
Sloong
{
struct
MySQLConnectInfo
{
string
Address
;
int
Port
;
string
User
;
string
Password
;
string
Database
;
};
}
#endif // !STRUCTS_H
This diff is collapsed.
Click to expand it.
sloongnet/userv.cpp
+
1
-
1
View file @
cfe163f4
...
...
@@ -50,7 +50,7 @@ void SloongWallUS::Initialize(CServerConfig* config)
m_pLog
->
SetWorkInterval
(
config
->
m_nSleepInterval
);
m_pEpoll
->
Initialize
(
m_pLog
,
config
->
m_nPort
,
config
->
m_nEPoolThreadQuantity
,
config
->
m_nPriorityLevel
,
config
->
m_bEnableSwiftNumberSup
,
config
->
m_bEnableMD5Check
);
m_pEpoll
->
SetSEM
(
&
m_oSem
);
m_pMsgProc
->
Initialize
(
m_pLog
,
config
->
m_strScriptFolder
);
m_pMsgProc
->
Initialize
(
m_pLog
,
config
->
m_strScriptFolder
,
&
config
->
m_oConnectInfo
);
}
void
SloongWallUS
::
Run
()
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets