aozhiwei 8ea4821d7f 1
2019-11-21 17:47:21 +08:00

89 lines
3.6 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->room_uuid).GetString());
//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->map_meta->p->map_id());
prop->SetVal("map_name", hum->room->map_meta->p->map_name());
prop->SetVal("map_tpl_name", hum->room->map_tpl_name);
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->room_uuid).GetString());
//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->map_meta->p->map_id());
prop->SetVal("map_name", hum->room->map_meta->p->map_name());
prop->SetVal("map_tpl_name", hum->room->map_tpl_name);
if (!hum->dead) {
prop->SetVal("alive_time", hum->room->frame_no * 1000.0f / SERVER_FRAME_RATE);
} else {
prop->SetVal("alive_time", hum->dead_frameno * 1000.0f / SERVER_FRAME_RATE);
}
f8::TGLog::Instance()->AddTrackLog(game_id, hum->account_id, hum->ip_saddr, logclass1, logclass2, prop);
delete prop;
prop = nullptr;
}