2020-07-22 17:22:42 +08:00

95 lines
4.1 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 "app.h"
#include "room.h"
#include "metadata.h"
void GameLog::GameStart(Player* hum)
{
int logclass1 = 11;
int logclass2 = 4;
int game_id = f8::ExtractGameIdFromAccountId(hum->account_id);
std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->account_id));
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("channel", channel);
prop->SetVal("ad_channel", "");
prop->SetVal("from_appid", hum->from_appid);
prop->SetVal("gameid", GAME_ID);
prop->SetVal("account_id", hum->account_id);
prop->SetVal("account_register_utctime", hum->account_registertime);
prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime));
prop->SetVal("game_uniid", a8::XValue(hum->room->GetRoomUuid()).GetString());
prop->SetVal("room_type", a8::XValue(hum->room->GetRoomType()).GetString());
prop->SetVal("room_mode", a8::XValue((int)hum->room->GetRoomMode()));
//prop->SetVal("game_param", "");
prop->SetVal("nickname", hum->name);
//prop->SetVal("localuuid", "");
//prop->SetVal("start_param", "");
prop->SetVal("team_id", hum->team_id);
prop->SetVal("server_node_id", App::Instance()->node_id);
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("map_id", hum->room->GetMapMeta()->i->map_id());
prop->SetVal("map_name", hum->room->GetMapMeta()->i->map_name());
prop->SetVal("map_tpl_name", hum->room->GetMapTplName());
f8::TGLog::Instance()->AddTrackLog(game_id, hum->account_id, hum->ip_saddr, logclass1, logclass2, prop);
delete prop;
prop = nullptr;
}
void GameLog::GameEnd(Player* hum)
{
int logclass1 = 11;
int logclass2 = 6;
int game_id = f8::ExtractGameIdFromAccountId(hum->account_id);
std::string channel = a8::XValue(f8::ExtractChannelIdFromAccountId(hum->account_id));
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
prop->SetVal("channel", channel);
prop->SetVal("ad_channel", "");
prop->SetVal("from_appid", hum->from_appid);
prop->SetVal("gameid", GAME_ID);
prop->SetVal("account_id", hum->account_id);
prop->SetVal("account_register_utctime", hum->account_registertime);
prop->SetVal("account_register_date", a8::TimestampToDateTime(hum->account_registertime));
prop->SetVal("game_uniid", a8::XValue(hum->room->GetRoomUuid()).GetString());
prop->SetVal("room_type", a8::XValue(hum->room->GetRoomType()).GetString());
prop->SetVal("room_mode", a8::XValue((int)hum->room->GetRoomMode()));
//prop->SetVal("game_param", "");
prop->SetVal("game_gold", hum->stats.gold);
prop->SetVal("game_score", hum->stats.score);
prop->SetVal("game_pass_score", hum->has_pass ? hum->stats.pass_score * 2 : hum->stats.pass_score);
prop->SetVal("game_rank_score", hum->stats.rank_score);
prop->SetVal("has_pass", hum->has_pass ? 1 : 0);
prop->SetVal("nickname", hum->name);
//prop->SetVal("localuuid", "");
prop->SetVal("game_time", a8::XGetTickCount() - hum->create_tick);
//prop->SetVal("start_param", "");
prop->SetVal("team_id", hum->team_id);
prop->SetVal("server_node_id", App::Instance()->node_id);
prop->SetVal("server_instance_id", App::Instance()->instance_id);
prop->SetVal("map_id", hum->room->GetMapMeta()->i->map_id());
prop->SetVal("map_name", hum->room->GetMapMeta()->i->map_name());
prop->SetVal("map_tpl_name", hum->room->GetMapTplName());
if (!hum->dead) {
prop->SetVal("alive_time", hum->room->GetFrameNo() * 1000.0f / SERVER_FRAME_RATE);
} else {
prop->SetVal("alive_time", hum->dead_frameno * 1000.0f / SERVER_FRAME_RATE);
}
prop->SetVal("gameover_pass_frame_num", hum->room->GetFrameNo() - hum->last_cmmove_frameno);
prop->SetVal("socket_handle", hum->socket_handle);
f8::TGLog::Instance()->AddTrackLog(game_id, hum->account_id, hum->ip_saddr, logclass1, logclass2, prop);
delete prop;
prop = nullptr;
}