From 6aa72939b8dc9bf3a7a8fdeba11ecd407aa7d71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 4 Feb 2014 17:26:47 +0100 Subject: [PATCH] added setting for number of components for the different cpu tiers, closes #113 --- src/main/java/li/cil/oc/Settings.scala | 8 +++- src/main/java/li/cil/oc/common/item/CPU.scala | 2 +- .../cil/oc/server/driver/item/Processor.scala | 2 +- src/main/resources/reference.conf | 40 +++++++++++-------- 4 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/main/java/li/cil/oc/Settings.scala b/src/main/java/li/cil/oc/Settings.scala index 009a56be4..29ce934a9 100644 --- a/src/main/java/li/cil/oc/Settings.scala +++ b/src/main/java/li/cil/oc/Settings.scala @@ -43,6 +43,13 @@ class Settings(config: Config) { Array(64, 128, 256, 512, 1024) } val ramScaleFor64Bit = config.getDouble("computer.ramScaleFor64Bit") max 1 + val cpuComponentSupport = Array(config.getIntList("computer.cpuComponentCount"): _*) match { + case Array(tier1, tier2, tier3) => + Array(tier1: Int, tier2: Int, tier3: Int) + case _ => + OpenComputers.log.warning("Bad number of CPU component counts, ignoring.") + Array(8, 12, 16) + } val canComputersBeOwned = config.getBoolean("computer.canComputersBeOwned") val maxUsers = config.getInt("computer.maxUsers") max 0 val maxUsernameLength = config.getInt("computer.maxUsernameLength") max 0 @@ -169,7 +176,6 @@ object Settings { val scriptPath = "/assets/" + resourceDomain + "/lua/" val screenResolutionsByTier = Array((50, 16), (80, 25), (160, 50)) val screenDepthsByTier = Array(PackedColor.Depth.OneBit, PackedColor.Depth.FourBit, PackedColor.Depth.EightBit) - val componentCountByTier = Array(8, 12, 16) // From UniversalElectricity's CompatibilityType class, to avoid having to // ship the UE API (causes weird issues because the way we build the mod it diff --git a/src/main/java/li/cil/oc/common/item/CPU.scala b/src/main/java/li/cil/oc/common/item/CPU.scala index a971f1e8a..6b2ca7960 100644 --- a/src/main/java/li/cil/oc/common/item/CPU.scala +++ b/src/main/java/li/cil/oc/common/item/CPU.scala @@ -15,7 +15,7 @@ class CPU(val parent: Delegator, val tier: Int) extends Delegate { override def rarity = Array(EnumRarity.common, EnumRarity.uncommon, EnumRarity.rare).apply(tier max 0 min 2) override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) { - tooltip.addAll(Tooltip.get(baseName, Settings.componentCountByTier(tier))) + tooltip.addAll(Tooltip.get(baseName, Settings.get.cpuComponentSupport(tier))) super.tooltipLines(stack, player, tooltip, advanced) } diff --git a/src/main/java/li/cil/oc/server/driver/item/Processor.scala b/src/main/java/li/cil/oc/server/driver/item/Processor.scala index e2b8f0256..cf6b9f8a3 100644 --- a/src/main/java/li/cil/oc/server/driver/item/Processor.scala +++ b/src/main/java/li/cil/oc/server/driver/item/Processor.scala @@ -22,7 +22,7 @@ object Processor extends Item with driver.Processor { def supportedComponents(stack: ItemStack) = Items.multi.subItem(stack) match { - case Some(cpu: item.CPU) => Settings.componentCountByTier(cpu.tier) + case Some(cpu: item.CPU) => Settings.get.cpuComponentSupport(cpu.tier) case _ => 0 } } diff --git a/src/main/resources/reference.conf b/src/main/resources/reference.conf index 92f310a44..c50178011 100644 --- a/src/main/resources/reference.conf +++ b/src/main/resources/reference.conf @@ -12,10 +12,10 @@ opencomputers { # List of block IDs the mod uses for different types of blocks. This list # must contain exactly four entries, or it will be ignored. block: [ - 3650 - 3651 - 3652 - 3653 + 3650 + 3651 + 3652 + 3653 ] } @@ -102,11 +102,11 @@ opencomputers { # The sizes of the three tiers of RAM, in kilobytes. This list must # contain exactly three entries, or it will be ignored. ramSizes: [ - 64 - 128 - 256 - 512 - 1024 + 64 + 128 + 256 + 512 + 1024 ] # This setting allows you to fine-tune how RAM sizes are scaled internally @@ -125,6 +125,14 @@ opencomputers { # are really 45KB free, `computer.freeMemory` will return 32KB. ramScaleFor64Bit: 1.8 + # The number of components the different CPU tiers support. This list + # must contain exactly three entries, or it will be ignored. + cpuComponentCount: [ + 8 + 12 + 16 + ] + # This determines whether computers can only be used by players that are # registered as users on them. Per default a newly placed computer has no # users. Whenever there are no users the computer is free for all. Users @@ -549,9 +557,9 @@ opencomputers { # The sizes of the three tiers of hard drives, in kilobytes. This list # must contain exactly three entries, or it will be ignored. hddSizes: [ - 1024 - 2048 - 4096 + 1024 + 2048 + 4096 ] # The size of writable floppy disks, in kilobytes. @@ -596,10 +604,10 @@ opencomputers { # All entries are regular expression patterns, but they will only be # applied to the host name (domain) of a given URL. blacklist: [ - "^127\\.0\\.0\\.1$" - "^10\\.\\d+\\.\\d+\\.\\d+$" - "^192\\.\\d+\\.\\d+\\.\\d+$" - "^localhost$" + "^127\\.0\\.0\\.1$" + "^10\\.\\d+\\.\\d+\\.\\d+$" + "^192\\.\\d+\\.\\d+\\.\\d+$" + "^localhost$" ] # This is a list of whitelisted domain names. Requests may only be made to