19039
19040
19041
19042
19043
19044
19045
19046
19047
19048
19049
19050
19051
19052
19053
19054
19055
19056
19057
19058
19059
19060
19061
19062
19063
19064
19065
19066
19067
19068
19069
19070
19071
19072
19073
19074
19075
19076
19077
19078
19079
19080
19081
19082
19083
19084
19085
19086
19087
19088
19089
19090
19091
19092
19093
19094
19095
19096
19097
19098
19099
19100
19101
19102
19103
19104
19105
19106
19107
19108
19109
19110
19111
19112
19113
19114
19115
19116
19117
19118
19119
19120
19121
19122
19123
19124
19125
19126
19127
19128
19129
19130
19131
19132
19133
19134
19135
19136
19137
19138
19139
19140
19141
19142
19143
19144
19145
19146
19147
19148
19149
19150
19151
19152
19153
19154
19155
19156
19157
19158
19159
19160
19161
19162
19163
19164
19165
19166
19167
19168
19169
19170
19171
19172
19173
19174
19175
19176
19177
19178
19179
19180
19181
19182
19183
|
# File 'lib/sc2ai/protocol/sc2api_pb.rb', line 19039
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
|