SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Thread Tools Display Modes
Old 09/08/2011, 09:34 PM   #1
Mauzen's Avatar
Join Date: Jun 2007
Location: Western Germany
Posts: 5,094
Reputation: 1521
Default MapAndreas v1.2.1 Updated

If you dont know what MapAndreas is, see the Original thread for the original description.

A lot of people had problems with the high RAM usage of the MapAndreas plugin, so I decided to update the plugin and add some stuff like the possibility to reduce the used RAM.
I am not the original author of MapAndreas. Kalcor created it, I just added a few things to this version (with his permission of course).

1.1: The major changes in v1.1 are 2 new buffer modes. Beside the original MAP_ANDREAS_MODE_FULL I added 2 other modes listed below. I also added 2 new functions.

1.2 (11.6.2014): I added the long anticipated functionality to edit the heightmap. The height for an x/y position can now be set with a scripting function, and the heightmap can be saved to any file then. Its also possible to load heightmap files with any name. Init-speed is also greatly boosted.
For more info about 1.2 see this post

1.2.1: This update by pamdex now allows sharing the loaded heightmap between plugins, without loading it again for every single one. We thought about how to solve this for a while, and this is the final and probably best solution. See his release post for information on this.
This update can be extremely handy for plugin developers, as they dont need to load their own instance, but share it with the MapAndreas plugin, allowing to use buffered modes without wasted RAM.

The plugin now provides these 6 functions:

// original
// Used to load the data file into memory - should be called at least once, or the other functions wont work
// Choose the name including "scriptfiles/" of your heightmap file or ignore the parameter to use the default ones.
// The mode must match the mode of the custom file name
native MapAndreas_Init(mode, name[]="");
// Puts highest Z value (ground level) into Z for the provided X,Y co-ordinate.
native MapAndreas_FindZ_For2DCoord(Float:X, Float:Y, &Float:Z); 
// new
native MapAndreas_FindAverageZ(Float: x, Float:y, &Float:z); // returns a linear approximation of the ground level at the x,y coordinate
native MapAndreas_Unload(); // Un-initialises the data and gives back all used memory. It can be re-initialised again afterwards
// new (1.2)
// Same as FindZ_For2DCoord, but it sets the Z value instead of returning it
// Only z values between 0 and 655.35 are supported, going beyond might have unexpected consequences ;)
MapAndreas_SetZ_For2DCoord(Float:X, Float:Y, Float:Z);
// Use it to safe SetZ changes to a file (else they arent permanent)
native MapAndreas_SaveCurrentHMap(name[]);
// This returns the memory address of the initialized MapAndreas, or 0 if its not initalized
// The address can then be used in other plugins to share the buffer
native MapAndreas_GetAddress();

MapAndreas_FindAverageZ is more accurate than the normal FindZ, but also about 3 times slower. It apporximates the z-level using the height neighbor fields, but might return unlogical values sometimes (e.g. at the edge of a house) I recommend using it when you need really exact data only.
MapAndreas_Unload was more likely made for testing but I think it is also quite useful for others. You can for example unload all the data when changing to a gamemode that does not need MapAndreas, so the server does not waste unused RAM.

Also there are 3 different modes now:

MAP_ANDREAS_MODE_FULL: Original mode, uses about 70MB RAM, requires SAfull.hmap in the scriptfiles directory, 1x1 squares
MAP_ANDREAS_MODE_MINIMAL: Uses only 3x3 squares, and so it just needs ~9MB RAM, but is less precise. Requires SAmin.hmap.
MAP_ANDREAS_MODE_NOBUFFER: Reads the data directly from the file without buffering, and so eats no additional RAM, but therefore it is WAY slower. Requires SAfull.hmap
[17:28:09] Starting test "FindZ, MODE_FULL" with 10000000 iterations...
[17:28:10] Test "FindZ, MODE_FULL" finished: 568ms (17605634.0/sec)

[17:28:10] Starting test "FindAverageZ, MODE_FULL" with 10000000 iterations...
[17:28:12] Test "FindAverageZ, MODE_FULL" finished: 1584ms (6313131.5/sec)

[17:28:13] Starting test "FindZ, MODE_MINIMAL" with 10000000 iterations...
[17:28:14] Test "FindZ, MODE_MINIMAL" finished: 605ms (16528926.0/sec)

[17:28:14] Starting test "FindAverageZ, MODE_MINIMAL" with 10000000 iterations...
[17:28:16] Test "FindAverageZ, MODE_MINIMAL" finished: 1696ms (5896226.5/sec)

[17:28:16] Starting test "FindZ, MODE_NOBUFFER" with 100000 iterations...
[17:28:16] Test "FindZ, MODE_NOBUFFER" finished: 377ms (265251.9/sec)

[17:28:16] Starting test "FindAverageZ, MODE_NOBUFFER" with 100000 iterations...
[17:28:17] Test "FindAverageZ, MODE_NOBUFFER" finished: 1123ms (89047.1/sec)
So still the original mode is the best choice in most cases. Do not use the NOBUFFER mode if you check the height very often (e.g. for anticheat).

