mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
26 lines
615 B
C++
26 lines
615 B
C++
|
#include "CNShared.hpp"
|
||
|
|
||
|
#ifdef __MINGW32__
|
||
|
#include "mingw/mingw.mutex.h"
|
||
|
#else
|
||
|
#include <mutex>
|
||
|
#endif
|
||
|
std::map<int64_t, Player> CNSharedData::players;
|
||
|
std::mutex playerCrit;
|
||
|
|
||
|
void CNSharedData::setPlayer(int64_t sk, Player& plr) {
|
||
|
std::lock_guard<std::mutex> lock(playerCrit); // the lock will be removed when the function ends
|
||
|
|
||
|
players[sk] = plr;
|
||
|
}
|
||
|
|
||
|
Player CNSharedData::getPlayer(int64_t sk) {
|
||
|
return players[sk];
|
||
|
}
|
||
|
|
||
|
void CNSharedData::erasePlayer(int64_t sk) {
|
||
|
std::lock_guard<std::mutex> lock(playerCrit); // the lock will be removed when the function ends
|
||
|
|
||
|
players.erase(sk);
|
||
|
}
|