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");
579 bool ChatHandler::HandleReloadAllQuestCommand(const char* /*args*/)
581 HandleReloadQuestAreaTriggersCommand("a");
582 HandleReloadQuestTemplateCommand("a");
584 sLog
.outString( "Re-Loading Quests Relations..." );
585 objmgr
.LoadQuestRelations();
586 SendGlobalSysMessage("DB tables `*_questrelation` and `*_involvedrelation` reloaded.");
590 bool ChatHandler::HandleReloadAllScriptsCommand(const char*)
592 if(sWorld
.IsScriptScheduled())
594 PSendSysMessage("DB scripts used currently, please attempt reload later.");
595 SetSentErrorMessage(true);
599 sLog
.outString( "Re-Loading Scripts..." );
600 HandleReloadGameObjectScriptsCommand("a");
601 HandleReloadEventScriptsCommand("a");
602 HandleReloadQuestEndScriptsCommand("a");
603 HandleReloadQuestStartScriptsCommand("a");
604 HandleReloadSpellScriptsCommand("a");
605 SendGlobalSysMessage("DB tables `*_scripts` reloaded.");
606 HandleReloadDbScriptStringCommand("a");
610 bool ChatHandler::HandleReloadAllSpellCommand(const char*)
612 HandleReloadSkillDiscoveryTemplateCommand("a");
613 HandleReloadSkillExtraItemTemplateCommand("a");
614 HandleReloadSpellAffectCommand("a");
615 HandleReloadSpellAreaCommand("a");
616 HandleReloadSpellChainCommand("a");
617 HandleReloadSpellElixirCommand("a");
618 HandleReloadSpellLearnSpellCommand("a");
619 HandleReloadSpellProcEventCommand("a");
620 HandleReloadSpellBonusesCommand("a");
621 HandleReloadSpellScriptTargetCommand("a");
622 HandleReloadSpellTargetPositionCommand("a");
623 HandleReloadSpellThreatsCommand("a");
624 HandleReloadSpellPetAurasCommand("a");
628 bool ChatHandler::HandleReloadAllItemCommand(const char*)
630 HandleReloadPageTextsCommand("a");
631 HandleReloadItemEnchantementsCommand("a");
635 bool ChatHandler::HandleReloadAllLocalesCommand(const char* /*args*/)
637 HandleReloadLocalesAchievementRewardCommand("a");
638 HandleReloadLocalesCreatureCommand("a");
639 HandleReloadLocalesGameobjectCommand("a");
640 HandleReloadLocalesItemCommand("a");
641 HandleReloadLocalesNpcTextCommand("a");
642 HandleReloadLocalesPageTextCommand("a");
643 HandleReloadLocalesPointsOfInterestCommand("a");
644 HandleReloadLocalesQuestCommand("a");
648 bool ChatHandler::HandleReloadConfigCommand(const char* /*args*/)
650 sLog
.outString( "Re-Loading config settings..." );
651 sWorld
.LoadConfigSettings(true);
652 SendGlobalSysMessage("World config settings reloaded.");
656 bool ChatHandler::HandleReloadAchievementCriteriaDataCommand(const char*)
658 sLog
.outString( "Re-Loading Additional Achievement Criteria Data..." );
659 achievementmgr
.LoadAchievementCriteriaData();
660 SendGlobalSysMessage("DB table `achievement_criteria_data` reloaded.");
664 bool ChatHandler::HandleReloadAchievementRewardCommand(const char*)
666 sLog
.outString( "Re-Loading Achievement Reward Data..." );
667 achievementmgr
.LoadRewards();
668 SendGlobalSysMessage("DB table `achievement_reward` reloaded.");
672 bool ChatHandler::HandleReloadAreaTriggerTavernCommand(const char*)
674 sLog
.outString( "Re-Loading Tavern Area Triggers..." );
675 objmgr
.LoadTavernAreaTriggers();
676 SendGlobalSysMessage("DB table `areatrigger_tavern` reloaded.");
680 bool ChatHandler::HandleReloadAreaTriggerTeleportCommand(const char*)
682 sLog
.outString( "Re-Loading AreaTrigger teleport definitions..." );
683 objmgr
.LoadAreaTriggerTeleports();
684 SendGlobalSysMessage("DB table `areatrigger_teleport` reloaded.");
688 bool ChatHandler::HandleReloadCommandCommand(const char*)
690 load_command_table
= true;
691 SendGlobalSysMessage("DB table `command` will be reloaded at next chat command use.");
695 bool ChatHandler::HandleReloadCreatureQuestRelationsCommand(const char*)
697 sLog
.outString( "Loading Quests Relations... (`creature_questrelation`)" );
698 objmgr
.LoadCreatureQuestRelations();
699 SendGlobalSysMessage("DB table `creature_questrelation` (creature quest givers) reloaded.");
703 bool ChatHandler::HandleReloadCreatureQuestInvRelationsCommand(const char*)
705 sLog
.outString( "Loading Quests Relations... (`creature_involvedrelation`)" );
706 objmgr
.LoadCreatureInvolvedRelations();
707 SendGlobalSysMessage("DB table `creature_involvedrelation` (creature quest takers) reloaded.");
711 bool ChatHandler::HandleReloadGOQuestRelationsCommand(const char*)
713 sLog
.outString( "Loading Quests Relations... (`gameobject_questrelation`)" );
714 objmgr
.LoadGameobjectQuestRelations();
715 SendGlobalSysMessage("DB table `gameobject_questrelation` (gameobject quest givers) reloaded.");
719 bool ChatHandler::HandleReloadGOQuestInvRelationsCommand(const char*)
721 sLog
.outString( "Loading Quests Relations... (`gameobject_involvedrelation`)" );
722 objmgr
.LoadGameobjectInvolvedRelations();
723 SendGlobalSysMessage("DB table `gameobject_involvedrelation` (gameobject quest takers) reloaded.");
727 bool ChatHandler::HandleReloadQuestAreaTriggersCommand(const char*)
729 sLog
.outString( "Re-Loading Quest Area Triggers..." );
730 objmgr
.LoadQuestAreaTriggers();
731 SendGlobalSysMessage("DB table `areatrigger_involvedrelation` (quest area triggers) reloaded.");
735 bool ChatHandler::HandleReloadQuestTemplateCommand(const char*)
737 sLog
.outString( "Re-Loading Quest Templates..." );
739 SendGlobalSysMessage("DB table `quest_template` (quest definitions) reloaded.");
741 /// dependent also from `gameobject` but this table not reloaded anyway
742 sLog
.outString( "Re-Loading GameObjects for quests..." );
743 objmgr
.LoadGameObjectForQuests();
744 SendGlobalSysMessage("Data GameObjects for quests reloaded.");
748 bool ChatHandler::HandleReloadLootTemplatesCreatureCommand(const char*)
750 sLog
.outString( "Re-Loading Loot Tables... (`creature_loot_template`)" );
751 LoadLootTemplates_Creature();
752 LootTemplates_Creature
.CheckLootRefs();
753 SendGlobalSysMessage("DB table `creature_loot_template` reloaded.");
757 bool ChatHandler::HandleReloadLootTemplatesDisenchantCommand(const char*)
759 sLog
.outString( "Re-Loading Loot Tables... (`disenchant_loot_template`)" );
760 LoadLootTemplates_Disenchant();
761 LootTemplates_Disenchant
.CheckLootRefs();
762 SendGlobalSysMessage("DB table `disenchant_loot_template` reloaded.");
766 bool ChatHandler::HandleReloadLootTemplatesFishingCommand(const char*)
768 sLog
.outString( "Re-Loading Loot Tables... (`fishing_loot_template`)" );
769 LoadLootTemplates_Fishing();
770 LootTemplates_Fishing
.CheckLootRefs();
771 SendGlobalSysMessage("DB table `fishing_loot_template` reloaded.");
775 bool ChatHandler::HandleReloadLootTemplatesGameobjectCommand(const char*)
777 sLog
.outString( "Re-Loading Loot Tables... (`gameobject_loot_template`)" );
778 LoadLootTemplates_Gameobject();
779 LootTemplates_Gameobject
.CheckLootRefs();
780 SendGlobalSysMessage("DB table `gameobject_loot_template` reloaded.");
784 bool ChatHandler::HandleReloadLootTemplatesItemCommand(const char*)
786 sLog
.outString( "Re-Loading Loot Tables... (`item_loot_template`)" );
787 LoadLootTemplates_Item();
788 LootTemplates_Item
.CheckLootRefs();
789 SendGlobalSysMessage("DB table `item_loot_template` reloaded.");
793 bool ChatHandler::HandleReloadLootTemplatesMillingCommand(const char*)
795 sLog
.outString( "Re-Loading Loot Tables... (`milling_loot_template`)" );
796 LoadLootTemplates_Milling();
797 LootTemplates_Milling
.CheckLootRefs();
798 SendGlobalSysMessage("DB table `milling_loot_template` reloaded.");
802 bool ChatHandler::HandleReloadLootTemplatesPickpocketingCommand(const char*)
804 sLog
.outString( "Re-Loading Loot Tables... (`pickpocketing_loot_template`)" );
805 LoadLootTemplates_Pickpocketing();
806 LootTemplates_Pickpocketing
.CheckLootRefs();
807 SendGlobalSysMessage("DB table `pickpocketing_loot_template` reloaded.");
811 bool ChatHandler::HandleReloadLootTemplatesProspectingCommand(const char*)
813 sLog
.outString( "Re-Loading Loot Tables... (`prospecting_loot_template`)" );
814 LoadLootTemplates_Prospecting();
815 LootTemplates_Prospecting
.CheckLootRefs();
816 SendGlobalSysMessage("DB table `prospecting_loot_template` reloaded.");
820 bool ChatHandler::HandleReloadLootTemplatesQuestMailCommand(const char*)
822 sLog
.outString( "Re-Loading Loot Tables... (`quest_mail_loot_template`)" );
823 LoadLootTemplates_QuestMail();
824 LootTemplates_QuestMail
.CheckLootRefs();
825 SendGlobalSysMessage("DB table `quest_mail_loot_template` reloaded.");
829 bool ChatHandler::HandleReloadLootTemplatesReferenceCommand(const char*)
831 sLog
.outString( "Re-Loading Loot Tables... (`reference_loot_template`)" );
832 LoadLootTemplates_Reference();
833 SendGlobalSysMessage("DB table `reference_loot_template` reloaded.");
837 bool ChatHandler::HandleReloadLootTemplatesSkinningCommand(const char*)
839 sLog
.outString( "Re-Loading Loot Tables... (`skinning_loot_template`)" );
840 LoadLootTemplates_Skinning();
841 LootTemplates_Skinning
.CheckLootRefs();
842 SendGlobalSysMessage("DB table `skinning_loot_template` reloaded.");
846 bool ChatHandler::HandleReloadLootTemplatesSpellCommand(const char*)
848 sLog
.outString( "Re-Loading Loot Tables... (`spell_loot_template`)" );
849 LoadLootTemplates_Spell();
850 LootTemplates_Spell
.CheckLootRefs();
851 SendGlobalSysMessage("DB table `spell_loot_template` reloaded.");
855 bool ChatHandler::HandleReloadMangosStringCommand(const char*)
857 sLog
.outString( "Re-Loading mangos_string Table!" );
858 objmgr
.LoadMangosStrings();
859 SendGlobalSysMessage("DB table `mangos_string` reloaded.");
863 bool ChatHandler::HandleReloadNpcOptionCommand(const char*)
865 sLog
.outString( "Re-Loading `npc_option` Table!" );
866 objmgr
.LoadNpcOptions();
867 SendGlobalSysMessage("DB table `npc_option` reloaded.");
871 bool ChatHandler::HandleReloadNpcGossipCommand(const char*)
873 sLog
.outString( "Re-Loading `npc_gossip` Table!" );
874 objmgr
.LoadNpcTextId();
875 SendGlobalSysMessage("DB table `npc_gossip` reloaded.");
879 bool ChatHandler::HandleReloadNpcTrainerCommand(const char*)
881 sLog
.outString( "Re-Loading `npc_trainer` Table!" );
882 objmgr
.LoadTrainerSpell();
883 SendGlobalSysMessage("DB table `npc_trainer` reloaded.");
887 bool ChatHandler::HandleReloadNpcVendorCommand(const char*)
889 sLog
.outString( "Re-Loading `npc_vendor` Table!" );
890 objmgr
.LoadVendors();
891 SendGlobalSysMessage("DB table `npc_vendor` reloaded.");
895 bool ChatHandler::HandleReloadPointsOfInterestCommand(const char*)
897 sLog
.outString( "Re-Loading `points_of_interest` Table!" );
898 objmgr
.LoadPointsOfInterest();
899 SendGlobalSysMessage("DB table `points_of_interest` reloaded.");
903 bool ChatHandler::HandleReloadReservedNameCommand(const char*)
905 sLog
.outString( "Loading ReservedNames... (`reserved_name`)" );
906 objmgr
.LoadReservedPlayersNames();
907 SendGlobalSysMessage("DB table `reserved_name` (player reserved names) reloaded.");
911 bool ChatHandler::HandleReloadSkillDiscoveryTemplateCommand(const char* /*args*/)
913 sLog
.outString( "Re-Loading Skill Discovery Table..." );
914 LoadSkillDiscoveryTable();
915 SendGlobalSysMessage("DB table `skill_discovery_template` (recipes discovered at crafting) reloaded.");
919 bool ChatHandler::HandleReloadSkillExtraItemTemplateCommand(const char* /*args*/)
921 sLog
.outString( "Re-Loading Skill Extra Item Table..." );
922 LoadSkillExtraItemTable();
923 SendGlobalSysMessage("DB table `skill_extra_item_template` (extra item creation when crafting) reloaded.");
927 bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(const char* /*args*/)
929 sLog
.outString( "Re-Loading Skill Fishing base level requirements..." );
930 objmgr
.LoadFishingBaseSkillLevel();
931 SendGlobalSysMessage("DB table `skill_fishing_base_level` (fishing base level for zone/subzone) reloaded.");
935 bool ChatHandler::HandleReloadSpellAffectCommand(const char*)
937 sLog
.outString( "Re-Loading SpellAffect definitions..." );
938 spellmgr
.LoadSpellAffects();
939 SendGlobalSysMessage("DB table `spell_affect` (spell mods apply requirements) reloaded.");
943 bool ChatHandler::HandleReloadSpellAreaCommand(const char*)
945 sLog
.outString( "Re-Loading SpellArea Data..." );
946 spellmgr
.LoadSpellAreas();
947 SendGlobalSysMessage("DB table `spell_area` (spell dependences from area/quest/auras state) reloaded.");
951 bool ChatHandler::HandleReloadSpellChainCommand(const char*)
953 sLog
.outString( "Re-Loading Spell Chain Data... " );
954 spellmgr
.LoadSpellChains();
955 SendGlobalSysMessage("DB table `spell_chain` (spell ranks) reloaded.");
959 bool ChatHandler::HandleReloadSpellElixirCommand(const char*)
961 sLog
.outString( "Re-Loading Spell Elixir types..." );
962 spellmgr
.LoadSpellElixirs();
963 SendGlobalSysMessage("DB table `spell_elixir` (spell elixir types) reloaded.");
967 bool ChatHandler::HandleReloadSpellLearnSpellCommand(const char*)
969 sLog
.outString( "Re-Loading Spell Learn Spells..." );
970 spellmgr
.LoadSpellLearnSpells();
971 SendGlobalSysMessage("DB table `spell_learn_spell` reloaded.");
975 bool ChatHandler::HandleReloadSpellProcEventCommand(const char*)
977 sLog
.outString( "Re-Loading Spell Proc Event conditions..." );
978 spellmgr
.LoadSpellProcEvents();
979 SendGlobalSysMessage("DB table `spell_proc_event` (spell proc trigger requirements) reloaded.");
983 bool ChatHandler::HandleReloadSpellBonusesCommand(const char*)
985 sLog
.outString( "Re-Loading Spell Bonus Data..." );
986 spellmgr
.LoadSpellBonusess();
987 SendGlobalSysMessage("DB table `spell_bonus_data` (spell damage/healing coefficients) reloaded.");
991 bool ChatHandler::HandleReloadSpellScriptTargetCommand(const char*)
993 sLog
.outString( "Re-Loading SpellsScriptTarget..." );
994 spellmgr
.LoadSpellScriptTarget();
995 SendGlobalSysMessage("DB table `spell_script_target` (spell targets selection in case specific creature/GO requirements) reloaded.");
999 bool ChatHandler::HandleReloadSpellTargetPositionCommand(const char*)
1001 sLog
.outString( "Re-Loading Spell target coordinates..." );
1002 spellmgr
.LoadSpellTargetPositions();
1003 SendGlobalSysMessage("DB table `spell_target_position` (destination coordinates for spell targets) reloaded.");
1007 bool ChatHandler::HandleReloadSpellThreatsCommand(const char*)
1009 sLog
.outString( "Re-Loading Aggro Spells Definitions...");
1010 spellmgr
.LoadSpellThreats();
1011 SendGlobalSysMessage("DB table `spell_threat` (spell aggro definitions) reloaded.");
1015 bool ChatHandler::HandleReloadSpellPetAurasCommand(const char*)
1017 sLog
.outString( "Re-Loading Spell pet auras...");
1018 spellmgr
.LoadSpellPetAuras();
1019 SendGlobalSysMessage("DB table `spell_pet_auras` reloaded.");
1023 bool ChatHandler::HandleReloadPageTextsCommand(const char*)
1025 sLog
.outString( "Re-Loading Page Texts..." );
1026 objmgr
.LoadPageTexts();
1027 SendGlobalSysMessage("DB table `page_texts` reloaded.");
1031 bool ChatHandler::HandleReloadItemEnchantementsCommand(const char*)
1033 sLog
.outString( "Re-Loading Item Random Enchantments Table..." );
1034 LoadRandomEnchantmentsTable();
1035 SendGlobalSysMessage("DB table `item_enchantment_template` reloaded.");
1039 bool ChatHandler::HandleReloadGameObjectScriptsCommand(const char* arg
)
1041 if(sWorld
.IsScriptScheduled())
1043 SendSysMessage("DB scripts used currently, please attempt reload later.");
1044 SetSentErrorMessage(true);
1049 sLog
.outString( "Re-Loading Scripts from `gameobject_scripts`...");
1051 objmgr
.LoadGameObjectScripts();
1054 SendGlobalSysMessage("DB table `gameobject_scripts` reloaded.");
1059 bool ChatHandler::HandleReloadEventScriptsCommand(const char* arg
)
1061 if(sWorld
.IsScriptScheduled())
1063 SendSysMessage("DB scripts used currently, please attempt reload later.");
1064 SetSentErrorMessage(true);
1069 sLog
.outString( "Re-Loading Scripts from `event_scripts`...");
1071 objmgr
.LoadEventScripts();
1074 SendGlobalSysMessage("DB table `event_scripts` reloaded.");
1079 bool ChatHandler::HandleReloadQuestEndScriptsCommand(const char* arg
)
1081 if(sWorld
.IsScriptScheduled())
1083 SendSysMessage("DB scripts used currently, please attempt reload later.");
1084 SetSentErrorMessage(true);
1089 sLog
.outString( "Re-Loading Scripts from `quest_end_scripts`...");
1091 objmgr
.LoadQuestEndScripts();
1094 SendGlobalSysMessage("DB table `quest_end_scripts` reloaded.");
1099 bool ChatHandler::HandleReloadQuestStartScriptsCommand(const char* arg
)
1101 if(sWorld
.IsScriptScheduled())
1103 SendSysMessage("DB scripts used currently, please attempt reload later.");
1104 SetSentErrorMessage(true);
1109 sLog
.outString( "Re-Loading Scripts from `quest_start_scripts`...");
1111 objmgr
.LoadQuestStartScripts();
1114 SendGlobalSysMessage("DB table `quest_start_scripts` reloaded.");
1119 bool ChatHandler::HandleReloadSpellScriptsCommand(const char* arg
)
1121 if(sWorld
.IsScriptScheduled())
1123 SendSysMessage("DB scripts used currently, please attempt reload later.");
1124 SetSentErrorMessage(true);
1129 sLog
.outString( "Re-Loading Scripts from `spell_scripts`...");
1131 objmgr
.LoadSpellScripts();
1134 SendGlobalSysMessage("DB table `spell_scripts` reloaded.");
1139 bool ChatHandler::HandleReloadDbScriptStringCommand(const char* arg
)
1141 sLog
.outString( "Re-Loading Script strings from `db_script_string`...");
1142 objmgr
.LoadDbScriptStrings();
1143 SendGlobalSysMessage("DB table `db_script_string` reloaded.");
1147 bool ChatHandler::HandleReloadGameGraveyardZoneCommand(const char* /*arg*/)
1149 sLog
.outString( "Re-Loading Graveyard-zone links...");
1151 objmgr
.LoadGraveyardZones();
1153 SendGlobalSysMessage("DB table `game_graveyard_zone` reloaded.");
1158 bool ChatHandler::HandleReloadGameTeleCommand(const char* /*arg*/)
1160 sLog
.outString( "Re-Loading Game Tele coordinates...");
1162 objmgr
.LoadGameTele();
1164 SendGlobalSysMessage("DB table `game_tele` reloaded.");
1169 bool ChatHandler::HandleReloadLocalesAchievementRewardCommand(const char*)
1171 sLog
.outString( "Re-Loading Locales Achievement Reward Data..." );
1172 achievementmgr
.LoadRewardLocales();
1173 SendGlobalSysMessage("DB table `locales_achievement_reward` reloaded.");
1177 bool ChatHandler::HandleReloadLocalesCreatureCommand(const char* /*arg*/)
1179 sLog
.outString( "Re-Loading Locales Creature ...");
1180 objmgr
.LoadCreatureLocales();
1181 SendGlobalSysMessage("DB table `locales_creature` reloaded.");
1185 bool ChatHandler::HandleReloadLocalesGameobjectCommand(const char* /*arg*/)
1187 sLog
.outString( "Re-Loading Locales Gameobject ... ");
1188 objmgr
.LoadGameObjectLocales();
1189 SendGlobalSysMessage("DB table `locales_gameobject` reloaded.");
1193 bool ChatHandler::HandleReloadLocalesItemCommand(const char* /*arg*/)
1195 sLog
.outString( "Re-Loading Locales Item ... ");
1196 objmgr
.LoadItemLocales();
1197 SendGlobalSysMessage("DB table `locales_item` reloaded.");
1201 bool ChatHandler::HandleReloadLocalesNpcTextCommand(const char* /*arg*/)
1203 sLog
.outString( "Re-Loading Locales NPC Text ... ");
1204 objmgr
.LoadNpcTextLocales();
1205 SendGlobalSysMessage("DB table `locales_npc_text` reloaded.");
1209 bool ChatHandler::HandleReloadLocalesPageTextCommand(const char* /*arg*/)
1211 sLog
.outString( "Re-Loading Locales Page Text ... ");
1212 objmgr
.LoadPageTextLocales();
1213 SendGlobalSysMessage("DB table `locales_page_text` reloaded.");
1217 bool ChatHandler::HandleReloadLocalesPointsOfInterestCommand(const char* /*arg*/)
1219 sLog
.outString( "Re-Loading Locales Points Of Interest ... ");
1220 objmgr
.LoadPointOfInterestLocales();
1221 SendGlobalSysMessage("DB table `locales_points_of_interest` reloaded.");
1225 bool ChatHandler::HandleReloadLocalesQuestCommand(const char* /*arg*/)
1227 sLog
.outString( "Re-Loading Locales Quest ... ");
1228 objmgr
.LoadQuestLocales();
1229 SendGlobalSysMessage("DB table `locales_quest` reloaded.");
1233 bool ChatHandler::HandleLoadScriptsCommand(const char* args
)
1235 if(!LoadScriptingModule(args
)) return true;
1237 sWorld
.SendWorldText(LANG_SCRIPTS_RELOADED
);
1241 bool ChatHandler::HandleAccountSetGmLevelCommand(const char* args
)
1243 char* arg1
= strtok((char*)args
, " ");
1247 /// must be NULL if targeted syntax and must be not nULL if not targeted
1248 char* arg2
= strtok(NULL
, " ");
1250 std::string targetAccountName
;
1251 uint32 targetAccountId
= 0;
1253 /// only target player different from self allowed (if targetPlayer!=NULL then not console)
1254 Player
* targetPlayer
= getSelectedPlayer();
1255 if(targetPlayer
&& m_session
->GetPlayer()!=targetPlayer
)
1257 /// wrong command syntax or unexpected targeting
1261 /// security level expected in arg2 after this if.
1264 targetAccountId
= targetPlayer
->GetSession()->GetAccountId();
1265 accmgr
.GetName(targetAccountId
, targetAccountName
);
1269 /// wrong command syntax (second arg expected)
1273 targetAccountName
= arg1
;
1274 if(!AccountMgr::normilizeString(targetAccountName
))
1276 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,targetAccountName
.c_str());
1277 SetSentErrorMessage(true);
1281 targetAccountId
= accmgr
.GetId(targetAccountName
);
1282 if(!targetAccountId
)
1284 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,targetAccountName
.c_str());
1285 SetSentErrorMessage(true);
1290 int32 gm
= (int32
)atoi(arg2
);
1291 if ( gm
< SEC_PLAYER
|| gm
> SEC_ADMINISTRATOR
)
1293 SendSysMessage(LANG_BAD_VALUE
);
1294 SetSentErrorMessage(true);
1298 /// can set security level only for target with less security and to less security that we have
1299 /// This will reject self apply by specify account name
1300 if(HasLowerSecurityAccount(NULL
,targetAccountId
,true))
1303 /// account can't set security to same or grater level, need more power GM or console
1304 AccountTypes plSecurity
= m_session
? m_session
->GetSecurity() : SEC_CONSOLE
;
1305 if (AccountTypes(gm
) >= plSecurity
)
1307 SendSysMessage(LANG_YOURS_SECURITY_IS_LOW
);
1308 SetSentErrorMessage(true);
1312 // This will prevent self apply by self target or no target
1313 if(targetPlayer
&& m_session
->GetPlayer()!=targetPlayer
)
1315 ChatHandler(targetPlayer
).PSendSysMessage(LANG_YOURS_SECURITY_CHANGED
,GetNameLink().c_str(), gm
);
1316 targetPlayer
->GetSession()->SetSecurity(AccountTypes(gm
));
1319 PSendSysMessage(LANG_YOU_CHANGE_SECURITY
, targetAccountName
.c_str(), gm
);
1320 loginDatabase
.PExecute("UPDATE account SET gmlevel = '%i' WHERE id = '%u'", gm
, targetAccountId
);
1325 /// Set password for account
1326 bool ChatHandler::HandleAccountSetPasswordCommand(const char* args
)
1331 ///- Get the command line arguments
1332 char *szAccount
= strtok ((char*)args
," ");
1333 char *szPassword1
= strtok (NULL
," ");
1334 char *szPassword2
= strtok (NULL
," ");
1336 if (!szAccount
||!szPassword1
|| !szPassword2
)
1339 std::string account_name
= szAccount
;
1340 if(!AccountMgr::normilizeString(account_name
))
1342 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
1343 SetSentErrorMessage(true);
1347 uint32 targetAccountId
= accmgr
.GetId(account_name
);
1348 if (!targetAccountId
)
1350 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
1351 SetSentErrorMessage(true);
1355 /// can set password only for target with less security
1356 /// This is also reject self apply in fact
1357 if(HasLowerSecurityAccount (NULL
,targetAccountId
,true))
1360 if (strcmp(szPassword1
,szPassword2
))
1362 SendSysMessage (LANG_NEW_PASSWORDS_NOT_MATCH
);
1363 SetSentErrorMessage (true);
1367 AccountOpResult result
= accmgr
.ChangePassword(targetAccountId
, szPassword1
);
1372 SendSysMessage(LANG_COMMAND_PASSWORD
);
1374 case AOR_NAME_NOT_EXIST
:
1375 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
1376 SetSentErrorMessage(true);
1378 case AOR_PASS_TOO_LONG
:
1379 SendSysMessage(LANG_PASSWORD_TOO_LONG
);
1380 SetSentErrorMessage(true);
1383 SendSysMessage(LANG_COMMAND_NOTCHANGEPASSWORD
);
1384 SetSentErrorMessage(true);
1391 bool ChatHandler::HandleMaxSkillCommand(const char* /*args*/)
1393 Player
* SelectedPlayer
= getSelectedPlayer();
1396 SendSysMessage(LANG_NO_CHAR_SELECTED
);
1397 SetSentErrorMessage(true);
1401 // each skills that have max skill value dependent from level seted to current level max skill value
1402 SelectedPlayer
->UpdateSkillsToMaxSkillsForLevel();
1406 bool ChatHandler::HandleSetSkillCommand(const char* args
)
1408 // number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r
1409 char* skill_p
= extractKeyFromLink((char*)args
,"Hskill");
1413 char *level_p
= strtok (NULL
, " ");
1418 char *max_p
= strtok (NULL
, " ");
1420 int32 skill
= atoi(skill_p
);
1423 PSendSysMessage(LANG_INVALID_SKILL_ID
, skill
);
1424 SetSentErrorMessage(true);
1428 int32 level
= atol (level_p
);
1430 Player
* target
= getSelectedPlayer();
1433 SendSysMessage(LANG_NO_CHAR_SELECTED
);
1434 SetSentErrorMessage(true);
1438 SkillLineEntry
const* sl
= sSkillLineStore
.LookupEntry(skill
);
1441 PSendSysMessage(LANG_INVALID_SKILL_ID
, skill
);
1442 SetSentErrorMessage(true);
1446 std::string tNameLink
= GetNameLink(target
);
1448 if(!target
->GetSkillValue(skill
))
1450 PSendSysMessage(LANG_SET_SKILL_ERROR
, tNameLink
.c_str(), skill
, sl
->name
[0]);
1451 SetSentErrorMessage(true);
1455 int32 max
= max_p
? atol (max_p
) : target
->GetPureMaxSkillValue(skill
);
1457 if( level
<= 0 || level
> max
|| max
<= 0 )
1460 target
->SetSkill(skill
, level
, max
);
1461 PSendSysMessage(LANG_SET_SKILL
, skill
, sl
->name
[0], tNameLink
.c_str(), level
, max
);
1466 bool ChatHandler::HandleUnLearnCommand(const char* args
)
1471 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
1472 uint32 spell_id
= extractSpellIdFromLink((char*)args
);
1476 char const* allStr
= strtok(NULL
," ");
1477 bool allRanks
= allStr
? (strncmp(allStr
, "all", strlen(allStr
)) == 0) : false;
1479 Player
* target
= getSelectedPlayer();
1482 SendSysMessage(LANG_NO_CHAR_SELECTED
);
1483 SetSentErrorMessage(true);
1488 spell_id
= spellmgr
.GetFirstSpellInChain (spell_id
);
1490 if (target
->HasSpell(spell_id
))
1491 target
->removeSpell(spell_id
,false,!allRanks
);
1493 SendSysMessage(LANG_FORGET_SPELL
);
1498 bool ChatHandler::HandleCooldownCommand(const char* args
)
1500 Player
* target
= getSelectedPlayer();
1503 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
1504 SetSentErrorMessage(true);
1508 std::string tNameLink
= GetNameLink(target
);
1512 target
->RemoveAllSpellCooldown();
1513 PSendSysMessage(LANG_REMOVEALL_COOLDOWN
, tNameLink
.c_str());
1517 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
1518 uint32 spell_id
= extractSpellIdFromLink((char*)args
);
1522 if(!sSpellStore
.LookupEntry(spell_id
))
1524 PSendSysMessage(LANG_UNKNOWN_SPELL
, target
==m_session
->GetPlayer() ? GetMangosString(LANG_YOU
) : tNameLink
.c_str());
1525 SetSentErrorMessage(true);
1529 WorldPacket
data( SMSG_CLEAR_COOLDOWN
, (4+8) );
1530 data
<< uint32(spell_id
);
1531 data
<< uint64(target
->GetGUID());
1532 target
->GetSession()->SendPacket(&data
);
1533 target
->RemoveSpellCooldown(spell_id
);
1534 PSendSysMessage(LANG_REMOVE_COOLDOWN
, spell_id
, target
==m_session
->GetPlayer() ? GetMangosString(LANG_YOU
) : tNameLink
.c_str());
1539 bool ChatHandler::HandleLearnAllCommand(const char* /*args*/)
1541 static const char *allSpellList
[] =
1924 //"9036", problems with ghost state
1933 //"6718", phasing stealth, annoying for learn all case.
2146 while(strcmp(allSpellList
[loop
], "0"))
2148 uint32 spell
= atol((char*)allSpellList
[loop
++]);
2150 if (m_session
->GetPlayer()->HasSpell(spell
))
2153 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
2154 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
2156 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
2160 m_session
->GetPlayer()->learnSpell(spell
,false);
2163 SendSysMessage(LANG_COMMAND_LEARN_MANY_SPELLS
);
2168 bool ChatHandler::HandleLearnAllGMCommand(const char* /*args*/)
2170 static const char *gmSpellList
[] =
2172 "24347", // Become A Fish, No Breath Bar
2173 "35132", // Visual Boom
2174 "38488", // Attack 4000-8000 AOE
2175 "38795", // Attack 2000 AOE + Slow Down 90%
2176 "15712", // Attack 200
2177 "1852", // GM Spell Silence
2180 "29878", // Kill My Self
2181 "26644", // More Kill
2183 "28550", //Invisible 24
2184 "23452", //Invisible + Target
2188 uint16 gmSpellIter
= 0;
2189 while( strcmp(gmSpellList
[gmSpellIter
], "0") )
2191 uint32 spell
= atol((char*)gmSpellList
[gmSpellIter
++]);
2193 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
2194 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
2196 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
2200 m_session
->GetPlayer()->learnSpell(spell
,false);
2203 SendSysMessage(LANG_LEARNING_GM_SKILLS
);
2207 bool ChatHandler::HandleLearnAllMyClassCommand(const char* /*args*/)
2209 HandleLearnAllMySpellsCommand("");
2210 HandleLearnAllMyTalentsCommand("");
2214 bool ChatHandler::HandleLearnAllMySpellsCommand(const char* /*args*/)
2216 ChrClassesEntry
const* clsEntry
= sChrClassesStore
.LookupEntry(m_session
->GetPlayer()->getClass());
2219 uint32 family
= clsEntry
->spellfamily
;
2221 for (uint32 i
= 0; i
< sSpellStore
.GetNumRows(); ++i
)
2223 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(i
);
2227 // skip server-side/triggered spells
2228 if(spellInfo
->spellLevel
==0)
2231 // skip wrong class/race skills
2232 if(!m_session
->GetPlayer()->IsSpellFitByClassAndRace(spellInfo
->Id
))
2235 // skip other spell families
2236 if( spellInfo
->SpellFamilyName
!= family
)
2239 // skip spells with first rank learned as talent (and all talents then also)
2240 uint32 first_rank
= spellmgr
.GetFirstSpellInChain(spellInfo
->Id
);
2241 if(GetTalentSpellCost(first_rank
) > 0 )
2244 // skip broken spells
2245 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer(),false))
2248 m_session
->GetPlayer()->learnSpell(i
,false);
2251 SendSysMessage(LANG_COMMAND_LEARN_CLASS_SPELLS
);
2255 bool ChatHandler::HandleLearnAllMyTalentsCommand(const char* /*args*/)
2257 Player
* player
= m_session
->GetPlayer();
2258 uint32 classMask
= player
->getClassMask();
2260 for (uint32 i
= 0; i
< sTalentStore
.GetNumRows(); ++i
)
2262 TalentEntry
const *talentInfo
= sTalentStore
.LookupEntry(i
);
2266 TalentTabEntry
const *talentTabInfo
= sTalentTabStore
.LookupEntry( talentInfo
->TalentTab
);
2270 if( (classMask
& talentTabInfo
->ClassMask
) == 0 )
2273 // search highest talent rank
2276 for(int rank
= MAX_TALENT_RANK
-1; rank
>= 0; --rank
)
2278 if(talentInfo
->RankID
[rank
]!=0)
2280 spellid
= talentInfo
->RankID
[rank
];
2285 if(!spellid
) // ??? none spells in talent
2288 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spellid
);
2289 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer(),false))
2292 // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree)
2293 player
->learnSpellHighRank(spellid
);
2296 SendSysMessage(LANG_COMMAND_LEARN_CLASS_TALENTS
);
2300 bool ChatHandler::HandleLearnAllMyPetTalentsCommand(const char* /*args*/)
2302 Player
* player
= m_session
->GetPlayer();
2304 Pet
* pet
= player
->GetPet();
2307 SendSysMessage(LANG_NO_PET_FOUND
);
2308 SetSentErrorMessage(true);
2312 CreatureInfo
const *ci
= pet
->GetCreatureInfo();
2315 SendSysMessage(LANG_WRONG_PET_TYPE
);
2316 SetSentErrorMessage(true);
2320 CreatureFamilyEntry
const *pet_family
= sCreatureFamilyStore
.LookupEntry(ci
->family
);
2323 SendSysMessage(LANG_WRONG_PET_TYPE
);
2324 SetSentErrorMessage(true);
2328 if(pet_family
->petTalentType
< 0) // not hunter pet
2330 SendSysMessage(LANG_WRONG_PET_TYPE
);
2331 SetSentErrorMessage(true);
2335 for (uint32 i
= 0; i
< sTalentStore
.GetNumRows(); ++i
)
2337 TalentEntry
const *talentInfo
= sTalentStore
.LookupEntry(i
);
2341 TalentTabEntry
const *talentTabInfo
= sTalentTabStore
.LookupEntry( talentInfo
->TalentTab
);
2345 // prevent learn talent for different family (cheating)
2346 if(((1 << pet_family
->petTalentType
) & talentTabInfo
->petTalentMask
)==0)
2349 // search highest talent rank
2352 for(int rank
= MAX_TALENT_RANK
-1; rank
>= 0; --rank
)
2354 if(talentInfo
->RankID
[rank
]!=0)
2356 spellid
= talentInfo
->RankID
[rank
];
2361 if(!spellid
) // ??? none spells in talent
2364 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spellid
);
2365 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer(),false))
2368 // learn highest rank of talent and learn all non-talent spell ranks (recursive by tree)
2369 pet
->learnSpellHighRank(spellid
);
2372 SendSysMessage(LANG_COMMAND_LEARN_PET_TALENTS
);
2376 bool ChatHandler::HandleLearnAllLangCommand(const char* /*args*/)
2378 // skipping UNIVERSAL language (0)
2379 for(int i
= 1; i
< LANGUAGES_COUNT
; ++i
)
2380 m_session
->GetPlayer()->learnSpell(lang_description
[i
].spell_id
,false);
2382 SendSysMessage(LANG_COMMAND_LEARN_ALL_LANG
);
2386 bool ChatHandler::HandleLearnAllDefaultCommand(const char* args
)
2388 Player
*player
= NULL
;
2391 std::string name
= extractPlayerNameFromLink((char*)args
);
2394 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
2395 SetSentErrorMessage(true);
2399 player
= objmgr
.GetPlayer(name
.c_str());
2402 player
= getSelectedPlayer();
2406 SendSysMessage(LANG_NO_CHAR_SELECTED
);
2407 SetSentErrorMessage(true);
2411 player
->learnDefaultSpells();
2412 player
->learnQuestRewardedSpells();
2414 PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST
,GetNameLink(player
).c_str());
2418 bool ChatHandler::HandleLearnCommand(const char* args
)
2420 Player
* targetPlayer
= getSelectedPlayer();
2424 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
2425 SetSentErrorMessage(true);
2429 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
2430 uint32 spell
= extractSpellIdFromLink((char*)args
);
2431 if(!spell
|| !sSpellStore
.LookupEntry(spell
))
2434 char const* allStr
= strtok(NULL
," ");
2435 bool allRanks
= allStr
? (strncmp(allStr
, "all", strlen(allStr
)) == 0) : false;
2437 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
2438 if(!spellInfo
|| !SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
2440 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
2441 SetSentErrorMessage(true);
2445 if (!allRanks
&& targetPlayer
->HasSpell(spell
))
2447 if(targetPlayer
== m_session
->GetPlayer())
2448 SendSysMessage(LANG_YOU_KNOWN_SPELL
);
2450 PSendSysMessage(LANG_TARGET_KNOWN_SPELL
,GetNameLink(targetPlayer
).c_str());
2451 SetSentErrorMessage(true);
2456 targetPlayer
->learnSpellHighRank(spell
);
2458 targetPlayer
->learnSpell(spell
,false);
2463 bool ChatHandler::HandleAddItemCommand(const char* args
)
2470 if(args
[0]=='[') // [name] manual form
2472 char* citemName
= citemName
= strtok((char*)args
, "]");
2474 if(citemName
&& citemName
[0])
2476 std::string itemName
= citemName
+1;
2477 WorldDatabase
.escape_string(itemName
);
2478 QueryResult
*result
= WorldDatabase
.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName
.c_str());
2481 PSendSysMessage(LANG_COMMAND_COULDNOTFIND
, citemName
+1);
2482 SetSentErrorMessage(true);
2485 itemId
= result
->Fetch()->GetUInt16();
2491 else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r
2493 char* cId
= extractKeyFromLink((char*)args
,"Hitem");
2499 char* ccount
= strtok(NULL
, " ");
2504 count
= strtol(ccount
, NULL
, 10);
2509 Player
* pl
= m_session
->GetPlayer();
2510 Player
* plTarget
= getSelectedPlayer();
2514 sLog
.outDetail(GetMangosString(LANG_ADDITEM
), itemId
, count
);
2516 ItemPrototype
const *pProto
= objmgr
.GetItemPrototype(itemId
);
2519 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID
, itemId
);
2520 SetSentErrorMessage(true);
2527 plTarget
->DestroyItemCount(itemId
, -count
, true, false);
2528 PSendSysMessage(LANG_REMOVEITEM
, itemId
, -count
, GetNameLink(plTarget
).c_str());
2533 uint32 noSpaceForCount
= 0;
2535 // check space and find places
2536 ItemPosCountVec dest
;
2537 uint8 msg
= plTarget
->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, itemId
, count
, &noSpaceForCount
);
2538 if( msg
!= EQUIP_ERR_OK
) // convert to possible store amount
2539 count
-= noSpaceForCount
;
2541 if( count
== 0 || dest
.empty()) // can't add any
2543 PSendSysMessage(LANG_ITEM_CANNOT_CREATE
, itemId
, noSpaceForCount
);
2544 SetSentErrorMessage(true);
2548 Item
* item
= plTarget
->StoreNewItem( dest
, itemId
, true, Item::GenerateItemRandomPropertyId(itemId
));
2550 // remove binding (let GM give it to another player later)
2552 for(ItemPosCountVec::const_iterator itr
= dest
.begin(); itr
!= dest
.end(); ++itr
)
2553 if(Item
* item1
= pl
->GetItemByPos(itr
->pos
))
2554 item1
->SetBinding( false );
2556 if(count
> 0 && item
)
2558 pl
->SendNewItem(item
,count
,false,true);
2560 plTarget
->SendNewItem(item
,count
,true,false);
2563 if(noSpaceForCount
> 0)
2564 PSendSysMessage(LANG_ITEM_CANNOT_CREATE
, itemId
, noSpaceForCount
);
2569 bool ChatHandler::HandleAddItemSetCommand(const char* args
)
2574 char* cId
= extractKeyFromLink((char*)args
,"Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r
2578 uint32 itemsetId
= atol(cId
);
2580 // prevent generation all items with itemset field value '0'
2583 PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND
,itemsetId
);
2584 SetSentErrorMessage(true);
2588 Player
* pl
= m_session
->GetPlayer();
2589 Player
* plTarget
= getSelectedPlayer();
2593 sLog
.outDetail(GetMangosString(LANG_ADDITEMSET
), itemsetId
);
2596 for (uint32 id
= 0; id
< sItemStorage
.MaxEntry
; id
++)
2598 ItemPrototype
const *pProto
= sItemStorage
.LookupEntry
<ItemPrototype
>(id
);
2602 if (pProto
->ItemSet
== itemsetId
)
2605 ItemPosCountVec dest
;
2606 uint8 msg
= plTarget
->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, pProto
->ItemId
, 1 );
2607 if (msg
== EQUIP_ERR_OK
)
2609 Item
* item
= plTarget
->StoreNewItem( dest
, pProto
->ItemId
, true);
2611 // remove binding (let GM give it to another player later)
2613 item
->SetBinding( false );
2615 pl
->SendNewItem(item
,1,false,true);
2617 plTarget
->SendNewItem(item
,1,true,false);
2621 pl
->SendEquipError( msg
, NULL
, NULL
);
2622 PSendSysMessage(LANG_ITEM_CANNOT_CREATE
, pProto
->ItemId
, 1);
2629 PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND
,itemsetId
);
2631 SetSentErrorMessage(true);
2638 bool ChatHandler::HandleListItemCommand(const char* args
)
2643 char* cId
= extractKeyFromLink((char*)args
,"Hitem");
2647 uint32 item_id
= atol(cId
);
2650 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID
, item_id
);
2651 SetSentErrorMessage(true);
2655 ItemPrototype
const* itemProto
= objmgr
.GetItemPrototype(item_id
);
2658 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID
, item_id
);
2659 SetSentErrorMessage(true);
2663 char* c_count
= strtok(NULL
, " ");
2664 int count
= c_count
? atol(c_count
) : 10;
2669 QueryResult
*result
;
2672 uint32 inv_count
= 0;
2673 result
=CharacterDatabase
.PQuery("SELECT COUNT(item_template) FROM character_inventory WHERE item_template='%u'",item_id
);
2676 inv_count
= (*result
)[0].GetUInt32();
2680 result
=CharacterDatabase
.PQuery(
2682 "SELECT ci.item, cibag.slot AS bag, ci.slot, ci.guid, characters.account,characters.name "
2683 "FROM character_inventory AS ci LEFT JOIN character_inventory AS cibag ON (cibag.item=ci.bag),characters "
2684 "WHERE ci.item_template='%u' AND ci.guid = characters.guid LIMIT %u ",
2685 item_id
,uint32(count
));
2691 Field
*fields
= result
->Fetch();
2692 uint32 item_guid
= fields
[0].GetUInt32();
2693 uint32 item_bag
= fields
[1].GetUInt32();
2694 uint32 item_slot
= fields
[2].GetUInt32();
2695 uint32 owner_guid
= fields
[3].GetUInt32();
2696 uint32 owner_acc
= fields
[4].GetUInt32();
2697 std::string owner_name
= fields
[5].GetCppString();
2699 char const* item_pos
= 0;
2700 if(Player::IsEquipmentPos(item_bag
,item_slot
))
2701 item_pos
= "[equipped]";
2702 else if(Player::IsInventoryPos(item_bag
,item_slot
))
2703 item_pos
= "[in inventory]";
2704 else if(Player::IsBankPos(item_bag
,item_slot
))
2705 item_pos
= "[in bank]";
2709 PSendSysMessage(LANG_ITEMLIST_SLOT
,
2710 item_guid
,owner_name
.c_str(),owner_guid
,owner_acc
,item_pos
);
2711 } while (result
->NextRow());
2713 int64 res_count
= result
->GetRowCount();
2717 if(count
> res_count
)
2724 uint32 mail_count
= 0;
2725 result
=CharacterDatabase
.PQuery("SELECT COUNT(item_template) FROM mail_items WHERE item_template='%u'", item_id
);
2728 mail_count
= (*result
)[0].GetUInt32();
2734 result
=CharacterDatabase
.PQuery(
2736 "SELECT mail_items.item_guid, mail.sender, mail.receiver, char_s.account, char_s.name, char_r.account, char_r.name "
2737 "FROM mail,mail_items,characters as char_s,characters as char_r "
2738 "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",
2739 item_id
,uint32(count
));
2748 Field
*fields
= result
->Fetch();
2749 uint32 item_guid
= fields
[0].GetUInt32();
2750 uint32 item_s
= fields
[1].GetUInt32();
2751 uint32 item_r
= fields
[2].GetUInt32();
2752 uint32 item_s_acc
= fields
[3].GetUInt32();
2753 std::string item_s_name
= fields
[4].GetCppString();
2754 uint32 item_r_acc
= fields
[5].GetUInt32();
2755 std::string item_r_name
= fields
[6].GetCppString();
2757 char const* item_pos
= "[in mail]";
2759 PSendSysMessage(LANG_ITEMLIST_MAIL
,
2760 item_guid
,item_s_name
.c_str(),item_s
,item_s_acc
,item_r_name
.c_str(),item_r
,item_r_acc
,item_pos
);
2761 } while (result
->NextRow());
2763 int64 res_count
= result
->GetRowCount();
2767 if(count
> res_count
)
2774 uint32 auc_count
= 0;
2775 result
=CharacterDatabase
.PQuery("SELECT COUNT(item_template) FROM auctionhouse WHERE item_template='%u'",item_id
);
2778 auc_count
= (*result
)[0].GetUInt32();
2784 result
=CharacterDatabase
.PQuery(
2786 "SELECT auctionhouse.itemguid, auctionhouse.itemowner, characters.account, characters.name "
2787 "FROM auctionhouse,characters WHERE auctionhouse.item_template='%u' AND characters.guid = auctionhouse.itemowner LIMIT %u",
2788 item_id
,uint32(count
));
2797 Field
*fields
= result
->Fetch();
2798 uint32 item_guid
= fields
[0].GetUInt32();
2799 uint32 owner
= fields
[1].GetUInt32();
2800 uint32 owner_acc
= fields
[2].GetUInt32();
2801 std::string owner_name
= fields
[3].GetCppString();
2803 char const* item_pos
= "[in auction]";
2805 PSendSysMessage(LANG_ITEMLIST_AUCTION
, item_guid
, owner_name
.c_str(), owner
, owner_acc
,item_pos
);
2806 } while (result
->NextRow());
2812 uint32 guild_count
= 0;
2813 result
=CharacterDatabase
.PQuery("SELECT COUNT(item_entry) FROM guild_bank_item WHERE item_entry='%u'",item_id
);
2816 guild_count
= (*result
)[0].GetUInt32();
2820 result
=CharacterDatabase
.PQuery(
2822 "SELECT gi.item_guid, gi.guildid, guild.name "
2823 "FROM guild_bank_item AS gi, guild WHERE gi.item_entry='%u' AND gi.guildid = guild.guildid LIMIT %u ",
2824 item_id
,uint32(count
));
2830 Field
*fields
= result
->Fetch();
2831 uint32 item_guid
= fields
[0].GetUInt32();
2832 uint32 guild_guid
= fields
[1].GetUInt32();
2833 std::string guild_name
= fields
[2].GetCppString();
2835 char const* item_pos
= "[in guild bank]";
2837 PSendSysMessage(LANG_ITEMLIST_GUILD
,item_guid
,guild_name
.c_str(),guild_guid
,item_pos
);
2838 } while (result
->NextRow());
2840 int64 res_count
= result
->GetRowCount();
2844 if(count
> res_count
)
2850 if(inv_count
+mail_count
+auc_count
+guild_count
== 0)
2852 SendSysMessage(LANG_COMMAND_NOITEMFOUND
);
2853 SetSentErrorMessage(true);
2857 PSendSysMessage(LANG_COMMAND_LISTITEMMESSAGE
,item_id
,inv_count
+mail_count
+auc_count
+guild_count
,inv_count
,mail_count
,auc_count
,guild_count
);
2862 bool ChatHandler::HandleListObjectCommand(const char* args
)
2867 // number or [name] Shift-click form |color|Hgameobject_entry:go_id|h[name]|h|r
2868 char* cId
= extractKeyFromLink((char*)args
,"Hgameobject_entry");
2872 uint32 go_id
= atol(cId
);
2875 PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID
, go_id
);
2876 SetSentErrorMessage(true);
2880 GameObjectInfo
const * gInfo
= objmgr
.GetGameObjectInfo(go_id
);
2883 PSendSysMessage(LANG_COMMAND_LISTOBJINVALIDID
, go_id
);
2884 SetSentErrorMessage(true);
2888 char* c_count
= strtok(NULL
, " ");
2889 int count
= c_count
? atol(c_count
) : 10;
2894 QueryResult
*result
;
2896 uint32 obj_count
= 0;
2897 result
=WorldDatabase
.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'",go_id
);
2900 obj_count
= (*result
)[0].GetUInt32();
2906 Player
* pl
= m_session
->GetPlayer();
2907 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",
2908 pl
->GetPositionX(), pl
->GetPositionY(), pl
->GetPositionZ(),go_id
,uint32(count
));
2911 result
= WorldDatabase
.PQuery("SELECT guid, position_x, position_y, position_z, map FROM gameobject WHERE id = '%u' LIMIT %u",
2912 go_id
,uint32(count
));
2918 Field
*fields
= result
->Fetch();
2919 uint32 guid
= fields
[0].GetUInt32();
2920 float x
= fields
[1].GetFloat();
2921 float y
= fields
[2].GetFloat();
2922 float z
= fields
[3].GetFloat();
2923 int mapid
= fields
[4].GetUInt16();
2926 PSendSysMessage(LANG_GO_LIST_CHAT
, guid
, guid
, gInfo
->name
, x
, y
, z
, mapid
);
2928 PSendSysMessage(LANG_GO_LIST_CONSOLE
, guid
, gInfo
->name
, x
, y
, z
, mapid
);
2929 } while (result
->NextRow());
2934 PSendSysMessage(LANG_COMMAND_LISTOBJMESSAGE
,go_id
,obj_count
);
2938 bool ChatHandler::HandleListCreatureCommand(const char* args
)
2943 // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
2944 char* cId
= extractKeyFromLink((char*)args
,"Hcreature_entry");
2948 uint32 cr_id
= atol(cId
);
2951 PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID
, cr_id
);
2952 SetSentErrorMessage(true);
2956 CreatureInfo
const* cInfo
= objmgr
.GetCreatureTemplate(cr_id
);
2959 PSendSysMessage(LANG_COMMAND_INVALIDCREATUREID
, cr_id
);
2960 SetSentErrorMessage(true);
2964 char* c_count
= strtok(NULL
, " ");
2965 int count
= c_count
? atol(c_count
) : 10;
2970 QueryResult
*result
;
2972 uint32 cr_count
= 0;
2973 result
=WorldDatabase
.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'",cr_id
);
2976 cr_count
= (*result
)[0].GetUInt32();
2982 Player
* pl
= m_session
->GetPlayer();
2983 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",
2984 pl
->GetPositionX(), pl
->GetPositionY(), pl
->GetPositionZ(), cr_id
,uint32(count
));
2987 result
= WorldDatabase
.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u",
2988 cr_id
,uint32(count
));
2994 Field
*fields
= result
->Fetch();
2995 uint32 guid
= fields
[0].GetUInt32();
2996 float x
= fields
[1].GetFloat();
2997 float y
= fields
[2].GetFloat();
2998 float z
= fields
[3].GetFloat();
2999 int mapid
= fields
[4].GetUInt16();
3002 PSendSysMessage(LANG_CREATURE_LIST_CHAT
, guid
, guid
, cInfo
->Name
, x
, y
, z
, mapid
);
3004 PSendSysMessage(LANG_CREATURE_LIST_CONSOLE
, guid
, cInfo
->Name
, x
, y
, z
, mapid
);
3005 } while (result
->NextRow());
3010 PSendSysMessage(LANG_COMMAND_LISTCREATUREMESSAGE
,cr_id
,cr_count
);
3014 bool ChatHandler::HandleLookupItemCommand(const char* args
)
3019 std::string namepart
= args
;
3020 std::wstring wnamepart
;
3022 // converting string that we try to find to lower case
3023 if(!Utf8toWStr(namepart
,wnamepart
))
3026 wstrToLower(wnamepart
);
3030 // Search in `item_template`
3031 for (uint32 id
= 0; id
< sItemStorage
.MaxEntry
; id
++)
3033 ItemPrototype
const *pProto
= sItemStorage
.LookupEntry
<ItemPrototype
>(id
);
3037 int loc_idx
= m_session
? m_session
->GetSessionDbLocaleIndex() : objmgr
.GetDBCLocaleIndex();
3040 ItemLocale
const *il
= objmgr
.GetItemLocale(pProto
->ItemId
);
3043 if (il
->Name
.size() > loc_idx
&& !il
->Name
[loc_idx
].empty())
3045 std::string name
= il
->Name
[loc_idx
];
3047 if (Utf8FitTo(name
, wnamepart
))
3050 PSendSysMessage(LANG_ITEM_LIST_CHAT
, id
, id
, name
.c_str());
3052 PSendSysMessage(LANG_ITEM_LIST_CONSOLE
, id
, name
.c_str());
3060 std::string name
= pProto
->Name1
;
3064 if (Utf8FitTo(name
, wnamepart
))
3067 PSendSysMessage(LANG_ITEM_LIST_CHAT
, id
, id
, name
.c_str());
3069 PSendSysMessage(LANG_ITEM_LIST_CONSOLE
, id
, name
.c_str());
3075 SendSysMessage(LANG_COMMAND_NOITEMFOUND
);
3080 bool ChatHandler::HandleLookupItemSetCommand(const char* args
)
3085 std::string namepart
= args
;
3086 std::wstring wnamepart
;
3088 if(!Utf8toWStr(namepart
,wnamepart
))
3091 // converting string that we try to find to lower case
3092 wstrToLower( wnamepart
);
3094 uint32 counter
= 0; // Counter for figure out that we found smth.
3096 // Search in ItemSet.dbc
3097 for (uint32 id
= 0; id
< sItemSetStore
.GetNumRows(); id
++)
3099 ItemSetEntry
const *set
= sItemSetStore
.LookupEntry(id
);
3102 int loc
= m_session
? m_session
->GetSessionDbcLocale() : sWorld
.GetDefaultDbcLocale();
3103 std::string name
= set
->name
[loc
];
3107 if (!Utf8FitTo(name
, wnamepart
))
3110 for(; loc
< MAX_LOCALE
; ++loc
)
3112 if(m_session
&& loc
==m_session
->GetSessionDbcLocale())
3115 name
= set
->name
[loc
];
3119 if (Utf8FitTo(name
, wnamepart
))
3124 if(loc
< MAX_LOCALE
)
3126 // send item set in "id - [namedlink locale]" format
3128 PSendSysMessage(LANG_ITEMSET_LIST_CHAT
,id
,id
,name
.c_str(),localeNames
[loc
]);
3130 PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE
,id
,name
.c_str(),localeNames
[loc
]);
3135 if (counter
== 0) // if counter == 0 then we found nth
3136 SendSysMessage(LANG_COMMAND_NOITEMSETFOUND
);
3140 bool ChatHandler::HandleLookupSkillCommand(const char* args
)
3145 // can be NULL in console call
3146 Player
* target
= getSelectedPlayer();
3148 std::string namepart
= args
;
3149 std::wstring wnamepart
;
3151 if(!Utf8toWStr(namepart
,wnamepart
))
3154 // converting string that we try to find to lower case
3155 wstrToLower( wnamepart
);
3157 uint32 counter
= 0; // Counter for figure out that we found smth.
3159 // Search in SkillLine.dbc
3160 for (uint32 id
= 0; id
< sSkillLineStore
.GetNumRows(); id
++)
3162 SkillLineEntry
const *skillInfo
= sSkillLineStore
.LookupEntry(id
);
3165 int loc
= m_session
? m_session
->GetSessionDbcLocale() : sWorld
.GetDefaultDbcLocale();
3166 std::string name
= skillInfo
->name
[loc
];
3170 if (!Utf8FitTo(name
, wnamepart
))
3173 for(; loc
< MAX_LOCALE
; ++loc
)
3175 if(m_session
&& loc
==m_session
->GetSessionDbcLocale())
3178 name
= skillInfo
->name
[loc
];
3182 if (Utf8FitTo(name
, wnamepart
))
3187 if(loc
< MAX_LOCALE
)
3189 char valStr
[50] = "";
3190 char const* knownStr
= "";
3191 if(target
&& target
->HasSkill(id
))
3193 knownStr
= GetMangosString(LANG_KNOWN
);
3194 uint32 curValue
= target
->GetPureSkillValue(id
);
3195 uint32 maxValue
= target
->GetPureMaxSkillValue(id
);
3196 uint32 permValue
= target
->GetSkillPermBonusValue(id
);
3197 uint32 tempValue
= target
->GetSkillTempBonusValue(id
);
3199 char const* valFormat
= GetMangosString(LANG_SKILL_VALUES
);
3200 snprintf(valStr
,50,valFormat
,curValue
,maxValue
,permValue
,tempValue
);
3203 // send skill in "id - [namedlink locale]" format
3205 PSendSysMessage(LANG_SKILL_LIST_CHAT
,id
,id
,name
.c_str(),localeNames
[loc
],knownStr
,valStr
);
3207 PSendSysMessage(LANG_SKILL_LIST_CONSOLE
,id
,name
.c_str(),localeNames
[loc
],knownStr
,valStr
);
3213 if (counter
== 0) // if counter == 0 then we found nth
3214 SendSysMessage(LANG_COMMAND_NOSKILLFOUND
);
3218 bool ChatHandler::HandleLookupSpellCommand(const char* args
)
3223 // can be NULL at console call
3224 Player
* target
= getSelectedPlayer();
3226 std::string namepart
= args
;
3227 std::wstring wnamepart
;
3229 if(!Utf8toWStr(namepart
,wnamepart
))
3232 // converting string that we try to find to lower case
3233 wstrToLower( wnamepart
);
3235 uint32 counter
= 0; // Counter for figure out that we found smth.
3237 // Search in Spell.dbc
3238 for (uint32 id
= 0; id
< sSpellStore
.GetNumRows(); id
++)
3240 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry(id
);
3243 int loc
= m_session
? m_session
->GetSessionDbcLocale() : sWorld
.GetDefaultDbcLocale();
3244 std::string name
= spellInfo
->SpellName
[loc
];
3248 if (!Utf8FitTo(name
, wnamepart
))
3251 for(; loc
< MAX_LOCALE
; ++loc
)
3253 if(m_session
&& loc
==m_session
->GetSessionDbcLocale())
3256 name
= spellInfo
->SpellName
[loc
];
3260 if (Utf8FitTo(name
, wnamepart
))
3265 if(loc
< MAX_LOCALE
)
3267 bool known
= target
&& target
->HasSpell(id
);
3268 bool learn
= (spellInfo
->Effect
[0] == SPELL_EFFECT_LEARN_SPELL
);
3270 uint32 talentCost
= GetTalentSpellCost(id
);
3272 bool talent
= (talentCost
> 0);
3273 bool passive
= IsPassiveSpell(id
);
3274 bool active
= target
&& target
->HasAura(id
);
3276 // unit32 used to prevent interpreting uint8 as char at output
3277 // find rank of learned spell for learning spell, or talent rank
3278 uint32 rank
= talentCost
? talentCost
: spellmgr
.GetSpellRank(learn
? spellInfo
->EffectTriggerSpell
[0] : id
);
3280 // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format
3281 std::ostringstream ss
;
3283 ss
<< id
<< " - |cffffffff|Hspell:" << id
<< "|h[" << name
;
3285 ss
<< id
<< " - " << name
;
3287 // include rank in link name
3289 ss
<< GetMangosString(LANG_SPELL_RANK
) << rank
;
3292 ss
<< " " << localeNames
[loc
] << "]|h|r";
3294 ss
<< " " << localeNames
[loc
];
3297 ss
<< GetMangosString(LANG_TALENT
);
3299 ss
<< GetMangosString(LANG_PASSIVE
);
3301 ss
<< GetMangosString(LANG_LEARN
);
3303 ss
<< GetMangosString(LANG_KNOWN
);
3305 ss
<< GetMangosString(LANG_ACTIVE
);
3307 SendSysMessage(ss
.str().c_str());
3313 if (counter
== 0) // if counter == 0 then we found nth
3314 SendSysMessage(LANG_COMMAND_NOSPELLFOUND
);
3318 bool ChatHandler::HandleLookupQuestCommand(const char* args
)
3323 // can be NULL at console call
3324 Player
* target
= getSelectedPlayer();
3326 std::string namepart
= args
;
3327 std::wstring wnamepart
;
3329 // converting string that we try to find to lower case
3330 if(!Utf8toWStr(namepart
,wnamepart
))
3333 wstrToLower(wnamepart
);
3335 uint32 counter
= 0 ;
3337 ObjectMgr::QuestMap
const& qTemplates
= objmgr
.GetQuestTemplates();
3338 for (ObjectMgr::QuestMap::const_iterator iter
= qTemplates
.begin(); iter
!= qTemplates
.end(); ++iter
)
3340 Quest
* qinfo
= iter
->second
;
3342 int loc_idx
= m_session
? m_session
->GetSessionDbLocaleIndex() : objmgr
.GetDBCLocaleIndex();
3345 QuestLocale
const *il
= objmgr
.GetQuestLocale(qinfo
->GetQuestId());
3348 if (il
->Title
.size() > loc_idx
&& !il
->Title
[loc_idx
].empty())
3350 std::string title
= il
->Title
[loc_idx
];
3352 if (Utf8FitTo(title
, wnamepart
))
3354 char const* statusStr
= "";
3358 QuestStatus status
= target
->GetQuestStatus(qinfo
->GetQuestId());
3360 if(status
== QUEST_STATUS_COMPLETE
)
3362 if(target
->GetQuestRewardStatus(qinfo
->GetQuestId()))
3363 statusStr
= GetMangosString(LANG_COMMAND_QUEST_REWARDED
);
3365 statusStr
= GetMangosString(LANG_COMMAND_QUEST_COMPLETE
);
3367 else if(status
== QUEST_STATUS_INCOMPLETE
)
3368 statusStr
= GetMangosString(LANG_COMMAND_QUEST_ACTIVE
);
3372 PSendSysMessage(LANG_QUEST_LIST_CHAT
,qinfo
->GetQuestId(),qinfo
->GetQuestId(),title
.c_str(),statusStr
);
3374 PSendSysMessage(LANG_QUEST_LIST_CONSOLE
,qinfo
->GetQuestId(),title
.c_str(),statusStr
);
3382 std::string title
= qinfo
->GetTitle();
3386 if (Utf8FitTo(title
, wnamepart
))
3388 char const* statusStr
= "";
3392 QuestStatus status
= target
->GetQuestStatus(qinfo
->GetQuestId());
3394 if(status
== QUEST_STATUS_COMPLETE
)
3396 if(target
->GetQuestRewardStatus(qinfo
->GetQuestId()))
3397 statusStr
= GetMangosString(LANG_COMMAND_QUEST_REWARDED
);
3399 statusStr
= GetMangosString(LANG_COMMAND_QUEST_COMPLETE
);
3401 else if(status
== QUEST_STATUS_INCOMPLETE
)
3402 statusStr
= GetMangosString(LANG_COMMAND_QUEST_ACTIVE
);
3406 PSendSysMessage(LANG_QUEST_LIST_CHAT
,qinfo
->GetQuestId(),qinfo
->GetQuestId(),title
.c_str(),statusStr
);
3408 PSendSysMessage(LANG_QUEST_LIST_CONSOLE
,qinfo
->GetQuestId(),title
.c_str(),statusStr
);
3415 SendSysMessage(LANG_COMMAND_NOQUESTFOUND
);
3420 bool ChatHandler::HandleLookupCreatureCommand(const char* args
)
3425 std::string namepart
= args
;
3426 std::wstring wnamepart
;
3428 // converting string that we try to find to lower case
3429 if (!Utf8toWStr (namepart
,wnamepart
))
3432 wstrToLower (wnamepart
);
3436 for (uint32 id
= 0; id
< sCreatureStorage
.MaxEntry
; ++id
)
3438 CreatureInfo
const* cInfo
= sCreatureStorage
.LookupEntry
<CreatureInfo
> (id
);
3442 int loc_idx
= m_session
? m_session
->GetSessionDbLocaleIndex() : objmgr
.GetDBCLocaleIndex();
3445 CreatureLocale
const *cl
= objmgr
.GetCreatureLocale (id
);
3448 if (cl
->Name
.size() > loc_idx
&& !cl
->Name
[loc_idx
].empty ())
3450 std::string name
= cl
->Name
[loc_idx
];
3452 if (Utf8FitTo (name
, wnamepart
))
3455 PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT
, id
, id
, name
.c_str ());
3457 PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE
, id
, name
.c_str ());
3465 std::string name
= cInfo
->Name
;
3469 if (Utf8FitTo(name
, wnamepart
))
3472 PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CHAT
, id
, id
, name
.c_str ());
3474 PSendSysMessage (LANG_CREATURE_ENTRY_LIST_CONSOLE
, id
, name
.c_str ());
3480 SendSysMessage (LANG_COMMAND_NOCREATUREFOUND
);
3485 bool ChatHandler::HandleLookupObjectCommand(const char* args
)
3490 std::string namepart
= args
;
3491 std::wstring wnamepart
;
3493 // converting string that we try to find to lower case
3494 if(!Utf8toWStr(namepart
,wnamepart
))
3497 wstrToLower(wnamepart
);
3501 for (uint32 id
= 0; id
< sGOStorage
.MaxEntry
; id
++ )
3503 GameObjectInfo
const* gInfo
= sGOStorage
.LookupEntry
<GameObjectInfo
>(id
);
3507 int loc_idx
= m_session
? m_session
->GetSessionDbLocaleIndex() : objmgr
.GetDBCLocaleIndex();
3510 GameObjectLocale
const *gl
= objmgr
.GetGameObjectLocale(id
);
3513 if (gl
->Name
.size() > loc_idx
&& !gl
->Name
[loc_idx
].empty())
3515 std::string name
= gl
->Name
[loc_idx
];
3517 if (Utf8FitTo(name
, wnamepart
))
3520 PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT
, id
, id
, name
.c_str());
3522 PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE
, id
, name
.c_str());
3530 std::string name
= gInfo
->name
;
3534 if(Utf8FitTo(name
, wnamepart
))
3537 PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT
, id
, id
, name
.c_str());
3539 PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE
, id
, name
.c_str());
3545 SendSysMessage(LANG_COMMAND_NOGAMEOBJECTFOUND
);
3550 /** \brief GM command level 3 - Create a guild.
3552 * This command allows a GM (level 3) to create a guild.
3554 * The "args" parameter contains the name of the guild leader
3555 * and then the name of the guild.
3558 bool ChatHandler::HandleGuildCreateCommand(const char* args
)
3564 char *lname
= strtok ((char*)args
, " ");
3565 char *gname
= strtok (NULL
, "");
3572 SendSysMessage (LANG_INSERT_GUILD_NAME
);
3573 SetSentErrorMessage (true);
3577 std::string guildname
= gname
;
3579 Player
* player
= ObjectAccessor::Instance ().FindPlayerByName (lname
);
3582 SendSysMessage (LANG_PLAYER_NOT_FOUND
);
3583 SetSentErrorMessage (true);
3587 if (player
->GetGuildId())
3589 SendSysMessage (LANG_PLAYER_IN_GUILD
);
3593 Guild
*guild
= new Guild
;
3594 if (!guild
->create (player
,guildname
))
3597 SendSysMessage (LANG_GUILD_NOT_CREATED
);
3598 SetSentErrorMessage (true);
3602 objmgr
.AddGuild (guild
);
3606 bool ChatHandler::HandleGuildInviteCommand(const char *args
)
3611 char* par1
= strtok ((char*)args
, " ");
3612 char* par2
= strtok (NULL
, "");
3616 std::string glName
= par2
;
3617 Guild
* targetGuild
= objmgr
.GetGuildByName (glName
);
3621 std::string plName
= extractPlayerNameFromLink(par1
);
3624 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3625 SetSentErrorMessage(true);
3630 if (Player
* targetPlayer
= ObjectAccessor::Instance ().FindPlayerByName (plName
.c_str ()))
3631 plGuid
= targetPlayer
->GetGUID ();
3633 plGuid
= objmgr
.GetPlayerGUIDByName (plName
);
3638 // player's guild membership checked in AddMember before add
3639 if (!targetGuild
->AddMember (plGuid
,targetGuild
->GetLowestRank ()))
3645 bool ChatHandler::HandleGuildUninviteCommand(const char *args
)
3650 char* par1
= strtok ((char*)args
, " ");
3654 std::string plName
= extractPlayerNameFromLink(par1
);
3657 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3658 SetSentErrorMessage(true);
3664 if (Player
* targetPlayer
= ObjectAccessor::Instance ().FindPlayerByName (plName
.c_str ()))
3666 plGuid
= targetPlayer
->GetGUID ();
3667 glId
= targetPlayer
->GetGuildId ();
3671 plGuid
= objmgr
.GetPlayerGUIDByName (plName
);
3672 glId
= Player::GetGuildIdFromDB (plGuid
);
3675 if (!plGuid
|| !glId
)
3678 Guild
* targetGuild
= objmgr
.GetGuildById (glId
);
3682 targetGuild
->DelMember (plGuid
);
3687 bool ChatHandler::HandleGuildRankCommand(const char *args
)
3692 char* par1
= strtok ((char*)args
, " ");
3693 char* par2
= strtok (NULL
, " ");
3697 std::string plName
= extractPlayerNameFromLink(par1
);
3700 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3701 SetSentErrorMessage(true);
3708 if (Player
* targetPlayer
= ObjectAccessor::Instance ().FindPlayerByName (plName
.c_str ()))
3710 plGuid
= targetPlayer
->GetGUID ();
3711 glId
= targetPlayer
->GetGuildId ();
3715 plGuid
= objmgr
.GetPlayerGUIDByName (plName
);
3716 glId
= Player::GetGuildIdFromDB (plGuid
);
3719 if (!plGuid
|| !glId
)
3722 Guild
* targetGuild
= objmgr
.GetGuildById (glId
);
3726 uint32 newrank
= uint32 (atoi (par2
));
3727 if (newrank
> targetGuild
->GetLowestRank ())
3730 targetGuild
->ChangeRank (plGuid
,newrank
);
3735 bool ChatHandler::HandleGuildDeleteCommand(const char* args
)
3740 char* par1
= strtok ((char*)args
, " ");
3744 std::string gld
= par1
;
3746 Guild
* targetGuild
= objmgr
.GetGuildByName (gld
);
3750 targetGuild
->Disband ();
3755 bool ChatHandler::HandleGetDistanceCommand(const char* args
)
3757 WorldObject
* obj
= NULL
;
3761 uint64 guid
= extractGuidFromLink((char*)args
);
3763 obj
= (WorldObject
*)ObjectAccessor::GetObjectByTypeMask(*m_session
->GetPlayer(),guid
,TYPEMASK_UNIT
|TYPEMASK_GAMEOBJECT
);
3767 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3768 SetSentErrorMessage(true);
3774 obj
= getSelectedUnit();
3778 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3779 SetSentErrorMessage(true);
3784 PSendSysMessage(LANG_DISTANCE
, m_session
->GetPlayer()->GetDistance(obj
),m_session
->GetPlayer()->GetDistance2d(obj
));
3789 bool ChatHandler::HandleDieCommand(const char* /*args*/)
3791 Unit
* target
= getSelectedUnit();
3793 if(!target
|| !m_session
->GetPlayer()->GetSelection())
3795 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3796 SetSentErrorMessage(true);
3800 if(target
->GetTypeId()==TYPEID_PLAYER
)
3802 if(HasLowerSecurity((Player
*)target
,0,false))
3806 if( target
->isAlive() )
3808 m_session
->GetPlayer()->DealDamage(target
, target
->GetHealth(), NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
3814 bool ChatHandler::HandleDamageCommand(const char * args
)
3819 Unit
* target
= getSelectedUnit();
3821 if(!target
|| !m_session
->GetPlayer()->GetSelection())
3823 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3824 SetSentErrorMessage(true);
3828 if( !target
->isAlive() )
3831 char* damageStr
= strtok((char*)args
, " ");
3835 int32 damage
= atoi((char*)damageStr
);
3839 char* schoolStr
= strtok((char*)NULL
, " ");
3841 // flat melee damage without resistence/etc reduction
3844 m_session
->GetPlayer()->DealDamage(target
, damage
, NULL
, DIRECT_DAMAGE
, SPELL_SCHOOL_MASK_NORMAL
, NULL
, false);
3845 m_session
->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2
, target
, 1, SPELL_SCHOOL_MASK_NORMAL
, damage
, 0, 0, VICTIMSTATE_NORMAL
, 0);
3849 uint32 school
= schoolStr
? atoi((char*)schoolStr
) : SPELL_SCHOOL_NORMAL
;
3850 if(school
>= MAX_SPELL_SCHOOL
)
3853 SpellSchoolMask schoolmask
= SpellSchoolMask(1 << school
);
3855 if ( schoolmask
& SPELL_SCHOOL_MASK_NORMAL
)
3856 damage
= m_session
->GetPlayer()->CalcArmorReducedDamage(target
, damage
);
3858 char* spellStr
= strtok((char*)NULL
, " ");
3860 // melee damage by specific school
3866 m_session
->GetPlayer()->CalcAbsorbResist(target
,schoolmask
, SPELL_DIRECT_DAMAGE
, damage
, &absorb
, &resist
);
3868 if (damage
<= absorb
+ resist
)
3871 damage
-= absorb
+ resist
;
3873 m_session
->GetPlayer()->DealDamage(target
, damage
, NULL
, DIRECT_DAMAGE
, schoolmask
, NULL
, false);
3874 m_session
->GetPlayer()->SendAttackStateUpdate (HITINFO_NORMALSWING2
, target
, 1, schoolmask
, damage
, absorb
, resist
, VICTIMSTATE_NORMAL
, 0);
3880 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
3881 uint32 spellid
= extractSpellIdFromLink((char*)args
);
3882 if(!spellid
|| !sSpellStore
.LookupEntry(spellid
))
3885 m_session
->GetPlayer()->SpellNonMeleeDamageLog(target
, spellid
, damage
, false);
3889 bool ChatHandler::HandleModifyArenaCommand(const char * args
)
3894 Player
*target
= getSelectedPlayer();
3897 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3898 SetSentErrorMessage(true);
3902 int32 amount
= (uint32
)atoi(args
);
3904 target
->ModifyArenaPoints(amount
);
3906 PSendSysMessage(LANG_COMMAND_MODIFY_ARENA
, GetNameLink(target
).c_str(), target
->GetArenaPoints());
3911 bool ChatHandler::HandleReviveCommand(const char* args
)
3913 Player
* player
= NULL
;
3914 uint64 player_guid
= 0;
3918 std::string name
= extractPlayerNameFromLink((char*)args
);
3921 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
3922 SetSentErrorMessage(true);
3926 player
= objmgr
.GetPlayer(name
.c_str());
3928 player_guid
= objmgr
.GetPlayerGUIDByName(name
);
3931 player
= getSelectedPlayer();
3935 player
->ResurrectPlayer(0.5f
);
3936 player
->SpawnCorpseBones();
3939 else if (player_guid
)
3941 // will resurrected at login without corpse
3942 ObjectAccessor::Instance().ConvertCorpseForPlayer(player_guid
);
3946 SendSysMessage(LANG_NO_CHAR_SELECTED
);
3947 SetSentErrorMessage(true);
3954 bool ChatHandler::HandleAuraCommand(const char* args
)
3956 Unit
*target
= getSelectedUnit();
3959 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3960 SetSentErrorMessage(true);
3964 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
3965 uint32 spellID
= extractSpellIdFromLink((char*)args
);
3967 SpellEntry
const *spellInfo
= sSpellStore
.LookupEntry( spellID
);
3970 for(uint32 i
= 0;i
<3;++i
)
3972 uint8 eff
= spellInfo
->Effect
[i
];
3973 if (eff
>=TOTAL_SPELL_EFFECTS
)
3975 if( IsAreaAuraEffect(eff
) ||
3976 eff
== SPELL_EFFECT_APPLY_AURA
||
3977 eff
== SPELL_EFFECT_PERSISTENT_AREA_AURA
)
3979 Aura
*Aur
= CreateAura(spellInfo
, i
, NULL
, target
);
3980 target
->AddAura(Aur
);
3988 bool ChatHandler::HandleUnAuraCommand(const char* args
)
3990 Unit
*target
= getSelectedUnit();
3993 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
3994 SetSentErrorMessage(true);
3998 std::string argstr
= args
;
3999 if (argstr
== "all")
4001 target
->RemoveAllAuras();
4005 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
4006 uint32 spellID
= extractSpellIdFromLink((char*)args
);
4010 target
->RemoveAurasDueToSpell(spellID
);
4015 bool ChatHandler::HandleLinkGraveCommand(const char* args
)
4020 char* px
= strtok((char*)args
, " ");
4024 uint32 g_id
= (uint32
)atoi(px
);
4028 char* px2
= strtok(NULL
, " ");
4032 else if (strncmp(px2
,"horde",6)==0)
4034 else if (strncmp(px2
,"alliance",9)==0)
4039 WorldSafeLocsEntry
const* graveyard
= sWorldSafeLocsStore
.LookupEntry(g_id
);
4043 PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST
, g_id
);
4044 SetSentErrorMessage(true);
4048 Player
* player
= m_session
->GetPlayer();
4050 uint32 zoneId
= player
->GetZoneId();
4052 AreaTableEntry
const *areaEntry
= GetAreaEntryByAreaID(zoneId
);
4053 if(!areaEntry
|| areaEntry
->zone
!=0 )
4055 PSendSysMessage(LANG_COMMAND_GRAVEYARDWRONGZONE
, g_id
,zoneId
);
4056 SetSentErrorMessage(true);
4060 if(objmgr
.AddGraveYardLink(g_id
,zoneId
,g_team
))
4061 PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED
, g_id
,zoneId
);
4063 PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED
, g_id
,zoneId
);
4068 bool ChatHandler::HandleNearGraveCommand(const char* args
)
4072 size_t argslen
= strlen(args
);
4076 else if (strncmp((char*)args
,"horde",argslen
)==0)
4078 else if (strncmp((char*)args
,"alliance",argslen
)==0)
4083 Player
* player
= m_session
->GetPlayer();
4084 uint32 zone_id
= player
->GetZoneId();
4086 WorldSafeLocsEntry
const* graveyard
= objmgr
.GetClosestGraveYard(
4087 player
->GetPositionX(), player
->GetPositionY(), player
->GetPositionZ(),player
->GetMapId(),g_team
);
4091 uint32 g_id
= graveyard
->ID
;
4093 GraveYardData
const* data
= objmgr
.FindGraveYardData(g_id
,zone_id
);
4096 PSendSysMessage(LANG_COMMAND_GRAVEYARDERROR
,g_id
);
4097 SetSentErrorMessage(true);
4101 g_team
= data
->team
;
4103 std::string team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_NOTEAM
);
4106 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ANY
);
4107 else if(g_team
== HORDE
)
4108 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE
);
4109 else if(g_team
== ALLIANCE
)
4110 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE
);
4112 PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST
, g_id
,team_name
.c_str(),zone_id
);
4116 std::string team_name
;
4119 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ANY
);
4120 else if(g_team
== HORDE
)
4121 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_HORDE
);
4122 else if(g_team
== ALLIANCE
)
4123 team_name
= GetMangosString(LANG_COMMAND_GRAVEYARD_ALLIANCE
);
4125 if(g_team
== ~uint32(0))
4126 PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS
, zone_id
);
4128 PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION
, zone_id
,team_name
.c_str());
4134 //-----------------------Npc Commands-----------------------
4135 bool ChatHandler::HandleNpcAllowMovementCommand(const char* /*args*/)
4137 if(sWorld
.getAllowMovement())
4139 sWorld
.SetAllowMovement(false);
4140 SendSysMessage(LANG_CREATURE_MOVE_DISABLED
);
4144 sWorld
.SetAllowMovement(true);
4145 SendSysMessage(LANG_CREATURE_MOVE_ENABLED
);
4150 bool ChatHandler::HandleNpcChangeEntryCommand(const char *args
)
4155 uint32 newEntryNum
= atoi(args
);
4159 Unit
* unit
= getSelectedUnit();
4160 if(!unit
|| unit
->GetTypeId() != TYPEID_UNIT
)
4162 SendSysMessage(LANG_SELECT_CREATURE
);
4163 SetSentErrorMessage(true);
4166 Creature
* creature
= (Creature
*)unit
;
4167 if(creature
->UpdateEntry(newEntryNum
))
4168 SendSysMessage(LANG_DONE
);
4170 SendSysMessage(LANG_ERROR
);
4174 bool ChatHandler::HandleNpcInfoCommand(const char* /*args*/)
4176 Creature
* target
= getSelectedCreature();
4180 SendSysMessage(LANG_SELECT_CREATURE
);
4181 SetSentErrorMessage(true);
4185 uint32 faction
= target
->getFaction();
4186 uint32 npcflags
= target
->GetUInt32Value(UNIT_NPC_FLAGS
);
4187 uint32 displayid
= target
->GetDisplayId();
4188 uint32 nativeid
= target
->GetNativeDisplayId();
4189 uint32 Entry
= target
->GetEntry();
4190 CreatureInfo
const* cInfo
= target
->GetCreatureInfo();
4192 int32 curRespawnDelay
= target
->GetRespawnTimeEx()-time(NULL
);
4193 if(curRespawnDelay
< 0)
4194 curRespawnDelay
= 0;
4195 std::string curRespawnDelayStr
= secsToTimeString(curRespawnDelay
,true);
4196 std::string defRespawnDelayStr
= secsToTimeString(target
->GetRespawnDelay(),true);
4198 PSendSysMessage(LANG_NPCINFO_CHAR
, target
->GetDBTableGUIDLow(), faction
, npcflags
, Entry
, displayid
, nativeid
);
4199 PSendSysMessage(LANG_NPCINFO_LEVEL
, target
->getLevel());
4200 PSendSysMessage(LANG_NPCINFO_HEALTH
,target
->GetCreateHealth(), target
->GetMaxHealth(), target
->GetHealth());
4201 PSendSysMessage(LANG_NPCINFO_FLAGS
, target
->GetUInt32Value(UNIT_FIELD_FLAGS
), target
->GetUInt32Value(UNIT_DYNAMIC_FLAGS
), target
->getFaction());
4202 PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES
, defRespawnDelayStr
.c_str(),curRespawnDelayStr
.c_str());
4203 PSendSysMessage(LANG_NPCINFO_LOOT
, cInfo
->lootid
,cInfo
->pickpocketLootId
,cInfo
->SkinLootId
);
4204 PSendSysMessage(LANG_NPCINFO_DUNGEON_ID
, target
->GetInstanceId());
4205 PSendSysMessage(LANG_NPCINFO_POSITION
,float(target
->GetPositionX()), float(target
->GetPositionY()), float(target
->GetPositionZ()));
4207 if ((npcflags
& UNIT_NPC_FLAG_VENDOR
) )
4209 SendSysMessage(LANG_NPCINFO_VENDOR
);
4211 if ((npcflags
& UNIT_NPC_FLAG_TRAINER
) )
4213 SendSysMessage(LANG_NPCINFO_TRAINER
);
4220 bool ChatHandler::HandleNpcPlayEmoteCommand(const char* args
)
4222 uint32 emote
= atoi((char*)args
);
4224 Creature
* target
= getSelectedCreature();
4227 SendSysMessage(LANG_SELECT_CREATURE
);
4228 SetSentErrorMessage(true);
4232 target
->SetUInt32Value(UNIT_NPC_EMOTESTATE
,emote
);
4237 //TODO: NpcCommands that needs to be fixed :
4239 bool ChatHandler::HandleNpcAddWeaponCommand(const char* /*args*/)
4244 uint64 guid = m_session->GetPlayer()->GetSelection();
4247 SendSysMessage(LANG_NO_SELECTION);
4251 Creature *pCreature = ObjectAccessor::GetCreature(*m_session->GetPlayer(), guid);
4255 SendSysMessage(LANG_SELECT_CREATURE);
4259 char* pSlotID = strtok((char*)args, " ");
4263 char* pItemID = strtok(NULL, " ");
4267 uint32 ItemID = atoi(pItemID);
4268 uint32 SlotID = atoi(pSlotID);
4270 ItemPrototype* tmpItem = objmgr.GetItemPrototype(ItemID);
4278 pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, ItemID);
4282 pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_01, ItemID);
4286 pCreature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY_02, ItemID);
4290 PSendSysMessage(LANG_ITEM_SLOT_NOT_EXIST,SlotID);
4296 PSendSysMessage(LANG_ITEM_ADDED_TO_SLOT,ItemID,tmpItem->Name1,SlotID);
4300 PSendSysMessage(LANG_ITEM_NOT_FOUND,ItemID);
4306 //----------------------------------------------------------
4308 bool ChatHandler::HandleExploreCheatCommand(const char* args
)
4313 int flag
= atoi((char*)args
);
4315 Player
*chr
= getSelectedPlayer();
4318 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4319 SetSentErrorMessage(true);
4325 PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL
, GetNameLink(chr
).c_str());
4326 if (needReportToTarget(chr
))
4327 ChatHandler(chr
).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL
,GetNameLink().c_str());
4331 PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING
, GetNameLink(chr
).c_str());
4332 if (needReportToTarget(chr
))
4333 ChatHandler(chr
).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING
,GetNameLink().c_str());
4336 for (uint8 i
=0; i
<128; ++i
)
4340 m_session
->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1
+i
,0xFFFFFFFF);
4344 m_session
->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1
+i
,0);
4351 bool ChatHandler::HandleHoverCommand(const char* args
)
4353 char* px
= strtok((char*)args
, " ");
4360 m_session
->GetPlayer()->SetHover(flag
);
4363 SendSysMessage(LANG_HOVER_ENABLED
);
4365 SendSysMessage(LANG_HOVER_DISABLED
);
4370 void ChatHandler::HandleCharacterLevel(Player
* player
, uint64 player_guid
, uint32 oldlevel
, uint32 newlevel
)
4374 player
->GiveLevel(newlevel
);
4375 player
->InitTalentForLevel();
4376 player
->SetUInt32Value(PLAYER_XP
,0);
4378 if(needReportToTarget(player
))
4380 if(oldlevel
== newlevel
)
4381 ChatHandler(player
).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET
,GetNameLink().c_str());
4382 else if(oldlevel
< newlevel
)
4383 ChatHandler(player
).PSendSysMessage(LANG_YOURS_LEVEL_UP
,GetNameLink().c_str(),newlevel
);
4384 else // if(oldlevel > newlevel)
4385 ChatHandler(player
).PSendSysMessage(LANG_YOURS_LEVEL_DOWN
,GetNameLink().c_str(),newlevel
);
4390 // update level and XP at level, all other will be updated at loading
4392 Player::LoadValuesArrayFromDB(values
,player_guid
);
4393 Player::SetUInt32ValueInArray(values
,UNIT_FIELD_LEVEL
,newlevel
);
4394 Player::SetUInt32ValueInArray(values
,PLAYER_XP
,0);
4395 Player::SaveValuesArrayInDB(values
,player_guid
);
4399 bool ChatHandler::HandleCharacterLevelCommand(const char* args
)
4401 char* px
= strtok((char*)args
, " ");
4402 char* py
= strtok((char*)NULL
, " ");
4404 // command format parsing
4405 char* pname
= (char*)NULL
;
4408 if(px
&& py
) // .character level $name #level
4410 newlevel
= atoi(py
);
4413 else if(px
&& !py
) // .character level $name OR .character level #level
4415 if(isalpha(px
[0])) // .character level $name
4417 else // .character level #level
4418 newlevel
= atoi(px
);
4420 // // .character level - progress reset
4423 return false; // invalid level
4425 if(newlevel
> STRONG_MAX_LEVEL
) // hardcoded maximum level
4426 newlevel
= STRONG_MAX_LEVEL
;
4430 uint64 chr_guid
= 0;
4434 if(pname
) // player by name
4436 name
= extractPlayerNameFromLink(pname
);
4439 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4440 SetSentErrorMessage(true);
4444 chr
= objmgr
.GetPlayer(name
.c_str());
4445 if(!chr
) // not in game
4447 chr_guid
= objmgr
.GetPlayerGUIDByName(name
);
4450 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4451 SetSentErrorMessage(true);
4456 else // player by selection
4458 chr
= getSelectedPlayer();
4462 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4463 SetSentErrorMessage(true);
4467 name
= chr
->GetName();
4470 assert(chr
|| chr_guid
);
4472 int32 oldlevel
= chr
? chr
->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL
,chr_guid
);
4474 if(!px
&& !py
) // .character level - progress reset
4475 newlevel
= oldlevel
;
4477 HandleCharacterLevel(chr
,chr_guid
,oldlevel
,newlevel
);
4479 if(m_session
&& m_session
->GetPlayer() != chr
) // including player==NULL
4481 std::string nameLink
= playerLink(name
);
4482 PSendSysMessage(LANG_YOU_CHANGE_LVL
,nameLink
.c_str(),newlevel
);
4488 bool ChatHandler::HandleLevelUpCommand(const char* args
)
4490 char* px
= strtok((char*)args
, " ");
4491 char* py
= strtok((char*)NULL
, " ");
4493 // command format parsing
4494 char* pname
= (char*)NULL
;
4497 if(px
&& py
) // .levelup name level
4499 addlevel
= atoi(py
);
4502 else if(px
&& !py
) // .levelup name OR .levelup level
4504 if(isalpha(px
[0])) // .levelup name
4506 else // .levelup level
4507 addlevel
= atoi(px
);
4509 // else .levelup - nothing do for preparing
4513 uint64 chr_guid
= 0;
4517 if(pname
) // player by name
4519 name
= extractPlayerNameFromLink(pname
);
4522 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4523 SetSentErrorMessage(true);
4527 chr
= objmgr
.GetPlayer(name
.c_str());
4528 if(!chr
) // not in game
4530 chr_guid
= objmgr
.GetPlayerGUIDByName(name
);
4533 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
4534 SetSentErrorMessage(true);
4539 else // player by selection
4541 chr
= getSelectedPlayer();
4545 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4546 SetSentErrorMessage(true);
4550 name
= chr
->GetName();
4553 assert(chr
|| chr_guid
);
4555 int32 oldlevel
= chr
? chr
->getLevel() : Player::GetUInt32ValueFromDB(UNIT_FIELD_LEVEL
,chr_guid
);
4556 int32 newlevel
= oldlevel
+ addlevel
;
4559 if(newlevel
> STRONG_MAX_LEVEL
) // hardcoded maximum level
4560 newlevel
= STRONG_MAX_LEVEL
;
4562 HandleCharacterLevel(chr
,chr_guid
,oldlevel
,newlevel
);
4564 if(m_session
&& m_session
->GetPlayer() != chr
) // including chr==NULL
4566 std::string nameLink
= playerLink(name
);
4567 PSendSysMessage(LANG_YOU_CHANGE_LVL
,nameLink
.c_str(),newlevel
);
4573 bool ChatHandler::HandleShowAreaCommand(const char* args
)
4578 Player
*chr
= getSelectedPlayer();
4581 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4582 SetSentErrorMessage(true);
4586 int area
= GetAreaFlagByAreaID(atoi((char*)args
));
4587 int offset
= area
/ 32;
4588 uint32 val
= (uint32
)(1 << (area
% 32));
4590 if(area
<0 || offset
>= 128)
4592 SendSysMessage(LANG_BAD_VALUE
);
4593 SetSentErrorMessage(true);
4597 uint32 currFields
= chr
->GetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
);
4598 chr
->SetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
, (uint32
)(currFields
| val
));
4600 SendSysMessage(LANG_EXPLORE_AREA
);
4604 bool ChatHandler::HandleHideAreaCommand(const char* args
)
4609 Player
*chr
= getSelectedPlayer();
4612 SendSysMessage(LANG_NO_CHAR_SELECTED
);
4613 SetSentErrorMessage(true);
4617 int area
= GetAreaFlagByAreaID(atoi((char*)args
));
4618 int offset
= area
/ 32;
4619 uint32 val
= (uint32
)(1 << (area
% 32));
4621 if(area
<0 || offset
>= 128)
4623 SendSysMessage(LANG_BAD_VALUE
);
4624 SetSentErrorMessage(true);
4628 uint32 currFields
= chr
->GetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
);
4629 chr
->SetUInt32Value(PLAYER_EXPLORED_ZONES_1
+ offset
, (uint32
)(currFields
^ val
));
4631 SendSysMessage(LANG_UNEXPLORE_AREA
);
4635 bool ChatHandler::HandleDebugUpdate(const char* args
)
4643 char* pUpdateIndex
= strtok((char*)args
, " ");
4645 Unit
* chr
= getSelectedUnit();
4648 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
4649 SetSentErrorMessage(true);
4657 updateIndex
= atoi(pUpdateIndex
);
4659 if(chr
->GetTypeId() == TYPEID_PLAYER
)
4661 if (updateIndex
>=PLAYER_END
) return true;
4665 if (updateIndex
>=UNIT_END
) return true;
4668 char* pvalue
= strtok(NULL
, " ");
4671 value
=chr
->GetUInt32Value(updateIndex
);
4673 PSendSysMessage(LANG_UPDATE
, chr
->GetGUIDLow(),updateIndex
,value
);
4679 PSendSysMessage(LANG_UPDATE_CHANGE
, chr
->GetGUIDLow(),updateIndex
,value
);
4681 chr
->SetUInt32Value(updateIndex
,value
);
4686 bool ChatHandler::HandleBankCommand(const char* /*args*/)
4688 m_session
->SendShowBank( m_session
->GetPlayer()->GetGUID() );
4693 bool ChatHandler::HandleChangeWeather(const char* args
)
4699 if (!sWorld
.getConfig(CONFIG_WEATHER
))
4701 SendSysMessage(LANG_WEATHER_DISABLED
);
4702 SetSentErrorMessage(true);
4706 //*Change the weather of a cell
4707 char* px
= strtok((char*)args
, " ");
4708 char* py
= strtok(NULL
, " ");
4713 uint32 type
= (uint32
)atoi(px
); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand
4714 float grade
= (float)atof(py
); //0 to 1, sending -1 is instand good weather
4716 Player
*player
= m_session
->GetPlayer();
4717 uint32 zoneid
= player
->GetZoneId();
4719 Weather
* wth
= sWorld
.FindWeather(zoneid
);
4722 wth
= sWorld
.AddWeather(zoneid
);
4725 SendSysMessage(LANG_NO_WEATHER
);
4726 SetSentErrorMessage(true);
4730 wth
->SetWeather(WeatherType(type
), grade
);
4735 bool ChatHandler::HandleDebugSetValue(const char* args
)
4740 char* px
= strtok((char*)args
, " ");
4741 char* py
= strtok(NULL
, " ");
4742 char* pz
= strtok(NULL
, " ");
4747 Unit
* target
= getSelectedUnit();
4750 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
4751 SetSentErrorMessage(true);
4755 uint64 guid
= target
->GetGUID();
4757 uint32 Opcode
= (uint32
)atoi(px
);
4758 if(Opcode
>= target
->GetValuesCount())
4760 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, GUID_LOPART(guid
), target
->GetValuesCount());
4765 bool isint32
= true;
4767 isint32
= (bool)atoi(pz
);
4770 iValue
= (uint32
)atoi(py
);
4771 sLog
.outDebug(GetMangosString(LANG_SET_UINT
), GUID_LOPART(guid
), Opcode
, iValue
);
4772 target
->SetUInt32Value( Opcode
, iValue
);
4773 PSendSysMessage(LANG_SET_UINT_FIELD
, GUID_LOPART(guid
), Opcode
,iValue
);
4777 fValue
= (float)atof(py
);
4778 sLog
.outDebug(GetMangosString(LANG_SET_FLOAT
), GUID_LOPART(guid
), Opcode
, fValue
);
4779 target
->SetFloatValue( Opcode
, fValue
);
4780 PSendSysMessage(LANG_SET_FLOAT_FIELD
, GUID_LOPART(guid
), Opcode
,fValue
);
4786 bool ChatHandler::HandleDebugGetValue(const char* args
)
4791 char* px
= strtok((char*)args
, " ");
4792 char* pz
= strtok(NULL
, " ");
4797 Unit
* target
= getSelectedUnit();
4800 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
4801 SetSentErrorMessage(true);
4805 uint64 guid
= target
->GetGUID();
4807 uint32 Opcode
= (uint32
)atoi(px
);
4808 if(Opcode
>= target
->GetValuesCount())
4810 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, GUID_LOPART(guid
), target
->GetValuesCount());
4815 bool isint32
= true;
4817 isint32
= (bool)atoi(pz
);
4821 iValue
= target
->GetUInt32Value( Opcode
);
4822 sLog
.outDebug(GetMangosString(LANG_GET_UINT
), GUID_LOPART(guid
), Opcode
, iValue
);
4823 PSendSysMessage(LANG_GET_UINT_FIELD
, GUID_LOPART(guid
), Opcode
, iValue
);
4827 fValue
= target
->GetFloatValue( Opcode
);
4828 sLog
.outDebug(GetMangosString(LANG_GET_FLOAT
), GUID_LOPART(guid
), Opcode
, fValue
);
4829 PSendSysMessage(LANG_GET_FLOAT_FIELD
, GUID_LOPART(guid
), Opcode
, fValue
);
4835 bool ChatHandler::HandleSet32Bit(const char* args
)
4840 char* px
= strtok((char*)args
, " ");
4841 char* py
= strtok(NULL
, " ");
4846 uint32 Opcode
= (uint32
)atoi(px
);
4847 uint32 Value
= (uint32
)atoi(py
);
4848 if (Value
> 32) //uint32 = 32 bits
4851 sLog
.outDebug(GetMangosString(LANG_SET_32BIT
), Opcode
, Value
);
4853 m_session
->GetPlayer( )->SetUInt32Value( Opcode
, 2^Value
);
4855 PSendSysMessage(LANG_SET_32BIT_FIELD
, Opcode
,1);
4859 bool ChatHandler::HandleDebugMod32Value(const char* args
)
4864 char* px
= strtok((char*)args
, " ");
4865 char* py
= strtok(NULL
, " ");
4870 uint32 Opcode
= (uint32
)atoi(px
);
4871 int Value
= atoi(py
);
4873 if(Opcode
>= m_session
->GetPlayer()->GetValuesCount())
4875 PSendSysMessage(LANG_TOO_BIG_INDEX
, Opcode
, m_session
->GetPlayer()->GetGUIDLow(), m_session
->GetPlayer( )->GetValuesCount());
4879 sLog
.outDebug(GetMangosString(LANG_CHANGE_32BIT
), Opcode
, Value
);
4881 int CurrentValue
= (int)m_session
->GetPlayer( )->GetUInt32Value( Opcode
);
4883 CurrentValue
+= Value
;
4884 m_session
->GetPlayer( )->SetUInt32Value( Opcode
, (uint32
)CurrentValue
);
4886 PSendSysMessage(LANG_CHANGE_32BIT_FIELD
, Opcode
,CurrentValue
);
4891 bool ChatHandler::HandleTeleAddCommand(const char * args
)
4896 Player
*player
=m_session
->GetPlayer();
4900 std::string name
= args
;
4902 if(objmgr
.GetGameTele(name
))
4904 SendSysMessage(LANG_COMMAND_TP_ALREADYEXIST
);
4905 SetSentErrorMessage(true);
4910 tele
.position_x
= player
->GetPositionX();
4911 tele
.position_y
= player
->GetPositionY();
4912 tele
.position_z
= player
->GetPositionZ();
4913 tele
.orientation
= player
->GetOrientation();
4914 tele
.mapId
= player
->GetMapId();
4917 if(objmgr
.AddGameTele(tele
))
4919 SendSysMessage(LANG_COMMAND_TP_ADDED
);
4923 SendSysMessage(LANG_COMMAND_TP_ADDEDERR
);
4924 SetSentErrorMessage(true);
4931 bool ChatHandler::HandleTeleDelCommand(const char * args
)
4936 std::string name
= args
;
4938 if(!objmgr
.DeleteGameTele(name
))
4940 SendSysMessage(LANG_COMMAND_TELE_NOTFOUND
);
4941 SetSentErrorMessage(true);
4945 SendSysMessage(LANG_COMMAND_TP_DELETED
);
4949 bool ChatHandler::HandleListAurasCommand (const char * /*args*/)
4951 Unit
*unit
= getSelectedUnit();
4954 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
4955 SetSentErrorMessage(true);
4959 char const* talentStr
= GetMangosString(LANG_TALENT
);
4960 char const* passiveStr
= GetMangosString(LANG_PASSIVE
);
4962 Unit::AuraMap
const& uAuras
= unit
->GetAuras();
4963 PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS
, uAuras
.size());
4964 for (Unit::AuraMap::const_iterator itr
= uAuras
.begin(); itr
!= uAuras
.end(); ++itr
)
4966 bool talent
= GetTalentSpellCost(itr
->second
->GetId()) > 0;
4968 char const* name
= itr
->second
->GetSpellProto()->SpellName
[m_session
->GetSessionDbcLocale()];
4972 std::ostringstream ss_name
;
4973 ss_name
<< "|cffffffff|Hspell:" << itr
->second
->GetId() << "|h[" << name
<< "]|h|r";
4975 PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL
, itr
->second
->GetId(), itr
->second
->GetEffIndex(),
4976 itr
->second
->GetModifier()->m_auraname
, itr
->second
->GetAuraDuration(), itr
->second
->GetAuraMaxDuration(),
4977 ss_name
.str().c_str(),
4978 (itr
->second
->IsPassive() ? passiveStr
: ""),(talent
? talentStr
: ""),
4979 IS_PLAYER_GUID(itr
->second
->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr
->second
->GetCasterGUID()));
4983 PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL
, itr
->second
->GetId(), itr
->second
->GetEffIndex(),
4984 itr
->second
->GetModifier()->m_auraname
, itr
->second
->GetAuraDuration(), itr
->second
->GetAuraMaxDuration(),
4986 (itr
->second
->IsPassive() ? passiveStr
: ""),(talent
? talentStr
: ""),
4987 IS_PLAYER_GUID(itr
->second
->GetCasterGUID()) ? "player" : "creature",GUID_LOPART(itr
->second
->GetCasterGUID()));
4990 for (int i
= 0; i
< TOTAL_AURAS
; ++i
)
4992 Unit::AuraList
const& uAuraList
= unit
->GetAurasByType(AuraType(i
));
4993 if (uAuraList
.empty()) continue;
4994 PSendSysMessage(LANG_COMMAND_TARGET_LISTAURATYPE
, uAuraList
.size(), i
);
4995 for (Unit::AuraList::const_iterator itr
= uAuraList
.begin(); itr
!= uAuraList
.end(); ++itr
)
4997 bool talent
= GetTalentSpellCost((*itr
)->GetId()) > 0;
4999 char const* name
= (*itr
)->GetSpellProto()->SpellName
[m_session
->GetSessionDbcLocale()];
5003 std::ostringstream ss_name
;
5004 ss_name
<< "|cffffffff|Hspell:" << (*itr
)->GetId() << "|h[" << name
<< "]|h|r";
5006 PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE
, (*itr
)->GetId(), (*itr
)->GetEffIndex(),
5007 ss_name
.str().c_str(),((*itr
)->IsPassive() ? passiveStr
: ""),(talent
? talentStr
: ""),
5008 IS_PLAYER_GUID((*itr
)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr
)->GetCasterGUID()));
5012 PSendSysMessage(LANG_COMMAND_TARGET_AURASIMPLE
, (*itr
)->GetId(), (*itr
)->GetEffIndex(),
5013 name
,((*itr
)->IsPassive() ? passiveStr
: ""),(talent
? talentStr
: ""),
5014 IS_PLAYER_GUID((*itr
)->GetCasterGUID()) ? "player" : "creature",GUID_LOPART((*itr
)->GetCasterGUID()));
5021 bool ChatHandler::HandleResetAchievementsCommand (const char * args
)
5023 char* pName
= strtok((char*)args
, "");
5024 Player
*player
= NULL
;
5028 std::string name
= extractPlayerNameFromLink(pName
);
5031 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5032 SetSentErrorMessage(true);
5036 guid
= objmgr
.GetPlayerGUIDByName(name
);
5037 player
= objmgr
.GetPlayer(guid
);
5041 player
= getSelectedPlayer();
5043 guid
= player
->GetGUID();
5046 if(!player
&& !guid
)
5048 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5053 player
->GetAchievementMgr().Reset();
5055 AchievementMgr::DeleteFromDB(GUID_LOPART(guid
));
5060 bool ChatHandler::HandleResetHonorCommand (const char * args
)
5062 char* pName
= strtok((char*)args
, "");
5063 Player
*player
= NULL
;
5066 std::string name
= extractPlayerNameFromLink(pName
);
5069 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5070 SetSentErrorMessage(true);
5074 uint64 guid
= objmgr
.GetPlayerGUIDByName(name
);
5075 player
= objmgr
.GetPlayer(guid
);
5078 player
= getSelectedPlayer();
5082 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5086 player
->SetUInt32Value(PLAYER_FIELD_KILLS
, 0);
5087 player
->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORBALE_KILLS
, 0);
5088 player
->SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY
, 0);
5089 player
->SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION
, 0);
5090 player
->SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION
, 0);
5092 player
->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL
);
5097 static bool HandleResetStatsOrLevelHelper(Player
* player
)
5099 PlayerInfo
const *info
= objmgr
.GetPlayerInfo(player
->getRace(), player
->getClass());
5100 if(!info
) return false;
5102 ChrClassesEntry
const* cEntry
= sChrClassesStore
.LookupEntry(player
->getClass());
5105 sLog
.outError("Class %u not found in DBC (Wrong DBC files?)",player
->getClass());
5109 uint8 powertype
= cEntry
->powerType
;
5111 // reset m_form if no aura
5112 if(!player
->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT
))
5113 player
->m_form
= FORM_NONE
;
5115 player
->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS
, DEFAULT_WORLD_OBJECT_SIZE
);
5116 player
->SetFloatValue(UNIT_FIELD_COMBATREACH
, 1.5f
);
5118 player
->setFactionForRace(player
->getRace());
5120 player
->SetUInt32Value(UNIT_FIELD_BYTES_0
, ( ( player
->getRace() ) | ( player
->getClass() << 8 ) | ( player
->getGender() << 16 ) | ( powertype
<< 24 ) ) );
5122 // reset only if player not in some form;
5123 if(player
->m_form
==FORM_NONE
)
5125 switch(player
->getGender())
5128 player
->SetDisplayId(info
->displayId_f
);
5129 player
->SetNativeDisplayId(info
->displayId_f
);
5132 player
->SetDisplayId(info
->displayId_m
);
5133 player
->SetNativeDisplayId(info
->displayId_m
);
5140 player
->SetByteValue(UNIT_FIELD_BYTES_2
, 1, UNIT_BYTE2_FLAG_PVP
);
5141 player
->SetByteValue(UNIT_FIELD_BYTES_2
, 3, player
->m_form
);
5143 player
->SetUInt32Value(UNIT_FIELD_FLAGS
, UNIT_FLAG_PVP_ATTACKABLE
);
5145 //-1 is default value
5146 player
->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX
, uint32(-1));
5148 //player->SetUInt32Value(PLAYER_FIELD_BYTES, 0xEEE00000 );
5152 bool ChatHandler::HandleResetLevelCommand(const char * args
)
5154 char* pName
= strtok((char*)args
, "");
5155 Player
*player
= NULL
;
5158 std::string name
= extractPlayerNameFromLink(pName
);
5161 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5162 SetSentErrorMessage(true);
5166 uint64 guid
= objmgr
.GetPlayerGUIDByName(name
);
5167 player
= objmgr
.GetPlayer(guid
);
5170 player
= getSelectedPlayer();
5174 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5175 SetSentErrorMessage(true);
5179 if(!HandleResetStatsOrLevelHelper(player
))
5182 // set starting level
5183 uint32 start_level
= player
->getClass() != CLASS_DEATH_KNIGHT
5184 ? sWorld
.getConfig(CONFIG_START_PLAYER_LEVEL
)
5185 : sWorld
.getConfig(CONFIG_START_HEROIC_PLAYER_LEVEL
);
5187 player
->SetLevel(start_level
);
5188 player
->InitRunes();
5189 player
->InitStatsForLevel(true);
5190 player
->InitTaxiNodesForLevel();
5191 player
->InitGlyphsForLevel();
5192 player
->InitTalentForLevel();
5193 player
->SetUInt32Value(PLAYER_XP
,0);
5195 // reset level to summoned pet
5196 Pet
* pet
= player
->GetPet();
5197 if(pet
&& pet
->getPetType()==SUMMON_PET
)
5199 pet
->InitStatsForLevel(1);
5200 pet
->InitTalentForLevel();
5205 bool ChatHandler::HandleResetStatsCommand(const char * args
)
5207 char* pName
= strtok((char*)args
, "");
5208 Player
*player
= NULL
;
5211 std::string name
= extractPlayerNameFromLink(pName
);
5214 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5215 SetSentErrorMessage(true);
5219 uint64 guid
= objmgr
.GetPlayerGUIDByName(name
);
5220 player
= objmgr
.GetPlayer(guid
);
5223 player
= getSelectedPlayer();
5227 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5228 SetSentErrorMessage(true);
5232 if(!HandleResetStatsOrLevelHelper(player
))
5235 player
->InitRunes();
5236 player
->InitStatsForLevel(true);
5237 player
->InitTaxiNodesForLevel();
5238 player
->InitGlyphsForLevel();
5239 player
->InitTalentForLevel();
5244 bool ChatHandler::HandleResetSpellsCommand(const char * args
)
5246 char* pName
= strtok((char*)args
, "");
5247 Player
*player
= NULL
;
5248 uint64 playerGUID
= 0;
5251 std::string name
= extractPlayerNameFromLink(pName
);
5254 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5255 SetSentErrorMessage(true);
5259 player
= objmgr
.GetPlayer(name
.c_str());
5261 playerGUID
= objmgr
.GetPlayerGUIDByName(name
);
5264 player
= getSelectedPlayer();
5266 if(!player
&& !playerGUID
)
5268 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5269 SetSentErrorMessage(true);
5275 player
->resetSpells();
5277 ChatHandler(player
).SendSysMessage(LANG_RESET_SPELLS
);
5278 if(m_session
->GetPlayer()!=player
)
5279 PSendSysMessage(LANG_RESET_SPELLS_ONLINE
,GetNameLink(player
).c_str());
5283 CharacterDatabase
.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_SPELLS
), GUID_LOPART(playerGUID
));
5284 PSendSysMessage(LANG_RESET_SPELLS_OFFLINE
,pName
);
5290 bool ChatHandler::HandleResetTalentsCommand(const char * args
)
5292 char* pName
= strtok((char*)args
, "");
5293 Player
*player
= NULL
;
5294 uint64 playerGUID
= 0;
5297 std::string name
= extractPlayerNameFromLink(pName
);
5300 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5301 SetSentErrorMessage(true);
5305 player
= objmgr
.GetPlayer(name
.c_str());
5307 playerGUID
= objmgr
.GetPlayerGUIDByName(name
);
5310 player
= getSelectedPlayer();
5314 player
->resetTalents(true);
5316 ChatHandler(player
).SendSysMessage(LANG_RESET_TALENTS
);
5317 if(m_session
->GetPlayer()!=player
)
5318 PSendSysMessage(LANG_RESET_TALENTS_ONLINE
,GetNameLink(player
).c_str());
5322 else if (playerGUID
)
5324 CharacterDatabase
.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE guid = '%u'",uint32(AT_LOGIN_RESET_TALENTS
), GUID_LOPART(playerGUID
) );
5325 std::string nameLink
= playerLink(pName
);
5326 PSendSysMessage(LANG_RESET_TALENTS_OFFLINE
,nameLink
.c_str());
5329 // Try reset talenents as Hunter Pet
5330 Creature
* creature
= getSelectedCreature();
5331 if (creature
&& creature
->isPet() && ((Pet
*)creature
)->getPetType() == HUNTER_PET
)
5333 ((Pet
*)creature
)->resetTalents(true);
5334 Unit
*owner
= creature
->GetOwner();
5335 if (owner
&& owner
->GetTypeId() == TYPEID_PLAYER
)
5337 player
= (Player
*)owner
;
5338 ChatHandler(player
).SendSysMessage(LANG_RESET_PET_TALENTS
);
5339 if(m_session
->GetPlayer()!=player
)
5340 PSendSysMessage(LANG_RESET_PET_TALENTS_ONLINE
,GetNameLink(player
).c_str());
5345 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5346 SetSentErrorMessage(true);
5350 bool ChatHandler::HandleResetAllCommand(const char * args
)
5355 std::string casename
= args
;
5357 AtLoginFlags atLogin
;
5359 // Command specially created as single command to prevent using short case names
5360 if(casename
=="spells")
5362 atLogin
= AT_LOGIN_RESET_SPELLS
;
5363 sWorld
.SendWorldText(LANG_RESETALL_SPELLS
);
5365 else if(casename
=="talents")
5367 atLogin
= AT_LOGIN_RESET_TALENTS
;
5368 sWorld
.SendWorldText(LANG_RESETALL_TALENTS
);
5372 PSendSysMessage(LANG_RESETALL_UNKNOWN_CASE
,args
);
5373 SetSentErrorMessage(true);
5377 CharacterDatabase
.PExecute("UPDATE characters SET at_login = at_login | '%u' WHERE (at_login & '%u') = '0'",atLogin
,atLogin
);
5378 HashMapHolder
<Player
>::MapType
const& plist
= ObjectAccessor::Instance().GetPlayers();
5379 for(HashMapHolder
<Player
>::MapType::const_iterator itr
= plist
.begin(); itr
!= plist
.end(); ++itr
)
5380 itr
->second
->SetAtLoginFlag(atLogin
);
5385 bool ChatHandler::HandleServerShutDownCancelCommand(const char* args
)
5387 sWorld
.ShutdownCancel();
5391 bool ChatHandler::HandleServerShutDownCommand(const char* args
)
5396 char* time_str
= strtok ((char*) args
, " ");
5397 char* exitcode_str
= strtok (NULL
, "");
5399 int32 time
= atoi (time_str
);
5401 ///- Prevent interpret wrong arg value as 0 secs shutdown time
5402 if(time
== 0 && (time_str
[0]!='0' || time_str
[1]!='\0') || time
< 0)
5407 int32 exitcode
= atoi (exitcode_str
);
5409 // Handle atoi() errors
5410 if (exitcode
== 0 && (exitcode_str
[0] != '0' || exitcode_str
[1] != '\0'))
5413 // Exit code should be in range of 0-125, 126-255 is used
5414 // in many shells for their own return codes and code > 255
5415 // is not supported in many others
5416 if (exitcode
< 0 || exitcode
> 125)
5419 sWorld
.ShutdownServ (time
, 0, exitcode
);
5422 sWorld
.ShutdownServ(time
,0,SHUTDOWN_EXIT_CODE
);
5426 bool ChatHandler::HandleServerRestartCommand(const char* args
)
5431 char* time_str
= strtok ((char*) args
, " ");
5432 char* exitcode_str
= strtok (NULL
, "");
5434 int32 time
= atoi (time_str
);
5436 ///- Prevent interpret wrong arg value as 0 secs shutdown time
5437 if(time
== 0 && (time_str
[0]!='0' || time_str
[1]!='\0') || time
< 0)
5442 int32 exitcode
= atoi (exitcode_str
);
5444 // Handle atoi() errors
5445 if (exitcode
== 0 && (exitcode_str
[0] != '0' || exitcode_str
[1] != '\0'))
5448 // Exit code should be in range of 0-125, 126-255 is used
5449 // in many shells for their own return codes and code > 255
5450 // is not supported in many others
5451 if (exitcode
< 0 || exitcode
> 125)
5454 sWorld
.ShutdownServ (time
, SHUTDOWN_MASK_RESTART
, exitcode
);
5457 sWorld
.ShutdownServ(time
, SHUTDOWN_MASK_RESTART
, RESTART_EXIT_CODE
);
5461 bool ChatHandler::HandleServerIdleRestartCommand(const char* args
)
5466 char* time_str
= strtok ((char*) args
, " ");
5467 char* exitcode_str
= strtok (NULL
, "");
5469 int32 time
= atoi (time_str
);
5471 ///- Prevent interpret wrong arg value as 0 secs shutdown time
5472 if(time
== 0 && (time_str
[0]!='0' || time_str
[1]!='\0') || time
< 0)
5477 int32 exitcode
= atoi (exitcode_str
);
5479 // Handle atoi() errors
5480 if (exitcode
== 0 && (exitcode_str
[0] != '0' || exitcode_str
[1] != '\0'))
5483 // Exit code should be in range of 0-125, 126-255 is used
5484 // in many shells for their own return codes and code > 255
5485 // is not supported in many others
5486 if (exitcode
< 0 || exitcode
> 125)
5489 sWorld
.ShutdownServ (time
, SHUTDOWN_MASK_RESTART
|SHUTDOWN_MASK_IDLE
, exitcode
);
5492 sWorld
.ShutdownServ(time
,SHUTDOWN_MASK_RESTART
|SHUTDOWN_MASK_IDLE
,RESTART_EXIT_CODE
);
5496 bool ChatHandler::HandleServerIdleShutDownCommand(const char* args
)
5501 char* time_str
= strtok ((char*) args
, " ");
5502 char* exitcode_str
= strtok (NULL
, "");
5504 int32 time
= atoi (time_str
);
5506 ///- Prevent interpret wrong arg value as 0 secs shutdown time
5507 if(time
== 0 && (time_str
[0]!='0' || time_str
[1]!='\0') || time
< 0)
5512 int32 exitcode
= atoi (exitcode_str
);
5514 // Handle atoi() errors
5515 if (exitcode
== 0 && (exitcode_str
[0] != '0' || exitcode_str
[1] != '\0'))
5518 // Exit code should be in range of 0-125, 126-255 is used
5519 // in many shells for their own return codes and code > 255
5520 // is not supported in many others
5521 if (exitcode
< 0 || exitcode
> 125)
5524 sWorld
.ShutdownServ (time
, SHUTDOWN_MASK_IDLE
, exitcode
);
5527 sWorld
.ShutdownServ(time
,SHUTDOWN_MASK_IDLE
,SHUTDOWN_EXIT_CODE
);
5531 bool ChatHandler::HandleQuestAdd(const char* args
)
5533 Player
* player
= getSelectedPlayer();
5536 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5537 SetSentErrorMessage(true);
5541 // .addquest #entry'
5542 // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r
5543 char* cId
= extractKeyFromLink((char*)args
,"Hquest");
5547 uint32 entry
= atol(cId
);
5549 Quest
const* pQuest
= objmgr
.GetQuestTemplate(entry
);
5553 PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND
,entry
);
5554 SetSentErrorMessage(true);
5558 // check item starting quest (it can work incorrectly if added without item in inventory)
5559 for (uint32 id
= 0; id
< sItemStorage
.MaxEntry
; id
++)
5561 ItemPrototype
const *pProto
= sItemStorage
.LookupEntry
<ItemPrototype
>(id
);
5565 if (pProto
->StartQuest
== entry
)
5567 PSendSysMessage(LANG_COMMAND_QUEST_STARTFROMITEM
, entry
, pProto
->ItemId
);
5568 SetSentErrorMessage(true);
5573 // ok, normal (creature/GO starting) quest
5574 if( player
->CanAddQuest( pQuest
, true ) )
5576 player
->AddQuest( pQuest
, NULL
);
5578 if ( player
->CanCompleteQuest( entry
) )
5579 player
->CompleteQuest( entry
);
5585 bool ChatHandler::HandleQuestRemove(const char* args
)
5587 Player
* player
= getSelectedPlayer();
5590 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5591 SetSentErrorMessage(true);
5595 // .removequest #entry'
5596 // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r
5597 char* cId
= extractKeyFromLink((char*)args
,"Hquest");
5601 uint32 entry
= atol(cId
);
5603 Quest
const* pQuest
= objmgr
.GetQuestTemplate(entry
);
5607 PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND
, entry
);
5608 SetSentErrorMessage(true);
5612 // remove all quest entries for 'entry' from quest log
5613 for(uint8 slot
= 0; slot
< MAX_QUEST_LOG_SIZE
; ++slot
)
5615 uint32 quest
= player
->GetQuestSlotQuestId(slot
);
5618 player
->SetQuestSlot(slot
,0);
5620 // we ignore unequippable quest items in this case, its' still be equipped
5621 player
->TakeQuestSourceItem( quest
, false );
5625 // set quest status to not started (will updated in DB at next save)
5626 player
->SetQuestStatus( entry
, QUEST_STATUS_NONE
);
5628 // reset rewarded for restart repeatable quest
5629 player
->getQuestStatusMap()[entry
].m_rewarded
= false;
5631 SendSysMessage(LANG_COMMAND_QUEST_REMOVED
);
5635 bool ChatHandler::HandleQuestComplete(const char* args
)
5637 Player
* player
= getSelectedPlayer();
5640 SendSysMessage(LANG_NO_CHAR_SELECTED
);
5641 SetSentErrorMessage(true);
5645 // .quest complete #entry
5646 // number or [name] Shift-click form |color|Hquest:quest_id|h[name]|h|r
5647 char* cId
= extractKeyFromLink((char*)args
,"Hquest");
5651 uint32 entry
= atol(cId
);
5653 Quest
const* pQuest
= objmgr
.GetQuestTemplate(entry
);
5655 // If player doesn't have the quest
5656 if(!pQuest
|| player
->GetQuestStatus(entry
) == QUEST_STATUS_NONE
)
5658 PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND
, entry
);
5659 SetSentErrorMessage(true);
5663 // Add quest items for quests that require items
5664 for(uint8 x
= 0; x
< QUEST_OBJECTIVES_COUNT
; ++x
)
5666 uint32 id
= pQuest
->ReqItemId
[x
];
5667 uint32 count
= pQuest
->ReqItemCount
[x
];
5671 uint32 curItemCount
= player
->GetItemCount(id
,true);
5673 ItemPosCountVec dest
;
5674 uint8 msg
= player
->CanStoreNewItem( NULL_BAG
, NULL_SLOT
, dest
, id
, count
-curItemCount
);
5675 if( msg
== EQUIP_ERR_OK
)
5677 Item
* item
= player
->StoreNewItem( dest
, id
, true);
5678 player
->SendNewItem(item
,count
-curItemCount
,true,false);
5682 // All creature/GO slain/casted (not required, but otherwise it will display "Creature slain 0/10")
5683 for(uint8 i
= 0; i
< QUEST_OBJECTIVES_COUNT
; ++i
)
5685 uint32 creature
= pQuest
->ReqCreatureOrGOId
[i
];
5686 uint32 creaturecount
= pQuest
->ReqCreatureOrGOCount
[i
];
5688 if(uint32 spell_id
= pQuest
->ReqSpell
[i
])
5690 for(uint16 z
= 0; z
< creaturecount
; ++z
)
5691 player
->CastedCreatureOrGO(creature
,0,spell_id
);
5693 else if(creature
> 0)
5695 for(uint16 z
= 0; z
< creaturecount
; ++z
)
5696 player
->KilledMonster(creature
,0);
5698 else if(creature
< 0)
5700 for(uint16 z
= 0; z
< creaturecount
; ++z
)
5701 player
->CastedCreatureOrGO(creature
,0,0);
5705 // If the quest requires reputation to complete
5706 if(uint32 repFaction
= pQuest
->GetRepObjectiveFaction())
5708 uint32 repValue
= pQuest
->GetRepObjectiveValue();
5709 uint32 curRep
= player
->GetReputationMgr().GetReputation(repFaction
);
5710 if(curRep
< repValue
)
5711 if(FactionEntry
const *factionEntry
= sFactionStore
.LookupEntry(repFaction
))
5712 player
->GetReputationMgr().SetReputation(factionEntry
,repValue
);
5715 // If the quest requires money
5716 int32 ReqOrRewMoney
= pQuest
->GetRewOrReqMoney();
5717 if(ReqOrRewMoney
< 0)
5718 player
->ModifyMoney(-ReqOrRewMoney
);
5720 player
->CompleteQuest(entry
);
5724 bool ChatHandler::HandleBanAccountCommand(const char* args
)
5726 return HandleBanHelper(BAN_ACCOUNT
,args
);
5729 bool ChatHandler::HandleBanCharacterCommand(const char* args
)
5731 return HandleBanHelper(BAN_CHARACTER
,args
);
5734 bool ChatHandler::HandleBanIPCommand(const char* args
)
5736 return HandleBanHelper(BAN_IP
,args
);
5739 bool ChatHandler::HandleBanHelper(BanMode mode
, const char* args
)
5744 char* cnameOrIP
= strtok ((char*)args
, " ");
5748 std::string nameOrIP
= cnameOrIP
;
5750 char* duration
= strtok (NULL
," ");
5751 if(!duration
|| !atoi(duration
))
5754 char* reason
= strtok (NULL
,"");
5761 if(!AccountMgr::normilizeString(nameOrIP
))
5763 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,nameOrIP
.c_str());
5764 SetSentErrorMessage(true);
5769 if(!normalizePlayerName(nameOrIP
))
5771 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5772 SetSentErrorMessage(true);
5777 if(!IsIPAddress(nameOrIP
.c_str()))
5782 switch(sWorld
.BanAccount(mode
, nameOrIP
, duration
, reason
,m_session
? m_session
->GetPlayerName() : ""))
5785 if(atoi(duration
)>0)
5786 PSendSysMessage(LANG_BAN_YOUBANNED
,nameOrIP
.c_str(),secsToTimeString(TimeStringToSecs(duration
),true).c_str(),reason
);
5788 PSendSysMessage(LANG_BAN_YOUPERMBANNED
,nameOrIP
.c_str(),reason
);
5790 case BAN_SYNTAX_ERROR
:
5796 PSendSysMessage(LANG_BAN_NOTFOUND
,"account",nameOrIP
.c_str());
5799 PSendSysMessage(LANG_BAN_NOTFOUND
,"character",nameOrIP
.c_str());
5802 PSendSysMessage(LANG_BAN_NOTFOUND
,"ip",nameOrIP
.c_str());
5805 SetSentErrorMessage(true);
5812 bool ChatHandler::HandleUnBanAccountCommand(const char* args
)
5814 return HandleUnBanHelper(BAN_ACCOUNT
,args
);
5817 bool ChatHandler::HandleUnBanCharacterCommand(const char* args
)
5819 return HandleUnBanHelper(BAN_CHARACTER
,args
);
5822 bool ChatHandler::HandleUnBanIPCommand(const char* args
)
5824 return HandleUnBanHelper(BAN_IP
,args
);
5827 bool ChatHandler::HandleUnBanHelper(BanMode mode
, const char* args
)
5832 char* cnameOrIP
= strtok ((char*)args
, " ");
5836 std::string nameOrIP
= cnameOrIP
;
5841 if(!AccountMgr::normilizeString(nameOrIP
))
5843 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,nameOrIP
.c_str());
5844 SetSentErrorMessage(true);
5849 if(!normalizePlayerName(nameOrIP
))
5851 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5852 SetSentErrorMessage(true);
5857 if(!IsIPAddress(nameOrIP
.c_str()))
5862 if(sWorld
.RemoveBanAccount(mode
,nameOrIP
))
5863 PSendSysMessage(LANG_UNBAN_UNBANNED
,nameOrIP
.c_str());
5865 PSendSysMessage(LANG_UNBAN_ERROR
,nameOrIP
.c_str());
5870 bool ChatHandler::HandleBanInfoAccountCommand(const char* args
)
5875 char* cname
= strtok((char*)args
, "");
5879 std::string account_name
= cname
;
5880 if(!AccountMgr::normilizeString(account_name
))
5882 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
5883 SetSentErrorMessage(true);
5887 uint32 accountid
= accmgr
.GetId(account_name
);
5890 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
5894 return HandleBanInfoHelper(accountid
,account_name
.c_str());
5897 bool ChatHandler::HandleBanInfoCharacterCommand(const char* args
)
5902 std::string name
= extractPlayerNameFromLink((char*)args
);
5905 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5906 SetSentErrorMessage(true);
5910 uint32 accountid
= objmgr
.GetPlayerAccountIdByPlayerName(name
);
5913 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
5914 SetSentErrorMessage(true);
5918 std::string accountname
;
5919 if(!accmgr
.GetName(accountid
,accountname
))
5921 PSendSysMessage(LANG_BANINFO_NOCHARACTER
);
5925 return HandleBanInfoHelper(accountid
,accountname
.c_str());
5928 bool ChatHandler::HandleBanInfoHelper(uint32 accountid
, char const* accountname
)
5930 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
);
5933 PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN
, accountname
);
5937 PSendSysMessage(LANG_BANINFO_BANHISTORY
,accountname
);
5940 Field
* fields
= result
->Fetch();
5942 time_t unbandate
= time_t(fields
[3].GetUInt64());
5943 bool active
= false;
5944 if(fields
[2].GetBool() && (fields
[1].GetUInt64() == (uint64
)0 ||unbandate
>= time(NULL
)) )
5946 bool permanent
= (fields
[1].GetUInt64() == (uint64
)0);
5947 std::string bantime
= permanent
?GetMangosString(LANG_BANINFO_INFINITE
):secsToTimeString(fields
[1].GetUInt64(), true);
5948 PSendSysMessage(LANG_BANINFO_HISTORYENTRY
,
5949 fields
[0].GetString(), bantime
.c_str(), active
? GetMangosString(LANG_BANINFO_YES
):GetMangosString(LANG_BANINFO_NO
), fields
[4].GetString(), fields
[5].GetString());
5950 }while (result
->NextRow());
5956 bool ChatHandler::HandleBanInfoIPCommand(const char* args
)
5961 char* cIP
= strtok ((char*)args
, "");
5965 if (!IsIPAddress(cIP
))
5968 std::string IP
= cIP
;
5970 loginDatabase
.escape_string(IP
);
5971 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());
5974 PSendSysMessage(LANG_BANINFO_NOIP
);
5978 Field
*fields
= result
->Fetch();
5979 bool permanent
= !fields
[6].GetUInt64();
5980 PSendSysMessage(LANG_BANINFO_IPENTRY
,
5981 fields
[0].GetString(), fields
[1].GetString(), permanent
? GetMangosString(LANG_BANINFO_NEVER
):fields
[2].GetString(),
5982 permanent
? GetMangosString(LANG_BANINFO_INFINITE
):secsToTimeString(fields
[3].GetUInt64(), true).c_str(), fields
[4].GetString(), fields
[5].GetString());
5987 bool ChatHandler::HandleBanListCharacterCommand(const char* args
)
5989 loginDatabase
.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
5991 char* cFilter
= strtok ((char*)args
, " ");
5995 std::string filter
= cFilter
;
5996 loginDatabase
.escape_string(filter
);
5997 QueryResult
* result
= CharacterDatabase
.PQuery("SELECT account FROM characters WHERE name "_LIKE_
" "_CONCAT3_("'%%'","'%s'","'%%'"),filter
.c_str());
6000 PSendSysMessage(LANG_BANLIST_NOCHARACTER
);
6004 return HandleBanListHelper(result
);
6007 bool ChatHandler::HandleBanListAccountCommand(const char* args
)
6009 loginDatabase
.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
6011 char* cFilter
= strtok((char*)args
, " ");
6012 std::string filter
= cFilter
? cFilter
: "";
6013 loginDatabase
.escape_string(filter
);
6015 QueryResult
* result
;
6019 result
= loginDatabase
.Query("SELECT account.id, username FROM account, account_banned"
6020 " WHERE account.id = account_banned.id AND active = 1 GROUP BY account.id");
6024 result
= loginDatabase
.PQuery("SELECT account.id, username FROM account, account_banned"
6025 " WHERE account.id = account_banned.id AND active = 1 AND username "_LIKE_
" "_CONCAT3_("'%%'","'%s'","'%%'")" GROUP BY account.id",
6031 PSendSysMessage(LANG_BANLIST_NOACCOUNT
);
6035 return HandleBanListHelper(result
);
6038 bool ChatHandler::HandleBanListHelper(QueryResult
* result
)
6040 PSendSysMessage(LANG_BANLIST_MATCHINGACCOUNT
);
6042 // Chat short output
6047 Field
* fields
= result
->Fetch();
6048 uint32 accountid
= fields
[0].GetUInt32();
6050 QueryResult
* banresult
= loginDatabase
.PQuery("SELECT account.username FROM account,account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id",accountid
);
6053 Field
* fields2
= banresult
->Fetch();
6054 PSendSysMessage("%s",fields2
[0].GetString());
6057 } while (result
->NextRow());
6059 // Console wide output
6062 SendSysMessage(LANG_BANLIST_ACCOUNTS
);
6063 SendSysMessage("===============================================================================");
6064 SendSysMessage(LANG_BANLIST_ACCOUNTS_HEADER
);
6067 SendSysMessage("-------------------------------------------------------------------------------");
6068 Field
*fields
= result
->Fetch();
6069 uint32 account_id
= fields
[0].GetUInt32 ();
6071 std::string account_name
;
6073 // "account" case, name can be get in same query
6074 if(result
->GetFieldCount() > 1)
6075 account_name
= fields
[1].GetCppString();
6076 // "character" case, name need extract from another DB
6078 accmgr
.GetName (account_id
,account_name
);
6080 // No SQL injection. id is uint32.
6081 QueryResult
*banInfo
= loginDatabase
.PQuery("SELECT bandate,unbandate,bannedby,banreason FROM account_banned WHERE id = %u ORDER BY unbandate", account_id
);
6084 Field
*fields2
= banInfo
->Fetch();
6087 time_t t_ban
= fields2
[0].GetUInt64();
6088 tm
* aTm_ban
= localtime(&t_ban
);
6090 if (fields2
[0].GetUInt64() == fields2
[1].GetUInt64())
6092 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
6093 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
,
6094 fields2
[2].GetString(),fields2
[3].GetString());
6098 time_t t_unban
= fields2
[1].GetUInt64();
6099 tm
* aTm_unban
= localtime(&t_unban
);
6100 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
6101 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
,
6102 aTm_unban
->tm_year
%100, aTm_unban
->tm_mon
+1, aTm_unban
->tm_mday
, aTm_unban
->tm_hour
, aTm_unban
->tm_min
,
6103 fields2
[2].GetString(),fields2
[3].GetString());
6105 }while ( banInfo
->NextRow() );
6108 }while( result
->NextRow() );
6109 SendSysMessage("===============================================================================");
6116 bool ChatHandler::HandleBanListIPCommand(const char* args
)
6118 loginDatabase
.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
6120 char* cFilter
= strtok((char*)args
, " ");
6121 std::string filter
= cFilter
? cFilter
: "";
6122 loginDatabase
.escape_string(filter
);
6124 QueryResult
* result
;
6128 result
= loginDatabase
.Query ("SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
6129 " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP())"
6130 " ORDER BY unbandate" );
6134 result
= loginDatabase
.PQuery( "SELECT ip,bandate,unbandate,bannedby,banreason FROM ip_banned"
6135 " WHERE (bandate=unbandate OR unbandate>UNIX_TIMESTAMP()) AND ip "_LIKE_
" "_CONCAT3_("'%%'","'%s'","'%%'")
6136 " ORDER BY unbandate",filter
.c_str() );
6141 PSendSysMessage(LANG_BANLIST_NOIP
);
6145 PSendSysMessage(LANG_BANLIST_MATCHINGIP
);
6146 // Chat short output
6151 Field
* fields
= result
->Fetch();
6152 PSendSysMessage("%s",fields
[0].GetString());
6153 } while (result
->NextRow());
6155 // Console wide output
6158 SendSysMessage(LANG_BANLIST_IPS
);
6159 SendSysMessage("===============================================================================");
6160 SendSysMessage(LANG_BANLIST_IPS_HEADER
);
6163 SendSysMessage("-------------------------------------------------------------------------------");
6164 Field
*fields
= result
->Fetch();
6165 time_t t_ban
= fields
[1].GetUInt64();
6166 tm
* aTm_ban
= localtime(&t_ban
);
6167 if ( fields
[1].GetUInt64() == fields
[2].GetUInt64() )
6169 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|",
6170 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
,
6171 fields
[3].GetString(), fields
[4].GetString());
6175 time_t t_unban
= fields
[2].GetUInt64();
6176 tm
* aTm_unban
= localtime(&t_unban
);
6177 PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|",
6178 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
,
6179 aTm_unban
->tm_year
%100, aTm_unban
->tm_mon
+1, aTm_unban
->tm_mday
, aTm_unban
->tm_hour
, aTm_unban
->tm_min
,
6180 fields
[3].GetString(), fields
[4].GetString());
6182 }while( result
->NextRow() );
6183 SendSysMessage("===============================================================================");
6190 bool ChatHandler::HandleRespawnCommand(const char* /*args*/)
6192 Player
* pl
= m_session
->GetPlayer();
6194 // accept only explicitly selected target (not implicitly self targeting case)
6195 Unit
* target
= getSelectedUnit();
6196 if(pl
->GetSelection() && target
)
6198 if(target
->GetTypeId()!=TYPEID_UNIT
)
6200 SendSysMessage(LANG_SELECT_CREATURE
);
6201 SetSentErrorMessage(true);
6205 if(target
->isDead())
6206 ((Creature
*)target
)->Respawn();
6210 CellPair
p(MaNGOS::ComputeCellPair(pl
->GetPositionX(), pl
->GetPositionY()));
6212 cell
.data
.Part
.reserved
= ALL_DISTRICT
;
6215 MaNGOS::RespawnDo u_do
;
6216 MaNGOS::WorldObjectWorker
<MaNGOS::RespawnDo
> worker(pl
,u_do
);
6218 TypeContainerVisitor
<MaNGOS::WorldObjectWorker
<MaNGOS::RespawnDo
>, GridTypeMapContainer
> obj_worker(worker
);
6219 CellLock
<GridReadGuard
> cell_lock(cell
, p
);
6220 cell_lock
->Visit(cell_lock
, obj_worker
, *pl
->GetMap());
6225 bool ChatHandler::HandleGMFlyCommand(const char* args
)
6230 Player
*target
= getSelectedPlayer();
6232 target
= m_session
->GetPlayer();
6234 WorldPacket
data(12);
6235 if (strncmp(args
, "on", 3) == 0)
6236 data
.SetOpcode(SMSG_MOVE_SET_CAN_FLY
);
6237 else if (strncmp(args
, "off", 4) == 0)
6238 data
.SetOpcode(SMSG_MOVE_UNSET_CAN_FLY
);
6241 SendSysMessage(LANG_USE_BOL
);
6244 data
.append(target
->GetPackGUID());
6245 data
<< uint32(0); // unknown
6246 target
->SendMessageToSet(&data
, true);
6247 PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS
, GetNameLink(target
).c_str(), args
);
6251 bool ChatHandler::HandlePDumpLoadCommand(const char *args
)
6256 char * file
= strtok((char*)args
, " ");
6260 char * account
= strtok(NULL
, " ");
6264 std::string account_name
= account
;
6265 if(!AccountMgr::normilizeString(account_name
))
6267 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
6268 SetSentErrorMessage(true);
6272 uint32 account_id
= accmgr
.GetId(account_name
);
6275 account_id
= atoi(account
); // use original string
6278 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
6279 SetSentErrorMessage(true);
6284 if(!accmgr
.GetName(account_id
,account_name
))
6286 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
6287 SetSentErrorMessage(true);
6291 char* guid_str
= NULL
;
6292 char* name_str
= strtok(NULL
, " ");
6298 // normalize the name if specified and check if it exists
6299 if(!normalizePlayerName(name
))
6301 PSendSysMessage(LANG_INVALID_CHARACTER_NAME
);
6302 SetSentErrorMessage(true);
6306 if(!ObjectMgr::IsValidName(name
,true))
6308 PSendSysMessage(LANG_INVALID_CHARACTER_NAME
);
6309 SetSentErrorMessage(true);
6313 guid_str
= strtok(NULL
, " ");
6320 guid
= atoi(guid_str
);
6323 PSendSysMessage(LANG_INVALID_CHARACTER_GUID
);
6324 SetSentErrorMessage(true);
6328 if(objmgr
.GetPlayerAccountIdByGUID(guid
))
6330 PSendSysMessage(LANG_CHARACTER_GUID_IN_USE
,guid
);
6331 SetSentErrorMessage(true);
6336 switch(PlayerDumpReader().LoadDump(file
, account_id
, name
, guid
))
6339 PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS
);
6341 case DUMP_FILE_OPEN_ERROR
:
6342 PSendSysMessage(LANG_FILE_OPEN_FAIL
,file
);
6343 SetSentErrorMessage(true);
6345 case DUMP_FILE_BROKEN
:
6346 PSendSysMessage(LANG_DUMP_BROKEN
,file
);
6347 SetSentErrorMessage(true);
6349 case DUMP_TOO_MANY_CHARS
:
6350 PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL
,account_name
.c_str(),account_id
);
6351 SetSentErrorMessage(true);
6354 PSendSysMessage(LANG_COMMAND_IMPORT_FAILED
);
6355 SetSentErrorMessage(true);
6362 bool ChatHandler::HandlePDumpWriteCommand(const char *args
)
6367 char* file
= strtok((char*)args
, " ");
6368 char* p2
= strtok(NULL
, " ");
6374 // character name can't start from number
6375 if (isNumeric(p2
[0]))
6379 std::string name
= extractPlayerNameFromLink(p2
);
6382 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
6383 SetSentErrorMessage(true);
6387 guid
= objmgr
.GetPlayerGUIDByName(name
);
6390 if(!objmgr
.GetPlayerAccountIdByGUID(guid
))
6392 PSendSysMessage(LANG_PLAYER_NOT_FOUND
);
6393 SetSentErrorMessage(true);
6397 switch(PlayerDumpWriter().WriteDump(file
, guid
))
6400 PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS
);
6402 case DUMP_FILE_OPEN_ERROR
:
6403 PSendSysMessage(LANG_FILE_OPEN_FAIL
,file
);
6404 SetSentErrorMessage(true);
6407 PSendSysMessage(LANG_COMMAND_EXPORT_FAILED
);
6408 SetSentErrorMessage(true);
6415 bool ChatHandler::HandleMovegensCommand(const char* /*args*/)
6417 Unit
* unit
= getSelectedUnit();
6420 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
6421 SetSentErrorMessage(true);
6425 PSendSysMessage(LANG_MOVEGENS_LIST
,(unit
->GetTypeId()==TYPEID_PLAYER
? "Player" : "Creature" ),unit
->GetGUIDLow());
6427 MotionMaster
* mm
= unit
->GetMotionMaster();
6428 for(MotionMaster::const_iterator itr
= mm
->begin(); itr
!= mm
->end(); ++itr
)
6430 switch((*itr
)->GetMovementGeneratorType())
6432 case IDLE_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_IDLE
); break;
6433 case RANDOM_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_RANDOM
); break;
6434 case WAYPOINT_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_WAYPOINT
); break;
6435 case ANIMAL_RANDOM_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_ANIMAL_RANDOM
); break;
6436 case CONFUSED_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_CONFUSED
); break;
6437 case TARGETED_MOTION_TYPE
:
6439 if(unit
->GetTypeId()==TYPEID_PLAYER
)
6441 TargetedMovementGenerator
<Player
> const* mgen
= static_cast<TargetedMovementGenerator
<Player
> const*>(*itr
);
6442 Unit
* target
= mgen
->GetTarget();
6444 PSendSysMessage(LANG_MOVEGENS_TARGETED_PLAYER
,target
->GetName(),target
->GetGUIDLow());
6446 SendSysMessage(LANG_MOVEGENS_TARGETED_NULL
);
6450 TargetedMovementGenerator
<Creature
> const* mgen
= static_cast<TargetedMovementGenerator
<Creature
> const*>(*itr
);
6451 Unit
* target
= mgen
->GetTarget();
6453 PSendSysMessage(LANG_MOVEGENS_TARGETED_CREATURE
,target
->GetName(),target
->GetGUIDLow());
6455 SendSysMessage(LANG_MOVEGENS_TARGETED_NULL
);
6459 case HOME_MOTION_TYPE
:
6460 if(unit
->GetTypeId()==TYPEID_UNIT
)
6463 (*itr
)->GetDestination(x
,y
,z
);
6464 PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE
,x
,y
,z
);
6467 SendSysMessage(LANG_MOVEGENS_HOME_PLAYER
);
6469 case FLIGHT_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_FLIGHT
); break;
6470 case POINT_MOTION_TYPE
:
6473 (*itr
)->GetDestination(x
,y
,z
);
6474 PSendSysMessage(LANG_MOVEGENS_POINT
,x
,y
,z
);
6477 case FLEEING_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_FEAR
); break;
6478 case DISTRACT_MOTION_TYPE
: SendSysMessage(LANG_MOVEGENS_DISTRACT
); break;
6480 PSendSysMessage(LANG_MOVEGENS_UNKNOWN
,(*itr
)->GetMovementGeneratorType());
6487 bool ChatHandler::HandleServerPLimitCommand(const char *args
)
6491 char* param
= strtok((char*)args
, " ");
6495 int l
= strlen(param
);
6497 if( strncmp(param
,"player",l
) == 0 )
6498 sWorld
.SetPlayerLimit(-SEC_PLAYER
);
6499 else if(strncmp(param
,"moderator",l
) == 0 )
6500 sWorld
.SetPlayerLimit(-SEC_MODERATOR
);
6501 else if(strncmp(param
,"gamemaster",l
) == 0 )
6502 sWorld
.SetPlayerLimit(-SEC_GAMEMASTER
);
6503 else if(strncmp(param
,"administrator",l
) == 0 )
6504 sWorld
.SetPlayerLimit(-SEC_ADMINISTRATOR
);
6505 else if(strncmp(param
,"reset",l
) == 0 )
6506 sWorld
.SetPlayerLimit( sConfig
.GetIntDefault("PlayerLimit", DEFAULT_PLAYER_LIMIT
) );
6509 int val
= atoi(param
);
6510 if(val
< -SEC_ADMINISTRATOR
) val
= -SEC_ADMINISTRATOR
;
6512 sWorld
.SetPlayerLimit(val
);
6515 // kick all low security level players
6516 if(sWorld
.GetPlayerAmountLimit() > SEC_PLAYER
)
6517 sWorld
.KickAllLess(sWorld
.GetPlayerSecurityLimit());
6520 uint32 pLimit
= sWorld
.GetPlayerAmountLimit();
6521 AccountTypes allowedAccountType
= sWorld
.GetPlayerSecurityLimit();
6522 char const* secName
= "";
6523 switch(allowedAccountType
)
6525 case SEC_PLAYER
: secName
= "Player"; break;
6526 case SEC_MODERATOR
: secName
= "Moderator"; break;
6527 case SEC_GAMEMASTER
: secName
= "Gamemaster"; break;
6528 case SEC_ADMINISTRATOR
: secName
= "Administrator"; break;
6529 default: secName
= "<unknown>"; break;
6532 PSendSysMessage("Player limits: amount %u, min. security level %s.",pLimit
,secName
);
6537 bool ChatHandler::HandleCastCommand(const char* args
)
6542 Unit
* target
= getSelectedUnit();
6546 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
6547 SetSentErrorMessage(true);
6551 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
6552 uint32 spell
= extractSpellIdFromLink((char*)args
);
6556 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
6560 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
6562 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
6563 SetSentErrorMessage(true);
6567 char* trig_str
= strtok(NULL
, " ");
6570 int l
= strlen(trig_str
);
6571 if(strncmp(trig_str
,"triggered",l
) != 0 )
6575 bool triggered
= (trig_str
!= NULL
);
6577 m_session
->GetPlayer()->CastSpell(target
,spell
,triggered
);
6582 bool ChatHandler::HandleCastBackCommand(const char* args
)
6584 Creature
* caster
= getSelectedCreature();
6588 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
6589 SetSentErrorMessage(true);
6593 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r
6594 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
6595 uint32 spell
= extractSpellIdFromLink((char*)args
);
6596 if(!spell
|| !sSpellStore
.LookupEntry(spell
))
6599 char* trig_str
= strtok(NULL
, " ");
6602 int l
= strlen(trig_str
);
6603 if(strncmp(trig_str
,"triggered",l
) != 0 )
6607 bool triggered
= (trig_str
!= NULL
);
6609 // update orientation at server
6610 caster
->SetOrientation(caster
->GetAngle(m_session
->GetPlayer()));
6614 caster
->BuildHeartBeatMsg(&data
);
6615 caster
->SendMessageToSet(&data
,true);
6617 caster
->CastSpell(m_session
->GetPlayer(),spell
,triggered
);
6622 bool ChatHandler::HandleCastDistCommand(const char* args
)
6627 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
6628 uint32 spell
= extractSpellIdFromLink((char*)args
);
6632 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
6636 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
6638 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
6639 SetSentErrorMessage(true);
6643 char *distStr
= strtok(NULL
, " ");
6648 sscanf(distStr
, "%f", &dist
);
6650 char* trig_str
= strtok(NULL
, " ");
6653 int l
= strlen(trig_str
);
6654 if(strncmp(trig_str
,"triggered",l
) != 0 )
6658 bool triggered
= (trig_str
!= NULL
);
6661 m_session
->GetPlayer()->GetClosePoint(x
,y
,z
,dist
);
6663 m_session
->GetPlayer()->CastSpell(x
,y
,z
,spell
,triggered
);
6667 bool ChatHandler::HandleCastTargetCommand(const char* args
)
6669 Creature
* caster
= getSelectedCreature();
6673 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
6674 SetSentErrorMessage(true);
6678 if(!caster
->getVictim())
6680 SendSysMessage(LANG_SELECTED_TARGET_NOT_HAVE_VICTIM
);
6681 SetSentErrorMessage(true);
6685 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
6686 uint32 spell
= extractSpellIdFromLink((char*)args
);
6687 if(!spell
|| !sSpellStore
.LookupEntry(spell
))
6690 char* trig_str
= strtok(NULL
, " ");
6693 int l
= strlen(trig_str
);
6694 if(strncmp(trig_str
,"triggered",l
) != 0 )
6698 bool triggered
= (trig_str
!= NULL
);
6700 // update orientation at server
6701 caster
->SetOrientation(caster
->GetAngle(m_session
->GetPlayer()));
6705 caster
->BuildHeartBeatMsg(&data
);
6706 caster
->SendMessageToSet(&data
,true);
6708 caster
->CastSpell(caster
->getVictim(),spell
,triggered
);
6714 ComeToMe command REQUIRED for 3rd party scripting library to have access to PointMovementGenerator
6715 Without this function 3rd party scripting library will get linking errors (unresolved external)
6716 when attempting to use the PointMovementGenerator
6718 bool ChatHandler::HandleComeToMeCommand(const char *args
)
6720 Creature
* caster
= getSelectedCreature();
6724 SendSysMessage(LANG_SELECT_CREATURE
);
6725 SetSentErrorMessage(true);
6729 char* newFlagStr
= strtok((char*)args
, " ");
6734 uint32 newFlags
= atoi(newFlagStr
);
6736 caster
->SetUnitMovementFlags(newFlags
);
6738 Player
* pl
= m_session
->GetPlayer();
6740 caster
->GetMotionMaster()->MovePoint(0, pl
->GetPositionX(), pl
->GetPositionY(), pl
->GetPositionZ());
6744 bool ChatHandler::HandleCastSelfCommand(const char* args
)
6749 Unit
* target
= getSelectedUnit();
6753 SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE
);
6754 SetSentErrorMessage(true);
6758 // number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
6759 uint32 spell
= extractSpellIdFromLink((char*)args
);
6763 SpellEntry
const* spellInfo
= sSpellStore
.LookupEntry(spell
);
6767 if(!SpellMgr::IsSpellValid(spellInfo
,m_session
->GetPlayer()))
6769 PSendSysMessage(LANG_COMMAND_SPELL_BROKEN
,spell
);
6770 SetSentErrorMessage(true);
6774 target
->CastSpell(target
,spell
,false);
6779 std::string
GetTimeString(uint32 time
)
6781 uint16 days
= time
/ DAY
, hours
= (time
% DAY
) / HOUR
, minute
= (time
% HOUR
) / MINUTE
;
6782 std::ostringstream ss
;
6783 if(days
) ss
<< days
<< "d ";
6784 if(hours
) ss
<< hours
<< "h ";
6785 ss
<< minute
<< "m";
6789 bool ChatHandler::HandleInstanceListBindsCommand(const char* /*args*/)
6791 Player
* player
= getSelectedPlayer();
6792 if (!player
) player
= m_session
->GetPlayer();
6794 for(uint8 i
= 0; i
< TOTAL_DIFFICULTIES
; ++i
)
6796 Player::BoundInstancesMap
&binds
= player
->GetBoundInstances(i
);
6797 for(Player::BoundInstancesMap::const_iterator itr
= binds
.begin(); itr
!= binds
.end(); ++itr
)
6799 InstanceSave
*save
= itr
->second
.save
;
6800 std::string timeleft
= GetTimeString(save
->GetResetTime() - time(NULL
));
6801 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());
6805 PSendSysMessage("player binds: %d", counter
);
6807 Group
*group
= player
->GetGroup();
6810 for(uint8 i
= 0; i
< TOTAL_DIFFICULTIES
; ++i
)
6812 Group::BoundInstancesMap
&binds
= group
->GetBoundInstances(i
);
6813 for(Group::BoundInstancesMap::const_iterator itr
= binds
.begin(); itr
!= binds
.end(); ++itr
)
6815 InstanceSave
*save
= itr
->second
.save
;
6816 std::string timeleft
= GetTimeString(save
->GetResetTime() - time(NULL
));
6817 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());
6822 PSendSysMessage("group binds: %d", counter
);
6827 bool ChatHandler::HandleInstanceUnbindCommand(const char* args
)
6832 std::string cmd
= args
;
6835 Player
* player
= getSelectedPlayer();
6836 if (!player
) player
= m_session
->GetPlayer();
6838 for(uint8 i
= 0; i
< TOTAL_DIFFICULTIES
; ++i
)
6840 Player::BoundInstancesMap
&binds
= player
->GetBoundInstances(i
);
6841 for(Player::BoundInstancesMap::iterator itr
= binds
.begin(); itr
!= binds
.end();)
6843 if(itr
->first
!= player
->GetMapId())
6845 InstanceSave
*save
= itr
->second
.save
;
6846 std::string timeleft
= GetTimeString(save
->GetResetTime() - time(NULL
));
6847 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());
6848 player
->UnbindInstance(itr
, i
);
6855 PSendSysMessage("instances unbound: %d", counter
);
6860 bool ChatHandler::HandleInstanceStatsCommand(const char* /*args*/)
6862 PSendSysMessage("instances loaded: %d", MapManager::Instance().GetNumInstances());
6863 PSendSysMessage("players in instances: %d", MapManager::Instance().GetNumPlayersInInstances());
6864 PSendSysMessage("instance saves: %d", sInstanceSaveManager
.GetNumInstanceSaves());
6865 PSendSysMessage("players bound: %d", sInstanceSaveManager
.GetNumBoundPlayersTotal());
6866 PSendSysMessage("groups bound: %d", sInstanceSaveManager
.GetNumBoundGroupsTotal());
6870 bool ChatHandler::HandleInstanceSaveDataCommand(const char * /*args*/)
6872 Player
* pl
= m_session
->GetPlayer();
6874 Map
* map
= pl
->GetMap();
6875 if (!map
->IsDungeon())
6877 PSendSysMessage("Map is not a dungeon.");
6878 SetSentErrorMessage(true);
6882 if (!((InstanceMap
*)map
)->GetInstanceData())
6884 PSendSysMessage("Map has no instance data.");
6885 SetSentErrorMessage(true);
6889 ((InstanceMap
*)map
)->GetInstanceData()->SaveToDB();
6893 /// Display the list of GMs
6894 bool ChatHandler::HandleGMListFullCommand(const char* /*args*/)
6896 ///- Get the accounts with GM Level >0
6897 QueryResult
*result
= loginDatabase
.Query( "SELECT username,gmlevel FROM account WHERE gmlevel > 0" );
6900 SendSysMessage(LANG_GMLIST
);
6901 SendSysMessage("========================");
6902 SendSysMessage(LANG_GMLIST_HEADER
);
6903 SendSysMessage("========================");
6905 ///- Circle through them. Display username and GM level
6908 Field
*fields
= result
->Fetch();
6909 PSendSysMessage("|%15s|%6s|", fields
[0].GetString(),fields
[1].GetString());
6910 }while( result
->NextRow() );
6912 PSendSysMessage("========================");
6916 PSendSysMessage(LANG_GMLIST_EMPTY
);
6920 /// Define the 'Message of the day' for the realm
6921 bool ChatHandler::HandleServerSetMotdCommand(const char* args
)
6923 sWorld
.SetMotd(args
);
6924 PSendSysMessage(LANG_MOTD_NEW
, args
);
6928 /// Set/Unset the expansion level for an account
6929 bool ChatHandler::HandleAccountSetAddonCommand(const char* args
)
6931 ///- Get the command line arguments
6932 char *szAcc
= strtok((char*)args
," ");
6933 char *szExp
= strtok(NULL
," ");
6938 std::string account_name
;
6943 Player
* player
= getSelectedPlayer();
6947 account_id
= player
->GetSession()->GetAccountId();
6948 accmgr
.GetName(account_id
,account_name
);
6953 ///- Convert Account name to Upper Format
6954 account_name
= szAcc
;
6955 if(!AccountMgr::normilizeString(account_name
))
6957 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
6958 SetSentErrorMessage(true);
6962 account_id
= accmgr
.GetId(account_name
);
6965 PSendSysMessage(LANG_ACCOUNT_NOT_EXIST
,account_name
.c_str());
6966 SetSentErrorMessage(true);
6972 // Let set addon state only for lesser (strong) security level
6973 // or to self account
6974 if (m_session
&& m_session
->GetAccountId () != account_id
&&
6975 HasLowerSecurityAccount (NULL
,account_id
,true))
6978 int lev
=atoi(szExp
); //get int anyway (0 if error)
6983 loginDatabase
.PExecute("UPDATE account SET expansion = '%d' WHERE id = '%u'",lev
,account_id
);
6984 PSendSysMessage(LANG_ACCOUNT_SETADDON
,account_name
.c_str(),account_id
,lev
);
6988 //Send items by mail
6989 bool ChatHandler::HandleSendItemsCommand(const char* args
)
6994 // format: name "subject text" "mail text" item1[:count1] item2[:count2] ... item12[:count12]
6996 std::string name
= extractPlayerNameFromLink((char*)args
);
6999 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7000 SetSentErrorMessage(true);
7004 char* tail1
= strtok(NULL
, "");
7010 msgSubject
= strtok(tail1
+1, "\"");
7013 char* space
= strtok(tail1
, "\"");
7016 msgSubject
= strtok(NULL
, "\"");
7022 char* tail2
= strtok(NULL
, "");
7028 msgText
= strtok(tail2
+1, "\"");
7031 char* space
= strtok(tail2
, "\"");
7034 msgText
= strtok(NULL
, "\"");
7040 // msgSubject, msgText isn't NUL after prev. check
7041 std::string subject
= msgSubject
;
7042 std::string text
= msgText
;
7045 typedef std::pair
<uint32
,uint32
> ItemPair
;
7046 typedef std::list
< ItemPair
> ItemPairs
;
7049 // get all tail string
7050 char* tail
= strtok(NULL
, "");
7052 // get from tail next item str
7053 while(char* itemStr
= strtok(tail
, " "))
7056 tail
= strtok(NULL
, "");
7059 char* itemIdStr
= strtok(itemStr
, ":");
7060 char* itemCountStr
= strtok(NULL
, " ");
7062 uint32 item_id
= atoi(itemIdStr
);
7066 ItemPrototype
const* item_proto
= objmgr
.GetItemPrototype(item_id
);
7069 PSendSysMessage(LANG_COMMAND_ITEMIDINVALID
, item_id
);
7070 SetSentErrorMessage(true);
7074 uint32 item_count
= itemCountStr
? atoi(itemCountStr
) : 1;
7075 if(item_count
< 1 || item_proto
->MaxCount
> 0 && item_count
> uint32(item_proto
->MaxCount
))
7077 PSendSysMessage(LANG_COMMAND_INVALID_ITEM_COUNT
, item_count
,item_id
);
7078 SetSentErrorMessage(true);
7082 while(item_count
> item_proto
->GetMaxStackSize())
7084 items
.push_back(ItemPair(item_id
,item_proto
->GetMaxStackSize()));
7085 item_count
-= item_proto
->GetMaxStackSize();
7088 items
.push_back(ItemPair(item_id
,item_count
));
7090 if(items
.size() > MAX_MAIL_ITEMS
)
7092 PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT
, MAX_MAIL_ITEMS
);
7093 SetSentErrorMessage(true);
7098 uint64 receiver_guid
= objmgr
.GetPlayerGUIDByName(name
);
7101 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7102 SetSentErrorMessage(true);
7106 // from console show not existed sender
7107 uint32 sender_guidlo
= m_session
? m_session
->GetPlayer()->GetGUIDLow() : 0;
7109 uint32 messagetype
= MAIL_NORMAL
;
7110 uint32 stationery
= MAIL_STATIONERY_GM
;
7111 uint32 itemTextId
= !text
.empty() ? objmgr
.CreateItemText( text
) : 0;
7113 Player
*receiver
= objmgr
.GetPlayer(receiver_guid
);
7116 MailItemsInfo mi
; // item list preparing
7118 for(ItemPairs::const_iterator itr
= items
.begin(); itr
!= items
.end(); ++itr
)
7120 if(Item
* item
= Item::CreateItem(itr
->first
,itr
->second
,m_session
? m_session
->GetPlayer() : 0))
7122 item
->SaveToDB(); // save for prevent lost at next mail load, if send fail then item will deleted
7123 mi
.AddItem(item
->GetGUIDLow(), item
->GetEntry(), item
);
7127 WorldSession::SendMailTo(receiver
,messagetype
, stationery
, sender_guidlo
, GUID_LOPART(receiver_guid
), subject
, itemTextId
, &mi
, 0, 0, MAIL_CHECK_MASK_NONE
);
7129 std::string nameLink
= playerLink(name
);
7130 PSendSysMessage(LANG_MAIL_SENT
, nameLink
.c_str());
7134 ///Send money by mail
7135 bool ChatHandler::HandleSendMoneyCommand(const char* args
)
7140 /// format: name "subject text" "mail text" money
7142 std::string name
= extractPlayerNameFromLink((char*)args
);
7145 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7146 SetSentErrorMessage(true);
7150 char* tail1
= strtok(NULL
, "");
7156 msgSubject
= strtok(tail1
+1, "\"");
7159 char* space
= strtok(tail1
, "\"");
7162 msgSubject
= strtok(NULL
, "\"");
7168 char* tail2
= strtok(NULL
, "");
7174 msgText
= strtok(tail2
+1, "\"");
7177 char* space
= strtok(tail2
, "\"");
7180 msgText
= strtok(NULL
, "\"");
7186 char* money_str
= strtok(NULL
, "");
7187 int32 money
= money_str
? atoi(money_str
) : 0;
7191 // msgSubject, msgText isn't NUL after prev. check
7192 std::string subject
= msgSubject
;
7193 std::string text
= msgText
;
7195 uint64 receiver_guid
= objmgr
.GetPlayerGUIDByName(name
);
7198 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7199 SetSentErrorMessage(true);
7203 // from console show not existed sender
7204 uint32 sender_guidlo
= m_session
? m_session
->GetPlayer()->GetGUIDLow() : 0;
7206 uint32 messagetype
= MAIL_NORMAL
;
7207 uint32 stationery
= MAIL_STATIONERY_GM
;
7208 uint32 itemTextId
= !text
.empty() ? objmgr
.CreateItemText( text
) : 0;
7210 Player
*receiver
= objmgr
.GetPlayer(receiver_guid
);
7212 WorldSession::SendMailTo(receiver
,messagetype
, stationery
, sender_guidlo
, GUID_LOPART(receiver_guid
), subject
, itemTextId
, NULL
, money
, 0, MAIL_CHECK_MASK_NONE
);
7214 std::string nameLink
= playerLink(name
);
7215 PSendSysMessage(LANG_MAIL_SENT
, nameLink
.c_str());
7219 /// Send a message to a player in game
7220 bool ChatHandler::HandleSendMessageCommand(const char* args
)
7222 ///- Get the command line arguments
7223 std::string name
= extractPlayerNameFromLink((char*)args
);
7226 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7227 SetSentErrorMessage(true);
7231 char* msg_str
= strtok(NULL
, "");
7235 ///- Find the player and check that he is not logging out.
7236 Player
*rPlayer
= objmgr
.GetPlayer(name
.c_str());
7239 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7240 SetSentErrorMessage(true);
7244 if(rPlayer
->GetSession()->isLogingOut())
7246 SendSysMessage(LANG_PLAYER_NOT_FOUND
);
7247 SetSentErrorMessage(true);
7251 ///- Send the message
7252 //Use SendAreaTriggerMessage for fastest delivery.
7253 rPlayer
->GetSession()->SendAreaTriggerMessage("%s", msg_str
);
7254 rPlayer
->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r");
7256 //Confirmation message
7257 std::string nameLink
= playerLink(name
);
7258 PSendSysMessage(LANG_SENDMESSAGE
,nameLink
.c_str(),msg_str
);
7262 bool ChatHandler::HandleFlushArenaPointsCommand(const char * /*args*/)
7264 sBattleGroundMgr
.DistributeArenaPoints();
7268 bool ChatHandler::HandleModifyGenderCommand(const char *args
)
7273 Player
*player
= getSelectedPlayer();
7277 PSendSysMessage(LANG_NO_PLAYER
);
7278 SetSentErrorMessage(true);
7282 PlayerInfo
const* info
= objmgr
.GetPlayerInfo(player
->getRace(), player
->getClass());
7286 char const* gender_str
= (char*)args
;
7287 int gender_len
= strlen(gender_str
);
7291 if(!strncmp(gender_str
, "male", gender_len
)) // MALE
7293 if(player
->getGender() == GENDER_MALE
)
7296 gender
= GENDER_MALE
;
7298 else if (!strncmp(gender_str
, "female", gender_len
)) // FEMALE
7300 if(player
->getGender() == GENDER_FEMALE
)
7303 gender
= GENDER_FEMALE
;
7307 SendSysMessage(LANG_MUST_MALE_OR_FEMALE
);
7308 SetSentErrorMessage(true);
7313 player
->SetByteValue(UNIT_FIELD_BYTES_0
, 2, gender
);
7314 player
->SetByteValue(PLAYER_BYTES_3
, 0, gender
);
7316 // Change display ID
7317 player
->SetDisplayId(gender
? info
->displayId_f
: info
->displayId_m
);
7318 player
->SetNativeDisplayId(gender
? info
->displayId_f
: info
->displayId_m
);
7320 char const* gender_full
= gender
? "female" : "male";
7322 PSendSysMessage(LANG_YOU_CHANGE_GENDER
, GetNameLink(player
).c_str(), gender_full
);
7324 if (needReportToTarget(player
))
7325 ChatHandler(player
).PSendSysMessage(LANG_YOUR_GENDER_CHANGED
, gender_full
, GetNameLink().c_str());