Skip to content

Commit

Permalink
Commit Code!
Browse files Browse the repository at this point in the history
  • Loading branch information
ylmbtm committed Apr 27, 2019
1 parent fbede1e commit d88cd35
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 23 deletions.
19 changes: 13 additions & 6 deletions Server/Src/LogicServer/PartnerModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ CPartnerModule::~CPartnerModule()

BOOL CPartnerModule::OnCreate(UINT64 u64RoleID)
{

for (int i = 0; i < 20; i++)
{
AddPartner(i + 1);
}
return TRUE;
}

Expand Down Expand Up @@ -93,6 +96,10 @@ BOOL CPartnerModule::SaveToClientLoginData(RoleLoginAck& Ack)
pItem->set_starexp(pObject->m_StarExp);
pItem->set_setpos(pObject->m_SetPos);
}

m_setChange.clear();
m_setRemove.clear();

return TRUE;
}

Expand All @@ -106,8 +113,8 @@ BOOL CPartnerModule::DispatchPacket(NetPacket* pNetPacket)
{
switch (pNetPacket->m_dwMsgID)
{
PROCESS_MESSAGE_ITEM(MSG_SETUP_PARTNER_REQ, OnMsgSetupPartnerReq);
PROCESS_MESSAGE_ITEM(MSG_UNSET_PARTNER_REQ, OnMsgUnsetPartnerReq);
PROCESS_MESSAGE_ITEM(MSG_SETUP_PARTNER_REQ, OnMsgSetupPartnerReq);
PROCESS_MESSAGE_ITEM(MSG_UNSET_PARTNER_REQ, OnMsgUnsetPartnerReq);
}

return FALSE;
Expand All @@ -127,7 +134,7 @@ BOOL CPartnerModule::OnMsgSetupPartnerReq(NetPacket* pNetPacket)
return TRUE;
}

PartnerDataObject *pPartnerObj = GetPartnerByGuid(Req.partnerguid());
PartnerDataObject* pPartnerObj = GetPartnerByGuid(Req.partnerguid());
if(pPartnerObj == NULL)
{
SetupPartnerAck Ack;
Expand All @@ -149,11 +156,11 @@ BOOL CPartnerModule::OnMsgSetupPartnerReq(NetPacket* pNetPacket)
pPartnerObj->m_SetPos = Req.targetpos();
pPartnerObj->Unlock();
m_setChange.insert(pPartnerObj->m_uGuid);

SetupPartnerAck Ack;
Ack.set_retcode(MRC_SUCCESSED);
m_pOwnPlayer->SendMsgProtoBuf(MSG_SETUP_PARTNER_ACK, Ack);

return TRUE;
}

Expand Down
5 changes: 4 additions & 1 deletion Server/Src/LogicServer/PetModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ CPetModule::~CPetModule()

BOOL CPetModule::OnCreate(UINT64 u64RoleID)
{

for (int i = 0; i < 13; i++)
{
AddPet(i + 1);
}
return TRUE;
}

Expand Down
15 changes: 12 additions & 3 deletions Server/Src/LogicServer/PlayerObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,19 +355,19 @@ BOOL CPlayerObject::SendRoleLoginAck()
return TRUE;
}

BOOL CPlayerObject::SendObjectChangeNtf(UINT32 dwChangeType, UINT64 uIntValue1, UINT64 uIntValue2, std::string strValue)
BOOL CPlayerObject::SendPlayerChange(EChangeType eChangeType, UINT64 uIntValue1, UINT64 uIntValue2, std::string strValue)
{
ObjectChangeNotify Ntf;
Ntf.set_roleid(GetObjectID());
Ntf.set_changetype(dwChangeType);
Ntf.set_changetype(eChangeType);
Ntf.set_intvalue1(uIntValue1);
Ntf.set_intvalue2(uIntValue2);
if (!strValue.empty() && strValue.size() > 0)
{
Ntf.set_strvalue(strValue);
}

SendMsgToScene(MSG_SCENEOBJ_CHAGE_NTF, Ntf);
SendMsgToScene(MSG_PLAYER_CHAGE_NTF, Ntf);

return TRUE;
}
Expand All @@ -385,6 +385,15 @@ BOOL CPlayerObject::ToTransferData( TransferDataReq& Req )
pRoleData->set_level(pModule->m_pRoleDataObject->m_Level);
pRoleData->set_name(pModule->m_pRoleDataObject->m_szName);

