1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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_STRING_MGR_MODULE_H
18 #define R2_STRING_MGR_MODULE_H
22 #include "nel/misc/types_nl.h"
24 #include "nel/net/module.h"
25 #include "nel/net/module_socket.h"
26 #include "nel/net/message.h"
28 #include "game_share/small_string_manager.h"
29 #include "game_share/r2_messages.h"
30 #include "game_share/dms.h"
32 #include "game_share/base_types.h"
33 #include "game_share/chat_group.h"
34 #include "game_share/dyn_chat.h"
44 Used to manage the creation / Destruction of Dynamic channel channel.
45 When we can speak as a npc 'In this case we open a channel' and when we write in this channel we simulate that the npc is speaking
46 When a npc is controlled and he want to talk. Its message are forwarded to this channel
48 class CStringManagerModule
;
53 CStringManagerModule
* Module
;
54 NLNET::TModuleId ModuleId
;
55 virtual void execute(TDataSetRow
& dsr
)=0;
67 NLNET::IModuleProxy
* Proxy
;
72 TDataSetRow
getIncarnation(TChanID chanId
);
74 TChanID
getIncarnation(TDataSetRow npcId
);
76 bool incarn(TDataSetRow npcId
);
78 void addIncarnation(TChanID chanId
,TDataSetRow
& npcId
);
80 //release all channels used by this client
83 void removeIncarnation(TDataSetRow
& npcId
);
87 std::vector
<TIncarn
> _Incarnations
;
93 class CStringManagerModule
: public NLNET::CModuleBase
, public CStringTableManager
96 CStringManagerModule();
98 ~CStringManagerModule();
100 void init(NLNET::IModuleSocket
* clientGW
,CDynamicMapService
* server
);
102 virtual void onServiceUp(const std::string
&serviceName
, NLNET::TServiceId serviceId
) { }
104 virtual void onServiceDown(const std::string
&serviceName
, NLNET::TServiceId serviceId
) {}
106 virtual void onModuleUpdate() {}
108 virtual void onApplicationExit();
110 virtual void onModuleUp(NLNET::IModuleProxy
*moduleProxy
);
112 virtual void onModuleDown(NLNET::IModuleProxy
*moduleProxy
);
114 virtual bool onProcessModuleMessage(NLNET::IModuleProxy
*senderModuleProxy
, const NLNET::CMessage
&message
);
116 virtual void onModuleSecurityChange(NLNET::IModuleProxy
*moduleProxy
);
118 virtual void onModuleSocketEvent(NLNET::IModuleSocket
*moduleSocket
, TModuleSocketEvent eventType
) {}
120 virtual void registerTableRequested(TSessionId sessionId
,CObject
* table
);
122 virtual void registerTableRequested(const NLNET::CMessage
& msgin
);
124 virtual void registerTableRequested(TSessionId sessionId
,std::vector
<std::pair
<std::string
,std::string
> >& entries
);
126 virtual void unregisterTableRequested(TSessionId sessionId
);
128 virtual void translateAndForward(TDataSetRow senderId
,CChatGroup::TGroupType groupType
,std::string id
,TSessionId sessionId
);
130 virtual void translateAndForwardWithArg(TDataSetRow senderId
,CChatGroup::TGroupType groupType
,std::string id
,TSessionId sessionId
,std::vector
<float>& val
);
132 virtual void talkAs(NLNET::TModuleId
& id
, TDataSetRow
& creaturRowId
,std::string
& name
,TSessionId sessionId
);
134 virtual void stopTalkAs(NLNET::TModuleId
& id
,TDataSetRow
& npcId
);
136 virtual void forwardIncarnChat(TChanID id
,TDataSetRow senderId
,ucstring sentence
);
138 virtual void sendTable(TSessionId sessionId
,NLNET::IModuleProxy
*moduleProxy
);
140 virtual void sendIdList(TSessionId sessionId
,NLNET::IModuleProxy
* senderModuleProxy
);
142 virtual void sendStringValue(TSessionId sessionId
,NLNET::IModuleProxy
* moduleProxy
,std::string id
);
144 virtual void releaseChannels(TSessionId sessionId
);
148 static TChanID
initChannel(std::string name
="",bool forwardInput
=true);
150 virtual void send(TDataSetRow
& senderId
,CChatGroup::TGroupType groupType
,const std::string
& toSend
);
152 virtual void insertClient(NLNET::IModuleProxy
*moduleProxy
,TChanID channelId
);
154 virtual void removeClient(NLNET::IModuleProxy
*moduleProxy
);
156 virtual void addAnimSession(NLNET::TModuleId id
,TSessionId scenarioId
);
158 void requestDsr( ucstring
& name
);
161 std::map
<uint32
,TChanID
> _AnimChans
;
163 std::map
<NLNET::TModuleId
,ClientInfo
* > _ClientChannels
;
171 #endif //STRING_MGR_MODULE_H