void WorldSession::HandleDestroyItemOpcode( WorldPacket & recv_data ) { if(!_player->IsInWorld()) return; CHECK_PACKET_SIZE(recv_data, 2); //Player *plyr = GetPlayer(); int8 SrcInvSlot, SrcSlot; recv_data >> SrcInvSlot >> SrcSlot; sLog.outDetail("ITEM: destroy, SrcInv Slot: %u Src slot: %u", (uint32)SrcInvSlot, (uint32)SrcSlot); Item *it = _player->GetItemInterface()->GetInventoryItem(SrcInvSlot,SrcSlot); if(it) { if(it->IsContainer()) { if(((Container*)it)->HasItems()) { _player->GetItemInterface()->BuildInventoryChangeError( it, NULL, INV_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS); return; } } if(it->GetProto()->ItemId == ITEM_ENTRY_GUILD_CHARTER) { Charter *gc = _player->m_charter; if(gc) gc->Destroy(); } uint32 mail_id = it->GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID); if(mail_id) sMailSystem.RemoveMessageIfDeleted(mail_id, _player->GetGUID()); bool result = _player->GetItemInterface()->SafeFullRemoveItemFromSlot(SrcInvSlot,SrcSlot); if(!result) { sLog.outDetail("ITEM: Destroy, SrcInv Slot: %u Src slot: %u Failed", (uint32)SrcInvSlot, (uint32)SrcSlot); } } }
void WorldSession::HandleCharterTurnInCharter(WorldPacket & recv_data) { uint64 mooguid; recv_data >> mooguid; Charter * pCharter = objmgr.GetCharterByItemGuid(mooguid); if(!pCharter) return; if(pCharter->CharterType == CHARTER_TYPE_GUILD) { Charter * gc = pCharter; if(gc == NULL) return; if( gc->GetLeader() != _player->GetLowGUID() ) return; if(gc->SignatureCount < 9 && Config.MainConfig.GetBoolDefault("Server", "RequireAllSignatures", false)) { SendNotification("You don't have the required amount of signatures to turn in this petition."); return; } // dont know hacky or not but only solution for now // If everything is fine create guild Guild *pGuild = Guild::Create(); pGuild->CreateFromCharter(gc, this); // Destroy the charter _player->m_playerInfo->charterId[CHARTER_TYPE_GUILD] = 0; gc->Destroy(); _player->GetItemInterface()->RemoveItemAmt(ITEM_ENTRY_GUILD_CHARTER, 1); sHookInterface.OnGuildCreate(_player, pGuild); } else { /* Arena charter - TODO: Replace with correct messages */ ArenaTeam * team; uint32 type; uint32 i; uint32 icon, iconcolor, bordercolor, border, background; recv_data >> iconcolor >>icon >> bordercolor >> border >> background; switch(pCharter->CharterType) { case CHARTER_TYPE_ARENA_2V2: type = ARENA_TEAM_TYPE_2V2; break; case CHARTER_TYPE_ARENA_3V3: type = ARENA_TEAM_TYPE_3V3; break; case CHARTER_TYPE_ARENA_5V5: type = ARENA_TEAM_TYPE_5V5; break; default: SendNotification("Internal Error"); return; } if( pCharter->GetLeader() != _player->GetLowGUID() ) return; if(_player->m_playerInfo->arenaTeam[pCharter->CharterType-1] != NULL) { sChatHandler.SystemMessage(this, "You are already in an arena team."); return; } if(pCharter->SignatureCount < pCharter->GetNumberOfSlotsByType() && Config.MainConfig.GetBoolDefault("Server", "RequireAllSignatures", false)) { sChatHandler.SystemMessage(this, "You don't have the required amount of signatures to turn in this petition."); return; } team = new ArenaTeam(type, objmgr.GenerateArenaTeamId()); team->m_name = pCharter->GuildName; team->m_emblemColour = iconcolor; team->m_emblemStyle = icon; team->m_borderColour = bordercolor; team->m_borderStyle = border; team->m_backgroundColour = background; team->m_leader=_player->GetLowGUID(); team->m_stat_rating=1500; objmgr.AddArenaTeam(team); objmgr.UpdateArenaTeamRankings(); team->AddMember(_player->m_playerInfo); /* Add the members */ for(i = 0; i < pCharter->SignatureCount; ++i) { PlayerInfo * info = objmgr.GetPlayerInfo(pCharter->Signatures[i]); if(info) { team->AddMember(info); } } _player->GetItemInterface()->SafeFullRemoveItemByGuid(mooguid); _player->m_playerInfo->charterId[pCharter->CharterType] = 0; pCharter->Destroy(); } WorldPacket data(4); data.SetOpcode(SMSG_TURN_IN_PETITION_RESULTS); data << uint32(0); SendPacket( &data ); }
// Charter part void WorldSession::HandleCharterBuy(WorldPacket & recv_data) { /* {CLIENT} Packet: (0x01BD) CMSG_PETITION_BUY PacketSize = 85 |------------------------------------------------|----------------| |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF| |------------------------------------------------|----------------| |50 91 00 00 6E 13 01 F0 00 00 00 00 00 00 00 00 |P...n...........| |00 00 00 00 53 74 6F 72 6D 62 72 69 6E 67 65 72 |....Stormbringer| |73 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |s...............| |00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| |00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 |................| |00 00 00 00 00 |..... | ------------------------------------------------------------------- */ uint64 creature_guid; uint64 crap; uint32 crap2; string name; uint8 error; uint32 crap3,crap4,crap5,crap6,crap7,crap8,crap9,crap10,crap11,arena_index,crap12; uint16 crap13; uint8 crap14; uint32 crap15; recv_data >> creature_guid >> crap >> crap2 >> name; recv_data >> crap3 >> crap4 >> crap5 >> crap6 >> crap7 >> crap8 >> crap9 >> crap10 >> crap11 >> crap12 >> crap13 >> crap14 >> arena_index >> crap15; Creature * crt = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(creature_guid)); if(!crt) { Disconnect(); return; } if( arena_index >= NUM_CHARTER_TYPES ) return; if(crt->GetEntry()==19861 || crt->GetEntry()==18897 || crt->GetEntry()==19856) /* i am lazy! */ { uint32 arena_type = arena_index - 1; if(arena_type > 2) return; if(_player->m_playerInfo->arenaTeam[arena_type]) { SendNotification("You are already in an arena team."); return; } if(_player->m_playerInfo->charterId[arena_index] != 0) { SendNotification("You already have an arena charter of this type."); return; } ArenaTeam * t = objmgr.GetArenaTeamByName(name, arena_type); if(t != NULL) { sChatHandler.SystemMessage(this,"That name is already in use."); return; } if(objmgr.GetCharterByName(name, (CharterTypes)arena_index)) { sChatHandler.SystemMessage(this,"That name is already in use."); return; } static uint32 item_ids[] = {ARENA_TEAM_CHARTER_2v2, ARENA_TEAM_CHARTER_3v3, ARENA_TEAM_CHARTER_5v5}; static uint32 costs[] = {ARENA_TEAM_CHARTER_2v2_COST,ARENA_TEAM_CHARTER_3v3_COST,ARENA_TEAM_CHARTER_5v5_COST}; if(_player->GetUInt32Value(PLAYER_FIELD_COINAGE) < costs[arena_type] && !sWorld.free_arena_teams) return; // error message needed here ItemPrototype * ip = ItemPrototypeStorage.LookupEntry(item_ids[arena_type]); ASSERT(ip); SlotResult res = _player->GetItemInterface()->FindFreeInventorySlot(ip); if(res.Result == 0) { _player->GetItemInterface()->BuildInventoryChangeError(0, 0, INV_ERR_INVENTORY_FULL); return; } error = _player->GetItemInterface()->CanReceiveItem(ip,1, NULL); if(error) { _player->GetItemInterface()->BuildInventoryChangeError(NULL,NULL,error); } else { // Create the item and charter Item * i = objmgr.CreateItem(item_ids[arena_type], _player); Charter * c = objmgr.CreateCharter(_player->GetLowGUID(), (CharterTypes)arena_index); c->GuildName = name; c->ItemGuid = i->GetGUID(); i->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1); i->SetUInt32Value(ITEM_FIELD_FLAGS, 1); i->SetUInt32Value(ITEM_FIELD_ENCHANTMENT, c->GetID()); i->SetUInt32Value(ITEM_FIELD_PROPERTY_SEED, 57813883); if( !_player->GetItemInterface()->AddItemToFreeSlot(i) ) { c->Destroy(); delete i; return; } c->SaveToDB(); /*WorldPacket data(45); BuildItemPushResult(&data, _player->GetGUID(), ITEM_PUSH_TYPE_RECEIVE, 1, item_ids[arena_type], 0); SendPacket(&data);*/ SendItemPushResult(i, false, true, false, true, _player->GetItemInterface()->LastSearchItemBagSlot(), _player->GetItemInterface()->LastSearchItemSlot(), 1); if(!sWorld.free_arena_teams) _player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -(int32)costs[arena_type]); _player->m_playerInfo->charterId[arena_index] = c->GetID(); _player->SaveToDB(false); } } else { if( _player->GetUInt32Value(PLAYER_FIELD_COINAGE) < 1000 && !sWorld.free_guild_charters ) { SendNotification("You don't have enough money."); return; } if(_player->m_playerInfo->charterId[CHARTER_TYPE_GUILD] != 0) { SendNotification("You already have a guild charter."); return; } Guild * g = objmgr.GetGuildByGuildName(name); Charter * c = objmgr.GetCharterByName(name, CHARTER_TYPE_GUILD); if(g != 0 || c != 0) { SendNotification("A guild with that name already exists."); return; } ItemPrototype * ip = ItemPrototypeStorage.LookupEntry(ITEM_ENTRY_GUILD_CHARTER); assert(ip); SlotResult res = _player->GetItemInterface()->FindFreeInventorySlot(ip); if(res.Result == 0) { _player->GetItemInterface()->BuildInventoryChangeError(0, 0, INV_ERR_INVENTORY_FULL); return; } error = _player->GetItemInterface()->CanReceiveItem(ItemPrototypeStorage.LookupEntry(ITEM_ENTRY_GUILD_CHARTER),1, NULL); if(error) { _player->GetItemInterface()->BuildInventoryChangeError(NULL,NULL,error); } else { // Meh... WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 12); data << uint32(0x000019C2); data << creature_guid; SendPacket(&data); // Create the item and charter Item * i = objmgr.CreateItem(ITEM_ENTRY_GUILD_CHARTER, _player); c = objmgr.CreateCharter(_player->GetLowGUID(), CHARTER_TYPE_GUILD); c->GuildName = name; c->ItemGuid = i->GetGUID(); i->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1); i->SetUInt32Value(ITEM_FIELD_FLAGS, 1); i->SetUInt32Value(ITEM_FIELD_ENCHANTMENT, c->GetID()); i->SetUInt32Value(ITEM_FIELD_PROPERTY_SEED, 57813883); if( !_player->GetItemInterface()->AddItemToFreeSlot(i) ) { c->Destroy(); delete i; return; } c->SaveToDB(); /*data.clear(); data.resize(45); BuildItemPushResult(&data, _player->GetGUID(), ITEM_PUSH_TYPE_RECEIVE, 1, ITEM_ENTRY_GUILD_CHARTER, 0); SendPacket(&data);*/ SendItemPushResult(i, false, true, false, true, _player->GetItemInterface()->LastSearchItemBagSlot(), _player->GetItemInterface()->LastSearchItemSlot(), 1); _player->m_playerInfo->charterId[CHARTER_TYPE_GUILD] = c->GetID(); // 10 silver if(!sWorld.free_guild_charters) _player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -1000); _player->SaveToDB(false); } } }
uint8 WorldSession::DeleteCharacter(uint32 guid) { PlayerInfo * inf = objmgr.GetPlayerInfo(guid); if( inf != NULL && inf->m_loggedInPlayer == NULL ) { QueryResult * result = CharacterDatabase.Query("SELECT name FROM characters WHERE guid = %u AND acct = %u", (uint32)guid, _accountId); if(!result) return CHAR_DELETE_FAILED; if(inf->guild) { if(inf->guild->GetGuildLeader()==inf->guid) return CHAR_DELETE_FAILED_GUILD_LEADER; else inf->guild->RemoveGuildMember(inf,NULL); } string name = result->Fetch()[0].GetString(); delete result; for(int i = 0; i < NUM_CHARTER_TYPES; i++) { if( inf->charterId[i] != 0 ) { Charter *pCharter = objmgr.GetCharter(inf->charterId[i], (CharterTypes)i); if( pCharter->LeaderGuid == inf->guid ) pCharter->Destroy(); else pCharter->RemoveSignature(inf->guid); } } for(int i = 0; i < NUM_ARENA_TEAM_TYPES; i++) { if( inf->arenaTeam[i] != NULL ) { if( inf->arenaTeam[i]->m_leader == guid ) return CHAR_DELETE_FAILED_ARENA_CAPTAIN; else inf->arenaTeam[i]->RemoveMember(inf); } } sPlrLog.writefromsession(this, "deleted character %s (GUID: %u)", name.c_str(), (uint32)guid); CharacterDatabase.WaitExecute("DELETE FROM characters WHERE guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM character_declinedname WHERE guid = '%u'", (uint32)guid); Corpse* c=objmgr.GetCorpseByOwner((uint32)guid); if(c) CharacterDatabase.Execute("DELETE FROM corpses WHERE guid = %u", c->GetLowGUID()); CharacterDatabase.Execute("DELETE FROM achievements WHERE player = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM auctions WHERE owner = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM charters WHERE leaderGuid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM gm_tickets WHERE guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM guild_data WHERE playerid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM instances WHERE creator_guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM mailbox WHERE player_guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playercooldowns WHERE player_guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playerglyphs WHERE guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playeritems WHERE ownerguid=%u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playerpets WHERE ownerguid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM character_pet_declinedname WHERE owner = '%u'", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playerpetspells WHERE ownerguid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playerskills WHERE player_guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playerspells WHERE guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playersummonspells WHERE ownerguid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playertalents WHERE guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM questlog WHERE player_guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM social_friends WHERE character_guid = %u OR friend_guid = %u", (uint32)guid, (uint32)guid); CharacterDatabase.Execute("DELETE FROM social_ignores WHERE character_guid = %u OR ignore_guid = %u", (uint32)guid, (uint32)guid); CharacterDatabase.Execute("DELETE FROM tutorials WHERE playerId = %u", (uint32)guid); /* remove player info */ objmgr.DeletePlayerInfo((uint32)guid); return CHAR_DELETE_SUCCESS; } return CHAR_DELETE_FAILED; }
// Charter part void WorldSession::HandleCharterBuy(WorldPacket & recv_data) { uint8 error; uint64 creature_guid; uint32 crap; uint64 crap2; string name, unkstr; uint32 Data[7]; uint16 crap10; uint32 crap11; uint32 crap12, PetitionSignerCount; string crap13; uint32 arena_index; recv_data >> creature_guid; recv_data >> crap >> crap2; recv_data >> name >> unkstr; recv_data >> Data[0] >> Data[1] >> Data[2] >> Data[3] >> Data[4] >> Data[5] >> Data[6]; recv_data >> crap10; recv_data >> crap11 >> crap12 >> PetitionSignerCount; for(uint32 s = 0; s < 10; ++s) recv_data >> crap13; recv_data >> arena_index; Creature* crt = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(creature_guid)); if(!crt) { Disconnect(); return; } if( arena_index >= NUM_CHARTER_TYPES ) return; //All arena organizers should be allowed to create arena charter's if( !crt->ArenaOrganizersFlags() ) { uint32 arena_type = arena_index - 1; if(arena_type > 2) return; if(_player->m_playerInfo->arenaTeam[arena_type]) { SendNotification("You are already in an arena team."); return; } if(_player->m_playerInfo->charterId[arena_index] != 0) { SendNotification("You already have an arena charter of this type."); return; } if(!sWorld.VerifyName(name.c_str(), name.length())) { SendNotification("That name is invalid or contains invalid characters."); return; } ArenaTeam * t = objmgr.GetArenaTeamByName(name, arena_type); if(t != NULL) { sChatHandler.SystemMessage(this,"That name is already in use."); return; } if(objmgr.GetCharterByName(name, (CharterTypes)arena_index)) { sChatHandler.SystemMessage(this,"That name is already in use."); return; } static uint32 item_ids[] = {ARENA_TEAM_CHARTER_2v2, ARENA_TEAM_CHARTER_3v3, ARENA_TEAM_CHARTER_5v5}; static uint32 costs[] = {ARENA_TEAM_CHARTER_2v2_COST,ARENA_TEAM_CHARTER_3v3_COST,ARENA_TEAM_CHARTER_5v5_COST}; if(_player->GetUInt32Value(PLAYER_FIELD_COINAGE) < costs[arena_type]) { sChatHandler.SystemMessage(this,"You don't have enough money!"); return; // error message needed here } ItemPrototype * ip = ItemPrototypeStorage.LookupEntry(item_ids[arena_type]); ASSERT(ip); SlotResult res = _player->GetItemInterface()->FindFreeInventorySlot(ip); if(res.Result == 0) { _player->GetItemInterface()->BuildInventoryChangeError(NULLITEM, NULLITEM, INV_ERR_INVENTORY_FULL); return; } error = _player->GetItemInterface()->CanReceiveItem(ip,1, NULL); if(error) { _player->GetItemInterface()->BuildInventoryChangeError(NULLITEM, NULLITEM,error); } else { // Create the item and charter Item* i = objmgr.CreateItem(item_ids[arena_type], _player); Charter * c = objmgr.CreateCharter(_player->GetLowGUID(), (CharterTypes)arena_index); c->GuildName = name; c->ItemGuid = i->GetGUID(); i->Bind(ITEM_BIND_ON_PICKUP); i->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1); i->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, c->GetID()); i->SetUInt32Value(ITEM_FIELD_PROPERTY_SEED, 57813883); if( !_player->GetItemInterface()->AddItemToFreeSlot(i) ) { c->Destroy(); c = NULL; i->DeleteMe(); i = NULL; return; } c->SaveToDB(); SendItemPushResult(i, false, true, false, true, _player->GetItemInterface()->LastSearchItemBagSlot(), _player->GetItemInterface()->LastSearchItemSlot(), 1); _player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -(int32)costs[arena_type]); _player->m_playerInfo->charterId[arena_index] = c->GetID(); _player->SaveToDB(false); } } else { if( _player->GetUInt32Value(PLAYER_FIELD_COINAGE) < 1000) { SendNotification("You don't have enough money."); return; } if(_player->m_playerInfo->charterId[CHARTER_TYPE_GUILD] != 0) { SendNotification("You already have a guild charter."); return; } if(!sWorld.VerifyName(name.c_str(), name.length())) { SendNotification("That name is invalid or contains invalid characters."); return; } Guild * g = objmgr.GetGuildByGuildName(name); Charter * c = objmgr.GetCharterByName(name, CHARTER_TYPE_GUILD); if(g != 0 || c != 0) { SendNotification("A guild with that name already exists."); return; } ItemPrototype * ip = ItemPrototypeStorage.LookupEntry(ITEM_ENTRY_GUILD_CHARTER); assert(ip); SlotResult res = _player->GetItemInterface()->FindFreeInventorySlot(ip); if(res.Result == 0) { _player->GetItemInterface()->BuildInventoryChangeError(NULLITEM, NULLITEM, INV_ERR_INVENTORY_FULL); return; } error = _player->GetItemInterface()->CanReceiveItem(ItemPrototypeStorage.LookupEntry(ITEM_ENTRY_GUILD_CHARTER),1, NULL); if(error) { _player->GetItemInterface()->BuildInventoryChangeError(NULLITEM, NULLITEM,error); } else { // Meh... WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 12); data << uint32(0x000019C2); data << creature_guid; SendPacket(&data); // Create the item and charter Item * i = objmgr.CreateItem(ITEM_ENTRY_GUILD_CHARTER, _player); c = objmgr.CreateCharter(_player->GetLowGUID(), CHARTER_TYPE_GUILD); c->GuildName = name; c->ItemGuid = i->GetGUID(); i->Bind(ITEM_BIND_ON_PICKUP); i->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1); i->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, c->GetID()); i->SetUInt32Value(ITEM_FIELD_PROPERTY_SEED, 57813883); if( !_player->GetItemInterface()->AddItemToFreeSlot(i) ) { c->Destroy(); c = NULL; i->DeleteMe(); i = NULL; return; } c->SaveToDB(); SendItemPushResult(i, false, true, false, true, _player->GetItemInterface()->LastSearchItemBagSlot(), _player->GetItemInterface()->LastSearchItemSlot(), 1); _player->m_playerInfo->charterId[CHARTER_TYPE_GUILD] = c->GetID(); // 10 silver _player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -1000); _player->SaveToDB(false); } } }
// Charter part void WorldSession::HandleCharterBuy(WorldPacket & recv_data) { CHECK_PACKET_SIZE(recv_data, 8+8+4+1+5*8+2+1+4+4); uint64 creature_guid; uint64 unk1, unk3, unk4, unk5, unk6, unk7; uint32 unk2; std::string name; uint16 unk8; uint8 unk9; uint32 arena_index; uint32 unk10; uint8 error; recv_data >> creature_guid; // NPC GUID recv_data >> unk1; // 0 recv_data >> unk2; // 0 recv_data >> name; // name // recheck CHECK_PACKET_SIZE(recv_data, 8+8+4+(name.size()+1)+5*8+2+1+4+4); recv_data >> unk3; // 0 recv_data >> unk4; // 0 recv_data >> unk5; // 0 recv_data >> unk6; // 0 recv_data >> unk7; // 0 recv_data >> unk8; // 0 recv_data >> unk9; // 0 recv_data >> arena_index; // index recv_data >> unk10; // 0 Creature* crt = _player->GetMapMgr()->GetCreature(GET_LOWGUID_PART(creature_guid)); if(!crt) { Disconnect(); return; } if( arena_index >= NUM_CHARTER_TYPES ) return; if( crt->IsArenaOrganizer() ) // All arena organizers should be allowed to create arena charter's { uint32 arena_type = arena_index - 1; if(arena_type > 2) return; if(_player->m_playerInfo->arenaTeam[arena_type]) { SendNotification("You are already in an arena team."); return; } if(_player->m_playerInfo->charterId[arena_index] != 0) { SendNotification("You already have an arena charter of this type."); return; } ArenaTeam * t = objmgr.GetArenaTeamByName(name, arena_type); if(t != NULL) { sChatHandler.SystemMessage(this,"That name is already in use."); return; } if(objmgr.GetCharterByName(name, (CharterTypes)arena_index)) { sChatHandler.SystemMessage(this,"That name is already in use."); return; } static uint32 item_ids[] = {ARENA_TEAM_CHARTER_2v2, ARENA_TEAM_CHARTER_3v3, ARENA_TEAM_CHARTER_5v5}; static uint32 costs[] = {ARENA_TEAM_CHARTER_2v2_COST,ARENA_TEAM_CHARTER_3v3_COST,ARENA_TEAM_CHARTER_5v5_COST}; if(_player->GetUInt32Value(PLAYER_FIELD_COINAGE) < costs[arena_type] && !sWorld.free_arena_teams) return; // error message needed here ItemPrototype * ip = ItemPrototypeStorage.LookupEntry(item_ids[arena_type]); ASSERT(ip); SlotResult res = _player->GetItemInterface()->FindFreeInventorySlot(ip); if(res.Result == 0) { _player->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_INVENTORY_FULL); return; } error = _player->GetItemInterface()->CanReceiveItem(ip,1, NULL); if(error) { _player->GetItemInterface()->BuildInventoryChangeError(NULL,NULL,error); } else { // Create the item and charter Item* i = objmgr.CreateItem(item_ids[arena_type], _player); Charter * c = objmgr.CreateCharter(_player->GetLowGUID(), (CharterTypes)arena_index); c->GuildName = name; c->ItemGuid = i->GetGUID(); i->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1); i->SetUInt32Value(ITEM_FIELD_FLAGS, 1); i->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, c->GetID()); i->SetUInt32Value(ITEM_FIELD_PROPERTY_SEED, 57813883); if( !_player->GetItemInterface()->AddItemToFreeSlot(i) ) { c->Destroy(); c = NULL; i->Destructor(); i = NULL; return; } c->SaveToDB(); SendItemPushResult(i, false, true, false, true, _player->GetItemInterface()->LastSearchItemBagSlot(), _player->GetItemInterface()->LastSearchItemSlot(), 1); if(!sWorld.free_arena_teams) _player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -(int32)costs[arena_type]); _player->m_playerInfo->charterId[arena_index] = c->GetID(); _player->SaveToDB(false); } } else { if( _player->GetUInt32Value(PLAYER_FIELD_COINAGE) < 1000 && !sWorld.free_guild_charters ) { SendNotification("You don't have enough money."); return; } if(_player->m_playerInfo->charterId[CHARTER_TYPE_GUILD] != 0) { SendNotification("You already have a guild charter."); return; } Guild * g = objmgr.GetGuildByGuildName(name); Charter * c = objmgr.GetCharterByName(name, CHARTER_TYPE_GUILD); if(g != 0 || c != 0) { SendNotification("A guild with that name already exists."); return; } ItemPrototype * ip = ItemPrototypeStorage.LookupEntry(ITEM_ENTRY_GUILD_CHARTER); assert(ip); SlotResult res = _player->GetItemInterface()->FindFreeInventorySlot(ip); if(res.Result == 0) { _player->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_INVENTORY_FULL); return; } error = _player->GetItemInterface()->CanReceiveItem(ItemPrototypeStorage.LookupEntry(ITEM_ENTRY_GUILD_CHARTER),1, NULL); if(error) { _player->GetItemInterface()->BuildInventoryChangeError(NULL,NULL,error); } else { // Meh... WorldPacket data(SMSG_PLAY_OBJECT_SOUND, 12); data << uint32(0x000019C2); data << creature_guid; SendPacket(&data); // Create the item and charter Item* i = objmgr.CreateItem(ITEM_ENTRY_GUILD_CHARTER, _player); c = objmgr.CreateCharter(_player->GetLowGUID(), CHARTER_TYPE_GUILD); c->GuildName = name; c->ItemGuid = i->GetGUID(); i->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1); i->SetUInt32Value(ITEM_FIELD_FLAGS, 1); i->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, c->GetID()); i->SetUInt32Value(ITEM_FIELD_PROPERTY_SEED, 57813883); if( !_player->GetItemInterface()->AddItemToFreeSlot(i) ) { c->Destroy(); i->Destructor(); return; } c->SaveToDB(); SendItemPushResult(i, false, true, false, true, _player->GetItemInterface()->LastSearchItemBagSlot(), _player->GetItemInterface()->LastSearchItemSlot(), 1); _player->m_playerInfo->charterId[CHARTER_TYPE_GUILD] = c->GetID(); // 10 silver if(!sWorld.free_guild_charters) _player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -1000); _player->SaveToDB(false); } } }
uint8 WorldSession::DeleteCharacter(uint32 guid) { PlayerInfo * inf = objmgr.GetPlayerInfo(guid); if( inf != NULL && inf->m_loggedInPlayer == NULL ) { QueryResult * result = CharacterDatabase.Query("SELECT name FROM characters WHERE guid = %u AND acct = %u", (uint32)guid, _accountId); if(!result) return CHAR_DELETE_FAILED; if(inf->GuildId) { GuildMember* gMember = guildmgr.GetGuildMember(inf->guid); if(gMember->pRank->iId == 0) return CHAR_DELETE_FAILED_GUILD_LEADER; else guildmgr.RemoveMember(NULL, inf); } string name = result->Fetch()[0].GetString(); delete result; for(int i = 0; i < NUM_CHARTER_TYPES; i++) { if( inf->charterId[i] != 0 ) { Charter *pCharter = guildmgr.GetCharter(inf->charterId[i], (CharterTypes)i); if( pCharter->LeaderGuid == inf->guid ) pCharter->Destroy(); else pCharter->RemoveSignature(inf->guid); } } for(int i = 0; i < NUM_ARENA_TEAM_TYPES; i++) { if( inf->arenaTeam[i] != NULL ) { if( inf->arenaTeam[i]->m_leader == guid ) return CHAR_DELETE_FAILED_ARENA_CAPTAIN; else inf->arenaTeam[i]->RemoveMember(inf); } } /*if( _socket != NULL ) sPlrsLog.write("Account: %s | IP: %s >> Deleted player %s", GetAccountName().c_str(), GetSocket()->GetRemoteIP().c_str(), name.c_str());*/ sWorld.LogPlayer(this, "deleted character %s (GUID: %u)", name.c_str(), (uint32)guid); /* if ( sWorld.char_restore_enabled ) { //insert data into "deleted" tables CharacterDatabase.WaitExecute("INSERT INTO characters_deleted SELECT UNIX_TIMESTAMP(NOW()),characters.* FROM characters WHERE guid = %u", (uint32)guid); CharacterDatabase.WaitExecute("INSERT INTO playerglyphs_deleted SELECT playerglyphs.* FROM playerglyphs WHERE guid = %u", (uint32)guid); CharacterDatabase.WaitExecute("INSERT INTO playeritems_deleted SELECT playeritems.* FROM playeritems WHERE ownerguid = %u", (uint32)guid); CharacterDatabase.WaitExecute("INSERT INTO playerskills_deleted SELECT playerskills.* FROM playerskills WHERE player_guid = %u", (uint32)guid); CharacterDatabase.WaitExecute("INSERT INTO playerspells_deleted SELECT playerspells.* FROM playerspells WHERE guid = %u", (uint32)guid); CharacterDatabase.WaitExecute("INSERT INTO playertalents_deleted SELECT playertalents.* FROM playertalents WHERE guid = %u", (uint32)guid); CharacterDatabase.WaitExecute("INSERT INTO questlog_deleted SELECT questlog.* FROM questlog WHERE player_guid = %u", (uint32)guid); }*/ CharacterDatabase.WaitExecute("DELETE FROM characters WHERE guid = %u", (uint32)guid); Corpse* c=objmgr.GetCorpseByOwner((uint32)guid); if(c) CharacterDatabase.Execute("DELETE FROM corpses WHERE guid = %u", c->GetLowGUID()); CharacterDatabase.Execute("DELETE FROM achievements WHERE player = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM auctions WHERE owner = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM charters WHERE leaderGuid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM gm_tickets WHERE guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM guild_data WHERE playerid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM instances WHERE creator_guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM mailbox WHERE player_guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playercooldowns WHERE player_guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playerglyphs WHERE guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playeritems WHERE ownerguid=%u",(uint32)guid); CharacterDatabase.Execute("DELETE FROM playerpets WHERE ownerguid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playerpetspells WHERE ownerguid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playerskills WHERE player_guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playerspells WHERE guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playersummonspells WHERE ownerguid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM playertalents WHERE guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM questlog WHERE player_guid = %u", (uint32)guid); CharacterDatabase.Execute("DELETE FROM social_friends WHERE character_guid = %u OR friend_guid = %u", (uint32)guid, (uint32)guid); CharacterDatabase.Execute("DELETE FROM social_ignores WHERE character_guid = %u OR ignore_guid = %u", (uint32)guid, (uint32)guid); CharacterDatabase.Execute("DELETE FROM tutorials WHERE playerId = %u", (uint32)guid); /* remove player info */ objmgr.DeletePlayerInfo((uint32)guid); return CHAR_DELETE_SUCCESS; } return CHAR_DELETE_FAILED; }