#115 Always save quests progress if config.ini has AutoSaveQuests = true - unless in open world. In tests.

This commit is contained in:
Lucca Faria Ferri 2023-01-31 14:51:49 -08:00
parent f227b01d5a
commit 85de65c041
2 changed files with 19 additions and 7 deletions

View File

@ -152,6 +152,15 @@ namespace DiIiS_NA.GameServer
set => Set(nameof(BossDamageMultiplier), value);
}
/// <summary>
/// Whether to bypass the quest's settings of "Saveable" to TRUE (unless in OpenWorld)
/// </summary>
public bool AutoSaveQuests
{
get => GetBoolean(nameof(AutoSaveQuests), false);
set => Set(nameof(AutoSaveQuests), value);
}
public static Config Instance { get; } = new();
private Config() : base("Game-Server")

View File

@ -11,6 +11,7 @@ using DiIiS_NA.Core.Logging;
using DiIiS_NA.Core.MPQ.FileFormats;
using DiIiS_NA.Core.Storage.AccountDataBase.Entities;
using DiIiS_NA.D3_GameServer.Core.Types.SNO;
using DiIiS_NA.GameServer;
using DiIiS_NA.GameServer.GSSystem.ActorSystem;
using DiIiS_NA.GameServer.GSSystem.GameSystem;
using DiIiS_NA.GameServer.GSSystem.ItemsSystem;
@ -261,7 +262,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
if (!Game.Empty)
{
RevealQuestProgress();
if (Quests[Game.CurrentQuest].Steps[Game.CurrentStep].Saveable)
if ((Game.CurrentActEnum != ActEnum.OpenWorld && Config.Instance.AutoSaveQuests) || Quests[Game.CurrentQuest].Steps[Game.CurrentStep].Saveable)
SaveQuestProgress(false);
}
OnQuestProgress();
@ -803,7 +804,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
public void SaveQuestProgress(bool questCompleted)
{
foreach (var player in Game.Players.Values)
Game.BroadcastPlayers((client, player) =>
{
player.Toon.CurrentAct = CurrentAct;
player.Toon.CurrentQuestId = Game.CurrentQuest;
@ -813,10 +814,12 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
dbi => dbi.DBToon.Id == player.Toon.PersistentID && dbi.QuestId == Game.CurrentQuest);
if (query.Count == 0)
{
var questHistory = new DBQuestHistory();
questHistory.DBToon = player.Toon.DBToon;
questHistory.QuestId = Game.CurrentQuest;
questHistory.QuestStep = Game.CurrentStep;
var questHistory = new DBQuestHistory
{
DBToon = player.Toon.DBToon,
QuestId = Game.CurrentQuest,
QuestStep = Game.CurrentStep
};
Game.GameDbSession.SessionSave(questHistory);
}
else
@ -829,7 +832,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
Game.GameDbSession.SessionUpdate(questHistory);
}
}
}
});
}
}