Skip to content

Commit

Permalink
SQL: Updated hotfix SQL output to the new system
Browse files Browse the repository at this point in the history
  • Loading branch information
Carbenium committed Dec 27, 2015
1 parent 6b9d581 commit c627c55
Show file tree
Hide file tree
Showing 58 changed files with 1,272 additions and 1,327 deletions.
3 changes: 3 additions & 0 deletions WowPacketParser/Enums/DB2Hash.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Diagnostics.CodeAnalysis;

namespace WowPacketParser.Enums
{
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum DB2Hash : uint
{
Achievement = 0xD2EE2CA7, // 6.2.2.20444
Expand Down
473 changes: 170 additions & 303 deletions WowPacketParser/SQL/Builders/DB2.cs

Large diffs are not rendered by default.

57 changes: 5 additions & 52 deletions WowPacketParser/SQL/Builders/Locales.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,15 @@ public static class Locales
[BuilderMethod]
public static string BroadcastTextLocale()
{
/*if (Storage.BroadcastTextLocales.IsEmpty())
return String.Empty;
if (Storage.BroadcastTextLocales.IsEmpty())
return string.Empty;

if (!Settings.HotfixSQLOutputFlag.HasAnyFlagBit(HotfixSQLOutput.broadcast_text_locale))
return String.Empty;
const string tableName = "broadcast_text_locale";
var rowsIns = new List<SQLInsertRow>();
var rowsUpd = new List<SQLUpdateRow>();
foreach (var broadcastTextLocale in Settings.SQLOrderByKey ? Storage.BroadcastTextLocales.OrderBy(blub => blub.Key).ToList() : Storage.BroadcastTextLocales.ToList())
{
if (SQLDatabase.BroadcastTextLocaleStores != null && SQLDatabase.BroadcastTextLocaleStores.ContainsKey(Tuple.Create(broadcastTextLocale.Key.Item1, broadcastTextLocale.Key.Item2)))
{
var row = new SQLUpdateRow();
var broadcastTextLocaleDB = SQLDatabase.BroadcastTextLocaleStores[Tuple.Create(broadcastTextLocale.Key.Item1, broadcastTextLocale.Key.Item2)];
if (!Utilities.EqualValues(broadcastTextLocaleDB.MaleText_lang, broadcastTextLocale.Value.Item1.MaleText_lang))
row.AddValue("MaleText_lang", broadcastTextLocale.Value.Item1.MaleText_lang);
if (!Utilities.EqualValues(broadcastTextLocaleDB.FemaleText_lang, broadcastTextLocale.Value.Item1.FemaleText_lang))
row.AddValue("FemaleText_lang", broadcastTextLocale.Value.Item1.FemaleText_lang);
if (!Utilities.EqualValues(broadcastTextLocaleDB.VerifiedBuild, broadcastTextLocale.Value.Item1.VerifiedBuild))
row.AddValue("VerifiedBuild", broadcastTextLocale.Value.Item1.VerifiedBuild);
row.AddWhere("ID", broadcastTextLocale.Key.Item1);
row.AddWhere("locale", broadcastTextLocale.Key.Item2);
row.Table = tableName;
rowsUpd.Add(row);
}
else // insert new
{
var row = new SQLInsertRow();
return string.Empty;

row.AddValue("ID", broadcastTextLocale.Key.Item1);
row.AddValue("locale", broadcastTextLocale.Key.Item2);
var templatesDb = SQLDatabase.Get(Storage.BroadcastTextLocales, Settings.HotfixesDatabase);

row.AddValue("MaleText_lang", broadcastTextLocale.Value.Item1.MaleText_lang);
row.AddValue("FemaleText_lang", broadcastTextLocale.Value.Item1.FemaleText_lang);
row.AddValue("VerifiedBuild", broadcastTextLocale.Value.Item1.VerifiedBuild);
rowsIns.Add(row);
}
}
var result = new SQLInsert(tableName, rowsIns, deleteDuplicates: false, primaryKeyNumber: 2).Build() +
new SQLUpdate(rowsUpd).Build();
return "SET NAMES 'utf8';" + Environment.NewLine + result + Environment.NewLine + "SET NAMES 'latin1';";
*/
return string.Empty;
return "SET NAMES 'utf8';" + Environment.NewLine + SQLUtil.Compare(Storage.BroadcastTextLocales, templatesDb, StoreNameType.None) + Environment.NewLine + "SET NAMES 'latin1';";
}

[BuilderMethod]
Expand Down
77 changes: 0 additions & 77 deletions WowPacketParser/SQL/SQLDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ public static class SQLDatabase
public static readonly ICollection<Tuple<uint, BroadcastText>> BroadcastTextStores =
new List<Tuple<uint, BroadcastText>>();

/// <summary>
/// Represents a dictionary of <see cref="CreatureDifficulty"/> accessed by their ids.
/// </summary>
public static readonly Dictionary<uint, CreatureDifficulty> CreatureDifficultyStores =
new Dictionary<uint, CreatureDifficulty>();

// Locale
/// <summary>
/// Represents a dictionary of <see cref="BroadcastTextLocale"/> accessed by a tuple of the broadcast text id and the locale string.
/// </summary>
public static readonly Dictionary<Tuple<uint, string>, BroadcastTextLocale> BroadcastTextLocaleStores =
new Dictionary<Tuple<uint, string>, BroadcastTextLocale>();

/// <summary>
/// Represents a dictionary of <see cref="LocalesQuest"/> accessed by a tuple of the quest id and the locale string.
/// </summary>
Expand Down Expand Up @@ -104,9 +91,7 @@ public static void LoadSQL()
var startTime = DateTime.Now;

LoadBroadcastText();
LoadCreatureDifficulty();
// Locale
LoadBroadcastTextLocale();
LoadQuestTemplateLocale();
LoadQuestObjectivesLocale();
// MapDifficulty
Expand Down Expand Up @@ -157,40 +142,6 @@ private static void LoadBroadcastText()
}
}

