增加玩家管理(没做完,需要steamid绑定名字啥的)
This commit is contained in:
26
csgo2/player_manager.cpp
Normal file
26
csgo2/player_manager.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "player_manager.h"
|
||||
namespace PlayerManager {
|
||||
std::shared_mutex mutex_PlayerNameList;
|
||||
std::unordered_map<uint32_t, std::string> PlayerNameList;
|
||||
auto AddPlayerNameToPlayerNameList(const CPlayerSlot PlayerSlot,
|
||||
const char* PlayerName) -> void {
|
||||
std::unique_lock lock(mutex_PlayerNameList);
|
||||
PlayerNameList[PlayerSlot.Get()] = PlayerName;
|
||||
LOG("%s PlayerNameList[%d] = %s \n", __FUNCTION__, PlayerSlot.Get(),
|
||||
PlayerName);
|
||||
}
|
||||
auto RemovePlayerNameFromPlayerNameList(const CPlayerSlot PlayerSlot,
|
||||
const char* PlayerName) -> void {
|
||||
std::unique_lock lock(mutex_PlayerNameList);
|
||||
PlayerNameList.erase(PlayerSlot.Get());
|
||||
LOG("%s PlayerNameList[%d] = %s \n", __FUNCTION__, PlayerSlot.Get(),
|
||||
PlayerName);
|
||||
}
|
||||
auto GetPlayerNameByPlayerSlot(const CPlayerSlot PlayerSlot) -> std::string {
|
||||
std::shared_lock lock(mutex_PlayerNameList);
|
||||
auto index = PlayerSlot.Get();
|
||||
auto name = PlayerNameList[index];
|
||||
LOG("get player name: %d %s \n", index, name.c_str());
|
||||
return name;
|
||||
}
|
||||
}; // namespace PlayerManager
|
||||
Reference in New Issue
Block a user