diff --git a/cachedump/src/org/moparscape/cacheutils/v508/Main.java b/cachedump/src/org/moparscape/cacheutils/v508/Main.java index 17e2b30..e27e6e0 100644 --- a/cachedump/src/org/moparscape/cacheutils/v508/Main.java +++ b/cachedump/src/org/moparscape/cacheutils/v508/Main.java @@ -8,8 +8,8 @@ import java.io.PrintStream; public class Main { public static final String folderName = "/home/mopar/htdocs/508/"; - // some (crappy) filesystems can handle more than this many files in any given folder, so we have to handle it (suffer) - public static final int maxFilesInFolder = 33000; + // some (crappy) filesystems can't handle more than this many files in any given folder, so we have to handle it (suffer) + public static final int maxFilesInFolder = 33005; public static PrintStream log; public Main() { @@ -77,10 +77,16 @@ public class Main { maxIds[10] = 1; dumpFile(cache, 10,1431655766); - for (short index = 0; index <= 255 && index >= 0; ++index) - for (int id = 0; id <= maxId && id >= 0; ++id) + int idCount; + for (short index = 0; index <= 255 && index >= 0; ++index){ + idCount = 0; + for (int id = 0; id <= maxId && id >= 0; ++id){ //for (int id = 0; id <= maxIds[index] && id >= 0; ++id) - dumpFile(cache, index, id); + if(!dumpFile(cache, index, id)) + ++idCount; + } + System.out.println("total files for index '"+index+"' is '"+idCount+"'"); + } } catch (Exception e) { e.printStackTrace(); @@ -172,14 +178,18 @@ public class Main { } public static File checkFile(int index, int id) throws Exception { - File file = new File(folderName + index); + String folder = folderName + index; + // handle crappy filesystems + if(id >= maxFilesInFolder) + folder += "/a"; + File file = new File(folder); if (!file.exists()) - if (!file.mkdir()) { + if (!file.mkdirs()) { println("can't create dir"); System.exit(1); } - file = new File(folderName + index + "/" + id); + file = new File(folder + "/" + id); if (file.exists()) { println("oh shit, collision!!!!!!"); System.exit(1); diff --git a/client508/src/Class20.java b/client508/src/Class20.java index ef12d11..65cc06d 100644 --- a/client508/src/Class20.java +++ b/client508/src/Class20.java @@ -94,9 +94,10 @@ public class Class20 is[i_3_] = (byte) -1; } } - for(byte b : is) - System.out.print(b + ", "); - System.out.println(); + //xxx moparisthebest added + //for(byte b : is) + // System.out.print(b + ", "); + //System.out.println(); class68_sub14.writeBytes(24, 0, is); } diff --git a/src/org/moparscape/classloader/CRCClassLoader.java b/src/org/moparscape/classloader/CRCClassLoader.java index ef5cf93..724dfaa 100644 --- a/src/org/moparscape/classloader/CRCClassLoader.java +++ b/src/org/moparscape/classloader/CRCClassLoader.java @@ -7,6 +7,7 @@ package org.moparscape.classloader; import org.moparscape.Update; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.security.ProtectionDomain; @@ -22,7 +23,7 @@ import java.util.zip.CRC32; */ public class CRCClassLoader extends ClassLoader { - private Map classes; + private Map classes = new HashMap(); private long crcVal; private ClassLoader parent = null; private ProtectionDomain pd = null; @@ -102,11 +103,17 @@ public class CRCClassLoader extends ClassLoader { } private void setup(String jarFileLoc, boolean updateCRC) throws IOException { + File f = new File(jarFileLoc); + if (!f.exists()) { + System.out.println("Jar file doesn't exist: " + jarFileLoc); + return; + } - JarFile jf = new JarFile(jarFileLoc); + JarFile jf = new JarFile(f); Enumeration entries = jf.entries(); - classes = new HashMap(); + if(updateCRC) + classes = new HashMap(); CRC32 crc = null; if (updateCRC) { @@ -119,7 +126,6 @@ public class CRCClassLoader extends ClassLoader { while (entries.hasMoreElements()) { JarEntry entry = (JarEntry) entries.nextElement(); if (entry.getName().endsWith(".class")) { - //System.out.println("class name: " + entry.getName()); InputStream in = jf.getInputStream(entry); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int len; @@ -135,6 +141,7 @@ public class CRCClassLoader extends ClassLoader { crc.update(classArr); String className = entry.getName().substring(0, entry.getName().lastIndexOf(".")).replaceAll("/", "."); + //if (updateCRC) System.out.println("class name: " + className); // save class classes.put(className, classArr); } @@ -152,17 +159,17 @@ public class CRCClassLoader extends ClassLoader { /** * Is called by the ClassLoader when the requested class * is not found in its cache. The parent is only used when - * this is ran as an applet strangely. + * this is ran as an applet, strangely. * * @param name The name of the class */ public Class findClass(String name) throws ClassNotFoundException { - // System.out.println("CRCClassLoader: Requesting class " + name); + //System.out.println("CRCClassLoader: Requesting class '" + name + "'"); byte[] classBytes = classes.get(name); if (classBytes == null) { if (parent == null) throw new ClassNotFoundException("Couldn't find class " + name); - //System.out.println("Couldn't find class " + name + " trying parent class loader."); + System.out.println("Couldn't find class '" + name + "' trying parent class loader."); return parent.loadClass(name); } Class foundClass = defineClass(name, classBytes, 0, classBytes.length, pd); diff --git a/src/org/moparscape/userver/Server.java b/src/org/moparscape/userver/Server.java index 73e1251..ce3ad5e 100644 --- a/src/org/moparscape/userver/Server.java +++ b/src/org/moparscape/userver/Server.java @@ -120,7 +120,7 @@ public abstract class Server extends Thread { public HttpURLConnection getHttpURLConnection(String request) { HttpURLConnection ret; String urlStr = customLocation + request; - System.out.println("getHttpURLConnection urlStr: "+urlStr); + //System.out.println("getHttpURLConnection urlStr: "+urlStr); try { ret = (HttpURLConnection) new URL(urlStr).openConnection(); // if response code is not 200 @@ -153,8 +153,7 @@ public abstract class Server extends Thread { public void handleException(Exception e) { if (MainPanel.debug()) { String myName = this.getClass().getName(); - if (myName.equals("org.moparscape.userver.v508.OndemandServer443")) - return; + //if (myName.equals("org.moparscape.userver.v508.OndemandServer443")) return; System.err.print("Server error: "); e.printStackTrace(); } diff --git a/src/org/moparscape/userver/v508/OndemandServer.java b/src/org/moparscape/userver/v508/OndemandServer.java index 557437d..d1900ea 100644 --- a/src/org/moparscape/userver/v508/OndemandServer.java +++ b/src/org/moparscape/userver/v508/OndemandServer.java @@ -17,8 +17,10 @@ import java.net.URLConnection; */ public class OndemandServer extends Server { - public static final String odsPath = "508/%d/%d"; + public static final String odsPath = "508/%d%s/%d"; public static final int clientVersion = 508; + // some (crappy) filesystems can't handle more than this many files in any given folder, so we have to handle it (suffer) + public static final int maxFilesInFolder = 33005; public byte[] buffer = new byte[1024]; public int len; @@ -113,9 +115,9 @@ public class OndemandServer extends Server { //long hash = (long) ((index << 16) + id); //System.out.println("request " + hash); - //System.out.println(String.format(odsPath, index, id)); + //System.out.println(String.format(odsPath, index, id >= maxFilesInFolder ? "/a" : "", id)); - URLConnection url = getHttpURLConnection(String.format(odsPath, index, id)); + URLConnection url = getHttpURLConnection(String.format(odsPath, index, id >= maxFilesInFolder ? "/a" : "", id)); // if url is null, custom and default cannot be reached, continue if (url == null) { // unless we want the update keys and may not be connected to the internet @@ -163,16 +165,16 @@ public class OndemandServer extends Server { // if size == -1 it doesn't exist // however this cannot be counted on as a 404 will still send html //System.out.println("size: " + size); - System.out.println("opening stream"); + //System.out.println("opening stream"); InputStream data1 = url.getInputStream(); - System.out.println("InputStream Open!"); + //System.out.println("InputStream Open!"); // buffer and len are static while ((len = data1.read(buffer)) >= 0){ - System.out.println("len read:"+len); + //System.out.println("len read:"+len); out.write(buffer, 0, len); } - System.out.println("Data Written! len:"+len); + //System.out.println("Data Written! len:"+len); out.flush(); data1.close(); }