Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ylmbtm committed Jul 28, 2020
1 parent 5374cab commit 8c45ec2
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 39 deletions.
35 changes: 29 additions & 6 deletions Server/Src/LogicServer/RoleModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ BOOL CRoleModule::OnCreate(UINT64 u64RoleID)
m_pRoleDataObject->m_CityCopyID = pInfo->dwBornCity;

m_pRoleDataObject->m_uCreateTime = CommonFunc::GetCurrTime();
m_pRoleDataObject->m_uLogonTime = m_pRoleDataObject->m_uCreateTime;
m_pRoleDataObject->m_uLogoffTime = m_pRoleDataObject->m_uLogonTime;

m_pRoleDataObject->Unlock();

Expand Down Expand Up @@ -91,6 +93,10 @@ BOOL CRoleModule::OnLogout()

BOOL CRoleModule::OnNewDay()
{
m_pRoleDataObject->Lock();
m_pRoleDataObject->m_uLogoffTime = CommonFunc::GetCurrTime() + 1;
m_pRoleDataObject->Unlock();

return TRUE;
}

Expand All @@ -105,10 +111,11 @@ BOOL CRoleModule::ReadFromDBLoginData( DBRoleLoginAck& Ack )
m_pRoleDataObject->m_CarrerID = Ack.roledata().carrerid();
m_pRoleDataObject->m_Level = Ack.roledata().level();
m_pRoleDataObject->m_Exp = Ack.roledata().exp();
m_pRoleDataObject->m_VipLvl = Ack.roledata().viplvl();
m_pRoleDataObject->m_VipExp = Ack.roledata().vipexp();
m_pRoleDataObject->m_nVipLvl = Ack.roledata().viplvl();
m_pRoleDataObject->m_nVipExp = Ack.roledata().vipexp();
m_pRoleDataObject->m_nLangID = Ack.roledata().langid();
m_pRoleDataObject->m_CityCopyID = Ack.roledata().citycopyid();
m_pRoleDataObject->m_uGuildID = Ack.roledata().guildid();
m_pRoleDataObject->m_uCreateTime = Ack.roledata().createtime();
m_pRoleDataObject->m_uLogonTime = Ack.roledata().logontime();
m_pRoleDataObject->m_uLogoffTime = Ack.roledata().logofftime();
Expand Down Expand Up @@ -150,8 +157,8 @@ BOOL CRoleModule::SaveToClientLoginData(RoleLoginAck& Ack)
Ack.set_carrer(m_pRoleDataObject->m_CarrerID);
Ack.set_fightvalue(m_pRoleDataObject->m_u64Fight);
Ack.set_exp(m_pRoleDataObject->m_Exp);
Ack.set_viplvl(m_pRoleDataObject->m_VipLvl);
Ack.set_vipexp(m_pRoleDataObject->m_VipExp);
Ack.set_viplvl(m_pRoleDataObject->m_nVipLvl);
Ack.set_vipexp(m_pRoleDataObject->m_nVipExp);
for(int i = 0; i < ACTION_NUM; i++)
{
ActionItem* pItem = Ack.add_actionlist();
Expand Down Expand Up @@ -352,7 +359,7 @@ INT32 CRoleModule::GetLevel()

INT32 CRoleModule::GetVipLevel()
{
return m_pRoleDataObject->m_VipLvl;
return m_pRoleDataObject->m_nVipLvl;
}

CHAR* CRoleModule::GetName()
Expand Down Expand Up @@ -404,11 +411,27 @@ UINT64 CRoleModule::AddExp( INT32 nExp )

UINT64 CRoleModule::GetLastLogoffTime()
{
ERROR_RETURN_FALSE(m_pRoleDataObject != NULL);
ERROR_RETURN_VALUE(m_pRoleDataObject != NULL, 0);

return m_pRoleDataObject->m_uLogoffTime;
}

BOOL CRoleModule::SetLastLogoffTime(UINT64 uTime)
{
ERROR_RETURN_FALSE(m_pRoleDataObject != NULL);

m_pRoleDataObject->m_uLogoffTime = uTime;

return TRUE;
}

UINT64 CRoleModule::GetLastLogonTime()
{
ERROR_RETURN_VALUE(m_pRoleDataObject != NULL, 0);

return m_pRoleDataObject->m_uLogonTime;
}

VOID CRoleModule::SetGroupMailTime(UINT64 uTime)
{
m_pRoleDataObject->Lock();
Expand Down
2 changes: 2 additions & 0 deletions Server/Src/LogicServer/RoleModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class CRoleModule : public CModuleBase
UINT64 AddExp(INT32 nExp);

UINT64 GetLastLogoffTime();
BOOL SetLastLogoffTime(UINT64 uTime);
UINT64 GetLastLogonTime();

VOID SetGroupMailTime(UINT64 uTime);
UINT64 GetGroupMailTime();
Expand Down
7 changes: 6 additions & 1 deletion Server/Src/LogicServer/SimpleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,12 @@ BOOL CSimpleManager::AddSimpleInfo(CSimpleInfo* pInfo)

m_mapID2Simple.insert(std::make_pair(pInfo->m_uRoleID, pInfo));

m_mapName2ID.insert(std::make_pair(pInfo->m_strName, pInfo->m_uRoleID));
auto ret = m_mapName2ID.insert(std::make_pair(pInfo->m_strName, pInfo->m_uRoleID));

if (!ret.second)
{
CLog::GetInstancePtr()->LogError("CSimpleManager::AddSimpleInfo Error Role Name :%s already exist!", pInfo->m_strName.c_str());
}

return TRUE;
}
75 changes: 43 additions & 32 deletions Server/Src/ServerData/RoleData.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ struct RoleDataObject : public ShareObject
m_Exp = 0; //经验
m_nLangID = 0; //语言ID
m_u64Fight = 0; //战力
m_VipLvl = 0; //VIP等级
m_VipExp = 0; //VIP经验
m_nVipLvl = 0; //VIP等级
m_nVipExp = 0; //VIP经验
m_CityCopyID = 0; //主城副本类型
m_bDelete = FALSE; //是否删除
m_CarrerID = 0; //职业
m_uCreateTime = 0; //角色创建时间
m_uLogonTime = 0; //最近一次登录时间
m_uLogoffTime = 0; //最近一次离线时间
m_nChannel = 0; //角色渠道
memset(m_szName, 0, ROLE_NAME_LEN);
}

