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
7921b5f8
Commit
7921b5f8
authored
Aug 04, 2010
by
Max-Wilhelm Bruker
Browse files
initial commit of local server code
parent
cbfbc542
Changes
35
Show whitespace changes
Inline
Side-by-side
cockatrice/src/tab_server.h
View file @
7921b5f8
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
#include
"tab.h"
#include
"tab.h"
#include
"protocol_datastructures.h"
#include
"protocol_datastructures.h"
class
Client
;
class
Abstract
Client
;
class
QTreeView
;
class
QTreeView
;
class
QTreeWidget
;
class
QTreeWidget
;
class
QPushButton
;
class
QPushButton
;
...
@@ -22,7 +22,7 @@ class Event_ServerMessage;
...
@@ -22,7 +22,7 @@ class Event_ServerMessage;
class
GameSelector
:
public
QGroupBox
{
class
GameSelector
:
public
QGroupBox
{
Q_OBJECT
Q_OBJECT
public:
public:
GameSelector
(
Client
*
_client
,
QWidget
*
parent
=
0
);
GameSelector
(
Abstract
Client
*
_client
,
QWidget
*
parent
=
0
);
void
retranslateUi
();
void
retranslateUi
();
private
slots
:
private
slots
:
void
processListGamesEvent
(
Event_ListGames
*
event
);
void
processListGamesEvent
(
Event_ListGames
*
event
);
...
@@ -33,7 +33,7 @@ private slots:
...
@@ -33,7 +33,7 @@ private slots:
signals:
signals:
void
gameJoined
(
int
gameId
);
void
gameJoined
(
int
gameId
);
private:
private:
Client
*
client
;
Abstract
Client
*
client
;
QTreeView
*
gameListView
;
QTreeView
*
gameListView
;
GamesModel
*
gameListModel
;
GamesModel
*
gameListModel
;
...
@@ -47,7 +47,7 @@ class ChatChannelSelector : public QGroupBox {
...
@@ -47,7 +47,7 @@ class ChatChannelSelector : public QGroupBox {
private:
private:
QTreeWidget
*
channelList
;
QTreeWidget
*
channelList
;
QPushButton
*
joinButton
;
QPushButton
*
joinButton
;
Client
*
client
;
Abstract
Client
*
client
;
void
joinChannel
(
const
QString
&
channelName
);
void
joinChannel
(
const
QString
&
channelName
);
private
slots
:
private
slots
:
...
@@ -57,7 +57,7 @@ private slots:
...
@@ -57,7 +57,7 @@ private slots:
signals:
signals:
void
channelJoined
(
const
QString
&
channelName
);
void
channelJoined
(
const
QString
&
channelName
);
public:
public:
ChatChannelSelector
(
Client
*
_client
,
QWidget
*
parent
=
0
);
ChatChannelSelector
(
Abstract
Client
*
_client
,
QWidget
*
parent
=
0
);
void
retranslateUi
();
void
retranslateUi
();
};
};
...
@@ -68,7 +68,7 @@ private:
...
@@ -68,7 +68,7 @@ private:
private
slots
:
private
slots
:
void
processServerMessageEvent
(
Event_ServerMessage
*
event
);
void
processServerMessageEvent
(
Event_ServerMessage
*
event
);
public:
public:
ServerMessageLog
(
Client
*
_client
,
QWidget
*
parent
=
0
);
ServerMessageLog
(
Abstract
Client
*
_client
,
QWidget
*
parent
=
0
);
void
retranslateUi
();
void
retranslateUi
();
};
};
...
@@ -78,12 +78,12 @@ signals:
...
@@ -78,12 +78,12 @@ signals:
void
chatChannelJoined
(
const
QString
&
channelName
);
void
chatChannelJoined
(
const
QString
&
channelName
);
void
gameJoined
(
int
gameId
);
void
gameJoined
(
int
gameId
);
private:
private:
Client
*
client
;
Abstract
Client
*
client
;
GameSelector
*
gameSelector
;
GameSelector
*
gameSelector
;
ChatChannelSelector
*
chatChannelSelector
;
ChatChannelSelector
*
chatChannelSelector
;
ServerMessageLog
*
serverMessageLog
;
ServerMessageLog
*
serverMessageLog
;
public:
public:
TabServer
(
Client
*
_client
,
QWidget
*
parent
=
0
);
TabServer
(
Abstract
Client
*
_client
,
QWidget
*
parent
=
0
);
void
retranslateUi
();
void
retranslateUi
();
QString
getTabText
()
const
{
return
tr
(
"Server"
);
}
QString
getTabText
()
const
{
return
tr
(
"Server"
);
}
};
};
...
...
cockatrice/src/tab_supervisor.cpp
View file @
7921b5f8
#include
<QApplication>
#include
<QApplication>
#include
"tab_supervisor.h"
#include
"tab_supervisor.h"
#include
"client.h"
#include
"
abstract
client.h"
#include
"tab_server.h"
#include
"tab_server.h"
#include
"tab_chatchannel.h"
#include
"tab_chatchannel.h"
#include
"tab_game.h"
#include
"tab_game.h"
#include
"tab_deck_storage.h"
#include
"tab_deck_storage.h"
#include
"protocol_items.h"
#include
"protocol_items.h"
#include
"pingpixmapgenerator.h"
#include
"pingpixmapgenerator.h"
#include
<QDebug>
TabSupervisor
::
TabSupervisor
(
QWidget
*
parent
)
TabSupervisor
::
TabSupervisor
(
QWidget
*
parent
)
:
QTabWidget
(
parent
),
client
(
0
),
tabServer
(
0
),
tabDeckStorage
(
0
)
:
QTabWidget
(
parent
),
client
(
0
),
tabServer
(
0
),
tabDeckStorage
(
0
)
...
@@ -48,7 +49,7 @@ void TabSupervisor::myAddTab(Tab *tab)
...
@@ -48,7 +49,7 @@ void TabSupervisor::myAddTab(Tab *tab)
addTab
(
tab
,
tab
->
getTabText
());
addTab
(
tab
,
tab
->
getTabText
());
}
}
void
TabSupervisor
::
start
(
Client
*
_client
)
void
TabSupervisor
::
start
(
Abstract
Client
*
_client
)
{
{
client
=
_client
;
client
=
_client
;
connect
(
client
,
SIGNAL
(
chatEventReceived
(
ChatEvent
*
)),
this
,
SLOT
(
processChatEvent
(
ChatEvent
*
)));
connect
(
client
,
SIGNAL
(
chatEventReceived
(
ChatEvent
*
)),
this
,
SLOT
(
processChatEvent
(
ChatEvent
*
)));
...
...
cockatrice/src/tab_supervisor.h
View file @
7921b5f8
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
#include
<QMap>
#include
<QMap>
class
QMenu
;
class
QMenu
;
class
Client
;
class
Abstract
Client
;
class
Tab
;
class
Tab
;
class
TabServer
;
class
TabServer
;
class
TabChatChannel
;
class
TabChatChannel
;
...
@@ -19,7 +19,7 @@ class TabSupervisor : public QTabWidget {
...
@@ -19,7 +19,7 @@ class TabSupervisor : public QTabWidget {
Q_OBJECT
Q_OBJECT
private:
private:
QIcon
*
tabChangedIcon
;
QIcon
*
tabChangedIcon
;
Client
*
client
;
Abstract
Client
*
client
;
TabServer
*
tabServer
;
TabServer
*
tabServer
;
TabDeckStorage
*
tabDeckStorage
;
TabDeckStorage
*
tabDeckStorage
;
QMap
<
QString
,
TabChatChannel
*>
chatChannelTabs
;
QMap
<
QString
,
TabChatChannel
*>
chatChannelTabs
;
...
@@ -29,7 +29,7 @@ public:
...
@@ -29,7 +29,7 @@ public:
TabSupervisor
(
QWidget
*
parent
=
0
);
TabSupervisor
(
QWidget
*
parent
=
0
);
~
TabSupervisor
();
~
TabSupervisor
();
void
retranslateUi
();
void
retranslateUi
();
void
start
(
Client
*
_client
);
void
start
(
Abstract
Client
*
_client
);
void
stop
();
void
stop
();
int
getGameCount
()
const
{
return
gameTabs
.
size
();
}
int
getGameCount
()
const
{
return
gameTabs
.
size
();
}
signals:
signals:
...
...
cockatrice/src/tablezone.cpp
View file @
7921b5f8
#include
<QtGui>
#include
<QtGui>
#include
"tablezone.h"
#include
"tablezone.h"
#include
"player.h"
#include
"player.h"
#include
"client.h"
#include
"protocol_items.h"
#include
"protocol_items.h"
#include
"settingscache.h"
#include
"settingscache.h"
#include
"arrowitem.h"
#include
"arrowitem.h"
...
...
cockatrice/src/window_main.cpp
View file @
7921b5f8
...
@@ -24,6 +24,10 @@
...
@@ -24,6 +24,10 @@
#include
"dlg_settings.h"
#include
"dlg_settings.h"
#include
"window_deckeditor.h"
#include
"window_deckeditor.h"
#include
"tab_supervisor.h"
#include
"tab_supervisor.h"
#include
"remoteclient.h"
#include
"localserver.h"
#include
"localserverinterface.h"
#include
"localclient.h"
const
QString
MainWindow
::
appName
=
"Cockatrice"
;
const
QString
MainWindow
::
appName
=
"Cockatrice"
;
...
@@ -74,6 +78,15 @@ void MainWindow::actDisconnect()
...
@@ -74,6 +78,15 @@ void MainWindow::actDisconnect()
client
->
disconnectFromServer
();
client
->
disconnectFromServer
();
}
}
void
MainWindow
::
actSinglePlayer
()
{
LocalServer
*
ls
=
new
LocalServer
(
this
);
LocalServerInterface
*
mainLsi
=
ls
->
newConnection
();
LocalClient
*
mainClient
=
new
LocalClient
(
mainLsi
,
this
);
tabSupervisor
->
start
(
mainClient
);
}
void
MainWindow
::
actDeckEditor
()
void
MainWindow
::
actDeckEditor
()
{
{
WndDeckEditor
*
deckEditor
=
new
WndDeckEditor
(
this
);
WndDeckEditor
*
deckEditor
=
new
WndDeckEditor
(
this
);
...
@@ -138,6 +151,7 @@ void MainWindow::retranslateUi()
...
@@ -138,6 +151,7 @@ void MainWindow::retranslateUi()
aConnect
->
setText
(
tr
(
"&Connect..."
));
aConnect
->
setText
(
tr
(
"&Connect..."
));
aDisconnect
->
setText
(
tr
(
"&Disconnect"
));
aDisconnect
->
setText
(
tr
(
"&Disconnect"
));
aSinglePlayer
->
setText
(
tr
(
"Start &local game..."
));
aDeckEditor
->
setText
(
tr
(
"&Deck editor"
));
aDeckEditor
->
setText
(
tr
(
"&Deck editor"
));
aFullScreen
->
setText
(
tr
(
"&Full screen"
));
aFullScreen
->
setText
(
tr
(
"&Full screen"
));
aFullScreen
->
setShortcut
(
tr
(
"Ctrl+F"
));
aFullScreen
->
setShortcut
(
tr
(
"Ctrl+F"
));
...
@@ -156,6 +170,8 @@ void MainWindow::createActions()
...
@@ -156,6 +170,8 @@ void MainWindow::createActions()
aDisconnect
=
new
QAction
(
this
);
aDisconnect
=
new
QAction
(
this
);
aDisconnect
->
setEnabled
(
false
);
aDisconnect
->
setEnabled
(
false
);
connect
(
aDisconnect
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actDisconnect
()));
connect
(
aDisconnect
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actDisconnect
()));
aSinglePlayer
=
new
QAction
(
this
);
connect
(
aSinglePlayer
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actSinglePlayer
()));
aDeckEditor
=
new
QAction
(
this
);
aDeckEditor
=
new
QAction
(
this
);
connect
(
aDeckEditor
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actDeckEditor
()));
connect
(
aDeckEditor
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actDeckEditor
()));
aFullScreen
=
new
QAction
(
this
);
aFullScreen
=
new
QAction
(
this
);
...
@@ -172,6 +188,7 @@ void MainWindow::createMenus()
...
@@ -172,6 +188,7 @@ void MainWindow::createMenus()
cockatriceMenu
=
menuBar
()
->
addMenu
(
QString
());
cockatriceMenu
=
menuBar
()
->
addMenu
(
QString
());
cockatriceMenu
->
addAction
(
aConnect
);
cockatriceMenu
->
addAction
(
aConnect
);
cockatriceMenu
->
addAction
(
aDisconnect
);
cockatriceMenu
->
addAction
(
aDisconnect
);
cockatriceMenu
->
addAction
(
aSinglePlayer
);
cockatriceMenu
->
addSeparator
();
cockatriceMenu
->
addSeparator
();
cockatriceMenu
->
addAction
(
aDeckEditor
);
cockatriceMenu
->
addAction
(
aDeckEditor
);
cockatriceMenu
->
addSeparator
();
cockatriceMenu
->
addSeparator
();
...
@@ -187,7 +204,7 @@ MainWindow::MainWindow(QWidget *parent)
...
@@ -187,7 +204,7 @@ MainWindow::MainWindow(QWidget *parent)
{
{
QPixmapCache
::
setCacheLimit
(
200000
);
QPixmapCache
::
setCacheLimit
(
200000
);
client
=
new
Client
(
this
);
client
=
new
Remote
Client
(
this
);
connect
(
client
,
SIGNAL
(
serverError
(
ResponseCode
)),
this
,
SLOT
(
serverError
(
ResponseCode
)));
connect
(
client
,
SIGNAL
(
serverError
(
ResponseCode
)),
this
,
SLOT
(
serverError
(
ResponseCode
)));
connect
(
client
,
SIGNAL
(
socketError
(
const
QString
&
)),
this
,
SLOT
(
socketError
(
const
QString
&
)));
connect
(
client
,
SIGNAL
(
socketError
(
const
QString
&
)),
this
,
SLOT
(
socketError
(
const
QString
&
)));
connect
(
client
,
SIGNAL
(
serverTimeout
()),
this
,
SLOT
(
serverTimeout
()));
connect
(
client
,
SIGNAL
(
serverTimeout
()),
this
,
SLOT
(
serverTimeout
()));
...
...
cockatrice/src/window_main.h
View file @
7921b5f8
...
@@ -21,10 +21,11 @@
...
@@ -21,10 +21,11 @@
#define WINDOW_H
#define WINDOW_H
#include
<QMainWindow>
#include
<QMainWindow>
#include
"client.h"
#include
"
abstract
client.h"
#include
"protocol_datastructures.h"
#include
"protocol_datastructures.h"
class
TabSupervisor
;
class
TabSupervisor
;
class
RemoteClient
;
class
MainWindow
:
public
QMainWindow
{
class
MainWindow
:
public
QMainWindow
{
Q_OBJECT
Q_OBJECT
...
@@ -38,6 +39,7 @@ private slots:
...
@@ -38,6 +39,7 @@ private slots:
void
actConnect
();
void
actConnect
();
void
actDisconnect
();
void
actDisconnect
();
void
actSinglePlayer
();
void
actDeckEditor
();
void
actDeckEditor
();
void
actFullScreen
(
bool
checked
);
void
actFullScreen
(
bool
checked
);
void
actSettings
();
void
actSettings
();
...
@@ -49,10 +51,10 @@ private:
...
@@ -49,10 +51,10 @@ private:
void
createActions
();
void
createActions
();
void
createMenus
();
void
createMenus
();
QMenu
*
cockatriceMenu
,
*
tabMenu
;
QMenu
*
cockatriceMenu
,
*
tabMenu
;
QAction
*
aConnect
,
*
aDisconnect
,
*
aDeckEditor
,
*
aFullScreen
,
*
aSettings
,
*
aExit
;
QAction
*
aConnect
,
*
aDisconnect
,
*
aSinglePlayer
,
*
aDeckEditor
,
*
aFullScreen
,
*
aSettings
,
*
aExit
;
TabSupervisor
*
tabSupervisor
;
TabSupervisor
*
tabSupervisor
;
Client
*
client
;
Remote
Client
*
client
;
public:
public:
MainWindow
(
QWidget
*
parent
=
0
);
MainWindow
(
QWidget
*
parent
=
0
);
protected:
protected:
...
...
cockatrice/src/zoneviewwidget.cpp
View file @
7921b5f8
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
#include
"carditem.h"
#include
"carditem.h"
#include
"zoneviewzone.h"
#include
"zoneviewzone.h"
#include
"player.h"
#include
"player.h"
#include
"client.h"
#include
"gamescene.h"
#include
"gamescene.h"
#include
"protocol_items.h"
#include
"protocol_items.h"
#include
"settingscache.h"
#include
"settingscache.h"
...
...
cockatrice/src/zoneviewzone.cpp
View file @
7921b5f8
#include
<QtGui>
#include
<QtGui>
#include
"zoneviewzone.h"
#include
"zoneviewzone.h"
#include
"player.h"
#include
"player.h"
#include
"client.h"
#include
"protocol_items.h"
#include
"protocol_items.h"
ZoneViewZone
::
ZoneViewZone
(
Player
*
_p
,
CardZone
*
_origZone
,
int
_numberCards
,
QGraphicsItem
*
parent
)
ZoneViewZone
::
ZoneViewZone
(
Player
*
_p
,
CardZone
*
_origZone
,
int
_numberCards
,
QGraphicsItem
*
parent
)
...
...
common/server.cpp
View file @
7921b5f8
...
@@ -92,9 +92,11 @@ void Server::broadcastGameListUpdate(Server_Game *game)
...
@@ -92,9 +92,11 @@ void Server::broadcastGameListUpdate(Server_Game *game)
eventGameList
.
append
(
new
ServerInfo_Game
(
game
->
getGameId
(),
QString
(),
false
,
0
,
game
->
getMaxPlayers
(),
QString
(),
false
,
0
));
eventGameList
.
append
(
new
ServerInfo_Game
(
game
->
getGameId
(),
QString
(),
false
,
0
,
game
->
getMaxPlayers
(),
QString
(),
false
,
0
));
Event_ListGames
*
event
=
new
Event_ListGames
(
eventGameList
);
Event_ListGames
*
event
=
new
Event_ListGames
(
eventGameList
);
bool
mayDelete
=
true
;
for
(
int
i
=
0
;
i
<
clients
.
size
();
i
++
)
for
(
int
i
=
0
;
i
<
clients
.
size
();
i
++
)
if
(
clients
[
i
]
->
getAcceptsGameListChanges
())
if
(
clients
[
i
]
->
getAcceptsGameListChanges
())
clients
[
i
]
->
sendProtocolItem
(
event
,
false
);
mayDelete
=
clients
[
i
]
->
sendProtocolItem
(
event
,
false
);
if
(
mayDelete
)
delete
event
;
delete
event
;
}
}
...
@@ -105,9 +107,11 @@ void Server::broadcastChannelUpdate()
...
@@ -105,9 +107,11 @@ void Server::broadcastChannelUpdate()
eventChannelList
.
append
(
new
ServerInfo_ChatChannel
(
channel
->
getName
(),
channel
->
getDescription
(),
channel
->
size
(),
channel
->
getAutoJoin
()));
eventChannelList
.
append
(
new
ServerInfo_ChatChannel
(
channel
->
getName
(),
channel
->
getDescription
(),
channel
->
size
(),
channel
->
getAutoJoin
()));
Event_ListChatChannels
*
event
=
new
Event_ListChatChannels
(
eventChannelList
);
Event_ListChatChannels
*
event
=
new
Event_ListChatChannels
(
eventChannelList
);
bool
mayDelete
=
true
;
for
(
int
i
=
0
;
i
<
clients
.
size
();
++
i
)
for
(
int
i
=
0
;
i
<
clients
.
size
();
++
i
)
if
(
clients
[
i
]
->
getAcceptsChatChannelListChanges
())
if
(
clients
[
i
]
->
getAcceptsChatChannelListChanges
())
clients
[
i
]
->
sendProtocolItem
(
event
,
false
);
mayDelete
=
clients
[
i
]
->
sendProtocolItem
(
event
,
false
);
if
(
mayDelete
)
delete
event
;
delete
event
;
}
}
...
...
common/server_chatchannel.cpp
View file @
7921b5f8
...
@@ -36,7 +36,9 @@ void Server_ChatChannel::say(Server_ProtocolHandler *client, const QString &s)
...
@@ -36,7 +36,9 @@ void Server_ChatChannel::say(Server_ProtocolHandler *client, const QString &s)
void
Server_ChatChannel
::
sendChatEvent
(
ChatEvent
*
event
)
void
Server_ChatChannel
::
sendChatEvent
(
ChatEvent
*
event
)
{
{
bool
mayDelete
=
true
;
for
(
int
i
=
0
;
i
<
size
();
++
i
)
for
(
int
i
=
0
;
i
<
size
();
++
i
)
at
(
i
)
->
sendProtocolItem
(
event
,
false
);
mayDelete
=
at
(
i
)
->
sendProtocolItem
(
event
,
false
);
if
(
mayDelete
)
delete
event
;
delete
event
;
}
}
common/server_game.cpp
View file @
7921b5f8
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
#include
"server_card.h"
#include
"server_card.h"
#include
"server_cardzone.h"
#include
"server_cardzone.h"
#include
"server_counter.h"
#include
"server_counter.h"
#include
<QSqlQuery>
#include
<QTimer>
#include
<QTimer>
Server_Game
::
Server_Game
(
Server_ProtocolHandler
*
_creator
,
int
_gameId
,
const
QString
&
_description
,
const
QString
&
_password
,
int
_maxPlayers
,
bool
_spectatorsAllowed
,
bool
_spectatorsNeedPassword
,
bool
_spectatorsCanTalk
,
bool
_spectatorsSeeEverything
,
QObject
*
parent
)
Server_Game
::
Server_Game
(
Server_ProtocolHandler
*
_creator
,
int
_gameId
,
const
QString
&
_description
,
const
QString
&
_password
,
int
_maxPlayers
,
bool
_spectatorsAllowed
,
bool
_spectatorsNeedPassword
,
bool
_spectatorsCanTalk
,
bool
_spectatorsSeeEverything
,
QObject
*
parent
)
...
@@ -345,27 +344,33 @@ void Server_Game::sendGameEvent(GameEvent *event, GameEventContext *context, Ser
...
@@ -345,27 +344,33 @@ void Server_Game::sendGameEvent(GameEvent *event, GameEventContext *context, Ser
void
Server_Game
::
sendGameEventContainer
(
GameEventContainer
*
cont
,
Server_Player
*
exclude
,
bool
excludeOmniscient
)
void
Server_Game
::
sendGameEventContainer
(
GameEventContainer
*
cont
,
Server_Player
*
exclude
,
bool
excludeOmniscient
)
{
{
bool
mayDelete
=
true
;
cont
->
setGameId
(
gameId
);
cont
->
setGameId
(
gameId
);
QMapIterator
<
int
,
Server_Player
*>
playerIterator
(
players
);
QMapIterator
<
int
,
Server_Player
*>
playerIterator
(
players
);
while
(
playerIterator
.
hasNext
())
{
while
(
playerIterator
.
hasNext
())
{
Server_Player
*
p
=
playerIterator
.
next
().
value
();
Server_Player
*
p
=
playerIterator
.
next
().
value
();
if
((
p
!=
exclude
)
&&
!
(
excludeOmniscient
&&
p
->
getSpectator
()
&&
spectatorsSeeEverything
))
if
((
p
!=
exclude
)
&&
!
(
excludeOmniscient
&&
p
->
getSpectator
()
&&
spectatorsSeeEverything
))
p
->
sendProtocolItem
(
cont
,
false
);
mayDelete
=
p
->
sendProtocolItem
(
cont
,
false
);
}
}
if
(
mayDelete
)
delete
cont
;
delete
cont
;
}
}
void
Server_Game
::
sendGameEventContainerOmniscient
(
GameEventContainer
*
cont
,
Server_Player
*
exclude
)
void
Server_Game
::
sendGameEventContainerOmniscient
(
GameEventContainer
*
cont
,
Server_Player
*
exclude
)
{
{
bool
mayDelete
=
true
;
cont
->
setGameId
(
gameId
);
cont
->
setGameId
(
gameId
);
QMapIterator
<
int
,
Server_Player
*>
playerIterator
(
players
);
QMapIterator
<
int
,
Server_Player
*>
playerIterator
(
players
);
while
(
playerIterator
.
hasNext
())
{
while
(
playerIterator
.
hasNext
())
{
Server_Player
*
p
=
playerIterator
.
next
().
value
();
Server_Player
*
p
=
playerIterator
.
next
().
value
();
if
((
p
!=
exclude
)
&&
(
p
->
getSpectator
()
&&
spectatorsSeeEverything
))
if
((
p
!=
exclude
)
&&
(
p
->
getSpectator
()
&&
spectatorsSeeEverything
))
p
->
sendProtocolItem
(
cont
,
false
);
mayDelete
=
p
->
sendProtocolItem
(
cont
,
false
);
}
}
if
(
mayDelete
)
delete
cont
;
delete
cont
;
}
}
...
...
common/server_player.cpp
View file @
7921b5f8
...
@@ -196,8 +196,10 @@ bool Server_Player::deleteCounter(int counterId)
...
@@ -196,8 +196,10 @@ bool Server_Player::deleteCounter(int counterId)
return
true
;
return
true
;
}
}
void
Server_Player
::
sendProtocolItem
(
ProtocolItem
*
item
,
bool
deleteItem
)
bool
Server_Player
::
sendProtocolItem
(
ProtocolItem
*
item
,
bool
deleteItem
)
{
{
if
(
handler
)
if
(
handler
)
handler
->
sendProtocolItem
(
item
,
deleteItem
);
return
handler
->
sendProtocolItem
(
item
,
deleteItem
);
else
return
true
;
}
}
common/server_player.h
View file @
7921b5f8
...
@@ -70,7 +70,7 @@ public:
...
@@ -70,7 +70,7 @@ public:
void
clearZones
();
void
clearZones
();
void
setupZones
();
void
setupZones
();
void
sendProtocolItem
(
ProtocolItem
*
item
,
bool
deleteItem
=
true
);
bool
sendProtocolItem
(
ProtocolItem
*
item
,
bool
deleteItem
=
true
);
};
};
#endif
#endif
common/server_protocolhandler.h
View file @
7921b5f8
...
@@ -94,7 +94,7 @@ public:
...
@@ -94,7 +94,7 @@ public:
const
QDateTime
&
getLastCommandTime
()
const
{
return
lastCommandTime
;
}
const
QDateTime
&
getLastCommandTime
()
const
{
return
lastCommandTime
;
}
void
processCommandContainer
(
CommandContainer
*
cont
);
void
processCommandContainer
(
CommandContainer
*
cont
);
virtual
void
sendProtocolItem
(
ProtocolItem
*
item
,
bool
deleteItem
=
true
)
=
0
;
virtual
bool
sendProtocolItem
(
ProtocolItem
*
item
,
bool
deleteItem
=
true
)
=
0
;
void
enqueueProtocolItem
(
ProtocolItem
*
item
);
void
enqueueProtocolItem
(
ProtocolItem
*
item
);
};
};
...
...
servatrice/src/serversocketinterface.cpp
View file @
7921b5f8
...
@@ -96,6 +96,7 @@ void ServerSocketInterface::sendProtocolItem(ProtocolItem *item, bool deleteItem
...
@@ -96,6 +96,7 @@ void ServerSocketInterface::sendProtocolItem(ProtocolItem *item, bool deleteItem
item
->
write
(
xmlWriter
);
item
->
write
(
xmlWriter
);
if
(
deleteItem
)
if
(
deleteItem
)
delete
item
;
delete
item
;
return
true
;
}
}
int
ServerSocketInterface
::
getDeckPathId
(
int
basePathId
,
QStringList
path
)
int
ServerSocketInterface
::
getDeckPathId
(
int
basePathId
,
QStringList
path
)
...
...
Prev
1
2
Next
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