diff options
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r-- | src/game/Player.cpp | 103 |
1 files changed, 80 insertions, 23 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 1be902f72e4..26ba1853176 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -731,12 +731,12 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 } } - StoreNewItemInBestSlot(item_id, count); + StoreNewItemInBestSlots(item_id, count); } } for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr!=info->item.end(); ++item_id_itr++) - StoreNewItemInBestSlot(item_id_itr->item_id, item_id_itr->item_amount); + StoreNewItemInBestSlots(item_id_itr->item_id, item_id_itr->item_amount); // bags and main-hand weapon must equipped at this moment // now second pass for not equipped (offhand weapon/shield if it attempt equipped before main-hand weapon) @@ -776,24 +776,30 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 return true; } -bool Player::StoreNewItemInBestSlot(uint32 titem_id, uint32 titem_amount) +bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount) { sLog.outDebug("STORAGE: Creating initial item, itemId = %u, count = %u",titem_id, titem_amount); - // attempt equip - uint16 eDest; - uint8 msg = CanEquipNewItem( NULL_SLOT, eDest, titem_id, titem_amount, false ); - if( msg == EQUIP_ERR_OK ) + // attempt equip by one + while(titem_amount > 0) { - EquipNewItem( eDest, titem_id, titem_amount, true); + uint16 eDest; + uint8 msg = CanEquipNewItem( NULL_SLOT, eDest, titem_id, false ); + if( msg != EQUIP_ERR_OK ) + break; + + EquipNewItem( eDest, titem_id, true); AutoUnequipOffhandIfNeed(); - return true; // equipped + --titem_amount; } + if(titem_amount == 0) + return true; // equipped + // attempt store ItemPosCountVec sDest; // store in main bag to simplify second pass (special bags can be not equipped yet at this moment) - msg = CanStoreNewItem( INVENTORY_SLOT_BAG_0, NULL_SLOT, sDest, titem_id, titem_amount ); + uint8 msg = CanStoreNewItem( INVENTORY_SLOT_BAG_0, NULL_SLOT, sDest, titem_id, titem_amount ); if( msg == EQUIP_ERR_OK ) { StoreNewItem( sDest, titem_id, true, Item::GenerateItemRandomPropertyId(titem_id) ); @@ -8098,7 +8104,7 @@ void Player::SendInitWorldStates(bool forceZone, uint32 forceZoneId) bg->FillInitialWorldStates(data); else { - data << uint32(0xbb8) << uint32(0x0); // 7 gold + data << uint32(0xbb8) << uint32(0x0); // 7 gold data << uint32(0xbb9) << uint32(0x0); // 8 green data << uint32(0xbba) << uint32(0x0); // 9 show } @@ -9666,10 +9672,10 @@ uint8 Player::CanStoreItems( Item **pItems,int count) const } ////////////////////////////////////////////////////////////////////////// -uint8 Player::CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, uint32 count, bool swap ) const +uint8 Player::CanEquipNewItem( uint8 slot, uint16 &dest, uint32 item, bool swap ) const { dest = 0; - Item *pItem = Item::CreateItem( item, count, this ); + Item *pItem = Item::CreateItem( item, 1, this ); if( pItem ) { uint8 result = CanEquipItem(slot, dest, pItem, swap ); @@ -10333,12 +10339,12 @@ Item* Player::_StoreItem( uint16 pos, Item *pItem, uint32 count, bool clone, boo } } -Item* Player::EquipNewItem( uint16 pos, uint32 item, uint32 count, bool update ) +Item* Player::EquipNewItem( uint16 pos, uint32 item, bool update ) { - Item *pItem = Item::CreateItem( item, count, this ); + Item *pItem = Item::CreateItem( item, 1, this ); if( pItem ) { - ItemAddedQuestCheck( item, count ); + ItemAddedQuestCheck( item, 1 ); Item * retItem = EquipItem( pos, pItem, update ); return retItem; @@ -13689,6 +13695,36 @@ void Player::_LoadDeclinedNames(QueryResult* result) delete result; } +void Player::_LoadArenaTeamInfo(QueryResult *result) +{ + // arenateamid, played_week, played_season, personal_rating + memset((void*)&m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1], 0, sizeof(uint32)*18); + if (!result) + return; + + do + { + Field *fields = result->Fetch(); + + uint32 arenateamid = fields[0].GetUInt32(); + uint32 played_week = fields[1].GetUInt32(); + uint32 played_season = fields[2].GetUInt32(); + uint32 personal_rating = fields[3].GetUInt32(); + + ArenaTeam* aTeam = objmgr.GetArenaTeamById(arenateamid); + uint8 arenaSlot = aTeam->GetSlot(); + + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 3] = arenateamid; // TeamID + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 3 + 1] = ((aTeam->GetCaptain() == GetGUID()) ? (uint32)0 : (uint32)1); // Captain 0, member 1 + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 3 + 2] = played_week; // Played Week + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 3 + 3] = played_season; // Played Season + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 3 + 4] = 0; // Unk + m_uint32Values[PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + arenaSlot * 3 + 5] = personal_rating; // Personal Rating + + }while (result->NextRow()); + delete result; +} + bool Player::LoadPositionFromDB(uint32& mapid, float& x,float& y,float& z,float& o, bool& in_flight, uint64 guid) { QueryResult *result = CharacterDatabase.PQuery("SELECT position_x,position_y,position_z,orientation,map,taxi_path FROM characters WHERE guid = '%u'",GUID_LOPART(guid)); @@ -13791,8 +13827,8 @@ float Player::GetFloatValueFromDB(uint16 index, uint64 guid) bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) { - //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [28] [29] 30 31 32 - //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty FROM characters WHERE guid = '%u'", guid); + //// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 [28] [29] 30 31 32 33 + //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty, arena_pending_points FROM characters WHERE guid = '%u'", guid); QueryResult *result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM); if(!result) @@ -13882,6 +13918,14 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) _LoadGroup(holder->GetResult(PLAYER_LOGIN_QUERY_LOADGROUP)); + _LoadArenaTeamInfo(holder->GetResult(PLAYER_LOGIN_QUERY_LOADARENAINFO)); + + uint32 arena_currency = GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY) + fields[33].GetUInt32(); + if (arena_currency > sWorld.getConfig(CONFIG_MAX_ARENA_POINTS)) + arena_currency = sWorld.getConfig(CONFIG_MAX_ARENA_POINTS); + + SetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY, arena_currency); + // check arena teams integrity for(uint32 arena_slot = 0; arena_slot < MAX_ARENA_SLOT; ++arena_slot) { @@ -15281,7 +15325,7 @@ void Player::SaveToDB() "taximask, online, cinematic, " "totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost, resettalents_time, " "trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, " - "death_expire_time, taxi_path, latency) VALUES (" + "death_expire_time, taxi_path, arena_pending_points, latency) VALUES (" << GetGUIDLow() << ", " << GetSession()->GetAccountId() << ", '" << sql_name << "', " @@ -15380,7 +15424,8 @@ void Player::SaveToDB() ss << ", '"; ss << m_taxi.SaveTaxiDestinationsToString(); - ss << "', '"; + + ss << "', '0', '"; ss << GetSession()->GetLatency(); ss << "' )"; @@ -17094,8 +17139,14 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint } else if( IsEquipmentPos( bag, slot ) ) { + if(pProto->BuyCount * count != 1) + { + SendEquipError( EQUIP_ERR_ITEM_CANT_BE_EQUIPPED, NULL, NULL ); + return false; + } + uint16 dest; - uint8 msg = CanEquipNewItem( slot, dest, item, pProto->BuyCount * count, false ); + uint8 msg = CanEquipNewItem( slot, dest, item, false ); if( msg != EQUIP_ERR_OK ) { SendEquipError( msg, NULL, NULL ); @@ -17117,7 +17168,7 @@ bool Player::BuyItemFromVendor(uint64 vendorguid, uint32 item, uint8 count, uint } } - if(Item *it = EquipNewItem( dest, item, pProto->BuyCount * count, true )) + if(Item *it = EquipNewItem( dest, item, true )) { uint32 new_count = pCreature->UpdateVendorItemCurrentCount(crItem,pProto->BuyCount * count); @@ -18253,6 +18304,11 @@ uint32 Player::GetBattleGroundQueueIdFromLevel() const return 6; else return level/10 - 1; // 20..29 -> 1, 30-39 -> 2, ... + /* + assert(bgTypeId < MAX_BATTLEGROUND_TYPES); + BattleGround *bg = sBattleGroundMgr.GetBattleGroundTemplate(bgTypeId); + assert(bg); + return (getLevel() - bg->GetMinLevel()) / 10;*/ } float Player::GetReputationPriceDiscount( Creature const* pCreature ) const @@ -18962,7 +19018,8 @@ void Player::HandleFallDamage(MovementInfo& movementInfo) void Player::HandleFallUnderMap() { - if(InBattleGround() && GetBattleGround() + if(InBattleGround() + && GetBattleGround() && GetBattleGround()->HandlePlayerUnderMap(this)) { // do nothing, the handle already did if returned true |