PDA

View Full Version : SPS.simba



Pages : [1] 2

marpis
02-11-2011, 03:35 PM
New SPS thread can be found here (http://villavu.com/forum/showthread.php?p=829125#post829125)

________________________
I give you...
SRL Positioning System

What is SPS?

100% color positioning system.
It gives you tile-like information of your current position in the worldmap.
It does not involve or require Reflection in any way.
It works without smart.
It does not give you your current tile like reflection does, but it does give you your position on the huge worldmap bitmap found in the SPS folder.


How can I test SPS?

Download SPS.rar here: http://uppit.com/dhg3h0q5bhi5/SPS-03-13-11.zip
Extract it to /Simba/Includes/SRL/SRL/core/
Go inside the /core/SPS/
Copy the SPS.dll to /Simba/Plugins/
Open /core/SPS/TestSPS.simba
Log in to RuneScape, go to Varrock East Bank, set your compass to North.
Drag the cursor from Simba to RuneScape client, and hit run.
The script will walk you from the bank to the eastern mine and back again.
Do not touch MapMaker.simba, it is for development purposes only!
Remember to post the results!


How can I use SPS in my scripts?

Let's assume you are making a Rimmington Yew chopper.
Go to SPS.dll
The 500x500 bitmaps you see are actually pieces of worldmap.bmp.
Find the bitmaps you will be walking on. For example now we would like to use bitmaps

8_4
8_5
9_4

We declare your script to use these 3 pieces, by adding them to SPS_Areas array.

program RimmingtonYews;
{.include SRL/SRL.scar}
{.include SRL/SRL/core/SPS/SPS.simba} // NOTE: SPS is not actually in SRL yet. You will have to manually include it like this.

begin
SetupSRL;
SPS_Areas := ['8_4', '8_5', '9_4'];
end.


You probably noticed that the numbers '8_4' serve as cordinates. 8 is the position in x-axis and 4 is the position in y-axis. This will help you find the places you're looking for.
Do not under any circumstances rename or move files to other folders in /core/SPS! This will break the whole system.
Now we need to create our path from the Falador bank to Rimmington yew trees.
Open /core/SPS/worldmap.bmp with MS Paint.
Find Falador Bank, move your mouse over it and look up the coords in the bottom-left corner. I get (3673, 1679).
Now get the cords of the next position in our path. (3650, 1707) Looks pretty good.
Continue this until you reach your destination, around (3372, 2175).
Remember to pick the points relatively close to each other, ~20-50 pixels apart.
Let's make a function that will walk this path

program RimmingtonYews;
{.include SRL/SRL.scar}
{.include SRL/SRL/core/SPS/SPS.simba}

var
MyPath: TPointArray; // We will store our points in a TPointArray

begin
SetupSRL;
SPS_Areas := ['8_4', '8_5', '9_4'];
MyPath := [Point(3673, 1679), Point(3650, 1707),
Point(1231, 3213), Point(9879, 7897),
Point(3372, 2175)]; // This does not work, I made some cords up
if WalkPath(MyPath) then
WriteLn('We made it!');

end.

If you want to run the same path to the other end, you can reverse the path by using InvertTPA:

InvertTPA(MyPath);



Credits

Wizzup? for helping me make the plugin.
mastaraymon also for helping make the plugin.

Sir R. M8gic1an
02-11-2011, 03:46 PM
This looks absolutely great.

Could be added as one of MSI v2's walking methods.... well, you can add it :)

~RM

IPwnz
02-11-2011, 04:28 PM
This may be a dumb question, but is it possible to use PathMaker to find the coords or do we have to find them in something like Paint?

Quickmarch
02-11-2011, 04:31 PM
Where's the .dll :s?

Sir R. M8gic1an
02-11-2011, 04:40 PM
This may be a dumb question, but is it possible to use PathMaker to find the coords or do we have to find them in something like Paint?

possibly.

It does give you coords and you've have to update the map to marpis'

From there it should only require some math to do TileToBitmap

~RM

Zyt3x
02-11-2011, 04:42 PM
Awesome, marpis! :)


This looks absolutely great.

Could be added as one of MSI v2's walking methods.... well, you can add it :)

~RMAgreed!

Wizzup?
02-11-2011, 04:42 PM
How can I test SPS?

Download SPS.rar here: http://marpis.comxa.com/


There?

marpis
02-11-2011, 04:43 PM
Where's the .dll :s?


Oh, crap! I'll add it immediately! :duh:

There?
I forgot to add it there :rolleyes:

E: Done! :) And I don't really remember how the PathMaker works, but it's really just as fast to take the points with MS Paint. It doesn't matter if they are too close to each other, WalkPath will find the furthest one and walk there.

Wanted
02-12-2011, 06:44 AM
Can't wait to test this.

So many questions to its effectiveness like reliability, speed, and accuracy.

KingKong
02-12-2011, 07:27 AM
The map doesn't show from verock east bank to the wilderness, is this done on purpose or did something happen to me that stuffed the bmp?

Suggestion: It would be epic if the world map was cut into grid and labelled what grid was number.

Oh, and btw, this is awesome as it is and i cant wait to test it!

Coh3n
02-12-2011, 09:32 AM
I tried to make a path from Port Sarim deposit box to Draynor bank. This is my setup

program RimmingtonYews;
{$i SRL/SRL/misc/smart.scar}
{$i SRL/SRL.scar}
{$i SRL/SRL/core/SPS.simba}

var
MyPath: TPointArray; // We will store our points in a TPointArray

begin
Smart_Server := 152;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
ClearDebug;
SetupSRL;
SPS_Areas := ['9_5'];
MyPath := [Point(3810, 2459), Point(3813, 2113), Point(3863, 2089),
Point(3908, 2101), Point(3938, 2103), Point(3994, 2123)];

if WalkPath(MyPath) then
WriteLn('We made it!');
end.

And I keep getting this

[SPS] Maps loaded in 0ms.
[SPS] Something is wrong!
[SPS] Something is wrong!
[SPS] Something is wrong!
[SPS] Something is wrong!

"Something is wrong" just spams the debug forever. =\

Not sure what I did wrong. :(

On another note, if someone could make a tool like the reflection path maker (or make it work with this map) that would be awesome! I tried, but unfortunately it didn't work. Probably doesn't help that I don't really know what I'm doing. :p

Smidqe
02-12-2011, 11:20 AM
[SPS] Maps loaded in 0ms.
[SPS] Something is wrong!
[SPS] Something is wrong!
[SPS] Something is wrong!
[SPS] Something is wrong!

"Something is wrong" just spams the debug forever. =\

Not sure what I did wrong. :(

On another note, if someone could make a tool like the reflection path maker (or make it work with this map) that would be awesome! I tried, but unfortunately it didn't work. Probably doesn't help that I don't really know what I'm doing. :p

Change the SPS_PATH in SPS.simba to the following
AppPath + '/Includes/SRL/SRL/Core/SPS/';
Because it's currently this
AppPath + '/Includes/SRL/SRL/SPS/';
I tested with your path and it works.
[SPS] Maps loaded in 328ms.
[SPS] Finished in 421 ms. Location = (3810, 2160)
[SPS] Finished in 390 ms. Location = (3810, 2120)
[SPS] Finished in 390 ms. Location = (3865, 2090)
[SPS] Finished in 343 ms. Location = (3680, 2405)
[SPS] Finished in 343 ms. Location = (3685, 2395)
[SPS] Finished in 343 ms. Location = (3680, 2400)
[SPS] Finished in 343 ms. Location = (3670, 2390)
[SPS] Finished in 343 ms. Location = (3675, 2395)
[SPS] Finished in 343 ms. Location = (3675, 2385)
[SPS] Finished in 344 ms. Location = (3675, 2385)
[SPS] Finished in 343 ms. Location = (3685, 2390)
[SPS] Finished in 343 ms. Location = (3680, 2385)
[SPS] Finished in 312 ms. Location = (3680, 2385)
[SPS] Finished in 343 ms. Location = (3685, 2385)
[SPS] Finished in 281 ms. Location = (3685, 2385)
[SPS] Finished in 327 ms. Location = (3680, 2390)
[SPS] Finished in 281 ms. Location = (3690, 2385)
[SPS] Finished in 343 ms. Location = (3690, 2385)
[SPS] Finished in 343 ms. Location = (3690, 2385)
[SPS] Finished in 343 ms. Location = (3685, 2390)
[SPS] Finished in 359 ms. Location = (3690, 2390)
[SPS] Finished in 343 ms. Location = (3685, 2390)
[SPS] Finished in 343 ms. Location = (3685, 2395)
[SPS] Finished in 343 ms. Location = (3685, 2400)
[SPS] Finished in 343 ms. Location = (3690, 2400)
[SPS] Finished in 343 ms. Location = (3685, 2405)
[SPS] Finished in 359 ms. Location = (3685, 2405)
[SPS] Finished in 343 ms. Location = (3685, 2410)
[SPS] Finished in 344 ms. Location = (3690, 2410)
[SPS] Finished in 343 ms. Location = (3685, 2415)
[SPS] Finished in 344 ms. Location = (3690, 2415)
[SPS] Finished in 343 ms. Location = (3685, 2420)
[SPS] Finished in 359 ms. Location = (3690, 2420)
[SPS] Finished in 280 ms. Location = (3910, 2050)
[SPS] Finished in 405 ms. Location = (3935, 2090)
We made it!
Successfully executed.


Had no run energy left otherwise debug would be smaller

Zyt3x
02-12-2011, 11:38 AM
This is truly awesome marpis :)

I'm going to check this out today (now)

E: I guess this is converting SMS coords to reflection tiles?
// THIS DOESN'T WORK WELL
function SPS_GlobalToTile(x, y: integer): TPoint;
begin
Result.x := Round(2018.75 + x/4);
Result.y := Round(3933.75 - y/4);
end;
How good does it work? I know it says "THIS DOESN'T WORK WELL", but that means it's not a 100% failure either

E2: Could you please post source, or more specifically how you're getting Reflection Tiles from the coordinates on the worldmap.bmp? :)

marpis
02-12-2011, 04:56 PM
The map doesn't show from verock east bank to the wilderness, is this done on purpose or did something happen to me that stuffed the bmp?

Suggestion: It would be epic if the world map was cut into grid and labelled what grid was number.

Oh, and btw, this is awesome as it is and i cant wait to test it!

Check out '11_2' and '11_3' :)
And I did left most of wilderness out on purpose.

smidqe, thanks a lot for testing! :) Nice to see someone got it working. Not that I had any doubts though, it works for me, why wouldn't it work for others too.

The GlobalToTile there doesn't work at all, but that's about how it should look, just with different base coords.

Also fixed the folder address, stoopeed me. :bart:

NCDS
02-12-2011, 07:27 PM
Awesome marpis :)

I was really looking forward to you finishing this, congratulations!

Now I'll have to test it out with a few paths.

I haven't really checked anything out yet, but do you think it would be possible to write an algorithm to convert reflection tiles to the color 'tiles' this uses, and the other way around? (MSI related ;))


@RM: This will be added to MSI once it is more thoroughly tested and proven to be stable. Has already been discussed ;)

LolL
02-12-2011, 07:52 PM
I tried the test script. The first thing I noticed is that you don't HAVE to start in the bank but can start anywhere along the path -- awesome. However, after a few walks this happens:


Compiled succesfully in 1437 ms.
OpenFile - Exception. Could not open file: E:\Program Files\Simba\Includes\SRL/logs/SRL log 12-02-11 1.txt
SRL Compiled in 32 msec
[SPS] Maps loaded in 500ms.
[SPS] Finished in 1141 ms. Location = (4640, 1420)
[SPS] Finished in 1484 ms. Location = (4685, 1390)
[SPS] Finished in 1516 ms. Location = (4735, 1390)
[ERROR] Exception: Access violation
[SPS] Something is wrong!
[ERROR] Exception: Access violation
[SPS] Something is wrong!

and the exception keeps repeating and repeating.
I think it has something to do with not being lag-proof because it happened every time I lagged and the screen froze (btw, I lagged right when the player was approaching the walk flag so then SPS begins searching for the next place to click and it's a bit intensive).

However, when the small bugs are resolved, this will be perhaps one of the greatest SRL capabilities thus far.

marpis
02-12-2011, 08:00 PM
Awesome marpis :)

I was really looking forward to you finishing this, congratulations!

Now I'll have to test it out with a few paths.

I haven't really checked anything out yet, but do you think it would be possible to write an algorithm to convert reflection tiles to the color 'tiles' this uses, and the other way around? (MSI related ;))


@RM: This will be added to MSI once it is more thoroughly tested and proven to be stable. Has already been discussed ;)

Yea it's very simple really, I'm just kinda lazy now :p
It'll be something like

function PosToTile(P: TPoint): TTile;
begin
Result.x := 3213 + P.x/4;
Result.y := 1231 - P.y/4;
end;
Just got to calculate the "3213" and "1231" numbers.
It's easy too. I'll get it tomorrow maybe.


I tried the test script. The first thing I noticed is that you don't HAVE to start in the bank but can start anywhere along the path -- awesome. However, after a few walks this happens:


Compiled succesfully in 1437 ms.
OpenFile - Exception. Could not open file: E:\Program Files\Simba\Includes\SRL/logs/SRL log 12-02-11 1.txt
SRL Compiled in 32 msec
[SPS] Maps loaded in 500ms.
[SPS] Finished in 1141 ms. Location = (4640, 1420)
[SPS] Finished in 1484 ms. Location = (4685, 1390)
[SPS] Finished in 1516 ms. Location = (4735, 1390)
[ERROR] Exception: Access violation
[SPS] Something is wrong!
[ERROR] Exception: Access violation
[SPS] Something is wrong!

and the exception keeps repeating and repeating.
I think it has something to do with not being lag-proof because it happened every time I lagged and the screen froze (btw, I lagged right when the player was approaching the walk flag so then SPS begins searching for the next place to click and it's a bit intensive).

However, when the small bugs are resolved, this will be perhaps one of the greatest SRL capabilities thus far.

Yea, it will walk as long as the path is visible :) I said start at the bank so it walks a little longer route, to see that it really works.
And there's not much that can be done for whitescreening. I believe whitescreening also messes up every other SRL script?

BTW: walking from Lumby to draynor through the monotonic forest with HELLALOTTA people, npcs and drops. Perfectly accurate still.

NCDS
02-12-2011, 08:06 PM
Yea it's very simple really, I'm just kinda lazy now :p
It'll be something like

function PosToTile(P: TPoint): TTile;
begin
Result.x := 3213 + P.x/4;
Result.y := 1231 - P.y/4;
end;
Just got to calculate the "3213" and "1231" numbers.
It's easy too. I'll get it tomorrow maybe.

Yeah I figured it would be fairly simple, I just hadn't seen any of your code yet so I wasn't sure how you went about everything. Glad it will work as I had hoped though. :)

KingKong
02-12-2011, 11:39 PM
This is the error it gives me when i try to use reflection and color walking:
Duplicate identifier 'WALKPATH' at line 198

It clashes with the walkpath in the reflection MMwalk include, which means this can't be used with reflection :(

LolL
02-13-2011, 12:29 AM
And there's not much that can be done for whitescreening. I believe whitescreening also messes up every other SRL script?
I was talking about a small part of the minimap turning black. "Whitescreening" (?) never happens to me if it's what I think it means.

Edit: I tried it again and it worked without flaw there and back this time...

Coh3n
02-13-2011, 01:55 AM
This is the error it gives me when i try to use reflection and color walking:
Duplicate identifier 'WALKPATH' at line 198

It clashes with the walkpath in the reflection MMwalk include, which means this can't be used with reflection :(
That's because there's also a WalkPath procedure in reflection. Rename one of them and you'll be fine.

@marpis: I haven't looked through the .dll so I don't know exactly what functions we could use, but it would be nice if there was one that would return the minimap coord from the big map coord. Just like TileToMM, but it would be like CoordToMM or something. Sorry if there's already one. :p

KingKong
02-13-2011, 02:48 AM
That's because there's also a WalkPath procedure in reflection. Rename one of them and you'll be fine.

Yes, I know renaming would solve the problem, i was just pointing out the problem. Oh and its a good idea to change the walkpath in the sps.simba instead of reflection, because if the reflections proc is renamed, all the antirandom files have to be changed.

Coh3n
02-13-2011, 02:56 AM
Yes, I know renaming would solve the problem, i was just pointing out the problem. Oh and its a good idea to change the walkpath in the sps.simba instead of reflection, because if the reflections proc is renamed, all the antirandom files have to be changed.
SPS_WalkPath? :)

Marpis, I got it to work and it worked great. :) Couple suggestions (+ my one above):

Have the option to turn the debugging off. When the flag went off the minimap, the spammed the debug (didn't mess up, just spammed "finished..."). I'm impressed at how well it worked when the flag went off the screen.
Maybe have it click the next point as soon as it's found on the minimap, rather than waiting for the player to stop moving.

Again, great job!

E: Oh, and you need to extract to SRL/SRL, not SRL/SRL/core. Once it put it with the core/misc/skill folders it worked perfectly.

E: I also think Sumilion's path maker could me used to get these paths. We just need to get the right offsets. I'll contact some people and see what I can do.

TomTuff
02-13-2011, 03:38 AM
Looks awesome. I want to use it in my script I'm working on right now, but unfortunately part of the area is underground (i.e. in a dungeon). Perhaps you could inform me how to get it working underground?

Opal Tasty
02-13-2011, 05:41 AM
This is amazing. I'm currently using it to move my army from Fally to Port Sarim. I'll let you know how it goes.

E:About halfway done (15ish players so far) and they have all worked perfectly!

Think of all the possibilities of retrieving lost players :spot:

Coh3n
02-13-2011, 06:14 AM
Looks awesome. I want to use it in my script I'm working on right now, but unfortunately part of the area is underground (i.e. in a dungeon). Perhaps you could inform me how to get it working underground?
I think he mentioned it, so I think it's in the future plans.

kingarabian
02-13-2011, 07:26 AM
This looks awesome, but why no Wilderness? I would love to make a walker from my death respawn point to edgville... It's part of the Runescape map right.

Coh3n
02-13-2011, 08:34 AM
This looks awesome, but why no Wilderness? I would love to make a walker from my death respawn point to edgville... It's part of the Runescape map right.
May have something to do with the wilderness ditch (if that still exists), but I'm not sure.

marpis
02-13-2011, 10:18 AM
This is the error it gives me when i try to use reflection and color walking:
Duplicate identifier 'WALKPATH' at line 198

It clashes with the walkpath in the reflection MMwalk include, which means this can't be used with reflection :(
Yeah... I think renaming reflection one to R_WalkPath makes more sense but I guess I'll have to rename this one to SPS_WalkPath.



@marpis: I haven't looked through the .dll so I don't know exactly what functions we could use, but it would be nice if there was one that would return the minimap coord from the big map coord. Just like TileToMM, but it would be like CoordToMM or something. Sorry if there's already one. :p
PosToMM() :TPoint in SPS.simba


SPS_WalkPath? :)

Marpis, I got it to work and it worked great. :) Couple suggestions (+ my one above):

Have the option to turn the debugging off. When the flag went off the minimap, the spammed the debug (didn't mess up, just spammed "finished..."). I'm impressed at how well it worked when the flag went off the screen.
Maybe have it click the next point as soon as it's found on the minimap, rather than waiting for the player to stop moving.


It uses Flag(10), and does click (for me at least) before a full stop. Slow computer perhaps? And yea, I'll make debugging boolean constant.



E: Oh, and you need to extract to SRL/SRL, not SRL/SRL/core. Once it put it with the core/misc/skill folders it worked perfectly.

You need to extract it to SRL/SRL/core now, I fixed this.
Bolding this so that if someone reads this they don't get confused.


Looks awesome. I want to use it in my script I'm working on right now, but unfortunately part of the area is underground (i.e. in a dungeon). Perhaps you could inform me how to get it working underground?
What dungeon? I'll add some of them in the future.



And I didn't think people would bot in wildy nowadays, so I left it out to cut down the bitmap count.

Iamadam
02-13-2011, 10:21 AM
This is one of the cooler things I have seen over the last 5 years in the RS cheating community.

Edit: Couldn't we use this at any minimap angle? Just have simba detect the angle and then rotate the minimap bitmap accordingly. Just a thought.

TomTuff
02-13-2011, 10:32 AM
What dungeon? I'll add some of them in the future.

The Edgeville dungeon, both the wilderness and non-wilderness areas.

Echo_
02-13-2011, 02:23 PM
This is sick, I'm going to go test it out now :)

Coh3n
02-13-2011, 08:06 PM
Yeah... I think renaming reflection one to R_WalkPath makes more sense but I guess I'll have to rename this one to SPS_WalkPath.
IMO, they both should be changed so there's no confusion.



PosToMM() :TPoint in SPS.simba
Fantastic! I didn't even know there was an SPS.simba, did that get added to /core/ when the plugin was moved? I honestly don't remember downloaded it. :o



It uses Flag(10), and does click (for me at least) before a full stop. Slow computer perhaps? And yea, I'll make debugging boolean constant.
It doesn't every time, but sometimes. I just thought since this is a tile-like walking, you could also use a similar function to MSI_WaitTile (which works really well; player never comes to a complete stop).

function MSI_WaitTile(Tile: TPoint): Boolean;
{$IFDEF REFLECTION}
var
t: Integer;
{$ENDIF}
begin
if (not LoggedIn) then
Exit;

{$IFDEF REFLECTION}
t := GetSystemTime + 15000; // Maximum wait time is 15 seconds
repeat
if (LeaveDangerZone) then
MSI_Debug('Left danger zone');

Result := TileOnMM(Tile);

MSI_FindRandoms(False);
MSI_AntiBan(RandomRange(200, 800), ANTI_BAN_CHANCE);
until(Result or (GetSystemTime > t));
{$ENDIF}
end;

But I guess that could just be made custom in scripts if necessary.



You need to extract it to SRL/SRL/core now, I fixed this.
Bolding this so that if someone reads this they don't get confused.

Thanks. :)



