gamelog ok

This commit is contained in:
aozhiwei 2020-10-12 14:47:22 +08:00
parent 2667ad8bf2
commit e3f4d806ed
4 changed files with 97 additions and 2 deletions

View File

@ -4,9 +4,12 @@
#include "framework/cpp/tglog.h" #include "framework/cpp/tglog.h"
#include <a8/mutable_xobject.h> #include <a8/mutable_xobject.h>
#include "player.h" #include "player.h"
#include "guild.h"
#include "app.h" #include "app.h"
#include "cs_proto.pb.h"
const char* const FRIEND_LOGIN_EVENT = "friend_login"; const char* const FRIEND_LOGIN_EVENT = "friend_login";
const char* const FRIEND_LOGOUT_EVENT = "friend_logout"; const char* const FRIEND_LOGOUT_EVENT = "friend_logout";
const char* const FRIEND_APPLY_EVENT = "friend_apply"; const char* const FRIEND_APPLY_EVENT = "friend_apply";
@ -197,3 +200,43 @@ void GameLog::FriendDelete(Player* hum, const std::string& account_id)
delete prop; delete prop;
prop = nullptr; prop = nullptr;
} }
void GameLog::GuildCreate(Player* hum, long long guild_id, const std::string& guild_name)
{
}
void GameLog::GuildApply(Guild* guild, const cs::MFBaseUserData& base_data)
{
}
void GameLog::GuildRefuse(Guild* guild, GuildMember* sender, long long db_idx, const std::string& account_id)
{
}
void GameLog::GuildAgree(Guild* guild, GuildMember* sender, long long db_idx, const std::string& account_id)
{
}
void GameLog::GuildKick(Guild* guild, GuildMember* sender, const std::string& account_id)
{
}
void GameLog::GuildQuit(Guild* guild, GuildMember* sender)
{
}
void GameLog::GuildSetJob(Guild* guild, GuildMember* sender, int old_job)
{
}
void GameLog::GuildAgreeInvite(Guild* guild, GuildMember* sender)
{
}

View File

@ -1,6 +1,13 @@
#pragma once #pragma once
namespace cs
{
class MFBaseUserData;
}
class Player; class Player;
class Guild;
struct GuildMember;
class GameLog : public a8::Singleton<GameLog> class GameLog : public a8::Singleton<GameLog>
{ {
private: private:
@ -19,6 +26,13 @@ class GameLog : public a8::Singleton<GameLog>
void FriendAgree(Player* hum, long long db_idx, const std::string& account_id); void FriendAgree(Player* hum, long long db_idx, const std::string& account_id);
void FriendDelete(Player* hum, const std::string& account_id); void FriendDelete(Player* hum, const std::string& account_id);
private: void GuildCreate(Player* hum, long long guild_id, const std::string& guild_name);
void GuildApply(Guild* guild, const cs::MFBaseUserData& base_data);
void GuildRefuse(Guild* guild, GuildMember* sender, long long db_idx, const std::string& account_id);
void GuildAgree(Guild* guild, GuildMember* sender, long long db_idx, const std::string& account_id);
void GuildKick(Guild* guild, GuildMember* sender, const std::string& account_id);
void GuildQuit(Guild* guild, GuildMember* sender);
void GuildSetJob(Guild* guild, GuildMember* sender, int old_job);
void GuildAgreeInvite(Guild* guild, GuildMember* sender);
}; };

View File

