openra 3.0.1 → 4.0.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: 0f9c700154d2bb31c15ac83a1edc2ec365fb567c17a4bc2d2e37c920c67de779
4
- data.tar.gz: 13ed839f20179328684f677211cf663bc83aad21024105baf26beaf012757b2b
3
+ metadata.gz: ffa865d3e9489b00e005822cb07c6d586bdeab1f16475a81a0fc752920e46192
4
+ data.tar.gz: cc8166eeb9d81ba373bd8e570e5ddb82122a2657044321e853683a32de4f7946
5
5
  SHA512:
6
- metadata.gz: 8bd6a6092972426e71f7f885f6eaa5f56dac5310c285c4b5af80aaaf48b67618d586b861b25151edfc9fbc98fc6f5fa4642dcdca19ea4c0e7a340aee484cd3a1
7
- data.tar.gz: 4d2ad04c37f95a9a88f9852bfe36f936f1977e5cfeb72fbc84901911d73f1c5df441569249a53c406c8df9f17430d22aeccdc70962810d432a7c25491390ed7c
6
+ metadata.gz: 70b0c4a280854133fb7cbb4ea961075393966a781ec1310bb1e33f6cf7198e29c0655a167cdb24731eea1055111e43a0d01210e3db89b1f69ea062873381390a
7
+ data.tar.gz: be5f4bbbb31afa430c8a78d6987ed7441dcc27107add02583bf66ce7322b1bb2891dd8ae3f5c29afa5d60ab0a1bd1ece4f62f03b26bec6722443d9b03513351d
@@ -1,6 +1,13 @@
1
1
  ## Unreleased
2
2
 
3
- [Compare v3.0.1...HEAD](https://github.com/AMHOL/openra-ruby/compare/v3.0.0...HEAD)
3
+ [Compare v4.0.0...HEAD](https://github.com/AMHOL/openra-ruby/compare/v3.0.0...HEAD)
4
+
5
+ ## v4.0.0
6
+
7
+ * [maint] Support playtest-20201213 - drops support for all older clients
8
+ * [core] Generate file hash in replay-data and replay-metadata commands
9
+
10
+ [Compare v3.0.1...v4.0.0](https://github.com/AMHOL/openra-ruby/compare/v3.0.1...v4.0.0)
4
11
 
5
12
  ## v3.0.1
6
13
 
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'openra/commands'
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # frozen_string_literal: true
4
-
5
3
  module Openra
6
4
  class CLI
7
5
  module Commands
@@ -14,6 +14,9 @@ module Openra
14
14
  mod: replay.metadata.mod,
15
15
  version: replay.metadata.version,
16
16
  server_name: nil,
17
+ file: {
18
+ hash: replay.file_hash
19
+ },
17
20
  map: {
18
21
  name: utf8(replay.metadata.map_name),
19
22
  hash: replay.metadata.map_hash
@@ -12,6 +12,9 @@ module Openra
12
12
  {
13
13
  mod: replay.metadata.mod,
14
14
  version: replay.metadata.version,
15
+ file: {
16
+ hash: replay.file_hash
17
+ },
15
18
  map: {
16
19
  name: utf8(replay.metadata.map_name),
17
20
  hash: replay.metadata.map_hash
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'date'
4
+ require 'digest'
4
5
  require 'bindata'
5
6
  require 'bindata/big_integer'
6
7
  require 'bindata/pascal_string'
@@ -24,6 +24,10 @@ module Openra
24
24
  end
25
25
  end
26
26
 
27
+ def generate_hash
28
+ Digest::SHA256.hexdigest(file.read)
29
+ end
30
+
27
31
  def metadata
28
32
  # https://github.com/OpenRA/OpenRA/blob/23b3c237b7071fd308c4664b0b6c5d719c0f3c74/OpenRA.Game/FileFormats/ReplayMetadata.cs#L96
29
33
  @metadata ||= begin
@@ -6,19 +6,22 @@ module Openra
6
6
  class Order < BinData::Record
7
7
  HEX_FE = ?\xFE.dup.force_encoding('ASCII-8BIT').freeze
8
8
  HEX_FF = ?\xFF.dup.force_encoding('ASCII-8BIT').freeze
9
- # NEED TO LEARN HOW TO READ FLAGS AND TARGET TYPE
9
+
10
10
  IS_STANDARD_ORDER = -> { order_type == HEX_FF }
11
11
  IS_IMMEDIATE_ORDER = -> { order_type == HEX_FE }
12
- HAS_TARGET = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 1) == 1 }
12
+ HAS_TARGET = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x01) == 0x01 }
13
+ HAS_EXTRA_ACTORS = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x02) == 0x02 }
13
14
  TARGET_IS_ACTOR = -> { instance_exec(&HAS_TARGET) && target_type == 1 }
14
15
  TARGET_IS_TERRAIN = -> { instance_exec(&HAS_TARGET) && target_type == 2 }
15
16
  TARGET_IS_FROZEN_ACTOR = -> { instance_exec(&HAS_TARGET) && target_type == 3 }
16
- TARGET_IS_CELL = -> { instance_exec(&TARGET_IS_TERRAIN) && (flags & 64) == 64 }
17
- TARGET_NOT_CELL = -> { instance_exec(&TARGET_IS_TERRAIN) && (flags & 64) != 64 }
18
- HAS_SUBJECT = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 128) == 128 }
19
- HAS_TARGET_STRING = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 4) == 4 }
20
- HAS_EXTRA_LOCATION = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 16) == 16 }
21
- HAS_EXTRA_DATA = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 32) == 32 }
17
+ TARGET_IS_CELL = -> { instance_exec(&TARGET_IS_TERRAIN) && (flags & 0x40) == 0x40 }
18
+ TARGET_NOT_CELL = -> { instance_exec(&TARGET_IS_TERRAIN) && (flags & 0x40) != 0x40 }
19
+ HAS_SUBJECT = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x80) == 0x80 }
20
+ HAS_TARGET_STRING = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x04) == 0x04 }
21
+ HAS_EXTRA_LOCATION = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x10) == 0x10 }
22
+ HAS_EXTRA_DATA = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x20) == 0x20 }
23
+ # IS_QUEUED = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x08) == 0x08 }
24
+ IS_GROUPED = -> { instance_exec(&IS_STANDARD_ORDER) && (flags & 0x100) == 0x100 }
22
25
 
23
26
  endian :little
24
27
  # Common
@@ -27,7 +30,7 @@ module Openra
27
30
  # Immediate Order Data
28
31
  pascal_string :immediate_order_target, onlyif: IS_IMMEDIATE_ORDER
29
32
  # Standard Order Data
30
- uint8 :flags, onlyif: IS_STANDARD_ORDER
33
+ int16 :flags, onlyif: IS_STANDARD_ORDER
31
34
  uint32 :subject_id, onlyif: HAS_SUBJECT
32
35
  uint8 :target_type, onlyif: HAS_TARGET
33
36
  uint32 :actor_id, onlyif: TARGET_IS_ACTOR
@@ -39,8 +42,12 @@ module Openra
39
42
  int32 :pos_y, onlyif: TARGET_NOT_CELL
40
43
  int32 :pos_z, onlyif: TARGET_NOT_CELL
41
44
  pascal_string :standard_order_target, onlyif: HAS_TARGET_STRING
45
+ int32 :extra_actors_count, onlyif: HAS_EXTRA_ACTORS
46
+ array :extra_actor_ids, type: :uint32, initial_length: :extra_actors_count, onlyif: HAS_EXTRA_ACTORS
42
47
  int32 :extra_cell, onlyif: HAS_EXTRA_LOCATION
43
48
  uint32 :extra_data, onlyif: HAS_EXTRA_DATA
49
+ int32 :grouped_actors_count, onlyif: IS_GROUPED
50
+ array :grouped_actor_ids, type: :uint32, initial_length: :grouped_actors_count, onlyif: IS_GROUPED
44
51
 
45
52
  def target
46
53
  standard? ? standard_order_target : immediate_order_target
@@ -9,6 +9,10 @@ module Openra
9
9
  @file = Openra::Replays::File.new(filename)
10
10
  end
11
11
 
12
+ def file_hash
13
+ file.generate_hash
14
+ end
15
+
12
16
  def metadata
13
17
  @metadata ||= Openra::Struct::Metadata.new(
14
18
  Openra::MiniYAML.load(file.metadata.data)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Openra
4
- VERSION = '3.0.1'.freeze
4
+ VERSION = '4.0.0'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openra
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Holland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-29 00:00:00.000000000 Z
11
+ date: 2021-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler