Skip to content

Commit d7752e8

Browse files
committed
fix(TRSObject): fixed finding them without a TColorFinder and not TModel
- fixed a small bug for the cpp client where window resizing was not coded properly
1 parent 5924d75 commit d7752e8

File tree

5 files changed

+63
-20
lines changed

5 files changed

+63
-20
lines changed

osrs/interfaces/login/login.simba

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ before giving up.
583583
*)
584584
procedure TRSLogin.SwitchWorld(worlds: TIntegerArray);
585585
var
586-
attempt, time: Integer;
586+
attempt: Integer;
587587
begin
588588
for attempt := 0 to 4 do
589589
begin

osrs/position/map/entities.simba

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -323,25 +323,27 @@ begin
323323
Exit;
324324
end;
325325

326+
if Self.Model <> nil then
327+
Exit(boundsArray);
328+
326329
for i := 0 to High(boundsArray) do
327-
Result += TPointArray(boundsArray[i]).ShapeFill();
330+
Result += TPointArray(boundsArray[i]).Connect().ShapeFill();
328331
end;
329332

330333
(*
331-
## TRSEntityV2.Find
334+
## TRSEntity.FindEx
332335
```pascal
333-
function TRSEntityV2.FindEx(out cuboids: TCuboidArray; out atpa: T2DPointArray): Boolean;
334-
function TRSEntityV2.Find(out atpa: T2DPointArray): Boolean;
335-
function TRSEntityV2.FindFromPosition(me: TPoint; out atpa: T2DPointArray): Boolean;
336+
function TRSEntity.FindEx(me: TPoint; out boundsArray: TPolygonArray; out coordinates: TPointArray; out atpa: T2DPointArray): Boolean;
336337
```
337-
TRSEntityV2 method used to find a {ref}`TRSEntityV2`. If found returns true, if not returns false.
338-
The "extended" method in particular is mostly meant for debugging and is the one used when you call `Debug(TRSEntity)`.
338+
Internal {ref}`TRSEntity` method used to find a {ref}`RSEntity`.
339339

340-
Example:
341-
```pascal
342-
WriteLn RSObjects.GEBank.Find(atpa); //Be in ge and with a walker setup there.
343-
Debug(atpa);
344-
```
340+
You also have {ref}`RSEntity.Find` to find entities, this version of the method
341+
is internal because it returns extra information about the found entities for
342+
internal use, like it's `cuboids` for example.
343+
344+
This also returns an `atpa` containing the colors of the object that were found
345+
assuming the object has a {ref}`TColorFinder` setup.
346+
If not, the cuboids area are returned as the match.
345347
*)
346348
function TRSEntity.FindEx(me: TPoint; out boundsArray: TPolygonArray; out coordinates: TPointArray; out atpa: T2DPointArray): Boolean;
347349
begin
@@ -353,13 +355,35 @@ begin
353355
end;
354356

355357

358+
(*
359+
## RSEntity.Find
360+
```pascal
356361
function TRSEntity.Find(out coordinates: TPointArray; out atpa: T2DPointArray): Boolean;
362+
function TRSEntity.Find(out atpa: T2DPointArray): Boolean; overload;
363+
```
364+
{ref}`TRSEntity` method used to find a {ref}`RSEntity`.
365+
This returns True/False if the entity was found and it's `atpa` which cointains
366+
the colors of it that were found.
367+
368+
For more information on this refer to {ref}`TRSEntity.FindEx`, it's an internal
369+
function but is used within this one and will go into more detail.
370+
*)
371+
function TRSEntity.Find(out coordinates: TPointArray; out atpa: T2DPointArray): Boolean;
372+
var
373+
boundsArray: TPolygonArray;
374+
begin
375+
Result := Self.FindEx(Self.Walker^.Position(), boundsArray, coordinates, atpa);
376+
end;
377+
378+
function TRSEntity.Find(out atpa: T2DPointArray): Boolean; overload;
357379
var
380+
coordinates: TPointArray;
358381
boundsArray: TPolygonArray;
359382
begin
360383
Result := Self.FindEx(Self.Walker^.Position(), boundsArray, coordinates, atpa);
361384
end;
362385

386+
363387
function TRSEntity.FindFrom(position: TPoint; out atpa: T2DPointArray): Boolean;
364388
var
365389
boundsArray: TPolygonArray;

osrs/position/map/objects.simba

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,18 @@ begin
334334
Exit;
335335
end;
336336

337+
if Self.Model <> nil then
338+
Exit(boundsArray);
339+
337340
for i := 0 to High(boundsArray) do
338-
Result += TPointArray(boundsArray[i]).ShapeFill();
341+
Result += TPointArray(boundsArray[i]).Connect().ShapeFill();
339342
end;
340343

341344

