OSDN Git Service

players.yaml is now read only. The server no longer writes last_game_win data to...
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Tue, 7 Oct 2008 13:09:10 +0000 (13:09 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Tue, 7 Oct 2008 13:09:10 +0000 (13:09 +0000)
shogi-server
shogi_server/league.rb
shogi_server/league/persistent.rb

index fc19b06..1f5a9f5 100755 (executable)
@@ -273,13 +273,11 @@ def main
   server = WEBrick::GenericServer.new(config)
   ["INT", "TERM"].each do |signal| 
     trap(signal) do
-      LEAGUE.shutdown
       server.shutdown
       fg_thread.kill if fg_thread
     end
   end
   trap("HUP") do
-    LEAGUE.shutdown
     Dependencies.clear
   end
   $stderr.puts("server started as a deamon [Revision: #{ShogiServer::Revision}]") if $options["daemon"] 
index 82e3b56..29d7bf2 100644 (file)
@@ -35,14 +35,6 @@ class League
   end
   attr_accessor :players, :games, :event, :dir
 
-  def shutdown
-    @mutex.synchronize do
-      @players.each do |name, player| 
-        @persistent.save(player)
-      end
-    end
-  end
-
   # this should be called just after instanciating a League object.
   def setup_players_database
     filename = File.join(@dir, "players.yaml")
@@ -57,16 +49,11 @@ class League
   end
   
   def delete(player)
-    @persistent.save(player)
     @mutex.synchronize do
       @players.delete(player.name)
     end
   end
 
-  def save(player)
-    @persistent.save(player)
-  end
-
   def reload
     @mutex.synchronize do
       @players.each do |name, player| 
index ae1ce1c..8d5ab98 100644 (file)
@@ -1,6 +1,26 @@
+## $Id$
+
+## Copyright (C) 2004 NABEYA Kenichi (aka nanami@2ch)
+## Copyright (C) 2007-2008 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
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
 module ShogiServer
 
 class League
+
   #
   # This manages those players who have their player_id.
   # Since mk_rate mainly updates the yaml file, basically,
@@ -44,21 +64,6 @@ class League
       player.rating_group  = hash['rating_group']
       player.win           = hash['win']  || 0
       player.loss          = hash['loss'] || 0
-      player.last_game_win = hash['last_game_win'] || false
-    end
-
-    def save(player)
-      return unless player.player_id
-
-      each_group do |group, players|
-        hash = players[player.player_id]
-        if hash
-          # write only this property. 
-          # the others are updated by ./mk_rate
-          hash['last_game_win'] = player.last_game_win
-          break
-        end
-      end
     end
 
     def get_players