Skip to content

Commit

Permalink
Add a config option to disable the legacy loader to preserve old 0.9
Browse files Browse the repository at this point in the history
worlds.
  • Loading branch information
Victorious3 committed Aug 9, 2015
1 parent 7108d5b commit dd8de0d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ private Config() {
public static boolean enableTooltips;
public static int sevenSegmentMaxDigits;

public static boolean enableLegacyLoader;

// TODO Generalize!
public static void preInitialize(File file) {
config = new Configuration(file);
Expand All @@ -44,6 +46,7 @@ public static void loadValues() {
enableTooltips = config.getBoolean("enableTooltips", "GENERAL", true, "");
enableTracker = config.getBoolean("enableTracker", "GENERAL", true, "");
sevenSegmentMaxDigits = config.getInt("sevenSegmentMaxDigits", "GENERAL", 16, 1, 16, "");
enableLegacyLoader = config.getBoolean("enableLegacyLoader", "GENERAL", true, "");

config.setCategoryRequiresMcRestart("PARTS", true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.LinkedList;
import java.util.List;

import moe.nightfall.vic.integratedcircuits.Config;
import moe.nightfall.vic.integratedcircuits.IntegratedCircuits;
import moe.nightfall.vic.integratedcircuits.cp.legacy.LegacyLoader;
import moe.nightfall.vic.integratedcircuits.cp.part.PartIOBit;
Expand Down Expand Up @@ -325,7 +326,8 @@ public static CircuitData readFromNBT(NBTTagCompound compound, ICircuit parent)
int version = compound.getInteger("version");

List<LegacyLoader> legacyLoaders = null;
if (version < CircuitData.version) {
boolean legacyLoad = version < CircuitData.version && Config.enableLegacyLoader;
if (legacyLoad) {
// TODO This can't work for multiple versions as those steps have to
// be executed in sequence.
legacyLoaders = LegacyLoader.getLegacyLoaders(version);
Expand All @@ -349,7 +351,7 @@ public static CircuitData readFromNBT(NBTTagCompound compound, ICircuit parent)
CircuitProperties prop = CircuitProperties.readFromNBT(compound.getCompoundTag("properties"));
int size = compound.getInteger("size");

if (version < CircuitData.version) {
if (legacyLoad) {
for (LegacyLoader loader : legacyLoaders) {
loader.transform(size, id, meta);
}
Expand All @@ -375,7 +377,7 @@ public static CircuitData readFromNBT(NBTTagCompound compound, ICircuit parent)

CircuitData cdata = new CircuitData(size, parent, id, meta, scheduledTicks, inputQueue, prop);

if (version < CircuitData.version) {
if (legacyLoad) {
// TODO Not future-proof. Will break if e.g. inputQueue is removed.
for (LegacyLoader loader : legacyLoaders) {
loader.postTransform(cdata);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/integratedcircuits/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ config.integratedcircuits.general.enableTracker=Enable tracker
config.integratedcircuits.general.enableTracker.tooltip=This setting will make the game visit this URL on startup: https://raw.githubusercontent.com/Victorious3/Integrated-Circuits/master/version.dat %nThe connection is established over bit.ly for statistics. The data collected is publicly visible on https://bitly.com/1GIaUA6+. Bit.ly will track %nyour country via your IP address, no other, or personal, information is gathered. I like statistics, and I would like you to keep this setting enabled, %nso that I get a better overview of how often my mod is used. Thanks.
config.integratedcircuits.general.sevenSegmentMaxDigits=Maximal digits seven segment display
config.integratedcircuits.general.sevenSegmentMaxDigits.tooltip=The maximum number of digits a seven segment display can have
config.integratedcircuits.general.enableLegacyLoader=Enable legacy loader
config.integratedcircuits.general.enableLegacyLoader.tooltip=This setting will try and convert old versions of the circuit blueprints to the current version. This should be left ON unless you know what you are doing.
config.integratedcircuits.parts.redirect=part.integratedcircuits.%s.name

# misc
Expand Down

0 comments on commit dd8de0d

Please sign in to comment.