doom 0.11.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8f1be6b4e908fb60c850e5ac7e4e9d5ade8fff60fd7c9744d89da3132625e5a
4
- data.tar.gz: bdbc30dcb9141292e4c6ae8d974b604b0d8cdb440dac964bc637615fd9cf53b4
3
+ metadata.gz: f2114bdabac04335b93702676f54d54e26ae49a2c47250c90be096c2a827f763
4
+ data.tar.gz: 0df53b232c93033c26a3bf0e44894e4e525967417ca600915069f233f44c9ca5
5
5
  SHA512:
6
- metadata.gz: e5a2273db5baa4bb26c5d9d08cc78b734ef102d7b8d354a95109e44e72bb8deaf901b743aa59a9a3ff4f1770059d13b2e7069f3f8be5d6ccaec942b7b69d3053
7
- data.tar.gz: 6cb2b7e235928e9a72ab95a87a44c7be3c84dbc0f59bcd45d7c0e40f0f3ebee54a46198baea930191b2355cc7a713e326d8c412354ab6eee103adf7ebe9bf5c9
6
+ metadata.gz: abb268a3b9b6b8605de489c49fc47825d4460b2db849a13cf0f89d465950cf3617075cbd0e4064c04c9703ff9cac184485a11419587f43787d53f7e918d35024
7
+ data.tar.gz: bcdfff32f9101693e8067790e0e1031d6f3c540bf574d7ccfca1967ca52763479ca019844efc3e247eecb683d6f480c662d19e4c8a256519c41d8fdab77ed8d1
data/README.md CHANGED
@@ -127,6 +127,12 @@ to present every frame the old way.
127
127
  brew install sdl2
128
128
  ```
129
129
 
130
+ If an older installation reports `symbol not found in flat namespace _OBJC_CLASS_$_NSScreen`,
131
+ update the gem with `gem update doom`. This is fixed in Doom Ruby 0.11.1.
132
+
133
+ If the first-run WAD downloader fails with `uninitialized constant Doom::Net::HTTP`,
134
+ update to Doom Ruby 0.11.2.
135
+
130
136
  **Ubuntu/Debian:**
131
137
  ```bash
132
138
  sudo apt-get install build-essential libsdl2-dev libgl1-mesa-dev libopenal-dev libsndfile1-dev libmpg123-dev libfontconfig1-dev
data/bin/doom CHANGED
@@ -131,13 +131,18 @@ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'truffleruby' && RUBY_PLATFORM.includ
131
131
  %w[
132
132
  /opt/homebrew/lib/libSDL2-2.0.0.dylib /opt/homebrew/lib/libSDL2.dylib
133
133
  /usr/local/lib/libSDL2-2.0.0.dylib /usr/local/lib/libSDL2.dylib
134
- ].each { |p| (Fiddle.dlopen(p); break) if File.exist?(p) }
134
+ ].each do |path|
135
+ next unless File.exist?(path)
136
+
137
+ Fiddle.dlopen(path)
138
+ break
139
+ end
135
140
  rescue StandardError => e
136
141
  warn "[doom] SDL2 preload for TruffleRuby failed (#{e.message}); the window may not open"
137
142
  end
138
143
  unless (ENV['JAVA_TOOL_OPTIONS'].to_s + ENV['TRUFFLERUBYOPT'].to_s).include?('XstartOnFirstThread')
139
- warn "[doom] on TruffleRuby/macOS the window needs the main thread: run with " \
140
- "`truffleruby --vm.XstartOnFirstThread bin/doom ...`"
144
+ warn '[doom] on TruffleRuby/macOS the window needs the main thread: run with ' \
145
+ '`truffleruby --vm.XstartOnFirstThread bin/doom ...`'
141
146
  end
142
147
  end
143
148
 
@@ -284,9 +284,11 @@ module Doom
284
284
  # Iterate linedefs that may interact with the player moving from
285
285
  # (x1, y1) to (x2, y2). Uses BLOCKMAP when available; otherwise falls
286
286
  # back to scanning all linedefs.
