#!/usr/bin/perl
#use Mooix::Thing;
run sub {
	my $this=shift;
	%_=@_;
	my $oldversion=$_{oldversion} || $this->croak("missing oldversion");
	
	if (38 > $oldversion) {
		# this goes away, the endmass and endvolume fields are now
		# used instead. Supply them with default values.
		if ($this->defines("consume_destroy")) {
			$this->endmass(0.01);
			$this->endvolume(0.01);
		}
		# convert current field to mass
		$this->mass($this->endmass + (($this->startmass - $this->endmass) / $this->max) * $this->current);
		# maybe set volume as well
		unless ($this->changevolume) {
			$this->volume($this->endvolume + (($this->startvolume - $this->endvolume) / $this->max) * $this->current);
		}
		unlink($this->fieldfile("current"));
	}

	return $this->super(@_);
}
