Fixed all file system speeds being off by one, causing raid to be broken.

Fixed potential NPE while loading, leading to raids losing their contents e.g.
This commit is contained in:
Florian Nücke 2016-01-03 12:22:24 +01:00
parent 337fed7d9c
commit db36d01032
30 changed files with 30 additions and 30 deletions

View File

@ -18,7 +18,7 @@ object DriverAPU extends DriverCPU with HostAware {
api.Items.get(Constants.ItemName.APUCreative))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else gpuTier(stack) match {
case Tier.One => new component.GraphicsCard(Tier.One)
case Tier.Two => new component.GraphicsCard(Tier.Two)

View File

@ -18,7 +18,7 @@ object DriverDataCard extends Item {
api.Items.get(Constants.ItemName.DataCardTier3))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else tier(stack) match {
case Tier.One => new component.DataCard.Tier1()
case Tier.Two => new component.DataCard.Tier2()

View File

@ -13,7 +13,7 @@ object DriverDebugCard extends Item {
api.Items.get(Constants.ItemName.DebugCard))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.DebugCard(host)
override def slot(stack: ItemStack) = Slot.Card

View File

@ -14,7 +14,7 @@ object DriverEEPROM extends Item {
api.Items.get(Constants.ItemName.EEPROM))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.EEPROM()
override def slot(stack: ItemStack) = Slot.EEPROM

View File

@ -24,7 +24,7 @@ object DriverFileSystem extends Item {
api.Items.get(Constants.ItemName.Floppy))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else Delegator.subItem(stack) match {
case Some(hdd: HardDiskDrive) => createEnvironment(stack, hdd.kiloBytes * 1024, hdd.platterCount, host, hdd.tier + 2)
case Some(disk: FloppyDisk) => createEnvironment(stack, Settings.get.floppySize * 1024, 1, host, 1)

View File

@ -14,7 +14,7 @@ object DriverGeolyzer extends Item with HostAware {
api.Items.get(Constants.BlockName.Geolyzer))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.Geolyzer(host)
override def slot(stack: ItemStack) = Slot.Upgrade

View File

@ -19,7 +19,7 @@ object DriverGraphicsCard extends Item with HostAware {
api.Items.get(Constants.ItemName.GraphicsCardTier3))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else tier(stack) match {
case Tier.One => new component.GraphicsCard(Tier.One)
case Tier.Two => new component.GraphicsCard(Tier.Two)

View File

@ -14,7 +14,7 @@ object DriverInternetCard extends Item {
api.Items.get(Constants.ItemName.InternetCard))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.InternetCard()
override def slot(stack: ItemStack) = Slot.Card

View File

@ -14,7 +14,7 @@ object DriverLinkedCard extends Item {
api.Items.get(Constants.ItemName.LinkedCard))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.LinkedCard()
override def slot(stack: ItemStack) = Slot.Card

View File

@ -14,7 +14,7 @@ object DriverNetworkCard extends Item with HostAware {
api.Items.get(Constants.ItemName.NetworkCard))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.NetworkCard(host)
override def slot(stack: ItemStack) = Slot.Card

View File

@ -22,7 +22,7 @@ object DriverRedstoneCard extends Item with HostAware {
api.Items.get(Constants.ItemName.RedstoneCardTier2))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else {
val isAdvanced = tier(stack) == Tier.Two
val hasBundled = BundledRedstone.isAvailable && isAdvanced

View File

@ -18,7 +18,7 @@ object DriverTablet extends Item {
api.Items.get(Constants.ItemName.Tablet))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else {
Tablet.Server.cache.invalidate(Tablet.getId(stack))
val data = new TabletData(stack)

View File

@ -14,7 +14,7 @@ object DriverTransposer extends Item with HostAware {
api.Items.get(Constants.BlockName.Transposer))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.Transposer.Upgrade(host)
override def slot(stack: ItemStack) = Slot.Upgrade

View File

@ -14,7 +14,7 @@ object DriverUpgradeAngel extends Item with HostAware {
api.Items.get(Constants.ItemName.AngelUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.UpgradeAngel()
override def slot(stack: ItemStack) = Slot.Upgrade

View File

@ -18,7 +18,7 @@ object DriverUpgradeBattery extends Item with HostAware {
api.Items.get(Constants.ItemName.BatteryUpgradeTier3))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.UpgradeBattery(tier(stack))
override def slot(stack: ItemStack) = Slot.Upgrade

View File

@ -15,7 +15,7 @@ object DriverUpgradeChunkloader extends Item with HostAware {
api.Items.get(Constants.ItemName.ChunkloaderUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.UpgradeChunkloader(host)
override def slot(stack: ItemStack) = Slot.Upgrade

View File

@ -16,7 +16,7 @@ object DriverUpgradeCrafting extends Item with HostAware {
api.Items.get(Constants.ItemName.CraftingUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else host match {
case robot: EnvironmentHost with Robot => new component.UpgradeCrafting(robot)
case _ => null

View File

@ -19,7 +19,7 @@ object DriverUpgradeDatabase extends Item with api.driver.item.HostAware {
api.Items.get(Constants.ItemName.DatabaseUpgradeTier3))
override def createEnvironment(stack: ItemStack, host: api.network.EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.UpgradeDatabase(new DatabaseInventory {
override def container = stack

View File

@ -16,7 +16,7 @@ object DriverUpgradeGenerator extends Item with HostAware {
api.Items.get(Constants.ItemName.GeneratorUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else host match {
case host: internal.Agent => new component.UpgradeGenerator(host)
case _ => null

View File

@ -18,7 +18,7 @@ object DriverUpgradeInventoryController extends Item with HostAware {
api.Items.get(Constants.ItemName.InventoryControllerUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else host match {
case host: EnvironmentHost with Adapter => new component.UpgradeInventoryController.Adapter(host)
case host: EnvironmentHost with Drone => new component.UpgradeInventoryController.Drone(host)

View File

@ -16,7 +16,7 @@ object DriverUpgradeLeash extends Item with HostAware {
api.Items.get(Constants.ItemName.LeashUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else host match {
case entity: Entity => new component.UpgradeLeash(entity)
case _ => null

View File

@ -16,7 +16,7 @@ object DriverUpgradeNavigation extends Item with HostAware {
api.Items.get(Constants.ItemName.NavigationUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else host match {
case rotatable: EnvironmentHost with Rotatable => new component.UpgradeNavigation(rotatable)
case _ => null

View File

@ -15,7 +15,7 @@ object DriverUpgradePiston extends Item with HostAware {
api.Items.get(Constants.ItemName.PistonUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else host match {
case host: internal.Drone => new component.UpgradePiston.Drone(host)
case host: internal.Tablet => new component.UpgradePiston.Tablet(host)

View File

@ -18,7 +18,7 @@ object DriverUpgradeSign extends Item with HostAware {
api.Items.get(Constants.ItemName.SignUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else host match {
case rotatable: EnvironmentHost with Rotatable => new UpgradeSignInRotatable(rotatable)
case adapter: EnvironmentHost with Adapter => new UpgradeSignInAdapter(adapter)

View File

@ -14,7 +14,7 @@ object DriverUpgradeSolarGenerator extends Item with HostAware {
api.Items.get(Constants.ItemName.SolarGeneratorUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.UpgradeSolarGenerator(host)
override def slot(stack: ItemStack) = Slot.Upgrade

View File

@ -13,7 +13,7 @@ object DriverUpgradeTank extends Item with HostAware {
api.Items.get(Constants.ItemName.TankUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.UpgradeTank(host, 16000)
override def slot(stack: ItemStack) = Slot.Upgrade

View File

@ -18,7 +18,7 @@ object DriverUpgradeTankController extends Item with HostAware {
api.Items.get(Constants.ItemName.TankControllerUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else host match {
case host: EnvironmentHost with Adapter => new component.UpgradeTankController.Adapter(host)
case host: EnvironmentHost with Drone => new component.UpgradeTankController.Drone(host)

View File

@ -19,7 +19,7 @@ object DriverUpgradeTractorBeam extends Item with HostAware {
api.Items.get(Constants.ItemName.TractorBeamUpgrade))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else host match {
case drone: Drone => new UpgradeTractorBeam.Drone(drone)
case robot: Robot => new component.UpgradeTractorBeam.Player(host, robot.player)

View File

@ -14,7 +14,7 @@ object DriverWirelessNetworkCard extends Item {
api.Items.get(Constants.ItemName.WirelessNetworkCard))
override def createEnvironment(stack: ItemStack, host: EnvironmentHost) =
if (host.world.isRemote) null
if (host.world != null && host.world.isRemote) null
else new component.WirelessNetworkCard(host)
override def slot(stack: ItemStack) = Slot.Card

View File

@ -114,7 +114,7 @@ object FileSystem extends api.detail.FileSystemAPI {
else new ReadOnlyWrapper(fileSystem)
def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: Label, host: EnvironmentHost, accessSound: String, speed: Int) =
Option(fileSystem).flatMap(fs => Some(new component.FileSystem(fs, label, Option(host), Option(accessSound), speed))).orNull
Option(fileSystem).flatMap(fs => Some(new component.FileSystem(fs, label, Option(host), Option(accessSound), (speed - 1) max 0 min 5))).orNull
def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: String, host: EnvironmentHost, accessSound: String, speed: Int) =
asManagedEnvironment(fileSystem, new ReadOnlyLabel(label), host, accessSound, speed)