Skip to content

Commit 3853a82

Browse files
committed
update scoping of the map
1 parent cdf07e8 commit 3853a82

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

osrs/position/map/maploader.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ begin
332332
begin
333333
if not FileExists(cachename + '.png') then
334334
begin
335-
Result.SetSize(RSTranslator.Map.ChunkSide, RSTranslator.Map.ChunkSide);
335+
Result.SetSize(RSTranslator.MapChunkSide, RSTranslator.MapChunkSide);
336336
if not DirCreate(PathExtractDir(cachename)) then
337337
raise GetDebugLn('MapLoader', 'Failed to create path: ' + PathExtractDir(cachename));
338338
end
@@ -379,7 +379,7 @@ begin
379379
hi := [Max(x, hi.X), Max(y, hi.Y)];
380380
end;
381381

382-
n := RSTranslator.Map.ChunkSide;
382+
n := RSTranslator.MapChunkSide;
383383

384384
Result := new TImage((hi.X-lo.X) * n + 1 + n, (hi.Y-lo.Y) * n + 1 + n);
385385

utils/math/rstranslator.simba

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@ that can be used by Simba and back.
2121
RSMap: record
2222
const ChunkSide: Integer = 64;
2323
const Dimensions: TPoint = [100,200];
24-
const Scope: TBox = [15, 19, 66, 196];
24+
const Scope: TBox = [0, 19, 99, 196];
2525
end;
2626

27-
Map: record
28-
const ChunkSide: Integer = 256;
29-
const Dimensions: TPoint = [2560, 5120];
30-
const Scope: TBox = [3840, 4864, 16896, 50176];
31-
end;
27+
const MapChunkSide: Integer = 256;
3228
end;
3329

3430
(*
@@ -45,7 +41,7 @@ WriteLn RSTranslator.MapWidth;
4541
*)
4642
property TRSTranslator.MapWidth: Integer;
4743
begin
48-
Result := Self.RSMap.Scope.Width * Self.Map.ChunkSide;
44+
Result := Self.RSMap.Scope.Width * Self.MapChunkSide;
4945
end;
5046

5147
(*
@@ -62,7 +58,7 @@ WriteLn RSTranslator.MapHeight;
6258
*)
6359
property TRSTranslator.MapHeight: Integer;
6460
begin
65-
Result := Self.RSMap.Scope.Height * Self.Map.ChunkSide;
61+
Result := Self.RSMap.Scope.Height * Self.MapChunkSide;
6662
end;
6763

6864

@@ -82,8 +78,8 @@ WriteLn RSTranslator.Global2Chunk(Point(2000, 2000));
8278
function TRSTranslator.Global2Chunk(p: TPoint): TPoint;
8379
begin
8480
while p.X > Self.MapWidth do p.X -= Self.MapWidth;
85-
Result.X := Self.RSMap.Scope.X1 + Floor(p.X / Self.Map.ChunkSide);
86-
Result.Y := Self.RSMap.Scope.Y2 - Floor(p.Y / Self.Map.ChunkSide);
81+
Result.X := Self.RSMap.Scope.X1 + Floor(p.X / Self.MapChunkSide);
82+
Result.Y := Self.RSMap.Scope.Y2 - Floor(p.Y / Self.MapChunkSide);
8783
end;
8884

8985
function TRSTranslator.Global2Chunk(b: TBox): TBox; overload;
@@ -111,8 +107,8 @@ WriteLn RSTranslator.Chunk2Coordinate(Point(53, 50));
111107
*)
112108
function TRSTranslator.Chunk2Coordinate(p: TPoint): TPoint;
113109
begin
114-
Result.X := p.X * Self.Map.ChunkSide - Self.Map.Scope.X1;
115-
Result.Y := Self.Map.Scope.Y2 - p.Y * Self.Map.ChunkSide;
110+
Result.X := p.X * Self.MapChunkSide;
111+
Result.Y := (Self.RSMap.Scope.Y2 - p.Y) * Self.MapChunkSide;
116112
end;
117113

118114
function TRSTranslator.Chunk2Coordinate(b: TBox): TBox; overload;

0 commit comments

Comments
 (0)