2011-07-02 14:45:12 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
|
* PokerTH - The open source texas holdem engine *
|
|
|
|
|
* Copyright (C) 2006-2011 Felix Hammer, Florian Thauer, Lothar May *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* GNU Affero General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
|
*****************************************************************************/
|
2007-11-16 15:24:25 +00:00
|
|
|
/* Player data. */
|
|
|
|
|
|
|
|
|
|
#ifndef _PLAYERDATA_H_
|
|
|
|
|
#define _PLAYERDATA_H_
|
|
|
|
|
|
2009-05-07 22:36:51 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
#include <boost/thread.hpp>
|
2007-11-16 15:24:25 +00:00
|
|
|
#include <string>
|
|
|
|
|
#include <list>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <map>
|
2009-05-07 22:36:51 +00:00
|
|
|
#include <core/crypthelper.h>
|
2009-10-11 09:20:17 +00:00
|
|
|
#include <db/serverdbcallback.h>
|
2007-11-16 15:24:25 +00:00
|
|
|
|
|
|
|
|
class SessionData;
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
enum PlayerType {
|
2007-11-16 15:24:25 +00:00
|
|
|
PLAYER_TYPE_COMPUTER,
|
|
|
|
|
PLAYER_TYPE_HUMAN
|
|
|
|
|
};
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
enum PlayerRights {
|
2010-03-24 15:54:04 +00:00
|
|
|
PLAYER_RIGHTS_GUEST = 1,
|
2007-11-16 15:24:25 +00:00
|
|
|
PLAYER_RIGHTS_NORMAL,
|
|
|
|
|
PLAYER_RIGHTS_ADMIN
|
|
|
|
|
};
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
enum AvatarFileType {
|
2007-11-16 15:24:25 +00:00
|
|
|
AVATAR_FILE_TYPE_UNKNOWN = 0,
|
|
|
|
|
AVATAR_FILE_TYPE_PNG,
|
|
|
|
|
AVATAR_FILE_TYPE_JPG,
|
|
|
|
|
AVATAR_FILE_TYPE_GIF
|
|
|
|
|
};
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
struct AvatarFile {
|
2009-08-02 15:11:40 +00:00
|
|
|
AvatarFile() : fileType(AVATAR_FILE_TYPE_UNKNOWN), reportedSize(0) {}
|
2007-11-16 15:24:25 +00:00
|
|
|
std::vector<unsigned char> fileData;
|
|
|
|
|
AvatarFileType fileType;
|
2011-04-10 10:04:42 +00:00
|
|
|
size_t reportedSize;
|
2007-11-16 15:24:25 +00:00
|
|
|
};
|
|
|
|
|
|
2011-02-11 20:02:08 +00:00
|
|
|
struct PlayerInfo {
|
2010-03-24 15:54:04 +00:00
|
|
|
PlayerInfo() : ptype(PLAYER_TYPE_HUMAN), isGuest(false), hasAvatar(false), avatarType(AVATAR_FILE_TYPE_UNKNOWN) {}
|
2007-11-16 15:24:25 +00:00
|
|
|
std::string playerName;
|
|
|
|
|
PlayerType ptype;
|
2010-03-24 15:54:04 +00:00
|
|
|
bool isGuest;
|
2010-04-01 17:09:49 +00:00
|
|
|
std::string countryCode;
|
2007-11-16 15:24:25 +00:00
|
|
|
bool hasAvatar;
|
|
|
|
|
MD5Buf avatar;
|
2009-03-22 00:39:25 +00:00
|
|
|
AvatarFileType avatarType;
|
2007-11-16 15:24:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PlayerData
|
|
|
|
|
{
|
|
|
|
|
public:
|
2010-03-26 21:41:35 +00:00
|
|
|
PlayerData(unsigned uniqueId, int number, PlayerType type, PlayerRights rights, bool isGameAdmin);
|
2007-11-16 15:24:25 +00:00
|
|
|
PlayerData(const PlayerData &other);
|
|
|
|
|
~PlayerData();
|
|
|
|
|
|
|
|
|
|
std::string GetName() const;
|
|
|
|
|
void SetName(const std::string &name);
|
2010-04-01 16:20:57 +00:00
|
|
|
std::string GetCountry() const;
|
|
|
|
|
void SetCountry(const std::string &country);
|
2007-11-16 15:24:25 +00:00
|
|
|
std::string GetAvatarFile() const;
|
|
|
|
|
void SetAvatarFile(const std::string &avatarFile);
|
|
|
|
|
MD5Buf GetAvatarMD5() const;
|
|
|
|
|
void SetAvatarMD5(const MD5Buf &avatarMD5);
|
2009-08-02 15:11:40 +00:00
|
|
|
boost::shared_ptr<AvatarFile> GetNetAvatarFile() const;
|
|
|
|
|
void SetNetAvatarFile(boost::shared_ptr<AvatarFile> AvatarFile);
|
2007-11-16 15:24:25 +00:00
|
|
|
PlayerType GetType() const;
|
|
|
|
|
void SetType(PlayerType type);
|
|
|
|
|
PlayerRights GetRights() const;
|
2010-03-26 21:41:35 +00:00
|
|
|
bool IsGameAdmin() const;
|
|
|
|
|
void SetGameAdmin(bool isAdmin);
|
2007-11-16 15:24:25 +00:00
|
|
|
unsigned GetUniqueId() const;
|
|
|
|
|
int GetNumber() const;
|
|
|
|
|
void SetNumber(int number);
|
2009-10-24 21:49:11 +00:00
|
|
|
DB_id GetDBId() const;
|
|
|
|
|
void SetDBId(DB_id id);
|
2007-11-16 15:24:25 +00:00
|
|
|
|
|
|
|
|
bool operator<(const PlayerData &other) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const unsigned m_uniqueId;
|
2009-10-11 09:20:17 +00:00
|
|
|
DB_id m_dbId;
|
2007-11-16 15:24:25 +00:00
|
|
|
int m_number;
|
|
|
|
|
std::string m_name;
|
2009-10-11 09:20:17 +00:00
|
|
|
std::string m_password;
|
2010-04-01 16:20:57 +00:00
|
|
|
std::string m_country;
|
2007-11-16 15:24:25 +00:00
|
|
|
std::string m_avatarFile;
|
|
|
|
|
MD5Buf m_avatarMD5;
|
|
|
|
|
PlayerType m_type;
|
|
|
|
|
PlayerRights m_rights;
|
2010-03-26 21:41:35 +00:00
|
|
|
bool m_isGameAdmin;
|
2009-08-02 15:11:40 +00:00
|
|
|
boost::shared_ptr<AvatarFile> m_netAvatarFile;
|
2007-11-16 15:24:25 +00:00
|
|
|
|
|
|
|
|
mutable boost::mutex m_dataMutex;
|
|
|
|
|
};
|
|
|
|
|
|
2008-03-06 15:27:31 +00:00
|
|
|
typedef std::list<std::pair<unsigned, unsigned> > RemovePlayerList;
|
2007-11-16 15:24:25 +00:00
|
|
|
typedef std::list<boost::shared_ptr<PlayerData> > PlayerDataList;
|
|
|
|
|
typedef std::map<unsigned, boost::shared_ptr<PlayerData> > PlayerDataMap;
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|