This commit is contained in:
aozhiwei 2023-11-08 10:38:37 +08:00
parent e1b3882a0e
commit a0f4623bd9
12 changed files with 35 additions and 35 deletions

View File

@ -499,9 +499,9 @@ bool App::ParseOpt()
return instance_id > 0 && node_id > 0;
}
long long App::NewUuid()
std::string App::NewUuid()
{
return uuid.Generate();
return a8::XValue(uuid.Generate()).GetString();
}
bool App::HasFlag(int flag)

View File

@ -32,7 +32,7 @@ public:
void NotifyLoopCond();
long long NewUuid();
std::string NewUuid();
bool HasFlag(int flag);
void SetFlag(int flag);
void UnSetFlag(int flag);

View File

@ -1446,7 +1446,7 @@ void Human::SendBattleReport()
already_report_battle_ = true;
SendGameOver();
} else {
long long room_uuid = room->GetRoomUuid();
std::string room_uuid = room->GetRoomUuid();
std::string sender_id = account_id;
HttpProxy::Instance()->HttpGet
(

View File

@ -59,7 +59,7 @@ class Human : public Creature
int today_enter_times = 0;
int account_registertime = 0;
int channel = 0;
long long battle_uuid = 0;
std::string battle_uuid;
int is_valid_battle = 0;
std::string payload;
HumanBehavior behavior;

View File

@ -41,7 +41,7 @@ struct RawTeamMember
{
class MatchTeam* team = nullptr;
std::shared_ptr<BattleDataContext> battle_context;
long long battle_uuid = 0;
std::string battle_uuid;
int is_valid_battle = 0;
std::string payload;
long long add_tick = 0;

View File

@ -18,7 +18,7 @@ class Skill;
struct BattleDataContext
{
std::shared_ptr<cs::CMJoin> join_msg;
long long battle_uuid = 0;
std::string battle_uuid;
int is_valid_battle = 0;
std::string payload;
int errcode = 0;

View File

@ -1662,7 +1662,7 @@ void Human::SendBattleSettlement()
}
}
#endif
long long room_uuid = room->GetRoomUuid();
std::string room_uuid = room->GetRoomUuid();
std::string tmp_account_id = account_id;
HttpProxy::Instance()->HttpGet

View File

@ -1325,7 +1325,7 @@ void Player::_CMRevive(f8::MsgHdr& hdr, const cs::CMRevive& msg)
url_params->SetVal("target_id", hum->account_id);
url_params->SetVal("num", 1);
long long room_uuid = room->GetRoomUuid();
std::string room_uuid = room->GetRoomUuid();
auto target_uniid = msg.target_uniid();
HttpProxy::Instance()->HttpGet
(

View File

@ -114,7 +114,7 @@ public:
const GasData& GetGasData() { return gas_data_; }
RoomType_e GetRoomType() { return room_type_; }
RoomMode_e GetRoomMode() { return room_mode_; }
long long GetRoomUuid() { return room_uuid_; }
std::string GetRoomUuid() { return room_uuid_; }
int GetRoomIdx() { return room_idx_; }
std::string GetMapTplName() { return map_tpl_name_; }
const mt::Map* GetMapMeta() { return map_meta_; }
@ -359,7 +359,7 @@ private:
std::vector<int> poly_ext_datas_;
int room_idx_ = 0;
RoomMode_e room_mode_ = kPvpMode;
long long room_uuid_ = 0;
std::string room_uuid_;
const mt::Map* map_meta_ = nullptr;
std::string map_tpl_name_;
RoomType_e room_type_ = RoomType_NewBrid;

View File

@ -362,7 +362,7 @@ Room* RoomMgr::GetJoinableRoom(MatchTeam* team)
nullptr);
}
Room* RoomMgr::GetRoomByUuid(long long room_uuid)
Room* RoomMgr::GetRoomByUuid(const std::string& room_uuid)
{
auto itr = room_hash_.find(room_uuid);
return itr != room_hash_.end() ? itr->second : nullptr;
@ -374,7 +374,7 @@ Room* RoomMgr::GetRoomByIdx(int room_idx)
return itr != room_idx_hash_.end() ? itr->second : nullptr;
}
void RoomMgr::AddOverRoom(long long room_uuid)
void RoomMgr::AddOverRoom(const std::string& room_uuid)
{
auto callback =
[room_uuid] (int event, const a8::Args* args)
@ -400,7 +400,7 @@ void RoomMgr::AddOverRoom(long long room_uuid)
}
}
void RoomMgr::ActiveRoom(long long room_uuid)
void RoomMgr::ActiveRoom(const std::string& room_uuid)
{
inactive_room_hash_.erase(room_uuid);
}
@ -467,7 +467,7 @@ void RoomMgr::ReportServerState(int instance_id, const std::string& host, int po
);
}
void RoomMgr::FreeOverRoom(long long room_uuid)
void RoomMgr::FreeOverRoom(const std::string& room_uuid)
{
auto itr = over_room_hash_.find(room_uuid);
if (itr != over_room_hash_.end()) {
@ -626,7 +626,7 @@ void RoomMgr::JoinTeam(MatchTeam* team)
room->AddTeam(team);
}
std::string RoomMgr::GenTeamHashData(const std::string& team_uuid, std::map<std::string, long long>* team_hash)
std::string RoomMgr::GenTeamHashData(const std::string& team_uuid, std::map<std::string, std::string>* team_hash)
{
std::string data;
data += a8::Format("team_uuid:%s ", {team_uuid});
@ -641,15 +641,15 @@ void RoomMgr::OnJoinRoomOk(const cs::CMJoin& msg, Player* hum)
if (msg.team_uuid().empty()) {
return;
}
std::map<std::string, long long>* team_hash = nullptr;
std::map<std::string, std::string>* team_hash = nullptr;
{
auto itr = team_room_hash_.find(msg.team_uuid());
if (itr == team_room_hash_.end()) {
team_room_hash_[msg.team_uuid()] = std::map<std::string, long long>();
team_room_hash_[msg.team_uuid()] = std::map<std::string, std::string>();
itr = team_room_hash_.find(msg.team_uuid());
team_hash = &itr->second;
for (auto& team_member : msg.team_members()) {
team_hash->insert(std::make_pair(team_member.account_id(), 0));
team_hash->insert(std::make_pair(team_member.account_id(), ""));
}
std::string team_uuid = msg.team_uuid();
f8::Timer::Instance()->SetTimeout
@ -686,7 +686,7 @@ void RoomMgr::OnJoinRoomOk(const cs::CMJoin& msg, Player* hum)
void RoomMgr::TeamRoomTimeOut(const std::string& team_uuid)
{
std::map<std::string, long long>* team_hash = nullptr;
std::map<std::string, std::string>* team_hash = nullptr;
{
auto itr = team_room_hash_.find(team_uuid);
if (itr != team_room_hash_.end()) {
@ -696,7 +696,7 @@ void RoomMgr::TeamRoomTimeOut(const std::string& team_uuid)
if (team_hash) {
bool ok = true;
for (auto pair : *team_hash) {
if (pair.second == 0) {
if (pair.second.empty()) {
ok = false;
break;
}

View File

@ -29,7 +29,7 @@ struct RoomInitInfo
{
int room_idx = 0;
RoomMode_e room_mode = kPvpMode;
long long room_uuid = 0;
std::string room_uuid;
RoomType_e room_type = RoomType_NewBrid;
int creator_game_times = 0;
int creator_register_time = 0;
@ -75,11 +75,11 @@ class RoomMgr : public a8::Singleton<RoomMgr>
void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg);
void _CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg);
void _CMPing(f8::MsgHdr& hdr, const cs::CMPing& msg);
void ActiveRoom(long long room_uuid);
void ActiveRoom(const std::string& room_uuid);
int RoomNum();
int OverRoomNum();
Room* GetRoomByUuid(long long uuid);
void AddOverRoom(long long room_uuid);
Room* GetRoomByUuid(const std::string& uuid);
void AddOverRoom(const std::string& room_uuid);
bool IsGM(const std::string& account_id);
void JoinTeam(MatchTeam* team);
void SendGetBattleData(int mode,
@ -100,7 +100,7 @@ class RoomMgr : public a8::Singleton<RoomMgr>
int channel);
Room* GetJoinableRoom(MatchTeam* team);
void ReportServerState(int instance_id, const std::string& host, int port);
void FreeOverRoom(long long room_uuid);
void FreeOverRoom(const std::string& room_uuid);
bool IsLimitJoin();
int AllocRoomIdx();
@ -113,7 +113,7 @@ class RoomMgr : public a8::Singleton<RoomMgr>
int map_id,
std::shared_ptr<CustomBattle> custom_battle);
void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle);
std::string GenTeamHashData(const std::string& team_uuid, std::map<std::string, long long>* team_hash);
std::string GenTeamHashData(const std::string& team_uuid, std::map<std::string, std::string>* team_hash);
void OnJoinRoomOk(const cs::CMJoin& msg, Player* hum);
void TeamRoomTimeOut(const std::string& team_uuid);
void AdjustCMJoin(cs::CMJoin* msg);
@ -127,13 +127,13 @@ class RoomMgr : public a8::Singleton<RoomMgr>
int current_room_idx_ = 0;
int match_mode_ = 0;
std::map<long long, Room*> inactive_room_hash_;
std::map<long long, Room*> room_hash_;
std::map<std::string, Room*> inactive_room_hash_;
std::map<std::string, Room*> room_hash_;
std::map<int, Room*> room_idx_hash_;
std::map<long long, Room*> over_room_hash_;
std::map<std::string, Room*> over_room_hash_;
f8::Attacher reportstate_timer_attacher_;
std::map<std::string, int> gm_hash_;
std::map<std::string, std::map<std::string, long long>> team_room_hash_;
std::map<std::string, std::map<std::string, std::string>> team_room_hash_;
std::map<std::string, std::shared_ptr<CustomBattle>> custom_room_hash_;
std::map<std::string, std::shared_ptr<CustomBattle>> his_custom_room_hash_;
};

View File

@ -245,7 +245,7 @@ void Team::SendTeamBattleReport(Human* sender)
params->SetVal("session_id", player->session_id);
params->SetVal("__POST", post_data->ToJsonStr());
long long room_uuid = room->GetRoomUuid();
std::string room_uuid = room->GetRoomUuid();
int team_id = GetTeamId();
HttpProxy::Instance()->HttpGet
(
@ -475,14 +475,14 @@ void Team::GenBattleReportData(Human* player, a8::MutableXObject* params)
void Team::GenBattleUuid()
{
long long battle_uuid = 0;
std::string battle_uuid = 0;
for (Human* hum : members_) {
if (hum->battle_uuid) {
if (!hum->battle_uuid.empty()) {
battle_uuid = hum->battle_uuid;
break;
}
}
if (!battle_uuid) {
if (!battle_uuid.empty()) {
battle_uuid = App::Instance()->NewUuid();
}