What dungeon? I'll add some of them in the future.
I'll suggest the Mining Guild also. E: And the Essence Mine. :)

Main
02-13-2011, 08:16 PM
for the win, will definitely test, does it work underground by any chance?

Coh3n
02-13-2011, 08:18 PM
for the win, will definitely test, does it work underground by any chance?
Not yet. Read the few posts above you. ;)

bbri06
02-13-2011, 08:26 PM
I feel like people have been talking about making this forever. It's nice that it is finally getting done :p

marpis
02-14-2011, 05:19 AM
IMO, they both should be changed so there's no confusion.


Fantastic! I didn't even know there was an SPS.simba, did that get added to /core/ when the plugin was moved? I honestly don't remember downloaded it. :o


It doesn't every time, but sometimes. I just thought since this is a tile-like walking, you could also use a similar function to MSI_WaitTile (which works really well; player never comes to a complete stop).

function MSI_WaitTile(Tile: TPoint): Boolean;
{$IFDEF REFLECTION}
var
t: Integer;
{$ENDIF}
begin
if (not LoggedIn) then
Exit;

{$IFDEF REFLECTION}
t := GetSystemTime + 15000; // Maximum wait time is 15 seconds
repeat
if (LeaveDangerZone) then
MSI_Debug('Left danger zone');

Result := TileOnMM(Tile);

MSI_FindRandoms(False);
MSI_AntiBan(RandomRange(200, 800), ANTI_BAN_CHANCE);
until(Result or (GetSystemTime > t));
{$ENDIF}
end;

But I guess that could just be made custom in scripts if necessary.


Thanks. :)


I'll suggest the Mining Guild also. E: And the Essence Mine. :)


I feel like people have been talking about making this forever. It's nice that it is finally getting done :p

The SPS.simba is in the .rar :)

I'm gonna have to take a look at MSI walking again, to see how the WaitTile should be implemented.

Coh3n
02-14-2011, 05:57 AM
The SPS.simba is in the .rar :)
Must have completely missed it. :p



I'm gonna have to take a look at MSI walking again, to see how the WaitTile should be implemented.
It would just be called after clicking the point. Just like the current WaitTile does, but if you want to see it, I think it's in MSI_ReflectionWalk and MSI_HybridWalk.

Iamadam
02-14-2011, 02:52 PM
http://villavu.com/forum/showthread.php?p=779467

An application to make pathmaking easier.

Edit: Marpis, is there any way to speed up the positioning algorithm? I'm finding that on long paths its taking upwards of 2000ms to get the next point. It would be great if it could search for the next point as it walked so it wasn't stop-start the whole time.

Edit (again):
I've noticed it takes a lot longer when more map pieces are loaded. I assume this is because it checks every piece to see if it contains the current minimap. Can I suggest that you make a function which accepts 'expected location,' and searches that map piece first? It would mean walking long paths was MUCH faster.

Edit (AGAIN...)
This might help:
X Pixel to X Tile: pixelX/4 + 2093.5
Y Pixel to Y Tile: 3776 - (pixelY / 4);

Coh3n
02-15-2011, 10:38 PM
Marpis, the RS map was updated today with a couple new mining locations for Clay. Does that mean a new map needs to be made (along with it's chunks)?

bigjosh0315
02-16-2011, 03:19 AM
I got this error when I ran the test script and when I tried to make my own.


[SPS] Something is wrong!
[ERROR] Exception: Access violation

I didn't lag or anything. It will usually work for a bit but won't finish the path. Any idea why?

marpis
02-16-2011, 08:38 AM
Marpis, the RS map was updated today with a couple new mining locations for Clay. Does that mean a new map needs to be made (along with it's chunks)?

Probably yea, but just for those parts that got updated, won't take long.
I'll probably get on it tonight.

Coh3n
02-16-2011, 07:46 PM
Probably yea, but just for those parts that got updated, won't take long.
I'll probably get on it tonight.
Awesome.

I'm going to use this in my personal MSI to test as I can't run MSI with reflection for more than a few hours. I'll let you know how it goes.

marpis
02-16-2011, 08:04 PM
Awesome.

I'm going to use this in my personal MSI to test as I can't run MSI with reflection for more than a few hours. I'll let you know how it goes.

Actually I think you can try without updating the map, It'll probably still work.

Coh3n
02-16-2011, 08:05 PM
Actually I think you can try without updating the map, It'll probably still work.
Oh I'm sure it will. I doubt the map size changed. There were just a couple symbols added at the new locations. I won't even be using those chuncks of the map anyway.

Zyt3x
02-16-2011, 08:39 PM
How is the updating process, marpis?

Coh3n
02-17-2011, 08:13 AM
So I basically worked all day on implementing this into MSI, and I think I've got it working. I'll be testing it over night and will make it available for anyone to test through MSI tomorrow. I'll write detailed instructions tomorrow for testing.

Also, I added this to SPS.simba (the Y offset is 2 lower than what was posted, I found that the resulting Y point was too large). Still may not be exact, but it's closer.

const
SPS_OFFSET_X = 2093.5;
SPS_OFFSET_Y = 3774.0;

function SPS_PixelToPoint(pixel: TPoint): TPoint;
begin
Result.X := Round(SPS_OFFSET_X + (pixel.X / 4));
Result.Y := Round(SPS_OFFSET_Y - (pixel.Y / 4));
end;

function SPS_PointToPixel(point: TPoint): TPoint;
begin
Result.X := Round((point.x - SPS_OFFSET_X) * 4);
Result.Y := Round((SPS_OFFSET_Y - point.y) * 4);
end;

Zyt3x
02-17-2011, 08:41 AM
function SPS_PointToPixel(point: TPoint): TPoint;
begin
Result.X := Round((point.x - SPS_OFFSET_X) * 4);
Result.Y := Round((SPS_OFFSET_Y - point.y) * 4);
end;
I just wanted to say that I couldn't get PointToPixel() to work like that.. I had to subtract some from both the X and the Y like this:
function SPS_TileToPixel(tileX, tileY : Integer): TPoint;
begin
Result.X := Round((tileX - 2093.5) * 4)-22;
Result.Y := Round((3774.0 - tileY) * 4)-17;
end;

Coh3n
02-17-2011, 08:44 AM
I just wanted to say that I couldn't get PointToPixel() to work like that.. I had to subtract some from both the X and the Y like this:
function SPS_TileToPixel(tileX, tileY : Integer): TPoint;
begin
Result.X := Round((tileX - 2093.5) * 4)-22;
Result.Y := Round((3774.0 - tileY) * 4)-17;
end;
Interesting. Mine worked for RM Yews path, but that doesn't mean it will work everywhere. I'd like to see how they were originally obtained.

marpis
02-17-2011, 09:15 AM
You get your tile and sps position, substract pixel.x/4 from tile.x and you get x offset which should theoretically be the tile.x on the very left border of the map.

then add pixel.y/4 to tile.y to get the theoretical tile.y in the very top border of the map.

Coh3n
02-17-2011, 10:50 AM
You get your tile and sps position, substract pixel.x/4 from tile.x and you get x offset which should theoretically be the tile.x on the very left border of the map.

then add pixel.y/4 to tile.y to get the theoretical tile.y in the very top border of the map.
Thanks. Also, any idea why this may happen? It was working great (did about 10 loads), then I stopped it to setup more players. When I tried running it again, this happened.

[0:00:10]: [ Empty Cohen ] ---- Player's SPS_Areas: ['8_5', '9_5']
[0:00:10]: [ Empty Cohen ] -- MSI_AtLocation
[0:00:10]: [ Empty Cohen ] ---- Checking Point: (3810, 2156)
[0:00:11]: [SPS] Maps loaded in 688ms.
[0:00:12]: [SPS] Finished in 594 ms. Location = (3815, 2160)
[0:00:12]: [ Empty Cohen ] ------ MSI_PointOnMM(3810, 2156): True
[0:00:12]: [ Empty Cohen ] ---- Distance from player to Port Sarim Deposit Box: 6
[0:00:12]: [ Empty Cohen ] ---- Player is at Port Sarim Deposit Box
[0:00:12]: [ Empty Cohen ] -- MSI_AtLocation: True
[0:00:12]: [ Empty Cohen ] -- MSI_AtLocation
[0:00:12]: [ Empty Cohen ] ---- Checking Point: (3810, 2156)
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ Empty Cohen ] ------ MSI_PointOnMM(3810, 2156): False
[0:00:12]: [ Empty Cohen ] ---- Player not at Port Sarim Deposit Box
[0:00:12]: [ Empty Cohen ] -- MSI_AtLocation: False
[0:00:12]: [ Empty Cohen ] -- MSI_Walk
[0:00:12]: [ Empty Cohen ] ------ MSI_WaitWhileResting
[0:00:12]: [ Empty Cohen ] ---- Player's Location = Port Sarim Deposit Box
[0:00:12]: [ Empty Cohen ] ---- MSI_AtLocation
[0:00:12]: [ Empty Cohen ] ------ Checking Point: (3374, 2172)
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ Empty Cohen ] -------- MSI_PointOnMM(3374, 2172): False
[0:00:12]: [ Empty Cohen ] ------ Checking Point: (3366, 2184)
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ Empty Cohen ] -------- MSI_PointOnMM(3366, 2184): False
[0:00:12]: [ Empty Cohen ] ------ Player not at Rimmington Yews
[0:00:12]: [ Empty Cohen ] ---- MSI_AtLocation: False
[0:00:12]: [ Empty Cohen ] ------ Scanning for randoms...
[0:00:12]: [ Empty Cohen ] ---- MSI_WalkPath
[0:00:12]: [ Empty Cohen ] -------- Loaded Path (Color): [[(3814, 2160), (3770, 2164), (3734, 2188), (3714, 2228), (3658, 2232), (3602, 2224), (3558, 2220), (3510, 2208), (3458, 2204), (3414, 2192), (3374, 2184)]]
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation

Then it repeats. I don't remember changing anything, and it's weird because it works the first time, but then not again after that. :unsure: If it matters, SPS_Areas isn't reset anywhere in between the first and second call of MSI_AtLocation. When I took out the try..except statement in SPS_GatherBitmap, it highlighted this line:

Result := SPS_BitmapToMap(realbitmap);

Any ideas?

marpis
02-17-2011, 06:32 PM
Thanks. Also, any idea why this may happen? It was working great (did about 10 loads), then I stopped it to setup more players. When I tried running it again, this happened.

[0:00:10]: [ Empty Cohen ] ---- Player's SPS_Areas: ['8_5', '9_5']
[0:00:10]: [ Empty Cohen ] -- MSI_AtLocation
[0:00:10]: [ Empty Cohen ] ---- Checking Point: (3810, 2156)
[0:00:11]: [SPS] Maps loaded in 688ms.
[0:00:12]: [SPS] Finished in 594 ms. Location = (3815, 2160)
[0:00:12]: [ Empty Cohen ] ------ MSI_PointOnMM(3810, 2156): True
[0:00:12]: [ Empty Cohen ] ---- Distance from player to Port Sarim Deposit Box: 6
[0:00:12]: [ Empty Cohen ] ---- Player is at Port Sarim Deposit Box
[0:00:12]: [ Empty Cohen ] -- MSI_AtLocation: True
[0:00:12]: [ Empty Cohen ] -- MSI_AtLocation
[0:00:12]: [ Empty Cohen ] ---- Checking Point: (3810, 2156)
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ Empty Cohen ] ------ MSI_PointOnMM(3810, 2156): False
[0:00:12]: [ Empty Cohen ] ---- Player not at Port Sarim Deposit Box
[0:00:12]: [ Empty Cohen ] -- MSI_AtLocation: False
[0:00:12]: [ Empty Cohen ] -- MSI_Walk
[0:00:12]: [ Empty Cohen ] ------ MSI_WaitWhileResting
[0:00:12]: [ Empty Cohen ] ---- Player's Location = Port Sarim Deposit Box
[0:00:12]: [ Empty Cohen ] ---- MSI_AtLocation
[0:00:12]: [ Empty Cohen ] ------ Checking Point: (3374, 2172)
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ Empty Cohen ] -------- MSI_PointOnMM(3374, 2172): False
[0:00:12]: [ Empty Cohen ] ------ Checking Point: (3366, 2184)
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ Empty Cohen ] -------- MSI_PointOnMM(3366, 2184): False
[0:00:12]: [ Empty Cohen ] ------ Player not at Rimmington Yews
[0:00:12]: [ Empty Cohen ] ---- MSI_AtLocation: False
[0:00:12]: [ Empty Cohen ] ------ Scanning for randoms...
[0:00:12]: [ Empty Cohen ] ---- MSI_WalkPath
[0:00:12]: [ Empty Cohen ] -------- Loaded Path (Color): [[(3814, 2160), (3770, 2164), (3734, 2188), (3714, 2228), (3658, 2232), (3602, 2224), (3558, 2220), (3510, 2208), (3458, 2204), (3414, 2192), (3374, 2184)]]
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation
[0:00:12]: [SPS] Something is wrong!
[0:00:12]: [ERROR] Exception: Access violation

Then it repeats. I don't remember changing anything, and it's weird because it works the first time, but then not again after that. :unsure: If it matters, SPS_Areas isn't reset anywhere in between the first and second call of MSI_AtLocation. When I took out the try..except statement in SPS_GatherBitmap, it highlighted this line:

Result := SPS_BitmapToMap(realbitmap);

Any ideas?

Hmm, I just ran my character from VEB to VEM 40 times repeatedly successfully without problems...
Weird...

And by the way, because of SPS_GetMyPos taking around 500ms I don't think it's efficient to use the WaitTile function, although you can try.
To me it seems like it's pretty ready to be added to SRL, just gotta add SPS_DEBUG: boolean constant. :)

Any regulary appearing bugs?
Any suggestions?

Coh3n
02-17-2011, 07:06 PM
Hmm, I just ran my character from VEB to VEM 40 times repeatedly successfully without problems...
Weird...
I'll keep trying some things, see if I can figure it out.



And by the way, because of SPS_GetMyPos taking around 500ms I don't think it's efficient to use the WaitTile function, although you can try.
To me it seems like it's pretty ready to be added to SRL, just gotta add SPS_DEBUG: boolean constant. :)
Yeah I forgot to mention that. I did try it, and didn't work out so well. :p It was worth a shot.



Any regulary appearing bugs?
Any suggestions?
Maybe instead of having just the DEBUG constant, have a var array for other settings as well, such as flag distance? Oh, and I'm sure you've done this but just a reminder to add the tile/point conversion functions, and name WalkPath, SPS_WalkPath to avoid duplicate identifiers.

Coh3n
02-17-2011, 07:36 PM
Alright well I can't for the life of me figure it out. I would really appreciate if someone tested this out with MSI. My version can be downloaded from here (https://github.com/Coh3n/MSI/archives/dabf3f8672797e1cc340db84e9d63eccbcc1c720), and I've attached my version of SPS.simba (has tile conversion functions). I will love you forever if you test. :D

E: Also, could someone post the script they've used to test this? I want to try it out and see if it's something I've done wrong.

E2: It's gotta be the setup in MSI. I just ran SPSTest.simba using the tile conversions and not using the tile conversions and they both worked fine.

marpis
02-17-2011, 07:53 PM
I'll keep trying some things, see if I can figure it out.


Yeah I forgot to mention that. I did try it, and didn't work out so well. :p It was worth a shot.


Maybe instead of having just the DEBUG constant, have a var array for other settings as well, such as flag distance? Oh, and I'm sure you've done this but just a reminder to add the tile/point conversion functions, and name WalkPath, SPS_WalkPath to avoid duplicate identifiers.

Remember that this is SRL Positioning System, not marpis positioning system :)
I only have a couple nights max a week to actually do anything for SRL, so you have just as much the right to change things in SPS as I do. Just do your stuff and post them here and I'll eventually update them to the .rar before this is in SRL.

Coh3n
02-17-2011, 07:57 PM
Remember that this is SRL Positioning System, not marpis positioning system :)
I only have a couple nights max a week to actually do anything for SRL, so you have just as much the right to change things in SPS as I do. Just do your stuff and post them here and I'll eventually update them to the .rar before this is in SRL.
Alright. Well my SPS.simba is attached in the post above. That was all I changed, and it's working fine outside MSI. I'll eventually figure it out (I hope). It was working PERFECTLY and I was so happy, then it just started failing. I wish I knew what I changed.

marpis
02-17-2011, 08:20 PM
Added SPS_17th_Feb.rar here: http://marpis.comxa.com/
It contains Tile conversion functions.

Note: You don't have to extract the whole folder when you only need the SPS.simba.

Coh3n
02-17-2011, 08:32 PM
I don't see how this made MSI work, but I updated my plugins and it's working. Marpis, if you think it's a good idea, I can add a SetupVars array later (like I mentioned above).

Iamadam
02-18-2011, 01:10 AM
Remember that this is SRL Positioning System, not marpis positioning system :)
I only have a couple nights max a week to actually do anything for SRL, so you have just as much the right to change things in SPS as I do. Just do your stuff and post them here and I'll eventually update them to the .rar before this is in SRL.

Plugin source? :)

Coh3n
02-18-2011, 07:43 AM
Seems to be working well for me right now; although I have gotten a couple code:8 (out of memory) errors after running for a couple hours. In MSI, I had it reload SPS/reset SPS_Areas after it switches players so if there were several players, all using different scripts, a dozen map pieces wouldn't be loaded. This causes LoadSPS to be called each time it switches players. I looked at LoadSPS, and I may be wrong, but are muf and realbitmap supposed to be freed as well as bmp?

procedure LoadSPS;
var
L, i, bmp, t : integer;
muf: TMufasaBitmap;
realbitmap: TBitmap;
begin
t := getsystemtime;
L := Length(SPS_Areas);
SetLength(SPS_Worldmap, L);
//Writeln('[SPS] Building maps... Estimated time: '+ToStr(5600*L)+' ms.');
for i := 0 to L - 1 do
begin
bmp := LoadBitmap(SPS_PATH + SPS_Areas[i] +'.bmp');
muf := GetMufasaBitmap(bmp);
realbitmap := muf.ToTBitmap;
SPS_Worldmap[i] := SPS_BitmapToMap(realbitmap);
end;
t := getsystemtime - t;
Writeln('[SPS] Maps loaded in '+ToStr(t)+'ms.');
SPS_Loaded := True;
FreeBitmap(bmp);
end;


E: I've also been watching my CPU usage, and it seems it increases quite a bit when SPS_GetMyPos is called. Does this happen for anyone else?

marpis
02-18-2011, 03:06 PM
I believe the bitmap is there only once. realbitmap, bmp and muf are just different paths to it. so when i call freebitmap(bmp) i think its totally freed?

TomTuff
02-18-2011, 03:19 PM
I believe the bitmap is there only once. realbitmap, bmp and muf are just different paths to it. so when i call freebitmap(bmp) i think its totally freed?

Well, if you're not sure, you could use the bitmap naming functions that Wizzup? mentioned recently.

Coh3n
02-18-2011, 04:55 PM
I believe the bitmap is there only once. realbitmap, bmp and muf are just different paths to it. so when i call freebitmap(bmp) i think its totally freed?
If that's true then there's a huge leak somewhere in MSI. I have no idea where it could possibly be, but it's definitely a problem. =\

Last night I called muf.free and realbitmap.free at the end of the procedure, and everything seemed to be fine (IOW the bitmaps still existed). Also, in SPS_GatherBitmap, you free muf and realbitmap, so it may not hurt to do the same in LoadSPS just to be sure.

In case anyone's wondering about the leak in MSI: http://villavu.com/forum/showthread.php?p=780779#post780779

E: Oh also, to be sure, you could run the VE path 40 or whatever times and watch the CPU usage while it runs to see if it increases at all. Just a suggestion. :)

Nava2
02-18-2011, 05:39 PM
function TMufasaBitmap.ToTBitmap: TBitmap;

var
tr:TRawImage;

