mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 22:42:14 -07:00
Turn things in common into separate libs.
Took 2 hours 27 minutes
This commit is contained in:
parent
53d80efab8
commit
01378b8314
389 changed files with 336 additions and 233 deletions
58
libs/server/src/serverinfo_user_container.cpp
Normal file
58
libs/server/src/serverinfo_user_container.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#include "../../common/serverinfo_user_container.h"
|
||||
|
||||
#include "pb/serverinfo_user.pb.h"
|
||||
|
||||
ServerInfo_User_Container::ServerInfo_User_Container(ServerInfo_User *_userInfo) : userInfo(_userInfo)
|
||||
{
|
||||
}
|
||||
|
||||
ServerInfo_User_Container::ServerInfo_User_Container(const ServerInfo_User &_userInfo)
|
||||
: userInfo(new ServerInfo_User(_userInfo))
|
||||
{
|
||||
}
|
||||
|
||||
ServerInfo_User_Container::ServerInfo_User_Container(const ServerInfo_User_Container &other)
|
||||
{
|
||||
if (other.userInfo)
|
||||
userInfo = new ServerInfo_User(*other.userInfo);
|
||||
else
|
||||
userInfo = nullptr;
|
||||
}
|
||||
|
||||
ServerInfo_User_Container::~ServerInfo_User_Container()
|
||||
{
|
||||
delete userInfo;
|
||||
}
|
||||
|
||||
void ServerInfo_User_Container::setUserInfo(const ServerInfo_User &_userInfo)
|
||||
{
|
||||
userInfo = new ServerInfo_User(_userInfo);
|
||||
}
|
||||
|
||||
ServerInfo_User &ServerInfo_User_Container::copyUserInfo(ServerInfo_User &result,
|
||||
bool complete,
|
||||
bool internalInfo,
|
||||
bool sessionInfo) const
|
||||
{
|
||||
if (userInfo) {
|
||||
result.CopyFrom(*userInfo);
|
||||
if (!sessionInfo) {
|
||||
result.clear_session_id();
|
||||
result.clear_address();
|
||||
result.clear_clientid();
|
||||
}
|
||||
if (!internalInfo) {
|
||||
result.clear_id();
|
||||
result.clear_email();
|
||||
}
|
||||
if (!complete)
|
||||
result.clear_avatar_bmp();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ServerInfo_User ServerInfo_User_Container::copyUserInfo(bool complete, bool internalInfo, bool sessionInfo) const
|
||||
{
|
||||
ServerInfo_User result;
|
||||
return copyUserInfo(result, complete, internalInfo, sessionInfo);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue