openra 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d50772fdfb058a097600d6739787d971d4181ea94f889f463f5790d87cae0df
4
- data.tar.gz: 325f6d9fae9516003c127b7ea580e69d4fdb45c70183a30e4b2ab35598ff2996
3
+ metadata.gz: e488c6ceb71360aa93bfcb831c16754fbe2ba4faf55608a7572b8b302e1820bb
4
+ data.tar.gz: a78247905a1918531599f321bfa3b1c31d4b2520e3f955b55dc15e44c4db3fc5
5
5
  SHA512:
6
- metadata.gz: 4b7591e6daa6aa379d36f990a01f873826e133a9c5cffacb7bcf63f935148410c67e2936a875da5507b7c14ad1c7c1f4389136fbfb19672fb8028306a3500ade
7
- data.tar.gz: 2304fa6ca53e18438a18c213fff87157a7835b4937e391af64cabd4202a2b9aa974e208cda17bbbf7bc2a51dba29585bcfd68c6f973d9fbc671b6ebd4bc758da
6
+ metadata.gz: e69e8ceeeabbd611d12f54850ffbd89fee488637d895d783c13582d1747426cad2659248d9c38332576125d5c5d0854a6ff82d384f52bfa05ba81dcb9792e9d5
7
+ data.tar.gz: 4926b3ce501e4c138239bd3660b45baa3199484b8c33ec8bf7fe8ecb0922673c9f1d841e07195fe2db38202217a2e55fbb471faffc31ba4fee6ca1b3a57d001b
@@ -1,6 +1,16 @@
1
1
  ## Unreleased
2
2
 
