diff --git a/sql/characters.sql b/sql/characters.sql index 2cc046598..9aee7b2d2 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -21,7 +21,7 @@ DROP TABLE IF EXISTS `character_db_version`; CREATE TABLE `character_db_version` ( - `required_12141_01_characters_character_currencies` bit(1) default NULL + `required_12150_01_characters_saved_variables` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB'; -- @@ -1725,7 +1725,7 @@ UNLOCK TABLES; DROP TABLE IF EXISTS `saved_variables`; CREATE TABLE `saved_variables` ( - `NextArenaPointDistributionTime` bigint(40) UNSIGNED NOT NULL DEFAULT '0', + `NextCurrenciesResetTime` bigint(40) UNSIGNED NOT NULL DEFAULT '0', `NextDailyQuestResetTime` bigint(40) unsigned NOT NULL default '0', `NextWeeklyQuestResetTime` bigint(40) unsigned NOT NULL default '0', `NextMonthlyQuestResetTime` bigint(40) unsigned NOT NULL default '0', diff --git a/sql/mangos.sql b/sql/mangos.sql index 0cb690581..68d910f58 100644 --- a/sql/mangos.sql +++ b/sql/mangos.sql @@ -24,7 +24,7 @@ CREATE TABLE `db_version` ( `version` varchar(120) default NULL, `creature_ai_version` varchar(120) default NULL, `cache_id` int(10) default '0', - `required_12141_02_mangos_mangos_command` bit(1) default NULL + `required_12150_01_mangos_mangos_string` bit(1) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes'; -- @@ -3897,12 +3897,6 @@ INSERT INTO `mangos_string` VALUES (738,'Arenas are set to normal playercount.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (739,'Battlegrounds are set to 1v0 for debugging.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (740,'Battlegrounds are set to normal playercount.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(741,'Flushing Arena points based on team ratings, this may take a few minutes. Please stand by...',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(742,'Distributing arena points to players...',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(743,'Finished setting arena points for online players.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(744,'Modifying played count, arena points etc. for loaded arena teams, sending updated stats to online players...',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(745,'Modification done.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), -(746,'Done flushing Arena points.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (750,'Not enough players. This game will close in %u mins.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (751,'Not enough players. This game will close in %u seconds.',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), (752,'Only the Alliance can use that portal',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL), diff --git a/sql/updates/12150_01_characters_saved_variables.sql b/sql/updates/12150_01_characters_saved_variables.sql new file mode 100644 index 000000000..98caac191 --- /dev/null +++ b/sql/updates/12150_01_characters_saved_variables.sql @@ -0,0 +1,4 @@ +ALTER TABLE character_db_version CHANGE COLUMN required_12141_01_characters_character_currencies required_12150_01_characters_saved_variables bit; + +ALTER TABLE `saved_variables` CHANGE COLUMN `NextArenaPointDistributionTime` `NextCurrenciesResetTime` bigint(40) unsigned NOT NULL DEFAULT '0'; +UPDATE `saved_variables` SET `NextCurrenciesResetTime` = 0; diff --git a/sql/updates/12150_01_mangos_mangos_string.sql b/sql/updates/12150_01_mangos_mangos_string.sql new file mode 100644 index 000000000..6d1e0cabb --- /dev/null +++ b/sql/updates/12150_01_mangos_mangos_string.sql @@ -0,0 +1,3 @@ +ALTER TABLE db_version CHANGE COLUMN required_12141_02_mangos_mangos_command required_12150_01_mangos_mangos_string bit; + +DELETE FROM `mangos_string` WHERE `entry` BETWEEN 741 AND 746; diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp index c699b098c..44aed8f9b 100644 --- a/src/game/ArenaTeam.cpp +++ b/src/game/ArenaTeam.cpp @@ -552,33 +552,6 @@ bool ArenaTeam::HaveMember(ObjectGuid guid) const return false; } -uint32 ArenaTeam::GetPoints(uint32 MemberRating) -{ - // returns how many points would be awarded with this team type with this rating - float points; - - uint32 rating = MemberRating + 150 < m_stats.rating ? MemberRating : m_stats.rating; - - if (rating <= 1500) - { - // As of Season 6 and later, all teams below 1500 rating will earn points as if they were a 1500 rated team - if (sWorld.getConfig(CONFIG_UINT32_ARENA_SEASON_ID) >= 6) - rating = 1500; - - points = (float)rating * 0.22f + 14.0f; - } - else - points = 1511.26f / (1.0f + 1639.28f * exp(-0.00412f * (float)rating)); - - // type penalties for <5v5 teams - if (m_Type == ARENA_TYPE_2v2) - points *= 0.76f; - else if (m_Type == ARENA_TYPE_3v3) - points *= 0.88f; - - return (uint32) points; -} - float ArenaTeam::GetChanceAgainst(uint32 own_rating, uint32 enemy_rating) { // returns the chance to win against a team with the given rating, used in the rating adjustment calculation @@ -715,35 +688,6 @@ void ArenaTeam::MemberWon(Player* plr, uint32 againstRating) } } -void ArenaTeam::UpdateArenaPointsHelper(std::map& PlayerPoints) -{ - // called after a match has ended and the stats are already modified - // helper function for arena point distribution (this way, when distributing, no actual calculation is required, just a few comparisons) - // 10 played games per week is a minimum - if (m_stats.games_week < 10) - return; - // to get points, a player has to participate in at least 30% of the matches - uint32 min_plays = (uint32) ceil(m_stats.games_week * 0.3); - for (MemberList::const_iterator itr = m_members.begin(); itr != m_members.end(); ++itr) - { - // the player participated in enough games, update his points - uint32 points_to_add = 0; - if (itr->games_week >= min_plays) - points_to_add = GetPoints(itr->personal_rating); - // OBSOLETE : CharacterDatabase.PExecute("UPDATE arena_team_member SET points_to_add = '%u' WHERE arenateamid = '%u' AND guid = '%u'", points_to_add, m_TeamId, itr->guid); - - std::map::iterator plr_itr = PlayerPoints.find(itr->guid.GetCounter()); - if (plr_itr != PlayerPoints.end()) - { - // check if there is already more points - if (plr_itr->second < points_to_add) - PlayerPoints[itr->guid.GetCounter()] = points_to_add; - } - else - PlayerPoints[itr->guid.GetCounter()] = points_to_add; - } -} - void ArenaTeam::SaveToDB() { // save team and member stats to db diff --git a/src/game/ArenaTeam.h b/src/game/ArenaTeam.h index 45ce56a6a..e90d36ca2 100644 --- a/src/game/ArenaTeam.h +++ b/src/game/ArenaTeam.h @@ -192,7 +192,6 @@ class ArenaTeam void Stats(WorldSession* session); void InspectStats(WorldSession* session, ObjectGuid guid); - uint32 GetPoints(uint32 MemberRating); float GetChanceAgainst(uint32 own_rating, uint32 enemy_rating); int32 WonAgainst(uint32 againstRating); void MemberWon(Player* plr, uint32 againstRating); @@ -200,8 +199,6 @@ class ArenaTeam void MemberLost(Player* plr, uint32 againstRating); void OfflineMemberLost(ObjectGuid guid, uint32 againstRating); - void UpdateArenaPointsHelper(std::map& PlayerPoints); - void NotifyStatsChanged(); void FinishWeek(); diff --git a/src/game/BattleGround/BattleGround.cpp b/src/game/BattleGround/BattleGround.cpp index b7c4192cc..f179bbf10 100644 --- a/src/game/BattleGround/BattleGround.cpp +++ b/src/game/BattleGround/BattleGround.cpp @@ -777,6 +777,7 @@ void BattleGround::EndBattleGround(Team winner) plr->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, member->personal_rating); winner_arena_team->MemberWon(plr, loser_rating); + plr->ModifyCurrencyCount(CURRENCY_CONQUEST_ARENA_META, sWorld.getConfig(CONFIG_UINT32_CURRENCY_ARENA_CONQUEST_POINTS_REWARD)); if (member) { @@ -817,9 +818,6 @@ void BattleGround::EndBattleGround(Team winner) if (isArena() && isRated() && winner_arena_team && loser_arena_team) { - // update arena points only after increasing the player's match count! - // obsolete: winner_arena_team->UpdateArenaPointsHelper(); - // obsolete: loser_arena_team->UpdateArenaPointsHelper(); // save the stat changes winner_arena_team->SaveToDB(); loser_arena_team->SaveToDB(); diff --git a/src/game/BattleGround/BattleGroundMgr.cpp b/src/game/BattleGround/BattleGroundMgr.cpp index 0b5e80d59..c5bb671d9 100644 --- a/src/game/BattleGround/BattleGroundMgr.cpp +++ b/src/game/BattleGround/BattleGroundMgr.cpp @@ -1125,7 +1125,7 @@ void BGQueueRemoveEvent::Abort(uint64 /*e_time*/) /*** BATTLEGROUND MANAGER ***/ /*********************************************************/ -BattleGroundMgr::BattleGroundMgr() : m_AutoDistributionTimeChecker(0), m_ArenaTesting(false) +BattleGroundMgr::BattleGroundMgr() : m_ArenaTesting(false) { for (uint8 i = BATTLEGROUND_TYPE_NONE; i < MAX_BATTLEGROUND_TYPE_ID; ++i) m_BattleGrounds[i].clear(); @@ -1198,21 +1198,6 @@ void BattleGroundMgr::Update(uint32 diff) else m_NextRatingDiscardUpdate -= diff; } - if (sWorld.getConfig(CONFIG_BOOL_ARENA_AUTO_DISTRIBUTE_POINTS)) - { - if (m_AutoDistributionTimeChecker < diff) - { - if (sWorld.GetGameTime() > m_NextAutoDistributionTime) - { - DistributeArenaPoints(); - m_NextAutoDistributionTime = time_t(m_NextAutoDistributionTime + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_UINT32_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS)); - CharacterDatabase.PExecute("UPDATE saved_variables SET NextArenaPointDistributionTime = '" UI64FMTD "'", uint64(m_NextAutoDistributionTime)); - } - m_AutoDistributionTimeChecker = 600000; // check 10 minutes - } - else - m_AutoDistributionTimeChecker -= diff; - } } void BattleGroundMgr::BuildBattleGroundStatusPacket(WorldPacket* data, BattleGround* bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2, ArenaType arenatype) @@ -1718,76 +1703,6 @@ void BattleGroundMgr::CreateInitialBattleGrounds() sLog.outString(">> Loaded %u battlegrounds", count); } -void BattleGroundMgr::InitAutomaticArenaPointDistribution() -{ - if (sWorld.getConfig(CONFIG_BOOL_ARENA_AUTO_DISTRIBUTE_POINTS)) - { - DEBUG_LOG("Initializing Automatic Arena Point Distribution"); - QueryResult* result = CharacterDatabase.Query("SELECT NextArenaPointDistributionTime FROM saved_variables"); - if (!result) - { - DEBUG_LOG("Battleground: Next arena point distribution time not found in SavedVariables, reseting it now."); - m_NextAutoDistributionTime = time_t(sWorld.GetGameTime() + BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY * sWorld.getConfig(CONFIG_UINT32_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS)); - CharacterDatabase.PExecute("INSERT INTO saved_variables (NextArenaPointDistributionTime) VALUES ('" UI64FMTD "')", uint64(m_NextAutoDistributionTime)); - } - else - { - m_NextAutoDistributionTime = time_t((*result)[0].GetUInt64()); - delete result; - } - DEBUG_LOG("Automatic Arena Point Distribution initialized."); - } -} - -void BattleGroundMgr::DistributeArenaPoints() -{ - // used to distribute arena points based on last week's stats - sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_START); - - sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_START); - - // temporary structure for storing maximum points to add values for all players - std::map PlayerPoints; - - // at first update all points for all team members - for (ObjectMgr::ArenaTeamMap::iterator team_itr = sObjectMgr.GetArenaTeamMapBegin(); team_itr != sObjectMgr.GetArenaTeamMapEnd(); ++team_itr) - { - if (ArenaTeam* at = team_itr->second) - { - at->UpdateArenaPointsHelper(PlayerPoints); - } - } - - // cycle that gives points to all players - for (std::map::iterator plr_itr = PlayerPoints.begin(); plr_itr != PlayerPoints.end(); ++plr_itr) - { - // update to database - CharacterDatabase.PExecute("UPDATE characters SET arenaPoints = arenaPoints + '%u' WHERE guid = '%u'", plr_itr->second, plr_itr->first); - // add points if player is online - //if (Player* pl = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, plr_itr->first))) - // pl->ModifyArenaPoints(plr_itr->second); - } - - PlayerPoints.clear(); - - sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_END); - - sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_START); - for (ObjectMgr::ArenaTeamMap::iterator titr = sObjectMgr.GetArenaTeamMapBegin(); titr != sObjectMgr.GetArenaTeamMapEnd(); ++titr) - { - if (ArenaTeam* at = titr->second) - { - at->FinishWeek(); // set played this week etc values to 0 in memory, too - at->SaveToDB(); // save changes - at->NotifyStatsChanged(); // notify the players of the changes - } - } - - sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_END); - - sWorld.SendWorldText(LANG_DIST_ARENA_POINTS_END); -} - void BattleGroundMgr::BuildBattleGroundListPacket(WorldPacket* data, ObjectGuid guid, Player* plr, BattleGroundTypeId bgTypeId, uint8 fromWhere) { if (!plr) diff --git a/src/game/BattleGround/BattleGroundMgr.h b/src/game/BattleGround/BattleGroundMgr.h index 1d13bccdd..10e618e95 100644 --- a/src/game/BattleGround/BattleGroundMgr.h +++ b/src/game/BattleGround/BattleGroundMgr.h @@ -36,7 +36,6 @@ typedef UNORDERED_MAP BattleMastersMap; typedef UNORDERED_MAP CreatureBattleEventIndexesMap; typedef UNORDERED_MAP GameObjectBattleEventIndexesMap; -#define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400 // seconds in a day #define COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME 10 struct GroupQueueInfo; // type predefinition @@ -235,8 +234,6 @@ class BattleGroundMgr uint32 GetRatingDiscardTimer() const; uint32 GetPrematureFinishTime() const; - void InitAutomaticArenaPointDistribution(); - void DistributeArenaPoints(); void ToggleArenaTesting(); void ToggleTesting(); @@ -289,8 +286,6 @@ class BattleGroundMgr typedef std::set ClientBattleGroundIdSet; ClientBattleGroundIdSet m_ClientBattleGroundIds[MAX_BATTLEGROUND_TYPE_ID][MAX_BATTLEGROUND_BRACKETS]; // the instanceids just visible for the client uint32 m_NextRatingDiscardUpdate; - time_t m_NextAutoDistributionTime; - uint32 m_AutoDistributionTimeChecker; bool m_ArenaTesting; bool m_Testing; }; diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 5def23fb3..b1ad6df00 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -104,6 +104,7 @@ bool LoginQueryHolder::Initialize() res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGLYPHS, "SELECT spec, slot, glyph FROM character_glyphs WHERE guid='%u'", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILS, "SELECT id,messageType,sender,receiver,subject,body,expire_time,deliver_time,money,cod,checked,stationery,mailTemplateId,has_items FROM mail WHERE receiver = '%u' ORDER BY id DESC", m_guid.GetCounter()); res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADMAILEDITEMS, "SELECT data, text, mail_id, item_guid, item_template FROM mail_items JOIN item_instance ON item_guid = guid WHERE receiver = '%u'", m_guid.GetCounter()); + res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADCURRENCIES, "SELECT id, totalCount, weekCount, seasonCount, flags FROM character_currencies WHERE guid = '%u'", m_guid.GetCounter()); return res; } diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index e6de5507f..98e30815e 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -821,7 +821,6 @@ ChatCommand* ChatHandler::getCommandTable() { "cometome", SEC_ADMINISTRATOR, false, &ChatHandler::HandleComeToMeCommand, "", NULL }, { "damage", SEC_ADMINISTRATOR, false, &ChatHandler::HandleDamageCommand, "", NULL }, { "combatstop", SEC_GAMEMASTER, false, &ChatHandler::HandleCombatStopCommand, "", NULL }, - { "flusharenapoints", SEC_ADMINISTRATOR, false, &ChatHandler::HandleFlushArenaPointsCommand, "", NULL }, { "repairitems", SEC_GAMEMASTER, true, &ChatHandler::HandleRepairitemsCommand, "", NULL }, { "stable", SEC_ADMINISTRATOR, false, &ChatHandler::HandleStableCommand, "", NULL }, { "waterwalk", SEC_GAMEMASTER, false, &ChatHandler::HandleWaterwalkCommand, "", NULL }, diff --git a/src/game/Chat.h b/src/game/Chat.h index ff8737efb..17169a365 100644 --- a/src/game/Chat.h +++ b/src/game/Chat.h @@ -592,7 +592,6 @@ class MANGOS_DLL_SPEC ChatHandler bool HandleRespawnCommand(char* args); bool HandleComeToMeCommand(char* args); bool HandleCombatStopCommand(char* args); - bool HandleFlushArenaPointsCommand(char* args); bool HandleRepairitemsCommand(char* args); bool HandleStableCommand(char* args); bool HandleWaterwalkCommand(char* args); diff --git a/src/game/Language.h b/src/game/Language.h index f1121d44e..f9fe32e30 100644 --- a/src/game/Language.h +++ b/src/game/Language.h @@ -736,12 +736,12 @@ enum MangosStrings LANG_DEBUG_ARENA_OFF = 738, LANG_DEBUG_BG_ON = 739, LANG_DEBUG_BG_OFF = 740, - LANG_DIST_ARENA_POINTS_START = 741, - LANG_DIST_ARENA_POINTS_ONLINE_START = 742, - LANG_DIST_ARENA_POINTS_ONLINE_END = 743, - LANG_DIST_ARENA_POINTS_TEAM_START = 744, - LANG_DIST_ARENA_POINTS_TEAM_END = 745, - LANG_DIST_ARENA_POINTS_END = 746, +// = 741, not used +// = 742, not used +// = 743, not used +// = 744, not used +// = 745, not used +// = 746, not used // = 747, not used // = 748, not used // = 749, not used diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index a25f78d8d..3b599fdee 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -7130,12 +7130,6 @@ bool ChatHandler::HandleSendMessageCommand(char* args) return true; } -bool ChatHandler::HandleFlushArenaPointsCommand(char* /*args*/) -{ - sBattleGroundMgr.DistributeArenaPoints(); - return true; -} - bool ChatHandler::HandleModifyGenderCommand(char* args) { if (!*args) diff --git a/src/game/Player.cpp b/src/game/Player.cpp index b986e8deb..f1ffdb412 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -720,8 +720,8 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c InitRunes(); SetUInt32Value(PLAYER_FIELD_COINAGE, sWorld.getConfig(CONFIG_UINT32_START_PLAYER_MONEY)); - SetCurrencyCount(CURRENCY_HONOR_POINTS,sWorld.getConfig(CONFIG_UINT32_START_HONOR_POINTS)); - SetCurrencyCount(CURRENCY_CONQUEST_POINTS, sWorld.getConfig(CONFIG_UINT32_START_CONQUEST_POINTS)); + SetCurrencyCount(CURRENCY_HONOR_POINTS,sWorld.getConfig(CONFIG_UINT32_CURRENCY_START_HONOR_POINTS)); + SetCurrencyCount(CURRENCY_CONQUEST_POINTS, sWorld.getConfig(CONFIG_UINT32_CURRENCY_START_CONQUEST_POINTS)); // Played time m_Last_tick = time(NULL); @@ -23190,7 +23190,7 @@ uint32 Player::GetCurrencyWeekCap(CurrencyTypesEntry const * currency) const switch (currency->ID) { case CURRENCY_CONQUEST_POINTS: - cap = sWorld.getConfig(CONFIG_UINT32_CONQUEST_POINTS_DEFAULT_WEEK_CAP); + cap = sWorld.getConfig(CONFIG_UINT32_CURRENCY_CONQUEST_POINTS_DEFAULT_WEEK_CAP); break; } @@ -23425,3 +23425,14 @@ void Player::SetCurrencyFlags(uint32 currencyId, uint8 flags) itr->second.state = PLAYERCURRENCY_CHANGED; } +void Player::ResetCurrencyWeekCounts() +{ + for (PlayerCurrenciesMap::iterator itr = m_currencies.begin(); itr != m_currencies.end(); ++itr) + { + itr->second.weekCount = 0; + itr->second.state = PLAYERCURRENCY_CHANGED; + } + + WorldPacket data(SMSG_WEEKLY_RESET_CURRENCY, 0); + SendDirectMessage(&data); +} diff --git a/src/game/Player.h b/src/game/Player.h index a53a9fdda..ef9e2a138 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1984,6 +1984,7 @@ class MANGOS_DLL_SPEC Player : public Unit void SetCurrencyCount(uint32 id, uint32 count); void SendCurrencyWeekCap(uint32 id) const; void SetCurrencyFlags(uint32 currencyId, uint8 flags); + void ResetCurrencyWeekCounts(); /*********************************************************/ /*** PVP SYSTEM ***/ diff --git a/src/game/World.cpp b/src/game/World.cpp index c1cf767ea..4eeb6ea74 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -35,6 +35,7 @@ #include "SkillDiscovery.h" #include "AccountMgr.h" #include "AchievementMgr.h" +#include "ArenaTeam.h" #include "AuctionHouseMgr.h" #include "ObjectMgr.h" #include "CreatureEventAIMgr.h" @@ -95,6 +96,7 @@ World::World() m_startTime = m_gameTime; m_maxActiveSessionCount = 0; m_maxQueuedSessionCount = 0; + m_NextCurrencyReset = 0; m_NextDailyQuestReset = 0; m_NextWeeklyQuestReset = 0; @@ -596,9 +598,13 @@ void World::LoadConfigSettings(bool reload) setConfigMinMax(CONFIG_UINT32_START_PLAYER_MONEY, "StartPlayerMoney", 0, 0, MAX_MONEY_AMOUNT); - setConfig(CONFIG_UINT32_START_HONOR_POINTS, "StartHonorPoints", 0); - setConfig(CONFIG_UINT32_CONQUEST_POINTS_DEFAULT_WEEK_CAP, "ConquestPointsDefaultWeekCap", 1350 * 100); // with precision - setConfig(CONFIG_UINT32_START_CONQUEST_POINTS, "StartConquestPoints", 0); + setConfigMinMax(CONFIG_UINT32_CURRENCY_RESET_TIME_HOUR, "Currency.ResetHour", 6, 0, 23); + setConfigMinMax(CONFIG_UINT32_CURRENCY_RESET_TIME_WEEK_DAY, "Currency.ResetWeekDay", 3, 0, 6); + setConfigMin(CONFIG_UINT32_CURRENCY_RESET_INTERVAL, "Currency.ResetInterval", 7, 1); + setConfig(CONFIG_UINT32_CURRENCY_START_CONQUEST_POINTS, "Currency.StartConquestPoints", 0); + setConfig(CONFIG_UINT32_CURRENCY_START_HONOR_POINTS, "Currency.StartHonorPoints", 0); + setConfig(CONFIG_UINT32_CURRENCY_CONQUEST_POINTS_DEFAULT_WEEK_CAP, "Currency.ConquestPointsDefaultWeekCap", 1350 * 100); // with precision + setConfig(CONFIG_UINT32_CURRENCY_ARENA_CONQUEST_POINTS_REWARD, "Currency.ConquestPointsArenaReward", 120 * 100); // with precision setConfig(CONFIG_BOOL_ALL_TAXI_PATHS, "AllFlightPaths", false); @@ -747,8 +753,6 @@ void World::LoadConfigSettings(bool reload) setConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH, "BattleGround.PremadeGroupWaitForMatch", 30 * MINUTE * IN_MILLISECONDS); setConfig(CONFIG_UINT32_ARENA_MAX_RATING_DIFFERENCE, "Arena.MaxRatingDifference", 150); setConfig(CONFIG_UINT32_ARENA_RATING_DISCARD_TIMER, "Arena.RatingDiscardTimer", 10 * MINUTE * IN_MILLISECONDS); - setConfig(CONFIG_BOOL_ARENA_AUTO_DISTRIBUTE_POINTS, "Arena.AutoDistributePoints", false); - setConfig(CONFIG_UINT32_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS, "Arena.AutoDistributeInterval", 7); setConfig(CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_JOIN, "Arena.QueueAnnouncer.Join", false); setConfig(CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_EXIT, "Arena.QueueAnnouncer.Exit", false); setConfig(CONFIG_UINT32_ARENA_SEASON_ID, "Arena.ArenaSeason.ID", 1); @@ -1380,7 +1384,6 @@ void World::SetInitialWorldSettings() ///- Initialize Battlegrounds sLog.outString("Starting BattleGround System"); sBattleGroundMgr.CreateInitialBattleGrounds(); - sBattleGroundMgr.InitAutomaticArenaPointDistribution(); ///- Initialize Outdoor PvP sLog.outString("Starting Outdoor PvP System"); @@ -1393,6 +1396,9 @@ void World::SetInitialWorldSettings() sLog.outString("Deleting expired bans..."); LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate"); + sLog.outString("Calculate next currency reset time..."); + InitCurrencyResetTime(); + sLog.outString("Calculate next daily quest reset time..."); InitDailyQuestResetTime(); @@ -1494,6 +1500,10 @@ void World::Update(uint32 diff) if (m_gameTime > m_NextMonthlyQuestReset) ResetMonthlyQuests(); + /// Handle monthly quests reset time + if (m_gameTime > m_NextCurrencyReset) + ResetCurrencyWeekCounts(); + ///
  • Handle auctions when the timer has passed if (m_timers[WUPDATE_AUCTIONS].Passed()) { @@ -2132,6 +2142,44 @@ void World::SetMonthlyQuestResetTime(bool initialize) CharacterDatabase.PExecute("UPDATE saved_variables SET NextMonthlyQuestResetTime = '" UI64FMTD "'", uint64(m_NextMonthlyQuestReset)); } +void World::InitCurrencyResetTime() +{ + QueryResult* result = CharacterDatabase.Query("SELECT `NextCurrenciesResetTime` FROM `saved_variables`"); + if (!result) + m_NextCurrencyReset = time_t(time(NULL)); // game time not yet init + else + m_NextCurrencyReset = time_t((*result)[0].GetUInt64()); + + // re-init case or not exists + if (!m_NextCurrencyReset) + { + // generate time by config + time_t curTime = time(NULL); + tm localTm = *localtime(&curTime); + + int week_day_offset = localTm.tm_wday - int(getConfig(CONFIG_UINT32_CURRENCY_RESET_TIME_WEEK_DAY)); + + // current week reset time + localTm.tm_hour = getConfig(CONFIG_UINT32_CURRENCY_RESET_TIME_HOUR); + localTm.tm_min = 0; + localTm.tm_sec = 0; + time_t nextWeekResetTime = mktime(&localTm); + nextWeekResetTime -= week_day_offset * DAY; + + // next reset time before current moment + if (curTime >= nextWeekResetTime) + nextWeekResetTime += getConfig(CONFIG_UINT32_CURRENCY_RESET_INTERVAL) * DAY; + + // normalize reset time + m_NextCurrencyReset = m_NextCurrencyReset < curTime ? nextWeekResetTime - getConfig(CONFIG_UINT32_CURRENCY_RESET_INTERVAL) * DAY : nextWeekResetTime; + } + + if (!result) + CharacterDatabase.PExecute("INSERT INTO `saved_variables` (`NextCurrenciesResetTime`) VALUES ('" UI64FMTD "')", uint64(m_NextCurrencyReset)); + else + delete result; +} + void World::ResetDailyQuests() { DETAIL_LOG("Daily quests reset for all characters."); @@ -2168,6 +2216,29 @@ void World::ResetMonthlyQuests() SetMonthlyQuestResetTime(false); } +void World::ResetCurrencyWeekCounts() +{ + CharacterDatabase.Execute("UPDATE `character_currencies` SET `weekCount` = 0"); + + for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) + if (itr->second->GetPlayer()) + itr->second->GetPlayer()->ResetCurrencyWeekCounts(); + + for(ObjectMgr::ArenaTeamMap::iterator titr = sObjectMgr.GetArenaTeamMapBegin(); titr != sObjectMgr.GetArenaTeamMapEnd(); ++titr) + { + if (ArenaTeam * at = titr->second) + { + at->FinishWeek(); // set played this week etc values to 0 in memory, too + at->SaveToDB(); // save changes + at->NotifyStatsChanged(); // notify the players of the changes + } + } + + m_NextCurrencyReset = time_t(m_NextCurrencyReset + DAY * sWorld.getConfig(CONFIG_UINT32_CURRENCY_RESET_INTERVAL)); + + CharacterDatabase.PExecute("UPDATE saved_variables SET `NextCurrenciesResetTime` = '" UI64FMTD "'", uint64(m_NextCurrencyReset)); +} + void World::SetPlayerLimit(int32 limit, bool needUpdate) { if (limit < -SEC_ADMINISTRATOR) diff --git a/src/game/World.h b/src/game/World.h index 5f7e88e11..436b4530f 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -108,8 +108,13 @@ enum eConfigUInt32Values CONFIG_UINT32_START_PLAYER_LEVEL, CONFIG_UINT32_START_HEROIC_PLAYER_LEVEL, CONFIG_UINT32_START_PLAYER_MONEY, - CONFIG_UINT32_START_HONOR_POINTS, - CONFIG_UINT32_START_CONQUEST_POINTS, + CONFIG_UINT32_CURRENCY_START_HONOR_POINTS, + CONFIG_UINT32_CURRENCY_START_CONQUEST_POINTS, + CONFIG_UINT32_CURRENCY_CONQUEST_POINTS_DEFAULT_WEEK_CAP, + CONFIG_UINT32_CURRENCY_ARENA_CONQUEST_POINTS_REWARD, + CONFIG_UINT32_CURRENCY_RESET_TIME_HOUR, + CONFIG_UINT32_CURRENCY_RESET_INTERVAL, + CONFIG_UINT32_CURRENCY_RESET_TIME_WEEK_DAY, CONFIG_UINT32_INSTANCE_RESET_TIME_HOUR, CONFIG_UINT32_INSTANCE_UNLOAD_DELAY, CONFIG_UINT32_MAX_SPELL_CASTS_IN_CHAIN, @@ -168,7 +173,6 @@ enum eConfigUInt32Values CONFIG_UINT32_BATTLEGROUND_QUEUE_ANNOUNCER_JOIN, CONFIG_UINT32_ARENA_MAX_RATING_DIFFERENCE, CONFIG_UINT32_ARENA_RATING_DISCARD_TIMER, - CONFIG_UINT32_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS, CONFIG_UINT32_ARENA_SEASON_ID, CONFIG_UINT32_ARENA_SEASON_PREVIOUS_ID, CONFIG_UINT32_CLIENTCACHE_VERSION, @@ -187,7 +191,6 @@ enum eConfigUInt32Values CONFIG_UINT32_GUID_RESERVE_SIZE_CREATURE, CONFIG_UINT32_GUID_RESERVE_SIZE_GAMEOBJECT, CONFIG_UINT32_MIN_LEVEL_FOR_RAID, - CONFIG_UINT32_CONQUEST_POINTS_DEFAULT_WEEK_CAP, CONFIG_UINT32_VALUE_COUNT }; @@ -324,7 +327,6 @@ enum eConfigBoolValues CONFIG_BOOL_SKILL_FAIL_POSSIBLE_FISHINGPOOL, CONFIG_BOOL_BATTLEGROUND_CAST_DESERTER, CONFIG_BOOL_BATTLEGROUND_QUEUE_ANNOUNCER_START, - CONFIG_BOOL_ARENA_AUTO_DISTRIBUTE_POINTS, CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_JOIN, CONFIG_BOOL_ARENA_QUEUE_ANNOUNCER_EXIT, CONFIG_BOOL_OUTDOORPVP_SI_ENABLED, @@ -594,9 +596,11 @@ class World // callback for UpdateRealmCharacters void _UpdateRealmCharCount(QueryResult* resultCharCount, uint32 accountId); + void InitCurrencyResetTime(); void InitDailyQuestResetTime(); void InitWeeklyQuestResetTime(); void SetMonthlyQuestResetTime(bool initialize = true); + void ResetCurrencyWeekCounts(); void ResetDailyQuests(); void ResetWeeklyQuests(); void ResetMonthlyQuests(); @@ -664,7 +668,8 @@ class World // CLI command holder to be thread safe ACE_Based::LockedQueue cliCmdQueue; - // next daily quests reset time + // scheduled reset times + time_t m_NextCurrencyReset; time_t m_NextDailyQuestReset; time_t m_NextWeeklyQuestReset; time_t m_NextMonthlyQuestReset; diff --git a/src/mangosd/mangosd.conf.dist.in b/src/mangosd/mangosd.conf.dist.in index 99c03d014..f4fa4cc5f 100644 --- a/src/mangosd/mangosd.conf.dist.in +++ b/src/mangosd/mangosd.conf.dist.in @@ -537,18 +537,6 @@ LogColors = "" # If you want to start with one silver, use for example 100 (100 copper = 1 silver) # Default: 0 # -# StartHonorPoints -# Amount of honor that new players will start with -# Default: 0 -# -# StartConquestPoints -# Amount of conquest points that new players will start with -# Default: 0 -# -# ConquestPointsDefaultWeekCap -# Amount of conquest points that player can earn per week -# Default: 135000 (with precision) -# # InstantLogout # Enable or disable instant logout for security level (0..4) or high (NOT in combat/while dueling/while falling) # Default: 1 (Mods/GMs/Admins) @@ -779,9 +767,6 @@ MaxPlayerLevel = 85 StartPlayerLevel = 1 StartHeroicPlayerLevel = 55 StartPlayerMoney = 0 -StartHonorPoints = 0 -StartConquestPoints = 0 -ConquestPointsDefaultWeekCap = 135000 InstantLogout = 1 DisableWaterBreath = 4 AllFlightPaths = 0 @@ -1484,15 +1469,6 @@ BattleGround.PremadeGroupWaitForMatch = 1800000 # Default: 600000 (10 minutes, recommended) # 0 (disable) # -# Arena.AutoDistributePoints -# Set if arena points should be distributed automatically, or by GM command -# Default: 0 (disable) (recommended): use gm command or sql query to distribute the points -# 1 (enable) arena points are distributed automatically -# -# Arena.AutoDistributeInterval -# How often should the distribution take place -# If automatic distribution is enabled in days -# Default: 7 (weekly) # # Arena.QueueAnnouncer.Join # Enable arena queue announcer posting to chat at join @@ -1524,8 +1500,6 @@ BattleGround.PremadeGroupWaitForMatch = 1800000 Arena.MaxRatingDifference = 150 Arena.RatingDiscardTimer = 600000 -Arena.AutoDistributePoints = 0 -Arena.AutoDistributeInterval = 7 Arena.QueueAnnouncer.Join = 0 Arena.QueueAnnouncer.Exit = 0 Arena.ArenaSeason.ID = 1 @@ -1677,3 +1651,44 @@ SOAP.Port = 7878 CharDelete.Method = 0 CharDelete.MinLevel = 0 CharDelete.KeepDays = 30 + +################################################################################################################### +# CURRENCIES +# +# Currency.StartHonorPoints +# Amount of honor that new players will start with +# Default: 0 (with precision) +# +# Currency.StartConquestPoints +# Amount of conquest points that new players will start with +# Default: 0 (with precision) +# +# Currency.ResetInterval +# How often should currency week count reset (days) +# Default: 7 (weekly) +# +# Currency.ResetWeekDay +# Week day when currency week count is reset (0..6) 0 == Sunday +# Default: 3 (Wednesday) +# +# Currency.ResetHour +# Hour of a day when currency week count is reset (0..23) +# Default: 6 +# +# Currency.ConquestPointsDefaultWeekCap +# Amount of conquest points that player can earn per week +# Default: 135000 (with precision) +# +# Currency.ConquestPointsArenaReward +# Amount of conquest points rewarded by winning arenas +# Default: 12000 (with precision) +# +################################################################################################################### + +Currency.StartHonorPoints = 0 +Currency.StartConquestPoints = 0 +Currency.ResetInterval = 7 +Currency.ResetWeekDay = 3 +Currency.ResetHour = 6 +Currency.ConquestPointsDefaultWeekCap = 135000 +Currency.ConquestPointsArenaReward = 12000 diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ca8f2b9c2..b1b2551f3 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12149" + #define REVISION_NR "12150" #endif // __REVISION_NR_H__ diff --git a/src/shared/revision_sql.h b/src/shared/revision_sql.h index 5017b3897..b9f1405fb 100644 --- a/src/shared/revision_sql.h +++ b/src/shared/revision_sql.h @@ -1,6 +1,6 @@ #ifndef __REVISION_SQL_H__ #define __REVISION_SQL_H__ - #define REVISION_DB_CHARACTERS "required_12141_01_characters_character_currencies" - #define REVISION_DB_MANGOS "required_12141_02_mangos_mangos_command" + #define REVISION_DB_CHARACTERS "required_12150_01_characters_saved_variables" + #define REVISION_DB_MANGOS "required_12150_01_mangos_mangos_string" #define REVISION_DB_REALMD "required_12112_01_realmd_account_access" #endif // __REVISION_SQL_H__