From d524c213324178263c74525d9b72ff521a8f401b Mon Sep 17 00:00:00 2001 From: Cyberarm Date: Mon, 4 May 2020 09:28:57 -0500 Subject: [PATCH] Enable server to require i-mic-fps.rb without launching game, fixed missing update method from connection/server, update gemfile to add releasy and rake --- Gemfile | 2 ++ Gemfile.lock | 16 +++++++++++++++- Rakefile | 4 ++-- i-mic-fps-server.rb | 10 +--------- i-mic-fps.rb | 29 ++++++++++++++++------------- lib/networking/connection.rb | 3 +++ lib/networking/server.rb | 3 +++ 7 files changed, 42 insertions(+), 25 deletions(-) diff --git a/Gemfile b/Gemfile index 493b75d..c9911c4 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,11 @@ source "https://rubygems.org" +gem "rake" gem "opengl-bindings", require: "opengl" gem "cyberarm_engine", git: "https://github.com/cyberarm/cyberarm_engine" gem "nokogiri", ">= 1.11.0.rc1" gem "async-websocket" group(:packaging) do + gem "releasy", github: "gosu/releasy" gem "ocra" end diff --git a/Gemfile.lock b/Gemfile.lock index a6d60df..00fd2d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,6 +6,16 @@ GIT gosu (~> 0.15.0) gosu_more_drawables (~> 0.3) +GIT + remote: https://github.com/gosu/releasy.git + revision: e8a24c079c4930c6ddbab17fc444027ba41491ca + specs: + releasy (0.2.3) + bundler (>= 1.2.1) + cri (~> 2.1.0) + ocra (~> 1.3.0) + rake (>= 0.9.2.2) + GEM remote: https://rubygems.org/ specs: @@ -22,13 +32,14 @@ GEM protocol-http2 (~> 0.14.0) async-io (1.29.0) async (~> 1.14) - async-pool (0.3.0) + async-pool (0.3.1) async (~> 1.25) async-websocket (0.14.0) async-http (~> 0.51) async-io (~> 1.23) protocol-websocket (~> 0.7.0) console (1.8.2) + cri (2.1.0) gosu (0.15.1) gosu (0.15.1-x64-mingw32) gosu_more_drawables (0.3.0) @@ -49,6 +60,7 @@ GEM protocol-websocket (0.7.4) protocol-http (~> 0.2) protocol-http1 (~> 0.2) + rake (13.0.1) timers (4.3.0) PLATFORMS @@ -61,6 +73,8 @@ DEPENDENCIES nokogiri (>= 1.11.0.rc1) ocra opengl-bindings + rake + releasy! BUNDLED WITH 2.1.4 diff --git a/Rakefile b/Rakefile index 80d1751..e22d8e3 100644 --- a/Rakefile +++ b/Rakefile @@ -3,8 +3,8 @@ require 'bundler/setup' # Releasy requires that your application uses bundler. require_relative "lib/version" Releasy::Project.new do - name "I-MIC FPS" - version "#{IMICFPS::VERSION}" + name IMICFPS::NAME + version IMICFPS::VERSION executable "i-mic-fps.rb" files ["lib/**/*.*", "assets/**/*.*", "blends/**/*.*", "shaders/**/*.*", "static/**/*.*", "maps/**/*.*", "data/**/*.*"] diff --git a/i-mic-fps-server.rb b/i-mic-fps-server.rb index 219a4bc..dba8ca1 100644 --- a/i-mic-fps-server.rb +++ b/i-mic-fps-server.rb @@ -1,12 +1,4 @@ -require "async/websocket" - -require_relative "lib/networking/director" -require_relative "lib/networking/packet_handler" -require_relative "lib/networking/server" -require_relative "lib/networking/client" - -require_relative "lib/networking/backends/memory_server" -require_relative "lib/networking/backends/memory_connection" +require_relative "i-mic-fps" director = IMICFPS::Networking::Director.new(mode: :server, hostname: "0.0.0.0", port: 56789, interface: IMICFPS::Networking::MemoryServer) director.define_singleton_method(:tick) do |dt| diff --git a/i-mic-fps.rb b/i-mic-fps.rb index 59dd30a..8c7c7f6 100644 --- a/i-mic-fps.rb +++ b/i-mic-fps.rb @@ -129,17 +129,20 @@ require_relative "lib/window" require_relative "lib/tools/asset_viewer" require_relative "lib/tools/map_editor" -if ARGV.join.include?("--profile") - begin - require "ruby-prof" - RubyProf.start - IMICFPS::Window.new.show - result = RubyProf.stop - printer = RubyProf::MultiPrinter.new(result) - printer.print(path: ".", profile: "profile", min_percent: 2) - rescue LoadError - puts "ruby-prof not installed!" +# Don't launch game if __FILE__ != launching command +if __FILE__ == $0 + if ARGV.join.include?("--profile") + begin + require "ruby-prof" + RubyProf.start + IMICFPS::Window.new.show + result = RubyProf.stop + printer = RubyProf::MultiPrinter.new(result) + printer.print(path: ".", profile: "profile", min_percent: 2) + rescue LoadError + puts "ruby-prof not installed!" + end + else + IMICFPS::Window.new.show end -else - IMICFPS::Window.new.show -end +end \ No newline at end of file diff --git a/lib/networking/connection.rb b/lib/networking/connection.rb index 41de78e..b9896a6 100644 --- a/lib/networking/connection.rb +++ b/lib/networking/connection.rb @@ -7,6 +7,9 @@ class IMICFPS def connect end + def update + end + def close end end diff --git a/lib/networking/server.rb b/lib/networking/server.rb index e7ec776..ee04c36 100644 --- a/lib/networking/server.rb +++ b/lib/networking/server.rb @@ -19,6 +19,9 @@ class IMICFPS def broadcast(packet) end + def update + end + def close end end