sc2ai 0.4.2 → 0.5.0

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/data/sc2ai/protocol/data.proto +2 -2
  3. data/data/sc2ai/protocol/debug.proto +1 -1
  4. data/data/sc2ai/protocol/raw.proto +6 -6
  5. data/data/sc2ai/protocol/sc2api.proto +1 -1
  6. data/data/sc2ai/protocol/ui.proto +1 -1
  7. data/{lib/docker_build → docker_build}/Dockerfile.ruby +2 -2
  8. data/lib/sc2ai/cli/ladderzip.rb +1 -1
  9. data/lib/sc2ai/local_play/client.rb +1 -1
  10. data/lib/sc2ai/local_play/match.rb +1 -0
  11. data/lib/sc2ai/overrides/async/process/child.rb +2 -1
  12. data/lib/sc2ai/paths.rb +0 -1
  13. data/lib/sc2ai/player/debug.rb +3 -3
  14. data/lib/sc2ai/player.rb +9 -0
  15. data/lib/sc2ai/protocol/common_pb.rb +460 -105
  16. data/lib/sc2ai/protocol/data_pb.rb +833 -482
  17. data/lib/sc2ai/protocol/debug_pb.rb +1112 -401
  18. data/lib/sc2ai/protocol/error_pb.rb +430 -862
  19. data/lib/sc2ai/protocol/extensions/action.rb +1 -1
  20. data/lib/sc2ai/protocol/extensions/color.rb +1 -1
  21. data/lib/sc2ai/protocol/extensions/point.rb +1 -1
  22. data/lib/sc2ai/protocol/extensions/point_2_d.rb +1 -1
  23. data/lib/sc2ai/protocol/extensions/point_distance.rb +4 -4
  24. data/lib/sc2ai/protocol/extensions/position.rb +20 -0
  25. data/lib/sc2ai/protocol/extensions/power_source.rb +1 -1
  26. data/lib/sc2ai/protocol/extensions/unit.rb +1 -1
  27. data/lib/sc2ai/protocol/extensions/unit_type_data.rb +1 -1
  28. data/lib/sc2ai/protocol/query_pb.rb +558 -88
  29. data/lib/sc2ai/protocol/raw_pb.rb +1829 -1156
  30. data/lib/sc2ai/protocol/sc2api_pb.rb +5233 -1463
  31. data/lib/sc2ai/protocol/score_pb.rb +444 -103
  32. data/lib/sc2ai/protocol/spatial_pb.rb +935 -145
  33. data/lib/sc2ai/protocol/ui_pb.rb +1432 -435
  34. data/lib/sc2ai/version.rb +1 -1
  35. data/lib/templates/new/api/data.proto +2 -2
  36. data/lib/templates/new/api/debug.proto +1 -1
  37. data/lib/templates/new/api/raw.proto +6 -6
  38. data/lib/templates/new/api/sc2api.proto +1 -1
  39. data/lib/templates/new/api/ui.proto +1 -1
  40. data/lib/templates/new/run_example_match.rb.tt +1 -1
  41. data/sig/sc2ai.rbs +1361 -23
  42. metadata +7 -7
  43. /data/{lib/docker_build → docker_build}/docker-compose-base-image.yml +0 -0
  44. /data/{lib/docker_build → docker_build}/docker-compose-ladderzip.yml +0 -0
@@ -127,20 +127,39 @@ module Api
127
127
  # unexpected, so discard it and continue.
128
128
  if !found
129
129
  wire_type = tag & 0x7
130
+
131
+ unknown_bytes = +"".b
132
+ val = tag
133
+ loop do
134
+ byte = val & 0x7F
135
+
136
+ val >>= 7
137
+ # This drops the top bits,
138
+ # Otherwise, with a signed right shift,
139
+ # we get infinity one bits at the top
140
+ val &= (1 << 57) - 1
141
+
142
+ byte |= 0x80 if val != 0
143
+ unknown_bytes << byte
144
+ break if val == 0
145
+ end
146
+
130
147
  case wire_type
131
148
  when 0
132
149
  i = 0
133
150
  while true
134
151
  newbyte = buff.getbyte(index)
135
152
  index += 1
136
- break if newbyte.nil? || newbyte < 0x80
153
+ break if newbyte.nil?
154
+ unknown_bytes << newbyte
155
+ break if newbyte < 0x80
137
156
  i += 1
138
157
  break if i > 9
139
158
  end
140
159
  when 1
160
+ unknown_bytes << buff.byteslice(index, 8)
141
161
  index += 8
142
162
  when 2
143
- ## PULL_BYTES
144
163
  value =
145
164
  if (byte0 = buff.getbyte(index)) < 0x80
146
165
  index += 1
@@ -196,15 +215,30 @@ module Api
196
215
  raise "integer decoding error"
197
216
  end
198
217
 
199
- buff.byteslice(index, value)
200
- index += value
218
+ val = value
219
+ loop do
220
+ byte = val & 0x7F
221
+
222
+ val >>= 7
223
+ # This drops the top bits,
224
+ # Otherwise, with a signed right shift,
225
+ # we get infinity one bits at the top
226
+ val &= (1 << 57) - 1
201
227
 
202
- ## END PULL_BYTES
228
+ byte |= 0x80 if val != 0
229
+ unknown_bytes << byte
230
+ break if val == 0
231
+ end
232
+
233
+ unknown_bytes << buff.byteslice(index, value)
234
+ index += value
203
235
  when 5
236
+ unknown_bytes << buff.byteslice(index, 4)
204
237
  index += 4
205
238
  else
206
239
  raise "unknown wire type #{wire_type}"
207
240
  end
241
+ (@_unknown_fields ||= +"".b) << unknown_bytes
208
242
  return self if index >= len
209
243
  ## PULL_UINT64
210
244
  tag =
@@ -594,16 +628,44 @@ module Api
594
628
 
595
629
  buff
596
630
  end
597
-
631
+ buff << @_unknown_fields if @_unknown_fields
598
632
  buff
599
633
  end
600
634
 
601
635
  def to_h
602
636
  result = {}
603
- result["renders".to_sym] = @renders.to_h
604
- result["minimap_renders".to_sym] = @minimap_renders.to_h
637
+
638
+ result[:"renders"] = @renders.to_h
639
+ result[:"minimap_renders"] = @minimap_renders.to_h
640
+
605
641
  result
606
642
  end
643
+
644
+ def as_json(options = {})
645
+ result = {}
646
+
647
+ result["renders"] = (
648
+ if @renders.nil?
649
+ {}
650
+ else
651
+ @renders.as_json(options)
652
+ end
653
+ ) if !options[:compact] || has_renders?
654
+ result["minimapRenders"] = (
655
+ if @minimap_renders.nil?
656
+ {}
657
+ else
658
+ @minimap_renders.as_json(options)
659
+ end
660
+ ) if !options[:compact] || has_minimap_renders?
661
+
662
+ result
663
+ end
664
+
665
+ def to_json(as_json_options = {})
666
+ require "json"
667
+ JSON.dump(as_json(as_json_options))
668
+ end
607
669
  end
608
670
  class FeatureLayers
609
671
  def self.decode(buff)
@@ -1232,20 +1294,39 @@ module Api
1232
1294
  # unexpected, so discard it and continue.
1233
1295
  if !found
1234
1296
  wire_type = tag & 0x7
