增加玩家管理(没做完,需要steamid绑定名字啥的)

This commit is contained in:
Huoji's
2023-10-01 22:13:20 +08:00
parent fb67632502
commit 1bae80e38d
681 changed files with 391721 additions and 218 deletions

26
csgo2/player_manager.cpp Normal file
View 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