287
- def each_nearby_linedef(x1, y1, x2, y2, &)
287
+ def each_nearby_linedef(x1, y1, x2, y2, &block)
288
+ return enum_for(__method__, x1, y1, x2, y2) unless block
289
+
288
290
  unless @map.respond_to?(:blockmap_loaded?) && @map.blockmap_loaded?
289
- @map.linedefs.each(&)
291
+ @map.linedefs.each(&block)
290
292
  return
291
293
  end
292
294
 
@@ -295,7 +297,7 @@ module Doom
295
297
  max_x = [x1, x2].max + PLAYER_RADIUS
296
298
  min_y = [y1, y2].min - PLAYER_RADIUS
297
299
  max_y = [y1, y2].max + PLAYER_RADIUS
298
- @map.each_linedef_near(min_x, min_y, max_x, max_y, &)
300
+ @map.each_linedef_near(min_x, min_y, max_x, max_y, &block)
299
301
  end
300
302
 
301
303
  def crosses_blocking_linedef?(x1, y1, x2, y2, linedef)
@@ -44,9 +44,11 @@ module Doom
44
44
  end
45
45
 
46
46
  # length-prefixed homogeneous array
47
- def list(items, &)
47
+ def list(items, &block)
48
+ return enum_for(__method__, items) unless block
49
+
48
50
  u32(items.size)
49
- items.each(&)
51
+ items.each(&block)
50
52
  end
51
53
 
52
54
  def to_s = @buf.dup
@@ -76,8 +78,10 @@ module Doom
76
78
  take(u16)
77
79
  end
78
80
 
79
- def list(&)
80
- Array.new(u32, &)
81
+ def list(&block)
82
+ return enum_for(__method__) unless block
83
+
84
+ Array.new(u32, &block)
81
85
  end
82
86
 
83
87
  private
data/lib/doom/map/data.rb CHANGED
@@ -302,9 +302,16 @@ module Doom
302
302
  # Yield each linedef whose block overlaps the bounding box (min_x, min_y,
303
303
  # max_x, max_y). Yields each linedef at most once per call. Falls back
304
304
  # to iterating all linedefs if no blockmap is loaded.
305
- def each_linedef_near(min_x, min_y, max_x, max_y, &)
305
+ # Avoid anonymous block forwarding: Ruby 4.0.9's parser rejects that form.
306
+ def each_linedef_near(min_x, min_y, max_x, max_y)
307
+ return enum_for(__method__, min_x, min_y, max_x, max_y) unless block_given?
308
+
306
309
  unless @blockmap_blocks
307
- @linedefs.each(&)
310
+ line_index = 0
311
+ while line_index < @linedefs.size
312
+ yield @linedefs[line_index]
313
+ line_index += 1
314
+ end
308
315
  return
309
316
  end
310
317
 
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rbconfig'
4
+
5
+ module Doom
6
+ module Platform
7
+ # Gosu 1.4.6's macOS extension can be linked without its AppKit and SDL2
8
+ # dependencies when sdl2-config does not implement --static-libs. Load the
9
+ # frameworks globally first so dyld can resolve the extension's symbols.
10
+ module GosuLoader
11
+ APPKIT = '/System/Library/Frameworks/AppKit.framework/AppKit'
12
+ SDL2_CANDIDATES = %w[
13
+ /opt/homebrew/opt/sdl2/lib/libSDL2.dylib
14
+ /usr/local/opt/sdl2/lib/libSDL2.dylib
15
+ /opt/homebrew/lib/libSDL2.dylib
16
+ /usr/local/lib/libSDL2.dylib
17
+ ].freeze
18
+
19
+ module_function
20
+
21
+ def prepare!
22
+ return unless RbConfig::CONFIG['host_os'].include?('darwin')
23
+
24
+ require 'fiddle'
25
+ flags = Fiddle::RTLD_GLOBAL | Fiddle::RTLD_LAZY
26
+ @handles ||= []
27
+ @handles << Fiddle::Handle.new(APPKIT, flags)
28
+
29
+ sdl2 = SDL2_CANDIDATES.find { |path| File.file?(path) }
30
+ unless sdl2
31
+ raise LoadError,
32
+ 'Could not find Homebrew SDL2 required by Gosu. Install it with `brew install sdl2`.'
33
+ end
34
+
35
+ @sdl2_handle = Fiddle::Handle.new(sdl2, flags)
36
+ @handles << @sdl2_handle
37
+ rescue Fiddle::DLError => e
38
+ raise LoadError, "Could not load macOS frameworks required by Gosu: #{e.message}"
39
+ end
40
+
41
+ def sdl2_handle
42
+ @sdl2_handle
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'gosu_loader'
4
+ Doom::Platform::GosuLoader.prepare!
3
5
  require 'gosu'