1297
+
1298
+ unknown_bytes = +"".b
1299
+ val = tag
1300
+ loop do
1301
+ byte = val & 0x7F
1302
+
1303
+ val >>= 7
1304
+ # This drops the top bits,
1305
+ # Otherwise, with a signed right shift,
1306
+ # we get infinity one bits at the top
1307
+ val &= (1 << 57) - 1
1308
+
1309
+ byte |= 0x80 if val != 0
1310
+ unknown_bytes << byte
1311
+ break if val == 0
1312
+ end
1313
+
1235
1314
  case wire_type
1236
1315
  when 0
1237
1316
  i = 0
1238
1317
  while true
1239
1318
  newbyte = buff.getbyte(index)
1240
1319
  index += 1
1241
- break if newbyte.nil? || newbyte < 0x80
1320
+ break if newbyte.nil?
1321
+ unknown_bytes << newbyte
1322
+ break if newbyte < 0x80
1242
1323
  i += 1
1243
1324
  break if i > 9
1244
1325
  end
1245
1326
  when 1
1327
+ unknown_bytes << buff.byteslice(index, 8)
1246
1328
  index += 8
1247
1329
  when 2
1248
- ## PULL_BYTES
1249
1330
  value =
1250
1331
  if (byte0 = buff.getbyte(index)) < 0x80
1251
1332
  index += 1
@@ -1301,15 +1382,30 @@ module Api
1301
1382
  raise "integer decoding error"
1302
1383
  end
1303
1384
 
1304
- buff.byteslice(index, value)
1305
- index += value
1385
+ val = value
1386
+ loop do
1387
+ byte = val & 0x7F
1306
1388
 
1307
- ## END PULL_BYTES
1389
+ val >>= 7
1390
+ # This drops the top bits,
1391
+ # Otherwise, with a signed right shift,
1392
+ # we get infinity one bits at the top
1393
+ val &= (1 << 57) - 1
1394
+
1395
+ byte |= 0x80 if val != 0
1396
+ unknown_bytes << byte
1397
+ break if val == 0
1398
+ end
1399
+
1400
+ unknown_bytes << buff.byteslice(index, value)
1401
+ index += value
1308
1402
  when 5
1403
+ unknown_bytes << buff.byteslice(index, 4)
1309
1404
  index += 4
1310
1405
  else
1311
1406
  raise "unknown wire type #{wire_type}"
1312
1407
  end
1408
+ (@_unknown_fields ||= +"".b) << unknown_bytes
1313
1409
  return self if index >= len
1314
1410
  ## PULL_UINT64
1315
1411
  tag =
@@ -5730,41 +5826,228 @@ module Api
5730
5826
 
5731
5827
  buff
5732
5828
  end
5733
-
5829
+ buff << @_unknown_fields if @_unknown_fields
5734
5830
  buff
5735
5831
  end
5736
5832
 
5737
5833
  def to_h
5738
5834
  result = {}
5739
- result["height_map".to_sym] = @height_map.to_h
5740
- result["visibility_map".to_sym] = @visibility_map.to_h
5741
- result["creep".to_sym] = @creep.to_h
5742
- result["power".to_sym] = @power.to_h
5743
- result["player_id".to_sym] = @player_id.to_h
5744
- result["unit_type".to_sym] = @unit_type.to_h
5745
- result["selected".to_sym] = @selected.to_h
5746
- result["unit_hit_points".to_sym] = @unit_hit_points.to_h
5747
- result["unit_hit_points_ratio".to_sym] = @unit_hit_points_ratio.to_h
5748
- result["unit_energy".to_sym] = @unit_energy.to_h
5749
- result["unit_energy_ratio".to_sym] = @unit_energy_ratio.to_h
5750
- result["unit_shields".to_sym] = @unit_shields.to_h
5751
- result["unit_shields_ratio".to_sym] = @unit_shields_ratio.to_h
5752
- result["player_relative".to_sym] = @player_relative.to_h
5753
- result["unit_density_aa".to_sym] = @unit_density_aa.to_h
5754
- result["unit_density".to_sym] = @unit_density.to_h
5755
- result["effects".to_sym] = @effects.to_h
5756
- result["hallucinations".to_sym] = @hallucinations.to_h
5757
- result["cloaked".to_sym] = @cloaked.to_h
5758
- result["blip".to_sym] = @blip.to_h
5759
- result["buffs".to_sym] = @buffs.to_h
5760
- result["buff_duration".to_sym] = @buff_duration.to_h
5761
- result["active".to_sym] = @active.to_h
5762
- result["build_progress".to_sym] = @build_progress.to_h
5763
- result["buildable".to_sym] = @buildable.to_h
5764
- result["pathable".to_sym] = @pathable.to_h
5765
- result["placeholder".to_sym] = @placeholder.to_h
5835
+
5836
+ result[:"height_map"] = @height_map.to_h
5837
+ result[:"visibility_map"] = @visibility_map.to_h
5838
+ result[:"creep"] = @creep.to_h
5839
+ result[:"power"] = @power.to_h
5840
+ result[:"player_id"] = @player_id.to_h
5841
+ result[:"unit_type"] = @unit_type.to_h
5842
+ result[:"selected"] = @selected.to_h
5843
+ result[:"unit_hit_points"] = @unit_hit_points.to_h
5844
+ result[:"unit_energy"] = @unit_energy.to_h
5845
+ result[:"unit_shields"] = @unit_shields.to_h
5846
+ result[:"player_relative"] = @player_relative.to_h
5847
+ result[:"unit_density_aa"] = @unit_density_aa.to_h
5848
+ result[:"unit_density"] = @unit_density.to_h
5849
+ result[:"unit_hit_points_ratio"] = @unit_hit_points_ratio.to_h
5850
+ result[:"unit_energy_ratio"] = @unit_energy_ratio.to_h
5851
+ result[:"unit_shields_ratio"] = @unit_shields_ratio.to_h
5852
+ result[:"effects"] = @effects.to_h
5853
+ result[:"hallucinations"] = @hallucinations.to_h
5854
+ result[:"cloaked"] = @cloaked.to_h
5855
+ result[:"blip"] = @blip.to_h
5856
+ result[:"buffs"] = @buffs.to_h
5857
+ result[:"active"] = @active.to_h
5858
+ result[:"buff_duration"] = @buff_duration.to_h
5859
+ result[:"build_progress"] = @build_progress.to_h
5860
+ result[:"buildable"] = @buildable.to_h
5861
+ result[:"pathable"] = @pathable.to_h
5862
+ result[:"placeholder"] = @placeholder.to_h
5863
+
5766
5864
  result
5767
5865
  end
