MapAndreas Include -
RyDeR` - 01.08.2011
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 Plugin | MapAndreas Include |
Memory usage | ~70 MB RAM | Nothing* |
Accuracy | | EXACTLY the same accuracy as the plugin |
Performance | The 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 time | Takes 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
Re: MapAndreas Include -
iPLEOMAX - 01.08.2011
Awesome work Ryder... You make very useful things everytime.
Thanks.
Re: MapAndreas Include -
MrDeath537 - 01.08.2011
inb4 I'll learn to use fseek.
Nice work RyDeR
EDIT 1: I don't understand how to use fseek. xD
Re: MapAndreas Include -
Donya - 01.08.2011
Wow! nice, this will help ALOT of people!
Re: MapAndreas Include -
Toni - 01.08.2011
Great job on this include! I looked at your code and wow that look's fairly advanced lol.
Re: MapAndreas Include -
SlashPT - 01.08.2011
That's what i call awesome shit
- Good work Ryder
Respuesta: MapAndreas Include -
D3IMON - 01.08.2011
I like good work
Re: MapAndreas Include -
[LoD]Hauke - 01.08.2011
Nice!
i like it!
Re: MapAndreas Include -
RyDeR` - 01.08.2011
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.
Re: MapAndreas Include -
wups - 01.08.2011
I can't think up much use with this speed.
Re: MapAndreas Include -
QuaTTrO - 01.08.2011
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
Re: MapAndreas Include -
RyDeR` - 01.08.2011
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)
Re: MapAndreas Include -
HyperZ - 01.08.2011
Awesome..!!
Re: MapAndreas Include -
vyper - 01.08.2011
Great I'm going to use it
thanks
Re: MapAndreas Include -
Zh3r0 - 01.08.2011
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!
Re: MapAndreas Include -
Lorenc_ - 01.08.2011
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.
Re: MapAndreas Include -
Hiddos - 01.08.2011
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.
Re: MapAndreas Include -
Lorenc_ - 01.08.2011
Quote:
Originally Posted by Hiddos
|
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"
Re: MapAndreas Include -
CoaPsyFactor - 01.08.2011
please change memory usage for fs, it can't be nothing, everything you start on your server, GM, FS, Plugin etc. use some memory
Re: MapAndreas Include -
RyDeR` - 01.08.2011
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.