47957
47958
47959
47960
47961
47962
47963
47964
47965
47966
47967
47968
47969
47970
47971
47972
47973
47974
47975
47976
47977
47978
47979
47980
47981
47982
47983
47984
47985
47986
47987
47988
47989
47990
47991
47992
47993
47994
47995
47996
47997
47998
47999
48000
48001
48002
48003
48004
48005
48006
48007
48008
48009
48010
48011
48012
48013
48014
48015
48016
48017
48018
48019
48020
48021
48022
48023
48024
48025
48026
48027
48028
48029
48030
48031
48032
48033
48034
48035
48036
48037
48038
48039
48040
48041
48042
48043
48044
48045
48046
48047
48048
48049
48050
48051
48052
48053
48054
48055
48056
48057
48058
48059
48060
48061
48062
48063
48064
48065
48066
48067
48068
48069
48070
48071
48072
48073
48074
48075
48076
48077
48078
48079
48080
48081
48082
48083
48084
48085
48086
48087
48088
48089
48090
48091
48092
48093
48094
48095
48096
48097
48098
48099
48100
48101
48102
48103
48104
48105
48106
48107
48108
48109
48110
48111
48112
48113
48114
48115
48116
48117
48118
48119
48120
48121
48122
48123
48124
48125
48126
48127
48128
48129
48130
48131
48132
48133
48134
48135
48136
48137
48138
48139
48140
48141
48142
48143
48144
48145
48146
48147
48148
48149
48150
48151
48152
48153
48154
48155
48156
48157
48158
48159
48160
48161
48162
48163
48164
48165
48166
48167
48168
48169
48170
48171
48172
48173
48174
48175
48176
48177
48178
48179
48180
48181
48182
48183
48184
48185
48186
48187
48188
48189
48190
48191
48192
48193
48194
48195
48196
48197
48198
48199
48200
48201
48202
48203
48204
48205
48206
48207
48208
48209
48210
48211
48212
48213
48214
48215
48216
48217
48218
48219
48220
48221
48222
48223
48224
48225
48226
48227
48228
48229
48230
48231
48232
48233
48234
48235
48236
48237
48238
48239
48240
48241
48242
48243
48244
48245
48246
48247
48248
48249
48250
48251
48252
48253
48254
48255
48256
48257
48258
48259
48260
48261
48262
48263
48264
48265
48266
48267
48268
48269
48270
48271
48272
48273
48274
48275
48276
48277
48278
48279
48280
48281
48282
48283
48284
48285
48286
48287
48288
48289
48290
48291
48292
48293
48294
48295
48296
48297
48298
48299
48300
48301
48302
48303
48304
48305
48306
48307
48308
48309
48310
48311
48312
48313
48314
48315
48316
48317
48318
48319
48320
48321
48322
48323
48324
48325
48326
48327
48328
48329
48330
48331
48332
48333
48334
48335
48336
48337
48338
48339
48340
48341
48342
48343
48344
48345
48346
48347
48348
48349
48350
48351
48352
48353
48354
48355
48356
48357
48358
48359
48360
48361
48362
48363
48364
48365
48366
48367
48368
48369
48370
48371
48372
48373
48374
48375
48376
48377
48378
48379
48380
48381
48382
48383
48384
48385
48386
|
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 47957
def decode_from(buff, index, len)
@_bitmask = 0
@player_id = 0
@result = 0
return self if index >= len
tag =
if (byte0 = buff.getbyte(index)) < 0x80
index += 1
byte0
elsif (byte1 = buff.getbyte(index + 1)) < 0x80
index += 2
(byte1 << 7) | (byte0 & 0x7F)
elsif (byte2 = buff.getbyte(index + 2)) < 0x80
index += 3
(byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte3 = buff.getbyte(index + 3)) < 0x80
index += 4
(byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
(byte0 & 0x7F)
elsif (byte4 = buff.getbyte(index + 4)) < 0x80
index += 5
(byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte5 = buff.getbyte(index + 5)) < 0x80
index += 6
(byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte6 = buff.getbyte(index + 6)) < 0x80
index += 7
(byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte7 = buff.getbyte(index + 7)) < 0x80
index += 8
(byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte8 = buff.getbyte(index + 8)) < 0x80
index += 9
(byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte9 = buff.getbyte(index + 9)) < 0x80
index += 10
(byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
else
raise "integer decoding error"
end
found = true
while true
if !found
wire_type = tag & 0x7
case wire_type
when 0
i = 0
while true
newbyte = buff.getbyte(index)
index += 1
break if newbyte.nil? || newbyte < 0x80
i += 1
break if i > 9
end
when 1
index += 8
when 2
value =
if (byte0 = buff.getbyte(index)) < 0x80
index += 1
byte0
elsif (byte1 = buff.getbyte(index + 1)) < 0x80
index += 2
(byte1 << 7) | (byte0 & 0x7F)
elsif (byte2 = buff.getbyte(index + 2)) < 0x80
index += 3
(byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte3 = buff.getbyte(index + 3)) < 0x80
index += 4
(byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
(byte0 & 0x7F)
elsif (byte4 = buff.getbyte(index + 4)) < 0x80
index += 5
(byte4 << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
(byte0 & 0x7F)
elsif (byte5 = buff.getbyte(index + 5)) < 0x80
index += 6
(byte5 << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte6 = buff.getbyte(index + 6)) < 0x80
index += 7
(byte6 << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
(byte0 & 0x7F)
elsif (byte7 = buff.getbyte(index + 7)) < 0x80
index += 8
(byte7 << 49) | ((byte6 & 0x7F) << 42) |
((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte8 = buff.getbyte(index + 8)) < 0x80
index += 9
(byte8 << 56) | ((byte7 & 0x7F) << 49) |
((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
(byte0 & 0x7F)
elsif (byte9 = buff.getbyte(index + 9)) < 0x80
index += 10
(byte9 << 63) | ((byte8 & 0x7F) << 56) |
((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
else
raise "integer decoding error"
end
buff.byteslice(index, value)
index += value
when 5
index += 4
else
raise "unknown wire type #{wire_type}"
end
return self if index >= len
tag =
if (byte0 = buff.getbyte(index)) < 0x80
index += 1
byte0
elsif (byte1 = buff.getbyte(index + 1)) < 0x80
index += 2
(byte1 << 7) | (byte0 & 0x7F)
elsif (byte2 = buff.getbyte(index + 2)) < 0x80
index += 3
(byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte3 = buff.getbyte(index + 3)) < 0x80
index += 4
(byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
(byte0 & 0x7F)
elsif (byte4 = buff.getbyte(index + 4)) < 0x80
index += 5
(byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte5 = buff.getbyte(index + 5)) < 0x80
index += 6
(byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte6 = buff.getbyte(index + 6)) < 0x80
index += 7
(byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte7 = buff.getbyte(index + 7)) < 0x80
index += 8
(byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte8 = buff.getbyte(index + 8)) < 0x80
index += 9
(byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte9 = buff.getbyte(index + 9)) < 0x80
index += 10
(byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
else
raise "integer decoding error"
end
end
found = false
if tag == 0x8
found = true
@player_id =
if (byte0 = buff.getbyte(index)) < 0x80
index += 1
byte0
elsif (byte1 = buff.getbyte(index + 1)) < 0x80
index += 2
(byte1 << 7) | (byte0 & 0x7F)
elsif (byte2 = buff.getbyte(index + 2)) < 0x80
index += 3
(byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte3 = buff.getbyte(index + 3)) < 0x80
index += 4
(byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
(byte0 & 0x7F)
elsif (byte4 = buff.getbyte(index + 4)) < 0x80
index += 5
(byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte5 = buff.getbyte(index + 5)) < 0x80
index += 6
(byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte6 = buff.getbyte(index + 6)) < 0x80
index += 7
(byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte7 = buff.getbyte(index + 7)) < 0x80
index += 8
(byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte8 = buff.getbyte(index + 8)) < 0x80
index += 9
(byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte9 = buff.getbyte(index + 9)) < 0x80
index += 10
(byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
else
raise "integer decoding error"
end
@_bitmask |= 0x0000000000000001
return self if index >= len
tag =
if (byte0 = buff.getbyte(index)) < 0x80
index += 1
byte0
elsif (byte1 = buff.getbyte(index + 1)) < 0x80
index += 2
(byte1 << 7) | (byte0 & 0x7F)
elsif (byte2 = buff.getbyte(index + 2)) < 0x80
index += 3
(byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte3 = buff.getbyte(index + 3)) < 0x80
index += 4
(byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
(byte0 & 0x7F)
elsif (byte4 = buff.getbyte(index + 4)) < 0x80
index += 5
(byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte5 = buff.getbyte(index + 5)) < 0x80
index += 6
(byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte6 = buff.getbyte(index + 6)) < 0x80
index += 7
(byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte7 = buff.getbyte(index + 7)) < 0x80
index += 8
(byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte8 = buff.getbyte(index + 8)) < 0x80
index += 9
(byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte9 = buff.getbyte(index + 9)) < 0x80
index += 10
(byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
else
raise "integer decoding error"
end
end
if tag == 0x10
found = true
@result =
if (byte0 = buff.getbyte(index)) < 0x80
index += 1
byte0
elsif (byte1 = buff.getbyte(index + 1)) < 0x80
index += 2
(byte1 << 7) | (byte0 & 0x7F)
elsif (byte2 = buff.getbyte(index + 2)) < 0x80
index += 3
(byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte3 = buff.getbyte(index + 3)) < 0x80
index += 4
(byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
(byte0 & 0x7F)
elsif (byte4 = buff.getbyte(index + 4)) < 0x80
index += 5
(byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte5 = buff.getbyte(index + 5)) < 0x80
index += 6
(byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte6 = buff.getbyte(index + 6)) < 0x80
index += 7
(byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte7 = buff.getbyte(index + 7)) < 0x80
index += 8
(byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte8 = buff.getbyte(index + 8)) < 0x80
index += 9
(byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte9 = buff.getbyte(index + 9)) < 0x80
index += 10
-(
(
(
~(
(byte9 << 63) | ((byte8 & 0x7F) << 56) |
((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
)
) & 0xFFFF_FFFF_FFFF_FFFF
) + 1
)
else
raise "integer decoding error"
end
@_bitmask |= 0x0000000000000002
return self if index >= len
tag =
if (byte0 = buff.getbyte(index)) < 0x80
index += 1
byte0
elsif (byte1 = buff.getbyte(index + 1)) < 0x80
index += 2
(byte1 << 7) | (byte0 & 0x7F)
elsif (byte2 = buff.getbyte(index + 2)) < 0x80
index += 3
(byte2 << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte3 = buff.getbyte(index + 3)) < 0x80
index += 4
(byte3 << 21) | ((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) |
(byte0 & 0x7F)
elsif (byte4 = buff.getbyte(index + 4)) < 0x80
index += 5
(byte4 << 28) | ((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte5 = buff.getbyte(index + 5)) < 0x80
index += 6
(byte5 << 35) | ((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte6 = buff.getbyte(index + 6)) < 0x80
index += 7
(byte6 << 42) | ((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte7 = buff.getbyte(index + 7)) < 0x80
index += 8
(byte7 << 49) | ((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte8 = buff.getbyte(index + 8)) < 0x80
index += 9
(byte8 << 56) | ((byte7 & 0x7F) << 49) | ((byte6 & 0x7F) << 42) |
((byte5 & 0x7F) << 35) | ((byte4 & 0x7F) << 28) |
((byte3 & 0x7F) << 21) | ((byte2 & 0x7F) << 14) |
((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
elsif (byte9 = buff.getbyte(index + 9)) < 0x80
index += 10
(byte9 << 63) | ((byte8 & 0x7F) << 56) | ((byte7 & 0x7F) << 49) |
((byte6 & 0x7F) << 42) | ((byte5 & 0x7F) << 35) |
((byte4 & 0x7F) << 28) | ((byte3 & 0x7F) << 21) |
((byte2 & 0x7F) << 14) | ((byte1 & 0x7F) << 7) | (byte0 & 0x7F)
else
raise "integer decoding error"
end
end
return self if index >= len
end
end
|