5866
+
5867
+ def as_json(options = {})
5868
+ result = {}
5869
+
5870
+ result["heightMap"] = (
5871
+ if @height_map.nil?
5872
+ {}
5873
+ else
5874
+ @height_map.as_json(options)
5875
+ end
5876
+ ) if !options[:compact] || has_height_map?
5877
+ result["visibilityMap"] = (
5878
+ if @visibility_map.nil?
5879
+ {}
5880
+ else
5881
+ @visibility_map.as_json(options)
5882
+ end
5883
+ ) if !options[:compact] || has_visibility_map?
5884
+ result["creep"] = @creep.nil? ? {} : @creep.as_json(options) if !options[
5885
+ :compact
5886
+ ] || has_creep?
5887
+ result["power"] = @power.nil? ? {} : @power.as_json(options) if !options[
5888
+ :compact
5889
+ ] || has_power?
5890
+ result["playerId"] = (
5891
+ if @player_id.nil?
5892
+ {}
5893
+ else
5894
+ @player_id.as_json(options)
5895
+ end
5896
+ ) if !options[:compact] || has_player_id?
5897
+ result["unitType"] = (
5898
+ if @unit_type.nil?
5899
+ {}
5900
+ else
5901
+ @unit_type.as_json(options)
5902
+ end
5903
+ ) if !options[:compact] || has_unit_type?
5904
+ result["selected"] = (
5905
+ if @selected.nil?
5906
+ {}
5907
+ else
5908
+ @selected.as_json(options)
5909
+ end
5910
+ ) if !options[:compact] || has_selected?
5911
+ result["unitHitPoints"] = (
5912
+ if @unit_hit_points.nil?
5913
+ {}
5914
+ else
5915
+ @unit_hit_points.as_json(options)
5916
+ end
5917
+ ) if !options[:compact] || has_unit_hit_points?
5918
+ result["unitEnergy"] = (
5919
+ if @unit_energy.nil?
5920
+ {}
5921
+ else
5922
+ @unit_energy.as_json(options)
5923
+ end
5924
+ ) if !options[:compact] || has_unit_energy?
5925
+ result["unitShields"] = (
5926
+ if @unit_shields.nil?
5927
+ {}
5928
+ else
5929
+ @unit_shields.as_json(options)
5930
+ end
5931
+ ) if !options[:compact] || has_unit_shields?
5932
+ result["playerRelative"] = (
5933
+ if @player_relative.nil?
5934
+ {}
5935
+ else
5936
+ @player_relative.as_json(options)
5937
+ end
5938
+ ) if !options[:compact] || has_player_relative?
5939
+ result["unitDensityAa"] = (
5940
+ if @unit_density_aa.nil?
5941
+ {}
5942
+ else
5943
+ @unit_density_aa.as_json(options)
5944
+ end
5945
+ ) if !options[:compact] || has_unit_density_aa?
5946
+ result["unitDensity"] = (
5947
+ if @unit_density.nil?
5948
+ {}
5949
+ else
5950
+ @unit_density.as_json(options)
5951
+ end
5952
+ ) if !options[:compact] || has_unit_density?
5953
+ result["unitHitPointsRatio"] = (
5954
+ if @unit_hit_points_ratio.nil?
5955
+ {}
5956
+ else
5957
+ @unit_hit_points_ratio.as_json(options)
5958
+ end
5959
+ ) if !options[:compact] || has_unit_hit_points_ratio?
5960
+ result["unitEnergyRatio"] = (
5961
+ if @unit_energy_ratio.nil?
5962
+ {}
5963
+ else
5964
+ @unit_energy_ratio.as_json(options)
5965
+ end
5966
+ ) if !options[:compact] || has_unit_energy_ratio?
5967
+ result["unitShieldsRatio"] = (
5968
+ if @unit_shields_ratio.nil?
5969
+ {}
5970
+ else
5971
+ @unit_shields_ratio.as_json(options)
5972
+ end
5973
+ ) if !options[:compact] || has_unit_shields_ratio?
5974
+ result["effects"] = (
5975
+ if @effects.nil?
5976
+ {}
5977
+ else
5978
+ @effects.as_json(options)
5979
+ end
5980
+ ) if !options[:compact] || has_effects?
5981
+ result["hallucinations"] = (
5982
+ if @hallucinations.nil?
5983
+ {}
5984
+ else
5985
+ @hallucinations.as_json(options)
5986
+ end
5987
+ ) if !options[:compact] || has_hallucinations?
5988
+ result["cloaked"] = (
5989
+ if @cloaked.nil?
5990
+ {}
5991
+ else
5992
+ @cloaked.as_json(options)
5993
+ end
5994
+ ) if !options[:compact] || has_cloaked?
5995
+ result["blip"] = @blip.nil? ? {} : @blip.as_json(options) if !options[
5996
+ :compact
5997
+ ] || has_blip?
5998
+ result["buffs"] = @buffs.nil? ? {} : @buffs.as_json(options) if !options[
5999
+ :compact
6000
+ ] || has_buffs?
6001
+ result["active"] = (
6002
+ if @active.nil?
6003
+ {}
6004
+ else
6005
+ @active.as_json(options)
6006
+ end
6007
+ ) if !options[:compact] || has_active?
6008
+ result["buffDuration"] = (
6009
+ if @buff_duration.nil?
6010
+ {}
6011
+ else
6012
+ @buff_duration.as_json(options)
6013
+ end
6014
+ ) if !options[:compact] || has_buff_duration?
6015
+ result["buildProgress"] = (
6016
+ if @build_progress.nil?
6017
+ {}
6018
+ else
6019
+ @build_progress.as_json(options)
6020
+ end
6021
+ ) if !options[:compact] || has_build_progress?
6022
+ result["buildable"] = (
6023
+ if @buildable.nil?
6024
+ {}
6025
+ else
6026
+ @buildable.as_json(options)
6027
+ end
6028
+ ) if !options[:compact] || has_buildable?
6029
+ result["pathable"] = (
6030
+ if @pathable.nil?
6031
+ {}
6032
+ else
6033
+ @pathable.as_json(options)
6034
+ end
6035
+ ) if !options[:compact] || has_pathable?
6036
+ result["placeholder"] = (
6037
+ if @placeholder.nil?
6038
+ {}
6039
+ else
6040
+ @placeholder.as_json(options)
6041
+ end
6042
+ ) if !options[:compact] || has_placeholder?
6043
+
6044
+ result
6045
+ end
6046
+
6047
+ def to_json(as_json_options = {})
6048
+ require "json"
6049
+ JSON.dump(as_json(as_json_options))
6050
+ end
5768
6051
  end
5769
6052
  class FeatureLayersMinimap
5770
6053
  def self.decode(buff)
@@ -6073,20 +6356,39 @@ module Api
6073
6356
  # unexpected, so discard it and continue.
6074
6357
  if !found
6075
6358
  wire_type = tag & 0x7
6359
+
6360
+ unknown_bytes = +"".b
6361
+ val = tag
6362
+ loop do
6363
+ byte = val & 0x7F
6364
+
6365
+ val >>= 7
6366
+ # This drops the top bits,
6367
+ # Otherwise, with a signed right shift,
6368
+ # we get infinity one bits at the top
6369
+ val &= (1 << 57) - 1
6370
+
6371
+ byte |= 0x80 if val != 0
6372
+ unknown_bytes << byte
6373
+ break if val == 0
6374
+ end
6375
+
6076
6376
  case wire_type
6077
6377
  when 0
6078
6378
  i = 0
6079
6379
  while true
6080
6380
  newbyte = buff.getbyte(index)
6081
6381
  index += 1
6082
- break if newbyte.nil? || newbyte < 0x80
6382
+ break if newbyte.nil?
6383
+ unknown_bytes << newbyte
6384
+ break if newbyte < 0x80
6083
6385
  i += 1
6084
6386
  break if i > 9
6085
6387
  end
6086
6388
  when 1
6389
+ unknown_bytes << buff.byteslice(index, 8)
6087
6390
  index += 8
6088
6391
  when 2
6089
- ## PULL_BYTES
6090
6392
  value =
6091
6393
  if (byte0 = buff.getbyte(index)) < 0x80
6092
6394
  index += 1
@@ -6142,15 +6444,30 @@ module Api
6142
6444
  raise "integer decoding error"
6143
6445
  end
6144
6446
 
