#!/usr/bin/perl
#use Mooix::Thing;
run sub {
	my $this=shift;
	%_=@_;
	my $oldversion=$_{oldversion} || $this->croak("missing oldversion");
	
	if (39 > $oldversion) {
		# This field should not be inherited from parents, but is
		# unique to each object. However, if it would be inherited
		# directly from an object in the static object tree, don't
		# worry about it. This allows me to change hit points for
		# system objects later on..
		require Mooix::Conf;
		import Mooix::Conf;
		my $distid = $Mooix::Conf::field{distobj};
		if ($this->parent->id !~ /^\Q$distid\E/) {
			$this->hitpoints($this->hitpoints);
		}
	}
	
	if (43 > $oldversion) {
		# Mass is not inherited either, similar to hitpoints.
		require Mooix::Conf;
		import Mooix::Conf;
		my $distid = $Mooix::Conf::field{distobj};
		if ($this->parent->id !~ /^\Q$distid\E/) {
			$this->_mass($this->_mass);
		}
	}
	
	if (53 > $oldversion) {
		# Self-ownership was accidentially set up by splittree for
		# some ojects before.
		if ($this->defines("owner") && $this->owner == $this) {
			unlink($this->fieldfile("owner")) || 
				$this->croak("remove owner link");
		}
	}
	
	return 1;
}
