Skip to content

Commit

Permalink
Remove StringBuilder from SpellInfo
Browse files Browse the repository at this point in the history
Rename strings Dictionary
Remove unused class LinqQueryBuilder
Add new extension metod "Append"

Signed-off-by: Konctantin <gawrilyako@gmail.com>
  • Loading branch information
Konctantin committed Jun 18, 2010
1 parent 2684788 commit 8156df4
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 85 deletions.
26 changes: 13 additions & 13 deletions SpellWork/DBC/DBC.cs
Expand Up @@ -11,20 +11,20 @@ public static class DBC
public const int MAX_EFFECT_INDEX = 3;
public const int SPELL_ENTRY_FOR_DETECT_LOCALE = 1;

public static Dictionary<uint, SpellEntry> Spell;
public static Dictionary<uint, SpellRadiusEntry> SpellRadius;
public static Dictionary<uint, SpellCastTimesEntry> SpellCastTimes;
public static Dictionary<uint, SpellRangeEntry> SpellRange;
public static Dictionary<uint, SpellDurationEntry> SpellDuration;
public static Dictionary<uint, SkillLineAbilityEntry> SkillLineAbility;
public static Dictionary<uint, SkillLineEntry> SkillLine;
public static Dictionary<uint, ScreenEffectEntry> ScreenEffect;
public static Dictionary<uint, OverrideSpellDataEntry> OverrideSpellData;
public static Dictionary<uint, SpellEntry> Spell;
public static Dictionary<uint, SpellRadiusEntry> SpellRadius;
public static Dictionary<uint, SpellCastTimesEntry> SpellCastTimes;
public static Dictionary<uint, SpellRangeEntry> SpellRange;
public static Dictionary<uint, SpellDurationEntry> SpellDuration;
public static Dictionary<uint, SkillLineAbilityEntry> SkillLineAbility;
public static Dictionary<uint, SkillLineEntry> SkillLine;
public static Dictionary<uint, ScreenEffectEntry> ScreenEffect;
public static Dictionary<uint, OverrideSpellDataEntry> OverrideSpellData;

public static Dictionary<uint, string> _SpellStrings = new Dictionary<uint, string>();
public static Dictionary<uint, string> _SkillLineStrings = new Dictionary<uint, string>();
public static Dictionary<uint, string> _SpellRangeStrings = new Dictionary<uint, string>();
public static Dictionary<uint, string> _ScreenEffectStrings = new Dictionary<uint, string>();
public static Dictionary<uint, string> SpellStrings = new Dictionary<uint, string>();
public static Dictionary<uint, string> SkillLineStrings = new Dictionary<uint, string>();
public static Dictionary<uint, string> SpellRangeStrings = new Dictionary<uint, string>();
public static Dictionary<uint, string> ScreenEffectStrings = new Dictionary<uint, string>();

// DB
public static List<Item> ItemTemplate = new List<Item>();
Expand Down
22 changes: 11 additions & 11 deletions SpellWork/DBC/Structure.cs
Expand Up @@ -179,15 +179,15 @@ public struct SpellEntry
/// </summary>
public string SpellName
{
get { return DBC._SpellStrings.GetValue(_SpellName[(uint)DBC.Locale]); }
get { return DBC.SpellStrings.GetValue(_SpellName[(uint)DBC.Locale]); }
}

/// <summary>
/// Return current Spell Rank
/// </summary>
public string Rank
{
get { return _Rank[(uint)DBC.Locale] != 0 ? DBC._SpellStrings[_Rank[(uint)DBC.Locale]] : ""; }
get { return _Rank[(uint)DBC.Locale] != 0 ? DBC.SpellStrings[_Rank[(uint)DBC.Locale]] : ""; }
}

public string SpellNameRank
Expand All @@ -200,20 +200,20 @@ public string SpellNameRank
/// </summary>
public string Description
{
get { return DBC._SpellStrings.GetValue(_Description[(uint)DBC.Locale]); }
get { return DBC.SpellStrings.GetValue(_Description[(uint)DBC.Locale]); }
}

/// <summary>
/// Return current Spell ToolTip
/// </summary>
public string ToolTip
{
get { return DBC._SpellStrings.GetValue(_ToolTip[(uint)DBC.Locale]); }
get { return DBC.SpellStrings.GetValue(_ToolTip[(uint)DBC.Locale]); }
}

public string GetName(byte loc)
{
return DBC._SpellStrings.GetValue(_SpellName[loc]);
return DBC.SpellStrings.GetValue(_SpellName[loc]);
}

public string ProcInfo
Expand Down Expand Up @@ -312,17 +312,17 @@ public struct SkillLineEntry

public string Name
{
get { return DBC._SkillLineStrings.GetValue(_Name[(uint)DBC.Locale]); }
get { return DBC.SkillLineStrings.GetValue(_Name[(uint)DBC.Locale]); }
}