6145
- buff.byteslice(index, value)
6146
- index += value
6447
+ val = value
6448
+ loop do
6449
+ byte = val & 0x7F
6147
6450
 
6148
- ## END PULL_BYTES
6451
+ val >>= 7
6452
+ # This drops the top bits,
6453
+ # Otherwise, with a signed right shift,
6454
+ # we get infinity one bits at the top
6455
+ val &= (1 << 57) - 1
6456
+
6457
+ byte |= 0x80 if val != 0
6458
+ unknown_bytes << byte
6459
+ break if val == 0
6460
+ end
6461
+
6462
+ unknown_bytes << buff.byteslice(index, value)
6463
+ index += value
6149
6464
  when 5
6465
+ unknown_bytes << buff.byteslice(index, 4)
6150
6466
  index += 4
6151
6467
  else
6152
6468
  raise "unknown wire type #{wire_type}"
6153
6469
  end
6470
+ (@_unknown_fields ||= +"".b) << unknown_bytes
6154
6471
  return self if index >= len
6155
6472
  ## PULL_UINT64
6156
6473
  tag =
@@ -7981,25 +8298,112 @@ module Api
7981
8298
 
7982
8299
  buff
7983
8300
  end
7984
-
8301
+ buff << @_unknown_fields if @_unknown_fields
7985
8302
  buff
7986
8303
  end
7987
8304
 
7988
8305
  def to_h
7989
8306
  result = {}
7990
- result["height_map".to_sym] = @height_map.to_h
7991
- result["visibility_map".to_sym] = @visibility_map.to_h
7992
- result["creep".to_sym] = @creep.to_h
7993
- result["camera".to_sym] = @camera.to_h
7994
- result["player_id".to_sym] = @player_id.to_h
7995
- result["player_relative".to_sym] = @player_relative.to_h
7996
- result["selected".to_sym] = @selected.to_h
7997
- result["alerts".to_sym] = @alerts.to_h
7998
- result["buildable".to_sym] = @buildable.to_h
7999
- result["pathable".to_sym] = @pathable.to_h
8000
- result["unit_type".to_sym] = @unit_type.to_h
8307
+
8308
+ result[:"height_map"] = @height_map.to_h
8309
+ result[:"visibility_map"] = @visibility_map.to_h
8310
+ result[:"creep"] = @creep.to_h
8311
+ result[:"camera"] = @camera.to_h
8312
+ result[:"player_id"] = @player_id.to_h
8313
+ result[:"player_relative"] = @player_relative.to_h
8314
+ result[:"selected"] = @selected.to_h
8315
+ result[:"unit_type"] = @unit_type.to_h
8316
+ result[:"alerts"] = @alerts.to_h
8317
+ result[:"buildable"] = @buildable.to_h
8318
+ result[:"pathable"] = @pathable.to_h
8319
+
8320
+ result
8321
+ end
8322
+
8323
+ def as_json(options = {})
8324
+ result = {}
8325
+
8326
+ result["heightMap"] = (
8327
+ if @height_map.nil?
8328
+ {}
8329
+ else
8330
+ @height_map.as_json(options)
8331
+ end
8332
+ ) if !options[:compact] || has_height_map?
8333
+ result["visibilityMap"] = (
8334
+ if @visibility_map.nil?
8335
+ {}
8336
+ else
8337
+ @visibility_map.as_json(options)
8338
+ end
8339
+ ) if !options[:compact] || has_visibility_map?
8340
+ result["creep"] = @creep.nil? ? {} : @creep.as_json(options) if !options[
8341
+ :compact
8342
+ ] || has_creep?
8343
+ result["camera"] = (
8344
+ if @camera.nil?
8345
+ {}
8346
+ else
8347
+ @camera.as_json(options)
8348
+ end
8349
+ ) if !options[:compact] || has_camera?
8350
+ result["playerId"] = (
8351
+ if @player_id.nil?
8352
+ {}
8353
+ else
8354
+ @player_id.as_json(options)
8355
+ end
8356
+ ) if !options[:compact] || has_player_id?
8357
+ result["playerRelative"] = (
8358
+ if @player_relative.nil?
8359
+ {}
8360
+ else
8361
+ @player_relative.as_json(options)
8362
+ end
8363
+ ) if !options[:compact] || has_player_relative?
8364
+ result["selected"] = (
8365
+ if @selected.nil?
8366
+ {}
8367
+ else
8368
+ @selected.as_json(options)
8369
+ end
8370
+ ) if !options[:compact] || has_selected?
8371
+ result["unitType"] = (
8372
+ if @unit_type.nil?
8373
+ {}
8374
+ else
8375
+ @unit_type.as_json(options)
8376
+ end
8377
+ ) if !options[:compact] || has_unit_type?
8378
+ result["alerts"] = (
8379
+ if @alerts.nil?
8380
+ {}
8381
+ else
8382
+ @alerts.as_json(options)
8383
+ end
8384
+ ) if !options[:compact] || has_alerts?
8385
+ result["buildable"] = (
8386
+ if @buildable.nil?
8387
+ {}
8388
+ else
8389
+ @buildable.as_json(options)
8390
+ end
8391
+ ) if !options[:compact] || has_buildable?
8392
+ result["pathable"] = (
8393
+ if @pathable.nil?
8394
+ {}
8395
+ else
8396
+ @pathable.as_json(options)
8397
+ end
8398
+ ) if !options[:compact] || has_pathable?
8399
+
8001
8400
  result
8002
8401
  end
8402
+
8403
+ def to_json(as_json_options = {})
8404
+ require "json"
8405
+ JSON.dump(as_json(as_json_options))
8406
+ end
8003
8407
  end
8004
8408
  class ObservationRender
8005
8409
  def self.decode(buff)
@@ -8125,20 +8529,39 @@ module Api
8125
8529
  # unexpected, so discard it and continue.
8126
8530
  if !found
8127
8531
  wire_type = tag & 0x7
8532
+
8533
+ unknown_bytes = +"".b
8534
+ val = tag
8535
+ loop do
8536
+ byte = val & 0x7F
8537
+
8538
+ val >>= 7
8539
+ # This drops the top bits,
8540
+ # Otherwise, with a signed right shift,
8541
+ # we get infinity one bits at the top
8542
+ val &= (1 << 57) - 1
8543
+
8544
+ byte |= 0x80 if val != 0
8545
+ unknown_bytes << byte
8546
+ break if val == 0
8547
+ end
8548
+
8128
8549
  case wire_type
8129
8550
  when 0
8130
8551
  i = 0
8131
8552
  while true
8132
8553
  newbyte = buff.getbyte(index)
8133
8554
  index += 1
8134
- break if newbyte.nil? || newbyte < 0x80
8555
+ break if newbyte.nil?
8556
+ unknown_bytes << newbyte
8557
+ break if newbyte < 0x80
8135
8558
  i += 1
8136
8559
  break if i > 9
8137
8560
  end
8138
8561
  when 1
8562
+ unknown_bytes << buff.byteslice(index, 8)
8139
8563
  index += 8
8140
8564
  when 2
8141
- ## PULL_BYTES
8142
8565
  value =
8143
8566
  if (byte0 = buff.getbyte(index)) < 0x80
8144
8567
  index += 1
@@ -8194,15 +8617,30 @@ module Api
8194
8617
  raise "integer decoding error"
8195
8618
  end
8196
8619
 
8197
- buff.byteslice(index, value)
8198
- index += value
8620
+ val = value
8621
+ loop do
8622
+ byte = val & 0x7F
8199
8623
 
