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/>.
21 #include <nel/misc/entity_id.h>
22 #include <nel/net/unified_network.h>
24 #include "game_share/ryzom_mirror_properties.h"
26 #include "input_output_service.h"
27 /*#include "game_share/tick_event_handler.h"
28 #include "game_share/msg_client_server.h"
29 #include "game_share/mode_and_behaviour.h" //TEMP!!!
30 #include "game_share/news_types.h"
31 #include "game_share/bot_chat_types.h"
32 #include "game_share/brick_types.h"
33 #include "game_share/loot_harvest_state.h"*/
34 #include "game_share/generic_xml_msg_mngr.h"
36 /*#include <nel/misc/command.h>*/
39 using namespace NLMISC
;
40 using namespace NLNET
;
43 extern CGenericXmlMsgHeaderManager GenericXmlMsgHeaderMngr
;
45 extern CVariable
<bool> VerboseChatManagement
;
47 typedef NLMISC::CTwinMap
<TChanID
, string
> TChanTwinMap
;
48 extern TChanTwinMap _ChanNames
;
51 //-----------------------------------------------
52 // cbImpulsionReadyString :
54 //-----------------------------------------------
57 void cbImpulsionReadyString( CMessage& msgin, const string &serviceName, TServiceId serviceId )
59 nlwarning("cbImpulsionReadyString : deprecated");
60 // Read sender and bitmemstream
63 CBitMemStream bms(true);
65 msgin.serial(nbBitsToSkip);
66 msgin.serialMemStream(bms);
68 // Unpack bitmemstream
70 bms.serial(xmlcode, nbBitsToSkip); // the XML code was already read by tbe sender service
71 std::string languageCode;
72 bms.serial(languageCode);
74 nlinfo("<impulsionRdy> send ready for client %s using language %s",sender.toString().c_str(), languageCode.c_str());
76 CCharacterInfos * charInfos = IOS->getCharInfos( sender );
77 if( charInfos != NULL )
79 // charInfos->Id.getDynamicId() = serviceId;
80 // read the language code used by the client for this session
81 charInfos->Language = SM->checkLanguageCode(languageCode);
82 nldebug ("set user %s to front end %d using language code %s", sender.toString().c_str(), serviceId, SM->getLanguageCodeString(charInfos->Language).c_str());
85 // send back the cache time stamp info
86 uint32 timestamp = SM->getCacheTimestamp();
88 // now, build the message for the client.
89 NLMISC::CBitMemStream bmsOut;
90 GenericXmlMsgHeaderMngr.pushNameToStream( "STRING_MANAGER:RELOAD_CACHE", bmsOut);
91 bmsOut.serial(timestamp);
93 // send the message to Front End
94 NLNET::CMessage msgout( "IMPULS_CH_ID" );
95 NLMISC::CEntityId destId = sender;
97 msgout.serial( destId );
98 msgout.serial( channel );
100 msgout.serialBufferWithSize((uint8*)bmsOut.buffer(), bmsOut.length());
101 NLNET::CUnifiedNetwork::getInstance()->send(charInfos->EntityId.getDynamicId(), msgout);
105 nlwarning("<cbImpulsionReadyString> The character %s doesn't have infos",sender.toString().c_str());
111 //-----------------------------------------------
114 //-----------------------------------------------
115 void cbImpulsionChat( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
118 msgin
.serial(sender
);
125 catch(const Exception
&e
)
127 nlwarning("<impulsionChat> %s",e
.what());
131 // Do a general filtering on client input
132 ucstr
= IOS
->getChatManager().filterClientInput(ucstr
);
136 nlinfo("<impulsionChat> CHAT received : %s",ucstr
.toString().c_str());
141 TDataSetRow senderRow
= TheDataset
.getDataSetRow(sender
);
142 IOS
->getChatManager().getClient(senderRow
).updateAudience();
143 IOS
->getChatManager().chat( senderRow
, ucstr
);
145 catch(const Exception
&e
)
147 nlwarning("<impulsionChat> %s",e
.what());
149 } // impulsionChat //
152 //-----------------------------------------------
153 // cbImpulsionChatTeam :
155 //-----------------------------------------------
156 void cbImpulsionChatTeam( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
159 msgin
.serial(sender
);
166 catch(const Exception
&e
)
168 nlwarning("<impulsionChatTeam> %s",e
.what());
172 // Do a general filtering on client input
173 ucstr
= IOS
->getChatManager().filterClientInput(ucstr
);
177 nlinfo("<impulsionChatTeam> CHAT_TEAM received : %s",ucstr
.toString().c_str());
182 TDataSetRow senderRow
= TheDataset
.getDataSetRow(sender
);
183 // get current chat mode
184 const CChatGroup::TGroupType chatModeBck
= IOS
->getChatManager().getClient(senderRow
).getChatMode();
185 // set chat mode to group
186 IOS
->getChatManager().getClient(senderRow
).setChatMode( CChatGroup::team
);
187 //IOS->getChatManager().getClient(sender).updateAudience(); // only for say and shout
189 IOS
->getChatManager().chat( senderRow
, ucstr
);
190 // reset chat mode to old value
191 IOS
->getChatManager().getClient(senderRow
).setChatMode( chatModeBck
);
193 catch(const Exception
&e
)
195 nlwarning("<impulsionChatTeam> %s",e
.what());
197 } // impulsionChatTeam //
200 //-----------------------------------------------
203 //-----------------------------------------------
204 void cbImpulsionTell( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
207 msgin
.serial(sender
);
213 msgin
.serial(receiver
);
216 catch(const Exception
&e
)
218 nlwarning("<impulsionTell> %s",e
.what());
222 // Do a general filtering on client input
223 str
= IOS
->getChatManager().filterClientInput(str
);
228 CCharacterInfos
*ci
= IOS
->getCharInfos(sender
);
230 senderName
= sender
.toString();
232 senderName
= IOS
->getRocketName(ci
->Name
);
234 nlinfo("<impulsionTell> TELL %s to %s: '%s'", senderName
.c_str(), receiver
.c_str(), str
.toString().c_str());
236 TDataSetRow senderRow
= TheDataset
.getDataSetRow(sender
);
238 IOS
->getChatManager().tell( senderRow
, receiver
, str
);
240 } // impulsionTell //
242 //-----------------------------------------------
245 //-----------------------------------------------
246 static void updateIgnoreStatus(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
, bool ignored
)
253 msgin
.serial(senderId
);
254 msgin
.serial(ignoredId
);
255 IOS
->getChatManager().getClient(TheDataset
.getDataSetRow(senderId
)).setIgnoreStatus(ignoredId
, ignored
);
257 catch(const Exception
&e
)
259 nlwarning("<impulsionIgnore> %s",e
.what());
264 //-----------------------------------------------
265 // cbImpulsionIgnore :
267 //-----------------------------------------------
268 void cbImpulsionIgnore( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
270 updateIgnoreStatus(msgin
, serviceName
, serviceId
, true);
271 } // impulsionIgnore //
273 //-----------------------------------------------
274 // cbImpulsionUnignore :
276 //-----------------------------------------------
277 void cbImpulsionUnignore( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
279 updateIgnoreStatus(msgin
, serviceName
, serviceId
, false);
280 } // impulsionUnignore //
282 //-----------------------------------------------
283 // cbImpulsionUnignoreAll :
285 //-----------------------------------------------
286 void cbImpulsionUnignoreAll( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
289 vector
<CEntityId
> ignoredIds
;
293 msgin
.serial(senderId
);
294 msgin
.serialCont(ignoredIds
);
295 for ( vector
<CEntityId
>::const_iterator it
=ignoredIds
.begin(); it
!=ignoredIds
.end(); ++it
)
297 IOS
->getChatManager().getClient(TheDataset
.getDataSetRow(senderId
)).setIgnoreStatus(*it
, false);
300 catch(const Exception
&e
)
302 nlwarning("<impulsionIgnoreAll> %s",e
.what());
306 } // impulsionUnignoreAll //
309 //-----------------------------------------------
310 // cbImpulsionFilter :
312 //-----------------------------------------------
313 void cbImpulsionFilter( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
316 msgin
.serial(sender
);
321 msgin
.serial( filterId
);
323 catch(const Exception
&e
)
325 nlwarning("<impulsionFilter> %s",e
.what());
329 CCharacterInfos
* charInfos
= IOS
->getCharInfos( sender
);
330 if( charInfos
!= NULL
)
334 IOS
->getChatManager().getClient(TheDataset
.getDataSetRow(sender
)).filter( filterId
);
336 catch(const Exception
&e
)
338 nlwarning("<impulsionFilter> %s",e
.what());
343 nlwarning("<impulsionFilter>The character %s doesn't have infos",sender
.toString().c_str());
345 } // impulsionFilter //
348 static const char* DebugChatModeName
[] =
365 //-----------------------------------------------
366 // cbImpulsionChatMode :
368 //-----------------------------------------------
369 void cbImpulsionChatMode( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
372 msgin
.serial(sender
);
378 msgin
.serial( chatMode
);
379 msgin
.serial(chanID
);
381 catch(const Exception
&e
)
383 nlwarning("<cbImpulsionChatMode> %s",e
.what());
386 CCharacterInfos
* charInfos
= IOS
->getCharInfos( sender
);
387 if( charInfos
!= NULL
)
393 case CChatGroup::say
:
394 case CChatGroup::shout
:
395 case CChatGroup::team
:
396 case CChatGroup::guild
:
397 case CChatGroup::region
:
398 case CChatGroup::universe
:
399 IOS
->getChatManager().getClient(TheDataset
.getDataSetRow(sender
)).setChatMode( static_cast<CChatGroup::TGroupType
>(chatMode
));
400 nldebug("IOS: Chat mode --> %s", DebugChatModeName
[chatMode
]);
402 case CChatGroup::dyn_chat
:
403 IOS
->getChatManager().getClient(TheDataset
.getDataSetRow(sender
)).setChatMode( static_cast<CChatGroup::TGroupType
>(chatMode
), chanID
);
406 if (chatMode
< CChatGroup::nbChatMode
)
407 nlwarning("<cbImpulsionChatMode>(CHAT_MODE) The chat mode '%s' can't be set", DebugChatModeName
[chatMode
]);
409 nlwarning("<cbImpulsionChatMode>(CHAT_MODE) The chat mode %d is out of enum !", chatMode
);
412 catch(const Exception
&e
)
414 nlwarning("<cbImpulsionChatMode> %s",e
.what());
419 nlwarning("<cbImpulsionChatMode> The character %s doesn't have infos",sender
.toString().c_str());
422 } // cbImpulsionChatMode //
425 //-----------------------------------------------
426 // cbImpulsionAfkTxt :
428 //-----------------------------------------------
429 void cbImpulsionAfkTxt( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
432 msgin
.serial(sender
);
437 msgin
.serial( afkTxt
);
439 catch(const Exception
&e
)
441 nlwarning("<cbImpulsionAfkTxt> %s",e
.what());
445 // Do a general filtering on client input
446 afkTxt
= IOS
->getChatManager().filterClientInputColorCode(afkTxt
);
448 CCharacterInfos
* charInfos
= IOS
->getCharInfos( sender
);
449 if( charInfos
!= NULL
)
451 charInfos
->AfkCustomTxt
= afkTxt
;
455 nlwarning("<cbImpulsionAfkTxt> The character %s doesn't have infos",sender
.toString().c_str());
458 } // cbImpulsionAfkTxt //
461 //-----------------------------------------------
462 // cbImpulsionStringRqId :
464 //-----------------------------------------------
465 //void cbImpulsionStringRqId( CMessage& msgin, const string &serviceName, TServiceId serviceId )
468 // msgin.serial(sender);
471 // msgin.serial(stringId);
473 // SM->requestString(sender, stringId);
477 //-----------------------------------------------
478 // cbImpulsionStringRqUid :
480 //-----------------------------------------------
481 void cbImpulsionStringRqUid( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
484 msgin
.serial(userId
);
487 msgin
.serial(stringId
);
489 SM
->requestString(userId
, stringId
);
496 TDataSetRow DataSetIndex
;
498 // uint16 FrontendId;
502 //-----------------------------------------------
505 //-----------------------------------------------
506 static void cbStaticString(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
511 set
<CEntityId
> excluded
;
514 msgin
.serial( receiver
);
515 msgin
.serialCont( excluded
);
516 msgin
.serial( strId
);
518 nlwarning("cbStaticString : service %u(%s) use deprecated phrase system. Trying to output string '%s'."
519 , serviceId
.get(), serviceName
.c_str(),
522 } // cbStaticString //
526 //-----------------------------------------------
529 //-----------------------------------------------
530 static void cbChatMessage(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
532 TDataSetRow entityId
;
537 msgin
.serial(entityId
);
540 catch(const Exception
&e
)
542 nlwarning("<cbChatMessage> %s",e
.what());
548 CChatGroup::TGroupType oldMode
= IOS
->getChatManager().getClient(entityId
).getChatMode();
549 if ( oldMode
!= CChatGroup::say
)
550 IOS
->getChatManager().getClient(entityId
).setChatMode(CChatGroup::say
);
552 IOS
->getChatManager().getClient(entityId
).updateAudience();
553 IOS
->getChatManager().chat( entityId
, str
);
555 if ( oldMode
!= CChatGroup::say
)
556 IOS
->getChatManager().getClient(entityId
).setChatMode(oldMode
);
558 catch(const Exception
&e
)
560 nlwarning("<cbChatMessage> %s",e
.what());
562 } // cbChatMessage //
565 //-----------------------------------------------
568 //-----------------------------------------------
569 /*static void cbRemoveEntity(CMessage& msgin, const string &serviceName, TServiceId serviceId)
575 msgin.serial( entityId );
577 catch(const Exception &e)
579 nlwarning("<cbRemoveEntity> %s",e.what());
584 IOS->removeEntity( entityId );
586 nldebug("<cbRemoveEntity> Removing entity %s",entityId.toString().c_str());
590 //-----------------------------------------------
593 //-----------------------------------------------
594 static void cbCharacterName(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
602 msgin
.serial( chId
);
605 msgin
.serial( name
);
607 catch(const Exception
&e
)
609 nlwarning("<cbCharacterName> %s",e
.what());
613 IOS
->addCharacterName( chId
, name
, TSessionId(0) );
615 } // cbCharacterName //
617 //-----------------------------------------------
618 // cbCharacterNameId :
620 //-----------------------------------------------
621 static void cbCharacterNameId(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
628 msgin
.serial( chId
);
630 // character's string Id
631 msgin
.serial( stringId
);
633 catch(const Exception
&e
)
635 nlwarning("<cbCharacterName> %s",e
.what());
638 IOS
->addCharacterName( chId
, SM
->getString( stringId
), TSessionId(0) );
640 } // cbCharacterNameId //
642 //-----------------------------------------------
643 // cbCharacterNameAndLang :
645 //-----------------------------------------------
646 static void cbCharacterNameAndLang(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
650 TSessionId sessionId
;
652 std::vector
<NLMISC::CEntityId
> ignoreList
;
657 msgin
.serial( chId
);
660 msgin
.serial( name
);
662 // character home mainland session
663 msgin
.serial( sessionId
);
666 msgin
.serial(language
);
669 msgin
.serialCont(ignoreList
);
672 msgin
.serial( havePrivilege
);
674 catch(const Exception
&e
)
676 nlwarning("<cbCharacterName> %s",e
.what());
680 IOS
->addCharacterName( chId
, name
, sessionId
);
681 CCharacterInfos
*ci
= IOS
->getCharInfos(TheDataset
.getEntityId(chId
), false);
684 ci
->Language
= SM
->checkLanguageCode(language
);
685 ci
->HavePrivilege
= havePrivilege
;
686 IOS
->getChatManager().getClient(chId
).setIgnoreList(ignoreList
);
689 } // cbCharacterNameAndLang //
691 //-----------------------------------------------
692 // cbCharacterEventFaction :
694 //-----------------------------------------------
695 static void cbCharacterEventFaction(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
702 msgin
.serial( chId
);
705 msgin
.serial( eventFaction
);
707 catch(const Exception
&e
)
709 nlwarning("<cbCharacterEventFaction> %s", e
.what());
713 CCharacterInfos
*ci
= IOS
->getCharInfos(TheDataset
.getEntityId(chId
), false);
714 if ( ci
&& TheDataset
.isAccessible(chId
) )
716 if (eventFaction
.empty())
717 ci
->UntranslatedEventFactionId
= 0;
719 ci
->UntranslatedEventFactionId
= SM
->storeString( eventFaction
);
721 // CMirrorPropValue<TYPE_EVENT_FACTION_ID> propEventFactionId( TheDataset, chId, DSPropertyEVENT_FACTION_ID );
722 // propEventFactionId = SM->translateEventFaction( ci->UntranslatedEventFactionId );
726 nlwarning("cbCharacterEventFaction: character has not been registered yet in IOS!");
729 } // cbCharacterEventFaction //
732 //-----------------------------------------------
735 //-----------------------------------------------
736 static void cbAddGroup( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
744 msgin
.serial( gType
);
746 catch(const Exception
&e
)
748 nlwarning("<cbAddGroup> %s",e
.what());
752 IOS
->getChatManager().addGroup( gId
, (CChatGroup::TGroupType
)gType
, "" );
754 if (VerboseChatManagement
)
755 nldebug("IOS: cbAddGroup Adding group %s with type '%s'",
756 gId
.toString().c_str(),
757 CChatGroup::groupTypeToString((CChatGroup::TGroupType
)gType
).c_str());
761 //-----------------------------------------------
764 //-----------------------------------------------
765 static void cbAddNamedGroup( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
774 msgin
.serial( gType
);
775 msgin
.serial( name
);
777 catch(const Exception
&e
)
779 nlwarning("<cbAddGroup> %s",e
.what());
783 IOS
->getChatManager().addGroup( gId
, (CChatGroup::TGroupType
)gType
, name
);
785 if (VerboseChatManagement
)
786 nldebug("IOS: cbAddGroup Adding named group %s with type '%s' as '%s'",
787 gId
.toString().c_str(),
788 CChatGroup::groupTypeToString((CChatGroup::TGroupType
)gType
).c_str(),
793 //-----------------------------------------------
796 //-----------------------------------------------
797 static void cbRemoveGroup( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
805 catch(const Exception
&e
)
807 nlwarning("<cbRemoveGroup> %s",e
.what());
811 IOS
->getChatManager().removeGroup( gId
);
813 nldebug("IOS: cbRemoveGroup Removing group %s",gId
.toString().c_str());
815 } // cbRemoveGroup //
818 //-----------------------------------------------
821 //-----------------------------------------------
822 static void cbAddToGroup( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
830 msgin
.serial( charId
);
832 catch(const Exception
& e
)
834 nlwarning("<cbAddToGroup> %s",e
.what());
838 TDataSetRow charRow
= TheDataset
.getDataSetRow(charId
);
840 if(charRow
.getIndex() == 0xffffff)
842 nlwarning("id.getIndex() == 0xffffff for entity %s, skip it", charId
.toString().c_str());
846 // if not already register in chat manager, add it
847 if (!IOS
->getChatManager().checkClient(charRow
))
848 IOS
->getChatManager().addClient( charRow
);
849 //IOS->getChatManager().getClient(charId).setChatMode(say);
851 IOS
->getChatManager().addToGroup( gId
, charRow
);
853 nldebug("IOS: cbAddToGroup Adding %s to group %s",charId
.toString().c_str(), gId
.toString().c_str());
858 //-----------------------------------------------
859 // cbRemoveFromGroup :
861 //-----------------------------------------------
862 static void cbRemoveFromGroup( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
870 msgin
.serial( charId
);
872 catch(const Exception
& e
)
874 nlwarning("<cbRemoveFromGroup> %s",e
.what());
878 TDataSetRow charRow
= TheDataset
.getDataSetRow(charId
);
880 if (charRow
.isValid())
882 IOS
->getChatManager().removeFromGroup( gId
, charRow
);
884 nldebug("IOS: cbAddToGroup Removing %s:%x from group %s",
885 charId
.toString().c_str(),
887 gId
.toString().c_str());
890 } // cbRemoveFromGroup //
894 //-----------------------------------------------
897 //-----------------------------------------------
898 //static void cbSendDynamicId( CMessage& msgin, const string &serviceName, TServiceId serviceId )
900 // CEntityId clientId;
901 // CEntityId entityId;
905 // msgin.serial( clientId );
906 // msgin.serial( entityId );
908 // catch(const Exception& e)
910 // nlwarning("<cbSendDynamicId> %s",e.what());
914 // CCharacterInfos * clientInfos = IOS->getCharInfos( clientId );
915 // CCharacterInfos * entityInfos = IOS->getCharInfos( entityId );
916 // if( clientInfos != NULL )
918 // if( entityInfos != NULL )
922 // if( IOS->getChatManager().getClient(clientInfos->DataSetIndex).knowString(entityInfos->OldNameIndex) == false )
924 // IOS->getChatManager().addDynStr( clientId, entityInfos->OldNameIndex, serviceId );
927 // catch(const CChatManager::EChatClient& e)
929 // nlwarning("<cbSendDynamicId> %s",e.what());
934 // nlwarning("<cbSendDynamicId> Infos about the other character %s not found",entityId.toString().c_str());
939 // nlwarning("<cbSendDynamicId> Infos about the receiver %s not found",clientId.toString().c_str());
942 //} // cbSendDynamicId //
945 //-----------------------------------------------
948 //-----------------------------------------------
949 void cbSysChat( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
955 msgin
.serial(talkToUser
);
956 msgin
.serial(talkTo
);
957 msgin
.serial(chatString
);
961 IOS
->getChatManager().sendChat(CChatGroup::tell
, TheDataset
.getDataSetRow(talkTo
), ucstring("{no_bubble}<"+serviceName
+":"+toString(serviceId
.get())+"> "+chatString
));
965 IOS
->getChatManager().chatInGroup(talkTo
, ucstring("{no_bubble}<"+serviceName
+":"+toString(serviceId
.get())+"> ")+chatString
, TDataSetRow());
971 //-----------------------------------------------
974 //-----------------------------------------------
975 void cbNpcTell( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
978 TDataSetRow receiver
;
981 msgin
.serial(sender
);
982 msgin
.serial(receiver
);
983 msgin
.serial(phraseId
);
985 CChatManager
&cm
= IOS
->getChatManager();
989 // TDataSetRow dsr = TheDataset.getDataSetRow(sender);
990 if (sender
== INVALID_DATASET_ROW
|| !sender
.isValid())
992 nlwarning("cbNpcTell : ignoring chat because NPC %u not yet in mirror", sender
.getIndex()/*.toString().c_str()*/);
995 // CChatClient &client = cm.getClient(sender);
996 cm
.sendChat2(CChatGroup::tell
, receiver
, phraseId
, sender
);
998 catch(const CChatManager::EChatClient
&)
1000 nlwarning("cbNpcTell : ignoring chat because NPC info not available yet");
1005 //-----------------------------------------------
1008 //-----------------------------------------------
1009 void cbGhostTell( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1011 TDataSetRow receiver
;
1014 msgin
.serial(receiver
);
1015 msgin
.serial(phraseId
);
1017 CChatManager
&cm
= IOS
->getChatManager();
1019 cm
.sendChat2(CChatGroup::tell
, receiver
, phraseId
);
1022 //-----------------------------------------------
1025 //-----------------------------------------------
1026 void cbNpcTellEx( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1029 TDataSetRow receiver
;
1032 msgin
.serial(sender
);
1033 msgin
.serial(receiver
);
1034 msgin
.serial(phraseId
);
1036 CChatManager
&cm
= IOS
->getChatManager();
1040 // TDataSetRow dsr = TheDataset.getDataSetRow(sender);
1041 if (sender
== INVALID_DATASET_ROW
|| !sender
.isValid())
1043 nlwarning("cbNpcTell : ignoring chat because NPC %u not valid", sender
.getIndex()/*.toString().c_str()*/);
1046 // CChatClient &client = cm.getClient(sender);
1047 cm
.sendChat2Ex(CChatGroup::tell
, receiver
, phraseId
, sender
);
1049 catch(const CChatManager::EChatClient
&)
1051 nlwarning("cbNpcTell : ignoring chat because NPC info not available yet");
1056 //-----------------------------------------------
1059 //-----------------------------------------------
1060 void cbNpcChatEx( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1063 CChatGroup::TGroupType type
= CChatGroup::nbChatMode
;
1066 msgin
.serial(sender
);
1067 msgin
.serialEnum(type
);
1068 msgin
.serial(phraseId
);
1070 CChatManager
&cm
= IOS
->getChatManager();
1074 // TDataSetRow dsr = TheDataset.getDataSetRow(sender);
1075 if (sender
== INVALID_DATASET_ROW
)
1077 nlwarning("cbNpcChatEx : ignoring chat because NPC %s:%x Invalid",
1078 TheDataset
.getEntityId(sender
).toString().c_str(),
1082 CChatClient
&client
= cm
.getClient(sender
);
1083 client
.setChatMode(type
);
1084 client
.updateAudience();
1085 cm
.chat2Ex(sender
, phraseId
);
1087 catch(const CChatManager::EChatClient
&)
1089 nlwarning("cbNpcChatEx : ignoring chat because NPC info not available yet");
1094 //-----------------------------------------------
1097 //-----------------------------------------------
1098 void cbNpcChat( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1101 CChatGroup::TGroupType type
= CChatGroup::nbChatMode
;
1104 msgin
.serial(sender
);
1105 msgin
.serialEnum(type
);
1106 msgin
.serial(phraseId
);
1108 CChatManager
&cm
= IOS
->getChatManager();
1112 // TDataSetRow dsr = TheDataset.getDataSetRow(sender);
1113 if ( !sender
.isValid() || !TheDataset
.isDataSetRowStillValid(sender
) )
1115 nlwarning("cbNpcChat : ignoring chat because NPC %x not yet/not anymore in mirror",
1119 CChatClient
&client
= cm
.getClient(sender
);
1120 client
.setChatMode(type
);
1121 client
.updateAudience();
1122 cm
.chat2(sender
, phraseId
);
1124 catch(const CChatManager::EChatClient
&)
1126 nlwarning("cbNpcChat : ignoring chat because NPC info not available yet");
1130 //-----------------------------------------------
1133 //-----------------------------------------------
1134 void cbNpcChatParam( CMessage
& msgin
, const string
&serviceName
, NLNET::TServiceId serviceId
)
1137 CChatGroup::TGroupType type
= CChatGroup::nbChatMode
;
1139 std::vector
<STRING_MANAGER::TParam
> params
;
1141 msgin
.serial(sender
);
1142 msgin
.serialEnum(type
);
1143 msgin
.serial(phraseId
);
1147 params
.resize(size
);
1148 for ( uint i
= 0; i
< size
; i
++ )
1151 msgin
.serial( type8
);
1152 params
[i
].serialParam( false, msgin
, (STRING_MANAGER::TParamType
) type8
);
1155 CChatManager
&cm
= IOS
->getChatManager();
1159 // TDataSetRow dsr = TheDataset.getDataSetRow(sender);
1160 if ( !sender
.isValid() || !TheDataset
.isDataSetRowStillValid(sender
) )
1162 nlwarning("cbNpcChat : ignoring chat because NPC %x not yet/not anymore in mirror",
1166 CChatClient
&client
= cm
.getClient(sender
);
1167 client
.setChatMode(type
);
1168 client
.updateAudience();
1169 cm
.chatParam(sender
, phraseId
, params
);
1171 catch(const CChatManager::EChatClient
&)
1173 nlwarning("cbNpcChat : ignoring chat because NPC info not available yet");
1178 //-----------------------------------------------
1179 // cbNpcChatSentence :
1181 //-----------------------------------------------
1182 void cbNpcChatSentence( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1185 CChatGroup::TGroupType type
= CChatGroup::nbChatMode
;
1188 msgin
.serial(sender
);
1189 msgin
.serialEnum(type
);
1190 msgin
.serial(sentence
);
1192 CChatManager
&cm
= IOS
->getChatManager();
1196 // TDataSetRow dsr = TheDataset.getDataSetRow(sender);
1197 if ( !sender
.isValid() || !TheDataset
.isDataSetRowStillValid(sender
) )
1199 nlwarning("cbNpcChatSentence : ignoring chat because NPC %x not yet/not anymore in mirror",
1203 CChatClient
&client
= cm
.getClient(sender
);
1204 client
.setChatMode(type
);
1205 client
.updateAudience();
1206 cm
.chat(sender
, sentence
);
1208 catch(const CChatManager::EChatClient
&)
1210 nlwarning("cbNpcChatSentence : ignoring chat because NPC info not available yet");
1214 //-----------------------------------------------
1215 // cbNpcChatSentenceEx :
1217 //-----------------------------------------------
1218 void cbNpcChatSentenceEx( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1226 msgin
.serial(sentence
);
1227 if(id
.isUnknownId())
1229 nlwarning("bad channel id : %s unable to chat! ",id
.toString().c_str());
1232 CCharacterInfos
* cInfo
= IOS
->getCharInfos(name
);
1233 sender
= cInfo
->DataSetIndex
;
1234 if(sender
.isValid())
1236 CChatManager
&cm
= IOS
->getChatManager();
1237 CChatClient
&client
= cm
.getClient(sender
);
1238 client
.setChatMode(CChatGroup::dyn_chat
,id
);
1239 client
.updateAudience();
1240 cm
.chat(sender
,sentence
);
1244 nlwarning("sender %s:%x invalid! unable to chat!",name
.toString().c_str(),sender
.getIndex());
1248 void cbNpcChatSentenceChannel( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1254 msgin
.serial(sender
);
1255 msgin
.serial(sentence
);
1257 if(sender
.isValid())
1259 CChatManager
&cm
= IOS
->getChatManager();
1260 CChatClient
&client
= cm
.getClient(sender
);
1261 client
.setChatMode(CChatGroup::dyn_chat
,id
);
1262 client
.updateAudience();
1263 cm
.chat(sender
,sentence
);
1264 nlwarning("%s said %s !",sender
.toString().c_str(),sentence
.toString().c_str());
1267 nlwarning("sender %x invalid! unable to chat!",sender
.getIndex());
1272 //-----------------------------------------------
1273 // cbGroupDynString :
1275 //-----------------------------------------------
1276 void cbGroupDynString( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1279 vector
<CEntityId
> excluded
;
1282 msgin
.serial(sender
);
1283 msgin
.serialCont(excluded
);
1284 msgin
.serial(phraseId
);
1286 CChatManager
&cm
= IOS
->getChatManager();
1290 // TDataSetRow dsr = TheDataset.getDataSetRow(sender);
1291 if (sender
== INVALID_DATASET_ROW
|| !sender
.isValid())
1293 nlwarning("cbGroupDynString : ignoring group message because entity %x not yet in mirror", sender
.getIndex());
1297 list
<CReceiver
> receiverList
;
1299 CChatClient
&client
= cm
.getClient(sender
);
1300 client
.updateAudience();
1301 CChatGroup group
= client
.getSayAudience();
1303 CChatGroup::TMemberCont::iterator itM
;
1304 for( itM
= group
.Members
.begin(); itM
!= group
.Members
.end(); ++itM
)
1306 const CEntityId
&id
= TheDataset
.getEntityId(*itM
);
1308 // skip it if excluded
1309 if ( std::find(excluded
.begin(), excluded
.end(), id
) != excluded
.end() )
1312 // send message to client front end
1313 CMessage
msgout( "IMPULSION_ID" );
1314 msgout
.serial( const_cast<CEntityId
&> (id
) );
1316 if ( ! GenericXmlMsgHeaderMngr
.pushNameToStream( "STRING:DYN_STRING", bms
) )
1318 nlwarning("Msg name CHAT:DYN_STRING not found");
1322 bms
.serial( phraseId
);
1323 msgout
.serialBufferWithSize((uint8
*)bms
.buffer(), bms
.length());
1324 CUnifiedNetwork::getInstance()->send( TServiceId(id
.getDynamicId()), msgout
);
1328 catch(const CChatManager::EChatClient
&)
1330 nlwarning("cbGroupDynString : ignoring group message because entity info not available yet");
1332 } // cbGroupDynString //
1334 void cbPhrasePrepare( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1336 SM
->receivePhrase(msgin
, false, serviceName
);
1339 void cbPhrasePrepareDebug( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1341 SM
->receivePhrase(msgin
, true, serviceName
);
1344 void cbUserPhrasePrepare( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1346 SM
->receiveUserPhrase(msgin
, false);
1349 void cbUserPhrasePrepareDebug( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1351 SM
->receiveUserPhrase(msgin
, true);
1354 void cbBroadcastSystemPhrase( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1356 SM
->broadcastSystemMessage(msgin
, false);
1359 void cbBroadcastSystemPhraseDebug( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1361 SM
->broadcastSystemMessage(msgin
, true);
1364 // message STORE_STRING
1365 void cbStoreString( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1369 uint32 stringId
= SM
->storeString(str
);
1371 CMessage
msgOut("STORE_STRING_RESULT");
1373 msgOut
.serial(stringId
);
1375 CUnifiedNetwork::getInstance()->send(serviceId
, msgOut
);
1378 void cbGetString(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1381 msgin
.serial( nameIndex
);
1382 SM
->sendString( nameIndex
, serviceId
);
1385 void cbRetrieveEntityNames( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1387 SM
->retrieveEntityNames( serviceId
);
1390 void cbUserLanguage( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1393 TServiceId frontEndId
;
1395 msgin
.serial( userId
);
1396 msgin
.serial( frontEndId
);
1397 msgin
.serial( lang
);
1398 SM
->updateUserLanguage( userId
,frontEndId
, lang
);
1400 // Note: removeUserLanguage() is never called, currently
1403 void cbRemoveUserLanguage( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1406 msgin
.serial( userId
);
1407 SM
->removeUserLanguage( userId
);
1410 void cbIgnoreTellMode( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1412 NLMISC::CEntityId userId
;
1414 msgin
.serial( userId
);
1415 msgin
.serial( mode
);
1416 CChatManager
&cm
= IOS
->getChatManager();
1418 cm
.addUserIgnoringTells( userId
);
1420 cm
.removeUserIgnoringTells( userId
);
1423 void cbMutePlayer( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1425 NLMISC::CEntityId userId
;
1427 msgin
.serial( userId
);
1428 msgin
.serial( mode
);
1429 CChatManager
&cm
= IOS
->getChatManager();
1431 cm
.addMutedUser( userId
);
1433 cm
.removeMutedUser( userId
);
1436 void cbUniverseMode( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1438 NLMISC::CEntityId userId
;
1440 msgin
.serial( userId
);
1441 msgin
.serial( mode
);
1443 CChatGroup::TGroupType type
= (mode
)?CChatGroup::universe
: CChatGroup::say
;
1444 CCharacterInfos
* charInfos
= IOS
->getCharInfos( userId
);
1445 if( charInfos
!= NULL
)
1449 IOS
->getChatManager().getClient(TheDataset
.getDataSetRow(userId
)).setChatMode( type
);
1451 catch(const Exception
& e
)
1453 nlwarning("<impulsionChatMode> %s",e
.what());
1458 nlwarning("<impulsionChatMode> The character %s doesn't have infos",userId
.toString().c_str());
1462 void cbMuteUniverse( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1464 NLMISC::CEntityId userId
;
1466 msgin
.serial( userId
);
1467 msgin
.serial( mode
);
1468 CChatManager
&cm
= IOS
->getChatManager();
1470 cm
.addUniverseMutedUser(userId
);
1472 cm
.removeUniverseMutedUser(userId
);
1475 //-----------------------------------------------
1476 // cbEmoteCrowd : a crowd receive an emote ( e.g. : everybody except the main target )
1478 //-----------------------------------------------
1479 void cbEmoteCrowd( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1482 string phraseTextId
;
1483 TVectorParamCheck params
;
1484 vector
<TDataSetRow
> ignored
;
1486 CChatManager
&cm
= IOS
->getChatManager();
1490 msgin
.serial(sender
);
1491 msgin
.serial(phraseTextId
);
1494 params
.resize(size
);
1495 for ( uint i
= 0; i
< size
; i
++ )
1498 msgin
.serial( type8
);
1499 params
[i
].serialParam( false, msgin
, (STRING_MANAGER::TParamType
) type8
);
1501 msgin
.serialCont( ignored
);
1504 if ( sender
== TDataSetRow::createFromRawIndex(INVALID_DATASET_ROW
) )
1506 nlwarning("cbNpcChat : ignoring emote because PC %x Invalid", sender
.getIndex());
1510 cm
.sendEmoteTextToAudience(sender
, phraseTextId
, params
,ignored
);
1512 catch(const CChatManager::EChatClient
&)
1514 nlwarning("cbNpcChatEx : ignoring chat because NPC info not available yet");
1519 //-----------------------------------------------
1520 // cbEmoteSolePlayer : a unique receive an emote ( e.g. : the main target )
1522 //-----------------------------------------------
1523 void cbEmoteSolePlayer( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1528 msgin
.serial(sender
);
1529 msgin
.serial(target
);
1530 msgin
.serial(phraseId
);
1531 CChatManager
&cm
= IOS
->getChatManager();
1532 cm
.sendEmoteTextToPlayer(sender
, target
, phraseId
);
1536 //-----------------------------------------------
1538 //-----------------------------------------------
1539 void cbCustomEmote( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1542 ucstring emoteCustomText
;
1544 CChatManager
&cm
= IOS
->getChatManager();
1548 msgin
.serial(sender
);
1549 msgin
.serial(emoteCustomText
);
1551 // filter emote text
1552 emoteCustomText
= IOS
->getChatManager().filterClientInputColorCode(emoteCustomText
);
1555 if ( sender
== TDataSetRow::createFromRawIndex(INVALID_DATASET_ROW
) )
1557 nlwarning("<cbCustomEmote> ignoring emote because PC %x Invalid", sender
.getIndex());
1561 cm
.sendEmoteCustomTextToAll(sender
, emoteCustomText
);
1563 catch(const CChatManager::EChatClient
&)
1565 nlwarning("<cbCustomEmote> exception, ignoring emote");
1568 } // cbCustomEmote //
1572 //-----------------------------------------------
1573 // cbSetPhrase : change the content of a phrase
1575 //-----------------------------------------------
1576 void cbSetPhrase( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1578 SM
->setPhrase(msgin
);
1581 void cbSetPhraseLang( CMessage
& msgin
, const string
& serviceName
, TServiceId serviceId
)
1583 SM
->setPhraseLang(msgin
);
1586 //-----------------------------------------------
1587 // Add a new channel in the dyn chat
1589 //-----------------------------------------------
1590 void cbDynChatAddChan(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1598 msgin
.serial(chanID
);
1599 msgin
.serial(noBroadcast
);
1600 msgin
.serial(forwardInput
);
1601 msgin
.serial(unify
);
1604 nlinfo("cbDynChatAddChan: add channel : %s", name
.c_str());
1605 bool res
= IOS
->getChatManager().getDynChat().addChan(chanID
, noBroadcast
, forwardInput
, unify
);
1607 nlwarning("Couldn't add chan %s", chanID
.toString().c_str());
1610 if (_ChanNames
.getA(name
) != NULL
)
1611 _ChanNames
.removeWithB(name
);
1612 if (_ChanNames
.getB(chanID
) != NULL
)
1613 _ChanNames
.removeWithA(chanID
);
1614 _ChanNames
.add(chanID
, name
);
1615 nlinfo("cbDynChatAddChan: add channel %s",chanID
.toString().c_str());
1619 //-----------------------------------------------
1620 // Remove a channel from the dyn chat
1622 //-----------------------------------------------
1623 void cbDynChatRemoveChan(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1626 msgin
.serial(chanID
);
1627 bool res
= IOS
->getChatManager().getDynChat().removeChan(chanID
);
1628 if (res
&& _ChanNames
.getB(chanID
) != NULL
)
1629 _ChanNames
.removeWithA(chanID
);
1631 if (!res
) nlwarning("Couldn't remove chan %s", chanID
.toString().c_str());
1635 //-----------------------------------------------
1636 // Add a session to the dyn chat
1638 //-----------------------------------------------
1639 void addSession(TDataSetRow client
,TChanID chan
,bool writeRight
)
1642 if (!IOS
->getChatManager().checkClient(client
))
1643 IOS
->getChatManager().addClient( client
);
1645 CDynChatSession
*session
= IOS
->getChatManager().getDynChat().addSession(chan
, client
);
1648 nlwarning("Couldn't create session");
1652 session
->WriteRight
= writeRight
;
1653 // send channel historic to client
1654 IOS
->getChatManager().sendHistoric(client
, chan
);
1655 nldebug("IOS: session added %s:%x!! on channel %s",TheDataset
.getEntityId(client
).toString().c_str(),client
.getIndex(),chan
.toString().c_str());
1658 void cbDynChatAddSession(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1664 msgin
.serial(client
);
1665 msgin
.serial(writeRight
);
1666 addSession(client
,chan
,writeRight
);
1669 if (!IOS->getChatManager().checkClient(client))
1670 IOS->getChatManager().addClient( client );
1672 CDynChatSession *session = IOS->getChatManager().getDynChat().addSession(chan, client);
1675 nlwarning("Couldn't create session");
1679 session->WriteRight = writeRight;
1680 // send channel historic to client
1681 IOS->getChatManager().sendHistoric(client, chan);
1682 nlwarning("session added %s:%x!! on channel %s",TheDataset.getEntityId(client).toString().c_str(),client.getIndex(),chan.toString().c_str());
1686 //-----------------------------------------------
1687 // Add a session to the dyn chat, using the name of a npc
1688 // TODO: factorize some code with cbDynChatAddSession
1689 //-----------------------------------------------
1690 void cbDynChatAddSessionWithName(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1694 ucstring clientName
;
1697 msgin
.serial(clientName
);
1698 msgin
.serial(writeRight
);
1700 if(chan
.isUnknownId())
1702 nlwarning("unknown channel id! unable to add session!");
1705 CCharacterInfos
* cInfo
= IOS
->getCharInfos(clientName
);
1706 client
= cInfo
->DataSetIndex
;
1707 if(client
.isValid())
1709 addSession(client
,chan
,writeRight
);
1711 if (!IOS->getChatManager().checkClient(client))
1712 IOS->getChatManager().addClient( client );
1714 CDynChatSession *session = IOS->getChatManager().getDynChat().addSession(chan, client);
1717 nlwarning("Couldn't create session");
1721 session->WriteRight = writeRight;
1722 // send channel historic to client
1723 IOS->getChatManager().sendHistoric(client, chan);
1728 nlwarning("sender %s:%x invalid! unable to add session!",clientName
.c_str(),client
.getIndex());
1731 //-----------------------------------------------
1732 // Remove a session from the dyn chat
1734 //-----------------------------------------------
1735 void cbDynChatRemoveSession(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1740 msgin
.serial(client
);
1741 bool res
= IOS
->getChatManager().getDynChat().removeSession(chan
, client
);
1742 if (!res
) nlwarning("Couldn't remove session");
1745 //-----------------------------------------------
1746 // Remove a session from the dyn chat, using the name of the npc
1747 // TODO: factorize some code with cbDynChatRemoveSession
1748 //-----------------------------------------------
1749 void cbDynChatRemoveSessionWithName(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1752 ucstring clientName
;
1755 msgin
.serial(clientName
);
1756 CCharacterInfos
* cInfo
= IOS
->getCharInfos(clientName
);
1757 client
= cInfo
->DataSetIndex
;
1758 if(client
.isValid())
1761 CMessage msgout("DYN_CHAT:REMOVE_SESSION");
1762 msgout.serial(chan);
1763 msgout.serial(client);
1764 CUnifiedNetwork::getInstance()->send("EGS",msgout);
1767 bool res
= IOS
->getChatManager().getDynChat().removeSession(chan
, client
);
1768 if (!res
) nlwarning("Couldn't remove session");
1773 //-----------------------------------------------
1774 // Set read only flag for a dyn chat session
1776 //-----------------------------------------------
1777 void cbDynChatSetWriteRight(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1783 msgin
.serial(client
);
1784 msgin
.serial(writeRight
);
1785 CDynChatSession
*session
= IOS
->getChatManager().getDynChat().getSession(chan
, client
);
1788 nlwarning("Unknown session");
1791 session
->WriteRight
= writeRight
;
1794 //-----------------------------------------------
1795 // Set the historic size for a channel
1796 //-----------------------------------------------
1797 void cbDynChatSetHistoricSize(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1800 uint32 historicSize
;
1801 msgin
.serial(chanID
);
1802 msgin
.serial(historicSize
);
1803 CDynChatChan
*chan
= IOS
->getChatManager().getDynChat().getChan(chanID
);
1806 nlwarning("Unknown chan");
1809 chan
->Historic
.setMaxSize(historicSize
);
1811 void cbDynChatSetHideBubble(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1816 msgin
.serial(chanID
);
1817 msgin
.serial(hideBubble
);
1819 CChatManager
&cm
= IOS
->getChatManager();
1820 CDynChatChan
*chan
= cm
.getDynChat().getChan(chanID
);
1823 nlwarning("Unknown chan");
1826 chan
->HideBubble
= hideBubble
;
1829 void cbDynChatSetUniversalChannel(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1832 bool universalChannel
;
1834 msgin
.serial(chanID
);
1835 msgin
.serial(universalChannel
);
1837 CChatManager
&cm
= IOS
->getChatManager();
1838 CDynChatChan
*chan
= cm
.getDynChat().getChan(chanID
);
1841 nlwarning("Unknown chan");
1844 chan
->UniversalChannel
= universalChannel
;
1847 void cbDynChatServiceChat(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1851 ucstring senderName
;
1853 msgin
.serial(chanID
);
1854 msgin
.serial(senderName
);
1857 CChatManager
&cm
= IOS
->getChatManager();
1858 CDynChatChan
*chan
= cm
.getDynChat().getChan(chanID
);
1861 nlwarning("Unknown chan");
1865 // add msg to the historic
1866 CDynChatChan::CHistoricEntry entry
;
1867 entry
.String
= text
;
1868 entry
.SenderString
= senderName
;
1869 chan
->Historic
.push(entry
);
1871 // send the message to all the player in this chat
1872 CDynChatSession
*dcc
= chan
->getFirstSession();
1873 if(!dcc
) nlwarning(("nobody hears on channel "+chanID
.toString()).c_str());
1877 cm
.sendChat(CChatGroup::dyn_chat
, dcc
->getClient()->getID(), text
, TDataSetRow(), chanID
, senderName
);
1878 dcc
= dcc
->getNextChannelSession(); // next session in this channel
1882 void cbDynChatServiceTell(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1887 ucstring senderName
;
1889 msgin
.serial(chanID
);
1890 msgin
.serial(senderName
);
1891 msgin
.serial(player
);
1894 CChatManager
&cm
= IOS
->getChatManager();
1895 CDynChatChan
*chan
= cm
.getDynChat().getChan(chanID
);
1898 nlwarning("Unknown chan");
1902 // NB: we don't put 'tell' text in channel history
1904 // send the message to the designated player in this chat
1905 CDynChatSession
*dcc
= chan
->getFirstSession();
1908 if (dcc
->getClient()->getID() == player
)
1910 cm
.sendChat(CChatGroup::dyn_chat
, dcc
->getClient()->getID(), text
, TDataSetRow(), chanID
, senderName
);
1911 dcc
= dcc
->getNextChannelSession(); // next session in this channel
1912 // no more needed to continue
1915 dcc
= dcc
->getNextChannelSession(); // next session in this channel
1919 //-----------------------------------------------
1920 // Reset the dyn chat (all channel & sessions are removed)
1922 //-----------------------------------------------
1923 void cbDynChatReset(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1925 IOS
->getChatManager().getDynChat().removeAllChannels();
1928 //-----------------------------------------------
1929 // update the alias list
1931 //-----------------------------------------------
1932 void cbUpdateAIAlias(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1935 enum {Set
=0, Add
= 1, Delete
=2 };
1938 msgin
.serial(subcommand
);
1945 IOS
->getAIAliasManager().clear();
1954 for ( ;first
!= last
; ++first
)
1958 msgin
.serial(alias
);
1960 IOS
->getAIAliasManager().add(alias
, name
);
1970 nlwarning("<updateAlias> invalid message");
1976 void cbRequestDsr(CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1978 //CMessage msg("DSR_VALUE");
1982 CCharacterInfos
* cInfo
= IOS
->getCharInfos(name
);
1984 client
= cInfo
->DataSetIndex
;
1985 if(client
.isValid())
1987 CMessage
msg("DSR_VALUE");
1988 nlwarning("dsr value sent! %s = %s",name
.toString().c_str(),client
.toString().c_str());
1991 CUnifiedNetwork::getInstance()->send(serviceName
,msg
);
1996 void cbUserDontTranslateLanguages( CMessage
& msgin
, const string
&serviceName
, TServiceId serviceId
)
1999 msgin
.serial(player
);
2004 msgin
.serial(langs
);
2006 catch(const Exception
&e
)
2008 nlwarning("<impulsionTell> %s",e
.what());
2012 if (player
== INVALID_DATASET_ROW
)
2014 nlwarning("cbUserTranslateLanguage : ignoring chat because Player %s:%x Invalid",
2015 TheDataset
.getEntityId(player
).toString().c_str(),
2020 CChatManager
&cm
= IOS
->getChatManager();
2022 if (!cm
.checkClient(player
))
2023 IOS
->getChatManager().addClient(player
);
2025 CChatClient
&client
= cm
.getClient(player
);
2027 nlinfo("USER DISBALED TRANSLATIONS: %s", langs
.c_str());
2028 vector
<string
> vlangs
;
2029 NLMISC::splitString(langs
, "|", vlangs
);
2030 client
.resetDisabledTranslations();
2031 for (uint i
=0; i
<vlangs
.size(); i
++)
2033 if (vlangs
[i
].size() == 3)
2035 if (vlangs
[i
][0] == '>')
2036 client
.disableSendTranslation(vlangs
[i
].substr(1));
2037 else if (vlangs
[i
][0] == '<')
2038 client
.disableReceiveTranslation(vlangs
[i
].substr(1));
2044 //void cbAddDM(CMessage& msgin, const string &serviceName, TServiceId serviceId)
2047 // msgin.serial(charId);
2049 // // rebuild the entity id
2050 // CEntityId eid(RYZOMID::player, charId, 0, 0);
2051 // // retrieve the datasetrow
2052 // TDataSetRow rowId = TheDataset.getDataSetRow(eid);
2053 // if (rowId.isValid())
2055 // // we need to add it in the universe chat
2056 // IOS->getChatManager().addToGroup(TGroupId(RYZOMID::chatGroup, 0), rowId);
2060 //void cbRemoveDM(CMessage& msgin, const string &serviceName, TServiceId serviceId)
2063 // msgin.serial(charId);
2065 // // rebuild the entity id
2066 // CEntityId eid(RYZOMID::player, charId, 0, 0);
2067 // // retrieve the datasetrow
2068 // TDataSetRow rowId = TheDataset.getDataSetRow(eid);
2069 // if (rowId.isValid())
2071 // // we need to remove it from the universe chat
2072 // IOS->getChatManager().removeFromGroup(TGroupId(RYZOMID::chatGroup, 0), rowId);
2077 //----------------------------
2079 //----------------------------
2080 TUnifiedCallbackItem CbIOSArray
[]=
2082 // Received from clients (via FS)
2083 // { "READY_STRING", cbImpulsionReadyString },
2084 { "CLIENT:STRING:CHAT", cbImpulsionChat
},
2085 { "CLIENT:STRING:CHAT_TEAM", cbImpulsionChatTeam
},
2086 { "CLIENT:STRING:TELL", cbImpulsionTell
},
2087 { "CLIENT:STRING:FILTER", cbImpulsionFilter
},
2088 { "CLIENT:STRING:CHAT_MODE", cbImpulsionChatMode
},
2089 { "CLIENT:STRING:AFK_TXT", cbImpulsionAfkTxt
},
2090 // { "STRING_RQ_ID", cbImpulsionStringRqId },
2091 { "STRING_RQ_UID", cbImpulsionStringRqUid
},
2093 // Received from the back-end
2094 { "STATIC_STRING", cbStaticString
},
2095 { "CHAT_MESSAGE", cbChatMessage
},
2096 { "CHARACTER_NAME", cbCharacterName
}, // receive a character name
2097 { "CHARACTER_NAME_ID", cbCharacterNameId
}, // receive a character name with a string manager string Id
2098 { "CHARACTER_NAME_LANG", cbCharacterNameAndLang
}, // receive a character name and a language code (for player)
2099 { "CHARACTER_EVENT_FACTION", cbCharacterEventFaction
},
2100 { "ADD_GROUP", cbAddGroup
},
2101 { "ADD_NAMED_GROUP", cbAddNamedGroup
},
2102 { "REMOVE_GROUP", cbRemoveGroup
},
2103 { "ADD_TO_GROUP", cbAddToGroup
},
2104 { "REMOVE_FROM_GROUP", cbRemoveFromGroup
},
2105 // { "SEND_DYNAMIC_ID", cbSendDynamicId },
2106 { "CHAT", cbSysChat
}, // talk to a user or a whole group
2108 { "NPC_CHAT", cbNpcChat
}, // Npc talk to a chat group
2109 { "NPC_CHAT_PARAM", cbNpcChatParam
}, // Npc talk to a chat group (with parameter)
2111 { "NPC_TELL", cbNpcTell
}, // Npc tell to a player
2112 { "GHOST_TELL", cbGhostTell
}, // Npc tell to a player, without Npc :)
2114 { "NPC_TELL_EX", cbNpcTellEx
}, // Extended Npc tell to a player. Receive a stringId (uint32), obtained through the PHRASE message for example
2115 { "NPC_CHAT_EX", cbNpcChatEx
}, // Extended Npc chat . Receive a stringId (uint32), obtained through the PHRASE message for example
2116 { "NPC_CHAT_SENTENCE", cbNpcChatSentence
}, //Npc chat. receive the sentence to chat
2117 { "NPC_CHAT_SENTENCE_CHANNEL",cbNpcChatSentenceChannel
},
2118 { "NPC_CHAT_SENTENCE_EX",cbNpcChatSentenceEx
},//Npc chat. receive the name of the npc which talks, and the sentence
2120 { "GROUP_DYN_STRING", cbGroupDynString
}, // send a system dynamic string to a group
2121 { "PHRASE", cbPhrasePrepare
},
2122 { "PHRASE_DEBUG", cbPhrasePrepareDebug
},
2123 { "PHRASE_USER", cbUserPhrasePrepare
},
2124 { "PHRASE_USER_DEBUG", cbUserPhrasePrepareDebug
},
2125 { "BROADCAST_SYSTEM_PHRASE", cbBroadcastSystemPhrase
},
2126 { "BROADCAST_SYSTEM_PHRASE_DEBUG", cbBroadcastSystemPhraseDebug
},
2127 { "STORE_STRING", cbStoreString
},
2128 { "GET_STRING", cbGetString
},
2129 { "RETR_ENTITY_NAMES", cbRetrieveEntityNames
},
2130 { "USER_LANGUAGE", cbUserLanguage
}, // receive an association between a userId and a language
2131 { "REMOVE_USER_LANGUAGE", cbRemoveUserLanguage
},
2132 { "SET_USER_DONT_TRANSLATE_LANGS", cbUserDontTranslateLanguages
},
2134 { "IGNORE_TELL_MODE", cbIgnoreTellMode
}, // receive an ignore tell mode command from EGS
2135 { "IGNORE", cbImpulsionIgnore
},
2136 { "UNIGNORE", cbImpulsionUnignore
},
2137 { "UNIGNORE_ALL", cbImpulsionUnignoreAll
},
2138 { "MUTE_PLAYER", cbMutePlayer
}, // receive a mute player command from EGS
2139 { "UNIVERSE_MODE", cbUniverseMode
}, // receive a universe mode command from EGS
2140 { "MUTE_UNIVERSE", cbMuteUniverse
}, // received a mute universe channel from EGS
2142 { "EMOTE_CROWD", cbEmoteCrowd
}, // EGS wants IOS to dispatch an emote texte to all users around the "emoting" player
2143 { "EMOTE_PLAYER", cbEmoteSolePlayer
}, // EGS wants IOS to dispatch an emote texte to a unique player
2144 { "CUSTOM_EMOTE", cbCustomEmote
}, // EGS wants IOS to dispatch an emote custom text to all users around
2146 { "SET_PHRASE", cbSetPhrase
}, // AIS wants IOS to change a phrase content
2147 { "SET_PHRASE_LANG", cbSetPhraseLang
}, // AIS or EGS wants IOS to change a phrase content for a language
2149 { "UPDATE_AIALIAS", cbUpdateAIAlias
},
2151 // Dyn chat, received from egs
2152 { "DYN_CHAT:ADD_CHAN", cbDynChatAddChan
},
2153 { "DYN_CHAT:REMOVE_CHAN", cbDynChatRemoveChan
},
2154 { "DYN_CHAT:ADD_SESSION", cbDynChatAddSession
},
2155 { "DYN_CHAT:ADD_SESSION_WITH_NAME", cbDynChatAddSessionWithName
},//add a session, receive a npc name
2156 { "DYN_CHAT:REMOVE_SESSION", cbDynChatRemoveSession
},
2157 { "DYN_CHAT:REMOVE_SESSION_WITH_NAME", cbDynChatRemoveSessionWithName
},//remove a session, receive a npc name
2158 { "DYN_CHAT:SET_WRITE_RIGHT", cbDynChatSetWriteRight
},
2160 { "DYN_CHAT:RESET", cbDynChatReset
},
2161 { "DYN_CHAT:SET_HISTORIC_SIZE", cbDynChatSetHistoricSize
},
2162 { "DYN_CHAT:SERVICE_CHAT", cbDynChatServiceChat
}, // a service send a chat message in the channel without sender id
2163 { "DYN_CHAT:SERVICE_TELL", cbDynChatServiceTell
}, // a service send a chat message to a specific client in the channel without sender id
2164 { "DYN_CHAT:SET_HIDE_BUBBLE", cbDynChatSetHideBubble
}, // a service send a chat message to a specific client in the channel without sender id
2165 { "DYN_CHAT:SET_UNIVERSAL_CHANNEL", cbDynChatSetUniversalChannel
},
2167 { "REQUEST_DSR", cbRequestDsr
},
2168 // { "ADD_DM", cbAddDM }, // A character enter a ring session that he own
2169 // { "REMOVE_DM", cbRemoveDM } // A character leave a DSS
2173 //-------------------------------------------------------------------------
2174 // singleton initialisation and release
2176 void CMessages::init()
2178 // setup the callback array
2179 CUnifiedNetwork::getInstance()->addCallbackArray( CbIOSArray
, sizeof(CbIOSArray
)/sizeof(CbIOSArray
[0]) );
2182 void CMessages::release()