begin
Result := TBitmap.Create;
ArrDataToRawImage(Self.Fdata, point(self.width,self.height), tr);
Result.LoadFromRawImage(tr, false);
end;

It looks like you need to free the TBitmap for sure..

I didn't look all that much to see about the other.

E: Also, it looks like Simba does NOT manage TBitmaps, so there needs to be a procedure added into the OnTerminate array to free all the map components. This could be where the memory issues are stemming from. You never actually free the array from what I can see.

Coh3n
02-19-2011, 06:24 PM
E: Also, it looks like Simba does NOT manage TBitmaps, so there needs to be a procedure added into the OnTerminate array to free all the map components. This could be where the memory issues are stemming from. You never actually free the array from what I can see.
But Simba automatically frees bitmaps that weren't freed, wouldn't adding them to the OnTerminate not make much of a difference because they're still in memory during runtime?

Nava2
02-19-2011, 09:50 PM
But Simba automatically frees bitmaps that weren't freed, wouldn't adding them to the OnTerminate not make much of a difference because they're still in memory during runtime?

You didn't read what I said, bud.

Simba does not manage TBitmaps. Since they are used, you need to make sure they stay in memory till they are done with. But when you end the script, you lose reference to the TBitmaps and they are not freed. This means that you are getting a massive increase in memory usage each time you restart the script. Hell, I'm not even sure if windows will clean up the memory leak when you close simba!

Also, when you load new ones, I do not think this accounts for that and just overwrites the memory spaces (under the assumption that Simba will play clean-up).

This is a relatively simple fix, but I think it may actually be the cause of some of the code 8 issues that started after SPS started being used.

Coh3n
02-19-2011, 10:01 PM
You didn't read what I said, bud.

Simba does not manage TBitmaps. Since they are used, you need to make sure they stay in memory till they are done with. But when you end the script, you lose reference to the TBitmaps and they are not freed. This means that you are getting a massive increase in memory usage each time you restart the script. Hell, I'm not even sure if windows will clean up the memory leak when you close simba!

Also, when you load new ones, I do not think this accounts for that and just overwrites the memory spaces (under the assumption that Simba will play clean-up).

This is a relatively simple fix, but I think it may actually be the cause of some of the code 8 issues that started after SPS started being used.
Oh, my bad. I'll assume, then, that SPS_Worldmap: T4DIntegerArray; is what needs to be freed at the end of the script.

I also fixed a compiling issue + freed muf and realbitmap in LoadSPS. The CPU still steadily increases, but not nearly as much.

I was also thinking about whether it would be better to load/free SPS each time it walks, rather than load all the bitmaps on startup, then freeing them in the end. I mean, potentially script's could have several bitmaps loaded, and not all of them would be used at one time, so we wouldn't want to be searching through them all anyway. So I thought about something like this:

procedure SPS_Load(Areas: TStringArray);
begin
// Would be the same as it is now, except take the parameter in to consideration
end;

procedure SPS_Free();
var
i, j, k, l: Integer;
begin
SPS_Areas := [];

// Not sure if this would be the right way to do it :p
for i := 0 to High(SPS_WorldMap) do
for j := 0 to High(SPS_WorldMap[i]) do
for k := 0 to High(SPS_WorldMap[i][j]) do
for l := 0 to High(SPS_WorldMap[i][j][k]) do
FreeBitmap(SPS_WorldMap[i][j][k][l]);
end;

Not sure how much of a difference in speed that would make, but all the SPS_Areas wouldn't be loaded the whole time.

Nava2
02-19-2011, 10:04 PM
Rather than FreeBitmap, you would need to do Area.Free. This is because TBitmaps are Classes and are not managed by Simba through the FreeBitmap method.

Coh3n
02-19-2011, 10:09 PM
Rather than FreeBitmap, you would need to do Area.Free. This is because TBitmaps are Classes and are not managed by Simba through the FreeBitmap method.
SPS_MiniMap is declared as a T4DIntegerArray though, not TBitmaps.

marpis
02-20-2011, 10:35 AM
Oh, my bad. I'll assume, then, that SPS_Worldmap: T4DIntegerArray; is what needs to be freed at the end of the script.

I also fixed a compiling issue + freed muf and realbitmap in LoadSPS. The CPU still steadily increases, but not nearly as much.

I was also thinking about whether it would be better to load/free SPS each time it walks, rather than load all the bitmaps on startup, then freeing them in the end. I mean, potentially script's could have several bitmaps loaded, and not all of them would be used at one time, so we wouldn't want to be searching through them all anyway. So I thought about something like this:

procedure SPS_Load(Areas: TStringArray);
begin
// Would be the same as it is now, except take the parameter in to consideration
end;

procedure SPS_Free();
var
i, j, k, l: Integer;
begin
SPS_Areas := [];

// Not sure if this would be the right way to do it :p
for i := 0 to High(SPS_WorldMap) do
for j := 0 to High(SPS_WorldMap[i]) do
for k := 0 to High(SPS_WorldMap[i][j]) do
for l := 0 to High(SPS_WorldMap[i][j][k]) do
FreeBitmap(SPS_WorldMap[i][j][k][l]);
end;

Not sure how much of a difference in speed that would make, but all the SPS_Areas wouldn't be loaded the whole time.
But those are not bitmaps, they are regular integers representing R, G, and B values of 5x5 squares. Check out SPS_BitmapToMap.

I'm very bad at things like these, memory management etc. I have no idea how the bitmaps should be freed.
All I know is that once the SPS_Worldmap is built, you can free all bitmaps that have something to do with the worldmap.


SPS_WorldMap[area_index][x][y][0] = Red count
SPS_WorldMap[area_index][x][y][1] = Green count
SPS_WorldMap[area_index][x][y][2] = Blue count


every [x][y] is a 5x5 box. You can think of it as a pixel at (x, y) just with a very low resolution :)

Nava2
02-20-2011, 01:11 PM
But those are not bitmaps, they are regular integers representing R, G, and B values of 5x5 squares. Check out SPS_BitmapToMap.

I'm very bad at things like these, memory management etc. I have no idea how the bitmaps should be freed.
All I know is that once the SPS_Worldmap is built, you can free all bitmaps that have something to do with the worldmap.


SPS_WorldMap[area_index][x][y][0] = Red count
SPS_WorldMap[area_index][x][y][1] = Green count
SPS_WorldMap[area_index][x][y][2] = Blue count


every [x][y] is a 5x5 box. You can think of it as a pixel at (x, y) just with a very low resolution :)

That being said then, the TBitmaps can all be freed when we start loading the map? That might save a lot of space..

Also, the array should probably be erased when a new one is created. I could see a T4DInteger array creating a large amount of memory!

Thanks for the clarification. :)

marpis
02-20-2011, 01:36 PM
That being said then, the TBitmaps can all be freed when we start loading the map? That might save a lot of space..

Also, the array should probably be erased when a new one is created. I could see a T4DInteger array creating a large amount of memory!

Thanks for the clarification. :)

Yea, maybe a
SPS_Worldmap := [];
would help, I don't know.


LoadSPS;
begin
LOAD BITMAPS
BUILD WorldMap
FREE BITMAPS
end;

SPS_GatherMinimap;
begin
CLIENT TO BITMAP
BUILD T4DIntegerArray Minimap
FREE BITMAP
end;


No bitmaps need to be kept in memory outside those functions.

Nava2
02-20-2011, 01:47 PM
Well, we can easily free the TBitmaps, thats a non-issue.

My question is, why do you use TBitmaps rather than TMufasaBitmaps? If I recall, TMufasaBitmaps mirror the functions associated with TBitmaps then add some.

marpis
02-20-2011, 01:56 PM
Well, we can easily free the TBitmaps, thats a non-issue.

My question is, why do you use TBitmaps rather than TMufasaBitmaps? If I recall, TMufasaBitmaps mirror the functions associated with TBitmaps then add some.

I pass TBitmaps to my plugin, where they are then processed into 3D Integer arrays containing info of their RGB values. I don't know how else I could do that.

But ok, some smart guy figure out how we should free the bitmaps and this should be ready for heavy testing. :)

Nava2
02-20-2011, 02:05 PM
I pass TBitmaps to my plugin, where they are then processed into 3D Integer arrays containing info of their RGB values. I don't know how else I could do that.

But ok, some smart guy figure out how we should free the bitmaps and this should be ready for heavy testing. :)

Sorry, my comment came off more arrogant than I intended.

Anyway, what do you do in the plugin? I do not have the source here, but if you are using ScanLines or something similar, you can do that using TMufasaBitmaps and then Simba would manage the memory. That last part is the big one. Just in case we mess something up.

All the TBitmap issue needs is a TBitmap.free(); in that loop where we load everything.

marpis
02-20-2011, 02:08 PM
Sorry, my comment came off more arrogant than I intended.

Anyway, what do you do in the plugin? I do not have the source here, but if you are using ScanLines or something similar, you can do that using TMufasaBitmaps and then Simba would manage the memory. That last part is the big one. Just in case we mess something up.

All the TBitmap issue needs is a TBitmap.free(); in that loop where we load everything.

I didn't think you were being arrogant at all :p
Anyhoo, all the functions in the plugin are found commented in SPS.simba.
I'm using GetPixel, not scaline. I think it's easiest to do it as it is now:



Create TBitmap in Simba
-> Pass it to .dll
<- get the wanted calculations from .dll
Free TBitmap in Simba


The only problem we have now is that I don't know what all things need to be freed and in which order ^^

Coh3n
02-20-2011, 04:11 PM
Thanks for the clarification, marpis. I'm pretty dure the version I posted earlier on the page has all the bitmaps freed. Someone may want to double check though. Also, if we were to have LoadSPS take a parameter, SPS_WorldMap wouldn't need to be reset, as it would automatically be reset when LoadSPS is called again, correct?

marpis
02-20-2011, 04:29 PM
Thanks for the clarification, marpis. I'm pretty dure the version I posted earlier on the page has all the bitmaps freed. Someone may want to double check though. Also, if we were to have LoadSPS take a parameter, SPS_WorldMap wouldn't need to be reset, as it would automatically be reset when LoadSPS is called again, correct?

I don't quite understand? SPS_WorldMap currently remade everytime you call LoadSPS, for example if you want to change areas during runtime.

Coh3n
02-20-2011, 05:27 PM
Yeah I know. You guys said something about SPS_WorldMap := [], and I didn't think you'd need to do that. So if I want to reset the areas during runtime I could just reset SPS_Areas and set SPSLoaded to false, right?

marpis
02-20-2011, 05:48 PM
Yeah I know. You guys said something about SPS_WorldMap := [], and I didn't think you'd need to do that. So if I want to reset the areas during runtime I could just reset SPS_Areas and set SPSLoaded to false, right?

Yup

Daniel
02-21-2011, 05:57 AM
I'm using GetPixel, not scaline.

The GetPixel function is very slow! If you need high (or even acceptable) performance, you should use the ScanLine property.

And implementing it isn't all that hard either.

EDIT:
Here's something I made like 2 years ago you could place inside your DLL so you can keep it simple like GetPixel:

//Returns the colour found at X and Y in bitmap MSC
function GetColour(x, y: Integer; MSC: TBitmap): Integer;
type
PxArr = array[0..2] of Byte;
var
PX: ^PxArr;
W, H: Integer;
begin
if((y <= MSC.Height - 1) and (X <= MSC.Width - 1)) then
begin
PX := MSC.ScanLine[y];
Inc(PX, X);
Result := PX^[2] or PX^[1] shl 8 or PX^[0] shl 16;
end;
end;

marpis
02-21-2011, 06:21 AM
The GetPixel function is very slow! If you need high (or even acceptable) performance, you should use the ScanLine property.

And implementing it isn't all that hard either.

EDIT:
Here's something I made like 2 years ago you could place inside your DLL so you can keep it simple like GetPixel:

//Returns the colour found at X and Y in bitmap MSC
function GetColour(x, y: Integer; MSC: TBitmap): Integer;
type
PxArr = array[0..2] of Byte;
var
PX: ^PxArr;
W, H: Integer;
begin
if((y <= MSC.Height - 1) and (X <= MSC.Width - 1)) then
begin
PX := MSC.ScanLine[y];
Inc(PX, X);
Result := PX^[2] or PX^[1] shl 8 or PX^[0] shl 16;
end;
end;

I'm using Lazarus, how do I get that to work?

Iamadam
02-21-2011, 06:37 AM
Marpis, where is FindMapInMapEx? In the plugin?
Just thinking it would be great if you could specify a map piece to search first when finding your location - that way you wouldn't have to search every single loaded area if you had an idea of where your player should be.
This would reduce 2 second+ search times to ~300ms on paths that use a lot of areas. Really worth doing for pathwalking.

marpis
02-21-2011, 06:52 AM
Marpis, where is FindMapInMapEx? In the plugin?
Just thinking it would be great if you could specify a map piece to search first when finding your location - that way you wouldn't have to search every single loaded area if you had an idea of where your player should be.
This would reduce 2 second+ search times to ~300ms on paths that use a lot of areas. Really worth doing for pathwalking.

You can do

SPS_Areas := ['new areas here'];
SPS_Loaded := False;


:)

Daniel
02-21-2011, 07:10 AM
I'm using Lazarus, how do I get that to work?
In the unit in which you call GetPixel... Then replace all instances of GetPixel with GetColour...

Nava2
02-21-2011, 06:12 PM
So, I was bored..

I implemented this with TMufasaBitmaps and hopefully optimized some of the code. :)

I can't compile it unfortunately, and it requires you to have the bitmaps unit from the MML. Its located in: Units/MMLCore/bitmaps.pas.

Let me know if it works, and if it actually speeds things up!

For those wondering, I implemented the scanlines equivalent from MML. Just I access the data directly rather than by rows ;).

E: I think you can probably remove some of the units as well.. FileUtil is not used I don't think. I also commented everywhere I made changes. :)

Check out .zip in next post for more up-to-date source.

New SPS.simba:
//-----------------------------------------------------------------//
//-- SRL Resource Library --//
//-- Positioning routines --//
//-----------------------------------------------------------------//
// * SPS_GetMyPos: TPoint; by: marpis //
// * SPS_PosToMM(P: TPoint): TPoint; by: marpis //
// * SPS_WalkToPos(P: TPoint): boolean; by: marpis //
// * SPS_WalkPath(Path: TPointArray): boolean; by: marpis //
// * //
//-----------------------------------------------------------------//

{$LOADLIB SPS.dll} // Load SPS.dll plugin


const
// Path where all the SPS files are
SPS_PATH = AppPath + '/Includes/SRL/SRL/core/SPS/';
// RGB tolerance used, 0.2 = 20% etc.
SPS_TOLERANCE = 0.2;
// Offsets for Reflection conversion
SPS_OFFSET_X = 2093.5;
SPS_OFFSET_Y = 3774.0;

// SPS Global variables
var
SPS_Loaded: boolean;
SPS_Areas: TStringArray;
SPS_Worldmap: T4DIntegerArray;

function SPS_GatherMinimap: T3DIntegerArray;
var
bmp: TMufasaBitmap;
c: TClient;
begin
try
bmp := TMufasaBitmap.Create; // yeah its not as clean as before, but the performance gains should be worth it.
bmp.SetSize(100, 100);
c := getTClient;
bmp.CopyClientToBitmap(
c.IOManager, false, 0,0, MMCX-50, MMCY-50, MMCX+50, MMCY+50
);
Result := SPS_BitmapToMap(bmp);
finally
bmp.free; // just in case
except
Writeln('[ERROR] '+ExceptionToString(ExceptionType, ExceptionParam));
end;
end;


procedure SPS_GetAreaCoords(Area: string; var x, y: integer);
var
s: string;
i: integer;
begin
for i := 1 to length(Area) do
begin
if Area[i] = '_' then
begin
x := StrToInt(s);
y := StrToInt(Copy(Area, i + 1, length(Area)));
Exit;
end;
s := s + Area[i];
end;
end;

function SPS_LocalToGlobal(Area: string; x, y: integer): TPoint;
var
cx, cy: integer;
begin
SPS_GetAreaCoords(Area, cx, cy);
Result.x := cx*400 + x;
Result.y := cy*400 + y;
end;

// THIS DOESN'T WORK AT ALL YET (Feb 12th 2011)
function SPS_GlobalToTile(x, y: integer): TPoint;
begin
Result.x := Round(2018.75 + x/4);
Result.y := Round(3933.75 - y/4);
end;

procedure LoadSPS;
var
L, i, t : integer;
bmp: TMufasaBitmap;
begin
t := getsystemtime;
L := Length(SPS_Areas);
SetLength(SPS_Worldmap, L);
//Writeln('[SPS] Building maps... Estimated time: '+ToStr(5600*L)+' ms.');
for i := 0 to L - 1 do
begin
try
bmp := TMufasaBitmap.Create;
bmp.LoadFromFile(SPS_PATH + SPS_Areas[i] +'.bmp');
SPS_Worldmap[i] := SPS_BitmapToMap(bmp);
finally
bmp.free; // just in case ;)
end;
end;
t := getsystemtime - t;
Writeln('[SPS] Maps loaded in '+ToStr(t)+'ms.');
SPS_Loaded := True;
end;


function SPS_GetMyPos: TPoint;
var
Minimap: T3DIntegerArray;
t, i, map: integer;
begin
if not LoggedIn then
Exit;

if not SPS_Loaded then
LoadSPS;

Result := Point(-1, -1);
MakeCompass('N');

t := getSystemTime;
Minimap := SPS_GatherMinimap;
try
map := SPS_FindMapInMapEx(
Result.X, Result.Y, SPS_Worldmap, Minimap, SPS_TOLERANCE
);
if ((Result.X > 0) and (Result.Y > 0)) then
begin
Result := SPS_LocalToGlobal(SPS_Areas[map], Result.X, Result.Y);
end;

t := getsystemtime - t;
writeln(
Format(
'[SPS] Finished in %dms. Location = %s',
[getSystemTime-t, ToStr(Result)]
)
);
except
Writeln('[SPS] ERROR' + ExceptionToString(ExceptionType, ExceptionParam));
end;
end;

function SPS_PixelToPoint(pixel: TPoint): TPoint;
begin
Result.X := Round(SPS_OFFSET_X + (pixel.X / 4));
Result.Y := Round(SPS_OFFSET_Y - (pixel.Y / 4));
end;

function SPS_PointToPixel(point: TPoint): TPoint;
begin
Result.X := Round((point.x - SPS_OFFSET_X) * 4);
Result.Y := Round((SPS_OFFSET_Y - point.y) * 4);
end;

// Finds position P in minimap by checking your own location
function SPS_PosToMM(P: TPoint): TPoint;
var
MyPos: TPoint;
begin
if not LoggedIn then Exit;
Result := Point(-1, -1);
MyPos := SPS_GetMyPos;
if Distance(MyPos.X, MyPos.Y, P.X, P.Y) < 72 then
Result := Point(MMCX + P.X - MyPos.X,
MMCY + P.Y - MyPos.Y);
end;

// Walks to position. If walking paths, please use WalkPath.
function SPS_WalkToPos(P: TPoint): boolean;
var
MM: TPoint;
begin
if not LoggedIn then Exit;
MM := SPS_PosToMM(P);

if (MM.X > 0) then
begin
Mouse(MM.X, MM.Y, 0, 0, True);
if WaitFunc(@IsMoving, 1, 3000 + random(500)) then
while IsMoving do
Flag;
Result := True;
end;
end;

// Walks from A to B, always walking as far as possible.
function SPS_WalkPath(Path: TPointArray): boolean;
var
I, H, T: integer;
P, MM: TPoint;
begin
H := High(Path);
T := GetSystemTime + (H + 1)*20000 + Random(5000);
while (not Result) and (GetSystemTime < T) do
begin
P := SPS_GetMyPos;
for I := H downto 0 do
begin
MM.X := MMCX + Path[I].X - P.X;
MM.Y := MMCY + Path[I].Y - P.Y;
if (Distance(MM.X, MM.Y, MMCX, MMCY) < 70) then
begin
MouseFlag(MM.X, MM.Y, 0, 0, Integer(I<>H)*10);
Break;
end;
end;
Result := (I = H);
end;
end;

Nava2
02-22-2011, 11:42 PM
ITS NOW COMPILED AND NOTED BELOW.

Could someone please compile this plugin for win32 and see if it works? I cannot seem to get cross compiling working.

I've attached the source, you need the Simba repos from: https://github.com/MerlijnWajer/Simba

Unrar the following into the `Projects` folder: http://goo.gl/S43Ud

Then just compile it.. it should build into a .dll.. I hope. :( If not, I did something wrong, so feel free to point it out and help me out.

thanks!

Btw.. I think I just triple posted..

e: It appears that I did.

E2: Could someone please test this http://www.frement.net/srl/SPS.dll replace the current dll with that one.

See if it works with the sps.simba I posted. :)

also, I know its massive.. I'll look into trimming it down. I think its massive because the entire MML is getting compiled in when thats not necessary.

Frement
02-23-2011, 02:03 AM
Access violations.

http://www.frement.net/srl/sps.png

