31281
31282
31283
31284
31285
31286
31287
31288
31289
31290
31291
31292
31293
31294
31295
31296
31297
31298
31299
31300
31301
31302
31303
31304
31305
31306
31307
31308
31309
31310
31311
31312
31313
31314
31315
31316
31317
31318
31319
31320
31321
31322
31323
31324
31325
31326
31327
31328
31329
31330
31331
31332
31333
31334
31335
31336
31337
31338
31339
31340
31341
31342
31343
31344
31345
31346
31347
31348
31349
31350
31351
31352
31353
31354
31355
31356
31357
31358
31359
31360
31361
31362
31363
31364
31365
31366
31367
31368
31369
31370
31371
31372
31373
31374
31375
31376
31377
31378
31379
31380
31381
31382
31383
31384
31385
31386
31387
31388
31389
31390
31391
31392
31393
31394
31395
31396
31397
31398
31399
31400
31401
31402
31403
31404
31405
31406
31407
31408
31409
31410
31411
31412
31413
31414
31415
31416
31417
31418
31419
31420
31421
31422
31423
31424
31425
|
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 31281
def decode_from(buff, index, len)
return self if index >= len
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
return self if index >= len
end
end
|