Skip to content

Commit

Permalink
Drop bad code
Browse files Browse the repository at this point in the history
Signed-off-by: Konctantin <gawrilyako@gmail.com>
  • Loading branch information
Konctantin committed Aug 2, 2010
1 parent 135da8f commit 9983d86
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 76 deletions.
6 changes: 4 additions & 2 deletions SpellWork/DBC/DBCReader.cs
Expand Up @@ -15,15 +15,17 @@ static class DBCReader

using (BinaryReader reader = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read), Encoding.UTF8))
{
if (!File.Exists(fileName))
throw new FileNotFoundException();
// read dbc header
DbcHeader header = reader.ReadStruct<DbcHeader>();
int size = Marshal.SizeOf(typeof(T));

if (!header.IsDBC)
throw new SpellWorkException("{0} is not DBC files", fileName);
throw new Exception(fileName + " is not DBC files!");

if (header.RecordSize != size)
throw new SpellWorkException("Size of row in DBC file ({0}) != size of DBC struct ({1}) in DBC: {2}", header.RecordSize, size, fileName);
throw new Exception(string.Format("Size of row in DBC file ({0}) != size of DBC struct ({1}) in DBC: {2}", header.RecordSize, size, fileName));

// read dbc data
for (int r = 0; r < header.RecordsCount; ++r)
Expand Down
21 changes: 0 additions & 21 deletions SpellWork/Extensions/SpellWorkException.cs

This file was deleted.

36 changes: 14 additions & 22 deletions SpellWork/Loader.cs
Expand Up @@ -8,30 +8,22 @@ namespace SpellWork
{
class Loader
{
public Loader(bool thread)
public Loader()
{
DBC.Spell = DBCReader.ReadDBC<SpellEntry>(DBC.SpellStrings);

if (thread)
new Thread(RunOther).Start();
else
RunOther();

DBC.Locale = DetectedLocale;
}
DBC.Spell = DBCReader.ReadDBC<SpellEntry>(DBC.SpellStrings);
DBC.SkillLine = DBCReader.ReadDBC<SkillLineEntry>(DBC.SkillLineStrings);
DBC.SpellRange = DBCReader.ReadDBC<SpellRangeEntry>(DBC.SpellRangeStrings);
DBC.ScreenEffect = DBCReader.ReadDBC<ScreenEffectEntry>(DBC.ScreenEffectStrings);

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.SpellDuration = DBCReader.ReadDBC<SpellDurationEntry>(null);
DBC.SkillLineAbility = DBCReader.ReadDBC<SkillLineAbilityEntry>(null);
DBC.SpellRadius = DBCReader.ReadDBC<SpellRadiusEntry>(null);
DBC.SpellCastTimes = DBCReader.ReadDBC<SpellCastTimesEntry>(null);
DBC.SpellDuration = DBCReader.ReadDBC<SpellDurationEntry>(null);
DBC.SkillLineAbility = DBCReader.ReadDBC<SkillLineAbilityEntry>(null);
DBC.SpellRadius = DBCReader.ReadDBC<SpellRadiusEntry>(null);
DBC.SpellCastTimes = DBCReader.ReadDBC<SpellCastTimesEntry>(null);

DBC.OverrideSpellData = DBCReader.ReadDBC<OverrideSpellDataEntry>(null);

DBC.OverrideSpellData = DBCReader.ReadDBC<OverrideSpellDataEntry>(null);

DBC.Locale = DetectedLocale;
}

private LocalesDBC DetectedLocale
Expand All @@ -44,7 +36,7 @@ private LocalesDBC DetectedLocale
++locale;

if (locale >= DBC.MAX_DBC_LOCALE)
throw new SpellWorkException("Detected unknown locale index {0}", locale);
throw new Exception("Detected unknown locale index " + locale);
}
return (LocalesDBC)locale;
}
Expand Down
36 changes: 7 additions & 29 deletions SpellWork/Program.cs
Expand Up @@ -17,37 +17,15 @@ static void Main(string[] args)
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

if (!File.Exists(DBC.DBC_PATH + "Spell.dbc") ||
!File.Exists(DBC.DBC_PATH + "SpellRadius.dbc") ||
!File.Exists(DBC.DBC_PATH + "SpellRange.dbc") ||
!File.Exists(DBC.DBC_PATH + "SpellDuration.dbc") ||
!File.Exists(DBC.DBC_PATH + "SkillLineAbility.dbc") ||
!File.Exists(DBC.DBC_PATH + "SkillLine.dbc") ||
!File.Exists(DBC.DBC_PATH + "SpellCastTimes.dbc") ||
!File.Exists(DBC.DBC_PATH + "ScreenEffect.dbc") ||
!File.Exists(DBC.DBC_PATH + "OverrideSpellData.dbc"))
try
{
MessageBox.Show(String.Format("Files not found:\r\n"
+ "{0}Spell.dbc\r\n"
+ "{0}SpellRadius.dbc\r\n"
+ "{0}SpellRange.dbc\r\n"
+ "{0}SpellDuration.dbc\r\n"
+ "{0}SkillLineAbility.dbc\r\n"
+ "{0}SkillLine.dbc\r\n"
+ "{0}SpellCastTimes.dbc\r\n"
+ "{0}ScreenEffect.dbc\r\n"
+ "{0}OverrideSpellData.dbc\r\n",
DBC.DBC_PATH),
"SpellWork ERROR",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
Application.Exit();
return;
new Loader();
Application.Run(new FormMain());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "SpellWork Eroor!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

new Loader(!(args.Count() > 0 && args[0].ToLower() == "nothread"));

Application.Run(new FormMain());
}
}
}
2 changes: 0 additions & 2 deletions SpellWork/SpellWork.csproj
Expand Up @@ -114,8 +114,6 @@
<DependentUpon>FormSettings.cs</DependentUpon>
</Compile>
<Compile Include="Spell\SpellCompare.cs" />
<Compile Include="Extensions\SpellWorkException.cs">
</Compile>
<Compile Include="DBC\Structure.cs" />
<Compile Include="Spell\SpellInfo.cs" />
<Compile Include="Spell\SpellEnums.cs" />
Expand Down

0 comments on commit 9983d86

Please sign in to comment.