Thread: Where Are "Clipped" Landscapes Fetched From?

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 Where Are "Clipped" Landscapes Fetched From? 
    Banned

    Join Date
    Mar 2011
    Posts
    4,064
    Thanks given
    194
    Thanks received
    689
    Rep Power
    0
    Didn't know how to describe it, so just put clipped landscapes, basically the gzipped files used here:

    Code:
    public static void load() {
    		long startup = System.currentTimeMillis();
    		System.out.println("Loading region clipping...");
    		try {
    			File f = new File("./data/cache/map_index.dat");
    			
    			byte[] buffer = new byte[(int) f.length()];
    			DataInputStream dis = new DataInputStream(new FileInputStream(f));
    			dis.readFully(buffer);
    			dis.close();
    			ByteStream in = new ByteStream(buffer);
    					
    			int size = in.readUnsignedShort();
    			
    			regions = new RegionClipping[size];
    			int[] mapRegionIds = new int[size];
    			int[] mapTerrains = new int[size];
    			int[] mapLandscapes = new int[size];			
    			for (int i = 0; i < size; i++) {
    				mapRegionIds[i] = in.readUnsignedShort();			
    				mapTerrains[i] = in.readUnsignedShort();
    				mapLandscapes[i] = in.readUnsignedShort();
    			}
    			
    			for (int i = 0; i < size; i++) {
    				regions[i] = new RegionClipping(mapRegionIds[i]);
    			}
    			
    			int amount = 0;
    			
    			for (int i = 0; i < size; i++) {
    				byte[] file1 = getBuffer(new File("./data/cache/map/" + mapLandscapes[i] + ".gz"));
    				byte[] file2 = getBuffer(new File("./data/cache/map/" + mapTerrains[i] + ".gz"));
    				if (file1 == null || file2 == null)
    					continue;
    				loadMaps(mapRegionIds[i], new ByteStream(file1), new ByteStream(file2), i);
    				amount++;
    			}
    			System.out.println("Loaded " + amount + " region clipping" + (amount != 1 ? "s" : "") + " in " + (System.currentTimeMillis() - startup) + "ms");
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
    	private static void loadMaps(int regionId, ByteStream landscapes, ByteStream terrains, int index) {
    		try {
    			int absX = (regionId >> 8) * 64;
    			int absY = (regionId & 0xff) * 64;
    			int[][][] someArray = new int[4][64][64];
    			for (int i = 0; i < 4; i++) {
    				for (int i2 = 0; i2 < 64; i2++) {
    					for (int i3 = 0; i3 < 64; i3++) {
    						
    						do {
    							if (terrains.offset + 1 > terrains.buffer.length)
    								break;
    							int l1 = terrains.getUByte();
    							if (l1 == 0) {
    								break;
    							} else if (l1 == 1) {
    								terrains.skip(1);
    								break;
    							} else if (l1 <= 49) {
    								terrains.skip(1);
    							} else if (l1 <= 81) {
    								someArray[i][i2][i3] = l1 - 49;
    							} else {
    								someArray[i][i2][i3] = l1 - 81;
    							}
    						} while(true);
    					}
    				}
    			}
    			for (int i = 0; i < 4; i++) {
    				for (int i2 = 0; i2 < 64; i2++) {
    					for (int i3 = 0; i3 < 64; i3++) {
    						if ((someArray[i][i2][i3] & 1) == 1) {
    							int height = i;
    							if ((someArray[1][i2][i3] & 2) == 2) {
    								height--;
    							}
    							if (height >= 0 && height <= 3) {
    								addClipping(absX + i2, absY + i3, height, 0x200000);
    							}
    						}
    					}
    				}
    			}
    			
    			int objectId = -1;
    			int value;
    			while ((value = landscapes.getUSmart()) != 0) {
    				System.out.println("value=" + value);
    				objectId += value;
    				int location = 0;
    				int increment;
    				while ((increment = landscapes.getUSmart()) != 0) {
    					System.out.println("increment=" + increment);
    					location += increment - 1;
    					System.out.println("location=" + location);
    					int localY = (location & 0x3f);
    					int localX = (location >> 6 & 0x3f);
    					int height = location >> 12;
    					int objectData = landscapes.getUByte();
    					int type = objectData >> 2;
    					int direction = objectData & 3;
    					int x = absX + localX;
    					int y = absY + localY;
    					if (localX < 0 || localX >= 64 || localY < 0 || localY >= 64) {
    						continue;
    					}
    					if ((someArray[1][localX][localY] & 2) == 2) {
    						height--;
    					}
    					if (height >= 0 && height <= 3) {
    						addObject(objectId, x, y, height, type, direction);
    						System.out.println("rendered object: " + objectId + "; x=" + x + "; y=" + y + "; z=" + height);
    					}
    				}
    			}
    			
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    Thought it was this:

    Code:
    public void extractMapFiles(String directory) throws IOException {
    		File folder = new File(directory);
    		if (folder.mkdir()) {
    			System.out.println("Created new directory: " + directory);
    		}
    		for (int i = 0; i < mainCacheFile[4].size(); i++) {
    			System.out.println("Extracting map: " + i);
    			byte[] map = mainCacheFile[4].get(i);
    			ByteArrayOutputStream bout = new ByteArrayOutputStream();
    			DeflaterOutputStream os = new GZIPOutputStream(bout);
    			try {
    				os.write(map);
    				os.finish();
    				DataOutputStream output = new DataOutputStream(new FileOutputStream(directory + i + ".gz"));
    				output.write(bout.toByteArray());
    			} finally {
    				os.close();
    			}
    		}
    	}
    But it wasn't as the reading was wrong, used the 317 map gzipped files (from the clipping release) and it worked fine, which is how I know that the dumped files are wrong.

    Anyone know which files I need to dump?
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Jul 2008
    Posts
    3,532
    Thanks given
    188
    Thanks received
    696
    Rep Power
    0
    the outputted files, are you sure theyre being dumped already gzipped?

    I think they have to be unzipped in order to be loaded for clipping
    Reply With Quote  
     

  3. #3  
    Registered Member Jumper's Avatar
    Join Date
    Aug 2013
    Posts
    722
    Thanks given
    19
    Thanks received
    103
    Rep Power
    63
    this is how i get the clipping maps

    dump as .dat
    use gzipper on .dat
    rename, (remove .dat from name)
    add to region clipping folder
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Mar 2011
    Posts
    4,064
    Thanks given
    194
    Thanks received
    689
    Rep Power
    0
    Nope, getting same thing...Dumped them as .dat instead of .gz then used this to gzip:

    Code:
    package org.tools;
    
    import java.io.BufferedInputStream;
    import java.io.DataInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.zip.GZIPOutputStream;
    
    public class GZip {
    
    	private static final String UNGZIPPED_DIRECTORY = "./ungzipped_files/";
    	
    	private static final String GZIPPED_DIRECTORY = "./gzipped_files/";
    	
    	private static final boolean DELETE_FILES = true;
    	
    	private static int amount = 0;
    	
    	public static void main(String[] args) throws IOException {
    		long startup = System.currentTimeMillis();
    		File directory = new File(UNGZIPPED_DIRECTORY);
    		for (File file : directory.listFiles()) {
    			if (file.isDirectory()) {
    				File[] moreFiles = file.listFiles();
    				for (File f : moreFiles) {
    					gzip(f);
    				}
    				return;
    			}
    			gzip(file);
    		}
    		System.out.println("GZipped " + amount + " files in " + (System.currentTimeMillis() - startup) + "ms.");
    	}
    	
    	private static void gzip(File file) throws IOException {
    		System.out.println("GZipping file: " + file.getName() + "...");
    		String[] args = file.getName().split(".dat");
    		String name = args[0].equals("") ? file.getName() : args[0];
    		byte[] bytes = new byte[(int)file.length()];
    		DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(file)));
        	dis.readFully(bytes,0,bytes.length);
        	dis.close();
        	File newLocation = new File(GZIPPED_DIRECTORY + name + ".gz");
        	//(new File(GZIPPED_DIRECTORY + file.getParent())).mkdir();
        	GZIPOutputStream gos = new GZIPOutputStream(new FileOutputStream(newLocation));
        	gos.write(bytes,0,bytes.length);
        	gos.close();
        	if (DELETE_FILES) {
        		System.out.println("Successfully gzipped file, now deleting...");
        		file.delete();
        	}
        	amount++;
    	}
    }
    And still getting same messed up files (object ids are always 31, when I used 317 gzipped files, they were loading correctly)
    Reply With Quote  
     

  5. #5  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,322
    Thanks given
    546
    Thanks received
    1,129
    Discord
    View profile
    Rep Power
    1806
    Quote Originally Posted by relex lawl View Post
    Nope, getting same thing...Dumped them as .dat instead of .gz then used this to gzip:


    And still getting same messed up files (object ids are always 31, when I used 317 gzipped files, they were loading correctly)
    Just wondering what revision are u trying to load if original 317 ones work fine...?
    ...
    Reply With Quote  
     

  6. #6  
    Banned

    Join Date
    Mar 2011
    Posts
    4,064
    Thanks given
    194
    Thanks received
    689
    Rep Power
    0
    Quote Originally Posted by mige5 View Post
    Just wondering what revision are u trying to load if original 317 ones work fine...?
    Using keldagrim's client, 667 maps
    Reply With Quote  
     

  7. #7  
    Registered Member
    hacker's Avatar
    Join Date
    Jun 2013
    Posts
    1,405
    Thanks given
    572
    Thanks received
    565
    Discord
    View profile
    Rep Power
    5000
    what exactly are u trying to do sorry dont relly understand
    Reply With Quote  
     

  8. #8  
    Banned

    Join Date
    Jul 2008
    Posts
    3,532
    Thanks given
    188
    Thanks received
    696
    Rep Power
    0
    if youre loading clipping via maps server sided you have to update the objects as well.. 317 objects wont work with 667 maps obviously
    Reply With Quote  
     

  9. #9  
    Banned

    Join Date
    Mar 2011
    Posts
    4,064
    Thanks given
    194
    Thanks received
    689
    Rep Power
    0
    Quote Originally Posted by Badger41 View Post
    if youre loading clipping via maps server sided you have to update the objects as well.. 317 objects wont work with 667 maps obviously
    I've modified everything to fit my server...From the classes (getting rid of the unnecessary ones as well) to dumping the client's map_index and loc.dat/idx (called object.dat/idx on mine). The only thing I need is the files I mentioned.
    Reply With Quote  
     

  10. #10  
    Banned

    Join Date
    Mar 2011
    Posts
    4,064
    Thanks given
    194
    Thanks received
    689
    Rep Power
    0
    Bump.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 2
    Last Post: 01-07-2013, 01:07 PM
  2. Where are you from?
    By Cody in forum Chat
    Replies: 19
    Last Post: 07-06-2011, 04:53 PM
  3. Where Are You From?
    By Arkadian in forum Voting
    Replies: 61
    Last Post: 06-06-2009, 01:51 PM
  4. Where are you from?
    By Jukk in forum Voting
    Replies: 16
    Last Post: 01-20-2008, 03:07 AM
  5. Replies: 67
    Last Post: 12-02-2007, 05:50 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •