Thread: Update cache - Ruse client

Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1 Update cache - Ruse client 
    Banned
    Join Date
    Sep 2015
    Posts
    78
    Thanks given
    54
    Thanks received
    34
    Rep Power
    0
    Why Ruse would download raw type files ( .dat ) etc is beyond me, Especially when its 160mb +

    Code:
    import java.io.BufferedOutputStream;
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLConnection;
    import java.util.Enumeration;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipFile;
    
    /**
     * The custom update server to download and update the cache.
     * @author Apacheah64
     */
    public class Update {
    	
    	/**
    	 * The client reference.
    	 */
    	private Client c;
    	
    	/**
    	 * The cache directory.
    	 */
    	private static final String CACHE_DIR = signlink.findcachedir();
    	
    	/**
    	 * Construct a new {@code Updater} {@code Object}.
    	 * @param c The client reference.
    	 */
    	public Update(Client c) {
    		this.c = c;
    	}
    	
    	/**
    	 * Update the cache.
    	 */
    	public void updateCache() {
    		new File(CACHE_DIR).mkdirs();
    		File file = new File(CACHE_DIR+"rusereborn.dat");//its a check if the cache already exists
    		if(!file.exists()) {
    			c.drawLoadingText(0, "Checking for updates");
    			downloadArchive("http://162.218.48.74/~ruserebo/client/cache/RuseReborn.zip");
    		}
    		file = new File(CACHE_DIR+"cache.zip");
    		if(file.exists()) {
    			unzip(CACHE_DIR+"cache.zip");
    		}
    	}
    	
    	/**
    	 * Download the cache archive from the web server.
    	 * @param dlurl The uniform resource locater to the file that has to be downloaded.
    	 * @param cachePart The part of the cache that is being downloaded.
    	 */
    	private void downloadArchive(String dlurl) {
    		try {
    			URLConnection url = new URL(dlurl).openConnection();
    		    int i = url.getContentLength();
    		    InputStream is = url.getInputStream();
    			OutputStream os = new FileOutputStream(CACHE_DIR+"/cache.zip");
    			byte[] b = new byte[4096];
    			int length;
    			int old = 0;
    			while ((length = is.read(b)) != -1) {
    				os.write(b, 0, length);
    				old += length;
    				int percent = (int) ((double) old / (double) i * 100.0);
    				drawLoadingText(percent, "Checking for updates - " + percent + "%");
    			}
    			is.close();
    			os.close();
    			unzip(CACHE_DIR+"cache.zip");
    			File file = new File(CACHE_DIR+"rusereborn.dat");
    			if(!file.exists()) {
    				file.createNewFile();// got ya
    			}
    		} catch (MalformedURLException e) {
    			e.printStackTrace();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    	
    	/**
    	 * Unzip the cache archive part.
    	 * @param file The file location.
    	 */
    	private void unzip(String file) {
    		Enumeration<?> entries;
    		ZipFile zipFile;
    		try {
    			zipFile = new ZipFile(file);
    			entries = zipFile.entries();
    			while(entries.hasMoreElements()) {
    				ZipEntry entry = (ZipEntry)entries.nextElement();
    				if(entry.isDirectory()) {
    					(new File(CACHE_DIR+"/"+entry.getName())).mkdir();
    					continue;
    				}
    				copyInputStream(zipFile.getInputStream(entry),
    				new BufferedOutputStream(new FileOutputStream(CACHE_DIR+"/"+entry.getName())));
    				drawLoadingText(100, "Unpacking Cache");
    			}
    			zipFile.close();
    			File zip = new File(file);
    			zip.delete();
    		} catch (IOException ioe) {
    			ioe.printStackTrace();
    			return;
    		}
    	}
    	
    	/**
    	 * Make a copy of the input stream and write it.
    	 * @param in The input.
    	 * @param out The output.
    	 * @throws IOException
    	 */
    	private static final void copyInputStream(InputStream in, OutputStream out) throws IOException {
    		byte[] buffer = new byte[1024];
    		int len;
    		while((len = in.read(buffer)) >= 0) {
    			out.write(buffer, 0, len);
    		}
    		in.close();
    		out.close();
    	}
    	
    	private static void drawLoadingText(int amount, String text) {
            Client.loadingPercentage = amount;
            Client.loadingText = text;
        }
    	
    }
    You can do the rest in client class. not spoonfeeding.
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Jul 2015
    Posts
    610
    Thanks given
    521
    Thanks received
    660
    Rep Power
    0
    I was using an update-server u idiot, but didn't want to release it rofl.
    btw ur doing the exact same thing but zipping it, so...
    Reply With Quote  
     


  3. #3  
    Banned
    Join Date
    Sep 2015
    Posts
    78
    Thanks given
    54
    Thanks received
    34
    Rep Power
    0
    Quote Originally Posted by Swiffy View Post
    I was using an update-server u idiot, but didn't want to release it rofl.
    btw ur doing the exact same thing but zipping it, so...
    and zips are less to download. and seeing as you " didnt release it rofl" , and im the idiot?
    Please.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jul 2015
    Posts
    4
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Quote Originally Posted by Swiffy View Post
    I was using an update-server u idiot, but didn't want to release it rofl.
    btw ur doing the exact same thing but zipping it, so...
    You released it and didn't expect people to release stuff for it?
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Jul 2015
    Posts
    610
    Thanks given
    521
    Thanks received
    660
    Rep Power
    0
    Quote Originally Posted by rsnerdhelp View Post
    You released it and didn't expect people to release stuff for it?
    ... what?
    I replied to the following statement that he made towards me;
    Why Ruse would download raw type files ( .dat ) etc is beyond me, Especially when its 160mb +
    I simply said that I was using jagcached which I did not include in the release.



    Anyway, on topic, this is stupid. The whole point of downloading an entire cache is stupid.

    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  6. Thankful users:


  7. #6  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,472
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    take a second to realize his name is ruse reborn yet he's bagging on the release

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  8. Thankful users:


  9. #7  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,108
    Thanks given
    2,402
    Thanks received
    2,825
    Rep Power
    4604
    Quote Originally Posted by Swiffy View Post
    ... what?
    I replied to the following statement that he made towards me;

    I simply said that I was using jagcached which I did not include in the release.



    Anyway, on topic, this is stupid. The whole point of downloading an entire cache is stupid.

    [Only registered and activated users can see links. ]
    Downloading the entirety of a cache is great in some situations, I'd hardly peg it as 'stupid'.
    Reply With Quote  
     

  10. Thankful user:


  11. #8  
    Banned

    Join Date
    Jul 2015
    Posts
    610
    Thanks given
    521
    Thanks received
    660
    Rep Power
    0
    Quote Originally Posted by Jason View Post
    Downloading the entirety of a cache is great in some situations, I'd hardly peg it as 'stupid'.
    No, it's not.. Did you ever see Runescape download their entire cache in any revision?
    Reply With Quote  
     

  12. #9  
    Donator

    Jason's Avatar
    Join Date
    Aug 2009
    Posts
    6,108
    Thanks given
    2,402
    Thanks received
    2,825
    Rep Power
    4604
    Quote Originally Posted by Swiffy View Post
    No, it's not.. Did you ever see Runescape download their entire cache in any revision?
    > great in some situations

    I was referring to the concept of retrieving the content of an entire cache in various environments, not just in the RuneScape scene. Although there is some wait time, there are some major benefits to downloading the entirety of a cache. For example in the RuneScape scene, i'd rather not receive a 'Please wait...' status and a frozen screen when switching regions in the wilderness because of partially loaded data.
    Reply With Quote  
     

  13. Thankful user:


  14. #10  
    Banned

    Join Date
    Jul 2015
    Posts
    610
    Thanks given
    521
    Thanks received
    660
    Rep Power
    0
    Quote Originally Posted by Jason View Post
    > great in some situations

    I was referring to the concept of retrieving the content of an entire cache in various environments, not just in the RuneScape scene. Although there is some wait time, there are some major benefits to downloading the entirety of a cache. For example in the RuneScape scene, i'd rather not receive a 'Please wait...' status and a frozen screen when switching regions in the wilderness because of partially loaded data.
    Obviously... But do you actually think that they'd prioritize that 'feature' enough to make people download hundreds of mb of data (some of the data which most people will never use)?
    Reply With Quote  
     

Page 1 of 3 123 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: 20
    Last Post: 08-29-2014, 07:19 AM
  2. (updated) Haxor-Isle Client
    By Clouds Mine in forum Downloads
    Replies: 20
    Last Post: 06-11-2008, 09:22 PM
  3. [POC] Repacked Cache [download + client + tut]
    By Clienthax in forum RS2 Client
    Replies: 22
    Last Post: 05-06-2008, 09:39 PM
  4. Auto Cache Downloading Client (OPEN SOURCE)
    By eyrescape in forum Downloads
    Replies: 8
    Last Post: 01-06-2008, 10:51 AM
  5. [REQUEST] I need a auto cache 377 client!
    By CLOUD The STRIFE in forum Requests
    Replies: 2
    Last Post: 07-30-2007, 01:03 AM
Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •