From 20239780e194470589f46d04cf4b57e180934c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Wed, 22 Apr 2015 15:21:43 +0200 Subject: [PATCH] Extended file system API to allow specifying a speed multiplier for file systems. For now, valid range is [1,6]. Floppies use 1, HDDs use 2-4, Raid is 6. Deprecated some internal FileSystem interface methods to allow simplifying the interface a bit when the time comes. Let's hope nobody is shipping the API \o/ --- src/main/java/li/cil/oc/api/API.java | 2 +- src/main/java/li/cil/oc/api/FileSystem.java | 105 ++++++++++++++---- .../li/cil/oc/api/detail/FileSystemAPI.java | 66 +++++++---- src/main/java/li/cil/oc/api/fs/Label.java | 2 +- .../li/cil/oc/common/tileentity/Raid.scala | 2 +- .../opencomputers/DriverFileSystem.scala | 8 +- .../cil/oc/server/component/FileSystem.scala | 71 +++++++++++- .../li/cil/oc/server/fs/FileSystem.scala | 16 ++- .../li/cil/oc/server/machine/Machine.scala | 2 +- 9 files changed, 211 insertions(+), 63 deletions(-) diff --git a/src/main/java/li/cil/oc/api/API.java b/src/main/java/li/cil/oc/api/API.java index adbec7d9cf..d3c61206c4 100644 --- a/src/main/java/li/cil/oc/api/API.java +++ b/src/main/java/li/cil/oc/api/API.java @@ -16,7 +16,7 @@ */ public class API { public static final String ID_OWNER = "OpenComputers|Core"; - public static final String VERSION = "5.1.1"; + public static final String VERSION = "5.2.0"; public static DriverAPI driver = null; public static FileSystemAPI fileSystem = null; diff --git a/src/main/java/li/cil/oc/api/FileSystem.java b/src/main/java/li/cil/oc/api/FileSystem.java index b9170805b6..e126f64408 100644 --- a/src/main/java/li/cil/oc/api/FileSystem.java +++ b/src/main/java/li/cil/oc/api/FileSystem.java @@ -141,6 +141,17 @@ public static li.cil.oc.api.fs.FileSystem fromComputerCraft(final Object mount) * access sounds. *

* The container may be null, if no such context can be provided. + *

+ * The access sound is the name of the sound effect to play when the file + * system is accessed, for example by listing a directory or reading from + * a file. It may be null to create a silent file system. + *

