@@ -13,6 +13,8 @@ namespace CATHODE
1313 /* DATA/ENV/PRODUCTION/x/WORLD/SOUNDEVENTDATA.DAT */
1414 public class SoundEventData : CathodeFile
1515 {
16+ //This stores all available sound events within soundbanks, along with their associated max attenuation and metadata (parameters)
17+
1618 public List < Soundbank > Entries = new List < Soundbank > ( ) ;
1719 public static new Implementation Implementation = Implementation . CREATE | Implementation . LOAD | Implementation . SAVE ;
1820 public SoundEventData ( string path ) : base ( path ) { }
@@ -22,17 +24,17 @@ override protected bool LoadInternal()
2224 {
2325 using ( BinaryReader reader = new BinaryReader ( File . OpenRead ( _filepath ) ) )
2426 {
25- reader . BaseStream . Position += 4 ;
27+ reader . BaseStream . Position += 4 ; //version
2628 int entryCount = reader . ReadInt32 ( ) ;
2729 for ( int i = 0 ; i < entryCount ; i ++ )
2830 {
2931 Soundbank . Event e = new Soundbank . Event ( ) ;
3032 int length = reader . ReadInt32 ( ) ;
3133 for ( int x = 0 ; x < length ; x ++ ) e . name += reader . ReadChar ( ) ;
3234 length = reader . ReadInt32 ( ) ;
33- for ( int x = 0 ; x < length ; x ++ ) e . args += reader . ReadChar ( ) ;
34- reader . BaseStream . Position += 2 ;
35- e . unknown = reader . ReadInt16 ( ) ;
35+ for ( int x = 0 ; x < length ; x ++ ) e . metadata += reader . ReadChar ( ) ;
36+
37+ e . max_attenuation = reader . ReadSingle ( ) ;
3638
3739 uint soundbankID = reader . ReadUInt32 ( ) ;
3840 Soundbank soundbank = Entries . FirstOrDefault ( o => o . id == soundbankID ) ;
@@ -53,20 +55,23 @@ override protected bool SaveInternal()
5355 {
5456 writer . BaseStream . SetLength ( 0 ) ;
5557 writer . Write ( 0 ) ;
56- writer . Write ( Entries . Count ) ;
58+ writer . Write ( 0 ) ;
59+ int count = 0 ;
5760 for ( int i = 0 ; i < Entries . Count ; i ++ )
5861 {
5962 for ( int x = 0 ; x < Entries [ i ] . events . Count ; x ++ )
6063 {
6164 writer . Write ( Entries [ i ] . events [ x ] . name . Length ) ;
6265 Utilities . WriteString ( Entries [ i ] . events [ x ] . name , writer ) ;
63- writer . Write ( Entries [ i ] . events [ x ] . args . Length ) ;
64- Utilities . WriteString ( Entries [ i ] . events [ x ] . args , writer ) ;
65- writer . Write ( ( Int16 ) 0 ) ;
66- writer . Write ( Entries [ i ] . events [ x ] . unknown ) ;
66+ writer . Write ( Entries [ i ] . events [ x ] . metadata . Length ) ;
67+ Utilities . WriteString ( Entries [ i ] . events [ x ] . metadata , writer ) ;
68+ writer . Write ( Entries [ i ] . events [ x ] . max_attenuation ) ;
6769 writer . Write ( Entries [ i ] . id ) ;
70+ count ++ ;
6871 }
6972 }
73+ writer . BaseStream . Position = 4 ;
74+ writer . Write ( count ) ;
7075 }
7176 return true ;
7277 }
@@ -80,10 +85,9 @@ public class Soundbank
8085
8186 public class Event
8287 {
83- public string name ;
84- public string args ;
85-
86- public int unknown ;
88+ public string name = "" ;
89+ public string metadata = "" ;
90+ public float max_attenuation = 1024.0f ;
8791 }
8892 } ;
8993 #endregion
0 commit comments