mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-18 03:21:27 +02:00
Removed no longer used mutexes from match server
This commit is contained in:
parent
f97ffd8e9a
commit
6eef197cea
@ -983,10 +983,7 @@ void CGameHandler::start(bool resume)
|
|||||||
for (PlayerColor color : players)
|
for (PlayerColor color : players)
|
||||||
{
|
{
|
||||||
sbuffer << color << " ";
|
sbuffer << color << " ";
|
||||||
{
|
connections[color].insert(cc);
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(gsm);
|
|
||||||
connections[color].insert(cc);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
logGlobal->info(sbuffer.str());
|
logGlobal->info(sbuffer.str());
|
||||||
}
|
}
|
||||||
@ -3183,8 +3180,6 @@ bool CGameHandler::setFormation(ObjectInstanceID hid, EArmyFormation formation)
|
|||||||
|
|
||||||
bool CGameHandler::queryReply(QueryID qid, std::optional<int32_t> answer, PlayerColor player)
|
bool CGameHandler::queryReply(QueryID qid, std::optional<int32_t> answer, PlayerColor player)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::recursive_mutex> lock(gsm);
|
|
||||||
|
|
||||||
logGlobal->trace("Player %s attempts answering query %d with answer:", player, qid);
|
logGlobal->trace("Player %s attempts answering query %d with answer:", player, qid);
|
||||||
if (answer)
|
if (answer)
|
||||||
logGlobal->trace("%d", *answer);
|
logGlobal->trace("%d", *answer);
|
||||||
|
@ -73,7 +73,6 @@ public:
|
|||||||
std::map<PlayerColor, std::set<std::shared_ptr<CConnection>>> connections; //player color -> connection to client with interface of that player
|
std::map<PlayerColor, std::set<std::shared_ptr<CConnection>>> connections; //player color -> connection to client with interface of that player
|
||||||
|
|
||||||
//queries stuff
|
//queries stuff
|
||||||
boost::recursive_mutex gsm;
|
|
||||||
ui32 QID;
|
ui32 QID;
|
||||||
|
|
||||||
SpellCastEnvironment * spellEnv;
|
SpellCastEnvironment * spellEnv;
|
||||||
|
@ -247,7 +247,6 @@ void CVCMIServer::prepareToRestart()
|
|||||||
for(auto c : activeConnections)
|
for(auto c : activeConnections)
|
||||||
c->enterLobbyConnectionMode();
|
c->enterLobbyConnectionMode();
|
||||||
|
|
||||||
boost::unique_lock<boost::recursive_mutex> queueLock(mx);
|
|
||||||
gh = nullptr;
|
gh = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,8 +406,7 @@ bool CVCMIServer::passHost(int toConnectionId)
|
|||||||
|
|
||||||
void CVCMIServer::clientConnected(std::shared_ptr<CConnection> c, std::vector<std::string> & names, const std::string & uuid, EStartMode mode)
|
void CVCMIServer::clientConnected(std::shared_ptr<CConnection> c, std::vector<std::string> & names, const std::string & uuid, EStartMode mode)
|
||||||
{
|
{
|
||||||
if(state != EServerState::LOBBY)
|
assert(state == EServerState::LOBBY);
|
||||||
throw std::runtime_error("CVCMIServer::clientConnected called while game is not accepting clients!");
|
|
||||||
|
|
||||||
c->connectionID = currentClientId++;
|
c->connectionID = currentClientId++;
|
||||||
|
|
||||||
@ -945,6 +943,10 @@ ui8 CVCMIServer::getIdOfFirstUnallocatedPlayer() const
|
|||||||
if(!si->getPlayersSettings(i->first))
|
if(!si->getPlayersSettings(i->first))
|
||||||
return i->first;
|
return i->first;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INetworkHandler & CVCMIServer::getNetworkHandler()
|
||||||
|
{
|
||||||
|
return *networkHandler;
|
||||||
|
}
|
||||||
|
@ -57,16 +57,10 @@ class CVCMIServer : public LobbyInfo, public INetworkServerListener, public INet
|
|||||||
std::chrono::steady_clock::time_point gameplayStartTime;
|
std::chrono::steady_clock::time_point gameplayStartTime;
|
||||||
std::chrono::steady_clock::time_point lastTimerUpdateTime;
|
std::chrono::steady_clock::time_point lastTimerUpdateTime;
|
||||||
|
|
||||||
public:
|
|
||||||
/// List of all active connections
|
|
||||||
std::vector<std::shared_ptr<CConnection>> activeConnections;
|
|
||||||
|
|
||||||
std::unique_ptr<INetworkHandler> networkHandler;
|
std::unique_ptr<INetworkHandler> networkHandler;
|
||||||
|
|
||||||
private:
|
|
||||||
bool restartGameplay; // FIXME: this is just a hack
|
bool restartGameplay; // FIXME: this is just a hack
|
||||||
|
|
||||||
boost::recursive_mutex mx;
|
|
||||||
std::shared_ptr<CApplier<CBaseForServerApply>> applier;
|
std::shared_ptr<CApplier<CBaseForServerApply>> applier;
|
||||||
EServerState state;
|
EServerState state;
|
||||||
|
|
||||||
@ -76,6 +70,9 @@ private:
|
|||||||
ui8 currentPlayerId;
|
ui8 currentPlayerId;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/// List of all active connections
|
||||||
|
std::vector<std::shared_ptr<CConnection>> activeConnections;
|
||||||
|
|
||||||
// INetworkListener impl
|
// INetworkListener impl
|
||||||
void onDisconnected(const std::shared_ptr<INetworkConnection> & connection, const std::string & errorMessage) override;
|
void onDisconnected(const std::shared_ptr<INetworkConnection> & connection, const std::string & errorMessage) override;
|
||||||
void onPacketReceived(const std::shared_ptr<INetworkConnection> & connection, const std::vector<std::byte> & message) override;
|
void onPacketReceived(const std::shared_ptr<INetworkConnection> & connection, const std::vector<std::byte> & message) override;
|
||||||
@ -109,13 +106,14 @@ public:
|
|||||||
void clientDisconnected(std::shared_ptr<CConnection> c);
|
void clientDisconnected(std::shared_ptr<CConnection> c);
|
||||||
void reconnectPlayer(int connId);
|
void reconnectPlayer(int connId);
|
||||||
|
|
||||||
public:
|
|
||||||
void announceMessage(const std::string & txt);
|
void announceMessage(const std::string & txt);
|
||||||
|
|
||||||
void handleReceivedPack(std::unique_ptr<CPackForLobby> pack);
|
void handleReceivedPack(std::unique_ptr<CPackForLobby> pack);
|
||||||
|
|
||||||
void updateAndPropagateLobbyState();
|
void updateAndPropagateLobbyState();
|
||||||
|
|
||||||
|
INetworkHandler & getNetworkHandler();
|
||||||
|
|
||||||
void setState(EServerState value);
|
void setState(EServerState value);
|
||||||
EServerState getState() const;
|
EServerState getState() const;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ void GlobalLobbyProcessor::establishNewConnection()
|
|||||||
{
|
{
|
||||||
std::string hostname = settings["lobby"]["hostname"].String();
|
std::string hostname = settings["lobby"]["hostname"].String();
|
||||||
int16_t port = settings["lobby"]["port"].Integer();
|
int16_t port = settings["lobby"]["port"].Integer();
|
||||||
owner.networkHandler->connectToRemote(*this, hostname, port);
|
owner.getNetworkHandler().connectToRemote(*this, hostname, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalLobbyProcessor::onDisconnected(const std::shared_ptr<INetworkConnection> & connection, const std::string & errorMessage)
|
void GlobalLobbyProcessor::onDisconnected(const std::shared_ptr<INetworkConnection> & connection, const std::string & errorMessage)
|
||||||
|
@ -29,7 +29,6 @@ TurnTimerHandler::TurnTimerHandler(CGameHandler & gh):
|
|||||||
|
|
||||||
void TurnTimerHandler::onGameplayStart(PlayerColor player)
|
void TurnTimerHandler::onGameplayStart(PlayerColor player)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(mx);
|
|
||||||
if(const auto * si = gameHandler.getStartInfo())
|
if(const auto * si = gameHandler.getStartInfo())
|
||||||
{
|
{
|
||||||
timers[player] = si->turnTimerInfo;
|
timers[player] = si->turnTimerInfo;
|
||||||
@ -45,7 +44,6 @@ void TurnTimerHandler::onGameplayStart(PlayerColor player)
|
|||||||
|
|
||||||
void TurnTimerHandler::setTimerEnabled(PlayerColor player, bool enabled)
|
void TurnTimerHandler::setTimerEnabled(PlayerColor player, bool enabled)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(mx);
|
|
||||||
assert(player.isValidPlayer());
|
assert(player.isValidPlayer());
|
||||||
timers[player].isActive = enabled;
|
timers[player].isActive = enabled;
|
||||||
sendTimerUpdate(player);
|
sendTimerUpdate(player);
|
||||||
@ -53,7 +51,6 @@ void TurnTimerHandler::setTimerEnabled(PlayerColor player, bool enabled)
|
|||||||
|
|
||||||
void TurnTimerHandler::setEndTurnAllowed(PlayerColor player, bool enabled)
|
void TurnTimerHandler::setEndTurnAllowed(PlayerColor player, bool enabled)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(mx);
|
|
||||||
assert(player.isValidPlayer());
|
assert(player.isValidPlayer());
|
||||||
endTurnAllowed[player] = enabled;
|
endTurnAllowed[player] = enabled;
|
||||||
}
|
}
|
||||||
@ -69,7 +66,6 @@ void TurnTimerHandler::sendTimerUpdate(PlayerColor player)
|
|||||||
|
|
||||||
void TurnTimerHandler::onPlayerGetTurn(PlayerColor player)
|
void TurnTimerHandler::onPlayerGetTurn(PlayerColor player)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(mx);
|
|
||||||
if(const auto * si = gameHandler.getStartInfo())
|
if(const auto * si = gameHandler.getStartInfo())
|
||||||
{
|
{
|
||||||
if(si->turnTimerInfo.isEnabled())
|
if(si->turnTimerInfo.isEnabled())
|
||||||
@ -87,7 +83,6 @@ void TurnTimerHandler::onPlayerGetTurn(PlayerColor player)
|
|||||||
|
|
||||||
void TurnTimerHandler::update(int waitTime)
|
void TurnTimerHandler::update(int waitTime)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(mx);
|
|
||||||
if(!gameHandler.getStartInfo()->turnTimerInfo.isEnabled())
|
if(!gameHandler.getStartInfo()->turnTimerInfo.isEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -122,7 +117,6 @@ bool TurnTimerHandler::timerCountDown(int & timer, int initialTimer, PlayerColor
|
|||||||
|
|
||||||
void TurnTimerHandler::onPlayerMakingTurn(PlayerColor player, int waitTime)
|
void TurnTimerHandler::onPlayerMakingTurn(PlayerColor player, int waitTime)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(mx);
|
|
||||||
const auto * gs = gameHandler.gameState();
|
const auto * gs = gameHandler.gameState();
|
||||||
const auto * si = gameHandler.getStartInfo();
|
const auto * si = gameHandler.getStartInfo();
|
||||||
if(!si || !gs || !si->turnTimerInfo.isEnabled())
|
if(!si || !gs || !si->turnTimerInfo.isEnabled())
|
||||||
@ -164,7 +158,6 @@ bool TurnTimerHandler::isPvpBattle(const BattleID & battleID) const
|
|||||||
|
|
||||||
void TurnTimerHandler::onBattleStart(const BattleID & battleID)
|
void TurnTimerHandler::onBattleStart(const BattleID & battleID)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(mx);
|
|
||||||
const auto * gs = gameHandler.gameState();
|
const auto * gs = gameHandler.gameState();
|
||||||
const auto * si = gameHandler.getStartInfo();
|
const auto * si = gameHandler.getStartInfo();
|
||||||
if(!si || !gs)
|
if(!si || !gs)
|
||||||
@ -192,7 +185,6 @@ void TurnTimerHandler::onBattleStart(const BattleID & battleID)
|
|||||||
|
|
||||||
void TurnTimerHandler::onBattleEnd(const BattleID & battleID)
|
void TurnTimerHandler::onBattleEnd(const BattleID & battleID)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(mx);
|
|
||||||
const auto * gs = gameHandler.gameState();
|
const auto * gs = gameHandler.gameState();
|
||||||
const auto * si = gameHandler.getStartInfo();
|
const auto * si = gameHandler.getStartInfo();
|
||||||
if(!si || !gs)
|
if(!si || !gs)
|
||||||
@ -221,7 +213,6 @@ void TurnTimerHandler::onBattleEnd(const BattleID & battleID)
|
|||||||
|
|
||||||
void TurnTimerHandler::onBattleNextStack(const BattleID & battleID, const CStack & stack)
|
void TurnTimerHandler::onBattleNextStack(const BattleID & battleID, const CStack & stack)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(mx);
|
|
||||||
const auto * gs = gameHandler.gameState();
|
const auto * gs = gameHandler.gameState();
|
||||||
const auto * si = gameHandler.getStartInfo();
|
const auto * si = gameHandler.getStartInfo();
|
||||||
if(!si || !gs || !gs->getBattle(battleID))
|
if(!si || !gs || !gs->getBattle(battleID))
|
||||||
@ -248,7 +239,6 @@ void TurnTimerHandler::onBattleNextStack(const BattleID & battleID, const CStack
|
|||||||
|
|
||||||
void TurnTimerHandler::onBattleLoop(const BattleID & battleID, int waitTime)
|
void TurnTimerHandler::onBattleLoop(const BattleID & battleID, int waitTime)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::recursive_mutex> guard(mx);
|
|
||||||
const auto * gs = gameHandler.gameState();
|
const auto * gs = gameHandler.gameState();
|
||||||
const auto * si = gameHandler.getStartInfo();
|
const auto * si = gameHandler.getStartInfo();
|
||||||
if(!si || !gs)
|
if(!si || !gs)
|
||||||
|
@ -29,7 +29,6 @@ class TurnTimerHandler
|
|||||||
std::map<PlayerColor, TurnTimerInfo> timers;
|
std::map<PlayerColor, TurnTimerInfo> timers;
|
||||||
std::map<PlayerColor, int> lastUpdate;
|
std::map<PlayerColor, int> lastUpdate;
|
||||||
std::map<PlayerColor, bool> endTurnAllowed;
|
std::map<PlayerColor, bool> endTurnAllowed;
|
||||||
std::recursive_mutex mx;
|
|
||||||
|
|
||||||
void onPlayerMakingTurn(PlayerColor player, int waitTime);
|
void onPlayerMakingTurn(PlayerColor player, int waitTime);
|
||||||
void onBattleLoop(const BattleID & battleID, int waitTime);
|
void onBattleLoop(const BattleID & battleID, int waitTime);
|
||||||
|
@ -49,8 +49,6 @@ CQuery::CQuery(CGameHandler * gameHandler)
|
|||||||
: owner(gameHandler->queries.get())
|
: owner(gameHandler->queries.get())
|
||||||
, gh(gameHandler)
|
, gh(gameHandler)
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> l(QueriesProcessor::mx);
|
|
||||||
|
|
||||||
static QueryID QID = QueryID(0);
|
static QueryID QID = QueryID(0);
|
||||||
|
|
||||||
queryID = ++QID;
|
queryID = ++QID;
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
#include "CQuery.h"
|
#include "CQuery.h"
|
||||||
|
|
||||||
boost::mutex QueriesProcessor::mx;
|
|
||||||
|
|
||||||
void QueriesProcessor::popQuery(PlayerColor player, QueryPtr query)
|
void QueriesProcessor::popQuery(PlayerColor player, QueryPtr query)
|
||||||
{
|
{
|
||||||
LOG_TRACE_PARAMS(logGlobal, "player='%s', query='%s'", player % query);
|
LOG_TRACE_PARAMS(logGlobal, "player='%s', query='%s'", player % query);
|
||||||
|
@ -23,8 +23,6 @@ private:
|
|||||||
std::map<PlayerColor, std::vector<QueryPtr>> queries; //player => stack of queries
|
std::map<PlayerColor, std::vector<QueryPtr>> queries; //player => stack of queries
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static boost::mutex mx;
|
|
||||||
|
|
||||||
void addQuery(QueryPtr query);
|
void addQuery(QueryPtr query);
|
||||||
void popQuery(const CQuery &query);
|
void popQuery(const CQuery &query);
|
||||||
void popQuery(QueryPtr query);
|
void popQuery(QueryPtr query);
|
||||||
|
Loading…
Reference in New Issue
Block a user