mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
more server code
This commit is contained in:
parent
8b3723b871
commit
dd5ae4d74d
9 changed files with 203 additions and 114 deletions
|
|
@ -193,3 +193,37 @@ void Event_ChatListPlayers::writeElement(QXmlStreamWriter *xml)
|
|||
xml->writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
bool Event_ListGames::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isStartElement() && (xml->name() == "game")) {
|
||||
gameList.append(GameInfo(
|
||||
xml->attributes().value("id").toString().toInt(),
|
||||
xml->attributes().value("description").toString(),
|
||||
xml->attributes().value("has_password").toString().toInt(),
|
||||
xml->attributes().value("player_count").toString().toInt(),
|
||||
xml->attributes().value("max_players").toString().toInt(),
|
||||
xml->attributes().value("creator").toString(),
|
||||
xml->attributes().value("spectators_allowed").toString().toInt(),
|
||||
xml->attributes().value("spectator_count").toString().toInt()
|
||||
));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Event_ListGames::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
for (int i = 0; i < gameList.size(); ++i) {
|
||||
xml->writeStartElement("game");
|
||||
xml->writeAttribute("id", QString::number(gameList[i].getGameId()));
|
||||
xml->writeAttribute("description", gameList[i].getDescription());
|
||||
xml->writeAttribute("has_password", gameList[i].getHasPassword() ? "1" : "0");
|
||||
xml->writeAttribute("player_count", QString::number(gameList[i].getPlayerCount()));
|
||||
xml->writeAttribute("max_players", QString::number(gameList[i].getMaxPlayers()));
|
||||
xml->writeAttribute("creator", gameList[i].getCreatorName());
|
||||
xml->writeAttribute("spectators_allowed", gameList[i].getSpectatorsAllowed() ? "1" : "0");
|
||||
xml->writeAttribute("spectator_count", QString::number(gameList[i].getSpectatorCount()));
|
||||
xml->writeEndElement();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue