Skip to content

Commit

Permalink
Port quest tracking over from TC (TrinityCore/TrinityCore#13353) (#110)
Browse files Browse the repository at this point in the history
* Port quest tracking over from TC (TrinityCore/TrinityCore#13353)

* Fix whitespace
  • Loading branch information
i-am-fyre authored Jul 24, 2023
1 parent 4638cdb commit 8601d27
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmake/MangosParams.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set(MANGOS_EXP "TBC")
set(MANGOS_PKG "Mangos One")
set(MANGOS_WORLD_VER 2022031600)
set(MANGOS_WORLD_VER 2023062700)
set(MANGOS_REALM_VER 2021010100)
set(MANGOS_AHBOT_VER 2021010100)
14 changes: 14 additions & 0 deletions src/game/ChatCommands/QuestCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "Chat.h"
#include "Language.h"
#include "ObjectMgr.h"
#include "World.h"
#include "SQLStorages.h"

bool ChatHandler::HandleQuestAddCommand(char* args)
Expand Down Expand Up @@ -232,6 +233,19 @@ bool ChatHandler::HandleQuestCompleteCommand(char* args)
player->ModifyMoney(-ReqOrRewMoney);
}

if (sWorld.getConfig(CONFIG_BOOL_ENABLE_QUEST_TRACKER)) // check if Quest Tracker is enabled
{
DEBUG_LOG("QUEST TRACKER: Quest Completed by GM.");
static SqlStatementID CHAR_UPD_QUEST_TRACK_GM_COMPLETE;
// prepare Quest Tracker datas
SqlStatement stmt = CharacterDatabase.CreateStatement(CHAR_UPD_QUEST_TRACK_GM_COMPLETE, "UPDATE `quest_tracker` SET `completed_by_gm` = 1 WHERE `id` = ? AND `character_guid` = ? ORDER BY `quest_accept_time` DESC LIMIT 1");
stmt.addUInt32(pQuest->GetQuestId());
stmt.addUInt32(player->GetGUIDLow());

// add to Quest Tracker
stmt.Execute();
}

player->CompleteQuest(entry, QUEST_STATUS_FORCE_COMPLETE);
return true;
}
30 changes: 30 additions & 0 deletions src/game/Object/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include "OutdoorPvP/OutdoorPvP.h"
#include "ArenaTeam.h"
#include "Chat.h"
#include "revision_data.h"
#include "Database/DatabaseImpl.h"
#include "Spell.h"
#include "ScriptMgr.h"
Expand Down Expand Up @@ -15284,6 +15285,22 @@ void Player::AddQuest(Quest const* pQuest, Object* questGiver)
}

UpdateForQuestWorldObjects();

if (sWorld.getConfig(CONFIG_BOOL_ENABLE_QUEST_TRACKER)) // check if Quest Tracker is enabled
{
DEBUG_LOG("QUEST TRACKER: Quest Added.");

static SqlStatementID CHAR_INS_QUEST_TRACK;
// prepare Quest Tracker datas
SqlStatement stmt = CharacterDatabase.CreateStatement(CHAR_INS_QUEST_TRACK, "INSERT INTO `quest_tracker` (`id`, `character_guid`, `quest_accept_time`, `core_hash`, `core_revision`) VALUES (?, ?, NOW(), ?, ?)");
stmt.addUInt32(quest_id);
stmt.addUInt32(GetGUIDLow());
stmt.addString(REVISION_HASH);
stmt.addString(REVISION_DATE);

// add to Quest Tracker
stmt.Execute();
}
}

void Player::CompleteQuest(uint32 quest_id, QuestStatus status)
Expand All @@ -15306,6 +15323,19 @@ void Player::CompleteQuest(uint32 quest_id, QuestStatus status)
}
}
}

