This commit is contained in:
aozhiwei 2020-06-23 15:37:46 +08:00
parent 3b52644e4e
commit 3ebe020780
2 changed files with 14 additions and 4 deletions

View File

@ -916,6 +916,9 @@ void Player::ProcessEventTimerFunc()
if (curr_max_event_idx_ >= DBEngine::Instance()->GetEventCurrIdx(myself.crc32_code)) {
return;
}
if (event_fetching_) {
return;
}
if (last_event_idx_ >= curr_max_event_idx_) {
curr_max_event_idx_ = DBEngine::Instance()->GetEventCurrIdx(myself.crc32_code);
}
@ -931,15 +934,22 @@ void Player::ProcessEventTimerFunc()
long long last_event_idx = param.param2;
Player* hum = PlayerMgr::Instance()->GetPlayerByAccountId(account_id);
if (hum) {
hum->event_fetching_ = false;
hum->last_event_idx_ = curr_max_event_idx;
hum->OnFetchEvent(curr_max_event_idx, data_set);
hum->OnFetchEvent(data_set);
}
};
auto on_error =
[] (a8::XParams& param, int error_code, const std::string& error_msg)
{
std::string account_id = param.sender.GetString();
Player* hum = PlayerMgr::Instance()->GetPlayerByAccountId(account_id);
if (hum) {
hum->event_fetching_ = false;
}
};
event_fetching_ = true;
a8::XObject conn_info = DBEngine::Instance()->GetConnInfo(myself.crc32_code);
DBEngine::Instance()->ExecAsyncQuery
(
@ -962,9 +972,8 @@ void Player::ProcessEventTimerFunc()
);
}
void Player::OnFetchEvent(long long max_event_idx, const f8::DataSet* data_set)
void Player::OnFetchEvent(const f8::DataSet* data_set)
{
curr_max_event_idx_ = max_event_idx;
if (data_set) {
for (auto& row : *data_set) {
Event event;

View File

@ -123,7 +123,7 @@ private:
void PushFriendList();
void SyncOtherFriend();
void ProcessEventTimerFunc();
void OnFetchEvent(long long max_event_idx, const f8::DataSet* data_set);
void OnFetchEvent(const f8::DataSet* data_set);
void ProcessEvent();
void OnFriendAgreeEvent(Event& event);
void OnFriendDeleteEvent(Event& event);
@ -142,6 +142,7 @@ private:
long long last_apply_idx_ = 0;
long long last_event_idx_ = 0;
long long curr_max_event_idx_ = 0;
bool event_fetching_ = false;
long long last_run_tick_ = 0;
std::map<long long, Event> event_hash_;
int red_point_flags_ = 0;