Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ylmbtm committed Aug 18, 2021
1 parent a667685 commit e28acad
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Proto/proto_raw/Msg_ID.proto
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum MessageID {
MSG_LOGIC_REGTO_DBSVR_REQ = 100031; //逻辑服注册到db服请求
MSG_LOGIC_REGTO_DBSVR_ACK = 100032; //逻辑服注册到db服返回

MSG_SET_LAST_SERVER_NTY = 100034;
MSG_SET_LAST_SERVER_NTY = 100033;

MSG_GM_SHUTDOWN_SVR_REQ = 100035;
MSG_GM_SHUTDOWN_SVR_ACK = 100036;
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ Game Engine Frame
跨平台的多进程游戏服务器框架,网络层分别使用SocketApi, Boost Asio, Libuv三种方式实现,
框架内使用共享内存,无锁队列,对象池,内存池来提高服务器性能。

还有一个不断完善的Unity3D客户端,游戏包含大量完整资源,坐骑,宠物,伙伴,装备, 这些均可上阵和穿戴, 并可进入副本战斗,多人玩法也己实现,持续开发中。
gitee地址: https://gitee.com/ylmbtm/GameProject3

交流QQ群 : 45139128
还有一个不断完善的Unity3D客户端,游戏包含大量完整资源,坐骑,宠物,伙伴,装备, 这些均可上阵和穿戴, 并可进入副本战斗,多人玩法也己实现,持续开发中(完整资源在群文件中)。

#### 服务器部署启动说明
##### 1.编译
Expand All @@ -32,9 +29,16 @@ gitee地址: https://gitee.com/ylmbtm/GameProject3
#### 文档与教程
1.群友 Binaryhobart(450282550) 提供的视频搭建教程 [教程地址](https://www.bilibili.com/video/BV1k5411s7Vf?from=search&seid=3304544258866101487)

#### 体验客户端效果(群文件中有全部客户端代码及资源)
gitee地址: https://gitee.com/ylmbtm/GameProject3

交流QQ群 : 871115813
公众号:![public1](https://github.com/ylmbtm/resource/blob/master/20210818175029.png)


#### 体验客户端效果(群文件中有全部客户端代码及资源)
![login1](https://github.com/ylmbtm/resource/blob/master/01.png)
![login2](https://github.com/ylmbtm/resource/blob/master/02.png)
![login3](https://github.com/ylmbtm/resource/blob/master/03.png)
![login4](https://github.com/ylmbtm/resource/blob/master/04.png)


3 changes: 2 additions & 1 deletion Server/Src/AccountServer/AccountMsgHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ BOOL CAccountMsgHandler::OnMsgAccontLoginReq(NetPacket* pPacket)

AccountLoginAck Ack;
Ack.set_review(Req.review());

Ack.set_channel(Req.channel());
Ack.set_ipaddr(Req.loginlog().ipaddr());
std::string strAccountName = Req.accountname();

if (!m_AccountManager.CheckAccountName(strAccountName, Req.fromchannel()))
Expand Down
2 changes: 1 addition & 1 deletion Server/Src/AccountServer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(AccountServer)
SET(PROJECT_ROOT_PATH ".")
add_definitions(-std=c++11)
add_definitions(-w)
include_directories(./ ../ServerEngine ../Lua ../ServerEngine/DBInterface ../ServerData ../../Common/Mysql ../../Common/protobuf/src ../Message ../LogData ../PublicData ../WatcherClient)
include_directories(./ ../ServerEngine ../../Common/Lua ../ServerEngine/DBInterface ../ServerData ../../Common/Mysql ../../Common/protobuf/src ../Message ../LogData ../PublicData ../WatcherClient)
link_directories(../../Common/lib /usr/lib64/mysql)


Expand Down
2 changes: 1 addition & 1 deletion Server/Src/DBServer/GameService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ BOOL CGameService::Init()
return FALSE;
}

m_DBMsgHandler.Init(0);
ERROR_RETURN_FALSE(m_DBMsgHandler.Init(0));

ERROR_RETURN_FALSE(m_DBWriterManger.Init());

Expand Down
1 change: 1 addition & 0 deletions Server/Src/LoginServer/GameService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ BOOL CGameService::OnCloseConnect(UINT32 nConnID)
if(nConnID == m_dwAccountConnID)
{
m_dwAccountConnID = 0;
CLog::GetInstancePtr()->LogError("CGameService::OnCloseConnect Disconnect From Account Server.");
}

CLoginClientMgr::GetInstancePtr()->OnCloseConnect(nConnID);
Expand Down
2 changes: 1 addition & 1 deletion Server/Src/LoginServer/LogicSvrManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct LogicServerNode
UINT32 m_dwMaxVersion; //最大可见版本
UINT64 m_uSvrOpenTime; //开服时间
std::string m_strSvrName; //服务器名字
std::string m_strOuterAddr; //服务器的外网地址
std::string m_strOuterAddr; //服务器的外网地址
std::string m_strInnerAddr; //服务器的内网地址
UINT64 m_uLastUpdate; //服务器最后更新时间
std::set<UINT32> m_CheckIpList; //过滤的IP地址
Expand Down
2 changes: 1 addition & 1 deletion Server/Src/ProxyServer/ProxyMsgHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ BOOL CProxyMsgHandler::OnMsgReconnectReq(NetPacket* pPacket)
CConnection* pConn = ServiceBase::GetInstancePtr()->GetConnectionByID(pPlayer->GetConnID());
if (pConn != NULL)
{
CLog::GetInstancePtr()->LogError("CProxyMsgHandler::OnMsgReconnectReq Error orgin connect alreay exist:%d", pPlayer->GetConnID());
CLog::GetInstancePtr()->LogError("CProxyMsgHandler::OnMsgReconnectReq Error orgin connect alreay exist OrgConnID:%d, NewConnID:%d", pPlayer->GetConnID(), pPacket->m_dwConnID);
pConn->SetConnectionData(0);
}
else
Expand Down
32 changes: 16 additions & 16 deletions Server/Src/ServerEngine/AVLTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,22 +517,22 @@ bool AVLTree<TKey, TValue>::InsertInner(TNodeTypePtr& pParentNode, TNodeTypePtr
template<typename TKey, typename TValue>
TreeNode<TKey, TValue>* AVLTree<TKey, TValue>::FindInner(TNodeTypePtr pNode, TKey Key)
{
if(pNode == NULL) //如果节点为空说明没找到,返回NULL
{
return NULL;
}
if(pNode->m_Key > Key)//如果x小于节点的值,就继续在节点的左子树中查找x
{
return FindInner(pNode->m_pLeft, Key);
}
else if(pNode->m_Key < Key) //如果x大于节点的值,就继续在节点的左子树中查找x
{
return FindInner(pNode->m_pRight, Key);
}
else
{
return pNode;
}
if(pNode == NULL) //如果节点为空说明没找到,返回NULL
{
return NULL;
}

if(pNode->m_Key > Key)//如果x小于节点的值,就继续在节点的左子树中查找x
{
return FindInner(pNode->m_pLeft, Key);
}

if(pNode->m_Key < Key) //如果x大于节点的值,就继续在节点的左子树中查找x
{
return FindInner(pNode->m_pRight, Key);
}

return pNode;
}
//查找接口
template<typename TKey, typename TValue>
Expand Down
24 changes: 22 additions & 2 deletions Server/Src/ServerEngine/ServiceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ BOOL ServiceBase::OnCloseConnect(UINT32 nConnID)

BOOL ServiceBase::OnNewConnect(UINT32 nConnID)
{
ERROR_RETURN_FALSE(nConnID != 0);
m_QueueLock.Lock();
ERROR_RETURN_FALSE(nConnID != 0);
m_QueueLock.Lock();
m_pRecvDataQueue->emplace_back(NetPacket(nConnID, NULL, NEW_CONNECTION));
m_QueueLock.Unlock();
return TRUE;
Expand Down Expand Up @@ -227,3 +227,23 @@ BOOL ServiceBase::Update()

return TRUE;
}

BOOL ServiceBase::WaitOneFrame(UINT32 nFrams)
{
if (nFrams < 1)
{
nFrams = 1;
}

static UINT64 uNextTick = CommonFunc::GetTickCount();
UINT64 uCurTick = CommonFunc::GetTickCount();

if (uNextTick > uCurTick)
{
CommonFunc::Sleep(uNextTick - uCurTick);
}

uNextTick = uNextTick + 1000 / nFrams;

return TRUE;
}
2 changes: 2 additions & 0 deletions Server/Src/ServerEngine/ServiceBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class ServiceBase : public IDataHandler//, public CEventFuncManager

BOOL Update();

BOOL WaitOneFrame(UINT32 nFrams);

protected:
IPacketDispatcher* m_pPacketDispatcher;

Expand Down

0 comments on commit e28acad

Please sign in to comment.