1
1
#include "wwise_bank.h"
2
+ #include "utils.h"
2
3
3
4
int8_t wwise_bank_parser_event_voice (kbtree_t (wwise_bank_key_value_map ) * map , binary_stream_t * stream ){
4
5
uint32_t id , wem ;
@@ -21,6 +22,7 @@ int8_t wwise_bank_parser_event_voice(kbtree_t(wwise_bank_key_value_map) *map, bi
21
22
if (type == 0 ){
22
23
kb_put (wwise_bank_key_value_map , map , entity );
23
24
}
25
+ __LIBUABE_DEBUG ("voice:%u,%u,%u\n" , id , type , wem );
24
26
return 0 ;
25
27
}
26
28
@@ -43,6 +45,7 @@ int8_t wwise_bank_parser_event_action(kbtree_t(wwise_bank_key_value_map) *map, b
43
45
entity .key = id ;
44
46
entity .value = voice ;
45
47
kb_put (wwise_bank_key_value_map , map , entity );
48
+ __LIBUABE_DEBUG ("action:%u,%u,%u,%u\n" , id , scope , type , voice );
46
49
return 0 ;
47
50
}
48
51
@@ -57,43 +60,97 @@ int8_t wwise_bank_parser_event_event(kbtree_t(wwise_bank_key_values_map) *map, b
57
60
}
58
61
entity .key = id ;
59
62
entity .size = number ;
63
+ __LIBUABE_DEBUG ("event:%u\n" , id );
60
64
for (int i = 0 ; i < number ; ++ i ){
61
65
if (i >= EVENT_MAX_ACTION_BUMBER ){
62
- puts ("EVENT_MAX_ACTION_BUMBER error.\n" );
66
+ __LIBUABE_DEBUG ("EVENT_MAX_ACTION_BUMBER error.\n" );
63
67
break ;
64
68
}
65
69
if (binary_stream_read_uint32 (stream , & action ) != 0 ){
66
70
return -3 ;
67
71
}
72
+ __LIBUABE_DEBUG ("--action:%u\n" , action );
68
73
entity .values [i ] = action ;
69
74
}
70
75
kb_put (wwise_bank_key_values_map , map , entity );
71
76
return 0 ;
72
77
}
73
78
74
- int8_t wwise_bank_parser_event_container (kbtree_t (wwise_bank_key_values_map ) * map , binary_stream_t * stream ){
75
- uint32_t id , number , voice ;
79
+ int8_t wwise_bank_parser_event_sequence (kbtree_t (wwise_bank_key_values_map ) * map , binary_stream_t * stream ){
80
+ uint16_t check = 0 ;
81
+ uint32_t id , number , object ;
76
82
wwise_bank_key_values_t entity ;
77
83
uint64_t start = binary_stream_seek (stream , 0 , SEEK_CUR );
78
84
if (binary_stream_read_uint32 (stream , & id ) != 0 ){
79
85
return -1 ;
80
86
}
81
- if (binary_stream_seek (stream , 0x34 , SEEK_CUR ) == -1 ){
87
+ do {
88
+ if (binary_stream_read_uint16 (stream , & check ) != 0 ){
89
+ return -2 ;
90
+ }
91
+ if (binary_stream_seek (stream , -1 , SEEK_CUR ) == -1 ){
92
+ return -2 ;
93
+ }
94
+ } while (check != 0x447A );
95
+ if (binary_stream_seek (stream , 15 , SEEK_CUR ) == -1 ){
96
+ return -2 ;
97
+ }
98
+ if (binary_stream_read_uint32 (stream , & number ) != 0 ){
99
+ return -2 ;
100
+ }
101
+ if (number > EVENT_MAX_ACTION_BUMBER ){
102
+ __LIBUABE_DEBUG ("sequence number too more.\n" );
103
+ return 0 ;
104
+ }
105
+ entity .key = id ;
106
+ entity .size = number ;
107
+ __LIBUABE_DEBUG ("sequence:%u\n" , id );
108
+ for (int i = 0 ; i < number ; ++ i ){
109
+ if (binary_stream_read_uint32 (stream , & object ) != 0 ){
110
+ return -3 ;
111
+ }
112
+ __LIBUABE_DEBUG ("--object:%u\n" , object );
113
+ entity .values [i ] = object ;
114
+ }
115
+ if (number > 0 ){
116
+ kb_put (wwise_bank_key_values_map , map , entity );
117
+ }
118
+ return 0 ;
119
+ }
120
+
121
+ int8_t wwise_bank_parser_event_switch (kbtree_t (wwise_bank_key_values_map ) * map , binary_stream_t * stream ){
122
+ uint8_t skip ;
123
+ uint32_t id , number , object ;
124
+ wwise_bank_key_values_t entity ;
125
+ uint64_t start = binary_stream_seek (stream , 0 , SEEK_CUR );
126
+ if (binary_stream_read_uint32 (stream , & id ) != 0 ){
127
+ return -1 ;
128
+ }
129
+ if (binary_stream_seek (stream , 0x0C , SEEK_CUR ) == -1 ){
130
+ return -2 ;
131
+ }
132
+ if (binary_stream_read_uint8 (stream , & skip ) != 0 ){
133
+ return -2 ;
134
+ }
135
+ if (binary_stream_seek (stream , 0x19 + 5 * skip , SEEK_CUR ) == -1 ){
82
136
return -2 ;
83
137
}
84
138
if (binary_stream_read_uint32 (stream , & number ) != 0 ){
85
139
return -2 ;
86
140
}
87
141
if (number > EVENT_MAX_ACTION_BUMBER ){
142
+ __LIBUABE_DEBUG ("switch number too more.\n" );
88
143
return 0 ;
89
144
}
90
145
entity .key = id ;
91
146
entity .size = number ;
147
+ __LIBUABE_DEBUG ("switch:%u\n" , id );
92
148
for (int i = 0 ; i < number ; ++ i ){
93
- if (binary_stream_read_uint32 (stream , & voice ) != 0 ){
149
+ if (binary_stream_read_uint32 (stream , & object ) != 0 ){
94
150
return -3 ;
95
151
}
96
- entity .values [i ] = voice ;
152
+ __LIBUABE_DEBUG ("--object:%u\n" , object );
153
+ entity .values [i ] = object ;
97
154
}
98
155
if (number > 0 ){
99
156
kb_put (wwise_bank_key_values_map , map , entity );
@@ -102,11 +159,11 @@ int8_t wwise_bank_parser_event_container(kbtree_t(wwise_bank_key_values_map) *ma
102
159
}
103
160
104
161
int8_t wwise_bank_parser_event (wwise_bank_t * bank , binary_stream_t * stream ){
105
- bank -> voice_wem_map = kb_init (wwise_bank_key_value_map , KB_DEFAULT_SIZE );
106
- bank -> event_wems_map = kb_init (wwise_bank_key_values_map , KB_DEFAULT_SIZE );
107
- bank -> action_object_map = kb_init (wwise_bank_key_value_map , KB_DEFAULT_SIZE );
108
- bank -> event_actions_map = kb_init (wwise_bank_key_values_map , KB_DEFAULT_SIZE );
109
- bank -> object_voices_map = kb_init (wwise_bank_key_values_map , KB_DEFAULT_SIZE );
162
+ bank -> voice_wem_map = kb_init (wwise_bank_key_value_map , KB_DEFAULT_SIZE * sizeof ( wwise_bank_key_value_t ) );
163
+ bank -> event_wems_map = kb_init (wwise_bank_key_values_map , KB_DEFAULT_SIZE * sizeof ( wwise_bank_key_values_t ) );
164
+ bank -> action_object_map = kb_init (wwise_bank_key_value_map , KB_DEFAULT_SIZE * sizeof ( wwise_bank_key_value_t ) );
165
+ bank -> event_actions_map = kb_init (wwise_bank_key_values_map , KB_DEFAULT_SIZE * sizeof ( wwise_bank_key_values_t ) );
166
+ bank -> object_voices_map = kb_init (wwise_bank_key_values_map , KB_DEFAULT_SIZE * sizeof ( wwise_bank_key_values_t ) );
110
167
uint8_t type ;
111
168
uint32_t number , length , id ;
112
169
int64_t end ;
@@ -125,6 +182,15 @@ int8_t wwise_bank_parser_event(wwise_bank_t *bank, binary_stream_t *stream){
125
182
if (end < 0 ){
126
183
return -3 ;
127
184
}
185
+ /*
186
+ if(binary_stream_read_uint32(stream, &id) != 0){
187
+ return -2;
188
+ }
189
+ binary_stream_seek(stream, -4, SEEK_CUR);
190
+ __LIBUABE_DEBUG("object:%u,%u,%u\n", id, type, length);
191
+ if(id == 151993151 || id == 606474963 || id == 698201592 || id == 462587676){
192
+ utils_file_stream_dump(stream, length, id);
193
+ }*/
128
194
switch (type ){
129
195
case 4 : //Event
130
196
if (wwise_bank_parser_event_event (bank -> event_actions_map , stream )!= 0 ){
@@ -142,7 +208,12 @@ int8_t wwise_bank_parser_event(wwise_bank_t *bank, binary_stream_t *stream){
142
208
}
143
209
break ;
144
210
case 5 : //Random Container or Sequence Container
145
- if (wwise_bank_parser_event_container (bank -> object_voices_map , stream )!= 0 ){
211
+ if (wwise_bank_parser_event_sequence (bank -> object_voices_map , stream )!= 0 ){
212
+ return -7 ;
213
+ }
214
+ break ;
215
+ case 6 : //Switch
216
+ if (wwise_bank_parser_event_switch (bank -> object_voices_map , stream )!= 0 ){
146
217
return -7 ;
147
218
}
148
219
break ;
@@ -212,6 +283,7 @@ int8_t wwise_bank_parser_didx(wwise_bank_t *bank, binary_stream_t *stream, uint3
212
283
if (current < 0 ){
213
284
return -6 ;
214
285
}
286
+ __LIBUABE_DEBUG ("wem:%u,%u\n" , put .key , put .length );
215
287
}
216
288
return 0 ;
217
289
}
@@ -221,7 +293,7 @@ int8_t wwise_bank_parser_data(wwise_bank_t *bank, binary_stream_t *stream){
221
293
int32_t start ;
222
294
wwise_bank_key_stream_t put ;
223
295
if (bank -> wem_stream_map == 0 ){
224
- printf ("wwise_bank_parser_data not didx." );
296
+ __LIBUABE_DEBUG ("wwise_bank_parser_data not didx." );
225
297
return 0 ;
226
298
}
227
299
start = binary_stream_seek (stream , 0 , SEEK_CUR );
0 commit comments