Skip to content

Commit

Permalink
Merge pull request #216 from sebastian-heinz/develop
Browse files Browse the repository at this point in the history
New release
  • Loading branch information
alborrajo authored Sep 28, 2023
2 parents 51d7728 + 63346e0 commit dd88306
Show file tree
Hide file tree
Showing 137 changed files with 38,369 additions and 5,158 deletions.
16 changes: 16 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*
!Arrowgene.DragonsDogmaOnline.sln
!SetSourceRevision.targets
# This is required by projects which import the SetSourceRevision.targets command to add Git revision info.
# Not including it causes (ingoreable) errors to be thrown
#!.git/
!Arrowgene.Ddon.Cli/
!Arrowgene.Ddon.Client/
!Arrowgene.Ddon.Database/
!Arrowgene.Ddon.GameServer/
!Arrowgene.Ddon.LoginServer/
!Arrowgene.Ddon.Rpc/
!Arrowgene.Ddon.Rpc.Web/
!Arrowgene.Ddon.Server/
!Arrowgene.Ddon.Shared/
!Arrowgene.Ddon.WebServer/
4 changes: 2 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"fudge.auto-using",
"jeff-hykin.better-cpp-syntax",
"ms-dotnettools.csharp",
"kreativ-software.csharpextensions",
"notblank00.hexeditor",
"wayou.vscode-todo-highlight",
"usernamehw.errorlens",
"mechatroner.rainbow-csv",
"yo1dog.cursor-align",
"wmaurer.change-case",
"softwareape.numbermonger",
"maziac.hex-hover-converter"
"maziac.hex-hover-converter",
"ms-dotnettools.csdevkit"
]
}
12 changes: 4 additions & 8 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"${workspaceFolder}/Arrowgene.Ddon.Cli/Arrowgene.Ddon.Cli.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
]
},
{
"label": "publish",
Expand All @@ -22,8 +21,7 @@
"${workspaceFolder}/Arrowgene.Ddon.Cli/Arrowgene.Ddon.Cli.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
]
},
{
"label": "watch",
Expand All @@ -35,8 +33,7 @@
"${workspaceFolder}/Arrowgene.Ddon.Cli/Arrowgene.Ddon.Cli.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
]
},
{
"label": "packet",
Expand All @@ -49,8 +46,7 @@
"packet",
"${input:pathToYaml}",
"${input:camelliaKey}"
],
"problemMatcher": "$msCompile"
]
}
],
"inputs": [
Expand Down
3 changes: 3 additions & 0 deletions Arrowgene.Ddon.Cli/Command/PacketCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Server.Network;
using Arrowgene.Ddon.Shared.Network;
Expand Down Expand Up @@ -85,6 +86,8 @@ public CommandResultType Run(CommandParameter parameter)
annotated.Append($" Pcap(No:{pcapPacket.Packet} Ts:{pcapPacket.TimeStamp})");
annotated.Append(Environment.NewLine);
annotated.Append(readPacket.PrintData());
annotated.Append(string.Join(", ", readPacket.Data.Select(dataByte => String.Format("0x{0:X}", dataByte))));
annotated.Append(Environment.NewLine);
annotated.Append(Environment.NewLine);
}
}
Expand Down
37 changes: 28 additions & 9 deletions Arrowgene.Ddon.Database/Files/Database/Script/schema_sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,12 @@ CREATE TABLE IF NOT EXISTS `ddon_equip_item`

CREATE TABLE IF NOT EXISTS `ddon_equip_job_item`
(
`character_common_id` INTEGER NOT NULL,
`job` TINYINT NOT NULL,
`job_item_id` INT NOT NULL,
`equip_slot_no` TINYINT NOT NULL,
PRIMARY KEY (`character_common_id`, `job`, `equip_slot_no`),
`item_uid` TEXT NOT NULL,
`character_common_id` INTEGER NOT NULL,
`job` TINYINT NOT NULL,
`equip_slot` SMALLINT NOT NULL,
PRIMARY KEY (`character_common_id`, `job`, `equip_slot`),
CONSTRAINT `fk_equip_job_item_item_uid` FOREIGN KEY (`item_uid`) REFERENCES `ddon_item` (`uid`) ON DELETE CASCADE,
CONSTRAINT `fk_equip_job_item_character_common_id` FOREIGN KEY (`character_common_id`) REFERENCES `ddon_character_common` (`character_common_id`) ON DELETE CASCADE
);