8200
- ## END PULL_BYTES
8624
+ val >>= 7
8625
+ # This drops the top bits,
8626
+ # Otherwise, with a signed right shift,
8627
+ # we get infinity one bits at the top
8628
+ val &= (1 << 57) - 1
8629
+
8630
+ byte |= 0x80 if val != 0
8631
+ unknown_bytes << byte
8632
+ break if val == 0
8633
+ end
8634
+
8635
+ unknown_bytes << buff.byteslice(index, value)
8636
+ index += value
8201
8637
  when 5
8638
+ unknown_bytes << buff.byteslice(index, 4)
8202
8639
  index += 4
8203
8640
  else
8204
8641
  raise "unknown wire type #{wire_type}"
8205
8642
  end
8643
+ (@_unknown_fields ||= +"".b) << unknown_bytes
8206
8644
  return self if index >= len
8207
8645
  ## PULL_UINT64
8208
8646
  tag =
@@ -8584,16 +9022,40 @@ module Api
8584
9022
 
8585
9023
  buff
8586
9024
  end
8587
-
9025
+ buff << @_unknown_fields if @_unknown_fields
8588
9026
  buff
8589
9027
  end
8590
9028
 
8591
9029
  def to_h
8592
9030
  result = {}
8593
- result["map".to_sym] = @map.to_h
8594
- result["minimap".to_sym] = @minimap.to_h
9031
+
9032
+ result[:"map"] = @map.to_h
9033
+ result[:"minimap"] = @minimap.to_h
9034
+
9035
+ result
9036
+ end
9037
+
9038
+ def as_json(options = {})
9039
+ result = {}
9040
+
9041
+ result["map"] = @map.nil? ? {} : @map.as_json(options) if !options[
9042
+ :compact
9043
+ ] || has_map?
9044
+ result["minimap"] = (
9045
+ if @minimap.nil?
9046
+ {}
9047
+ else
9048
+ @minimap.as_json(options)
9049
+ end
9050
+ ) if !options[:compact] || has_minimap?
9051
+
8595
9052
  result
8596
9053
  end
9054
+
9055
+ def to_json(as_json_options = {})
9056
+ require "json"
9057
+ JSON.dump(as_json(as_json_options))
9058
+ end
8597
9059
  end
8598
9060
  class ActionSpatial
8599
9061
  def self.decode(buff)
@@ -8745,20 +9207,39 @@ module Api
8745
9207
  # unexpected, so discard it and continue.
8746
9208
  if !found
8747
9209
  wire_type = tag & 0x7
9210
+
9211
+ unknown_bytes = +"".b
9212
+ val = tag
9213
+ loop do
9214
+ byte = val & 0x7F
9215
+
9216
+ val >>= 7
9217
+ # This drops the top bits,
9218
+ # Otherwise, with a signed right shift,
9219
+ # we get infinity one bits at the top
9220
+ val &= (1 << 57) - 1
9221
+
9222
+ byte |= 0x80 if val != 0
9223
+ unknown_bytes << byte
9224
+ break if val == 0
9225
+ end
9226
+
8748
9227
  case wire_type
8749
9228
  when 0
8750
9229
  i = 0
8751
9230
  while true
8752
9231
  newbyte = buff.getbyte(index)
8753
9232
  index += 1
8754
- break if newbyte.nil? || newbyte < 0x80
9233
+ break if newbyte.nil?
9234
+ unknown_bytes << newbyte
9235
+ break if newbyte < 0x80
8755
9236
  i += 1
8756
9237
  break if i > 9
8757
9238
  end
8758
9239
  when 1
9240
+ unknown_bytes << buff.byteslice(index, 8)
8759
9241
  index += 8
8760
9242
  when 2
8761
- ## PULL_BYTES
8762
9243
  value =
8763
9244
  if (byte0 = buff.getbyte(index)) < 0x80
8764
9245
  index += 1
@@ -8814,15 +9295,30 @@ module Api
8814
9295
  raise "integer decoding error"
8815
9296
  end
8816
9297
 
8817
- buff.byteslice(index, value)
8818
- index += value
9298
+ val = value
9299
+ loop do
9300
+ byte = val & 0x7F
9301
+
9302
+ val >>= 7
9303
+ # This drops the top bits,
9304
+ # Otherwise, with a signed right shift,
9305
+ # we get infinity one bits at the top
9306
+ val &= (1 << 57) - 1
8819
9307
 
8820
- ## END PULL_BYTES
9308
+ byte |= 0x80 if val != 0
9309
+ unknown_bytes << byte
9310
+ break if val == 0
9311
+ end
9312
+
9313
+ unknown_bytes << buff.byteslice(index, value)
9314
+ index += value
8821
9315
  when 5
9316
+ unknown_bytes << buff.byteslice(index, 4)
8822
9317
  index += 4
8823
9318
  else
8824
9319
  raise "unknown wire type #{wire_type}"
8825
9320
  end
9321
+ (@_unknown_fields ||= +"".b) << unknown_bytes
8826
9322
  return self if index >= len
8827
9323
  ## PULL_UINT64
8828
9324
  tag =
@@ -9542,15 +10038,71 @@ module Api
9542
10038
 
9543
10039
  buff
9544
10040
  end
9545
-
10041
+ buff << @_unknown_fields if @_unknown_fields
9546
10042
  buff
9547
10043
  end
9548
10044
 
9549
10045
  def to_h
9550
10046
  result = {}
9551
- send("action").tap { |f| result[f.to_sym] = send(f) if f }
10047
+
10048
+ resolved_action = self.action
10049
+
10050
+ result[:"unit_command"] = @unit_command.to_h if resolved_action ==
10051
+ :"unit_command"
10052
+ result[:"camera_move"] = @camera_move.to_h if resolved_action ==
10053
+ :"camera_move"
10054
+ result[
10055
+ :"unit_selection_point"
10056
+ ] = @unit_selection_point.to_h if resolved_action ==
10057
+ :"unit_selection_point"
10058
+ result[
10059
+ :"unit_selection_rect"
10060
+ ] = @unit_selection_rect.to_h if resolved_action == :"unit_selection_rect"
10061
+
10062
+ result
10063
+ end
10064
+
10065
+ def as_json(options = {})
10066
+ result = {}
10067
+
10068
+ resolved_action = self.action
10069
+
10070
+ result["unitCommand"] = (
10071
+ if @unit_command.nil?
10072
+ {}
10073
+ else
10074
+ @unit_command.as_json(options)
10075
+ end
10076
+ ) if resolved_action == :"unit_command"
10077
+ result["cameraMove"] = (
10078
+ if @camera_move.nil?
10079
+ {}
10080
+ else
10081
+ @camera_move.as_json(options)
10082
+ end
10083
+ ) if resolved_action == :"camera_move"
10084
+ result["unitSelectionPoint"] = (
10085
+ if @unit_selection_point.nil?
10086
+ {}
10087
+ else
10088
+ @unit_selection_point.as_json(options)
10089
+ end
10090
+ ) if resolved_action == :"unit_selection_point"
10091
+ result["unitSelectionRect"] = (
10092
+ if @unit_selection_rect.nil?
10093
+ {}
10094
+ else
10095
+ @unit_selection_rect.as_json(options)
10096
+ end
10097
+ ) if resolved_action == :"unit_selection_rect"
10098
+
9552
10099
  result
9553
10100
  end