public string Description
{
get { return DBC._SkillLineStrings.GetValue(_Description[(uint)DBC.Locale]); }
get { return DBC.SkillLineStrings.GetValue(_Description[(uint)DBC.Locale]); }
}

public string AlternateVerb
{
get { return DBC._SkillLineStrings.GetValue(_AlternateVerb[(uint)DBC.Locale]); }
get { return DBC.SkillLineStrings.GetValue(_AlternateVerb[(uint)DBC.Locale]); }
}
};

Expand Down Expand Up @@ -369,12 +369,12 @@ public struct SpellRangeEntry

public string Description1
{
get { return DBC._SpellRangeStrings.GetValue(_Desc1[(uint)DBC.Locale]); }
get { return DBC.SpellRangeStrings.GetValue(_Desc1[(uint)DBC.Locale]); }
}

public string Description2
{
get { return DBC._SpellRangeStrings.GetValue(_Desc2[(uint)DBC.Locale]); }
get { return DBC.SpellRangeStrings.GetValue(_Desc2[(uint)DBC.Locale]); }
}
};

Expand Down Expand Up @@ -413,7 +413,7 @@ public struct ScreenEffectEntry

public string Name
{
get { return DBC._ScreenEffectStrings.GetValue(_Name); }
get { return DBC.ScreenEffectStrings.GetValue(_Name); }
}
};

Expand Down
33 changes: 0 additions & 33 deletions SpellWork/DataBase/LinqQueryBuilder.cs

This file was deleted.