Expand All @@ -312,15 +313,34 @@ CREATE TABLE IF NOT EXISTS `ddon_normal_skill_param`
CONSTRAINT `fk_normal_skill_param_character_common_id` FOREIGN KEY (`character_common_id`) REFERENCES `ddon_character_common` (`character_common_id`) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS `ddon_learned_custom_skill`
(
`character_common_id` INTEGER NOT NULL,
`job` TINYINT NOT NULL,
`skill_id` INT NOT NULL,
`skill_lv` TINYINT NOT NULL,
PRIMARY KEY (`character_common_id`, `job`, `skill_id`),
CONSTRAINT `fk_learned_custom_skill_character_common_id` FOREIGN KEY (`character_common_id`) REFERENCES `ddon_character_common` (`character_common_id`) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS `ddon_equipped_custom_skill`
(
`character_common_id` INTEGER NOT NULL,
`job` TINYINT NOT NULL,
`slot_no` TINYINT NOT NULL,
`skill_id` INT NOT NULL,
`skill_lv` TINYINT NOT NULL,
PRIMARY KEY (`character_common_id`, `job`, `slot_no`),
CONSTRAINT `fk_set_acquirement_param_character_common_id` FOREIGN KEY (`character_common_id`) REFERENCES `ddon_character_common` (`character_common_id`) ON DELETE CASCADE
CONSTRAINT `fk_equipped_custom_skill_character_common_id` FOREIGN KEY (`character_common_id`, `job`, `skill_id`) REFERENCES `ddon_learned_custom_skill` (`character_common_id`, `job`, `skill_id`) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS `ddon_learned_ability`
(
`character_common_id` INTEGER NOT NULL,
`job` TINYINT NOT NULL,
`ability_id` INT NOT NULL,
`ability_lv` TINYINT NOT NULL,
PRIMARY KEY (`character_common_id`, `job`, `ability_id`),
CONSTRAINT `fk_learned_ability_character_common_id` FOREIGN KEY (`character_common_id`) REFERENCES `ddon_character_common` (`character_common_id`) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS `ddon_equipped_ability`
Expand All @@ -330,9 +350,8 @@ CREATE TABLE IF NOT EXISTS `ddon_equipped_ability`
`job` TINYINT NOT NULL,
`slot_no` TINYINT NOT NULL,
`ability_id` INT NOT NULL,
`ability_lv` TINYINT NOT NULL,
PRIMARY KEY (`character_common_id`, `equipped_to_job`, `slot_no`),
CONSTRAINT `fk_set_acquirement_param_character_common_id` FOREIGN KEY (`character_common_id`) REFERENCES `ddon_character_common` (`character_common_id`) ON DELETE CASCADE
CONSTRAINT `fk_equipped_ability_character_common_id` FOREIGN KEY (`character_common_id`, `job`, `ability_id`) REFERENCES `ddon_learned_ability` (`character_common_id`, `job`, `ability_id`) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS `ddon_shortcut`
Expand Down
25 changes: 18 additions & 7 deletions Arrowgene.Ddon.Database/IDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public interface IDatabase
Pawn SelectPawn(uint pawnId);
List<Pawn> SelectPawnsByCharacterId(uint characterId);
bool DeletePawn(uint pawnId);
bool UpdatePawnBaseInfo(Pawn pawn);

// CharacterJobData
bool ReplaceCharacterJobData(uint commonId, CDataCharacterJobData replacedCharacterJobData);
Expand Down Expand Up @@ -70,20 +71,30 @@ public interface IDatabase

// Equip
bool InsertEquipItem(uint commonId, JobId job, EquipType equipType, byte equipSlot, string itemUId);
bool ReplaceEquipItem(uint commonId, JobId job, EquipType equipType, byte equipSlot, string itemUId);
bool UpdateEquipItem(uint commonId, JobId job, EquipType equipType, byte equipSlot, string itemUId);
bool DeleteEquipItem(uint commonId, JobId job, EquipType equipType, byte equipSlot, string itemUId);

// Job Items
bool InsertEquipJobItem(string itemUId, uint commonId, JobId job, ushort slotNo);
bool ReplaceEquipJobItem(string itemUId, uint commonId, JobId job, ushort slotNo);
bool DeleteEquipJobItem(uint commonId, JobId job, ushort slotNo);

// CustomSkills
bool InsertEquippedCustomSkill(uint characterId, CustomSkill skill);
bool ReplaceEquippedCustomSkill(uint characterId, CustomSkill skill);
bool UpdateEquippedCustomSkill(uint characterId, JobId oldJob, byte oldSlotNo, CustomSkill skill);
bool DeleteEquippedCustomSkill(uint characterId, JobId job, byte slotNo);
bool InsertLearnedCustomSkill(uint commonId, CustomSkill skill);
bool UpdateLearnedCustomSkill(uint commonId, CustomSkill updatedSkill);
bool InsertEquippedCustomSkill(uint commonId, byte slotNo, CustomSkill skill);
bool ReplaceEquippedCustomSkill(uint commonId, byte slotNo, CustomSkill skill);
bool UpdateEquippedCustomSkill(uint commonId, JobId oldJob, byte oldSlotNo, byte slotNo, CustomSkill skill);
bool DeleteEquippedCustomSkill(uint commonId, JobId job, byte slotNo);

// Abilities
bool InsertEquippedAbility(uint commonId, Ability skill);
bool ReplaceEquippedAbility(uint commonId, Ability skill);
bool InsertLearnedAbility(uint commonId, Ability ability);
bool UpdateLearnedAbility(uint commonId, Ability ability);
bool InsertEquippedAbility(uint commonId, JobId equipptedToJob, byte slotNo, Ability ability);
bool ReplaceEquippedAbility(uint commonId, JobId equipptedToJob, byte slotNo, Ability ability);
bool ReplaceEquippedAbilities(uint commonId, JobId equippedToJob, List<Ability> abilities);
bool UpdateEquippedAbility(uint commonId, JobId oldEquippedToJob, byte oldSlotNo, Ability skill);
bool UpdateEquippedAbility(uint commonId, JobId oldEquippedToJob, byte oldSlotNo, JobId equipptedToJob, byte slotNo, Ability ability);
bool DeleteEquippedAbility(uint commonId, JobId equippedToJob, byte slotNo);
bool DeleteEquippedAbilities(uint commonId, JobId equippedToJob);

Expand Down
2 changes: 1 addition & 1 deletion Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbCharacter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private void CreateItems(TCon conn, Character character)
}

// Create equipment items
foreach (KeyValuePair<JobId, Dictionary<EquipType, List<Item>>> jobEquipment in character.Equipment.getAllEquipment())
foreach (KeyValuePair<JobId, Dictionary<EquipType, List<Item>>> jobEquipment in character.Equipment.GetAllEquipment())
{
JobId job = jobEquipment.Key;
foreach (KeyValuePair<EquipType, List<Item>> equipment in jobEquipment.Value)
Expand Down
111 changes: 84 additions & 27 deletions Arrowgene.Ddon.Database/Sql/Core/DdonSqlDbCharacterCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,32 @@ private void QueryCharacterCommonData(TCon conn, CharacterCommon common)
if(reader2.Read())
{
Item item = ReadItem(reader2);
common.Equipment.setEquipItem(item, job, equipType, equipSlot);
common.Equipment.SetEquipItem(item, job, equipType, equipSlot);
}
});
}
});

