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 x = pos.getBlockX();
int z = pos.getBlockZ(); int z = pos.getBlockZ();
String filename = "r." + (x >> 5) + "." + (z >> 5) + ".mcr"; String filename = "r." + (x >> 5) + "." + (z >> 5) + ".mca";
return filename; return filename;
} }

View File

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

View File

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

View File

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