1
This commit is contained in:
parent
a76389eccb
commit
109b15dfc8
@ -600,3 +600,51 @@ void Guild::ClearApplyByIdx(long long idx)
|
|||||||
apply_hash_.erase(itr);
|
apply_hash_.erase(itr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Guild* Guild::CreateGuild(int gameid,
|
||||||
|
long long guild_id,
|
||||||
|
const std::string& guild_name,
|
||||||
|
int guild_lv,
|
||||||
|
int guild_exp,
|
||||||
|
int guild_badge,
|
||||||
|
int guild_apply_num,
|
||||||
|
const std::string& guild_members,
|
||||||
|
const std::string& guild_notice,
|
||||||
|
const std::string& guild_declaration,
|
||||||
|
const std::string& guild_log,
|
||||||
|
const std::string& owner_id,
|
||||||
|
const std::string& owner_name,
|
||||||
|
const std::string& owner_avatar_url,
|
||||||
|
const std::string& creator_id,
|
||||||
|
const std::string& creator_name,
|
||||||
|
const std::string& creator_avatar_url,
|
||||||
|
const std::string& guild_data,
|
||||||
|
int guild_status,
|
||||||
|
int createtime
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (GuildMgr::Instance()->GetGuild(guild_id)) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
Guild* guild = new Guild;
|
||||||
|
guild->gameid_ = gameid;
|
||||||
|
guild->guild_id_ = guild_id;
|
||||||
|
guild->guild_name_ = guild_name;
|
||||||
|
guild->guild_lv_ = guild_lv;
|
||||||
|
guild->guild_exp_ = guild_exp;
|
||||||
|
guild->guild_badge_ = guild_badge;
|
||||||
|
guild->guild_apply_num_ = guild_apply_num;
|
||||||
|
guild->guild_notice_ = guild_notice;
|
||||||
|
guild->guild_declaration_ = guild_declaration;
|
||||||
|
guild->owner_id_ = owner_id;
|
||||||
|
guild->owner_name_ = owner_name;
|
||||||
|
guild->owner_avatar_url_ = owner_avatar_url;
|
||||||
|
guild->creator_id_ = creator_id;
|
||||||
|
guild->creator_name_ = creator_name;
|
||||||
|
guild->creator_avatar_url_ = creator_avatar_url;
|
||||||
|
guild->guild_status_ = guild_status;
|
||||||
|
guild->createtime_ = createtime;
|
||||||
|
//guild_members
|
||||||
|
guild->Deserialize(guild_data, guild_log);
|
||||||
|
return guild;
|
||||||
|
}
|
||||||
|
@ -78,5 +78,26 @@ private:
|
|||||||
|
|
||||||
a8::TimerAttacher timer_attacher_;
|
a8::TimerAttacher timer_attacher_;
|
||||||
|
|
||||||
friend class GuildMgr;
|
public:
|
||||||
|
static Guild* CreateGuild(int gameid,
|
||||||
|
long long guild_id,
|
||||||
|
const std::string& guild_name,
|
||||||
|
int guild_lv,
|
||||||
|
int guild_exp,
|
||||||
|
int guild_badge,
|
||||||
|
int guild_apply_num,
|
||||||
|
const std::string& guild_members,
|
||||||
|
const std::string& guild_notice,
|
||||||
|
const std::string& guild_declaration,
|
||||||
|
const std::string& guild_log,
|
||||||
|
const std::string& owner_id,
|
||||||
|
const std::string& owner_name,
|
||||||
|
const std::string& owner_avatar_url,
|
||||||
|
const std::string& creator_id,
|
||||||
|
const std::string& creator_name,
|
||||||
|
const std::string& creator_avatar_url,
|
||||||
|
const std::string& guild_data,
|
||||||
|
int guild_status,
|
||||||
|
int createtime
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
@ -66,7 +66,16 @@ void GuildMgr::Init()
|
|||||||
|
|
||||||
void GuildMgr::UnInit()
|
void GuildMgr::UnInit()
|
||||||
{
|
{
|
||||||
|
for (auto& pair : id_hash_) {
|
||||||
|
delete pair.second;
|
||||||
|
}
|
||||||
|
id_hash_.clear();
|
||||||
|
for (auto& pair : task_hash_) {
|
||||||
|
for (auto task :pair.second) {
|
||||||
|
delete task;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
task_hash_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg)
|
void GuildMgr::_SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg)
|
||||||
@ -123,7 +132,7 @@ void GuildMgr::LoadGuild(long long guild_id)
|
|||||||
GuildMgr::Instance()->pending_guild_hash_.erase(param.sender);
|
GuildMgr::Instance()->pending_guild_hash_.erase(param.sender);
|
||||||
if (data_set) {
|
if (data_set) {
|
||||||
for (auto& row : *data_set) {
|
for (auto& row : *data_set) {
|
||||||
GuildMgr::Instance()->CreateGuild
|
Guild* guild = Guild::CreateGuild
|
||||||
(
|
(
|
||||||
a8::XValue(row[0]), //gameid
|
a8::XValue(row[0]), //gameid
|
||||||
a8::XValue(row[1]), //guild_id
|
a8::XValue(row[1]), //guild_id
|
||||||
@ -146,6 +155,7 @@ void GuildMgr::LoadGuild(long long guild_id)
|
|||||||
a8::XValue(19), //guild_status
|
a8::XValue(19), //guild_status
|
||||||
a8::XValue(20) //createtime
|
a8::XValue(20) //createtime
|
||||||
);
|
);
|
||||||
|
GuildMgr::Instance()->id_hash_[guild->GuildId()] = guild;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,51 +216,3 @@ void GuildMgr::ForwardGuildSMMsg(int socket_handle,
|
|||||||
smmsg.SerializeToString(msg.mutable_payload());
|
smmsg.SerializeToString(msg.mutable_payload());
|
||||||
IMListener::Instance()->SendMsg(socket_handle, msg);
|
IMListener::Instance()->SendMsg(socket_handle, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuildMgr::CreateGuild(int gameid,
|
|
||||||
long long guild_id,
|
|
||||||
const std::string& guild_name,
|
|
||||||
int guild_lv,
|
|
||||||
int guild_exp,
|
|
||||||
int guild_badge,
|
|
||||||
int guild_apply_num,
|
|
||||||
const std::string& guild_members,
|
|
||||||
const std::string& guild_notice,
|
|
||||||
const std::string& guild_declaration,
|
|
||||||
const std::string& guild_log,
|
|
||||||
const std::string& owner_id,
|
|
||||||
const std::string& owner_name,
|
|
||||||
const std::string& owner_avatar_url,
|
|
||||||
const std::string& creator_id,
|
|
||||||
const std::string& creator_name,
|
|
||||||
const std::string& creator_avatar_url,
|
|
||||||
const std::string& guild_data,
|
|
||||||
int guild_status,
|
|
||||||
int createtime
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (GetGuild(guild_id)) {
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
Guild* guild = new Guild;
|
|
||||||
guild->gameid_ = gameid;
|
|
||||||
guild->guild_id_ = guild_id;
|
|
||||||
guild->guild_name_ = guild_name;
|
|
||||||
guild->guild_lv_ = guild_lv;
|
|
||||||
guild->guild_exp_ = guild_exp;
|
|
||||||
guild->guild_badge_ = guild_badge;
|
|
||||||
guild->guild_apply_num_ = guild_apply_num;
|
|
||||||
guild->guild_notice_ = guild_notice;
|
|
||||||
guild->guild_declaration_ = guild_declaration;
|
|
||||||
guild->owner_id_ = owner_id;
|
|
||||||
guild->owner_name_ = owner_name;
|
|
||||||
guild->owner_avatar_url_ = owner_avatar_url;
|
|
||||||
guild->creator_id_ = creator_id;
|
|
||||||
guild->creator_name_ = creator_name;
|
|
||||||
guild->creator_avatar_url_ = creator_avatar_url;
|
|
||||||
guild->guild_status_ = guild_status;
|
|
||||||
guild->createtime_ = createtime;
|
|
||||||
//guild_members
|
|
||||||
guild->Deserialize(guild_data, guild_log);
|
|
||||||
id_hash_[guild_id] = guild;
|
|
||||||
}
|
|
||||||
|
@ -33,31 +33,12 @@ class GuildMgr : public a8::Singleton<GuildMgr>
|
|||||||
int msgid,
|
int msgid,
|
||||||
const ::google::protobuf::Message& smmsg);
|
const ::google::protobuf::Message& smmsg);
|
||||||
void _SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg);
|
void _SS_IM_ForwardGuildCMMsg(f8::MsgHdr& hdr, const ss::SS_IM_ForwardGuildCMMsg& msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateAsyncTask(int socket_handle, long long guild_id, AsyncGuildTask* task);
|
void CreateAsyncTask(int socket_handle, long long guild_id, AsyncGuildTask* task);
|
||||||
void LoadGuild(long long guild_id);
|
void LoadGuild(long long guild_id);
|
||||||
bool IsValidGuildId(long long guild_id);
|
bool IsValidGuildId(long long guild_id);
|
||||||
void CreateGuild(int gameid,
|
|
||||||
long long guild_id,
|
|
||||||
const std::string& guild_name,
|
|
||||||
int guild_lv,
|
|
||||||
int guild_exp,
|
|
||||||
int guild_badge,
|
|
||||||
int guild_apply_num,
|
|
||||||
const std::string& guild_members,
|
|
||||||
const std::string& guild_notice,
|
|
||||||
const std::string& guild_declaration,
|
|
||||||
const std::string& guild_log,
|
|
||||||
const std::string& owner_id,
|
|
||||||
const std::string& owner_name,
|
|
||||||
const std::string& owner_avatar_url,
|
|
||||||
const std::string& creator_id,
|
|
||||||
const std::string& creator_name,
|
|
||||||
const std::string& creator_avatar_url,
|
|
||||||
const std::string& guild_data,
|
|
||||||
int guild_status,
|
|
||||||
int createtime
|
|
||||||
);
|
|
||||||
private:
|
private:
|
||||||
std::map<long long, Guild*> id_hash_;
|
std::map<long long, Guild*> id_hash_;
|
||||||
std::set<long long> pending_guild_hash_;
|
std::set<long long> pending_guild_hash_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user