mirror of
https://github.com/barronwaffles/dwc_network_server_emulator.git
synced 2026-07-14 15:12:09 -05:00
Add optional overload to the get_short and get_int functions
This commit is contained in:
parent
07de306dbd
commit
97277fb9b0
|
|
@ -91,18 +91,18 @@ def base32_decode(s, reverse=False):
|
|||
|
||||
# Number routines
|
||||
def get_num_from_bytes(data, idx, fmt, bigEndian=False):
|
||||
return struct.unpack_from("<>"[bigEndian] + fmt, data, idx)[0]
|
||||
return struct.unpack_from("<>"[bigEndian] + fmt, bytearray(data), idx)[0]
|
||||
|
||||
# Instead of passing slices, pass the buffer and index so we can calculate
|
||||
# the length automatically.
|
||||
|
||||
|
||||
def get_short(data, idx):
|
||||
return get_num_from_bytes(data, idx, 'h', False)
|
||||
def get_short(data, idx, bigEndian=False):
|
||||
return get_num_from_bytes(data, idx, 'h', bigEndian)
|
||||
|
||||
|
||||
def get_int(data, idx):
|
||||
return get_num_from_bytes(data, idx, 'i', False)
|
||||
def get_int(data, idx, bigEndian=False):
|
||||
return get_num_from_bytes(data, idx, 'i', bigEndian)
|
||||
|
||||
|
||||
def get_string(data, idx):
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user