diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index f1c876e307..0000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "Ijw.DirectX"] - path = Ijw.DirectX - url = git://github.com/chrisforbes/Ijw.DirectX.git diff --git a/Ijw.DirectX b/Ijw.DirectX deleted file mode 160000 index 57bf1241a4..0000000000 --- a/Ijw.DirectX +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 57bf1241a4b386e81c5d7c60ff15f2dec2cdc25e diff --git a/OpenRa.FileFormats/Cache.cs b/OpenRa.FileFormats/Cache.cs new file mode 100644 index 0000000000..9972f7cf63 --- /dev/null +++ b/OpenRa.FileFormats/Cache.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Collections; + +namespace OpenRa.FileFormats +{ + public class Cache : IEnumerable> + { + Dictionary hax = new Dictionary(); + Func loader; + + public Cache(Func loader) + { + if (loader == null) + throw new ArgumentNullException(); + + this.loader = loader; + } + + public U this[T key] + { + get + { + U result; + if (!hax.TryGetValue(key, out result)) + hax.Add(key, result = loader(key)); + + return result; + } + } + + public IEnumerator> GetEnumerator() { return hax.GetEnumerator(); } + + IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } + + public IEnumerable Keys { get { return hax.Keys; } } + public IEnumerable Values { get { return hax.Values; } } + } +} diff --git a/OpenRa.FileFormats/Collections/Set.cs b/OpenRa.FileFormats/Collections/Set.cs index 8a1fd8e1ef..ec00ab32f5 100755 --- a/OpenRa.FileFormats/Collections/Set.cs +++ b/OpenRa.FileFormats/Collections/Set.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using IjwFramework.Types; using System.Collections; namespace OpenRa.Collections diff --git a/OpenRa.FileFormats/FileSystem.cs b/OpenRa.FileFormats/FileSystem.cs index 7408916860..862680a633 100644 --- a/OpenRa.FileFormats/FileSystem.cs +++ b/OpenRa.FileFormats/FileSystem.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using IjwFramework.Collections; using System; namespace OpenRa.FileFormats diff --git a/OpenRa.FileFormats/Lazy.cs b/OpenRa.FileFormats/Lazy.cs new file mode 100644 index 0000000000..d479651c51 --- /dev/null +++ b/OpenRa.FileFormats/Lazy.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenRa.FileFormats +{ + public class Lazy + { + Func p; + T value; + + public Lazy(Func p) + { + if (p == null) + throw new ArgumentNullException(); + + this.p = p; + } + + public T Value + { + get + { + if (p == null) + return value; + + value = p(); + p = null; + return value; + } + } + } + + public static class Lazy + { + public static Lazy New(Func p) { return new Lazy(p); } + } +} diff --git a/OpenRa.FileFormats/Map.cs b/OpenRa.FileFormats/Map.cs index 342bce0c8c..1b5d633659 100644 --- a/OpenRa.FileFormats/Map.cs +++ b/OpenRa.FileFormats/Map.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using IjwFramework.Types; namespace OpenRa.FileFormats { diff --git a/OpenRa.FileFormats/OpenRa.FileFormats.csproj b/OpenRa.FileFormats/OpenRa.FileFormats.csproj index 046c9fc74e..da302ed829 100644 --- a/OpenRa.FileFormats/OpenRa.FileFormats.csproj +++ b/OpenRa.FileFormats/OpenRa.FileFormats.csproj @@ -35,10 +35,6 @@ prompt - - False - ..\Ijw.DirectX\Ijw.Framework\IjwFramework\bin\Release\IjwFramework.dll - 3.5 @@ -51,6 +47,7 @@ + @@ -66,12 +63,15 @@ + + + diff --git a/OpenRa.FileFormats/Pair.cs b/OpenRa.FileFormats/Pair.cs new file mode 100644 index 0000000000..87c1f39ca8 --- /dev/null +++ b/OpenRa.FileFormats/Pair.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenRa.FileFormats +{ + public struct Pair + { + public T First; + public U Second; + + public Pair(T first, U second) + { + First = first; + Second = second; + } + + static IEqualityComparer tc = EqualityComparer.Default; + static IEqualityComparer uc = EqualityComparer.Default; + + public static bool operator ==(Pair a, Pair b) + { + return tc.Equals(a.First, b.First) && uc.Equals(a.Second, b.Second); + } + + public static bool operator !=(Pair a, Pair b) + { + return !(a == b); + } + + public override bool Equals(object obj) + { + if (!(obj is Pair)) + return false; + + return (Pair)obj == this; + } + + public override int GetHashCode() + { + return First.GetHashCode() ^ Second.GetHashCode(); + } + + public Pair WithFirst(T t) { return new Pair(t, Second); } + public Pair WithSecond(U u) { return new Pair(First, u); } + + public static T AsFirst(Pair p) { return p.First; } + public static U AsSecond(Pair p) { return p.Second; } + + public Pair Swap() { return Pair.New(Second, First); } + } + + public static class Pair + { + public static Pair New(T t, U u) { return new Pair(t, u); } + } +} diff --git a/OpenRa.FileFormats/PriorityQueue.cs b/OpenRa.FileFormats/PriorityQueue.cs new file mode 100644 index 0000000000..f373699989 --- /dev/null +++ b/OpenRa.FileFormats/PriorityQueue.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenRa.FileFormats +{ + public class PriorityQueue + where T : IComparable + { + List items = new List(); + int level, index; + + public PriorityQueue() + { + items.Add(new T[1]); + } + + public void Add(T item) + { + int addLevel = level; + int addIndex = index; + + while (addLevel >= 1 && Above(addLevel, addIndex).CompareTo(item) > 0) + { + items[addLevel][addIndex] = Above(addLevel, addIndex); + --addLevel; + addIndex >>= 1; + } + + items[addLevel][addIndex] = item; + + if (++index >= (1 << level)) + { + index = 0; + if (items.Count <= ++level) + items.Add(new T[1 << level]); + } + } + + public bool Empty { get { return (level == 0); } } + + T At(int level, int index) { return items[level][index]; } + T Above(int level, int index) { return items[level - 1][index >> 1]; } + + T Last() + { + int lastLevel = level; + int lastIndex = index; + + if (--lastIndex < 0) + lastIndex = (1 << --lastLevel) - 1; + + return At(lastLevel, lastIndex); + } + + public T Pop() + { + if (level == 0 && index == 0) + throw new InvalidOperationException("Attempting to pop empty PriorityQueue"); + + T ret = At(0, 0); + BubbleInto(0, 0, Last()); + if (--index < 0) + index = (1 << --level) - 1; + + return ret; + } + + void BubbleInto(int intoLevel, int intoIndex, T val) + { + int downLevel = intoLevel + 1; + int downIndex = intoIndex << 1; + + if (downLevel > level || (downLevel == level && downIndex >= index)) + { + items[intoLevel][intoIndex] = val; + return; + } + + if (downLevel <= level && downIndex < index - 1 && + At(downLevel, downIndex).CompareTo(At(downLevel, downIndex + 1)) >= 0) + ++downIndex; + + if (val.CompareTo(At(downLevel, downIndex)) <= 0) + { + items[intoLevel][intoIndex] = val; + return; + } + + items[intoLevel][intoIndex] = At(downLevel, downIndex); + BubbleInto(downLevel, downIndex, val); + } + + int RowLength(int i) + { + if (i == level) + return index; + return (1 << i); + } + } +} diff --git a/OpenRa.FileFormats/TypeDictionary.cs b/OpenRa.FileFormats/TypeDictionary.cs index 94c71835cd..35a110a9bd 100644 --- a/OpenRa.FileFormats/TypeDictionary.cs +++ b/OpenRa.FileFormats/TypeDictionary.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using IjwFramework.Collections; namespace OpenRa.FileFormats { diff --git a/OpenRa.Game/Chrome.cs b/OpenRa.Game/Chrome.cs index 182f8e9d16..97edfbc642 100644 --- a/OpenRa.Game/Chrome.cs +++ b/OpenRa.Game/Chrome.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; -using IjwFramework.Types; using OpenRa.FileFormats; using OpenRa.Graphics; using OpenRa.Orders; diff --git a/OpenRa.Game/Controller.cs b/OpenRa.Game/Controller.cs index 74d81d81f2..967d2d94e5 100644 --- a/OpenRa.Game/Controller.cs +++ b/OpenRa.Game/Controller.cs @@ -1,12 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; -using IjwFramework.Collections; -using IjwFramework.Types; using OpenRa.GameRules; using OpenRa.Graphics; using OpenRa.Orders; using OpenRa.Traits; +using OpenRa.FileFormats; namespace OpenRa { diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index 0af42c64db..6b84767fc8 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Windows.Forms; -using IjwFramework.Types; using OpenRa.FileFormats; using OpenRa.GameRules; using OpenRa.Graphics; diff --git a/OpenRa.Game/GameRules/ActorInfo.cs b/OpenRa.Game/GameRules/ActorInfo.cs index 93d53b4491..a35c3ba4f0 100644 --- a/OpenRa.Game/GameRules/ActorInfo.cs +++ b/OpenRa.Game/GameRules/ActorInfo.cs @@ -4,7 +4,6 @@ using System.Linq; using OpenRa.FileFormats; using OpenRa.Traits; using System.Reflection; -using IjwFramework.Types; using System.IO; namespace OpenRa.GameRules diff --git a/OpenRa.Game/GameRules/InfoLoader.cs b/OpenRa.Game/GameRules/InfoLoader.cs index 5e6cafb88f..7882c78526 100644 --- a/OpenRa.Game/GameRules/InfoLoader.cs +++ b/OpenRa.Game/GameRules/InfoLoader.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Text; using OpenRa.FileFormats; using OpenRa.Graphics; -using IjwFramework.Types; using System.Collections; namespace OpenRa.GameRules diff --git a/OpenRa.Game/GameRules/Rules.cs b/OpenRa.Game/GameRules/Rules.cs index 5d62d957cc..3732cc1258 100755 --- a/OpenRa.Game/GameRules/Rules.cs +++ b/OpenRa.Game/GameRules/Rules.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using IjwFramework.Types; using OpenRa.FileFormats; using OpenRa.GameRules; diff --git a/OpenRa.Game/GameRules/TechTree.cs b/OpenRa.Game/GameRules/TechTree.cs index e4bc8e6019..952ffb7379 100755 --- a/OpenRa.Game/GameRules/TechTree.cs +++ b/OpenRa.Game/GameRules/TechTree.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; -using IjwFramework.Collections; using OpenRa.Traits; +using OpenRa.FileFormats; namespace OpenRa.GameRules { diff --git a/OpenRa.Game/GameRules/VoiceInfo.cs b/OpenRa.Game/GameRules/VoiceInfo.cs index 34d45d559c..47711193c6 100644 --- a/OpenRa.Game/GameRules/VoiceInfo.cs +++ b/OpenRa.Game/GameRules/VoiceInfo.cs @@ -1,5 +1,5 @@ using System.Collections.Generic; -using IjwFramework.Types; +using OpenRa.FileFormats; namespace OpenRa.GameRules { diff --git a/OpenRa.Game/Graphics/CursorSheetBuilder.cs b/OpenRa.Game/Graphics/CursorSheetBuilder.cs index 6761851e80..4a7f1999d7 100644 --- a/OpenRa.Game/Graphics/CursorSheetBuilder.cs +++ b/OpenRa.Game/Graphics/CursorSheetBuilder.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using IjwFramework.Collections; using OpenRa.FileFormats; namespace OpenRa.Graphics diff --git a/OpenRa.Game/Graphics/Minimap.cs b/OpenRa.Game/Graphics/Minimap.cs index b702f8ddd5..c608ad0193 100644 --- a/OpenRa.Game/Graphics/Minimap.cs +++ b/OpenRa.Game/Graphics/Minimap.cs @@ -4,9 +4,7 @@ using System.Linq; using OpenRa.Traits; using OpenRa.FileFormats; using System.Drawing.Imaging; -using IjwFramework.Collections; using System.Collections.Generic; -using IjwFramework.Types; namespace OpenRa.Graphics { diff --git a/OpenRa.Game/Graphics/SpriteSheetBuilder.cs b/OpenRa.Game/Graphics/SpriteSheetBuilder.cs index b7054962ff..68195e9ce7 100644 --- a/OpenRa.Game/Graphics/SpriteSheetBuilder.cs +++ b/OpenRa.Game/Graphics/SpriteSheetBuilder.cs @@ -1,5 +1,4 @@ using System.Linq; -using IjwFramework.Collections; using OpenRa.FileFormats; namespace OpenRa.Graphics diff --git a/OpenRa.Game/Graphics/TerrainRenderer.cs b/OpenRa.Game/Graphics/TerrainRenderer.cs index dd2828dfd3..e7d3b11c9a 100644 --- a/OpenRa.Game/Graphics/TerrainRenderer.cs +++ b/OpenRa.Game/Graphics/TerrainRenderer.cs @@ -1,6 +1,5 @@ using System.Drawing; using OpenRa.GlRenderer; -using IjwFramework.Collections; using OpenRa.FileFormats; namespace OpenRa.Graphics diff --git a/OpenRa.Game/Network/OrderManager.cs b/OpenRa.Game/Network/OrderManager.cs index 1e0ec62224..50dc73befb 100755 --- a/OpenRa.Game/Network/OrderManager.cs +++ b/OpenRa.Game/Network/OrderManager.cs @@ -2,8 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using IjwFramework.Types; +using OpenRa.FileFormats; namespace OpenRa.Network { diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index a7f4c3375f..7bde530f77 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -55,10 +55,6 @@ prompt - - False - ..\Ijw.DirectX\Ijw.Framework\IjwFramework\bin\Debug\IjwFramework.dll - 3.5 diff --git a/OpenRa.Game/PathSearch.cs b/OpenRa.Game/PathSearch.cs index abd07e1945..9b7da2e6e7 100755 --- a/OpenRa.Game/PathSearch.cs +++ b/OpenRa.Game/PathSearch.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using IjwFramework.Collections; using OpenRa.Graphics; using OpenRa.Traits; +using OpenRa.FileFormats; namespace OpenRa { diff --git a/OpenRa.Game/Selection.cs b/OpenRa.Game/Selection.cs index 696d7c54cb..51779eb21f 100644 --- a/OpenRa.Game/Selection.cs +++ b/OpenRa.Game/Selection.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using OpenRa.Traits; -using IjwFramework.Collections; +using OpenRa.FileFormats; namespace OpenRa { diff --git a/OpenRa.Game/Shroud.cs b/OpenRa.Game/Shroud.cs index 44847ef606..c2760359e8 100644 --- a/OpenRa.Game/Shroud.cs +++ b/OpenRa.Game/Shroud.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using IjwFramework.Types; using OpenRa.Graphics; using OpenRa.Traits; using OpenRa.FileFormats; diff --git a/OpenRa.Game/Sound.cs b/OpenRa.Game/Sound.cs index 0cfbbfb32c..fb25ceea41 100644 --- a/OpenRa.Game/Sound.cs +++ b/OpenRa.Game/Sound.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using IjwFramework.Collections; using OpenRa.FileFormats; using OpenRa.Support; using OpenRa.Traits; diff --git a/OpenRa.Game/Support/PerfHistory.cs b/OpenRa.Game/Support/PerfHistory.cs index d233df7a97..ee7e16e147 100644 --- a/OpenRa.Game/Support/PerfHistory.cs +++ b/OpenRa.Game/Support/PerfHistory.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; -using IjwFramework.Collections; using OpenRa.Graphics; +using OpenRa.FileFormats; namespace OpenRa.Support { diff --git a/OpenRa.Game/Sync.cs b/OpenRa.Game/Sync.cs index 57fb3815f7..571d9c50cf 100755 --- a/OpenRa.Game/Sync.cs +++ b/OpenRa.Game/Sync.cs @@ -2,7 +2,6 @@ using System.Linq; using System.Reflection; using System.Reflection.Emit; -using IjwFramework.Collections; using OpenRa.FileFormats; namespace OpenRa diff --git a/OpenRa.Game/Traits/Attack/AttackBase.cs b/OpenRa.Game/Traits/Attack/AttackBase.cs index ac9ca0631b..7d0cb73cc8 100644 --- a/OpenRa.Game/Traits/Attack/AttackBase.cs +++ b/OpenRa.Game/Traits/Attack/AttackBase.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using IjwFramework.Types; using OpenRa.Effects; using System.Drawing; +using OpenRa.FileFormats; namespace OpenRa.Traits { diff --git a/OpenRa.Game/Traits/Bridge.cs b/OpenRa.Game/Traits/Bridge.cs index 77a7276877..59e0ebeff7 100644 --- a/OpenRa.Game/Traits/Bridge.cs +++ b/OpenRa.Game/Traits/Bridge.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Text; using OpenRa.Graphics; using OpenRa.FileFormats; -using IjwFramework.Collections; using System.Drawing; namespace OpenRa.Traits diff --git a/OpenRa.Game/Traits/Crate.cs b/OpenRa.Game/Traits/Crate.cs index 4676d7b944..fe9c48fb47 100644 --- a/OpenRa.Game/Traits/Crate.cs +++ b/OpenRa.Game/Traits/Crate.cs @@ -2,7 +2,7 @@ using System.Linq; using OpenRa.Effects; using OpenRa.Traits; -using IjwFramework.Types; +using OpenRa.FileFormats; /* * Crates left to implement: diff --git a/OpenRa.Game/Traits/Player/ProductionQueue.cs b/OpenRa.Game/Traits/Player/ProductionQueue.cs index 29a52ccfa6..cb10834126 100644 --- a/OpenRa.Game/Traits/Player/ProductionQueue.cs +++ b/OpenRa.Game/Traits/Player/ProductionQueue.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using IjwFramework.Collections; +using OpenRa.FileFormats; namespace OpenRa.Traits { diff --git a/OpenRa.Game/Traits/TraitsInterfaces.cs b/OpenRa.Game/Traits/TraitsInterfaces.cs index 897e5fc44a..a27a3183f2 100644 --- a/OpenRa.Game/Traits/TraitsInterfaces.cs +++ b/OpenRa.Game/Traits/TraitsInterfaces.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; using System.Drawing; -using IjwFramework.Types; using OpenRa.GameRules; using OpenRa.Graphics; using OpenRa.Traits.Activities; +using OpenRa.FileFormats; namespace OpenRa.Traits { diff --git a/OpenRa.Gl/OpenRa.Gl.csproj b/OpenRa.Gl/OpenRa.Gl.csproj index 0be5075adf..0a299eafbc 100644 --- a/OpenRa.Gl/OpenRa.Gl.csproj +++ b/OpenRa.Gl/OpenRa.Gl.csproj @@ -48,9 +48,6 @@ False - - False - False diff --git a/SequenceEditor/SequenceEditor.csproj b/SequenceEditor/SequenceEditor.csproj index 1bc2a5217a..fe4ab9fbec 100644 --- a/SequenceEditor/SequenceEditor.csproj +++ b/SequenceEditor/SequenceEditor.csproj @@ -31,14 +31,6 @@ prompt - - False - ..\Ijw.DirectX\bin\Ijw.DirectX.dll - - - False - ..\Ijw.DirectX\bin\Ijw.Math.dll - False ..\Ijw.DirectX\bin\IjwFramework.dll