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
d7e76061
Commit
d7e76061
authored
May 28, 2012
by
Max-Wilhelm Bruker
Browse files
fixed 'open deck in deck editor' option in game, fixed freeze when closing local game
parent
9af69f53
Changes
9
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/localserver.cpp
View file @
d7e76061
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
#include
"server_room.h"
#include
"server_room.h"
LocalServer
::
LocalServer
(
QObject
*
parent
)
LocalServer
::
LocalServer
(
QObject
*
parent
)
:
Server
(
parent
)
:
Server
(
false
,
parent
)
{
{
setDatabaseInterface
(
new
LocalServer_DatabaseInterface
(
this
));
setDatabaseInterface
(
new
LocalServer_DatabaseInterface
(
this
));
addRoom
(
new
Server_Room
(
0
,
QString
(),
QString
(),
false
,
QString
(),
QStringList
(),
this
));
addRoom
(
new
Server_Room
(
0
,
QString
(),
QString
(),
false
,
QString
(),
QStringList
(),
this
));
...
...
cockatrice/src/player.cpp
View file @
d7e76061
...
@@ -792,7 +792,7 @@ void Player::actAlwaysRevealTopCard()
...
@@ -792,7 +792,7 @@ void Player::actAlwaysRevealTopCard()
void
Player
::
actOpenDeckInDeckEditor
()
void
Player
::
actOpenDeckInDeckEditor
()
{
{
emit
openDeckEditor
(
*
deck
);
emit
openDeckEditor
(
deck
);
}
}
void
Player
::
actViewGraveyard
()
void
Player
::
actViewGraveyard
()
...
...
cockatrice/src/player.h
View file @
d7e76061
...
@@ -77,7 +77,7 @@ public:
...
@@ -77,7 +77,7 @@ public:
class
Player
:
public
QObject
,
public
QGraphicsItem
{
class
Player
:
public
QObject
,
public
QGraphicsItem
{
Q_OBJECT
Q_OBJECT
signals:
signals:
void
openDeckEditor
(
const
DeckLoader
&
deck
);
void
openDeckEditor
(
const
DeckLoader
*
deck
);
void
newCardAdded
(
AbstractCardItem
*
card
);
void
newCardAdded
(
AbstractCardItem
*
card
);
// Log events
// Log events
void
logSay
(
Player
*
player
,
QString
message
);
void
logSay
(
Player
*
player
,
QString
message
);
...
...
cockatrice/src/tab_game.cpp
View file @
d7e76061
...
@@ -733,7 +733,7 @@ Player *TabGame::addPlayer(int playerId, const ServerInfo_User &info)
...
@@ -733,7 +733,7 @@ Player *TabGame::addPlayer(int playerId, const ServerInfo_User &info)
{
{
bool
local
=
((
clients
.
size
()
>
1
)
||
(
playerId
==
localPlayerId
));
bool
local
=
((
clients
.
size
()
>
1
)
||
(
playerId
==
localPlayerId
));
Player
*
newPlayer
=
new
Player
(
info
,
playerId
,
local
,
this
);
Player
*
newPlayer
=
new
Player
(
info
,
playerId
,
local
,
this
);
connect
(
newPlayer
,
SIGNAL
(
openDeckEditor
(
DeckList
*
)),
this
,
SIGNAL
(
openDeckEditor
(
DeckList
*
)));
connect
(
newPlayer
,
SIGNAL
(
openDeckEditor
(
const
DeckLoader
*
)),
this
,
SIGNAL
(
openDeckEditor
(
const
DeckLoader
*
)));
scene
->
addPlayer
(
newPlayer
);
scene
->
addPlayer
(
newPlayer
);
connect
(
newPlayer
,
SIGNAL
(
newCardAdded
(
AbstractCardItem
*
)),
this
,
SLOT
(
newCardAdded
(
AbstractCardItem
*
)));
connect
(
newPlayer
,
SIGNAL
(
newCardAdded
(
AbstractCardItem
*
)),
this
,
SLOT
(
newCardAdded
(
AbstractCardItem
*
)));
...
...
cockatrice/src/tab_game.h
View file @
d7e76061
...
@@ -171,7 +171,7 @@ signals:
...
@@ -171,7 +171,7 @@ signals:
void
containerProcessingStarted
(
const
GameEventContext
&
context
);
void
containerProcessingStarted
(
const
GameEventContext
&
context
);
void
containerProcessingDone
();
void
containerProcessingDone
();
void
openMessageDialog
(
const
QString
&
userName
,
bool
focus
);
void
openMessageDialog
(
const
QString
&
userName
,
bool
focus
);
void
openDeckEditor
(
const
DeckLoader
&
deck
);
void
openDeckEditor
(
const
DeckLoader
*
deck
);
private
slots
:
private
slots
:
void
replayNextEvent
();
void
replayNextEvent
();
void
replayFinished
();
void
replayFinished
();
...
...
cockatrice/src/tab_supervisor.cpp
View file @
d7e76061
...
@@ -280,8 +280,7 @@ void TabSupervisor::gameJoined(const Event_GameJoined &event)
...
@@ -280,8 +280,7 @@ void TabSupervisor::gameJoined(const Event_GameJoined &event)
TabGame
*
tab
=
new
TabGame
(
this
,
QList
<
AbstractClient
*>
()
<<
client
,
event
,
roomGameTypes
);
TabGame
*
tab
=
new
TabGame
(
this
,
QList
<
AbstractClient
*>
()
<<
client
,
event
,
roomGameTypes
);
connect
(
tab
,
SIGNAL
(
gameClosing
(
TabGame
*
)),
this
,
SLOT
(
gameLeft
(
TabGame
*
)));
connect
(
tab
,
SIGNAL
(
gameClosing
(
TabGame
*
)),
this
,
SLOT
(
gameLeft
(
TabGame
*
)));
connect
(
tab
,
SIGNAL
(
openMessageDialog
(
const
QString
&
,
bool
)),
this
,
SLOT
(
addMessageTab
(
const
QString
&
,
bool
)));
connect
(
tab
,
SIGNAL
(
openMessageDialog
(
const
QString
&
,
bool
)),
this
,
SLOT
(
addMessageTab
(
const
QString
&
,
bool
)));
connect
(
tab
,
SIGNAL
(
openDeckEditor
(
DeckList
*
,
QString
,
DeckList
::
FileFormat
)),
this
,
SLOT
(
addDeckEditorTab
(
DeckList
*
,
QString
,
DeckList
::
FileFormat
)));
connect
(
tab
,
SIGNAL
(
openDeckEditor
(
const
DeckLoader
*
)),
this
,
SLOT
(
addDeckEditorTab
(
const
DeckLoader
*
)));
connect
(
tab
,
SIGNAL
(
openDeckEditor
(
DeckList
*
,
int
)),
this
,
SLOT
(
addDeckEditorTab
(
DeckList
*
,
int
)));
int
tabIndex
=
myAddTab
(
tab
);
int
tabIndex
=
myAddTab
(
tab
);
addCloseButtonToTab
(
tab
,
tabIndex
);
addCloseButtonToTab
(
tab
,
tabIndex
);
gameTabs
.
insert
(
event
.
game_info
().
game_id
(),
tab
);
gameTabs
.
insert
(
event
.
game_info
().
game_id
(),
tab
);
...
@@ -292,7 +291,7 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
...
@@ -292,7 +291,7 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
{
{
TabGame
*
tab
=
new
TabGame
(
this
,
localClients
,
event
,
QMap
<
int
,
QString
>
());
TabGame
*
tab
=
new
TabGame
(
this
,
localClients
,
event
,
QMap
<
int
,
QString
>
());
connect
(
tab
,
SIGNAL
(
gameClosing
(
TabGame
*
)),
this
,
SLOT
(
gameLeft
(
TabGame
*
)));
connect
(
tab
,
SIGNAL
(
gameClosing
(
TabGame
*
)),
this
,
SLOT
(
gameLeft
(
TabGame
*
)));
connect
(
tab
,
SIGNAL
(
openDeckEditor
(
DeckList
*
)),
this
,
SLOT
(
addDeckEditorTab
(
DeckList
*
)));
connect
(
tab
,
SIGNAL
(
openDeckEditor
(
const
DeckLoader
*
)),
this
,
SLOT
(
addDeckEditorTab
(
const
DeckLoader
*
)));
int
tabIndex
=
myAddTab
(
tab
);
int
tabIndex
=
myAddTab
(
tab
);
addCloseButtonToTab
(
tab
,
tabIndex
);
addCloseButtonToTab
(
tab
,
tabIndex
);
gameTabs
.
insert
(
event
.
game_info
().
game_id
(),
tab
);
gameTabs
.
insert
(
event
.
game_info
().
game_id
(),
tab
);
...
...
common/server.cpp
View file @
d7e76061
...
@@ -35,8 +35,8 @@
...
@@ -35,8 +35,8 @@
#include
<QThread>
#include
<QThread>
#include
<QDebug>
#include
<QDebug>
Server
::
Server
(
QObject
*
parent
)
Server
::
Server
(
bool
_threaded
,
QObject
*
parent
)
:
QObject
(
parent
),
clientsLock
(
QReadWriteLock
::
Recursive
)
:
QObject
(
parent
),
threaded
(
_threaded
),
clientsLock
(
QReadWriteLock
::
Recursive
)
{
{
qRegisterMetaType
<
ServerInfo_Game
>
(
"ServerInfo_Game"
);
qRegisterMetaType
<
ServerInfo_Game
>
(
"ServerInfo_Game"
);
qRegisterMetaType
<
ServerInfo_Room
>
(
"ServerInfo_Room"
);
qRegisterMetaType
<
ServerInfo_Room
>
(
"ServerInfo_Room"
);
...
@@ -56,20 +56,27 @@ Server::~Server()
...
@@ -56,20 +56,27 @@ Server::~Server()
void
Server
::
prepareDestroy
()
void
Server
::
prepareDestroy
()
{
{
clientsLock
.
lockForRead
();
for
(
int
i
=
0
;
i
<
clients
.
size
();
++
i
)
QMetaObject
::
invokeMethod
(
clients
.
at
(
i
),
"prepareDestroy"
,
Qt
::
QueuedConnection
);
clientsLock
.
unlock
();
// dirty :(
// dirty :(
bool
done
=
false
;
if
(
threaded
)
{
do
{
usleep
(
10000
);
clientsLock
.
lockForRead
();
clientsLock
.
lockForRead
();
if
(
clients
.
isEmpty
())
for
(
int
i
=
0
;
i
<
clients
.
size
();
++
i
)
done
=
true
;
QMetaObject
::
invokeMethod
(
clients
.
at
(
i
),
"prepareDestroy"
,
Qt
::
QueuedConnection
);
clientsLock
.
unlock
();
bool
done
=
false
;
do
{
usleep
(
10000
);
clientsLock
.
lockForRead
();
if
(
clients
.
isEmpty
())
done
=
true
;
clientsLock
.
unlock
();
}
while
(
!
done
);
}
else
{
clientsLock
.
lockForWrite
();
while
(
!
clients
.
isEmpty
())
clients
.
first
()
->
prepareDestroy
();
clientsLock
.
unlock
();
clientsLock
.
unlock
();
}
while
(
!
done
);
}
roomsLock
.
lockForWrite
();
roomsLock
.
lockForWrite
();
QMapIterator
<
int
,
Server_Room
*>
roomIterator
(
rooms
);
QMapIterator
<
int
,
Server_Room
*>
roomIterator
(
rooms
);
...
...
common/server.h
View file @
d7e76061
...
@@ -41,7 +41,7 @@ private slots:
...
@@ -41,7 +41,7 @@ private slots:
void
broadcastRoomUpdate
(
const
ServerInfo_Room
&
roomInfo
,
bool
sendToIsl
=
false
);
void
broadcastRoomUpdate
(
const
ServerInfo_Room
&
roomInfo
,
bool
sendToIsl
=
false
);
public:
public:
mutable
QReadWriteLock
clientsLock
,
roomsLock
;
// locking order: roomsLock before clientsLock
mutable
QReadWriteLock
clientsLock
,
roomsLock
;
// locking order: roomsLock before clientsLock
Server
(
QObject
*
parent
=
0
);
Server
(
bool
_threaded
,
QObject
*
parent
=
0
);
~
Server
();
~
Server
();
AuthenticationResult
loginUser
(
Server_ProtocolHandler
*
session
,
QString
&
name
,
const
QString
&
password
,
QString
&
reason
,
int
&
secondsLeft
);
AuthenticationResult
loginUser
(
Server_ProtocolHandler
*
session
,
QString
&
name
,
const
QString
&
password
,
QString
&
reason
,
int
&
secondsLeft
);
const
QMap
<
int
,
Server_Room
*>
&
getRooms
()
{
return
rooms
;
}
const
QMap
<
int
,
Server_Room
*>
&
getRooms
()
{
return
rooms
;
}
...
@@ -79,6 +79,7 @@ public:
...
@@ -79,6 +79,7 @@ public:
void
removePersistentPlayer
(
const
QString
&
userName
,
int
roomId
,
int
gameId
,
int
playerId
);
void
removePersistentPlayer
(
const
QString
&
userName
,
int
roomId
,
int
gameId
,
int
playerId
);
QList
<
PlayerReference
>
getPersistentPlayerReferences
(
const
QString
&
userName
)
const
;
QList
<
PlayerReference
>
getPersistentPlayerReferences
(
const
QString
&
userName
)
const
;
private:
private:
bool
threaded
;
QMultiMap
<
QString
,
PlayerReference
>
persistentPlayers
;
QMultiMap
<
QString
,
PlayerReference
>
persistentPlayers
;
mutable
QReadWriteLock
persistentPlayersLock
;
mutable
QReadWriteLock
persistentPlayersLock
;
protected
slots
:
protected
slots
:
...
...
servatrice/src/servatrice.cpp
View file @
d7e76061
...
@@ -108,7 +108,7 @@ void Servatrice_IslServer::incomingConnection(int socketDescriptor)
...
@@ -108,7 +108,7 @@ void Servatrice_IslServer::incomingConnection(int socketDescriptor)
}
}
Servatrice
::
Servatrice
(
QSettings
*
_settings
,
QObject
*
parent
)
Servatrice
::
Servatrice
(
QSettings
*
_settings
,
QObject
*
parent
)
:
Server
(
parent
),
settings
(
_settings
),
uptime
(
0
),
shutdownTimer
(
0
)
:
Server
(
true
,
parent
),
settings
(
_settings
),
uptime
(
0
),
shutdownTimer
(
0
)
{
{
qRegisterMetaType
<
QSqlDatabase
>
(
"QSqlDatabase"
);
qRegisterMetaType
<
QSqlDatabase
>
(
"QSqlDatabase"
);
}
}
...
...
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