1
This commit is contained in:
parent
d299cb6bee
commit
e480b86564
@ -138,11 +138,25 @@ void Guild::_CMGuildAgree(f8::MsgHdr& hdr, const cs::CMGuildAgree& msg)
|
||||
if (IsFull()) {
|
||||
respmsg.set_errcode(1);
|
||||
respmsg.set_errmsg("公会人数已达上限");
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(hdr.socket_handle,
|
||||
forward_msg->context(),
|
||||
respmsg);
|
||||
return;
|
||||
}
|
||||
GuildMember* sender = GetMember(forward_msg->context().user_info().base_data().account_id());
|
||||
if (!sender) {
|
||||
respmsg.set_errcode(2);
|
||||
respmsg.set_errmsg("服务器内部错误");
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(hdr.socket_handle,
|
||||
forward_msg->context(),
|
||||
respmsg);
|
||||
return;
|
||||
}
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(hdr.socket_handle,
|
||||
forward_msg->context(),
|
||||
respmsg);
|
||||
if (!GetMember(forward_msg->context().user_info().base_data().account_id())) {
|
||||
if (respmsg.errcode() == 0 &&
|
||||
!GetMember(forward_msg->context().user_info().base_data().account_id())) {
|
||||
GuildMember* member = new GuildMember();
|
||||
TypeConvert::Convert(forward_msg->context().user_info().base_data(), *member);
|
||||
AddMember(member);
|
||||
@ -261,7 +275,9 @@ void Guild::_CMGuildApplyList(f8::MsgHdr& hdr, const cs::CMGuildApplyList& msg)
|
||||
}
|
||||
}
|
||||
cs::SMGuildApplyList respmsg;
|
||||
guild->FillApplyList(*paging, respmsg);
|
||||
guild->FillApplyList(forward_msg->context().user_info().base_data().account_id(),
|
||||
*paging,
|
||||
respmsg);
|
||||
GuildMgr::Instance()->ForwardGuildSMMsg(param.param1,
|
||||
forward_msg->context(),
|
||||
respmsg);
|
||||
@ -463,7 +479,36 @@ int Guild::GetMemberNum()
|
||||
return member_hash_.size();
|
||||
}
|
||||
|
||||
void Guild::FillApplyList(cs::MFPaging& paging, cs::SMGuildApplyList& respmsg)
|
||||
void Guild::FillApplyList(const std::string& account_id, cs::MFPaging& paging, cs::SMGuildApplyList& respmsg)
|
||||
{
|
||||
|
||||
#if 0
|
||||
RemoveHandledApply();
|
||||
#endif
|
||||
int i = 0;
|
||||
int start = paging.curr_page() * paging.page_size();
|
||||
for (auto& pair : apply_hash_) {
|
||||
if (i >= start && i < start + paging.page_size()) {
|
||||
if (pair.second->flag == 1) {
|
||||
continue;
|
||||
}
|
||||
auto apply_pb = respmsg.add_apply_list();
|
||||
TypeConvert::Convert(*pair.second, *apply_pb);
|
||||
{
|
||||
int target_channel = f8::ExtractChannelIdFromAccountId
|
||||
(apply_pb->base_data().account_id());
|
||||
int channel = f8::ExtractChannelIdFromAccountId(account_id);
|
||||
App::Instance()->PreProcAvatarUrl
|
||||
(channel,
|
||||
target_channel,
|
||||
*apply_pb->mutable_base_data()->mutable_avatar_url());
|
||||
}
|
||||
}
|
||||
++i;
|
||||
}
|
||||
*respmsg.mutable_paging() = paging;
|
||||
if (paging.page_size() > 0) {
|
||||
respmsg.mutable_paging()->set__total_page(ceil(i / paging.page_size()));
|
||||
} else {
|
||||
respmsg.mutable_paging()->set__total_page(1);
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ private:
|
||||
void SaveToDB();
|
||||
void GenSortedMembers();
|
||||
int GetMemberNum();
|
||||
void FillApplyList(cs::MFPaging& paging, cs::SMGuildApplyList& respmsg);
|
||||
void FillApplyList(const std::string& account_id, cs::MFPaging& paging, cs::SMGuildApplyList& respmsg);
|
||||
|
||||
private:
|
||||
bool dirty_ = false;
|
||||
|
@ -22,6 +22,24 @@ void TypeConvert::Convert(const FriendApply& apply, cs::MFFriendApply& apply_pb)
|
||||
Convert(apply.base_data, *apply_pb.mutable_base_data());
|
||||
}
|
||||
|
||||
void TypeConvert::Convert(const cs::MFGuildApply& apply_pb, GuildApply& apply)
|
||||
{
|
||||
apply.idx = apply_pb.idx();
|
||||
apply.applyid = apply_pb.applyid();
|
||||
apply.guild_id = apply_pb.guild_id();
|
||||
#if 0
|
||||
Convert(apply_pb.base_data(), apply.base_data);
|
||||
#endif
|
||||
}
|
||||
|
||||
void TypeConvert::Convert(const GuildApply& apply, cs::MFGuildApply& apply_pb)
|
||||
{
|
||||
apply_pb.set_idx(apply.idx);
|
||||
apply_pb.set_applyid(apply.applyid);
|
||||
apply_pb.set_guild_id(apply.guild_id);
|
||||
Convert(apply.base_data, *apply_pb.mutable_base_data());
|
||||
}
|
||||
|
||||
void TypeConvert::Convert(a8::XObject& xobj, cs::MFGuildBasic* guild_basic)
|
||||
{
|
||||
guild_basic->set_guild_id(xobj.At("guild_id")->AsXValue());
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace cs
|
||||
{
|
||||
class MFGuildApply;
|
||||
class MFFriendApply;
|
||||
class MFBaseUserData;
|
||||
class MFUserTempCustomData;
|
||||
@ -20,6 +21,9 @@ class TypeConvert
|
||||
static void Convert(const cs::MFFriendApply& apply_pb, FriendApply& apply);
|
||||
static void Convert(const FriendApply& apply, cs::MFFriendApply& apply_pb);
|
||||
|
||||
static void Convert(const cs::MFGuildApply& apply_pb, GuildApply& apply);
|
||||
static void Convert(const GuildApply& apply, cs::MFGuildApply& apply_pb);
|
||||
|
||||
static void Convert(a8::XObject& xobj, cs::MFGuildBasic* guild_basic);
|
||||
static void Convert(a8::XObject& xobj, cs::MFPaging* paging);
|
||||
|
||||
|
@ -92,7 +92,7 @@ message MFGuildApply
|
||||
{
|
||||
optional int64 idx = 1; //唯一索引id
|
||||
optional int64 applyid = 2; //applyid
|
||||
optional string target_id = 3; //target_id
|
||||
optional int64 guild_id = 3; //guild_id
|
||||
optional MFBaseUserData base_data = 4; //基础数据
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user