4
6
  require_relative 'sdl'
5
7
  require_relative 'window_logic'
@@ -9,12 +9,13 @@ module Doom
9
9
  gosu_spec = Gem.loaded_specs['gosu']
10
10
  lib_ext = RbConfig::CONFIG['DLEXT'] || 'so'
11
11
  bundle = File.join(gosu_spec.full_gem_path, 'lib', "gosu.#{lib_ext}")
12
- @lib = Fiddle.dlopen(bundle)
12
+ @gosu_lib = Fiddle.dlopen(bundle)
13
+ @sdl_lib = Doom::Platform::GosuLoader.sdl2_handle || @gosu_lib
13
14
  @shared_window = Fiddle::Function.new(
14
- @lib['_ZN4Gosu13shared_windowEv'], [], Fiddle::TYPE_VOIDP
15
+ @gosu_lib['_ZN4Gosu13shared_windowEv'], [], Fiddle::TYPE_VOIDP
15
16
  )
16
17
  @set_kb_grab = Fiddle::Function.new(
17
- @lib['SDL_SetWindowKeyboardGrab'],
18
+ @sdl_lib['SDL_SetWindowKeyboardGrab'],
18
19
  [Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT], Fiddle::TYPE_VOID
19
20
  )
20
21
  @ready = true
@@ -52,7 +53,8 @@ module Doom
52
53
  require 'fiddle'
53
54
  gosu_spec = Gem.loaded_specs['gosu']
54
55
  lib_ext = RbConfig::CONFIG['DLEXT'] || 'so'
55
- lib = Fiddle.dlopen(File.join(gosu_spec.full_gem_path, 'lib', "gosu.#{lib_ext}"))
56
+ bundle = File.join(gosu_spec.full_gem_path, 'lib', "gosu.#{lib_ext}")
57
+ lib = Doom::Platform::GosuLoader.sdl2_handle || Fiddle.dlopen(bundle)
56
58
 
