/
LobbyPlayerInfo.cpp
61 lines (54 loc) · 1.25 KB
/
LobbyPlayerInfo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// SPDX-License-Identifier: GPL-2.0-or-later
//
// Copyright (c) 2005 - 2019 Settlers Freaks (sf-team at siedler25.org)
//
#include "liblobby/LobbyPlayerInfo.h"
#include <s25util/Serializer.h>
LobbyPlayerInfo::LobbyPlayerInfo()
{
clear();
}
LobbyPlayerInfo::LobbyPlayerInfo(const unsigned /*playerId*/, Serializer& ser)
{
deserialize(ser);
isIngame = false;
}
/**
* leert die Informationen.
*/
void LobbyPlayerInfo::clear()
{
playerId_ = static_cast<unsigned>(-1);
name_.clear();
version_.clear();
isIngame = false;
}
/**
* serialisiert die Daten.
*
* @param[in] ser der benutzte Serializer
*/
void LobbyPlayerInfo::serialize(Serializer& ser) const
{
ser.PushUnsignedInt(playerId_);
ser.PushLongString(name_);
ser.PushLongString(version_);
ser.PushSignedInt(0); // points
ser.PushUnsignedInt(0); // games won
ser.PushUnsignedInt(0); // games lost
}
/**
* deserialisiert die Daten.
*
* @param[in] ser der benutzte Serializer
*/
void LobbyPlayerInfo::deserialize(Serializer& ser)
{
playerId_ = ser.PopUnsignedInt();
name_ = ser.PopLongString();
version_ = ser.PopLongString();
ser.PopSignedInt(); // points
ser.PopUnsignedInt(); // games won
ser.PopUnsignedInt(); // games lost
}