Expand All @@ -33,15 +34,17 @@ struct RoleDataObject : public ShareObject
INT64 m_Exp; //经验
INT32 m_nLangID; //语言ID
INT64 m_u64Fight; //战力
INT32 m_VipLvl; //VIP等级
INT32 m_VipExp; //VIP经验
INT32 m_nVipLvl; //VIP等级
INT32 m_nVipExp; //VIP经验
INT32 m_CityCopyID; //主城副本类型
INT32 m_nChannel; //角色渠道
BOOL m_bDelete; //是否删除
INT64 m_uQQ; //QQ号
UINT64 m_uCreateTime; //角色创建时间
UINT64 m_uLogonTime; //本次登录时间
UINT64 m_uLogoffTime; //离线时间
UINT64 m_uGroupMailTime; //群邮件接收时间
UINT64 m_uGuildID; //公会ID

//签到数据
INT32 m_nSignNum; //签到天数
Expand All @@ -50,8 +53,8 @@ struct RoleDataObject : public ShareObject

BOOL Create(IDBInterface* pDB)
{
static CDBStoredProcedure csp("REPLACE INTO player (id, accountid, name, carrerid,level, citycopyid,exp, langid, action1, action2, action3,action4, actime1, actime2, actime3,actime4, createtime, logontime, logofftime, grouptime) \
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);");
static CDBStoredProcedure csp("REPLACE INTO player (id, accountid, name, carrerid,level, citycopyid,exp, langid, viplevel, vipexp, action1, action2, action3,action4, actime1, actime2, actime3,actime4, createtime, logontime, logofftime, grouptime, fightvalue, guildid) \
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);");
csp.set_uint64(0, m_uRoleID);
csp.set_uint64(1, m_uAccountID);
csp.set_string(2, m_szName, strlen(m_szName));
Expand All @@ -60,25 +63,29 @@ struct RoleDataObject : public ShareObject
csp.set_int64(5, m_CityCopyID);
csp.set_int64(6, m_Exp);
csp.set_int32(7, m_nLangID);
csp.set_int64(8, m_Action[0]);
csp.set_int64(9, m_Action[1]);
csp.set_int64(10, m_Action[2]);
csp.set_int64(11, m_Action[3]);
csp.set_int64(12, m_Actime[0]);
csp.set_int64(13, m_Actime[1]);
csp.set_int64(14, m_Actime[2]);
csp.set_int64(15, m_Actime[3]);
csp.set_int64(16, m_uCreateTime);
csp.set_int64(17, m_uLogonTime);
csp.set_int64(18, m_uLogoffTime);
csp.set_int64(19, m_uGroupMailTime);
csp.set_int32(8, m_nVipLvl);
csp.set_int32(9, m_nVipExp);
csp.set_int64(10, m_Action[0]);
csp.set_int64(11, m_Action[1]);
csp.set_int64(12, m_Action[2]);
csp.set_int64(13, m_Action[3]);
csp.set_int64(14, m_Actime[0]);
csp.set_int64(15, m_Actime[1]);
csp.set_int64(16, m_Actime[2]);
csp.set_int64(17, m_Actime[3]);
csp.set_int64(18, m_uCreateTime);
csp.set_int64(19, m_uLogonTime);
csp.set_int64(20, m_uLogoffTime);
csp.set_int64(21, m_uGroupMailTime);
csp.set_int64(22, m_u64Fight);
csp.set_int64(23, m_uGuildID);
return pDB->Execute(&csp);
}

