# file:: chucho_mud.rb # author:: Ralph M. Churchill # version:: # date:: # # This source code copyright (C) 2006 by Ralph M. Churchill # All rights reserved. # # Released under the terms of the GNU General Public License # See LICENSE file for additional information. require 'rubygems' require 'optparse' require 'ostruct' $: << 'lib' unless $:.include?('lib') require 'network/manager' require 'engine/game_engine' def handle_signal(sig) exit end def parse_args(argv) options = OpenStruct.new opts = OptionParser.new do |opts| opts.banner = "Usage: chucho_mud.rb [options]" opts.separator "" opts.separator "Specific options:" opts.on("-m","--module MODULE", "Indicate which Module to load") do |module_name| options.module = module_name end opts.separator "" opts.separator "Common options:" opts.on_tail("-h", "--help", "Show this message") do puts opts exit end =begin opts.on_tail("--version","Show version") do puts Version.join('.') exit end =end end begin opts.parse(argv) raise "Error: Module Required." if options.module.nil? rescue => e $stderr.puts e puts opts exit end options end if $0 == __FILE__ Signal.trap("INT",method(:handle_signal)) Signal.trap("TERM",method(:handle_signal)) Signal.trap("KILL",method(:handle_signal)) options = parse_args(ARGV) GameEngine.instance.startup(options) begin manager = NetManager.new(GameEngine.instance,4000) while true manager.manage end ensure GameEngine.instance.shutdown $stdout.puts 'Shutdown Complete' end end