Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ylmbtm committed Jan 19, 2021
1 parent fece900 commit 6ecfc06
Showing 12 changed files with 88 additions and 40 deletions.
3 changes: 2 additions & 1 deletion Server/Src/LogicServer/PlayerObject.cpp
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ BOOL CPlayerObject::OnCreate(UINT64 u64RoleID)
ERROR_RETURN_FALSE(pBase != NULL);
pBase->OnCreate(u64RoleID);
}

return TRUE;
}

@@ -209,7 +210,7 @@ BOOL CPlayerObject::SendMsgProtoBuf(UINT32 dwMsgID, const google::protobuf::Mess
{
if (m_dwProxyConnID == 0)
{
CLog::GetInstancePtr()->LogError("Error SendMsgProtoBuf Failed m_dwProxyConnID==0 MessageID:%d, RoleID:%ld", dwMsgID, m_u64ID);
CLog::GetInstancePtr()->LogWarn("Error SendMsgProtoBuf Failed m_dwProxyConnID==0 MessageID:%d, RoleID:%ld", dwMsgID, m_u64ID);
return FALSE;
}

2 changes: 1 addition & 1 deletion Server/Src/LogicServer/WebCommandMgr.cpp
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ BOOL CLogicMsgHandler::ProcessGMCommand(UINT64 u64ID, std::vector<std::string>&
BOOL CWebCommandMgr::OnMsgGmCommandReq(NetPacket* pNetPacket)
{
CHAR szMsgBuf[1024] = { 0 };
strncpy(szMsgBuf, pNetPacket->m_pDataBuffer->GetData(), pNetPacket->m_pDataBuffer->GetBodyLenth());
CommonConvert::StrCopy(szMsgBuf, pNetPacket->m_pDataBuffer->GetData(), pNetPacket->m_pDataBuffer->GetBodyLenth() + 1);

HttpParameter Params;
Params.ParseStringToMap(szMsgBuf);
5 changes: 3 additions & 2 deletions Server/Src/LoginServer/LogicSvrManager.cpp
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ BOOL LogicSvrManager::RegisterLogicServer(UINT32 dwConnID, UINT32 dwServerID, UI
pNode->m_dwWatchPort = dwWatchPort;
pNode->m_strSvrName = strSvrName;
pNode->m_strInnerAddr = strInnderIp;
pNode->m_uSvrOpenTime = CommonFunc::GetCurrTime();
pNode->m_eChangeStatus = EUS_NEW_REG;
pNode->m_ServerStatus = ESS_SVR_ONLINE;
insert(std::make_pair(dwServerID, pNode));
@@ -391,8 +392,8 @@ BOOL LogicSvrManager::SaveLogicServerThread()

if (pTempNode->m_eChangeStatus == EUS_NEW_REG)
{
snprintf(szSql, SQL_BUFF_LEN, "insert into server_list(id, name, outer_ip,inner_ip, port,http_port,watch_port,svr_flag, corner_mark,min_version, max_version, check_chan, check_ip) values(%d, '%s', '%s','%s', %d, %d, %d, %d, %d, '%s','%s','%s','%s');",
pTempNode->m_dwServerID, pTempNode->m_strSvrName.c_str(), "127.0.0.1", pTempNode->m_strInnerAddr.c_str(), pTempNode->m_dwPort, pTempNode->m_dwHttpPort, pTempNode->m_dwWatchPort, pTempNode->m_ServerFlag, 0, "1.0.0", "9.0.0", "*", "*");
snprintf(szSql, SQL_BUFF_LEN, "insert into server_list(id, name, outer_ip,inner_ip, port,http_port,watch_port,svr_flag, corner_mark,opentime,min_version, max_version, check_chan, check_ip) values(%d, '%s', '%s','%s', %d, %d, %d, %d, %d, %lld,'%s','%s','%s','%s');",
pTempNode->m_dwServerID, pTempNode->m_strSvrName.c_str(), "127.0.0.1", pTempNode->m_strInnerAddr.c_str(), pTempNode->m_dwPort, pTempNode->m_dwHttpPort, pTempNode->m_dwWatchPort, pTempNode->m_ServerFlag, pTempNode->m_CornerMark, pTempNode->m_uSvrOpenTime, "1.0.0", "9.0.0", "*", "*");
if (tDBConnection.execSQL(szSql) < 0)
{
CLog::GetInstancePtr()->LogError("LogicSvrManager::SaveLogicServerInfo Error :%s", tDBConnection.GetErrorMsg());
1 change: 1 addition & 0 deletions Server/Src/ProxyServer/GameService.cpp
Original file line number Diff line number Diff line change
@@ -76,6 +76,7 @@ BOOL CGameService::OnNewConnect(UINT32 nConnID)
{
m_bLogicConnect = TRUE;
}

m_ProxyMsgHandler.OnNewConnect(nConnID);

CWatcherClient::GetInstancePtr()->OnNewConnect(nConnID);
26 changes: 26 additions & 0 deletions Server/Src/ServerEngine/CommonFunc.cpp
Original file line number Diff line number Diff line change
@@ -664,6 +664,32 @@ UINT32 CommonFunc::GetProcessID(std::string strProcName)
#endif
}

BOOL CommonFunc::CreateProcess(std::string strProcName, std::string strCommandLine)
{
#ifdef WIN32
STARTUPINFO stStartUpInfo;
memset(&stStartUpInfo, 0, sizeof(stStartUpInfo));
stStartUpInfo.cb = sizeof(stStartUpInfo);

PROCESS_INFORMATION stProcessInfo;
memset(&stProcessInfo, 0, sizeof(stProcessInfo));

if (!CreateProcess(strProcName.c_str(), (LPSTR)strCommandLine.c_str(), NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &stStartUpInfo, &stProcessInfo))
{
return FALSE;
}
#else
std::string strExe = "./" + strProcName;
if (execl(strExe.c_str(), strProcName.c_str(), strCommandLine.c_str(), (char*)0) < 0)
{
return FALSE;
}

#endif

return TRUE;
}

BOOL CommonFunc::IsAlreadyRun(std::string strSignName)
{
#ifdef WIN32
2 changes: 2 additions & 0 deletions Server/Src/ServerEngine/CommonFunc.h
Original file line number Diff line number Diff line change
@@ -81,6 +81,8 @@ BOOL IsProcessExist(UINT64 dwPid);

UINT32 GetProcessID(std::string strProcName);

BOOL CreateProcess(std::string strProcName, std::string strCommandLine);

BOOL IsAlreadyRun(std::string strSignName);

BOOL PrintColorText(CHAR* pSzText, INT32 nColor);
13 changes: 13 additions & 0 deletions Server/Src/ServerEngine/PacketHeader.h
Original file line number Diff line number Diff line change
@@ -16,6 +16,19 @@ struct PacketHeader
UINT32 dwUserData; //客户端在副本中的情况下,dwUserData是copyguid, 在逻辑服的情况下, 部分协议充当客户端连接ID
};

struct PacketHeader2
{
UINT32 CheckCode: 8;
UINT32 dwSize : 24;
UINT32 dwPacketNo : 8; //生成序号 = wCommandID^dwSize+index(每个包自动增长索引); 还原序号 = pHeader->dwPacketNo - pHeader->wCommandID^pHeader->dwSize;
UINT32 Compress : 1;
UINT32 Encrypt : 1;
UINT32 dwMsgID: 22;
UINT64 u64TargetID;
UINT32 dwUserData; //客户端在副本中的情况下,dwUserData是copyguid, 在逻辑服的情况下, 部分协议充当客户端连接ID
};


#pragma pack(pop)


4 changes: 2 additions & 2 deletions Server/Src/ServerEngine/SharedMemory.cpp
Original file line number Diff line number Diff line change
@@ -112,8 +112,7 @@ BOOL SharedMemoryBase::NewPage()
//----------------------------------------------
void SharedMemoryBase::InitPage(shareMemoryPage& rPage)
{
UINT32 size = 0;
size = m_nCountperPage * m_rawblockSize;
UINT32 size = m_nCountperPage * m_rawblockSize;
char* pdata = rPage.m_pdata;
memset(pdata, 0, size);

@@ -252,6 +251,7 @@ SharedMemoryBase::SharedMemoryBase(const UINT32& nModuleID, UINT32 rawblockSize,
m_nPageCount++;
m_nCount += m_nCountperPage;
InitPage(firstpage);

m_ShareMemoryPageMapping.push_back(firstpage);
}

63 changes: 30 additions & 33 deletions Server/Src/ServerEngine_asio/ServerEngine_asio.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -42,9 +42,6 @@
<ClCompile Include="..\ServerEngine\CommonSocket.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="..\ServerEngine\CommonWorkThread.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="..\ServerEngine\ConfigFile.cpp">
<Filter>源文件</Filter>
</ClCompile>
@@ -95,9 +92,6 @@
<ClInclude Include="stdafx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="EventFuncManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\LockFreeQueue.h">
<Filter>Common</Filter>
</ClInclude>
@@ -107,56 +101,59 @@
<ClInclude Include="..\ServerEngine\TimerManager.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\AstarFinder.h">
<ClInclude Include="..\ServerEngine\CrashReport.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\CommonConvert.h">
<ClInclude Include="..\ServerEngine\DBInterface\CppMysql.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\CommonFunc.h">
<ClInclude Include="..\ServerEngine\DBInterface\DBConnection.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\CommonSocket.h">
<ClInclude Include="..\ServerEngine\LuaManager.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\ConfigFile.h">
<ClInclude Include="..\ServerEngine\Platform.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\CrashReport.h">
<Filter>头文件</Filter>
<ClInclude Include="..\ServerEngine\AstarFinder.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\DataBuffer.h">
<Filter>头文件</Filter>
<ClInclude Include="..\ServerEngine\CommonConvert.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\DBInterface\CppMysql.h">
<Filter>头文件</Filter>
<ClInclude Include="..\ServerEngine\CommonFunc.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\DBInterface\DBConnection.h">
<Filter>头文件</Filter>
<ClInclude Include="..\ServerEngine\CommonSocket.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\DBInterface\DBInterface.h">
<Filter>头文件</Filter>
<ClInclude Include="..\ServerEngine\ConfigFile.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\DBInterface\DBRecordSet.h">
<Filter>头文件</Filter>
<ClInclude Include="..\ServerEngine\DataBuffer.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\DBInterface\DBStoredProc.h">
<Filter>头文件</Filter>
<ClInclude Include="EventFuncManager.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\Log.h">
<Filter>头文件</Filter>
<ClInclude Include="..\ServerEngine\DBInterface\DBStoredProc.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\LuaManager.h">
<Filter>头文件</Filter>
<ClInclude Include="..\ServerEngine\DBInterface\DBRecordSet.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\Platform.h">
<Filter>头文件</Filter>
<ClInclude Include="..\ServerEngine\DBInterface\DBInterface.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\SharedMemory.h">
<Filter>头文件</Filter>
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\XMath.h">
<Filter>头文件</Filter>
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="..\ServerEngine\Log.h">
<Filter>Common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
1 change: 0 additions & 1 deletion Server/Src/WatchServer/WatchMsgHandler.cpp
Original file line number Diff line number Diff line change
@@ -274,7 +274,6 @@ BOOL CWatchMsgHandler::CheckProcessStatus(UINT32 nIndex)
break;
case EPS_Stoping:
{
//如果2秒还没有连上我,就是表示不存在
if (uCurrentTick - serverInfo.LastHeartTick > 2000)
{
serverInfo.ProscessStatus = EPS_Stop;
6 changes: 6 additions & 0 deletions Server/Src/WatcherClient/WatcherClient.cpp
Original file line number Diff line number Diff line change
@@ -34,6 +34,12 @@ BOOL CWatcherClient::IsRun()
return m_bRun;
}

BOOL CWatcherClient::StopServer()
{
m_bRun = FALSE;

return TRUE;
}
BOOL CWatcherClient::OnNewConnect(UINT32 nConnID)
{
if (nConnID == m_dwWatchSvrConnID)
2 changes: 2 additions & 0 deletions Server/Src/WatcherClient/WatcherClient.h
Original file line number Diff line number Diff line change
@@ -26,6 +26,8 @@ class CWatcherClient

BOOL IsRun();

BOOL StopServer();

UINT32 m_dwWatchSvrConnID;
UINT32 m_dwWatchIndex;
UINT64 m_uLastHeartTime;

0 comments on commit 6ecfc06

Please sign in to comment.