66using System . Linq ;
77using System . Numerics ;
88using System . Runtime . InteropServices ;
9- using System . Runtime . Serialization . Formatters . Binary ;
9+ using System . Runtime . Serialization . Formatters . Binary ;
10+ using System . Text ;
1011
1112namespace CathodeLib
1213{
@@ -183,19 +184,6 @@ public static void Write<T>(BinaryWriter stream, List<T> aux)
183184 Write < T > ( stream , aux . ToArray < T > ( ) ) ;
184185 }
185186
186- //Clones an object (slow!)
187- public static T CloneObject < T > ( T obj )
188- {
189- //A somewhat hacky an inefficient way of deep cloning an object (TODO: optimise this as we use it a lot!)
190- MemoryStream ms = new MemoryStream ( ) ;
191- new BinaryFormatter ( ) . Serialize ( ms , obj ) ;
192- ms . Position = 0 ;
193- T obj2 = ( T ) new BinaryFormatter ( ) . Deserialize ( ms ) ;
194- ms . Close ( ) ;
195- return obj2 ;
196- //obj.MemberwiseClone();
197- }
198-
199187 //Generate a hashed string for use in the animation system (FNV hash)
200188 public static uint AnimationHashedString ( string str )
201189 {
@@ -212,6 +200,21 @@ public static uint AnimationHashedString(string str)
212200 return hash ;
213201 }
214202
203+ //Generate a hashed string for use in sound system (wwise FNV-1)
204+ public static uint SoundHashedString ( string str )
205+ {
206+ byte [ ] namebytes = Encoding . UTF8 . GetBytes ( str . ToLower ( ) ) ;
207+ uint hash = 2166136261 ;
208+ for ( int i = 0 ; i < namebytes . Length ; i ++ )
209+ {
210+ byte namebyte = namebytes [ i ] ;
211+ hash = hash * 16777619 ;
212+ hash = hash ^ namebyte ;
213+ hash = hash & 0xFFFFFFFF ;
214+ }
215+ return hash ;
216+ }
217+
215218 //Read a PAK
216219 public static List < PAKContent > ReadPAK ( string path , FileIdentifiers type )
217220 {
0 commit comments