summaryrefslogtreecommitdiff
path: root/NW4RTools/Misc.cs
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-02-20 05:30:01 +0100
committerTreeki <treeki@gmail.com>2012-02-20 05:30:01 +0100
commit31380b4bb93d1fb65faff8f71753de80fb0a8c9d (patch)
tree8880321028df33877fec9af6c424afe48e7ac4ef /NW4RTools/Misc.cs
parent364e99d849378546323d1d06307b6773e813b742 (diff)
downloadnw4rtools-31380b4bb93d1fb65faff8f71753de80fb0a8c9d.tar.gz
nw4rtools-31380b4bb93d1fb65faff8f71753de80fb0a8c9d.zip
AnmChr/Clr/TexSrt writing done for now. Not 100% perfect but it works!
Diffstat (limited to '')
-rw-r--r--NW4RTools/Misc.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/NW4RTools/Misc.cs b/NW4RTools/Misc.cs
index c42b185..118f164 100644
--- a/NW4RTools/Misc.cs
+++ b/NW4RTools/Misc.cs
@@ -16,6 +16,46 @@ namespace NW4RTools {
public static uint AlignDown(uint val, uint to) {
return val & ~(to - 1);
}
+
+
+ public static void Assert(bool condition) {
+ if (!condition)
+ throw new Exception("Assert failed");
+ }
+ public static void Assert(bool condition, string format, params object[] args) {
+ if (!condition)
+ throw new Exception(String.Format(format, args));
+ }
+
+
+ public static bool ArrayCompare<T>(T[] one, T[] two) {
+ if (one == two)
+ return true;
+ if (one == null || two == null)
+ return false;
+ if (one.Length != two.Length)
+ return false;
+
+ for (int i = 0; i < one.Length; i++) {
+ if (!one[i].Equals(two[i]))
+ return false;
+ }
+
+ return true;
+ }
+
+
+ public static int ArrayHash<T>(T[] arr) {
+ if (arr == null)
+ return 0xEA7BEEF;
+
+ int hash = 0;
+
+ for (int i = 0; i < arr.Length; i++)
+ hash ^= arr[i].GetHashCode();
+
+ return hash;
+ }
}
}