Nava2
02-23-2011, 02:28 AM
Access violations.

...snip...

Can you try this:

//-----------------------------------------------------------------//
//-- SRL Resource Library --//
//-- Positioning routines --//
//-----------------------------------------------------------------//
// * SPS_GetMyPos: TPoint; by: marpis //
// * SPS_PosToMM(P: TPoint): TPoint; by: marpis //
// * SPS_WalkToPos(P: TPoint): boolean; by: marpis //
// * SPS_WalkPath(Path: TPointArray): boolean; by: marpis //
// * //
//-----------------------------------------------------------------//

{$LOADLIB SPS.dll} // Load SPS.dll plugin


const
// Path where all the SPS files are
SPS_PATH = AppPath + '/Includes/SRL/SRL/core/SPS/';
// RGB tolerance used, 0.2 = 20% etc.
SPS_TOLERANCE = 0.2;
// Offsets for Reflection conversion
SPS_OFFSET_X = 2093.5;
SPS_OFFSET_Y = 3774.0;

// SPS Global variables
var
SPS_Loaded: boolean;
SPS_Areas: TStringArray;
SPS_Worldmap: T4DIntegerArray;

function SPS_GatherMinimap: T3DIntegerArray;
var
bmp: TMufasaBitmap;
c: TClient;
begin
try
bmp := TMufasaBitmap.Create;
bmp.SetSize(100, 100);
c := getTClient;
bmp.CopyClientToBitmap(
c.IOManager, false, 0,0, MMCX-50, MMCY-50, MMCX+50, MMCY+50
);
Result := SPS_BitmapToMap(bmp);
finally
bmp.free; // just in case
except
Writeln('[ERROR] '+ExceptionToString(ExceptionType, ExceptionParam));
end;
end;


procedure SPS_GetAreaCoords(Area: string; var x, y: integer);
var
p: integer;
begin
p := pos('_', Area);
if (p <= 0) then
// raise an exception if Area is of wrong format
RaiseException(erCustomError, 'Invalid Area passed: ' + area);

x := StrToIntDef(copy(Area, 1, p), -1);
y := StrToIntDef(copy(Area, p+1, Length(Area)), -1);
end;

function SPS_LocalToGlobal(Area: string; x, y: integer): TPoint;
var
cx, cy: integer;
begin
SPS_GetAreaCoords(Area, cx, cy);
Result.x := cx*400 + x;
Result.y := cy*400 + y;
end;

// THIS DOESN'T WORK AT ALL YET (Feb 12th 2011)
function SPS_GlobalToTile(x, y: integer): TPoint;
begin
Result.x := Round(2018.75 + x/4);
Result.y := Round(3933.75 - y/4);
end;

procedure LoadSPS;
var
L, i, timer : integer;
bmp: TMufasaBitmap;
begin
timer := getSystemTime;
L := Length(SPS_Areas);

// clean up the old one just in case, we do not want copies in wrong places.
SetLength(SPS_WorldMap, 0);
SetLength(SPS_Worldmap, L);

//Writeln('[SPS] Building maps... Estimated time: '+ToStr(5600*L)+' ms.');
for i := L-1 downto 0 do
begin
try
bmp := TMufasaBitmap.Create;
bmp.LoadFromFile(SPS_PATH + SPS_Areas[i] +'.bmp');
SPS_Worldmap[i] := SPS_BitmapToMap(bmp);
finally
bmp.free; // just in case ;)
end;
end;

Writeln('[SPS] Maps loaded in '+ToStr(getSystemTime - timer)+'ms.');
SPS_Loaded := True;
end;


function SPS_GetMyPos: TPoint;
var
Minimap: T3DIntegerArray;
t, i, map: integer;
begin
if not LoggedIn then
Exit;

if not SPS_Loaded then
LoadSPS;

Result := Point(-1, -1);
// we should just rotate the minimap according to the minimap angle.
MakeCompass('N');

t := getSystemTime;
Minimap := SPS_GatherMinimap;
try
map := SPS_FindMapInMapEx(
Result.X, Result.Y, SPS_Worldmap, Minimap, SPS_TOLERANCE
);
if ((Result.X > 0) and (Result.Y > 0)) then
begin
Result := SPS_LocalToGlobal(SPS_Areas[map], Result.X, Result.Y);
end;

writeln(
Format(
'[SPS] Finished in %dms. Location = %s',
[getSystemTime-t, ToStr(Result)]
)
);
except
Writeln('[SPS] ERROR' + ExceptionToString(ExceptionType, ExceptionParam));
end;
end;

function SPS_PixelToPoint(pixel: TPoint): TPoint;
begin
Result.X := Round(SPS_OFFSET_X + (pixel.X / 4));
Result.Y := Round(SPS_OFFSET_Y - (pixel.Y / 4));
end;

function SPS_PointToPixel(point: TPoint): TPoint;
begin
Result.X := Round((point.x - SPS_OFFSET_X) * 4);
Result.Y := Round((SPS_OFFSET_Y - point.y) * 4);
end;

// Finds position P in minimap by checking your own location
function SPS_PosToMM(P: TPoint): TPoint;
var
MyPos: TPoint;
begin
if not LoggedIn then Exit;
Result := Point(-1, -1);
MyPos := SPS_GetMyPos;
if Distance(MyPos.X, MyPos.Y, P.X, P.Y) < 72 then
Result := Point(MMCX + P.X - MyPos.X,
MMCY + P.Y - MyPos.Y);
end;

// Walks to position. If walking paths, please use WalkPath.
function SPS_WalkToPos(P: TPoint): boolean;
var
MM: TPoint;
begin
if not LoggedIn then Exit;
MM := SPS_PosToMM(P);

if (MM.X > 0) then
begin
Mouse(MM.X, MM.Y, 0, 0, True);
if WaitFunc(@IsMoving, 1, 3000 + random(500)) then
while IsMoving do
Flag;
Result := True;
end;
end;

// Walks from A to B, always walking as far as possible.
function SPS_WalkPath(Path: TPointArray): boolean;
var
I, H, T: integer;
P, MM: TPoint;
begin
H := High(Path);
T := GetSystemTime + (H + 1)*20000 + Random(5000);
while (not Result) and (GetSystemTime < T) do
begin
P := SPS_GetMyPos;
for I := H downto 0 do
begin
MM.X := MMCX + Path[I].X - P.X;
MM.Y := MMCY + Path[I].Y - P.Y;
if (Distance(MM.X, MM.Y, MMCX, MMCY) < 70) then
begin
MouseFlag(MM.X, MM.Y, 0, 0, Integer(I<>H)*10);
Break;
end;
end;
Result := (I = H);
end;
end;

Might have fixed some.. or at least give a better idea.

Nava2
02-23-2011, 03:44 AM
Okay, so here's the deal..

We do NOT know where the access violation stems from. If someone could please use the attached SPS.simba to try and find the issue function, I would really appreciate it.

If you find it and want to help out, feel free to look what could cause the issues. I really have no idea... :(

We've tried removing functions etc, if anyone can figure it out.. there's cookies involved.

The sauce for the plugin is in the SPS folder in the .zip, the simba files to use are in the simba folder.. the compiled .dll (thanks for Frement) is located here: http://www.frement.net/srl/SPS.rar.

To compile the .dll, you need the simba sources and the instructions are posted in an earlier post.

lordsaturn
02-23-2011, 05:30 AM
If you find it and want to help out, feel free to look what could cause the issues. I really have no idea... :(
The function GetAreaCoords is incorrect. Marpis uses the third parameter of copy as an index in the string, and it is not. The third parameter of copy is iCount. heres your fix:
procedure SPS_GetAreaCoords(Area: string; var x, y: integer);
var
p: integer;
begin
p := pos('_', Area);
if (p <= 0) then
// raise an exception if Area is of wrong format
RaiseException(erCustomError, 'Invalid Area passed: ' + area);

x := StrToIntDef(copy(Area, 1, p-1), -1);
y := StrToIntDef(copy(Area, p+1, Length(Area)-p), -1);
writeln(format('[SPS] area coords (%d,%d)', [x,y]));
end;

here's what it was earlier:
x := StrToIntDef(copy(Area, 1, p), -1);
y := StrToIntDef(copy(Area, p+1, Length(Area)), -1);

Nava2
02-23-2011, 05:42 AM
The function GetAreaCoords is incorrect. Marpis uses the third parameter of copy as an index in the string, and it is not. The third parameter of copy is iCount. heres your fix:
procedure SPS_GetAreaCoords(Area: string; var x, y: integer);
var
p: integer;
begin
p := pos('_', Area);
if (p <= 0) then
// raise an exception if Area is of wrong format
RaiseException(erCustomError, 'Invalid Area passed: ' + area);

x := StrToIntDef(copy(Area, 1, p-1), -1);
y := StrToIntDef(copy(Area, p+1, Length(Area)-p), -1);
writeln(format('[SPS] area coords (%d,%d)', [x,y]));
end;

here's what it was earlier:
x := StrToIntDef(copy(Area, 1, p), -1);
y := StrToIntDef(copy(Area, p+1, Length(Area)), -1);

/facepalm

Thank you. :)

I have uploaded a new semi-stable version of SPS. It is located here: http://goo.gl/A6mn1

Please test and report back with what happens. I hope that it is significantly faster than before. Loading takes about 15ms now (vs. the 300+ before) and getMyPos should take about 60ms.

COMMENTS AND CRITICISM WELCOMED.

Oh, and a huge thanks to Frement for working on this as well. :)

lordsaturn
02-23-2011, 06:40 AM
Alright to compile sps.lpj, you need to add the folder "SPS" to simba projects folder so you get "Simba/Projects/SPS/sps.lpj".

(this next step probably isnt necessary)
Then open the project, navigate to project->project inspector. Change the bitmaps.pas dependency to match your file structure.

Then add the Interfaces import to the uses clause.
Uncomment the TIntegerArray type declaration.
Tada.

marpis
02-23-2011, 07:19 AM
I have uploaded a new semi-stable version of SPS. It is located here: http://goo.gl/A6mn1


Gives me access violation :(

Frement
02-23-2011, 01:06 PM
It still gives me access violation. The problem still exists.

Wizzup?
02-23-2011, 03:40 PM
Nava, you do know what the implications of a plugin are with regard to memory sharing?

Nava2
02-23-2011, 04:16 PM
Nava, you do know what the implications of a plugin are with regard to memory sharing?

Not entirely, I thought I had eliminated them though.. or at least marpis had since I did not change anything... >.>

Simba creates and frees the memory for the TMufasaBitmap.

I'm not sure what you mean though..


It still gives me access violation. The problem still exists.

Saturn said he got it working.. o.O

marpis
02-25-2011, 08:14 AM
Damn I want this bitch working already :( Any progress in removing the access violation?

Nava2
02-25-2011, 04:57 PM
Damn I want this bitch working already :( Any progress in removing the access violation?

Haven't had time to sit down with it.. :(

Coh3n
02-26-2011, 10:38 PM
Love how much faster you guys made it. :) I'll try the last version you uploaded, Nava; although I probably won't be able to pinpoint the error, but we'll see.

Nava2
02-27-2011, 02:13 AM
so, I think I fixed this..

But, I'm not at home, nor have access to compile this.

Also, in plugins, does one need to manage memory directly aka alloc space for arrays of primitive types or is it only for arrays of non-primitives?

library sps;

{$mode objfpc}{$H+}

uses
Classes, sysutils, Graphics, FileUtil, bitmaps, mufasatypes, Interfaces;

type
TIntegerArray = Array of Integer;
T3DIntegerArray = Array of Array of Array of Integer;
T4DIntegerArray = Array of Array of Array of Array of Integer;


function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean; register;
begin
Result := False;
if (B1[0] >= Round(B2[0]*(1-tol))) and (B1[0] <= Round(B2[0]*(1+tol))) and
(B1[1] >= Round(B2[1]*(1-tol))) and (B1[1] <= Round(B2[1]*(1+tol))) and
(B1[2] >= Round(B2[2]*(1-tol))) and (B1[2] <= Round(B2[2]*(1+tol))) then
begin
Result := True;
end;
end;

function MakeColorBoxEx(bmp: TMufasaBitmap; x1, y1: integer): TIntegerArray;
//[0]=Red [1]=Green [2]=Blue
var
x, y, width, row: integer;
// C: TColor;
// R, G, B: integer;
c: TRGB32;
begin
SetLength(Result, 3);
width := bmp.Width; // may not be necessary, but should help a bit.
for y := (y1 + 4) downto y1 do
begin
row := y*width;
for x := (x1 + 4) downto x1 do
begin
try
c := bmp.FData[row+x];
Result[0] := Result[0] + c.r;
Result[1] := Result[1] + c.g;
Result[2] := Result[2] + c.b;
except
WriteLn(Format('[SPS-Plugin] MakeColorBoxEx exception: %d,%d', [x,y]));
end;
end;
end;
end;

function SPS_BitmapToMap(bmp: TMufasaBitmap): T3DIntegerArray; register;
var
X, Y, HighX, HighY: integer;
begin
HighX := Trunc(bmp.Width / (5.0));
HighY := Trunc(bmp.Height / (5.0));

SetLength(Result, HighX);//moved outside to remove memory management iteration
for X := 0 to HighX-1 do
begin
SetLength(Result[X], HighY); // see above.
for Y := 0 to HighY-1 do
begin
Result[X][Y] := MakeColorBoxEx(bmp, X*5, Y*5);
end;
end;
end;

//
function SPS_FindMapInMapEx(out fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer; register;
var
x, y, HighX, HighY, cm, L: integer;
xx, yy: integer;
Matching, BestMatch: integer;
begin
fX := -1;
fY := -1;
BestMatch := 0;

L := Length(LargeMap);
Result := -1;

for cm := 0 to L-1 do
begin
HighX := High(LargeMap[cm]) - 19;
HighY := High(LargeMap[cm][0]) - 19;
for x := 0 to HighX do
for y := 0 to HighY do
begin
Matching := 0;
for xx := 0 to 19 do
for yy := 0 to 19 do
if SPS_ColorBoxesMatch(LargeMap[cm][x+xx][y+yy], SmallMap[xx][yy], tol) then
Inc(Matching);

if (Matching > BestMatch) then
begin
BestMatch := Matching;
Result := cm;
fX := x;
fY := y;
//WriteLn(Format('BM: %d Res: %d fx,fy: %d,%d',[bestMatch, cm, fX,fY]));
end;
end;
end;

if (Result > -1) then
begin
// moved outside to remove uncessary calculations in interations.
fX := fX*5 + 50; // cause we want the center
fy := fY*5 + 50;
end;
end;


////// TYPES //////////////////////////////////////////////////////////////////

function GetTypeCount(): Integer; stdcall; export;
begin
Result := 2;
end;

function GetTypeInfo(x: Integer; var sType, sTypeDef: string): integer; stdcall;
begin
case x of

0: begin
sType := 'T3DIntegerArray';
sTypeDef := 'Array of Array of Array of Integer;';
end;

1: begin
sType := 'T4DIntegerArray';
sTypeDef := 'Array of T3DIntegerArray;';
end;

else
Result := -1;
end;
end;




////// EXPORTING /////////////////////////////////////////////////////////////
function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 3;
end;

function GetFunctionCallingConv(x : Integer) : Integer; stdcall; export;
begin
Result := 0;
case x of
0..2 : Result := 1;
end;
end;

function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall; export;
begin
case x of
0:
begin
ProcAddr := @SPS_ColorBoxesMatch;
StrPCopy(ProcDef, 'function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean;');
end;
1:
begin
ProcAddr := @SPS_FindMapInMapEx;
StrPCopy(ProcDef, 'function SPS_FindMapInMapEx(out fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer;');
end;
2:
begin
ProcAddr := @SPS_BitmapToMap;
StrPCopy(ProcDef, 'function SPS_BitmapToMap(bmp: TMufasaBitmap): T3DIntegerArray;');
end;
else
x := -1;
end;
Result := x;
end;



exports GetTypeCount;
exports GetTypeInfo;
exports GetFunctionCount;
exports GetFunctionInfo;
exports GetFunctionCallingConv;

begin
end.

What I changed was merely rather than converting the FData to rgb, I actually access the already stored information! I was not using it correctly, that was my bad.

I also implemented the compiling issues that saturn suggested.. PLEASE test.

Nothing is to be changed in the SPS.simba.

lordsaturn
02-27-2011, 03:12 AM
so, I think I fixed this..

Compiled from source: http://www.mediafire.com/?9k72f2yu8bqjkes


The old dll worked for me too as long as I didn't run across any loading screens.

Edit: To compile , add MufasaTypes to imports.

Coh3n
02-27-2011, 07:49 AM
The dll saturn posted is working great for me. I'm having it walk back and forth a bunch of times to check for memory leaks. So far it looks good; however, I've noticed a few things about the path walking. Sometimes it will click the same point twice if it's close enough to the flag, but the point isn't on the minimap, and I've seen it a couple times return true before finishing the last point.

I'll make some tweaks and see how it goes. I'm also going to try WaitPoint again, now that it's a lot faster. :)

Nava2
02-27-2011, 07:53 AM
The dll saturn posted is working great for me. I'm having it walk back and forth a bunch of times to check for memory leaks. So far it looks good; however, I've noticed a few things about the path walking. Sometimes it will click the same point twice if it's close enough to the flag, but the point isn't on the minimap, and I've seen it a couple times return true before finishing the last point.

I'll make some tweaks and see how it goes. I'm also going to try WaitPoint again, now that it's a lot faster. :)

This leads me to believe there is an issue in the way that Frement was compiling the .dll. This is actually good news! :)

How is it for memory, though? Better? Does there appear to be a leak based on SMS?

My changes did not change the functionality. If there is an issue with the walking functions, I can safely say that was not in my domain. I only changed things to do with the finding of tiles ;)

Coh3n
02-27-2011, 07:57 AM
This leads me to believe there is an issue in the way that Frement was compiling the .dll. This is actually good news! :)

How is it for memory, though? Better? Does there appear to be a leak based on SMS?

My changes did not change the functionality. If there is an issue with the walking functions, I can safely say that was not in my domain. I only changed things to do with the finding of tiles ;)
It jumps up quite a bit when the maps are loaded as expected, then about half of it gets freed when I terminate the script. But while it's running, I didn't notice any change.

Iamadam
02-27-2011, 10:56 AM
Been testing it, and it is running much more stably. Good work :)
Any idea of when this will be made part of SRL core?
Also, are the paths going to stay in pixel format or can we convert them to tile format now that we know how? It'd be good to maybe use both...


//-----------------------------------------------------------------//
//-- SRL Resource Library --//
//-- Positioning routines --//
//-----------------------------------------------------------------//
// * SPS_GetMyPos: TPoint; by: marpis //
// * SPS_PosToMM(P: TPoint): TPoint; by: marpis //
// * SPS_WalkToPos(P: TPoint): boolean; by: marpis //
// * SPS_WalkPath(Path: TPointArray): boolean; by: marpis //
// * //
//-----------------------------------------------------------------//

{$LOADLIB SPS.dll} // Load SPS.dll plugin


const
// Path where all the SPS files are
SPS_PATH = AppPath + '/Includes/SRL/SRL/core/SPS/';
// RGB tolerance used, 0.2 = 20% etc.
SPS_TOLERANCE = 0.2;
// Offsets for Reflection conversion
SPS_OFFSET_X = 2093.5;
SPS_OFFSET_Y = 3774.0;

// SPS Global variables
var
SPS_Loaded: boolean;
SPS_Areas: TStringArray;
SPS_Worldmap: T4DIntegerArray;


procedure LoadSPS;
var
L, i, t : integer;
bmp: TMufasaBitmap;
begin
t := getsystemtime;
L := Length(SPS_Areas);
SetLength(SPS_Worldmap, L);
//Writeln('[SPS] Building maps... Estimated time: '+ToStr(5600*L)+' ms.');
for i := 0 to L - 1 do
begin
try
bmp := TMufasaBitmap.Create;
bmp.LoadFromFile(SPS_PATH + SPS_Areas[i] +'.bmp');
SPS_Worldmap[i] := SPS_BitmapToMap(bmp);
finally
bmp.free; // just in case ;)
end;
end;
t := getsystemtime - t;
Writeln('[SPS] Maps loaded in '+ToStr(t)+'ms.');
SPS_Loaded := True;
end;

function SPS_GatherMinimap: T3DIntegerArray;
var
bmp: TMufasaBitmap;
c: TClient;
begin
try
bmp := TMufasaBitmap.Create; // yeah its not as clean as before, but the performance gains should be worth it.
bmp.SetSize(100, 100);
c := getTClient;
bmp.CopyClientToBitmap(
c.IOManager, false, 0,0, MMCX-50, MMCY-50, MMCX+50, MMCY+50
);
Result := SPS_BitmapToMap(bmp);
finally
bmp.free; // just in case
except
Writeln('[ERROR] '+ExceptionToString(ExceptionType, ExceptionParam));
end;
end;