1 change: 0 additions & 1 deletion SpellWork/Extensions/LinqExtensions.cs
Expand Up @@ -43,7 +43,6 @@ public static bool CreateFilter<T>(this T T_entry, object field, object val)
return false;
}
case @"Single[]":
case @"Float[]":
{
foreach (float el in (float[])basicValue)
{
Expand Down
5 changes: 5 additions & 0 deletions SpellWork/Extensions/RichTextBoxExtensions.cs
Expand Up @@ -29,6 +29,11 @@ public static void AppendLine(this RichTextBox textbox, string text)
textbox.AppendText(text + Environment.NewLine);
}

public static void Append(this RichTextBox textbox, object text)
{
textbox.AppendText(text.ToString());
}

public static void AppendFormatLineIfNotNull(this RichTextBox builder, string format, uint arg)
{
if (arg != 0)
Expand Down
8 changes: 4 additions & 4 deletions SpellWork/Loader.cs
Expand Up @@ -10,7 +10,7 @@ class Loader
{
public Loader(bool thread)
{
DBC.Spell = DBCReader.ReadDBC<SpellEntry>(DBC._SpellStrings);
DBC.Spell = DBCReader.ReadDBC<SpellEntry>(DBC.SpellStrings);

if (thread)
new Thread(RunOther).Start();
Expand All @@ -22,9 +22,9 @@ public Loader(bool thread)

private void RunOther()
{
DBC.SkillLine = DBCReader.ReadDBC<SkillLineEntry>(DBC._SkillLineStrings);
DBC.SpellRange = DBCReader.ReadDBC<SpellRangeEntry>(DBC._SpellRangeStrings);
DBC.ScreenEffect = DBCReader.ReadDBC<ScreenEffectEntry>(DBC._ScreenEffectStrings);
DBC.SkillLine = DBCReader.ReadDBC<SkillLineEntry>(DBC.SkillLineStrings);
DBC.SpellRange = DBCReader.ReadDBC<SpellRangeEntry>(DBC.SpellRangeStrings);
DBC.ScreenEffect = DBCReader.ReadDBC<ScreenEffectEntry>(DBC.ScreenEffectStrings);

DBC.SpellDuration = DBCReader.ReadDBC<SpellDurationEntry>(null);
DBC.SkillLineAbility = DBCReader.ReadDBC<SkillLineAbilityEntry>(null);
Expand Down
49 changes: 27 additions & 22 deletions SpellWork/Spell/SpellInfo.cs
Expand Up @@ -253,7 +253,7 @@ private void AppendSpellEffectInfo()
spell.EffectImplicitTargetA[EFFECT_INDEX], spell.EffectImplicitTargetB[EFFECT_INDEX],
(Targets)spell.EffectImplicitTargetA[EFFECT_INDEX], (Targets)spell.EffectImplicitTargetB[EFFECT_INDEX]);

rtb.AppendText(AuraModTypeName(EFFECT_INDEX));
AuraModTypeName(EFFECT_INDEX);

uint[] ClassMask = new uint[3];

Expand Down Expand Up @@ -368,74 +368,79 @@ private void AppendSpellAura()
}
}

private string AuraModTypeName(int index)
private void AuraModTypeName(int index)
{
AuraType aura = (AuraType)spell.EffectApplyAuraName[index];
int misc = spell.EffectMiscValue[index];
StringBuilder sb = new StringBuilder();

if (spell.EffectApplyAuraName[index] == 0)
{
sb.AppendFormatLineIfNotNull("EffectMiscValueA = {0}", spell.EffectMiscValue[index]);
sb.AppendFormatLineIfNotNull("EffectMiscValueB = {0}", spell.EffectMiscValueB[index]);
sb.AppendFormatLineIfNotNull("EffectAmplitude = {0}", spell.EffectAmplitude[index]);
rtb.AppendFormatLineIfNotNull("EffectMiscValueA = {0}", spell.EffectMiscValue[index]);
rtb.AppendFormatLineIfNotNull("EffectMiscValueB = {0}", spell.EffectMiscValueB[index]);
rtb.AppendFormatLineIfNotNull("EffectAmplitude = {0}", spell.EffectAmplitude[index]);

return sb.ToString();
return;
}

sb.AppendFormat("Aura Id {0:D} ({0})", aura);
sb.AppendFormat(", value = {0}", spell.EffectBasePoints[index] + 1);
sb.AppendFormat(", misc = {0} (", misc);
rtb.AppendFormat("Aura Id {0:D} ({0})", aura);
rtb.AppendFormat(", value = {0}", spell.EffectBasePoints[index] + 1);
rtb.AppendFormat(", misc = {0} (", misc);

switch (aura)
{
case AuraType.SPELL_AURA_MOD_STAT:
sb.Append((UnitMods)misc);
rtb.Append((UnitMods)misc);
break;
case AuraType.SPELL_AURA_MOD_RATING:
sb.Append((CombatRating)misc);
rtb.Append((CombatRating)misc);
break;
case AuraType.SPELL_AURA_ADD_FLAT_MODIFIER:
case AuraType.SPELL_AURA_ADD_PCT_MODIFIER:
sb.Append((SpellModOp)misc);
rtb.Append((SpellModOp)misc);
break;
// todo: more case
default:
sb.Append(misc);
rtb.Append(misc);
break;
}

sb.AppendFormat("), miscB = {0}", spell.EffectMiscValueB[index]);
sb.AppendFormatLine(", periodic = {0}", spell.EffectAmplitude[index]);
rtb.AppendFormat("), miscB = {0}", spell.EffectMiscValueB[index]);
rtb.AppendFormatLine(", periodic = {0}", spell.EffectAmplitude[index]);

switch (aura)
{
case AuraType.SPELL_AURA_OVERRIDE_SPELLS:
if (!DBC.OverrideSpellData.ContainsKey((uint)misc))
sb.AppendFormatLine("Cannot find key {0} in OverrideSpellData.dbc", (uint)misc);
{
rtb.SetStyle(Color.Red, FontStyle.Bold);
rtb.AppendFormatLine("Cannot find key {0} in OverrideSpellData.dbc", (uint)misc);
}
else
{
sb.AppendLine("Overriding Spells:");
rtb.AppendLine();
rtb.SetStyle(Color.DarkRed, FontStyle.Bold);
rtb.AppendLine("Overriding Spells:");
OverrideSpellDataEntry Override = DBC.OverrideSpellData[(uint)misc];
for (int i = 0; i < 10; ++i)
{
if (Override.Spells[i] == 0)
continue;

sb.AppendFormatLine(" - #{0} ({1}) {2}", i, Override.Spells[i],
rtb.SetStyle(Color.DarkBlue, FontStyle.Regular);
rtb.AppendFormatLine("\t - #{0} ({1}) {2}", i + 1, Override.Spells[i],
DBC.Spell.ContainsKey(Override.Spells[i]) ? DBC.Spell[Override.Spells[i]].SpellName : "?????");
}
rtb.AppendLine();
}
break;
case AuraType.SPELL_AURA_SCREEN_EFFECT:
sb.AppendFormatLine("ScreenEffect: {0}",
rtb.SetStyle(Color.DarkBlue, FontStyle.Bold);
rtb.AppendFormatLine("ScreenEffect: {0}",
DBC.ScreenEffect.ContainsKey((uint)misc) ? DBC.ScreenEffect[(uint)misc].Name : "?????");
break;
default:
break;
}

return sb.ToString();
}

private void AppendItemInfo()
Expand Down
1 change: 0 additions & 1 deletion SpellWork/SpellWork.csproj
Expand Up @@ -79,7 +79,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataBase\LinqQueryBuilder.cs" />
<Compile Include="Extensions\LinqExtensions.cs" />
<Compile Include="Extensions\TreeViewExtensions.cs" />
<Compile Include="Forms\FormAboutBox.cs">
Expand Down
Binary file modified SpellWork/bin/Release/SpellWork.exe
Binary file not shown.

0 comments on commit 8156df4

Please sign in to comment.