Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. decodeColumnEvalsResponse = (buffer, encoding, logger) ->
  2. reader = new BufferReader(buffer)
  3. messageLength = reader.readUInt32LE() & 0x0FFFFFFF
  4. evalCount = reader.readUInt32LE()
  5. screenCount = reader.readUInt32LE()
  6. screens = {}
  7. # Column eval numbers
  8. for s in [1 .. screenCount] by 1
  9. name = reader.readString(encoding)
  10. reader.align(4)
  11. columnCount = reader.readUInt32LE()
  12. columns = []
  13. for c in [1 .. columnCount] by 1
  14. columns[c] = reader.readInt32LE()
  15. screens[name] = {columns}
  16. # Button eval numbers
  17. for s in [1 .. screenCount] by 1
  18. name = reader.readString(encoding)
  19. reader.align(4)
  20. # This is actually the count of integers, not buttons, each button has an active and disabled state
  21. buttonCount = reader.readUInt32LE() # For each button there is BUTTONEVAL_, BUTTONDISABLEVAL_
  22. buttons = []
  23. buttonsDisabled = []
  24. for c in [0 ... buttonCount / 2]
  25. buttons[c + 1] = reader.readInt32LE()
  26. buttonsDisabled[c + 1] = reader.readInt32LE()
  27. screens[name].buttons = buttons
  28. screens[name].buttonsDisabled = buttonsDisabled
  29. # State eval numbers
  30. for s in [1 .. screenCount] by 1
  31. name = reader.readString(encoding)
  32. reader.align(4)
  33. stateCount = reader.readUInt32LE()
  34. states = []
  35. for c in [1 .. stateCount] by 1
  36. states[c] = reader.readInt32LE()
  37. screens[name].states = states
  38. return {
  39. message: new ColumnEvalsResponse {screens, evalCount}
  40. consumed: messageLength
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement