Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / common / src / game_share / ring_access.h
blob243b7f30f7d5c014bbedfa45fcba9e372137f7cd
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef R2_RING_ACCESS_H
18 #define R2_RING_ACCESS_H
20 //-----------------------------------------------------------------------------
21 // includes
22 //-----------------------------------------------------------------------------
24 #include "nel/misc/singleton.h"
25 #include "nel/misc/sheet_id.h"
27 //-----------------------------------------------------------------------------
28 // R2 namespace
29 //-----------------------------------------------------------------------------
31 namespace R2
33 class CObject;
34 //-----------------------------------------------------------------------------
35 // class CRingAccess
36 //-----------------------------------------------------------------------------
38 class CVerfiyRightRtScenarioError
40 public:
41 enum TType {None, InvalidData, InvalidIslandLevel, InvalidBotLevel};
42 TType Type;
43 std::string Name; //bot or island name
44 std::string Package; //package
45 int Level;
46 int CharLevel;
48 CVerfiyRightRtScenarioError(TType varType = None, std::string name = "", std::string package = "",
49 int level = 0, int charLevel = 0):
50 Type(varType), Name(name), Package(package), Level(level), CharLevel(charLevel) {}
52 public:
53 std::string toString() const;
58 class CRingAccess : public NLMISC::CSingleton<R2::CRingAccess>
60 public:
63 // load (load data from xml)
64 // If not call explicityl this function is automaticly called by lazy initialisation
65 void init();
67 // lookup the integer id for a given island
68 std::string getSheetIdAccessInfo(const NLMISC::CSheetId& sheetClientId, const NLMISC::CSheetId& sheetServerId) const;
69 std::string getSheetAccessInfo(const std::string& sheetClient, const std::string& sheetServer="") const;
70 std::string getIslandAccessInfo(const std::string& islandeName) const;
71 void getRingAccessAsMap(const std::string& ringAccess, std::map<std::string, int> & ringAccessAsMap) const;
72 // Upgrade a ring access by another eg "d1:f3:l1" + "d3:f1:j1" => "d3:f2:l1:j1"
73 std::string upgradeRingAccess(const std::string& defaultValue, const std::string& bonusValue) const;
74 bool verifyRight(const std::string& askedAcces, const std::string& allowedAccess) const;
75 bool verifyRight(const std::map<std::string, int>& askedAccesMap, const std::map<std::string, int>& allowedAccessMap, std::string& package, int& neededLevel, int& charLevel) const;
76 //return null if ok otherwise return error
77 bool verifyRtScenario(CObject* rtScenario, const std::string& charRingAccess, CVerfiyRightRtScenarioError* &err) const;
78 static uint32 cypherCharId(uint32 id);
79 static uint32 uncypherCharId(uint32 id);
80 bool isPlotItemSheetId(const NLMISC::CSheetId& sheetId ) const;
81 bool isSheetClient(const NLMISC::CSheetId& sheet) const;
82 private: // private types
83 typedef std::map< std::pair<NLMISC::CSheetId, NLMISC::CSheetId>, std::string> TSheetIdToAccess; // Map sheetClientId, sheetServerId => RingAccess(as string)
85 public: // private functions
87 // this is a singleton so prevent instantiation
88 CRingAccess();
90 private: // private members
91 TSheetIdToAccess _SheetIdToAccess; //SheetId to access
92 std::set<NLMISC::CSheetId> _CustomNpcSheetId;
93 std::set<NLMISC::CSheetId> _R2PlotItemSheetId;
94 bool _Initialised;
99 } // namespace R2
101 //-----------------------------------------------------------------------------
103 #endif