Advertisement
Guest User

Terraria bytewise player unknowns diff

a guest
Jul 8th, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. def compare_indexes( a, b ):
  2.     l_a, l_b = len(a), len(b)
  3.     if l_a > l_b:
  4.         print( 'a is ' + str( l_a - l_b ) + 'bytes longer than b.' )
  5.         return
  6.     elif l_a < l_b:
  7.         print( 'a is ' + str( l_b - l_a ) + 'bytes shorter than b.' )
  8.         return
  9.     else:
  10.         boundaries = deque( [ 0, # Start of format version
  11.                               4, # after format version
  12.                               24, # 20 bytes of unknown is over
  13.                               36, # after bytes for 5char name, diff, hair and hair dye
  14.                               44, # 8 bytes of unknown is over
  15.                               65, # after whether demon heart has been used
  16.                               69, # 4 bytes of unknown is over
  17.                               180, # after last social accessory
  18.                               190, # 10 bytes of unknown is over
  19.                               235, # after last dye
  20.                               240, # 5 bytes of unknown is over
  21.                               1779, # after display_moon
  22.                               1780 # 1 unknown byte is over
  23.                               ] )
  24.        
  25.         skip = False
  26.         for i in range( l_a ):
  27.             if len(boundaries) > 0 and i == boundaries[0]:   # Toggle skipping if at next boundary
  28.                 skip = not skip
  29.                 boundaries.popleft()
  30.                 #print( ('Not s' if not skip else 'S') + 'kipping from index: ' + str(i) )
  31.             if not skip:    # Compare at index if not skipping
  32.                 a_i, b_i = a[i], b[i]
  33.                 if a_i != b_i:
  34.                     print( 'Difference index: ' + str(i) + ': ' + str(a_i) + ': ' + str(b_i) )
  35.             if skip and len(boundaries) == 0:   # If set to skip and never going to change that, exit loop
  36.                 print( 'Ending comparison early after index: ' + str(i) )
  37.                 break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement