2007-04-26 21:11:13 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
* Copyright (C) 2007 by Lothar May *
|
|
|
|
|
* *
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation; either version 2 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 General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
/* Player data. */
|
|
|
|
|
|
|
|
|
|
#ifndef _PLAYERDATA_H_
|
|
|
|
|
#define _PLAYERDATA_H_
|
|
|
|
|
|
2007-09-09 00:00:19 +00:00
|
|
|
#include <core/crypthelper.h>
|
2007-04-26 21:11:13 +00:00
|
|
|
#include <string>
|
|
|
|
|
#include <list>
|
2007-04-27 21:35:18 +00:00
|
|
|
#include <map>
|
2007-04-26 21:11:13 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
2007-09-29 14:05:41 +00:00
|
|
|
#include <boost/thread.hpp>
|
2007-04-26 21:11:13 +00:00
|
|
|
|
2007-05-13 22:25:59 +00:00
|
|
|
class SessionData;
|
|
|
|
|
|
2007-04-26 21:11:13 +00:00
|
|
|
enum PlayerType
|
|
|
|
|
{
|
|
|
|
|
PLAYER_TYPE_COMPUTER,
|
2007-07-30 23:22:58 +00:00
|
|
|
PLAYER_TYPE_HUMAN
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum PlayerRights
|
|
|
|
|
{
|
|
|
|
|
PLAYER_RIGHTS_NORMAL,
|
|
|
|
|
PLAYER_RIGHTS_ADMIN
|
2007-04-26 21:11:13 +00:00
|
|
|
};
|
|
|
|
|
|
2007-10-04 23:05:50 +00:00
|
|
|
enum AvatarFileType
|
|
|
|
|
{
|
2007-10-06 12:50:19 +00:00
|
|
|
AVATAR_FILE_TYPE_UNKNOWN = 0,
|
|
|
|
|
AVATAR_FILE_TYPE_PNG,
|
|
|
|
|
AVATAR_FILE_TYPE_JPG,
|
|
|
|
|
AVATAR_FILE_TYPE_GIF
|
2007-10-04 23:05:50 +00:00
|
|
|
};
|
|
|
|
|
|
2007-08-26 22:41:37 +00:00
|
|
|
struct PlayerInfo
|
|
|
|
|
{
|
|
|
|
|
PlayerInfo() : ptype(PLAYER_TYPE_HUMAN) {}
|
|
|
|
|
std::string playerName;
|
|
|
|
|
PlayerType ptype;
|
2007-09-09 00:00:19 +00:00
|
|
|
bool hasAvatar;
|
|
|
|
|
MD5Buf avatar;
|
2007-08-26 22:41:37 +00:00
|
|
|
};
|
|
|
|
|
|
2007-04-26 21:11:13 +00:00
|
|
|
class PlayerData
|
|
|
|
|
{
|
|
|
|
|
public:
|
2007-08-02 20:52:13 +00:00
|
|
|
PlayerData(unsigned uniqueId, int number, PlayerType type, PlayerRights rights);
|
2007-09-29 14:05:41 +00:00
|
|
|
PlayerData(const PlayerData &other);
|
2007-04-26 21:11:13 +00:00
|
|
|
~PlayerData();
|
|
|
|
|
|
2007-09-29 14:05:41 +00:00
|
|
|
const std::string &GetName() const;
|
|
|
|
|
void SetName(const std::string &name);
|
|
|
|
|
const std::string &GetAvatarFile() const;
|
|
|
|
|
void SetAvatarFile(const std::string &avatarFile);
|
|
|
|
|
boost::shared_ptr<SessionData> GetNetSessionData() const;
|
|
|
|
|
void SetNetSessionData(boost::shared_ptr<SessionData> session);
|
|
|
|
|
PlayerType GetType() const;
|
|
|
|
|
void SetType(PlayerType type);
|
|
|
|
|
PlayerRights GetRights() const;
|
|
|
|
|
void SetRights(PlayerRights rights);
|
|
|
|
|
unsigned GetUniqueId() const;
|
|
|
|
|
int GetNumber() const;
|
|
|
|
|
void SetNumber(int number);
|
2007-04-26 21:11:13 +00:00
|
|
|
|
2007-09-29 14:05:41 +00:00
|
|
|
bool operator<(const PlayerData &other) const;
|
2007-05-08 06:45:46 +00:00
|
|
|
|
2007-04-26 21:11:13 +00:00
|
|
|
private:
|
2007-09-29 14:05:41 +00:00
|
|
|
const unsigned m_uniqueId;
|
2007-05-13 22:25:59 +00:00
|
|
|
int m_number;
|
|
|
|
|
std::string m_name;
|
|
|
|
|
std::string m_avatarFile;
|
|
|
|
|
PlayerType m_type;
|
2007-08-02 20:52:13 +00:00
|
|
|
PlayerRights m_rights;
|
2007-05-13 22:25:59 +00:00
|
|
|
boost::shared_ptr<SessionData> m_netSessionData;
|
2007-09-29 14:05:41 +00:00
|
|
|
|
|
|
|
|
mutable boost::mutex m_dataMutex;
|
2007-04-26 21:11:13 +00:00
|
|
|
};
|
|
|
|
|
|
2007-09-01 22:59:55 +00:00
|
|
|
typedef std::list<unsigned> PlayerIdList;
|
2007-04-26 21:11:13 +00:00
|
|
|
typedef std::list<boost::shared_ptr<PlayerData> > PlayerDataList;
|
2007-04-27 21:35:18 +00:00
|
|
|
typedef std::map<unsigned, boost::shared_ptr<PlayerData> > PlayerDataMap;
|
2007-04-26 21:11:13 +00:00
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|