邏輯代碼
- 結(jié)構(gòu)體信息
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; //登陸天數(shù)
...
}
- 接口
//零點更新
void on_crossed_one_day();
void on_crossed_one_week();
void on_crossed_one_month();
//更新每天需要重置的數(shù)據(jù)
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();
}
檢查玩家數(shù)據(jù)是否同步
4.refresh_daily_data
send_affix_mail_to_player
refresh()
5.update_daily_data接口實現(xiàn)
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.函數(shù)調(diào)用過程
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