Add infos into target window
[ryzomcore.git] / ryzom / server / src / entities_game_service / client_messages.cpp
blob38c78f8b1052361b6bca83d0e3d5ebbaa4e98e8f
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019-2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "stdpch.h"
24 //net
25 #include "nel/net/message.h"
26 #include "nel/misc/command.h"
27 #include "nel/misc/algo.h"
28 #include "nel/misc/common.h"
29 //game_share
30 #include "game_share/generic_xml_msg_mngr.h"
31 #include "game_share/sphrase_com.h"
32 #include "game_share/security_check.h"
33 #include "server_share/log_item_gen.h"
34 //egs
35 #include "client_messages.h"
36 #include "player_manager/player_manager.h"
37 #include "player_manager/player.h"
38 #include "player_manager/character.h"
39 #include "entity_manager/entity_callbacks.h"
40 #include "phrase_manager/phrase_manager_callbacks.h"
41 #include "zone_manager.h"
42 #include "phrase_manager/phrase_manager.h"
43 #include "mission_manager/mission_queue_manager.h"
44 #include "building_manager/building_manager.h"
45 #include "team_manager/team_manager.h"
46 #include "creature_manager/creature_manager.h"
47 #include "egs_sheets/egs_sheets.h"
48 #include "pvp_manager/pvp_manager.h"
49 #include "pvp_manager/pvp_manager_2.h"
50 #include "pvp_manager/pvp.h"
51 #include "building_manager/room_instance.h"
52 #include "player_manager/gear_latency.h"
53 #include "outpost_manager/outpost_manager.h"
54 #include "pvp_manager/pvp_faction_reward_manager/pvp_faction_reward_manager.h"
55 #include "guild_manager/guild_member.h"
56 #include "guild_manager/guild.h"
57 #include "guild_manager/guild_manager.h"
58 #include "modules/r2_mission_item.h"
59 #include "modules/r2_give_item.h"
60 #include "game_share/scenario.h"
61 #include "server_share/r2_vision.h"
63 using namespace NLMISC;
64 using namespace NLNET;
65 using namespace std;
67 extern CGenericXmlMsgHeaderManager GenericMsgManager;
69 CVariable<bool> BuildSpireActive( "egs", "BuildSpireActive", "Activate build spire", true, 0, true );
72 ///////////////////////////////////////////////////////////////////////////////////////////////////
73 ///////////////////////////////////////////////////////////////////////////////////////////////////
74 // CLIENT:ITEM
75 ///////////////////////////////////////////////////////////////////////////////////////////////////
76 ///////////////////////////////////////////////////////////////////////////////////////////////////
79 void cbClientItemDrop( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
81 cbItemDrop(msgin, serviceName, serviceId);
86 void cbClientItemPickUpClose( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
88 cbItemClosePickup(msgin, serviceName, serviceId);
92 void cbClientItemSwap( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
94 cbItemSwap(msgin, serviceName, serviceId);
98 void cbClientItemHarvest( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
100 cbHarvest(msgin, serviceName, serviceId);
104 void cbClientItemHarvestClose( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
106 cbHarvestClose(msgin, serviceName, serviceId);
110 void cbClientItemEquip( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
112 H_AUTO(cbClientItemEquip);
114 uint16 equippedInventory, equippedSlot, bagSlot;
115 CEntityId id;
119 msgin.serial( id );
120 msgin.serial( equippedInventory );
121 msgin.serial( equippedSlot );
122 msgin.serial( bagSlot );
124 catch(const Exception &e)
126 nlwarning("Bad cbClientItemEquip serialisation '%s'", e.what());
127 return;
131 CCharacter *c = (CCharacter * ) CEntityBaseManager::getEntityBasePtr( id );
132 if( c )
134 c->setAfkState(false);
135 c->incInterfaceCounter();
137 // if player is stunned or dead cancel action
138 if (c->isDead() || c->isStunned())
139 return;
140 c->equipCharacter( INVENTORIES::TInventory(equippedInventory), equippedSlot, bagSlot, false );
145 void cbClientItemUnequip( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
147 H_AUTO(cbClientItemUnequip);
149 uint16 equippedInventory, equippedSlot;
150 CEntityId id;
153 msgin.serial( id );
154 msgin.serial( equippedInventory );
155 msgin.serial( equippedSlot );
157 catch(const Exception &e)
159 nlwarning("Bad cbClientItemUnequip serialisation '%s'", e.what());
160 return;
163 CCharacter *c = (CCharacter * ) CEntityBaseManager::getEntityBasePtr( id );
164 if( c )
166 c->setAfkState(false);
167 c->incInterfaceCounter();
169 // if player is stunned or dead cancel action
170 if (c->isDead() || c->isStunned())
171 return;
173 c->unequipCharacter( INVENTORIES::TInventory(equippedInventory), equippedSlot, false );
178 //----------------------------
179 // cbItemDestroy
180 //----------------------------
181 void cbClientItemDestroy( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
183 H_AUTO(cbClientItemDestroy);
185 CEntityId user;
186 uint16 inventory,slot,quantity;
190 msgin.serial(user);
191 msgin.serial(inventory);
192 msgin.serial(slot);
193 msgin.serial(quantity);
195 catch(const Exception &e)
197 nlwarning("Bad cbClientItemDestroy serialisation '%s'", e.what());
198 return;
201 CCharacter *character = PlayerManager.getChar( user );
202 if (character == NULL)
204 nlwarning("<cbItemDestroy> Invalid player Id %s", user.toString().c_str() );
205 return;
208 // check character is ready
209 if (!character->getEnterFlag())
211 nlwarning("<cbItemDestroy> player Id %s not yet ready", user.toString().c_str() );
212 return;
215 character->setAfkState(false);
216 character->destroyItem( INVENTORIES::TInventory(inventory), slot, quantity, true );
219 // take an item from temp inventory to bag
220 void cbClientItemTempToBag( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
222 H_AUTO(cbClientItemTempToBag);
224 CEntityId user;
225 uint16 slot;
229 msgin.serial(user);
230 msgin.serial(slot);
232 catch(const Exception &e)
234 nlwarning("Bad cbClientItemTempToBag serialisation '%s'", e.what());
235 return;
238 CCharacter *character = PlayerManager.getChar( user );
239 if (character == NULL)
241 nlwarning("<cbClientItemTempToBag> Invalid player Id %s", user.toString().c_str() );
242 return;
245 // check character is ready
246 if (!character->getEnterFlag())
248 nlwarning("<cbClientItemTempToBag> player Id %s not yet ready", user.toString().c_str() );
249 return;
252 character->setAfkState(false);
253 character->itemTempInventoryToBag( slot );
254 vector<string> params = character->getCustomMissionParams("__TAKE_TEMP_INV__");
255 if (params.size() >= 2)
257 character->validateDynamicMissionStep(params[0]+"&take_items=one");
258 character->setCustomMissionParams("__TAKE_TEMP_INV__", "");
262 // get all item from temp inventory
263 void cbClientItemAllTemp( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
265 H_AUTO(cbClientItemAllTemp);
267 CEntityId user;
270 msgin.serial(user);
272 catch(const Exception &e)
274 nlwarning("Bad cbClientItemAllTemp serialisation '%s'", e.what());
275 return;
278 CCharacter *character = PlayerManager.getChar( user );
279 if (character == NULL)
281 nlwarning("<cbClientItemAllTemp> Invalid player Id %s", user.toString().c_str() );
282 return;
284 // check character is ready
285 if (!character->getEnterFlag())
287 nlwarning("<cbClientItemAllTemp> player Id %s not yet ready", user.toString().c_str() );
288 return;
291 character->setAfkState(false);
292 character->sendCloseTempInventoryImpulsion();
293 vector<string> params = character->getCustomMissionParams("__TAKE_TEMP_INV__");
294 if (params.size() >= 2)
296 character->validateDynamicMissionStep(params[0]+"&take_items=all");
297 character->setCustomMissionParams("__TAKE_TEMP_INV__", "");
301 // clear temp inventory
302 void cbClientItemNoTemp( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
304 H_AUTO(cbClientItemNoTemp);
306 CEntityId user;
309 msgin.serial(user);
311 catch(const Exception &e)
313 nlwarning("Bad cbClientItemNoTemp serialisation '%s'", e.what());
314 return;
317 CCharacter *character = PlayerManager.getChar( user );
318 if (character == NULL)
320 nlwarning("<cbClientItemNoTemp> Invalid player Id %s", user.toString().c_str() );
321 return;
323 // check character is ready
324 if (!character->getEnterFlag())
326 nlwarning("<cbClientItemAllTemp> player Id %s not yet ready", user.toString().c_str() );
327 return;
330 TLogContext_Item_DropTempInventory dropTemp(user);
332 character->setAfkState(false);
333 character->clearTempInventory();
334 vector<string> params = character->getCustomMissionParams("__TAKE_TEMP_INV__");
335 if (params.size() >= 2)
337 character->validateDynamicMissionStep(params[0]+"&take_items=none");
338 character->setCustomMissionParams("__TAKE_TEMP_INV__", "");
342 // Enchant or recharge an item
343 void cbClientItemEnchant( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
345 H_AUTO(cbClientItemEnchant);
347 CEntityId user;
348 uint8 inv;
349 uint16 slot;
353 msgin.serial(user);
354 msgin.serial(inv, slot);
356 catch(const Exception &e)
358 nlwarning("Bad cbClientItemEnchant serialisation '%s'", e.what());
359 return;
362 CCharacter *character = PlayerManager.getChar( user );
363 if (character == NULL)
365 nlwarning("<cbClientItemEnchant> Invalid player Id %s", user.toString().c_str() );
366 return;
368 // check character is ready
369 if (!character->getEnterFlag())
371 nlwarning("<cbClientItemEnchant> player Id %s not yet ready", user.toString().c_str() );
372 return;
375 // if player is dead or stunned don't reload or enchant
376 if (character->isDead() || character->isStunned())
377 return;
379 character->enchantOrRechargeItem( (INVENTORIES::TInventory) inv, slot );
380 character->setAfkState(false);
383 // use a tp item
384 void cbClientItemUseItem( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
386 H_AUTO(cbClientItemUseItem);
388 CEntityId user;
389 msgin.serial(user);
391 uint16 slot;
392 msgin.serial(slot);
394 CCharacter *character = PlayerManager.getChar( user );
395 if (character == NULL)
397 nlwarning("<USEITEM> Invalid player Id %s", user.toString().c_str() );
398 return;
400 // check character is ready
401 if (!character->getEnterFlag())
403 nlwarning("<USEITEM> player Id %s not yet ready", user.toString().c_str() );
404 return;
407 character->useItem(slot);
410 void cbClientItemStopUseXpCat( CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
412 H_AUTO(cbClientItemStopUseXpCat);
414 CEntityId user;
415 msgin.serial(user);
417 bool isRingCatalyser;
418 msgin.serial(isRingCatalyser);
420 CCharacter *character = PlayerManager.getChar( user );
421 if (character == NULL)
423 nlwarning("<cbClientItemStopUseXpCat> Invalid player Id %s", user.toString().c_str() );
424 return;
426 // check character is ready
427 if (!character->getEnterFlag())
429 nlwarning("<cbClientItemStopUseXpCat> player Id %s not yet ready", user.toString().c_str() );
430 return;
433 character->stopUseItem( isRingCatalyser );
437 ///////////////////////////////////////////////////////////////////////////////////////////////////
438 ///////////////////////////////////////////////////////////////////////////////////////////////////
439 // CLIENT:HARVEST
440 ///////////////////////////////////////////////////////////////////////////////////////////////////
441 ///////////////////////////////////////////////////////////////////////////////////////////////////
443 void cbClientHarvestDeposit( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
445 cbHarvestDeposit(msgin, serviceName, serviceId);
449 ///////////////////////////////////////////////////////////////////////////////////////////////////
450 ///////////////////////////////////////////////////////////////////////////////////////////////////
451 // CLIENT:PHRASE
452 ///////////////////////////////////////////////////////////////////////////////////////////////////
453 ///////////////////////////////////////////////////////////////////////////////////////////////////
455 // execute client sentence
456 void cbClientPhraseExecute( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
458 H_AUTO(cbClientPhraseExecute);
460 CEntityId Id;
461 msgin.serial( Id );
463 uint8 set,slot;
464 msgin.serial(set,slot);
466 CCharacter *ch = PlayerManager.getChar( Id );
467 if ( !ch )
469 nlwarning("<cbClientPhraseExecute> Unknown character %s", Id.toString().c_str() );
470 return;
472 // check character is ready
473 if (!ch->getEnterFlag())
475 nlwarning("<cbClientPhraseExecute> player Id %s not yet ready", Id.toString().c_str() );
476 return;
479 ch->executeMemorizedPhrase( set, slot, false , false);
480 ch->setAfkState(false);
485 void cbClientPhraseExecuteCyclic( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
487 H_AUTO(cbClientPhraseExecuteCyclic);
489 CEntityId Id;
490 msgin.serial( Id );
492 uint8 set,slot;
493 msgin.serial(set,slot);
495 CCharacter *ch = PlayerManager.getChar( Id );
496 if ( !ch )
498 nlwarning("<cbClientPhraseExecuteCyclic> Unknown character %s", Id.toString().c_str() );
499 return;
501 // check character is ready
502 if (!ch->getEnterFlag())
504 nlwarning("<cbClientPhraseExecuteCyclic> player Id %s not yet ready", Id.toString().c_str() );
505 return;
508 ch->setAfkState(false);
509 ch->executeMemorizedPhrase( set, slot, true,false );
514 void cbClientPhraseExecuteFaber( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
516 H_AUTO(cbClientPhraseExecuteFaber);
518 CEntityId Id;
519 msgin.serial( Id );
521 NLMISC::CSheetId craftPlan;
522 msgin.serial( craftPlan );
524 uint8 set,slot;
525 msgin.serial(set,slot);
527 CCharacter *ch = PlayerManager.getChar( Id );
528 if ( !ch )
530 nlwarning("Unknown character %s", Id.toString().c_str() );
531 return;
533 // check character is ready
534 if (!ch->getEnterFlag())
536 nlwarning("player Id %s not yet ready", Id.toString().c_str() );
537 return;
541 if ( ch->getKnownBricks().find( craftPlan ) == ch->getKnownBricks().end())
543 string name = CEntityIdTranslator::getInstance()->getByEntity(Id).toString();
544 nlwarning("HACK: %s %s tries to craft a brick he doesn't know %s", Id.toString().c_str(), name.c_str(), craftPlan.toString().c_str());
545 return;
548 ch->abortExchange();
550 ch->setCraftPlan( craftPlan );
552 ch->clearFaberRms();
553 msgin.serialCont( ch->getFaberRmsNoConst() );
554 msgin.serialCont( ch->getFaberRmsFormulaNoConst() );
556 ch->executeMemorizedPhrase( set, slot, false,false );
557 ch->setAfkState(false);
562 void cbClientPhraseMemorize( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
564 H_AUTO(cbClientPhraseMemorize);
566 CEntityId Id;
567 msgin.serial( Id );
569 uint8 set,slot;
570 msgin.serial(set, slot);
572 uint16 phraseId;
573 msgin.serial( phraseId );
575 CSPhraseCom phraseDesc;
576 msgin.serial( phraseDesc );
578 CCharacter *ch = PlayerManager.getChar( Id );
579 if ( !ch )
581 nlwarning("<cbClientPhraseMemorize> Unknown character %s", Id.toString().c_str() );
582 return;
584 // check character is ready
585 if (!ch->getEnterFlag())
587 nlwarning("<cbClientPhraseMemorize> player Id %s not yet ready", Id.toString().c_str() );
588 return;
591 // memorize
592 ch->memorize(set, slot,phraseId,phraseDesc.Bricks);
593 ch->setAfkState(false);
597 void cbClientPhraseForget( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
599 H_AUTO(cbClientPhraseForget);
601 CEntityId Id;
602 msgin.serial( Id );
604 uint8 set,slot;
605 msgin.serial(set,slot);
607 CCharacter *ch = PlayerManager.getChar( Id );
608 if ( !ch )
610 nlwarning("<cbClientPhraseForget> Unknown character %s", Id.toString().c_str() );
611 return;
613 // check character is ready
614 if (!ch->getEnterFlag())
616 nlwarning("<cbClientPhraseForget> player Id %s not yet ready", Id.toString().c_str() );
617 return;
620 ch->forgetPhrase( set, slot);
621 ch->setAfkState(false);
625 void cbClientPhraseDelete( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
627 H_AUTO(cbClientPhraseDelete);
629 CEntityId Id;
630 msgin.serial( Id );
632 uint16 phraseId;
633 msgin.serial( phraseId );
635 CCharacter *ch = PlayerManager.getChar( Id );
636 if ( !ch )
638 nlwarning("<cbClientPhraseDelete> Unknown character %s", Id.toString().c_str() );
639 return;
641 // check character is ready
642 if (!ch->getEnterFlag())
644 nlwarning("<cbClientPhraseDelete> player Id %s not yet ready", Id.toString().c_str() );
645 return;
648 ch->deleteKnownPhrase(phraseId);
649 ch->setAfkState(false);
653 void cbClientPhraseLearn( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
655 H_AUTO(cbClientPhraseLearn);
657 CEntityId Id;
658 msgin.serial( Id );
660 uint16 phraseId;
661 msgin.serial( phraseId );
663 CSPhraseCom phrase;
664 msgin.serial( phrase );
666 CCharacter *ch = PlayerManager.getChar( Id );
667 if ( !ch )
669 nlwarning("<cbClientPhraseLearn> Unknown character %s", Id.toString().c_str() );
670 return;
672 // check character is ready
673 if (!ch->getEnterFlag())
675 nlwarning("<cbClientPhraseLearn> player Id %s not yet ready", Id.toString().c_str() );
676 return;
679 ch->learnPhrase( phrase.Bricks, phraseId, phrase.Name, phrase.IconIndex );
680 ch->setAfkState(false);
684 void cbClientPhraseBuyByIndex( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
686 H_AUTO(cbClientPhraseBuyByIndex);
688 CEntityId Id;
689 msgin.serial( Id );
691 uint8 botChatIndex;
692 msgin.serial( botChatIndex );
694 uint16 phraseId;
695 msgin.serial( phraseId );
697 CCharacter *ch = PlayerManager.getChar( Id );
698 if ( !ch )
700 nlwarning("<cbClientPhraseBuyByIndex> Unknown character %s", Id.toString().c_str() );
701 return;
703 // check character is ready
704 if (!ch->getEnterFlag())
706 nlwarning("<cbClientPhraseBuyByIndex> player Id %s not yet ready", Id.toString().c_str() );
707 return;
710 ch->incInterfaceCounter();
711 ch->buyPhraseByIndex( botChatIndex, phraseId);
712 ch->setAfkState(false);
715 void cbClientPhraseBuyBySheet( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
717 H_AUTO(cbClientPhraseBuyBySheet);
719 CEntityId Id;
720 msgin.serial( Id );
722 CSheetId phraseSheetId;
723 uint32 val;
724 msgin.serial( val );
725 phraseSheetId = val;
727 uint16 index;
728 msgin.serial( index );
730 CCharacter *ch = PlayerManager.getChar( Id );
731 if ( !ch )
733 nlwarning("<cbClientPhraseBuyBySheet> Unknown character %s", Id.toString().c_str() );
734 return;
736 // check character is ready
737 if (!ch->getEnterFlag())
739 nlwarning("<cbClientPhraseBuyBySheet> player Id %s not yet ready", Id.toString().c_str() );
740 return;
743 ch->incInterfaceCounter();
744 ch->buyPhraseBySheet(phraseSheetId,index);
745 ch->setAfkState(false);
748 void cbClientPhraseCancelTop( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
750 H_AUTO(cbClientPhraseCancelTop);
752 if ( ! Mirror.mirrorIsReady() )
754 nlwarning("<cbClientPhraseCancelTop> Received from %s service but mirror not yet ready", serviceName.c_str() );
755 return;
758 NLMISC::CEntityId entityId;
759 msgin.serial( entityId );
761 TDataSetRow entityRowId = TheDataset.getDataSetRow(entityId);
763 CPhraseManager::getInstance().cancelTopPhrase(entityRowId);
764 } // cbClientPhraseCancelTop //
766 void cbClientPhraseCancelAll( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
768 H_AUTO(cbClientPhraseCancelAll);
770 if ( ! Mirror.mirrorIsReady() )
772 nlwarning("<cbClientPhraseCancelAll> Received from %s service but mirror not yet ready", serviceName.c_str() );
773 return;
776 NLMISC::CEntityId entityId;
777 msgin.serial( entityId );
779 TDataSetRow entityRowId = TheDataset.getDataSetRow(entityId);
781 CPhraseManager::getInstance().cancelAllPhrases(entityRowId);
782 } // cbClientPhraseCancelAll //
784 void cbClientPhraseCristalize( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
786 H_AUTO(cbClientPhraseCristalize);
788 CEntityId Id;
789 msgin.serial( Id );
791 uint8 set,slot;
792 msgin.serial(set,slot);
794 CCharacter *ch = PlayerManager.getChar( Id );
795 if ( !ch )
797 nlwarning("<cbClientPhraseCristalize> Unknown character %s", Id.toString().c_str() );
798 return;
800 // check character is ready
801 if (!ch->getEnterFlag())
803 nlwarning("<cbClientPhraseCristalize> player Id %s not yet ready", Id.toString().c_str() );
804 return;
807 ch->executeMemorizedPhrase( set, slot, false, true );
808 ch->setAfkState(false);
811 ///////////////////////////////////////////////////////////////////////////////////////////////////
812 ///////////////////////////////////////////////////////////////////////////////////////////////////
813 // CLIENT:COMBAT
814 ///////////////////////////////////////////////////////////////////////////////////////////////////
815 ///////////////////////////////////////////////////////////////////////////////////////////////////
818 void cbClientCombatEngage( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
820 cbEngage(msgin, serviceName, serviceId);
824 void cbClientCombatDisengage( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
826 cbDisengage( msgin, serviceName, serviceId);
830 void cbClientCombatDefaultAttack( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
832 cbDefaultAttack(msgin, serviceName, serviceId);
836 void cbClientValidateMeleeCombat( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
838 H_AUTO(cbClientValidateMeleeCombat);
840 CEntityId idPlayer;
841 msgin.serial( idPlayer );
843 uint8 flag;
844 msgin.serial(flag);
846 CCharacter *ch = PlayerManager.getChar( idPlayer );
847 if ( ch && ch->getEnterFlag() )
849 ch->validateMeleeCombat(flag != 0);
850 //ch->setAfkState(false);
854 void cbClientCombatProtectedSlot( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
856 H_AUTO(cbClientCombatProtectedSlot);
858 CEntityId idPlayer;
859 msgin.serial( idPlayer );
861 uint8 slot;
862 msgin.serial( slot );
864 CCharacter *ch = PlayerManager.getChar( idPlayer );
865 if ( ch && ch->getEnterFlag() )
867 ch->protectedSlot( SLOT_EQUIPMENT::TSlotEquipment(slot) );
868 ch->setAfkState(false);
872 void cbClientCombatParry( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
874 H_AUTO(cbClientCombatParry);
876 CEntityId idPlayer;
877 msgin.serial( idPlayer );
879 CCharacter *ch = PlayerManager.getChar( idPlayer );
880 if ( ch && ch->getEnterFlag() )
882 ch->dodgeAsDefense( false );
883 ch->setAfkState(false);
887 void cbClientCombatDodge( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
889 H_AUTO(cbClientCombatDodge);
891 CEntityId idPlayer;
892 msgin.serial( idPlayer );
894 CCharacter *ch = PlayerManager.getChar( idPlayer );
895 if ( ch && ch->getEnterFlag() )
897 ch->dodgeAsDefense( true );
898 ch->setAfkState(false);
902 void cbClientAutoPact( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
904 H_AUTO(cbClientAutoPact);
906 CEntityId charId;
907 msgin.serial(charId);
909 bool activate = false;
911 CCharacter *character = PlayerManager.getChar(charId);
912 if (character && character->getEnterFlag())
914 uint8 bval;
915 msgin.serial(bval);
917 if (bval)
918 activate = true;
919 character->doPact(activate);
921 else
922 nlwarning("%s is invalid", charId.toString().c_str());
926 ///////////////////////////////////////////////////////////////////////////////////////////////////
927 ///////////////////////////////////////////////////////////////////////////////////////////////////
928 // CLIENT:LEAGUE
929 ///////////////////////////////////////////////////////////////////////////////////////////////////
930 ///////////////////////////////////////////////////////////////////////////////////////////////////
933 void cbClientLeagueJoin( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
935 cbJoinLeague(msgin, serviceName, serviceId);
939 void cbClientLeagueJoinProposal( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
941 cbJoinLeagueProposal(msgin, serviceName, serviceId);
945 void cbClientLeagueJoinProposalDecline( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
947 cbJoinLeagueDecline(msgin, serviceName, serviceId);
951 ///////////////////////////////////////////////////////////////////////////////////////////////////
952 ///////////////////////////////////////////////////////////////////////////////////////////////////
953 // CLIENT:TEAM
954 ///////////////////////////////////////////////////////////////////////////////////////////////////
955 ///////////////////////////////////////////////////////////////////////////////////////////////////
958 void cbClientTeamLeave( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
960 cbLeaveTeam(msgin, serviceName, serviceId);
964 void cbClientTeamJoin( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
966 cbJoinTeam(msgin, serviceName, serviceId);
970 void cbClientTeamKick( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
972 cbKickTeammate(msgin, serviceName, serviceId);
976 void cbClientTeamJoinProposal( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
978 cbJoinTeamProposal(msgin, serviceName, serviceId);
982 void cbClientTeamJoinProposalDecline( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
984 cbJoinTeamDecline(msgin, serviceName, serviceId);
987 void cbClientTeamSetSuccessor( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
989 H_AUTO(cbClientTeamSetSuccessor);
991 CEntityId id;
992 uint8 idx;
993 msgin.serial(id);
994 msgin.serial(idx);
995 CCharacter* user = PlayerManager.getChar( id );
996 if ( !user )
998 nlwarning("<TEAM> Invalid user %s",id.toString().c_str() );
999 return;
1001 CTeam * team = TeamManager.getTeam( user->getTeamId() );
1002 if ( !team )
1004 nlwarning("<TEAM> Invalid team for user %s",id.toString().c_str() );
1005 return;
1007 if ( team->getLeader() != id )
1009 nlwarning("<TEAM> user %s is not leader: cant set successor",id.toString().c_str() );
1010 return;
1012 if (team->getSuccessor() == id)
1014 nlwarning("<TEAM> user %s already is successor", id.toString().c_str() );
1015 return;
1018 // increment the target index as the leader is not in its team list
1019 ++idx;
1020 team->setSuccessor( idx );
1024 void cbClientTeamShareValidItem( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1026 H_AUTO(cbClientTeamShareValidItem);
1028 CEntityId id;
1029 msgin.serial(id);
1030 CCharacter * user = PlayerManager.getChar(id);
1031 if ( !user )
1033 nlwarning("<cbClientTeamShareValidItem>invalid char %s",id.toString().c_str());
1034 return;
1036 // check character is ready
1037 if (!user->getEnterFlag())
1039 nlwarning("<cbClientTeamShareValidItem> player Id %s not yet ready", id.toString().c_str() );
1040 return;
1043 user->setAfkState(false);
1044 CTeam * team = TeamManager.getRealTeam(user->getTeamId());
1045 if (!team)
1047 nlwarning("<cbClientTeamShareValidItem>char %s has no valid team",id.toString().c_str());
1048 return;
1050 if ( !team->getReward() )
1052 nlwarning("<cbClientTeamShareValidItem>char %s: his team has no reward",id.toString().c_str());
1053 return;
1056 uint8 pos,state;
1057 msgin.serial(pos);
1058 msgin.serial(state);
1059 team->getReward()->userItemSelect(user->getEntityRowId(),pos,state);
1062 void cbClientTeamShareInvalidItem( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1064 H_AUTO(cbClientTeamShareInvalidItem);
1066 CEntityId id;
1067 msgin.serial(id);
1068 CCharacter * user = PlayerManager.getChar(id);
1069 if ( !user )
1071 nlwarning("<cbClientTeamShareInvalidItem>invalid char %s",id.toString().c_str());
1072 return;
1074 // check character is ready
1075 if (!user->getEnterFlag())
1077 nlwarning("<cbClientTeamShareInvalidItem> player Id %s not yet ready", id.toString().c_str() );
1078 return;
1080 user->setAfkState(false);
1081 CTeam * team = TeamManager.getRealTeam(user->getTeamId());
1082 if (!team)
1084 nlwarning("<cbClientTeamShareInvalidItem>char %s has no valid team",id.toString().c_str());
1085 return;
1087 if ( !team->getReward() )
1089 nlwarning("<cbClientTeamShareInvalidItem>char %s: his team has no reward",id.toString().c_str());
1090 return;
1093 uint8 pos,state;
1094 msgin.serial(pos);
1095 msgin.serial(state);
1096 team->getReward()->userItemSelect(user->getEntityRowId(),pos,state);
1099 void cbClientTeamShareValid( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1101 H_AUTO(cbClientTeamShareValid);
1103 CEntityId id;
1104 msgin.serial(id);
1105 CCharacter * user = PlayerManager.getChar(id);
1106 if ( !user )
1108 nlwarning("<cbClientTeamShareValid>invalid char %s",id.toString().c_str());
1109 return;
1111 // check character is ready
1112 if (!user->getEnterFlag())
1114 nlwarning("<cbClientTeamShareValid> player Id %s not yet ready", id.toString().c_str() );
1115 return;
1117 user->setAfkState(false);
1118 CTeam * team = TeamManager.getRealTeam(user->getTeamId());
1119 if (!team)
1121 nlwarning("<cbClientTeamShareValid>char %s has no valid team",id.toString().c_str());
1122 return;
1124 if ( !team->getReward() )
1126 nlwarning("<cbClientTeamShareValid>char %s: his team has no reward",id.toString().c_str());
1127 return;
1130 uint8 state;
1131 msgin.serial(state);
1132 if ( team->getReward()->userValidSelect(user->getEntityRowId(),state) )
1133 team->clearReward();
1136 //---------------------------------------------------
1137 // Add a player to contact list or ignore list
1138 //---------------------------------------------------
1139 void cbClientAddToContactList( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1141 H_AUTO(cbClientAddToContactList);
1143 CEntityId charId;
1144 ucstring playerName;
1145 uint8 list;
1147 msgin.serial(charId);
1148 msgin.serial(playerName);
1149 msgin.serial(list);
1151 CCharacter * c = PlayerManager.getChar( charId );
1152 if( c && c->getEnterFlag() )
1154 c->setAfkState(false);
1155 if (list == 0)
1157 c->addPlayerToFriendList(playerName);
1159 else
1161 c->addPlayerToIgnoreList(playerName);
1164 else
1165 nlwarning("<cbAddToContactList> Unknown character %s", charId.toString().c_str() );
1168 //---------------------------------------------------
1169 // remove a player from contact list or ignore list
1170 //---------------------------------------------------
1171 void cbClientRemoveFromContactList( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1173 H_AUTO(cbClientRemoveFromContactList);
1175 CEntityId charId;
1176 uint32 contactId;
1177 uint8 list;
1179 msgin.serial(charId);
1180 msgin.serial(contactId);
1181 msgin.serial(list);
1183 CCharacter * c = PlayerManager.getChar( charId );
1184 if( c && c->getEnterFlag() )
1186 c->setAfkState(false);
1187 if (list == 0)
1189 c->removePlayerFromFriendListByContactId(contactId);
1191 else
1193 c->removePlayerFromIgnoreListByContactId(contactId);
1196 else
1197 nlwarning("<cbAddToContactList> Unknown character %s", charId.toString().c_str() );
1200 //---------------------------------------------------
1201 // Mobe a player from a contact list to an another one
1202 //---------------------------------------------------
1203 void cbClientMoveInContactLists( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1205 H_AUTO(cbClientMoveInContactLists);
1207 CEntityId charId;
1208 uint32 contactIdOrigin;
1209 uint8 listOrigin;
1211 msgin.serial(charId);
1212 msgin.serial(contactIdOrigin);
1213 msgin.serial(listOrigin);
1215 CCharacter * c = PlayerManager.getChar( charId );
1216 if( c && c->getEnterFlag() )
1218 c->setAfkState(false);
1219 if (listOrigin == 0)
1221 NLMISC::CEntityId eid= c->getFriendByContactId(contactIdOrigin);
1222 // allows the whole operation or nothing if player does not exist
1223 if (eid != CEntityId::Unknown)
1225 c->removePlayerFromFriendListByEntityId(eid);
1226 c->addPlayerToIgnoreList(eid);
1228 else
1230 // player not found => message
1231 PHRASE_UTILITIES::sendDynamicSystemMessage( c->getEntityRowId(), "OPERATION_NOTEXIST");
1234 else
1236 NLMISC::CEntityId eid= c->getIgnoreByContactId(contactIdOrigin);
1237 // allows the whole operation or nothing if player is not present
1238 if(eid != CEntityId::Unknown)
1240 c->removePlayerFromIgnoreListByEntityId(eid);
1241 c->addPlayerToFriendList(eid);
1243 else
1245 // player not found => message
1246 PHRASE_UTILITIES::sendDynamicSystemMessage( c->getEntityRowId(), "OPERATION_NOTEXIST");
1250 else
1251 nlwarning("<cbAddToContactList> Unknown character %s", charId.toString().c_str() );
1254 ///////////////////////////////////////////////////////////////////////////////////////////////////
1255 ///////////////////////////////////////////////////////////////////////////////////////////////////
1256 // CLIENT:TP
1257 ///////////////////////////////////////////////////////////////////////////////////////////////////
1258 ///////////////////////////////////////////////////////////////////////////////////////////////////
1260 // teleport near a bot
1261 /*void cbClientTpBot( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
1263 CEntityId idPlayer;
1264 string name;
1265 CEntityId botId;
1266 msgin.serial( idPlayer );
1267 msgin.serial( name );
1269 CCharacter *ch = PlayerManager.getChar( idPlayer );
1270 if ( ch && ch->havePriv(PriviliegeGameMaster))
1272 CEntityBase* entity = PlayerManager.getCharacterByName( name );
1273 if( ! entity )
1275 TAIAlias alias = CAIAliasTranslator::getInstance()->getNPCAliasFromName(name);
1276 if ( ! CAIAliasTranslator::getInstance()->getEntityId(alias,botId) )
1278 nlwarning("<cbClientTpBot> Unknown alias %d", alias );
1279 return;
1281 entity = CreatureManager.getCreature( botId );
1283 if ( entity )
1285 sint32 x = entity->getState().X + sint32( cos(entity->getState().Heading) * 2000 );
1286 sint32 y = entity->getState().Y + sint32( sin(entity->getState().Heading) * 2000 );
1287 ch->allowNearPetTp();
1288 ch->tpWanted( x,y, entity->getState().Z );
1290 else
1292 nlwarning("<cbClientTpBot> Unknown bot %s", botId.toString().c_str() );
1295 else
1297 nlwarning("<cbClientTpBot> Unknown character %s or don't have priv", idPlayer.toString().c_str() );
1302 /*void cbClientTpWanted( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
1304 CEntityId Id;
1305 sint32 x, y, z;
1307 msgin.serial( Id );
1308 msgin.serial( x );
1309 msgin.serial( y );
1310 msgin.serial( z );
1312 CCharacter *ch = PlayerManager.getChar( Id );
1313 if ( ch && ch->havePriv(PriviliegeGameMaster))
1315 ch->forbidNearPetTp();
1316 ch->tpWanted( x, y , z );
1318 else
1320 nlwarning("<cbClientTpWanted> Unknown character %s or don't have priv", Id.toString().c_str() );
1326 // client want tp at respawn point (beta test features for work-arround stuck collide)
1327 /*void cbClientTpRespawn( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
1329 CEntityId characterId;
1330 msgin.serial( characterId );
1332 CCharacter *ch = PlayerManager.getChar( characterId );
1333 if ( ch )
1335 COfflineEntityState state = PlayerManager.getStartState( ch->getActiveRole() );
1336 ch->allowNearPetTp();
1337 ch->tpWanted( state.X, state.Y, state.Z );
1342 ///////////////////////////////////////////////////////////////////////////////////////////////////
1343 ///////////////////////////////////////////////////////////////////////////////////////////////////
1344 // CLIENT:ANIMALS
1345 ///////////////////////////////////////////////////////////////////////////////////////////////////
1346 ///////////////////////////////////////////////////////////////////////////////////////////////////
1349 void cbClientAnimalsBeast( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1351 cbAnimalCommand(msgin, serviceName, serviceId);
1355 void cbClientAnimalsDisbandConvoy( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
1357 CEntityId id;
1358 msgin.serial( id );
1360 CCharacter * c = PlayerManager.getChar( id );
1361 if( c && c->getEnterFlag() )
1363 c->setAfkState(false);
1364 c->clearBeastTrain();
1366 else
1368 nlwarning("<cbClientAnimalsDisbandConvoy> received message from unknown client %s", id.toString().c_str() );
1375 ///////////////////////////////////////////////////////////////////////////////////////////////////
1376 ///////////////////////////////////////////////////////////////////////////////////////////////////
1377 // CLIENT:TRADE
1378 ///////////////////////////////////////////////////////////////////////////////////////////////////
1379 ///////////////////////////////////////////////////////////////////////////////////////////////////
1382 void cbClientTradeNextPage( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
1384 CEntityId userId;
1385 uint16 session;
1386 msgin.serial(userId);
1387 msgin.serial(session);
1388 CCharacter * c = PlayerManager.getChar( userId );
1389 if ( c )
1390 ;//c->tradeNextPage(session);
1391 else
1392 nlwarning("<cbClientTradeNextPage> Invalid user %s",userId.toString().c_str());
1397 void cbClientTradeMissionNextPage( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
1399 CEntityId userId;
1400 uint16 session;
1401 msgin.serial(userId);
1402 msgin.serial(session);
1403 CCharacter * c = PlayerManager.getChar( userId );
1404 if ( c )
1405 ;//c->tradeMissionNextPage(session);
1406 else
1407 nlwarning("<cbClientTradeNextPage> Invalid user %s",userId.toString().c_str());
1410 // Client want buy an item
1411 void cbClientTradeBuy( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
1413 cbTradeBuySomething(msgin, serviceName, serviceId);
1417 // Client ask selling price of an item
1418 void cbClientTradeQuerySellPrice( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
1420 CEntityId id;
1421 uint16 Inventory, Slot;
1423 msgin.serial( id );
1424 msgin.serial( Inventory );
1425 msgin.serial( Slot );
1427 CCharacter * c = PlayerManager.getChar( id );
1428 if( c )
1430 c->askSellPrice( Inventory, Slot );
1432 else
1434 nlwarning("<cbClientTradeQuerySellPrice> received message from unknown client %s", id.toString().c_str() );
1438 // Client sell an item
1439 void cbClientTradeSellItem( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
1441 CEntityId id;
1442 uint16 Inventory, Slot;
1443 uint16 Quantity;
1445 msgin.serial( id );
1446 msgin.serial( Inventory );
1447 msgin.serial( Slot );
1448 msgin.serial( Quantity );
1450 CCharacter * c = PlayerManager.getChar( id );
1451 if( c )
1453 c->sellItem( Inventory, Slot, Quantity );
1455 else
1457 nlwarning("<cbClientTradeSellItem> received message from unknown client %s", id.toString().c_str() );
1461 ///////////////////////////////////////////////////////////////////////////////////////////////////
1462 ///////////////////////////////////////////////////////////////////////////////////////////////////
1463 // CLIENT:EXCHANGE
1464 ///////////////////////////////////////////////////////////////////////////////////////////////////
1465 ///////////////////////////////////////////////////////////////////////////////////////////////////
1468 void cbClientExchangeProposal( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1470 cbExchangeProposal(msgin, serviceName, serviceId);
1474 void cbClientExchangeAcceptInvitation( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1476 cbAcceptExchangeInvitation(msgin, serviceName, serviceId);
1480 void cbClientExchangeDeclineInvitation( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1482 cbDeclineExchangeInvitation(msgin, serviceName, serviceId);
1486 void cbClientExchangeSeeds( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1488 cbExchangeSeeds(msgin, serviceName, serviceId);
1492 void cbClientExchangeEnd( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1494 cbEndExchange(msgin, serviceName, serviceId);
1498 void cbClientExchangeValidate( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1500 cbAcceptExchange(msgin, serviceName, serviceId);
1504 void cbClientExchangeInvalidate( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1506 H_AUTO(cbClientExchangeInvalidate);
1508 CEntityId id;
1509 msgin.serial(id);
1510 CCharacter * c = PlayerManager.getChar( id );
1511 if (c && c->getEnterFlag() )
1513 c->setAfkState(false);
1514 c->invalidateExchange();
1516 else
1517 nlwarning("<cbClientExchangeInvalidate : invalid char %s>",id.toString().c_str());
1520 void cbClientExchangeAdd( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1522 H_AUTO(cbClientExchangeAdd);
1524 CEntityId id;
1525 msgin.serial(id);
1527 uint16 invSrc, slotSrc, slotDest;
1528 uint16 quantity;
1530 msgin.serial(invSrc);
1531 msgin.serial(slotSrc);
1532 msgin.serial(slotDest);
1533 msgin.serial(quantity);
1535 CCharacter * c = PlayerManager.getChar( id );
1536 if (c && c->getEnterFlag() )
1538 c->setAfkState(false);
1539 c->incInterfaceCounter();
1540 c->itemInvToExchange(invSrc, slotSrc, slotDest, quantity);
1542 else
1543 nlwarning("<cbClientExchangeAdd : invalid char %s>",id.toString().c_str());
1546 void cbClientExchangeRemove( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId)
1548 H_AUTO(cbClientExchangeRemove);
1550 CEntityId id;
1551 msgin.serial(id);
1553 uint16 slotSrc;
1554 msgin.serial(slotSrc);
1556 CCharacter * c = PlayerManager.getChar( id );
1557 if (c && c->getEnterFlag() )
1559 c->setAfkState(false);
1560 c->incInterfaceCounter();
1561 c->itemExchangeToBag(slotSrc);
1563 else
1564 nlwarning("<cbClientExchangeRemove : invalid char %s>",id.toString().c_str());
1567 ///////////////////////////////////////////////////////////////////////////////////////////////////
1568 ///////////////////////////////////////////////////////////////////////////////////////////////////
1569 // BRICK/SENTENCE RELATED COMMANDS
1570 ///////////////////////////////////////////////////////////////////////////////////////////////////
1571 ///////////////////////////////////////////////////////////////////////////////////////////////////
1574 /*void cbClientSentenceCancelCurrent( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
1576 cbCancelCurrentSentence(msgin, serviceName, serviceId);
1580 void cbClientSentenceCancel( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
1582 cbCancelSentence(msgin, serviceName, serviceId);
1586 void cbClientSentenceCancelAll( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
1588 cbCancelAllSentences(msgin, serviceName, serviceId);
1595 ///////////////////////////////////////////////////////////////////////////////////////////////////
1596 ///////////////////////////////////////////////////////////////////////////////////////////////////
1597 // bot chat missions commands
1598 ///////////////////////////////////////////////////////////////////////////////////////////////////
1599 ///////////////////////////////////////////////////////////////////////////////////////////////////
1601 /// start the static mission interface
1602 void cbClientBotChatChooseStaticMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId );
1604 /// ask for the next mission page
1605 void cbClientBotChatNextMissionPage( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId );
1607 /// pick a static mission
1608 void cbClientBotChatPickStaticMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId );
1610 ///continue a mission by ending the current step
1611 void cbClientContinueMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId );
1613 ///validate a gift to a bot
1614 void cbClientValidateMissionGift( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId );
1616 /// client ends a bot gift
1617 void cbClientBotChatEndGift( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId );
1619 /// client sends a dynamic bot chat nswer
1620 void cbClientBotChatDynChatSend( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId );
1622 // client abandons a mission
1623 void cbClientAbandonMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId );
1625 // client abandons a group mission
1626 void cbClientGroupAbandonMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId );
1629 ///////////////////////////////////////////////////////////////////////////////////////////////////
1630 ///////////////////////////////////////////////////////////////////////////////////////////////////
1631 // bot chat trade
1632 ///////////////////////////////////////////////////////////////////////////////////////////////////
1633 ///////////////////////////////////////////////////////////////////////////////////////////////////
1636 /// open interface for item trade
1637 void cbClientBotChatStartTradeItem( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1639 H_AUTO(cbClientBotChatStartTradeItem);
1641 uint16 session;
1642 CEntityId userId;
1643 msgin.serial(userId,session);
1644 CCharacter * user = PlayerManager.getChar(userId);
1646 if ( !user )
1648 nlwarning("<cbClientBotChatStartTradeItem> Invalid char %s",userId.toString().c_str());
1649 return;
1651 // check character is ready
1652 if (!user->getEnterFlag())
1654 nlwarning("<cbClientBotChatStartTradeItem> player Id %s not yet ready", userId.toString().c_str() );
1655 return;
1658 // start a bot chat
1659 if ( !user->startBotChat( BOTCHATTYPE::TradeItemFlag ) )
1661 return;
1664 user->resetRawMaterialItemPartFilter();
1665 user->resetItemTypeFilter();
1666 user->startTradeItemSession(session);
1667 user->setAfkState(false);
1670 /// open interface for teleport trade
1671 void cbClientBotChatStartTradeTp( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1673 H_AUTO(cbClientBotChatStartTradeTp);
1675 uint16 session;
1676 CEntityId userId;
1677 msgin.serial(userId,session);
1678 CCharacter * user = PlayerManager.getChar(userId);
1680 if ( !user )
1682 nlwarning("<cbClientBotChatStartTradeTp> Invalid char %s",userId.toString().c_str());
1683 return;
1685 // check character is ready
1686 if (!user->getEnterFlag())
1688 nlwarning("<cbClientBotChatStartTradeTp> player Id %s not yet ready", userId.toString().c_str() );
1689 return;
1692 // start a bot chat
1693 if ( !user->startBotChat( BOTCHATTYPE::TradeTeleportFlag ) )
1695 return;
1697 user->startTradeItemSession(session);
1698 user->setAfkState(false);
1701 /// open interface for faction item trade
1702 void cbClientBotChatStartTradeFaction( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1704 H_AUTO(cbClientBotChatStartTradeFaction);
1706 uint16 session;
1707 CEntityId userId;
1708 msgin.serial(userId,session);
1709 CCharacter * user = PlayerManager.getChar(userId);
1711 if ( !user )
1713 nlwarning("<cbClientBotChatStartTradeFaction> Invalid char %s",userId.toString().c_str());
1714 return;
1716 // check character is ready
1717 if (!user->getEnterFlag())
1719 nlwarning("<cbClientBotChatStartTradeFaction> player Id %s not yet ready", userId.toString().c_str() );
1720 return;
1723 // start a bot chat
1724 if ( !user->startBotChat( BOTCHATTYPE::TradeFactionFlag ) )
1726 return;
1728 user->startTradeItemSession(session);
1729 user->setAfkState(false);
1732 /// start trade guild options
1733 void cbClientBotChatStartTradeGuildOptions( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1735 H_AUTO(cbClientBotChatStartTradeGuildOptions);
1736 uint16 session;
1737 CEntityId userId;
1738 msgin.serial(userId,session);
1739 CBuildingManager::getInstance()->buildBuildingTradeList(userId,session);
1742 /// buy a guild option
1743 void cbClientBotChatBuyGuildOptions( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1745 H_AUTO(cbClientBotChatBuyGuildOptions);
1746 uint8 idx;
1747 CEntityId userId;
1748 msgin.serial( userId,idx );
1749 CBuildingManager::getInstance()->buyBuildingOption( userId,idx );
1752 /// start research with a guild bot
1753 void cbClientBotChatStartGuildResearch( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1755 H_AUTO(cbClientBotChatStartGuildResearch);
1757 uint16 session;
1758 CEntityId userId;
1759 msgin.serial(userId,session);
1761 /// todo appart
1762 // CGuildManager::getInstance()->buildGuildResearchList(userId,session);
1766 /// trade next page
1767 void cbClientBotChatTradeNextPage( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1769 H_AUTO(cbClientBotChatTradeNextPage);
1771 uint16 session;
1772 CEntityId userId;
1773 msgin.serial(userId,session);
1774 CCharacter * user = PlayerManager.getChar(userId);
1776 if ( !user )
1778 nlwarning("<cbClientBotChatTradeNextPage> Invalid char %s",userId.toString().c_str());
1779 return;
1781 // check character is ready
1782 if (!user->getEnterFlag())
1784 nlwarning("<cbClientBotChatTradeNextPage> player Id %s not yet ready", userId.toString().c_str() );
1785 return;
1787 user->fillTradePage(session);
1791 /// buy an item
1792 void cbClientBotChatTradeBuy( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1794 H_AUTO(cbClientBotChatTradeBuy);
1796 uint16 idx;
1797 uint16 quantity;
1798 CEntityId userId;
1799 msgin.serial(userId,idx,quantity);
1800 CCharacter * user = PlayerManager.getChar(userId);
1802 if ( !user )
1804 nlwarning("<cbClientBotChatTradeBuy> Invalid char %s",userId.toString().c_str());
1805 return;
1807 // check character is ready
1808 if (!user->getEnterFlag())
1810 nlwarning("<cbClientBotChatTradeBuy> player Id %s not yet ready", userId.toString().c_str() );
1811 return;
1813 user->buyItem( idx,quantity);
1814 user->setAfkState(false);
1817 // destroy an item in sale store
1818 void cbClientBotChatTradeDestroy( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1820 H_AUTO(cbClientBotChatTradeDestroy);
1821 uint16 idx;
1822 uint16 quantity;
1823 CEntityId userId;
1826 msgin.serial(userId,idx,quantity);
1828 catch(const Exception &e)
1830 nlwarning("Bad cbClientBotChatTradeDestroy serialisation '%s'", e.what());
1831 return;
1833 CCharacter * user = PlayerManager.getChar(userId);
1835 if ( !user )
1837 nlwarning("<cbClientBotChatTradeDestroy> Invalid char %s",userId.toString().c_str());
1838 return;
1840 // check character is ready
1841 if (!user->getEnterFlag())
1843 nlwarning("<cbClientBotChatTradeDestroy> player Id %s not yet ready", userId.toString().c_str() );
1844 return;
1846 user->destroySaleItem( idx,quantity);
1847 user->setAfkState(false);
1850 // sell item
1851 void cbClientBotChatTradeSell( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1853 H_AUTO(cbClientBotChatTradeSell);
1855 uint8 inv;
1856 uint16 idx;
1857 uint16 quantity;
1858 uint32 price;
1859 CEntityId userId;
1863 msgin.serial(userId,inv,idx,quantity,price);
1865 catch(const Exception &e)
1867 nlwarning("Bad cbClientBotChatTradeSell serialisation '%s'", e.what());
1868 return;
1871 CCharacter * user = PlayerManager.getChar(userId);
1872 if ( !user )
1874 nlwarning("<cbClientBotChatTradeSell> Invalid char %s",userId.toString().c_str());
1875 return;
1877 // check character is ready
1878 if (!user->getEnterFlag())
1880 nlwarning("<cbClientBotChatTradeSell> player Id %s not yet ready", userId.toString().c_str() );
1881 return;
1883 user->sellItem(INVENTORIES::TInventory(inv),idx,quantity,price);
1884 user->setAfkState(false);
1887 // start a guild creation session
1888 void cbClientBotChatStartGuildCreation( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1890 H_AUTO(cbClientBotChatStartGuildCreation);
1892 CEntityId id;
1893 msgin.serial(id);
1894 CCharacter * user = PlayerManager.getChar(id);
1895 if ( !user )
1897 nlwarning("<cbClientBotChatStartGuildCreation> Invalid char %s",id.toString().c_str());
1898 return;
1900 // check character is ready
1901 if (!user->getEnterFlag())
1903 nlwarning("<cbClientBotChatStartGuildCreation> player Id %s not yet ready", id.toString().c_str() );
1904 return;
1907 user->setAfkState(false);
1909 if ( !user->startBotChat( BOTCHATTYPE::CreateGuildFlag ) )
1910 return;
1914 // start trade actions
1915 void cbClientBotChatStartTradeAction( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1917 H_AUTO(cbClientBotChatStartTradeAction);
1919 uint16 sessionId;
1920 CEntityId userId;
1922 msgin.serial(userId, sessionId);
1924 CCharacter * user = PlayerManager.getChar(userId);
1925 if ( !user )
1927 nlwarning("<cbClientBotChatStartTradeAction> Invalid char %s",userId.toString().c_str());
1928 return;
1930 // check character is ready
1931 if (!user->getEnterFlag())
1933 nlwarning("<cbClientBotChatStartTradeAction> player Id %s not yet ready", userId.toString().c_str() );
1934 return;
1936 user->setAfkState(false);
1938 // start a bot chat
1939 if ( !user->startBotChat( BOTCHATTYPE::TradePhraseFlag ) )
1941 return;
1944 user->startTradePhrases(sessionId);
1948 void cbClientBotChatSetFilters( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1950 H_AUTO(cbClientBotChatSetFilters);
1951 CEntityId userId;
1953 uint32 minQuality, maxQuality, minPrice, maxPrice;
1954 uint8 minClass, maxClass;
1955 uint8 itemPartFilter;
1956 uint8 itemTypeFilter;
1958 msgin.serial(userId, minQuality, maxQuality, minPrice, maxPrice);
1959 msgin.serial(minClass, maxClass, itemPartFilter, itemTypeFilter);
1961 CCharacter * user = PlayerManager.getChar(userId);
1962 if ( !user )
1964 nlwarning("<cbClientBotChatSetFilters> Invalid char %s",userId.toString().c_str());
1965 return;
1968 user->setAfkState(false);
1969 user->setFilters( minQuality, maxQuality, minPrice, maxPrice, (RM_CLASS_TYPE::TRMClassType)minClass, (RM_CLASS_TYPE::TRMClassType)maxClass, (RM_FABER_TYPE::TRMFType)itemPartFilter, (ITEM_TYPE::TItemType)itemTypeFilter );
1972 void cbRefreshTradeList( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1974 H_AUTO(cbRefreshTradeList);
1975 CEntityId userId;
1977 msgin.serial( userId );
1978 CCharacter * user = PlayerManager.getChar(userId);
1979 if ( !user )
1981 nlwarning("<cbClientBotChatSetFilters> Invalid char %s",userId.toString().c_str());
1982 return;
1984 user->refreshTradeList();
1989 ///////////////////////////////////////////////////////////////////////////////////////////////////
1990 ///////////////////////////////////////////////////////////////////////////////////////////////////
1991 // Client bot chat end
1992 ///////////////////////////////////////////////////////////////////////////////////////////////////
1993 ///////////////////////////////////////////////////////////////////////////////////////////////////
1994 void cbClientBotChatEnd( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
1996 H_AUTO(cbClientBotChatEnd);
1998 CEntityId userId;
1999 msgin.serial(userId);
2000 CCharacter* user = PlayerManager.getChar( userId );
2001 if (user && user->getEnterFlag())
2003 user->endBotChat();
2004 user->incInterfaceCounter();
2005 user->setAfkState(false);
2007 else
2008 nlwarning("<cbClientBotChatEnd> invalid character %s", userId.toString().c_str());
2011 ///////////////////////////////////////////////////////////////////////////////////////////////////
2012 ///////////////////////////////////////////////////////////////////////////////////////////////////
2013 // PLAYER COMMAND
2014 ///////////////////////////////////////////////////////////////////////////////////////////////////
2015 ///////////////////////////////////////////////////////////////////////////////////////////////////
2017 // client send an emote
2018 void cbClientSendEmote( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
2020 H_AUTO(cbClientSendEmote);
2022 CEntityId id;
2023 MBEHAV::EBehaviour behaviour = MBEHAV::IDLE;
2024 uint16 emoteTextId;
2027 msgin.serial( id );
2028 msgin.serialEnum( behaviour );
2029 msgin.serial( emoteTextId );
2031 catch(const Exception &e)
2033 nlwarning("Bad emote serialisation '%s'", e.what());
2034 return;
2037 CCharacter * c = PlayerManager.getChar( id );
2038 if( c && c->getEnterFlag() )
2040 // check if client can launch this emote from his UI
2041 const CStaticTextEmotes & emotes = CSheets::getTextEmoteList();
2042 const CStaticTextEmotes::CTextEmotePhrases * phraseCont = emotes.getPhrase( emoteTextId );
2043 if ( phraseCont != NULL )
2045 if( phraseCont->UsableFromClientUI == false )
2047 nlwarning("<cbClientSendEmote> client %s sent a forbidden emote : %u",c->getId().toString().c_str(),emoteTextId );
2048 return;
2052 c->sendEmote( id, behaviour, emoteTextId );
2054 else
2056 nlwarning("<cbClientSendEmote> received message from unknown client %s", id.toString().c_str() );
2061 // client send a custom emote
2062 void cbClientSendCustomEmote( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
2064 H_AUTO(cbClientSendCustomEmote);
2066 CEntityId id;
2067 MBEHAV::EBehaviour behaviour = MBEHAV::IDLE;
2068 ucstring emoteCustomText;
2071 msgin.serial( id );
2072 msgin.serialEnum( behaviour );
2073 msgin.serial( emoteCustomText );
2075 catch(const Exception &e)
2077 nlwarning("Bad custom emote serialisation '%s'", e.what());
2078 return;
2081 if (behaviour >= (MBEHAV::EMOTE_BEGIN + 80) && behaviour <= (MBEHAV::EMOTE_BEGIN + 109))
2083 string name = CEntityIdTranslator::getInstance()->getByEntity(id).toString();
2084 nlwarning("HACK: %s %s tries to launch a firework %d", id.toString().c_str(), name.c_str(), behaviour);
2085 return;
2088 CCharacter * c = PlayerManager.getChar( id );
2089 if( c && c->getEnterFlag() )
2091 c->sendCustomEmote( id, behaviour, emoteCustomText );
2093 else
2095 nlwarning("<cbClientSendCustomEmote> received message from unknown client %s", id.toString().c_str() );
2099 // client send a command where for known where is it
2100 void cbClientSendWhere( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
2102 H_AUTO(cbClientSendWhere);
2104 CEntityId id;
2105 msgin.serial( id );
2106 CZoneManager::getInstance().answerWhere(id);
2109 // client send a command where for known where is it
2110 void cbClientSendAfk( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
2112 H_AUTO(cbClientSendAfk);
2114 CEntityId id;
2115 bool afk;
2116 msgin.serial( id );
2117 msgin.serial( afk );
2118 CCharacter * user = PlayerManager.getChar( id );
2119 if ( !user )
2121 nlwarning("<AFK>'%s' is not a valid user",id.toString().c_str() );
2122 return;
2124 user->setAfkState( afk );
2127 // client send a command to kill its player
2128 void cbClientSelfKill( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
2130 H_AUTO(cbClientSelfKill);
2132 CEntityId id;
2133 msgin.serial( id );
2134 CCharacter * user = PlayerManager.getChar( id );
2136 if ( !user )
2138 nlwarning("<cbClientSelfKill> Invalid char %s", id.toString().c_str());
2139 return;
2141 // check character is ready
2142 if (!user->getEnterFlag())
2144 nlwarning("<cbClientSelfKill> player Id %s not yet ready", id.toString().c_str() );
2145 return;
2148 if (!user->havePriv(":DEV:SGM:GM:VG:SG:G:EM:EG:"))
2149 return;
2151 // disable command if pvp flagged recent (red flag)
2152 if (user->getPvPRecentActionFlag())
2154 CCharacter::sendDynamicSystemMessage(id, "PVP_COMMAND_FORBIDDEN");
2155 return;
2158 user->setAfkState(false);
2159 user->killMe();
2162 // client send a command to roll a dice
2163 void cbClientRollDice( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
2165 H_AUTO(cbClientRollDice);
2167 CEntityId entityId;
2168 sint16 min;
2169 sint16 max;
2170 sint16 roll;
2171 msgin.serial( entityId );
2172 msgin.serial( min );
2173 msgin.serial( max );
2175 static NLMISC::CRandom* dice = (NLMISC::CRandom*)NULL;
2176 if (!dice)
2178 dice = new NLMISC::CRandom;
2179 dice->srand(CTickEventHandler::getGameCycle());
2182 roll = min + (sint16)dice->rand(max-min);
2184 SM_STATIC_PARAMS_4(params, STRING_MANAGER::player, STRING_MANAGER::integer, STRING_MANAGER::integer, STRING_MANAGER::integer);
2185 params[0].setEIdAIAlias(entityId, CAIAliasTranslator::getInstance()->getAIAlias(entityId));
2186 params[1].Int = min;
2187 params[2].Int = max;
2188 params[3].Int = roll;
2190 TDataSetRow playerRowId = TheDataset.getDataSetRow( entityId );
2191 if ( !TheDataset.isAccessible(playerRowId) )
2192 return;
2194 PHRASE_UTILITIES::sendDynamicSystemMessage(playerRowId, "ROLL_DICE", params);
2195 STRING_MANAGER::sendSystemStringToClientAudience(playerRowId, std::vector<NLMISC::CEntityId>(), CChatGroup::shout, "ROLL_DICE", params);
2198 // client send command sit (for sit/up)
2199 void cbClientSit( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
2201 H_AUTO(cbClientSit);
2203 CEntityId id;
2204 bool sit;
2205 msgin.serial( id );
2206 msgin.serial( sit );
2208 CCharacter * c = PlayerManager.getChar( id );
2209 if( c && c->getEnterFlag() )
2211 c->setAfkState(false);
2212 if( sit )
2214 if( !c->isInWater() && c->getMode()!=MBEHAV::MOUNT_NORMAL && c->getMode()!=MBEHAV::DEATH )
2216 c->setMode( MBEHAV::SIT );
2217 // only if player is'nt equipping an item
2218 //( to prevent exploit "sit to reduce equip latency time")
2219 if( !c->getGearLatency().isLatent() )
2221 c->cancelStaticActionInProgress(STATIC_ACT_TYPES::Neutral, false, false);
2223 c->cancelStaticEffects();
2226 else
2228 c->setMode( MBEHAV::NORMAL );
2231 else
2233 nlwarning("<cbClientSendWhere> received message from unknown client %s", id.toString().c_str() );
2238 // client send a command to change guild motd
2239 void cbClientGuildMotd( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
2241 H_AUTO(cbClientGuildMotd);
2243 CEntityId entityId;
2244 string motd;
2245 msgin.serial( entityId );
2246 msgin.serial( motd );
2248 CCharacter * user = PlayerManager.getChar( entityId );
2249 if (!user)
2251 nlwarning("<cbClientGuildMotd>'%s' is not a valid char",entityId.toString().c_str());
2252 return;
2254 if (!user->getEnterFlag())
2256 nlwarning("<cbClientGuildMotd>'%s' is not entered", entityId.toString().c_str());
2257 return;
2259 if (!TheDataset.isAccessible(user->getEntityRowId()))
2261 nlwarning("<cbClientGuildMotd>'%s' is not valid in mirror", entityId.toString().c_str());
2262 return;
2265 CGuild * guild = CGuildManager::getInstance()->getGuildFromId( user->getGuildId() );
2266 if( guild )
2268 guild->setMOTD(motd, entityId);
2273 ///////////////////////////////////////////////////////////////////////////////////////////////////
2274 ///////////////////////////////////////////////////////////////////////////////////////////////////
2275 // CLIENT:CHEAT
2276 ///////////////////////////////////////////////////////////////////////////////////////////////////
2277 ///////////////////////////////////////////////////////////////////////////////////////////////////
2279 // turn character to god mod
2280 //void cbGodMode( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId);
2281 /*void cbClientCheatGod( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
2283 CEntityId id;
2284 msgin.serial( id );
2286 CCharacter * c = PlayerManager.getChar( id );
2287 if( c && c->havePriv(PriviliegeGameMaster))
2289 c->ToggleGodMode();
2292 // cbGodMode(msgin, serviceName, serviceId);
2296 void cbClientCreateItemInBag( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
2298 CEntityId charId;
2299 msgin.serial( charId );
2301 CSheetId itemSheetId;
2302 msgin.serial( itemSheetId );
2304 uint16 quantity;
2305 msgin.serial( quantity );
2307 uint16 quality;
2308 msgin.serial( quality );
2310 // get character
2311 CCharacter *c = PlayerManager.getChar( charId );
2312 if (c&& c->havePriv(PriviliegeGameMaster))
2314 nlwarning("<cbClientCreateItemInBag> Invalid player Id %s", charId.toString().c_str() );
2315 return;
2318 c->createItemInBag( quality, quantity, itemSheetId );
2321 /*// character learn all existing bricks
2322 void cbClientLearnAllBricks( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId)
2324 CEntityId id;
2325 msgin.serial( id );
2327 CCharacter * c = PlayerManager.getChar( id );
2328 if( c && c->havePriv(PriviliegeGameMaster))
2329 GameItemManager.learnAllBricks( c );
2330 else
2331 nlwarning("cbClientLearnAllBricks, unknown player '%s'", id.toString().c_str() );
2335 // client ask to add money to his character
2336 /*void cbClientMoney( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
2338 CEntityId id;
2339 msgin.serial ( id );
2341 sint32 vb, b, m, s;
2343 msgin.serial ( vb );
2344 msgin.serial ( b );
2345 msgin.serial ( m );
2346 msgin.serial ( s );
2348 CCharacter * c = PlayerManager.getChar( id );
2349 if( c && c->havePriv(PriviliegeGameMaster))
2351 c->giveSeed( CSeeds( vb, b, m, s ) );
2355 /*// Client want set Ryzom Time
2356 void cbClientRyzomTime( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
2358 CEntityId Id;
2359 msgin.serial( Id );
2361 if (!PlayerManager.havePriv(Id, PriviliegeGameMaster))
2362 return;
2364 float Time;
2365 msgin.serial( Time );
2367 CMessage msgout( "SET_RYZOM_TIME" );
2368 msgout.serial( Time );
2369 sendMessageViaMirror( "WOS", msgout );
2372 // Client want set Ryzom Day
2373 void cbClientRyzomDay( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
2375 CEntityId Id;
2376 msgin.serial( Id );
2378 if (!PlayerManager.havePriv(Id, PriviliegeGameMaster))
2379 return;
2381 uint32 Day;
2382 msgin.serial( Day );
2384 CMessage msgout( "SET_RYZOM_DAY" );
2385 msgout.serial( Day );
2386 sendMessageViaMirror( "WOS", msgout );
2389 // Client want gain xp in indicated skill
2390 /*void cbClientGainXp( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
2392 CEntityId Id;
2393 string Skill, Speciality;
2394 uint32 Xp;
2396 msgin.serial( Id );
2397 msgin.serial( Xp );
2398 msgin.serial( Skill );
2400 CCharacter * c = PlayerManager.getChar( Id );
2401 if( c && c->havePriv(PriviliegeGameMaster))
2403 c->addXpToSkill( (double) Xp, Skill );
2407 // Client create a new character
2408 /*void cbClientCreateCharacter( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
2410 CEntityId id;
2411 string characterName;
2412 EGSPD::CPeople::TPeople people;
2413 GSGENDER::EGender gender;
2414 //Deprecated
2415 // ROLES::ERole role;
2416 uint16 level;
2418 msgin.serial( id );
2419 msgin.serial( characterName );
2420 msgin.serialEnum( people );
2421 msgin.serialEnum( gender );
2422 // msgin.serialEnum( role );
2423 msgin.serial( level );
2425 CCharacter * c = PlayerManager.getChar( id );
2426 if( c && c->havePriv(PriviliegeGameMaster))
2428 uint32 playerId = PlayerManager.getPlayerId( id );
2429 CPlayer * player = PlayerManager.getPlayer( playerId );
2430 if( player )
2432 player->replaceCharacter( characterName, people, gender, level );
2433 PlayerManager.savePlayer( playerId );
2438 // Client create a new character
2439 /*void cbClientAddRole( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
2441 CEntityId id;
2442 ROLES::ERole role;
2443 uint16 level;
2445 msgin.serial( id );
2446 msgin.serialEnum( role );
2447 msgin.serial( level );
2449 CCharacter * c = PlayerManager.getChar( id );
2450 if( c && c->havePriv(PriviliegeGameMaster))
2452 c->getRoles().addNewJob( JOBS::getJobForRace( role, (EGSPD::CPeople::TPeople) c->getRace() ) );
2456 // Client want to learn bricks
2457 /*void cbClientLearnBrick( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
2459 CEntityId id;
2460 ROLES::ERole role;
2461 uint16 level;
2463 msgin.serial( id );
2464 msgin.serialEnum( role );
2465 msgin.serial( level );
2467 CCharacter * c = PlayerManager.getChar( id );
2468 if( c && c->havePriv(PriviliegeGameMaster))
2470 GameItemManager.learnAllBricksForRoleAndRace( c, role, (EGSPD::CPeople::TPeople) c->getRace(), level );
2474 /// cient want to learn all faber plans
2475 /*void cbClientLearnAllFaberPlans( NLNET::CMessage& msgin, const std::string &serviceName, uint16 serviceId )
2477 CEntityId id;
2479 msgin.serial( id );
2481 CCharacter * c = PlayerManager.getChar( id );
2482 if( c && c->havePriv(PriviliegeGameMaster))
2484 c->learnAllFaberPlans();
2486 } // cbClientLearnAllFaberPlans //
2490 * CLIENT:DEBUG
2493 // Send server client coordinate
2494 void cbClientWhere( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
2496 H_AUTO(cbClientWhere);
2498 CEntityId id;
2499 msgin.serial( id );
2500 CCharacter * c = PlayerManager.getChar( id );
2501 if( c && c->getEnterFlag() )
2503 c->setAfkState(false);
2504 CMessage msgout( "IMPULSION_ID" );
2505 msgout.serial( id );
2506 CBitMemStream bms;
2507 if ( ! GenericMsgManager.pushNameToStream( "DEBUG:REPLY_WHERE", bms) )
2509 nlwarning("<cbClientWhere> Msg name DEBUG:REPLY_WHERE not found");
2510 return;
2512 bms.serial( const_cast< sint32& > (c->getState().X.getValue()) );
2513 bms.serial( const_cast< sint32& > (c->getState().Y.getValue()) );
2514 bms.serial( const_cast< sint32& > (c->getState().Z.getValue()) );
2515 msgout.serialBufferWithSize((uint8*)bms.buffer(), bms.length());
2516 CUnifiedNetwork::getInstance()->send( NLNET::TServiceId(id.getDynamicId()), msgout );
2521 // local macro definition ( undef below )
2522 #define SEND_GM_WHO_ANSWER( _code_ , _msg_) {\
2523 gms = PlayerManager.getSpecialUsers(_code_);\
2524 if ( gms && !gms->empty() )\
2526 for ( uint i = 0; i < gms->size(); i++ )\
2528 TDataSetRow row = TheDataset.getDataSetRow( (*gms)[i] );\
2529 if ( TheDataset.isAccessible( row ) )\
2531 CMirrorPropValue<TYPE_WHO_SEES_ME> whoSeesMe(TheDataset, row, DSPropertyWHO_SEES_ME );\
2532 if ( R2_VISION::isEntityVisibleToPlayers(whoSeesMe) )\
2534 params[0].setEId((*gms)[i]);\
2535 CCharacter::sendDynamicSystemMessage( id,_msg_,params );\
2536 nbAnswers++;\
2543 // local macro definition ( undef below )
2544 #define SEND_GM_WHO_ANSWER_INVIS( _code_ , _msg_) {\
2545 gms = PlayerManager.getSpecialUsers(_code_);\
2546 if ( gms && !gms->empty() )\
2548 for ( uint i = 0; i < gms->size(); i++ )\
2550 TDataSetRow row = TheDataset.getDataSetRow( (*gms)[i] );\
2551 if ( TheDataset.isAccessible( row ) )\
2553 CMirrorPropValue<TYPE_WHO_SEES_ME> whoSeesMe(TheDataset, row, DSPropertyWHO_SEES_ME );\
2554 if ( !R2_VISION::isEntityVisibleToPlayers(whoSeesMe) )\
2556 params[0].setEId( (*gms)[i] );\
2557 CCharacter::sendDynamicSystemMessage( id,_msg_,params );\
2558 nbAnswers++;\
2565 // Send list of connected character name / account to client
2566 void cbClientWho( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
2568 H_AUTO(cbClientWho);
2570 CEntityId id;
2571 std::string opt;
2572 msgin.serial( id,opt );
2573 const std::vector<CEntityId> * gms = NULL;
2575 // Make sure opt is not like "A(c)" for e acute
2576 ucstring ucopt;
2577 ucopt.fromUtf8(opt);
2578 opt = ucopt.toString();
2580 uint nbAnswers = 0;
2582 // standard who
2583 if ( opt.empty() )
2585 CCharacter * user = PlayerManager.getChar( id );
2586 if ( !user )
2588 nlwarning("<WHO>'%s' is invalid", id.toString().c_str() );
2589 return;
2591 CRegion* region = dynamic_cast<CRegion*>( CZoneManager::getInstance().getPlaceFromId( user->getCurrentRegion() ) );
2592 if ( region == NULL )
2594 nlwarning("<WHO>'%s' Invalid region %u", id.toString().c_str(), user->getCurrentRegion() );
2595 return;
2599 SM_STATIC_PARAMS_1(params, STRING_MANAGER::place);
2600 params[0].Identifier = region->getName();
2601 CCharacter::sendDynamicSystemMessage( id,"WHO_REGION_INTRO",params );
2604 // send all users in region
2606 SM_STATIC_PARAMS_1(params, STRING_MANAGER::player);
2607 for ( set<CEntityId>::const_iterator it = region->getPlayersInside().begin(); it != region->getPlayersInside().end(); ++it )
2609 TDataSetRow row = TheDataset.getDataSetRow( (*it) );
2610 if ( TheDataset.isAccessible( row ) )
2612 CCharacter *ch = PlayerManager.getChar( *it );
2614 // check that user are visible to each other and in the same instance
2615 if ( R2_VISION::isEntityVisibleToPlayers(ch->getWhoSeesMe())
2616 && user->getInstanceNumber() == ch->getInstanceNumber())
2618 params[0].setEId( (*it) );
2619 CCharacter::sendDynamicSystemMessage( id,"WHO_REGION_LIST", params );
2620 nbAnswers++;
2627 // GM who
2628 else if ( NLMISC::nlstricmp( opt.c_str(), "GM" ) == 0)
2630 TVectorParamCheck params(1);
2631 params[0].Type = STRING_MANAGER::player;
2632 CCharacter::sendDynamicSystemMessage( id,"WHO_GM_INTRO" );
2633 SEND_GM_WHO_ANSWER( ":SGM:","WHO_SGM_LIST" );
2634 SEND_GM_WHO_ANSWER( ":GM:","WHO_GM_LIST" );
2635 SEND_GM_WHO_ANSWER( ":VG:","WHO_VG_LIST" );
2636 SEND_GM_WHO_ANSWER( ":SG:","WHO_SG_LIST" );
2637 SEND_GM_WHO_ANSWER( ":G:","WHO_G_LIST" );
2639 CCharacter * user = PlayerManager.getChar( id );
2640 if ( user )
2642 CPlayer *p = PlayerManager.getPlayer(PlayerManager.getPlayerId(user->getId()));
2643 if (p != NULL)
2645 bool allowIt = p->havePriv(":DEV:");
2646 if( allowIt || p->havePriv(":SGM:GM:VG:SG:G:") )
2648 nbAnswers = 0;
2649 TVectorParamCheck params(1);
2650 params[0].Type = STRING_MANAGER::player;
2651 CCharacter::sendDynamicSystemMessage( id,"WHO_INVISIBLE_GM_INTRO" );
2652 if ( allowIt || p->havePriv(":SGM:") )
2654 SEND_GM_WHO_ANSWER_INVIS( ":SGM:","WHO_SGM_LIST" );
2655 allowIt = true;
2657 if ( allowIt || p->havePriv(":SGM:GM:") )
2659 SEND_GM_WHO_ANSWER_INVIS( ":GM:","WHO_GM_LIST" );
2660 allowIt = true;
2662 if ( allowIt || p->havePriv(":SGM:GM:VG:") )
2664 SEND_GM_WHO_ANSWER_INVIS( ":VG:","WHO_VG_LIST" );
2666 if ( allowIt || p->havePriv(":SGM:GM:VG:SG:") )
2668 SEND_GM_WHO_ANSWER_INVIS( ":SG:","WHO_SG_LIST" );
2670 SEND_GM_WHO_ANSWER_INVIS( ":G:","WHO_G_LIST" );
2675 else
2677 TChanID chanID;
2679 CCharacter * user = PlayerManager.getChar( id );
2680 if ( !user )
2682 nlwarning("<WHO>'%s' is invalid", id.toString().c_str() );
2683 return;
2685 CPlayer *p = PlayerManager.getPlayer(PlayerManager.getPlayerId(user->getId()));
2687 if (NLMISC::nlstricmp( opt.c_str(), "league" ) == 0)
2689 chanID = user->getLeagueId();
2691 else
2693 chanID = DynChatEGS.getChanIDFromName(opt);
2696 if (chanID == DYN_CHAT_INVALID_CHAN)
2698 CCharacter::sendDynamicSystemMessage( id, "WHO_CHANNEL_NOT_FOUND" );
2699 return;
2702 bool havePriv = p->havePriv(":DEV:SGM:GM:EM:");
2703 bool hasChannel = false;
2704 nbAnswers = 0;
2706 vector<NLMISC::CEntityId> players;
2707 DynChatEGS.getPlayersInChan(chanID, players);
2708 ucstring playerNames("");
2709 uint32 shardId = CEntityIdTranslator::getInstance()->getEntityShardId(id);
2711 for (uint i = 0; i < players.size(); i++)
2713 if (players[i] == id)
2714 hasChannel = true;
2716 ucstring name = CEntityIdTranslator::getInstance()->getByEntity(players[i]);
2717 if (shardId == CEntityIdTranslator::getInstance()->getEntityShardId(players[i]))
2719 // Same shard, remove shard from name
2720 CEntityIdTranslator::removeShardFromName(name);
2722 playerNames += ((i > 0) ? "\n" : "") + name ;
2725 if (!hasChannel && !havePriv)
2727 SM_STATIC_PARAMS_1(params, STRING_MANAGER::literal);
2728 params[0].Literal = opt;
2729 CCharacter::sendDynamicSystemMessage( id, "WHO_CHANNEL_NOT_CONNECTED", params );
2731 return;
2734 if (!playerNames.empty())
2736 SM_STATIC_PARAMS_1(params, STRING_MANAGER::literal);
2737 params[0].Literal = opt;
2738 CCharacter::sendDynamicSystemMessage( id, "WHO_CHANNEL_INTRO", params);
2739 //playerNames = "Players in channel \"" + opt + "\":" + playerNames;
2740 params[0].Literal = playerNames;
2741 CCharacter::sendDynamicSystemMessage( id, "LITERAL", params );
2742 return;
2746 if ( nbAnswers == 0 )
2748 CCharacter::sendDynamicSystemMessage( id,"WHO_NO_ANSWER" );
2752 #undef SEND_GM_WHO_ANSWER_INVIS
2753 #undef SEND_GM_WHO_ANSWER
2755 // received a ping from a client, write it to client database
2756 void cbClientPing( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
2758 CEntityId id;
2759 msgin.serial( id );
2761 TGameCycle time;
2762 msgin.serial( time );
2764 CCharacter * c = PlayerManager.getChar( id );
2765 if( c )
2767 // c->_PropertyDatabase.setProp( c->getDataIndexReminder()->DATABASE_PING.PING, time );
2768 CBankAccessor_PLR::getDEBUG_INFO().setPing(c->_PropertyDatabase, time );
2773 extern void cbClientAdmin( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId);
2774 extern void cbClientAdminOffline( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId);
2775 extern void cbClientRemoteAdmin( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId);
2778 /************************************************************************/
2779 /* GUILD CALLBACKS */
2780 /* implemented in guild_client_callbacks.cpp */
2781 /************************************************************************/
2783 // client wants to create a guild
2784 void cbClientGuildCreate( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
2785 /// set the leader
2786 void cbClientGuildSetLeader( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
2787 /// set playergrade
2788 void cbClientGuildSetGrade( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
2789 //client asked another to join his guild
2790 void cbClientGuildJoinInvitation( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
2791 //client accept invitation
2792 void cbClientGuildAcceptJoinInvitation( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
2793 //client refused invitation
2794 void cbClientGuildRefuseJoinInvitation( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
2795 /// kick a member
2796 void cbClientGuildKickMember( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
2797 /// quit the guild
2798 void cbClientGuildQuit( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
2799 /// item : bag to guild
2800 //void cbClientBagToGuild( NLNET::CMessage& msgin, const std::string & serviceName, uint16 serviceId );
2801 /// item : guild to bag
2802 //void cbClientGuildToBag( NLNET::CMessage& msgin, const std::string & serviceName, uint16 serviceId );
2803 /// money : bag to guild
2804 void cbClientGuildPutMoney( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
2805 /// money : guild to bag
2806 void cbClientGuildTakeMoney( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
2808 /// outpost callbacks (implemented in guild_client_callbacks.cpp)
2809 void cbClientOutpostSetSquad(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2810 void cbClientOutpostSetSquadSpawnZone(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2811 void cbClientOutpostInsertSquad(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2812 void cbClientOutpostRemoveSquad(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2813 void cbClientOutpostSetExpenseLimit(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2814 //void cbClientOutpostBuyBuilding(NLNET::CMessage & msgin, const std::string & serviceName, uint16 serviceId);
2815 //void cbClientOutpostDestroyBuilding(NLNET::CMessage & msgin, const std::string & serviceName, uint16 serviceId);
2816 void cbClientOutpostSideChosen( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
2817 void cbClientOutpostSelect(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2818 void cbClientOutpostUnselect(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2819 void cbClientOutpostWarStart(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2820 void cbClientOutpostWarValidate(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2821 void cbClientOutpostGiveup(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2822 void cbClientOutpostBanishPlayer(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2823 void cbClientOutpostBanishGuild(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2824 void cbClientOutpostSetDefensePeriod(NLNET::CMessage & msgin, const std::string & serviceName, NLNET::TServiceId serviceId);
2826 // client asked for a lift destination
2827 void cbClientGuildLiftDestAsked( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
2829 CEntityId eId;
2830 msgin.serial( eId );
2831 uint16 session;
2832 msgin.serial(session);
2833 CBuildingManager::getInstance()->fillTriggerPage(eId, session,true );
2836 // client asked for a lift next page
2837 void cbClientGuildLiftNextPage( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
2839 CEntityId eId;
2840 msgin.serial( eId );
2841 uint16 session;
2842 msgin.serial(session);
2843 CBuildingManager::getInstance()->fillTriggerPage(eId, session, false );
2846 // client asked for a lift teleport
2847 void cbClientGuildLiftTeleport( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
2849 CEntityId eId;
2850 msgin.serial( eId );
2851 uint16 index;
2852 msgin.serial(index);
2853 CCharacter * user = PlayerManager.getChar( eId );
2854 if ( user )
2855 CBuildingManager::getInstance()->triggerTeleport(user,index);
2858 void cbClientSetCharacterTitle( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
2860 CEntityId eId;
2861 uint8 title;
2862 msgin.serial( eId );
2863 msgin.serial( title );
2865 CCharacter * c = PlayerManager.getChar(eId);
2866 if ( !c )
2868 nlwarning("<cbClientSetCharacterTitle> Invalid user %s",eId.toString().c_str());
2869 return;
2871 c->setAfkState(false);
2873 const uint32 userId = PlayerManager.getPlayerId(eId);
2874 CPlayer * p = PlayerManager.getPlayer(userId);
2875 if (p == NULL)
2877 nlwarning("<cbClientSetCharacterTitle> Invalid player %u", userId);
2878 return;
2881 if ( title == uint8(CHARACTER_TITLE::FBT) )
2883 if ( !p->isBetaTester() )
2884 return;
2886 else if ( title == uint8(CHARACTER_TITLE::WIND) )
2888 if ( !p->isWindermeerCommunity() )
2889 return;
2891 else if ( title >= uint8(CHARACTER_TITLE::BeginGmTitle) && title <= uint8(CHARACTER_TITLE::EndGmTitle) )
2893 return;
2896 // kxu: TODO: check validity of title chosen by player
2897 c->setNewTitle(CHARACTER_TITLE::toString((CHARACTER_TITLE::ECharacterTitle)title));
2898 c->registerName();
2902 ///////////////////////////////////////////////////////////////////////////////////////////////////
2903 ///////////////////////////////////////////////////////////////////////////////////////////////////
2904 // CLIENT:ITEM_INFO
2905 ///////////////////////////////////////////////////////////////////////////////////////////////////
2906 ///////////////////////////////////////////////////////////////////////////////////////////////////
2907 void cbClientItemInfos( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
2909 CEntityId userId;
2910 uint16 slotId;
2911 msgin.serial(userId,slotId);
2912 CCharacter * user = PlayerManager.getChar(userId);
2913 if ( user && user->getEnterFlag() && TheDataset.isAccessible( user->getEntityRowId() ) )
2914 user->sendItemInfos( slotId );
2917 ///////////////////////////////////////////////////////////////////////////////////////////////////
2918 ///////////////////////////////////////////////////////////////////////////////////////////////////
2919 // CLIENT:MISSION_PREREQ
2920 ///////////////////////////////////////////////////////////////////////////////////////////////////
2921 ///////////////////////////////////////////////////////////////////////////////////////////////////
2922 void cbClientMissionPrereq( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
2924 CEntityId userId;
2925 uint8 slotId;
2926 msgin.serial(userId, slotId);
2927 CCharacter * user = PlayerManager.getChar(userId);
2928 if ( user && user->getEnterFlag() && TheDataset.isAccessible( user->getEntityRowId() ) )
2929 user->sendMissionPrerequisitInfos( slotId );
2933 ///////////////////////////////////////////////////////////////////////////////////////////////////
2934 ///////////////////////////////////////////////////////////////////////////////////////////////////
2935 // CLIENT:DEATH:ASK_RESPAWN
2936 ///////////////////////////////////////////////////////////////////////////////////////////////////
2937 ///////////////////////////////////////////////////////////////////////////////////////////////////
2938 void cbClientAskRespawn( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
2940 CEntityId userId;
2941 uint16 index;
2942 msgin.serial(userId,index);
2944 CCharacter * user = PlayerManager.getChar(userId);
2945 if ( user && user->getEnterFlag() )
2947 user->respawn( index );
2948 user->setAfkState(false);
2952 ///////////////////////////////////////////////////////////////////////////////////////////////////
2953 ///////////////////////////////////////////////////////////////////////////////////////////////////
2954 // CLIENT:TARGET
2955 ///////////////////////////////////////////////////////////////////////////////////////////////////
2956 ///////////////////////////////////////////////////////////////////////////////////////////////////
2957 void cbClientCompassEnableDynamic( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
2959 CEntityId userId;
2960 //TDataSetIndex compressedIndex;
2961 uint32 compressedIndex;
2963 msgin.serial(userId);
2964 msgin.serial(compressedIndex);
2966 TDataSetRow index = TheDataset.getCurrentDataSetRow( compressedIndex );
2967 if ( ! TheDataset.isAccessible(index) )
2969 nlwarning("<cbClientCompassEnableDynamic>: compressed index results in an invalid datasetrow");
2970 return;
2973 CCharacter * user = PlayerManager.getChar(userId);
2974 if ( user && user->getEnterFlag() )
2976 user->setCompassTarget( index );
2980 void cbClientCompassDisableDynamic( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
2982 static const TDataSetRow invalidRow;
2984 CEntityId userId;
2985 msgin.serial(userId);
2987 CCharacter * user = PlayerManager.getChar(userId);
2988 if ( user && user->getEnterFlag() )
2990 user->setCompassTarget( invalidRow );
2995 ///////////////////////////////////////////////////////////////////////////////////////////////////
2996 ///////////////////////////////////////////////////////////////////////////////////////////////////
2997 // CLIENT: PVP choose clan
2998 ///////////////////////////////////////////////////////////////////////////////////////////////////
2999 ///////////////////////////////////////////////////////////////////////////////////////////////////
3001 void cbClientPvpChooseClan( NLNET::CMessage& msgin, const std::string & serviceName, uint16 serviceId )
3003 CEntityId userId;
3004 uint8 clan;
3006 msgin.serial(userId,clan);
3008 CCharacter * user = PlayerManager.getChar(userId);
3009 if ( user && user->getEnterFlag() )
3011 if ( user->getPVPInterface().isValid() )
3012 user->getPVPInterface().setUserClan( clan );
3017 ///////////////////////////////////////////////////////////////////////////////////////////////////
3018 ///////////////////////////////////////////////////////////////////////////////////////////////////
3019 // CLIENT:MISSION
3020 ///////////////////////////////////////////////////////////////////////////////////////////////////
3021 ///////////////////////////////////////////////////////////////////////////////////////////////////
3022 void cbClientMissionEnterCritical( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3024 CEntityId userId;
3025 msgin.serial(userId);
3027 bool accept;
3028 msgin.serial(accept);
3030 CCharacter *player = PlayerManager.getChar(userId);
3031 if (player)
3032 CMissionQueueManager::getInstance()->playerEntersCriticalArea(userId, player->getEnterCriticalZoneProposalQueueId(), accept);
3037 void cbClientMissionWake( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
3039 void cbClientMissionGroupWake( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId );
3041 ///////////////////////////////////////////////////////////////////////////////////////////////////
3042 ///////////////////////////////////////////////////////////////////////////////////////////////////
3043 // CLIENT:DUEL
3044 ///////////////////////////////////////////////////////////////////////////////////////////////////
3045 ///////////////////////////////////////////////////////////////////////////////////////////////////
3047 void cbClientDuelAsked( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3049 CEntityId userId;
3050 msgin.serial(userId);
3051 CPVPManager2::getInstance()->askForDuel( userId );
3054 void cbClientDuelAccept( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3056 CEntityId userId;
3057 msgin.serial(userId);
3058 CPVPManager2::getInstance()->acceptDuel( userId );
3061 void cbClientDuelRefuse( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3063 CEntityId userId;
3064 msgin.serial(userId);
3065 CPVPManager2::getInstance()->refuseDuel( userId );
3068 void cbClientDuelAbandon( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3070 CEntityId userId;
3071 msgin.serial(userId);
3072 CPVPManager2::getInstance()->abandonDuel( userId );
3075 ///////////////////////////////////////////////////////////////////////////////////////////////////
3076 ///////////////////////////////////////////////////////////////////////////////////////////////////
3077 // CLIENT:PVP CHALLENGE
3078 ///////////////////////////////////////////////////////////////////////////////////////////////////
3079 ///////////////////////////////////////////////////////////////////////////////////////////////////
3081 void cbClientPVPChallengeAsked( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3083 CEntityId userId;
3084 msgin.serial(userId);
3085 CPVPManager::getInstance()->askForPVPChallenge( userId );
3088 void cbClientPVPChallengeAccept( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3090 CEntityId userId;
3091 msgin.serial(userId);
3092 CPVPManager::getInstance()->acceptPVPChallenge( userId );
3095 void cbClientPVPChallengeRefuse( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3097 CEntityId userId;
3098 msgin.serial(userId);
3099 CPVPManager::getInstance()->refusePVPChallenge( userId );
3102 void cbClientPVPChallengeAbandon( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3104 CEntityId userId;
3105 msgin.serial(userId);
3106 CCharacter * user = PlayerManager.getChar( userId );
3107 if ( !user )
3109 nlwarning("<PVP>%s is invalid",userId.toString().c_str());
3110 return;
3112 CTeam * team = TeamManager.getTeam( user->getTeamId() );
3113 if ( team && team->getLeader() != userId )
3115 CCharacter::sendDynamicSystemMessage( userId,"CHALLENGE_ABANDON_NOT_LEADER" );
3116 return;
3119 if ( user->getPVPInterface().isValid() )
3120 user->getPVPInterface().leavePVP( IPVP::AbandonChallenge );
3123 ///////////////////////////////////////////////////////////////////////////////////////////////////
3124 ///////////////////////////////////////////////////////////////////////////////////////////////////
3125 // CLIENT:PVP FACTION / GUILDE / ALLEGIANCE
3126 ///////////////////////////////////////////////////////////////////////////////////////////////////
3127 ///////////////////////////////////////////////////////////////////////////////////////////////////
3128 void cbClientPvPSetTag( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3130 CEntityId charId;
3131 msgin.serial(charId);
3133 bool tagPVP = false;
3134 uint8 flag;
3135 msgin.serial(flag);
3136 if(flag) tagPVP = true;
3138 CCharacter * c = PlayerManager.getOnlineChar(charId);
3139 if( c != 0)
3141 c->setPVPFlag( tagPVP );
3143 else
3145 nlwarning("<cbClientPvPSetTag> %s is invalid", charId.toString().c_str());
3149 void cbClientPvPSetNeutralAllegiance( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3151 CEntityId charId;
3152 msgin.serial(charId);
3154 uint8 allegianceU8;
3155 msgin.serial(allegianceU8);
3157 PVP_CLAN::TPVPClan allegiance = (PVP_CLAN::TPVPClan)allegianceU8;
3159 CCharacter * c = PlayerManager.getOnlineChar(charId);
3160 if( c != 0)
3162 c->setAllegianceFromIndeterminedStatus(allegiance);
3164 else
3166 nlwarning("<cbClientPvPSetNeutralAllegiance> %s is invalid", charId.toString().c_str());
3170 void cbClientPvPSetNeutralAllegianceGuild( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3172 CEntityId charId;
3173 msgin.serial(charId);
3175 uint8 allegianceU8;
3176 msgin.serial(allegianceU8);
3178 PVP_CLAN::TPVPClan allegiance = (PVP_CLAN::TPVPClan)allegianceU8;
3180 CCharacter * c = PlayerManager.getOnlineChar(charId);
3181 if( c != 0)
3183 CGuild * guild = CGuildManager::getInstance()->getGuildFromId(c->getGuildId());
3184 if( guild )
3186 CGuildMember * gm = guild->getMemberFromEId(charId);
3187 if( gm->getGrade() == EGSPD::CGuildGrade::Leader )
3189 guild->setAllegianceFromIndeterminedStatus(allegiance);
3191 else
3193 CCharacter::sendDynamicSystemMessage( charId,"GUILD_INSUFFICIENT_GRADE" );
3196 else
3198 nlwarning("<cbClientPvPSetNeutralAllegianceGuild> Player Character % have no guild", charId.toString().c_str());
3201 else
3203 nlwarning("<cbClientPvPSetNeutralAllegiance> %s is invalid", charId.toString().c_str());
3208 ///////////////////////////////////////////////////////////////////////////////////////////////////
3209 void cbClientQuitGameRequest( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3211 CEntityId charId;
3212 bool bypassDisconnectionTimer = false;
3216 msgin.serial(charId);
3217 CPlayer *player = PlayerManager.getPlayer(uint32(charId.getShortId()) >> 4);
3219 if (IsRingShard)
3220 bypassDisconnectionTimer = true;
3221 /*else
3223 msgin.serial(bypassDisconnectionTimer);
3224 if (bypassDisconnectionTimer)
3226 // For fast-disconnection on a mainland shard, one needs to produce credentials!
3227 H_AUTO(BypassDiscoTimer);
3228 CSecurityCheckForFastDisconnection securityCheck;
3229 securityCheck.receiveSecurityCode(msgin);
3230 if (player)
3231 securityCheck.setCookie(player->getLoginCookie()); // if not set (null player), the check won't pass
3233 securityCheck.check("QtXp1o1t?");
3237 if (IsDevShard || (player != NULL && player->havePriv( ":DEV:SGM:GM:" )))
3238 bypassDisconnectionTimer = true;
3240 catch (const Exception &e) // will catch any serialization/security exception
3242 GIVEUP_IF(charId.isUnknownId(), "cbClientQuitGameRequest: unknown char", return);
3243 nldebug("BypassDisconnectionTimer denied for %s: %s", charId.toString().c_str(), e.what());
3244 bypassDisconnectionTimer = false;
3247 TDataSetRow rowId = TheDataset.getDataSetRow(charId);
3248 const uint32 playerId = PlayerManager.getPlayerId(charId);
3250 if (!rowId.isValid())
3252 PlayerManager.disconnectPlayer(playerId);
3254 else
3256 // stop all phrases in execution for character
3257 CPhraseManager::getInstance().cancelAllPhrases(rowId);
3259 if (bypassDisconnectionTimer)
3261 // send the disconnection acknowledgement at once
3262 PlayerManager.disconnectPlayer(playerId);
3264 else
3266 // add disconnection phrase in manager
3267 static CSheetId decoBrick("bapa02.sbrick");
3268 vector<CSheetId> bricks;
3269 bricks.push_back(decoBrick);
3270 if ( CPhraseManager::getInstance().executePhrase(rowId, rowId, bricks) == NULL )
3272 // error while building the phrase, can happen when character isn't really online (connection failed)
3273 PlayerManager.userDisconnected( playerId ); // still waits for the timer before really disconnecting
3279 ///////////////////////////////////////////////////////////////////////////////////////////////////
3280 void cbClientReturnToMainland( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3282 uint32 userId;
3283 msgin.serial(userId);
3284 uint8 charIndex;
3285 msgin.serial(charIndex);
3286 TSessionId rejectedSessionId;
3287 msgin.serial(rejectedSessionId);
3289 CCharacter *character = PlayerManager.getChar( userId, (uint32)charIndex );
3290 if (character)
3291 character->returnToPreviousSession( userId, (sint32)charIndex, rejectedSessionId );
3292 else
3293 nlwarning( "Char not found for %u/%u", userId, (uint)charIndex );
3297 ///////////////////////////////////////////////////////////////////////////////////////////////////
3298 ///////////////////////////////////////////////////////////////////////////////////////////////////
3299 // CLIENT:EVENT
3300 ///////////////////////////////////////////////////////////////////////////////////////////////////
3301 ///////////////////////////////////////////////////////////////////////////////////////////////////
3303 /// returns 0 on success, anything else is error:
3304 /// -1: Invalid inventory
3305 /// -2: Invalid slot
3306 /// -3: Empty slot
3307 sint32 clientEventSetItemCustomText(CCharacter* character, INVENTORIES::TInventory inventory, uint32 slot, ucstring const& text)
3309 if (inventory==INVENTORIES::UNDEFINED)
3311 return -1;
3313 CInventoryPtr invent = character->getInventory(inventory);
3314 if (slot >= invent->getSlotCount())
3316 return -2;
3318 if (invent->getItem(slot) == NULL)
3320 return -3;
3323 CGameItemPtr item = invent->getItem(slot);
3324 item->setCustomText(text);
3325 // Following line was commented out by trap, reason unknown
3326 character->incSlotVersion(inventory, slot);
3328 return 0;
3331 void cbClientEventSetItemCustomText( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3333 CEntityId eid;
3334 INVENTORIES::TInventory inventory;
3335 uint32 uiInventory;
3336 uint32 slot;
3337 ucstring text;
3338 msgin.serial(eid);
3339 msgin.serial(uiInventory);
3340 inventory = (INVENTORIES::TInventory)uiInventory;
3341 msgin.serial(slot);
3342 msgin.serial(text);
3344 CCharacter* character = PlayerManager.getChar(eid);
3345 if(!character) return;
3347 if (!character->havePriv(":DEV:SGM:GM:EM:"))
3349 // it should be the crafter of the item, check
3350 if (inventory==INVENTORIES::UNDEFINED) return;
3351 CInventoryPtr invent = character->getInventory(inventory);
3352 if (slot >= invent->getSlotCount()) return;
3353 if (invent->getItem(slot) == NULL) return;
3354 CGameItemPtr item = invent->getItem(slot);
3356 const NLMISC::CEntityId &crafterEId = item->getCreator();
3357 const NLMISC::CEntityId &userEId = character->getId();
3359 if(crafterEId != userEId)
3361 string name = CEntityIdTranslator::getInstance()->getByEntity(userEId).toString();
3362 nlwarning("HACK: %s %s tries to set custom text on an item he didn't crafted", userEId.toString().c_str(), name.c_str());
3363 return;
3366 // text must not be too big
3367 if(text.size() > 256)
3369 string name = CEntityIdTranslator::getInstance()->getByEntity(userEId).toString();
3370 nlwarning("HACK: %s %s tries to set custom text of a size > 256 (%d)", userEId.toString().c_str(), name.c_str(), text.size());
3371 return;
3374 // the item must have the good family
3375 const CStaticItem * form = item->getStaticForm();
3376 if (!form) return;
3377 ITEMFAMILY::EItemFamily family = form->Family;
3378 if (!ITEMFAMILY::isTextCustomizable(family))
3380 string name = CEntityIdTranslator::getInstance()->getByEntity(userEId).toString();
3381 nlwarning("HACK: %s %s tries to set custom text on a item that is not text customizable (%s)", userEId.toString().c_str(), name.c_str(), ITEMFAMILY::toString(family).c_str());
3382 return;
3385 // prevent use of @WEB at begin
3386 if (text.size() > 3 && text[0]=='@' && text[1]=='W' && text[2]=='E' && text[3]=='B')
3387 text = text.substr(4, text.size() - 4);
3389 // prevent use of @LUA at begin
3390 if (text.size() > 3 && text[0]=='@' && text[1]=='L' && text[2]=='U' && text[3]=='A')
3391 text = text.substr(4, text.size() - 4);
3393 // force that the begin of the text for non admin is %mfc
3394 if(!text.empty() && text.substr(0, 4) != ucstring("%mfc"))
3396 text = ucstring("%mfc") + text;
3400 clientEventSetItemCustomText(character, inventory, slot, text);
3405 ///////////////////////////////////////////////////////////////////////////////////////////////////
3406 ///////////////////////////////////////////////////////////////////////////////////////////////////
3407 // CLIENT:TOTEM
3408 ///////////////////////////////////////////////////////////////////////////////////////////////////
3409 ///////////////////////////////////////////////////////////////////////////////////////////////////
3410 void cbTotemBuild( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3412 if( BuildSpireActive == false )
3413 return;
3414 CEntityId Id;
3415 msgin.serial( Id );
3417 CCharacter *ch = PlayerManager.getChar( Id );
3419 if ( !ch )
3421 nlwarning("Totem build aborted: no character");
3422 return;
3424 if ( !ch->getPVPFlag() )
3426 nlwarning("Totem build aborted: character has no pvp flag");
3427 return;
3430 CGuild::TAllegiances allegiance = ch->getAllegiance();
3431 if ( allegiance.first == PVP_CLAN::Neutral )
3433 nlwarning("Totem build aborted: character has no cult allegiance");
3434 return;
3436 NLMISC::CVector pos( (float)ch->getX() / 1000.0f, (float)ch->getY() / 1000.0f, 0 );
3437 CRegion* region = CZoneManager::getInstance().getRegion( pos );
3439 if ( !region )
3441 nlwarning("Totem build aborted: no region where character is");
3442 return;
3444 if ( !CPVPFactionRewardManager::getInstance().canBuildTotem( ch ) )
3446 nlwarning("Totem build aborted: can't build totem");
3447 return;
3449 CPVPFactionRewardManager::getInstance().startTotemBuilding( region->getId(), ch );
3450 nlinfo( "<cbTotemBuild> : %s is building a totem in region %s", Id.toString().c_str(), region->getName().c_str() );
3456 ///////////////////////////////////////////////////////////////////////////////////////////////////
3457 ///////////////////////////////////////////////////////////////////////////////////////////////////
3458 // CLIENT:DM_GIFT
3459 ///////////////////////////////////////////////////////////////////////////////////////////////////
3460 ///////////////////////////////////////////////////////////////////////////////////////////////////
3461 void cbDMGiftBegin( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3463 CEntityId eid;
3464 msgin.serial( eid );
3466 if(!IsRingShard)
3468 string name = CEntityIdTranslator::getInstance()->getByEntity(eid).toString();
3469 nlwarning("HACK: %s %s tries to start a GM gift on a non ring shard", eid.toString().c_str(), name.c_str());
3470 return;
3473 CR2MissionItem::getInstance().dmGiftBegin( eid );
3476 void cbDMGiftValidate( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3478 CEntityId eid;
3479 msgin.serial( eid );
3481 if(!IsRingShard)
3483 string name = CEntityIdTranslator::getInstance()->getByEntity(eid).toString();
3484 nlwarning("HACK: %s %s tries to validate a GM gift on a non ring shard", eid.toString().c_str(), name.c_str());
3485 return;
3488 std::vector< R2::TItemAndQuantity > items;
3489 CSheetId sheet;
3490 uint8 quantity;
3492 while( msgin.getPos() < (sint32) msgin.length() )
3494 msgin.serial( sheet );
3495 msgin.serial( quantity );
3496 if( sheet != CSheetId::Unknown && quantity != 0)
3498 R2::TItemAndQuantity item;
3499 item.SheetId = sheet;
3500 item.Quantity = quantity;
3502 const CStaticItem * form = CSheets::getForm(sheet);
3503 if (form == NULL)
3505 string name = CEntityIdTranslator::getInstance()->getByEntity(eid).toString();
3506 nlwarning("HACK: %s %s tries to create an item that has a null form", eid.toString().c_str(), name.c_str());
3507 return;
3509 if(form->Family != ITEMFAMILY::SCROLL_R2)
3511 string name = CEntityIdTranslator::getInstance()->getByEntity(eid).toString();
3512 nlwarning("HACK: %s %s tries to create an item that is not a plot item", eid.toString().c_str(), name.c_str());
3513 return;
3515 items.push_back( item );
3518 CR2MissionItem::getInstance().dmGiftValidate( eid, items );
3522 ///////////////////////////////////////////////////////////////////////////////////////////////////
3523 ///////////////////////////////////////////////////////////////////////////////////////////////////
3524 // CLIENT:RING_MISSION
3525 ///////////////////////////////////////////////////////////////////////////////////////////////////
3526 ///////////////////////////////////////////////////////////////////////////////////////////////////
3527 void cbRingMissionSelectAction( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3529 CEntityId eid;
3530 uint32 actionId;
3532 msgin.serial( eid );
3533 msgin.serial( actionId );
3535 CCharacter *ch = PlayerManager.getChar( eid );
3536 if( ch )
3538 CR2GiveItem::getInstance().giveItemGranted( ch->getTargetDataSetRow(), actionId );
3543 ///////////////////////////////////////////////////////////////////////////////////////////////////
3544 ///////////////////////////////////////////////////////////////////////////////////////////////////
3545 // CLIENT:NPC_ICON
3546 ///////////////////////////////////////////////////////////////////////////////////////////////////
3547 ///////////////////////////////////////////////////////////////////////////////////////////////////
3548 void cbGetNpcIconDesc( NLNET::CMessage& msgin, const std::string & serviceName, NLNET::TServiceId serviceId )
3550 CEntityId eid;
3551 vector<uint32> npcKeys;
3553 msgin.serial( eid );
3554 msgin.serialCont( npcKeys );
3556 CCharacter *ch = PlayerManager.getChar( eid );
3557 if( ch )
3559 ch->sendNpcMissionGiverIconDesc( npcKeys );
3564 //----------------------------
3565 // CbClientArray
3566 //----------------------------
3567 TUnifiedCallbackItem CbClientArray[]=
3569 { "CLIENT:CONNECTION:CLIENT_QUIT_REQUEST", cbClientQuitGameRequest },
3570 { "RET_MAINLAND", cbClientReturnToMainland },
3572 { "CLIENT:ITEM:DROP", cbClientItemDrop },
3573 { "CLIENT:ITEM:PICK_UP_CLOSE", cbClientItemPickUpClose },
3574 { "CLIENT:ITEM:SWAP", cbClientItemSwap },
3575 { "CLIENT:ITEM:HARVEST", cbClientItemHarvest },
3576 { "CLIENT:ITEM:HARVEST_CLOSE", cbClientItemHarvestClose },
3577 { "CLIENT:ITEM:DESTROY", cbClientItemDestroy },
3578 { "CLIENT:ITEM:EQUIP", cbClientItemEquip },
3579 { "CLIENT:ITEM:UNEQUIP", cbClientItemUnequip },
3580 { "CLIENT:ITEM:TEMP_TO_BAG", cbClientItemTempToBag },
3581 { "CLIENT:ITEM:ALL_TEMP", cbClientItemAllTemp },
3582 { "CLIENT:ITEM:NO_TEMP", cbClientItemNoTemp },
3583 { "CLIENT:ITEM:ENCHANT", cbClientItemEnchant },
3584 { "CLIENT:ITEM:USE_ITEM", cbClientItemUseItem },
3585 { "CLIENT:ITEM:STOP_USE_XP_CAT", cbClientItemStopUseXpCat },
3588 { "CLIENT:ITEM_INFO:GET", cbClientItemInfos },
3589 { "CLIENT:MISSION_PREREQ:GET", cbClientMissionPrereq },
3591 { "CLIENT:HARVEST:DEPOSIT", cbClientHarvestDeposit },
3593 { "CLIENT:PHRASE:MEMORIZE", cbClientPhraseMemorize },
3594 { "CLIENT:PHRASE:FORGET", cbClientPhraseForget },
3595 { "CLIENT:PHRASE:LEARN", cbClientPhraseLearn },
3596 { "CLIENT:PHRASE:DELETE", cbClientPhraseDelete },
3597 { "CLIENT:PHRASE:EXECUTE", cbClientPhraseExecute },
3598 { "CLIENT:PHRASE:EXECUTE_CYCLIC", cbClientPhraseExecuteCyclic },
3599 { "CLIENT:PHRASE:EXECUTE_FABER", cbClientPhraseExecuteFaber },
3600 { "CLIENT:PHRASE:BUY", cbClientPhraseBuyByIndex },
3601 { "CLIENT:PHRASE:BUY_SHEET", cbClientPhraseBuyBySheet },
3603 { "CLIENT:PHRASE:CANCEL_TOP", cbClientPhraseCancelTop },
3604 { "CLIENT:PHRASE:CANCEL_ALL", cbClientPhraseCancelAll },
3605 { "CLIENT:PHRASE:CRISTALIZE", cbClientPhraseCristalize },
3608 { "CLIENT:COMBAT:ENGAGE", cbClientCombatEngage },
3609 { "CLIENT:COMBAT:DISENGAGE", cbClientCombatDisengage },
3610 { "CLIENT:COMBAT:DEFAULT_ATTACK", cbClientCombatDefaultAttack },
3611 { "CLIENT:COMBAT:VALIDATE_MELEE", cbClientValidateMeleeCombat },
3612 { "CLIENT:COMBAT:PARRY", cbClientCombatParry },
3613 { "CLIENT:COMBAT:DODGE", cbClientCombatDodge },
3614 { "CLIENT:COMBAT:PROTECTED_SLOT", cbClientCombatProtectedSlot },
3616 { "CLIENT:TEAM:LEAVE", cbClientTeamLeave },
3617 { "CLIENT:TEAM:JOIN", cbClientTeamJoin },
3618 { "CLIENT:TEAM:KICK", cbClientTeamKick },
3619 { "CLIENT:TEAM:JOIN_PROPOSAL", cbClientTeamJoinProposal },
3620 { "CLIENT:TEAM:JOIN_PROPOSAL_DECLINE", cbClientTeamJoinProposalDecline },
3621 { "CLIENT:TEAM:SET_SUCCESSOR", cbClientTeamSetSuccessor },
3623 { "CLIENT:TEAM:SHARE_VALID_ITEM", cbClientTeamShareValidItem },
3624 { "CLIENT:TEAM:SHARE_INVALID_ITEM", cbClientTeamShareInvalidItem },
3625 { "CLIENT:TEAM:SHARE_VALID", cbClientTeamShareValid },
3627 { "CLIENT:TEAM:CONTACT_ADD", cbClientAddToContactList },
3628 { "CLIENT:TEAM:CONTACT_DEL", cbClientRemoveFromContactList },
3629 { "CLIENT:TEAM:CONTACT_MOVE", cbClientMoveInContactLists },
3632 // { "CLIENT:TP:BOT", cbClientTpBot },
3633 // { "CLIENT:TP:WANTED", cbClientTpWanted },
3634 { "CLIENT:TP:ACK", cbClientTpAck },
3635 // { "CLIENT:TP:RESPAWN", cbClientTpRespawn },
3637 // { "CLIENT:ANIMALS:DISBAND_CONVOY", cbClientAnimalsDisbandConvoy },
3638 { "CLIENT:ANIMALS:BEAST", cbClientAnimalsBeast },
3639 // { "CLIENT:ANIMALS:MOUNT", cbAnimalMount },
3640 // { "CLIENT:ANIMALS:UNSEAT", cbAnimalUnseat },
3643 { "CLIENT:TRADE:NEXT_PAGE_ITEM", cbClientTradeNextPage },
3644 { "CLIENT:TRADE:NEXT_PAGE_MISSION_ITEM",cbClientTradeMissionNextPage },
3645 { "CLIENT:TRADE:BUY", cbClientTradeBuy },
3646 { "CLIENT:TRADE:QUERY_PRICE", cbClientTradeQuerySellPrice },
3647 { "CLIENT:TRADE:SELL", cbClientTradeSellItem },
3650 { "CLIENT:EXCHANGE:PROPOSAL", cbClientExchangeProposal },
3651 { "CLIENT:EXCHANGE:ACCEPT_INVITATION", cbClientExchangeAcceptInvitation },
3652 { "CLIENT:EXCHANGE:DECLINE_INVITATION", cbClientExchangeDeclineInvitation },
3653 { "CLIENT:EXCHANGE:SEEDS", cbClientExchangeSeeds },
3654 { "CLIENT:EXCHANGE:END", cbClientExchangeEnd },
3655 { "CLIENT:EXCHANGE:VALIDATE", cbClientExchangeValidate },
3656 { "CLIENT:EXCHANGE:INVALIDATE", cbClientExchangeInvalidate },
3657 { "CLIENT:EXCHANGE:ADD", cbClientExchangeAdd },
3658 { "CLIENT:EXCHANGE:REMOVE", cbClientExchangeRemove },
3661 // { "CLIENT:SENTENCE:CANCEL_CURRENT", cbClientSentenceCancelCurrent },
3662 // { "CLIENT:SENTENCE:CANCEL", cbClientSentenceCancel },
3663 // { "CLIENT:SENTENCE:CANCEL_ALL", cbClientSentenceCancelAll },
3665 { "CLIENT:COMMAND:EMOTE", cbClientSendEmote },
3666 { "CLIENT:COMMAND:CUSTOM_EMOTE", cbClientSendCustomEmote },
3667 { "CLIENT:COMMAND:WHERE", cbClientSendWhere },
3668 { "CLIENT:COMMAND:ADMIN", cbClientAdmin },
3669 { "CLIENT:COMMAND:ADMIN_OFFLINE", cbClientAdminOffline },
3670 { "CLIENT:COMMAND:REMOTE_ADMIN_ANSWER", cbClientRemoteAdmin },
3671 { "CLIENT:COMMAND:SIT", cbClientSit },
3672 { "CLIENT:COMMAND:AFK", cbClientSendAfk },
3673 { "CLIENT:COMMAND:SELFKILL", cbClientSelfKill },
3674 { "CLIENT:COMMAND:RANDOM", cbClientRollDice },
3675 { "CLIENT:COMMAND:GUILDMOTD", cbClientGuildMotd },
3676 { "CLIENT:COMMAND:AUTOPACT", cbClientAutoPact },
3679 // For all these commented commands, now you have to use the CLIENT:COMMAND:ADMIN message using /a client command
3681 // { "CLIENT:CHEAT:GOD", cbClientCheatGod },
3682 // { "CLIENT:CHEAT:CREATE_ITEM_IN_BAG", cbClientCreateItemInBag },
3683 // { "CLIENT:CHEAT:LEARN_ALL_BRICKS", cbClientLearnAllBricks },
3684 // { "CLIENT:CHEAT:MONEY", cbClientMoney },
3685 // { "CLIENT:CHEAT:SET_TIME", cbClientRyzomTime },
3686 // { "CLIENT:CHEAT:SET_DAY", cbClientRyzomDay },
3687 // { "CLIENT:CHEAT:XP", cbClientGainXp },
3688 // { "CLIENT:CHEAT:CREATE_CHARACTER", cbClientCreateCharacter },
3689 // { "CLIENT:CHEAT:ADD_ROLE", cbClientAddRole },
3690 // { "CLIENT:CHEAT:LEARN_BRICK", cbClientLearnBrick },
3691 // { "CLIENT:CHEAT:LEARN_ALL_FABER_PLANS", cbClientLearnAllFaberPlans },
3693 { "CLIENT:DEBUG:WHERE", cbClientWhere },
3694 { "CLIENT:DEBUG:WHO", cbClientWho },
3695 { "CLIENT:DEBUG:PING", cbClientPing },
3697 { "CLIENT:BOTCHAT:START_CHOOSE_MISSION", cbClientBotChatChooseStaticMission },
3698 { "CLIENT:BOTCHAT:NEXT_PAGE_MISSION", cbClientBotChatNextMissionPage },
3699 { "CLIENT:BOTCHAT:PICK_MISSION", cbClientBotChatPickStaticMission },
3700 { "CLIENT:BOTCHAT:CONTINUE_MISSION", cbClientContinueMission },
3701 { "CLIENT:BOTCHAT:VALIDATE_PLAYER_GIFT", cbClientValidateMissionGift },
3704 { "CLIENT:BOTCHAT:START_TRADE_ITEM", cbClientBotChatStartTradeItem },
3705 { "CLIENT:BOTCHAT:START_TRADE_TELEPORT", cbClientBotChatStartTradeTp },
3706 { "CLIENT:BOTCHAT:START_TRADE_FACTION", cbClientBotChatStartTradeFaction },
3708 { "CLIENT:BOTCHAT:START_TRADE_GUILD_OPTIONS", cbClientBotChatStartTradeGuildOptions },
3709 { "CLIENT:BOTCHAT:BUY_GUILD_OPTION", cbClientBotChatBuyGuildOptions },
3710 { "CLIENT:BOTCHAT:START_GUILD_RESEARCH", cbClientBotChatStartGuildResearch },
3713 /* { "CLIENT:BOTCHAT:START_TRADE_SKILL", cbClientBotChatStartTradeSkill },
3714 { "CLIENT:BOTCHAT:START_TRADE_PACT", cbClientBotChatStartTradePact },*/
3715 { "CLIENT:BOTCHAT:START_TRADE_ACTION", cbClientBotChatStartTradeAction },
3717 { "CLIENT:BOTCHAT:SET_FILTERS", cbClientBotChatSetFilters },
3720 { "CLIENT:BOTCHAT:NEXT_PAGE_ITEM", cbClientBotChatTradeNextPage },
3721 { "CLIENT:BOTCHAT:BUY", cbClientBotChatTradeBuy },
3722 { "CLIENT:BOTCHAT:DESTROY_ITEM", cbClientBotChatTradeDestroy },
3723 { "CLIENT:BOTCHAT:SELL", cbClientBotChatTradeSell },
3724 { "CLIENT:BOTCHAT:REFRESH_TRADE_LIST", cbRefreshTradeList },
3726 { "CLIENT:BOTCHAT:START_CREATE_GUILD", cbClientBotChatStartGuildCreation },
3728 { "CLIENT:BOTCHAT:END", cbClientBotChatEnd },
3729 { "CLIENT:BOTCHAT:END_GIFT", cbClientBotChatEndGift },
3731 { "CLIENT:BOTCHAT:DYNCHAT_SEND", cbClientBotChatDynChatSend },
3734 // mission journal related commands
3735 { "CLIENT:JOURNAL:MISSION_ABANDON", cbClientAbandonMission },
3736 { "CLIENT:JOURNAL:GROUP_MISSION_ABANDON", cbClientGroupAbandonMission },
3738 // guild related messages
3739 { "CLIENT:GUILD:CREATE", cbClientGuildCreate },
3740 { "CLIENT:GUILD:INVITATION", cbClientGuildJoinInvitation },
3741 { "CLIENT:GUILD:ACCEPT_INVITATION", cbClientGuildAcceptJoinInvitation },
3742 { "CLIENT:GUILD:REFUSE_INVITATION", cbClientGuildRefuseJoinInvitation },
3744 { "CLIENT:GUILD:SET_GRADE", cbClientGuildSetGrade },
3745 { "CLIENT:GUILD:KICK_MEMBER", cbClientGuildKickMember },
3748 { "CLIENT:GUILD:QUIT", cbClientGuildQuit },
3749 { "CLIENT:GUILD:TELEPORT", cbClientGuildLiftTeleport },
3750 { "CLIENT:GUILD:FIRST_ASCENSOR_PAGE", cbClientGuildLiftDestAsked },
3751 { "CLIENT:GUILD:NEXT_ASCENSOR_PAGE", cbClientGuildLiftNextPage },
3752 { "CLIENT:GUILD:SET_PLAYER_TITLE", cbClientSetCharacterTitle },
3753 //{ "CLIENT:GUILD:BAG_TO_GUILD", cbClientBagToGuild },
3754 //{ "CLIENT:GUILD:GUILD_TO_BAG", cbClientGuildToBag },
3755 { "CLIENT:GUILD:PUT_MONEY", cbClientGuildPutMoney },
3756 { "CLIENT:GUILD:TAKE_MONEY", cbClientGuildTakeMoney },
3758 // outpost related messages
3759 { "CLIENT:OUTPOST:SET_SQUAD", cbClientOutpostSetSquad },
3760 { "CLIENT:OUTPOST:SET_SQUAD_SPAWN", cbClientOutpostSetSquadSpawnZone },
3761 { "CLIENT:OUTPOST:INSERT_SQUAD", cbClientOutpostInsertSquad },
3762 { "CLIENT:OUTPOST:REMOVE_SQUAD", cbClientOutpostRemoveSquad },
3763 { "CLIENT:OUTPOST:SET_SQUAD_CAPITAL", cbClientOutpostSetExpenseLimit },
3764 // { "CLIENT:OUTPOST:BUY_BUILDING", cbClientOutpostBuyBuilding },
3765 // { "CLIENT:OUTPOST:DESTROY_BUILDING", cbClientOutpostDestroyBuilding },
3766 { "CLIENT:OUTPOST:SIDE_CHOSEN", cbClientOutpostSideChosen },
3767 { "CLIENT:OUTPOST:SELECT", cbClientOutpostSelect },
3768 { "CLIENT:OUTPOST:UNSELECT", cbClientOutpostUnselect },
3769 { "CLIENT:OUTPOST:DECLARE_WAR_START", cbClientOutpostWarStart },
3770 { "CLIENT:OUTPOST:DECLARE_WAR_VALIDATE", cbClientOutpostWarValidate },
3771 { "CLIENT:OUTPOST:GIVEUP_OUTPOST", cbClientOutpostGiveup },
3772 { "CLIENT:OUTPOST:BANISH_PLAYER", cbClientOutpostBanishPlayer },
3773 { "CLIENT:OUTPOST:BANISH_GUILD", cbClientOutpostBanishGuild },
3774 { "CLIENT:OUTPOST:SET_DEF_PERIOD", cbClientOutpostSetDefensePeriod },
3776 // death management messages
3777 { "CLIENT:DEATH:ASK_RESPAWN", cbClientAskRespawn },
3779 // set compass target
3780 { "CLIENT:TARGET:COMPASS_DYNAMIC", cbClientCompassEnableDynamic },
3781 { "CLIENT:TARGET:COMPASS_NOT_DYNAMIC", cbClientCompassDisableDynamic },
3783 { "CLIENT:DUEL:ASK", cbClientDuelAsked },
3784 { "CLIENT:DUEL:ACCEPT", cbClientDuelAccept },
3785 { "CLIENT:DUEL:REFUSE", cbClientDuelRefuse },
3786 { "CLIENT:DUEL:ABANDON", cbClientDuelAbandon },
3788 { "CLIENT:PVP_CHALLENGE:ASK", cbClientLeagueJoinProposal },
3789 { "CLIENT:PVP_CHALLENGE:ACCEPT", cbClientLeagueJoin },
3790 { "CLIENT:PVP_CHALLENGE:REFUSE", cbClientLeagueJoinProposalDecline },
3791 { "CLIENT:PVP_CHALLENGE:ABANDON", cbClientPVPChallengeAbandon },
3793 // { "CLIENT:PVP_VERSUS:CLAN", cbClientPvpChooseClan },
3794 { "CLIENT:PVP:PVP_TAG", cbClientPvPSetTag },
3795 { "CLIENT:PVP:SET_NEUTRAL_ALLEGIANCE", cbClientPvPSetNeutralAllegiance },
3796 { "CLIENT:PVP:SET_NEUTRAL_ALLEGIANCE_GUILD",cbClientPvPSetNeutralAllegianceGuild },
3798 { "CLIENT:MISSION:ENTER_CRITICAL", cbClientMissionEnterCritical },
3799 { "CLIENT:MISSION:WAKE", cbClientMissionWake },
3800 { "CLIENT:MISSION:GROUP_WAKE", cbClientMissionGroupWake },
3802 { "CLIENT:EVENT:SET_ITEM_CUSTOM_TEXT", cbClientEventSetItemCustomText },
3804 { "CLIENT:TOTEM:BUILD", cbTotemBuild },
3806 { "CLIENT:DM_GIFT:BEGIN", cbDMGiftBegin },
3807 { "CLIENT:DM_GIFT:VALIDATE", cbDMGiftValidate },
3809 { "CLIENT:RING_MISSION:MISSION_RING_SELECT",cbRingMissionSelectAction },
3811 { "CLIENT:NPC_ICON:GET_DESC", cbGetNpcIconDesc },
3816 void CClientMessages::init()
3818 // setup the callback array
3819 CUnifiedNetwork::getInstance()->addCallbackArray( CbClientArray, sizeof(CbClientArray)/sizeof(CbClientArray[0]) );
3822 void CClientMessages::release()