Class: RuneRb::Network::RS317::ContextSynchronizationMessage

Inherits:
Message
  • Object
show all
Defined in:
app/network/protocol/rs317/outgoing/synchronization.rb

Overview

Since:

  • 0.9.3

Constant Summary

Constants included from Constants

Constants::BIT_MASK_OUT, Constants::BYTE_MUTATIONS, Constants::BYTE_ORDERS, Constants::BYTE_SIZE, Constants::CONNECTION_TYPES, Constants::LOGIN_RESPONSES, Constants::MESSAGE_SIZES, Constants::PROTOCOL_TEMPLATES, Constants::RW_TYPES, Constants::SIDEBAR_INTERFACES

Instance Attribute Summary

Attributes inherited from Message

#header, #mode

Instance Method Summary collapse

Methods inherited from Message

compile_header, #inspect, #peek, validate

Methods included from System::Log

#class_name, #err, #err!, #log, #log!, #symbolize_file

Constructor Details

#initialize(context) ⇒ ContextSynchronizationMessage

Called when a new SynchronizationMessage is created

Parameters:

Since:

  • 0.9.3


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/network/protocol/rs317/outgoing/synchronization.rb', line 7

def initialize(context)
  super('w',{ op_code: 81 }, :VARIABLE_SHORT)

  # Switch to bit access
  switch_access

  # Write Context entity movement
  write_movement(context)

  # Create a state block which to write the appearance of the context mob and surrounding mobs to.
  state_block = ContextStateBlock.new(context)

  # Write the existing local list size
  write_bits(context.locals[:players].size, 8)

  # write the local list for the context.
  write_locals(state_block, context, context.world)

  # Update the local list
  update_locals(state_block, context, context.world)

  # Write 2047 in 11 bits to indicate we're no longer updating the list.
  write_bits(2047, 11)

  # Switch to byte access
  switch_access

  # Push the bytes from the state block.
  write_bytes(state_block)
end