+ * The speed multiplier controls how fast read and write operations on the + * file system are. It must be a value in [1,6], and controls the access + * speed, with the default being one. + * For reference, floppies are using the default, hard drives scale with + * their tiers, i.e. a tier one hard drive uses speed two, tier three uses + * speed four. * * @param fileSystem the file system to wrap. * @param label the label of the file system. @@ -149,73 +160,121 @@ public static li.cil.oc.api.fs.FileSystem fromComputerCraft(final Object mount) * system is accessed. This has to be the fully * qualified resource name, e.g. * opencomputers:floppy_access. + * @param speed the speed multiplier for this file system. * @return the network node wrapping the file system. */ - public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final Label label, final EnvironmentHost host, final String accessSound) { + public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final Label label, final EnvironmentHost host, final String accessSound, int speed) { if (API.fileSystem != null) - return API.fileSystem.asManagedEnvironment(fileSystem, label, host, accessSound); + return API.fileSystem.asManagedEnvironment(fileSystem, label, host, accessSound, speed); return null; } /** - * Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, li.cil.oc.api.driver.EnvironmentHost, String)}, - * but creates a read-only label initialized to the specified value. + * Creates a network node that makes the specified file system available via + * the common file system driver. + *

+ * Creates a file system with the a read-only label and the specified + * access sound and file system speed. * * @param fileSystem the file system to wrap. - * @param label the read-only label of the file system. + * @param label the label of the file system. * @param host the tile entity containing the file system. * @param accessSound the name of the sound effect to play when the file * system is accessed. This has to be the fully * qualified resource name, e.g. * opencomputers:floppy_access. + * @param speed the speed multiplier for this file system. * @return the network node wrapping the file system. */ - public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final String label, final EnvironmentHost host, final String accessSound) { + public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final String label, final EnvironmentHost host, final String accessSound, int speed) { if (API.fileSystem != null) - return API.fileSystem.asManagedEnvironment(fileSystem, label, host, accessSound); + return API.fileSystem.asManagedEnvironment(fileSystem, label, host, accessSound, speed); return null; } /** - * Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, li.cil.oc.api.driver.EnvironmentHost, String)}, - * but does not provide a container. + * Creates a network node that makes the specified file system available via + * the common file system driver. + *

+ * Creates a file system with the specified label and the specified access + * sound, using the default file system speed. + * + * @param fileSystem the file system to wrap. + * @param label the label of the file system. + * @param host the tile entity containing the file system. + * @param accessSound the name of the sound effect to play when the file + * system is accessed. This has to be the fully + * qualified resource name, e.g. + * opencomputers:floppy_access. + * @return the network node wrapping the file system. + */ + public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final Label label, final EnvironmentHost host, final String accessSound) { + return asManagedEnvironment(fileSystem, label, host, accessSound, 1); + } + + /** + * Creates a network node that makes the specified file system available via + * the common file system driver. + *

+ * Creates a file system with a read-only label and the specified access + * sound, using the default file system speed. + * + * @param fileSystem the file system to wrap. + * @param label the read-only label of the file system. + * @param host the tile entity containing the file system. + * @param accessSound the name of the sound effect to play when the file + * system is accessed. This has to be the fully + * qualified resource name, e.g. + * opencomputers:floppy_access. + * @return the network node wrapping the file system. + */ + public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final String label, final EnvironmentHost host, final String accessSound) { + return asManagedEnvironment(fileSystem, label, host, accessSound, 1); + } + + /** + * Creates a network node that makes the specified file system available via + * the common file system driver. + *

+ * Creates a file system with the specified label, without an environment + * and access sound, using the default file system speed. * * @param fileSystem the file system to wrap. * @param label the label of the file system. * @return the network node wrapping the file system. */ public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final Label label) { - if (API.fileSystem != null) - return API.fileSystem.asManagedEnvironment(fileSystem, label); - return null; + return asManagedEnvironment(fileSystem, label, null, null, 1); } /** - * Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label)}, - * but creates a read-only label initialized to the specified value. + * Creates a network node that makes the specified file system available via + * the common file system driver. + *

+ * Creates a file system with a read-only label, without an environment and + * access sound, using the default file system speed. * * @param fileSystem the file system to wrap. * @param label the read-only label of the file system. * @return the network node wrapping the file system. */ public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final String label) { - if (API.fileSystem != null) - return API.fileSystem.asManagedEnvironment(fileSystem, label); - return null; + return asManagedEnvironment(fileSystem, label, null, null, 1); } /** - * Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label)}, - * but creates an unlabeled file system (i.e. the label can neither be read - * nor written). + * Creates a network node that makes the specified file system available via + * the common file system driver. + *

+ * Creates an unlabeled file system (i.e. the label can neither be read nor + * written), without an environment and access sound, using the default + * file system speed. * * @param fileSystem the file system to wrap. * @return the network node wrapping the file system. */ public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem) { - if (API.fileSystem != null) - return API.fileSystem.asManagedEnvironment(fileSystem); - return null; + return asManagedEnvironment(fileSystem, (Label) null, null, null, 1); } // ----------------------------------------------------------------------- // diff --git a/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java b/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java index e0a53518d2..b45bd5b3e9 100644 --- a/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java +++ b/src/main/java/li/cil/oc/api/detail/FileSystemAPI.java @@ -97,56 +97,76 @@ public interface FileSystemAPI { * access sounds. *

* The container may be null, if no such context can be provided. + *

+ * The access sound is the name of the sound effect to play when the file + * system is accessed, for example by listing a directory or reading from + * a file. It may be null to create a silent file system. + *

