relation/server/imserver/gamelog.cc
aozhiwei beb7b96837 1
2020-10-13 17:16:20 +08:00

406 lines
17 KiB
C++

#include "precompile.h"
#include "gamelog.h"
#include "framework/cpp/utils.h"
#include "framework/cpp/tglog.h"
#include <a8/mutable_xobject.h>
#include "player.h"
#include "guild.h"
#include "app.h"
#include "cs_proto.pb.h"
const char* const FRIEND_LOGIN_EVENT = "friend_login";
const char* const FRIEND_LOGOUT_EVENT = "friend_logout";
const char* const FRIEND_APPLY_EVENT = "friend_apply";
const char* const FRIEND_REFUSE_EVENT = "friend_refuse";
const char* const FRIEND_AGREE_EVENT = "friend_agree";
const char* const FRIEND_DELETE_EVENT = "friend_delete";
const char* const GUILD_CREATE_EVENT = "guild_create";
const char* const GUILD_APPLY_EVENT = "guild_apply";
const char* const GUILD_REFUSE_EVENT = "guild_refuse";
const char* const GUILD_AGREE_EVENT = "guild_agree";
const char* const GUILD_KICK_EVENT = "guild_kick";
const char* const GUILD_QUIT_EVENT = "guild_quit";
const char* const GUILD_SETJOB_EVENT = "guild_setjob";
const char* const GUILD_AGREE_INVITE_EVENT = "guild_agree_invite";
void GameLog::Init()
{
}
void GameLog::UnInit()
{
}
void GameLog::Login(Player* hum)
{
int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId());
std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId()));
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("channel", channel);
prop->SetVal("ad_channel", "");
prop->SetVal("gameid", game_id);
prop->SetVal("account_id", hum->AccountId());
prop->SetVal("account_register_utctime", hum->account_registertime);
prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime));
prop->SetVal("nickname", hum->NickName());
prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString());
prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString());
prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
f8::TGLog::Instance()->AddTrackLog(game_id,
hum->AccountId(),
hum->ip_saddr,
FRIEND_LOGIN_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::Logout(Player* hum)
{
int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId());
std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId()));
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("channel", channel);
prop->SetVal("ad_channel", "");
prop->SetVal("gameid", game_id);
prop->SetVal("account_id", hum->AccountId());
prop->SetVal("account_register_utctime", hum->account_registertime);
prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime));
prop->SetVal("nickname", hum->NickName());
prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString());
prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString());
prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
f8::TGLog::Instance()->AddTrackLog(game_id,
hum->AccountId(),
hum->ip_saddr,
FRIEND_LOGOUT_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::FriendApply(Player* hum, const std::string& account_id)
{
int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId());
std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId()));
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("channel", channel);
prop->SetVal("ad_channel", "");
prop->SetVal("gameid", game_id);
prop->SetVal("account_id", hum->AccountId());
prop->SetVal("account_register_utctime", hum->account_registertime);
prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime));
prop->SetVal("nickname", hum->NickName());
prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString());
prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString());
prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("target_id", account_id);
f8::TGLog::Instance()->AddTrackLog(game_id,
hum->AccountId(),
hum->ip_saddr,
FRIEND_APPLY_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::FriendRefuse(Player* hum, long long db_idx, const std::string& account_id)
{
int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId());
std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId()));
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("channel", channel);
prop->SetVal("ad_channel", "");
prop->SetVal("gameid", game_id);
prop->SetVal("account_id", hum->AccountId());
prop->SetVal("account_register_utctime", hum->account_registertime);
prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime));
prop->SetVal("nickname", hum->NickName());
prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString());
prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString());
prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("db_idx", db_idx);
prop->SetVal("target_id", account_id);
f8::TGLog::Instance()->AddTrackLog(game_id,
hum->AccountId(),
hum->ip_saddr,
FRIEND_REFUSE_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::FriendAgree(Player* hum, long long db_idx, const std::string& account_id)
{
int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId());
std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId()));
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("channel", channel);
prop->SetVal("ad_channel", "");
prop->SetVal("gameid", game_id);
prop->SetVal("account_id", hum->AccountId());
prop->SetVal("account_register_utctime", hum->account_registertime);
prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime));
prop->SetVal("nickname", hum->NickName());
prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString());
prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString());
prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("db_idx", db_idx);
prop->SetVal("target_id", account_id);
f8::TGLog::Instance()->AddTrackLog(game_id,
hum->AccountId(),
hum->ip_saddr,
FRIEND_AGREE_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::FriendDelete(Player* hum, const std::string& account_id)
{
int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId());
std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId()));
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("channel", channel);
prop->SetVal("ad_channel", "");
prop->SetVal("gameid", game_id);
prop->SetVal("account_id", hum->AccountId());
prop->SetVal("account_register_utctime", hum->account_registertime);
prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime));
prop->SetVal("nickname", hum->NickName());
prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString());
prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString());
prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("target_id", account_id);
f8::TGLog::Instance()->AddTrackLog(game_id,
hum->AccountId(),
hum->ip_saddr,
FRIEND_DELETE_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::GuildCreate(Player* hum, long long guild_id, const std::string& guild_name)
{
int game_id = f8::ExtractGameIdFromAccountId(hum->AccountId());
std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->AccountId()));
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("channel", channel);
prop->SetVal("ad_channel", "");
prop->SetVal("gameid", game_id);
prop->SetVal("account_id", hum->AccountId());
prop->SetVal("account_register_utctime", hum->account_registertime);
prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime));
prop->SetVal("nickname", hum->NickName());
prop->SetVal("user_value1", a8::XValue(hum->myself.base_data.user_value1).GetString());
prop->SetVal("user_value2", a8::XValue(hum->myself.base_data.user_value2).GetString());
prop->SetVal("user_value3", a8::XValue(hum->myself.base_data.user_value3).GetString());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("guild_id", guild_id);
prop->SetVal("guild_name", guild_name);
f8::TGLog::Instance()->AddTrackLog(game_id,
hum->AccountId(),
hum->ip_saddr,
GUILD_CREATE_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::GuildApply(Guild* guild, const cs::MFBaseUserData& base_data)
{
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("gameid", guild->GetGameId());
prop->SetVal("channel", guild->GetChannel());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("guild_id", guild->GuildId());
prop->SetVal("guild_name", guild->GuildName());
prop->SetVal("mumber_num", guild->GetMemberNum());
prop->SetVal("account_id", base_data.account_id());
prop->SetVal("nickname", base_data.nickname());
prop->SetVal("user_value1", a8::XValue(base_data.user_value1()).GetString());
prop->SetVal("user_value2", a8::XValue(base_data.user_value2()).GetString());
prop->SetVal("user_value3", a8::XValue(base_data.user_value3()).GetString());
f8::TGLog::Instance()->AddTrackLog(guild->GetGameId(),
base_data.account_id(),
0,
GUILD_APPLY_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::GuildRefuse(Guild* guild, GuildMember* sender, long long db_idx, const std::string& account_id)
{
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("gameid", guild->GetGameId());
prop->SetVal("channel", guild->GetChannel());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("guild_id", guild->GuildId());
prop->SetVal("guild_name", guild->GuildName());
prop->SetVal("mumber_num", guild->GetMemberNum());
prop->SetVal("sender_account_id", sender->account_id);
prop->SetVal("sender_job", guild->GetMemberJob(sender->account_id));
prop->SetVal("target_account_id", account_id);
f8::TGLog::Instance()->AddTrackLog(guild->GetGameId(),
sender->account_id,
0,
GUILD_REFUSE_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::GuildAgree(Guild* guild, GuildMember* sender, long long db_idx, const std::string& account_id)
{
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("gameid", guild->GetGameId());
prop->SetVal("channel", guild->GetChannel());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("guild_id", guild->GuildId());
prop->SetVal("guild_name", guild->GuildName());
prop->SetVal("mumber_num", guild->GetMemberNum());
prop->SetVal("sender_account_id", sender->account_id);
prop->SetVal("sender_job", guild->GetMemberJob(sender->account_id));
prop->SetVal("target_account_id", account_id);
prop->SetVal("db_idx", db_idx);
f8::TGLog::Instance()->AddTrackLog(guild->GetGameId(),
sender->account_id,
0,
GUILD_AGREE_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::GuildKick(Guild* guild, GuildMember* sender, const std::string& account_id)
{
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("gameid", guild->GetGameId());
prop->SetVal("channel", guild->GetChannel());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("guild_id", guild->GuildId());
prop->SetVal("guild_name", guild->GuildName());
prop->SetVal("mumber_num", guild->GetMemberNum());
prop->SetVal("sender_account_id", sender->account_id);
prop->SetVal("sender_job", guild->GetMemberJob(sender->account_id));
prop->SetVal("target_account_id", account_id);
prop->SetVal("target_job", guild->GetMemberJob(account_id));
f8::TGLog::Instance()->AddTrackLog(guild->GetGameId(),
sender->account_id,
0,
GUILD_KICK_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::GuildQuit(Guild* guild, GuildMember* sender)
{
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("gameid", guild->GetGameId());
prop->SetVal("channel", guild->GetChannel());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("guild_id", guild->GuildId());
prop->SetVal("guild_name", guild->GuildName());
prop->SetVal("mumber_num", guild->GetMemberNum());
prop->SetVal("sender_account_id", sender->account_id);
prop->SetVal("sender_job", guild->GetMemberJob(sender->account_id));
f8::TGLog::Instance()->AddTrackLog(guild->GetGameId(),
sender->account_id,
0,
GUILD_QUIT_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::GuildSetJob(Guild* guild, GuildMember* sender, int old_job)
{
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("gameid", guild->GetGameId());
prop->SetVal("channel", guild->GetChannel());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("guild_id", guild->GuildId());
prop->SetVal("guild_name", guild->GuildName());
prop->SetVal("mumber_num", guild->GetMemberNum());
prop->SetVal("sender_account_id", sender->account_id);
prop->SetVal("sender_job", guild->GetMemberJob(sender->account_id));
prop->SetVal("sender_old_job", old_job);
f8::TGLog::Instance()->AddTrackLog(guild->GetGameId(),
sender->account_id,
0,
GUILD_SETJOB_EVENT,
prop);
delete prop;
prop = nullptr;
}
void GameLog::GuildAgreeInvite(Guild* guild, GuildMember* sender)
{
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("gameid", guild->GetGameId());
prop->SetVal("channel", guild->GetChannel());
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("guild_id", guild->GuildId());
prop->SetVal("guild_name", guild->GuildName());
prop->SetVal("mumber_num", guild->GetMemberNum());
prop->SetVal("sender_account_id", sender->account_id);
prop->SetVal("sender_job", guild->GetMemberJob(sender->account_id));
f8::TGLog::Instance()->AddTrackLog(guild->GetGameId(),
sender->account_id,
0,
GUILD_AGREE_INVITE_EVENT,
prop);
delete prop;
prop = nullptr;
}