mirror of
https://github.com/catfoolyou/Beta-1.4_01.git
synced 2025-05-31 19:00:57 -05:00
Fix the damn McRegion
This commit is contained in:
parent
2735c2a1f1
commit
4dadf430e0
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
.gradle/
|
||||
build/
|
||||
lwjgl-rundir/*.log
|
||||
lwjgl-rundir/filesystem/
|
||||
lwjgl-rundir/filesystem/
|
||||
lwjgl-rundir/*.mcr
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -1035,7 +1035,7 @@ public class Minecraft {
|
||||
|
||||
private void convertMapFormat(String var1, String var2) {
|
||||
this.loadingScreen.printText("Converting World to " + this.saveLoader.formatName());
|
||||
this.loadingScreen.displayLoadingString("This may take a while :)");
|
||||
this.loadingScreen.displayLoadingString("Oh fuck");
|
||||
this.saveLoader.convertMapFormat(var1, this.loadingScreen);
|
||||
this.startWorld(var1, var2, 0L);
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ public class GuiSelectWorld extends GuiScreen {
|
||||
}
|
||||
|
||||
protected String getSaveFileName(int var1) {
|
||||
System.out.println("got save " + ((SaveFormatComparator)this.saveList.get(var1)).getFileName());
|
||||
return ((SaveFormatComparator)this.saveList.get(var1)).getDisplayName();
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,8 @@ import java.util.zip.InflaterInputStream;
|
||||
|
||||
public class RegionFile {
|
||||
private static final byte[] field_22213_a = new byte[4096];
|
||||
private final VFile2 field_22212_b;
|
||||
private RandomAccessFile field_22219_c;
|
||||
private final VFile2 regionVFile;
|
||||
private RandomAccessFile regionFile;
|
||||
private final int[] field_22218_d = new int[1024];
|
||||
private final int[] field_22217_e = new int[1024];
|
||||
private ArrayList field_22216_f;
|
||||
@ -19,36 +19,39 @@ public class RegionFile {
|
||||
private long field_22214_h = 0L;
|
||||
|
||||
public RegionFile(VFile2 var1) {
|
||||
this.field_22212_b = var1;
|
||||
this.func_22204_b("REGION LOAD " + this.field_22212_b);
|
||||
this.regionVFile = var1;
|
||||
this.func_22204_b("REGION LOAD " + this.regionVFile);
|
||||
this.field_22215_g = 0;
|
||||
|
||||
try {
|
||||
if(var1.exists()) {
|
||||
//this.field_22214_h = var1.lastModified();
|
||||
String[] parts = regionVFile.getPath().split("/");
|
||||
String name = null;
|
||||
if (parts.length >= 3) {
|
||||
name = parts[1];
|
||||
}
|
||||
|
||||
this.field_22219_c = new RandomAccessFile(var1.getName(), "rw");
|
||||
this.regionFile = new RandomAccessFile(name + var1.getName(), "rw"); // fix this
|
||||
|
||||
int var2;
|
||||
if(this.field_22219_c.length() < 4096L) {
|
||||
if(this.regionVFile.length() < 4096L) {
|
||||
for(var2 = 0; var2 < 1024; ++var2) {
|
||||
this.field_22219_c.writeInt(0);
|
||||
this.regionFile.writeInt(0);
|
||||
}
|
||||
|
||||
for(var2 = 0; var2 < 1024; ++var2) {
|
||||
this.field_22219_c.writeInt(0);
|
||||
this.regionFile.writeInt(0);
|
||||
}
|
||||
|
||||
this.field_22215_g += 8192;
|
||||
}
|
||||
|
||||
if((this.field_22219_c.length() & 4095L) != 0L) {
|
||||
for(var2 = 0; (long)var2 < (this.field_22219_c.length() & 4095L); ++var2) {
|
||||
this.field_22219_c.write(0);
|
||||
if((this.regionFile.length() & 4095L) != 0L) {
|
||||
for(var2 = 0; (long)var2 < (this.regionFile.length() & 4095L); ++var2) {
|
||||
this.regionFile.write(0);
|
||||
}
|
||||
}
|
||||
|
||||
var2 = (int)this.field_22219_c.length() / 4096;
|
||||
var2 = (int)this.regionFile.length() / 4096;
|
||||
this.field_22216_f = new ArrayList(var2);
|
||||
|
||||
int var3;
|
||||
@ -58,11 +61,11 @@ public class RegionFile {
|
||||
|
||||
this.field_22216_f.set(0, Boolean.valueOf(false));
|
||||
this.field_22216_f.set(1, Boolean.valueOf(false));
|
||||
this.field_22219_c.seek(0L);
|
||||
this.regionFile.seek(0L);
|
||||
|
||||
int var4;
|
||||
for(var3 = 0; var3 < 1024; ++var3) {
|
||||
var4 = this.field_22219_c.readInt();
|
||||
var4 = this.regionFile.readInt();
|
||||
this.field_22218_d[var3] = var4;
|
||||
if(var4 != 0 && (var4 >> 8) + (var4 & 255) <= this.field_22216_f.size()) {
|
||||
for(int var5 = 0; var5 < (var4 & 255); ++var5) {
|
||||
@ -72,11 +75,12 @@ public class RegionFile {
|
||||
}
|
||||
|
||||
for(var3 = 0; var3 < 1024; ++var3) {
|
||||
var4 = this.field_22219_c.readInt();
|
||||
var4 = this.regionFile.readInt();
|
||||
this.field_22217_e[var3] = var4;
|
||||
}
|
||||
} catch (IOException var6) {
|
||||
var6.printStackTrace();
|
||||
System.out.println(var6.getMessage());
|
||||
//var6.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
@ -95,11 +99,11 @@ public class RegionFile {
|
||||
}
|
||||
|
||||
private void func_22199_a(String var1, int var2, int var3, String var4) {
|
||||
this.func_22211_a("REGION " + var1 + " " + this.field_22212_b.getName() + "[" + var2 + "," + var3 + "] = " + var4);
|
||||
this.func_22211_a("REGION " + var1 + " " + this.regionVFile.getName() + "[" + var2 + "," + var3 + "] = " + var4);
|
||||
}
|
||||
|
||||
private void func_22197_a(String var1, int var2, int var3, int var4, String var5) {
|
||||
this.func_22211_a("REGION " + var1 + " " + this.field_22212_b.getName() + "[" + var2 + "," + var3 + "] " + var4 + "B = " + var5);
|
||||
this.func_22211_a("REGION " + var1 + " " + this.regionVFile.getName() + "[" + var2 + "," + var3 + "] " + var4 + "B = " + var5);
|
||||
}
|
||||
|
||||
private void func_22201_b(String var1, int var2, int var3, String var4) {
|
||||
@ -122,23 +126,23 @@ public class RegionFile {
|
||||
this.func_22201_b("READ", var1, var2, "invalid sector");
|
||||
return null;
|
||||
} else {
|
||||
this.field_22219_c.seek((long)(var4 * 4096));
|
||||
int var6 = this.field_22219_c.readInt();
|
||||
this.regionFile.seek((long)(var4 * 4096));
|
||||
int var6 = this.regionFile.readInt();
|
||||
if(var6 > 4096 * var5) {
|
||||
this.func_22201_b("READ", var1, var2, "invalid length: " + var6 + " > 4096 * " + var5);
|
||||
return null;
|
||||
} else {
|
||||
byte var7 = this.field_22219_c.readByte();
|
||||
byte var7 = this.regionFile.readByte();
|
||||
byte[] var8;
|
||||
DataInputStream var9;
|
||||
if(var7 == 1) {
|
||||
var8 = new byte[var6 - 1];
|
||||
this.field_22219_c.read(var8);
|
||||
this.regionFile.read(var8);
|
||||
var9 = new DataInputStream(new GZIPInputStream(new ByteArrayInputStream(var8)));
|
||||
return var9;
|
||||
} else if(var7 == 2) {
|
||||
var8 = new byte[var6 - 1];
|
||||
this.field_22219_c.read(var8);
|
||||
this.regionFile.read(var8);
|
||||
var9 = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(var8)));
|
||||
return var9;
|
||||
} else {
|
||||
@ -212,11 +216,11 @@ public class RegionFile {
|
||||
this.func_22200_a(var6, var3, var4);
|
||||
} else {
|
||||
this.func_22197_a("SAVE", var1, var2, var4, "grow");
|
||||
this.field_22219_c.seek(this.field_22219_c.length());
|
||||
this.regionFile.seek(this.regionFile.length());
|
||||
var6 = this.field_22216_f.size();
|
||||
|
||||
for(var11 = 0; var11 < var8; ++var11) {
|
||||
this.field_22219_c.write(field_22213_a);
|
||||
this.regionFile.write(field_22213_a);
|
||||
this.field_22216_f.add(Boolean.valueOf(false));
|
||||
}
|
||||
|
||||
@ -228,17 +232,18 @@ public class RegionFile {
|
||||
|
||||
this.func_22208_b(var1, var2, (int)(System.currentTimeMillis() / 1000L));
|
||||
} catch (IOException var12) {
|
||||
var12.printStackTrace();
|
||||
System.out.println(var12.getMessage());
|
||||
//var12.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void func_22200_a(int var1, byte[] var2, int var3) throws IOException {
|
||||
this.func_22204_b(" " + var1);
|
||||
this.field_22219_c.seek((long)(var1 * 4096));
|
||||
this.field_22219_c.writeInt(var3 + 1);
|
||||
this.field_22219_c.writeByte(2);
|
||||
this.field_22219_c.write(var2, 0, var3);
|
||||
this.regionFile.seek((long)(var1 * 4096));
|
||||
this.regionFile.writeInt(var3 + 1);
|
||||
this.regionFile.writeByte(2);
|
||||
this.regionFile.write(var2, 0, var3);
|
||||
}
|
||||
|
||||
private boolean func_22206_d(int var1, int var2) {
|
||||
@ -255,17 +260,17 @@ public class RegionFile {
|
||||
|
||||
private void func_22198_a(int var1, int var2, int var3) throws IOException {
|
||||
this.field_22218_d[var1 + var2 * 32] = var3;
|
||||
this.field_22219_c.seek((long)((var1 + var2 * 32) * 4));
|
||||
this.field_22219_c.writeInt(var3);
|
||||
this.regionFile.seek((long)((var1 + var2 * 32) * 4));
|
||||
this.regionFile.writeInt(var3);
|
||||
}
|
||||
|
||||
private void func_22208_b(int var1, int var2, int var3) throws IOException {
|
||||
this.field_22217_e[var1 + var2 * 32] = var3;
|
||||
this.field_22219_c.seek((long)(4096 + (var1 + var2 * 32) * 4));
|
||||
this.field_22219_c.writeInt(var3);
|
||||
this.regionFile.seek((long)(4096 + (var1 + var2 * 32) * 4));
|
||||
this.regionFile.writeInt(var3);
|
||||
}
|
||||
|
||||
public void func_22196_b() throws IOException {
|
||||
this.field_22219_c.close();
|
||||
this.regionFile.close();
|
||||
}
|
||||
}
|
||||
|
@ -5,71 +5,62 @@ import net.lax1dude.eaglercraft.internal.vfs2.VFile2;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
public class RegionFileCache {
|
||||
private static final Map field_22195_a = new HashMap();
|
||||
private static final Map regionFiles = new HashMap();
|
||||
|
||||
public static synchronized RegionFile func_22193_a(VFile2 var0, int var1, int var2) {
|
||||
public static synchronized RegionFile getRegionFile(VFile2 var0, int var1, int var2) {
|
||||
VFile2 var3 = new VFile2(var0, "region");
|
||||
VFile2 var4 = new VFile2(var3, "r." + (var1 >> 5) + "." + (var2 >> 5) + ".mcr");
|
||||
Reference var5 = (Reference)field_22195_a.get(var4);
|
||||
RegionFile var6;
|
||||
RegionFile var5 = (RegionFile) regionFiles.get(var4);
|
||||
if(var5 != null) {
|
||||
var6 = (RegionFile)var5.get();
|
||||
if(var6 != null) {
|
||||
return var6;
|
||||
if(var5 != null) {
|
||||
return var5;
|
||||
}
|
||||
}
|
||||
|
||||
if(!var3.exists()) {
|
||||
//var3.mkdirs();
|
||||
}
|
||||
|
||||
if(field_22195_a.size() >= 256) {
|
||||
if(regionFiles.size() >= 256) {
|
||||
func_22192_a();
|
||||
}
|
||||
|
||||
var6 = new RegionFile(var4);
|
||||
field_22195_a.put(var4, new SoftReference(var6));
|
||||
return var6;
|
||||
var5 = new RegionFile(var4);
|
||||
regionFiles.put(var4, var5);
|
||||
return var5;
|
||||
}
|
||||
|
||||
public static synchronized void func_22192_a() {
|
||||
Iterator var0 = field_22195_a.values().iterator();
|
||||
Iterator var0 = regionFiles.values().iterator();
|
||||
|
||||
while(var0.hasNext()) {
|
||||
Reference var1 = (Reference)var0.next();
|
||||
RegionFile var1 = (RegionFile) var0.next();
|
||||
|
||||
try {
|
||||
RegionFile var2 = (RegionFile)var1.get();
|
||||
if(var2 != null) {
|
||||
var2.func_22196_b();
|
||||
if(var1 != null) {
|
||||
var1.func_22196_b();
|
||||
}
|
||||
} catch (IOException var3) {
|
||||
var3.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
field_22195_a.clear();
|
||||
regionFiles.clear();
|
||||
}
|
||||
|
||||
public static int func_22191_b(VFile2 var0, int var1, int var2) {
|
||||
RegionFile var3 = func_22193_a(var0, var1, var2);
|
||||
RegionFile var3 = getRegionFile(var0, var1, var2);
|
||||
return var3.func_22209_a();
|
||||
}
|
||||
|
||||
public static DataInputStream getChunkInputStream(VFile2 var0, int var1, int var2) {
|
||||
RegionFile var3 = func_22193_a(var0, var1, var2);
|
||||
RegionFile var3 = getRegionFile(var0, var1, var2);
|
||||
return var3.func_22210_a(var1 & 31, var2 & 31);
|
||||
}
|
||||
|
||||
public static DataOutputStream getChunkOutputStream(VFile2 var0, int var1, int var2) {
|
||||
RegionFile var3 = func_22193_a(var0, var1, var2);
|
||||
RegionFile var3 = getRegionFile(var0, var1, var2);
|
||||
return var3.func_22205_b(var1 & 31, var2 & 31);
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class SaveConverterMcRegion extends SaveFormatOld {
|
||||
FileMatcher var8 = (FileMatcher)var7.next();
|
||||
int var9 = var8.func_22323_b();
|
||||
int var10 = var8.func_22321_c();
|
||||
RegionFile var11 = RegionFileCache.func_22193_a(var1, var9, var10);
|
||||
RegionFile var11 = RegionFileCache.getRegionFile(var1, var9, var10);
|
||||
if(!var11.func_22202_c(var9 & 31, var10 & 31)) {
|
||||
try {
|
||||
DataInputStream var12 = new DataInputStream(new GZIPInputStream(var8.func_22324_a().getInputStream()));
|
||||
|
@ -74,9 +74,6 @@ public class SaveFormatOld implements ISaveFormat {
|
||||
deleteWorldFiles(files.toArray(new VFile2[0]));
|
||||
var3.delete();
|
||||
}
|
||||
else {
|
||||
System.out.println("fuck");
|
||||
}
|
||||
}
|
||||
|
||||
protected static void deleteWorldFiles(VFile2[] var0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user