Skip to content

Commit

Permalink
Fixed TRSLobbyWorlds.getCurrentWorld (http://villavu.com/forum/issue.…
Browse files Browse the repository at this point in the history
  • Loading branch information
cohenadair committed Nov 28, 2013
1 parent 86bc608 commit 2ca721f
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions lib/interfaces/lobby/worlds.simba
Expand Up @@ -324,41 +324,55 @@ Returns the currently selected world.
.. note::

- by Home
- Last Updated: 23 July 2013 by Coh3n
- Last Updated: 28 November 2013 by Coh3n

Example:

.. code-block:: pascal

if (not lobbyWorlds.getCurrentWorld(115)) then
if (not lobbyWorlds.getCurrentWorld() = 115) then
lobbyWorlds.selectWorld(115);
*)
function TRSLobbyWorlds.getCurrentWorld(): integer;
var
atpa: T2DPointArray;
atpa, atpaDigits: T2DPointArray;
tpa: TPointArray;
bmp, n: integer;
bmp, n, i: integer;
begin
result := -1;

if (not self.isOpen()) then
exit();

bmp := bitmapFromClient(self.x + 575, self.y + 60, self.x+self.w - 10, self.y + 75); // box around the current world
bmp := bitmapFromClient(self.x + 550, self.y + 60, self.x+self.w - 15, self.y + 80); // box around the current world

getMufasaBitmap(bmp).posterize(222);
getMufasaBitmap(bmp).findColors(tpa, 14606046);
getMufasaBitmap(bmp).findColors(tpa, 14606046); // color on posterized bmp

freeBitmap(bmp);

if (length(tpa) > 0) then
begin
atpa := tpa.split(1, 10);
sortATPAFromFirstPointX(atpa, [0, 0]);

n := strToInt(getTextATPA(atpa, 3, 'NumberCharsSmooth', numbers));
if (self._isWorldValid(n)) then
result := n;
if (length(atpa) > 6) then // elements 0-5 is the star and "World" text; 6-length is number
begin
sortATPAFromFirstPointX(atpa, [0, 0]);

// remove the star and "World" text to improve accuracy
for i := 6 to high(atpa) do
begin
setLength(atpaDigits, length(atpaDigits) + 1);
atpaDigits[high(atpaDigits)] := atpa[i];
end;

n := strToInt(getTextATPA(atpaDigits, 3, 'NumberCharsSmooth', numbers));
if (self._isWorldValid(n)) then
result := n;

end else
print('TRSLobbyWorlds.getCurrentWorld(): Not enough text characters', TDebug.ERROR);

end else
print('TRSLobbyWorlds.getCurrentWorld(): Failed to find text color', TDebug.ERROR);

Expand Down

0 comments on commit 2ca721f

Please sign in to comment.