Thread: loc.dat / loc.idx structure?

Results 1 to 6 of 6
  1. #1 loc.dat / loc.idx structure? 
    Registered Member
    Join Date
    Oct 2012
    Posts
    205
    Thanks given
    10
    Thanks received
    17
    Rep Power
    30
    Does anyone have any information on how the loc.dat/loc.idx are composed (the contents inside)?

    I am looking to edit this to add my own objects for specific regions and would like to know how to go about this.

    Any help is appreciated.

    What are these files even for? I've heard that objects can be added by just editing the map itself

    Share knowledge pls - I have looked everywhere for info on this and there doesn't seem to be anything.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Oct 2012
    Posts
    205
    Thanks given
    10
    Thanks received
    17
    Rep Power
    30
    bump
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Oct 2012
    Posts
    205
    Thanks given
    10
    Thanks received
    17
    Rep Power
    30
    bump
    Reply With Quote  
     

  4. #4  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,541
    Thanks given
    457
    Thanks received
    1,259
    Rep Power
    1003
    just look in the client its your best resource. look at a client that's heavily refactored. [Only registered and activated users can see links. ]

    Code:
    loc.dat
    totalEntries : UShort
    while(true) {
    	opcode : UByte
    	objectDef Attribute/Attributes
    }
    Code:
    loc.idx
    totalEntries : UShort
    foreach entry {
    dataOffset : UShort
    }
    objectDef Attributes can be any of these
    Code:
    			} else if (type == 1) {
    				int length = stream.readUnsignedByte();				
    				if (length > 0) {
    					if (modelIds == null || lowMemory) {
    						modelTypes = new int[length];
    						modelIds = new int[length];
    						for (int i = 0; i < length; i++) {							
    							modelIds[i] = stream.readUShort();
    							modelTypes[i] = stream.readUnsignedByte();
    						}
    					} else {
    						stream.currentPosition += length * 3;
    					}
    				}
    			} else if (type == 2) {
    				name = stream.readString();
    			} else if (type == 3) {
    				description = stream.readString();
    			} else if (type == 5) {
    				int len = stream.readUnsignedByte();
    				if (len > 0) {
    					if (modelIds == null || lowMemory) {
    						modelTypes = null;
    						modelIds  = new int[len];
    						for (int l1 = 0; l1 < len; l1++)
    							modelIds[l1] = stream.readUShort();
    					} else {
    						stream.currentPosition += len * 2;
    					}
    				}
    			} else if (type == 14) {
    				objectSizeX = stream.readUnsignedByte();
    			} else if (type == 15) {
    				objectSizeY = stream.readUnsignedByte();
    			} else if (type == 17) {
    				solid  = false;
    			} else if (type == 18) {
    				impenetrable  = false;
    			}
    			else if (type == 19)
    				isInteractive = (stream.readUnsignedByte() == 1);
    			else if (type == 21)
    				contouredGround = true;
    			else if (type == 22)
    				delayShading = false;
    			else if (type == 23)
    				occludes  = true;
    			else if (type == 24) {
    				animation  = stream.readUShort();
    				if (animation   == 65535)
    					animation  = -1;
    			} else if (type == 28)
    				decorDisplacement = stream.readUnsignedByte();
    			else if (type == 29)
    				ambientLighting  = stream.readSignedByte();
    			else if (type == 39)
    				lightDiffusion  = stream.readSignedByte();
    			else if (type >= 30 && type < 39) {
    				if (interactions  == null)
    					interactions = new String[5];
    				interactions[type - 30] = stream.readString();
    				if (interactions[type - 30].equalsIgnoreCase("hidden"))
    					interactions[type - 30] = null;
    			} else if (type == 40) {
    				int i1 = stream.readUnsignedByte();
    				modifiedModelColors = new int[i1];
    				originalModelColors = new int[i1];
    				for (int i2 = 0; i2 < i1; i2++) {
    					modifiedModelColors[i2] = stream.readUShort();
    					originalModelColors[i2] = stream.readUShort();
    				}
    			} else if (type == 41) {
    				int j2 = stream.readUnsignedByte();
    				modifiedTexture = new short[j2];
    				originalTexture = new short[j2];
    				for (int k = 0; k < j2; k++) {
    					modifiedTexture[k] = (short) stream.readUShort();
    					originalTexture[k] = (short) stream.readUShort();
    				}
    
    
    			} else if (type == 82)
    				minimapFunction = stream.readUShort();
    			else if (type == 62)
    				inverted = true;
    			else if (type == 64)
    				castsShadow = false;
    			else if (type == 65)
    				scaleX = stream.readUShort();
    			else if (type == 66)
    				scaleY = stream.readUShort();
    			else if (type == 67)
    				scaleZ = stream.readUShort();
    			else if (type == 68)
    				mapscene = stream.readUShort();
    			else if (type == 69)
    				surroundings = stream.readUnsignedByte();
    			else if (type == 70)
    				translateX = stream.readShort();
    			else if (type == 71)
    				translateY = stream.readShort();
    			else if (type == 72)
    				translateZ = stream.readShort();
    			else if (type == 73)
    				obstructsGround = true;
    			else if (type == 74)
    				hollow  = true;
    			else if (type == 75)
    				supportItems = stream.readUnsignedByte();
    			else if (type == 77) {
    				varp = stream.readUShort();
    				if (varp == 65535) {
    					varp = -1;
    				}
    				varbit = stream.readUShort();
    				if (varbit == 65535) {
    					varbit = -1;
    				}
    				int length = stream.readUnsignedByte();				
    				childrenIDs = new int[length];
    				for (int i = 0; i < length; i++) {					
    					childrenIDs[i] = stream.readUShort();
    					if (childrenIDs[i] == 65535) {
    						childrenIDs[i] = -1;
    					}
    				}
    			}
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Oct 2012
    Posts
    205
    Thanks given
    10
    Thanks received
    17
    Rep Power
    30
    Quote Originally Posted by nshusa View Post
    just look in the client its your best resource. look at a client that's heavily refactored. [Only registered and activated users can see links. ]

    Code:
    loc.dat
    totalEntries : UShort
    while(true) {
    	opcode : UByte
    	objectDef Attribute/Attributes
    }
    Code:
    loc.idx
    totalEntries : UShort
    foreach entry {
    dataOffset : UShort
    }
    objectDef Attributes can be any of these
    Code:
    			} else if (type == 1) {
    				int length = stream.readUnsignedByte();				
    				if (length > 0) {
    					if (modelIds == null || lowMemory) {
    						modelTypes = new int[length];
    						modelIds = new int[length];
    						for (int i = 0; i < length; i++) {							
    							modelIds[i] = stream.readUShort();
    							modelTypes[i] = stream.readUnsignedByte();
    						}
    					} else {
    						stream.currentPosition += length * 3;
    					}
    				}
    			} else if (type == 2) {
    				name = stream.readString();
    			} else if (type == 3) {
    				description = stream.readString();
    			} else if (type == 5) {
    				int len = stream.readUnsignedByte();
    				if (len > 0) {
    					if (modelIds == null || lowMemory) {
    						modelTypes = null;
    						modelIds  = new int[len];
    						for (int l1 = 0; l1 < len; l1++)
    							modelIds[l1] = stream.readUShort();
    					} else {
    						stream.currentPosition += len * 2;
    					}
    				}
    			} else if (type == 14) {
    				objectSizeX = stream.readUnsignedByte();
    			} else if (type == 15) {
    				objectSizeY = stream.readUnsignedByte();
    			} else if (type == 17) {
    				solid  = false;
    			} else if (type == 18) {
    				impenetrable  = false;
    			}
    			else if (type == 19)
    				isInteractive = (stream.readUnsignedByte() == 1);
    			else if (type == 21)
    				contouredGround = true;
    			else if (type == 22)
    				delayShading = false;
    			else if (type == 23)
    				occludes  = true;
    			else if (type == 24) {
    				animation  = stream.readUShort();
    				if (animation   == 65535)
    					animation  = -1;
    			} else if (type == 28)
    				decorDisplacement = stream.readUnsignedByte();
    			else if (type == 29)
    				ambientLighting  = stream.readSignedByte();
    			else if (type == 39)
    				lightDiffusion  = stream.readSignedByte();
    			else if (type >= 30 && type < 39) {
    				if (interactions  == null)
    					interactions = new String[5];
    				interactions[type - 30] = stream.readString();
    				if (interactions[type - 30].equalsIgnoreCase("hidden"))
    					interactions[type - 30] = null;
    			} else if (type == 40) {
    				int i1 = stream.readUnsignedByte();
    				modifiedModelColors = new int[i1];
    				originalModelColors = new int[i1];
    				for (int i2 = 0; i2 < i1; i2++) {
    					modifiedModelColors[i2] = stream.readUShort();
    					originalModelColors[i2] = stream.readUShort();
    				}
    			} else if (type == 41) {
    				int j2 = stream.readUnsignedByte();
    				modifiedTexture = new short[j2];
    				originalTexture = new short[j2];
    				for (int k = 0; k < j2; k++) {
    					modifiedTexture[k] = (short) stream.readUShort();
    					originalTexture[k] = (short) stream.readUShort();
    				}
    
    
    			} else if (type == 82)
    				minimapFunction = stream.readUShort();
    			else if (type == 62)
    				inverted = true;
    			else if (type == 64)
    				castsShadow = false;
    			else if (type == 65)
    				scaleX = stream.readUShort();
    			else if (type == 66)
    				scaleY = stream.readUShort();
    			else if (type == 67)
    				scaleZ = stream.readUShort();
    			else if (type == 68)
    				mapscene = stream.readUShort();
    			else if (type == 69)
    				surroundings = stream.readUnsignedByte();
    			else if (type == 70)
    				translateX = stream.readShort();
    			else if (type == 71)
    				translateY = stream.readShort();
    			else if (type == 72)
    				translateZ = stream.readShort();
    			else if (type == 73)
    				obstructsGround = true;
    			else if (type == 74)
    				hollow  = true;
    			else if (type == 75)
    				supportItems = stream.readUnsignedByte();
    			else if (type == 77) {
    				varp = stream.readUShort();
    				if (varp == 65535) {
    					varp = -1;
    				}
    				varbit = stream.readUShort();
    				if (varbit == 65535) {
    					varbit = -1;
    				}
    				int length = stream.readUnsignedByte();				
    				childrenIDs = new int[length];
    				for (int i = 0; i < length; i++) {					
    					childrenIDs[i] = stream.readUShort();
    					if (childrenIDs[i] == 65535) {
    						childrenIDs[i] = -1;
    					}
    				}
    			}

    Hi thanks,

    the link is dead on that thread, would you happen to have another so I can play around?

    Also is this used for defining object positions? I've noticed when using multiple locs the positions of objects will change and new ones will spawn etc... How does this work?
    Reply With Quote  
     

  6. #6  
    Registered Member Stevenhax's Avatar
    Join Date
    Jul 2014
    Posts
    389
    Thanks given
    53
    Thanks received
    64
    Rep Power
    42
    Quote Originally Posted by ohokay View Post
    Hi thanks,

    the link is dead on that thread, would you happen to have another so I can play around?

    Also is this used for defining object positions? I've noticed when using multiple locs the positions of objects will change and new ones will spawn etc... How does this work?
    Loc files only contain information about the object such as which models it has, what name and actions it has and what color it has ingame.
    The only use in loading multiple locs is having objects from different revisions. For example if you want to load the Abyssal Sire area you would want a
    OSRS loc because the 317 doesn't contain the data you need for the objects of the area, yet you would want the keep the 317 loc if you want your edgeville
    to look like 317 edgeville and not OSRS edgeville.

    Consider this a short version of what happends when you load a map file
    1) Mapfile is loaded
    2) Object IDs and positions are extracted
    3) loc file is searched for object ID
    4) model, name, actions etc are retrieved from the loc
    5) object models etc are loaded from the cache
    6) object is displayed ingame with actions, name, models etc retrieved earlier

    As I said the position of objects is handled in map files (index 4 in your cache). The easiest way of adding custom objects ingame
    is just hardcoding them although if you want to do it properly you could use a map edittor (there are a few but they are mediocre or hard to get to work).
    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. 667 loc.dat, loc.idx and models
    By Richard1992 in forum Downloads
    Replies: 52
    Last Post: 11-22-2017, 11:03 AM
  2. 667 loc.dat loc.idx
    By Sgsrocks in forum Requests
    Replies: 2
    Last Post: 08-05-2014, 04:34 PM
  3. 508 loc.dat and idx
    By owner blade in forum Requests
    Replies: 3
    Last Post: 01-04-2013, 07:38 PM
  4. How to add loc.dat & loc.idx
    By ST1211 in forum Help
    Replies: 2
    Last Post: 05-28-2012, 02:47 PM
  5. 474 loc.dat & loc.idx for 317
    By Kenshin1388 in forum Requests
    Replies: 2
    Last Post: 04-12-2010, 06:42 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
  •