dsp_blueprint_parser 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,227 +1,227 @@
1
- # frozen_string_literal: true
2
-
3
- module DspBlueprintParser
4
- # class to orchestrate building parsing
5
- class BuildingParser
6
- class << self
7
- # @param [BlueprintData] blueprint
8
- # @param [BinaryReader] reader
9
- # @return [void]
10
- def process!(blueprint, reader)
11
- reader.read_i32.times do
12
- path_num = reader.read_i32
13
- building = if path_num <= -102
14
- path_102(reader)
15
- elsif path_num <= -101
16
- path_101(reader)
17
- elsif path_num <= -100
18
- path_100(reader)
19
- else
20
- path_default(reader, path_num)
21
- end
22
-
23
- blueprint.buildings << building
24
- end
25
- end
26
-
27
- private
28
-
29
- # @param [BinaryReader] reader
30
- # @return [Building]
31
- def path_102(reader)
32
- building = Building.new
33
- building.index = reader.read_i32
34
- building.item_id = reader.read_i16
35
- building.model_index = reader.read_i16
36
- building.area_index = reader.read_i8
37
- building.local_offset_x = reader.read_single
38
- building.local_offset_y = reader.read_single
39
- building.local_offset_z = reader.read_single
40
- building.yaw = reader.read_single
41
-
42
- if building.item_id > 2000 && building.item_id < 2010
43
- building.tilt = reader.read_single
44
- building.pitch = 0.0
45
- building.local_offset_x2 = building.local_offset_x
46
- building.local_offset_y2 = building.local_offset_y
47
- building.local_offset_z2 = building.local_offset_z
48
- building.yaw2 = building.yaw
49
- building.tilt2 = building.tilt
50
- building.pitch2 = 0.0
51
- elsif building.item_id > 2010 && building.item_id < 2020
52
- building.tilt = reader.read_single
53
- building.pitch = reader.read_single
54
- building.local_offset_x2 = reader.read_single
55
- building.local_offset_y2 = reader.read_single
56
- building.local_offset_z2 = reader.read_single
57
- building.yaw2 = reader.read_single
58
- building.tilt2 = reader.read_single
59
- building.pitch2 = reader.read_single
60
- else
61
- building.tilt = 0.0
62
- building.pitch = 0.0
63
- building.local_offset_x2 = building.local_offset_x
64
- building.local_offset_y2 = building.local_offset_y
65
- building.local_offset_z2 = building.local_offset_z
66
- building.yaw2 = building.yaw
67
- building.tilt2 = 0.0
68
- building.pitch2 = 0.0
69
- end
70
-
71
- building.temp_output_obj_idx = reader.read_i32
72
- building.temp_input_obj_idx = reader.read_i32
73
- building.output_to_slot = reader.read_i8
74
- building.input_from_slot = reader.read_i8
75
- building.output_from_slot = reader.read_i8
76
- building.input_to_slot = reader.read_i8
77
- building.output_offset = reader.read_i8
78
- building.input_offset = reader.read_i8
79
- building.recipe_id = reader.read_i16
80
- building.filter_fd = reader.read_i16
81
-
82
- reader.read_i16.times do
83
- building.parameters << reader.read_i32
84
- end
85
-
86
- building
87
- end
88
-
89
- # @param [BinaryReader] reader
90
- # @return [Building]
91
- def path_101(reader)
92
- building = Building.new
93
- building.index = reader.read_i32
94
- building.item_id = reader.read_i16
95
- building.model_index = reader.read_i16
96
- building.area_index = reader.read_i8
97
- building.local_offset_x = reader.read_single
98
- building.local_offset_y = reader.read_single
99
- building.local_offset_z = reader.read_single
100
- building.yaw = reader.read_single
101
-
102
- if building.item_id > 2000 && building.item_id < 2010
103
- building.tilt = reader.read_single
104
- building.pitch = 0.0
105
- building.local_offset_x2 = building.local_offset_x
106
- building.local_offset_y2 = building.local_offset_y
107
- building.local_offset_z2 = building.local_offset_z
108
- building.yaw2 = building.yaw
109
- building.tilt2 = building.tilt
110
- building.pitch2 = 0.0
111
- elsif building.item_id > 2010 && building.item_id < 2020
112
- building.tilt = reader.read_single
113
- building.pitch = reader.read_single
114
- building.local_offset_x2 = reader.read_single
115
- building.local_offset_y2 = reader.read_single
116
- building.local_offset_z2 = reader.read_single
117
- building.yaw2 = reader.read_single
118
- building.tilt2 = reader.read_single
119
- building.pitch2 = reader.read_single
120
- else
121
- building.tilt = 0.0
122
- building.pitch = 0.0
123
- building.local_offset_x2 = building.local_offset_x
124
- building.local_offset_y2 = building.local_offset_y
125
- building.local_offset_z2 = building.local_offset_z
126
- building.yaw2 = building.yaw
127
- building.tilt2 = 0.0
128
- building.pitch2 = 0.0
129
- end
130
-
131
- building.temp_output_obj_idx = reader.read_i32
132
- building.temp_input_obj_idx = reader.read_i32
133
- building.output_to_slot = reader.read_i8
134
- building.input_from_slot = reader.read_i8
135
- building.output_from_slot = reader.read_i8
136
- building.input_to_slot = reader.read_i8
137
- building.output_offset = reader.read_i8
138
- building.input_offset = reader.read_i8
139
- building.recipe_id = reader.read_i16
140
- building.filter_fd = reader.read_i16
141
-
142
- reader.read_i16.times do
143
- building.parameters << reader.read_i32
144
- end
145
-
146
- building
147
- end
148
-
149
- # @param [BinaryReader] reader
150
- # @return [Building]
151
- def path_100(reader)
152
- building = Building.new
153
- building.index = reader.read_i32
154
- building.area_index = reader.read_i8
155
- building.local_offset_x = reader.read_single
156
- building.local_offset_y = reader.read_single
157
- building.local_offset_z = reader.read_single
158
- building.local_offset_x2 = reader.read_single
159
- building.local_offset_y2 = reader.read_single
160
- building.local_offset_z2 = reader.read_single
161
- building.pitch = 0.0
162
- building.pitch2 = 0.0
163
- building.yaw = reader.read_single
164
- building.yaw2 = reader.read_single
165
- building.tilt = reader.read_single
166
- building.tilt2 = 0.0
167
- building.item_id = reader.read_i16
168
- building.model_index = reader.read_i16
169
- building.temp_output_obj_idx = reader.read_i32
170
- building.temp_input_obj_idx = reader.read_i32
171
- building.output_to_slot = reader.read_i8
172
- building.input_from_slot = reader.read_i8
173
- building.output_from_slot = reader.read_i8
174
- building.input_to_slot = reader.read_i8
175
- building.output_offset = reader.read_i8
176
- building.input_offset = reader.read_i8
177
- building.recipe_id = reader.read_i16
178
- building.filter_fd = reader.read_i16
179
-
180
- reader.read_i16.times do
181
- building.parameters << reader.read_i32
182
- end
183
-
184
- building
185
- end
186
-
187
- # @param [BinaryReader] reader
188
- # @param [Integer] index
189
- # @return [Building]
190
- def path_default(reader, index)
191
- building = Building.new
192
- building.index = index
193
- building.area_index = reader.read_i8
194
- building.local_offset_x = reader.read_single
195
- building.local_offset_y = reader.read_single
196
- building.local_offset_z = reader.read_single
197
- building.local_offset_x2 = reader.read_single
198
- building.local_offset_y2 = reader.read_single
199
- building.local_offset_z2 = reader.read_single
200
- building.pitch = 0.0
201
- building.pitch2 = 0.0
202
- building.yaw = reader.read_single
203
- building.yaw2 = reader.read_single
204
- building.tilt = 0.0
205
- building.tilt2 = 0.0
206
- building.item_id = reader.read_i16
207
- building.model_index = reader.read_i16
208
- building.temp_output_obj_idx = reader.read_i32
209
- building.temp_input_obj_idx = reader.read_i32
210
- building.output_to_slot = reader.read_i8
211
- building.input_from_slot = reader.read_i8
212
- building.output_from_slot = reader.read_i8
213
- building.input_to_slot = reader.read_i8
214
- building.output_offset = reader.read_i8
215
- building.input_offset = reader.read_i8
216
- building.recipe_id = reader.read_i16
217
- building.filter_fd = reader.read_i16
218
-
219
- reader.read_i16.times do
220
- building.parameters << reader.read_i32
221
- end
222
-
223
- building
224
- end
225
- end
226
- end
227
- end
1
+ # frozen_string_literal: true
2
+
3
+ module DspBlueprintParser
4
+ # class to orchestrate building parsing
5
+ class BuildingParser
6
+ class << self
7
+ # @param [BlueprintData] blueprint
8
+ # @param [BinaryReader] reader
9
+ # @return [void]
10
+ def process!(blueprint, reader)
11
+ reader.read_i32.times do
12
+ path_num = reader.read_i32
13
+ building = if path_num <= -102
14
+ path_102(reader)
15
+ elsif path_num <= -101
16
+ path_101(reader)
17
+ elsif path_num <= -100
18
+ path_100(reader)
19
+ else
20
+ path_default(reader, path_num)
21
+ end
22
+
23
+ blueprint.buildings << building
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ # @param [BinaryReader] reader
30
+ # @return [Building]
31
+ def path_102(reader)
32
+ building = Building.new
33
+ building.index = reader.read_i32
34
+ building.item_id = reader.read_i16
35
+ building.model_index = reader.read_i16
36
+ building.area_index = reader.read_i8
37
+ building.local_offset_x = reader.read_single
38
+ building.local_offset_y = reader.read_single
39
+ building.local_offset_z = reader.read_single
40
+ building.yaw = reader.read_single
41
+
42
+ if building.item_id > 2000 && building.item_id < 2010
43
+ building.tilt = reader.read_single
44
+ building.pitch = 0.0
45
+ building.local_offset_x2 = building.local_offset_x
46
+ building.local_offset_y2 = building.local_offset_y
47
+ building.local_offset_z2 = building.local_offset_z
48
+ building.yaw2 = building.yaw
49
+ building.tilt2 = building.tilt
50
+ building.pitch2 = 0.0
51
+ elsif building.item_id > 2010 && building.item_id < 2020
52
+ building.tilt = reader.read_single
53
+ building.pitch = reader.read_single
54
+ building.local_offset_x2 = reader.read_single
55
+ building.local_offset_y2 = reader.read_single
56
+ building.local_offset_z2 = reader.read_single
57
+ building.yaw2 = reader.read_single
58
+ building.tilt2 = reader.read_single
59
+ building.pitch2 = reader.read_single
60
+ else
61
+ building.tilt = 0.0
62
+ building.pitch = 0.0
63
+ building.local_offset_x2 = building.local_offset_x
64
+ building.local_offset_y2 = building.local_offset_y
65
+ building.local_offset_z2 = building.local_offset_z
66
+ building.yaw2 = building.yaw
67
+ building.tilt2 = 0.0
68
+ building.pitch2 = 0.0
69
+ end
70
+
71
+ building.temp_output_obj_idx = reader.read_i32
72
+ building.temp_input_obj_idx = reader.read_i32
73
+ building.output_to_slot = reader.read_i8
74
+ building.input_from_slot = reader.read_i8
75
+ building.output_from_slot = reader.read_i8
76
+ building.input_to_slot = reader.read_i8
77
+ building.output_offset = reader.read_i8
78
+ building.input_offset = reader.read_i8
79
+ building.recipe_id = reader.read_i16
80
+ building.filter_fd = reader.read_i16
81
+
82
+ reader.read_i16.times do
83
+ building.parameters << reader.read_i32
84
+ end
85
+
86
+ building
87
+ end
88
+
89
+ # @param [BinaryReader] reader
90
+ # @return [Building]
91
+ def path_101(reader)
92
+ building = Building.new
93
+ building.index = reader.read_i32
94
+ building.item_id = reader.read_i16
95
+ building.model_index = reader.read_i16
96
+ building.area_index = reader.read_i8
97
+ building.local_offset_x = reader.read_single
98
+ building.local_offset_y = reader.read_single
99
+ building.local_offset_z = reader.read_single
100
+ building.yaw = reader.read_single
101
+
102
+ if building.item_id > 2000 && building.item_id < 2010
103
+ building.tilt = reader.read_single
104
+ building.pitch = 0.0
105
+ building.local_offset_x2 = building.local_offset_x
106
+ building.local_offset_y2 = building.local_offset_y
107
+ building.local_offset_z2 = building.local_offset_z
108
+ building.yaw2 = building.yaw
109
+ building.tilt2 = building.tilt
110
+ building.pitch2 = 0.0
111
+ elsif building.item_id > 2010 && building.item_id < 2020
112
+ building.tilt = reader.read_single
113
+ building.pitch = reader.read_single
114
+ building.local_offset_x2 = reader.read_single
115
+ building.local_offset_y2 = reader.read_single
116
+ building.local_offset_z2 = reader.read_single
117
+ building.yaw2 = reader.read_single
118
+ building.tilt2 = reader.read_single
119
+ building.pitch2 = reader.read_single
120
+ else
121
+ building.tilt = 0.0
122
+ building.pitch = 0.0
123
+ building.local_offset_x2 = building.local_offset_x
124
+ building.local_offset_y2 = building.local_offset_y
125
+ building.local_offset_z2 = building.local_offset_z
126
+ building.yaw2 = building.yaw
127
+ building.tilt2 = 0.0
128
+ building.pitch2 = 0.0
129
+ end
130
+
131
+ building.temp_output_obj_idx = reader.read_i32
132
+ building.temp_input_obj_idx = reader.read_i32
133
+ building.output_to_slot = reader.read_i8
134
+ building.input_from_slot = reader.read_i8
135
+ building.output_from_slot = reader.read_i8
136
+ building.input_to_slot = reader.read_i8
137
+ building.output_offset = reader.read_i8
138
+ building.input_offset = reader.read_i8
139
+ building.recipe_id = reader.read_i16
140
+ building.filter_fd = reader.read_i16
141
+
142
+ reader.read_i16.times do
143
+ building.parameters << reader.read_i32
144
+ end
145
+
146
+ building
147
+ end
148
+
149
+ # @param [BinaryReader] reader
150
+ # @return [Building]
151
+ def path_100(reader)
152
+ building = Building.new
153
+ building.index = reader.read_i32
154
+ building.area_index = reader.read_i8
155
+ building.local_offset_x = reader.read_single
156
+ building.local_offset_y = reader.read_single
157
+ building.local_offset_z = reader.read_single
158
+ building.local_offset_x2 = reader.read_single
159
+ building.local_offset_y2 = reader.read_single
160
+ building.local_offset_z2 = reader.read_single
161
+ building.pitch = 0.0
162
+ building.pitch2 = 0.0
163
+ building.yaw = reader.read_single
164
+ building.yaw2 = reader.read_single
165
+ building.tilt = reader.read_single
166
+ building.tilt2 = 0.0
167
+ building.item_id = reader.read_i16
168
+ building.model_index = reader.read_i16
169
+ building.temp_output_obj_idx = reader.read_i32
170
+ building.temp_input_obj_idx = reader.read_i32
171
+ building.output_to_slot = reader.read_i8
172
+ building.input_from_slot = reader.read_i8
173
+ building.output_from_slot = reader.read_i8
174
+ building.input_to_slot = reader.read_i8
175
+ building.output_offset = reader.read_i8
176
+ building.input_offset = reader.read_i8
177
+ building.recipe_id = reader.read_i16
178
+ building.filter_fd = reader.read_i16
179
+
180
+ reader.read_i16.times do
181
+ building.parameters << reader.read_i32
182
+ end
183
+
184
+ building
185
+ end
186
+
187
+ # @param [BinaryReader] reader
188
+ # @param [Integer] index
189
+ # @return [Building]
190
+ def path_default(reader, index)
191
+ building = Building.new
192
+ building.index = index
193
+ building.area_index = reader.read_i8
194
+ building.local_offset_x = reader.read_single
195
+ building.local_offset_y = reader.read_single
196
+ building.local_offset_z = reader.read_single
197
+ building.local_offset_x2 = reader.read_single
198
+ building.local_offset_y2 = reader.read_single
199
+ building.local_offset_z2 = reader.read_single
200
+ building.pitch = 0.0
201
+ building.pitch2 = 0.0
202
+ building.yaw = reader.read_single
203
+ building.yaw2 = reader.read_single
204
+ building.tilt = 0.0
205
+ building.tilt2 = 0.0
206
+ building.item_id = reader.read_i16
207
+ building.model_index = reader.read_i16
208
+ building.temp_output_obj_idx = reader.read_i32
209
+ building.temp_input_obj_idx = reader.read_i32
210
+ building.output_to_slot = reader.read_i8
211
+ building.input_from_slot = reader.read_i8
212
+ building.output_from_slot = reader.read_i8
213
+ building.input_to_slot = reader.read_i8
214
+ building.output_offset = reader.read_i8
215
+ building.input_offset = reader.read_i8
216
+ building.recipe_id = reader.read_i16
217
+ building.filter_fd = reader.read_i16
218
+
219
+ reader.read_i16.times do
220
+ building.parameters << reader.read_i32
221
+ end
222
+
223
+ building
224
+ end
225
+ end
226
+ end
227
+ end
@@ -1,41 +1,41 @@
1
- # frozen_string_literal: true
2
-
3
- module DspBlueprintParser
4
- # Data Sections
5
- #
6
- # Given a raw DSP Blueprint sting this returns readability
7
- # usable data on the string
8
- class DataSections
9
- # @param str_blueprint [String]
10
- def initialize(str_blueprint)
11
- @str_blueprint = str_blueprint.strip
12
- @blueprint_type_loc = @str_blueprint.index(':')
13
- @first_quote_loc = @str_blueprint.index('"')
14
- @second_quote_loc = @str_blueprint[(@first_quote_loc + 1)..].index('"') + @first_quote_loc + 1
15
- end
16
-
17
- # @return [Array<String>]
18
- def header_segments
19
- @header_segments ||= @str_blueprint[@blueprint_type_loc..@first_quote_loc - 1].split(',')
20
- end
21
-
22
- def hashed_string
23
- @str_blueprint[..@second_quote_loc - 1]
24
- end
25
-
26
- def hash
27
- @str_blueprint[@second_quote_loc + 1..-1]
28
- end
29
-
30
- # @return [Array<Integer>] array of bytes, 0..255
31
- def decompressed_body
32
- @decompressed_body ||=
33
- @str_blueprint[@first_quote_loc + 1..@second_quote_loc - 1]
34
- .then(&Base64.method(:decode64))
35
- .then(&StringIO.method(:new))
36
- .then(&Zlib::GzipReader.method(:new))
37
- .each_byte
38
- .to_a
39
- end
40
- end
41
- end
1
+ # frozen_string_literal: true
2
+
3
+ module DspBlueprintParser
4
+ # Data Sections
5
+ #
6
+ # Given a raw DSP Blueprint sting this returns readability
7
+ # usable data on the string
8
+ class DataSections
9
+ # @param str_blueprint [String]
10
+ def initialize(str_blueprint)
11
+ @str_blueprint = str_blueprint.strip
12
+ @blueprint_type_loc = @str_blueprint.index(':')
13
+ @first_quote_loc = @str_blueprint.index('"')
14
+ @second_quote_loc = @str_blueprint[(@first_quote_loc + 1)..].index('"') + @first_quote_loc + 1
15
+ end
16
+
17
+ # @return [Array<String>]
18
+ def header_segments
19
+ @header_segments ||= @str_blueprint[@blueprint_type_loc..@first_quote_loc - 1].split(',')
20
+ end
21
+
22
+ def hashed_string
23
+ @str_blueprint[..@second_quote_loc - 1]
24
+ end
25
+
26
+ def hash
27
+ @str_blueprint[@second_quote_loc + 1..-1]
28
+ end
29
+
30
+ # @return [Array<Integer>] array of bytes, 0..255
31
+ def decompressed_body
32
+ @decompressed_body ||=
33
+ @str_blueprint[@first_quote_loc + 1..@second_quote_loc - 1]
34
+ .then(&Base64.method(:decode64))
35
+ .then(&StringIO.method(:new))
36
+ .then(&Zlib::GzipReader.method(:new))
37
+ .each_byte
38
+ .to_a
39
+ end
40
+ end
41
+ end
@@ -1,23 +1,23 @@
1
- # frozen_string_literal: true
2
-
3
- module DspBlueprintParser
4
- module IconLayout
5
- NONE = 0
6
- NO_ICON = 1
7
- ONE_ICON = 10
8
- ONE_ICON_SMALL = 11
9
- TWO_ICON_46 = 20
10
- TWO_ICON_53 = 21
11
- TWO_ICON_59 = 22
12
- TWO_ICON_57 = 23
13
- TWO_ICON_51 = 24
14
- THREE_ICON_813 = 30
15
- THREE_ICON_279 = 31
16
- THREE_ICON_573 = 32
17
- THREE_ICON_591 = 33
18
- FOUR_ICON_7913 = 40
19
- FOUR_ICON_8462 = 41
20
- FIVE_ICON_57913 = 50
21
- FIVE_ICON_PENTA = 51
22
- end
23
- end
1
+ # frozen_string_literal: true
2
+
3
+ module DspBlueprintParser
4
+ module IconLayout
5
+ NONE = 0
6
+ NO_ICON = 1
7
+ ONE_ICON = 10
8
+ ONE_ICON_SMALL = 11
9
+ TWO_ICON_46 = 20
10
+ TWO_ICON_53 = 21
11
+ TWO_ICON_59 = 22
12
+ TWO_ICON_57 = 23
13
+ TWO_ICON_51 = 24
14
+ THREE_ICON_813 = 30
15
+ THREE_ICON_279 = 31
16
+ THREE_ICON_573 = 32
17
+ THREE_ICON_591 = 33
18
+ FOUR_ICON_7913 = 40
19
+ FOUR_ICON_8462 = 41
20
+ FIVE_ICON_57913 = 50
21
+ FIVE_ICON_PENTA = 51
22
+ end
23
+ end