faluco@505: /**
faluco@505: * vim: set ts=4 :
ds@1330: * =============================================================================
faluco@505: * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
ds@1330: * =============================================================================
ds@1330: *
ds@1330: * This file is part of the SourceMod/SourcePawn SDK.
faluco@505: *
ds@1330: * This program is free software; you can redistribute it and/or modify it under
ds@1330: * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330: * Free Software Foundation.
ds@1330: *
ds@1330: * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
ds@1330: * details.
ds@1330: *
ds@1330: * You should have received a copy of the GNU General Public License along with
ds@1330: * this program. If not, see .
ds@1330: *
ds@1330: * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330: * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330: * by the Valve Corporation. You must obey the GNU General Public License in
ds@1330: * all respects for all other code used. Additionally, AlliedModders LLC grants
ds@1330: * this exception to all derivative works. AlliedModders LLC defines further
ds@1330: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330: * or .
faluco@505: *
faluco@505: * Version: $Id$
faluco@505: */
faluco@505:
faluco@505: #if defined _bitbuffer_included
faluco@505: #endinput
faluco@505: #endif
faluco@505: #define _bitbuffer_included
faluco@505:
faluco@505: /**
faluco@505: * Writes a single bit to a writable bitbuffer (bf_write).
faluco@505: *
faluco@505: * @param bf bf_write handle to write to.
faluco@505: * @param bit Bit to write (true for 1, false for 0).
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteBool(Handle:bf, bool:bit);
faluco@505:
faluco@505: /**
faluco@505: * Writes a byte to a writable bitbuffer (bf_write).
faluco@505: *
faluco@505: * @param bf bf_write handle to write to.
faluco@505: * @param byte Byte to write (value will be written as 8bit).
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteByte(Handle:bf, byte);
faluco@505:
faluco@505: /**
faluco@505: * Writes a byte to a writable bitbuffer (bf_write).
faluco@505: *
faluco@505: * @param bf bf_write handle to write to.
faluco@505: * @param chr Character to write.
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteChar(Handle:bf, chr);
faluco@505:
faluco@505: /**
faluco@505: * Writes a 16bit integer to a writable bitbuffer (bf_write).
faluco@505: *
faluco@505: * @param bf bf_write handle to write to.
faluco@505: * @param num Integer to write (value will be written as 16bit).
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteShort(Handle:bf, num);
faluco@505:
faluco@505: /**
faluco@505: * Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
faluco@505: *
faluco@505: * @param bf bf_write handle to write to.
faluco@505: * @param num Integer to write (value will be written as 16bit).
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteWord(Handle:bf, num);
faluco@505:
faluco@505: /**
faluco@505: * Writes a normal integer to a writable bitbuffer (bf_write).
faluco@505: *
faluco@505: * @param bf bf_write handle to write to.
faluco@505: * @param num Integer to write (value will be written as 32bit).
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteNum(Handle:bf, num);
faluco@505:
faluco@505: /**
faluco@505: * Writes a floating point number to a writable bitbuffer (bf_write).
faluco@505: *
faluco@505: * @param bf bf_write handle to write to.
faluco@505: * @param num Number to write.
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteFloat(Handle:bf, Float:num);
faluco@505:
faluco@505: /**
faluco@505: * Writes a string to a writable bitbuffer (bf_write).
faluco@505: *
faluco@505: * @param bf bf_write handle to write to.
faluco@505: * @param string Text string to write.
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteString(Handle:bf, const String:string[]);
faluco@505:
faluco@505: /**
faluco@505: * Writes an entity to a writable bitbuffer (bf_write).
faluco@505: * @note This is a wrapper around BfWriteShort().
faluco@505: *
faluco@505: * @param bf bf_write handle to write to.
faluco@505: * @param ent Entity index to write.
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle, or invalid entity.
faluco@505: */
faluco@505: native BfWriteEntity(Handle:bf, ent);
faluco@505:
faluco@505: /**
faluco@505: * Writes a bit angle to a writable bitbuffer (bf_write).
faluco@505: *
faluco@505: * @param bf bf_write handle to write to.
faluco@505: * @param angle Angle to write.
faluco@505: * @param numBits Optional number of bits to use.
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteAngle(Handle:bf, Float:angle, numBits=8);
faluco@505:
faluco@505: /**
faluco@505: * Writes a coordinate to a writable bitbuffer (bf_write).
faluco@505: *
faluco@505: * @param bf bf_write handle to write to.
faluco@505: * @param coord Coordinate to write.
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteCoord(Handle:bf, Float:coord);
faluco@505:
faluco@505: /**
faluco@505: * Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
faluco@505: *
faluco@598: * @param bf bf_write handle to write to.
faluco@505: * @param coord Coordinate array to write.
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteVecCoord(Handle:bf, Float:coord[3]);
faluco@505:
faluco@505: /**
faluco@505: * Writes a 3D normal vector to a writable bitbuffer (bf_write).
faluco@505: *
faluco@598: * @param bf bf_write handle to write to.
faluco@505: * @param vec Vector to write.
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteVecNormal(Handle:bf, Float:vec[3]);
faluco@505:
faluco@505: /**
faluco@505: * Writes a 3D angle vector to a writable bitbuffer (bf_write).
faluco@505: *
faluco@598: * @param bf bf_write handle to write to.
faluco@505: * @param angles Angle vector to write.
faluco@505: * @noreturn
faluco@505: * @error Invalid or incorrect Handle.
faluco@505: */
faluco@505: native BfWriteAngles(Handle:bf, Float:angles[3]);
faluco@598:
faluco@598: /**
faluco@598: * Reads a single bit from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @return Bit value read.
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native bool:BfReadBool(Handle:bf);
faluco@598:
faluco@598: /**
faluco@598: * Reads a byte from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @return Byte value read (read as 8bit).
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native BfReadByte(Handle:bf);
faluco@598:
faluco@598: /**
faluco@598: * Reads a character from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @return Character value read.
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native BfReadChar(Handle:bf);
faluco@598:
faluco@598: /**
faluco@598: * Reads a 16bit integer from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @return Integer value read (read as 16bit).
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native BfReadShort(Handle:bf);
faluco@598:
faluco@598: /**
faluco@598: * Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @return Integer value read (read as 16bit).
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native BfReadWord(Handle:bf);
faluco@598:
faluco@598: /**
faluco@598: * Reads a normal integer to a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @return Integer value read (read as 32bit).
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native BfReadNum(Handle:bf);
faluco@598:
faluco@598: /**
faluco@598: * Reads a floating point number from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @return Floating point value read.
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native Float:BfReadFloat(Handle:bf);
faluco@598:
faluco@598: /**
faluco@598: * Reads a string from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @param buffer Destination string buffer.
faluco@598: * @param maxlength Maximum length of output string buffer.
dvander@716: * @param line If true the buffer will be copied until it reaches a '\n' or a null terminator.
faluco@598: * @noreturn
faluco@598: * @error Invalid or incorrect Handle, destination string buffer was too short.
faluco@598: */
dvander@716: native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
faluco@598:
faluco@598: /**
faluco@598: * Reads an entity from a readable bitbuffer (bf_read).
faluco@598: * @note This is a wrapper around BfReadShort().
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @return Entity index read.
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native BfReadEntity(Handle:bf);
faluco@598:
faluco@598: /**
faluco@598: * Reads a bit angle from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @param numBits Optional number of bits to use.
faluco@598: * @return Angle read.
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native Float:BfReadAngle(Handle:bf, numBits=8);
faluco@598:
faluco@598: /**
faluco@598: * Reads a coordinate from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @return Coordinate read.
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native Float:BfReadCoord(Handle:bf);
faluco@598:
faluco@598: /**
faluco@598: * Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @param coord Destination coordinate array.
faluco@598: * @noreturn
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native BfReadVecCoord(Handle:bf, Float:coord[3]);
faluco@598:
faluco@598: /**
faluco@598: * Reads a 3D normal vector from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @param vec Destination vector array.
faluco@598: * @noreturn
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native BfReadVecNormal(Handle:bf, Float:vec[3]);
faluco@598:
faluco@598: /**
faluco@598: * Reads a 3D angle vector from a readable bitbuffer (bf_read).
faluco@598: *
faluco@598: * @param bf bf_read handle to read from.
faluco@598: * @param angles Destination angle vector.
faluco@598: * @noreturn
faluco@598: * @error Invalid or incorrect Handle.
faluco@598: */
faluco@598: native BfReadAngles(Handle:bf, Float:angles[3]);