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
38e47816
Commit
38e47816
authored
Dec 18, 2011
by
Max-Wilhelm Bruker
Browse files
fixed packet length calculation bug, re-enabled deck selection
parent
314f1709
Changes
7
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/abstractclient.cpp
View file @
38e47816
...
...
@@ -5,7 +5,6 @@
#include
"pending_command.h"
#include
"pb/commands.pb.h"
#include
<google/protobuf/descriptor.h>
#include
<QDebug>
AbstractClient
::
AbstractClient
(
QObject
*
parent
)
:
QObject
(
parent
),
nextCmdId
(
0
),
status
(
StatusDisconnected
)
...
...
cockatrice/src/pending_command.cpp
View file @
38e47816
...
...
@@ -3,7 +3,6 @@
void
PendingCommand
::
processResponse
(
ProtocolResponse
*
response
)
{
qDebug
(
"processResponse"
);
emit
finished
(
response
);
emit
finished
(
response
->
getResponseCode
());
}
cockatrice/src/tab_game.cpp
View file @
38e47816
...
...
@@ -123,7 +123,7 @@ void DeckViewContainer::loadLocalDeck()
}
Command_DeckSelect
cmd
;
cmd
.
set_deck
(
""
);
// XXX
cmd
.
set_deck
(
deck
->
writeToString_Native
().
toStdString
());
PendingCommand
*
pend
=
static_cast
<
TabGame
*>
(
parent
())
->
prepareGameCommand
(
cmd
);
connect
(
pend
,
SIGNAL
(
finished
(
ProtocolResponse
*
)),
this
,
SLOT
(
deckSelectFinished
(
ProtocolResponse
*
)));
static_cast
<
TabGame
*>
(
parent
())
->
sendGameCommand
(
pend
,
playerId
);
...
...
common/decklist.cpp
View file @
38e47816
...
...
@@ -267,6 +267,15 @@ DeckList::DeckList(DeckList *other)
updateDeckHash
();
}
DeckList
::
DeckList
(
const
QString
&
nativeString
)
:
SerializableItem
(
"cockatrice_deck"
),
currentZone
(
0
),
currentSideboardPlan
(
0
)
{
root
=
new
InnerDecklistNode
;
QXmlStreamReader
xml
(
nativeString
);
loadFromXml
(
&
xml
);
}
DeckList
::~
DeckList
()
{
delete
root
;
...
...
@@ -360,6 +369,16 @@ void DeckList::loadFromXml(QXmlStreamReader *xml)
updateDeckHash
();
}
QString
DeckList
::
writeToString_Native
()
{
QString
result
;
QXmlStreamWriter
xml
(
&
result
);
xml
.
writeStartDocument
();
write
(
&
xml
);
xml
.
writeEndDocument
();
return
result
;
}
bool
DeckList
::
loadFromFile_Native
(
QIODevice
*
device
)
{
QXmlStreamReader
xml
(
device
);
...
...
common/decklist.h
View file @
38e47816
...
...
@@ -139,6 +139,7 @@ public:
static
const
QStringList
fileNameFilters
;
DeckList
();
DeckList
(
DeckList
*
other
);
DeckList
(
const
QString
&
nativeString
);
~
DeckList
();
QString
getName
()
const
{
return
name
;
}
QString
getComments
()
const
{
return
comments
;
}
...
...
@@ -151,7 +152,7 @@ public:
bool
readElement
(
QXmlStreamReader
*
xml
);
void
writeElement
(
QXmlStreamWriter
*
xml
);
void
loadFromXml
(
QXmlStreamReader
*
xml
);
QString
writeToString_Native
();
bool
loadFromFile_Native
(
QIODevice
*
device
);
bool
saveToFile_Native
(
QIODevice
*
device
);
bool
loadFromStream_Plain
(
QTextStream
&
stream
);
...
...
common/server_protocolhandler.cpp
View file @
38e47816
...
...
@@ -708,17 +708,15 @@ ResponseCode Server_ProtocolHandler::cmdDeckSelect(const Command_DeckSelect &cmd
return
RespFunctionNotAllowed
;
DeckList
*
deck
;
if
(
cmd
.
deck_id
()
==
-
1
)
{
// if (!cmd->getDeck())
// return RespInvalidData;
// deck = new DeckList(cmd->getDeck());
}
else
{
if
(
cmd
.
has_deck_id
())
{
try
{
deck
=
getDeckFromDatabase
(
cmd
.
deck_id
());
}
catch
(
ResponseCode
r
)
{
return
r
;
}
}
}
else
deck
=
new
DeckList
(
QString
::
fromStdString
(
cmd
.
deck
()));
player
->
setDeck
(
deck
);
game
->
sendGameEvent
(
new
Event_PlayerPropertiesChanged
(
player
->
getPlayerId
(),
player
->
getProperties
()),
new
Context_DeckSelect
(
deck
->
getDeckHash
()));
...
...
servatrice/src/serversocketinterface.cpp
View file @
38e47816
...
...
@@ -102,7 +102,10 @@ void ServerSocketInterface::readClient()
do
{
if
(
!
messageInProgress
)
{
if
(
inputBuffer
.
size
()
>=
4
)
{
messageLength
=
(
int
)
(((
quint32
)
inputBuffer
[
0
])
<<
24
)
+
(((
quint32
)
inputBuffer
[
1
])
<<
16
)
+
(((
quint32
)
inputBuffer
[
2
])
<<
8
)
+
((
quint32
)
inputBuffer
[
3
]);
messageLength
=
(((
quint32
)
(
unsigned
char
)
inputBuffer
[
0
])
<<
24
)
+
(((
quint32
)
(
unsigned
char
)
inputBuffer
[
1
])
<<
16
)
+
(((
quint32
)
(
unsigned
char
)
inputBuffer
[
2
])
<<
8
)
+
((
quint32
)
(
unsigned
char
)
inputBuffer
[
3
]);
inputBuffer
.
remove
(
0
,
4
);
messageInProgress
=
true
;
}
else
...
...
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