• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

shogi-server source


Commit MetaInfo

Revisão360533de4731f88c6e4e5b4a3ff1979e6fb1b07e (tree)
Hora2020-12-14 20:42:55
AutorMizar <mizar.jp@gmai...>
CommiterMizar

Mensagem de Log

work for Windows wip

Mudança Sumário

Diff

--- a/bin/usiToCsa.rb
+++ b/bin/usiToCsa.rb
@@ -28,6 +28,7 @@ $:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), ".."))
2828 require 'shogi_server'
2929 require 'logger'
3030 require 'socket'
31+require 'timeout'
3132
3233 # Global variables
3334
@@ -482,7 +483,14 @@ class BridgeState
482483 throw "Bad state at event_engine_recv: #@state"
483484 end
484485
485- str = $server.gets
486+ str = nil
487+ begin
488+ Timeout.timeout(0.001){
489+ str = $server.gets
490+ }
491+ rescue Timeout::Error
492+ log_error "event_server_recv timeout"
493+ end
486494 return if str.nil? || str.strip.empty?
487495 log_server_recv str
488496
@@ -598,9 +606,15 @@ end
598606 def start_engine
599607 log_info("Starting engine... #{$options[:engine_path]}")
600608
601- cmd = %Q!| #{$options[:engine_path]}!
602- $engine = open(cmd, "w+")
609+ $engine = IO.popen($options[:engine_path], "w+")
603610 $engine.sync = true
611+ if false and RUBY_PLATFORM.downcase =~ /mswin|mingw|cygwin|bccwin|msys/
612+ require 'Win32API'
613+ get_osfhandle = Win32API.new('msvcrt', '_get_osfhandle', 'I', 'L')
614+ set_namedpipehandlestate = Win32API.new('kernel32', 'SetNamedPipeHandleState', 'LPPP', 'I')
615+ os_fhandle = get_osfhandle.call($engine.to_i)
616+ pipe_res = set_namedpipehandlestate.call(os_fhandle, [1].pack("L"), [0].pack("L"), [0].pack("L"))
617+ end
604618
605619 select(nil, [$engine], nil)
606620 log_engine_send "usi"