342345
(*
343346
## RSObject.FindEx
344347
```pascal
345-
function TRSObject.FindEx(me: TPoint; out cuboids: TCuboidArray; out atpa: T2DPointArray): Boolean;
348+
function TRSObject.FindEx(me: TPoint; out boundsArray: TPolygonArray; out coordinates: TPointArray; out atpa: T2DPointArray): Boolean;
346349
```
347350
Internal {ref}`TRSObject` method used to find a {ref}`RSObject`.
348351
If found returns true, if not returns false.
@@ -410,14 +413,15 @@ end;
410413
(*
411414
## RSObject.Find
412415
```pascal
413-
function TRSObject.Find(out atpa: T2DPointArray): Boolean;
416+
function TRSObject.Find(out coordinates: TPointArray; out atpa: T2DPointArray): Boolean;
417+
function TRSObject.Find(out atpa: T2DPointArray): Boolean; overload;
414418
```
415419
{ref}`TRSObject` method used to find a {ref}`RSObject`.
416420
This returns True/False if the object was found and it's `atpa` which cointains
417421
the colors of it that were found.
418422

419423
For more information on this refer to {ref}`RSObject.FindEx`, it's an internal
420-
function but is user within this one and will go into more detail.
424+
function but is used within this one and will go into more detail.
421425
*)
422426
function TRSObject.Find(out coordinates: TPointArray; out atpa: T2DPointArray): Boolean;
423427
var
@@ -426,6 +430,15 @@ begin
426430
Result := Self.FindEx(Self.Walker^.Position(), boundsArray, coordinates, atpa);
427431
end;
428432

433+
function TRSObject.Find(out atpa: T2DPointArray): Boolean; overload;
434+
var
435+
coordinates: TPointArray;
436+
boundsArray: TPolygonArray;
437+
begin
438+
Result := Self.FindEx(Self.Walker^.Position(), boundsArray, coordinates, atpa);
439+
end;
440+
441+
429442
(*
430443
## RSObject.FindFrom
431444
```pascal

osrs/rsclient.simba

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ ShowOnTarget(RSClient._Bounds());
101101
function TRSClient._Bounds(img: TImage): TBox;
102102
var
103103
x1, x2, y2: Integer;
104+
win: TWindowHandle;
104105
begin
105106
if img.Pixel[0, img.Height-1] <> $0 then
106107
Exit(Target.Bounds);
@@ -115,8 +116,9 @@ begin
115116

116117
if img.Height-1 < 503 then
117118
begin
118-
with GetSimbaTargetWindow().GetBounds() do
119-
GetSimbaTargetWindow().SetBounds([X1, Y1, X2, Y1+503]);
119+
win := GetSimbaTargetWindow().GetRootWindow();
120+
with win.GetBounds() do
121+
win.SetBounds([X1, Y1, X2, Y1+535]);
120122
Result := [x1, 0, x2, 503];
121123
end
122124
else

utils/rschunks.simba

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ type
152152
EDGEVILLE,
153153
FALADOR,
154154
FOSSIL_ISLAND,
155+
GUARDIANS_OF_THE_RIFT,
155156
HOSIDIUS_KITCHEN,
156157
ICEBERG,
157158
LUMBRIDGE,
@@ -162,6 +163,7 @@ type
162163
PRIFDDINAS,
163164
ROGUES_DEN,
164165
RUINS_OF_UNKAH,
166+
RUNECRAFTING_ALTARS,
165167
SEERS_VILLAGE,
166168
STRONGHOLD_SLAYER_CAVE,
167169
TEMPOROSS_COVE,
@@ -185,8 +187,9 @@ begin
185187
ERSChunk.EDGEVILLE : Result := Chunk(Box(48,54,48,54), 0);
186188
ERSChunk.FALADOR : Result := Chunk(Box(45,53,47,51), 0);
187189
ERSChunk.FOSSIL_ISLAND : Result := Chunk(Box(56,61,60,57), [0,1]);
188-
ERSChunk.ICEBERG : Result := Chunk(Box(40,64,42,61), [0,1]);
190+
ERSChunk.GUARDIANS_OF_THE_RIFT : Result := Chunk(Box(55,149,57,147), 0);
189191
ERSChunk.HOSIDIUS_KITCHEN : Result := Chunk(Box(25,56,26,56), 0);
192+
ERSChunk.ICEBERG : Result := Chunk(Box(40,64,42,61), [0,1]);
190193
ERSChunk.LUMBRIDGE : Result := Chunk(Box(49,51,50,49), [0,1,2]);
191194
ERSChunk.LUNAR_ISLE : Result := Chunk(Box(32,61,33,60), 0);
192195
ERSChunk.MINING_GUILD : Result := Chunk(Box(46,152,47,151), 0);
@@ -195,6 +198,7 @@ begin
195198
ERSChunk.PRIFDDINAS : Result := Chunk(Box(50,95,51,94), 0);
196199
ERSChunk.ROGUES_DEN : Result := Chunk(Box(46,79,47,77), 1);
197200
ERSChunk.RUINS_OF_UNKAH : Result := Chunk(Box(48,44,49,44), 0);
201+
ERSChunk.RUNECRAFTING_ALTARS : Result := Chunk(Box(31,76,51,74), 0);
198202
ERSChunk.SEERS_VILLAGE : Result := Chunk(Box(41,55,43,53), [0,2]);
199203
ERSChunk.STRONGHOLD_SLAYER_CAVE : Result := Chunk(Box(37,153,38,152), 0);
200204
ERSChunk.TEMPOROSS_COVE : Result := Chunk(Box(47,46,47,46), 0);

0 commit comments

Comments
 (0)