[2] | 1 | /* |
---|
[44] | 2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
[2] | 3 | * |
---|
[44] | 4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
---|
| 5 | * |
---|
[2] | 6 | * This program is free software; you can redistribute it and/or modify |
---|
| 7 | * it under the terms of the GNU General Public License as published by |
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | * (at your option) any later version. |
---|
| 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[44] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[2] | 14 | * GNU General Public License for more details. |
---|
| 15 | * |
---|
| 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; if not, write to the Free Software |
---|
[44] | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[2] | 19 | */ |
---|
| 20 | |
---|
| 21 | #include "Common.h" |
---|
| 22 | #include "Database/DatabaseEnv.h" |
---|
| 23 | #include "WorldPacket.h" |
---|
| 24 | #include "WorldSession.h" |
---|
| 25 | #include "World.h" |
---|
| 26 | #include "Player.h" |
---|
| 27 | #include "Opcodes.h" |
---|
| 28 | #include "Chat.h" |
---|
| 29 | #include "Log.h" |
---|
| 30 | #include "Unit.h" |
---|
| 31 | #include "ObjectAccessor.h" |
---|
| 32 | #include "GossipDef.h" |
---|
| 33 | #include "Language.h" |
---|
| 34 | #include "MapManager.h" |
---|
[9] | 35 | #include "BattleGroundMgr.h" |
---|
[2] | 36 | |
---|
| 37 | bool ChatHandler::HandleDebugInArcCommand(const char* /*args*/) |
---|
| 38 | { |
---|
| 39 | Object *obj = getSelectedUnit(); |
---|
| 40 | |
---|
| 41 | if(!obj) |
---|
| 42 | { |
---|
| 43 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 44 | return true; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | SendSysMessage(LANG_NOT_IMPLEMENTED); |
---|
| 48 | |
---|
| 49 | return true; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | bool ChatHandler::HandleDebugSpellFailCommand(const char* args) |
---|
| 53 | { |
---|
| 54 | if(!args) |
---|
| 55 | return false; |
---|
| 56 | |
---|
| 57 | char* px = strtok((char*)args, " "); |
---|
| 58 | if(!px) |
---|
| 59 | return false; |
---|
| 60 | |
---|
| 61 | uint8 failnum = (uint8)atoi(px); |
---|
| 62 | |
---|
| 63 | WorldPacket data(SMSG_CAST_FAILED, 5); |
---|
| 64 | data << (uint32)133; |
---|
| 65 | data << failnum; |
---|
| 66 | m_session->SendPacket(&data); |
---|
| 67 | |
---|
| 68 | return true; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | bool ChatHandler::HandleSetPoiCommand(const char* args) |
---|
| 72 | { |
---|
| 73 | Player *pPlayer = m_session->GetPlayer(); |
---|
| 74 | Unit* target = getSelectedUnit(); |
---|
| 75 | if(!target) |
---|
| 76 | { |
---|
| 77 | SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE); |
---|
| 78 | return true; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | if(!args) |
---|
| 82 | return false; |
---|
| 83 | |
---|
| 84 | char* icon_text = strtok((char*)args, " "); |
---|
| 85 | char* flags_text = strtok(NULL, " "); |
---|
| 86 | if(!icon_text || !flags_text) |
---|
| 87 | return false; |
---|
| 88 | |
---|
| 89 | uint32 icon = atol(icon_text); |
---|
| 90 | if ( icon < 0 ) |
---|
| 91 | icon = 0; |
---|
| 92 | |
---|
| 93 | uint32 flags = atol(flags_text); |
---|
| 94 | |
---|
| 95 | sLog.outDetail("Command : POI, NPC = %u, icon = %u flags = %u", target->GetGUIDLow(), icon,flags); |
---|
| 96 | pPlayer->PlayerTalkClass->SendPointOfInterest(target->GetPositionX(), target->GetPositionY(), Poi_Icon(icon), flags, 30, "Test POI"); |
---|
| 97 | return true; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | bool ChatHandler::HandleEquipErrorCommand(const char* args) |
---|
| 101 | { |
---|
| 102 | if(!args) |
---|
| 103 | return false; |
---|
| 104 | |
---|
| 105 | uint8 msg = atoi(args); |
---|
| 106 | m_session->GetPlayer()->SendEquipError(msg, 0, 0); |
---|
| 107 | return true; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | bool ChatHandler::HandleSellErrorCommand(const char* args) |
---|
| 111 | { |
---|
| 112 | if(!args) |
---|
| 113 | return false; |
---|
| 114 | |
---|
| 115 | uint8 msg = atoi(args); |
---|
| 116 | m_session->GetPlayer()->SendSellError(msg, 0, 0, 0); |
---|
| 117 | return true; |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | bool ChatHandler::HandleBuyErrorCommand(const char* args) |
---|
| 121 | { |
---|
| 122 | if(!args) |
---|
| 123 | return false; |
---|
| 124 | |
---|
| 125 | uint8 msg = atoi(args); |
---|
| 126 | m_session->GetPlayer()->SendBuyError(msg, 0, 0, 0); |
---|
| 127 | return true; |
---|
| 128 | } |
---|
| 129 | |
---|
| 130 | bool ChatHandler::HandleSendOpcodeCommand(const char* args) |
---|
| 131 | { |
---|
| 132 | Unit *unit = getSelectedUnit(); |
---|
| 133 | if (!unit || (unit->GetTypeId() != TYPEID_PLAYER)) |
---|
| 134 | unit = m_session->GetPlayer(); |
---|
| 135 | |
---|
| 136 | FILE *file = fopen("opcode.txt", "r"); |
---|
| 137 | if(!file) |
---|
| 138 | return false; |
---|
| 139 | |
---|
| 140 | uint32 type; |
---|
| 141 | |
---|
| 142 | uint32 val1; |
---|
| 143 | uint64 val2; |
---|
| 144 | float val3; |
---|
| 145 | char val4[101]; |
---|
| 146 | |
---|
| 147 | uint32 opcode = 0; |
---|
| 148 | fscanf(file, "%u", &opcode); |
---|
| 149 | if(!opcode) |
---|
| 150 | { |
---|
| 151 | fclose(file); |
---|
| 152 | return false; |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | WorldPacket data(opcode, 0); |
---|
| 156 | |
---|
| 157 | while(fscanf(file, "%u", &type) != EOF) |
---|
| 158 | { |
---|
| 159 | switch(type) |
---|
| 160 | { |
---|
| 161 | case 0: // uint8 |
---|
| 162 | fscanf(file, "%u", &val1); |
---|
| 163 | data << uint8(val1); |
---|
| 164 | break; |
---|
| 165 | case 1: // uint16 |
---|
| 166 | fscanf(file, "%u", &val1); |
---|
| 167 | data << uint16(val1); |
---|
| 168 | break; |
---|
| 169 | case 2: // uint32 |
---|
| 170 | fscanf(file, "%u", &val1); |
---|
| 171 | data << uint32(val1); |
---|
| 172 | break; |
---|
| 173 | case 3: // uint64 |
---|
| 174 | fscanf(file, I64FMTD, &val2); |
---|
| 175 | data << uint64(val2); |
---|
| 176 | break; |
---|
| 177 | case 4: // float |
---|
| 178 | fscanf(file, "%f", &val3); |
---|
| 179 | data << float(val3); |
---|
| 180 | break; |
---|
| 181 | case 5: // string |
---|
| 182 | fscanf(file, "%s", val4, 101); |
---|
| 183 | data << val4; |
---|
| 184 | break; |
---|
| 185 | case 6: // packed guid |
---|
| 186 | data.append(unit->GetPackGUID()); |
---|
| 187 | break; |
---|
| 188 | default: |
---|
| 189 | fclose(file); |
---|
| 190 | return false; |
---|
| 191 | } |
---|
| 192 | } |
---|
| 193 | fclose(file); |
---|
| 194 | sLog.outDebug("Sending opcode %u", data.GetOpcode()); |
---|
| 195 | data.hexlike(); |
---|
| 196 | ((Player*)unit)->GetSession()->SendPacket(&data); |
---|
| 197 | PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName()); |
---|
| 198 | return true; |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | bool ChatHandler::HandleUpdateWorldStateCommand(const char* args) |
---|
| 202 | { |
---|
| 203 | char* w = strtok((char*)args, " "); |
---|
| 204 | char* s = strtok(NULL, " "); |
---|
| 205 | |
---|
| 206 | if (!w || !s) |
---|
| 207 | return false; |
---|
| 208 | |
---|
| 209 | uint32 world = (uint32)atoi(w); |
---|
| 210 | uint32 state = (uint32)atoi(s); |
---|
| 211 | m_session->GetPlayer()->SendUpdateWorldState(world, state); |
---|
| 212 | return true; |
---|
| 213 | } |
---|
| 214 | |
---|
| 215 | bool ChatHandler::HandlePlaySound2Command(const char* args) |
---|
| 216 | { |
---|
| 217 | if(!args) |
---|
| 218 | return false; |
---|
| 219 | |
---|
| 220 | uint32 soundid = atoi(args); |
---|
[12] | 221 | m_session->GetPlayer()->SendPlaySound(soundid, false); |
---|
[2] | 222 | return true; |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | //Send notification in channel |
---|
| 226 | bool ChatHandler::HandleSendChannelNotifyCommand(const char* args) |
---|
| 227 | { |
---|
| 228 | if(!args) |
---|
| 229 | return false; |
---|
| 230 | |
---|
| 231 | const char *name = "test"; |
---|
| 232 | uint8 code = atoi(args); |
---|
| 233 | |
---|
| 234 | WorldPacket data(SMSG_CHANNEL_NOTIFY, (1+10)); |
---|
| 235 | data << code; // notify type |
---|
| 236 | data << name; // channel name |
---|
| 237 | data << uint32(0); |
---|
| 238 | data << uint32(0); |
---|
| 239 | m_session->SendPacket(&data); |
---|
| 240 | return true; |
---|
| 241 | } |
---|
| 242 | |
---|
| 243 | //Send notification in chat |
---|
| 244 | bool ChatHandler::HandleSendChatMsgCommand(const char* args) |
---|
| 245 | { |
---|
| 246 | if(!args) |
---|
| 247 | return false; |
---|
| 248 | |
---|
| 249 | const char *msg = "testtest"; |
---|
| 250 | uint8 type = atoi(args); |
---|
| 251 | WorldPacket data; |
---|
| 252 | ChatHandler::FillMessageData(&data, m_session, type, 0, "chan", m_session->GetPlayer()->GetGUID(), msg, m_session->GetPlayer()); |
---|
| 253 | m_session->SendPacket(&data); |
---|
| 254 | return true; |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | bool ChatHandler::HandleSendQuestPartyMsgCommand(const char* args) |
---|
| 258 | { |
---|
| 259 | uint32 msg = atol((char*)args); |
---|
| 260 | if (msg >= 0) |
---|
| 261 | m_session->GetPlayer()->SendPushToPartyResponse(m_session->GetPlayer(), msg); |
---|
| 262 | return true; |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | bool ChatHandler::HandleGetLootRecipient(const char* args) |
---|
| 266 | { |
---|
| 267 | Creature* target = getSelectedCreature(); |
---|
| 268 | if(!target) |
---|
| 269 | return false; |
---|
| 270 | |
---|
| 271 | PSendSysMessage("loot recipient: %s", target->hasLootRecipient()?(target->GetLootRecipient()?target->GetLootRecipient()->GetName():"offline"):"no loot recipient"); |
---|
| 272 | return true; |
---|
| 273 | } |
---|
| 274 | |
---|
| 275 | bool ChatHandler::HandleSendQuestInvalidMsgCommand(const char* args) |
---|
| 276 | { |
---|
| 277 | uint32 msg = atol((char*)args); |
---|
| 278 | if (msg >= 0) |
---|
| 279 | m_session->GetPlayer()->SendCanTakeQuestResponse(msg); |
---|
| 280 | return true; |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | bool ChatHandler::HandleGetItemState(const char* args) |
---|
| 284 | { |
---|
| 285 | if (!args) |
---|
| 286 | return false; |
---|
| 287 | |
---|
| 288 | std::string state_str = args; |
---|
| 289 | |
---|
| 290 | ItemUpdateState state = ITEM_UNCHANGED; |
---|
| 291 | bool list_queue = false, check_all = false; |
---|
| 292 | if (state_str == "unchanged") state = ITEM_UNCHANGED; |
---|
| 293 | else if (state_str == "changed") state = ITEM_CHANGED; |
---|
| 294 | else if (state_str == "new") state = ITEM_NEW; |
---|
| 295 | else if (state_str == "removed") state = ITEM_REMOVED; |
---|
| 296 | else if (state_str == "queue") list_queue = true; |
---|
| 297 | else if (state_str == "check_all") check_all = true; |
---|
| 298 | else return false; |
---|
| 299 | |
---|
| 300 | Player* player = getSelectedPlayer(); |
---|
| 301 | if (!player) player = m_session->GetPlayer(); |
---|
| 302 | |
---|
| 303 | if (!list_queue && !check_all) |
---|
| 304 | { |
---|
| 305 | state_str = "The player has the following " + state_str + " items: "; |
---|
| 306 | SendSysMessage(state_str.c_str()); |
---|
| 307 | for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; i++) |
---|
| 308 | { |
---|
| 309 | if(i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) |
---|
| 310 | continue; |
---|
| 311 | |
---|
| 312 | Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); |
---|
| 313 | if (!item) continue; |
---|
| 314 | if (!item->IsBag()) |
---|
| 315 | { |
---|
| 316 | if (item->GetState() == state) |
---|
| 317 | PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID())); |
---|
| 318 | } |
---|
| 319 | else |
---|
| 320 | { |
---|
| 321 | Bag *bag = (Bag*)item; |
---|
| 322 | const ItemPrototype *proto = bag->GetProto(); |
---|
| 323 | for (uint8 j = 0; j < proto->ContainerSlots; ++j) |
---|
| 324 | { |
---|
| 325 | Item* item = bag->GetItemByPos(j); |
---|
| 326 | if (item && item->GetState() == state) |
---|
| 327 | PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID())); |
---|
| 328 | } |
---|
| 329 | } |
---|
| 330 | } |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | if (list_queue) |
---|
| 334 | { |
---|
| 335 | std::vector<Item *> &updateQueue = player->GetItemUpdateQueue(); |
---|
| 336 | for(size_t i = 0; i < updateQueue.size(); i++) |
---|
| 337 | { |
---|
| 338 | Item *item = updateQueue[i]; |
---|
| 339 | if(!item) continue; |
---|
| 340 | |
---|
| 341 | Bag *container = item->GetContainer(); |
---|
| 342 | uint8 bag_slot = container ? container->GetSlot() : uint8(INVENTORY_SLOT_BAG_0); |
---|
| 343 | |
---|
| 344 | std::string st; |
---|
| 345 | switch(item->GetState()) |
---|
| 346 | { |
---|
| 347 | case ITEM_UNCHANGED: st = "unchanged"; break; |
---|
| 348 | case ITEM_CHANGED: st = "changed"; break; |
---|
| 349 | case ITEM_NEW: st = "new"; break; |
---|
| 350 | case ITEM_REMOVED: st = "removed"; break; |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bag_slot, item->GetSlot(), item->GetGUIDLow(), st.c_str()); |
---|
| 354 | } |
---|
| 355 | if (updateQueue.empty()) |
---|
| 356 | PSendSysMessage("updatequeue empty"); |
---|
| 357 | } |
---|
| 358 | |
---|
| 359 | if (check_all) |
---|
| 360 | { |
---|
| 361 | bool error = false; |
---|
| 362 | std::vector<Item *> &updateQueue = player->GetItemUpdateQueue(); |
---|
| 363 | for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; i++) |
---|
| 364 | { |
---|
| 365 | if(i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) |
---|
| 366 | continue; |
---|
| 367 | |
---|
| 368 | Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); |
---|
| 369 | if (!item) continue; |
---|
| 370 | |
---|
| 371 | if (item->GetSlot() != i) |
---|
| 372 | { |
---|
| 373 | PSendSysMessage("item at slot %d, guid %d has an incorrect slot value: %d", i, item->GetGUIDLow(), item->GetSlot()); |
---|
| 374 | error = true; continue; |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | if (item->GetOwnerGUID() != player->GetGUID()) |
---|
| 378 | { |
---|
| 379 | PSendSysMessage("for the item at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); |
---|
| 380 | error = true; continue; |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | if (Bag *container = item->GetContainer()) |
---|
| 384 | { |
---|
| 385 | PSendSysMessage("item at slot: %d guid: %d has a container (slot: %d, guid: %d) but shouldnt!", item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); |
---|
| 386 | error = true; continue; |
---|
| 387 | } |
---|
| 388 | |
---|
| 389 | if (item->IsInUpdateQueue()) |
---|
| 390 | { |
---|
| 391 | uint16 qp = item->GetQueuePos(); |
---|
| 392 | if (qp > updateQueue.size()) |
---|
| 393 | { |
---|
| 394 | PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUIDLow(), qp); |
---|
| 395 | error = true; continue; |
---|
| 396 | } |
---|
| 397 | |
---|
| 398 | if (updateQueue[qp] == NULL) |
---|
| 399 | { |
---|
| 400 | PSendSysMessage("item at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", item->GetSlot(), item->GetGUIDLow(), qp); |
---|
| 401 | error = true; continue; |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | if (updateQueue[qp] != item) |
---|
| 405 | { |
---|
| 406 | PSendSysMessage("item at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); |
---|
| 407 | error = true; continue; |
---|
| 408 | } |
---|
| 409 | } |
---|
| 410 | else if (item->GetState() != ITEM_UNCHANGED) |
---|
| 411 | { |
---|
| 412 | PSendSysMessage("item at slot: %d guid: %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUIDLow(), item->GetState()); |
---|
| 413 | error = true; continue; |
---|
| 414 | } |
---|
| 415 | |
---|
| 416 | if(item->IsBag()) |
---|
| 417 | { |
---|
| 418 | Bag *bag = (Bag*)item; |
---|
| 419 | const ItemPrototype *proto = bag->GetProto(); |
---|
| 420 | for (uint8 j = 0; j < proto->ContainerSlots; ++j) |
---|
| 421 | { |
---|
| 422 | Item* item = bag->GetItemByPos(j); |
---|
| 423 | if (!item) continue; |
---|
| 424 | |
---|
| 425 | if (item->GetSlot() != j) |
---|
| 426 | { |
---|
| 427 | PSendSysMessage("the item in bag %d slot %d, guid %d has an incorrect slot value: %d", bag->GetSlot(), j, item->GetGUIDLow(), item->GetSlot()); |
---|
| 428 | error = true; continue; |
---|
| 429 | } |
---|
| 430 | |
---|
| 431 | if (item->GetOwnerGUID() != player->GetGUID()) |
---|
| 432 | { |
---|
| 433 | PSendSysMessage("for the item in bag %d at slot %d and itemguid %d, owner's guid (%d) and player's guid (%d) don't match!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); |
---|
| 434 | error = true; continue; |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | Bag *container = item->GetContainer(); |
---|
| 438 | if (!container) |
---|
| 439 | { |
---|
| 440 | PSendSysMessage("the item in bag %d at slot %d with guid %d has no container!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow()); |
---|
| 441 | error = true; continue; |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | if (container != bag) |
---|
| 445 | { |
---|
| 446 | PSendSysMessage("the item in bag %d at slot %d with guid %d has a different container(slot %d guid %d)!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), container->GetSlot(), container->GetGUIDLow()); |
---|
| 447 | error = true; continue; |
---|
| 448 | } |
---|
| 449 | |
---|
| 450 | if (item->IsInUpdateQueue()) |
---|
| 451 | { |
---|
| 452 | uint16 qp = item->GetQueuePos(); |
---|
| 453 | if (qp > updateQueue.size()) |
---|
| 454 | { |
---|
| 455 | PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), qp); |
---|
| 456 | error = true; continue; |
---|
| 457 | } |
---|
| 458 | |
---|
| 459 | if (updateQueue[qp] == NULL) |
---|
| 460 | { |
---|
| 461 | PSendSysMessage("item in bag: %d at slot: %d guid: %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), qp); |
---|
| 462 | error = true; continue; |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | if (updateQueue[qp] != item) |
---|
| 466 | { |
---|
| 467 | PSendSysMessage("item in bag: %d at slot: %d guid: %d has has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUIDLow()); |
---|
| 468 | error = true; continue; |
---|
| 469 | } |
---|
| 470 | } |
---|
| 471 | else if (item->GetState() != ITEM_UNCHANGED) |
---|
| 472 | { |
---|
| 473 | PSendSysMessage("item in bag: %d at slot: %d guid: %d is not in queue but should be (state: %d)!", bag->GetSlot(), item->GetSlot(), item->GetGUIDLow(), item->GetState()); |
---|
| 474 | error = true; continue; |
---|
| 475 | } |
---|
| 476 | } |
---|
| 477 | } |
---|
| 478 | } |
---|
| 479 | |
---|
| 480 | for(size_t i = 0; i < updateQueue.size(); i++) |
---|
| 481 | { |
---|
| 482 | Item *item = updateQueue[i]; |
---|
| 483 | if(!item) continue; |
---|
| 484 | |
---|
| 485 | if (item->GetOwnerGUID() != player->GetGUID()) |
---|
| 486 | { |
---|
| 487 | PSendSysMessage("queue(%d): for the an item (guid %d), the owner's guid (%d) and player's guid (%d) don't match!", i, item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID()), player->GetGUIDLow()); |
---|
| 488 | error = true; continue; |
---|
| 489 | } |
---|
| 490 | |
---|
| 491 | if (item->GetQueuePos() != i) |
---|
| 492 | { |
---|
| 493 | PSendSysMessage("queue(%d): for the an item (guid %d), the queuepos doesn't match it's position in the queue!", i, item->GetGUIDLow()); |
---|
| 494 | error = true; continue; |
---|
| 495 | } |
---|
| 496 | |
---|
| 497 | if (item->GetState() == ITEM_REMOVED) continue; |
---|
| 498 | Item *test = player->GetItemByPos( item->GetBagSlot(), item->GetSlot()); |
---|
| 499 | |
---|
| 500 | if (test == NULL) |
---|
| 501 | { |
---|
| 502 | PSendSysMessage("queue(%d): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the player doesn't have an item at that position!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow()); |
---|
| 503 | error = true; continue; |
---|
| 504 | } |
---|
| 505 | |
---|
| 506 | if (test != item) |
---|
| 507 | { |
---|
| 508 | PSendSysMessage("queue(%d): the bag(%d) and slot(%d) values for the item with guid %d are incorrect, the item with guid %d is there instead!", i, item->GetBagSlot(), item->GetSlot(), item->GetGUIDLow(), test->GetGUIDLow()); |
---|
| 509 | error = true; continue; |
---|
| 510 | } |
---|
| 511 | } |
---|
| 512 | if (!error) |
---|
| 513 | SendSysMessage("All OK!"); |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | return true; |
---|
| 517 | } |
---|
[9] | 518 | |
---|
| 519 | bool ChatHandler::HandleDebugArenaCommand(const char * /*args*/) |
---|
| 520 | { |
---|
| 521 | sBattleGroundMgr.ToggleArenaTesting(); |
---|
| 522 | return true; |
---|
| 523 | } |
---|
[44] | 524 | |
---|
| 525 | bool ChatHandler::HandleDebugThreatList(const char * /*args*/) |
---|
| 526 | { |
---|
| 527 | Creature* target = getSelectedCreature(); |
---|
| 528 | if(!target || target->isTotem() || target->isPet()) |
---|
| 529 | return false; |
---|
| 530 | |
---|
| 531 | std::list<HostilReference*>& tlist = target->getThreatManager().getThreatList(); |
---|
| 532 | std::list<HostilReference*>::iterator itr; |
---|
| 533 | uint32 cnt = 0; |
---|
| 534 | PSendSysMessage("Threat list of %s (guid %u)",target->GetName(), target->GetGUIDLow()); |
---|
| 535 | for(itr = tlist.begin(); itr != tlist.end(); ++itr) |
---|
| 536 | { |
---|
| 537 | Unit* unit = (*itr)->getTarget(); |
---|
| 538 | if(!unit) |
---|
| 539 | continue; |
---|
| 540 | ++cnt; |
---|
| 541 | PSendSysMessage(" %u. %s (guid %u) - threat %f",cnt,unit->GetName(), unit->GetGUIDLow(), (*itr)->getThreat()); |
---|
| 542 | } |
---|
| 543 | SendSysMessage("End of threat list."); |
---|
| 544 | return true; |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | bool ChatHandler::HandleDebugHostilRefList(const char * /*args*/) |
---|
| 548 | { |
---|
| 549 | Unit* target = getSelectedUnit(); |
---|
| 550 | if(!target) |
---|
| 551 | target = m_session->GetPlayer(); |
---|
| 552 | HostilReference* ref = target->getHostilRefManager().getFirst(); |
---|
| 553 | uint32 cnt = 0; |
---|
| 554 | PSendSysMessage("Hostil reference list of %s (guid %u)",target->GetName(), target->GetGUIDLow()); |
---|
| 555 | while(ref) |
---|
| 556 | { |
---|
| 557 | if(Unit * unit = ref->getSource()->getOwner()) |
---|
| 558 | { |
---|
| 559 | ++cnt; |
---|
| 560 | PSendSysMessage(" %u. %s (guid %u) - threat %f",cnt,unit->GetName(), unit->GetGUIDLow(), ref->getThreat()); |
---|
| 561 | } |
---|
| 562 | ref = ref->next(); |
---|
| 563 | } |
---|
| 564 | SendSysMessage("End of hostil reference list."); |
---|
| 565 | return true; |
---|
| 566 | } |
---|