Skip to content

Commit

Permalink
Merge pull request #570 from sebastian-heinz/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
alborrajo authored Sep 23, 2024
2 parents 16848da + e2a09a5 commit bd930b2
Show file tree
Hide file tree
Showing 381 changed files with 37,612 additions and 2,881 deletions.
12 changes: 3 additions & 9 deletions Arrowgene.Ddon.Cli/Command/ClientCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -221,15 +221,9 @@ public CommandResultType Run(CommandParameter parameter)
GmdCsv.Entry matchCsvEntry = null;
foreach (GmdCsv.Entry csvEntry in gmdCsvEntries)
{
if (!string.IsNullOrEmpty(entry.Key) && csvEntry.Key == entry.Key)
{
// matched based on key
matchCsvEntry = csvEntry;
break;
}

if (entry.ReadIndex == csvEntry.ReadIndex)
if (!string.IsNullOrEmpty(entry.Key) && csvEntry.Key == entry.Key && entry.ReadIndex == csvEntry.ReadIndex)
{
// Both key AND index have to match, because there are gui entries with duplicate keys.
matchCsvEntry = csvEntry;
break;
}
Expand Down
19 changes: 16 additions & 3 deletions Arrowgene.Ddon.Cli/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* This file is part of Arrowgene.Ddon.Cli
*
* Arrowgene.Ddon.Cli is a server implementation for the game "Dragons Dogma Online".
Expand Down Expand Up @@ -47,13 +47,26 @@ internal class Program
// A list of packet Ids to always ignore, regardless of setting
private static HashSet<PacketId> IgnorePacketIds = new HashSet<PacketId>()
{
new PacketId(3, 3, 16, ""),
new PacketId(6, 25, 16, ""),
PacketId.C2S_CONNECTION_PING_REQ,
PacketId.S2C_CONNECTION_PING_RES,

PacketId.C2L_PING_REQ,
PacketId.L2C_PING_RES,

PacketId.S2C_LOBBY_LOBBY_DATA_MSG_NTC,
PacketId.C2S_LOBBY_LOBBY_DATA_MSG_REQ,
PacketId.S2C_LOBBY_LOBBY_CHAT_MSG_NTC,

PacketId.C2S_PARTY_SEND_BINARY_MSG_NTC,
PacketId.S2C_PARTY_RECV_BINARY_MSG_NTC,

PacketId.S2C_CONTEXT_MASTER_CHANGE_NTC,
PacketId.C2S_CONTEXT_GET_SET_CONTEXT_REQ,
PacketId.C2S_CONTEXT_SET_CONTEXT_NTC,
PacketId.S2C_CONTEXT_SET_CONTEXT_NTC,
PacketId.S2C_CONTEXT_SET_CONTEXT_BASE_NTC,

PacketId.S2C_USER_LIST_JOIN_NTC
};

private static void Main(string[] args)
Expand Down
12 changes: 12 additions & 0 deletions Arrowgene.Ddon.Database/Arrowgene.Ddon.Database.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
<ContentWithTargetPath Remove="files\database\script\crest_migration.sql" />
<ContentWithTargetPath Remove="Files\Database\Script\equippoints_migration.sql" />
<ContentWithTargetPath Remove="Files\Database\Script\equip_migration_sqlite.sql" />
<ContentWithTargetPath Remove="files\database\script\migration_msq_2.0.sql" />
<ContentWithTargetPath Remove="files\database\script\migration_msq_2.1.sql" />
<ContentWithTargetPath Remove="Files\Database\Script\migration_quest_variant.sql" />
<ContentWithTargetPath Remove="Files\Database\Script\migration_rented_pawn.sql" />
<ContentWithTargetPath Remove="Files\Database\Script\pawncraftingdata_migration.sql" />
<ContentWithTargetPath Remove="Files\Database\Script\schema_sqlite.sql" />
Expand Down Expand Up @@ -71,6 +74,12 @@
<None Update="Files\Database\Script\equip_migration_sqlite.sql">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Database\Script\migration_msq_2.0.sql">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Database\Script\migration_msq_2.1.sql">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Database\Script\migration_rented_pawn.sql">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -98,6 +107,9 @@
<None Update="Files\Database\Script\AddMissingOnDeleteCascades_migration.sql">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Database\Script\migration_quest_variant.sql">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion Arrowgene.Ddon.Database/DdonDatabaseBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static class DdonDatabaseBuilder
private static readonly ILogger Logger = LogProvider.Logger<Logger>(typeof(DdonDatabaseBuilder));
private const string DefaultSchemaFile = "Script/schema_sqlite.sql";

public const uint Version = 14;
public const uint Version = 17;

public static IDatabase Build(DatabaseSetting settings)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO ddon_quest_progress(character_common_id, quest_type, quest_id, step, variant_quest_id)
VALUES ((SELECT character_common_id FROM ddon_completed_quests WHERE quest_id = 30), 3, 20010, 0, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO ddon_quest_progress(character_common_id, quest_type, quest_id, step, variant_quest_id)
VALUES ((SELECT character_common_id FROM ddon_completed_quests WHERE quest_id = 20070), 3, 20080, 0, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

ALTER TABLE "ddon_quest_progress"
ADD COLUMN "variant_quest_id" INTEGER NOT NULL DEFAULT 0;

ALTER TABLE "ddon_reward_box"
ADD COLUMN "variant_quest_id" INTEGER NOT NULL DEFAULT 0;

UPDATE "ddon_quest_progress" SET "quest_id" = 20055001 WHERE "quest_id" = 2005501;
UPDATE "ddon_quest_progress" SET "variant_quest_id" = 102030 WHERE "quest_id" = 20055001;

UPDATE "ddon_priority_quests" SET "quest_id" = 20055001 WHERE "quest_id" = 2005501;

UPDATE "ddon_reward_box" SET "quest_id" = 20055001 WHERE "quest_id" = 2005501;

UPDATE "ddon_completed_quests" SET "quest_id" = 20055001 WHERE "quest_id" = 2005501;
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ CREATE TABLE IF NOT EXISTS "ddon_reward_box"
"random_reward1_index" INTEGER NOT NULL,
"random_reward2_index" INTEGER NOT NULL,
"random_reward3_index" INTEGER NOT NULL,
"variant_quest_id" INTEGER NOT NULL DEFAULT 0,
CONSTRAINT "fk_ddon_reward_box_character_common_id" FOREIGN KEY ("character_common_id") REFERENCES "ddon_character_common" ("character_common_id") ON DELETE CASCADE
);

Expand All @@ -551,6 +552,7 @@ CREATE TABLE IF NOT EXISTS "ddon_quest_progress"
"quest_type" INTEGER NOT NULL,
"quest_id" INTEGER NOT NULL,
"step" INTEGER NOT NULL,
"variant_quest_id" INTEGER NOT NULL,
CONSTRAINT "fk_ddon_quest_progress_character_common_id" FOREIGN KEY ("character_common_id") REFERENCES "ddon_character_common" ("character_common_id") ON DELETE CASCADE
);

Expand Down
19 changes: 8 additions & 11 deletions Arrowgene.Ddon.Database/IDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ CDataPawnSearchParameter searchParams

#region Pawn craft progress
bool ReplacePawnCraftProgress(CraftProgress craftProgress);
bool InsertPawnCraftProgress(CraftProgress craftProgress);
bool InsertPawnCraftProgress(CraftProgress craftProgress, DbConnection? connectionIn = null);
bool InsertIfNotExistsPawnCraftProgress(CraftProgress craftProgress);
bool UpdatePawnCraftProgress(CraftProgress craftProgress);
bool DeletePawnCraftProgress(uint craftCharacterId, uint craftLeadPawnId);
Expand All @@ -140,7 +140,7 @@ CDataPawnSearchParameter searchParams
bool DeleteSpSkill(uint pawnId, JobId job, byte spSkillId);

// CharacterJobData
bool ReplaceCharacterJobData(uint commonId, CDataCharacterJobData replacedCharacterJobData);
bool ReplaceCharacterJobData(uint commonId, CDataCharacterJobData replacedCharacterJobData, DbConnection? connectionIn = null);
bool UpdateCharacterJobData(uint commonId, CDataCharacterJobData updatedCharacterJobData);

// Wallet Points
Expand Down Expand Up @@ -424,19 +424,16 @@ bool InsertIfNotExistCompletedQuest(
QuestType questType
);

// Quest Progress
bool InsertQuestProgress(
bool ReplaceCompletedQuest(
uint characterCommonId,
QuestId questId,
QuestType questType,
uint step
);
bool UpdateQuestProgress(
uint characterCommonId,
QuestId questId,
QuestType questType,
uint step
uint count = 1
);

// Quest Progress
bool InsertQuestProgress(uint characterCommonId, QuestId questId, QuestType questType, uint step, uint variantId=0);
bool UpdateQuestProgress(uint characterCommonId, QuestId questId, QuestType questType, uint step);
bool RemoveQuestProgress(uint characterCommonId, QuestId questId, QuestType questType);
List<QuestProgress> GetQuestProgressByType(uint characterCommonId, QuestType questType);
QuestProgress GetQuestProgressById(uint characterCommonId, QuestId questId);
Expand Down
27 changes: 27 additions & 0 deletions Arrowgene.Ddon.Database/Sql/Core/DdonSqlCompletedQuests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public abstract partial class DdonSqlDb<TCon, TCom, TReader> : SqlDb<TCon, TCom,
$"\"character_common_id\" = @character_common_id AND \"quest_id\" = @quest_id);";
private readonly string SqlSelectCompletedQuestByType = $"SELECT {BuildQueryField(CompletedQuestsFields)} FROM \"ddon_completed_quests\" WHERE \"character_common_id\" = @character_common_id AND \"quest_type\" = @quest_type;";
private readonly string SqlSelectCompletedQuestById = $"SELECT {BuildQueryField(CompletedQuestsFields)} FROM \"ddon_completed_quests\" WHERE \"character_common_id\" = @character_common_id AND \"quest_id\" = @quest_id;";
private readonly string SqlUpdateCompletedQuestId = $"UPDATE \"ddon_completed_quests\" SET \"clear_count\" = @clear_count WHERE \"character_common_id\" = @character_common_id AND \"quest_id\" = @quest_id;";

public List<CompletedQuest> GetCompletedQuestsByType(uint characterCommonId, QuestType questType)
{
Expand Down Expand Up @@ -103,6 +104,32 @@ public bool InsertIfNotExistCompletedQuest(TCon connection, uint characterCommon
AddParameter(command, "clear_count", 1);
}) == 1;
}

public bool ReplaceCompletedQuest(uint characterCommonId, QuestId questId, QuestType questType, uint count = 1)
{
using TCon connection = OpenNewConnection();
return ReplaceCompletedQuest(connection, characterCommonId, questId, questType, count);
}

public bool ReplaceCompletedQuest(TCon connection, uint characterCommonId, QuestId questId, QuestType questType, uint count = 1)
{
if (!InsertIfNotExistCompletedQuest(connection, characterCommonId, questId, questType))
{
return UpdateCompletedQuest(connection, characterCommonId, questId, questType, count);
}
return true;
}

private bool UpdateCompletedQuest(TCon connection, uint characterCommonId, QuestId questId, QuestType questType, uint count = 1)
{
return ExecuteNonQuery(connection, SqlUpdateCompletedQuestId, command =>
{
AddParameter(command, "character_common_id", characterCommonId);
AddParameter(command, "quest_id", (uint)questId);
AddParameter(command, "quest_type", (uint)questType);
AddParameter(command, "clear_count", count);
}) == 1;
}
}
}

