Fixed snapshots not properly loading .mcr files, made snapshots use fast mode.

This commit is contained in:
sk89q 2012-07-09 23:55:19 -07:00
parent 0d279e7706
commit 97380f28de
4 changed files with 10 additions and 20 deletions

View File

@ -42,7 +42,7 @@ public abstract class McRegionChunkStore extends ChunkStore {
int x = pos.getBlockX();
int z = pos.getBlockZ();
String filename = "r." + (x >> 5) + "." + (z >> 5) + ".mcr";
String filename = "r." + (x >> 5) + "." + (z >> 5) + ".mca";
return filename;
}

View File

@ -100,21 +100,13 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
name = folder + "/" + name;
}
} else {
Pattern pattern = Pattern.compile(".*\\.mcr$");
Pattern patternmca = Pattern.compile(".*\\.mca$"); // TODO: does this need a separate class?
Pattern pattern = Pattern.compile(".*\\.mc[ra]$");
// World pattern
Pattern worldPattern = Pattern.compile(worldname + "\\$");
for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
ZipEntry testEntry = (ZipEntry) e.nextElement();
// Check for world
if (worldPattern.matcher(worldname).matches()) {
// Check for file
// TODO: does this need a separate class?
if (patternmca.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/"));
name = folder + "/" + name.replace("mcr", "mca");
break;
}
// Check for file
if (pattern.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/"));

View File

@ -98,19 +98,12 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
name = folder + "/" + name;
}
} else {
Pattern pattern = Pattern.compile(".*\\.mcr$");
Pattern patternmca = Pattern.compile(".*\\.mca$"); // TODO: does this need a separate class?
Pattern pattern = Pattern.compile(".*\\.mc[ra]$");
for (Enumeration<? extends ZipEntry> e = zip.entries(); e.hasMoreElements(); ) {
ZipEntry testEntry = (ZipEntry) e.nextElement();
// Check for world
if (testEntry.getName().startsWith(worldname + "/")) {
// TODO: does this need a separate class?
if (patternmca.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/"));
name = folder + "/" + name.replace("mcr", "mca");
break;
}
if (pattern.matcher(testEntry.getName()).matches()) {
if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/"));
name = folder + "/" + name;
break;

View File

@ -155,6 +155,9 @@ public class SnapshotRestore {
for (Map.Entry<BlockVector2D, ArrayList<Vector>> entry : neededChunks.entrySet()) {
BlockVector2D chunkPos = entry.getKey();
Chunk chunk;
boolean hasFastMode = editSession.hasFastMode();
editSession.setFastMode(true);
try {
chunk = chunkStore.getChunk(chunkPos, editSession.getWorld());
@ -163,7 +166,7 @@ public class SnapshotRestore {
// Now just copy blocks!
for (Vector pos : entry.getValue()) {
BaseBlock block = chunk.getBlock(pos);
editSession.setBlock(pos, block);
editSession.rawSetBlock(pos, block);
}
} catch (MissingChunkException me) {
missingChunks.add(chunkPos);
@ -176,6 +179,8 @@ public class SnapshotRestore {
} catch (IOException ioe) {
errorChunks.add(chunkPos);
lastErrorMessage = ioe.getMessage();
} finally {
editSession.setFastMode(hasFastMode);
}
}
}