57
59
  get_mode = Fiddle::Function.new(
58
60
  lib['SDL_GetCurrentDisplayMode'],
@@ -5,7 +5,7 @@
5
5
  begin
6
6
  require 'opengl'
7
7
  rescue LoadError
8
- warn "[doom] opengl gem not available; the hardware renderer is disabled" if $VERBOSE
8
+ warn '[doom] opengl gem not available; the hardware renderer is disabled' if $VERBOSE
9
9
  end
10
10
 
11
11
  module Doom
@@ -94,8 +94,10 @@ module Doom
94
94
  [minimum, maximum]
95
95
  end
96
96
 
97
- def axes(&)
98
- 3.times.map(&)
97
+ def axes(&block)
98
+ return enum_for(__method__) unless block
99
+
100
+ 3.times.map(&block)
99
101
  end
100
102
  end
101
103
  end
@@ -67,13 +67,8 @@ module Doom
67
67
  # Opt-in: route the wall/floor/ceiling rasterisation through the
68
68
  # spinel_native-compiled port of this renderer's hot path. Everything
69
69
  # else (sprites, weapon, HUD, physics, sound) stays the real game.
70
- @native_kernel = !ENV["DOOM_NATIVE"].to_s.empty? && ENV["DOOM_NATIVE"] != "0"
71
- if @native_kernel
72
- warn "[doom] compiling spinel_native render kernel (first run may take a few seconds)..."
73
- @sn = build_native_renderer
74
- @native_kernel = !@sn.nil?
75
- warn "[doom] spinel_native renderer ready" if @sn
76
- end
70
+ @native_kernel = !ENV['DOOM_NATIVE'].to_s.empty? && ENV['DOOM_NATIVE'] != '0'
71
+ warn '[doom] spinel_native renderer requested; loading it on first frame' if @native_kernel
77
72
  @sprites = sprites
78
73
  @animations = animations
79
74
  @hidden_things = nil
@@ -309,7 +304,7 @@ module Doom
309
304
  def build_native_renderer
310
305
  # Dynamic form so the spinel AOT compiler ignores this require (it pulls
311
306
  # in the spinel_native gem, irrelevant to an AOT build); CRuby is unaffected.
312
- send(:require_relative, "spinel_native_renderer")
307
+ send(:require_relative, 'spinel_native_renderer')
313
308
  SpinelNativeRenderer.new(@map, @palette, @colormap, @textures, @flats_array)
314
309
  rescue StandardError, LoadError => e
315
310
  warn "[doom] spinel_native renderer unavailable, using Ruby renderer (#{e.message.lines.first.to_s.strip})"
data/lib/doom/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Doom
4
- VERSION = '0.11.0'
4
+ VERSION = '0.11.2'
5
5
  end
@@ -83,28 +83,28 @@ module Doom
83
83
  def self.download_from_url(url, destination, redirect_limit: 5)
84
84
  raise DownloadError, 'Too many redirects' if redirect_limit.negative?
85
85
 
86
- uri = URI.parse(url)
86
+ uri = ::URI.parse(url)
87
87
  ssl_opts = { use_ssl: uri.scheme == 'https' }
88
88
 
89
89
  if ssl_opts[:use_ssl]
90
90
  begin
91
- Net::HTTP.start(uri.host, uri.port, **ssl_opts) { |h| h.head(uri) }
92
- rescue OpenSSL::SSL::SSLError
91
+ ::Net::HTTP.start(uri.host, uri.port, **ssl_opts) { |h| h.head(uri) }
92
+ rescue ::OpenSSL::SSL::SSLError
93
93
  puts 'SSL certificate verification failed, retrying without verification...'
94
- ssl_opts[:verify_mode] = OpenSSL::SSL::VERIFY_NONE
94
+ ssl_opts[:verify_mode] = ::OpenSSL::SSL::VERIFY_NONE
95
95
  end
96
96
  end
97
97
 
98
98
  downloaded = 0
99
- Net::HTTP.start(uri.host, uri.port, **ssl_opts) do |http|
100
- request = Net::HTTP::Get.new(uri)
99
+ ::Net::HTTP.start(uri.host, uri.port, **ssl_opts) do |http|
100
+ request = ::Net::HTTP::Get.new(uri)
101
101
 
102
102
  http.request(request) do |response|
103
103
  case response
104
- when Net::HTTPRedirection
104
+ when ::Net::HTTPRedirection
105
105
  return download_from_url(response['location'], destination,
106
106
  redirect_limit: redirect_limit - 1)
107
- when Net::HTTPSuccess
107
+ when ::Net::HTTPSuccess
108
108
  total_size = response['content-length']&.to_i || SHAREWARE_SIZE
109
109
 
110
110
  File.open(destination, 'wb') do |file|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hasinski
@@ -148,6 +148,7 @@ files:
148
148
  - lib/doom/net/protocol.rb
149
149
  - lib/doom/net/session.rb
150
150
  - lib/doom/net/transport.rb
151
+ - lib/doom/platform/gosu_loader.rb
151
152
  - lib/doom/platform/gosu_window.rb
152
153
  - lib/doom/platform/sdl.rb
153
154
  - lib/doom/platform/window_logic.rb
@@ -196,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
197
  - !ruby/object:Gem::Version
197
198
  version: '0'
198
199
  requirements: []
199
- rubygems_version: 4.0.16
200
+ rubygems_version: 4.0.20
200
201
  specification_version: 4
201
202
  summary: Doom engine port with multiplayer and modern renderers
202
203
  test_files: []