This commit is contained in:
aozhiwei 2024-01-29 22:19:04 +08:00
parent 6095167478
commit e7c340d53a
2 changed files with 10 additions and 1 deletions

View File

@ -22,3 +22,9 @@ void RoomOb::UnInit()
{ {
} }
Player* RoomOb::GetByAccountId(const std::string& account_id)
{
auto itr = id_hash_.find(account_id);
return itr != id_hash_.end() ? itr->second : nullptr;
}

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
class Room; class Room;
class Player;
class RoomOb : public std::enable_shared_from_this<RoomOb> class RoomOb : public std::enable_shared_from_this<RoomOb>
{ {
@ -11,7 +12,9 @@ class RoomOb : public std::enable_shared_from_this<RoomOb>
void Init(); void Init();
void UnInit(); void UnInit();
Player* GetByAccountId(const std::string& account_id);
private: private:
Room* room_ = nullptr; Room* room_ = nullptr;
std::map<std::string, Player*> id_hash_;
}; };