procedure SPS_GetAreaCoords(Area: string; var x, y: integer);
var
s: string;
i: integer;
begin
for i := 1 to length(Area) do
begin
if Area[i] = '_' then
begin
x := StrToInt(s);
y := StrToInt(Copy(Area, i + 1, length(Area)));
Exit;
end;
s := s + Area[i];
end;
end;

function SPS_LocalToGlobal(Area: string; x, y: integer): TPoint;
var
cx, cy: integer;
begin
SPS_GetAreaCoords(Area, cx, cy);
Result.x := cx*400 + x;
Result.y := cy*400 + y;
end;

function SPS_GetMyPos: TPoint;
var
Minimap: T3DIntegerArray;
t, i, map: integer;
begin
if not LoggedIn then
Exit;

if not SPS_Loaded then
LoadSPS;

Result := Point(-1, -1);
MakeCompass('N');

t := getSystemTime;
Minimap := SPS_GatherMinimap;
try
map := SPS_FindMapInMapEx(
Result.X, Result.Y, SPS_Worldmap, Minimap, SPS_TOLERANCE
);
if ((Result.X > 0) and (Result.Y > 0)) then
begin
Result := SPS_LocalToGlobal(SPS_Areas[map], Result.X, Result.Y);
end;

t := getsystemtime - t;
writeln(
Format(
'[SPS] Finished in %dms. Location = %s',
[t, ToStr(Result)]
)
);
except
Writeln('[SPS] ERROR' + ExceptionToString(ExceptionType, ExceptionParam));
end;
end;


// Finds position P in minimap by checking your own location
function SPS_PosToMM(P: TPoint): TPoint;
var
MyPos: TPoint;
begin
if not LoggedIn then Exit;
Result := Point(-1, -1);
MyPos := SPS_GetMyPos;
if Distance(MyPos.X, MyPos.Y, P.X, P.Y) < 72 then
Result := Point(MMCX + P.X - MyPos.X,
MMCY + P.Y - MyPos.Y);
end;

// Walks to position. If walking paths, please use WalkPath.
function SPS_WalkToPos(P: TPoint): boolean;
var
MM: TPoint;
begin
if not LoggedIn then Exit;
MM := SPS_PosToMM(P);

if (MM.X > 0) then
begin
Mouse(MM.X, MM.Y, 0, 0, True);
if WaitFunc(@IsMoving, 1, 3000 + random(500)) then
while IsMoving do
Flag;
Result := True;
end;
end;

// Walks from A to B, always walking as far as possible.
function SPS_WalkPath(Path: TPointArray): boolean;
var
I, H, T: integer;
P, MM: TPoint;
begin
H := High(Path);
T := GetSystemTime + (H + 1)*20000 + Random(5000);
while (not Result) and (GetSystemTime < T) do
begin
P := SPS_GetMyPos;
for I := H downto 0 do
begin
MM.X := MMCX + Path[I].X - P.X;
MM.Y := MMCY + Path[I].Y - P.Y;
if (Distance(MM.X, MM.Y, MMCX, MMCY) < 70) then
begin
MouseFlag(MM.X, MM.Y, 0, 0, Integer(I<>H)*10);
Break;
end;
end;
Result := (I = H);
end;
end;

function SPS_PixelToTile(pixel: TPoint): TPoint;
begin
Result.X := Round(SPS_OFFSET_X + (pixel.X / 4));
Result.Y := Round(SPS_OFFSET_Y - (pixel.Y / 4));
end;

function SPS_TileToPixel(tile: TPoint): TPoint;
begin
Result.X := Round((tile.x - SPS_OFFSET_X) * 4);
Result.Y := Round((SPS_OFFSET_Y - tile.y) * 4);
end;

function SPS_WalkTilePath(Path: TPointArray): boolean;
var
i, h, t: integer;
p, MM, currentPathPoint: TPoint;
begin
h := High(Path);
t := GetSystemTime + (h + 1)*20000 + Random(5000);
while (not Result) and (GetSystemTime < t) do
begin
p := SPS_GetMyPos;
for i := h downto 0 do
begin
currentPathPoint := SPS_TileToPixel(path[i]);
MM.x := MMCX + currentPathPoint.x - p.x;
MM.y := MMCY + currentPathPoint.y - p.y;
if (Distance(MM.x, MM.y, MMCX, MMCY) < 70) then
begin
MouseFlag(MM.x, MM.y, 0, 0, Integer(i<>h)*10);
Break;
end;
end;
Result := (i = h);
end;
end;
New function is SPS_WalkTilePath. Give it a (reflection style) tile path and it will walk it using color.

Coh3n
02-27-2011, 04:36 PM
Iamadam, SPS_WalkTilePath is basically the same thing as SPS_WalkPath. You may as well just have:

function MSI_ConvertTilePath(Tiles: TPointArray): TPointArray;
var
i: Integer;
begin
SetLength(Result, Length(Tiles));

for i := 0 to High(Result) do
Result[i] := SPS_PointToPixel(Tiles[i]);
end;

function SPS_WalkTilePath(Tiles: TPointArray): Boolean;
begin
Result := SPS_WalkPath(ConvertTilePath(Tiles));
end;

On another note, I had two instances of MSI run for over 6 hours last night using this and everything seemed pretty good. I was watching the one when I got up and it was waiting a few seconds before walking to the next point, on every point. I haven't tried a WaitPoint function yet, though.

E: Yeah, using a WaitPoint is still too slow. It's not too bad with short paths, but for long paths it's much better to use the one you have. :)

Nava2
02-27-2011, 04:51 PM
Iamadam, SPS_WalkTilePath is basically the same thing as SPS_WalkPath. You may as well just have:

function MSI_ConvertTilePath(Tiles: TPointArray): TPointArray;
var
i: Integer;
begin
SetLength(Result, Length(Tiles));

for i := 0 to High(Result) do
Result[i] := SPS_PointToPixel(Tiles[i]);
end;

function SPS_WalkTilePath(Tiles: TPointArray): Boolean;
begin
Result := SPS_WalkPath(ConvertTilePath(Tiles));
end;

On another note, I had two instances of MSI run for over 6 hours last night using this and everything seemed pretty good. I was watching the one when I got up and it was waiting a few seconds before walking to the next point, on every point. I haven't tried a WaitPoint function yet, though.

The Tile->SPS conversion is not working..

The walkPath function that is implemented is just silly. It needs to be rewritten and better.. I just do not have time for that right now.

Coh3n
02-27-2011, 05:17 PM
The Tile->SPS conversion is not working..
What do you mean it's not working? That's what I use in MSI, and I got two 6 hour reports using SPS last night.



The walkPath function that is implemented is just silly. It needs to be rewritten and better.. I just do not have time for that right now.
What's wrong with it?

Nava2
02-27-2011, 06:21 PM
What do you mean it's not working? That's what I use in MSI, and I got two 6 hour reports using SPS last night.

marpis stated that it was not working.. Humph, he could be wrng though.



What's wrong with it?

Its a ridiculous amount of loops, the timing is inefficient and it lacks the finese necessary ;).

Coh3n
02-27-2011, 06:24 PM
marpis stated that it was not working.. Humph, he could be wrng though.
I've been using it ever since he added PixelToPoint and PointToPixel.



Its a ridiculous amount of loops, the timing is inefficient and it lacks the finese necessary ;).
Lol oh, I see. :p

Nava2
02-27-2011, 06:25 PM
I've been using it ever since he added PixelToPoint and PointToPixel.

Uh.. I'm talking about the conversion between reflection tiles and the tiles associated with SPS. Are we talking about the same thing?

Coh3n
02-27-2011, 06:26 PM
Uh.. I'm talking about the conversion between reflection tiles and the tiles associated with SPS. Are we talking about the same thing?
Yes. PointToPixel converts reflection tiles to SPS tiles, and PixelToPoint is the opposite.

Nava2
02-27-2011, 06:37 PM
Yes. PointToPixel converts reflection tiles to SPS tiles, and PixelToPoint is the opposite.

Well, thats a nice surprise.

Made some optimizations in the plugin, no real difference so update whenever.

I would love it if someone with some FPC experience could figure out how to trim the thing down from 13mb. Its wayyy larger than it should be.

library sps;

{$mode objfpc}{$H+}

uses
Classes, sysutils, Graphics, FileUtil, bitmaps, mufasatypes, Interfaces;

type
TIntegerArray = Array of Integer;
T3DIntegerArray = Array of Array of Array of Integer;
T4DIntegerArray = Array of Array of Array of Array of Integer;


function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean; register;
begin
Result := False;
if (B1[0] >= Round(B2[0]*(1-tol))) and (B1[0] <= Round(B2[0]*(1+tol))) and
(B1[1] >= Round(B2[1]*(1-tol))) and (B1[1] <= Round(B2[1]*(1+tol))) and
(B1[2] >= Round(B2[2]*(1-tol))) and (B1[2] <= Round(B2[2]*(1+tol))) then
begin
Result := True;
end;
end;

function MakeColorBoxEx(bmp: TMufasaBitmap; x1, y1: integer): TIntegerArray;
//[0]=Red [1]=Green [2]=Blue
var
x, y, width, row: integer;
// C: TColor;
// R, G, B: integer;
c: TRGB32;
begin
SetLength(Result, 3);
width := bmp.Width; // may not be necessary, but should help a bit.
for y := (y1 + 4) downto y1 do
begin
row := y*width;
for x := (x1 + 4) downto x1 do
begin
try
c := bmp.FData[row+x];
Result[0] := Result[0] + c.r;
Result[1] := Result[1] + c.g;
Result[2] := Result[2] + c.b;
except
WriteLn(Format('[SPS-Plugin] MakeColorBoxEx exception: %d,%d', [x,y]));
end;
end;
end;
end;

function SPS_BitmapToMap(bmp: TMufasaBitmap): T3DIntegerArray; register;
var
X, Y, HighX, HighY: integer;
begin
HighX := Trunc(bmp.Width / (5.0));
HighY := Trunc(bmp.Height / (5.0));

SetLength(Result, HighX);//moved outside to remove memory management iteration
for X := 0 to HighX-1 do
begin
SetLength(Result[X], HighY); // see above.
for Y := 0 to HighY-1 do
begin
Result[X][Y] := MakeColorBoxEx(bmp, X*5, Y*5);
end;
end;
end;

//
function SPS_FindMapInMapEx(out fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer; register;
var
x, y, HighX, HighY, cm, L: integer;
xx, yy: integer;
Matching, BestMatch: integer;
begin
fX := -1;
fY := -1;
BestMatch := 0;

L := Length(LargeMap);
Result := -1;

for cm := 0 to L-1 do
begin
HighX := High(LargeMap[cm]) - 19;
HighY := High(LargeMap[cm][0]) - 19;
for x := 0 to HighX do
for y := 0 to HighY do
begin
Matching := 0;
for xx := 0 to 19 do
for yy := 0 to 19 do
if SPS_ColorBoxesMatch(LargeMap[cm][x+xx][y+yy], SmallMap[xx][yy], tol) then
Inc(Matching);

if (Matching > BestMatch) then
begin
BestMatch := Matching;
Result := cm;
fX := x;
fY := y;
//WriteLn(Format('BM: %d Res: %d fx,fy: %d,%d',[bestMatch, cm, fX,fY]));
end;
end;
end;

if (Result > -1) then
begin
// moved outside to remove uncessary calculations in interations.
fX := fX*5 + 50; // cause we want the center
fy := fY*5 + 50;
end;
end;


////// TYPES //////////////////////////////////////////////////////////////////

function GetTypeCount(): Integer; stdcall; export;
begin
Result := 2;
end;

function GetTypeInfo(x: Integer; var sType, sTypeDef: string): integer; stdcall;
begin
case x of

0: begin
sType := 'T3DIntegerArray';
sTypeDef := 'Array of Array of Array of Integer;';
end;

1: begin
sType := 'T4DIntegerArray';
sTypeDef := 'Array of T3DIntegerArray;';
end;

else
Result := -1;
end;
end;




////// EXPORTING /////////////////////////////////////////////////////////////
function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 3;
end;

function GetFunctionCallingConv(x : Integer) : Integer; stdcall; export;
begin
Result := 0;
case x of
0..2 : Result := 1;
end;
end;

function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall; export;
begin
case x of
0:
begin
ProcAddr := @SPS_ColorBoxesMatch;
StrPCopy(ProcDef, 'function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean;');
end;
1:
begin
ProcAddr := @SPS_FindMapInMapEx;
StrPCopy(ProcDef, 'function SPS_FindMapInMapEx(out fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer;');
end;
2:
begin
ProcAddr := @SPS_BitmapToMap;
StrPCopy(ProcDef, 'function SPS_BitmapToMap(bmp: TMufasaBitmap): T3DIntegerArray;');
end;
else
x := -1;
end;
Result := x;
end;



exports GetTypeCount;
exports GetTypeInfo;
exports GetFunctionCount;
exports GetFunctionInfo;
exports GetFunctionCallingConv;

begin
end.

Iamadam
02-28-2011, 01:55 AM
Iamadam, SPS_WalkTilePath is basically the same thing as SPS_WalkPath. You may as well just have:

function MSI_ConvertTilePath(Tiles: TPointArray): TPointArray;
var
i: Integer;
begin
SetLength(Result, Length(Tiles));

for i := 0 to High(Result) do
Result[i] := SPS_PointToPixel(Tiles[i]);
end;

function SPS_WalkTilePath(Tiles: TPointArray): Boolean;
begin
Result := SPS_WalkPath(ConvertTilePath(Tiles));
end;

On another note, I had two instances of MSI run for over 6 hours last night using this and everything seemed pretty good. I was watching the one when I got up and it was waiting a few seconds before walking to the next point, on every point. I haven't tried a WaitPoint function yet, though.

E: Yeah, using a WaitPoint is still too slow. It's not too bad with short paths, but for long paths it's much better to use the one you have. :)

Could do that too :0)

Also, I think it's much better to call it PixelToTile rather than PixelToPoint. Just reflects what it does much better :)

marpis
02-28-2011, 02:39 PM
I tested the .dll saturn posted, it works great :)
Coh3n, have you made any improvements to SPS.simba?
Have you tested it with the most recent changes and the latest plugin and gotten any errors?

Basically, are there more things to be fixed before official release?

Frement
02-28-2011, 02:50 PM
Compiled from source: http://www.mediafire.com/?9k72f2yu8bqjkes


The old dll worked for me too as long as I didn't run across any loading screens.

Edit: To compile , add MufasaTypes to imports.

Compiler options and shit like that? I always get access violations with my DLL.

Coh3n
02-28-2011, 05:16 PM
I tested the .dll saturn posted, it works great :)
Coh3n, have you made any improvements to SPS.simba?
Have you tested it with the most recent changes and the latest plugin and gotten any errors?

Basically, are there more things to be fixed before official release?
I'm using the dll saturn posted, and the rest that nava posted on the last page. I've still gotten the access violation spamming the debug box sometimes (like a said at the beginning). YoHoJo has also had this problem. Sometimes it takes a couple tries, but usually when I restart Simba it works.

Nava2
02-28-2011, 11:37 PM
I took out most of the spammy WriteLns. Those were there from when I was trying to figure out where the access violation was coming from. :|

Flight
03-01-2011, 12:38 AM
Have you released a newest version of SPS up to this day? I noticed the last on your site is Feb 17th, just wondering if you're planning to update that any time soon, I'm really interested in using this.

Nava2
03-01-2011, 12:42 AM
Have you released a newest version of SPS up to this day? I noticed the last on your site is Feb 17th, just wondering if you're planning to update that any time soon, I'm really interested in using this.

Use the .simba I posted (most recently) and the plugin compiled by lordsaturn.

Coh3n
03-01-2011, 12:51 AM
Here's mine. :) Everything should work. It's the last .simba Nava posted and Saturn's plugin.

http://uppit.com/ly6bl8k4ue6q/SPS-28-02-2011.zip

Flight
03-01-2011, 02:03 AM
Ah thank you very much guys.

marpis
03-05-2011, 07:55 PM
Any news to this? How much real problems?
There's not much that I can do anymore :(

Coh3n
03-05-2011, 08:05 PM
Aside from that rare access violation, it workd well for me. I don't see why it can't be officially released. :)

marpis
03-05-2011, 08:18 PM
Aside from that rare access violation, it workd well for me. I don't see why it can't be officially released. :)

Great! I'll wrap it up tomorrow, commit, and make an announcement.
This is the second file I'll be adding to SRL :p

Coh3n
03-07-2011, 07:05 AM
Not sure if this has been said already, but would a PixelToMS be possible? Like TileToMS?

Floor66
03-07-2011, 07:06 AM
SRL has a function called 'MMToMS' in it.

Coh3n
03-07-2011, 07:11 AM
SRL has a function called 'MMToMS' in it.
Not the same though. You still have to find where the object is on the minimap. I'm talking about knowing the SPS tile already so it doesn't matter where the object is on the minimap, you can still find it on the main screen.

Floor66
03-07-2011, 07:12 AM
Ah right, sorry :)

marpis
03-07-2011, 08:10 AM
Not the same though. You still have to find where the object is on the minimap. I'm talking about knowing the SPS tile already so it doesn't matter where the object is on the minimap, you can still find it on the main screen.


function PixelToMM(P: TPoint): TPoint;
var
CP: TPoint;
begin
CP := SPS_GetMyPos;
Result := Point(MMCX + P.x - CP.x, MMCY + P.y - CP.y);
end;

function PixelToMS(P: TPoint): TPoint;
begin
Result := MMtoMS(PixelToMM(P));
end;

Coh3n
03-07-2011, 05:02 PM
function PixelToMM(P: TPoint): TPoint;
var
CP: TPoint;
begin
CP := SPS_GetMyPos;
Result := Point(MMCX + P.x - CP.x, MMCY + P.y - CP.y);
end;

function PixelToMS(P: TPoint): TPoint;
begin
Result := MMtoMS(PixelToMM(P));
end;

<3

I'm going to have to try that out for object finding. When I write private reflection scripts I always use tiles rather than object IDs, so this would be the same. :)

marpis
03-07-2011, 06:41 PM
<3

I'm going to have to try that out for object finding. When I write private reflection scripts I always use tiles rather than object IDs, so this would be the same. :)

Yea but be sure to do a color search and just sort them from that point. It's really not that accurate.

Coh3n
03-07-2011, 06:43 PM
Yea but be sure to do a color search and just sort them from that point. It's really not that accurate.
Will do, thanks. :)

csawan
03-10-2011, 10:45 PM
[Error] (42:34): Unknown identifier 'MMCX' at line 41
Compiling failed.

Zyt3x
03-10-2011, 10:58 PM
[Error] (42:34): Unknown identifier 'MMCX' at line 41
Compiling failed.You have to download SRL: http://villavu.com/forum/showthread.php?t=57883#1

csawan
03-10-2011, 11:12 PM
That guide is like outdated. I downloaded SIMBA and it didn't have the UPDATE button at the top at all. It didn't have reflection.sex in the extensions either. I am trying to figure it out but that guide is way outdated. That is talking about version like 631 and the site you download 801.

csawan
03-10-2011, 11:50 PM
This doesn't work with the new version of SIMBA

Echo_
03-11-2011, 12:41 AM
Did you go to view, then select extensions? Maybe your using an older version and haven't updated your extensions like it says in the debug box?

Please refrain from double posting too, there's an edit button.

Nava2
03-11-2011, 01:02 AM
This doesn't work with the new version of SIMBA

... Yes it does.

Download the extensions off github if necessary.
https://github.com/MerlijnWajer/Simba/tree/master/Extensions