24 changes: 24 additions & 0 deletions Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbCharacter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Arrowgene.Ddon.Shared.Csv;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Ddon.Shared.Model;
using Arrowgene.Ddon.Shared.Model.Quest;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;

namespace Arrowgene.Ddon.Database.Sql.Core
{
Expand Down Expand Up @@ -372,6 +374,28 @@ private void QueryCharacterData(TCon conn, Character character)
character.AbilityPresets.Add(ReadAbilityPreset(reader));
}
});

// Quest Completion
foreach (var questType in Enum.GetValues(typeof(QuestType)).Cast<QuestType>())
{
ExecuteReader(conn, SqlSelectCompletedQuestByType,
command => {
AddParameter(command, "@character_common_id", character.CommonId);
AddParameter(command, "@quest_type", (uint)questType);
}, reader => {
while (reader.Read())
{
var quest = new CompletedQuest()
{
QuestId = (QuestId)GetUInt32(reader, "quest_id"),
QuestType = questType,
ClearCount = GetUInt32(reader, "clear_count")
};

character.CompletedQuests.TryAdd(quest.QuestId, quest);
}
});
}
}

public bool UpdateMyPawnSlot(uint characterId, uint num)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private void StoreCharacterCommonData(TCon conn, CharacterCommon common)
{
foreach(CDataCharacterJobData characterJobData in common.CharacterJobDataList)
{
ReplaceCharacterJobData(conn, common.CommonId, characterJobData);
ReplaceCharacterJobData(common.CommonId, characterJobData, conn);
}

foreach(CDataNormalSkillParam normalSkillParam in common.LearnedNormalSkills)
Expand Down
28 changes: 16 additions & 12 deletions Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbCharacterJobData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Data.Common;
using Arrowgene.Ddon.Database.Model;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Ddon.Shared.Model;

Expand Down Expand Up @@ -36,21 +37,24 @@ public abstract partial class DdonSqlDb<TCon, TCom, TReader> : SqlDb<TCon, TCom,

private const string SqlDeleteCharacterJobData = "DELETE FROM \"ddon_character_job_data\" WHERE \"character_common_id\"=@character_common_id AND \"job\" = @job;";

public bool ReplaceCharacterJobData(uint commonId, CDataCharacterJobData replacedCharacterJobData)
public bool ReplaceCharacterJobData(uint commonId, CDataCharacterJobData replacedCharacterJobData, DbConnection? connectionIn = null)
{
using TCon connection = OpenNewConnection();
return ReplaceCharacterJobData(connection, commonId, replacedCharacterJobData);
}

public bool ReplaceCharacterJobData(TCon connection, uint commonId, CDataCharacterJobData replacedCharacterJobData)
{
Logger.Debug("Inserting character job data.");
if (!InsertIfNotExistsCharacterJobData(connection, commonId, replacedCharacterJobData))
bool isTransaction = connectionIn is not null;
TCon connection = (TCon)(connectionIn ?? OpenNewConnection());
try
{
Logger.Debug("Inserting character job data.");
if (!InsertIfNotExistsCharacterJobData(connection, commonId, replacedCharacterJobData))
{
Logger.Debug("Character job data already exists, replacing.");
return UpdateCharacterJobData(connection, commonId, replacedCharacterJobData);
}
return true;
}
finally
{
Logger.Debug("Character job data already exists, replacing.");
return UpdateCharacterJobData(connection, commonId, replacedCharacterJobData);
if (!isTransaction) connection.Dispose();
}
return true;
}

public bool InsertCharacterJobData(uint commonId, CDataCharacterJobData updatedCharacterJobData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ public bool ReplaceCommunicationShortcut(uint characterId, CDataCommunicationSho
TCon connection = (TCon)(connectionIn ?? OpenNewConnection());
try
{
Logger.Debug("Inserting communication shortcut.");
if (!InsertIfNotExistsCommunicationShortcut((TCon)connection, characterId, communicationShortcut))
{
Logger.Debug("Communication shortcut already exists, replacing.");
return UpdateCommunicationShortcut((TCon)connection, characterId, communicationShortcut.PageNo, communicationShortcut.ButtonNo, communicationShortcut);
}
return true;
Expand Down
21 changes: 13 additions & 8 deletions Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbPawnCraftProgress.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.ComponentModel.Design;
using System.Data.Common;
using Arrowgene.Ddon.Database.Model;
using Arrowgene.Ddon.Shared.Model;

namespace Arrowgene.Ddon.Database.Sql.Core
Expand Down Expand Up @@ -47,15 +49,18 @@ public bool ReplacePawnCraftProgress(TCon connection, CraftProgress craftProgres
return true;
}

public bool InsertPawnCraftProgress(CraftProgress craftProgress)
public bool InsertPawnCraftProgress(CraftProgress craftProgress, DbConnection? connectionIn = null)
{
using TCon connection = OpenNewConnection();
return InsertPawnCraftProgress(connection, craftProgress);
}

public bool InsertPawnCraftProgress(TCon connection, CraftProgress craftProgress)
{
return ExecuteNonQuery(connection, SqlInsertPawnCraftProgress, command => { AddAllParameters(command, craftProgress); }) == 1;
bool isTransaction = connectionIn is not null;
TCon connection = (TCon)(connectionIn ?? OpenNewConnection());
try
{
return ExecuteNonQuery(connection, SqlInsertPawnCraftProgress, command => { AddAllParameters(command, craftProgress); }) == 1;
}
finally
{
if (!isTransaction) connection.Dispose();
}
}

public bool InsertIfNotExistsPawnCraftProgress(CraftProgress craftProgress)
Expand Down
4 changes: 3 additions & 1 deletion Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbQuestReward.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract partial class DdonSqlDb<TCon, TCom, TReader> : SqlDb<TCon, TCom,
private readonly int MAX_RANDOM_REWARDS = 4;
protected static readonly string[] RewardBoxFields = new string[]
{
/* uniq_reward_id */ "character_common_id", "quest_id", "num_random_rewards", "random_reward0_index", "random_reward1_index", "random_reward2_index", "random_reward3_index"
/* uniq_reward_id */ "character_common_id", "quest_id", "num_random_rewards", "random_reward0_index", "random_reward1_index", "random_reward2_index", "random_reward3_index", "variant_quest_id"
};

private readonly string SqlInsertRewardBoxItems = $"INSERT INTO \"ddon_reward_box\" ({BuildQueryField(RewardBoxFields)}) VALUES ({BuildQueryInsert(RewardBoxFields)});";
Expand All @@ -39,6 +39,7 @@ public bool InsertBoxRewardItems(TCon conn, uint commonId, QuestBoxRewards rewar
AddParameter(command, "character_common_id", commonId);
AddParameter(command, "quest_id", (uint) rewards.QuestId);
AddParameter(command, "num_random_rewards", rewards.NumRandomRewards);
AddParameter(command, "variant_quest_id", rewards.VariantId);

int i;
for(i = 0; i < rewards.NumRandomRewards; i++)
Expand Down Expand Up @@ -102,6 +103,7 @@ private QuestBoxRewards ReadDatabaseQuestBoxReward(TReader reader)
obj.CharacterCommonId = GetUInt32(reader, "character_common_id");
obj.QuestId = (QuestId) GetUInt32(reader, "quest_id");
obj.NumRandomRewards = GetInt32(reader, "num_random_rewards");
obj.VariantId = GetUInt32(reader, "variant_quest_id");

for (int i = 0; i < obj.NumRandomRewards; i++)
{
Expand Down
2 changes: 0 additions & 2 deletions Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbShortcut.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ public bool ReplaceShortcut(uint characterId, CDataShortCut shortcut, DbConnecti
TCon connection = (TCon)(connectionIn ?? OpenNewConnection());
try
{
Logger.Debug("Inserting shortcut.");
if (!InsertIfNotExistsShortcut((TCon)connection, characterId, shortcut))
{
Logger.Debug("Shortcut already exists, replacing.");
return UpdateShortcut((TCon)connection, characterId, shortcut.PageNo, shortcut.ButtonNo, shortcut);
}
return true;
Expand Down
Loading

0 comments on commit bd930b2

Please sign in to comment.