This commit is contained in:
aozhiwei 2020-11-18 17:09:23 +08:00
parent 650b9ba773
commit 8963e9d982
3 changed files with 31 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include "synchelper.h"
#include "player.h"
#include "gamelog.h"
#include "metamgr.h"
#include "framework/cpp/httpclientpool.h"
@ -403,6 +404,24 @@ void Guild::_CMGuildAgree(f8::MsgHdr& hdr, const cs::CMGuildAgree& msg)
void Guild::_CMGuildGainExp(f8::MsgHdr& hdr, const cs::CMGuildGainExp& msg)
{
ss::SS_IM_ForwardGuildCMMsg *forward_msg = (ss::SS_IM_ForwardGuildCMMsg*)hdr.user_data;
int exp = msg.exp();
if (exp > 0) {
MetaData::Guild* next_guild_meta = nullptr;
do {
MetaData::Guild* curr_guild_meta = MetaMgr::Instance()->GetGuild(GuildLv());
next_guild_meta = MetaMgr::Instance()->GetGuild(GuildLv() + 1);
if (!next_guild_meta || !curr_guild_meta) {
break;
}
int add_exp = std::max(curr_guild_meta->i->experience(), 0);
} while (next_guild_meta && exp > 0);
}
cs::SMGuildGainExp respmsg;
GuildMgr::Instance()->ForwardGuildSMMsg(hdr.socket_handle,
forward_msg->context(),
respmsg);
}
void Guild::_CMGuildRefuse(f8::MsgHdr& hdr, const cs::CMGuildRefuse& msg)

View File

@ -94,3 +94,13 @@ void MetaMgr::Reload()
loader_ = new MetaDataLoader();
loader_->Load();
}
MetaData::Guild* MetaMgr::GetGuild(int guild_lv)
{
auto itr = loader_->guild_hash.find(guild_lv);
if (itr != loader_->guild_hash.end()) {
return itr->second;
} else {
return nullptr;
}
}

View File

@ -16,6 +16,8 @@ class MetaMgr : public a8::Singleton<MetaMgr>
void UnInit();
void Reload();
MetaData::Guild* GetGuild(int guild_lv);
private:
MetaDataLoader* loader_ = nullptr;