MapLoader¶
This file is responsible for loading chunk maps for TRSMap. It was made from scratch but heavily inspired in the original TRSWalker by slacky and it’s future iterations made by Olly.
Note
Most things in this file are for internal use only and you shouldn’t use them directly nor modify them if you don’t quite understand them.
Credits: Torwent
TRSMapRegion¶
Map region record, responsible for storing the map region/chunk data.
Note
This is an internal type. Don’t use it if you don’t know what you are doing.
TRSMapRegion.Name¶
property TRSMapRegion.Name: String;
Returns a unique string representing this map region.
ERSMap¶
ERSMap = enum(NORMAL, HEIGHT, COLLISION);
Enum representing the types of map files available in TRSMap and TRSMapLoader.
TRSMapLoader¶
TRSMapLoader is what’s responsible for loading a map for TRSMap based on chunks.
Note
This is an internal type. Don’t use it if you don’t know what you are doing.
Points Translation¶
This might be the only thing you need to use from time to time from the MapLoader.
It’s important to understand the difference between local and global points to use these effectively. Understanding them and making conversions of this coordinates is needed for proper coordinate debugging.
Global Points¶
Global points and points on the real runescape map. This is the “Global map”.
E.G., if you visit Wasp Map, all coordinates on that map are Global coordinates.
These are usually the ones you use when telling your scripts to walk or click a certain tile and/or object.
Local Points¶
When you build a map, the region or regions you load are taken from the map and joined into a small, efficient map that only contains what you choose.
This is your “Local map”.
This is important because the bigger the map is the slower it is to use.
Because the regions are joined into a small map, it means that their “coordinates” don’t line up with their original ones anymore.
If you pick for example, pixel [100, 100] on your local map, that pixel won’t be matching the pixel [100, 100] on the global map. Instead it matches the pixel [100,100] from the top left corner of one of your regions to put it simply.
TRSMapLoader.LocalIndex¶
function TRSMapLoader.LocalIndex(pt: TPoint): Integer;
Returns the index of the TRSMapRegion a Local point is at.
Returns -1
if none is found.
TRSMapLoader.GlobalIndex¶
function TRSMapLoader.GlobalIndex(pt: TPoint): Integer;
Returns the index of the TRSMapRegion a Global point is at.
Returns -1
if none is found.
TRSMapLoader.GetGlobal¶
function TRSMapLoader.GetGlobal(regionIndex: Integer; pt: TPoint; offset: TPoint = [0,0]): TPoint;
function TRSMapLoader.GetGlobal(pt: TPoint; offset: TPoint = [0,0]): TPoint; overload;
Converts a Local point to a Global point.
You can optionally specify the regionIndex
you want your pt
to be converted to or let Simba figure it out.
For points in bulk from the same region specifying it is better as you save Simba from doing more math.
The specified pt
is returned unmodified if not region index matching the point is found.
TRSMapLoader.GetLocal¶
function TRSMapLoader.GetLocal(regionIndex: Integer; pt: TPoint; offset: TPoint = [0,0]): TPoint;
function TRSMapLoader.GetLocal(pt: TPoint; offset: TPoint = [0,0]): TPoint; overload;
function TRSMapLoader.GetLocal(tpa: TPointArray; offset: TPoint = [0,0]): TPointArray; overload;
Converts a Global point to a Local point.
You can optionally specify the regionIndex
you want your pt
to be converted to or let Simba figure it out.
You can also optionally specify points in bulk as a tpa
.
The specified pt
is returned unmodified if not region index matching the point is found.
MapLoader.GetFile¶
function TRSMapLoader.GetFile(chunk: TPoint; plane: Integer; map: ERSMap): TImage;
Internal method that returns a chunk image. If possible, it will be loaded from a cached .bmp file. If no .bmp file exists, the .png file is loaded instead, it’s saved as .bmp for future uses and the .png file is deleted.
MapLoader.GetMap¶
function TRSMapLoader.GetMap(chunks: TPointArray; plane: Integer; map: ERSMap): TImage;
Internal method that returns a TImage
of all the chunks
you pass into it.
MapLoader.GetGraph¶
function TRSMapLoader.GetGraph(name: String; plane: Integer; map: TImage): TWebGraph;
Returns a TWebGraph for the given map
.
If the graph is already cached we load it from cache, otherwise we build it with WebGraph Generator and save it into cache.
Note
This is an internal method. Don’t use it if you don’t know what you are doing.
MapLoader.Load¶
procedure TRSMapLoader.Load(chunks: TRSMapChunkArray; downscale: Integer = 8; padding: Integer = 40);
Loads a map and sets the TRSMapLoader internal values, the most important ones being:
TRSMapLoader.Map
, which will hold the image of your map.TRSMapLoader.Heightmap
which will hold your heightmap.TRSMapLoader.Collision
which will hold your collision mapTRSMapLoader.DownscaledMap
which is an exact copy ofTRSMapLoader.Map
downscaled by the specifieddownscale
.TRSMapLoader.Graph
which holds your TWebGraph which is used for walking.TRSMapLoader.Regions
an array of the available TRSMapRegion that were loaded.
The best way to visualize most of these is to use the Map Debugger:
Example:
{$I WaspLib/osrs.simba}
begin
Map.Setup([ERSChunk.VARROCK]);
MapDebugger.Setup(@Map.Loader);
MapDebugger.Show();
end.

Note
This is an internal method. Usually, TRSMap Load
methods will call this for you.
MapLoader.Add¶
procedure TRSMapLoader.Add(chunks: array of TRSMapChunk; downscale: UInt32 = 8; padding: UInt32 = 40);
Adds one or more TRSMapChunk
to your already, previously loaded TRSMapLoader
.
This is very similar to what MapLoader.Load does and should be used after it as it sets up some internal values that this doesn’t.
This basically updates some of the values it previously setup.
Note
This is an internal method. Usually, TRSMap Add
methods will call this for you.