Thread: Cache objects x, y?

Results 1 to 3 of 3
  1. #1 Cache objects x, y? 
    Respected Member

    Join Date
    Jan 2009
    Posts
    5,682
    Thanks given
    1,093
    Thanks received
    3,494
    Discord
    View profile
    Rep Power
    5000
    loc.dat seems to only contain the definition for the objects, not the x y where they are located. Not sure if I have the protocol completely right, but I am pretty sure it is... Does the cache contain the x and y locations for the object placement? If so where should I be looking.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Stacx's Avatar
    Join Date
    Jun 2009
    Posts
    463
    Thanks given
    166
    Thanks received
    105
    Rep Power
    125
    They are located in object/landscape maps most likely.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Nov 2010
    Posts
    11
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    reference:
    Code:
    package org.hyperion.cache.map;
    
    import java.io.IOException;
    import java.nio.ByteBuffer;
    
    import org.hyperion.cache.Cache;
    import org.hyperion.cache.index.impl.MapIndex;
    import org.hyperion.cache.util.ByteBufferUtils;
    import org.hyperion.cache.util.ZipUtils;
    import org.hyperion.rs2.model.GameObject;
    import org.hyperion.rs2.model.GameObjectDefinition;
    import org.hyperion.rs2.model.Location;
    
    /**
     * A class which parses landscape files and fires events to a listener class.
     * @author Graham Edgecombe
     *
     */
    public class LandscapeParser {
    	
    	/**
    	 * The cache.
    	 */
    	private Cache cache;
    	
    	/**
    	 * The cache file.
    	 */
    	private int area;
    	
    	/**
    	 * The listener.
    	 */
    	private LandscapeListener listener;
    	
    	/**
    	 * Creates the parser.
    	 * @param cache The cache.
    	 * @param area The area id.
    	 * @param listener The listener.
    	 */
    	public LandscapeParser(Cache cache, int area, LandscapeListener listener) {
    		this.cache = cache;
    		this.area = area;
    		this.listener = listener;
    	}
    	
    	/**
    	 * Parses the landscape file.
    	 * @throws IOException if an I/O error occurs.
    	 */
    	public void parse() throws IOException {
    		int x = ((area >> 8) & 0xFF) * 64;
    		int y = (area & 0xFF) * 64;
    		
    		MapIndex index = cache.getIndexTable().getMapIndex(area);
    		
    		ByteBuffer buf = ZipUtils.unzip(cache.getFile(4, index.getLandscapeFile()));
    		int objId = -1;
    		while(true) {
    			int objIdOffset = ByteBufferUtils.getSmart(buf);
    			if(objIdOffset == 0) {
    				break;
    			} else {
    				objId += objIdOffset;
    				int objPosInfo = 0;
    				while(true) {
    					int objPosInfoOffset = ByteBufferUtils.getSmart(buf);
    					if(objPosInfoOffset == 0) {
    						break;
    					} else {
    						objPosInfo += objPosInfoOffset - 1;
    						
    						int localX = objPosInfo >> 6 & 0x3f;
    						int localY = objPosInfo & 0x3f;
    						int plane = objPosInfo >> 12;
    						
    						int objOtherInfo = buf.get() & 0xFF;
    						
    						int type = objOtherInfo >> 2;
    						int rotation = objOtherInfo & 3;
    						
    						Location loc = Location.create(localX + x, localY + y, plane);
    						
    						listener.objectParsed(new GameObject(GameObjectDefinition.forId(objId), loc, type, rotation));
    					}
    				}
    			}
    		}
    	}
    
    }
    Reply With Quote  
     


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. Removing Objects From Cache
    By xytelica in forum Help
    Replies: 5
    Last Post: 04-11-2010, 05:32 PM
  2. 377 cache, objects fucked.
    By Xenon in forum Help
    Replies: 8
    Last Post: 01-30-2010, 06:05 AM
  3. cache objects
    By I Kolo I in forum Help
    Replies: 0
    Last Post: 06-20-2009, 11:15 PM
  4. Cache objects
    By Echo` in forum Help
    Replies: 2
    Last Post: 06-06-2009, 04:18 PM
  5. The 377 cache (items-npc's-objects)
    By razvanx in forum Tutorials
    Replies: 0
    Last Post: 05-18-2008, 05:19 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •