添加埋点
This commit is contained in:
parent
79be580f3d
commit
acd95739a6
@ -92,3 +92,43 @@ void GameLog::GameEnd(Player* hum)
|
||||
delete prop;
|
||||
prop = nullptr;
|
||||
}
|
||||
|
||||
void GameLog::ZbModeEnd(Room* room)
|
||||
{
|
||||
int game_id = GAME_ID;
|
||||
|
||||
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
|
||||
prop->SetVal("game_uniid", a8::XValue(room->GetRoomUuid()).GetString());
|
||||
prop->SetVal("room_type", a8::XValue(room->GetRoomType()).GetString());
|
||||
prop->SetVal("room_mode", a8::XValue((int)room->GetRoomMode()));
|
||||
prop->SetVal("battle_started", a8::XValue(room->BattleStarted() ? 1 : 0));
|
||||
|
||||
if (room->BattleStarted()) {
|
||||
prop->SetVal("human_alive_count", room->GetAliveCountByRace(kHumanRace));
|
||||
prop->SetVal("zombie_alive_count", room->GetAliveCountByRace(kZombieRace));
|
||||
prop->SetVal("game_timeout", room->IsGameTimeOut() ? 1 : 0);
|
||||
}
|
||||
|
||||
f8::TGLog::Instance()->AddTrackLog(game_id, "gameover", 0, "gameover", prop);
|
||||
|
||||
delete prop;
|
||||
prop = nullptr;
|
||||
}
|
||||
|
||||
void GameLog::ForceOver(Room* room)
|
||||
{
|
||||
int game_id = GAME_ID;
|
||||
|
||||
a8::MutableXObject* prop = a8::MutableXObject::NewObject();
|
||||
prop->SetVal("game_uniid", a8::XValue(room->GetRoomUuid()).GetString());
|
||||
prop->SetVal("room_type", a8::XValue(room->GetRoomType()).GetString());
|
||||
prop->SetVal("room_mode", a8::XValue((int)room->GetRoomMode()));
|
||||
prop->SetVal("battle_started", a8::XValue(room->BattleStarted() ? 1 : 0));
|
||||
prop->SetVal("game_duration", room->GetFrameNo() * SERVER_FRAME_RATE);
|
||||
prop->SetVal("player_num", room->GetRealPlayerNum());
|
||||
|
||||
f8::TGLog::Instance()->AddTrackLog(game_id, "forceover", 0, "forceover", prop);
|
||||
|
||||
delete prop;
|
||||
prop = nullptr;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
class Player;
|
||||
class Room;
|
||||
class GameLog : public a8::Singleton<GameLog>
|
||||
{
|
||||
private:
|
||||
@ -9,6 +10,8 @@ class GameLog : public a8::Singleton<GameLog>
|
||||
public:
|
||||
void GameStart(Player* hum);
|
||||
void GameEnd(Player* hum);
|
||||
void ZbModeEnd(Room* room);
|
||||
void ForceOver(Room* room);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -775,6 +775,7 @@ void Room::OnPlayerOffline(Player* hum)
|
||||
}
|
||||
}
|
||||
if (!has_player) {
|
||||
GameLog::Instance()->ForceOver(this);
|
||||
RoomMgr::Instance()->AddOverRoom(room_uuid_);
|
||||
}
|
||||
}
|
||||
@ -1554,6 +1555,9 @@ void Room::OnGameOver()
|
||||
pair.second->SendGameOver();
|
||||
}
|
||||
}
|
||||
if (GetRoomMode() == kZombieMode) {
|
||||
GameLog::Instance()->ZbModeEnd(this);
|
||||
}
|
||||
RoomMgr::Instance()->AddOverRoom(room_uuid_);
|
||||
}
|
||||
|
||||
@ -2927,9 +2931,12 @@ void Room::ZombieModeStart()
|
||||
{
|
||||
Room* room = (Room*)param.sender.GetUserData();
|
||||
#if 1
|
||||
room->game_over_ = true;
|
||||
room->game_over_frameno_ = room->GetFrameNo();
|
||||
room->OnGameOver();
|
||||
if (!room->game_over_) {
|
||||
room->game_timeout_ = true;
|
||||
room->game_over_ = true;
|
||||
room->game_over_frameno_ = room->GetFrameNo();
|
||||
room->OnGameOver();
|
||||
}
|
||||
#else
|
||||
room->BattleReport();
|
||||
#endif
|
||||
@ -3263,6 +3270,18 @@ void Room::OnZombieAppear(Human* hum)
|
||||
}
|
||||
}
|
||||
|
||||
int Room::GetAliveCountByRace(RaceType_e race)
|
||||
{
|
||||
int count = 0;
|
||||
for (auto& pair : human_hash_) {
|
||||
if (pair.second->GetRace() == race &&
|
||||
!pair.second->dead) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
size_t Room::GetRoomMaxPlayerNum()
|
||||
{
|
||||
if (room_mode_ == kZombieMode) {
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
inline long long GetFrameNo() { return frameno_; }
|
||||
long long GetBattleStartFrameNo() { return battle_start_frameno_; }
|
||||
bool IsGameOver() { return game_over_; }
|
||||
bool IsGameTimeOut() { return game_timeout_; }
|
||||
const GasData& GetGasData() { return gas_data_; }
|
||||
RoomType_e GetRoomType() { return room_type_; }
|
||||
RoomMode_e GetRoomMode() { return room_mode_; }
|
||||
@ -70,6 +71,7 @@ public:
|
||||
Player* GetPlayerByUniId(int uniid);
|
||||
Entity* GetEntityByUniId(int uniid);
|
||||
Human* GetFirstNewBie() { return first_newbie_; }
|
||||
int GetRealPlayerNum() { return accountid_hash_.size();}
|
||||
|
||||
Player* NewPlayer();
|
||||
void AddPlayer(Player* hum);
|
||||
@ -139,6 +141,7 @@ public:
|
||||
void NotifyCountdown(const std::string& msg, int time);
|
||||
void NotifySysPiao(const std::string& msg, int color, int duration);
|
||||
void OnZombieAppear(Human* hum);
|
||||
int GetAliveCountByRace(RaceType_e race);
|
||||
|
||||
private:
|
||||
int AllocUniid();
|
||||
@ -245,6 +248,7 @@ private:
|
||||
GasData gas_data_;
|
||||
long long frameno_ = 0;
|
||||
long long battle_start_frameno_ = 0;
|
||||
bool game_timeout_ = false;
|
||||
bool game_over_ = false;
|
||||
long long game_over_frameno_ = 0;
|
||||
int elapsed_time_ = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user