+ * The speed multiplier controls how fast read and write operations on the + * file system are. It must be a value in [1,6], and controls the access + * speed, with the default being one. + * For reference, floppies are using the default, hard drives scale with + * their tiers, i.e. a tier one hard drive uses speed two, tier three uses + * speed four. * * @param fileSystem the file system to wrap. * @param label the label of the file system. * @param host the tile entity containing the file system. * @param accessSound the name of the sound effect to play when the file - * system is accessed. + * system is accessed. This has to be the fully + * qualified resource name, e.g. + * opencomputers:floppy_access. + * @param speed the speed multiplier for this file system. * @return the network node wrapping the file system. */ - ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, Label label, EnvironmentHost host, String accessSound); + ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, Label label, EnvironmentHost host, String accessSound, int speed); /** - * Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, li.cil.oc.api.driver.EnvironmentHost, String)}, - * but creates a read-only label initialized to the specified value. + * Creates a network node that makes the specified file system available via + * the common file system driver. + *

+ * Creates a file system with the a read-only label and the specified + * access sound and file system speed. * * @param fileSystem the file system to wrap. * @param label the read-only label of the file system. * @param host the tile entity containing the file system. * @param accessSound the name of the sound effect to play when the file - * system is accessed. + * system is accessed. This has to be the fully + * qualified resource name, e.g. + * opencomputers:floppy_access. + * @param speed the speed multiplier for this file system. * @return the network node wrapping the file system. */ + ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, String label, EnvironmentHost host, String accessSound, int speed); + + /** + * @deprecated Don't use this directly, use the wrapper in {@link li.cil.oc.api.FileSystem}. + */ + @Deprecated + ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, Label label, EnvironmentHost host, String accessSound); + + /** + * @deprecated Don't use this directly, use the wrapper in {@link li.cil.oc.api.FileSystem}. + */ + @Deprecated ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, String label, EnvironmentHost host, String accessSound); /** - * Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, li.cil.oc.api.driver.EnvironmentHost, String)}, - * but does not provide a container and access sound. - * - * @param fileSystem the file system to wrap. - * @param label the label of the file system. - * @return the network node wrapping the file system. + * @deprecated Don't use this directly, use the wrapper in {@link li.cil.oc.api.FileSystem}. */ + @Deprecated ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, Label label); /** - * Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label)}, - * but creates a read-only label initialized to the specified value. - * - * @param fileSystem the file system to wrap. - * @param label the read-only label of the file system. - * @return the network node wrapping the file system. + * @deprecated Don't use this directly, use the wrapper in {@link li.cil.oc.api.FileSystem}. */ + @Deprecated ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, String label); /** - * Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label)}, - * but creates an unlabeled file system (i.e. the label can neither be read - * nor written). - * - * @param fileSystem the file system to wrap. - * @return the network node wrapping the file system. + * @deprecated Don't use this directly, use the wrapper in {@link li.cil.oc.api.FileSystem}. */ + @Deprecated ManagedEnvironment asManagedEnvironment(FileSystem fileSystem); } \ No newline at end of file diff --git a/src/main/java/li/cil/oc/api/fs/Label.java b/src/main/java/li/cil/oc/api/fs/Label.java index e98e45cdbc..4256c80ff6 100644 --- a/src/main/java/li/cil/oc/api/fs/Label.java +++ b/src/main/java/li/cil/oc/api/fs/Label.java @@ -5,7 +5,7 @@ /** * Used by file system components to get and set the file system's label. * - * @see li.cil.oc.api.FileSystem#asManagedEnvironment(FileSystem, Label) + * @see li.cil.oc.api.FileSystem#asManagedEnvironment */ public interface Label extends Persistable { /** diff --git a/src/main/scala/li/cil/oc/common/tileentity/Raid.scala b/src/main/scala/li/cil/oc/common/tileentity/Raid.scala index def714fdae..590a56cea9 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Raid.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Raid.scala @@ -81,7 +81,7 @@ class Raid extends traits.Environment with traits.Inventory with traits.Rotatabl filesystem.foreach(fs => if (fs.node != null) fs.node.remove()) val fs = api.FileSystem.asManagedEnvironment( api.FileSystem.fromSaveDirectory(id, wipeDisksAndComputeSpace, Settings.get.bufferChanges), - label, this, Settings.resourceDomain + ":hdd_access"). + label, this, Settings.resourceDomain + ":hdd_access", 6). asInstanceOf[FileSystem] val nbtToSetAddress = new NBTTagCompound() nbtToSetAddress.setString("address", id) diff --git a/src/main/scala/li/cil/oc/integration/opencomputers/DriverFileSystem.scala b/src/main/scala/li/cil/oc/integration/opencomputers/DriverFileSystem.scala index 17a7304fe4..824d04533d 100644 --- a/src/main/scala/li/cil/oc/integration/opencomputers/DriverFileSystem.scala +++ b/src/main/scala/li/cil/oc/integration/opencomputers/DriverFileSystem.scala @@ -22,8 +22,8 @@ object DriverFileSystem extends Item { override def createEnvironment(stack: ItemStack, host: EnvironmentHost) = Delegator.subItem(stack) match { - case Some(hdd: HardDiskDrive) => createEnvironment(stack, hdd.kiloBytes * 1024, host) - case Some(disk: FloppyDisk) => createEnvironment(stack, Settings.get.floppySize * 1024, host) + case Some(hdd: HardDiskDrive) => createEnvironment(stack, hdd.kiloBytes * 1024, host, hdd.tier + 2) + case Some(disk: FloppyDisk) => createEnvironment(stack, Settings.get.floppySize * 1024, host, 1) case _ => null } @@ -40,14 +40,14 @@ object DriverFileSystem extends Item { case _ => 0 } - private def createEnvironment(stack: ItemStack, capacity: Int, host: EnvironmentHost) = { + private def createEnvironment(stack: ItemStack, capacity: Int, host: EnvironmentHost, speed: Int) = { // We have a bit of a chicken-egg problem here, because we want to use the // node's address as the folder name... so we generate the address here, // if necessary. No one will know, right? Right!? val address = addressFromTag(dataTag(stack)) val isFloppy = api.Items.get(stack) == api.Items.get(Constants.ItemName.Floppy) val fs = oc.api.FileSystem.fromSaveDirectory(address, capacity, Settings.get.bufferChanges) - val environment = oc.api.FileSystem.asManagedEnvironment(fs, new ReadWriteItemLabel(stack), host, Settings.resourceDomain + ":" + (if (isFloppy) "floppy_access" else "hdd_access")) + val environment = oc.api.FileSystem.asManagedEnvironment(fs, new ReadWriteItemLabel(stack), host, Settings.resourceDomain + ":" + (if (isFloppy) "floppy_access" else "hdd_access"), speed) if (environment != null && environment.node != null) { environment.node.asInstanceOf[oc.server.network.Node].address = address } diff --git a/src/main/scala/li/cil/oc/server/component/FileSystem.scala b/src/main/scala/li/cil/oc/server/component/FileSystem.scala index 552b7d14bd..10d6e3487d 100644 --- a/src/main/scala/li/cil/oc/server/component/FileSystem.scala +++ b/src/main/scala/li/cil/oc/server/component/FileSystem.scala @@ -23,7 +23,7 @@ import net.minecraftforge.common.util.Constants.NBT import scala.collection.mutable -class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option[EnvironmentHost] = None, val sound: Option[String] = None) extends prefab.ManagedEnvironment { +class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option[EnvironmentHost], val sound: Option[String]) extends prefab.ManagedEnvironment { override val node = Network.newNode(this, Visibility.Network). withComponent("filesystem", Visibility.Neighbors). withConnector(). @@ -151,7 +151,6 @@ class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option result(handle) } - @Callback(direct = true, limit = 4, doc = """function(handle:number, count:number):string or nil -- Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached.""") def read(context: Context, args: Arguments): Array[AnyRef] = fileSystem.synchronized { val handle = args.checkInteger(0) val n = math.min(Settings.get.maxReadBuffer, math.max(0, args.checkInteger(1))) @@ -183,7 +182,6 @@ class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option } } - @Callback(direct = true, limit = 4, doc = """function(handle:number, whence:string, offset:number):number -- Seeks in an open file descriptor with the specified handle. Returns the new pointer position.""") def seek(context: Context, args: Arguments): Array[AnyRef] = fileSystem.synchronized { val handle = args.checkInteger(0) val whence = args.checkString(1) @@ -202,7 +200,6 @@ class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option } } - @Callback(doc = """function(handle:number, value:string):boolean -- Writes the specified data to an open file descriptor with the specified handle.""") def write(context: Context, args: Arguments): Array[AnyRef] = fileSystem.synchronized { val handle = args.checkInteger(0) val value = args.checkByteArray(1) @@ -315,3 +312,69 @@ class FileSystem(val fileSystem: IFileSystem, var label: Label, val host: Option } } } + +object FileSystem { + // I really need to come up with a way to make the call limit dynamic... + def apply(fileSystem: IFileSystem, label: Label, host: Option[EnvironmentHost], sound: Option[String], speed: Int = 1): FileSystem = speed match { + case 6 => new FileSystem(fileSystem, label, host, sound) { + @Callback(direct = true, limit = 15, doc = """function(handle:number, count:number):string or nil -- Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached.""") + override def read(context: Context, args: Arguments): Array[AnyRef] = super.read(context, args) + + @Callback(direct = true, limit = 15, doc = """function(handle:number, whence:string, offset:number):number -- Seeks in an open file descriptor with the specified handle. Returns the new pointer position.""") + override def seek(context: Context, args: Arguments): Array[AnyRef] = super.seek(context, args) + + @Callback(direct = true, limit = 6, doc = """function(handle:number, value:string):boolean -- Writes the specified data to an open file descriptor with the specified handle.""") + override def write(context: Context, args: Arguments): Array[AnyRef] = super.write(context, args) + } + case 5 => new FileSystem(fileSystem, label, host, sound) { + @Callback(direct = true, limit = 13, doc = """function(handle:number, count:number):string or nil -- Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached.""") + override def read(context: Context, args: Arguments): Array[AnyRef] = super.read(context, args) + + @Callback(direct = true, limit = 13, doc = """function(handle:number, whence:string, offset:number):number -- Seeks in an open file descriptor with the specified handle. Returns the new pointer position.""") + override def seek(context: Context, args: Arguments): Array[AnyRef] = super.seek(context, args) + + @Callback(direct = true, limit = 5, doc = """function(handle:number, value:string):boolean -- Writes the specified data to an open file descriptor with the specified handle.""") + override def write(context: Context, args: Arguments): Array[AnyRef] = super.write(context, args) + } + case 4 => new FileSystem(fileSystem, label, host, sound) { + @Callback(direct = true, limit = 10, doc = """function(handle:number, count:number):string or nil -- Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached.""") + override def read(context: Context, args: Arguments): Array[AnyRef] = super.read(context, args) + + @Callback(direct = true, limit = 10, doc = """function(handle:number, whence:string, offset:number):number -- Seeks in an open file descriptor with the specified handle. Returns the new pointer position.""") + override def seek(context: Context, args: Arguments): Array[AnyRef] = super.seek(context, args) + + @Callback(direct = true, limit = 4, doc = """function(handle:number, value:string):boolean -- Writes the specified data to an open file descriptor with the specified handle.""") + override def write(context: Context, args: Arguments): Array[AnyRef] = super.write(context, args) + } + case 3 => new FileSystem(fileSystem, label, host, sound) { + @Callback(direct = true, limit = 7, doc = """function(handle:number, count:number):string or nil -- Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached.""") + override def read(context: Context, args: Arguments): Array[AnyRef] = super.read(context, args) + + @Callback(direct = true, limit = 7, doc = """function(handle:number, whence:string, offset:number):number -- Seeks in an open file descriptor with the specified handle. Returns the new pointer position.""") + override def seek(context: Context, args: Arguments): Array[AnyRef] = super.seek(context, args) + + @Callback(direct = true, limit = 3, doc = """function(handle:number, value:string):boolean -- Writes the specified data to an open file descriptor with the specified handle.""") + override def write(context: Context, args: Arguments): Array[AnyRef] = super.write(context, args) + } + case 2 => new FileSystem(fileSystem, label, host, sound) { + @Callback(direct = true, limit = 4, doc = """function(handle:number, count:number):string or nil -- Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached.""") + override def read(context: Context, args: Arguments): Array[AnyRef] = super.read(context, args) + + @Callback(direct = true, limit = 4, doc = """function(handle:number, whence:string, offset:number):number -- Seeks in an open file descriptor with the specified handle. Returns the new pointer position.""") + override def seek(context: Context, args: Arguments): Array[AnyRef] = super.seek(context, args) + + @Callback(direct = true, limit = 2, doc = """function(handle:number, value:string):boolean -- Writes the specified data to an open file descriptor with the specified handle.""") + override def write(context: Context, args: Arguments): Array[AnyRef] = super.write(context, args) + } + case _ => new FileSystem(fileSystem, label, host, sound) { + @Callback(direct = true, limit = 1, doc = """function(handle:number, count:number):string or nil -- Reads up to the specified amount of data from an open file descriptor with the specified handle. Returns nil when EOF is reached.""") + override def read(context: Context, args: Arguments): Array[AnyRef] = super.read(context, args) + + @Callback(direct = true, limit = 1, doc = """function(handle:number, whence:string, offset:number):number -- Seeks in an open file descriptor with the specified handle. Returns the new pointer position.""") + override def seek(context: Context, args: Arguments): Array[AnyRef] = super.seek(context, args) + + @Callback(direct = true, limit = 1, doc = """function(handle:number, value:string):boolean -- Writes the specified data to an open file descriptor with the specified handle.""") + override def write(context: Context, args: Arguments): Array[AnyRef] = super.write(context, args) + } + } +} diff --git a/src/main/scala/li/cil/oc/server/fs/FileSystem.scala b/src/main/scala/li/cil/oc/server/fs/FileSystem.scala index 86422ab36f..4f500240c1 100644 --- a/src/main/scala/li/cil/oc/server/fs/FileSystem.scala +++ b/src/main/scala/li/cil/oc/server/fs/FileSystem.scala @@ -104,20 +104,26 @@ object FileSystem extends api.detail.FileSystemAPI { } else null + def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: Label, host: EnvironmentHost, accessSound: String, speed: Int) = + Option(fileSystem).flatMap(fs => Some(component.FileSystem(fs, label, Option(host), Option(accessSound), speed))).orNull + + def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: String, host: EnvironmentHost, accessSound: String, speed: Int) = + asManagedEnvironment(fileSystem, new ReadOnlyLabel(label), host, accessSound, speed) + def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: Label, host: EnvironmentHost, sound: String) = - Option(fileSystem).flatMap(fs => Some(new component.FileSystem(fs, label, Option(host), Option(sound)))).orNull + asManagedEnvironment(fileSystem, label, host, sound, 1) def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: String, host: EnvironmentHost, sound: String) = - asManagedEnvironment(fileSystem, new ReadOnlyLabel(label), host, sound) + asManagedEnvironment(fileSystem, new ReadOnlyLabel(label), host, sound, 1) def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: Label) = - Option(fileSystem).flatMap(fs => Some(new component.FileSystem(fs, label))).orNull + asManagedEnvironment(fileSystem, label, null, null, 1) def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: String) = - asManagedEnvironment(fileSystem, new ReadOnlyLabel(label)) + asManagedEnvironment(fileSystem, new ReadOnlyLabel(label), null, null, 1) def asManagedEnvironment(fileSystem: api.fs.FileSystem) = - asManagedEnvironment(fileSystem, null: Label) + asManagedEnvironment(fileSystem, null: Label, null, null, 1) abstract class ItemLabel(val stack: ItemStack) extends Label diff --git a/src/main/scala/li/cil/oc/server/machine/Machine.scala b/src/main/scala/li/cil/oc/server/machine/Machine.scala index 92033ef976..bb63cddf85 100644 --- a/src/main/scala/li/cil/oc/server/machine/Machine.scala +++ b/src/main/scala/li/cil/oc/server/machine/Machine.scala @@ -53,7 +53,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach val tmp = if (Settings.get.tmpSize > 0) { Option(FileSystem.asManagedEnvironment(FileSystem. - fromMemory(Settings.get.tmpSize * 1024), "tmpfs")) + fromMemory(Settings.get.tmpSize * 1024), "tmpfs", null, null, 5)) } else None var architecture: Architecture = _