2 * Copyright (C) 2005-2009 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
20 #include "Database/DatabaseEnv.h"
21 #include "WorldPacket.h"
22 #include "WorldSession.h"
24 #include "ObjectMgr.h"
25 #include "AccountMgr.h"
26 #include "PlayerDump.h"
30 #include "GameObject.h"
34 #include "ObjectAccessor.h"
35 #include "MapManager.h"
36 #include "ScriptCalls.h"
38 #include "GridNotifiersImpl.h"
41 #include "PointMovementGenerator.h"
42 #include "TargetedMovementGenerator.h"
43 #include "SkillDiscovery.h"
44 #include "SkillExtraItems.h"
45 #include "SystemConfig.h"
46 #include "Config/ConfigEnv.h"
48 #include "ItemEnchantmentMgr.h"
49 #include "BattleGroundMgr.h"
50 #include "InstanceSaveMgr.h"
51 #include "InstanceData.h"
52 #include "AuctionHouseBot.h"
54 bool ChatHandler::HandleAHBotOptionsCommand(const char* args
)
57 char * opt
= strtok((char*)args
, " ");
58 char * ahMapIdStr
= strtok(NULL
, " ");
61 ahMapID
= (uint32
) strtoul(ahMapIdStr
, NULL
, 0);
65 PSendSysMessage("Syntax is: ahbotoptions $option $ahMapID (2, 6 or 7) $parameter");
66 PSendSysMessage("Try ahbotoptions help to see a list of options.");
71 if (strncmp(opt
,"help",l
) == 0)
73 PSendSysMessage("AHBot commands:");
74 PSendSysMessage("ahexpire");
75 PSendSysMessage("minitems");
76 PSendSysMessage("maxitems");
77 PSendSysMessage("mintime");
78 PSendSysMessage("maxtime");
79 PSendSysMessage("percentages");
80 PSendSysMessage("minprice");
81 PSendSysMessage("maxprice");
82 PSendSysMessage("minbidprice");
83 PSendSysMessage("maxbidprice");
84 PSendSysMessage("maxstack");
85 PSendSysMessage("buyerprice");
86 PSendSysMessage("bidinterval");
87 PSendSysMessage("bidsperinterval");
90 else if (strncmp(opt
,"ahexpire",l
) == 0)
94 PSendSysMessage("Syntax is: ahbotoptions ahexpire $ahMapID (2, 6 or 7)");
97 AuctionHouseBotCommands(0, ahMapID
, NULL
, NULL
);
99 else if (strncmp(opt
,"minitems",l
) == 0)
101 char * param1
= strtok(NULL
, " ");
102 if ((!ahMapIdStr
) || (!param1
))
104 PSendSysMessage("Syntax is: ahbotoptions minitems $ahMapID (2, 6 or 7) $minItems");
107 AuctionHouseBotCommands(1, ahMapID
, NULL
, param1
);
109 else if (strncmp(opt
,"maxitems",l
) == 0)
111 char * param1
= strtok(NULL
, " ");
112 if ((!ahMapIdStr
) || (!param1
))
114 PSendSysMessage("Syntax is: ahbotoptions maxitems $ahMapID (2, 6 or 7) $maxItems");
117 AuctionHouseBotCommands(2, ahMapID
, NULL
, param1
);
119 else if (strncmp(opt
,"mintime",l
) == 0)
121 char * param1
= strtok(NULL
, " ");
122 if ((!ahMapIdStr
) || (!param1
))
124 PSendSysMessage("Syntax is: ahbotoptions mintime $ahMapID (2, 6 or 7) $mintime");
127 AuctionHouseBotCommands(3, ahMapID
, NULL
, param1
);
129 else if (strncmp(opt
,"maxtime",l
) == 0)
131 char * param1
= strtok(NULL
, " ");
132 if ((!ahMapIdStr
) || (!param1
))
134 PSendSysMessage("Syntax is: ahbotoptions maxtime $ahMapID (2, 6 or 7) $maxtime");
137 AuctionHouseBotCommands(4, ahMapID
, NULL
, param1
);
139 else if (strncmp(opt
,"percentages",l
) == 0)
141 char * param1
= strtok(NULL
, " ");
142 char * param2
= strtok(NULL
, " ");
143 char * param3
= strtok(NULL
, " ");
144 char * param4
= strtok(NULL
, " ");
145 char * param5
= strtok(NULL
, " ");
146 char * param6
= strtok(NULL
, " ");
147 char * param7
= strtok(NULL
, " ");
148 char * param8
= strtok(NULL
, " ");
149 char * param9
= strtok(NULL
, " ");
150 char * param10
= strtok(NULL
, " ");
151 char * param11
= strtok(NULL
, " ");
152 char * param12
= strtok(NULL
, " ");
153 char * param13
= strtok(NULL
, " ");
154 char * param14
= strtok(NULL
, " ");
155 if ((!ahMapIdStr
) || (!param14
))
157 PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14");
158 PSendSysMessage("1 GreyTradeGoods 2 WhiteTradeGoods 3 GreenTradeGoods 4 BlueTradeGoods 5 PurpleTradeGoods");
159 PSendSysMessage("6 OrangeTradeGoods 7 YellowTradeGoods 8 GreyItems 9 WhiteItems 10 GreenItems 11 BlueItems");
160 PSendSysMessage("12 PurpleItems 13 OrangeItems 14 YellowItems");
161 PSendSysMessage("The total must add up to 100%");
164 uint32 greytg
= (uint32
) strtoul(param1
, NULL
, 0);
165 uint32 whitetg
= (uint32
) strtoul(param2
, NULL
, 0);
166 uint32 greentg
= (uint32
) strtoul(param3
, NULL
, 0);
167 uint32 bluetg
= (uint32
) strtoul(param3
, NULL
, 0);
168 uint32 purpletg
= (uint32
) strtoul(param5
, NULL
, 0);
169 uint32 orangetg
= (uint32
) strtoul(param6
, NULL
, 0);
170 uint32 yellowtg
= (uint32
) strtoul(param7
, NULL
, 0);
171 uint32 greyi
= (uint32
) strtoul(param8
, NULL
, 0);
172 uint32 whitei
= (uint32
) strtoul(param9
, NULL
, 0);
173 uint32 greeni
= (uint32
) strtoul(param10
, NULL
, 0);
174 uint32 bluei
= (uint32
) strtoul(param11
, NULL
, 0);
175 uint32 purplei
= (uint32
) strtoul(param12
, NULL
, 0);
176 uint32 orangei
= (uint32
) strtoul(param13
, NULL
, 0);
177 uint32 yellowi
= (uint32
) strtoul(param14
, NULL
, 0);
178 uint32 totalPercent
= greytg
+ whitetg
+ greentg
+ bluetg
+ purpletg
+ orangetg
+ yellowtg
+ greyi
+ whitei
+ greeni
+ bluei
+ purplei
+ orangei
+ yellowi
;
179 if ((totalPercent
== 0) || (totalPercent
!= 100))
181 PSendSysMessage("Syntax is: ahbotoptions percentages $ahMapID (2, 6 or 7) $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14");
182 PSendSysMessage("1 GreyTradeGoods 2 WhiteTradeGoods 3 GreenTradeGoods 4 BlueTradeGoods 5 PurpleTradeGoods");
183 PSendSysMessage("6 OrangeTradeGoods 7 YellowTradeGoods 8 GreyItems 9 WhiteItems 10 GreenItems 11 BlueItems");
184 PSendSysMessage("12 PurpleItems 13 OrangeItems 14 YellowItems");
185 PSendSysMessage("The total must add up to 100%");
190 strcat(param
, param1
);
192 strcat(param
, param2
);
194 strcat(param
, param3
);
196 strcat(param
, param4
);
198 strcat(param
, param5
);
200 strcat(param
, param6
);
202 strcat(param
, param7
);
204 strcat(param
, param8
);
206 strcat(param
, param9
);
208 strcat(param
, param10
);
210 strcat(param
, param11
);
212 strcat(param
, param12
);
214 strcat(param
, param13
);
216 strcat(param
, param14
);
217 AuctionHouseBotCommands(5, ahMapID
, NULL
, param
);
219 else if (strncmp(opt
,"minprice",l
) == 0)
221 char * param1
= strtok(NULL
, " ");
222 char * param2
= strtok(NULL
, " ");
223 if ((!ahMapIdStr
) || (!param1
) || (!param2
))
225 PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
228 if (strncmp(param1
,"grey",l
) == 0)
230 AuctionHouseBotCommands(6, ahMapID
, AHB_GREY
, param2
);
232 else if (strncmp(param1
,"white",l
) == 0)
234 AuctionHouseBotCommands(6, ahMapID
, AHB_WHITE
, param2
);
236 else if (strncmp(param1
,"green",l
) == 0)
238 AuctionHouseBotCommands(6, ahMapID
, AHB_GREEN
, param2
);
240 else if (strncmp(param1
,"blue",l
) == 0)
242 AuctionHouseBotCommands(6, ahMapID
, AHB_BLUE
, param2
);
244 else if (strncmp(param1
,"purple",l
) == 0)
246 AuctionHouseBotCommands(6, ahMapID
, AHB_PURPLE
, param2
);
248 else if (strncmp(param1
,"orange",l
) == 0)
250 AuctionHouseBotCommands(6, ahMapID
, AHB_ORANGE
, param2
);
252 else if (strncmp(param1
,"yellow",l
) == 0)
254 AuctionHouseBotCommands(6, ahMapID
, AHB_YELLOW
, param2
);
258 PSendSysMessage("Syntax is: ahbotoptions minprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
262 else if (strncmp(opt
,"maxprice",l
) == 0)
264 char * param1
= strtok(NULL
, " ");
265 char * param2
= strtok(NULL
, " ");
266 if ((!ahMapIdStr
) || (!param1
) || (!param2
))
268 PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
271 if (strncmp(param1
,"grey",l
) == 0)
273 AuctionHouseBotCommands(7, ahMapID
, AHB_GREY
, param2
);
275 else if (strncmp(param1
,"white",l
) == 0)
277 AuctionHouseBotCommands(7, ahMapID
, AHB_WHITE
, param2
);
279 else if (strncmp(param1
,"green",l
) == 0)
281 AuctionHouseBotCommands(7, ahMapID
, AHB_GREEN
, param2
);
283 else if (strncmp(param1
,"blue",l
) == 0)
285 AuctionHouseBotCommands(7, ahMapID
, AHB_BLUE
, param2
);
287 else if (strncmp(param1
,"purple",l
) == 0)
289 AuctionHouseBotCommands(7, ahMapID
, AHB_PURPLE
, param2
);
291 else if (strncmp(param1
,"orange",l
) == 0)
293 AuctionHouseBotCommands(7, ahMapID
, AHB_ORANGE
, param2
);
295 else if (strncmp(param1
,"yellow",l
) == 0)
297 AuctionHouseBotCommands(7, ahMapID
, AHB_YELLOW
, param2
);
301 PSendSysMessage("Syntax is: ahbotoptions maxprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
305 else if (strncmp(opt
,"minbidprice",l
) == 0)
307 char * param1
= strtok(NULL
, " ");
308 char * param2
= strtok(NULL
, " ");
309 if ((!ahMapIdStr
) || (!param1
) || (!param2
))
311 PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
314 uint32 minBidPrice
= (uint32
) strtoul(param2
, NULL
, 0);
315 if ((minBidPrice
< 1) || (minBidPrice
> 100))
317 PSendSysMessage("The min bid price multiplier must be between 1 and 100");
320 if (strncmp(param1
,"grey",l
) == 0)
322 AuctionHouseBotCommands(8, ahMapID
, AHB_GREY
, param2
);
324 else if (strncmp(param1
,"white",l
) == 0)
326 AuctionHouseBotCommands(8, ahMapID
, AHB_WHITE
, param2
);
328 else if (strncmp(param1
,"green",l
) == 0)
330 AuctionHouseBotCommands(8, ahMapID
, AHB_GREEN
, param2
);
332 else if (strncmp(param1
,"blue",l
) == 0)
334 AuctionHouseBotCommands(8, ahMapID
, AHB_BLUE
, param2
);
336 else if (strncmp(param1
,"purple",l
) == 0)
338 AuctionHouseBotCommands(8, ahMapID
, AHB_PURPLE
, param2
);
340 else if (strncmp(param1
,"orange",l
) == 0)
342 AuctionHouseBotCommands(8, ahMapID
, AHB_ORANGE
, param2
);
344 else if (strncmp(param1
,"yellow",l
) == 0)
346 AuctionHouseBotCommands(8, ahMapID
, AHB_YELLOW
, param2
);
350 PSendSysMessage("Syntax is: ahbotoptions minbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
354 else if (strncmp(opt
,"maxbidprice",l
) == 0)
356 char * param1
= strtok(NULL
, " ");
357 char * param2
= strtok(NULL
, " ");
358 if ((!ahMapIdStr
) || (!param1
) || (!param2
))
360 PSendSysMessage("Syntax is: ahbotoptions maxbidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
363 uint32 maxBidPrice
= (uint32
) strtoul(param2
, NULL
, 0);
364 if ((maxBidPrice
< 1) || (maxBidPrice
> 100))
366 PSendSysMessage("The max bid price multiplier must be between 1 and 100");
369 if (strncmp(param1
,"grey",l
) == 0)
371 AuctionHouseBotCommands(9, ahMapID
, AHB_GREY
, param2
);
373 else if (strncmp(param1
,"white",l
) == 0)
375 AuctionHouseBotCommands(9, ahMapID
, AHB_WHITE
, param2
);
377 else if (strncmp(param1
,"green",l
) == 0)
379 AuctionHouseBotCommands(9, ahMapID
, AHB_GREEN
, param2
);
381 else if (strncmp(param1
,"blue",l
) == 0)
383 AuctionHouseBotCommands(9, ahMapID
, AHB_BLUE
, param2
);
385 else if (strncmp(param1
,"purple",l
) == 0)
387 AuctionHouseBotCommands(9, ahMapID
, AHB_PURPLE
, param2
);
389 else if (strncmp(param1
,"orange",l
) == 0)
391 AuctionHouseBotCommands(9, ahMapID
, AHB_ORANGE
, param2
);
393 else if (strncmp(param1
,"yellow",l
) == 0)
395 AuctionHouseBotCommands(9, ahMapID
, AHB_YELLOW
, param2
);
399 PSendSysMessage("Syntax is: ahbotoptions max bidprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $price");
403 else if (strncmp(opt
,"maxstack",l
) == 0)
405 char * param1
= strtok(NULL
, " ");
406 char * param2
= strtok(NULL
, " ");
407 if ((!ahMapIdStr
) || (!param1
) || (!param2
))
409 PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value");
412 uint32 maxStack
= (uint32
) strtoul(param2
, NULL
, 0);
415 PSendSysMessage("maxstack can't be a negative number.");
418 if (strncmp(param1
,"grey",l
) == 0)
420 AuctionHouseBotCommands(10, ahMapID
, AHB_GREY
, param2
);
422 else if (strncmp(param1
,"white",l
) == 0)
424 AuctionHouseBotCommands(10, ahMapID
, AHB_WHITE
, param2
);
426 else if (strncmp(param1
,"green",l
) == 0)
428 AuctionHouseBotCommands(10, ahMapID
, AHB_GREEN
, param2
);
430 else if (strncmp(param1
,"blue",l
) == 0)
432 AuctionHouseBotCommands(10, ahMapID
, AHB_BLUE
, param2
);
434 else if (strncmp(param1
,"purple",l
) == 0)
436 AuctionHouseBotCommands(10, ahMapID
, AHB_PURPLE
, param2
);
438 else if (strncmp(param1
,"orange",l
) == 0)
440 AuctionHouseBotCommands(10, ahMapID
, AHB_ORANGE
, param2
);
442 else if (strncmp(param1
,"yellow",l
) == 0)
444 AuctionHouseBotCommands(10, ahMapID
, AHB_YELLOW
, param2
);
448 PSendSysMessage("Syntax is: ahbotoptions maxstack $ahMapID (2, 6 or 7) $color (grey, white, green, blue, purple, orange or yellow) $value");
452 else if (strncmp(opt
,"buyerprice",l
) == 0)
454 char * param1
= strtok(NULL
, " ");
455 char * param2
= strtok(NULL
, " ");
456 if ((!ahMapIdStr
) || (!param1
) || (!param2
))
458 PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price");
461 if (strncmp(param1
,"grey",l
) == 0)
463 AuctionHouseBotCommands(11, ahMapID
, AHB_GREY
, param2
);
465 else if (strncmp(param1
,"white",l
) == 0)
467 AuctionHouseBotCommands(11, ahMapID
, AHB_WHITE
, param2
);
469 else if (strncmp(param1
,"green",l
) == 0)
471 AuctionHouseBotCommands(11, ahMapID
, AHB_GREEN
, param2
);
473 else if (strncmp(param1
,"blue",l
) == 0)
475 AuctionHouseBotCommands(11, ahMapID
, AHB_BLUE
, param2
);
477 else if (strncmp(param1
,"purple",l
) == 0)
479 AuctionHouseBotCommands(11, ahMapID
, AHB_PURPLE
, param2
);
481 else if (strncmp(param1
,"orange",l
) == 0)
483 AuctionHouseBotCommands(11, ahMapID
, AHB_ORANGE
, param2
);
485 else if (strncmp(param1
,"yellow",l
) == 0)
487 AuctionHouseBotCommands(11, ahMapID
, AHB_YELLOW
, param2
);
491 PSendSysMessage("Syntax is: ahbotoptions buyerprice $ahMapID (2, 6 or 7) $color (grey, white, green, blue or purple) $price");
495 else if (strncmp(opt
,"bidinterval",l
) == 0)
497 char * param1
= strtok(NULL
, " ");
498 if ((!ahMapIdStr
) || (!param1
))
500 PSendSysMessage("Syntax is: ahbotoptions bidinterval $ahMapID (2, 6 or 7) $interval(in minutes)");
503 AuctionHouseBotCommands(12, ahMapID
, NULL
, param1
);
505 else if (strncmp(opt
,"bidsperinterval",l
) == 0)
507 char * param1
= strtok(NULL
, " ");
508 if ((!ahMapIdStr
) || (!param1
))
510 PSendSysMessage("Syntax is: ahbotoptions bidsperinterval $ahMapID (2, 6 or 7) $bids");
513 AuctionHouseBotCommands(13, ahMapID
, NULL
, param1
);
517 PSendSysMessage("Syntax is: ahbotoptions $option $ahMapID (2, 6 or 7) $parameter");
518 PSendSysMessage("Try ahbotoptions help to see a list of options.");
525 bool ChatHandler::HandleReloadAllCommand(const char*)
527 HandleReloadSkillFishingBaseLevelCommand("");
529 HandleReloadAllAchievementCommand("");
530 HandleReloadAllAreaCommand("");
531 HandleReloadAllLootCommand("");
532 HandleReloadAllNpcCommand("");
533 HandleReloadAllQuestCommand("");
534 HandleReloadAllSpellCommand("");
535 HandleReloadAllItemCommand("");
536 HandleReloadAllLocalesCommand("");
538 HandleReloadCommandCommand("");
539 HandleReloadReservedNameCommand("");
540 HandleReloadMangosStringCommand("");
541 HandleReloadGameTeleCommand("");
545 bool ChatHandler::HandleReloadAllAchievementCommand(const char*)
547 HandleReloadAchievementCriteriaDataCommand("");
548 HandleReloadAchievementRewardCommand("");
552 bool ChatHandler::HandleReloadAllAreaCommand(const char*)
554 //HandleReloadQuestAreaTriggersCommand(""); -- reloaded in HandleReloadAllQuestCommand
555 HandleReloadAreaTriggerTeleportCommand("");
556 HandleReloadAreaTriggerTavernCommand("");
557 HandleReloadGameGraveyardZoneCommand("");
561 bool ChatHandler::HandleReloadAllLootCommand(const char*)
563 sLog
.outString( "Re-Loading Loot Tables..." );
565 SendGlobalSysMessage("DB tables `*_loot_template` reloaded.");
569 bool ChatHandler::HandleReloadAllNpcCommand(const char* /*args*/)
571 HandleReloadNpcGossipCommand("a");
572 HandleReloadNpcOptionCommand("a");
573 HandleReloadNpcTrainerCommand("a");
574 HandleReloadNpcVendorCommand("a");
575 HandleReloadPointsOfInterestCommand("a");
576 HandleReloadSpellClickSpellsCommand("a");
580 bool ChatHandler::HandleReloadAllQuestCommand(const char* /*args*/)
582 HandleReloadQuestAreaTriggersCommand("a");
583 HandleReloadQuestTemplateCommand("a");
585 sLog
.outString( "Re-Loading Quests Relations..." );
586 objmgr
.LoadQuestRelations();
587 SendGlobalSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded.");
591 bool ChatHandler::HandleReloadAllScriptsCommand(const char*)
593 if(sWorld
.IsScriptScheduled())
595 PSendSysMessage("DB scripts used currently, please attempt reload later.");
596 SetSentErrorMessage(true);
600 sLog
.outString( "Re-Loading Scripts..." );
601 HandleReloadGameObjectScriptsCommand("a");
602 HandleReloadEventScriptsCommand("a");
603 HandleReloadQuestEndScriptsCommand("a");
604 HandleReloadQuestStartScriptsCommand("a");
605 HandleReloadSpellScriptsCommand("a");
606 SendGlobalSysMessage("DB tables `*_scripts` reloaded.");
607 HandleReloadDbScriptStringCommand("a");
611 bool ChatHandler::HandleReloadAllSpellCommand(const char*)
613 HandleReloadSkillDiscoveryTemplateCommand("a");
614 HandleReloadSkillExtraItemTemplateCommand("a");
615 HandleReloadSpellAffectCommand("a");
616 HandleReloadSpellAreaCommand("a");
617 HandleReloadSpellChainCommand("a");
618 HandleReloadSpellElixirCommand("a");
619 HandleReloadSpellLearnSpellCommand("a");
620 HandleReloadSpellProcEventCommand("a");
621 HandleReloadSpellBonusesCommand("a");
622 HandleReloadSpellScriptTargetCommand("a");
623 HandleReloadSpellTargetPositionCommand("a");
624 HandleReloadSpellThreatsCommand("a");
625 HandleReloadSpellPetAurasCommand("a");
629 bool ChatHandler::HandleReloadAllItemCommand(const char*)
631 HandleReloadPageTextsCommand("a");
632 HandleReloadItemEnchantementsCommand("a");
636 bool ChatHandler::HandleReloadAllLocalesCommand(const char* /*args*/)
638 HandleReloadLocalesAchievementRewardCommand("a");
639 HandleReloadLocalesCreatureCommand("a");
640 HandleReloadLocalesGameobjectCommand("a");
641 HandleReloadLocalesItemCommand("a");
642 HandleReloadLocalesNpcTextCommand("a");
643 HandleReloadLocalesPageTextCommand("a");
644 HandleReloadLocalesPointsOfInterestCommand("a");
645 HandleReloadLocalesQuestCommand("a");
649 bool ChatHandler::HandleReloadConfigCommand(const char* /*args*/)
651 sLog
.outString( "Re-Loading config settings..." );
652 sWorld
.LoadConfigSettings(true);
653 SendGlobalSysMessage("World config settings reloaded.");
657 bool ChatHandler::HandleReloadAchievementCriteriaDataCommand(const char*)
659 sLog
.outString( "Re-Loading Additional Achievement Criteria Data..." );
660 achievementmgr
.LoadAchievementCriteriaData();
661 SendGlobalSysMessage("DB table `achievement_criteria_data` reloaded.");
665 bool ChatHandler::HandleReloadAchievementRewardCommand(const char*)
667 sLog
.outString( "Re-Loading Achievement Reward Data..." );
668 achievementmgr
.LoadRewards();
669 SendGlobalSysMessage("DB table `achievement_reward` reloaded.");
673 bool ChatHandler::HandleReloadAreaTriggerTavernCommand(const char*)
675 sLog
.outString( "Re-Loading Tavern Area Triggers..." );
676 objmgr
.LoadTavernAreaTriggers();
677 SendGlobalSysMessage("DB table `areatrigger_tavern` reloaded.");
681 bool ChatHandler::HandleReloadAreaTriggerTeleportCommand(const char*)
683 sLog
.outString( "Re-Loading AreaTrigger teleport definitions..." );
684 objmgr
.LoadAreaTriggerTeleports();
685 SendGlobalSysMessage("DB table `areatrigger_teleport` reloaded.");
689 bool ChatHandler::HandleReloadCommandCommand(const char*)
691 load_command_table
= true;
692 SendGlobalSysMessage("DB table `command` will be reloaded at next chat command use.");
696 bool ChatHandler::HandleReloadCreatureQuestRelationsCommand(const char*)
698 sLog
.outString( "Loading Quests Relations... (`creature_questrelation`)" );
699 objmgr
.LoadCreatureQuestRelations();
700 SendGlobalSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded.");
704 bool ChatHandler::HandleReloadCreatureQuestInvRelationsCommand(const char*)
706 sLog
.outString( "Loading Quests Relations... (`creature_involvedrelation`)" );
707 objmgr
.LoadCreatureInvolvedRelations();
708 SendGlobalSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded.");
712 bool ChatHandler::HandleReloadGOQuestRelationsCommand(const char*)
714 sLog
.outString( "Loading Quests Relations... (`gameobject_questrelation`)" );
715 objmgr
.LoadGameobjectQuestRelations();
716 SendGlobalSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded.");
720 bool ChatHandler::HandleReloadGOQuestInvRelationsCommand(const char*)
722 sLog
.outString( "Loading Quests Relations... (`gameobject_involvedrelation`)" );
723 objmgr
.LoadGameobjectInvolvedRelations();
724 SendGlobalSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded.");
728 bool ChatHandler::HandleReloadQuestAreaTriggersCommand(const char*)
730 sLog
.outString( "Re-Loading Quest Area Triggers..." );
731 objmgr
.LoadQuestAreaTriggers();
732 SendGlobalSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded.");
736 bool ChatHandler::HandleReloadQuestTemplateCommand(const char*)
738 sLog
.outString( "Re-Loading Quest Templates..." );
740 SendGlobalSysMessage("DB table `quest_template` (quest definitions) reloaded.");
742 /// dependent also from `gameobject` but this table not reloaded anyway
743 sLog
.outString( "Re-Loading GameObjects for quests..." );
744 objmgr
.LoadGameObjectForQuests();
745 SendGlobalSysMessage("Data GameObjects for quests reloaded.");
749 bool ChatHandler::HandleReloadLootTemplatesCreatureCommand(const char*)
751 sLog
.outString( "Re-Loading Loot Tables... (`creature_loot_template`)" );
752 LoadLootTemplates_Creature();
753 LootTemplates_Creature
.CheckLootRefs();
754 SendGlobalSysMessage("DB table `creature_loot_template` reloaded.");
758 bool ChatHandler::HandleReloadLootTemplatesDisenchantCommand(const char*)
760 sLog
.outString( "Re-Loading Loot Tables... (`disenchant_loot_template`)" );
761 LoadLootTemplates_Disenchant();
762 LootTemplates_Disenchant
.CheckLootRefs();
763 SendGlobalSysMessage("DB table `disenchant_loot_template` reloaded.");
767 bool ChatHandler::HandleReloadLootTemplatesFishingCommand(const char*)
769 sLog
.outString( "Re-Loading Loot Tables... (`fishing_loot_template`)" );
770 LoadLootTemplates_Fishing();
771 LootTemplates_Fishing
.CheckLootRefs();
772 SendGlobalSysMessage("DB table `fishing_loot_template` reloaded.");
776 bool ChatHandler::HandleReloadLootTemplatesGameobjectCommand(const char*)
778 sLog
.outString( "Re-Loading Loot Tables... (`gameobject_loot_template`)" );
779 LoadLootTemplates_Gameobject();
780 LootTemplates_Gameobject
.CheckLootRefs();
781 SendGlobalSysMessage("DB table `gameobject_loot_template` reloaded.");
785 bool ChatHandler::HandleReloadLootTemplatesItemCommand(const char*)
787 sLog
.outString( "Re-Loading Loot Tables... (`item_loot_template`)" );
788 LoadLootTemplates_Item();
789 LootTemplates_Item
.CheckLootRefs();
790 SendGlobalSysMessage("DB table `item_loot_template` reloaded.");
794 bool ChatHandler::HandleReloadLootTemplatesMillingCommand(const char*)
796 sLog
.outString( "Re-Loading Loot Tables... (`milling_loot_template`)" );
797 LoadLootTemplates_Milling();
798 LootTemplates_Milling
.CheckLootRefs();
799 SendGlobalSysMessage("DB table `milling_loot_template` reloaded.");
803 bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(const char*)
805 sLog
.outString( "Re-Loading Loot Tables... (`pickpocketing_loot_template`)" );
806 LoadLootTemplates_Pickpocketing();
807 LootTemplates_Pickpocketing
.CheckLootRefs();
808 SendGlobalSysMessage("DB table `pickpocketing_loot_template` reloaded.");
812 bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(const char*)
814 sLog
.outString( "Re-Loading Loot Tables... (`prospecting_loot_template`)" );
815 LoadLootTemplates_Prospecting();
816 LootTemplates_Prospecting
.CheckLootRefs();
817 SendGlobalSysMessage("DB table `prospecting_loot_template` reloaded.");
821 bool ChatHandler::HandleReloadLootTemplatesQuestMailCommand(const char*)
823 sLog
.outString( "Re-Loading Loot Tables... (`quest_mail_loot_template`)" );
824 LoadLootTemplates_QuestMail();
825 LootTemplates_QuestMail
.CheckLootRefs();
826 SendGlobalSysMessage("DB table `quest_mail_loot_template` reloaded.");
830 bool ChatHandler::HandleReloadLootTemplatesReferenceCommand(const char*)
832 sLog
.outString( "Re-Loading Loot Tables... (`reference_loot_template`)" );
833 LoadLootTemplates_Reference();
834 SendGlobalSysMessage("DB table `reference_loot_template` reloaded.");
838 bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(const char*)
840 sLog
.outString( "Re-Loading Loot Tables... (`skinning_loot_template`)" );
841 LoadLootTemplates_Skinning();
842 LootTemplates_Skinning
.CheckLootRefs();
843 SendGlobalSysMessage("DB table `skinning_loot_template` reloaded.");
847 bool ChatHandler::HandleReloadLootTemplatesSpellCommand(const char*)
849 sLog
.outString( "Re-Loading Loot Tables... (`spell_loot_template`)" );
850 LoadLootTemplates_Spell();
851 LootTemplates_Spell
.CheckLootRefs();
852 SendGlobalSysMessage("DB table `spell_loot_template` reloaded.");
856 bool ChatHandler::HandleReloadMangosStringCommand(const char*)
858 sLog
.outString( "Re-Loading mangos_string Table!" );
859 objmgr
.LoadMangosStrings();
860 SendGlobalSysMessage("DB table `mangos_string` reloaded.");
864 bool ChatHandler::HandleReloadNpcOptionCommand(const char*)
866 sLog
.outString( "Re-Loading `npc_option` Table!" );
867 objmgr
.LoadNpcOptions();
868 SendGlobalSysMessage("DB table `npc_option` reloaded.");
872 bool ChatHandler::HandleReloadNpcGossipCommand(const char*)
874 sLog
.outString( "Re-Loading `npc_gossip` Table!" );
875 objmgr
.LoadNpcTextId();
876 SendGlobalSysMessage("DB table `npc_gossip` reloaded.");
880 bool ChatHandler::HandleReloadNpcTrainerCommand(const char*)
882 sLog
.outString( "Re-Loading `npc_trainer` Table!" );
883 objmgr
.LoadTrainerSpell();
884 SendGlobalSysMessage("DB table `npc_trainer` reloaded.");
888 bool ChatHandler::HandleReloadNpcVendorCommand(const char*)
890 sLog
.outString( "Re-Loading `npc_vendor` Table!" );
891 objmgr
.LoadVendors();
892 SendGlobalSysMessage("DB table `npc_vendor` reloaded.");
896 bool ChatHandler::HandleReloadPointsOfInterestCommand(const char*)
898 sLog
.outString( "Re-Loading `points_of_interest` Table!" );
899 objmgr
.LoadPointsOfInterest();
900 SendGlobalSysMessage("DB table `points_of_interest` reloaded.");
904 bool ChatHandler::HandleReloadSpellClickSpellsCommand(const char*)
906 sLog
.outString( "Re-Loading `npc_spellclick_spells` Table!" );
907 objmgr
.LoadNPCSpellClickSpells();
908 SendGlobalSysMessage("DB table `npc_spellclick_spells` reloaded.");
912 bool ChatHandler::HandleReloadReservedNameCommand(const char*)
914 sLog
.outString( "Loading ReservedNames... (`reserved_name`)" );
915 objmgr
.LoadReservedPlayersNames();
916 SendGlobalSysMessage("DB table `reserved_name` (player reserved names) reloaded.");
920 bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(const char* /*args*/)
922 sLog
.outString( "Re-Loading Skill Discovery Table..." );
923 LoadSkillDiscoveryTable();
924 SendGlobalSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded.");
928 bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(const char* /*args*/)
930 sLog
.outString( "Re-Loading Skill Extra Item Table..." );
931 LoadSkillExtraItemTable();
932 SendGlobalSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded.");
936 bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(const char* /*args*/)
938 sLog
.outString( "Re-Loading Skill Fishing base level requirements..." );
939 objmgr
.LoadFishingBaseSkillLevel();
940 SendGlobalSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded.");
944 bool ChatHandler::HandleReloadSpellAffectCommand(const char*)
946 sLog
.outString( "Re-Loading SpellAffect definitions..." );
947 spellmgr
.LoadSpellAffects();
948 SendGlobalSysMessage("DB table `spell_affect` (spell mods apply requirements) reloaded.");
952 bool ChatHandler::HandleReloadSpellAreaCommand(const char*)
954 sLog
.outString( "Re-Loading SpellArea Data..." );
955 spellmgr
.LoadSpellAreas();
956 SendGlobalSysMessage("DB table `spell_area` (spell dependences from area/quest/auras state) reloaded.");
960 bool ChatHandler::HandleReloadSpellChainCommand(const char*)
962 sLog
.outString( "Re-Loading Spell Chain Data... " );
963 spellmgr
.LoadSpellChains();
964 SendGlobalSysMessage("DB table `spell_chain` (spell ranks) reloaded.");
968 bool ChatHandler::HandleReloadSpellElixirCommand(const char*)
970 sLog
.outString( "Re-Loading Spell Elixir types..." );
971 spellmgr
.LoadSpellElixirs();
972 SendGlobalSysMessage("DB table `spell_elixir` (spell elixir types) reloaded.");
976 bool ChatHandler::HandleReloadSpellLearnSpellCommand(const char*)
978 sLog
.outString( "Re-Loading Spell Learn Spells..." );
979 spellmgr
.LoadSpellLearnSpells();
980 SendGlobalSysMessage("DB table `spell_learn_spell` reloaded.");
984 bool ChatHandler::HandleReloadSpellProcEventCommand(const char*)
986 sLog
.outString( "Re-Loading Spell Proc Event conditions..." );
987 spellmgr
.LoadSpellProcEvents();
988 SendGlobalSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded.");
992 bool ChatHandler::HandleReloadSpellBonusesCommand(const char*)
994 sLog
.outString( "Re-Loading Spell Bonus Data..." );
995 spellmgr
.LoadSpellBonusess();
996 SendGlobalSysMessage("DB table `spell_bonus_data` (spell damage/healing coefficients) reloaded.");
1000 bool ChatHandler::HandleReloadSpellScriptTargetCommand(const char*)
1002 sLog
.outString( "Re-Loading SpellsScriptTarget..." );
1003 spellmgr
.LoadSpellScriptTarget();
1004 SendGlobalSysMessage("DB table `spell_script_target` (spell targets selection in case specific creature/GO requirements) reloaded.");
1008 bool ChatHandler::HandleReloadSpellTargetPositionCommand(const char*)
1010 sLog
.outString( "Re-Loading Spell target coordinates..." );
1011 spellmgr
.LoadSpellTargetPositions();
1012 SendGlobalSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded.");
1016 bool ChatHandler::HandleReloadSpellThreatsCommand(const char*)
1018 sLog
.outString( "Re-Loading Aggro Spells Definitions...");
1019 spellmgr
.LoadSpellThreats();
1020 SendGlobalSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded.");
1024 bool ChatHandler::HandleReloadSpellPetAurasCommand(const char*)
1026 sLog
.outString( "Re-Loading Spell pet auras...");
1027 spellmgr
.LoadSpellPetAuras();
1028 SendGlobalSysMessage("DB table `spell_pet_auras` reloaded.");
1032 bool ChatHandler::HandleReloadPageTextsCommand(const char*)
1034 sLog
.outString( "Re-Loading Page Texts..." );
1035 objmgr
.LoadPageTexts();
1036 SendGlobalSysMessage("DB table `page_texts` reloaded.");
1040 bool ChatHandler::HandleReloadItemEnchantementsCommand(const char*)
1042 sLog
.outString( "Re-Loading Item Random Enchantments Table..." );
1043 LoadRandomEnchantmentsTable();
1044 SendGlobalSysMessage("DB table `item_enchantment_template` reloaded.");
1048 bool ChatHandler::HandleReloadGameObjectScriptsCommand(const char* arg
)
1050 if(sWorld
.IsScriptScheduled())
1052 SendSysMessage("DB scripts used currently, please attempt reload later.");
1053 SetSentErrorMessage(true);
1058 sLog
.outString( "Re-Loading Scripts from `gameobject_scripts`...");
1060 objmgr
.LoadGameObjectScripts();
1063 SendGlobalSysMessage("DB table `gameobject_scripts` reloaded.");
1068 bool ChatHandler::HandleReloadEventScriptsCommand(const char* arg
)
1070 if(sWorld
.IsScriptScheduled())
1072 SendSysMessage("DB scripts used currently, please attempt reload later.");
1073 SetSentErrorMessage(true);
1078 sLog
.outString( "Re-Loading Scripts from `event_scripts`...");
1080 objmgr
.LoadEventScripts();
1083 SendGlobalSysMessage("DB table `event_scripts` reloaded.");
1088 bool ChatHandler::HandleReloadQuestEndScriptsCommand(const char* arg
)
1090 if(sWorld
.IsScriptScheduled())
1092 SendSysMessage("DB scripts used currently, please attempt reload later.");
1093 SetSentErrorMessage(true);
1098 sLog
.outString( "Re-Loading Scripts from `quest_end_scripts`...");
1100 objmgr
.LoadQuestEndScripts();
1103 SendGlobalSysMessage("DB table `quest_end_scripts` reloaded.");
1108 bool ChatHandler::HandleReloadQuestStartScriptsCommand(const char* arg
)
1110 if(sWorld
.IsScriptScheduled())
1112 SendSysMessage("DB scripts used currently, please attempt reload later.");
1113 SetSentErrorMessage(true);
1118 sLog
.outString( "Re-Loading Scripts from `quest_start_scripts`...");
1120 objmgr
.LoadQuestStartScripts();
1123 SendGlobalSysMessage("DB table `quest_start_scripts` reloaded.");
1128 bool ChatHandler::HandleReloadSpellScriptsCommand(const char* arg
)
1130 if(sWorld
.IsScriptScheduled())
1132 SendSysMessage("DB scripts used currently, please attempt reload later.");
1133 SetSentErrorMessage(true);
1138 sLog
.outString( "Re-Loading Scripts from `spell_scripts`...");
1140 objmgr
.LoadSpellScripts();
1143 SendGlobalSysMessage("DB table `spell_scripts` reloaded.");
1148 bool ChatHandler::HandleReloadDbScriptStringCommand(const char* /*arg*/)
1150 sLog
.outString( "Re-Loading Script strings from `db_script_string`...");
1151 objmgr
.LoadDbScriptStrings();
1152 SendGlobalSysMessage("DB table `db_script_string` reloaded.");
1156 bool ChatHandler::HandleReloadGameGraveyardZoneCommand(const char* /*arg*/)
1158 sLog
.outString( "Re-Loading Graveyard-zone links...");
1160 objmgr
.LoadGraveyardZones();
1162 SendGlobalSysMessage("DB table `game_graveyard_zone` reloaded.");
1167 bool ChatHandler::HandleReloadGameTeleCommand(const char* /*arg*/)
1169 sLog
.outString( "Re-Loading Game Tele coordinates...");
1171 objmgr
.LoadGameTele();
1173 SendGlobalSysMessage("DB table `game_tele` reloaded.");
1178 bool ChatHandler::HandleReloadLocalesAchievementRewardCommand(const char*)
1180 sLog
.outString( "Re-Loading Locales Achievement Reward Data..." );
1181 achievementmgr
.LoadRewardLocales();
1182 SendGlobalSysMessage("DB table `locales_achievement_reward` reloaded.");
1186 bool ChatHandler::HandleReloadLocalesCreatureCommand(const char* /*arg*/)
1188 sLog
.outString( "Re-Loading Locales Creature ...");
1189 objmgr
.LoadCreatureLocales();
1190 SendGlobalSysMessage("DB table `locales_creature` reloaded.");
1194 bool ChatHandler::HandleReloadLocalesGameobjectCommand(const char* /*arg*/)
1196 sLog
.outString( "Re-Loading Locales Gameobject ... ");
1197 objmgr
.LoadGameObjectLocales();
1198 SendGlobalSysMessage("DB table `locales_gameobject` reloaded.");
1202 bool ChatHandler::HandleReloadLocalesItemCommand(const char* /*arg*/)
1204 sLog
.outString( "Re-Loading Locales Item ... ");
1205 objmgr
.LoadItemLocales();
1206 SendGlobalSysMessage("DB table `locales_item` reloaded.");
1210 bool ChatHandler::HandleReloadLocalesNpcTextCommand(const char* /*arg*/)
1212 sLog
.outString( "Re-Loading Locales NPC Text ... ");
1213 objmgr
.LoadNpcTextLocales();
1214 SendGlobalSysMessage("DB table `locales_npc_text` reloaded.");
1218 bool ChatHandler::HandleReloadLocalesPageTextCommand(const char* /*arg*/)
1220 sLog
.outString( "Re-Loading Locales Page Text ... ");
1221 objmgr
.LoadPageTextLocales();
1222 SendGlobalSysMessage("DB table `locales_page_text` reloaded.");
1226 bool ChatHandler::HandleReloadLocalesPointsOfInterestCommand(const char* /*arg*/)
1228 sLog
.outString( "Re-Loading Locales Points Of Interest ... ");
1229 objmgr
.LoadPointOfInterestLocales();
1230 SendGlobalSysMessage("DB table `locales_points_of_interest` reloaded.");
1234 bool ChatHandler::HandleReloadLocalesQuestCommand(const char* /*arg*/)
1236 sLog
.outString( "Re-Loading Locales Quest ... ");
1237 objmgr
.LoadQuestLocales();
1238 SendGlobalSysMessage("DB table `locales_quest` reloaded.");
1242 bool ChatHandler::HandleLoadScriptsCommand(const char* args
)
1244 if(!LoadScriptingModule(args
)) return true;
1246 sWorld
.SendWorldText(LANG_SCRIPTS_RELOADED
);
1250 bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args
)
1252 char* arg1
= strtok((char*)args
, " ");
1256 /// must be NULL if targeted syntax and must be not nULL if not targeted
1257 char* arg2
= strtok(NULL
, " ");
1259 std::string targetAccountName
;
1260 uint32 targetAccountId
= 0;
1262 /// only target player different from self allowed (if targetPlayer!=NULL then not console)
1263 Player
* targetPlayer
= getSelectedPlayer();
1264 if(targetPlayer
&& m_session
->GetPlayer()!=targetPlayer
)
1266 /// wrong command syntax or unexpected targeting
1270 /// security level expected in arg2 after this if.
1273 targetAccountId
= targetPlayer
->GetSession()->GetAccountId();
1274 accmgr
.GetName(targetAccountId
, targetAccountName
);
1278 /// wrong command syntax (second arg expected)
1282 targetAccountName
= arg1
;
1283 if(!AccountMgr::normilizeString(targetAccountName
))
1285 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,targetAccountName
.c_str());
1286 SetSentErrorMessage(true);
1290 targetAccountId
= accmgr
.GetId(targetAccountName
);
1291 if(!targetAccountId
)
1293 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,targetAccountName
.c_str());
1294 SetSentErrorMessage(true);
1299 int32 gm
= (int32
)atoi(arg2
);
1300 if ( gm
< SEC_PLAYER
|| gm
> SEC_ADMINISTRATOR
)
1302 SendSysMessage(LANG_BAD_VALUE
);
1303 SetSentErrorMessage(true);
1307 /// can set security level only for target with less security and to less security that we have
1308 /// This will reject self apply by specify account name
1309 if(HasLowerSecurityAccount(NULL
,targetAccountId
,true))
1312 /// account can't set security to same or grater level, need more power GM or console
1313 AccountTypes plSecurity
= m_session
? m_session
->GetSecurity() : SEC_CONSOLE
;
1314 if (AccountTypes(gm
) >= plSecurity
)
1316 SendSysMessage(LANG_YOURS_SECURITY_IS_LOW
);
1317 SetSentErrorMessage(true);
1321 // This will prevent self apply by self target or no target
1322 if(targetPlayer
&& m_session
->GetPlayer()!=targetPlayer
)
1324 ChatHandler(targetPlayer
).PSendSysMessage(LANG_YOURS_SECURITY_CHANGED
,GetNameLink().c_str(), gm
);
1325 targetPlayer
->GetSession()->SetSecurity(AccountTypes(gm
));
1328 PSendSysMessage(LANG_YOU_CHANGE_SECURITY
, targetAccountName
.c_str(), gm
);
1329 loginDatabase
.PExecute("UPDATE account SET gmlevel = '%i' WHERE id = '%u'", gm
, targetAccountId
);
1334 /// Set password for account
1335 bool ChatHandler::HandleAccountSetPasswordCommand(const char* args
)
1340 ///- Get the command line arguments
1341 char *szAccount
= strtok ((char*)args
," ");
1342 char *szPassword1
= strtok (NULL
," ");
1343 char *szPassword2
= strtok (NULL
," ");
1345 if (!szAccount
||!szPassword1
|| !szPassword2
)
1348 std::string account_name
= szAccount
;
1349 if(!AccountMgr::normilizeString(account_name
))
1351 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
1352 SetSentErrorMessage(true);
1356 uint32 targetAccountId
= accmgr
.GetId(account_name
);
1357 if (!targetAccountId
)
1359 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
1360 SetSentErrorMessage(true);
1364 /// can set password only for target with less security
1365 /// This is also reject self apply in fact
1366 if(HasLowerSecurityAccount (NULL
,targetAccountId
,true))
1369 if (strcmp(szPassword1
,szPassword2
))
1371 SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH
);
1372 SetSentErrorMessage (true);
1376 AccountOpResult result
= accmgr
.ChangePassword(targetAccountId
, szPassword1
);
1381 SendSysMessage(LANG_COMMAND_PASSWORD
);
1383 case AOR_NAME_NOT_EXIST
:
1384 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
1385 SetSentErrorMessage(true);
1387 case AOR_PASS_TOO_LONG
:
1388 SendSysMessage(LANG_PASSWORD_TOO_LONG
);
1389 SetSentErrorMessage(true);
1392 SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD
);
1393 SetSentErrorMessage(true);
1400 bool ChatHandler::HandleMaxSkillCommand(const char* /*args*/)
1402 Player
* SelectedPlayer
= getSelectedPlayer();
1405 SendSysMessage(LANG_NO_CHAR_SELECTED
);
1406 SetSentErrorMessage(true);
1410 // each skills that have max skill value dependent from level seted to current level max skill value
1411 SelectedPlayer
->UpdateSkillsToMaxSkillsForLevel();
1415 bool ChatHandler::HandleSetSkillCommand(const char* args
)
1417 // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r
1418 char* skill_p
= extractKeyFromLink((char*)args
,"Hskill");
1422 char *level_p
= strtok (NULL
, " ");
1427 char *max_p
= strtok (NULL
, " ");
1429 int32 skill
= atoi(skill_p
);
1432 PSendSysMessage(LANG_INVALID_SKILL_ID
, skill
);
1433 SetSentErrorMessage(true);
1437 int32 level
= atol (level_p
);
1439 Player
* target
= getSelectedPlayer();
1442 SendSysMessage(LANG_NO_CHAR_SELECTED
);
1443 SetSentErrorMessage(true);
1447 SkillLineEntry
const* sl
= sSkillLineStore
.LookupEntry(skill
);
1450 PSendSysMessage(LANG_INVALID_SKILL_ID
, skill
);
1451 SetSentErrorMessage(true);
1455 std::string tNameLink
= GetNameLink(target
);
1457 if(!target
->GetSkillValue(skill
))
1459 PSendSysMessage(LANG_SET_SKILL_ERROR
, tNameLink
.c_str(), skill
, sl
->name
[0]);
1460 SetSentErrorMessage(true);
1464 int32 max
= max_p
? atol (max_p
) : target
->GetPureMaxSkillValue(skill
);
1466 if( level
<= 0 || level
> max
|| max
<= 0 )
1469 target
->SetSkill(skill
, level
, max
);
1470 PSendSysMessage(LANG_SET_SKILL
, skill
, sl
->name
[0], tNameLink
.c_str(), level
, max
);
1475 bool ChatHandler::HandleUnLearnCommand(const char* args
)
1480 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
1481 uint32 spell_id
= extractSpellIdFromLink((char*)args
);
1485 char const* allStr
= strtok(NULL
," ");
1486 bool allRanks
= allStr
? (strncmp(allStr
, "all", strlen(allStr
)) == 0) : false;
1488 Player
* target
= getSelectedPlayer();
1491 SendSysMessage(LANG_NO_CHAR_SELECTED
);
1492 SetSentErrorMessage(true);
1497 spell_id
= spellmgr
.GetFirstSpellInChain (spell_id
);
1499 if (target
->HasSpell(spell_id
))
1500 target
->removeSpell(spell_id
,false,!allRanks
);
1502 SendSysMessage(LANG_FORGET_SPELL
);
1507 bool ChatHandler::HandleCooldownCommand(const char* args
)
1509 Player
* target
= getSelectedPlayer();
1512 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
1513 SetSentErrorMessage(true);
1517 std::string tNameLink
= GetNameLink(target
);
1521 target
->RemoveAllSpellCooldown();
1522 PSendSysMessage(LANG_REMOVEALL_COOLDOWN
, tNameLink
.c_str());
1526 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
1527 uint32 spell_id
= extractSpellIdFromLink((char*)args
);
1531 if(!sSpellStore
.LookupEntry(spell_id
))
1533 PSendSysMessage(LANG_UNKNOWN_SPELL
, target
==m_session
->GetPlayer() ? GetMangosString(LANG_YOU
) : tNameLink
.c_str());
1534 SetSentErrorMessage(true);
1538 WorldPacket
data( SMSG_CLEAR_COOLDOWN
, (4+8) );
1539 data
<< uint32(spell_id
);
1540 data
<< uint64(target
->GetGUID());
1541 target
->GetSession()->SendPacket(&data
);
1542 target
->RemoveSpellCooldown(spell_id
);
1543 PSendSysMessage(LANG_REMOVE_COOLDOWN
, spell_id
, target
==m_session
->GetPlayer() ? GetMangosString(LANG_YOU
) : tNameLink
.c_str());
1548 bool ChatHandler::HandleLearnAllCommand(const char* /*args*/)
1550 static const char *allSpellList
[] =
1933 //"9036", problems with ghost state
1942 //"6718", phasing stealth, annoying for learn all case.
2155 while(strcmp(allSpellList
[loop
], "0"))
2157 uint32 spell
= atol((char*)allSpellList
[loop
++]);
2159 if (m_session
->GetPlayer()->HasSpell(spell
))
2162 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
2163 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
2165 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
2169 m_session
->GetPlayer()->learnSpell(spell
,false);
2172 SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS
);
2177 bool ChatHandler::HandleLearnAllGMCommand(const char* /*args*/)
2179 static const char *gmSpellList
[] =
2181 "24347", // Become A Fish, No Breath Bar
2182 "35132", // Visual Boom
2183 "38488", // Attack 4000-8000 AOE
2184 "38795", // Attack 2000 AOE + Slow Down 90%
2185 "15712", // Attack 200
2186 "1852", // GM Spell Silence
2189 "29878", // Kill My Self
2190 "26644", // More Kill
2192 "28550", //Invisible 24
2193 "23452", //Invisible + Target
2197 uint16 gmSpellIter
= 0;
2198 while( strcmp(gmSpellList
[gmSpellIter
], "0") )
2200 uint32 spell
= atol((char*)gmSpellList
[gmSpellIter
++]);
2202 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
2203 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
2205 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
2209 m_session
->GetPlayer()->learnSpell(spell
,false);
2212 SendSysMessage(LANG_LEARNING_GM_SKILLS
);
2216 bool ChatHandler::HandleLearnAllMyClassCommand(const char* /*args*/)
2218 HandleLearnAllMySpellsCommand("");
2219 HandleLearnAllMyTalentsCommand("");
2223 bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/)
2225 ChrClassesEntry
const* clsEntry
= sChrClassesStore
.LookupEntry(m_session
->GetPlayer()->getClass());
2228 uint32 family
= clsEntry
->spellfamily
;
2230 for (uint32 i
= 0; i
< sSpellStore
.GetNumRows(); ++i
)
2232 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(i
);
2236 // skip server-side/triggered spells
2237 if(spellInfo
->spellLevel
==0)
2240 // skip wrong class/race skills
2241 if(!m_session
->GetPlayer()->IsSpellFitByClassAndRace(spellInfo
->Id
))
2244 // skip other spell families
2245 if( spellInfo
->SpellFamilyName
!= family
)
2248 // skip spells with first rank learned as talent (and all talents then also)
2249 uint32 first_rank
= spellmgr
.GetFirstSpellInChain(spellInfo
->Id
);
2250 if(GetTalentSpellCost(first_rank
) > 0 )
2253 // skip broken spells
2254 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer(),false))
2257 m_session
->GetPlayer()->learnSpell(i
,false);
2260 SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS
);
2264 bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/)
2266 Player
* player
= m_session
->GetPlayer();
2267 uint32 classMask
= player
->getClassMask();
2269 for (uint32 i
= 0; i
< sTalentStore
.GetNumRows(); ++i
)
2271 TalentEntry
const *talentInfo
= sTalentStore
.LookupEntry(i
);
2275 TalentTabEntry
const *talentTabInfo
= sTalentTabStore
.LookupEntry( talentInfo
->TalentTab
);
2279 if( (classMask
& talentTabInfo
->ClassMask
) == 0 )
2282 // search highest talent rank
2285 for(int rank
= MAX_TALENT_RANK
-1; rank
>= 0; --rank
)
2287 if(talentInfo
->RankID
[rank
]!=0)
2289 spellid
= talentInfo
->RankID
[rank
];
2294 if(!spellid
) // ??? none spells in talent
2297 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spellid
);
2298 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer(),false))
2301 // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree)
2302 player
->learnSpellHighRank(spellid
);
2305 SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS
);
2309 bool ChatHandler::HandleLearnAllMyPetTalentsCommand(const char* /*args*/)
2311 Player
* player
= m_session
->GetPlayer();
2313 Pet
* pet
= player
->GetPet();
2316 SendSysMessage(LANG_NO_PET_FOUND
);
2317 SetSentErrorMessage(true);
2321 CreatureInfo
const *ci
= pet
->GetCreatureInfo();
2324 SendSysMessage(LANG_WRONG_PET_TYPE
);
2325 SetSentErrorMessage(true);
2329 CreatureFamilyEntry
const *pet_family
= sCreatureFamilyStore
.LookupEntry(ci
->family
);
2332 SendSysMessage(LANG_WRONG_PET_TYPE
);
2333 SetSentErrorMessage(true);
2337 if(pet_family
->petTalentType
< 0) // not hunter pet
2339 SendSysMessage(LANG_WRONG_PET_TYPE
);
2340 SetSentErrorMessage(true);
2344 for (uint32 i
= 0; i
< sTalentStore
.GetNumRows(); ++i
)
2346 TalentEntry
const *talentInfo
= sTalentStore
.LookupEntry(i
);
2350 TalentTabEntry
const *talentTabInfo
= sTalentTabStore
.LookupEntry( talentInfo
->TalentTab
);
2354 // prevent learn talent for different family (cheating)
2355 if(((1 << pet_family
->petTalentType
) & talentTabInfo
->petTalentMask
)==0)
2358 // search highest talent rank
2361 for(int rank
= MAX_TALENT_RANK
-1; rank
>= 0; --rank
)
2363 if(talentInfo
->RankID
[rank
]!=0)
2365 spellid
= talentInfo
->RankID
[rank
];
2370 if(!spellid
) // ??? none spells in talent
2373 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spellid
);
2374 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer(),false))
2377 // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree)
2378 pet
->learnSpellHighRank(spellid
);
2381 SendSysMessage(LANG_COMMAND_LEARN_PET_TALENTS
);
2385 bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/)
2387 // skipping UNIVERSAL language (0)
2388 for(int i
= 1; i
< LANGUAGES_COUNT
; ++i
)
2389 m_session
->GetPlayer()->learnSpell(lang_description
[i
].spell_id
,false);
2391 SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG
);
2395 bool ChatHandler::HandleLearnAllDefaultCommand(const char* args
)
2397 Player
*player
= NULL
;
2400 std::string name
= extractPlayerNameFromLink((char*)args
);
2403 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
2404 SetSentErrorMessage(true);
2408 player
= objmgr
.GetPlayer(name
.c_str());
2411 player
= getSelectedPlayer();
2415 SendSysMessage(LANG_NO_CHAR_SELECTED
);
2416 SetSentErrorMessage(true);
2420 player
->learnDefaultSpells();
2421 player
->learnQuestRewardedSpells();
2423 PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST
,GetNameLink(player
).c_str());
2427 bool ChatHandler::HandleLearnCommand(const char* args
)
2429 Player
* targetPlayer
= getSelectedPlayer();
2433 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
2434 SetSentErrorMessage(true);
2438 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
2439 uint32 spell
= extractSpellIdFromLink((char*)args
);
2440 if(!spell
|| !sSpellStore
.LookupEntry(spell
))
2443 char const* allStr
= strtok(NULL
," ");
2444 bool allRanks
= allStr
? (strncmp(allStr
, "all", strlen(allStr
)) == 0) : false;
2446 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
2447 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
2449 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
2450 SetSentErrorMessage(true);
2454 if (!allRanks
&& targetPlayer
->HasSpell(spell
))
2456 if(targetPlayer
== m_session
->GetPlayer())
2457 SendSysMessage(LANG_YOU_KNOWN_SPELL
);
2459 PSendSysMessage(LANG_TARGET_KNOWN_SPELL
,GetNameLink(targetPlayer
).c_str());
2460 SetSentErrorMessage(true);
2465 targetPlayer
->learnSpellHighRank(spell
);
2467 targetPlayer
->learnSpell(spell
,false);
2472 bool ChatHandler::HandleAddItemCommand(const char* args
)
2479 if(args
[0]=='[') // [name] manual form
2481 char* citemName
= strtok((char*)args
, "]");
2483 if(citemName
&& citemName
[0])
2485 std::string itemName
= citemName
+1;
2486 WorldDatabase
.escape_string(itemName
);
2487 QueryResult
*result
= WorldDatabase
.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName
.c_str());
2490 PSendSysMessage(LANG_COMMAND_COULDNOTFIND
, citemName
+1);
2491 SetSentErrorMessage(true);
2494 itemId
= result
->Fetch()->GetUInt16();
2500 else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r
2502 char* cId
= extractKeyFromLink((char*)args
,"Hitem");
2508 char* ccount
= strtok(NULL
, " ");
2513 count
= strtol(ccount
, NULL
, 10);
2518 Player
* pl
= m_session
->GetPlayer();
2519 Player
* plTarget
= getSelectedPlayer();
2523 sLog
.outDetail(GetMangosString(LANG_ADDITEM
), itemId
, count
);
2525 ItemPrototype
const *pProto
= objmgr
.GetItemPrototype(itemId
);
2528 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID
, itemId
);
2529 SetSentErrorMessage(true);
2536 plTarget
->DestroyItemCount(itemId
, -count
, true, false);
2537 PSendSysMessage(LANG_REMOVEITEM
, itemId
, -count
, GetNameLink(plTarget
).c_str());
2542 uint32 noSpaceForCount
= 0;
2544 // check space and find places
2545 ItemPosCountVec dest
;
2546 uint8 msg
= plTarget
->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, itemId
, count
, &noSpaceForCount
);
2547 if( msg
!= EQUIP_ERR_OK
) // convert to possible store amount
2548 count
-= noSpaceForCount
;
2550 if( count
== 0 || dest
.empty()) // can't add any
2552 PSendSysMessage(LANG_ITEM_CANNOT_CREATE
, itemId
, noSpaceForCount
);
2553 SetSentErrorMessage(true);
2557 Item
* item
= plTarget
->StoreNewItem( dest
, itemId
, true, Item::GenerateItemRandomPropertyId(itemId
));
2559 // remove binding (let GM give it to another player later)
2561 for(ItemPosCountVec::const_iterator itr
= dest
.begin(); itr
!= dest
.end(); ++itr
)
2562 if(Item
* item1
= pl
->GetItemByPos(itr
->pos
))
2563 item1
->SetBinding( false );
2565 if(count
> 0 && item
)
2567 pl
->SendNewItem(item
,count
,false,true);
2569 plTarget
->SendNewItem(item
,count
,true,false);
2572 if(noSpaceForCount
> 0)
2573 PSendSysMessage(LANG_ITEM_CANNOT_CREATE
, itemId
, noSpaceForCount
);
2578 bool ChatHandler::HandleAddItemSetCommand(const char* args
)
2583 char* cId
= extractKeyFromLink((char*)args
,"Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r
2587 uint32 itemsetId
= atol(cId
);
2589 // prevent generation all items with itemset field value '0'
2592 PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND
,itemsetId
);
2593 SetSentErrorMessage(true);
2597 Player
* pl
= m_session
->GetPlayer();
2598 Player
* plTarget
= getSelectedPlayer();
2602 sLog
.outDetail(GetMangosString(LANG_ADDITEMSET
), itemsetId
);
2605 for (uint32 id
= 0; id
< sItemStorage
.MaxEntry
; id
++)
2607 ItemPrototype
const *pProto
= sItemStorage
.LookupEntry
<ItemPrototype
>(id
);
2611 if (pProto
->ItemSet
== itemsetId
)
2614 ItemPosCountVec dest
;
2615 uint8 msg
= plTarget
->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, pProto
->ItemId
, 1 );
2616 if (msg
== EQUIP_ERR_OK
)
2618 Item
* item
= plTarget
->StoreNewItem( dest
, pProto
->ItemId
, true);
2620 // remove binding (let GM give it to another player later)
2622 item
->SetBinding( false );
2624 pl
->SendNewItem(item
,1,false,true);
2626 plTarget
->SendNewItem(item
,1,true,false);
2630 pl
->SendEquipError( msg
, NULL
, NULL
);
2631 PSendSysMessage(LANG_ITEM_CANNOT_CREATE
, pProto
->ItemId
, 1);
2638 PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND
,itemsetId
);
2640 SetSentErrorMessage(true);
2647 bool ChatHandler::HandleListItemCommand(const char* args
)
2652 char* cId
= extractKeyFromLink((char*)args
,"Hitem");
2656 uint32 item_id
= atol(cId
);
2659 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID
, item_id
);
2660 SetSentErrorMessage(true);
2664 ItemPrototype
const* itemProto
= objmgr
.GetItemPrototype(item_id
);
2667 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID
, item_id
);
2668 SetSentErrorMessage(true);
2672 char* c_count
= strtok(NULL
, " ");
2673 int count
= c_count
? atol(c_count
) : 10;
2678 QueryResult
*result
;
2681 uint32 inv_count
= 0;
2682 result
=CharacterDatabase
.PQuery("SELECT COUNT(item_template) FROM character_inventory WHERE item_template='%u'",item_id
);
2685 inv_count
= (*result
)[0].GetUInt32();
2689 result
=CharacterDatabase
.PQuery(
2691 "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name "
2692 "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters "
2693 "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ",
2694 item_id
,uint32(count
));
2700 Field
*fields
= result
->Fetch();
2701 uint32 item_guid
= fields
[0].GetUInt32();
2702 uint32 item_bag
= fields
[1].GetUInt32();
2703 uint32 item_slot
= fields
[2].GetUInt32();
2704 uint32 owner_guid
= fields
[3].GetUInt32();
2705 uint32 owner_acc
= fields
[4].GetUInt32();
2706 std::string owner_name
= fields
[5].GetCppString();
2708 char const* item_pos
= 0;
2709 if(Player::IsEquipmentPos(item_bag
,item_slot
))
2710 item_pos
= "[equipped]";
2711 else if(Player::IsInventoryPos(item_bag
,item_slot
))
2712 item_pos
= "[in inventory]";
2713 else if(Player::IsBankPos(item_bag
,item_slot
))
2714 item_pos
= "[in bank]";
2718 PSendSysMessage(LANG_ITEMLIST_SLOT
,
2719 item_guid
,owner_name
.c_str(),owner_guid
,owner_acc
,item_pos
);
2720 } while (result
->NextRow());
2722 int64 res_count
= result
->GetRowCount();
2726 if(count
> res_count
)
2733 uint32 mail_count
= 0;
2734 result
=CharacterDatabase
.PQuery("SELECT COUNT(item_template) FROM mail_items WHERE item_template='%u'", item_id
);
2737 mail_count
= (*result
)[0].GetUInt32();
2743 result
=CharacterDatabase
.PQuery(
2745 "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name "
2746 "FROM mail,mail_items,characters as char_s,characters as char_r "
2747 "WHERE mail_items.item_template='%u' AND char_s.guid = mail.sender AND char_r.guid = mail.receiver AND mail.id=mail_items.mail_id LIMIT %u",
2748 item_id
,uint32(count
));
2757 Field
*fields
= result
->Fetch();
2758 uint32 item_guid
= fields
[0].GetUInt32();
2759 uint32 item_s
= fields
[1].GetUInt32();
2760 uint32 item_r
= fields
[2].GetUInt32();
2761 uint32 item_s_acc
= fields
[3].GetUInt32();
2762 std::string item_s_name
= fields
[4].GetCppString();
2763 uint32 item_r_acc
= fields
[5].GetUInt32();
2764 std::string item_r_name
= fields
[6].GetCppString();
2766 char const* item_pos
= "[in mail]";
2768 PSendSysMessage(LANG_ITEMLIST_MAIL
,
2769 item_guid
,item_s_name
.c_str(),item_s
,item_s_acc
,item_r_name
.c_str(),item_r
,item_r_acc
,item_pos
);
2770 } while (result
->NextRow());
2772 int64 res_count
= result
->GetRowCount();
2776 if(count
> res_count
)
2783 uint32 auc_count
= 0;
2784 result
=CharacterDatabase
.PQuery("SELECT COUNT(item_template) FROM auctionhouse WHERE item_template='%u'",item_id
);
2787 auc_count
= (*result
)[0].GetUInt32();
2793 result
=CharacterDatabase
.PQuery(
2795 "SELECT auctionhouse.itemguid, auctionhouse.itemowner, characters.account, characters.name "
2796 "FROM auctionhouse,characters WHERE auctionhouse.item_template='%u' AND characters.guid = auctionhouse.itemowner LIMIT %u",
2797 item_id
,uint32(count
));
2806 Field
*fields
= result
->Fetch();
2807 uint32 item_guid
= fields
[0].GetUInt32();
2808 uint32 owner
= fields
[1].GetUInt32();
2809 uint32 owner_acc
= fields
[2].GetUInt32();
2810 std::string owner_name
= fields
[3].GetCppString();
2812 char const* item_pos
= "[in auction]";
2814 PSendSysMessage(LANG_ITEMLIST_AUCTION
, item_guid
, owner_name
.c_str(), owner
, owner_acc
,item_pos
);
2815 } while (result
->NextRow());
2821 uint32 guild_count
= 0;
2822 result
=CharacterDatabase
.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id
);
2825 guild_count
= (*result
)[0].GetUInt32();
2829 result
=CharacterDatabase
.PQuery(
2831 "SELECT gi.item_guid, gi.guildid, guild.name "
2832 "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ",
2833 item_id
,uint32(count
));
2839 Field
*fields
= result
->Fetch();
2840 uint32 item_guid
= fields
[0].GetUInt32();
2841 uint32 guild_guid
= fields
[1].GetUInt32();
2842 std::string guild_name
= fields
[2].GetCppString();
2844 char const* item_pos
= "[in guild bank]";
2846 PSendSysMessage(LANG_ITEMLIST_GUILD
,item_guid
,guild_name
.c_str(),guild_guid
,item_pos
);
2847 } while (result
->NextRow());
2849 int64 res_count
= result
->GetRowCount();
2853 if(count
> res_count
)
2859 if(inv_count
+mail_count
+auc_count
+guild_count
== 0)
2861 SendSysMessage(LANG_COMMAND_NOITEMFOUND
);
2862 SetSentErrorMessage(true);
2866 PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE
,item_id
,inv_count
+mail_count
+auc_count
+guild_count
,inv_count
,mail_count
,auc_count
,guild_count
);
2871 bool ChatHandler::HandleListObjectCommand(const char* args
)
2876 // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
2877 char* cId
= extractKeyFromLink((char*)args
,"Hgameobject_entry");
2881 uint32 go_id
= atol(cId
);
2884 PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID
, go_id
);
2885 SetSentErrorMessage(true);
2889 GameObjectInfo
const * gInfo
= objmgr
.GetGameObjectInfo(go_id
);
2892 PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID
, go_id
);
2893 SetSentErrorMessage(true);
2897 char* c_count
= strtok(NULL
, " ");
2898 int count
= c_count
? atol(c_count
) : 10;
2903 QueryResult
*result
;
2905 uint32 obj_count
= 0;
2906 result
=WorldDatabase
.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'",go_id
);
2909 obj_count
= (*result
)[0].GetUInt32();
2915 Player
* pl
= m_session
->GetPlayer();
2916 result
= WorldDatabase
.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
2917 pl
->GetPositionX(), pl
->GetPositionY(), pl
->GetPositionZ(),go_id
,uint32(count
));
2920 result
= WorldDatabase
.PQuery("SELECT guid, position_x, position_y, position_z, map FROM gameobject WHERE id = '%u' LIMIT %u",
2921 go_id
,uint32(count
));
2927 Field
*fields
= result
->Fetch();
2928 uint32 guid
= fields
[0].GetUInt32();
2929 float x
= fields
[1].GetFloat();
2930 float y
= fields
[2].GetFloat();
2931 float z
= fields
[3].GetFloat();
2932 int mapid
= fields
[4].GetUInt16();
2935 PSendSysMessage(LANG_GO_LIST_CHAT
, guid
, guid
, gInfo
->name
, x
, y
, z
, mapid
);
2937 PSendSysMessage(LANG_GO_LIST_CONSOLE
, guid
, gInfo
->name
, x
, y
, z
, mapid
);
2938 } while (result
->NextRow());
2943 PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE
,go_id
,obj_count
);
2947 bool ChatHandler::HandleListCreatureCommand(const char* args
)
2952 // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
2953 char* cId
= extractKeyFromLink((char*)args
,"Hcreature_entry");
2957 uint32 cr_id
= atol(cId
);
2960 PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID
, cr_id
);
2961 SetSentErrorMessage(true);
2965 CreatureInfo
const* cInfo
= objmgr
.GetCreatureTemplate(cr_id
);
2968 PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID
, cr_id
);
2969 SetSentErrorMessage(true);
2973 char* c_count
= strtok(NULL
, " ");
2974 int count
= c_count
? atol(c_count
) : 10;
2979 QueryResult
*result
;
2981 uint32 cr_count
= 0;
2982 result
=WorldDatabase
.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'",cr_id
);
2985 cr_count
= (*result
)[0].GetUInt32();
2991 Player
* pl
= m_session
->GetPlayer();
2992 result
= WorldDatabase
.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u",
2993 pl
->GetPositionX(), pl
->GetPositionY(), pl
->GetPositionZ(), cr_id
,uint32(count
));
2996 result
= WorldDatabase
.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u",
2997 cr_id
,uint32(count
));
3003 Field
*fields
= result
->Fetch();
3004 uint32 guid
= fields
[0].GetUInt32();
3005 float x
= fields
[1].GetFloat();
3006 float y
= fields
[2].GetFloat();
3007 float z
= fields
[3].GetFloat();
3008 int mapid
= fields
[4].GetUInt16();
3011 PSendSysMessage(LANG_CREATURE_LIST_CHAT
, guid
, guid
, cInfo
->Name
, x
, y
, z
, mapid
);
3013 PSendSysMessage(LANG_CREATURE_LIST_CONSOLE
, guid
, cInfo
->Name
, x
, y
, z
, mapid
);
3014 } while (result
->NextRow());
3019 PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE
,cr_id
,cr_count
);
3023 bool ChatHandler::HandleLookupItemCommand(const char* args
)
3028 std::string namepart
= args
;
3029 std::wstring wnamepart
;
3031 // converting string that we try to find to lower case
3032 if(!Utf8toWStr(namepart
,wnamepart
))
3035 wstrToLower(wnamepart
);
3039 // Search in `item_template`
3040 for (uint32 id
= 0; id
< sItemStorage
.MaxEntry
; id
++)
3042 ItemPrototype
const *pProto
= sItemStorage
.LookupEntry
<ItemPrototype
>(id
);
3046 int loc_idx
= m_session
? m_session
->GetSessionDbLocaleIndex() : objmgr
.GetDBCLocaleIndex();
3049 ItemLocale
const *il
= objmgr
.GetItemLocale(pProto
->ItemId
);
3052 if (il
->Name
.size() > loc_idx
&& !il
->Name
[loc_idx
].empty())
3054 std::string name
= il
->Name
[loc_idx
];
3056 if (Utf8FitTo(name
, wnamepart
))
3059 PSendSysMessage(LANG_ITEM_LIST_CHAT
, id
, id
, name
.c_str());
3061 PSendSysMessage(LANG_ITEM_LIST_CONSOLE
, id
, name
.c_str());
3069 std::string name
= pProto
->Name1
;
3073 if (Utf8FitTo(name
, wnamepart
))
3076 PSendSysMessage(LANG_ITEM_LIST_CHAT
, id
, id
, name
.c_str());
3078 PSendSysMessage(LANG_ITEM_LIST_CONSOLE
, id
, name
.c_str());
3084 SendSysMessage(LANG_COMMAND_NOITEMFOUND
);
3089 bool ChatHandler::HandleLookupItemSetCommand(const char* args
)
3094 std::string namepart
= args
;
3095 std::wstring wnamepart
;
3097 if(!Utf8toWStr(namepart
,wnamepart
))
3100 // converting string that we try to find to lower case
3101 wstrToLower( wnamepart
);
3103 uint32 counter
= 0; // Counter for figure out that we found smth.
3105 // Search in ItemSet.dbc
3106 for (uint32 id
= 0; id
< sItemSetStore
.GetNumRows(); id
++)
3108 ItemSetEntry
const *set
= sItemSetStore
.LookupEntry(id
);
3111 int loc
= m_session
? m_session
->GetSessionDbcLocale() : sWorld
.GetDefaultDbcLocale();
3112 std::string name
= set
->name
[loc
];
3116 if (!Utf8FitTo(name
, wnamepart
))
3119 for(; loc
< MAX_LOCALE
; ++loc
)
3121 if(m_session
&& loc
==m_session
->GetSessionDbcLocale())
3124 name
= set
->name
[loc
];
3128 if (Utf8FitTo(name
, wnamepart
))
3133 if(loc
< MAX_LOCALE
)
3135 // send item set in "id - [namedlink locale]" format
3137 PSendSysMessage(LANG_ITEMSET_LIST_CHAT
,id
,id
,name
.c_str(),localeNames
[loc
]);
3139 PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE
,id
,name
.c_str(),localeNames
[loc
]);
3144 if (counter
== 0) // if counter == 0 then we found nth
3145 SendSysMessage(LANG_COMMAND_NOITEMSETFOUND
);
3149 bool ChatHandler::HandleLookupSkillCommand(const char* args
)
3154 // can be NULL in console call
3155 Player
* target
= getSelectedPlayer();
3157 std::string namepart
= args
;
3158 std::wstring wnamepart
;
3160 if(!Utf8toWStr(namepart
,wnamepart
))
3163 // converting string that we try to find to lower case
3164 wstrToLower( wnamepart
);
3166 uint32 counter
= 0; // Counter for figure out that we found smth.
3168 // Search in SkillLine.dbc
3169 for (uint32 id
= 0; id
< sSkillLineStore
.GetNumRows(); id
++)
3171 SkillLineEntry
const *skillInfo
= sSkillLineStore
.LookupEntry(id
);
3174 int loc
= m_session
? m_session
->GetSessionDbcLocale() : sWorld
.GetDefaultDbcLocale();
3175 std::string name
= skillInfo
->name
[loc
];
3179 if (!Utf8FitTo(name
, wnamepart
))
3182 for(; loc
< MAX_LOCALE
; ++loc
)
3184 if(m_session
&& loc
==m_session
->GetSessionDbcLocale())
3187 name
= skillInfo
->name
[loc
];
3191 if (Utf8FitTo(name
, wnamepart
))
3196 if(loc
< MAX_LOCALE
)
3198 char valStr
[50] = "";
3199 char const* knownStr
= "";
3200 if(target
&& target
->HasSkill(id
))
3202 knownStr
= GetMangosString(LANG_KNOWN
);
3203 uint32 curValue
= target
->GetPureSkillValue(id
);
3204 uint32 maxValue
= target
->GetPureMaxSkillValue(id
);
3205 uint32 permValue
= target
->GetSkillPermBonusValue(id
);
3206 uint32 tempValue
= target
->GetSkillTempBonusValue(id
);
3208 char const* valFormat
= GetMangosString(LANG_SKILL_VALUES
);
3209 snprintf(valStr
,50,valFormat
,curValue
,maxValue
,permValue
,tempValue
);
3212 // send skill in "id - [namedlink locale]" format
3214 PSendSysMessage(LANG_SKILL_LIST_CHAT
,id
,id
,name
.c_str(),localeNames
[loc
],knownStr
,valStr
);
3216 PSendSysMessage(LANG_SKILL_LIST_CONSOLE
,id
,name
.c_str(),localeNames
[loc
],knownStr
,valStr
);
3222 if (counter
== 0) // if counter == 0 then we found nth
3223 SendSysMessage(LANG_COMMAND_NOSKILLFOUND
);
3227 bool ChatHandler::HandleLookupSpellCommand(const char* args
)
3232 // can be NULL at console call
3233 Player
* target
= getSelectedPlayer();
3235 std::string namepart
= args
;
3236 std::wstring wnamepart
;
3238 if(!Utf8toWStr(namepart
,wnamepart
))
3241 // converting string that we try to find to lower case
3242 wstrToLower( wnamepart
);
3244 uint32 counter
= 0; // Counter for figure out that we found smth.
3246 // Search in Spell.dbc
3247 for (uint32 id
= 0; id
< sSpellStore
.GetNumRows(); id
++)
3249 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(id
);
3252 int loc
= m_session
? m_session
->GetSessionDbcLocale() : sWorld
.GetDefaultDbcLocale();
3253 std::string name
= spellInfo
->SpellName
[loc
];
3257 if (!Utf8FitTo(name
, wnamepart
))
3260 for(; loc
< MAX_LOCALE
; ++loc
)
3262 if(m_session
&& loc
==m_session
->GetSessionDbcLocale())
3265 name
= spellInfo
->SpellName
[loc
];
3269 if (Utf8FitTo(name
, wnamepart
))
3274 if(loc
< MAX_LOCALE
)
3276 bool known
= target
&& target
->HasSpell(id
);
3277 bool learn
= (spellInfo
->Effect
[0] == SPELL_EFFECT_LEARN_SPELL
);
3279 uint32 talentCost
= GetTalentSpellCost(id
);
3281 bool talent
= (talentCost
> 0);
3282 bool passive
= IsPassiveSpell(id
);
3283 bool active
= target
&& target
->HasAura(id
);
3285 // unit32 used to prevent interpreting uint8 as char at output
3286 // find rank of learned spell for learning spell, or talent rank
3287 uint32 rank
= talentCost
? talentCost
: spellmgr
.GetSpellRank(learn
? spellInfo
->EffectTriggerSpell
[0] : id
);
3289 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
3290 std::ostringstream ss
;
3292 ss
<< id
<< " - |cffffffff|Hspell:" << id
<< "|h[" << name
;
3294 ss
<< id
<< " - " << name
;
3296 // include rank in link name
3298 ss
<< GetMangosString(LANG_SPELL_RANK
) << rank
;
3301 ss
<< " " << localeNames
[loc
] << "]|h|r";
3303 ss
<< " " << localeNames
[loc
];
3306 ss
<< GetMangosString(LANG_TALENT
);
3308 ss
<< GetMangosString(LANG_PASSIVE
);
3310 ss
<< GetMangosString(LANG_LEARN
);
3312 ss
<< GetMangosString(LANG_KNOWN
);
3314 ss
<< GetMangosString(LANG_ACTIVE
);
3316 SendSysMessage(ss
.str().c_str());
3322 if (counter
== 0) // if counter == 0 then we found nth
3323 SendSysMessage(LANG_COMMAND_NOSPELLFOUND
);
3327 bool ChatHandler::HandleLookupQuestCommand(const char* args
)
3332 // can be NULL at console call
3333 Player
* target
= getSelectedPlayer();
3335 std::string namepart
= args
;
3336 std::wstring wnamepart
;
3338 // converting string that we try to find to lower case
3339 if(!Utf8toWStr(namepart
,wnamepart
))
3342 wstrToLower(wnamepart
);
3344 uint32 counter
= 0 ;
3346 ObjectMgr::QuestMap
const& qTemplates
= objmgr
.GetQuestTemplates();
3347 for (ObjectMgr::QuestMap::const_iterator iter
= qTemplates
.begin(); iter
!= qTemplates
.end(); ++iter
)
3349 Quest
* qinfo
= iter
->second
;
3351 int loc_idx
= m_session
? m_session
->GetSessionDbLocaleIndex() : objmgr
.GetDBCLocaleIndex();
3354 QuestLocale
const *il
= objmgr
.GetQuestLocale(qinfo
->GetQuestId());
3357 if (il
->Title
.size() > loc_idx
&& !il
->Title
[loc_idx
].empty())
3359 std::string title
= il
->Title
[loc_idx
];
3361 if (Utf8FitTo(title
, wnamepart
))
3363 char const* statusStr
= "";
3367 QuestStatus status
= target
->GetQuestStatus(qinfo
->GetQuestId());
3369 if(status
== QUEST_STATUS_COMPLETE
)
3371 if(target
->GetQuestRewardStatus(qinfo
->GetQuestId()))
3372 statusStr
= GetMangosString(LANG_COMMAND_QUEST_REWARDED
);
3374 statusStr
= GetMangosString(LANG_COMMAND_QUEST_COMPLETE
);
3376 else if(status
== QUEST_STATUS_INCOMPLETE
)
3377 statusStr
= GetMangosString(LANG_COMMAND_QUEST_ACTIVE
);
3381 PSendSysMessage(LANG_QUEST_LIST_CHAT
,qinfo
->GetQuestId(),qinfo
->GetQuestId(),title
.c_str(),statusStr
);
3383 PSendSysMessage(LANG_QUEST_LIST_CONSOLE
,qinfo
->GetQuestId(),title
.c_str(),statusStr
);
3391 std::string title
= qinfo
->GetTitle();
3395 if (Utf8FitTo(title
, wnamepart
))
3397 char const* statusStr
= "";
3401 QuestStatus status
= target
->GetQuestStatus(qinfo
->GetQuestId());
3403 if(status
== QUEST_STATUS_COMPLETE
)
3405 if(target
->GetQuestRewardStatus(qinfo
->GetQuestId()))
3406 statusStr
= GetMangosString(LANG_COMMAND_QUEST_REWARDED
);
3408 statusStr
= GetMangosString(LANG_COMMAND_QUEST_COMPLETE
);
3410 else if(status
== QUEST_STATUS_INCOMPLETE
)
3411 statusStr
= GetMangosString(LANG_COMMAND_QUEST_ACTIVE
);
3415 PSendSysMessage(LANG_QUEST_LIST_CHAT
,qinfo
->GetQuestId(),qinfo
->GetQuestId(),title
.c_str(),statusStr
);
3417 PSendSysMessage(LANG_QUEST_LIST_CONSOLE
,qinfo
->GetQuestId(),title
.c_str(),statusStr
);
3424 SendSysMessage(LANG_COMMAND_NOQUESTFOUND
);
3429 bool ChatHandler::HandleLookupCreatureCommand(const char* args
)
3434 std::string namepart
= args
;
3435 std::wstring wnamepart
;
3437 // converting string that we try to find to lower case
3438 if (!Utf8toWStr (namepart
,wnamepart
))
3441 wstrToLower (wnamepart
);
3445 for (uint32 id
= 0; id
< sCreatureStorage
.MaxEntry
; ++id
)
3447 CreatureInfo
const* cInfo
= sCreatureStorage
.LookupEntry
<CreatureInfo
> (id
);
3451 int loc_idx
= m_session
? m_session
->GetSessionDbLocaleIndex() : objmgr
.GetDBCLocaleIndex();
3454 CreatureLocale
const *cl
= objmgr
.GetCreatureLocale (id
);
3457 if (cl
->Name
.size() > loc_idx
&& !cl
->Name
[loc_idx
].empty ())
3459 std::string name
= cl
->Name
[loc_idx
];
3461 if (Utf8FitTo (name
, wnamepart
))
3464 PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT
, id
, id
, name
.c_str ());
3466 PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE
, id
, name
.c_str ());
3474 std::string name
= cInfo
->Name
;
3478 if (Utf8FitTo(name
, wnamepart
))
3481 PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT
, id
, id
, name
.c_str ());
3483 PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE
, id
, name
.c_str ());
3489 SendSysMessage (LANG_COMMAND_NOCREATUREFOUND
);
3494 bool ChatHandler::HandleLookupObjectCommand(const char* args
)
3499 std::string namepart
= args
;
3500 std::wstring wnamepart
;
3502 // converting string that we try to find to lower case
3503 if(!Utf8toWStr(namepart
,wnamepart
))
3506 wstrToLower(wnamepart
);
3510 for (uint32 id
= 0; id
< sGOStorage
.MaxEntry
; id
++ )
3512 GameObjectInfo
const* gInfo
= sGOStorage
.LookupEntry
<GameObjectInfo
>(id
);
3516 int loc_idx
= m_session
? m_session
->GetSessionDbLocaleIndex() : objmgr
.GetDBCLocaleIndex();
3519 GameObjectLocale
const *gl
= objmgr
.GetGameObjectLocale(id
);
3522 if (gl
->Name
.size() > loc_idx
&& !gl
->Name
[loc_idx
].empty())
3524 std::string name
= gl
->Name
[loc_idx
];
3526 if (Utf8FitTo(name
, wnamepart
))
3529 PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT
, id
, id
, name
.c_str());
3531 PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE
, id
, name
.c_str());
3539 std::string name
= gInfo
->name
;
3543 if(Utf8FitTo(name
, wnamepart
))
3546 PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT
, id
, id
, name
.c_str());
3548 PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE
, id
, name
.c_str());
3554 SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND
);
3559 bool ChatHandler::HandleLookupTaxiNodeCommand(const char * args
)
3564 std::string namepart
= args
;
3565 std::wstring wnamepart
;
3567 if(!Utf8toWStr(namepart
,wnamepart
))
3570 // converting string that we try to find to lower case
3571 wstrToLower( wnamepart
);
3573 uint32 counter
= 0; // Counter for figure out that we found smth.
3575 // Search in TaxiNodes.dbc
3576 for (uint32 id
= 0; id
< sTaxiNodesStore
.GetNumRows(); id
++)
3578 TaxiNodesEntry
const *nodeEntry
= sTaxiNodesStore
.LookupEntry(id
);
3581 int loc
= m_session
? m_session
->GetSessionDbcLocale() : sWorld
.GetDefaultDbcLocale();
3582 std::string name
= nodeEntry
->name
[loc
];
3586 if (!Utf8FitTo(name
, wnamepart
))
3589 for(; loc
< MAX_LOCALE
; ++loc
)
3591 if(m_session
&& loc
==m_session
->GetSessionDbcLocale())
3594 name
= nodeEntry
->name
[loc
];
3598 if (Utf8FitTo(name
, wnamepart
))
3603 if(loc
< MAX_LOCALE
)
3605 // send taxinode in "id - [name] (Map:m X:x Y:y Z:z)" format
3607 PSendSysMessage (LANG_TAXINODE_ENTRY_LIST_CHAT
, id
, id
, name
.c_str(),localeNames
[loc
],
3608 nodeEntry
->map_id
,nodeEntry
->x
,nodeEntry
->y
,nodeEntry
->z
);
3610 PSendSysMessage (LANG_TAXINODE_ENTRY_LIST_CONSOLE
, id
, name
.c_str(), localeNames
[loc
],
3611 nodeEntry
->map_id
,nodeEntry
->x
,nodeEntry
->y
,nodeEntry
->z
);
3616 if (counter
== 0) // if counter == 0 then we found nth
3617 SendSysMessage(LANG_COMMAND_NOSPELLFOUND
);
3621 /** \brief GM command level 3 - Create a guild.
3623 * This command allows a GM (level 3) to create a guild.
3625 * The "args" parameter contains the name of the guild leader
3626 * and then the name of the guild.
3629 bool ChatHandler::HandleGuildCreateCommand(const char* args
)
3635 char *lname
= strtok ((char*)args
, " ");
3636 char *gname
= strtok (NULL
, "");
3643 SendSysMessage (LANG_INSERT_GUILD_NAME
);
3644 SetSentErrorMessage (true);
3648 std::string guildname
= gname
;
3650 Player
* player
= ObjectAccessor::Instance ().FindPlayerByName (lname
);
3653 SendSysMessage (LANG_PLAYER_NOT_FOUND
);
3654 SetSentErrorMessage (true);
3658 if (player
->GetGuildId())
3660 SendSysMessage (LANG_PLAYER_IN_GUILD
);
3664 Guild
*guild
= new Guild
;
3665 if (!guild
->create (player
,guildname
))
3668 SendSysMessage (LANG_GUILD_NOT_CREATED
);
3669 SetSentErrorMessage (true);
3673 objmgr
.AddGuild (guild
);
3677 bool ChatHandler::HandleGuildInviteCommand(const char *args
)
3682 char* par1
= strtok ((char*)args
, " ");
3683 char* par2
= strtok (NULL
, "");
3687 std::string glName
= par2
;
3688 Guild
* targetGuild
= objmgr
.GetGuildByName (glName
);
3692 std::string plName
= extractPlayerNameFromLink(par1
);
3695 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3696 SetSentErrorMessage(true);
3701 if (Player
* targetPlayer
= ObjectAccessor::Instance ().FindPlayerByName (plName
.c_str ()))
3702 plGuid
= targetPlayer
->GetGUID ();
3704 plGuid
= objmgr
.GetPlayerGUIDByName (plName
);
3709 // player's guild membership checked in AddMember before add
3710 if (!targetGuild
->AddMember (plGuid
,targetGuild
->GetLowestRank ()))
3716 bool ChatHandler::HandleGuildUninviteCommand(const char *args
)
3721 char* par1
= strtok ((char*)args
, " ");
3725 std::string plName
= extractPlayerNameFromLink(par1
);
3728 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3729 SetSentErrorMessage(true);
3735 if (Player
* targetPlayer
= ObjectAccessor::Instance ().FindPlayerByName (plName
.c_str ()))
3737 plGuid
= targetPlayer
->GetGUID ();
3738 glId
= targetPlayer
->GetGuildId ();
3742 plGuid
= objmgr
.GetPlayerGUIDByName (plName
);
3743 glId
= Player::GetGuildIdFromDB (plGuid
);
3746 if (!plGuid
|| !glId
)
3749 Guild
* targetGuild
= objmgr
.GetGuildById (glId
);
3753 targetGuild
->DelMember (plGuid
);
3758 bool ChatHandler::HandleGuildRankCommand(const char *args
)
3763 char* par1
= strtok ((char*)args
, " ");
3764 char* par2
= strtok (NULL
, " ");
3768 std::string plName
= extractPlayerNameFromLink(par1
);
3771 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3772 SetSentErrorMessage(true);
3779 if (Player
* targetPlayer
= ObjectAccessor::Instance ().FindPlayerByName (plName
.c_str ()))
3781 plGuid
= targetPlayer
->GetGUID ();
3782 glId
= targetPlayer
->GetGuildId ();
3786 plGuid
= objmgr
.GetPlayerGUIDByName (plName
);
3787 glId
= Player::GetGuildIdFromDB (plGuid
);
3790 if (!plGuid
|| !glId
)
3793 Guild
* targetGuild
= objmgr
.GetGuildById (glId
);
3797 uint32 newrank
= uint32 (atoi (par2
));
3798 if (newrank
> targetGuild
->GetLowestRank ())
3801 targetGuild
->ChangeRank (plGuid
,newrank
);
3806 bool ChatHandler::HandleGuildDeleteCommand(const char* args
)
3811 char* par1
= strtok ((char*)args
, " ");
3815 std::string gld
= par1
;
3817 Guild
* targetGuild
= objmgr
.GetGuildByName (gld
);
3821 targetGuild
->Disband ();
3826 bool ChatHandler::HandleGetDistanceCommand(const char* args
)
3828 WorldObject
* obj
= NULL
;
3832 uint64 guid
= extractGuidFromLink((char*)args
);
3834 obj
= (WorldObject
*)ObjectAccessor::GetObjectByTypeMask(*m_session
->GetPlayer(),guid
,TYPEMASK_UNIT
|TYPEMASK_GAMEOBJECT
);
3838 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3839 SetSentErrorMessage(true);
3845 obj
= getSelectedUnit();
3849 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3850 SetSentErrorMessage(true);
3855 PSendSysMessage(LANG_DISTANCE
, m_session
->GetPlayer()->GetDistance(obj
),m_session
->GetPlayer()->GetDistance2d(obj
));
3860 bool ChatHandler::HandleDieCommand(const char* /*args*/)
3862 Unit
* target
= getSelectedUnit();
3864 if(!target
|| !m_session
->GetPlayer()->GetSelection())
3866 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3867 SetSentErrorMessage(true);
3871 if(target
->GetTypeId()==TYPEID_PLAYER
)
3873 if(HasLowerSecurity((Player
*)target
,0,false))
3877 if( target
->isAlive() )
3879 m_session
->GetPlayer()->DealDamage(target
, target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
3885 bool ChatHandler::HandleDamageCommand(const char * args
)
3890 Unit
* target
= getSelectedUnit();
3892 if (!target
|| !m_session
->GetPlayer()->GetSelection())
3894 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3895 SetSentErrorMessage(true);
3899 if (!target
->isAlive())
3902 char* damageStr
= strtok((char*)args
, " ");
3906 int32 damage_int
= atoi((char*)damageStr
);
3910 uint32 damage
= damage_int
;
3912 char* schoolStr
= strtok((char*)NULL
, " ");
3914 // flat melee damage without resistence/etc reduction
3917 m_session
->GetPlayer()->DealDamage(target
, damage
, NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
3918 if (target
!= m_session
->GetPlayer())
3919 m_session
->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2
, target
, 1, SPELL_SCHOOL_MASK_NORMAL
, damage
, 0, 0, VICTIMSTATE_NORMAL
, 0);
3923 uint32 school
= schoolStr
? atoi((char*)schoolStr
) : SPELL_SCHOOL_NORMAL
;
3924 if(school
>= MAX_SPELL_SCHOOL
)
3927 SpellSchoolMask schoolmask
= SpellSchoolMask(1 << school
);
3929 if ( schoolmask
& SPELL_SCHOOL_MASK_NORMAL
)
3930 damage
= m_session
->GetPlayer()->CalcArmorReducedDamage(target
, damage
);
3932 char* spellStr
= strtok((char*)NULL
, " ");
3934 // melee damage by specific school
3940 m_session
->GetPlayer()->CalcAbsorbResist(target
,schoolmask
, SPELL_DIRECT_DAMAGE
, damage
, &absorb
, &resist
);
3942 if (damage
<= absorb
+ resist
)
3945 damage
-= absorb
+ resist
;
3947 m_session
->GetPlayer()->DealDamageMods(target
,damage
,&absorb
);
3948 m_session
->GetPlayer()->DealDamage(target
, damage
, NULL
, DIRECT_DAMAGE
, schoolmask
, NULL
, false);
3949 m_session
->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2
, target
, 1, schoolmask
, damage
, absorb
, resist
, VICTIMSTATE_NORMAL
, 0);
3955 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
3956 uint32 spellid
= extractSpellIdFromLink((char*)args
);
3957 if (!spellid
|| !sSpellStore
.LookupEntry(spellid
))
3960 m_session
->GetPlayer()->SpellNonMeleeDamageLog(target
, spellid
, damage
);
3964 bool ChatHandler::HandleModifyArenaCommand(const char * args
)
3969 Player
*target
= getSelectedPlayer();
3972 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3973 SetSentErrorMessage(true);
3977 int32 amount
= (uint32
)atoi(args
);
3979 target
->ModifyArenaPoints(amount
);
3981 PSendSysMessage(LANG_COMMAND_MODIFY_ARENA
, GetNameLink(target
).c_str(), target
->GetArenaPoints());
3986 bool ChatHandler::HandleReviveCommand(const char* args
)
3988 Player
* player
= NULL
;
3989 uint64 player_guid
= 0;
3993 std::string name
= extractPlayerNameFromLink((char*)args
);
3996 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3997 SetSentErrorMessage(true);
4001 player
= objmgr
.GetPlayer(name
.c_str());
4003 player_guid
= objmgr
.GetPlayerGUIDByName(name
);
4006 player
= getSelectedPlayer();
4010 player
->ResurrectPlayer(0.5f
);
4011 player
->SpawnCorpseBones();
4014 else if (player_guid
)
4016 // will resurrected at login without corpse
4017 ObjectAccessor::Instance().ConvertCorpseForPlayer(player_guid
);
4021 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4022 SetSentErrorMessage(true);
4029 bool ChatHandler::HandleAuraCommand(const char* args
)
4031 Unit
*target
= getSelectedUnit();
4034 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
4035 SetSentErrorMessage(true);
4039 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
4040 uint32 spellID
= extractSpellIdFromLink((char*)args
);
4042 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( spellID
);
4045 for(uint32 i
= 0;i
<3;++i
)
4047 uint8 eff
= spellInfo
->Effect
[i
];
4048 if (eff
>=TOTAL_SPELL_EFFECTS
)
4050 if( IsAreaAuraEffect(eff
) ||
4051 eff
== SPELL_EFFECT_APPLY_AURA
||
4052 eff
== SPELL_EFFECT_PERSISTENT_AREA_AURA
)
4054 Aura
*Aur
= CreateAura(spellInfo
, i
, NULL
, target
);
4055 target
->AddAura(Aur
);
4063 bool ChatHandler::HandleUnAuraCommand(const char* args
)
4065 Unit
*target
= getSelectedUnit();
4068 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
4069 SetSentErrorMessage(true);
4073 std::string argstr
= args
;
4074 if (argstr
== "all")
4076 target
->RemoveAllAuras();
4080 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
4081 uint32 spellID
= extractSpellIdFromLink((char*)args
);
4085 target
->RemoveAurasDueToSpell(spellID
);
4090 bool ChatHandler::HandleLinkGraveCommand(const char* args
)
4095 char* px
= strtok((char*)args
, " ");
4099 uint32 g_id
= (uint32
)atoi(px
);
4103 char* px2
= strtok(NULL
, " ");
4107 else if (strncmp(px2
,"horde",6)==0)
4109 else if (strncmp(px2
,"alliance",9)==0)
4114 WorldSafeLocsEntry
const* graveyard
= sWorldSafeLocsStore
.LookupEntry(g_id
);
4118 PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST
, g_id
);
4119 SetSentErrorMessage(true);
4123 Player
* player
= m_session
->GetPlayer();
4125 uint32 zoneId
= player
->GetZoneId();
4127 AreaTableEntry
const *areaEntry
= GetAreaEntryByAreaID(zoneId
);
4128 if(!areaEntry
|| areaEntry
->zone
!=0 )
4130 PSendSysMessage(LANG_COMMAND_GRAVEYARDWRONGZONE
, g_id
,zoneId
);
4131 SetSentErrorMessage(true);
4135 if(objmgr
.AddGraveYardLink(g_id
,zoneId
,g_team
))
4136 PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED
, g_id
,zoneId
);
4138 PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED
, g_id
,zoneId
);
4143 bool ChatHandler::HandleNearGraveCommand(const char* args
)
4147 size_t argslen
= strlen(args
);
4151 else if (strncmp((char*)args
,"horde",argslen
)==0)
4153 else if (strncmp((char*)args
,"alliance",argslen
)==0)
4158 Player
* player
= m_session
->GetPlayer();
4159 uint32 zone_id
= player
->GetZoneId();
4161 WorldSafeLocsEntry
const* graveyard
= objmgr
.GetClosestGraveYard(
4162 player
->GetPositionX(), player
->GetPositionY(), player
->GetPositionZ(),player
->GetMapId(),g_team
);
4166 uint32 g_id
= graveyard
->ID
;
4168 GraveYardData
const* data
= objmgr
.FindGraveYardData(g_id
,zone_id
);
4171 PSendSysMessage(LANG_COMMAND_GRAVEYARDERROR
,g_id
);
4172 SetSentErrorMessage(true);
4176 g_team
= data
->team
;
4178 std::string team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_NOTEAM
);
4181 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ANY
);
4182 else if(g_team
== HORDE
)
4183 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE
);
4184 else if(g_team
== ALLIANCE
)
4185 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE
);
4187 PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST
, g_id
,team_name
.c_str(),zone_id
);
4191 std::string team_name
;
4194 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ANY
);
4195 else if(g_team
== HORDE
)
4196 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE
);
4197 else if(g_team
== ALLIANCE
)
4198 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE
);
4200 if(g_team
== ~uint32(0))
4201 PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS
, zone_id
);
4203 PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION
, zone_id
,team_name
.c_str());
4209 //-----------------------Npc Commands-----------------------
4210 bool ChatHandler::HandleNpcAllowMovementCommand(const char* /*args*/)
4212 if(sWorld
.getAllowMovement())
4214 sWorld
.SetAllowMovement(false);
4215 SendSysMessage(LANG_CREATURE_MOVE_DISABLED
);
4219 sWorld
.SetAllowMovement(true);
4220 SendSysMessage(LANG_CREATURE_MOVE_ENABLED
);
4225 bool ChatHandler::HandleNpcChangeEntryCommand(const char *args
)
4230 uint32 newEntryNum
= atoi(args
);
4234 Unit
* unit
= getSelectedUnit();
4235 if(!unit
|| unit
->GetTypeId() != TYPEID_UNIT
)
4237 SendSysMessage(LANG_SELECT_CREATURE
);
4238 SetSentErrorMessage(true);
4241 Creature
* creature
= (Creature
*)unit
;
4242 if(creature
->UpdateEntry(newEntryNum
))
4243 SendSysMessage(LANG_DONE
);
4245 SendSysMessage(LANG_ERROR
);
4249 bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/)
4251 Creature
* target
= getSelectedCreature();
4255 SendSysMessage(LANG_SELECT_CREATURE
);
4256 SetSentErrorMessage(true);
4260 uint32 faction
= target
->getFaction();
4261 uint32 npcflags
= target
->GetUInt32Value(UNIT_NPC_FLAGS
);
4262 uint32 displayid
= target
->GetDisplayId();
4263 uint32 nativeid
= target
->GetNativeDisplayId();
4264 uint32 Entry
= target
->GetEntry();
4265 CreatureInfo
const* cInfo
= target
->GetCreatureInfo();
4267 int32 curRespawnDelay
= target
->GetRespawnTimeEx()-time(NULL
);
4268 if(curRespawnDelay
< 0)
4269 curRespawnDelay
= 0;
4270 std::string curRespawnDelayStr
= secsToTimeString(curRespawnDelay
,true);
4271 std::string defRespawnDelayStr
= secsToTimeString(target
->GetRespawnDelay(),true);
4273 PSendSysMessage(LANG_NPCINFO_CHAR
, target
->GetDBTableGUIDLow(), faction
, npcflags
, Entry
, displayid
, nativeid
);
4274 PSendSysMessage(LANG_NPCINFO_LEVEL
, target
->getLevel());
4275 PSendSysMessage(LANG_NPCINFO_HEALTH
,target
->GetCreateHealth(), target
->GetMaxHealth(), target
->GetHealth());
4276 PSendSysMessage(LANG_NPCINFO_FLAGS
, target
->GetUInt32Value(UNIT_FIELD_FLAGS
), target
->GetUInt32Value(UNIT_DYNAMIC_FLAGS
), target
->getFaction());
4277 PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES
, defRespawnDelayStr
.c_str(),curRespawnDelayStr
.c_str());
4278 PSendSysMessage(LANG_NPCINFO_LOOT
, cInfo
->lootid
,cInfo
->pickpocketLootId
,cInfo
->SkinLootId
);
4279 PSendSysMessage(LANG_NPCINFO_DUNGEON_ID
, target
->GetInstanceId());
4280 PSendSysMessage(LANG_NPCINFO_POSITION
,float(target
->GetPositionX()), float(target
->GetPositionY()), float(target
->GetPositionZ()));
4282 if ((npcflags
& UNIT_NPC_FLAG_VENDOR
) )
4284 SendSysMessage(LANG_NPCINFO_VENDOR
);
4286 if ((npcflags
& UNIT_NPC_FLAG_TRAINER
) )
4288 SendSysMessage(LANG_NPCINFO_TRAINER
);
4295 bool ChatHandler::HandleNpcPlayEmoteCommand(const char* args
)
4297 uint32 emote
= atoi((char*)args
);
4299 Creature
* target
= getSelectedCreature();
4302 SendSysMessage(LANG_SELECT_CREATURE
);
4303 SetSentErrorMessage(true);
4307 target
->SetUInt32Value(UNIT_NPC_EMOTESTATE
,emote
);
4312 //TODO: NpcCommands that needs to be fixed :
4314 bool ChatHandler::HandleNpcAddWeaponCommand(const char* /*args*/)
4319 uint64 guid = m_session->GetPlayer()->GetSelection();
4322 SendSysMessage(LANG_NO_SELECTION);
4326 Creature *pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid);
4330 SendSysMessage(LANG_SELECT_CREATURE);
4334 char* pSlotID = strtok((char*)args, " ");
4338 char* pItemID = strtok(NULL, " ");
4342 uint32 ItemID = atoi(pItemID);
4343 uint32 SlotID = atoi(pSlotID);
4345 ItemPrototype* tmpItem = objmgr.GetItemPrototype(ItemID);
4353 pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID);
4357 pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID);
4361 pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID);
4365 PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST,SlotID);
4371 PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT,ItemID,tmpItem->Name1,SlotID);
4375 PSendSysMessage(LANG_ITEM_NOT_FOUND,ItemID);
4381 //----------------------------------------------------------
4383 bool ChatHandler::HandleExploreCheatCommand(const char* args
)
4388 int flag
= atoi((char*)args
);
4390 Player
*chr
= getSelectedPlayer();
4393 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4394 SetSentErrorMessage(true);
4400 PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL
, GetNameLink(chr
).c_str());
4401 if (needReportToTarget(chr
))
4402 ChatHandler(chr
).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL
,GetNameLink().c_str());
4406 PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING
, GetNameLink(chr
).c_str());
4407 if (needReportToTarget(chr
))
4408 ChatHandler(chr
).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING
,GetNameLink().c_str());
4411 for (uint8 i
=0; i
<128; ++i
)
4415 m_session
->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1
+i
,0xFFFFFFFF);
4419 m_session
->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1
+i
,0);
4426 bool ChatHandler::HandleHoverCommand(const char* args
)
4428 char* px
= strtok((char*)args
, " ");
4435 m_session
->GetPlayer()->SetHover(flag
);
4438 SendSysMessage(LANG_HOVER_ENABLED
);
4440 SendSysMessage(LANG_HOVER_DISABLED
);
4445 void ChatHandler::HandleCharacterLevel(Player
* player
, uint64 player_guid
, uint32 oldlevel
, uint32 newlevel
)
4449 player
->GiveLevel(newlevel
);
4450 player
->InitTalentForLevel();
4451 player
->SetUInt32Value(PLAYER_XP
,0);
4453 if(needReportToTarget(player
))
4455 if(oldlevel
== newlevel
)
4456 ChatHandler(player
).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET
,GetNameLink().c_str());
4457 else if(oldlevel
< newlevel
)
4458 ChatHandler(player
).PSendSysMessage(LANG_YOURS_LEVEL_UP
,GetNameLink().c_str(),newlevel
);
4459 else // if(oldlevel > newlevel)
4460 ChatHandler(player
).PSendSysMessage(LANG_YOURS_LEVEL_DOWN
,GetNameLink().c_str(),newlevel
);
4465 // update level and XP at level, all other will be updated at loading
4467 Player::LoadValuesArrayFromDB(values
,player_guid
);
4468 Player::SetUInt32ValueInArray(values
,UNIT_FIELD_LEVEL
,newlevel
);
4469 Player::SetUInt32ValueInArray(values
,PLAYER_XP
,0);
4470 Player::SaveValuesArrayInDB(values
,player_guid
);
4474 bool ChatHandler::HandleCharacterLevelCommand(const char* args
)
4476 char* px
= strtok((char*)args
, " ");
4477 char* py
= strtok((char*)NULL
, " ");
4479 // command format parsing
4480 char* pname
= (char*)NULL
;
4483 if(px
&& py
) // .character level $name #level
4485 newlevel
= atoi(py
);
4488 else if(px
&& !py
) // .character level $name OR .character level #level
4490 if(isalpha(px
[0])) // .character level $name
4492 else // .character level #level
4493 newlevel
= atoi(px
);
4495 // // .character level - progress reset
4498 return false; // invalid level
4500 if(newlevel
> STRONG_MAX_LEVEL
) // hardcoded maximum level
4501 newlevel
= STRONG_MAX_LEVEL
;
4505 uint64 chr_guid
= 0;
4509 if(pname
) // player by name
4511 name
= extractPlayerNameFromLink(pname
);
4514 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4515 SetSentErrorMessage(true);
4519 chr
= objmgr
.GetPlayer(name
.c_str());
4520 if(!chr
) // not in game
4522 chr_guid
= objmgr
.GetPlayerGUIDByName(name
);
4525 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4526 SetSentErrorMessage(true);
4531 else // player by selection
4533 chr
= getSelectedPlayer();
4537 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4538 SetSentErrorMessage(true);
4542 name
= chr
->GetName();
4545 assert(chr
|| chr_guid
);
4547 int32 oldlevel
= chr
? chr
->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL
,chr_guid
);
4549 if(!px
&& !py
) // .character level - progress reset
4550 newlevel
= oldlevel
;
4552 HandleCharacterLevel(chr
,chr_guid
,oldlevel
,newlevel
);
4554 if(m_session
&& m_session
->GetPlayer() != chr
) // including player==NULL
4556 std::string nameLink
= playerLink(name
);
4557 PSendSysMessage(LANG_YOU_CHANGE_LVL
,nameLink
.c_str(),newlevel
);
4563 bool ChatHandler::HandleLevelUpCommand(const char* args
)
4565 char* px
= strtok((char*)args
, " ");
4566 char* py
= strtok((char*)NULL
, " ");
4568 // command format parsing
4569 char* pname
= (char*)NULL
;
4572 if(px
&& py
) // .levelup name level
4574 addlevel
= atoi(py
);
4577 else if(px
&& !py
) // .levelup name OR .levelup level
4579 if(isalpha(px
[0])) // .levelup name
4581 else // .levelup level
4582 addlevel
= atoi(px
);
4584 // else .levelup - nothing do for preparing
4588 uint64 chr_guid
= 0;
4592 if(pname
) // player by name
4594 name
= extractPlayerNameFromLink(pname
);
4597 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4598 SetSentErrorMessage(true);
4602 chr
= objmgr
.GetPlayer(name
.c_str());
4603 if(!chr
) // not in game
4605 chr_guid
= objmgr
.GetPlayerGUIDByName(name
);
4608 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4609 SetSentErrorMessage(true);
4614 else // player by selection
4616 chr
= getSelectedPlayer();
4620 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4621 SetSentErrorMessage(true);
4625 name
= chr
->GetName();
4628 assert(chr
|| chr_guid
);
4630 int32 oldlevel
= chr
? chr
->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL
,chr_guid
);
4631 int32 newlevel
= oldlevel
+ addlevel
;
4634 if(newlevel
> STRONG_MAX_LEVEL
) // hardcoded maximum level
4635 newlevel
= STRONG_MAX_LEVEL
;
4637 HandleCharacterLevel(chr
,chr_guid
,oldlevel
,newlevel
);
4639 if(m_session
&& m_session
->GetPlayer() != chr
) // including chr==NULL
4641 std::string nameLink
= playerLink(name
);
4642 PSendSysMessage(LANG_YOU_CHANGE_LVL
,nameLink
.c_str(),newlevel
);
4648 bool ChatHandler::HandleShowAreaCommand(const char* args
)
4653 Player
*chr
= getSelectedPlayer();
4656 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4657 SetSentErrorMessage(true);
4661 int area
= GetAreaFlagByAreaID(atoi((char*)args
));
4662 int offset
= area
/ 32;
4663 uint32 val
= (uint32
)(1 << (area
% 32));
4665 if(area
<0 || offset
>= 128)
4667 SendSysMessage(LANG_BAD_VALUE
);
4668 SetSentErrorMessage(true);
4672 uint32 currFields
= chr
->GetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
);
4673 chr
->SetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
, (uint32
)(currFields
| val
));
4675 SendSysMessage(LANG_EXPLORE_AREA
);
4679 bool ChatHandler::HandleHideAreaCommand(const char* args
)
4684 Player
*chr
= getSelectedPlayer();
4687 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4688 SetSentErrorMessage(true);
4692 int area
= GetAreaFlagByAreaID(atoi((char*)args
));
4693 int offset
= area
/ 32;
4694 uint32 val
= (uint32
)(1 << (area
% 32));
4696 if(area
<0 || offset
>= 128)
4698 SendSysMessage(LANG_BAD_VALUE
);
4699 SetSentErrorMessage(true);
4703 uint32 currFields
= chr
->GetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
);
4704 chr
->SetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
, (uint32
)(currFields
^ val
));
4706 SendSysMessage(LANG_UNEXPLORE_AREA
);
4710 bool ChatHandler::HandleDebugUpdate(const char* args
)
4718 char* pUpdateIndex
= strtok((char*)args
, " ");
4720 Unit
* chr
= getSelectedUnit();
4723 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
4724 SetSentErrorMessage(true);
4732 updateIndex
= atoi(pUpdateIndex
);
4734 if(chr
->GetTypeId() == TYPEID_PLAYER
)
4736 if (updateIndex
>=PLAYER_END
) return true;
4740 if (updateIndex
>=UNIT_END
) return true;
4743 char* pvalue
= strtok(NULL
, " ");
4746 value
=chr
->GetUInt32Value(updateIndex
);
4748 PSendSysMessage(LANG_UPDATE
, chr
->GetGUIDLow(),updateIndex
,value
);
4754 PSendSysMessage(LANG_UPDATE_CHANGE
, chr
->GetGUIDLow(),updateIndex
,value
);
4756 chr
->SetUInt32Value(updateIndex
,value
);
4761 bool ChatHandler::HandleBankCommand(const char* /*args*/)
4763 m_session
->SendShowBank( m_session
->GetPlayer()->GetGUID() );
4768 bool ChatHandler::HandleChangeWeather(const char* args
)
4774 if (!sWorld
.getConfig(CONFIG_WEATHER
))
4776 SendSysMessage(LANG_WEATHER_DISABLED
);
4777 SetSentErrorMessage(true);
4781 //*Change the weather of a cell
4782 char* px
= strtok((char*)args
, " ");
4783 char* py
= strtok(NULL
, " ");
4788 uint32 type
= (uint32
)atoi(px
); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand
4789 float grade
= (float)atof(py
); //0 to 1, sending -1 is instand good weather
4791 Player
*player
= m_session
->GetPlayer();
4792 uint32 zoneid
= player
->GetZoneId();
4794 Weather
* wth
= sWorld
.FindWeather(zoneid
);
4797 wth
= sWorld
.AddWeather(zoneid
);
4800 SendSysMessage(LANG_NO_WEATHER
);
4801 SetSentErrorMessage(true);
4805 wth
->SetWeather(WeatherType(type
), grade
);
4810 bool ChatHandler::HandleDebugSetValue(const char* args
)
4815 char* px
= strtok((char*)args
, " ");
4816 char* py
= strtok(NULL
, " ");
4817 char* pz
= strtok(NULL
, " ");
4822 Unit
* target
= getSelectedUnit();
4825 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
4826 SetSentErrorMessage(true);
4830 uint64 guid
= target
->GetGUID();
4832 uint32 Opcode
= (uint32
)atoi(px
);
4833 if(Opcode
>= target
->GetValuesCount())
4835 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, GUID_LOPART(guid
), target
->GetValuesCount());
4840 bool isint32
= true;
4842 isint32
= (bool)atoi(pz
);
4845 iValue
= (uint32
)atoi(py
);
4846 sLog
.outDebug(GetMangosString(LANG_SET_UINT
), GUID_LOPART(guid
), Opcode
, iValue
);
4847 target
->SetUInt32Value( Opcode
, iValue
);
4848 PSendSysMessage(LANG_SET_UINT_FIELD
, GUID_LOPART(guid
), Opcode
,iValue
);
4852 fValue
= (float)atof(py
);
4853 sLog
.outDebug(GetMangosString(LANG_SET_FLOAT
), GUID_LOPART(guid
), Opcode
, fValue
);
4854 target
->SetFloatValue( Opcode
, fValue
);
4855 PSendSysMessage(LANG_SET_FLOAT_FIELD
, GUID_LOPART(guid
), Opcode
,fValue
);
4861 bool ChatHandler::HandleDebugGetValue(const char* args
)
4866 char* px
= strtok((char*)args
, " ");
4867 char* pz
= strtok(NULL
, " ");
4872 Unit
* target
= getSelectedUnit();
4875 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
4876 SetSentErrorMessage(true);
4880 uint64 guid
= target
->GetGUID();
4882 uint32 Opcode
= (uint32
)atoi(px
);
4883 if(Opcode
>= target
->GetValuesCount())
4885 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, GUID_LOPART(guid
), target
->GetValuesCount());
4890 bool isint32
= true;
4892 isint32
= (bool)atoi(pz
);
4896 iValue
= target
->GetUInt32Value( Opcode
);
4897 sLog
.outDebug(GetMangosString(LANG_GET_UINT
), GUID_LOPART(guid
), Opcode
, iValue
);
4898 PSendSysMessage(LANG_GET_UINT_FIELD
, GUID_LOPART(guid
), Opcode
, iValue
);
4902 fValue
= target
->GetFloatValue( Opcode
);
4903 sLog
.outDebug(GetMangosString(LANG_GET_FLOAT
), GUID_LOPART(guid
), Opcode
, fValue
);
4904 PSendSysMessage(LANG_GET_FLOAT_FIELD
, GUID_LOPART(guid
), Opcode
, fValue
);
4910 bool ChatHandler::HandleSet32Bit(const char* args
)
4915 char* px
= strtok((char*)args
, " ");
4916 char* py
= strtok(NULL
, " ");
4921 uint32 Opcode
= (uint32
)atoi(px
);
4922 uint32 Value
= (uint32
)atoi(py
);
4923 if (Value
> 32) //uint32 = 32 bits
4926 sLog
.outDebug(GetMangosString(LANG_SET_32BIT
), Opcode
, Value
);
4928 m_session
->GetPlayer( )->SetUInt32Value( Opcode
, 2^Value
);
4930 PSendSysMessage(LANG_SET_32BIT_FIELD
, Opcode
,1);
4934 bool ChatHandler::HandleDebugMod32Value(const char* args
)
4939 char* px
= strtok((char*)args
, " ");
4940 char* py
= strtok(NULL
, " ");
4945 uint32 Opcode
= (uint32
)atoi(px
);
4946 int Value
= atoi(py
);
4948 if(Opcode
>= m_session
->GetPlayer()->GetValuesCount())
4950 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, m_session
->GetPlayer()->GetGUIDLow(), m_session
->GetPlayer( )->GetValuesCount());
4954 sLog
.outDebug(GetMangosString(LANG_CHANGE_32BIT
), Opcode
, Value
);
4956 int CurrentValue
= (int)m_session
->GetPlayer( )->GetUInt32Value( Opcode
);
4958 CurrentValue
+= Value
;
4959 m_session
->GetPlayer( )->SetUInt32Value( Opcode
, (uint32
)CurrentValue
);
4961 PSendSysMessage(LANG_CHANGE_32BIT_FIELD
, Opcode
,CurrentValue
);
4966 bool ChatHandler::HandleTeleAddCommand(const char * args
)
4971 Player
*player
=m_session
->GetPlayer();
4975 std::string name
= args
;
4977 if(objmgr
.GetGameTele(name
))
4979 SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST
);
4980 SetSentErrorMessage(true);
4985 tele
.position_x
= player
->GetPositionX();
4986 tele
.position_y
= player
->GetPositionY();
4987 tele
.position_z
= player
->GetPositionZ();
4988 tele
.orientation
= player
->GetOrientation();
4989 tele
.mapId
= player
->GetMapId();
4992 if(objmgr
.AddGameTele(tele
))
4994 SendSysMessage(LANG_COMMAND_TP_ADDED
);
4998 SendSysMessage(LANG_COMMAND_TP_ADDEDERR
);
4999 SetSentErrorMessage(true);
5006 bool ChatHandler::HandleTeleDelCommand(const char * args
)
5011 std::string name
= args
;
5013 if(!objmgr
.DeleteGameTele(name
))
5015 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND
);
5016 SetSentErrorMessage(true);
5020 SendSysMessage(LANG_COMMAND_TP_DELETED
);
5024 bool ChatHandler::HandleListAurasCommand (const char * /*args*/)
5026 Unit
*unit
= getSelectedUnit();
5029 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
5030 SetSentErrorMessage(true);
5034 char const* talentStr
= GetMangosString(LANG_TALENT
);
5035 char const* passiveStr
= GetMangosString(LANG_PASSIVE
);
5037 Unit::AuraMap
const& uAuras
= unit
->GetAuras();
5038 PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS
, uAuras
.size());
5039 for (Unit::AuraMap::const_iterator itr
= uAuras
.begin(); itr
!= uAuras
.end(); ++itr
)
5041 bool talent
= GetTalentSpellCost(itr
->second
->GetId()) > 0;
5043 char const* name
= itr
->second
->GetSpellProto()->SpellName
[m_session
->GetSessionDbcLocale()];
5047 std::ostringstream ss_name
;
5048 ss_name
<< "|cffffffff|Hspell:" << itr
->second
->GetId() << "|h[" << name
<< "]|h|r";
5050 PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL
, itr
->second
->GetId(), itr
->second
->GetEffIndex(),
5051 itr
->second
->GetModifier()->m_auraname
, itr
->second
->GetAuraDuration(), itr
->second
->GetAuraMaxDuration(),
5052 ss_name
.str().c_str(),
5053 (itr
->second
->IsPassive() ? passiveStr
: ""),(talent
? talentStr
: ""),
5054 IS_PLAYER_GUID(itr
->second
->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr
->second
->GetCasterGUID()));
5058 PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL
, itr
->second
->GetId(), itr
->second
->GetEffIndex(),
5059 itr
->second
->GetModifier()->m_auraname
, itr
->second
->GetAuraDuration(), itr
->second
->GetAuraMaxDuration(),
5061 (itr
->second
->IsPassive() ? passiveStr
: ""),(talent
? talentStr
: ""),
5062 IS_PLAYER_GUID(itr
->second
->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr
->second
->GetCasterGUID()));
5065 for (int i
= 0; i
< TOTAL_AURAS
; ++i
)
5067 Unit::AuraList
const& uAuraList
= unit
->GetAurasByType(AuraType(i
));
5068 if (uAuraList
.empty()) continue;
5069 PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE
, uAuraList
.size(), i
);
5070 for (Unit::AuraList::const_iterator itr
= uAuraList
.begin(); itr
!= uAuraList
.end(); ++itr
)
5072 bool talent
= GetTalentSpellCost((*itr
)->GetId()) > 0;
5074 char const* name
= (*itr
)->GetSpellProto()->SpellName
[m_session
->GetSessionDbcLocale()];
5078 std::ostringstream ss_name
;
5079 ss_name
<< "|cffffffff|Hspell:" << (*itr
)->GetId() << "|h[" << name
<< "]|h|r";
5081 PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE
, (*itr
)->GetId(), (*itr
)->GetEffIndex(),
5082 ss_name
.str().c_str(),((*itr
)->IsPassive() ? passiveStr
: ""),(talent
? talentStr
: ""),
5083 IS_PLAYER_GUID((*itr
)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr
)->GetCasterGUID()));
5087 PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE
, (*itr
)->GetId(), (*itr
)->GetEffIndex(),
5088 name
,((*itr
)->IsPassive() ? passiveStr
: ""),(talent
? talentStr
: ""),
5089 IS_PLAYER_GUID((*itr
)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr
)->GetCasterGUID()));
5096 bool ChatHandler::HandleResetAchievementsCommand (const char * args
)
5098 char* pName
= strtok((char*)args
, "");
5099 Player
*player
= NULL
;
5103 std::string name
= extractPlayerNameFromLink(pName
);
5106 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5107 SetSentErrorMessage(true);
5111 guid
= objmgr
.GetPlayerGUIDByName(name
);
5112 player
= objmgr
.GetPlayer(guid
);
5116 player
= getSelectedPlayer();
5118 guid
= player
->GetGUID();
5121 if(!player
&& !guid
)
5123 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5128 player
->GetAchievementMgr().Reset();
5130 AchievementMgr::DeleteFromDB(GUID_LOPART(guid
));
5135 bool ChatHandler::HandleResetHonorCommand (const char * args
)
5137 char* pName
= strtok((char*)args
, "");
5138 Player
*player
= NULL
;
5141 std::string name
= extractPlayerNameFromLink(pName
);
5144 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5145 SetSentErrorMessage(true);
5149 uint64 guid
= objmgr
.GetPlayerGUIDByName(name
);
5150 player
= objmgr
.GetPlayer(guid
);
5153 player
= getSelectedPlayer();
5157 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5161 player
->SetUInt32Value(PLAYER_FIELD_KILLS
, 0);
5162 player
->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
, 0);
5163 player
->SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
, 0);
5164 player
->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION
, 0);
5165 player
->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION
, 0);
5167 player
->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL
);
5172 static bool HandleResetStatsOrLevelHelper(Player
* player
)
5174 PlayerInfo
const *info
= objmgr
.GetPlayerInfo(player
->getRace(), player
->getClass());
5175 if(!info
) return false;
5177 ChrClassesEntry
const* cEntry
= sChrClassesStore
.LookupEntry(player
->getClass());
5180 sLog
.outError("Class %u not found in DBC (Wrong DBC files?)",player
->getClass());
5184 uint8 powertype
= cEntry
->powerType
;
5186 // reset m_form if no aura
5187 if(!player
->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT
))
5188 player
->m_form
= FORM_NONE
;
5190 player
->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS
, DEFAULT_WORLD_OBJECT_SIZE
);
5191 player
->SetFloatValue(UNIT_FIELD_COMBATREACH
, 1.5f
);
5193 player
->setFactionForRace(player
->getRace());
5195 player
->SetUInt32Value(UNIT_FIELD_BYTES_0
, ( ( player
->getRace() ) | ( player
->getClass() << 8 ) | ( player
->getGender() << 16 ) | ( powertype
<< 24 ) ) );
5197 // reset only if player not in some form;
5198 if(player
->m_form
==FORM_NONE
)
5200 switch(player
->getGender())
5203 player
->SetDisplayId(info
->displayId_f
);
5204 player
->SetNativeDisplayId(info
->displayId_f
);
5207 player
->SetDisplayId(info
->displayId_m
);
5208 player
->SetNativeDisplayId(info
->displayId_m
);
5215 player
->SetByteValue(UNIT_FIELD_BYTES_2
, 1, UNIT_BYTE2_FLAG_PVP
);
5216 player
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, player
->m_form
);
5218 player
->SetUInt32Value(UNIT_FIELD_FLAGS
, UNIT_FLAG_PVP_ATTACKABLE
);
5220 //-1 is default value
5221 player
->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX
, uint32(-1));
5223 //player->SetUInt32Value(PLAYER_FIELD_BYTES, 0xEEE00000 );
5227 bool ChatHandler::HandleResetLevelCommand(const char * args
)
5229 char* pName
= strtok((char*)args
, "");
5230 Player
*player
= NULL
;
5233 std::string name
= extractPlayerNameFromLink(pName
);
5236 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5237 SetSentErrorMessage(true);
5241 uint64 guid
= objmgr
.GetPlayerGUIDByName(name
);
5242 player
= objmgr
.GetPlayer(guid
);
5245 player
= getSelectedPlayer();
5249 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5250 SetSentErrorMessage(true);
5254 if(!HandleResetStatsOrLevelHelper(player
))
5257 // set starting level
5258 uint32 start_level
= player
->getClass() != CLASS_DEATH_KNIGHT
5259 ? sWorld
.getConfig(CONFIG_START_PLAYER_LEVEL
)
5260 : sWorld
.getConfig(CONFIG_START_HEROIC_PLAYER_LEVEL
);
5262 player
->SetLevel(start_level
);
5263 player
->InitRunes();
5264 player
->InitStatsForLevel(true);
5265 player
->InitTaxiNodesForLevel();
5266 player
->InitGlyphsForLevel();
5267 player
->InitTalentForLevel();
5268 player
->SetUInt32Value(PLAYER_XP
,0);
5270 // reset level to summoned pet
5271 Pet
* pet
= player
->GetPet();
5272 if(pet
&& pet
->getPetType()==SUMMON_PET
)
5274 pet
->InitStatsForLevel(1);
5275 pet
->InitTalentForLevel();
5280 bool ChatHandler::HandleResetStatsCommand(const char * args
)
5282 char* pName
= strtok((char*)args
, "");
5283 Player
*player
= NULL
;
5286 std::string name
= extractPlayerNameFromLink(pName
);
5289 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5290 SetSentErrorMessage(true);
5294 uint64 guid
= objmgr
.GetPlayerGUIDByName(name
);
5295 player
= objmgr
.GetPlayer(guid
);
5298 player
= getSelectedPlayer();
5302 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5303 SetSentErrorMessage(true);
5307 if(!HandleResetStatsOrLevelHelper(player
))
5310 player
->InitRunes();
5311 player
->InitStatsForLevel(true);
5312 player
->InitTaxiNodesForLevel();
5313 player
->InitGlyphsForLevel();
5314 player
->InitTalentForLevel();
5319 bool ChatHandler::HandleResetSpellsCommand(const char * args
)
5321 char* pName
= strtok((char*)args
, "");
5322 Player
*player
= NULL
;
5323 uint64 playerGUID
= 0;
5326 std::string name
= extractPlayerNameFromLink(pName
);
5329 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5330 SetSentErrorMessage(true);
5334 player
= objmgr
.GetPlayer(name
.c_str());
5336 playerGUID
= objmgr
.GetPlayerGUIDByName(name
);
5339 player
= getSelectedPlayer();
5341 if(!player
&& !playerGUID
)
5343 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5344 SetSentErrorMessage(true);
5350 player
->resetSpells();
5352 ChatHandler(player
).SendSysMessage(LANG_RESET_SPELLS
);
5353 if(m_session
->GetPlayer()!=player
)
5354 PSendSysMessage(LANG_RESET_SPELLS_ONLINE
,GetNameLink(player
).c_str());
5358 CharacterDatabase
.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_SPELLS
), GUID_LOPART(playerGUID
));
5359 PSendSysMessage(LANG_RESET_SPELLS_OFFLINE
,pName
);
5365 bool ChatHandler::HandleResetTalentsCommand(const char * args
)
5367 char* pName
= strtok((char*)args
, "");
5368 Player
*player
= NULL
;
5369 uint64 playerGUID
= 0;
5372 std::string name
= extractPlayerNameFromLink(pName
);
5375 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5376 SetSentErrorMessage(true);
5380 player
= objmgr
.GetPlayer(name
.c_str());
5382 playerGUID
= objmgr
.GetPlayerGUIDByName(name
);
5385 player
= getSelectedPlayer();
5389 player
->resetTalents(true);
5391 ChatHandler(player
).SendSysMessage(LANG_RESET_TALENTS
);
5392 if(m_session
->GetPlayer()!=player
)
5393 PSendSysMessage(LANG_RESET_TALENTS_ONLINE
,GetNameLink(player
).c_str());
5397 else if (playerGUID
)
5399 CharacterDatabase
.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_TALENTS
), GUID_LOPART(playerGUID
) );
5400 std::string nameLink
= playerLink(pName
);
5401 PSendSysMessage(LANG_RESET_TALENTS_OFFLINE
,nameLink
.c_str());
5404 // Try reset talenents as Hunter Pet
5405 Creature
* creature
= getSelectedCreature();
5406 if (creature
&& creature
->isPet() && ((Pet
*)creature
)->getPetType() == HUNTER_PET
)
5408 ((Pet
*)creature
)->resetTalents(true);
5409 Unit
*owner
= creature
->GetOwner();
5410 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
5412 player
= (Player
*)owner
;
5413 ChatHandler(player
).SendSysMessage(LANG_RESET_PET_TALENTS
);
5414 if(m_session
->GetPlayer()!=player
)
5415 PSendSysMessage(LANG_RESET_PET_TALENTS_ONLINE
,GetNameLink(player
).c_str());
5420 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5421 SetSentErrorMessage(true);
5425 bool ChatHandler::HandleResetAllCommand(const char * args
)
5430 std::string casename
= args
;
5432 AtLoginFlags atLogin
;
5434 // Command specially created as single command to prevent using short case names
5435 if(casename
=="spells")
5437 atLogin
= AT_LOGIN_RESET_SPELLS
;
5438 sWorld
.SendWorldText(LANG_RESETALL_SPELLS
);
5440 else if(casename
=="talents")
5442 atLogin
= AT_LOGIN_RESET_TALENTS
;
5443 sWorld
.SendWorldText(LANG_RESETALL_TALENTS
);
5447 PSendSysMessage(LANG_RESETALL_UNKNOWN_CASE
,args
);
5448 SetSentErrorMessage(true);
5452 CharacterDatabase
.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE (at_login & '%u') = '0'",atLogin
,atLogin
);
5453 HashMapHolder
<Player
>::MapType
const& plist
= ObjectAccessor::Instance().GetPlayers();
5454 for(HashMapHolder
<Player
>::MapType::const_iterator itr
= plist
.begin(); itr
!= plist
.end(); ++itr
)
5455 itr
->second
->SetAtLoginFlag(atLogin
);
5460 bool ChatHandler::HandleServerShutDownCancelCommand(const char* /*args*/)
5462 sWorld
.ShutdownCancel();
5466 bool ChatHandler::HandleServerShutDownCommand(const char* args
)
5471 char* time_str
= strtok ((char*) args
, " ");
5472 char* exitcode_str
= strtok (NULL
, "");
5474 int32 time
= atoi (time_str
);
5476 ///- Prevent interpret wrong arg value as 0 secs shutdown time
5477 if ((time
== 0 && (time_str
[0]!='0' || time_str
[1]!='\0')) || time
< 0)
5482 int32 exitcode
= atoi (exitcode_str
);
5484 // Handle atoi() errors
5485 if (exitcode
== 0 && (exitcode_str
[0] != '0' || exitcode_str
[1] != '\0'))
5488 // Exit code should be in range of 0-125, 126-255 is used
5489 // in many shells for their own return codes and code > 255
5490 // is not supported in many others
5491 if (exitcode
< 0 || exitcode
> 125)
5494 sWorld
.ShutdownServ (time
, 0, exitcode
);
5497 sWorld
.ShutdownServ(time
,0,SHUTDOWN_EXIT_CODE
);
5501 bool ChatHandler::HandleServerRestartCommand(const char* args
)
5506 char* time_str
= strtok ((char*) args
, " ");
5507 char* exitcode_str
= strtok (NULL
, "");
5509 int32 time
= atoi (time_str
);
5511 ///- Prevent interpret wrong arg value as 0 secs shutdown time
5512 if(time
== 0 && (time_str
[0]!='0' || time_str
[1]!='\0') || time
< 0)
5517 int32 exitcode
= atoi (exitcode_str
);
5519 // Handle atoi() errors
5520 if (exitcode
== 0 && (exitcode_str
[0] != '0' || exitcode_str
[1] != '\0'))
5523 // Exit code should be in range of 0-125, 126-255 is used
5524 // in many shells for their own return codes and code > 255
5525 // is not supported in many others
5526 if (exitcode
< 0 || exitcode
> 125)
5529 sWorld
.ShutdownServ (time
, SHUTDOWN_MASK_RESTART
, exitcode
);
5532 sWorld
.ShutdownServ(time
, SHUTDOWN_MASK_RESTART
, RESTART_EXIT_CODE
);
5536 bool ChatHandler::HandleServerIdleRestartCommand(const char* args
)
5541 char* time_str
= strtok ((char*) args
, " ");
5542 char* exitcode_str
= strtok (NULL
, "");
5544 int32 time
= atoi (time_str
);
5546 ///- Prevent interpret wrong arg value as 0 secs shutdown time
5547 if(time
== 0 && (time_str
[0]!='0' || time_str
[1]!='\0') || time
< 0)
5552 int32 exitcode
= atoi (exitcode_str
);
5554 // Handle atoi() errors
5555 if (exitcode
== 0 && (exitcode_str
[0] != '0' || exitcode_str
[1] != '\0'))
5558 // Exit code should be in range of 0-125, 126-255 is used
5559 // in many shells for their own return codes and code > 255
5560 // is not supported in many others
5561 if (exitcode
< 0 || exitcode
> 125)
5564 sWorld
.ShutdownServ (time
, SHUTDOWN_MASK_RESTART
|SHUTDOWN_MASK_IDLE
, exitcode
);
5567 sWorld
.ShutdownServ(time
,SHUTDOWN_MASK_RESTART
|SHUTDOWN_MASK_IDLE
,RESTART_EXIT_CODE
);
5571 bool ChatHandler::HandleServerIdleShutDownCommand(const char* args
)
5576 char* time_str
= strtok ((char*) args
, " ");
5577 char* exitcode_str
= strtok (NULL
, "");
5579 int32 time
= atoi (time_str
);
5581 ///- Prevent interpret wrong arg value as 0 secs shutdown time
5582 if(time
== 0 && (time_str
[0]!='0' || time_str
[1]!='\0') || time
< 0)
5587 int32 exitcode
= atoi (exitcode_str
);
5589 // Handle atoi() errors
5590 if (exitcode
== 0 && (exitcode_str
[0] != '0' || exitcode_str
[1] != '\0'))
5593 // Exit code should be in range of 0-125, 126-255 is used
5594 // in many shells for their own return codes and code > 255
5595 // is not supported in many others
5596 if (exitcode
< 0 || exitcode
> 125)
5599 sWorld
.ShutdownServ (time
, SHUTDOWN_MASK_IDLE
, exitcode
);
5602 sWorld
.ShutdownServ(time
,SHUTDOWN_MASK_IDLE
,SHUTDOWN_EXIT_CODE
);
5606 bool ChatHandler::HandleQuestAdd(const char* args
)
5608 Player
* player
= getSelectedPlayer();
5611 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5612 SetSentErrorMessage(true);
5616 // .addquest #entry'
5617 // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r
5618 char* cId
= extractKeyFromLink((char*)args
,"Hquest");
5622 uint32 entry
= atol(cId
);
5624 Quest
const* pQuest
= objmgr
.GetQuestTemplate(entry
);
5628 PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND
,entry
);
5629 SetSentErrorMessage(true);
5633 // check item starting quest (it can work incorrectly if added without item in inventory)
5634 for (uint32 id
= 0; id
< sItemStorage
.MaxEntry
; id
++)
5636 ItemPrototype
const *pProto
= sItemStorage
.LookupEntry
<ItemPrototype
>(id
);
5640 if (pProto
->StartQuest
== entry
)
5642 PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM
, entry
, pProto
->ItemId
);
5643 SetSentErrorMessage(true);
5648 // ok, normal (creature/GO starting) quest
5649 if( player
->CanAddQuest( pQuest
, true ) )
5651 player
->AddQuest( pQuest
, NULL
);
5653 if ( player
->CanCompleteQuest( entry
) )
5654 player
->CompleteQuest( entry
);
5660 bool ChatHandler::HandleQuestRemove(const char* args
)
5662 Player
* player
= getSelectedPlayer();
5665 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5666 SetSentErrorMessage(true);
5670 // .removequest #entry'
5671 // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r
5672 char* cId
= extractKeyFromLink((char*)args
,"Hquest");
5676 uint32 entry
= atol(cId
);
5678 Quest
const* pQuest
= objmgr
.GetQuestTemplate(entry
);
5682 PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND
, entry
);
5683 SetSentErrorMessage(true);
5687 // remove all quest entries for 'entry' from quest log
5688 for(uint8 slot
= 0; slot
< MAX_QUEST_LOG_SIZE
; ++slot
)
5690 uint32 quest
= player
->GetQuestSlotQuestId(slot
);
5693 player
->SetQuestSlot(slot
,0);
5695 // we ignore unequippable quest items in this case, its' still be equipped
5696 player
->TakeQuestSourceItem( quest
, false );
5700 // set quest status to not started (will updated in DB at next save)
5701 player
->SetQuestStatus( entry
, QUEST_STATUS_NONE
);
5703 // reset rewarded for restart repeatable quest
5704 player
->getQuestStatusMap()[entry
].m_rewarded
= false;
5706 SendSysMessage(LANG_COMMAND_QUEST_REMOVED
);
5710 bool ChatHandler::HandleQuestComplete(const char* args
)
5712 Player
* player
= getSelectedPlayer();
5715 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5716 SetSentErrorMessage(true);
5720 // .quest complete #entry
5721 // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r
5722 char* cId
= extractKeyFromLink((char*)args
,"Hquest");
5726 uint32 entry
= atol(cId
);
5728 Quest
const* pQuest
= objmgr
.GetQuestTemplate(entry
);
5730 // If player doesn't have the quest
5731 if(!pQuest
|| player
->GetQuestStatus(entry
) == QUEST_STATUS_NONE
)
5733 PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND
, entry
);
5734 SetSentErrorMessage(true);
5738 // Add quest items for quests that require items
5739 for(uint8 x
= 0; x
< QUEST_OBJECTIVES_COUNT
; ++x
)
5741 uint32 id
= pQuest
->ReqItemId
[x
];
5742 uint32 count
= pQuest
->ReqItemCount
[x
];
5746 uint32 curItemCount
= player
->GetItemCount(id
,true);
5748 ItemPosCountVec dest
;
5749 uint8 msg
= player
->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, id
, count
-curItemCount
);
5750 if( msg
== EQUIP_ERR_OK
)
5752 Item
* item
= player
->StoreNewItem( dest
, id
, true);
5753 player
->SendNewItem(item
,count
-curItemCount
,true,false);
5757 // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10")
5758 for(uint8 i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
5760 uint32 creature
= pQuest
->ReqCreatureOrGOId
[i
];
5761 uint32 creaturecount
= pQuest
->ReqCreatureOrGOCount
[i
];
5763 if(uint32 spell_id
= pQuest
->ReqSpell
[i
])
5765 for(uint16 z
= 0; z
< creaturecount
; ++z
)
5766 player
->CastedCreatureOrGO(creature
,0,spell_id
);
5768 else if(creature
> 0)
5770 for(uint16 z
= 0; z
< creaturecount
; ++z
)
5771 player
->KilledMonster(creature
,0);
5773 else if(creature
< 0)
5775 for(uint16 z
= 0; z
< creaturecount
; ++z
)
5776 player
->CastedCreatureOrGO(creature
,0,0);
5780 // If the quest requires reputation to complete
5781 if(uint32 repFaction
= pQuest
->GetRepObjectiveFaction())
5783 uint32 repValue
= pQuest
->GetRepObjectiveValue();
5784 uint32 curRep
= player
->GetReputationMgr().GetReputation(repFaction
);
5785 if(curRep
< repValue
)
5786 if(FactionEntry
const *factionEntry
= sFactionStore
.LookupEntry(repFaction
))
5787 player
->GetReputationMgr().SetReputation(factionEntry
,repValue
);
5790 // If the quest requires money
5791 int32 ReqOrRewMoney
= pQuest
->GetRewOrReqMoney();
5792 if(ReqOrRewMoney
< 0)
5793 player
->ModifyMoney(-ReqOrRewMoney
);
5795 player
->CompleteQuest(entry
);
5799 bool ChatHandler::HandleBanAccountCommand(const char* args
)
5801 return HandleBanHelper(BAN_ACCOUNT
,args
);
5804 bool ChatHandler::HandleBanCharacterCommand(const char* args
)
5806 return HandleBanHelper(BAN_CHARACTER
,args
);
5809 bool ChatHandler::HandleBanIPCommand(const char* args
)
5811 return HandleBanHelper(BAN_IP
,args
);
5814 bool ChatHandler::HandleBanHelper(BanMode mode
, const char* args
)
5819 char* cnameOrIP
= strtok ((char*)args
, " ");
5823 std::string nameOrIP
= cnameOrIP
;
5825 char* duration
= strtok (NULL
," ");
5826 if(!duration
|| !atoi(duration
))
5829 char* reason
= strtok (NULL
,"");
5836 if(!AccountMgr::normilizeString(nameOrIP
))
5838 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,nameOrIP
.c_str());
5839 SetSentErrorMessage(true);
5844 if(!normalizePlayerName(nameOrIP
))
5846 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5847 SetSentErrorMessage(true);
5852 if(!IsIPAddress(nameOrIP
.c_str()))
5857 switch(sWorld
.BanAccount(mode
, nameOrIP
, duration
, reason
,m_session
? m_session
->GetPlayerName() : ""))
5860 if(atoi(duration
)>0)
5861 PSendSysMessage(LANG_BAN_YOUBANNED
,nameOrIP
.c_str(),secsToTimeString(TimeStringToSecs(duration
),true).c_str(),reason
);
5863 PSendSysMessage(LANG_BAN_YOUPERMBANNED
,nameOrIP
.c_str(),reason
);
5865 case BAN_SYNTAX_ERROR
:
5871 PSendSysMessage(LANG_BAN_NOTFOUND
,"account",nameOrIP
.c_str());
5874 PSendSysMessage(LANG_BAN_NOTFOUND
,"character",nameOrIP
.c_str());
5877 PSendSysMessage(LANG_BAN_NOTFOUND
,"ip",nameOrIP
.c_str());
5880 SetSentErrorMessage(true);
5887 bool ChatHandler::HandleUnBanAccountCommand(const char* args
)
5889 return HandleUnBanHelper(BAN_ACCOUNT
,args
);
5892 bool ChatHandler::HandleUnBanCharacterCommand(const char* args
)
5894 return HandleUnBanHelper(BAN_CHARACTER
,args
);
5897 bool ChatHandler::HandleUnBanIPCommand(const char* args
)
5899 return HandleUnBanHelper(BAN_IP
,args
);
5902 bool ChatHandler::HandleUnBanHelper(BanMode mode
, const char* args
)
5907 char* cnameOrIP
= strtok ((char*)args
, " ");
5911 std::string nameOrIP
= cnameOrIP
;
5916 if(!AccountMgr::normilizeString(nameOrIP
))
5918 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,nameOrIP
.c_str());
5919 SetSentErrorMessage(true);
5924 if(!normalizePlayerName(nameOrIP
))
5926 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5927 SetSentErrorMessage(true);
5932 if(!IsIPAddress(nameOrIP
.c_str()))
5937 if(sWorld
.RemoveBanAccount(mode
,nameOrIP
))
5938 PSendSysMessage(LANG_UNBAN_UNBANNED
,nameOrIP
.c_str());
5940 PSendSysMessage(LANG_UNBAN_ERROR
,nameOrIP
.c_str());
5945 bool ChatHandler::HandleBanInfoAccountCommand(const char* args
)
5950 char* cname
= strtok((char*)args
, "");
5954 std::string account_name
= cname
;
5955 if(!AccountMgr::normilizeString(account_name
))
5957 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
5958 SetSentErrorMessage(true);
5962 uint32 accountid
= accmgr
.GetId(account_name
);
5965 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
5969 return HandleBanInfoHelper(accountid
,account_name
.c_str());
5972 bool ChatHandler::HandleBanInfoCharacterCommand(const char* args
)
5977 std::string name
= extractPlayerNameFromLink((char*)args
);
5980 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5981 SetSentErrorMessage(true);
5985 uint32 accountid
= objmgr
.GetPlayerAccountIdByPlayerName(name
);
5988 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5989 SetSentErrorMessage(true);
5993 std::string accountname
;
5994 if(!accmgr
.GetName(accountid
,accountname
))
5996 PSendSysMessage(LANG_BANINFO_NOCHARACTER
);
6000 return HandleBanInfoHelper(accountid
,accountname
.c_str());
6003 bool ChatHandler::HandleBanInfoHelper(uint32 accountid
, char const* accountname
)
6005 QueryResult
*result
= loginDatabase
.PQuery("SELECT FROM_UNIXTIME(bandate), unbandate-bandate, active, unbandate,banreason,bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC",accountid
);
6008 PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN
, accountname
);
6012 PSendSysMessage(LANG_BANINFO_BANHISTORY
,accountname
);
6015 Field
* fields
= result
->Fetch();
6017 time_t unbandate
= time_t(fields
[3].GetUInt64());
6018 bool active
= false;
6019 if(fields
[2].GetBool() && (fields
[1].GetUInt64() == (uint64
)0 ||unbandate
>= time(NULL
)) )
6021 bool permanent
= (fields
[1].GetUInt64() == (uint64
)0);
6022 std::string bantime
= permanent
?GetMangosString(LANG_BANINFO_INFINITE
):secsToTimeString(fields
[1].GetUInt64(), true);
6023 PSendSysMessage(LANG_BANINFO_HISTORYENTRY
,
6024 fields
[0].GetString(), bantime
.c_str(), active
? GetMangosString(LANG_BANINFO_YES
):GetMangosString(LANG_BANINFO_NO
), fields
[4].GetString(), fields
[5].GetString());
6025 }while (result
->NextRow());
6031 bool ChatHandler::HandleBanInfoIPCommand(const char* args
)
6036 char* cIP
= strtok ((char*)args
, "");
6040 if (!IsIPAddress(cIP
))
6043 std::string IP
= cIP
;
6045 loginDatabase
.escape_string(IP
);
6046 QueryResult
*result
= loginDatabase
.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason,bannedby,unbandate-bandate FROM ip_banned WHERE ip = '%s'",IP
.c_str());
6049 PSendSysMessage(LANG_BANINFO_NOIP
);
6053 Field
*fields
= result
->Fetch();
6054 bool permanent
= !fields
[6].GetUInt64();
6055 PSendSysMessage(LANG_BANINFO_IPENTRY
,
6056 fields
[0].GetString(), fields
[1].GetString(), permanent
? GetMangosString(LANG_BANINFO_NEVER
):fields
[2].GetString(),
6057 permanent
? GetMangosString(LANG_BANINFO_INFINITE
):secsToTimeString(fields
[3].GetUInt64(), true).c_str(), fields
[4].GetString(), fields
[5].GetString());
6062 bool ChatHandler::HandleBanListCharacterCommand(const char* args
)
6064 loginDatabase
.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
6066 char* cFilter
= strtok ((char*)args
, " ");
6070 std::string filter
= cFilter
;
6071 loginDatabase
.escape_string(filter
);
6072 QueryResult
* result
= CharacterDatabase
.PQuery("SELECT account FROM characters WHERE name "_LIKE_
" "_CONCAT3_("'%%'","'%s'","'%%'"),filter
.c_str());
6075 PSendSysMessage(LANG_BANLIST_NOCHARACTER
);
6079 return HandleBanListHelper(result
);
6082 bool ChatHandler::HandleBanListAccountCommand(const char* args
)
6084 loginDatabase
.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
6086 char* cFilter
= strtok((char*)args
, " ");
6087 std::string filter
= cFilter
? cFilter
: "";
6088 loginDatabase
.escape_string(filter
);
6090 QueryResult
* result
;
6094 result
= loginDatabase
.Query("SELECT account.id, username FROM account, account_banned"
6095 " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id");
6099 result
= loginDatabase
.PQuery("SELECT account.id, username FROM account, account_banned"
6100 " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_
" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id",
6106 PSendSysMessage(LANG_BANLIST_NOACCOUNT
);
6110 return HandleBanListHelper(result
);
6113 bool ChatHandler::HandleBanListHelper(QueryResult
* result
)
6115 PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT
);
6117 // Chat short output
6122 Field
* fields
= result
->Fetch();
6123 uint32 accountid
= fields
[0].GetUInt32();
6125 QueryResult
* banresult
= loginDatabase
.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid
);
6128 Field
* fields2
= banresult
->Fetch();
6129 PSendSysMessage("%s",fields2
[0].GetString());
6132 } while (result
->NextRow());
6134 // Console wide output
6137 SendSysMessage(LANG_BANLIST_ACCOUNTS
);
6138 SendSysMessage("===============================================================================");
6139 SendSysMessage(LANG_BANLIST_ACCOUNTS_HEADER
);
6142 SendSysMessage("-------------------------------------------------------------------------------");
6143 Field
*fields
= result
->Fetch();
6144 uint32 account_id
= fields
[0].GetUInt32 ();
6146 std::string account_name
;
6148 // "account" case, name can be get in same query
6149 if(result
->GetFieldCount() > 1)
6150 account_name
= fields
[1].GetCppString();
6151 // "character" case, name need extract from another DB
6153 accmgr
.GetName (account_id
,account_name
);
6155 // No SQL injection. id is uint32.
6156 QueryResult
*banInfo
= loginDatabase
.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id
);
6159 Field
*fields2
= banInfo
->Fetch();
6162 time_t t_ban
= fields2
[0].GetUInt64();
6163 tm
* aTm_ban
= localtime(&t_ban
);
6165 if (fields2
[0].GetUInt64() == fields2
[1].GetUInt64())
6167 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
6168 account_name
.c_str(),aTm_ban
->tm_year
%100, aTm_ban
->tm_mon
+1, aTm_ban
->tm_mday
, aTm_ban
->tm_hour
, aTm_ban
->tm_min
,
6169 fields2
[2].GetString(),fields2
[3].GetString());
6173 time_t t_unban
= fields2
[1].GetUInt64();
6174 tm
* aTm_unban
= localtime(&t_unban
);
6175 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
6176 account_name
.c_str(),aTm_ban
->tm_year
%100, aTm_ban
->tm_mon
+1, aTm_ban
->tm_mday
, aTm_ban
->tm_hour
, aTm_ban
->tm_min
,
6177 aTm_unban
->tm_year
%100, aTm_unban
->tm_mon
+1, aTm_unban
->tm_mday
, aTm_unban
->tm_hour
, aTm_unban
->tm_min
,
6178 fields2
[2].GetString(),fields2
[3].GetString());
6180 }while ( banInfo
->NextRow() );
6183 }while( result
->NextRow() );
6184 SendSysMessage("===============================================================================");
6191 bool ChatHandler::HandleBanListIPCommand(const char* args
)
6193 loginDatabase
.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
6195 char* cFilter
= strtok((char*)args
, " ");
6196 std::string filter
= cFilter
? cFilter
: "";
6197 loginDatabase
.escape_string(filter
);
6199 QueryResult
* result
;
6203 result
= loginDatabase
.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
6204 " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())"
6205 " ORDER BY unbandate" );
6209 result
= loginDatabase
.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
6210 " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_
" "_CONCAT3_("'%%'","'%s'","'%%'")
6211 " ORDER BY unbandate",filter
.c_str() );
6216 PSendSysMessage(LANG_BANLIST_NOIP
);
6220 PSendSysMessage(LANG_BANLIST_MATCHINGIP
);
6221 // Chat short output
6226 Field
* fields
= result
->Fetch();
6227 PSendSysMessage("%s",fields
[0].GetString());
6228 } while (result
->NextRow());
6230 // Console wide output
6233 SendSysMessage(LANG_BANLIST_IPS
);
6234 SendSysMessage("===============================================================================");
6235 SendSysMessage(LANG_BANLIST_IPS_HEADER
);
6238 SendSysMessage("-------------------------------------------------------------------------------");
6239 Field
*fields
= result
->Fetch();
6240 time_t t_ban
= fields
[1].GetUInt64();
6241 tm
* aTm_ban
= localtime(&t_ban
);
6242 if ( fields
[1].GetUInt64() == fields
[2].GetUInt64() )
6244 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
6245 fields
[0].GetString(), aTm_ban
->tm_year
%100, aTm_ban
->tm_mon
+1, aTm_ban
->tm_mday
, aTm_ban
->tm_hour
, aTm_ban
->tm_min
,
6246 fields
[3].GetString(), fields
[4].GetString());
6250 time_t t_unban
= fields
[2].GetUInt64();
6251 tm
* aTm_unban
= localtime(&t_unban
);
6252 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
6253 fields
[0].GetString(), aTm_ban
->tm_year
%100, aTm_ban
->tm_mon
+1, aTm_ban
->tm_mday
, aTm_ban
->tm_hour
, aTm_ban
->tm_min
,
6254 aTm_unban
->tm_year
%100, aTm_unban
->tm_mon
+1, aTm_unban
->tm_mday
, aTm_unban
->tm_hour
, aTm_unban
->tm_min
,
6255 fields
[3].GetString(), fields
[4].GetString());
6257 }while( result
->NextRow() );
6258 SendSysMessage("===============================================================================");
6265 bool ChatHandler::HandleRespawnCommand(const char* /*args*/)
6267 Player
* pl
= m_session
->GetPlayer();
6269 // accept only explicitly selected target (not implicitly self targeting case)
6270 Unit
* target
= getSelectedUnit();
6271 if(pl
->GetSelection() && target
)
6273 if(target
->GetTypeId()!=TYPEID_UNIT
)
6275 SendSysMessage(LANG_SELECT_CREATURE
);
6276 SetSentErrorMessage(true);
6280 if(target
->isDead())
6281 ((Creature
*)target
)->Respawn();
6285 CellPair
p(MaNGOS::ComputeCellPair(pl
->GetPositionX(), pl
->GetPositionY()));
6287 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
6290 MaNGOS::RespawnDo u_do
;
6291 MaNGOS::WorldObjectWorker
<MaNGOS::RespawnDo
> worker(pl
,u_do
);
6293 TypeContainerVisitor
<MaNGOS::WorldObjectWorker
<MaNGOS::RespawnDo
>, GridTypeMapContainer
> obj_worker(worker
);
6294 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
6295 cell_lock
->Visit(cell_lock
, obj_worker
, *pl
->GetMap());
6300 bool ChatHandler::HandleGMFlyCommand(const char* args
)
6305 Player
*target
= getSelectedPlayer();
6307 target
= m_session
->GetPlayer();
6309 WorldPacket
data(12);
6310 if (strncmp(args
, "on", 3) == 0)
6311 data
.SetOpcode(SMSG_MOVE_SET_CAN_FLY
);
6312 else if (strncmp(args
, "off", 4) == 0)
6313 data
.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY
);
6316 SendSysMessage(LANG_USE_BOL
);
6319 data
.append(target
->GetPackGUID());
6320 data
<< uint32(0); // unknown
6321 target
->SendMessageToSet(&data
, true);
6322 PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS
, GetNameLink(target
).c_str(), args
);
6326 bool ChatHandler::HandlePDumpLoadCommand(const char *args
)
6331 char * file
= strtok((char*)args
, " ");
6335 char * account
= strtok(NULL
, " ");
6339 std::string account_name
= account
;
6340 if(!AccountMgr::normilizeString(account_name
))
6342 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
6343 SetSentErrorMessage(true);
6347 uint32 account_id
= accmgr
.GetId(account_name
);
6350 account_id
= atoi(account
); // use original string
6353 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
6354 SetSentErrorMessage(true);
6359 if(!accmgr
.GetName(account_id
,account_name
))
6361 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
6362 SetSentErrorMessage(true);
6366 char* guid_str
= NULL
;
6367 char* name_str
= strtok(NULL
, " ");
6373 // normalize the name if specified and check if it exists
6374 if(!normalizePlayerName(name
))
6376 PSendSysMessage(LANG_INVALID_CHARACTER_NAME
);
6377 SetSentErrorMessage(true);
6381 if(!ObjectMgr::IsValidName(name
,true))
6383 PSendSysMessage(LANG_INVALID_CHARACTER_NAME
);
6384 SetSentErrorMessage(true);
6388 guid_str
= strtok(NULL
, " ");
6395 guid
= atoi(guid_str
);
6398 PSendSysMessage(LANG_INVALID_CHARACTER_GUID
);
6399 SetSentErrorMessage(true);
6403 if(objmgr
.GetPlayerAccountIdByGUID(guid
))
6405 PSendSysMessage(LANG_CHARACTER_GUID_IN_USE
,guid
);
6406 SetSentErrorMessage(true);
6411 switch(PlayerDumpReader().LoadDump(file
, account_id
, name
, guid
))
6414 PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS
);
6416 case DUMP_FILE_OPEN_ERROR
:
6417 PSendSysMessage(LANG_FILE_OPEN_FAIL
,file
);
6418 SetSentErrorMessage(true);
6420 case DUMP_FILE_BROKEN
:
6421 PSendSysMessage(LANG_DUMP_BROKEN
,file
);
6422 SetSentErrorMessage(true);
6424 case DUMP_TOO_MANY_CHARS
:
6425 PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL
,account_name
.c_str(),account_id
);
6426 SetSentErrorMessage(true);
6429 PSendSysMessage(LANG_COMMAND_IMPORT_FAILED
);
6430 SetSentErrorMessage(true);
6437 bool ChatHandler::HandlePDumpWriteCommand(const char *args
)
6442 char* file
= strtok((char*)args
, " ");
6443 char* p2
= strtok(NULL
, " ");
6449 // character name can't start from number
6450 if (isNumeric(p2
[0]))
6454 std::string name
= extractPlayerNameFromLink(p2
);
6457 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
6458 SetSentErrorMessage(true);
6462 guid
= objmgr
.GetPlayerGUIDByName(name
);
6465 if(!objmgr
.GetPlayerAccountIdByGUID(guid
))
6467 PSendSysMessage(LANG_PLAYER_NOT_FOUND
);
6468 SetSentErrorMessage(true);
6472 switch(PlayerDumpWriter().WriteDump(file
, guid
))
6475 PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS
);
6477 case DUMP_FILE_OPEN_ERROR
:
6478 PSendSysMessage(LANG_FILE_OPEN_FAIL
,file
);
6479 SetSentErrorMessage(true);
6482 PSendSysMessage(LANG_COMMAND_EXPORT_FAILED
);
6483 SetSentErrorMessage(true);
6490 bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
6492 Unit
* unit
= getSelectedUnit();
6495 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
6496 SetSentErrorMessage(true);
6500 PSendSysMessage(LANG_MOVEGENS_LIST
,(unit
->GetTypeId()==TYPEID_PLAYER
? "Player" : "Creature" ),unit
->GetGUIDLow());
6502 MotionMaster
* mm
= unit
->GetMotionMaster();
6503 for(MotionMaster::const_iterator itr
= mm
->begin(); itr
!= mm
->end(); ++itr
)
6505 switch((*itr
)->GetMovementGeneratorType())
6507 case IDLE_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_IDLE
); break;
6508 case RANDOM_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_RANDOM
); break;
6509 case WAYPOINT_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_WAYPOINT
); break;
6510 case ANIMAL_RANDOM_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_ANIMAL_RANDOM
); break;
6511 case CONFUSED_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_CONFUSED
); break;
6512 case TARGETED_MOTION_TYPE
:
6514 if(unit
->GetTypeId()==TYPEID_PLAYER
)
6516 TargetedMovementGenerator
<Player
> const* mgen
= static_cast<TargetedMovementGenerator
<Player
> const*>(*itr
);
6517 Unit
* target
= mgen
->GetTarget();
6519 PSendSysMessage(LANG_MOVEGENS_TARGETED_PLAYER
,target
->GetName(),target
->GetGUIDLow());
6521 SendSysMessage(LANG_MOVEGENS_TARGETED_NULL
);
6525 TargetedMovementGenerator
<Creature
> const* mgen
= static_cast<TargetedMovementGenerator
<Creature
> const*>(*itr
);
6526 Unit
* target
= mgen
->GetTarget();
6528 PSendSysMessage(LANG_MOVEGENS_TARGETED_CREATURE
,target
->GetName(),target
->GetGUIDLow());
6530 SendSysMessage(LANG_MOVEGENS_TARGETED_NULL
);
6534 case HOME_MOTION_TYPE
:
6535 if(unit
->GetTypeId()==TYPEID_UNIT
)
6538 (*itr
)->GetDestination(x
,y
,z
);
6539 PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE
,x
,y
,z
);
6542 SendSysMessage(LANG_MOVEGENS_HOME_PLAYER
);
6544 case FLIGHT_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_FLIGHT
); break;
6545 case POINT_MOTION_TYPE
:
6548 (*itr
)->GetDestination(x
,y
,z
);
6549 PSendSysMessage(LANG_MOVEGENS_POINT
,x
,y
,z
);
6552 case FLEEING_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_FEAR
); break;
6553 case DISTRACT_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_DISTRACT
); break;
6555 PSendSysMessage(LANG_MOVEGENS_UNKNOWN
,(*itr
)->GetMovementGeneratorType());
6562 bool ChatHandler::HandleServerPLimitCommand(const char *args
)
6566 char* param
= strtok((char*)args
, " ");
6570 int l
= strlen(param
);
6572 if( strncmp(param
,"player",l
) == 0 )
6573 sWorld
.SetPlayerLimit(-SEC_PLAYER
);
6574 else if(strncmp(param
,"moderator",l
) == 0 )
6575 sWorld
.SetPlayerLimit(-SEC_MODERATOR
);
6576 else if(strncmp(param
,"gamemaster",l
) == 0 )
6577 sWorld
.SetPlayerLimit(-SEC_GAMEMASTER
);
6578 else if(strncmp(param
,"administrator",l
) == 0 )
6579 sWorld
.SetPlayerLimit(-SEC_ADMINISTRATOR
);
6580 else if(strncmp(param
,"reset",l
) == 0 )
6581 sWorld
.SetPlayerLimit( sConfig
.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT
) );
6584 int val
= atoi(param
);
6585 if(val
< -SEC_ADMINISTRATOR
) val
= -SEC_ADMINISTRATOR
;
6587 sWorld
.SetPlayerLimit(val
);
6590 // kick all low security level players
6591 if(sWorld
.GetPlayerAmountLimit() > SEC_PLAYER
)
6592 sWorld
.KickAllLess(sWorld
.GetPlayerSecurityLimit());
6595 uint32 pLimit
= sWorld
.GetPlayerAmountLimit();
6596 AccountTypes allowedAccountType
= sWorld
.GetPlayerSecurityLimit();
6597 char const* secName
= "";
6598 switch(allowedAccountType
)
6600 case SEC_PLAYER
: secName
= "Player"; break;
6601 case SEC_MODERATOR
: secName
= "Moderator"; break;
6602 case SEC_GAMEMASTER
: secName
= "Gamemaster"; break;
6603 case SEC_ADMINISTRATOR
: secName
= "Administrator"; break;
6604 default: secName
= "<unknown>"; break;
6607 PSendSysMessage("Player limits: amount %u, min. security level %s.",pLimit
,secName
);
6612 bool ChatHandler::HandleCastCommand(const char* args
)
6617 Unit
* target
= getSelectedUnit();
6621 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
6622 SetSentErrorMessage(true);
6626 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
6627 uint32 spell
= extractSpellIdFromLink((char*)args
);
6631 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
6635 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
6637 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
6638 SetSentErrorMessage(true);
6642 char* trig_str
= strtok(NULL
, " ");
6645 int l
= strlen(trig_str
);
6646 if(strncmp(trig_str
,"triggered",l
) != 0 )
6650 bool triggered
= (trig_str
!= NULL
);
6652 m_session
->GetPlayer()->CastSpell(target
,spell
,triggered
);
6657 bool ChatHandler::HandleCastBackCommand(const char* args
)
6659 Creature
* caster
= getSelectedCreature();
6663 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
6664 SetSentErrorMessage(true);
6668 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
6669 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
6670 uint32 spell
= extractSpellIdFromLink((char*)args
);
6671 if(!spell
|| !sSpellStore
.LookupEntry(spell
))
6674 char* trig_str
= strtok(NULL
, " ");
6677 int l
= strlen(trig_str
);
6678 if(strncmp(trig_str
,"triggered",l
) != 0 )
6682 bool triggered
= (trig_str
!= NULL
);
6684 // update orientation at server
6685 caster
->SetOrientation(caster
->GetAngle(m_session
->GetPlayer()));
6689 caster
->BuildHeartBeatMsg(&data
);
6690 caster
->SendMessageToSet(&data
,true);
6692 caster
->CastSpell(m_session
->GetPlayer(),spell
,triggered
);
6697 bool ChatHandler::HandleCastDistCommand(const char* args
)
6702 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
6703 uint32 spell
= extractSpellIdFromLink((char*)args
);
6707 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
6711 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
6713 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
6714 SetSentErrorMessage(true);
6718 char *distStr
= strtok(NULL
, " ");
6723 sscanf(distStr
, "%f", &dist
);
6725 char* trig_str
= strtok(NULL
, " ");
6728 int l
= strlen(trig_str
);
6729 if(strncmp(trig_str
,"triggered",l
) != 0 )
6733 bool triggered
= (trig_str
!= NULL
);
6736 m_session
->GetPlayer()->GetClosePoint(x
,y
,z
,dist
);
6738 m_session
->GetPlayer()->CastSpell(x
,y
,z
,spell
,triggered
);
6742 bool ChatHandler::HandleCastTargetCommand(const char* args
)
6744 Creature
* caster
= getSelectedCreature();
6748 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
6749 SetSentErrorMessage(true);
6753 if(!caster
->getVictim())
6755 SendSysMessage(LANG_SELECTED_TARGET_NOT_HAVE_VICTIM
);
6756 SetSentErrorMessage(true);
6760 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
6761 uint32 spell
= extractSpellIdFromLink((char*)args
);
6762 if(!spell
|| !sSpellStore
.LookupEntry(spell
))
6765 char* trig_str
= strtok(NULL
, " ");
6768 int l
= strlen(trig_str
);
6769 if(strncmp(trig_str
,"triggered",l
) != 0 )
6773 bool triggered
= (trig_str
!= NULL
);
6775 // update orientation at server
6776 caster
->SetOrientation(caster
->GetAngle(m_session
->GetPlayer()));
6780 caster
->BuildHeartBeatMsg(&data
);
6781 caster
->SendMessageToSet(&data
,true);
6783 caster
->CastSpell(caster
->getVictim(),spell
,triggered
);
6789 ComeToMe command REQUIRED for 3rd party scripting library to have access to PointMovementGenerator
6790 Without this function 3rd party scripting library will get linking errors (unresolved external)
6791 when attempting to use the PointMovementGenerator
6793 bool ChatHandler::HandleComeToMeCommand(const char *args
)
6795 Creature
* caster
= getSelectedCreature();
6799 SendSysMessage(LANG_SELECT_CREATURE
);
6800 SetSentErrorMessage(true);
6804 char* newFlagStr
= strtok((char*)args
, " ");
6809 uint32 newFlags
= atoi(newFlagStr
);
6811 caster
->SetUnitMovementFlags(newFlags
);
6813 Player
* pl
= m_session
->GetPlayer();
6815 caster
->GetMotionMaster()->MovePoint(0, pl
->GetPositionX(), pl
->GetPositionY(), pl
->GetPositionZ());
6819 bool ChatHandler::HandleCastSelfCommand(const char* args
)
6824 Unit
* target
= getSelectedUnit();
6828 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
6829 SetSentErrorMessage(true);
6833 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
6834 uint32 spell
= extractSpellIdFromLink((char*)args
);
6838 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
6842 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
6844 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
6845 SetSentErrorMessage(true);
6849 target
->CastSpell(target
,spell
,false);
6854 std::string
GetTimeString(uint32 time
)
6856 uint16 days
= time
/ DAY
, hours
= (time
% DAY
) / HOUR
, minute
= (time
% HOUR
) / MINUTE
;
6857 std::ostringstream ss
;
6858 if(days
) ss
<< days
<< "d ";
6859 if(hours
) ss
<< hours
<< "h ";
6860 ss
<< minute
<< "m";
6864 bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/)
6866 Player
* player
= getSelectedPlayer();
6867 if (!player
) player
= m_session
->GetPlayer();
6869 for(uint8 i
= 0; i
< TOTAL_DIFFICULTIES
; ++i
)
6871 Player::BoundInstancesMap
&binds
= player
->GetBoundInstances(i
);
6872 for(Player::BoundInstancesMap::const_iterator itr
= binds
.begin(); itr
!= binds
.end(); ++itr
)
6874 InstanceSave
*save
= itr
->second
.save
;
6875 std::string timeleft
= GetTimeString(save
->GetResetTime() - time(NULL
));
6876 PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr
->first
, save
->GetInstanceId(), itr
->second
.perm
? "yes" : "no", save
->GetDifficulty() == DIFFICULTY_NORMAL
? "normal" : "heroic", save
->CanReset() ? "yes" : "no", timeleft
.c_str());
6880 PSendSysMessage("player binds: %d", counter
);
6882 Group
*group
= player
->GetGroup();
6885 for(uint8 i
= 0; i
< TOTAL_DIFFICULTIES
; ++i
)
6887 Group::BoundInstancesMap
&binds
= group
->GetBoundInstances(i
);
6888 for(Group::BoundInstancesMap::const_iterator itr
= binds
.begin(); itr
!= binds
.end(); ++itr
)
6890 InstanceSave
*save
= itr
->second
.save
;
6891 std::string timeleft
= GetTimeString(save
->GetResetTime() - time(NULL
));
6892 PSendSysMessage("map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr
->first
, save
->GetInstanceId(), itr
->second
.perm
? "yes" : "no", save
->GetDifficulty() == DIFFICULTY_NORMAL
? "normal" : "heroic", save
->CanReset() ? "yes" : "no", timeleft
.c_str());
6897 PSendSysMessage("group binds: %d", counter
);
6902 bool ChatHandler::HandleInstanceUnbindCommand(const char* args
)
6907 std::string cmd
= args
;
6910 Player
* player
= getSelectedPlayer();
6911 if (!player
) player
= m_session
->GetPlayer();
6913 for(uint8 i
= 0; i
< TOTAL_DIFFICULTIES
; ++i
)
6915 Player::BoundInstancesMap
&binds
= player
->GetBoundInstances(i
);
6916 for(Player::BoundInstancesMap::iterator itr
= binds
.begin(); itr
!= binds
.end();)
6918 if(itr
->first
!= player
->GetMapId())
6920 InstanceSave
*save
= itr
->second
.save
;
6921 std::string timeleft
= GetTimeString(save
->GetResetTime() - time(NULL
));
6922 PSendSysMessage("unbinding map: %d inst: %d perm: %s diff: %s canReset: %s TTR: %s", itr
->first
, save
->GetInstanceId(), itr
->second
.perm
? "yes" : "no", save
->GetDifficulty() == DIFFICULTY_NORMAL
? "normal" : "heroic", save
->CanReset() ? "yes" : "no", timeleft
.c_str());
6923 player
->UnbindInstance(itr
, i
);
6930 PSendSysMessage("instances unbound: %d", counter
);
6935 bool ChatHandler::HandleInstanceStatsCommand(const char* /*args*/)
6937 PSendSysMessage("instances loaded: %d", MapManager::Instance().GetNumInstances());
6938 PSendSysMessage("players in instances: %d", MapManager::Instance().GetNumPlayersInInstances());
6939 PSendSysMessage("instance saves: %d", sInstanceSaveManager
.GetNumInstanceSaves());
6940 PSendSysMessage("players bound: %d", sInstanceSaveManager
.GetNumBoundPlayersTotal());
6941 PSendSysMessage("groups bound: %d", sInstanceSaveManager
.GetNumBoundGroupsTotal());
6945 bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/)
6947 Player
* pl
= m_session
->GetPlayer();
6949 Map
* map
= pl
->GetMap();
6950 if (!map
->IsDungeon())
6952 PSendSysMessage("Map is not a dungeon.");
6953 SetSentErrorMessage(true);
6957 if (!((InstanceMap
*)map
)->GetInstanceData())
6959 PSendSysMessage("Map has no instance data.");
6960 SetSentErrorMessage(true);
6964 ((InstanceMap
*)map
)->GetInstanceData()->SaveToDB();
6968 /// Display the list of GMs
6969 bool ChatHandler::HandleGMListFullCommand(const char* /*args*/)
6971 ///- Get the accounts with GM Level >0
6972 QueryResult
*result
= loginDatabase
.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" );
6975 SendSysMessage(LANG_GMLIST
);
6976 SendSysMessage("========================");
6977 SendSysMessage(LANG_GMLIST_HEADER
);
6978 SendSysMessage("========================");
6980 ///- Circle through them. Display username and GM level
6983 Field
*fields
= result
->Fetch();
6984 PSendSysMessage("|%15s|%6s|", fields
[0].GetString(),fields
[1].GetString());
6985 }while( result
->NextRow() );
6987 PSendSysMessage("========================");
6991 PSendSysMessage(LANG_GMLIST_EMPTY
);
6995 /// Define the 'Message of the day' for the realm
6996 bool ChatHandler::HandleServerSetMotdCommand(const char* args
)
6998 sWorld
.SetMotd(args
);
6999 PSendSysMessage(LANG_MOTD_NEW
, args
);
7003 /// Set/Unset the expansion level for an account
7004 bool ChatHandler::HandleAccountSetAddonCommand(const char* args
)
7006 ///- Get the command line arguments
7007 char *szAcc
= strtok((char*)args
," ");
7008 char *szExp
= strtok(NULL
," ");
7013 std::string account_name
;
7018 Player
* player
= getSelectedPlayer();
7022 account_id
= player
->GetSession()->GetAccountId();
7023 accmgr
.GetName(account_id
,account_name
);
7028 ///- Convert Account name to Upper Format
7029 account_name
= szAcc
;
7030 if(!AccountMgr::normilizeString(account_name
))
7032 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
7033 SetSentErrorMessage(true);
7037 account_id
= accmgr
.GetId(account_name
);
7040 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
7041 SetSentErrorMessage(true);
7047 // Let set addon state only for lesser (strong) security level
7048 // or to self account
7049 if (m_session
&& m_session
->GetAccountId () != account_id
&&
7050 HasLowerSecurityAccount (NULL
,account_id
,true))
7053 int lev
=atoi(szExp
); //get int anyway (0 if error)
7058 loginDatabase
.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev
,account_id
);
7059 PSendSysMessage(LANG_ACCOUNT_SETADDON
,account_name
.c_str(),account_id
,lev
);
7063 //Send items by mail
7064 bool ChatHandler::HandleSendItemsCommand(const char* args
)
7069 // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
7071 std::string name
= extractPlayerNameFromLink((char*)args
);
7074 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7075 SetSentErrorMessage(true);
7079 char* tail1
= strtok(NULL
, "");
7085 msgSubject
= strtok(tail1
+1, "\"");
7088 char* space
= strtok(tail1
, "\"");
7091 msgSubject
= strtok(NULL
, "\"");
7097 char* tail2
= strtok(NULL
, "");
7103 msgText
= strtok(tail2
+1, "\"");
7106 char* space
= strtok(tail2
, "\"");
7109 msgText
= strtok(NULL
, "\"");
7115 // msgSubject, msgText isn't NUL after prev. check
7116 std::string subject
= msgSubject
;
7117 std::string text
= msgText
;
7120 typedef std::pair
<uint32
,uint32
> ItemPair
;
7121 typedef std::list
< ItemPair
> ItemPairs
;
7124 // get all tail string
7125 char* tail
= strtok(NULL
, "");
7127 // get from tail next item str
7128 while(char* itemStr
= strtok(tail
, " "))
7131 tail
= strtok(NULL
, "");
7134 char* itemIdStr
= strtok(itemStr
, ":");
7135 char* itemCountStr
= strtok(NULL
, " ");
7137 uint32 item_id
= atoi(itemIdStr
);
7141 ItemPrototype
const* item_proto
= objmgr
.GetItemPrototype(item_id
);
7144 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID
, item_id
);
7145 SetSentErrorMessage(true);
7149 uint32 item_count
= itemCountStr
? atoi(itemCountStr
) : 1;
7150 if(item_count
< 1 || item_proto
->MaxCount
> 0 && item_count
> uint32(item_proto
->MaxCount
))
7152 PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT
, item_count
,item_id
);
7153 SetSentErrorMessage(true);
7157 while(item_count
> item_proto
->GetMaxStackSize())
7159 items
.push_back(ItemPair(item_id
,item_proto
->GetMaxStackSize()));
7160 item_count
-= item_proto
->GetMaxStackSize();
7163 items
.push_back(ItemPair(item_id
,item_count
));
7165 if(items
.size() > MAX_MAIL_ITEMS
)
7167 PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT
, MAX_MAIL_ITEMS
);
7168 SetSentErrorMessage(true);
7173 uint64 receiver_guid
= objmgr
.GetPlayerGUIDByName(name
);
7176 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7177 SetSentErrorMessage(true);
7181 // from console show not existed sender
7182 uint32 sender_guidlo
= m_session
? m_session
->GetPlayer()->GetGUIDLow() : 0;
7184 uint32 messagetype
= MAIL_NORMAL
;
7185 uint32 stationery
= MAIL_STATIONERY_GM
;
7186 uint32 itemTextId
= !text
.empty() ? objmgr
.CreateItemText( text
) : 0;
7188 Player
*receiver
= objmgr
.GetPlayer(receiver_guid
);
7191 MailItemsInfo mi
; // item list preparing
7193 for(ItemPairs::const_iterator itr
= items
.begin(); itr
!= items
.end(); ++itr
)
7195 if(Item
* item
= Item::CreateItem(itr
->first
,itr
->second
,m_session
? m_session
->GetPlayer() : 0))
7197 item
->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted
7198 mi
.AddItem(item
->GetGUIDLow(), item
->GetEntry(), item
);
7202 WorldSession::SendMailTo(receiver
,messagetype
, stationery
, sender_guidlo
, GUID_LOPART(receiver_guid
), subject
, itemTextId
, &mi
, 0, 0, MAIL_CHECK_MASK_NONE
);
7204 std::string nameLink
= playerLink(name
);
7205 PSendSysMessage(LANG_MAIL_SENT
, nameLink
.c_str());
7209 ///Send money by mail
7210 bool ChatHandler::HandleSendMoneyCommand(const char* args
)
7215 /// format: name "subject text" "mail text" money
7217 std::string name
= extractPlayerNameFromLink((char*)args
);
7220 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7221 SetSentErrorMessage(true);
7225 char* tail1
= strtok(NULL
, "");
7231 msgSubject
= strtok(tail1
+1, "\"");
7234 char* space
= strtok(tail1
, "\"");
7237 msgSubject
= strtok(NULL
, "\"");
7243 char* tail2
= strtok(NULL
, "");
7249 msgText
= strtok(tail2
+1, "\"");
7252 char* space
= strtok(tail2
, "\"");
7255 msgText
= strtok(NULL
, "\"");
7261 char* money_str
= strtok(NULL
, "");
7262 int32 money
= money_str
? atoi(money_str
) : 0;
7266 // msgSubject, msgText isn't NUL after prev. check
7267 std::string subject
= msgSubject
;
7268 std::string text
= msgText
;
7270 uint64 receiver_guid
= objmgr
.GetPlayerGUIDByName(name
);
7273 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7274 SetSentErrorMessage(true);
7278 // from console show not existed sender
7279 uint32 sender_guidlo
= m_session
? m_session
->GetPlayer()->GetGUIDLow() : 0;
7281 uint32 messagetype
= MAIL_NORMAL
;
7282 uint32 stationery
= MAIL_STATIONERY_GM
;
7283 uint32 itemTextId
= !text
.empty() ? objmgr
.CreateItemText( text
) : 0;
7285 Player
*receiver
= objmgr
.GetPlayer(receiver_guid
);
7287 WorldSession::SendMailTo(receiver
,messagetype
, stationery
, sender_guidlo
, GUID_LOPART(receiver_guid
), subject
, itemTextId
, NULL
, money
, 0, MAIL_CHECK_MASK_NONE
);
7289 std::string nameLink
= playerLink(name
);
7290 PSendSysMessage(LANG_MAIL_SENT
, nameLink
.c_str());
7294 /// Send a message to a player in game
7295 bool ChatHandler::HandleSendMessageCommand(const char* args
)
7297 ///- Get the command line arguments
7298 std::string name
= extractPlayerNameFromLink((char*)args
);
7301 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7302 SetSentErrorMessage(true);
7306 char* msg_str
= strtok(NULL
, "");
7310 ///- Find the player and check that he is not logging out.
7311 Player
*rPlayer
= objmgr
.GetPlayer(name
.c_str());
7314 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7315 SetSentErrorMessage(true);
7319 if(rPlayer
->GetSession()->isLogingOut())
7321 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7322 SetSentErrorMessage(true);
7326 ///- Send the message
7327 //Use SendAreaTriggerMessage for fastest delivery.
7328 rPlayer
->GetSession()->SendAreaTriggerMessage("%s", msg_str
);
7329 rPlayer
->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r");
7331 //Confirmation message
7332 std::string nameLink
= playerLink(name
);
7333 PSendSysMessage(LANG_SENDMESSAGE
,nameLink
.c_str(),msg_str
);
7337 bool ChatHandler::HandleFlushArenaPointsCommand(const char * /*args*/)
7339 sBattleGroundMgr
.DistributeArenaPoints();
7343 bool ChatHandler::HandleModifyGenderCommand(const char *args
)
7348 Player
*player
= getSelectedPlayer();
7352 PSendSysMessage(LANG_PLAYER_NOT_FOUND
);
7353 SetSentErrorMessage(true);
7357 PlayerInfo
const* info
= objmgr
.GetPlayerInfo(player
->getRace(), player
->getClass());
7361 char const* gender_str
= (char*)args
;
7362 int gender_len
= strlen(gender_str
);
7366 if(!strncmp(gender_str
, "male", gender_len
)) // MALE
7368 if(player
->getGender() == GENDER_MALE
)
7371 gender
= GENDER_MALE
;
7373 else if (!strncmp(gender_str
, "female", gender_len
)) // FEMALE
7375 if(player
->getGender() == GENDER_FEMALE
)
7378 gender
= GENDER_FEMALE
;
7382 SendSysMessage(LANG_MUST_MALE_OR_FEMALE
);
7383 SetSentErrorMessage(true);
7388 player
->SetByteValue(UNIT_FIELD_BYTES_0
, 2, gender
);
7389 player
->SetByteValue(PLAYER_BYTES_3
, 0, gender
);
7391 // Change display ID
7392 player
->SetDisplayId(gender
? info
->displayId_f
: info
->displayId_m
);
7393 player
->SetNativeDisplayId(gender
? info
->displayId_f
: info
->displayId_m
);
7395 char const* gender_full
= gender
? "female" : "male";
7397 PSendSysMessage(LANG_YOU_CHANGE_GENDER
, GetNameLink(player
).c_str(), gender_full
);
7399 if (needReportToTarget(player
))
7400 ChatHandler(player
).PSendSysMessage(LANG_YOUR_GENDER_CHANGED
, gender_full
, GetNameLink().c_str());