From a21a12b4c47b3042be1be4927a68e1aee2bca781 Mon Sep 17 00:00:00 2001 From: beatles Date: Tue, 7 Oct 2008 13:09:10 +0000 Subject: [PATCH] players.yaml is now read only. The server no longer writes last_game_win data to it. It will be written in another file (in future). --- shogi-server | 2 -- shogi_server/league.rb | 13 ------------- shogi_server/league/persistent.rb | 35 ++++++++++++++++++++--------------- 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/shogi-server b/shogi-server index fc19b06..1f5a9f5 100755 --- a/shogi-server +++ b/shogi-server @@ -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"] diff --git a/shogi_server/league.rb b/shogi_server/league.rb index 82e3b56..29d7bf2 100644 --- a/shogi_server/league.rb +++ b/shogi_server/league.rb @@ -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| diff --git a/shogi_server/league/persistent.rb b/shogi_server/league/persistent.rb index ae1ce1c..8d5ab98 100644 --- a/shogi_server/league/persistent.rb +++ b/shogi_server/league/persistent.rb @@ -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 -- 2.11.0