Coh3n
03-11-2011, 02:42 AM
That guide is like outdated. I downloaded SIMBA and it didn't have the UPDATE button at the top at all. It didn't have reflection.sex in the extensions either. I am trying to figure it out but that guide is way outdated. That is talking about version like 631 and the site you download 801.
Use this (http://villavu.com/forum/showthread.php?t=47714) guide.

Ogre
03-13-2011, 08:00 PM
I get that access violation pretty often
[ERROR] GATHERMINIMAP:: Exception: Access violation
but when it's not getting that, it works great! :)

Sorry if I'm just posting what tons of other people already have - cbf to read through 6 pages of posts.

Nava2
03-13-2011, 08:11 PM
I get that access violation pretty often
[ERROR] GATHERMINIMAP:: Exception: Access violation
but when it's not getting that, it works great! :)

Sorry if I'm just posting what tons of other people already have - cbf to read through 6 pages of posts.

which version are you using

Ogre
03-13-2011, 08:23 PM
E: nvm, restarted simba and it's not happening anymore :)

Nava2
03-13-2011, 08:29 PM
Well, thats a nice surprise.

Made some optimizations in the plugin, no real difference so update whenever.

I would love it if someone with some FPC experience could figure out how to trim the thing down from 13mb. Its wayyy larger than it should be.

library sps;

{$mode objfpc}{$H+}

uses
Classes, sysutils, Graphics, FileUtil, bitmaps, mufasatypes, Interfaces;

type
TIntegerArray = Array of Integer;
T3DIntegerArray = Array of Array of Array of Integer;
T4DIntegerArray = Array of Array of Array of Array of Integer;


function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean; register;
begin
Result := False;
if (B1[0] >= Round(B2[0]*(1-tol))) and (B1[0] <= Round(B2[0]*(1+tol))) and
(B1[1] >= Round(B2[1]*(1-tol))) and (B1[1] <= Round(B2[1]*(1+tol))) and
(B1[2] >= Round(B2[2]*(1-tol))) and (B1[2] <= Round(B2[2]*(1+tol))) then
begin
Result := True;
end;
end;

function MakeColorBoxEx(bmp: TMufasaBitmap; x1, y1: integer): TIntegerArray;
//[0]=Red [1]=Green [2]=Blue
var
x, y, width, row: integer;
// C: TColor;
// R, G, B: integer;
c: TRGB32;
begin
SetLength(Result, 3);
width := bmp.Width; // may not be necessary, but should help a bit.
for y := (y1 + 4) downto y1 do
begin
row := y*width;
for x := (x1 + 4) downto x1 do
begin
try
c := bmp.FData[row+x];
Result[0] := Result[0] + c.r;
Result[1] := Result[1] + c.g;
Result[2] := Result[2] + c.b;
except
WriteLn(Format('[SPS-Plugin] MakeColorBoxEx exception: %d,%d', [x,y]));
end;
end;
end;
end;

function SPS_BitmapToMap(bmp: TMufasaBitmap): T3DIntegerArray; register;
var
X, Y, HighX, HighY: integer;
begin
HighX := Trunc(bmp.Width / (5.0));
HighY := Trunc(bmp.Height / (5.0));

SetLength(Result, HighX);//moved outside to remove memory management iteration
for X := 0 to HighX-1 do
begin
SetLength(Result[X], HighY); // see above.
for Y := 0 to HighY-1 do
begin
Result[X][Y] := MakeColorBoxEx(bmp, X*5, Y*5);
end;
end;
end;

//
function SPS_FindMapInMapEx(out fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer; register;
var
x, y, HighX, HighY, cm, L: integer;
xx, yy: integer;
Matching, BestMatch: integer;
begin
fX := -1;
fY := -1;
BestMatch := 0;

L := Length(LargeMap);
Result := -1;

for cm := 0 to L-1 do
begin
HighX := High(LargeMap[cm]) - 19;
HighY := High(LargeMap[cm][0]) - 19;
for x := 0 to HighX do
for y := 0 to HighY do
begin
Matching := 0;
for xx := 0 to 19 do
for yy := 0 to 19 do
if SPS_ColorBoxesMatch(LargeMap[cm][x+xx][y+yy], SmallMap[xx][yy], tol) then
Inc(Matching);

if (Matching > BestMatch) then
begin
BestMatch := Matching;
Result := cm;
fX := x;
fY := y;
//WriteLn(Format('BM: %d Res: %d fx,fy: %d,%d',[bestMatch, cm, fX,fY]));
end;
end;
end;

if (Result > -1) then
begin
// moved outside to remove uncessary calculations in interations.
fX := fX*5 + 50; // cause we want the center
fy := fY*5 + 50;
end;
end;


////// TYPES //////////////////////////////////////////////////////////////////

function GetTypeCount(): Integer; stdcall; export;
begin
Result := 2;
end;

function GetTypeInfo(x: Integer; var sType, sTypeDef: string): integer; stdcall;
begin
case x of

0: begin
sType := 'T3DIntegerArray';
sTypeDef := 'Array of Array of Array of Integer;';
end;

1: begin
sType := 'T4DIntegerArray';
sTypeDef := 'Array of T3DIntegerArray;';
end;

else
Result := -1;
end;
end;




////// EXPORTING /////////////////////////////////////////////////////////////
function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 3;
end;

function GetFunctionCallingConv(x : Integer) : Integer; stdcall; export;
begin
Result := 0;
case x of
0..2 : Result := 1;
end;
end;

function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall; export;
begin
case x of
0:
begin
ProcAddr := @SPS_ColorBoxesMatch;
StrPCopy(ProcDef, 'function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean;');
end;
1:
begin
ProcAddr := @SPS_FindMapInMapEx;
StrPCopy(ProcDef, 'function SPS_FindMapInMapEx(out fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer;');
end;
2:
begin
ProcAddr := @SPS_BitmapToMap;
StrPCopy(ProcDef, 'function SPS_BitmapToMap(bmp: TMufasaBitmap): T3DIntegerArray;');
end;
else
x := -1;
end;
Result := x;
end;



exports GetTypeCount;
exports GetTypeInfo;
exports GetFunctionCount;
exports GetFunctionInfo;
exports GetFunctionCallingConv;

begin
end.

Could someone compile the new version? :)

lordsaturn
03-13-2011, 10:38 PM
Could someone compile the new version? :)

Here it is, stripped.

Zyt3x
03-14-2011, 12:18 AM
In "SPS_FindMapInMapEx", wouldn't it be good to break out of the loops when a result is set? "Result := cm;"

Nava2
03-14-2011, 05:23 AM
Updated for a *much* smaller project include.

Just replace the .dll and the .simba with these. As well, place the img folder in the SPS folder.

http://up.ht/fXUiAh

Coh3n
03-14-2011, 05:56 AM
Updated for a *much* smaller project include.

Just replace the .dll and the .simba with these. As well, place the img folder in the SPS folder.

http://up.ht/fXUiAh
Works perfectly for me, and yes it's 1000x smaller. :)

I added a SPS_Debug boolean variable so the scripter can choose to debug SPS. It will debug exceptions no matter what, however.

Everything you need can be downloaded here (http://uppit.com/dhg3h0q5bhi5/SPS-03-13-11.zip) (including what Nava posted above). I will update the first post.

E: Just got this on one of the two Simbas I tried to run.

[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation

I'm assuming that's the same thing that was talked about above, and it's what was happening to me when I first tested. Not sure why it only happens sometimes.

Nava2
03-14-2011, 06:05 AM
Works perfectly for me, and yes it's 1000x smaller. :)

I added a SPS_Debug boolean variable so the scripter can choose to debug SPS. It will debug exceptions no matter what, however.

Everything you need can be downloaded here (http://uppit.com/dhg3h0q5bhi5/SPS-03-13-11.zip) (including what Nava posted above). I will update the first post.

E: Just got this on one of the two Simbas I tried to run.

[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:58]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:00:59]: [ERROR] GATHERMINIMAP:: Exception: Access violation

I'm assuming that's the same thing that was talked about above, and it's what was happening to me when I first tested. Not sure why it only happens sometimes.

Could be windows because you are simultaneously trying to access the map?

Coh3n
03-14-2011, 06:07 AM
Could be windows because you are simultaneously trying to access the map?
I thought that at first also, but it's happened with only one Simba as well. Plus I would think it would just get loaded into memory for each Simba rather than loaded/unloaded, etc., etc.

E: Also just got it after a few loads on the Simba that worked.

Wizzup?
03-14-2011, 07:23 AM
Could be windows because you are simultaneously trying to access the map?

As far as I know you can read with as many processes as you like, unless you acquire a read lock, which isn't default.

SundayForever
03-16-2011, 02:51 AM
The map doesn't show from verock east bank to the wilderness, is this done on purpose or did something happen to me that stuffed the bmp?

Suggestion: It would be epic if the world map was cut into grid and labelled what grid was number.

Oh, and btw, this is awesome as it is and i cant wait to test it!

Coh3n
03-16-2011, 07:06 PM
The map doesn't show from verock east bank to the wilderness, is this done on purpose or did something happen to me that stuffed the bmp?

Suggestion: It would be epic if the world map was cut into grid and labelled what grid was number.

Oh, and btw, this is awesome as it is and i cant wait to test it!
As far as I know marpis didn't include the wilderness. And the map is already cut into a grid. 5_3, for example, is the 5th column, 3rd row.

Floor66
03-16-2011, 07:08 PM
The map doesn't show from verock east bank to the wilderness, is this done on purpose or did something happen to me that stuffed the bmp?

Suggestion: It would be epic if the world map was cut into grid and labelled what grid was number.

Oh, and btw, this is awesome as it is and i cant wait to test it!

That SundayForever guy is a spambot, Coh3n. He copied the above post >.>

Coh3n
03-16-2011, 07:20 PM
That SundayForever guy is a spambot, Coh3n. He copied the above post >.>
Oh wow, thanks.

Nava2
03-18-2011, 08:39 PM
Does this work with the lumbridge updates?

Coh3n
03-18-2011, 10:51 PM
Does this work with the lumbridge updates?
If you're talking about the swamp, I highly doubt it. Looks like it was a pretty drastic change.

marpis
03-19-2011, 09:53 PM
Ok so I have the new worldmap, but I've lost the MapMaker.simba.
That's bad.

Does anyone have any version of that saved?

Zyt3x
03-20-2011, 06:11 PM
Did you ever post it on the forum?

Coh3n
03-20-2011, 07:03 PM
I looked through this whole thread and couldn't find it. I do remember looking at it somewhere though.

LolL
03-20-2011, 07:42 PM
I just downloaded the latest upload and followed the instructions exactly.

Then I tried to make a walker from the VW bank to the V fountain:



program TestSPS;
{$i SRL/SRL.scar}
{$i SRL/SRL/core/SPS/SPS.simba}

var
TestPath : TPointArray;

begin
SetupSRL;
ActivateClient;
Sleep(RandomRange(1000, 2000));
(*
WriteLn(SPS_PixelToPoint(Point(367, 157)));
WriteLn(SPS_PixelToPoint(Point(394, 184)));
WriteLn(SPS_PixelToPoint(Point(411, 185)));
WriteLn(SPS_PixelToPoint(Point(447, 187)));
WriteLn(SPS_PixelToPoint(Point(481, 187)));
TerminateScript;
*)
SPS_Areas := ['10_3'];
TestPath := [Point(2184, 3735),
Point(2192, 3728),
Point(2196, 3728),
Point(2204, 3728),
Point(2214, 3728)];
if SPS_WalkPath(TestPath) then
begin
WriteLn('Walk was successful');
end
else
begin
WriteLn('Failed to walk');
end;
end.



[Hint] E:\Program Files\Simba\Includes\SRL/SRL/core/SPS/SPS.simba(115:3): Variable 'I' never used at line 114
[Hint] E:\Program Files\Simba\Includes\SRL/SRL/core/SRLlog.scar(17:3): Variable 'THEFILE' never used at line 16
Compiled succesfully in 562 ms.
SRL Compiled in 16 msec
[ERROR] GATHERMINIMAP:: Exception: Access violation
[ERROR] GATHERMINIMAP:: Exception: Access violation
[ERROR] GATHERMINIMAP:: Exception: Access violation
[ERROR] GATHERMINIMAP:: Exception: Access violation
[ERROR] GATHERMINIMAP:: Exception: Access violation
[ERROR] GATHERMINIMAP:: Exception: Access violation
[ERROR] GATHERMINIMAP:: Exception: Access violation
[ERROR] GATHERMINIMAP:: Exception: Access violation
[ERROR] GATHERMINIMAP:: Exception: Access violation


And it keeps printing that error...

Coh3n
03-25-2011, 04:09 PM
^ Where'd you get those coords in the Writeln's from? PixelToPoint I'm pretty sure converts coords from the entire world map to tiles.

Also, I ran MSI using this last night and everything worked well except I think there's still a memory leak somewhere. Memory jumped over 200k over night. No, I wasn't using MSI's form, and no it didn't increase this much when I used reflection walking. I could still be wrong, but just thought I'd post it anyway.

Bobzilla69
04-29-2011, 08:20 AM
Is this still functional?

i was thinking of using it was a backup to my new script :)

Edit:

It seems to be working, i did get a error about not being able to get MiniMap due to a access violation, but i simply restarted the script and it was fine :)

marpis
04-29-2011, 01:18 PM
Nice to hear it works :) Although that's not surprising.
I'm a bit sorry this hasn't gotten finishes. I have no time since I'm studying 10 hours a day, and in July I'm going to the army.

I guess I could write the MapMaker.simba again since it vanished somehow.
I'd love to see someone work on this and make it commitable.

Bobzilla69
04-29-2011, 01:42 PM
I hope someone will pick this up, i am currently implementing it into my script so i hope support will continue

Bobzilla69
04-30-2011, 09:36 AM
Small bug.

if you start half way thought a path it come up with following error



[SPS] Did not gather Minimap.
[ERROR] GATHERMINIMAP:: Exception: Access violation
[SPS] Did not gather Minimap.
[ERROR] GATHERMINIMAP:: Exception: Access violation
[SPS] Did not gather Minimap.
[ERROR] GATHERMINIMAP:: Exception: Access violation
[SPS] Did not gather Minimap.
[ERROR] GATHERMINIMAP:: Exception: Access violation
[SPS] Did not gather Minimap.
[ERROR] GATHERMINIMAP:: Exception: Access violation
[SPS] Did not gather Minimap.
[ERROR] GATHERMINIMAP:: Exception: Access violation
[SPS] Did not gather Minimap.
[ERROR] GATHERMINIMAP:: Exception: Access violation
[SPS] Did not gather Minimap.
[ERROR] GATHERMINIMAP:: Exception: Access violation
[SPS] Did not gather Minimap.


edit:

or not just got it after first point was walked to

Smidqe
04-30-2011, 10:31 AM
Nice to hear it works :) Although that's not surprising.
I'm a bit sorry this hasn't gotten finishes. I have no time since I'm studying 10 hours a day, and in July I'm going to the army.

I guess I could write the MapMaker.simba again since it vanished somehow.
I'd love to see someone work on this and make it commitable.

I found MapMaker.simba in my SPS folder. Now you don't need to create it from scratch. :)

Bobzilla69
04-30-2011, 04:11 PM
how do we go about getting the new updated world map?

i think thats whats throwing up the errors

edit: never mind got one :)

Damn wrong size :(

Coh3n
05-02-2011, 02:50 AM
@marpis, I think the only reason it hasn't been committed is because the images were too big to be included in SRL. Maybe an extension to download SPS would work?

Nava2
05-02-2011, 07:22 AM
@marpis, I think the only reason it hasn't been committed is because the images were too big to be included in SRL. Maybe an extension to download SPS would work?

Its not that large when you use compressed png images (which Simba supports) rather than bmp.

The issue iw that its a waste of resources to re-download these files when they *rarely* change. The best option ffrom my point of view is to use a separate updater for the map files and use the regular updater for the SPS.simba.

Coh3n
05-03-2011, 12:40 AM
Its not that large when you use compressed png images (which Simba supports) rather than bmp.

The issue iw that its a waste of resources to re-download these files when they *rarely* change. The best option ffrom my point of view is to use a separate updater for the map files and use the regular updater for the SPS.simba.
Oh I know it's a lot smaller, but IIRC it still doubles the total size of SRL, which like you said would waste resources. I agree about including SPS.simba and separately downloading the images.

Yago
05-03-2011, 01:37 AM
Oh I know it's a lot smaller, but IIRC it still doubles the total size of SRL, which like you said would waste resources. I agree about including SPS.simba and separately downloading the images.

Do you need the image to run SPS?

Smartzkid
05-03-2011, 01:47 AM
Do you need the image to run SPS?

Yes

Yago
05-03-2011, 01:50 AM
Yes

Nvm. Is there a way you can download it and then delete it?

I downloaded a bmp for one of my scripts then checked if it existed.

sm0k3
05-03-2011, 03:54 PM
well if its any help .
if anyone here knows php well enough and can write a script,
to pull the world map from where ever and split it to the write sizes 500x500 i think? (image magic should work for this?)
i will then setup a cronjob to fech and split every night (even smallest of map changes will allways be included then)
then i can honestly say that i will make sure there is allways the most recent map and tiles availible .
also i can setup my server to allow which ever way you think would be fastest to disribute . and you wont have to worry about any restictions ie bandwidth uptime or filesizes .

this is somthing i would like to do if no one is doing this allready

( i could do it in bash or ruby i guess though but i dont think it would be as efficiant )

Coh3n
05-25-2011, 07:33 PM
A little advancement on the Access Violation error. SPS was working great for the longest time. Just recently I started getting the error again after 5-10 minutes of run time. When I stopped the script, it highlighted this line in SPS_GatherBitmap:

Result := SPS_BitmapToMap(bmp);
It would be nice to get to the bottom of this. :o

the smith400
05-28-2011, 01:05 PM
[Error] (42:34): Unknown identifier 'MMCX' at line 41
Compiling failed.


Uncool... Anyway, this somehow just occurred, and now I cant test the Varrock East Bank thing and my msi script won't run because it says reflection is broken/not selected, download SPS from srl forums.

Zyt3x
05-28-2011, 01:10 PM
The constant MMCX is in SRL. Re-download SRL and you should be fine :)

the smith400
05-28-2011, 01:15 PM
Hmm, should i Re-download the whole SRL folder in Simba/Includes or just the SRL.SCAR file?

Honestly, i've never understood how srl works, for 4 years now. Could you explain to me what exactly i have re-download and how so i don't waste my time

masterBB
05-28-2011, 01:41 PM
The whole folder.

the smith400
05-28-2011, 01:43 PM
sweet, sweet. How can I manually redownload it? I tried deleting that folder and redownloading(updating) it through simba but it didnt work.

EDIT: Just removed and reinstalled simba. Same problem, plus when running this

program new;
{$i srl/srl/misc/smart.scar}
{$i srl/srl.scar}
{$i reflection/reflection.simba}

begin
SetupSRL;
SetupReflectionEx***40;False***41;;
end.


i get this


[Error] (43:34): Unknown identifier 'MMCX' at line 42
Compiling failed.


Just made stuff worse.

Coh3n
05-28-2011, 06:38 PM
Replace ***40 with ( and ***41 with ); although, I don't see why that you cause you to get that error.

i luffs yeww
05-28-2011, 07:16 PM
He's including things in the wrong order, isn't he? Shouldn't it be SRL, SMART, then reflection?

Nava2
05-28-2011, 07:46 PM
He's including things in the wrong order, isn't he? Shouldn't it be SRL, SMART, then reflection?

Smart, SRL, Reflection ;)

the smith400
05-29-2011, 01:02 PM
still failed. i give up

Coh3n
05-29-2011, 08:03 PM
still failed. i give upDo you have and SRL and Reflection folder in Simba/Includes/?

Frement
05-29-2011, 08:37 PM
well if its any help .
if anyone here knows php well enough and can write a script,
to pull the world map from where ever and split it to the write sizes 500x500 i think? (image magic should work for this?)
i will then setup a cronjob to fech and split every night (even smallest of map changes will allways be included then)
then i can honestly say that i will make sure there is allways the most recent map and tiles availible .
also i can setup my server to allow which ever way you think would be fastest to disribute . and you wont have to worry about any restictions ie bandwidth uptime or filesizes .

this is somthing i would like to do if no one is doing this allready

( i could do it in bash or ruby i guess though but i dont think it would be as efficiant )

Is there any progress on this? I think I still have some PNG <-> BMP conversion functions somewhere for PHP. I could give a hand when I get free time, sm0k3 we can discuss this on MSN when you get time and I'm online?

Nava2
05-29-2011, 08:57 PM
Do you have and SRL and Reflection folder in Simba/Includes/?

What? I'm not having issues lol

Coh3n
05-29-2011, 09:26 PM
What? I'm not having issues lolWoops, quoted the wrong person. Fixed.

the smith400
05-30-2011, 01:48 AM
Do you have and SRL and Reflection folder in Simba/Includes/?

yeah i do, i also thought since the srl scripts run with scar that id also download scar. but the same problem occurs. The thing is, I may have not properly downloaded scar, do I need scar downloaded properly with all the attachments?

Coh3n
05-30-2011, 11:19 AM
yeah i do, i also thought since the srl scripts run with scar that id also download scar. but the same problem occurs. The thing is, I may have not properly downloaded scar, do I need scar downloaded properly with all the attachments?Sorry, I have no idea how to download and setup SCAR properly. Did you try restarting Simba?

mat_de_b
05-30-2011, 03:15 PM
I'm getting

'[ERROR] GATHERMINIMAP:: Exception: Access violation'

That error just spams the debug.

I only happens on 1 of 4 points though. I walk from the bank to an area( which takes two points) , do my task and walk one point back (1 of two points overall), and then it starts giving me this error.

Yago
05-30-2011, 03:37 PM
Yes, I think Marpis has been busy lately an unable to fix certain errors. There are countless errors I get when running this.

the smith400
05-30-2011, 03:49 PM
Sorry, I have no idea how to download and setup SCAR properly. Did you try restarting Simba?

restart simba? 4 times. repeating your steps exactly. You could delete that thread and I'd be able to recreate the same tutorial, word for word. It's really irritating knowing that it CAN be fixed and I am so close to doing so, yet everytime I fail, I feel as though it's just impossible.

