Skip to content

Commit

Permalink
[Data] Attention! The format of the database has been changed:
Browse files Browse the repository at this point in the history
- Now requires the database compact.server.table.sqlite3 - contains server tables;
- Now the database required is compact.sqlite3 - the database from the current client;
- added the line "31 9 26 29880" to the "item_look_convert_required_items" table.
  • Loading branch information
NL0bP committed Apr 30, 2024
1 parent 56166af commit f02a1b4
Show file tree
Hide file tree
Showing 24 changed files with 188 additions and 161 deletions.
4 changes: 3 additions & 1 deletion AAEmu.Game/Core/Managers/AuctionManager.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;

using AAEmu.Commons.Utils;
using AAEmu.Commons.Utils.DB;
using AAEmu.Game.Core.Packets.G2C;
using AAEmu.Game.Models.Game;
using AAEmu.Game.Models.Game.Auction;
using AAEmu.Game.Models.Game.Auction.Templates;
using AAEmu.Game.Models.Game.Char;
using AAEmu.Game.Models.Game.Items;
using AAEmu.Game.Models.Game.Mails;

using MySql.Data.MySqlClient;

using NLog;

namespace AAEmu.Game.Core.Managers;
Expand Down
79 changes: 43 additions & 36 deletions AAEmu.Game/Core/Managers/ItemManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,8 @@ public List<Item> CreateLootDropItems(uint npcId, BaseUnit killer)
if (lootPack == null)
continue;
items = lootPack.GenerateNpcPackItems(ref baseId, lootDropRate, lootGoldRate);
if (_lootDropItems.ContainsKey(npcId))
if (!_lootDropItems.TryAdd(npcId, items))
_lootDropItems[npcId].AddRange(items);
else
_lootDropItems.Add(npcId, items);
}

if (!_lootDropItems.TryGetValue(npcId, out items))
Expand Down Expand Up @@ -623,6 +621,8 @@ public void Load()
LastTimerCheck = DateTime.UtcNow;

SkillManager.Instance.OnSkillsLoaded += OnSkillsLoaded;

using (var connection2 = SQLite.CreateConnection("Data", "compact.server.table.sqlite3"))
using (var connection = SQLite.CreateConnection())
{
Logger.Info("Loading item templates ...");
Expand Down Expand Up @@ -664,8 +664,7 @@ public void Load()
template.Id = reader.GetUInt32("item_look_convert_id");
template.RequiredItemId = reader.GetUInt32("item_id");
template.RequiredItemCount = reader.GetInt32("item_count");
if (!_itemLookConverts.ContainsKey(template.Id))
_itemLookConverts.Add(template.Id, template);
_itemLookConverts.TryAdd(template.Id, template);
}
}
}
Expand All @@ -681,8 +680,7 @@ public void Load()
{
var itemLookConvertId = reader.GetUInt32("item_look_convert_id");
var holdableId = reader.GetUInt32("holdable_id");
if (!_holdableItemLookConverts.ContainsKey(holdableId))
_holdableItemLookConverts.Add(holdableId, itemLookConvertId);
_holdableItemLookConverts.TryAdd(holdableId, itemLookConvertId);
}
}
}
Expand All @@ -698,8 +696,7 @@ public void Load()
{
var itemLookConvertId = reader.GetUInt32("item_look_convert_id");
var wearableId = reader.GetUInt32("wearable_slot_id");
if (!_wearableItemLookConverts.ContainsKey(wearableId))
_wearableItemLookConverts.Add(wearableId, itemLookConvertId);
_wearableItemLookConverts.TryAdd(wearableId, itemLookConvertId);
}
}
}
Expand Down Expand Up @@ -1171,8 +1168,7 @@ public void Load()
template.LivingPointPrice = reader.GetInt32("living_point_price");
template.CharGender = reader.GetByte("char_gender_id");

