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