Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
c4ba33df
Commit
c4ba33df
authored
Apr 21, 2011
by
Max-Wilhelm Bruker
Browse files
server mutex fix
parent
38b31681
Changes
3
Hide whitespace changes
Inline
Side-by-side
common/server_game.cpp
View file @
c4ba33df
...
...
@@ -51,7 +51,7 @@ Server_Game::~Server_Game()
QMapIterator
<
int
,
Server_Player
*>
playerIterator
(
players
);
while
(
playerIterator
.
hasNext
())
delete
playerIterator
.
next
().
value
();
playerIterator
.
next
().
value
()
->
prepareDestroy
()
;
players
.
clear
();
room
->
removeGame
(
this
);
...
...
@@ -243,7 +243,7 @@ void Server_Game::removePlayer(Server_Player *player)
sendGameEvent
(
new
Event_Leave
(
player
->
getPlayerId
()));
bool
playerActive
=
activePlayer
==
player
->
getPlayerId
();
bool
spectator
=
player
->
getSpectator
();
delete
player
;
player
->
prepareDestroy
()
;
if
(
!
getPlayerCount
())
deleteLater
();
...
...
common/server_player.cpp
View file @
c4ba33df
...
...
@@ -16,17 +16,25 @@ Server_Player::Server_Player(Server_Game *_game, int _playerId, ServerInfo_User
}
Server_Player
::~
Server_Player
()
{
}
void
Server_Player
::
prepareDestroy
()
{
QMutexLocker
locker
(
&
game
->
gameMutex
);
QMutexLocker
locker2
(
&
playerMutex
);
delete
deck
;
playerMutex
.
lock
();
if
(
handler
)
handler
->
playerRemovedFromGame
(
game
);
playerMutex
.
unlock
();
delete
userInfo
;
clearZones
();
deleteLater
();
}
void
Server_Player
::
moveToThread
(
QThread
*
thread
)
...
...
common/server_player.h
View file @
c4ba33df
...
...
@@ -43,6 +43,7 @@ private:
public:
Server_Player
(
Server_Game
*
_game
,
int
_playerId
,
ServerInfo_User
*
_userInfo
,
bool
_spectator
,
Server_ProtocolHandler
*
_handler
);
~
Server_Player
();
void
prepareDestroy
();
void
moveToThread
(
QThread
*
thread
);
Server_ProtocolHandler
*
getProtocolHandler
()
const
{
return
handler
;
}
void
setProtocolHandler
(
Server_ProtocolHandler
*
_handler
)
{
playerMutex
.
lock
();
handler
=
_handler
;
playerMutex
.
unlock
();
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment