X-Git-Url: http://git.sourceforge.jp/view?p=shogi-server%2Fshogi-server.git;a=blobdiff_plain;f=shogi_server%2Fcommand.rb;h=ad8684d97d70652cdd42d69727bbda5bb95a27d0;hp=8a2b38c09a888174a29c6d74bca874e85043a6e5;hb=a29f0d5a40176fd026f13004fa4a519e4e934e86;hpb=48967e86b1a0ca5ed7c67b882757b9acd2a58655 diff --git a/shogi_server/command.rb b/shogi_server/command.rb index 8a2b38c..ad8684d 100644 --- a/shogi_server/command.rb +++ b/shogi_server/command.rb @@ -1,7 +1,7 @@ ## $Id$ ## Copyright (C) 2004 NABEYA Kenichi (aka nanami@2ch) -## Copyright (C) 2007-2008 Daigo Moriwaki (daigo at debian dot org) +## Copyright (C) 2007-2012 Daigo Moriwaki (daigo at debian dot org) ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -121,6 +121,7 @@ module ShogiServer end cmd.time = time + player.last_command_at = time return cmd end @@ -496,9 +497,12 @@ module ShogiServer end def call - if (! Login::good_game_name?(@game_name)) + if (!ShogiServer::available?) + @player.write_safe("##[ERROR] As the service is going to shutdown shortly, starting new games is not allowed now.\n") + return :continue + elsif (! Login::good_game_name?(@game_name)) @player.write_safe(sprintf("##[ERROR] bad game name: %s.\n", @game_name)) - if (/^(.+)-\d+-\d+$/ =~ @game_name) + if (/^(.+)-\d+-\d+F?$/ =~ @game_name) if Login::good_identifier?($1) # do nothing else @@ -551,7 +555,7 @@ module ShogiServer board = Board.new begin board.set_from_moves(moves_array) - rescue => err + rescue # it will never happen since moves have already been checked log_error "Failed to set up a buoy game: #{moves}" return :continue @@ -774,7 +778,7 @@ module ShogiServer # found two players: p1 and p2 log_info("Starting a buoy game: %s with %s and %s" % [@game_name, p1.name, p2.name]) buoy.decrement_count(buoy_game) - game = Game::new(@game_name, p1, p2, board) + Game::new(@game_name, p1, p2, board) return :continue rescue WrongMoves => e @@ -831,6 +835,7 @@ module ShogiServer @player.write_safe("##[GETBUOYCOUNT] %s\n" % [buoy_game.count]) end @player.write_safe("##[GETBUOYCOUNT] +OK\n") + return :continue end end @@ -855,7 +860,7 @@ module ShogiServer byo_time = nil if @source_game.split("+").size >= 2 && - /^([^-]+)-(\d+)-(\d+)/ =~ @source_game.split("+")[1] + /^([^-]+)-(\d+)-(\d+F?)/ =~ @source_game.split("+")[1] name = $1 total_time = $2 byo_time = $3