if (!_templates.ContainsKey(template.Id))
_templates.Add(template.Id, template);
_templates.TryAdd(template.Id, template);
}
}
}
Expand All @@ -1190,8 +1186,7 @@ public void Load()
//template.Id = reader.GetUInt32("id"); // there is no such field in the database for version 3.0.3.0
template.SlotTypeId = reader.GetUInt32("slot_type_id");
template.Cost = reader.GetInt32("cost");
if (!_enchantingCosts.ContainsKey(template.SlotTypeId))
_enchantingCosts.Add(template.SlotTypeId, template);
_enchantingCosts.TryAdd(template.SlotTypeId, template);
}
}
}
Expand Down Expand Up @@ -1220,8 +1215,7 @@ public void Load()
template.AddDowngradeMul = reader.GetInt32("add_downgrade_mul");
template.AddGreatSuccessGrade = reader.GetInt32("add_great_success_grade");

if (!_enchantingSupports.ContainsKey(template.ItemId))
_enchantingSupports.Add(template.ItemId, template);
_enchantingSupports.TryAdd(template.ItemId, template);
}
}
}
Expand All @@ -1238,8 +1232,7 @@ public void Load()
var numSockets = reader.GetUInt32("id"); // num_sockets
var chance = reader.GetUInt32("cost_ratio"); // success_ratio

if (!_socketChance.ContainsKey(numSockets))
_socketChance.Add(numSockets, chance);
_socketChance.TryAdd(numSockets, chance);
}
}
}
Expand All @@ -1259,8 +1252,7 @@ public void Load()
template.ScaleMin = reader.GetInt32("scale_min");
template.ScaleMax = reader.GetInt32("scale_max");

if (!_itemCapScales.ContainsKey(template.SkillId))
_itemCapScales.Add(template.SkillId, template);
_itemCapScales.TryAdd(template.SkillId, template);
}
}
}
Expand Down Expand Up @@ -1358,7 +1350,7 @@ public void Load()
}
}

using (var command = connection.CreateCommand())
using (var command = connection2.CreateCommand())
{
command.CommandText = "SELECT * FROM loot_pack_dropping_npcs";
command.Prepare();
Expand Down Expand Up @@ -1473,13 +1465,11 @@ public void Load()
{
while (reader.Read())
{
var armorGradeBuff = new ArmorGradeBuff()
{
Id = reader.GetByte("id"),
ArmorType = (ArmorType)reader.GetUInt32("armor_type_id"),
ItemGrade = (ItemGrade)reader.GetUInt32("item_grade_id"),
BuffId = reader.GetUInt32("buff_id")
};
var armorGradeBuff = new ArmorGradeBuff();
armorGradeBuff.Id = reader.GetByte("id");
//armorGradeBuff.ArmorType = (ArmorType)reader.GetUInt32("armor_type_id"); // there is no such field in the database for version 3.0.3.0
//armorGradeBuff.ItemGrade = (ItemGrade)reader.GetUInt32("item_grade_id"); // there is no such field in the database for version 3.0.3.0
armorGradeBuff.BuffId = reader.GetUInt32("buff_id");

if (!_armorGradeBuffs.ContainsKey(armorGradeBuff.ArmorType))
_armorGradeBuffs.Add(armorGradeBuff.ArmorType, new Dictionary<ItemGrade, ArmorGradeBuff>());
Expand Down Expand Up @@ -1833,6 +1823,11 @@ public void LoadUserItems()
item = new Item();
}

if (item == null)
{
continue;
}

item.Id = itemId;
item.OwnerId = reader.GetUInt64("owner");
item.TemplateId = itemTemplateId;
Expand Down Expand Up @@ -1924,11 +1919,15 @@ public void LoadUserItems()
private ulong GetNewId()
{
var itemId = ItemIdManager.Instance.GetNextId();
lock (_removedItems)
if (_removedItems != null)
{
if (itemId != 0 && _removedItems.Contains(itemId))
_removedItems.Remove(itemId);
lock (_removedItems)
{
if (itemId != 0 && _removedItems.Contains(itemId))
_removedItems.Remove(itemId);
}
}

return itemId;
}

Expand All @@ -1938,16 +1937,24 @@ private ulong GetNewId()
/// <param name="itemId">itemId of the item to be freed up</param>
public void ReleaseId(ulong itemId)
{
lock (_removedItems)
if (_removedItems != null)
{
if (itemId != 0 && !_removedItems.Contains(itemId))
_removedItems.Add(itemId);
lock (_removedItems)
{
if (itemId != 0 && !_removedItems.Contains(itemId))
_removedItems.Add(itemId);
}
}
lock (_allItems)

if (_allItems != null)
{
if (_allItems.ContainsKey(itemId))
_allItems.Remove(itemId);
lock (_allItems)
{
if (_allItems.ContainsKey(itemId))
_allItems.Remove(itemId);
}
}

// This should be the only place where ItemId ReleaseId should be called directly
ItemIdManager.Instance.ReleaseId((uint)itemId);
}
Expand Down
11 changes: 6 additions & 5 deletions AAEmu.Game/Core/Managers/SkillManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ public void Load()
_skillReagents = new Dictionary<uint, SkillReagent>();
_skillProducts = new Dictionary<uint, SkillProduct>();

using (var connection2 = SQLite.CreateConnection("Data", "compact.server.table.sqlite3"))
using (var connection = SQLite.CreateConnection())
{
Logger.Info("Loading skills...");
Expand Down Expand Up @@ -867,7 +868,7 @@ public void Load()
}
}

using (var command = connection.CreateCommand())
using (var command = connection2.CreateCommand())
{
command.CommandText = "SELECT * FROM cinema_effects";
command.Prepare();
Expand Down Expand Up @@ -1198,7 +1199,7 @@ public void Load()
}
}