Just like every other plugin. Just be sure you have the right hmap file in the scriptfiles directory.

Im working on a way to compress the data directly in RAM to get a mode with less RAM but still good speed. If I get it working there will be another update.

1.1 Windows .dll + both heightmap files (30 MB)
1.1 Windows .dll and include only
1.1 Linux .so (Thanks toTheArcher for reupload, orig. compiled by Gamer_Z)
1.1 Source code

1.2 source, plugins and include
1.2 full package including heightmaps

1.2.1 update by pamdex Be sure to read his release post

I hope this update helps some guys who couldnt use this plugin before!

Last edited by Mauzen; 21/07/2014 at 12:42 PM. Reason: Version 1.2.1
Mauzen is offline   Reply With Quote
Old 09/08/2011, 09:37 PM   #2
Join Date: May 2010
Posts: 873
Reputation: 115
Default Re: MapAndreas v1.1 Updated

Nice work Mauzen.
Snipa is offline   Reply With Quote
Old 09/08/2011, 09:51 PM   #3
Ash.'s Avatar
Join Date: Jan 2010
Location: England
Posts: 2,119
Reputation: 163
Default Re: MapAndreas v1.1 Updated

Nice on Mauzen, keep up the good work!

Although I've never used the MapAndreas plugin, I'm intrigued by the new buffer modes
Work, Play, Make Friends
Written from scratch, and originally released in 2011, play today!
Visit the forum | Play the game
Ash. is offline   Reply With Quote
Old 09/08/2011, 10:28 PM   #4
Join Date: Mar 2011
Posts: 758
Reputation: 33
Default Re: MapAndreas v1.1 Updated

yay! thank you for MAP_ANDREAS_MODE_MINIMAL
[FilterScript]Exception 0xC0000005 at 0x7F120E Protection | OnVehicleMod monitoring. Now Full Protection!

I'm sorry for what was posted earlier, I was hacked.
Donya is offline   Reply With Quote
Old 09/08/2011, 10:32 PM   #5
Huge Clucker
BloodyEric's Avatar
Join Date: May 2008
Location: Berlin, Germany
Posts: 357
Reputation: 12
Default AW: MapAndreas v1.1 Updated

Awesome Mauzen, awesome...
BloodyEric is offline   Reply With Quote
Old 09/08/2011, 11:18 PM   #6
Toni's Avatar
Join Date: Aug 2009
Location: United States
Posts: 1,512
Reputation: 156
Default Re: MapAndreas v1.1 Updated

Was hoping for an update from someone . Keep up the good work!
Toni is offline   Reply With Quote
Old 09/08/2011, 11:37 PM   #7
Posts: n/a
Default Re: MapAndreas v1.1 Updated

Nice work.
  Reply With Quote
Old 09/08/2011, 11:38 PM   #8
Big Clucker
Firzendxiw's Avatar
Join Date: Oct 2008
Location: I live insideout
Posts: 165
Reputation: 43
Default Re: MapAndreas v1.1 Updated

Sweet Mauzen, thanks for this
Firzendxiw is offline   Reply With Quote
Old 09/08/2011, 11:45 PM   #9
Gamer_Z's Avatar
Join Date: Jun 2009
Location: Eindhoven, NL
Posts: 3,605
Reputation: 1354
Default Re: MapAndreas v1.1 Updated

Compiled for linux.

Here you go:

also for the Hmap file I recommend creating an UHARC SFX archive.

Believe it or not, I get a 16% compression ratio,

(20 MB LESS than your upload)
Attached Files
File Type: rar SAfull.part2.rar (3.59 MB, 33 views)
File Type: rar SAfull.part3.rar (3.59 MB, 21 views)
File Type: rar SAfull.part1.rar (3.59 MB, 32 views)

Do not contact me for private help, please stop wasting your time trying to offer me a job
(Especially if you cannot pay the market rate for a developer)
If you are looking for scripters/mappers/staff/whatever look here
The only help I offer is my occasional reaction on the public forums
Gamer_Z is offline   Reply With Quote
Old 09/08/2011, 11:59 PM   #10
Huge Clucker
vyper's Avatar
Join Date: Jul 2009
Location: Hell. x_x
Posts: 371
Reputation: 68
Thumbs up Re: MapAndreas v1.1 Updated

Great ! Thanks
vyper is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] MapAndreas higorklein Português/Portuguese 2 22/03/2014 06:13 PM
Mapandreas Help SequenceCuz Scripting Help 8 07/04/2013 01:07 PM
Need the updated that works with updated YSI gychem Scripting Help 2 06/02/2013 07:36 PM
[Ajuda] MapAndreas. tonisantolia Português/Portuguese 4 09/01/2013 09:26 PM
MapAndreas JaKe Elite Scripting Help 5 08/10/2012 12:28 PM

All times are GMT. The time now is 10:59 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.