10101
+
10102
+ def to_json(as_json_options = {})
10103
+ require "json"
10104
+ JSON.dump(as_json(as_json_options))
10105
+ end
9554
10106
  end
9555
10107
  class ActionSpatialUnitCommand
9556
10108
  def self.decode(buff)
@@ -9728,20 +10280,39 @@ module Api
9728
10280
  # unexpected, so discard it and continue.
9729
10281
  if !found
9730
10282
  wire_type = tag & 0x7
10283
+
10284
+ unknown_bytes = +"".b
10285
+ val = tag
10286
+ loop do
10287
+ byte = val & 0x7F
10288
+
10289
+ val >>= 7
10290
+ # This drops the top bits,
10291
+ # Otherwise, with a signed right shift,
10292
+ # we get infinity one bits at the top
10293
+ val &= (1 << 57) - 1
10294
+
10295
+ byte |= 0x80 if val != 0
10296
+ unknown_bytes << byte
10297
+ break if val == 0
10298
+ end
10299
+
9731
10300
  case wire_type
9732
10301
  when 0
9733
10302
  i = 0
9734
10303
  while true
9735
10304
  newbyte = buff.getbyte(index)
9736
10305
  index += 1
9737
- break if newbyte.nil? || newbyte < 0x80
10306
+ break if newbyte.nil?
10307
+ unknown_bytes << newbyte
10308
+ break if newbyte < 0x80
9738
10309
  i += 1
9739
10310
  break if i > 9
9740
10311
  end
9741
10312
  when 1
10313
+ unknown_bytes << buff.byteslice(index, 8)
9742
10314
  index += 8
9743
10315
  when 2
9744
- ## PULL_BYTES
9745
10316
  value =
9746
10317
  if (byte0 = buff.getbyte(index)) < 0x80
9747
10318
  index += 1
@@ -9797,15 +10368,30 @@ module Api
9797
10368
  raise "integer decoding error"
9798
10369
  end
9799
10370
 
9800
- buff.byteslice(index, value)
9801
- index += value
10371
+ val = value
10372
+ loop do
10373
+ byte = val & 0x7F
10374
+
10375
+ val >>= 7
10376
+ # This drops the top bits,
10377
+ # Otherwise, with a signed right shift,
10378
+ # we get infinity one bits at the top
10379
+ val &= (1 << 57) - 1
9802
10380
 
9803
- ## END PULL_BYTES
10381
+ byte |= 0x80 if val != 0
10382
+ unknown_bytes << byte
10383
+ break if val == 0
10384
+ end
10385
+
10386
+ unknown_bytes << buff.byteslice(index, value)
10387
+ index += value
9804
10388
  when 5
10389
+ unknown_bytes << buff.byteslice(index, 4)
9805
10390
  index += 4
9806
10391
  else
9807
10392
  raise "unknown wire type #{wire_type}"
9808
10393
  end
10394
+ (@_unknown_fields ||= +"".b) << unknown_bytes
9809
10395
  return self if index >= len
9810
10396
  ## PULL_UINT64
9811
10397
  tag =
@@ -10274,10 +10860,10 @@ module Api
10274
10860
  end
10275
10861
  def _encode(buff)
10276
10862
  val = @ability_id
10277
- if val != 0
10863
+ if has_ability_id?
10278
10864
  buff << 0x08
10279
10865
 
10280
- while val != 0
10866
+ loop do
10281
10867
  byte = val & 0x7F
10282
10868
 
10283
10869
  val >>= 7
@@ -10288,6 +10874,7 @@ module Api
10288
10874
 
10289
10875
  byte |= 0x80 if val != 0
10290
10876
  buff << byte
10877
+ break if val == 0
10291
10878
  end
10292
10879
  end
10293
10880
 
@@ -10387,27 +10974,68 @@ module Api
10387
10974
  buff
10388
10975
  end
10389
10976
 
10390
- val = @queue_command
10391
- if val == true
10977
+ if has_queue_command?
10978
+ val = @queue_command
10392
10979
  buff << 0x20
10393
10980
 
10394
- buff << 1
10395
- elsif val == false
10396
- # Default value, encode nothing
10397
- else
10398
- raise "bool values should be true or false"
10981
+ if val == true
10982
+ buff << 1
10983
+ elsif val == false
10984
+ buff << 0
10985
+ end
10399
10986
  end
10400
-
10987
+ buff << @_unknown_fields if @_unknown_fields
10401
10988
  buff
10402
10989
  end
10403
10990
 
10404
10991
  def to_h
10405
10992
  result = {}
10406
- send("target").tap { |f| result[f.to_sym] = send(f) if f }
10407
- result["ability_id".to_sym] = @ability_id
10408
- result["queue_command".to_sym] = @queue_command
10993
+
10994
+ resolved_target = self.target
10995
+
10996
+ result[:"ability_id"] = @ability_id
10997
+ result[
10998
+ :"target_screen_coord"
10999
+ ] = @target_screen_coord.to_h if resolved_target == :"target_screen_coord"
11000
+ result[
11001
+ :"target_minimap_coord"
11002
+ ] = @target_minimap_coord.to_h if resolved_target ==
11003
+ :"target_minimap_coord"
11004
+ result[:"queue_command"] = @queue_command
11005
+
11006
+ result
11007
+ end
11008
+
11009
+ def as_json(options = {})
11010
+ result = {}
11011
+
11012
+ resolved_target = self.target
11013
+
11014
+ result["abilityId"] = @ability_id if !options[:compact] || has_ability_id?
11015
+ result["targetScreenCoord"] = (
11016
+ if @target_screen_coord.nil?
11017
+ {}
11018
+ else
11019
+ @target_screen_coord.as_json(options)
11020
+ end
11021
+ ) if resolved_target == :"target_screen_coord"
11022
+ result["targetMinimapCoord"] = (
11023
+ if @target_minimap_coord.nil?
11024
+ {}
11025
+ else
11026
+ @target_minimap_coord.as_json(options)
11027
+ end
11028
+ ) if resolved_target == :"target_minimap_coord"
11029
+ result["queueCommand"] = @queue_command if !options[:compact] ||
11030
+ has_queue_command?
11031
+
10409
11032
  result
10410
11033
  end
11034
+
11035
+ def to_json(as_json_options = {})
11036
+ require "json"
11037
+ JSON.dump(as_json(as_json_options))
11038
+ end
10411
11039
  end
10412
11040
  class ActionSpatialCameraMove
10413
11041
  def self.decode(buff)
@@ -10514,20 +11142,39 @@ module Api
10514
11142
  # unexpected, so discard it and continue.
10515
11143
  if !found
10516
11144
  wire_type = tag & 0x7
11145
+
11146
+ unknown_bytes = +"".b
11147
+ val = tag
11148
+ loop do
11149
+ byte = val & 0x7F
11150
+
11151
+ val >>= 7
11152
+ # This drops the top bits,
11153
+ # Otherwise, with a signed right shift,
11154
+ # we get infinity one bits at the top
11155
+ val &= (1 << 57) - 1
11156
+
11157
+ byte |= 0x80 if val != 0
11158
+ unknown_bytes << byte
11159
+ break if val == 0
11160
+ end
11161
+
10517
11162
  case wire_type
10518
11163
  when 0
10519
11164
  i = 0
10520
11165
  while true
10521
11166
  newbyte = buff.getbyte(index)
10522
11167
  index += 1
10523
- break if newbyte.nil? || newbyte < 0x80
11168
+ break if newbyte.nil?
11169
+ unknown_bytes << newbyte
11170
+ break if newbyte < 0x80
10524
11171
  i += 1
