Skip to content

Commit

Permalink
Misc fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Macagno committed Aug 26, 2015
1 parent 4d5aa0f commit 612e5a3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/main/java/cr0s/warpdrive/config/filler/FillerSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@ public FillerSet(String name) {

this.name = name;

weightedFillerBlocks = null;
weightedFillerBlocks = new MetaBlock[1];
factory = new FillerFactory();
}

public MetaBlock getRandomBlock(Random rand) {
if (weightedFillerBlocks == null || weightedFillerBlocks.length == 0) {
return null;
}
return weightedFillerBlocks[rand.nextInt(weightedFillerBlocks.length)];
}

Expand Down Expand Up @@ -87,7 +84,7 @@ public void loadFromXmlElement(Element element) throws InvalidXmlException {
boolean hasWeightOrRatio = false;

// It is intentional that a filler could have both a ratio and a weight

// Check for a weight and add it to the factory
String stringWeight = filler.getAttribute("weight");
int weight;
Expand Down Expand Up @@ -119,7 +116,7 @@ public void loadFromXmlElement(Element element) throws InvalidXmlException {
throw new InvalidXmlException(ex.getMessage());
}
}

if (!hasWeightOrRatio) {
throw new InvalidXmlException("Filler " + filler.getBaseURI() + " is missing a weight or a ratio!");
}
Expand All @@ -137,6 +134,7 @@ public void saveToXmlElement(Element e, Document d) throws InvalidXmlException {
* Clears the memory used for construction
*/
public void finishContruction() {
WarpDrive.logger.info("Finishing construction of FillerSet " + name);
weightedFillerBlocks = factory.constructWeightedMetaBlockList();
factory = null;
}
Expand All @@ -153,7 +151,7 @@ public String toString() {

/**
* Adds the blocks from the given fillerSet into this one. Must be pre-finishConstruction()
*
*
* @param fillerSet
* The fillerset to add from
*/
Expand Down

0 comments on commit 612e5a3

Please sign in to comment.