using (var command = connection.CreateCommand())
using (var command = connection2.CreateCommand())
{
command.CommandText = "SELECT * FROM npc_control_effects";
command.Prepare();
Expand Down Expand Up @@ -1405,7 +1406,7 @@ public void Load()
}
}

using (var command = connection.CreateCommand())
using (var command = connection2.CreateCommand())
{
command.CommandText = "SELECT * FROM npc_spawner_spawn_effects";
command.Prepare();
Expand All @@ -1425,7 +1426,7 @@ public void Load()
}
}

using (var command = connection.CreateCommand())
using (var command = connection2.CreateCommand())
{
command.CommandText = "SELECT * FROM npc_spawner_despawn_effects";
command.Prepare();
Expand Down Expand Up @@ -1681,7 +1682,7 @@ public void Load()
}
}

using (var command = connection.CreateCommand())
using (var command = connection2.CreateCommand())
{
command.CommandText = "SELECT * FROM combat_buffs";
command.Prepare();
Expand Down
3 changes: 2 additions & 1 deletion AAEmu.Game/Core/Managers/SlaveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ public void Load()

#region SQLLite

using (var connection2 = SQLite.CreateConnection("Data", "compact.server.table.sqlite3"))
using (var connection = SQLite.CreateConnection())
{
using (var command = connection.CreateCommand())
Expand Down Expand Up @@ -1074,7 +1075,7 @@ public void Load()
}
}

