Permalink
Browse files

Merge branch 'tjkirch/origin'

  • Loading branch information...
presidentbeef committed Apr 25, 2011
2 parents 9483a92 + 997e360 commit 6fd750e8034af0b8434243f52d78c4e5fb212d67
Showing with 31 additions and 14 deletions.
  1. +1 −1 components/commandparser.rb
  2. +1 −3 components/manager.rb
  3. +22 −5 components/storage.rb
  4. +1 −2 events/admin.rb
  5. +1 −1 lib/gary.rb
  6. +5 −2 traits/reacts.rb
@@ -241,7 +241,7 @@ def parse(player, input)
elsif @news.include? command
parse_news input
elsif @mobile.include? command and player.is_a? Mobile
parse_mobile command
parse_mobile command ### implement me
elsif input =~ /^alarm\s+([0-9]+)$/i
after $1.to_i do
player.output "***ALARM***"
View
@@ -20,8 +20,8 @@ class Manager
#a Manager object in an external script.
def initialize(objects = nil)
@soft_restart = false
@storage = StorageMachine.new
@uptime = Time.new.to_i
unless objects
@cancelled_events = Set.new
@@ -38,8 +38,6 @@ def initialize(objects = nil)
else
@game_objects = objects
end
@uptime = Time.new.to_i
end
#Checks if a game object ID exists already, to avoid conflicts.
View
@@ -8,15 +8,32 @@
load 'util/all-behaviors.rb'
load 'util/all-objects.rb'
#Storage class for object persistance. Uses GDBM.
# Storage class for object persistance. Uses GDBM.
#
#GDBM is a file-system hash table which is fast and available on many platforms. However, it only stores strings. So objects are stored as Strings representing the marshaled object.
# GDBM is a file-system hash table which is fast and available on many
# platforms. However, it only stores strings. So objects are stored as Strings
# representing the marshaled object.
#
#The default storage system works this way: each GameObject is stored in a file which is named after the GameObject's class. For example, a Door would be in storage/Door. In each file, objects are indexed by their GOID. There is a special file in storage/goids which lists GOIDs and the class of the GameObject. This is used to find Objects according to their GOID.
# The default storage system works this way: each GameObject is stored in a
# file which is named after the GameObject's class. For example, a Door would
# be in storage/Door. In each file, objects are indexed by their GOID. There
# is a special file in storage/goids which lists GOIDs and the class of the
# GameObject. This is used to find Objects according to their GOID.
#
#Here is an example: you want to load an object with a GOID of 476dfe3e-96bc-1952-fadd-26c22043a5a3. The StorageMachine will first open up storage/goids and retrieve the class pointed to by 476dfe3e-96bc-1952-fadd-26c22043a5a3, which happens to be Dog. The StorageMachine then opens up storage/Dog and again retrieves the Object pointed to by 476dfe3e-96bc-1952-fadd-26c22043a5a3, but this time it will be the (marshaled string of the) Dog object.
# Here is an example: you want to load an object with a GOID of
# 476dfe3e-96bc-1952-fadd-26c22043a5a3. The StorageMachine will first open up
# storage/goids and retrieve the class pointed to by
# 476dfe3e-96bc-1952-fadd-26c22043a5a3, which happens to be Dog. The
# StorageMachine then opens up storage/Dog and again retrieves the Object
# pointed to by 476dfe3e-96bc-1952-fadd-26c22043a5a3, but this time it will be
# the (marshaled string of the) Dog object.
#
#Of course, there is an exception. Players are handled differently, because they are typically looked up by name and not by their GOID. Instead of being listed in storage/goids, they are listed in storage/players. This file maps player names to GOIDs. Then they can be looked up by GOID in the storage/Player file. Additionally, passwords are stored as MD5 hashes in storage/passwords, indexed by GOID (a tiny bit of security there).
# Of course, there are exceptions. Players are handled differently, because
# they are typically looked up by name and not by their GOID. Instead of being
# listed in storage/goids, they are listed in storage/players. This file maps
# player names to GOIDs. Then they can be looked up by GOID in the
# storage/Player file. Additionally, passwords are stored as MD5 hashes in
# storage/passwords, indexed by GOID (a tiny bit of security there).
class StorageMachine
def initialize(path = 'storage/')
@path = path
View
@@ -571,7 +571,7 @@ def aset(event, player, room)
when "false"
value = false
when /^:/
value = value.to_sym
value = value[1..-1].to_sym
when "nil"
value = nil
when /^[0-9]+$/
@@ -899,7 +899,6 @@ def areaction(event, player, room)
elsif not object.is_a? Reacts and (event[:command] == "load" or event[:command] == "reload")
player.output "Object cannot react, adding react ability."
object.extend(Reacts)
object.init_reactor
end
case event[:command]
View
@@ -134,7 +134,7 @@ def find_all(attrib, match)
when /^\d+$/
match = match.to_i
when /^:/
match = match.to_sym
match = match[1..-1].to_sym
end
if attrib == "class" and (match.is_a? Class or match.is_a? Module)
@ghash.dup.each do |goid, obj|
View
@@ -11,8 +11,11 @@ def uses_reaction? file
@reactions_files.include? file
end
#This is called when the object is created, but if the
#module is mixed in dynamically this needs to be called before being used
# Automatically set up the reactor when we extend an object
def self.extended(obj)
obj.init_reactor
end
def init_reactor
@reactor ||= Reactor.new(self)
@reaction_files ||= Set.new

0 comments on commit 6fd750e

Please sign in to comment.