// Job Items
ExecuteReader(conn, SqlSelectEquipJobItemByCharacter,
ExecuteReader(conn, SqlSelectEquipJobItemsByCharacter,
command => { AddParameter(command, "@character_common_id", common.CommonId); },
reader =>
{
while (reader.Read())
{
string UId = GetString(reader, "item_uid");
JobId job = (JobId) GetByte(reader, "job");
CDataEquipJobItem equipJobItem = ReadEquipJobItem(reader);
if(!common.CharacterEquipJobItemListDictionary.ContainsKey(job))
{
common.CharacterEquipJobItemListDictionary.Add(job, new List<CDataEquipJobItem>());
}
common.CharacterEquipJobItemListDictionary[job].Add(equipJobItem);
byte equipSlot = GetByte(reader, "equip_slot");
ExecuteReader(conn, SqlSelectItem,
command2 => { AddParameter(command2, "@uid", UId); },
reader2 =>
{
if(reader2.Read())
{
Item item = ReadItem(reader2);
common.Equipment.SetJobItem(item, job, equipSlot);
}
});
}
});

Expand All @@ -162,29 +168,58 @@ private void QueryCharacterCommonData(TCon conn, CharacterCommon common)
{
while (reader.Read())
{
common.NormalSkills.Add(ReadNormalSkillParam(reader));
common.LearnedNormalSkills.Add(ReadNormalSkillParam(reader));
}
});

