minetest-jachoo/src/clans.h

91 lines
2.1 KiB
C++

/*
Minetest-c55
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
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.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
Clans.h - author: Jan Cychnerski
*/
#ifndef CLANS_HEADER
#define CLANS_HEADER
#include "common_irrlicht.h"
#include "utility.h"
//#include "player.h"
#include <map>
#include <set>
#include <string>
class Player;
class Settings;
struct Clan {
u16 id;
std::string name;
v3f spawnPoint;
bool hasSpawnPoint;
Clan():id(0),name("?"),spawnPoint(0,0,0),hasSpawnPoint(false){}
inline void deleteSpawnPoint(){hasSpawnPoint=false;}
inline void setSpawnPoint(const v3f& pos){spawnPoint=pos;hasSpawnPoint=true;}
};
class ClansManager {
public:
ClansManager();
u16 newClan(const std::string& name, Player* player);
void deleteClan(u16 id);
bool clanExists(u16 id) const;
bool clanExists(const std::string& name) const;
bool clanDeleted(u16 id) const;
u16 clanId(const std::string& name) const;
const std::string& clanName(u16 id) const; //throws if not existing clan
const std::string& clanNameNoEx(u16 id) const;
Clan* getClan(u16 id);
const Clan* getClan(u16 id) const;
const std::map<u16,Clan>& getClans() const;
const std::set<u16>& getDeleted() const;
void setClan(u16 id, const std::string& name, bool hasSpawnPoint, v3f spawnPoint = v3f());
void addDeleted(u16 id);
void save(Settings& args) const;
void load(Settings& args);
protected:
std::map<u16,Clan> m_ids;
std::map<std::string,Clan*> m_names;
std::set<u16> m_deleted;
u16 m_maxId;
private:
};
#endif