using (var command = connection.CreateCommand())
using (var command = connection2.CreateCommand())
{
command.CommandText = "SELECT * FROM repairable_slaves";
command.Prepare();
Expand Down
8 changes: 5 additions & 3 deletions AAEmu.Game/Core/Managers/UnitManagers/DoodadManager.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

using AAEmu.Commons.Utils;
using AAEmu.Game.Core.Managers.Id;
using AAEmu.Game.Core.Managers.World;
using AAEmu.Game.Core.Packets.G2C;
using AAEmu.Game.Models.Game;
using AAEmu.Game.Models.Game.Char;
using AAEmu.Game.Models.Game.DoodadObj;
using AAEmu.Game.Models.Game.DoodadObj.Details;
Expand All @@ -22,6 +22,7 @@
using AAEmu.Game.Models.Game.World;
using AAEmu.Game.Models.Game.World.Zones;
using AAEmu.Game.Utils.DB;

using NLog;

// ReSharper disable ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
Expand Down Expand Up @@ -87,6 +88,7 @@ public void Load()

_doodadFuncConsumeChangerItem = new Dictionary<uint, DoodadFuncConsumeChangerItem>();

using (var connection2 = SQLite.CreateConnection("Data", "compact.server.table.sqlite3"))
using (var connection = SQLite.CreateConnection())
{
#region doodad_funcs
Expand Down Expand Up @@ -2143,7 +2145,7 @@ public void Load()
}

// doodad_func_respawns
using (var command = connection.CreateCommand())
using (var command = connection2.CreateCommand())
{
command.CommandText = "SELECT * FROM doodad_func_respawns";
command.Prepare();
Expand Down
8 changes: 3 additions & 5 deletions AAEmu.Game/Core/Managers/UnitManagers/NpcManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public void Load()
template.NpcTemplateId = (NpcTemplateType)reader.GetByte("npc_template_id");
template.ModelId = reader.GetUInt32("model_id");
template.FactionId = reader.GetUInt32("faction_id");
template.HeirLevel = reader.GetUInt32("heir_level");
//template.HeirLevel = reader.GetUInt32("heir_level"); // there is no such field in the database for version 3.0.3.0
template.SkillTrainer = reader.GetBoolean("skill_trainer", true);
template.AiFileId = reader.GetInt32("ai_file_id");
template.Merchant = reader.GetBoolean("merchant", true);
Expand Down Expand Up @@ -565,8 +565,7 @@ public void Load()
template.HonorPoint = reader.GetInt32("honor_point");
template.Trader = reader.GetBoolean("trader", true);
template.AggroLinkSpecialGuard = reader.GetBoolean("aggro_link_special_guard", true);
template.AggroLinkSpecialIgnoreNpcAttacker =
reader.GetBoolean("aggro_link_special_ignore_npc_attacker", true);
template.AggroLinkSpecialIgnoreNpcAttacker = reader.GetBoolean("aggro_link_special_ignore_npc_attacker", true);
template.AbsoluteReturnDistance = reader.GetFloat("absolute_return_distance");
template.Repairman = reader.GetBoolean("repairman", true);
template.ActivateAiAlways = reader.GetBoolean("activate_ai_always", true);
Expand All @@ -582,8 +581,7 @@ public void Load()
template.BaseSkillDelay = reader.GetFloat("base_skill_delay");
template.NpcInteractionSetId = reader.GetInt32("npc_interaction_set_id", 0);
template.UseAbuserList = reader.GetBoolean("use_abuser_list", true);
template.ReturnWhenEnterHousingArea =
reader.GetBoolean("return_when_enter_housing_area", true);
template.ReturnWhenEnterHousingArea = reader.GetBoolean("return_when_enter_housing_area", true);
template.LookConverter = reader.GetBoolean("look_converter", true);
template.UseDDCMSMountSkill = reader.GetBoolean("use_ddcms_mount_skill", true);
template.CrowdEffect = reader.GetBoolean("crowd_effect", true);
Expand Down
3 changes: 2 additions & 1 deletion AAEmu.Game/Core/Managers/World/WorldManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ public void Load()

#region LoadServerDB

using (var connection2 = SQLite.CreateConnection("Data", "compact.server.table.sqlite3"))
using (var connection = SQLite.CreateConnection())
{
using (var command = connection.CreateCommand())
Expand Down Expand Up @@ -326,7 +327,7 @@ public void Load()
}
*/

using (var command = connection.CreateCommand())
using (var command = connection2.CreateCommand())
{
command.CommandText = "SELECT * FROM wi_group_wis";
command.Prepare();
Expand Down
Loading

0 comments on commit f02a1b4

Please sign in to comment.