10525
11172
  break if i > 9
10526
11173
  end
10527
11174
  when 1
11175
+ unknown_bytes << buff.byteslice(index, 8)
10528
11176
  index += 8
10529
11177
  when 2
10530
- ## PULL_BYTES
10531
11178
  value =
10532
11179
  if (byte0 = buff.getbyte(index)) < 0x80
10533
11180
  index += 1
@@ -10583,15 +11230,30 @@ module Api
10583
11230
  raise "integer decoding error"
10584
11231
  end
10585
11232
 
10586
- buff.byteslice(index, value)
10587
- index += value
11233
+ val = value
11234
+ loop do
11235
+ byte = val & 0x7F
11236
+
11237
+ val >>= 7
11238
+ # This drops the top bits,
11239
+ # Otherwise, with a signed right shift,
11240
+ # we get infinity one bits at the top
11241
+ val &= (1 << 57) - 1
10588
11242
 
10589
- ## END PULL_BYTES
11243
+ byte |= 0x80 if val != 0
11244
+ unknown_bytes << byte
11245
+ break if val == 0
11246
+ end
11247
+
11248
+ unknown_bytes << buff.byteslice(index, value)
11249
+ index += value
10590
11250
  when 5
11251
+ unknown_bytes << buff.byteslice(index, 4)
10591
11252
  index += 4
10592
11253
  else
10593
11254
  raise "unknown wire type #{wire_type}"
10594
11255
  end
11256
+ (@_unknown_fields ||= +"".b) << unknown_bytes
10595
11257
  return self if index >= len
10596
11258
  ## PULL_UINT64
10597
11259
  tag =
@@ -10812,15 +11474,36 @@ module Api
10812
11474
 
10813
11475
  buff
10814
11476
  end
10815
-
11477
+ buff << @_unknown_fields if @_unknown_fields
10816
11478
  buff
10817
11479
  end
10818
11480
 
10819
11481
  def to_h
10820
11482
  result = {}
10821
- result["center_minimap".to_sym] = @center_minimap.to_h
11483
+
11484
+ result[:"center_minimap"] = @center_minimap.to_h
11485
+
11486
+ result
11487
+ end
11488
+
11489
+ def as_json(options = {})
11490
+ result = {}
11491
+
11492
+ result["centerMinimap"] = (
11493
+ if @center_minimap.nil?
11494
+ {}
11495
+ else
11496
+ @center_minimap.as_json(options)
11497
+ end
11498
+ ) if !options[:compact] || has_center_minimap?
11499
+
10822
11500
  result
10823
11501
  end
11502
+
11503
+ def to_json(as_json_options = {})
11504
+ require "json"
11505
+ JSON.dump(as_json(as_json_options))
11506
+ end
10824
11507
  end
10825
11508
  class ActionSpatialUnitSelectionPoint
10826
11509
  def self.decode(buff)
@@ -10838,31 +11521,19 @@ module Api
10838
11521
  ADD_ALL_TYPE = 4
10839
11522
 
10840
11523
  def self.lookup(val)
10841
- if val == 0
10842
- :ENUM_ACTION_SPATIAL_UNIT_SELECTION_POINT_TYPE_UNSET
10843
- elsif val == 1
10844
- :SELECT
10845
- elsif val == 2
10846
- :TOGGLE
10847
- elsif val == 3
10848
- :ALL_TYPE
10849
- elsif val == 4
10850
- :ADD_ALL_TYPE
10851
- end
11524
+ return :ENUM_ACTION_SPATIAL_UNIT_SELECTION_POINT_TYPE_UNSET if val == 0
11525
+ return :SELECT if val == 1
11526
+ return :TOGGLE if val == 2
11527
+ return :ALL_TYPE if val == 3
11528
+ return :ADD_ALL_TYPE if val == 4
10852
11529
  end
10853
11530
 
10854
11531
  def self.resolve(val)
10855
- if val == :ENUM_ACTION_SPATIAL_UNIT_SELECTION_POINT_TYPE_UNSET
10856
- 0
10857
- elsif val == :SELECT
10858
- 1
10859
- elsif val == :TOGGLE
10860
- 2
10861
- elsif val == :ALL_TYPE
10862
- 3
10863
- elsif val == :ADD_ALL_TYPE
10864
- 4
10865
- end
11532
+ return 0 if val == :ENUM_ACTION_SPATIAL_UNIT_SELECTION_POINT_TYPE_UNSET
11533
+ return 1 if val == :SELECT
11534
+ return 2 if val == :TOGGLE
11535
+ return 3 if val == :ALL_TYPE
11536
+ return 4 if val == :ADD_ALL_TYPE
10866
11537
  end
10867
11538
  end
10868
11539
  # required field readers
@@ -10878,6 +11549,7 @@ module Api
10878
11549
  # enum writers
10879
11550
  def type=(v)
10880
11551
  @type = Api::ActionSpatialUnitSelectionPoint::Type.resolve(v) || v
11552
+ @_bitmask |= 0x0000000000000002
10881
11553
  end
10882
11554
 
10883
11555
  # BEGIN writers for optional fields
@@ -10914,6 +11586,10 @@ module Api
10914
11586
  (@_bitmask & 0x0000000000000001) == 0x0000000000000001
10915
11587
  end
10916
11588
 
11589
+ def has_type?
11590
+ (@_bitmask & 0x0000000000000002) == 0x0000000000000002
11591
+ end
11592
+
10917
11593
  def decode_from(buff, index, len)
10918
11594
  @_bitmask = 0
10919
11595
 
@@ -10979,20 +11655,39 @@ module Api
10979
11655
  # unexpected, so discard it and continue.
10980
11656
  if !found
10981
11657
  wire_type = tag & 0x7
11658
+
11659
+ unknown_bytes = +"".b
11660
+ val = tag
11661
+ loop do
11662
+ byte = val & 0x7F
11663
+
11664
+ val >>= 7
11665
+ # This drops the top bits,
11666
+ # Otherwise, with a signed right shift,
11667
+ # we get infinity one bits at the top
11668
+ val &= (1 << 57) - 1
11669
+
11670
+ byte |= 0x80 if val != 0
11671
+ unknown_bytes << byte
11672
+ break if val == 0
11673
+ end
11674
+
10982
11675
  case wire_type
10983
11676
  when 0
10984
11677
  i = 0
10985
11678
  while true
10986
11679
  newbyte = buff.getbyte(index)
10987
11680
  index += 1
10988
- break if newbyte.nil? || newbyte < 0x80
11681
+ break if newbyte.nil?
11682
+ unknown_bytes << newbyte
11683
+ break if newbyte < 0x80
10989
11684
  i += 1
10990
11685
  break if i > 9
10991
11686
  end
10992
11687
  when 1
11688
+ unknown_bytes << buff.byteslice(index, 8)
10993
11689
  index += 8
10994
11690
  when 2
10995
- ## PULL_BYTES
10996
11691
  value =
10997
11692
  if (byte0 = buff.getbyte(index)) < 0x80
10998
11693
  index += 1
@@ -11048,15 +11743,30 @@ module Api
11048
11743
  raise "integer decoding error"
11049
11744
  end
11050
11745
 
11051
- buff.byteslice(index, value)
11052
- index += value
11746
+ val = value
11747
+ loop do
11748
+ byte = val & 0x7F
11053
11749
 
