[6982] Implemented gmlevel-based command security
[getmangos.git] / src / game / Level1.cpp
blobd42141d0d5ef099377a0dd4b94e9bdcc018d9628
1 /*
2 * Copyright (C) 2005-2008 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "Common.h"
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
23 #include "World.h"
24 #include "ObjectMgr.h"
25 #include "Player.h"
26 #include "Opcodes.h"
27 #include "Chat.h"
28 #include "Log.h"
29 #include "MapManager.h"
30 #include "ObjectAccessor.h"
31 #include "Language.h"
32 #include "CellImpl.h"
33 #include "InstanceSaveMgr.h"
34 #include "Util.h"
35 #ifdef _DEBUG_VMAPS
36 #include "VMapFactory.h"
37 #endif
39 bool ChatHandler::HandleNpcSayCommand(const char* args)
41 if(!*args)
42 return false;
44 Creature* pCreature = getSelectedCreature();
45 if(!pCreature)
47 SendSysMessage(LANG_SELECT_CREATURE);
48 SetSentErrorMessage(true);
49 return false;
52 pCreature->Say(args, LANG_UNIVERSAL, 0);
54 return true;
57 bool ChatHandler::HandleNpcYellCommand(const char* args)
59 if(!*args)
60 return false;
62 Creature* pCreature = getSelectedCreature();
63 if(!pCreature)
65 SendSysMessage(LANG_SELECT_CREATURE);
66 SetSentErrorMessage(true);
67 return false;
70 pCreature->Yell(args, LANG_UNIVERSAL, 0);
72 return true;
75 //show text emote by creature in chat
76 bool ChatHandler::HandleNpcTextEmoteCommand(const char* args)
78 if(!*args)
79 return false;
81 Creature* pCreature = getSelectedCreature();
83 if(!pCreature)
85 SendSysMessage(LANG_SELECT_CREATURE);
86 SetSentErrorMessage(true);
87 return false;
90 pCreature->TextEmote(args, 0);
92 return true;
95 // make npc whisper to player
96 bool ChatHandler::HandleNpcWhisperCommand(const char* args)
98 if(!*args)
99 return false;
101 char* receiver_str = strtok((char*)args, " ");
102 char* text = strtok(NULL, "");
104 uint64 guid = m_session->GetPlayer()->GetSelection();
105 Creature* pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid);
107 if(!pCreature || !receiver_str || !text)
109 return false;
112 uint64 receiver_guid= atol(receiver_str);
114 // check online security
115 if (HasLowerSecurity(objmgr.GetPlayer(receiver_guid), 0))
116 return false;
118 pCreature->Whisper(text,receiver_guid);
120 return true;
123 // global announce
124 bool ChatHandler::HandleAnnounceCommand(const char* args)
126 if(!*args)
127 return false;
129 sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args);
130 return true;
133 //notification player at the screen
134 bool ChatHandler::HandleNotifyCommand(const char* args)
136 if(!*args)
137 return false;
139 std::string str = GetMangosString(LANG_GLOBAL_NOTIFY);
140 str += args;
142 WorldPacket data(SMSG_NOTIFICATION, (str.size()+1));
143 data << str;
144 sWorld.SendGlobalMessage(&data);
146 return true;
149 //Enable\Dissable GM Mode
150 bool ChatHandler::HandleGMmodeCommand(const char* args)
152 if(!*args)
154 if(m_session->GetPlayer()->isGameMaster())
155 m_session->SendNotification(LANG_GM_ON);
156 else
157 m_session->SendNotification(LANG_GM_OFF);
158 return true;
161 std::string argstr = (char*)args;
163 if (argstr == "on")
165 m_session->GetPlayer()->SetGameMaster(true);
166 m_session->SendNotification(LANG_GM_ON);
167 #ifdef _DEBUG_VMAPS
168 VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager();
169 vMapManager->processCommand("stoplog");
170 #endif
171 return true;
174 if (argstr == "off")
176 m_session->GetPlayer()->SetGameMaster(false);
177 m_session->SendNotification(LANG_GM_OFF);
178 #ifdef _DEBUG_VMAPS
179 VMAP::IVMapManager *vMapManager = VMAP::VMapFactory::createOrGetVMapManager();
180 vMapManager->processCommand("startlog");
181 #endif
182 return true;
185 SendSysMessage(LANG_USE_BOL);
186 SetSentErrorMessage(true);
187 return false;
190 // Enables or disables hiding of the staff badge
191 bool ChatHandler::HandleGMChatCommand(const char* args)
193 if(!*args)
195 if(m_session->GetPlayer()->isGMChat())
196 m_session->SendNotification(LANG_GM_CHAT_ON);
197 else
198 m_session->SendNotification(LANG_GM_CHAT_OFF);
199 return true;
202 std::string argstr = (char*)args;
204 if (argstr == "on")
206 m_session->GetPlayer()->SetGMChat(true);
207 m_session->SendNotification(LANG_GM_CHAT_ON);
208 return true;
211 if (argstr == "off")
213 m_session->GetPlayer()->SetGMChat(false);
214 m_session->SendNotification(LANG_GM_CHAT_OFF);
215 return true;
218 SendSysMessage(LANG_USE_BOL);
219 SetSentErrorMessage(true);
220 return false;
223 //Enable\Dissable Invisible mode
224 bool ChatHandler::HandleVisibleCommand(const char* args)
226 if (!*args)
228 PSendSysMessage(LANG_YOU_ARE, m_session->GetPlayer()->isGMVisible() ? GetMangosString(LANG_VISIBLE) : GetMangosString(LANG_INVISIBLE));
229 return true;
232 std::string argstr = (char*)args;
234 if (argstr == "on")
236 m_session->GetPlayer()->SetGMVisible(true);
237 m_session->SendNotification(LANG_INVISIBLE_VISIBLE);
238 return true;
241 if (argstr == "off")
243 m_session->SendNotification(LANG_INVISIBLE_INVISIBLE);
244 m_session->GetPlayer()->SetGMVisible(false);
245 return true;
248 SendSysMessage(LANG_USE_BOL);
249 SetSentErrorMessage(true);
250 return false;
253 bool ChatHandler::HandleGPSCommand(const char* args)
255 WorldObject *obj = NULL;
256 if (*args)
258 std::string name = args;
259 if(normalizePlayerName(name))
260 obj = objmgr.GetPlayer(name.c_str());
262 if(!obj)
264 SendSysMessage(LANG_PLAYER_NOT_FOUND);
265 SetSentErrorMessage(true);
266 return false;
269 else
271 obj = getSelectedUnit();
273 if(!obj)
275 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
276 SetSentErrorMessage(true);
277 return false;
280 CellPair cell_val = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
281 Cell cell(cell_val);
283 uint32 zone_id = obj->GetZoneId();
284 uint32 area_id = obj->GetAreaId();
286 MapEntry const* mapEntry = sMapStore.LookupEntry(obj->GetMapId());
287 AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zone_id);
288 AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(area_id);
290 float zone_x = obj->GetPositionX();
291 float zone_y = obj->GetPositionY();
293 Map2ZoneCoordinates(zone_x,zone_y,zone_id);
295 Map const *map = obj->GetMap();
296 float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT);
297 float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ());
299 GridPair p = MaNGOS::ComputeGridPair(obj->GetPositionX(), obj->GetPositionY());
301 int gx=63-p.x_coord;
302 int gy=63-p.y_coord;
304 uint32 have_map = Map::ExistMap(obj->GetMapId(),gx,gy) ? 1 : 0;
305 uint32 have_vmap = Map::ExistVMap(obj->GetMapId(),gx,gy) ? 1 : 0;
307 PSendSysMessage(LANG_MAP_POSITION,
308 obj->GetMapId(), (mapEntry ? mapEntry->name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
309 zone_id, (zoneEntry ? zoneEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
310 area_id, (areaEntry ? areaEntry->area_name[m_session->GetSessionDbcLocale()] : "<unknown>" ),
311 obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
312 cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
313 zone_x, zone_y, ground_z, floor_z, have_map, have_vmap );
315 sLog.outDebug("Player %s GPS call for %s '%s' (%s: %u):",
316 GetName(),
317 (obj->GetTypeId() == TYPEID_PLAYER ? "player" : "creature"), obj->GetName(),
318 (obj->GetTypeId() == TYPEID_PLAYER ? "GUID" : "Entry"), (obj->GetTypeId() == TYPEID_PLAYER ? obj->GetGUIDLow(): obj->GetEntry()) );
320 sLog.outDebug(GetMangosString(LANG_MAP_POSITION),
321 obj->GetMapId(), (mapEntry ? mapEntry->name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
322 zone_id, (zoneEntry ? zoneEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
323 area_id, (areaEntry ? areaEntry->area_name[sWorld.GetDefaultDbcLocale()] : "<unknown>" ),
324 obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj->GetOrientation(),
325 cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), obj->GetInstanceId(),
326 zone_x, zone_y, ground_z, floor_z, have_map, have_vmap );
328 return true;
331 //Summon Player
332 bool ChatHandler::HandleNamegoCommand(const char* args)
334 if(!*args)
335 return false;
337 std::string name = args;
339 if(!normalizePlayerName(name))
341 SendSysMessage(LANG_PLAYER_NOT_FOUND);
342 SetSentErrorMessage(true);
343 return false;
346 Player *chr = objmgr.GetPlayer(name.c_str());
347 if (chr)
349 // check online security
350 if (HasLowerSecurity(chr, 0))
351 return false;
353 if(chr->IsBeingTeleported()==true)
355 PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
356 SetSentErrorMessage(true);
357 return false;
360 Map* pMap = m_session->GetPlayer()->GetMap();
362 if(pMap->IsBattleGroundOrArena())
364 // cannot summon to bg
365 PSendSysMessage(LANG_CANNOT_SUMMON_TO_BG,chr->GetName());
366 SetSentErrorMessage(true);
367 return false;
369 else if(pMap->IsDungeon())
371 Map* cMap = chr->GetMap();
372 if( cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId() )
374 // cannot summon from instance to instance
375 PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName());
376 SetSentErrorMessage(true);
377 return false;
380 // we are in instance, and can summon only player in our group with us as lead
381 if ( !m_session->GetPlayer()->GetGroup() || !chr->GetGroup() ||
382 (chr->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ||
383 (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) )
384 // the last check is a bit excessive, but let it be, just in case
386 PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,chr->GetName());
387 SetSentErrorMessage(true);
388 return false;
392 PSendSysMessage(LANG_SUMMONING, chr->GetName(),"");
393 if (needReportToTarget(chr))
394 ChatHandler(chr).PSendSysMessage(LANG_SUMMONED_BY, GetName());
396 // stop flight if need
397 if(chr->isInFlight())
399 chr->GetMotionMaster()->MovementExpired();
400 chr->m_taxi.ClearTaxiDestinations();
402 // save only in non-flight case
403 else
404 chr->SaveRecallPosition();
406 // before GM
407 float x,y,z;
408 m_session->GetPlayer()->GetClosePoint(x,y,z,chr->GetObjectSize());
409 chr->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,chr->GetOrientation());
411 else if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
413 // check offline security
414 if (HasLowerSecurity(NULL, guid))
415 return false;
417 PSendSysMessage(LANG_SUMMONING, name.c_str(),GetMangosString(LANG_OFFLINE));
419 // in point where GM stay
420 Player::SavePositionInDB(m_session->GetPlayer()->GetMapId(),
421 m_session->GetPlayer()->GetPositionX(),
422 m_session->GetPlayer()->GetPositionY(),
423 m_session->GetPlayer()->GetPositionZ(),
424 m_session->GetPlayer()->GetOrientation(),
425 m_session->GetPlayer()->GetZoneId(),
426 guid);
428 else
430 PSendSysMessage(LANG_NO_PLAYER, args);
431 SetSentErrorMessage(true);
434 return true;
437 //Teleport to Player
438 bool ChatHandler::HandleGonameCommand(const char* args)
440 if(!*args)
441 return false;
443 Player* _player = m_session->GetPlayer();
445 std::string name = args;
447 if(!normalizePlayerName(name))
449 SendSysMessage(LANG_PLAYER_NOT_FOUND);
450 SetSentErrorMessage(true);
451 return false;
454 Player *chr = objmgr.GetPlayer(name.c_str());
455 if (chr)
457 // check online security
458 if (HasLowerSecurity(chr, 0))
459 return false;
461 Map* cMap = chr->GetMap();
462 if(cMap->IsBattleGroundOrArena())
464 // only allow if gm mode is on
465 if (!_player->isGameMaster())
467 PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM,chr->GetName());
468 SetSentErrorMessage(true);
469 return false;
471 // if already in a bg, don't let port to other
472 else if (_player->GetBattleGroundId())
474 PSendSysMessage(LANG_CANNOT_GO_TO_BG_FROM_BG,chr->GetName());
475 SetSentErrorMessage(true);
476 return false;
478 // all's well, set bg id
479 // when porting out from the bg, it will be reset to 0
480 _player->SetBattleGroundId(chr->GetBattleGroundId());
482 else if(cMap->IsDungeon())
483 Map* cMap = chr->GetMap();
484 if(cMap->Instanceable())
486 // we have to go to instance, and can go to player only if:
487 // 1) we are in his group (either as leader or as member)
488 // 2) we are not bound to any group and have GM mode on
489 if (_player->GetGroup())
491 // we are in group, we can go only if we are in the player group
492 if (_player->GetGroup() != chr->GetGroup())
494 PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY,chr->GetName());
495 SetSentErrorMessage(true);
496 return false;
499 else
501 // we are not in group, let's verify our GM mode
502 if (!_player->isGameMaster())
504 PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM,chr->GetName());
505 SetSentErrorMessage(true);
506 return false;
510 // if the player or the player's group is bound to another instance
511 // the player will not be bound to another one
512 InstancePlayerBind *pBind = _player->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty());
513 if(!pBind)
515 Group *group = _player->GetGroup();
516 InstanceGroupBind *gBind = group ? group->GetBoundInstance(chr->GetMapId(), chr->GetDifficulty()) : NULL;
517 if(!gBind)
519 // if no bind exists, create a solo bind
520 InstanceSave *save = sInstanceSaveManager.GetInstanceSave(chr->GetInstanceId());
521 if(save) _player->BindToInstance(save, !save->CanReset());
525 _player->SetDifficulty(chr->GetDifficulty());
528 PSendSysMessage(LANG_APPEARING_AT, chr->GetName());
530 if (_player->IsVisibleGloballyFor(chr))
531 ChatHandler(chr).PSendSysMessage(LANG_APPEARING_TO, _player->GetName());
533 // stop flight if need
534 if(_player->isInFlight())
536 _player->GetMotionMaster()->MovementExpired();
537 _player->m_taxi.ClearTaxiDestinations();
539 // save only in non-flight case
540 else
541 _player->SaveRecallPosition();
543 // to point to see at target with same orientation
544 float x,y,z;
545 chr->GetContactPoint(m_session->GetPlayer(),x,y,z);
547 _player->TeleportTo(chr->GetMapId(), x, y, z, _player->GetAngle( chr ), TELE_TO_GM_MODE);
549 return true;
552 if (uint64 guid = objmgr.GetPlayerGUIDByName(name))
554 // check offline security
555 if (HasLowerSecurity(NULL, guid))
556 return false;
558 PSendSysMessage(LANG_APPEARING_AT, name.c_str());
560 // to point where player stay (if loaded)
561 float x,y,z,o;
562 uint32 map;
563 bool in_flight;
564 if(Player::LoadPositionFromDB(map,x,y,z,o,in_flight,guid))
566 // stop flight if need
567 if(_player->isInFlight())
569 _player->GetMotionMaster()->MovementExpired();
570 _player->m_taxi.ClearTaxiDestinations();
572 // save only in non-flight case
573 else
574 _player->SaveRecallPosition();
576 _player->TeleportTo(map, x, y, z,_player->GetOrientation());
577 return true;
581 PSendSysMessage(LANG_NO_PLAYER, args);
583 SetSentErrorMessage(true);
584 return false;
587 // Teleport player to last position
588 bool ChatHandler::HandleRecallCommand(const char* args)
590 Player* chr = NULL;
592 if(!*args)
594 chr = getSelectedPlayer();
595 if(!chr)
596 chr = m_session->GetPlayer();
598 // check online security
599 else if (HasLowerSecurity(chr, 0))
600 return false;
602 else
604 std::string name = args;
606 if(!normalizePlayerName(name))
608 SendSysMessage(LANG_PLAYER_NOT_FOUND);
609 SetSentErrorMessage(true);
610 return false;
613 chr = objmgr.GetPlayer(name.c_str());
615 if(!chr)
617 PSendSysMessage(LANG_NO_PLAYER, args);
618 SetSentErrorMessage(true);
619 return false;
622 // check online security
623 if (HasLowerSecurity(chr, 0))
624 return false;
627 if(chr->IsBeingTeleported())
629 PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
630 SetSentErrorMessage(true);
631 return false;
634 // stop flight if need
635 if(chr->isInFlight())
637 chr->GetMotionMaster()->MovementExpired();
638 chr->m_taxi.ClearTaxiDestinations();
641 chr->TeleportTo(chr->m_recallMap, chr->m_recallX, chr->m_recallY, chr->m_recallZ, chr->m_recallO);
642 return true;
645 //Edit Player KnownTitles
646 bool ChatHandler::HandleModifyKnownTitlesCommand(const char* args)
648 if(!*args)
649 return false;
651 uint64 titles = 0;
653 sscanf((char*)args, I64FMTD, &titles);
655 Player *chr = getSelectedPlayer();
656 if (!chr)
658 SendSysMessage(LANG_NO_CHAR_SELECTED);
659 SetSentErrorMessage(true);
660 return false;
663 // check online security
664 if (HasLowerSecurity(chr, 0))
665 return false;
667 uint64 titles2 = titles;
669 for(int i=1; i < sCharTitlesStore.GetNumRows(); ++i)
670 if(CharTitlesEntry const* tEntry = sCharTitlesStore.LookupEntry(i))
671 titles2 &= ~(uint64(1) << tEntry->bit_index);
673 titles &= ~titles2; // remove not existed titles
675 chr->SetUInt64Value(PLAYER__FIELD_KNOWN_TITLES, titles);
676 SendSysMessage(LANG_DONE);
678 return true;
681 //Edit Player HP
682 bool ChatHandler::HandleModifyHPCommand(const char* args)
684 if(!*args)
685 return false;
687 // char* pHp = strtok((char*)args, " ");
688 // if (!pHp)
689 // return false;
691 // char* pHpMax = strtok(NULL, " ");
692 // if (!pHpMax)
693 // return false;
695 // int32 hpm = atoi(pHpMax);
696 // int32 hp = atoi(pHp);
698 int32 hp = atoi((char*)args);
699 int32 hpm = atoi((char*)args);
701 if (hp <= 0 || hpm <= 0 || hpm < hp)
703 SendSysMessage(LANG_BAD_VALUE);
704 SetSentErrorMessage(true);
705 return false;
708 Player *chr = getSelectedPlayer();
709 if (chr == NULL)
711 SendSysMessage(LANG_NO_CHAR_SELECTED);
712 SetSentErrorMessage(true);
713 return false;
716 // check online security
717 if (HasLowerSecurity(chr, 0))
718 return false;
720 PSendSysMessage(LANG_YOU_CHANGE_HP, chr->GetName(), hp, hpm);
721 if (needReportToTarget(chr))
722 ChatHandler(chr).PSendSysMessage(LANG_YOURS_HP_CHANGED, GetName(), hp, hpm);
724 chr->SetMaxHealth( hpm );
725 chr->SetHealth( hp );
727 return true;
730 //Edit Player Mana
731 bool ChatHandler::HandleModifyManaCommand(const char* args)
733 if(!*args)
734 return false;
736 // char* pmana = strtok((char*)args, " ");
737 // if (!pmana)
738 // return false;
740 // char* pmanaMax = strtok(NULL, " ");
741 // if (!pmanaMax)
742 // return false;
744 // int32 manam = atoi(pmanaMax);
745 // int32 mana = atoi(pmana);
746 int32 mana = atoi((char*)args);
747 int32 manam = atoi((char*)args);
749 if (mana <= 0 || manam <= 0 || manam < mana)
751 SendSysMessage(LANG_BAD_VALUE);
752 SetSentErrorMessage(true);
753 return false;
756 Player *chr = getSelectedPlayer();
757 if (chr == NULL)
759 SendSysMessage(LANG_NO_CHAR_SELECTED);
760 SetSentErrorMessage(true);
761 return false;
764 // check online security
765 if (HasLowerSecurity(chr, 0))
766 return false;
768 PSendSysMessage(LANG_YOU_CHANGE_MANA, chr->GetName(), mana, manam);
769 if (needReportToTarget(chr))
770 ChatHandler(chr).PSendSysMessage(LANG_YOURS_MANA_CHANGED, GetName(), mana, manam);
772 chr->SetMaxPower(POWER_MANA,manam );
773 chr->SetPower(POWER_MANA, mana );
775 return true;
778 //Edit Player Energy
779 bool ChatHandler::HandleModifyEnergyCommand(const char* args)
781 if(!*args)
782 return false;
784 // char* pmana = strtok((char*)args, " ");
785 // if (!pmana)
786 // return false;
788 // char* pmanaMax = strtok(NULL, " ");
789 // if (!pmanaMax)
790 // return false;
792 // int32 manam = atoi(pmanaMax);
793 // int32 mana = atoi(pmana);
795 int32 energy = atoi((char*)args)*10;
796 int32 energym = atoi((char*)args)*10;
798 if (energy <= 0 || energym <= 0 || energym < energy)
800 SendSysMessage(LANG_BAD_VALUE);
801 SetSentErrorMessage(true);
802 return false;
805 Player *chr = getSelectedPlayer();
806 if (!chr)
808 SendSysMessage(LANG_NO_CHAR_SELECTED);
809 SetSentErrorMessage(true);
810 return false;
813 // check online security
814 if (HasLowerSecurity(chr, 0))
815 return false;
817 PSendSysMessage(LANG_YOU_CHANGE_ENERGY, chr->GetName(), energy/10, energym/10);
818 if (needReportToTarget(chr))
819 ChatHandler(chr).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, GetName(), energy/10, energym/10);
821 chr->SetMaxPower(POWER_ENERGY,energym );
822 chr->SetPower(POWER_ENERGY, energy );
824 sLog.outDetail(GetMangosString(LANG_CURRENT_ENERGY),chr->GetMaxPower(POWER_ENERGY));
826 return true;
829 //Edit Player Rage
830 bool ChatHandler::HandleModifyRageCommand(const char* args)
832 if(!*args)
833 return false;
835 // char* pmana = strtok((char*)args, " ");
836 // if (!pmana)
837 // return false;
839 // char* pmanaMax = strtok(NULL, " ");
840 // if (!pmanaMax)
841 // return false;
843 // int32 manam = atoi(pmanaMax);
844 // int32 mana = atoi(pmana);
846 int32 rage = atoi((char*)args)*10;
847 int32 ragem = atoi((char*)args)*10;
849 if (rage <= 0 || ragem <= 0 || ragem < rage)
851 SendSysMessage(LANG_BAD_VALUE);
852 SetSentErrorMessage(true);
853 return false;
856 Player *chr = getSelectedPlayer();
857 if (chr == NULL)
859 SendSysMessage(LANG_NO_CHAR_SELECTED);
860 SetSentErrorMessage(true);
861 return false;
864 // check online security
865 if (HasLowerSecurity(chr, 0))
866 return false;
868 PSendSysMessage(LANG_YOU_CHANGE_RAGE, chr->GetName(), rage/10, ragem/10);
869 if (needReportToTarget(chr))
870 ChatHandler(chr).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, GetName(), rage/10, ragem/10);
872 chr->SetMaxPower(POWER_RAGE,ragem );
873 chr->SetPower(POWER_RAGE, rage );
875 return true;
878 // Edit Player Runic Power
879 bool ChatHandler::HandleModifyRunicPowerCommand(const char* args)
881 if(!*args)
882 return false;
884 int32 rune = atoi((char*)args)*10;
885 int32 runem = atoi((char*)args)*10;
887 if (rune <= 0 || runem <= 0 || runem < rune)
889 SendSysMessage(LANG_BAD_VALUE);
890 SetSentErrorMessage(true);
891 return false;
894 Player *chr = getSelectedPlayer();
895 if (chr == NULL)
897 SendSysMessage(LANG_NO_CHAR_SELECTED);
898 SetSentErrorMessage(true);
899 return false;
902 PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, chr->GetName(), rune/10, runem/10);
903 if (needReportToTarget(chr))
904 ChatHandler(chr).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, GetName(), rune/10, runem/10);
906 chr->SetMaxPower(POWER_RUNIC_POWER,runem );
907 chr->SetPower(POWER_RUNIC_POWER, rune );
909 return true;
912 //Edit Player Faction
913 bool ChatHandler::HandleModifyFactionCommand(const char* args)
915 if(!*args)
916 return false;
918 char* pfactionid = extractKeyFromLink((char*)args,"Hfaction");
920 Creature* chr = getSelectedCreature();
921 if(!chr)
923 SendSysMessage(LANG_SELECT_CREATURE);
924 SetSentErrorMessage(true);
925 return false;
928 if(!pfactionid)
930 if(chr)
932 uint32 factionid = chr->getFaction();
933 uint32 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS);
934 uint32 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS);
935 uint32 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
936 PSendSysMessage(LANG_CURRENT_FACTION,chr->GetGUIDLow(),factionid,flag,npcflag,dyflag);
938 return true;
941 if( !chr )
943 SendSysMessage(LANG_NO_CHAR_SELECTED);
944 SetSentErrorMessage(true);
945 return false;
948 uint32 factionid = atoi(pfactionid);
949 uint32 flag;
951 char *pflag = strtok(NULL, " ");
952 if (!pflag)
953 flag = chr->GetUInt32Value(UNIT_FIELD_FLAGS);
954 else
955 flag = atoi(pflag);
957 char* pnpcflag = strtok(NULL, " ");
959 uint32 npcflag;
960 if(!pnpcflag)
961 npcflag = chr->GetUInt32Value(UNIT_NPC_FLAGS);
962 else
963 npcflag = atoi(pnpcflag);
965 char* pdyflag = strtok(NULL, " ");
967 uint32 dyflag;
968 if(!pdyflag)
969 dyflag = chr->GetUInt32Value(UNIT_DYNAMIC_FLAGS);
970 else
971 dyflag = atoi(pdyflag);
973 if(!sFactionTemplateStore.LookupEntry(factionid))
975 PSendSysMessage(LANG_WRONG_FACTION, factionid);
976 SetSentErrorMessage(true);
977 return false;
980 PSendSysMessage(LANG_YOU_CHANGE_FACTION, chr->GetGUIDLow(),factionid,flag,npcflag,dyflag);
982 chr->setFaction(factionid);
983 chr->SetUInt32Value(UNIT_FIELD_FLAGS,flag);
984 chr->SetUInt32Value(UNIT_NPC_FLAGS,npcflag);
985 chr->SetUInt32Value(UNIT_DYNAMIC_FLAGS,dyflag);
987 return true;
990 //Edit Player Spell
991 bool ChatHandler::HandleModifySpellCommand(const char* args)
993 if(!*args) return false;
994 char* pspellflatid = strtok((char*)args, " ");
995 if (!pspellflatid)
996 return false;
998 char* pop = strtok(NULL, " ");
999 if (!pop)
1000 return false;
1002 char* pval = strtok(NULL, " ");
1003 if (!pval)
1004 return false;
1006 uint16 mark;
1008 char* pmark = strtok(NULL, " ");
1010 uint8 spellflatid = atoi(pspellflatid);
1011 uint8 op = atoi(pop);
1012 uint16 val = atoi(pval);
1013 if(!pmark)
1014 mark = 65535;
1015 else
1016 mark = atoi(pmark);
1018 Player *chr = getSelectedPlayer();
1019 if (chr == NULL)
1021 SendSysMessage(LANG_NO_CHAR_SELECTED);
1022 SetSentErrorMessage(true);
1023 return false;
1026 // check online security
1027 if (HasLowerSecurity(chr, 0))
1028 return false;
1030 PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellflatid, val, mark, chr->GetName());
1031 if (needReportToTarget(chr))
1032 ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, GetName(), spellflatid, val, mark);
1034 WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1+1+2+2));
1035 data << uint8(spellflatid);
1036 data << uint8(op);
1037 data << uint16(val);
1038 data << uint16(mark);
1039 chr->GetSession()->SendPacket(&data);
1041 return true;
1044 //Edit Player TP
1045 bool ChatHandler::HandleModifyTalentCommand (const char* args)
1047 if (!*args)
1048 return false;
1050 int tp = atoi((char*)args);
1051 if (tp>0)
1053 Player* player = getSelectedPlayer();
1054 if(!player)
1056 SendSysMessage(LANG_NO_CHAR_SELECTED);
1057 SetSentErrorMessage(true);
1058 return false;
1061 // check online security
1062 if (HasLowerSecurity(player, 0))
1063 return false;
1065 player->SetFreeTalentPoints(tp);
1066 return true;
1068 return false;
1071 //Enable On\OFF all taxi paths
1072 bool ChatHandler::HandleTaxiCheatCommand(const char* args)
1074 if (!*args)
1076 SendSysMessage(LANG_USE_BOL);
1077 SetSentErrorMessage(true);
1078 return false;
1081 std::string argstr = (char*)args;
1083 Player *chr = getSelectedPlayer();
1084 if (!chr)
1086 chr=m_session->GetPlayer();
1089 // check online security
1090 else if (HasLowerSecurity(chr, 0))
1091 return false;
1093 if (argstr == "on")
1095 chr->SetTaxiCheater(true);
1096 PSendSysMessage(LANG_YOU_GIVE_TAXIS, chr->GetName());
1097 if (needReportToTarget(chr))
1098 ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, GetName());
1099 return true;
1102 if (argstr == "off")
1104 chr->SetTaxiCheater(false);
1105 PSendSysMessage(LANG_YOU_REMOVE_TAXIS, chr->GetName());
1106 if (needReportToTarget(chr))
1107 ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, GetName());
1109 return true;
1112 SendSysMessage(LANG_USE_BOL);
1113 SetSentErrorMessage(true);
1114 return false;
1117 //Edit Player Aspeed
1118 bool ChatHandler::HandleModifyASpeedCommand(const char* args)
1120 if (!*args)
1121 return false;
1123 float ASpeed = (float)atof((char*)args);
1125 if (ASpeed > 10 || ASpeed < 0.1)
1127 SendSysMessage(LANG_BAD_VALUE);
1128 SetSentErrorMessage(true);
1129 return false;
1132 Player *chr = getSelectedPlayer();
1133 if (chr == NULL)
1135 SendSysMessage(LANG_NO_CHAR_SELECTED);
1136 SetSentErrorMessage(true);
1137 return false;
1140 // check online security
1141 if (HasLowerSecurity(chr, 0))
1142 return false;
1144 if(chr->isInFlight())
1146 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1147 SetSentErrorMessage(true);
1148 return false;
1151 PSendSysMessage(LANG_YOU_CHANGE_ASPEED, ASpeed, chr->GetName());
1152 if (needReportToTarget(chr))
1153 ChatHandler(chr).PSendSysMessage(LANG_YOURS_ASPEED_CHANGED, GetName(), ASpeed);
1155 chr->SetSpeed(MOVE_WALK, ASpeed,true);
1156 chr->SetSpeed(MOVE_RUN, ASpeed,true);
1157 chr->SetSpeed(MOVE_SWIM, ASpeed,true);
1158 //chr->SetSpeed(MOVE_TURN, ASpeed,true);
1159 chr->SetSpeed(MOVE_FLIGHT, ASpeed,true);
1160 return true;
1163 //Edit Player Speed
1164 bool ChatHandler::HandleModifySpeedCommand(const char* args)
1166 if (!*args)
1167 return false;
1169 float Speed = (float)atof((char*)args);
1171 if (Speed > 10 || Speed < 0.1)
1173 SendSysMessage(LANG_BAD_VALUE);
1174 SetSentErrorMessage(true);
1175 return false;
1178 Player *chr = getSelectedPlayer();
1179 if (chr == NULL)
1181 SendSysMessage(LANG_NO_CHAR_SELECTED);
1182 SetSentErrorMessage(true);
1183 return false;
1186 // check online security
1187 if (HasLowerSecurity(chr, 0))
1188 return false;
1190 if(chr->isInFlight())
1192 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1193 SetSentErrorMessage(true);
1194 return false;
1197 PSendSysMessage(LANG_YOU_CHANGE_SPEED, Speed, chr->GetName());
1198 if (needReportToTarget(chr))
1199 ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, GetName(), Speed);
1201 chr->SetSpeed(MOVE_RUN,Speed,true);
1203 return true;
1206 //Edit Player Swim Speed
1207 bool ChatHandler::HandleModifySwimCommand(const char* args)
1209 if (!*args)
1210 return false;
1212 float Swim = (float)atof((char*)args);
1214 if (Swim > 10.0f || Swim < 0.01f)
1216 SendSysMessage(LANG_BAD_VALUE);
1217 SetSentErrorMessage(true);
1218 return false;
1221 Player *chr = getSelectedPlayer();
1222 if (chr == NULL)
1224 SendSysMessage(LANG_NO_CHAR_SELECTED);
1225 SetSentErrorMessage(true);
1226 return false;
1229 // check online security
1230 if (HasLowerSecurity(chr, 0))
1231 return false;
1233 if(chr->isInFlight())
1235 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1236 SetSentErrorMessage(true);
1237 return false;
1240 PSendSysMessage(LANG_YOU_CHANGE_SWIM_SPEED, Swim, chr->GetName());
1241 if (needReportToTarget(chr))
1242 ChatHandler(chr).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, GetName(), Swim);
1244 chr->SetSpeed(MOVE_SWIM,Swim,true);
1246 return true;
1249 //Edit Player Walk Speed
1250 bool ChatHandler::HandleModifyBWalkCommand(const char* args)
1252 if (!*args)
1253 return false;
1255 float BSpeed = (float)atof((char*)args);
1257 if (BSpeed > 10.0f || BSpeed < 0.1f)
1259 SendSysMessage(LANG_BAD_VALUE);
1260 SetSentErrorMessage(true);
1261 return false;
1264 Player *chr = getSelectedPlayer();
1265 if (chr == NULL)
1267 SendSysMessage(LANG_NO_CHAR_SELECTED);
1268 SetSentErrorMessage(true);
1269 return false;
1272 // check online security
1273 if (HasLowerSecurity(chr, 0))
1274 return false;
1276 if(chr->isInFlight())
1278 PSendSysMessage(LANG_CHAR_IN_FLIGHT,chr->GetName());
1279 SetSentErrorMessage(true);
1280 return false;
1283 PSendSysMessage(LANG_YOU_CHANGE_BACK_SPEED, BSpeed, chr->GetName());
1284 if (needReportToTarget(chr))
1285 ChatHandler(chr).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, GetName(), BSpeed);
1287 chr->SetSpeed(MOVE_RUN_BACK,BSpeed,true);
1289 return true;
1292 //Edit Player Fly
1293 bool ChatHandler::HandleModifyFlyCommand(const char* args)
1295 if (!*args)
1296 return false;
1298 float FSpeed = (float)atof((char*)args);
1300 if (FSpeed > 10.0f || FSpeed < 0.1f)
1302 SendSysMessage(LANG_BAD_VALUE);
1303 SetSentErrorMessage(true);
1304 return false;
1307 Player *chr = getSelectedPlayer();
1308 if (chr == NULL)
1310 SendSysMessage(LANG_NO_CHAR_SELECTED);
1311 SetSentErrorMessage(true);
1312 return false;
1315 // check online security
1316 if (HasLowerSecurity(chr, 0))
1317 return false;
1319 PSendSysMessage(LANG_YOU_CHANGE_FLY_SPEED, FSpeed, chr->GetName());
1320 if (needReportToTarget(chr))
1321 ChatHandler(chr).PSendSysMessage(LANG_YOURS_FLY_SPEED_CHANGED, GetName(), FSpeed);
1323 chr->SetSpeed(MOVE_FLIGHT,FSpeed,true);
1325 return true;
1328 //Edit Player Scale
1329 bool ChatHandler::HandleModifyScaleCommand(const char* args)
1331 if (!*args)
1332 return false;
1334 float Scale = (float)atof((char*)args);
1335 if (Scale > 3.0f || Scale <= 0.0f)
1337 SendSysMessage(LANG_BAD_VALUE);
1338 SetSentErrorMessage(true);
1339 return false;
1342 Player *chr = getSelectedPlayer();
1343 if (chr == NULL)
1345 SendSysMessage(LANG_NO_CHAR_SELECTED);
1346 SetSentErrorMessage(true);
1347 return false;
1350 // check online security
1351 if (HasLowerSecurity(chr, 0))
1352 return false;
1354 PSendSysMessage(LANG_YOU_CHANGE_SIZE, Scale, chr->GetName());
1355 if (needReportToTarget(chr))
1356 ChatHandler(chr).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, GetName(), Scale);
1358 chr->SetFloatValue(OBJECT_FIELD_SCALE_X, Scale);
1360 return true;
1363 //Enable Player mount
1364 bool ChatHandler::HandleModifyMountCommand(const char* args)
1366 if(!*args)
1367 return false;
1369 uint16 mId = 1147;
1370 float speed = (float)15;
1371 uint32 num = 0;
1373 num = atoi((char*)args);
1374 switch(num)
1376 case 1:
1377 mId=14340;
1378 break;
1379 case 2:
1380 mId=4806;
1381 break;
1382 case 3:
1383 mId=6471;
1384 break;
1385 case 4:
1386 mId=12345;
1387 break;
1388 case 5:
1389 mId=6472;
1390 break;
1391 case 6:
1392 mId=6473;
1393 break;
1394 case 7:
1395 mId=10670;
1396 break;
1397 case 8:
1398 mId=10719;
1399 break;
1400 case 9:
1401 mId=10671;
1402 break;
1403 case 10:
1404 mId=10672;
1405 break;
1406 case 11:
1407 mId=10720;
1408 break;
1409 case 12:
1410 mId=14349;
1411 break;
1412 case 13:
1413 mId=11641;
1414 break;
1415 case 14:
1416 mId=12244;
1417 break;
1418 case 15:
1419 mId=12242;
1420 break;
1421 case 16:
1422 mId=14578;
1423 break;
1424 case 17:
1425 mId=14579;
1426 break;
1427 case 18:
1428 mId=14349;
1429 break;
1430 case 19:
1431 mId=12245;
1432 break;
1433 case 20:
1434 mId=14335;
1435 break;
1436 case 21:
1437 mId=207;
1438 break;
1439 case 22:
1440 mId=2328;
1441 break;
1442 case 23:
1443 mId=2327;
1444 break;
1445 case 24:
1446 mId=2326;
1447 break;
1448 case 25:
1449 mId=14573;
1450 break;
1451 case 26:
1452 mId=14574;
1453 break;
1454 case 27:
1455 mId=14575;
1456 break;
1457 case 28:
1458 mId=604;
1459 break;
1460 case 29:
1461 mId=1166;
1462 break;
1463 case 30:
1464 mId=2402;
1465 break;
1466 case 31:
1467 mId=2410;
1468 break;
1469 case 32:
1470 mId=2409;
1471 break;
1472 case 33:
1473 mId=2408;
1474 break;
1475 case 34:
1476 mId=2405;
1477 break;
1478 case 35:
1479 mId=14337;
1480 break;
1481 case 36:
1482 mId=6569;
1483 break;
1484 case 37:
1485 mId=10661;
1486 break;
1487 case 38:
1488 mId=10666;
1489 break;
1490 case 39:
1491 mId=9473;
1492 break;
1493 case 40:
1494 mId=9476;
1495 break;
1496 case 41:
1497 mId=9474;
1498 break;
1499 case 42:
1500 mId=14374;
1501 break;
1502 case 43:
1503 mId=14376;
1504 break;
1505 case 44:
1506 mId=14377;
1507 break;
1508 case 45:
1509 mId=2404;
1510 break;
1511 case 46:
1512 mId=2784;
1513 break;
1514 case 47:
1515 mId=2787;
1516 break;
1517 case 48:
1518 mId=2785;
1519 break;
1520 case 49:
1521 mId=2736;
1522 break;
1523 case 50:
1524 mId=2786;
1525 break;
1526 case 51:
1527 mId=14347;
1528 break;
1529 case 52:
1530 mId=14346;
1531 break;
1532 case 53:
1533 mId=14576;
1534 break;
1535 case 54:
1536 mId=9695;
1537 break;
1538 case 55:
1539 mId=9991;
1540 break;
1541 case 56:
1542 mId=6448;
1543 break;
1544 case 57:
1545 mId=6444;
1546 break;
1547 case 58:
1548 mId=6080;
1549 break;
1550 case 59:
1551 mId=6447;
1552 break;
1553 case 60:
1554 mId=4805;
1555 break;
1556 case 61:
1557 mId=9714;
1558 break;
1559 case 62:
1560 mId=6448;
1561 break;
1562 case 63:
1563 mId=6442;
1564 break;
1565 case 64:
1566 mId=14632;
1567 break;
1568 case 65:
1569 mId=14332;
1570 break;
1571 case 66:
1572 mId=14331;
1573 break;
1574 case 67:
1575 mId=8469;
1576 break;
1577 case 68:
1578 mId=2830;
1579 break;
1580 case 69:
1581 mId=2346;
1582 break;
1583 default:
1584 SendSysMessage(LANG_NO_MOUNT);
1585 SetSentErrorMessage(true);
1586 return false;
1589 Player *chr = getSelectedPlayer();
1590 if (chr == NULL)
1592 SendSysMessage(LANG_NO_CHAR_SELECTED);
1593 SetSentErrorMessage(true);
1594 return false;
1597 // check online security
1598 if (HasLowerSecurity(chr, 0))
1599 return false;
1601 PSendSysMessage(LANG_YOU_GIVE_MOUNT, chr->GetName());
1602 if (needReportToTarget(chr))
1603 ChatHandler(chr).PSendSysMessage(LANG_MOUNT_GIVED, GetName());
1605 chr->SetUInt32Value( UNIT_FIELD_FLAGS , 0x001000 );
1606 chr->Mount(mId);
1608 WorldPacket data( SMSG_FORCE_RUN_SPEED_CHANGE, (8+4+1+4) );
1609 data.append(chr->GetPackGUID());
1610 data << (uint32)0;
1611 data << (uint8)0; //new 2.1.0
1612 data << float(speed);
1613 chr->SendMessageToSet( &data, true );
1615 data.Initialize( SMSG_FORCE_SWIM_SPEED_CHANGE, (8+4+4) );
1616 data.append(chr->GetPackGUID());
1617 data << (uint32)0;
1618 data << float(speed);
1619 chr->SendMessageToSet( &data, true );
1621 return true;
1624 //Edit Player money
1625 bool ChatHandler::HandleModifyMoneyCommand(const char* args)
1627 if (!*args)
1628 return false;
1630 Player *chr = getSelectedPlayer();
1631 if (chr == NULL)
1633 SendSysMessage(LANG_NO_CHAR_SELECTED);
1634 SetSentErrorMessage(true);
1635 return false;
1638 // check online security
1639 if (HasLowerSecurity(chr, 0))
1640 return false;
1642 int32 addmoney = atoi((char*)args);
1644 uint32 moneyuser = chr->GetMoney();
1646 if(addmoney < 0)
1648 int32 newmoney = moneyuser + addmoney;
1650 sLog.outDetail(GetMangosString(LANG_CURRENT_MONEY), moneyuser, addmoney, newmoney);
1651 if(newmoney <= 0 )
1653 PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, chr->GetName());
1654 if (needReportToTarget(chr))
1655 ChatHandler(chr).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, GetName());
1657 chr->SetMoney(0);
1659 else
1661 PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(addmoney), chr->GetName());
1662 if (needReportToTarget(chr))
1663 ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, GetName(), abs(addmoney));
1664 chr->SetMoney( newmoney );
1667 else
1669 PSendSysMessage(LANG_YOU_GIVE_MONEY, addmoney, chr->GetName());
1670 if (needReportToTarget(chr))
1671 ChatHandler(chr).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, GetName(), addmoney);
1672 chr->ModifyMoney( addmoney );
1675 sLog.outDetail(GetMangosString(LANG_NEW_MONEY), moneyuser, addmoney, chr->GetMoney() );
1677 return true;
1680 //Edit Player field
1681 bool ChatHandler::HandleModifyBitCommand(const char* args)
1683 if( !*args )
1684 return false;
1686 Player *chr = getSelectedPlayer();
1687 if (chr == NULL)
1689 SendSysMessage(LANG_NO_CHAR_SELECTED);
1690 SetSentErrorMessage(true);
1691 return false;
1694 // check online security
1695 if (HasLowerSecurity(chr, 0))
1696 return false;
1698 char* pField = strtok((char*)args, " ");
1699 if (!pField)
1700 return false;
1702 char* pBit = strtok(NULL, " ");
1703 if (!pBit)
1704 return false;
1706 uint16 field = atoi(pField);
1707 uint32 bit = atoi(pBit);
1709 if (field < 1 || field >= PLAYER_END)
1711 SendSysMessage(LANG_BAD_VALUE);
1712 SetSentErrorMessage(true);
1713 return false;
1716 if (bit < 1 || bit > 32)
1718 SendSysMessage(LANG_BAD_VALUE);
1719 SetSentErrorMessage(true);
1720 return false;
1723 if ( chr->HasFlag( field, (1<<(bit-1)) ) )
1725 chr->RemoveFlag( field, (1<<(bit-1)) );
1726 PSendSysMessage(LANG_REMOVE_BIT, bit, field);
1728 else
1730 chr->SetFlag( field, (1<<(bit-1)) );
1731 PSendSysMessage(LANG_SET_BIT, bit, field);
1734 return true;
1737 bool ChatHandler::HandleModifyHonorCommand (const char* args)
1739 if (!*args)
1740 return false;
1742 Player *target = getSelectedPlayer();
1743 if(!target)
1745 SendSysMessage(LANG_PLAYER_NOT_FOUND);
1746 SetSentErrorMessage(true);
1747 return false;
1750 // check online security
1751 if (HasLowerSecurity(target, 0))
1752 return false;
1754 int32 amount = (uint32)atoi(args);
1756 target->ModifyHonorPoints(amount);
1758 PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, target->GetName(), target->GetHonorPoints());
1760 return true;
1763 bool ChatHandler::HandleTeleCommand(const char * args)
1765 if(!*args)
1766 return false;
1768 Player* _player = m_session->GetPlayer();
1770 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
1771 GameTele const* tele = extractGameTeleFromLink((char*)args);
1773 if (!tele)
1775 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
1776 SetSentErrorMessage(true);
1777 return false;
1780 // stop flight if need
1781 if(_player->isInFlight())
1783 _player->GetMotionMaster()->MovementExpired();
1784 _player->m_taxi.ClearTaxiDestinations();
1786 // save only in non-flight case
1787 else
1788 _player->SaveRecallPosition();
1790 _player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
1791 return true;
1794 bool ChatHandler::HandleLookupAreaCommand(const char* args)
1796 if (!*args)
1797 return false;
1799 std::string namepart = args;
1800 std::wstring wnamepart;
1802 if (!Utf8toWStr (namepart,wnamepart))
1803 return false;
1805 uint32 counter = 0; // Counter for figure out that we found smth.
1807 // converting string that we try to find to lower case
1808 wstrToLower (wnamepart);
1810 // Search in AreaTable.dbc
1811 for (uint32 areaflag = 0; areaflag < sAreaStore.GetNumRows (); ++areaflag)
1813 AreaTableEntry const *areaEntry = sAreaStore.LookupEntry (areaflag);
1814 if (areaEntry)
1816 int loc = m_session ? m_session->GetSessionDbcLocale () : sWorld.GetDefaultDbcLocale();
1817 std::string name = areaEntry->area_name[loc];
1818 if (name.empty())
1819 continue;
1821 if (!Utf8FitTo (name, wnamepart))
1823 loc = 0;
1824 for(; loc < MAX_LOCALE; ++loc)
1826 if (m_session && loc==m_session->GetSessionDbcLocale ())
1827 continue;
1829 name = areaEntry->area_name[loc];
1830 if (name.empty ())
1831 continue;
1833 if (Utf8FitTo (name, wnamepart))
1834 break;
1838 if (loc < MAX_LOCALE)
1840 // send area in "id - [name]" format
1841 std::ostringstream ss;
1842 if (m_session)
1843 ss << areaEntry->ID << " - |cffffffff|Harea:" << areaEntry->ID << "|h[" << name << " " << localeNames[loc]<< "]|h|r";
1844 else
1845 ss << areaEntry->ID << " - " << name << " " << localeNames[loc];
1847 SendSysMessage (ss.str ().c_str());
1849 ++counter;
1854 if (counter == 0) // if counter == 0 then we found nth
1855 SendSysMessage (LANG_COMMAND_NOAREAFOUND);
1857 return true;
1860 //Find tele in game_tele order by name
1861 bool ChatHandler::HandleLookupTeleCommand(const char * args)
1863 if(!*args)
1865 SendSysMessage(LANG_COMMAND_TELE_PARAMETER);
1866 SetSentErrorMessage(true);
1867 return false;
1870 char const* str = strtok((char*)args, " ");
1871 if(!str)
1872 return false;
1874 std::string namepart = str;
1875 std::wstring wnamepart;
1877 if(!Utf8toWStr(namepart,wnamepart))
1878 return false;
1880 // converting string that we try to find to lower case
1881 wstrToLower( wnamepart );
1883 std::ostringstream reply;
1885 GameTeleMap const & teleMap = objmgr.GetGameTeleMap();
1886 for(GameTeleMap::const_iterator itr = teleMap.begin(); itr != teleMap.end(); ++itr)
1888 GameTele const* tele = &itr->second;
1890 if(tele->wnameLow.find(wnamepart) == std::wstring::npos)
1891 continue;
1893 if (m_session)
1894 reply << " |cffffffff|Htele:" << itr->first << "|h[" << tele->name << "]|h|r\n";
1895 else
1896 reply << " " << itr->first << " " << tele->name << "\n";
1899 if(reply.str().empty())
1900 SendSysMessage(LANG_COMMAND_TELE_NOLOCATION);
1901 else
1902 PSendSysMessage(LANG_COMMAND_TELE_LOCATION,reply.str().c_str());
1904 return true;
1907 //Enable\Dissable accept whispers (for GM)
1908 bool ChatHandler::HandleWhispersCommand(const char* args)
1910 if(!*args)
1912 PSendSysMessage(LANG_COMMAND_WHISPERACCEPTING, m_session->GetPlayer()->isAcceptWhispers() ? GetMangosString(LANG_ON) : GetMangosString(LANG_OFF));
1913 return true;
1916 std::string argstr = (char*)args;
1917 // whisper on
1918 if (argstr == "on")
1920 m_session->GetPlayer()->SetAcceptWhispers(true);
1921 SendSysMessage(LANG_COMMAND_WHISPERON);
1922 return true;
1925 // whisper off
1926 if (argstr == "off")
1928 m_session->GetPlayer()->SetAcceptWhispers(false);
1929 SendSysMessage(LANG_COMMAND_WHISPEROFF);
1930 return true;
1933 SendSysMessage(LANG_USE_BOL);
1934 SetSentErrorMessage(true);
1935 return false;
1938 //Play sound
1939 bool ChatHandler::HandlePlaySoundCommand(const char* args)
1941 // USAGE: .debug playsound #soundid
1942 // #soundid - ID decimal number from SoundEntries.dbc (1st column)
1943 // this file have about 5000 sounds.
1944 // In this realization only caller can hear this sound.
1945 if( *args )
1947 uint32 dwSoundId = atoi((char*)args);
1949 if( !sSoundEntriesStore.LookupEntry(dwSoundId) )
1951 PSendSysMessage(LANG_SOUND_NOT_EXIST, dwSoundId);
1952 SetSentErrorMessage(true);
1953 return false;
1956 WorldPacket data(SMSG_PLAY_OBJECT_SOUND,4+8);
1957 data << uint32(dwSoundId) << m_session->GetPlayer()->GetGUID();
1958 m_session->SendPacket(&data);
1960 PSendSysMessage(LANG_YOU_HEAR_SOUND, dwSoundId);
1961 return true;
1964 return false;
1967 //Save all players in the world
1968 bool ChatHandler::HandleSaveAllCommand(const char* /*args*/)
1970 ObjectAccessor::Instance().SaveAllPlayers();
1971 SendSysMessage(LANG_PLAYERS_SAVED);
1972 return true;
1975 //Send mail by command
1976 bool ChatHandler::HandleSendMailCommand(const char* args)
1978 if(!*args)
1979 return false;
1981 // format: name "subject text" "mail text"
1983 char* pName = strtok((char*)args, " ");
1984 if(!pName)
1985 return false;
1987 char* tail1 = strtok(NULL, "");
1988 if(!tail1)
1989 return false;
1991 char* msgSubject;
1992 if(*tail1=='"')
1993 msgSubject = strtok(tail1+1, "\"");
1994 else
1996 char* space = strtok(tail1, "\"");
1997 if(!space)
1998 return false;
1999 msgSubject = strtok(NULL, "\"");
2002 if (!msgSubject)
2003 return false;
2005 char* tail2 = strtok(NULL, "");
2006 if(!tail2)
2007 return false;
2009 char* msgText;
2010 if(*tail2=='"')
2011 msgText = strtok(tail2+1, "\"");
2012 else
2014 char* space = strtok(tail2, "\"");
2015 if(!space)
2016 return false;
2017 msgText = strtok(NULL, "\"");
2020 if (!msgText)
2021 return false;
2023 // pName, msgSubject, msgText isn't NUL after prev. check
2024 std::string name = pName;
2025 std::string subject = msgSubject;
2026 std::string text = msgText;
2028 if(!normalizePlayerName(name))
2030 SendSysMessage(LANG_PLAYER_NOT_FOUND);
2031 SetSentErrorMessage(true);
2032 return false;
2035 uint64 receiver_guid = objmgr.GetPlayerGUIDByName(name);
2036 if(!receiver_guid)
2038 SendSysMessage(LANG_PLAYER_NOT_FOUND);
2039 SetSentErrorMessage(true);
2040 return false;
2043 // from console show not existed sender
2044 uint32 sender_guidlo = m_session ? m_session->GetPlayer()->GetGUIDLow() : 0;
2046 uint32 messagetype = MAIL_NORMAL;
2047 uint32 stationery = MAIL_STATIONERY_GM;
2048 uint32 itemTextId = !text.empty() ? objmgr.CreateItemText( text ) : 0;
2050 Player *receiver = objmgr.GetPlayer(receiver_guid);
2052 WorldSession::SendMailTo(receiver,messagetype, stationery, sender_guidlo, GUID_LOPART(receiver_guid), subject, itemTextId, NULL, 0, 0, MAIL_CHECK_MASK_NONE);
2054 PSendSysMessage(LANG_MAIL_SENT, name.c_str());
2055 return true;
2058 // teleport player to given game_tele.entry
2059 bool ChatHandler::HandleNameTeleCommand(const char * args)
2061 if(!*args)
2062 return false;
2064 char* pName = strtok((char*)args, " ");
2066 if(!pName)
2067 return false;
2069 std::string name = pName;
2071 if(!normalizePlayerName(name))
2073 SendSysMessage(LANG_PLAYER_NOT_FOUND);
2074 SetSentErrorMessage(true);
2075 return false;
2078 char* tail = strtok(NULL, "");
2079 if(!tail)
2080 return false;
2082 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
2083 GameTele const* tele = extractGameTeleFromLink(tail);
2084 if(!tele)
2086 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
2087 SetSentErrorMessage(true);
2088 return false;
2091 Player *chr = objmgr.GetPlayer(name.c_str());
2092 if (chr)
2094 // check online security
2095 if (HasLowerSecurity(chr, 0))
2096 return false;
2098 if(chr->IsBeingTeleported()==true)
2100 PSendSysMessage(LANG_IS_TELEPORTED, chr->GetName());
2101 SetSentErrorMessage(true);
2102 return false;
2105 PSendSysMessage(LANG_TELEPORTING_TO, chr->GetName(),"", tele->name.c_str());
2106 if (needReportToTarget(chr))
2107 ChatHandler(chr).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetName());
2109 // stop flight if need
2110 if(chr->isInFlight())
2112 chr->GetMotionMaster()->MovementExpired();
2113 chr->m_taxi.ClearTaxiDestinations();
2115 // save only in non-flight case
2116 else
2117 chr->SaveRecallPosition();
2119 chr->TeleportTo(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation);
2121 else if (uint64 guid = objmgr.GetPlayerGUIDByName(name.c_str()))
2123 // check offline security
2124 if (HasLowerSecurity(NULL, guid))
2125 return false;
2127 PSendSysMessage(LANG_TELEPORTING_TO, name.c_str(), GetMangosString(LANG_OFFLINE), tele->name.c_str());
2128 Player::SavePositionInDB(tele->mapId,tele->position_x,tele->position_y,tele->position_z,tele->orientation,MapManager::Instance().GetZoneId(tele->mapId,tele->position_x,tele->position_y),guid);
2130 else
2131 PSendSysMessage(LANG_NO_PLAYER, name.c_str());
2133 return true;
2136 //Teleport group to given game_tele.entry
2137 bool ChatHandler::HandleGroupTeleCommand(const char * args)
2139 if(!*args)
2140 return false;
2142 Player *player = getSelectedPlayer();
2143 if (!player)
2145 SendSysMessage(LANG_NO_CHAR_SELECTED);
2146 SetSentErrorMessage(true);
2147 return false;
2150 // check online security
2151 if (HasLowerSecurity(player, 0))
2152 return false;
2154 // id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
2155 GameTele const* tele = extractGameTeleFromLink((char*)args);
2156 if(!tele)
2158 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND);
2159 SetSentErrorMessage(true);
2160 return false;
2163 Group *grp = player->GetGroup();
2164 if(!grp)
2166 PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName());
2167 SetSentErrorMessage(true);
2168 return false;
2171 for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
2173 Player *pl = itr->getSource();
2175 if(!pl || !pl->GetSession() )
2176 continue;
2178 // check online security
2179 if (HasLowerSecurity(pl, 0))
2180 return false;
2182 if(pl->IsBeingTeleported())
2184 PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName());
2185 continue;
2188 PSendSysMessage(LANG_TELEPORTING_TO, pl->GetName(),"", tele->name.c_str());
2189 if (needReportToTarget(pl))
2190 ChatHandler(pl).PSendSysMessage(LANG_TELEPORTED_TO_BY, GetName());
2192 // stop flight if need
2193 if(pl->isInFlight())
2195 pl->GetMotionMaster()->MovementExpired();
2196 pl->m_taxi.ClearTaxiDestinations();
2198 // save only in non-flight case
2199 else
2200 pl->SaveRecallPosition();
2202 pl->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
2205 return true;
2208 //Summon group of player
2209 bool ChatHandler::HandleGroupgoCommand(const char* args)
2211 if(!*args)
2212 return false;
2214 std::string name = args;
2216 if(!normalizePlayerName(name))
2218 SendSysMessage(LANG_PLAYER_NOT_FOUND);
2219 SetSentErrorMessage(true);
2220 return false;
2223 Player *player = objmgr.GetPlayer(name.c_str());
2224 if (!player)
2226 PSendSysMessage(LANG_NO_PLAYER, args);
2227 SetSentErrorMessage(true);
2228 return false;
2231 // check online security
2232 if (HasLowerSecurity(player, 0))
2233 return false;
2235 Group *grp = player->GetGroup();
2237 if(!grp)
2239 PSendSysMessage(LANG_NOT_IN_GROUP,player->GetName());
2240 SetSentErrorMessage(true);
2241 return false;
2244 Map* gmMap = m_session->GetPlayer()->GetMap();
2245 bool to_instance = gmMap->Instanceable();
2247 // we are in instance, and can summon only player in our group with us as lead
2248 if ( to_instance && (
2249 !m_session->GetPlayer()->GetGroup() || (grp->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ||
2250 (m_session->GetPlayer()->GetGroup()->GetLeaderGUID() != m_session->GetPlayer()->GetGUID()) ) )
2251 // the last check is a bit excessive, but let it be, just in case
2253 SendSysMessage(LANG_CANNOT_SUMMON_TO_INST);
2254 SetSentErrorMessage(true);
2255 return false;
2258 for(GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
2260 Player *pl = itr->getSource();
2262 if(!pl || pl==m_session->GetPlayer() || !pl->GetSession() )
2263 continue;
2265 // check online security
2266 if (HasLowerSecurity(pl, 0))
2267 return false;
2269 if(pl->IsBeingTeleported()==true)
2271 PSendSysMessage(LANG_IS_TELEPORTED, pl->GetName());
2272 SetSentErrorMessage(true);
2273 return false;
2276 if (to_instance)
2278 Map* plMap = pl->GetMap();
2280 if ( plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId() )
2282 // cannot summon from instance to instance
2283 PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST,pl->GetName());
2284 SetSentErrorMessage(true);
2285 return false;
2289 PSendSysMessage(LANG_SUMMONING, pl->GetName(),"");
2290 if (needReportToTarget(pl))
2291 ChatHandler(pl).PSendSysMessage(LANG_SUMMONED_BY, GetName());
2293 // stop flight if need
2294 if(pl->isInFlight())
2296 pl->GetMotionMaster()->MovementExpired();
2297 pl->m_taxi.ClearTaxiDestinations();
2299 // save only in non-flight case
2300 else
2301 pl->SaveRecallPosition();
2303 // before GM
2304 float x,y,z;
2305 m_session->GetPlayer()->GetClosePoint(x,y,z,pl->GetObjectSize());
2306 pl->TeleportTo(m_session->GetPlayer()->GetMapId(),x,y,z,pl->GetOrientation());
2309 return true;
2312 //teleport at coordinates
2313 bool ChatHandler::HandleGoXYCommand(const char* args)
2315 if(!*args)
2316 return false;
2318 Player* _player = m_session->GetPlayer();
2320 char* px = strtok((char*)args, " ");
2321 char* py = strtok(NULL, " ");
2322 char* pmapid = strtok(NULL, " ");
2324 if (!px || !py)
2325 return false;
2327 float x = (float)atof(px);
2328 float y = (float)atof(py);
2329 uint32 mapid;
2330 if (pmapid)
2331 mapid = (uint32)atoi(pmapid);
2332 else mapid = _player->GetMapId();
2334 if(!MapManager::IsValidMapCoord(mapid,x,y))
2336 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
2337 SetSentErrorMessage(true);
2338 return false;
2341 // stop flight if need
2342 if(_player->isInFlight())
2344 _player->GetMotionMaster()->MovementExpired();
2345 _player->m_taxi.ClearTaxiDestinations();
2347 // save only in non-flight case
2348 else
2349 _player->SaveRecallPosition();
2351 Map const *map = MapManager::Instance().GetBaseMap(mapid);
2352 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
2354 _player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
2356 return true;
2359 //teleport at coordinates, including Z
2360 bool ChatHandler::HandleGoXYZCommand(const char* args)
2362 if(!*args)
2363 return false;
2365 Player* _player = m_session->GetPlayer();
2367 char* px = strtok((char*)args, " ");
2368 char* py = strtok(NULL, " ");
2369 char* pz = strtok(NULL, " ");
2370 char* pmapid = strtok(NULL, " ");
2372 if (!px || !py || !pz)
2373 return false;
2375 float x = (float)atof(px);
2376 float y = (float)atof(py);
2377 float z = (float)atof(pz);
2378 uint32 mapid;
2379 if (pmapid)
2380 mapid = (uint32)atoi(pmapid);
2381 else
2382 mapid = _player->GetMapId();
2384 if(!MapManager::IsValidMapCoord(mapid,x,y,z))
2386 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
2387 SetSentErrorMessage(true);
2388 return false;
2391 // stop flight if need
2392 if(_player->isInFlight())
2394 _player->GetMotionMaster()->MovementExpired();
2395 _player->m_taxi.ClearTaxiDestinations();
2397 // save only in non-flight case
2398 else
2399 _player->SaveRecallPosition();
2401 _player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
2403 return true;
2406 //teleport at coordinates
2407 bool ChatHandler::HandleGoZoneXYCommand(const char* args)
2409 if(!*args)
2410 return false;
2412 Player* _player = m_session->GetPlayer();
2414 char* px = strtok((char*)args, " ");
2415 char* py = strtok(NULL, " ");
2416 char* tail = strtok(NULL,"");
2418 char* cAreaId = extractKeyFromLink(tail,"Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r
2420 if (!px || !py)
2421 return false;
2423 float x = (float)atof(px);
2424 float y = (float)atof(py);
2425 uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId();
2427 AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid);
2429 if( x<0 || x>100 || y<0 || y>100 || !areaEntry )
2431 PSendSysMessage(LANG_INVALID_ZONE_COORD,x,y,areaid);
2432 SetSentErrorMessage(true);
2433 return false;
2436 // update to parent zone if exist (client map show only zones without parents)
2437 AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry;
2439 Map const *map = MapManager::Instance().GetBaseMap(zoneEntry->mapid);
2441 if(map->Instanceable())
2443 PSendSysMessage(LANG_INVALID_ZONE_MAP,areaEntry->ID,areaEntry->area_name[m_session->GetSessionDbcLocale()],map->GetId(),map->GetMapName());
2444 SetSentErrorMessage(true);
2445 return false;
2448 Zone2MapCoordinates(x,y,zoneEntry->ID);
2450 if(!MapManager::IsValidMapCoord(zoneEntry->mapid,x,y))
2452 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,zoneEntry->mapid);
2453 SetSentErrorMessage(true);
2454 return false;
2457 // stop flight if need
2458 if(_player->isInFlight())
2460 _player->GetMotionMaster()->MovementExpired();
2461 _player->m_taxi.ClearTaxiDestinations();
2463 // save only in non-flight case
2464 else
2465 _player->SaveRecallPosition();
2467 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
2468 _player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation());
2470 return true;
2473 //teleport to grid
2474 bool ChatHandler::HandleGoGridCommand(const char* args)
2476 if(!*args) return false;
2477 Player* _player = m_session->GetPlayer();
2479 char* px = strtok((char*)args, " ");
2480 char* py = strtok(NULL, " ");
2481 char* pmapid = strtok(NULL, " ");
2483 if (!px || !py)
2484 return false;
2486 float grid_x = (float)atof(px);
2487 float grid_y = (float)atof(py);
2488 uint32 mapid;
2489 if (pmapid)
2490 mapid = (uint32)atoi(pmapid);
2491 else mapid = _player->GetMapId();
2493 // center of grid
2494 float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS;
2495 float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS;
2497 if(!MapManager::IsValidMapCoord(mapid,x,y))
2499 PSendSysMessage(LANG_INVALID_TARGET_COORD,x,y,mapid);
2500 SetSentErrorMessage(true);
2501 return false;
2504 // stop flight if need
2505 if(_player->isInFlight())
2507 _player->GetMotionMaster()->MovementExpired();
2508 _player->m_taxi.ClearTaxiDestinations();
2510 // save only in non-flight case
2511 else
2512 _player->SaveRecallPosition();
2514 Map const *map = MapManager::Instance().GetBaseMap(mapid);
2515 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
2516 _player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
2518 return true;
2521 bool ChatHandler::HandleDrunkCommand(const char* args)
2523 if(!*args) return false;
2525 uint32 drunklevel = (uint32)atoi(args);
2526 if(drunklevel > 100)
2527 drunklevel = 100;
2529 uint16 drunkMod = drunklevel * 0xFFFF / 100;
2531 m_session->GetPlayer()->SetDrunkValue(drunkMod);
2533 return true;