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
25d77fb6
Commit
25d77fb6
authored
Dec 15, 2015
by
Fabio Bas
Browse files
Possibly fix #1598
parent
7e6972a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
25d77fb6
...
...
@@ -19,6 +19,10 @@ if(POLICY CMP0048)
cmake_policy
(
SET CMP0048 OLD
)
endif
()
if
(
POLICY CMP0064
)
cmake_policy
(
SET CMP0064 OLD
)
endif
()
set
(
PROJECT_NAME
"Cockatrice"
)
# Default to "Release" build type
...
...
common/server_protocolhandler.cpp
View file @
25d77fb6
...
...
@@ -603,8 +603,11 @@ Response::ResponseCode Server_ProtocolHandler::cmdJoinRoom(const Command_JoinRoo
joinMessageEvent
.
set_message_type
(
Event_RoomSay
::
Welcome
);
rc
.
enqueuePostResponseItem
(
ServerMessage
::
ROOM_EVENT
,
r
->
prepareRoomEvent
(
joinMessageEvent
));
ServerInfo_ChatMessage
chatMessage
;
for
(
int
i
=
0
;
i
<
r
->
chatHistory
.
size
();
++
i
)
{
chatMessage
=
r
->
chatHistory
.
at
(
i
);
QReadLocker
chatHistoryLocker
(
&
r
->
historyLock
);
QList
<
ServerInfo_ChatMessage
>
chatHistory
=
r
->
getChatHistory
();
ServerInfo_ChatMessage
chatMessage
;
for
(
int
i
=
0
;
i
<
chatHistory
.
size
();
++
i
)
{
chatMessage
=
chatHistory
.
at
(
i
);
qDebug
()
<<
QString
::
fromStdString
(
chatMessage
.
message
()).
simplified
();
Event_RoomSay
roomChatHistory
;
roomChatHistory
.
set_message
(
chatMessage
.
sender_name
()
+
": "
+
chatMessage
.
message
());
...
...
common/server_room.cpp
View file @
25d77fb6
...
...
@@ -236,7 +236,6 @@ void Server_Room::say(const QString &userName, const QString &s, bool sendToIsl)
sendRoomEvent
(
prepareRoomEvent
(
event
),
sendToIsl
);
if
(
chatHistorySize
!=
0
)
{
ServerInfo_ChatMessage
chatMessage
;
QDateTime
dateTime
=
dateTime
.
currentDateTimeUtc
();
QString
dateTimeString
=
dateTime
.
toString
();
...
...
@@ -244,10 +243,12 @@ void Server_Room::say(const QString &userName, const QString &s, bool sendToIsl)
chatMessage
.
set_sender_name
(
userName
.
toStdString
());
chatMessage
.
set_message
(
s
.
simplified
().
toStdString
());
historyLock
.
lockForWrite
();
if
(
chatHistory
.
size
()
>=
chatHistorySize
)
chatHistory
.
removeAt
(
0
);
chatHistory
<<
chatMessage
;
historyLock
.
unlock
();
}
}
...
...
common/server_room.h
View file @
25d77fb6
...
...
@@ -42,12 +42,13 @@ private:
QMap
<
int
,
ServerInfo_Game
>
externalGames
;
QMap
<
QString
,
Server_ProtocolHandler
*>
users
;
QMap
<
QString
,
ServerInfo_User_Container
>
externalUsers
;
QList
<
ServerInfo_ChatMessage
>
chatHistory
;
private
slots
:
void
broadcastGameListUpdate
(
const
ServerInfo_Game
&
gameInfo
,
bool
sendToIsl
=
true
);
public:
mutable
QReadWriteLock
usersLock
;
mutable
QReadWriteLock
gamesLock
;
QList
<
ServerInfo_ChatMessage
>
chatH
istory
;
mutable
QReadWriteLock
h
istory
Lock
;
Server_Room
(
int
_id
,
int
_chatHistorySize
,
const
QString
&
_name
,
const
QString
&
_description
,
const
QString
&
_permissionLevel
,
bool
_autoJoin
,
const
QString
&
_joinMessage
,
const
QStringList
&
_gameTypes
,
Server
*
parent
);
~
Server_Room
();
int
getId
()
const
{
return
id
;
}
...
...
@@ -63,7 +64,7 @@ public:
const
ServerInfo_Room
&
getInfo
(
ServerInfo_Room
&
result
,
bool
complete
,
bool
showGameTypes
=
false
,
bool
includeExternalData
=
true
)
const
;
int
getGamesCreatedByUser
(
const
QString
&
name
)
const
;
QList
<
ServerInfo_Game
>
getGamesOfUser
(
const
QString
&
name
)
const
;
QList
<
ServerInfo_ChatMessage
>
getChatHistory
()
{
return
chatHistory
;
}
QList
<
ServerInfo_ChatMessage
>
&
getChatHistory
()
{
return
chatHistory
;
}
void
addClient
(
Server_ProtocolHandler
*
client
);
void
removeClient
(
Server_ProtocolHandler
*
client
);
...
...
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