Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
Lorenc_ - 21.08.2011
Yeah getting a error here:
Code:
rBits.inc(1) : error 010: invalid function or declaration
Can anyone pass me a old version of this include? May work.
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
RyDeR` - 21.08.2011
Quote:
Originally Posted by Lorenc_
Yeah getting a error here:
Code:
rBits.inc(1) : error 010: invalid function or declaration
Can anyone pass me a old version of this include? May work.
|
This is and was the only version untill now. What's on line 1?
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
System64 - 21.08.2011
I've found my problem, problem is that I can't use Bit_Set, than eq. BitSet, why?
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
GangsTa_ - 22.08.2011
This is just what I needed.
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
Lorenc_ - 24.08.2011
Quote:
Originally Posted by RyDeR`
This is and was the only version untill now. What's on line 1?
|
Nothing, though I managed to ask TheKiller for his version of the Include, works perfectly now. Theres nothing in the include. It's completely clean and it gives the error.
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
Gh0sT_ - 28.08.2011
can I set negative values?
e.g: BitX_Set(array, id, -1);
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
RyDeR` - 28.08.2011
Quote:
Originally Posted by Gh0sT_
can I set negative values?
e.g: BitX_Set(array, id, -1);
|
Yes but no. When you set for example -1 at 4 bits, the value will become 15. If you do the same for -2 the value will becomw 14. Same way of working for other bit types.
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
Lorenc_ - 28.08.2011
Just renamed most functions/defines so they don't conflict with YSI.
to anyone that wants it:
Code:
/*
SA-MP "rBits" Include
Copyright © 2011 RyDeR`
*/
#if defined _Included_rBits
#endinput
#endif
#define _Included_rBits
#define BIT_TAGS \
{ rBit1, rBit2, rBit4, rBit8, rBit16 }
enum e_Bits
{
rBit1,
rBit2,
rBit4,
rBit8,
rBit16,
rBit32
};
#define rBit1:%0<%1> \
rBit1: %0[((%1) + 31) >>> _: rBit32]
#define rBit1_Set(%0,%1,%2) \
rBit_Set(%0, (%1), (%2), rBit1)
#define rBit1_Get(%0,%1) \
rBit_Get(%0, (%1), rBit1)
#define rBit2:%0<%1> \
rBit2: %0[((%1) + 15) >>> _: (rBit32 - rBit2)]
#define rBit2_Set(%0,%1,%2) \
rBit_Set(%0, (%1), (%2), rBit2)
#define rBit2_Get(%0,%1) \
rBit_Get(%0, (%1), rBit2)
#define rBit4:%0<%1> \
rBit4: %0[((%1) + 7) >>> _: (rBit32 - rBit4)]
#define rBit4_Set(%0,%1,%2) \
rBit_Set(%0, (%1), (%2), rBit4)
#define rBit4_Get(%0,%1) \
rBit_Get(%0, (%1), rBit4)
#define rBit8:%0<%1> \
rBit8: %0[(%1) char]
#define rBit8_Set(%0,%1,%2) \
(_: %0{(%1)} = (%2))
#define rBit8_Get(%0,%1) \
(_: %0{(%1)})
#define rBit16:%0<%1> \
rBit16: %0[((%1) + 1) >>> _: (rBit32 - rBit16)]
#define rBit16_Set(%0,%1,%2) \
rBit_Set(%0, (%1), (%2), rBit16)
#define rBit16_Get(%0,%1) \
rBit_Get(%0, (%1), rBit16)
stock rBit_Set(BIT_TAGS: bitArr[], arrIdx, value, e_Bits: bitShift, arrSize = sizeof(bitArr))
{
new
bitVar = ((arrIdx & ((1 << _: (rBit32 - bitShift)) - 1)) << _: bitShift),
bitLim = ((1 << (1 << _: bitShift)) - 1)
;
if(!(0 <= (arrIdx >>>= _: (rBit32 - bitShift)) < arrSize))
return 0;
(_: bitArr[arrIdx]) &= ~(bitLim << bitVar);
(_: bitArr[arrIdx]) |= ((bitLim & value) << bitVar);
return 1;
}
stock rBit_Get(BIT_TAGS: bitArr[], arrIdx, e_Bits: bitShift, arrSize = sizeof(bitArr))
{
new
bitVar = ((arrIdx & ((1 << _: (rBit32 - bitShift)) - 1)) << _: bitShift),
bitLim = ((1 << (1 << _: bitShift)) - 1)
;
if(!(0 <= (arrIdx >>>= _: (rBit32 - bitShift)) < arrSize))
return 0;
return ((_: bitArr[arrIdx] >>> bitVar) & bitLim);
}
You just need to add a 'r' next to your function(s).
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
System64 - 28.08.2011
thanks lorenc *_____*
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
oFLu - 28.08.2011
Ne İse Yaradıgını Anlamadım İngilizcem Kotudur
Thanks
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
Konstantinos - 08.02.2012
Amazing work RyDeR`. The way the .amx size decreases is awesome.
I want to use it, although I have two questions.
How can I use it on Money. I have enum with money init but the value can be more than one billion.
Is there any way to use it with Bit, or to make the enum as normal and use rBits only a the Global Variables.
Also, about password with whirlpool Bit8: is fine?
Regards,
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
RyDeR` - 08.02.2012
Quote:
Originally Posted by Dwane
How can I use it on Money.
|
If the value goes over billions, just use a normal, 32-bit, variable.
Quote:
Originally Posted by Dwane
Also, about password with whirlpool Bit8: is fine?
|
No, this include only supports integers. However, to answer your question, you can just use char arrays with strpack and strunpack.
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
Konstantinos - 08.02.2012
Oh, my bad. Well, I will use it then to those variables (integers with value less 65535).
Thank you!
Edit: The result is amazing.
pawn Code:
First GameMode: .pwn ( 133KB ) || .amx ( 312KB )
Second GameMode: .pwn ( 150KB ) || .amx ( 315KB ) [ Uses rBits ]
I added more at my second GM and the amx size is only 3KB more than the first GameMode!
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
RyDeR` - 23.02.2012
Quote:
Originally Posted by Dwane
Oh, my bad. Well, I will use it then to those variables (integers with value less 65535).
Thank you!
Edit: The result is amazing.
pawn Code:
First GameMode: .pwn ( 133KB ) || .amx ( 312KB ) Second GameMode: .pwn ( 150KB ) || .amx ( 315KB ) [ Uses rBits ]
I added more at my second GM and the amx size is only 3KB more than the first GameMode!
|
Glad to see you're using it pretty well!
This post is just to let you know I updated the topic and the include itself. Nothing really changed as I only changed the style of the include so it's not necessary to update if you don't want to.
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
Konstantinos - 27.02.2012
Quote:
Originally Posted by RyDeR`
Glad to see you're using it pretty well!
This post is just to let you know I updated the topic and the include itself. Nothing really changed as I only changed the style of the include so it's not necessary to update if you don't want to.
|
Thanks. I updated! Moreover, I am using about 30 variables with rBits and I have new result.
pawn Code:
First GameMode: .pwn ( 133KB ) || .amx ( 312KB )
Second GameMode: .pwn ( 168KB ) || .amx ( 288KB ) [ Uses rBits ]
It's lower than the first Gamemode that it doesn't use rBits.
Excellent work RyDeR`.
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
Slice - 05.02.2016
Look at "Integer Limits" in the first post.
4 bits can store 0-15.
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
IgoRangel - 02.08.2016
ryder poderia dispinibilizar ela ja em arquivo inc pf ?
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] - justice96 - 10.08.2016
What If someone already using YSI stuffs, I think that is not compatible.
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
AbyssMorgan - 10.08.2016
Quote:
Originally Posted by justice96
What If someone already using YSI stuffs, I think that is not compatible.
|
Why don't you use Bit Functions, is faster.
https://sampforum.blast.hk/showthread.php?tid=591223
Re: rBits [supports 16, 8, 4, 2 and 1-bit arrays] -
Bussyman - 27.04.2017
It's only for numbers?