mat_de_b
05-30-2011, 04:26 PM
To reinstall scar just redownload the installer? Delete all of the files apart from the includes and scripts. Then re install it and move all of the files back in. that will get rid of all errors not to do with SRL/SPS/Reflection or script problems.

Nava2
05-30-2011, 07:35 PM
To reinstall scar just redownload the installer? Delete all of the files apart from the includes and scripts. Then re install it and move all of the files back in. that will get rid of all errors not to do with SRL/SPS/Reflection or script problems.

This was written for Simba and requires parts of the MML as well. Thus, it will NOT work in SCAR.

Coh3n
05-30-2011, 08:03 PM
I'm getting

'[ERROR] GATHERMINIMAP:: Exception: Access violation'

That error just spams the debug.

I only happens on 1 of 4 points though. I walk from the bank to an area( which takes two points) , do my task and walk one point back (1 of two points overall), and then it starts giving me this error.I get this also... sometimes. Ever since SPS was released I've gotten it. No one has figured out why it happens.


Yes, I think Marpis has been busy lately an unable to fix certain errors. There are countless errors I get when running this.What other errors do you have?


restart simba? 4 times. repeating your steps exactly. You could delete that thread and I'd be able to recreate the same tutorial, word for word. It's really irritating knowing that it CAN be fixed and I am so close to doing so, yet everytime I fail, I feel as though it's just impossible.I honestly don't know what to tell you. You aren't the only one who'd been getting weird compiling errors though. I honestly don't understand why. I suggest creating a detailed (as much as possible) thread here (http://villavu.com/forum/forumdisplay.php?f=305), and hopefully we can figure things out.

Yago
05-30-2011, 10:17 PM
What other errors do you have?


I haven't used it in a while, but I think I would get errors like out of range or something. I gave up on it about a month ago though lol.

mat_de_b
05-30-2011, 11:53 PM
This was written for Simba and requires parts of the MML as well. Thus, it will NOT work in SCAR.

Is it not the same scenario with Simba though? Download the installer and move the include/script folders over?

Coh3n
05-31-2011, 02:38 AM
Is it not the same scenario with Simba though? Download the installer and move the include/script folders over?
Similar yes, but they're different programs. He's saying that SPS uses functions that are in Simba, but not in SCAR.

Nava2
05-31-2011, 03:29 AM
Similar yes, but they're different programs. He's saying that SPS uses functions that are in Simba, but not in SCAR.

Actually it uses the Mufasa Macroing Library which is in Simba and Simba reads the plugin in a way that SCAR can't as of yet ;).

Anyway.. off topic kinda.

Wolygon
06-13-2011, 09:39 PM
I have created a Path Creator for SPS however it does not yet generate the SPS_Areas.

Check it out:
http://villavu.com/forum/showthread.php?p=812007#post812007

Coh3n
06-28-2011, 12:09 PM
I just tried to run MSI using SPS and it seems that the tile to point conversion is off quite a bit. Anyone else experience this? I'll try to fix it later if no one else checks it out.

I've added sps.simba to SRL so the most updated version will always be there.

Carlito
07-12-2011, 09:08 AM
Not sure what im doing wrong, but i followed how to extract it but it seems not to be working.

Im running MSI (EV yews) - Color selected for walking

Setting up MSI took 577 ms.
SRL Compiled in 16 msec
SMART Initialized.
Loaded: Server 152, Members: False, Signed: True, Super Detail: False.
[0:01:08]: [ Mr Juji ] ---- Player's SPS_Areas: ['9_2']
[0:01:08]: [ Mr Juji ] -- MSI_SetupPlayer
[0:01:08]: [ Mr Juji ] ---- Player is not logged in
[0:01:27]: Welcome to Runescape.
[0:01:28]: Mr Juji
[0:01:43]: Failed to find World 109!
[0:01:55]: [ Mr Juji ] ------ Scanning for randoms...
[0:01:57]: [ Mr Juji ] ---- MSI_SetPlayerLoc
[0:01:57]: [ Mr Juji ] ------ MSI_AtLocation
[0:01:57]: [ Mr Juji ] -------- Checking Point: (3998, 1124)
[0:01:58]: [ Mr Juji ] ---------- MSI_PointOnMM(3998, 1124): True
[0:01:58]: [ Mr Juji ] -------- Distance from player to Edgeville bank: 16
[0:01:58]: [ Mr Juji ] -------- Player is at Edgeville bank
[0:01:58]: [ Mr Juji ] ------ MSI_AtLocation: True
[0:01:58]: [ Mr Juji ] ------ Player's location: Edgeville bank
[0:01:58]: [ Mr Juji ] ---- MSI_SetPlayerLoc: True
[0:01:58]: [ Mr Juji ] ---- MSI_SetSkillLevels
[0:01:58]: [ Mr Juji ] ------ [HOOKED] CharacterStats_FunctionCall: CharacterStats
[0:01:58]: [ Mr Juji ] ---------- Bobzilla_GetData: Getting skill levels
[0:01:59]: [ Mr Juji ] ---------- Player Found in XML, Updating
[0:01:59]: [ Mr Juji ] ------ [HOOKED] CharacterStats_FunctionCall: CharacterStats: 1
[0:01:59]: [ Mr Juji ] ------ Woodcutting Level: 85
[0:01:59]: [ Mr Juji ] ---- MSI_SetSkillLevels: Finished
[0:01:59]: [ Mr Juji ] ---- MSI_SetupWC/Mining
[0:01:59]: [ Mr Juji ] ------ Best tool for Woodcutting is Dragon Hatchet
[0:02:00]: [ Mr Juji ] ------ MSI_FindTool
[0:02:00]: [ Mr Juji ] -------- Searching Equipment tab
[0:02:00]: [ Mr Juji ] -------- Failed to find DTM of Dragon Hatchet
[0:02:00]: [ Mr Juji ] ------ MSI_FindTool: False
[0:02:00]: [ Mr Juji ] ------ MSI_FindTool
[0:02:00]: [ Mr Juji ] -------- Searching Equipment tab
[0:02:00]: [ Mr Juji ] -------- Found DTM of Rune Hatchet
[0:02:00]: [ Mr Juji ] ------ MSI_FindTool: True
[0:02:00]: [ Mr Juji ] ---- MSI_SetupWC/Mining: True
[0:02:00]: [ Mr Juji ] -- MSI_SetupPlayer: True
[0:02:00]: [ Mr Juji ] -- MSI_AtLocation
[0:02:00]: [ Mr Juji ] ---- Checking Point: (3974, 1208)
[0:02:01]: [ Mr Juji ] ------ MSI_PointOnMM(3974, 1208): False
[0:02:01]: [ Mr Juji ] ---- Checking Point: (3974, 1180)
[0:02:02]: [ Mr Juji ] ------ MSI_PointOnMM(3974, 1180): True
[0:02:02]: [ Mr Juji ] ---- Distance from player to Edgeville yews: 48
[0:02:02]: [ Mr Juji ] ---- Player not at Edgeville yews
[0:02:02]: [ Mr Juji ] -- MSI_AtLocation: False
[0:02:03]: [ Mr Juji ] -- MSI_Walk
[0:02:03]: [ Mr Juji ] ------ Current Energy: 100
[0:02:03]: [ Mr Juji ] ---- Player's Location = Edgeville bank
[0:02:03]: [ Mr Juji ] ---- MSI_AtLocation
[0:02:03]: [ Mr Juji ] ------ Checking Point: (3974, 1208)
[0:02:03]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:02:03]: [ Mr Juji ] -------- MSI_PointOnMM(3974, 1208): False
[0:02:03]: [ Mr Juji ] ------ Checking Point: (3974, 1180)
[0:02:03]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:02:03]: [ Mr Juji ] -------- MSI_PointOnMM(3974, 1180): False
[0:02:03]: [ Mr Juji ] ------ Player not at Edgeville yews
[0:02:03]: [ Mr Juji ] ---- MSI_AtLocation: False
[0:02:03]: [ Mr Juji ] ------ Scanning for randoms...
[0:02:03]: [ Mr Juji ] ---- MSI_WalkPath
[0:02:03]: [ Mr Juji ] -------- Loaded Path (Color): [[(3998, 1128), (3998, 1184), (3974, 1208)]]
[0:02:03]: [ERROR] GATHERMINIMAP:: Exception: Access violation
[0:02:03]: [ERROR] GATHERMINIMAP:: Exception: Access violation

Coh3n
07-12-2011, 10:08 AM
You aren't doing anything wrong. This has been reported multiple times and no one is able to find out why it happens. It happens sometimes for me as well. Other times it works fine. Usually when I restart Simba a couple times it'll start working. It's unfortunate, I know, but seems to be the only solution right now.

Carlito
07-13-2011, 06:49 AM
You aren't doing anything wrong. This has been reported multiple times and no one is able to find out why it happens. It happens sometimes for me as well. Other times it works fine. Usually when I restart Simba a couple times it'll start working. It's unfortunate, I know, but seems to be the only solution right now.

Dang, truly is unfortunate but im sure there will be a way to get it working.

Good luck :D

masterBB
07-22-2011, 08:42 PM
Is this open source? If so, where can I find the source?

Coh3n
07-23-2011, 01:00 AM
Is this open source? If so, where can I find the source?It is. If the source isn't with the original download, you may have to ask marpis. I think Nava2 may have a copy also.

Dgby714
07-23-2011, 01:03 AM
It is. If the source isn't with the original download, you may have to ask marpis. I think Nava2 may have a copy also.

I have an older version of the source, maybe, I'd have to find it.

Coh3n
07-23-2011, 01:08 AM
I have an older version of the source, maybe, I'd have to find it.
The speed difference between Nava's and Marpis' versions is like 2 or 3 seconds. If you have Nava's then great, otherwise there may be a big difference.

Nava2
07-23-2011, 01:13 AM
Quick check for it: Does it use TMufasaBitmaps instead of Bitmaps? :D

Anyway.. glad this is working, but for that issue I'm curious if breakpoints could help.

Coh3n
07-23-2011, 01:18 AM
Quick check for it: Does it use TMufasaBitmaps instead of Bitmaps? :D

Anyway.. glad this is working, but for that issue I'm curious if breakpoints could help.Um, SPS_WorldMap is declared as a T4DIntegerArray, and SPS_GatherMinimap uses TMufasaBitmaps.

I forget who it was, but they said running Simba as Admin got rid of the error (on Vista).

Dgby714
07-23-2011, 01:30 AM
O I have an old version of Marpis. It was before he released it, was helping with something.

Coh3n
07-28-2011, 11:45 PM
Yeah I`m sure that versions very outdated. :(

E: Got a reply from marpis. :) What he did was login to RS in full screen mode and took screenshots of the map at 100% zoom, then cropped them all together. He said it didn't take longer than a couple hours. A script could probably be made to do this too if someone was interested.

Smidqe
07-30-2011, 11:56 AM
E: Got a reply from marpis. :) What he did was login to RS in full screen mode and took screenshots of the map at 100% zoom, then cropped them all together. He said it didn't take longer than a couple hours. A script could probably be made to do this too if someone was interested.

No need for any script(altought it would be a great, since you can do it by hand), since I cropped it to a single .png file this morning. BMP file would've been way too big, ~125 Mb, Hopefully the map works(Might need new offsets):

Here's the link for full ingame worldmap:
http://uppit.com/je0yy68wbwqs/Worldmap_30-July-2011.rar

I've build the bitmaps but I still need to convert them to .png form since they are currently .bmp. I'll convert them today(probably).

Geo
07-30-2011, 12:35 PM
Yeah I`m sure that versions very outdated. :(

E: Got a reply from marpis. :) What he did was login to RS in full screen mode and took screenshots of the map at 100% zoom, then cropped them all together. He said it didn't take longer than a couple hours. A script could probably be made to do this too if someone was interested.

I created the script last night. Works as far as I know also crops the images so the 'X' button is removed and saves them to a folder in the Simba directory.

Also, it has a 89px overlap so it'll make up for cropping out the 'X' button.

This works with the fixed client.

EDIT: make sure SPS_IMG_PATH and SPS_CROPIMG_PATH are correct or it'll throw an out of range error.

EDIT2: Put it through a full run and it worked like expected. I'll be running it again as I messed up on the directories and it saved the images wrong. :o

EDIT3: Ok, I got everything cropped. Used Irfan Viewer to batch convert all the .BMPs to .PNGs as I didn't feel like doing them by hand and this is what they look like. http://fimbored.com/SPS/PNG_Cropped.zip

Smidqe's WorldMap put through the mapmaker: http://fimbored.com/SPS/PNG.zip

Smidqe, Nice work on the worldmap.

Smidqe
07-30-2011, 01:27 PM
Thanks :)

It's quite tedious task when done by hand. Especially when you have to convert over 200 bmp to .png. :p

E:
Done.

Here's the link.
http://uppit.com/fds45085m1oz/SPS-7-30-11.rar

WARNING:
Offsets need a quite a bit tweak.

E2: Nice job Geo, you got ahead of me :p

Nava2
07-30-2011, 03:54 PM
Uhm, whoever did that conversion by hand. You silly!

Just use imagemagick and a simple Bash script. :P

Coh3n
07-30-2011, 04:18 PM
Nice job, guys. That's great there's a script to do it now, will make future updates much easier. Theoretically, the script should work for dungeon maps as well, correct? I'll probably start a new github project for this so we can start thinking about dungeon support (any ideas are welcome). In the meantime we need some testing done + I'm sure with new map pieces, the SPS_Areas will be broken for every script.

Smidqe
07-30-2011, 04:19 PM
Uhm, whoever did that conversion by hand. You silly!

Just use imagemagick and a simple Bash script. :P

Nah, it's much more rewarding when done with the hard way(Paint) :p

Imagemagick? Never heard of that program, I'll have to take a look.

E:
Nice job, guys. That's great there's a script to do it now, will make future updates much easier. Theoretically, the script should work for dungeon maps as well, correct? I'll probably start a new github project for this so we can start thinking about dungeon support (any ideas are welcome). In the meantime we need some testing done + I'm sure with new map pieces, the SPS_Areas will be broken for every script.

I did a test with SPS on MSI, especially LSW got much better(it walked all the way), of course offsets are way off now but it worked better than before I updated SPS areas but I still need test much more, I used these offsets(Not the most accurate):

SPS_OFFSET_X = 2044.0;
SPS_OFFSET_Y = 4162.0;
As for future updates, it's not that hard to gather maps from ingame and merge them into one huge worldmap, of course script is easier.

E2: Dungeons? It sounds like an awesome idea :)

Yago
07-30-2011, 08:35 PM
It would be nice if somone could also update the png for sumilions pathmaker or ehaterever its called

Nava2
07-31-2011, 01:36 AM
http://www.imagemagick.org/script/index.php

I should write a quick script up to do this.. it was not hard when I wrote it the first time.

Coh3n
07-31-2011, 03:44 PM
http://www.imagemagick.org/script/index.php

I should write a quick script up to do this.. it was not hard when I wrote it the first time.A script to convert or make the map? If for the map it would have be nice if you mentioned that earlier...

Coh3n
08-02-2011, 09:14 PM
Smidge, I don't have time to figure it out now and there's like 8 links in the last few posts. Can you post the link to the entire world map, the pieces you used, and the mapmaker.simba script, please? I'm going to start a github repository for this, get it all fixed up, make a new thread, then we can start planning dungeon support.

Also, if there was a script to generate the entire world map, post that as well (plus who wrote it). I want to include everything in the repo.

Smidqe
08-03-2011, 07:46 AM
Smidge, I don't have time to figure it out now and there's like 8 links in the last few posts. Can you post the link to the entire world map, the pieces you used, and the mapmaker.simba script, please? I'm going to start a github repository for this, get it all fixed up, make a new thread, then we can start planning dungeon support.

Also, if there was a script to generate the entire world map, post that as well (plus who wrote it). I want to include everything in the repo.

Sure. :)

Here's the entire worldmap and the pieces (1_2, 1_3 and so on)
http://uppit.com/fds45085m1oz/SPS-7-30-11.rar

As for the script, Geo did one in post #217. Unfortunately it doesn't create the whole worldmap, since it crops and saves only the areas.

Mapmaker is attached to this post (SPS.simba is not included since there's no changes). Saving directly to .png format wasn't working for me so it saves them to .bmp first and then I have to manually set them to .png otherwise many of them would be corrupt.

Nava2
08-04-2011, 04:49 AM
I think TMufasaBitmaps support saving to png, btw.

Coh3n
08-04-2011, 04:53 AM
Sure. :)

Here's the entire worldmap and the pieces (1_2, 1_3 and so on)
http://uppit.com/fds45085m1oz/SPS-7-30-11.rar

As for the script, Geo did one in post #217. Unfortunately it doesn't create the whole worldmap, since it crops and saves only the areas.

Mapmaker is attached to this post (SPS.simba is not included since there's no changes). Saving directly to .png format wasn't working for me so it saves them to .bmp first and then I have to manually set them to .png otherwise many of them would be corrupt.Thanks! I should be able to make the repository tomorrow. :)

