[Include] MapAndreas Include
#1

Foreword

I love the MapAndreas plugin, but I find so unfortunate that it uses ~70 MB's of RAM memory, so I started browsing the topic and found out that you can actually get the same results using fseek by setting the position indicator of the file using a small calculation instead of allocating the whole map into the memory.

Features

This include has exactly the same features as the MapAndreas plugin and is as accurate - there's simply no difference in terms of functioning between them:

MapAndreas PluginMapAndreas Include
Memory usage~70 MB RAMNothing*
AccuracyEXACTLY the same accuracy as the plugin
PerformanceThe plugin is really fast (because the data is allocated in the memory first and has the C++ performance advantage)This include is slower than the plugin (obviously because we're using fseek and read all time again plus we don't have the C++ performance advantage in this case)
Initialize timeTakes some time to allocate the memory (~5 seconds)No waiting needed - immediately ready for use
* Although every script needs some memory (depending what you're using and how much) to execute. I assume this will use a couple of hundred kilobytes.

Function(s)

We have only one function:
pawn Код:
stock Float: GetPointZPos(const Float: fX, const Float: fY, &Float: fZ = 0.0);
It returns the result and stores it in fZ (if variable defined).

Example(s)

Here are some basic examples:
pawn Код:
printf("The Z-coordinate of X = 2033.55 | Y = 1007.73 is Z = %.02f", GetPointZPos(2033.55, 1007.73));
Or you can just do it this way:
pawn Код:
new
    Float: fZ
;
GetPointZPos(1254.65, -554.55, fZ);
printf("The Z-coordinate of X = 1254.65 | Y = -554.55 is Z = %.02f", fZ);
Results:
Код:
The Z-coordinate of X = 2033.55 | Y = 1007.73 is Z = 9.81
The Z-coordinate of X = 1254.65 | Y = -554.55 is Z = 67.48
Notes

- Credits to Kalcor for his MapAndreas plugin.
- Credits to De[M]oN who posted a C++ fseek example in there.

Download

MapAndreas.inc
SAfull.hmap
Reply
#2

Awesome work Ryder... You make very useful things everytime.
Thanks.
Reply
#3

inb4 I'll learn to use fseek.
Nice work RyDeR

EDIT 1: I don't understand how to use fseek. xD
Reply
#4

Wow! nice, this will help ALOT of people!
Reply
#5

Great job on this include! I looked at your code and wow that look's fairly advanced lol.
Reply
#6

That's what i call awesome shit

- Good work Ryder
Reply
#7

I like good work
Reply
#8

Nice!
i like it!
Reply
#9

Quote:
Originally Posted by MrDeath537
Посмотреть сообщение
inb4 I'll learn to use fseek.
Nice work RyDeR

EDIT 1: I don't understand how to use fseek. xD
"fseek" is just setting the position indicator from a specific file handle (first parameter) by adding an offset (position parameter) to a reference position specified by origin (whence parameter).

EDIT:
Quote:
Originally Posted by Donya
Посмотреть сообщение
Wow! nice, this will help ALOT of people!

ohwell.

<results>

Well, that is of choice on my slow pc, I'm show it won't be that slow on a real host
Yes - Probably your PC because it's not really correct.
Reply
#10

I can't think up much use with this speed.
Reply
#11

This is awesome better than Kalcor plugin (but plugin is faster). I have question is possible to create your own file with z coordinates ?
For example i have "base.hmap" and myfile has got z coordinates of own created objects
Reply
#12

Quote:
Originally Posted by wups
Посмотреть сообщение
I can't think up much use with this speed.
It's not exaggerated slow. The results Donya posted aren't correct (so don't get distracted by that). I did a speedtest, ran it 100.000 times and it took only 930 ms to execute - Not that bad.

PS: Donya, can you please remove your speedtest results? I will post true ones soon.

Quote:
Originally Posted by __[ShaDoW]__
Посмотреть сообщение
This is awesome better than Kalcor plugin (but plugin is faster). I have question is possible to create your own file with z coordinates ?
For example i have "base.hmap" and myfile has got z coordinates of own created objects
Not quite sure how, but yes it would be possible (I guess)
Reply
#13

Awesome..!!
Reply
#14

Great I'm going to use it thanks
Reply
#15

Still to think of it that it's slower but doesn't consume that much CPU, which is way more advantageous.
Also keep in mind that this is not over used.


Good job RyDeR!
Reply
#16

Holy shit, I'll be converting right away, my +5 goes to you RyDeR`, you legend.

Edit:

I thought about having a NPC created and using the function pre-made by samp that finds the Z, Not sure if it'll work but I could give it a try sometime.
Reply
#17

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Holy shit, I'll be converting right away, my +5 goes to you RyDeR`, you legend.

Edit:

I thought about having a NPC created and using the function pre-made by samp that finds the Z, Not sure if it'll work but I could give it a try sometime.
https://sampforum.blast.hk/showthread.php?tid=160203

Looks good, some people might or might not find this useful.
Reply
#18

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
https://sampforum.blast.hk/showthread.php?tid=160203

Looks good, some people might or might not find this useful.
Yeah just saw that, perhaps he coded it wrongly or simply it cant be created that way

"This include does not work. Do not bother downloading"
Reply
#19

please change memory usage for fs, it can't be nothing, everything you start on your server, GM, FS, Plugin etc. use some memory
Reply
#20

Quote:
Originally Posted by CoaPsyFactor
Посмотреть сообщение
please change memory usage for fs, it can't be nothing, everything you start on your server, GM, FS, Plugin etc. use some memory
Quote:
Originally Posted by RyDeR`
Посмотреть сообщение
* Although every script needs some memory (depending what you're using and how much) to execute. This will take a couple hundred kilobytes I assume.
Next time read a bit more before posting useless things.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)