CMountModule* pMountModule = (CMountModule*)GetModuleByType(MT_MOUNT);
ERROR_RETURN_FALSE(pMountModule != NULL);

MountDataObject* pMountData = pMountModule->GetCurrentMountData();
if (pMountData != NULL)
{
pRoleData->set_mountid(pMountData->m_MountID);
}

for(int i = 0; i < PROPERTY_NUM; i++)
{
pRoleData->add_propertys(m_Propertys[i]);
Expand Down
3 changes: 2 additions & 1 deletion Server/Src/LogicServer/PlayerObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "ModuleBase.h"
#include "../Message/Msg_Game.pb.h"
#include "../ServerData/ServerDefine.h"
#include "../ServerData/serverStruct.h"

class CPlayerObject
{
Expand Down Expand Up @@ -52,7 +53,7 @@ class CPlayerObject
BOOL SendIntoSceneNotify(UINT32 dwCopyGuid, UINT32 dwCopyID, UINT32 dwSvrID);
BOOL SendLeaveScene(UINT32 dwCopyGuid, UINT32 dwSvrID);
BOOL SendRoleLoginAck();
BOOL SendObjectChangeNtf(UINT32 dwChangeType, UINT64 uIntValue1, UINT64 uIntValue2, std::string strValue);
BOOL SendPlayerChange(EChangeType eChangeType, UINT64 uIntValue1, UINT64 uIntValue2, std::string strValue);

BOOL SetConnectID(UINT32 dwProxyID, UINT32 dwClientID);

Expand Down
9 changes: 8 additions & 1 deletion Server/Src/LoginServer/LogicSvrManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ BOOL LogicSvrManager::RegisterLogicServer(UINT32 dwConnID, UINT32 dwServerID, UI

char szSql[SQL_BUFF_LEN] = { 0 };
snprintf(szSql, SQL_BUFF_LEN, "replace into server_list(id, name, ip, port,http_port,watch_port,state, min_version, max_version, check_chan, check_ip) values(%d, '%s', '%s', %d, %d, %d, %d, '%s','%s','%s','%s');",
pNode->m_dwServerID, pNode->m_strSvrName.c_str(),"127.0.0.1", pNode->m_dwPort, pNode->m_dwHttpPort, pNode->m_dwWatchPort, ESS_GOOD, "1.0.0", "9.0.0","*", "*");
pNode->m_dwServerID, pNode->m_strSvrName.c_str(), "127.0.0.1", pNode->m_dwPort, pNode->m_dwHttpPort, pNode->m_dwWatchPort, ESS_GOOD, "1.0.0", "9.0.0", "*", "*");
if (m_DBConnection.execSQL(szSql) < 0)
{
CLog::GetInstancePtr()->LogError("LogicSvrManager::RegisterLogicServer Error :%s", m_DBConnection.GetErrorMsg());
Expand Down Expand Up @@ -203,6 +203,13 @@ BOOL LogicSvrManager::ReloadServerList(UINT32 dwServerID)
pNode->m_strIpAddr = QueryResult.getStringField("ip", "*");
pNode->m_dwPort = QueryResult.getIntField("port", 0);
pNode->m_bDelete = FALSE;

if (pNode->m_strIpAddr.empty() || pNode->m_strIpAddr == "*")
{
CLog::GetInstancePtr()->LogError("ReloadServerList Failed, serverid:%d has no ip address!", dwSvrID);
return FALSE;
}

std::string strMinVersion = QueryResult.getStringField("min_version", "0");
if(strMinVersion.empty())
{
Expand Down
9 changes: 9 additions & 0 deletions Server/Src/ServerData/ServerStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,14 @@ struct BattleRecord
UINT32 m_dwDamage; //总伤害值
};

enum EChangeType
{
ECT_EQUIP = 1,//装备改变
ECT_MOUNT = 2,//坐骑改变
ECT_LEVEL = 3,//等级
ECT_PARTNER = 4,//伙伴
};



#endif //__SERVER_STRUCT_H__
9 changes: 7 additions & 2 deletions Server/Src/ServerEngine/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,15 @@ CConnectionMgr::~CConnectionMgr()

CConnection* CConnectionMgr::CreateConnection()
{
ERROR_RETURN_NULL(m_pFreeConnRoot != NULL);

CConnection* pTemp = NULL;
m_CritSecConnList.Lock();
if (m_pFreeConnRoot == NULL)
{
//表示己到达连接的上限,不能再创建新的连接了
m_CritSecConnList.Unlock();
return NULL;
}

if(m_pFreeConnRoot == m_pFreeConnTail)
{
pTemp = m_pFreeConnRoot;
Expand Down
6 changes: 3 additions & 3 deletions Server/Src/ServerEngine/DBInterface/DBInterface.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __SERVER_STRUCT_H__
#define __SERVER_STRUCT_H__
#ifndef __DB_INTERFACE_H__
#define __DB_INTERFACE_H__

class CDBStoredProcedure;

Expand Down Expand Up @@ -56,4 +56,4 @@ while(pProcedure->m_DBRecordSet.MoveNext())
}
*/

#endif //__SERVER_STRUCT_H__
#endif //__DB_INTERFACE_H__
5 changes: 3 additions & 2 deletions Server/Src/ServerEngine/NetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ BOOL CNetManager::WorkThread_Listen()
SOCKET hClientSocket = accept(m_hListenSocket, (sockaddr*)&Con_Addr, &nLen);
if(hClientSocket == INVALID_SOCKET)
{
break;
CLog::GetInstancePtr()->LogError("accept 错误 原因:%s!", CommonSocket::GetLastErrorStr(CommonSocket::GetSocketLastError()).c_str());
return FALSE;
}
CommonSocket::SetSocketUnblock(hClientSocket);
CConnection* pConnection = AssociateCompletePort(hClientSocket, FALSE);
Expand All @@ -76,7 +77,7 @@ BOOL CNetManager::WorkThread_Listen()
}
else
{
CLog::GetInstancePtr()->LogError("accept 错误 原因:%s!", CommonSocket::GetLastErrorStr(CommonSocket::GetSocketLastError()).c_str());
CLog::GetInstancePtr()->LogError("接受新连接失败 原因:己达到最大连接数或者绑定失败!");
}
}

Expand Down
2 changes: 0 additions & 2 deletions Server/Src/StaticData/ConfigDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ enum ETaskEvent
{
TE_NONE = 0,
TE_PASS_MAIN_COPY, //挑战主线


};


Expand Down
32 changes: 30 additions & 2 deletions Server/Src/StaticData/StaticData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ BOOL CStaticData::InitDataReader()
m_vtDataFuncList.push_back(DataFuncNode("Data_Equip", &CStaticData::ReadEquipInfo));
m_vtDataFuncList.push_back(DataFuncNode("Data_Gem", &CStaticData::ReadGemInfo));
m_vtDataFuncList.push_back(DataFuncNode("Data_Partner", &CStaticData::ReadPartnerInfo));
m_vtDataFuncList.push_back(DataFuncNode("Data_Mount", &CStaticData::ReadMountInfo));
m_vtDataFuncList.push_back(DataFuncNode("Data_Store", &CStaticData::ReadStoreInfo));
m_vtDataFuncList.push_back(DataFuncNode("Data_Combo_Skill", &CStaticData::ReadComboSkillInfo));
m_vtDataFuncList.push_back(DataFuncNode("Data_Skill", &CStaticData::ReadSkillInfo));
m_vtDataFuncList.push_back(DataFuncNode("Data_FlyObject", &CStaticData::ReadBulletInfo));

m_vtDataFuncList.push_back(DataFuncNode("Data_Pet", &CStaticData::ReadPetInfo));

// m_vtDataFuncList.push_back(DataFuncNode("Data_Language", &CStaticData::ReadLanguage));
// m_vtDataFuncList.push_back(DataFuncNode("Data_Award", &CStaticData::ReadAwardData));
// m_vtDataFuncList.push_back(DataFuncNode("Data_Func", &CStaticData::ReadFuncInfo));
// m_vtDataFuncList.push_back(DataFuncNode("Data_Func_Vip", &CStaticData::ReadFuncVipInfo));
// m_vtDataFuncList.push_back(DataFuncNode("Data_Func_Cost", &CStaticData::ReadFuncCostInfo));
// m_vtDataFuncList.push_back(DataFuncNode("Data_Pet", &CStaticData::ReadPetInfo));
// m_vtDataFuncList.push_back(DataFuncNode("Data_Task", &CStaticData::ReadTaskInfo));
// m_vtDataFuncList.push_back(DataFuncNode("Data_Buff", &CStaticData::ReadBuffInfo));

Expand Down Expand Up @@ -863,6 +863,7 @@ BOOL CStaticData::ReadPetInfo(CppSQLite3Query& QueryData)
{
StPetInfo stValue;
stValue.dwPetID = QueryData.getIntField("Id");
stValue.dwActorID = QueryData.getIntField("ActorId");
m_mapPetInfo.insert(std::make_pair(stValue.dwPetID, stValue));
QueryData.nextRow();
}
Expand Down Expand Up @@ -908,6 +909,33 @@ StPartnerInfo* CStaticData::GetPartnerInfo(UINT32 dwPartnerID)
return NULL;
}

BOOL CStaticData::ReadMountInfo(CppSQLite3Query& QueryData)
{
m_mapMountInfo.clear();

while (!QueryData.eof())
{
StMountInfo stValue;
stValue.dwMountID = QueryData.getIntField("Id");
stValue.dwMountID = QueryData.getIntField("ActorId");
m_mapMountInfo.insert(std::make_pair(stValue.dwMountID, stValue));
QueryData.nextRow();
}

return TRUE;
}

StMountInfo* CStaticData::GetMountInfo(UINT32 dwMountID)
{
ERROR_RETURN_NULL(dwMountID != 0);
auto itor = m_mapMountInfo.find(dwMountID);
if (itor != m_mapMountInfo.end())
{
return &itor->second;
}
return NULL;
}

BOOL CStaticData::ReadTaskInfo(CppSQLite3Query& QueryData)
{
m_mapTaskInfo.clear();
Expand Down
5 changes: 5 additions & 0 deletions Server/Src/StaticData/StaticData.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ class CStaticData
BOOL ReadPartnerInfo(CppSQLite3Query& QueryData);
StPartnerInfo* GetPartnerInfo(UINT32 dwPartnerID);

//坐骑
std::map<UINT32, StMountInfo> m_mapMountInfo;
BOOL ReadMountInfo(CppSQLite3Query& QueryData);
StMountInfo* GetMountInfo(UINT32 dwMountID);

//任务
std::map<UINT32, StTaskInfo> m_mapTaskInfo;
BOOL ReadTaskInfo(CppSQLite3Query& QueryData);
Expand Down
6 changes: 6 additions & 0 deletions Server/Src/StaticData/StaticStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ struct StPartnerInfo
};


struct StMountInfo
{
UINT32 dwMountID; //! ID
UINT32 dwActorID;
};

struct StTaskInfo
{
UINT32 TaskID; //! 任务ID
Expand Down

0 comments on commit d88cd35

Please sign in to comment.