E: Okay, I've made the repository, but haven't yet added the map pieces. You can check it out here (https://github.com/Coh3n/SPS).

@Smidge: Did you make the world map by hand?

@Geo: The script you wrote that creates the map: does it just create the map pieces, and not the entire world map? If so, maybe you can alter it so it adds to a bitmap and the result is the entire map? That would make it extremely easy to add all the dungeons. We'd just have to run mapmaker.simba on each dungeon's map. I'm pretty sure SPS uses the world map as well as the pieces to locate the player, so we'll always need an entire map.

Another thing I was thinking. Mapmaker.simba should be edited to work with any map size. Right now it loops through 17 times horizontally, and 15 times vertically. Those numbers should be determined by the size of the map. Should be able to do some simple math after getting the width and height of the entire map. Probably just divide by how big the pieces are (I think 500x500?).

I'm also thinking, we could probably delete all the images that are completely black, white, or water since they'll never be used and are just taking up space. That would also make it so the dungeon maps will probably have less than 10 pieces.


I think TMufasaBitmaps support saving to png, btw.mapmaker.simba should be edited to use TMufasaBitmaps anyway. Currently it just uses loadBitmap. Correct me if I'm wrong, but wouldn't TMufasaBitmaps speed things up a little?

Smidqe
08-04-2011, 09:14 AM
@Coh3n

Yes. I did the whole worldmap by hand. Wasn't that hard to do it.

As for the black pieces, I wasn't sure if it would affect the SPS. So I kept them, just in case.

And you can edit the mapmaker to work with any size. Just change x and y values on slicebitmap(or something like that). Can't remember which lines they were, because i can't access my computer right now. It's just horrible to write with phone. :p

E: Lines 36-37 is what you want to change. Just remember to round the number to one larger, so that it doesn't miss anything. If the number is too large it'll give an error. Too small and you'll have only a part of a map covered.
for x:=0 to (any number) do
for y:= to (any number) do

Coh3n
08-04-2011, 07:13 PM
@Coh3n

Yes. I did the whole worldmap by hand. Wasn't that hard to do it.
I was afraid of that. Would be a real pain to do the same thing for every dungeon map that's included in the game map viewer.



As for the black pieces, I wasn't sure if it would affect the SPS. So I kept them, just in case.I'm not sure either, but I can't think of why it would matter. We'll just have to try it out and see.



And you can edit the mapmaker to work with any size. Just change x and y values on slicebitmap(or something like that). Can't remember which lines they were, because i can't access my computer right now. It's just horrible to write with phone. :p

E: Lines 36-37 is what you want to change. Just remember to round the number to one larger, so that it doesn't miss anything. If the number is too large it'll give an error. Too small and you'll have only a part of a map covered.
for x:=0 to (any number) do
for y:= to (any number) do Yeah I was thinking of having something like:

highX := round(bmp.width / pieceWidth);
highY := round(bmp.height / pieceHeight);
I'm just not exactly sure how to get the w/h of the bitmap yet. I think it's fairly simple if we switch to using TMufasaBitmaps.

Zyt3x
08-04-2011, 10:49 PM
Not sure if it's useful but here's some maps:

http://runescape.wikia.com/wiki/File:RuneScape_Worldmap.png (http://images1.wikia.nocookie.net/__cb20110515082958/runescape/images/1/10/RuneScape_Worldmap.png)

Coh3n
08-04-2011, 11:45 PM
Not sure if it's useful but here's some maps:

http://runescape.wikia.com/wiki/File:RuneScape_Worldmap.png (http://images1.wikia.nocookie.net/__cb20110515082958/runescape/images/1/10/RuneScape_Worldmap.png)Yeah I looked at those originally, but we need the map at 100% zoom without text. Exactly like this (http://i53.tinypic.com/24oat1z.png) one (Smidqe made it by hand). We need that done for every dungeon map that can be shown in the in-game map (or at least the ones that will be used right away).

Geo
08-06-2011, 08:59 AM
Sorry I haven't replied in a couple days. I've been busy working...

The script I made only makes pieces of the worldmap. It still needs to be manually put together like a jigsaw puzzle. I'm not exactly sure how I would go about putting together the pieces into the whole worldmap using pascal.

As for the mapmaker.simba the x and y vars in the loop of the Procedure SliceMap would be width divide 500 and y should be the height divide 500. both rounded up by one.

Also, I agree on deleting the map pieces that won't be used.

Coh3n
08-06-2011, 09:27 PM
Sorry I haven't replied in a couple days. I've been busy working...

The script I made only makes pieces of the worldmap. It still needs to be manually put together like a jigsaw puzzle. I'm not exactly sure how I would go about putting together the pieces into the whole worldmap using pascal.Well it should be simple:

repeat
stuffThatCreatesPiece;
addPiece(newlyCreatedPiece, x * 500, y * 500);
until(entireMapCreated);
Basically, as you create each piece, increase the width or height of "entireMap" by 500, then draw the piece on the bitmap. I'm no expert on bitmaps, so you may have to ask for help on exactly HOW to do it. :p


Also, I agree on deleting the map pieces that won't be used.Yeah, I see no reason why it wouldn't work, but I'll be testing it out regardless. Unless someone else can in the meantime.

E: Since I'm changing the structure of SPS to be more organized for dungeons, I need the source for sps.dll (I would like the source regardless, to include in the repository), so if anyone has it, please post here. I'm PM'ing marpis in the meantime to see if he has it.

E2: I've committed the new surface map pieces and removed the useless pieces, which turned out to be 74 in total. :eek: I just need the source for sps.simba so I can edit the new system and then create a new thread.

Nava2
08-08-2011, 02:09 AM
$ stat ./sps.lpr
File: `./sps.lpr'
Size: 4945 Blocks: 16 IO Block: 4096 regular file
Device: 805h/2053d Inode: 918771 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 500/ kevin) Gid: ( 500/ kevin)
Access: 2011-08-07 22:08:00.848907290 -0400
Modify: 2011-02-22 16:05:49.806211999 -0500
Change: 2011-05-19 18:18:19.749187082 -0400
Birth: -


library sps;

{$mode objfpc}{$H+}

uses
Classes, sysutils, Graphics, FileUtil, bitmaps;

type
TIntegerArray = Array of Integer;
T3DIntegerArray = Array of Array of Array of Integer;
T4DIntegerArray = Array of Array of Array of Array of Integer;


function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean; register;
begin
Result := False;
if (B1[0] >= Round(B2[0]*(1-tol))) and (B1[0] <= Round(B2[0]*(1+tol))) and
(B1[1] >= Round(B2[1]*(1-tol))) and (B1[1] <= Round(B2[1]*(1+tol))) and
(B1[2] >= Round(B2[2]*(1-tol))) and (B1[2] <= Round(B2[2]*(1+tol))) then
begin
Result := True;
end;
end;

procedure ColorToRGB(Color: Integer; out r, g, b: Integer); inline; // inline for optimization.
begin
r := (Color) and 255;
g := (Color shr 8) and 255;
b := (Color shr 16) and 255;
end;

function SPS_MakeColorBoxEx(bmp: TMufasaBitmap; x1, y1: integer): TIntegerArray;
//[0]=Red [1]=Green [2]=Blue
var
x, y, width: integer;
C: TColor;
R, G, B: integer;
begin
SetLength(Result, 3);
width := bmp.Width; // may not be necessary, but should help a bit.

for x := (x1 + 4) downto x1 do // flipped these to downto since order is irrelevant
for y := (y1 + 4) downto y1 do // downto will calc the initial only once rather than each time.
begin
try
C := bmp.FData[y*width + x]; // much faster than calling getPixel[x,y]
ColorToRGB(C, R, G, B);
Result[0] := Result[0] + R;
Result[1] := Result[1] + G;
Result[2] := Result[2] + B;
except
//writeln('ColorToRGB exception: '+inttostr(x)+', '+inttostr(y));
end;
end;
end;

function SPS_BitmapToMap(bmp: TMufasaBitmap): T3DIntegerArray; register;
var
X, Y, HighX, HighY: integer;
begin
HighX := Trunc(bmp.Width / (5.0));
HighY := Trunc(bmp.Height / (5.0));

SetLength(Result, HighX);//moved outside to remove memory management iteration
for X := 0 to HighX-1 do
begin
SetLength(Result[X], HighY); // see above.
for Y := 0 to HighY-1 do
begin
Result[X][Y] := SPS_MakeColorBoxEx(bmp, X*5, Y*5);
end;
end;
end;

//
function SPS_FindMapInMapEx(out fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer; register;
var
x, y, HighX, HighY, cm, L: integer;
xx, yy: integer;
Matching, BestMatch: integer;
begin
fX := -1;
fY := -1;
BestMatch := 0;

L := Length(LargeMap);
Result := -1;

for cm := 0 to L-1 do
begin
HighX := High(LargeMap[cm]) - 19;
HighY := High(LargeMap[cm][0]) - 19;
for x := 0 to HighX do
for y := 0 to HighY do
begin
Matching := 0;
for xx := 0 to 19 do
for yy := 0 to 19 do
if SPS_ColorBoxesMatch(LargeMap[cm][x+xx][y+yy], SmallMap[xx][yy], tol) then
Inc(Matching);

if (Matching > BestMatch) then
begin
BestMatch := Matching;
Result := cm;
fX := x;
fY := y;
end;
end;
end;

if (Result > -1) then
begin
// moved outside to remove uncessary calculations in interations.
fX := fX*5 + 50; // cause we want the center
fy := fY*5 + 50;
end;
end;


////// TYPES //////////////////////////////////////////////////////////////////

function GetTypeCount(): Integer; stdcall; export;
begin
Result := 2;
end;

function GetTypeInfo(x: Integer; var sType, sTypeDef: string): integer; stdcall;
begin
case x of

0: begin
sType := 'T3DIntegerArray';
sTypeDef := 'Array of Array of Array of Integer;';
end;

1: begin
sType := 'T4DIntegerArray';
sTypeDef := 'Array of T3DIntegerArray;';
end;

else
Result := -1;
end;
end;




////// EXPORTING /////////////////////////////////////////////////////////////
function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 3;
end;

function GetFunctionCallingConv(x : Integer) : Integer; stdcall; export;
begin
Result := 0;
case x of
0..2 : Result := 1;
end;
end;

function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall; export;
begin
case x of
0:
begin
ProcAddr := @SPS_ColorBoxesMatch;
StrPCopy(ProcDef, 'function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean;');
end;
1:
begin
ProcAddr := @SPS_FindMapInMapEx;
StrPCopy(ProcDef, 'function SPS_FindMapInMapEx(var fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer;');
end;
2:
begin
ProcAddr := @SPS_BitmapToMap;
StrPCopy(ProcDef, 'function SPS_BitmapToMap(bmp: TMufasaBitmap): T3DIntegerArray;');
end;
else
x := -1;
end;
Result := x;
end;



exports GetTypeCount;
exports GetTypeInfo;
exports GetFunctionCount;
exports GetFunctionInfo;
exports GetFunctionCallingConv;

begin
end.


I thiiink thats the newest one.

E: Also have this:

library sps;

{$mode objfpc}{$H+}

uses
Classes, sysutils, Graphics, FileUtil, bitmaps;

type
TIntegerArray = Array of Integer;
T3DIntegerArray = Array of Array of Array of Integer;
T4DIntegerArray = Array of Array of Array of Array of Integer;


function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean; register;
begin
Result := False;
if (B1[0] >= Round(B2[0]*(1-tol))) and (B1[0] <= Round(B2[0]*(1+tol))) and
(B1[1] >= Round(B2[1]*(1-tol))) and (B1[1] <= Round(B2[1]*(1+tol))) and
(B1[2] >= Round(B2[2]*(1-tol))) and (B1[2] <= Round(B2[2]*(1+tol))) then
begin
Result := True;
end;
end;

procedure ColorToRGB(Color: Integer; out r, g, b: Integer); inline; // inline for optimization.
begin
r := (Color) and 255;
g := (Color shr 8) and 255;
b := (Color shr 16) and 255;
end;

function SPS_MakeColorBoxEx(bmp: TMufasaBitmap; x1, y1: integer): TIntegerArray;
//[0]=Red [1]=Green [2]=Blue
var
x, y, width: integer;
C: TColor;
R, G, B: integer;
begin
SetLength(Result, 3);
width := bmp.Width; // may not be necessary, but should help a bit.

for x := (x1 + 4) downto x1 do // flipped these to downto since order is irrelevant
for y := (y1 + 4) downto y1 do // downto will calc the initial only once rather than each time.
begin
try
C := bmp.FData[y*width + x]; // much faster than calling getPixel[x,y]
ColorToRGB(C, R, G, B);
Result[0] := Result[0] + R;
Result[1] := Result[1] + G;
Result[2] := Result[2] + B;
except
//writeln('ColorToRGB exception: '+inttostr(x)+', '+inttostr(y));
end;
end;
end;

function SPS_BitmapToMap(bmp: TMufasaBitmap): T3DIntegerArray; register;
var
X, Y, HighX, HighY: integer;
begin
HighX := Trunc(bmp.Width / (5.0));
HighY := Trunc(bmp.Height / (5.0));

SetLength(Result, HighX);//moved outside to remove memory management iteration
for X := 0 to HighX-1 do
begin
SetLength(Result[X], HighY); // see above.
for Y := 0 to HighY-1 do
begin
Result[X][Y] := SPS_MakeColorBoxEx(bmp, X*5, Y*5);
end;
end;
end;

//
function SPS_FindMapInMapEx(out fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer; register;
var
x, y, HighX, HighY, cm, L: integer;
xx, yy: integer;
Matching, BestMatch: integer;
begin
fX := -1;
fY := -1;
BestMatch := 0;

L := Length(LargeMap);
Result := -1;

for cm := 0 to L-1 do
begin
HighX := High(LargeMap[cm]) - 19;
HighY := High(LargeMap[cm][0]) - 19;
for x := 0 to HighX do
for y := 0 to HighY do
begin
Matching := 0;
for xx := 0 to 19 do
for yy := 0 to 19 do
if SPS_ColorBoxesMatch(LargeMap[cm][x+xx][y+yy], SmallMap[xx][yy], tol) then
Inc(Matching);

if (Matching > BestMatch) then
begin
BestMatch := Matching;
Result := cm;
fX := x;
fY := y;
end;
end;
end;

if (Result > -1) then
begin
// moved outside to remove uncessary calculations in interations.
fX := fX*5 + 50; // cause we want the center
fy := fY*5 + 50;
end;
end;


////// TYPES //////////////////////////////////////////////////////////////////

function GetTypeCount(): Integer; stdcall; export;
begin
Result := 2;
end;

function GetTypeInfo(x: Integer; var sType, sTypeDef: string): integer; stdcall;
begin
case x of

0: begin
sType := 'T3DIntegerArray';
sTypeDef := 'Array of Array of Array of Integer;';
end;

1: begin
sType := 'T4DIntegerArray';
sTypeDef := 'Array of T3DIntegerArray;';
end;

else
Result := -1;
end;
end;




////// EXPORTING /////////////////////////////////////////////////////////////
function GetFunctionCount(): Integer; stdcall; export;
begin
Result := 3;
end;

function GetFunctionCallingConv(x : Integer) : Integer; stdcall; export;
begin
Result := 0;
case x of
0..2 : Result := 1;
end;
end;

function GetFunctionInfo(x: Integer; var ProcAddr: Pointer; var ProcDef: PChar): Integer; stdcall; export;
begin
case x of
0:
begin
ProcAddr := @SPS_ColorBoxesMatch;
StrPCopy(ProcDef, 'function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean;');
end;
1:
begin
ProcAddr := @SPS_FindMapInMapEx;
StrPCopy(ProcDef, 'function SPS_FindMapInMapEx(var fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer;');
end;
2:
begin
ProcAddr := @SPS_BitmapToMap;
StrPCopy(ProcDef, 'function SPS_BitmapToMap(bmp: TMufasaBitmap): T3DIntegerArray;');
end;
else
x := -1;
end;
Result := x;
end;



exports GetTypeCount;
exports GetTypeInfo;
exports GetFunctionCount;
exports GetFunctionInfo;
exports GetFunctionCallingConv;

begin
end.


$ stat sps.lpr
File: `sps.lpr'
Size: 5064 Blocks: 16 IO Block: 4096 regular file
Device: 805h/2053d Inode: 1707036 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 500/ kevin) Gid: ( 500/ kevin)
Access: 2011-05-18 17:29:13.150019102 -0400
Modify: 2011-02-22 22:30:47.226212000 -0500
Change: 2011-05-19 18:18:09.887187073 -0400
Birth: -

Coh3n
08-08-2011, 02:45 AM
Thanks, Nava. Which one is the latest/is there a difference between the two? :p

E: It doesn't look like I'll have to edit that for the new structure, so that's good. Also, Nava, is there any possible way to speed it up even more?

Nava2
08-08-2011, 12:22 PM
Not much.. uhm only thing I see that will make a difference during runtime:


function SPS_ColorBoxesMatchInline(B1, B2: TIntegerArray; tol: extended): boolean; inline;
var
oneMinusTol,tolPlusOne: extended;
begin
oneMinusTol := 1-tol;
tolPlusOne := 1+tol;
Result := ((B1[0] >= Round(B2[0]*oneMinusTol)) and (B1[0] <= Round(B2[0]*tolPlusOne))) and
((B1[1] >= Round(B2[1]*oneMinusTol)) and (B1[1] <= Round(B2[1]*tolPlusOne))) and
((B1[2] >= Round(B2[2]*oneMinusTol)) and (B1[2] <= Round(B2[2]*tolPlusOne)));
end;

function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean; register;
begin
Result := SPS_ColorBoxesMatchInline(B1, B2, tol);
end;

function SPS_FindMapInMapEx(out fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer; register;
var
x, y, HighX, HighY, cm, L: integer;
xx, yy: integer;
Matching, BestMatch: integer;
b: Boolean;
begin
fX := -1;
fY := -1;
BestMatch := 0;

L := Length(LargeMap);
Result := -1;

for cm := 0 to L-1 do
begin
HighX := High(LargeMap[cm]) - 19;
HighY := High(LargeMap[cm][0]) - 19;
for x := 0 to HighX do
for y := 0 to HighY do
begin
Matching := 0;
for xx := 0 to 19 do
for yy := 0 to 19 do
begin
b:= SPS_ColorBoxesMatchInline(LargeMap[cm][x+xx][y+yy], SmallMap[xx][yy], tol);
if (b) then Inc(Matching);
end;

if (Matching > BestMatch) then
begin
BestMatch := Matching;
Result := cm;
fX := x;
fY := y;
end;
end;
end;

if (Result > -1) then
begin
// moved outside to remove uncessary calculations in interations.
fX := fX*5 + 50; // cause we want the center
fy := fY*5 + 50;
end;
end;


That should make it faster.. but if it does not then I'm not sure. The next step would be to write it in C. Most of the stuff that is speed intensive does not rely on the TMufasaBitmaps anyway.

Coh3n
08-08-2011, 03:22 PM
Not much.. uhm only thing I see that will make a difference during runtime:


function SPS_ColorBoxesMatchInline(B1, B2: TIntegerArray; tol: extended): boolean; inline;
var
oneMinusTol,tolPlusOne: extended;
begin
oneMinusTol := 1-tol;
tolPlusOne := 1+tol;
Result := ((B1[0] >= Round(B2[0]*oneMinusTol)) and (B1[0] <= Round(B2[0]*tolPlusOne))) and
((B1[1] >= Round(B2[1]*oneMinusTol)) and (B1[1] <= Round(B2[1]*tolPlusOne))) and
((B1[2] >= Round(B2[2]*oneMinusTol)) and (B1[2] <= Round(B2[2]*tolPlusOne)));
end;

function SPS_ColorBoxesMatch(B1, B2: TIntegerArray; tol: extended): boolean; register;
begin
Result := SPS_ColorBoxesMatchInline(B1, B2, tol);
end;

function SPS_FindMapInMapEx(out fx, fy: integer; LargeMap: T4DIntegerArray; SmallMap: T3DIntegerArray; tol: extended): integer; register;
var
x, y, HighX, HighY, cm, L: integer;
xx, yy: integer;
Matching, BestMatch: integer;
b: Boolean;
begin
fX := -1;
fY := -1;
BestMatch := 0;

L := Length(LargeMap);
Result := -1;

for cm := 0 to L-1 do
begin
HighX := High(LargeMap[cm]) - 19;
HighY := High(LargeMap[cm][0]) - 19;
for x := 0 to HighX do
for y := 0 to HighY do
begin
Matching := 0;
for xx := 0 to 19 do
for yy := 0 to 19 do
begin
b:= SPS_ColorBoxesMatchInline(LargeMap[cm][x+xx][y+yy], SmallMap[xx][yy], tol);
if (b) then Inc(Matching);
end;

if (Matching > BestMatch) then
begin
BestMatch := Matching;
Result := cm;
fX := x;
fY := y;
end;
end;
end;

if (Result > -1) then
begin
// moved outside to remove uncessary calculations in interations.
fX := fX*5 + 50; // cause we want the center
fy := fY*5 + 50;
end;
end;


That should make it faster.. but if it does not then I'm not sure. The next step would be to write it in C. Most of the stuff that is speed intensive does not rely on the TMufasaBitmaps anyway.Okay thanks. Obviously, I won't be the one to write a C plugin, but if someone else wants to, be my guest.

Nava2
08-08-2011, 09:24 PM
Oh, also, if possible.. using Trunc instead of Round would be a good idea to speed it up as well. Round is slow comparatively. But I'm not sure if that would bugger the algorithm.

Coh3n
08-08-2011, 09:46 PM
Oh, also, if possible.. using Trunc instead of Round would be a good idea to speed it up as well. Round is slow comparatively. But I'm not sure if that would bugger the algorithm.I can't imagine it would effect it too much, but I'll try it out and see.

E: I've added the source to the repository and applied your changes; however, I get and "Unknow library Graphics" when I try to build. I have to go now, but I'll have to check it out later tonight.

Nava2
08-11-2011, 06:17 AM
I can't imagine it would effect it too much, but I'll try it out and see.

E: I've added the source to the repository and applied your changes; however, I get and "Unknow library Graphics" when I try to build. I have to go now, but I'll have to check it out later tonight.

Yeah, tol is an extended, do not use trunc lol. Albeit, not doing *anything* might be even better :>.

Yago
08-11-2011, 02:03 PM
I think there should be an extensions for this...

Coh3n
08-11-2011, 02:44 PM
I think there should be an extensions for this...I thought about that too, but with the images, it's quite large which puts some stress on Wizzup?'s server if a lot of people update at the same time. I assure you, though, something will be figured out. :)

Choroid
08-11-2011, 03:40 PM
I thought about that too, but with the images, it's quite large which puts some stress on Wizzup?'s server if a lot of people update at the same time. I assure you, though, something will be figured out. :)
Do they have to come from Wizzup?'s servers for an extension?

Coh3n
08-11-2011, 03:40 PM
Do they have to come from Wizzup?'s servers for an extension?Nope, I'm pretty sure you just set a link.

Choroid
08-11-2011, 03:44 PM
Nope, I'm pretty sure you just set a link.

So shouldn't it be possible to pull them from github? That seems like it would save Wizzup?'s server from the images, and github should have more than enough bandwidth to easily deal with SRL.

Edit: I just checked, and it seems like you HAVE to use git to download from their website, unless you click on links. So github wouldn't work I guess.

Coh3n
08-11-2011, 03:47 PM
So shouldn't it be possible to pull them from github? That seems like it would save Wizzup?'s server from the images, and github should have more than enough bandwidth to easily deal with SRL.I don't think it's that simple, otherwise that's what we'd already do. I'm not really the one to talk to about this as I don't know much about it. You should get in contact with Wizzup? or Dgby on IRC, they'll know more about it.

Nava2
08-12-2011, 03:07 AM
I don't think it's that simple, otherwise that's what we'd already do. I'm not really the one to talk to about this as I don't know much about it. You should get in contact with Wizzup? or Dgby on IRC, they'll know more about it.

One just needs to maintain a version file online. You can easily use github as the mirror. :)

Also, coh3n, the SPS sauce you have in your repos is out of date. Talk to Dgby!

Coh3n
08-12-2011, 04:12 AM
One just needs to maintain a version file online. You can easily use github as the mirror. :)

Also, coh3n, the SPS sauce you have in your repos is out of date. Talk to Dgby!
Okay first of all, don't use "sauce" when you mean "source" else I'll stop talking to you. Second of all, the source that's there is what Dgby did the other day. If he's made updates since then he'll have to send a pull request.

Nava2
08-12-2011, 01:59 PM
Okay first of all, don't use "sauce" when you mean "source" else I'll stop talking to you. Second of all, the source that's there is what Dgby did the other day. If he's made updates since then he'll have to send a pull request.

Yeah, we were talking the other day and he changed his sauce because I had been using TRGB32 wrong.. which might be causing all the issues. Its a record and I'm just silly. So I'm sure he'll open a pull request to make his sauce your sauce and make all the sauce the same. :)