/// <summary>
/// Loads the creature difficulties form the database.
/// </summary>
private static void LoadCreatureDifficulty()
{
string query =
$"SELECT ID, CreatureID, FactionID, Expansion, MinLevel, MaxLevel, Flags1, Flags2, Flags3, Flags4, Flags5 FROM {Settings.HotfixesDatabase}.creature_difficulty;";
using (var reader = SQLConnector.ExecuteQuery(query))
{
if (reader == null)
return;

while (reader.Read())
{
var creatureDifficulty = new CreatureDifficulty();

uint id = (uint)reader.GetValue(0);

creatureDifficulty.CreatureID = (uint)reader.GetValue(1);
creatureDifficulty.FactionID = (uint)reader.GetValue(2);

creatureDifficulty.Expansion = (int)reader.GetValue(3);
creatureDifficulty.MinLevel = (int)reader.GetValue(4);
creatureDifficulty.MaxLevel = (int)reader.GetValue(5);

creatureDifficulty.Flags = new uint[5];
for (int i = 0; i < 5; i++)
creatureDifficulty.Flags[i] = (uint)reader.GetValue(i + 6);

CreatureDifficultyStores.Add(id, creatureDifficulty);
}
}
}

/// <summary>
/// Loads the localized quest template strings from the database.
/// </summary>
Expand Down Expand Up @@ -256,34 +207,6 @@ private static void LoadQuestObjectivesLocale()
}
}

/// <summary>
/// Loads the localized broadcast texts from the database.
/// </summary>
private static void LoadBroadcastTextLocale()
{
string query =
$"SELECT Id, locale, MaleText_lang, FemaleText_lang, VerifiedBuild FROM {Settings.HotfixesDatabase}.broadcast_text_locale;";
using (var reader = SQLConnector.ExecuteQuery(query))
{
if (reader == null)
return;

while (reader.Read())
{
var broadcastTextLocale = new BroadcastTextLocale();

var id = (uint)reader.GetValue(0);
var locale = (string)reader.GetValue(1);

broadcastTextLocale.MaleText_lang = (string)reader.GetValue(2);
broadcastTextLocale.FemaleText_lang = (string)reader.GetValue(3);
broadcastTextLocale.VerifiedBuild = Convert.ToInt16(reader.GetValue(4));

BroadcastTextLocaleStores.Add(Tuple.Create(id, locale), broadcastTextLocale);
}
}
}

