diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/BattleGroundMgr.cpp | 14 | ||||
-rw-r--r-- | src/game/CharacterHandler.cpp | 6 | ||||
-rw-r--r-- | src/game/Player.cpp | 95 |
3 files changed, 80 insertions, 35 deletions
diff --git a/src/game/BattleGroundMgr.cpp b/src/game/BattleGroundMgr.cpp index 864268fc07a..92723ae7ca2 100644 --- a/src/game/BattleGroundMgr.cpp +++ b/src/game/BattleGroundMgr.cpp @@ -1815,19 +1815,13 @@ void BattleGroundMgr::DistributeArenaPoints() //cycle that gives points to all players for (std::map<uint32, uint32>::iterator plr_itr = PlayerPoints.begin(); plr_itr != PlayerPoints.end(); ++plr_itr) { - //add points to player + //update to database + CharacterDatabase.PExecute("UPDATE characters SET arenaPoints = arenaPoints + '%u' WHERE guid = '%u'", plr_itr->second, plr_itr->first); + + //add points to player if online Player* pl = objmgr.GetPlayer(plr_itr->first); if (pl) - { - CharacterDatabase.PExecute("UPDATE characters SET arena_pending_points = '%u' WHERE guid = '%u'", plr_itr->second, plr_itr->first); pl->ModifyArenaPoints(plr_itr->second); - } - else - { - CharacterDatabase.PExecute("UPDATE characters SET arena_pending_points = 0 WHERE guid = '%u'", plr_itr->first); - CharacterDatabase._UpdateDataBlobValue(plr_itr->first, PLAYER_FIELD_ARENA_CURRENCY, - std::min(int32(plr_itr->second),int32(sWorld.getConfig(CONFIG_MAX_ARENA_POINTS)))); - } } PlayerPoints.clear(); diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 3d36c23c904..d105c13ee07 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -65,7 +65,11 @@ bool LoginQueryHolder::Initialize() // NOTE: all fields in `characters` must be read to prevent lost character data at next save in case wrong DB structure. // !!! NOTE: including unused `zone`,`online` - res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, 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, instance_id, speccount, activespec FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid)); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADFROM, "SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags," + "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," + "arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk," + "health, power1, power2, power3, power4, power5, power6, power7, instance_id, speccount, activespec FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid)); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_mask,recalculate_mask,stackcount,amount0,amount1,amount2,base_amount0,base_amount1,base_amount2,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid)); diff --git a/src/game/Player.cpp b/src/game/Player.cpp index e9b9e06fd8b..884820041b3 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -15457,8 +15457,16 @@ 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 33 34 35 36 37 38 39 40 41 42 43 - //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, 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, instance_id, speccount, activespec FROM characters WHERE guid = '%u'", guid); + //// 0 1 2 3 4 5 6 7 8 9 10 11 12 + //QueryResult *result = CharacterDatabase.PQuery("SELECT guid, account, data, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags," + // 13 14 15 16 17 18 19 20 21 22 23 24 25 + //"position_x, position_y, position_z, map, orientation, taximask, cinematic, totaltime, leveltime, rest_bonus, logout_time, is_logout_resting, resettalents_cost," + // 26 27 28 29 30 31 32 33 34 35 36 37 38 39 + //"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," + // 40 41 42 43 44 45 46 47 48 49 50 + //"arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk," + // 51 52 53 54 55 56 57 58 59 60 61 + //"health, power1, power2, power3, power4, power5, power6, power7, instance_id, speccount, activespec FROM characters WHERE guid = '%u'", guid); QueryResult_AutoPtr result = holder->GetResult(PLAYER_LOGIN_QUERY_LOADFROM); if(!result) @@ -15509,11 +15517,18 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) SetUInt32Value(UNIT_FIELD_LEVEL, fields[7].GetUInt8()); SetUInt32Value(PLAYER_XP, fields[8].GetUInt32()); - SetUInt32Value(PLAYER_FIELD_COINAGE, fields[9].GetUInt32()); + + uint32 money = fields[9].GetUInt32(); + if (money > MAX_MONEY_AMOUNT) + money = MAX_MONEY_AMOUNT; + SetMoney(money); + SetUInt32Value(PLAYER_BYTES, fields[10].GetUInt32()); SetUInt32Value(PLAYER_BYTES_2, fields[11].GetUInt32()); - SetUInt32Value(PLAYER_BYTES_3, (GetUInt32Value(PLAYER_BYTES_3) & ~1) | fields[6].GetUInt8()); + SetUInt32Value(PLAYER_BYTES_3, (fields[50].GetUInt16() & 0xFFFE) | fields[6].GetUInt8()); SetUInt32Value(PLAYER_FLAGS, fields[12].GetUInt32()); + SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, fields[49].GetUInt32()); + SetUInt64Value(PLAYER_FIELD_KNOWN_CURRENCIES, fields[48].GetUInt64()); InitDisplayIds(); @@ -15530,10 +15545,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) } } - // update money limits - if(GetMoney() > MAX_MONEY_AMOUNT) - SetMoney(MAX_MONEY_AMOUNT); - sLog.outDebug("Load Basic value of player %s is: ", m_name.c_str()); outDebugValues(); @@ -15551,7 +15562,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) uint32 transGUID = fields[31].GetUInt32(); Relocate(fields[13].GetFloat(),fields[14].GetFloat(),fields[15].GetFloat(),fields[17].GetFloat()); uint32 mapId = fields[16].GetUInt32(); - uint32 instanceId = fields[41].GetFloat(); + uint32 instanceId = fields[59].GetFloat(); uint32 difficulty = fields[39].GetUInt32(); if(difficulty >= MAX_DUNGEON_DIFFICULTY) @@ -15565,7 +15576,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) _LoadArenaTeamInfo(holder->GetResult(PLAYER_LOGIN_QUERY_LOADARENAINFO)); - uint32 arena_currency = GetUInt32Value(PLAYER_FIELD_ARENA_CURRENCY) + fields[40].GetUInt32(); + uint32 arena_currency = fields[40].GetUInt32(); if (arena_currency > sWorld.getConfig(CONFIG_MAX_ARENA_POINTS)) arena_currency = sWorld.getConfig(CONFIG_MAX_ARENA_POINTS); @@ -15587,6 +15598,13 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (arena_slot * ARENA_TEAM_END) + j, 0); } + SetUInt32Value(PLAYER_FIELD_HONOR_CURRENCY, fields[41].GetUInt32()); + SetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION, fields[42].GetUInt32()); + SetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION, fields[43].GetUInt32()); + SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, fields[44].GetUInt32()); + SetUInt16Value(PLAYER_FIELD_KILLS, 0, fields[45].GetUInt16()); + SetUInt16Value(PLAYER_FIELD_KILLS, 1, fields[46].GetUInt16()); + _LoadBoundInstances(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES)); _LoadBGData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBGDATA)); @@ -15895,12 +15913,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) SetUInt64Value(PLAYER_DUEL_ARBITER, 0); SetUInt32Value(PLAYER_DUEL_TEAM, 0); - // remember loaded power/health values to restore after stats initialization and modifier applying - uint32 savedHealth = GetHealth(); - uint32 savedPower[MAX_POWERS]; - for (uint8 i = 0; i < MAX_POWERS; ++i) - savedPower[i] = GetPower(Powers(i)); - // reset stats before loading any modifiers InitStatsForLevel(); InitGlyphsForLevel(); @@ -15915,8 +15927,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) //mails are loaded only when needed ;-) - when player in game click on mailbox. //_LoadMail(); - m_specsCount = fields[42].GetUInt8(); - m_activeSpec = fields[43].GetUInt8(); + m_specsCount = fields[60].GetUInt8(); + m_activeSpec = fields[61].GetUInt8(); // sanity check if (m_specsCount > MAX_TALENT_SPECS || m_activeSpec > MAX_TALENT_SPEC || @@ -15961,9 +15973,11 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) // check PLAYER_CHOSEN_TITLE compatibility with PLAYER__FIELD_KNOWN_TITLES // note: PLAYER__FIELD_KNOWN_TITLES updated at quest status loaded - if (uint32 curTitle = GetUInt32Value(PLAYER_CHOSEN_TITLE)) - if(!HasTitle(curTitle)) - SetUInt32Value(PLAYER_CHOSEN_TITLE, 0); + uint32 curTitle = fields[10].GetUInt32(); + if (curTitle && !HasTitle(curTitle)) + curTitle = 0; + + SetUInt32Value(PLAYER_CHOSEN_TITLE, curTitle); // has to be called after last Relocate() in Player::LoadFromDB SetFallInformation(0, GetPositionZ()); @@ -15980,9 +15994,13 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) UpdateAllStats(); // restore remembered power/health values (but not more max values) + uint32 savedHealth = fields[51].GetUInt32(); SetHealth(savedHealth > GetMaxHealth() ? GetMaxHealth() : savedHealth); for (uint8 i = 0; i < MAX_POWERS; ++i) - SetPower(Powers(i),savedPower[i] > GetMaxPower(Powers(i)) ? GetMaxPower(Powers(i)) : savedPower[i]); + { + uint32 savedPower = fields[52+i].GetUInt32(); + SetPower(Powers(i),savedPower > GetMaxPower(Powers(i)) ? GetMaxPower(Powers(i)) : savedPower); + } sLog.outDebug("The value of player %s after load item and aura is: ", m_name.c_str()); outDebugValues(); @@ -17126,7 +17144,9 @@ 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, arena_pending_points, latency, speccount, activespec) VALUES (" + "death_expire_time, taxi_path, arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, " + "todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk, health, power1, power2, power3, " + "power4, power5, power6, power7, latency, speccount, activespec) VALUES (" << GetGUIDLow() << ", " << GetSession()->GetAccountId() << ", '" << sql_name << "', " @@ -17205,7 +17225,34 @@ void Player::SaveToDB() ss << (uint64)m_deathExpireTime << ", '"; ss << m_taxi.SaveTaxiDestinationsToString() << "', "; - ss << "'0', "; // arena_pending_points + + ss << GetArenaPoints() << ", "; + + ss << GetHonorPoints() << ", "; + + ss << GetUInt32Value(PLAYER_FIELD_TODAY_CONTRIBUTION) << ", "; + + ss << GetUInt32Value(PLAYER_FIELD_YESTERDAY_CONTRIBUTION) << ", "; + + ss << GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS) << ", "; + + ss << GetUInt16Value(PLAYER_FIELD_KILLS, 0) << ", "; + + ss << GetUInt16Value(PLAYER_FIELD_KILLS, 1) << ", "; + + ss << GetUInt32Value(PLAYER_CHOSEN_TITLE) << ", "; + + ss << GetUInt64Value(PLAYER_FIELD_KNOWN_CURRENCIES) << ", "; + + ss << GetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX) << ", "; + + ss << (uint16)(GetUInt32Value(PLAYER_BYTES_3) & 0xFFFE) << ", "; + + ss << GetHealth(); + + for (uint32 i = 0; i < MAX_POWERS; ++i) + ss << ", " << GetPower(Powers(i)); + ss << ", "; ss << GetSession()->GetLatency(); ss << ", "; ss << uint32(m_specsCount); |