23.03.2014, 21:13
I need to create include for rBits, only find it with pastebin on ******, please help!.
Thanks
PHP код:
/*
SA-MP "rBits" Include
Copyright © 2011 RyDeR`
*/
#if defined _Included_rBits
#endinput
#endif
#define _Included_rBits
#define BIT_TAGS \
{ Bit1, Bit2, Bit4, Bit8, Bit16 }
enum e_Bits
{
Bit1,
Bit2,
Bit4,
Bit8,
Bit16,
Bit32
};
#define Bit1:%0<%1> \
Bit1: %0[((%1) + 31) >>> _: Bit32]
#define Bit1_Set(%0,%1,%2) \
Bit_Set(%0, (%1), (%2), Bit1)
#define Bit1_Get(%0,%1) \
Bit_Get(%0, (%1), Bit1)
#define Bit2:%0<%1> \
Bit2: %0[((%1) + 15) >>> _: (Bit32 - Bit2)]
#define Bit2_Set(%0,%1,%2) \
Bit_Set(%0, (%1), (%2), Bit2)
#define Bit2_Get(%0,%1) \
Bit_Get(%0, (%1), Bit2)
#define Bit4:%0<%1> \
Bit4: %0[((%1) + 7) >>> _: (Bit32 - Bit4)]
#define Bit4_Set(%0,%1,%2) \
Bit_Set(%0, (%1), (%2), Bit4)
#define Bit4_Get(%0,%1) \
Bit_Get(%0, (%1), Bit4)
#define Bit8:%0<%1> \
Bit8: %0[(%1) char]
#define Bit8_Set(%0,%1,%2) \
(_: %0{(%1)} = (%2))
#define Bit8_Get(%0,%1) \
(_: %0{(%1)})
#define Bit16:%0<%1> \
Bit16: %0[((%1) + 1) >>> _: (Bit32 - Bit16)]
#define Bit16_Set(%0,%1,%2) \
Bit_Set(%0, (%1), (%2), Bit16)
#define Bit16_Get(%0,%1) \
Bit_Get(%0, (%1), Bit16)
#if defined Bit_Set && defined Bit_Vet
stock Bit_Set_Hook({Bit1, Bit2, Bit4, Bit8, Bit16, Bit}:bitArr[], arrIdx, {_, bool}:value = 0, e_Bits:bitShift = Bit1, arrSize = sizeof(bitArr), arrTag = tagof(bitArr))
{
if (arrTag == tagof(Bit:))
return Bit_Set(bitArr, arrIdx, bool:value);
#define Bit_Set Bit_Set_Hook
#else
stock Bit_Set(BIT_TAGS: bitArr[], arrIdx, value, e_Bits: bitShift, arrSize = sizeof(bitArr))
{
#endif
new
bitVar = ((arrIdx & ((1 << _: (Bit32 - bitShift)) - 1)) << _: bitShift),
bitLim = ((1 << (1 << _: bitShift)) - 1)
;
if(!(0 <= (arrIdx >>>= _: (Bit32 - bitShift)) < arrSize))
return 0;
(_: bitArr[arrIdx]) &= ~(bitLim << bitVar);
(_: bitArr[arrIdx]) |= ((bitLim & value) << bitVar);
return 1;
}
#if defined Bit_Get && defined Bit_Vet
stock Bit_Get_Hook({Bit1, Bit2, Bit4, Bit8, Bit16, Bit}:bitArr[], arrIdx, e_Bits:bitShift = Bit1, arrSize = sizeof(bitArr), arrTag = tagof(bitArr))
{
if (arrTag == tagof(Bit:))
return _:Bit_GetBit(Bit:bitArr, _:arrIdx);
#undef Bit_Get
#define Bit_Get Bit_Get_Hook
#else
stock Bit_Get(BIT_TAGS: bitArr[], arrIdx, e_Bits: bitShift, arrSize = sizeof(bitArr))
{
#endif
new
bitVar = ((arrIdx & ((1 << _: (Bit32 - bitShift)) - 1)) << _: bitShift),
bitLim = ((1 << (1 << _: bitShift)) - 1)
;
if(!(0 <= (arrIdx >>>= _: (Bit32 - bitShift)) < arrSize))
return 0;
return ((_: bitArr[arrIdx] >>> bitVar) & bitLim);
}