3
- [Compare v2.0.0...HEAD](https://github.com/AMHOL/openra-ruby/compare/v2.0.0...HEAD)
3
+ [Compare v2.1.0...HEAD](https://github.com/AMHOL/openra-ruby/compare/v2.1.0...HEAD)
4
+
5
+ ## v2.1.0
6
+
7
+ ### Added
8
+
9
+ * [replay-data] Add client fingerprint to output ([AMHOL](https://github.com/AMHOL))
10
+ * [replay-data] Restored placement outputs to x, y, layers hash
11
+ * [replay-data] Added support for bot replays
12
+
13
+ [Compare v2.0.0...v2.1.0](https://github.com/AMHOL/openra-ruby/compare/v2.0.0...v2.1.0)
4
14
 
5
15
  ## v2.0.0
6
16
 
@@ -55,10 +55,13 @@ module Openra
55
55
 
56
56
  data[:clients] = sync_info.clients.map do |client|
57
57
  player = replay.player(client.index)
58
+ player_index = replay.players.index(player) + FIRST_PLAYER_INDEX if player
58
59
 
59
60
  {
60
61
  index: client.index,
62
+ player_index: player_index,
61
63
  name: utf8(client.name),
64
+ fingerprint: client.fingerprint,
62
65
  preferred_color: client.preferred_color,
63
66
  color: client.color,
64
67
  spawn: {
@@ -112,18 +115,20 @@ module Openra
112
115
  client_hash[:support_powers] << {
113
116
  type: key,
114
117
  game_time: time(order.frame * sync_info.global_settings.frametime_multiplier),
115
- placement: order.target_pos.to_i,
116
- extra_placement: order.extra_pos.to_i
118
+ placement: cell(order.target_cell.to_i),
119
+ extra_placement: cell(order.extra_cell.to_i),
117
120
  }
118
121
  when 'PlaceBuilding'
122
+ # subject_id stores the player index here
123
+ # as bot commands are issued by the host client
119
124
  client_hash = data[:clients].find do |candidate|
120
- candidate[:index] == order.client_index.to_s
125
+ candidate[:player_index] == order.subject_id
121
126
  end
122
127
 
123
128
  client_hash[:build] << {
124
129
  structure: utf8(order.target),
125
130
  game_time: time(order.frame * sync_info.global_settings.frametime_multiplier),
126
- placement: order.target_pos.to_i
131
+ placement: cell(order.target_cell.to_i)
127
132
  }
128
133
  when 'Message'
129
134
  data[:chat] << {
@@ -7,6 +7,16 @@ module Openra
7
7
  string.force_encoding('UTF-8')
8
8
  end
9
9
 
10
+ def cell(pos)
11
+ return if pos.zero?
12
+
13
+ {
14
+ x: pos >> 20,
15
+ y: ((pos >> 4) & 0xFFF0) >> 4,
16
+ layer: pos & 0xFF
17
+ }
18
+ end
19
+
10
20
  def time(msec)
11
21
  sec = msec / 1000
12
22
  mm, ss = sec.divmod(60)
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Openra
4
+ FIRST_PLAYER_INDEX = 3
5
+
4
6
  SUPPORT_POWERS = {
5
7
  'ra' => {
6
8
  'SovietSpyPlane' => :spy_plane,
@@ -32,13 +32,13 @@ module Openra
32
32
  uint32 :actor_id, onlyif: TARGET_IS_ACTOR
33
33
  uint32 :player_actor_id, onlyif: TARGET_IS_FROZEN_ACTOR
34
34
  uint32 :frozen_actor_id, onlyif: TARGET_IS_FROZEN_ACTOR
35
- int32 :target_pos, onlyif: TARGET_IS_CELL
35
+ int32 :target_cell, onlyif: TARGET_IS_CELL
36
36
  uint8 :target_sub_cell, onlyif: TARGET_IS_CELL
37
37
  int32 :pos_x, onlyif: TARGET_NOT_CELL
38
38
  int32 :pos_y, onlyif: TARGET_NOT_CELL
39
39
  int32 :pos_z, onlyif: TARGET_NOT_CELL
40
40
  pascal_string :standard_order_target, onlyif: HAS_TARGET_STRING
41
- int32 :extra_pos, onlyif: HAS_EXTRA_LOCATION
41
+ int32 :extra_cell, onlyif: HAS_EXTRA_LOCATION
42
42
  uint32 :extra_data, onlyif: HAS_EXTRA_DATA
43
43
 
44
44
  def target
@@ -25,7 +25,7 @@ module Openra
25
25
 
26
26
  def player(index)
27
27
  players.find do |candidate|
28
- candidate.index == index
28
+ candidate.client_index == index
29
29
  end
30
30
  end
31
31
  end
@@ -12,6 +12,7 @@ module Openra
12
12
  attribute :faction_name, Types::Strict::String.meta(from: 'Faction')
13
13
  attribute :spawn_point, Types::Strict::String.meta(from: 'SpawnPoint')
14
14
  attribute :name, Types::Strict::String.meta(from: 'Name')
15
+ attribute :fingerprint, Types::Strict::String.meta(from: 'Fingerprint')
15
16
  attribute :ip, Types::Strict::String.meta(from: 'IpAddress')
16
17
  attribute :state, Types::Strict::String.meta(from: 'State')
17
18
  attribute :team, Types::Strict::String.meta(from: 'Team')
@@ -3,9 +3,12 @@
3
3
  module Openra
4
4
  class Struct < Dry::Struct
5
5
  class Player < Openra::Struct
6
+ transform_types(&:omittable)
7
+
6
8
  define do
7
- attribute :index, Types::Strict::String.meta(from: 'ClientIndex')
9
+ attribute :client_index, Types::Strict::String.meta(from: 'ClientIndex')
8
10
  attribute :name, Types::Strict::String.meta(from: 'Name')
11
+ attribute :fingerprint, Types::Strict::String.meta(from: 'Fingerprint')
9
12
  attribute :is_human, Types::Params::Bool.meta(from: 'IsHuman')
10
13
  attribute :is_bot, Types::Params::Bool.meta(from: 'IsBot')
11
14
  attribute :faction_name, Types::Strict::String.meta(from: 'FactionName')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Openra
4
- VERSION = '2.0.0'.freeze
4
+ VERSION = '2.1.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openra
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Holland