@ -13,6 +13,7 @@
#include "dbhelper.h" #include "dbhelper.h"
#include "synchelper.h" #include "synchelper.h"
#include "player.h" #include "player.h"
#include "gamelog.h"
#include "framework/cpp/httpclientpool.h" #include "framework/cpp/httpclientpool.h"
@ -265,6 +266,7 @@ void Guild::_CMGuildJoin(f8::MsgHdr& hdr, const cs::CMGuildJoin& msg)
SyncHelper::Instance()->SyncGuildMemberUpdateOnlyOnline(this, member, kGuildUpdateReasonJoin); SyncHelper::Instance()->SyncGuildMemberUpdateOnlyOnline(this, member, kGuildUpdateReasonJoin);
} else { } else {
DBHelper::Instance()->AddGuildApply(this, forward_msg->context().user_info()); DBHelper::Instance()->AddGuildApply(this, forward_msg->context().user_info());
GameLog::Instance()->GuildApply(this, forward_msg->context().user_info().base_data());
} }
} }
@ -383,6 +385,16 @@ void Guild::_CMGuildRefuse(f8::MsgHdr& hdr, const cs::CMGuildRefuse& msg)
ss::SS_IM_ForwardGuildCMMsg *forward_msg = (ss::SS_IM_ForwardGuildCMMsg*)hdr.user_data; ss::SS_IM_ForwardGuildCMMsg *forward_msg = (ss::SS_IM_ForwardGuildCMMsg*)hdr.user_data;
cs::SMGuildRefuse respmsg; cs::SMGuildRefuse respmsg;
GuildMember* sender = GetMember(forward_msg->context().user_info().base_data().account_id());
if (!sender) {
SendErrorMsg(hdr.socket_handle, forward_msg->context(), "服务器内部错误");
respmsg.set_errcode(2);
respmsg.set_errmsg("服务器内部错误");
GuildMgr::Instance()->ForwardGuildSMMsg(hdr.socket_handle,
forward_msg->context(),
respmsg);
return;
}
GuildMgr::Instance()->ForwardGuildSMMsg(hdr.socket_handle, GuildMgr::Instance()->ForwardGuildSMMsg(hdr.socket_handle,
forward_msg->context(), forward_msg->context(),
respmsg); respmsg);
@ -394,6 +406,10 @@ void Guild::_CMGuildRefuse(f8::MsgHdr& hdr, const cs::CMGuildRefuse& msg)
kGuildApplyReject kGuildApplyReject
); );
ClearApplyByIdx(msg.apply().idx()); ClearApplyByIdx(msg.apply().idx());
GameLog::Instance()->GuildRefuse(this,
sender,
msg.apply().idx(),
msg.apply().base_data().account_id());
} }
void Guild::_CMGuildKick(f8::MsgHdr& hdr, const cs::CMGuildKick& msg) void Guild::_CMGuildKick(f8::MsgHdr& hdr, const cs::CMGuildKick& msg)
@ -458,6 +474,11 @@ void Guild::_CMGuildKick(f8::MsgHdr& hdr, const cs::CMGuildKick& msg)
RemoveMember(sender->account_id, RemoveMember(sender->account_id,
member->account_id, member->account_id,
kGuildKick); kGuildKick);
GameLog::Instance()->GuildKick(
this,
sender,
msg.account_id()
);
} }
void Guild::_CMGuildQuit(f8::MsgHdr& hdr, const cs::CMGuildQuit& msg) void Guild::_CMGuildQuit(f8::MsgHdr& hdr, const cs::CMGuildQuit& msg)
@ -470,6 +491,7 @@ void Guild::_CMGuildQuit(f8::MsgHdr& hdr, const cs::CMGuildQuit& msg)
respmsg); respmsg);
GuildMember* sender = GetMember(forward_msg->context().user_info().base_data().account_id()); GuildMember* sender = GetMember(forward_msg->context().user_info().base_data().account_id());
if (sender) { if (sender) {
GameLog::Instance()->GuildQuit(this, sender);
std::string src_account_id = sender->account_id; std::string src_account_id = sender->account_id;
int src_job = GetMemberJob(sender->account_id); int src_job = GetMemberJob(sender->account_id);
RemoveMember(sender->account_id, RemoveMember(sender->account_id,
@ -514,6 +536,7 @@ void Guild::_CMGuildQuit(f8::MsgHdr& hdr, const cs::CMGuildQuit& msg)
void Guild::_CMGuildDismiss(f8::MsgHdr& hdr, const cs::CMGuildDismiss& msg) void Guild::_CMGuildDismiss(f8::MsgHdr& hdr, const cs::CMGuildDismiss& msg)
{ {
#if 0
ss::SS_IM_ForwardGuildCMMsg *forward_msg = (ss::SS_IM_ForwardGuildCMMsg*)hdr.user_data; ss::SS_IM_ForwardGuildCMMsg *forward_msg = (ss::SS_IM_ForwardGuildCMMsg*)hdr.user_data;
cs::SMGuildDismiss respmsg; cs::SMGuildDismiss respmsg;
@ -539,6 +562,7 @@ void Guild::_CMGuildDismiss(f8::MsgHdr& hdr, const cs::CMGuildDismiss& msg)
} }
guild_status_ = kGuildDismissed; guild_status_ = kGuildDismissed;
SaveToDB(); SaveToDB();
#endif
} }
void Guild::_CMGuildChange(f8::MsgHdr& hdr, const cs::CMGuildChange& msg) void Guild::_CMGuildChange(f8::MsgHdr& hdr, const cs::CMGuildChange& msg)
@ -924,6 +948,9 @@ void Guild::_CMGuildMemberSetJob(f8::MsgHdr& hdr, const cs::CMGuildMemberSetJob&
} }
break; break;
} }
GameLog::Instance()->GuildSetJob(this,
sender,
src_job);
} }
{ {
auto p = respmsg.add_chged_members(); auto p = respmsg.add_chged_members();
@ -977,6 +1004,7 @@ void Guild::_CMGuildAgreeInvite(f8::MsgHdr& hdr, const cs::CMGuildAgreeInvite& m
kGuildApplyAgree kGuildApplyAgree
); );
ClearApplyBySenderId(forward_msg->context().user_info().base_data().account_id()); ClearApplyBySenderId(forward_msg->context().user_info().base_data().account_id());
GameLog::Instance()->GuildAgreeInvite(this, member);
} }
int Guild::GetMemberJob(const std::string& account_id) int Guild::GetMemberJob(const std::string& account_id)
@ -1517,4 +1545,10 @@ void Guild::GuildAgreeCb(int socket_handle, const ss::MFIMMsgConext& context, co
}); });
} }
GameLog::Instance()->GuildAgree(
this,
sender,
msg.apply().idx(),
msg.apply().base_data().account_id()
);
} }