BOOL Update(IDBInterface* pDB)
{
static CDBStoredProcedure csp("REPLACE INTO player (id, accountid, name, carrerid,level, citycopyid,exp, langid, action1, action2, action3,action4, actime1, actime2, actime3,actime4, createtime, logontime, logofftime, grouptime) \
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);");
static CDBStoredProcedure csp("REPLACE INTO player (id, accountid, name, carrerid,level, citycopyid,exp, langid, viplevel, vipexp, action1, action2, action3,action4, actime1, actime2, actime3,actime4, createtime, logontime, logofftime, grouptime, fightvalue, guildid) \
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);");
csp.set_uint64(0, m_uRoleID);
csp.set_uint64(1, m_uAccountID);
csp.set_string(2, m_szName, strlen(m_szName));
Expand All @@ -87,18 +94,22 @@ struct RoleDataObject : public ShareObject
csp.set_int64(5, m_CityCopyID);
csp.set_int64(6, m_Exp);
csp.set_int32(7, m_nLangID);
csp.set_int64(8, m_Action[0]);
csp.set_int64(9, m_Action[1]);
csp.set_int64(10, m_Action[2]);
csp.set_int64(11, m_Action[3]);
csp.set_int64(12, m_Actime[0]);
csp.set_int64(13, m_Actime[1]);
csp.set_int64(14, m_Actime[2]);
csp.set_int64(15, m_Actime[3]);
csp.set_int64(16, m_uCreateTime);
csp.set_int64(17, m_uLogonTime);
csp.set_int64(18, m_uLogoffTime);
csp.set_int64(19, m_uGroupMailTime);
csp.set_int32(8, m_nVipLvl);
csp.set_int32(9, m_nVipExp);
csp.set_int64(10, m_Action[0]);
csp.set_int64(11, m_Action[1]);
csp.set_int64(12, m_Action[2]);
csp.set_int64(13, m_Action[3]);
csp.set_int64(14, m_Actime[0]);
csp.set_int64(15, m_Actime[1]);
csp.set_int64(16, m_Actime[2]);
csp.set_int64(17, m_Actime[3]);
csp.set_int64(18, m_uCreateTime);
csp.set_int64(19, m_uLogonTime);
csp.set_int64(20, m_uLogoffTime);
csp.set_int64(21, m_uGroupMailTime);
csp.set_int64(22, m_u64Fight);
csp.set_int64(23, m_uGuildID);
return pDB->Execute(&csp);
}

Expand Down

0 comments on commit 8c45ec2

Please sign in to comment.