Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / dms.h
blobb53b8626dacfb5ea9440ca78efbc7ee6ac614e3b
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/>.
18 #ifndef R2_DMS_H
19 #define R2_DMS_H
21 //-----------------------------------------------------------------------------
22 // includes
23 //-----------------------------------------------------------------------------
24 #include "nel/misc/types_nl.h"
25 #include "nel/misc/entity_id.h"
26 #include "nel/net/service.h"
27 #include "nel/net/message.h"
28 #include "nel/net/module.h"
29 #include "game_share/dyn_chat.h"
30 #include "game_share/chat_group.h"
31 #include "game_share/base_types.h"
33 #include "game_share/r2_types.h"
35 #include <list>
36 #include <map>
37 #include <vector>
39 namespace NLNET
41 class IModuleSocket;
42 class IModuleProxy;
43 class IModule;
46 namespace RSMGR
48 struct TSessionType;
51 namespace NLMISC
53 struct CEntityId;
57 namespace R2
61 class CObject;
62 class CUserConnectionMgr;
63 class CObjectId;
64 class CScenario;
65 class CServerAnimationModule;
66 class CServerAdminModule;
67 class CServerEditionModule;
68 class CStringManagerModule;
69 class CAnimationMessageAnimationStart;
74 class IServerEditionModule
76 public:
77 typedef uint32 TCharId;
78 // typedef CSessionId TSessionId; // typedef uint32 TSessionId;
80 public:
81 virtual ~IServerEditionModule(){}
82 virtual void createSessionWithoutSu(uint32 charId, NLMISC::CEntityId clientEid) = 0;
83 virtual TPioneersSessionsAllowed * getSessionAllowedForChar(TCharId charId) const = 0;
84 virtual CScenario* getScenarioById(TSessionId sessionId) const = 0;
85 // getEditing position (use AdminModule::getPosition for having a position in editing and animation mode)
86 virtual bool getPosition(TSessionId sessionId, double& x, double& y, double& orient, uint8& season, uint32 locationIndex = 0) = 0;
87 virtual TSessionId getSessionIdByCharId(TCharId charId) const = 0;
88 virtual bool isClientAuthorized(uint32 charId) const = 0;
89 virtual void disconnectChar(uint32 charId) = 0;
90 virtual const NLNET::TModuleProxyPtr * getClientProxyPtr(TCharId charId) const = 0;
91 virtual void tpToEntryPoint(NLNET::IModuleProxy *senderModuleProxy, uint32 actId) = 0;
92 // wakup a session (load session from BS), start animation, connect waiting clients
93 virtual bool wakeUpSession(TSessionId sessionId, TCharId ownerId, std::string& msg) = 0;
95 virtual bool isSessionHibernating(TSessionId sessionId, RSMGR::TSessionType& sessionType, double& x, double& y, double& orient, uint8& season) = 0;
96 virtual bool isEditingSession(TSessionId sessionId) const = 0;
97 virtual TSessionId getLinkedSessionId(TSessionId sessionId) const = 0;
98 virtual void getStartParams(uint32 charId, TSessionId lastStoredSessionId) = 0;
99 virtual void updateCharPioneerRight(TCharId charId) = 0;
100 virtual void characterReady(TCharId charId) =0;
101 virtual void returnToPreviousSession(TCharId charId) = 0;
106 class IServerAnimationModule
108 public:
109 typedef uint32 TCharId;
110 // typedef uint32 TSessionId;
112 public:
113 virtual ~IServerAnimationModule() {}
114 virtual TSessionId getSessionIdByCharId(TCharId charId) const = 0;
115 virtual bool getPosition(TSessionId sessionId, double& x, double& y, double& orient, uint8& season, uint32 locationIndex = 0) = 0;
116 virtual void scheduleStartSession(const CAnimationMessageAnimationStart &msg) = 0;
117 virtual void addPioneer( TSessionId sessionId, TCharId charId) = 0;
118 virtual bool stopTest(TSessionId sessionId, uint32 & lastAct) = 0;
119 virtual void disconnectChar(uint32 charId) = 0;
120 virtual bool getConnectedChars(TSessionId sessionId, std::vector<TCharId>& chars) const = 0;
121 virtual NLNET::IModule* getModule() const = 0;
123 virtual bool isSessionRunning(TSessionId sessionId) const = 0;
124 virtual uint32 getCurrentAct(TSessionId sessionId) const = 0;
125 virtual void stopControlNpcs(TCharId charId) = 0;
126 virtual void setSessionStartParams(TSessionId sessionId, sint32 x, sint32 y, uint8 season) = 0;
127 virtual bool mustReloadPosition(TSessionId sessionId, TCharId charId) const = 0;
128 virtual bool getHeaderInfo(TSessionId sessionId, TScenarioHeaderSerializer::TValueType& values) const = 0;
129 virtual bool getScore(TSessionId sessionId, uint32 &score, NLMISC::TTime &timeTaken) = 0;
132 class IServerAdminModule
134 public:
135 virtual ~IServerAdminModule() {}
137 virtual bool getPosition(TSessionId sessionId, double&x, double&y, double& orient, uint8& season, uint32 locationIndex = 0) = 0;
139 virtual TSessionId getSessionIdByCharId(uint32 charId) const = 0;
142 //-----------------------------------------------------------------------------
143 // class CDynamicMapService
144 //-----------------------------------------------------------------------------
146 class CDynamicMapService
148 public:
149 CDynamicMapService( NLMISC::CConfigFile& confFile, NLNET::IModuleSocket * gateway);
151 virtual ~CDynamicMapService();
153 static CDynamicMapService* getInstance();
155 virtual void init();
157 virtual void init2();
158 bool useNetwork() const { return _UseNetwork;}
159 virtual void translateAndForwardRequested(TDataSetRow senderId,CChatGroup::TGroupType groupType,std::string id,TSessionId sessionId);
161 void forwardIncarnChat(TChanID id,TDataSetRow senderId,ucstring sentence);
163 IServerAnimationModule* getAnimationModule() const;
165 IServerEditionModule* getEditionModule() const;
167 IServerAdminModule* getAdminModule() const;
169 std::string getValue(TSessionId sessionId, const std::string& msg) const;
171 private:
172 static CDynamicMapService* _Instance;
173 // CUserConnectionMgr* _UserConnectionMgr; will be session manager
174 CServerAnimationModule* _AnimationModule;
175 CServerAdminModule* _AdminModule;
176 CServerEditionModule* _EditionModule;
177 CStringManagerModule* _StringMgrModule;
179 NLMISC::CConfigFile& _ConfigFile;
180 bool _UseNetwork;
184 // get the security info of the module
185 bool getCharInfo(NLNET::IModuleProxy *senderModuleProxy, uint32 & charId, NLMISC::CEntityId & clientEid, std::string & userPriv, std::string &extendedPriv);
187 // get the security info of the module and verify that the su has allowed the client to connect to the dss
188 bool checkSecurityInfo(NLNET::IModuleProxy *senderModuleProxy, uint32 & charId, NLMISC::CEntityId & clientEid, std::string & userPriv, std::string &extendedPriv);
190 } // namespace R2
192 #endif //R2_DMS_H