/// <summary>
/// Loads the map difficulties from the database.
/// </summary>
Expand Down
31 changes: 17 additions & 14 deletions WowPacketParser/Store/Objects/AreaPOI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,34 @@
namespace WowPacketParser.Store.Objects
{
[DBTableName("area_poi")]
public sealed class AreaPOI
public sealed class AreaPOI : IDataModel
{
[DBFieldName("ID", true)]
public uint? ID;

[DBFieldName("Flags")]
public uint Flags;
public uint? Flags;

[DBFieldName("Importance")]
public uint Importance;
public uint? Importance;

[DBFieldName("FactionID")]
public uint FactionID;
public uint? FactionID;

[DBFieldName("MapID")]
public uint MapID;
public uint? MapID;

[DBFieldName("AreaID")]
public uint AreaID;
public uint? AreaID;

[DBFieldName("MapID")]
public uint Icon;
public uint? Icon;

[DBFieldName("PositionX")]
public float PositionX;
public float? PositionX;

[DBFieldName("PositionY")]
public float PositionY;
public float? PositionY;

[DBFieldName("Name")]
public string Name;
Expand All @@ -37,18 +40,18 @@ public sealed class AreaPOI
public string Description;

[DBFieldName("WorldStateID")]
public uint WorldStateID;
public uint? WorldStateID;

[DBFieldName("PlayerConditionID")]
public uint PlayerConditionID;
public uint? PlayerConditionID;

[DBFieldName("WorldMapLink")]
public uint WorldMapLink;
public uint? WorldMapLink;

[DBFieldName("PortLocID")]
public uint PortLocID;
public uint? PortLocID;

[DBFieldName("VerifiedBuild")]
public int VerifiedBuild = ClientVersion.BuildInt;
public int? VerifiedBuild = ClientVersion.BuildInt;
}
}
13 changes: 8 additions & 5 deletions WowPacketParser/Store/Objects/AreaPOIState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@
namespace WowPacketParser.Store.Objects
{
[DBTableName("area_poi_state")]
public sealed class AreaPOIState
public sealed class AreaPOIState : IDataModel
{
[DBFieldName("ID", true)]
public uint? ID;

[DBFieldName("AreaPOIID")]
public uint AreaPOIID;
public uint? AreaPoiID;

[DBFieldName("State")]
public uint State;
public uint? State;

[DBFieldName("Icon")]
public uint Icon;
public uint? Icon;

[DBFieldName("Description")]
public string Description;

[DBFieldName("VerifiedBuild")]
public int VerifiedBuild = ClientVersion.BuildInt;
public int? VerifiedBuild = ClientVersion.BuildInt;
}
}
19 changes: 11 additions & 8 deletions WowPacketParser/Store/Objects/BattlePetSpecies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,28 @@
namespace WowPacketParser.Store.Objects
{
[DBTableName("battle_pet_species")]
public sealed class BattlePetSpecies
public sealed class BattlePetSpecies : IDataModel
{
[DBFieldName("ID", true)]
public uint? ID;

[DBFieldName("CreatureID")]
public uint CreatureID;
public uint? CreatureID;

[DBFieldName("IconFileID")]
public uint IconFileID;
public uint? IconFileID;

[DBFieldName("SummonSpellID")]
public uint SummonSpellID;
public uint? SummonSpellID;

[DBFieldName("PetType")]
public int PetType;
public int? PetType;

[DBFieldName("Source")]
public uint Source;
public uint? Source;

[DBFieldName("Flags")]
public uint Flags;
public uint? Flags;

[DBFieldName("SourceText")]
public string SourceText;
Expand All @@ -31,6 +34,6 @@ public sealed class BattlePetSpecies
public string Description;

[DBFieldName("VerifiedBuild")]
public int VerifiedBuild = ClientVersion.BuildInt;
public int? VerifiedBuild = ClientVersion.BuildInt;
}
}
26 changes: 18 additions & 8 deletions WowPacketParser/Store/Objects/BroadcastText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,36 @@
namespace WowPacketParser.Store.Objects
{
[DBTableName("broadcast_text")]
public class BroadcastText
public sealed class BroadcastText : IDataModel
{
[DBFieldName("ID", true)]
public uint? ID;

[DBFieldName("Language")]
public int Language;
public int? Language;

[DBFieldName("MaleText", LocaleConstant.enUS)]
public string MaleText;

[DBFieldName("FemaleText", LocaleConstant.enUS)]
public string FemaleText;

[DBFieldName("EmoteID", 3)]
public uint[] EmoteID = new uint[3];
public uint?[] EmoteID;

[DBFieldName("EmoteDelay", 3)]
public uint[] EmoteDelay = new uint[3];
public uint?[] EmoteDelay;

[DBFieldName("SoundId")]
public uint SoundId;
public uint? SoundId;

[DBFieldName("UnkEmoteID")]
public uint UnkEmoteId;
public uint? UnkEmoteId;

[DBFieldName("Type")]
public uint Type;
public uint? Type;

[DBFieldName("VerifiedBuild")]
public int VerifiedBuild = ClientVersion.BuildInt;
public int? VerifiedBuild = ClientVersion.BuildInt;
}
}
14 changes: 10 additions & 4 deletions WowPacketParser/Store/Objects/BroadcastTextLocale.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@
namespace WowPacketParser.Store.Objects
{
[DBTableName("broadcast_text_locale")]
public sealed class BroadcastTextLocale
public sealed class BroadcastTextLocale : IDataModel
{
[DBFieldName("ID", true)]
public uint? ID;

[DBFieldName("locale", true)]
public string Locale;

[DBFieldName("MaleText_lang")]
public string MaleText_lang;
public string MaleTextLang;

[DBFieldName("FemaleText_lang")]
public string FemaleText_lang;
public string FemaleTextLang;

[DBFieldName("VerifiedBuild")]
public int VerifiedBuild = ClientVersion.BuildInt;
public int? VerifiedBuild = ClientVersion.BuildInt;
}
}
Loading

0 comments on commit c627c55

Please sign in to comment.