11054
- ## END PULL_BYTES
11750
+ val >>= 7
11751
+ # This drops the top bits,
11752
+ # Otherwise, with a signed right shift,
11753
+ # we get infinity one bits at the top
11754
+ val &= (1 << 57) - 1
11755
+
11756
+ byte |= 0x80 if val != 0
11757
+ unknown_bytes << byte
11758
+ break if val == 0
11759
+ end
11760
+
11761
+ unknown_bytes << buff.byteslice(index, value)
11762
+ index += value
11055
11763
  when 5
11764
+ unknown_bytes << buff.byteslice(index, 4)
11056
11765
  index += 4
11057
11766
  else
11058
11767
  raise "unknown wire type #{wire_type}"
11059
11768
  end
11769
+ (@_unknown_fields ||= +"".b) << unknown_bytes
11060
11770
  return self if index >= len
11061
11771
  ## PULL_UINT64
11062
11772
  tag =
@@ -11399,10 +12109,10 @@ module Api
11399
12109
  end
11400
12110
 
11401
12111
  val = @type
11402
- if val != 0
12112
+ if has_type?
11403
12113
  buff << 0x10
11404
12114
 
11405
- while val != 0
12115
+ loop do
11406
12116
  byte = val & 0x7F
11407
12117
 
11408
12118
  val >>= 7
@@ -11413,18 +12123,41 @@ module Api
11413
12123
 
11414
12124
  byte |= 0x80 if val != 0
11415
12125
  buff << byte
12126
+ break if val == 0
11416
12127
  end
11417
12128
  end
11418
-
12129
+ buff << @_unknown_fields if @_unknown_fields
11419
12130
  buff
11420
12131
  end
11421
12132
 
11422
12133
  def to_h
11423
12134
  result = {}
11424
- result["selection_screen_coord".to_sym] = @selection_screen_coord.to_h
11425
- result["type".to_sym] = @type
12135
+
12136
+ result[:"selection_screen_coord"] = @selection_screen_coord.to_h
12137
+ result[:"type"] = @type
12138
+
12139
+ result
12140
+ end
12141
+
12142
+ def as_json(options = {})
12143
+ result = {}
12144
+
12145
+ result["selectionScreenCoord"] = (
12146
+ if @selection_screen_coord.nil?
12147
+ {}
12148
+ else
12149
+ @selection_screen_coord.as_json(options)
12150
+ end
12151
+ ) if !options[:compact] || has_selection_screen_coord?
12152
+ result["type"] = @type if !options[:compact] || has_type?
12153
+
11426
12154
  result
11427
12155
  end
12156
+
12157
+ def to_json(as_json_options = {})
12158
+ require "json"
12159
+ JSON.dump(as_json(as_json_options))
12160
+ end
11428
12161
  end
11429
12162
  class ActionSpatialUnitSelectionRect
11430
12163
  def self.decode(buff)
@@ -11540,20 +12273,39 @@ module Api
11540
12273
  # unexpected, so discard it and continue.
11541
12274
  if !found
11542
12275
  wire_type = tag & 0x7
12276
+
12277
+ unknown_bytes = +"".b
12278
+ val = tag
12279
+ loop do
12280
+ byte = val & 0x7F
12281
+
12282
+ val >>= 7
12283
+ # This drops the top bits,
12284
+ # Otherwise, with a signed right shift,
12285
+ # we get infinity one bits at the top
12286
+ val &= (1 << 57) - 1
12287
+
12288
+ byte |= 0x80 if val != 0
12289
+ unknown_bytes << byte
12290
+ break if val == 0
12291
+ end
12292
+
11543
12293
  case wire_type
11544
12294
  when 0
11545
12295
  i = 0
11546
12296
  while true
11547
12297
  newbyte = buff.getbyte(index)
11548
12298
  index += 1
11549
- break if newbyte.nil? || newbyte < 0x80
12299
+ break if newbyte.nil?
12300
+ unknown_bytes << newbyte
12301
+ break if newbyte < 0x80
11550
12302
  i += 1
11551
12303
  break if i > 9
11552
12304
  end
11553
12305
  when 1
12306
+ unknown_bytes << buff.byteslice(index, 8)
11554
12307
  index += 8
11555
12308
  when 2
11556
- ## PULL_BYTES
11557
12309
  value =
11558
12310
  if (byte0 = buff.getbyte(index)) < 0x80
11559
12311
  index += 1
@@ -11609,15 +12361,30 @@ module Api
11609
12361
  raise "integer decoding error"
11610
12362
  end
11611
12363
 
11612
- buff.byteslice(index, value)
11613
- index += value
12364
+ val = value
12365
+ loop do
12366
+ byte = val & 0x7F
12367
+
12368
+ val >>= 7
12369
+ # This drops the top bits,
12370
+ # Otherwise, with a signed right shift,
12371
+ # we get infinity one bits at the top
12372
+ val &= (1 << 57) - 1
11614
12373
 
11615
- ## END PULL_BYTES
12374
+ byte |= 0x80 if val != 0
12375
+ unknown_bytes << byte
12376
+ break if val == 0
12377
+ end
12378
+
12379
+ unknown_bytes << buff.byteslice(index, value)
12380
+ index += value
11616
12381
  when 5
12382
+ unknown_bytes << buff.byteslice(index, 4)
11617
12383
  index += 4
11618
12384
  else
11619
12385
  raise "unknown wire type #{wire_type}"
11620
12386
  end
12387
+ (@_unknown_fields ||= +"".b) << unknown_bytes
11621
12388
  return self if index >= len
11622
12389
  ## PULL_UINT64
11623
12390
  tag =
@@ -11928,25 +12695,48 @@ module Api
11928
12695
  end
11929
12696
  end
11930
12697
 
11931
- val = @selection_add
11932
- if val == true
12698
+ if has_selection_add?
12699
+ val = @selection_add
11933
12700
  buff << 0x10
11934
12701
 
11935
- buff << 1
11936
- elsif val == false
11937
- # Default value, encode nothing
11938
- else
11939
- raise "bool values should be true or false"
12702
+ if val == true
12703
+ buff << 1
12704
+ elsif val == false
12705
+ buff << 0
12706
+ end
11940
12707
  end
11941
-
12708
+ buff << @_unknown_fields if @_unknown_fields
11942
12709
  buff
11943
12710
  end
11944
12711
 
11945
12712
  def to_h
11946
12713
  result = {}
11947
- result["selection_screen_coord".to_sym] = @selection_screen_coord
11948
- result["selection_add".to_sym] = @selection_add
12714
+
12715
+ result[:"selection_screen_coord"] = @selection_screen_coord.map(&:to_h)
12716
+ result[:"selection_add"] = @selection_add
12717
+
12718
+ result
12719
+ end
12720
+
12721
+ def as_json(options = {})
12722
+ result = {}
12723
+
12724
+ tmp_selection_screen_coord =
12725
+ @selection_screen_coord.map { |v| v.as_json(options) }
12726
+
12727
+ result["selectionScreenCoord"] = tmp_selection_screen_coord if !options[
12728
+ :compact
12729
+ ] || tmp_selection_screen_coord.any?
12730
+
12731
+ result["selectionAdd"] = @selection_add if !options[:compact] ||
12732
+ has_selection_add?
12733
+
11949
12734
  result
11950
12735
  end
12736
+
12737
+ def to_json(as_json_options = {})
12738
+ require "json"
12739
+ JSON.dump(as_json(as_json_options))
12740
+ end
11951
12741
  end
11952
12742
  end