View File

@ -700,7 +700,8 @@ void Player::_CMGuildCreate(f8::MsgHdr& hdr, const cs::CMGuildCreate& msg)
f8::HttpClientPool::Instance()->HttpGet f8::HttpClientPool::Instance()->HttpGet
( (
a8::XParams() a8::XParams()
.SetSender(msg_context), .SetSender(msg_context)
.SetParam1(msg.guild_name()),
[] (a8::XParams& param, a8::XObject& data) [] (a8::XParams& param, a8::XObject& data)
{ {
MsgContext* msg_context = (MsgContext*)param.sender.GetUserData(); MsgContext* msg_context = (MsgContext*)param.sender.GetUserData();
@ -709,6 +710,9 @@ void Player::_CMGuildCreate(f8::MsgHdr& hdr, const cs::CMGuildCreate& msg)
if (hum && hum->AccountId() == msg_context->account_id) { if (hum && hum->AccountId() == msg_context->account_id) {
if (data.At("errcode")->AsXValue().GetInt() == 0) { if (data.At("errcode")->AsXValue().GetInt() == 0) {
DBHelper::Instance()->ConfirmGuild(hum, msg_context->guild_id); DBHelper::Instance()->ConfirmGuild(hum, msg_context->guild_id);
GameLog::Instance()->GuildCreate(hum,
msg_context->guild_id,
param.param1);
} else { } else {
hum->ShowErrorMsg(data.At("errmsg")->AsXValue().GetString()); hum->ShowErrorMsg(data.At("errmsg")->AsXValue().GetString());
} }