diff --git a/src/mudlib/zmachine/zobjectparser.py b/src/mudlib/zmachine/zobjectparser.py index 5c265b6..0daad38 100644 --- a/src/mudlib/zmachine/zobjectparser.py +++ b/src/mudlib/zmachine/zobjectparser.py @@ -163,6 +163,8 @@ class ZObjectParser: def get_attribute(self, objectnum, attrnum): """Return value (0 or 1) of attribute number ATTRNUM of object number OBJECTNUM.""" + if objectnum == 0: + return 0 object_addr = self._get_object_addr(objectnum) @@ -183,6 +185,8 @@ class ZObjectParser: def set_attribute(self, objectnum, attrnum): """Set attribute number ATTRNUM of object number OBJECTNUM to 1.""" + if objectnum == 0: + return object_addr = self._get_object_addr(objectnum) @@ -206,6 +210,8 @@ class ZObjectParser: def clear_attribute(self, objectnum, attrnum): """Clear attribute number ATTRNUM of object number OBJECTNUM to 0.""" + if objectnum == 0: + return object_addr = self._get_object_addr(objectnum) @@ -247,18 +253,24 @@ class ZObjectParser: def get_parent(self, objectnum): """Return object number of parent of object number OBJECTNUM.""" + if objectnum == 0: + return 0 [parent, sibling, child] = self._get_parent_sibling_child(objectnum) return parent def get_child(self, objectnum): """Return object number of child of object number OBJECTNUM.""" + if objectnum == 0: + return 0 [parent, sibling, child] = self._get_parent_sibling_child(objectnum) return child def get_sibling(self, objectnum): """Return object number of sibling of object number OBJECTNUM.""" + if objectnum == 0: + return 0 [parent, sibling, child] = self._get_parent_sibling_child(objectnum) return sibling @@ -298,6 +310,8 @@ class ZObjectParser: def remove_object(self, objectnum): """Detach object OBJECTNUM from its parent (unlink from sibling chain).""" + if objectnum == 0: + return parent = self.get_parent(objectnum) if parent == 0: @@ -335,6 +349,8 @@ class ZObjectParser: Per the Z-spec: if new_child already has a parent, it is first removed from that parent's child list, then made the first child of parent_object.""" + if parent_object == 0 or new_child == 0: + return # Remove from old parent first (spec says "first removed") self.remove_object(new_child) @@ -347,6 +363,8 @@ class ZObjectParser: def get_shortname(self, objectnum): """Return 'short name' of object number OBJECTNUM as ascii string.""" + if objectnum == 0: + return "" addr = self._get_proptable_addr(objectnum) return self._stringfactory.get(addr + 1) @@ -354,6 +372,8 @@ class ZObjectParser: def get_prop(self, objectnum, propnum): """Return either a byte or word value of property PROPNUM of object OBJECTNUM.""" + if objectnum == 0: + return 0 (addr, size) = self.get_prop_addr_len(objectnum, propnum) if size == 1: return self._memory[addr] @@ -467,6 +487,8 @@ class ZObjectParser: def get_property_data_address(self, objectnum, propnum): """Return the address of property PROPNUM's data bytes for object OBJECTNUM. Return 0 if the object doesn't have that property.""" + if objectnum == 0: + return 0 try: addr, size = self.get_prop_addr_len(objectnum, propnum) @@ -484,6 +506,8 @@ class ZObjectParser: """If PROPNUM is 0, return the first property number of object OBJECTNUM. Otherwise, return the property number after PROPNUM in the property list. Return 0 if there are no more properties.""" + if objectnum == 0: + return 0 if propnum == 0: # Return first property number