OSDN Git Service

* [shogi-server]
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Mon, 15 Jun 2009 14:24:34 +0000 (14:24 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Mon, 15 Jun 2009 14:24:34 +0000 (14:24 +0000)
  - When a Gote player AGREEd a new game and then a Sente player
    logged out (LOGOUT), the Gote incorrectly received a LOGOUT message
    from the server. Since Gote's state was not AGREEd or STARTed yet,
    the Gote should be REJECTed. This issue has been fixed.
    (Closes: #17335)

changelog
shogi_server/game.rb
test/TC_ALL.rb
test/TC_before_agree.rb [new file with mode: 0644]

index 0c30678..1e6ecc7 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,12 @@
+2009-06-15 Daigo Moriwaki <daigo at debian dot org>
+
+       * [shogi-server]
+         - When a Gote player AGREEd a new game and then a Sente player
+           logged out (LOGOUT), the Gote incorrectly received a LOGOUT message 
+           from the server. Since Gote's state was not AGREEd or STARTed yet,
+           the Gote should be REJECTed. This issue has been fixed. 
+           (Closes: #17335)
+
 2009-06-14 Daigo Moriwaki <daigo at debian dot org>
 
        * [shogi-server]
 2009-06-14 Daigo Moriwaki <daigo at debian dot org>
 
        * [shogi-server]
index 365b608..0dc3746 100644 (file)
@@ -350,9 +350,14 @@ class Game
   end
 
   def kill(killer)
   end
 
   def kill(killer)
-    if ["agree_waiting", "start_waiting"].include?(@sente.status)
-      reject(killer.name)
-    elsif (@current_player == killer)
+    [@sente, @gote].each do |player|
+      if ["agree_waiting", "start_waiting"].include?(player.status)
+        reject(killer.name)
+        return # return from this method
+      end
+    end
+    
+    if (@current_player == killer)
       result = GameResultAbnormalWin.new(self, @next_player, @current_player)
       result.process
       finish
       result = GameResultAbnormalWin.new(self, @next_player, @current_player)
       result.process
       finish
index f13eb2c..619d313 100644 (file)
@@ -1,6 +1,7 @@
 $:.unshift File.dirname(__FILE__)
 
 require 'TC_board'
 $:.unshift File.dirname(__FILE__)
 
 require 'TC_board'
+require 'TC_before_agree'
 require 'TC_floodgate'
 require 'TC_functional'
 require 'TC_game_result'
 require 'TC_floodgate'
 require 'TC_functional'
 require 'TC_game_result'
diff --git a/test/TC_before_agree.rb b/test/TC_before_agree.rb
new file mode 100644 (file)
index 0000000..c3761ac
--- /dev/null
@@ -0,0 +1,30 @@
+require "baseclient"
+require "kconv"
+
+class TestBeforeAgree < BaseClient
+
+  def test_before_agree_gote_logout
+    login
+    result  = cmd  "AGREE"
+    result2 = cmd2 "LOGOUT"
+
+    result  += read_nonblock(@socket1)
+    result2 += read_nonblock(@socket2)
+
+    assert(/^REJECT/ =~ result)
+    assert(/^REJECT/ =~ result2)
+  end
+
+  def test_before_agree_sente_logout
+    login
+    sleep 0.5
+    result2 = cmd2 "AGREE"
+    result  = cmd  "LOGOUT"
+
+    result  += read_nonblock(@socket1)
+    result2 += read_nonblock(@socket2)
+
+    assert(/^REJECT/ =~ result)
+    assert(/^REJECT/ =~ result2)
+  end
+end