// Custom Skills
ExecuteReader(conn, SqlSelectLearnedCustomSkills,
command => { AddParameter(command, "@character_common_id", common.CommonId); },
reader =>
{
while (reader.Read())
{
common.LearnedCustomSkills.Add(ReadLearnedCustomSkill(reader));
}
});
ExecuteReader(conn, SqlSelectEquippedCustomSkills,
command => { AddParameter(command, "@character_common_id", common.CommonId); },
reader =>
{
while (reader.Read())
{
common.CustomSkills.Add(ReadCustomSkill(reader));
uint skillId = GetUInt32(reader, "skill_id");
JobId job = (JobId) GetByte(reader, "job");
CustomSkill skill = common.LearnedCustomSkills.Where(x => x.Job == job && x.SkillId == skillId).Single();

byte slotNo = GetByte(reader, "slot_no");
common.EquippedCustomSkillsDictionary[job][slotNo-1] = skill;
}
});

// Abilities
ExecuteReader(conn, SqlSelectLearnedAbilities,
command => { AddParameter(command, "@character_common_id", common.CommonId); },
reader =>
{
while (reader.Read())
{
common.LearnedAbilities.Add(ReadLearnedAbility(reader));
}
});
ExecuteReader(conn, SqlSelectEquippedAbilities,
command => { AddParameter(command, "@character_common_id", common.CommonId); },
reader =>
{
while (reader.Read())
{
common.Abilities.Add(ReadAbility(reader));
uint abilityId = GetUInt32(reader, "ability_id");
JobId job = (JobId) GetByte(reader, "job");
JobId equippedToJob = (JobId) GetByte(reader, "equipped_to_job");
Ability aug = common.LearnedAbilities.Where(x => x.Job == job && x.AbilityId == abilityId).Single();

byte slotNo = GetByte(reader, "slot_no");
common.EquippedAbilitiesDictionary[equippedToJob][slotNo-1] = aug;
}
});
}
Expand All @@ -199,40 +234,62 @@ private void StoreCharacterCommonData(TCon conn, CharacterCommon common)
});
}

foreach(KeyValuePair<JobId, List<CDataEquipJobItem>> characterEquipJobItemListByJob in common.CharacterEquipJobItemListDictionary)
foreach(CDataNormalSkillParam normalSkillParam in common.LearnedNormalSkills)
{
foreach(CDataEquipJobItem equipJobItem in characterEquipJobItemListByJob.Value)
ExecuteNonQuery(conn, SqlReplaceNormalSkillParam, command =>
{
ExecuteNonQuery(conn, SqlReplaceEquipJobItem, command =>
{
AddParameter(command, common.CommonId, characterEquipJobItemListByJob.Key, equipJobItem);
});
}
AddParameter(command, common.CommonId, normalSkillParam);
});
}

foreach(CDataNormalSkillParam normalSkillParam in common.NormalSkills)
foreach(CustomSkill learnedSkills in common.LearnedCustomSkills)
{
ExecuteNonQuery(conn, SqlReplaceNormalSkillParam, command =>
ExecuteNonQuery(conn, SqlInsertLearnedCustomSkill, command =>
{
AddParameter(command, common.CommonId, normalSkillParam);
AddParameter(command, common.CommonId, learnedSkills);
});
}

foreach(CustomSkill skill in common.CustomSkills)
foreach(KeyValuePair<JobId, List<CustomSkill>> jobAndSkills in common.EquippedCustomSkillsDictionary)
{
ExecuteNonQuery(conn, SqlReplaceEquippedCustomSkill, command =>
for(int i=0; i<jobAndSkills.Value.Count; i++)
{
AddParameter(command, common.CommonId, skill);
});
CustomSkill? skill = jobAndSkills.Value[i];
byte slotNo = (byte)(i+1);
if(skill != null)
{
ExecuteNonQuery(conn, SqlReplaceEquippedCustomSkill, command =>
{
AddParameter(command, common.CommonId, slotNo, skill);
});
}
}
}

foreach(Ability ability in common.Abilities)
foreach(Ability ability in common.LearnedAbilities)
{
ExecuteNonQuery(conn, SqlReplaceEquippedAbility, command =>
ExecuteNonQuery(conn, SqlInsertLearnedAbility, command =>
{
AddParameter(command, common.CommonId, ability);
});
}

foreach(KeyValuePair<JobId, List<Ability>> jobAndAugs in common.EquippedAbilitiesDictionary)
{
JobId equippedToJob = jobAndAugs.Key;
for(int i=0; i<jobAndAugs.Value.Count; i++)
{
Ability? ability = jobAndAugs.Value[i];
byte slotNo = (byte)(i+1);
if(ability != null)
{
ExecuteNonQuery(conn, SqlReplaceEquippedAbility, command =>
{
AddParameter(command, common.CommonId, equippedToJob, slotNo, ability);
});
}
}
}
}

private void ReadAllCharacterCommonData(DbDataReader reader, CharacterCommon common)
Expand Down
Loading

0 comments on commit dd88306

Please sign in to comment.