if (sWorld.getConfig(CONFIG_BOOL_ENABLE_QUEST_TRACKER)) // check if Quest Tracker is enabled
{
DEBUG_LOG("QUEST TRACKER: Quest Completed.");
static SqlStatementID CHAR_UPD_QUEST_TRACK_COMPLETE_TIME;
// prepare Quest Tracker datas
SqlStatement stmt = CharacterDatabase.CreateStatement(CHAR_UPD_QUEST_TRACK_COMPLETE_TIME, "UPDATE `quest_tracker` SET `quest_complete_time` = NOW() WHERE `id` = ? AND `character_guid` = ? ORDER BY `quest_accept_time` DESC LIMIT 1");
stmt.addUInt32(quest_id);
stmt.addUInt32(GetGUIDLow());

// add to Quest Tracker
stmt.Execute();
}
}

void Player::IncompleteQuest(uint32 quest_id)
Expand Down
13 changes: 13 additions & 0 deletions src/game/WorldHandlers/QuestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,19 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recv_data)

_player->SetQuestStatus(quest, QUEST_STATUS_NONE);

if (sWorld.getConfig(CONFIG_BOOL_ENABLE_QUEST_TRACKER)) // check if Quest Tracker is enabled
{
DEBUG_LOG("QUEST TRACKER: Quest Abandoned.");
static SqlStatementID CHAR_UPD_QUEST_TRACK_ABANDON_TIME;
// prepare Quest Tracker datas
SqlStatement stmt = CharacterDatabase.CreateStatement(CHAR_UPD_QUEST_TRACK_ABANDON_TIME, "UPDATE `quest_tracker` SET `quest_abandon_time` = NOW() WHERE `id` = ? AND `character_guid` = ? ORDER BY `quest_accept_time` DESC LIMIT 1");
stmt.addUInt32(quest);
stmt.addUInt32(_player->GetGUIDLow());

// add to Quest Tracker
stmt.Execute();
}

// Used by Eluna
#ifdef ENABLE_ELUNA
sEluna->OnQuestAbandon(_player, quest);
Expand Down
2 changes: 2 additions & 0 deletions src/game/WorldHandlers/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,8 @@ void World::LoadConfigSettings(bool reload)

setConfig(CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT, "PetUnsummonAtMount", true);

setConfig(CONFIG_BOOL_ENABLE_QUEST_TRACKER, "QuestTracker.Enable", 0);

#ifdef ENABLE_PLAYERBOTS
setConfig(CONFIG_BOOL_PLAYERBOT_DISABLE, "PlayerbotAI.DisableBots", true);
setConfig(CONFIG_BOOL_PLAYERBOT_DEBUGWHISPER, "PlayerbotAI.DebugWhisper", false);
Expand Down
1 change: 1 addition & 0 deletions src/game/WorldHandlers/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ enum eConfigBoolValues
CONFIG_BOOL_MMAP_ENABLED,
CONFIG_BOOL_ELUNA_ENABLED,
CONFIG_BOOL_PLAYER_COMMANDS,
CONFIG_BOOL_ENABLE_QUEST_TRACKER,

#ifdef ENABLE_PLAYERBOTS
CONFIG_BOOL_PLAYERBOT_DISABLE,
Expand Down
11 changes: 11 additions & 0 deletions src/mangosd/mangosd.conf.dist.in
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,17 @@ CharDelete.Method = 0
CharDelete.MinLevel = 0
CharDelete.KeepDays = 30

###################################################################################################
# QUEST TRACKER
# QuestTracker.Enable
# Description: Store data in the database about quest completion and abandonment to help find bugged quests.
# Default: 0 - (Disabled)
# 1 - (Enabled)
#
###################################################################################################

QuestTracker.Enable = 0

###################################################################################################
# WARDEN SETTINGS
#
Expand Down
4 changes: 2 additions & 2 deletions src/shared/revision_data.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
#define REALMD_DB_UPDATE_DESCRIPT "Release 22"

#define CHAR_DB_VERSION_NR "22"
#define CHAR_DB_STRUCTURE_NR "6"
#define CHAR_DB_STRUCTURE_NR "7"
#define CHAR_DB_CONTENT_NR "1"
#define CHAR_DB_UPDATE_DESCRIPT "remove_item_text"
#define CHAR_DB_UPDATE_DESCRIPT "Add_Quest_Tracker_Table"

#define WORLD_DB_VERSION_NR "22"
#define WORLD_DB_STRUCTURE_NR "3"
Expand Down

0 comments on commit 8601d27

Please sign in to comment.