逻辑代码
- 结构体信息
CPbDailyUpdateData
struct stDailyUpdateData
{
stDailyUpdateData() { clear(); }
void clear(void);
int32_t encode(char** pOut);
int32_t decode(char** pIn);
void refresh(void);
int32_t m_iUpdateTime;
int32_t m_iOnLineAwardTime; // 在线时长
int32_t m_iLoginDays; //登陆天数
...
}
- 接口
//零点更新
void on_crossed_one_day();
void on_crossed_one_week();
void on_crossed_one_month();
//更新每天需要重置的数据
int32_t refresh_daily_data();
int32_t update_daily_data();
//notify message (from db server)
int32_t process_notify_update_daily_data(CMessageHead& rstMsgHead, char* pszMsgBody, int32_t iBodyLength);
int32_t send_daily_data_to_client();
3.on_crossed_one_day
判断 是不是一天
if (!is_today(iUpdateTime))
{
this->on_crossed_one_day();
}
检查玩家数据是否同步
4.refresh_daily_data
send_affix_mail_to_player
refresh()
5.update_daily_data接口实现
int32_t CPlayer::update_daily_data()
{
if (!this->is_player_loaded()) /* 判断玩家信息是否同步 */
{
return fail;
}
this->m_stDailyUpdateData.m_iOnlineAwardTime += (time(NULL) - this->m_iLastUpdateOnlineTime);
this->m_iLastUpdateOnlineTime = time(NULL);
send_daily_date_to_client();
CRequestUpdateDailyDate stReqBody;
stReqBody.m_stDailyUpdateData = m_stDailyUpdateData;
send_request_to_gamedb(&stReqBody, SS_MSG_UPDATE_DAILY_DATA, -1);
return success;
}
6.函数调用过程
SS_MSG_UPDATE_DAILY_DATA
ExecuteSqlUpdateDailyData
SS_MSG_GET_ROLE_INFO
SendPlayerDataToLogicServer
SendNotifyDailyData
SS_MSG_NOTIFY_UPDATE_DAILY_DATA
process_notify_update_daily_data
send_daily_data_to_client
MSG_LOGIC_NOTIFY_UPDATE_DAILY_DATA