• 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

Revisione549c6dfdb66adbe66909389f005a45526d6b144 (tree)
Time2020-12-14 20:42:55
AuthorMizar <mizar.jp@gmai...>
CommiterMizar

Log Message

Handle timeout checks when executing KeepAlive and Space commands

Change Summary

Incremental Difference

--- a/shogi_server/command.rb
+++ b/shogi_server/command.rb
@@ -157,6 +157,10 @@ module ShogiServer
157157
158158 def call
159159 @player.write_safe("\n")
160+ if (@player.status == "game")
161+ s = @player.game.handle_one_move(:keepalive, @player, @time)
162+ return :return if (s && @player.protocol == LoginCSA::PROTOCOL)
163+ end
160164 return :continue
161165 end
162166 end
@@ -685,6 +689,10 @@ module ShogiServer
685689
686690 def call
687691 ## ignore null string
692+ if (@player.status == "game")
693+ s = @player.game.handle_one_move(:space, @player, @time)
694+ return :return if (s && @player.protocol == LoginCSA::PROTOCOL)
695+ end
688696 return :continue
689697 end
690698 end
--- a/shogi_server/game.rb
+++ b/shogi_server/game.rb
@@ -248,7 +248,7 @@ class Game
248248 # class Game
249249 def handle_one_move(str, player, end_time)
250250 unless turn?(player)
251- return false if str == :timeout
251+ return false if (str == :timeout || str == :keepalive || str == :space)
252252
253253 @fh.puts("'Deferred %s" % [str])
254254 log_warning("Deferred a move [%s] scince it is not %s 's turn." %
@@ -263,7 +263,7 @@ class Game
263263
264264 if (@time_clock.timeout?(@current_player, @start_time, @end_time))
265265 status = :timeout
266- elsif (str == :timeout)
266+ elsif (str == :timeout || str == :keepalive || str == :space)
267267 return false # time isn't expired. players aren't swapped. continue game
268268 else
269269 t = @time_clock.process_time(@current_player, @start_time, @end_time)