add gamelog
This commit is contained in:
parent
529ca37af4
commit
3dbfb976d3
@ -31,7 +31,7 @@ public:
|
||||
}
|
||||
App::Instance()->AddSocketMsg(SF_GameGate,
|
||||
(socket_handle << 16) + p->socket_handle,
|
||||
saddr,
|
||||
p->ip_saddr,
|
||||
p->msgid,
|
||||
p->seqid,
|
||||
&buf[offset + sizeof(f8::WSProxyPackHead_C)],
|
||||
|
74
server/gameserver/gamelog.cc
Normal file
74
server/gameserver/gamelog.cc
Normal file
@ -0,0 +1,74 @@
|
||||
#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("from_appid", hum->from_appid);
|
||||
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("map_id", hum->room->map_meta->i->map_id());
|
||||
prop->SetVal("map_name", hum->room->map_meta->i->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("from_appid", hum->from_appid);
|
||||
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_score", hum->stats.score);
|
||||
prop->SetVal("nickname", hum->name);
|
||||
//prop->SetVal("localuuid", "");
|
||||
prop->SetVal("game_time", a8::XGetTickCount() - hum->create_tick);
|
||||
//prop->SetVal("start_param", "");
|
||||
|
||||
prop->SetVal("map_id", hum->room->map_meta->i->map_id());
|
||||
prop->SetVal("map_name", hum->room->map_meta->i->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;
|
||||
}
|
15
server/gameserver/gamelog.h
Normal file
15
server/gameserver/gamelog.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
class Player;
|
||||
class GameLog : public a8::Singleton<GameLog>
|
||||
{
|
||||
private:
|
||||
GameLog(){};
|
||||
friend class a8::Singleton<GameLog>;
|
||||
public:
|
||||
void GameStart(Player* hum);
|
||||
void GameEnd(Player* hum);
|
||||
|
||||
private:
|
||||
|
||||
};
|
@ -15,6 +15,7 @@
|
||||
#include "app.h"
|
||||
#include "roommgr.h"
|
||||
#include "android.h"
|
||||
#include "gamelog.h"
|
||||
|
||||
#include "framework/cpp/utils.h"
|
||||
#include "framework/cpp/httpclientpool.h"
|
||||
@ -1884,6 +1885,10 @@ void Human::InternalSendGameOver()
|
||||
cs::SMGameOver msg;
|
||||
hum->FillSMGameOver(msg);
|
||||
hum->SendNotifyMsg(msg);
|
||||
if (!hum->sent_game_end_ && hum->entity_subtype == EST_Player) {
|
||||
GameLog::Instance()->GameEnd((Player*)hum);
|
||||
hum->sent_game_end_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -34,9 +34,12 @@ class Human : public Entity
|
||||
{
|
||||
public:
|
||||
int socket_handle = 0;
|
||||
long ip_saddr = 0;
|
||||
int team_id = 0;
|
||||
std::string account_id;
|
||||
std::string from_appid;
|
||||
std::string team_uuid;
|
||||
int account_registertime = 0;
|
||||
MetaData::Player* meta = nullptr;
|
||||
MetaData::Equip* helmet_meta = nullptr;
|
||||
MetaData::Equip* chest_meta = nullptr;
|
||||
@ -226,6 +229,7 @@ private:
|
||||
|
||||
bool already_report_battle_ = false;
|
||||
bool sending_gameover_ = false;
|
||||
bool sent_game_end_ = false;
|
||||
int send_gameover_trycount_ = 0;
|
||||
|
||||
friend class FrameMaker;
|
||||
|
@ -25,6 +25,7 @@ class Player : public Human
|
||||
int player_count = 0;
|
||||
bool auto_fill = false;
|
||||
bool use_touch = false;
|
||||
long long create_tick = 0;
|
||||
|
||||
int last_seq_id = 0;
|
||||
bool moving = false;
|
||||
|
@ -33,10 +33,11 @@ Player* PlayerMgr::GetPlayerBySocket(int socket)
|
||||
return itr != socket_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
Player* PlayerMgr::CreatePlayerByCMJoin(int socket, const cs::CMJoin& msg)
|
||||
Player* PlayerMgr::CreatePlayerByCMJoin(long ip_saddr, int socket, const cs::CMJoin& msg)
|
||||
{
|
||||
Player* hum = new Player();
|
||||
hum->socket_handle = socket;
|
||||
hum->ip_saddr = ip_saddr;
|
||||
hum->account_id = msg.account_id();
|
||||
hum->name = msg.name();
|
||||
hum->health = 0;
|
||||
@ -47,6 +48,7 @@ Player* PlayerMgr::CreatePlayerByCMJoin(int socket, const cs::CMJoin& msg)
|
||||
hum->use_touch = msg.use_touch();
|
||||
hum->avatar_url = msg.avatar_url();
|
||||
hum->energy_shield = msg.energy_shield();
|
||||
hum->create_tick = a8::XGetTickCount();
|
||||
for (auto& weapon : msg.weapons()) {
|
||||
if (weapon.weapon_id() != 0 && weapon.weapon_lv() > 0) {
|
||||
hum->weapon_configs[weapon.weapon_id()] = weapon.weapon_lv();
|
||||
|
@ -28,7 +28,7 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
|
||||
|
||||
int OnlineNum();
|
||||
Player* GetPlayerBySocket(int socket);
|
||||
Player* CreatePlayerByCMJoin(int socket, const cs::CMJoin& msg);
|
||||
Player* CreatePlayerByCMJoin(long ip_saddr, int socket, const cs::CMJoin& msg);
|
||||
void OnClientDisconnect(a8::XParams& param);
|
||||
void RemovePlayerBySocket(int socket_handle);
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "roommgr.h"
|
||||
#include "app.h"
|
||||
#include "hero.h"
|
||||
#include "gamelog.h"
|
||||
|
||||
const int ROOM_MAX_PLAYER_NUM = 50;
|
||||
|
||||
@ -890,11 +891,14 @@ void Room::UpdateGas()
|
||||
{
|
||||
if (a8::HasBitFlag(hum->status, HS_Fly)) {
|
||||
hum->DoJump();
|
||||
if (hum->entity_subtype == EST_Player) {
|
||||
GameLog::Instance()->GameStart((Player*)hum);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
gas_data.gas_mode = GasWaiting;
|
||||
gas_data.old_area_meta = MetaMgr::Instance()->GetSafeArea(30001);
|
||||
gas_data.old_area_meta = MetaMgr::Instance()->GetSafeArea(30001);
|
||||
gas_data.new_area_meta = MetaMgr::Instance()->GetSafeArea(30002);
|
||||
gas_data.gas_progress = gas_data.old_area_meta->i->rad();
|
||||
gas_data.gas_start_frameno = frame_no;
|
||||
|
@ -84,9 +84,9 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
}
|
||||
if (i == 0) {
|
||||
{
|
||||
Player* hum = PlayerMgr::Instance()->CreatePlayerByCMJoin(hdr.socket_handle, msg);
|
||||
hum->meta = hum_meta;
|
||||
room->AddPlayer(hum);
|
||||
Player* hum = PlayerMgr::Instance()->CreatePlayerByCMJoin(hdr.ip_saddr, hdr.socket_handle, msg);
|
||||
hum->meta = hum_meta;
|
||||
room->AddPlayer(hum);
|
||||
|
||||
cs::SMJoinedNotify notifymsg;
|
||||
notifymsg.set_error_code(0);
|
||||
@ -115,7 +115,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
inactive_room_hash_[room->room_uuid] = room;
|
||||
room_hash_[room->room_uuid] = room;
|
||||
}
|
||||
Player* hum = PlayerMgr::Instance()->CreatePlayerByCMJoin(hdr.socket_handle, msg);
|
||||
Player* hum = PlayerMgr::Instance()->CreatePlayerByCMJoin(hdr.ip_saddr, hdr.socket_handle, msg);
|
||||
hum->meta = hum_meta;
|
||||
room->AddPlayer(hum);
|
||||
|
||||
|
2
third_party/a8engine
vendored
2
third_party/a8engine
vendored
@ -1 +1 @@
|
||||
Subproject commit f9222e376f8a678a252932c4a3fb93860d7625f2
|
||||
Subproject commit c086156f8094a8ecce9faf5f30667d22e3918dc1
|
Loading…
x
Reference in New Issue
Block a user