plugins/include/bitbuffer.inc
author Scott Ehlert <ds@alliedmods.net>
Wed Mar 21 21:35:07 2012 -0500 (2012-03-21)
changeset 3472 7c8bf140de6b
parent 2289 44045ead61cd
permissions -rw-r--r--
Fixed build scripts for OS X 10.7 build slave.
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     5  * =============================================================================
     6  *
     7  * This file is part of the SourceMod/SourcePawn SDK.
     8  *
     9  * This program is free software; you can redistribute it and/or modify it under
    10  * the terms of the GNU General Public License, version 3.0, as published by the
    11  * Free Software Foundation.
    12  * 
    13  * This program is distributed in the hope that it will be useful, but WITHOUT
    14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    16  * details.
    17  *
    18  * You should have received a copy of the GNU General Public License along with
    19  * this program.  If not, see <http://www.gnu.org/licenses/>.
    20  *
    21  * As a special exception, AlliedModders LLC gives you permission to link the
    22  * code of this program (as well as its derivative works) to "Half-Life 2," the
    23  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    24  * by the Valve Corporation.  You must obey the GNU General Public License in
    25  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    26  * this exception to all derivative works.  AlliedModders LLC defines further
    27  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    28  * or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32 
    33 #if defined _bitbuffer_included
    34  #endinput
    35 #endif
    36 #define _bitbuffer_included
    37 
    38 /** 
    39  * Writes a single bit to a writable bitbuffer (bf_write).
    40  *
    41  * @param bf			bf_write handle to write to.
    42  * @param bit			Bit to write (true for 1, false for 0).
    43  * @noreturn
    44  * @error				Invalid or incorrect Handle.
    45  */
    46 native BfWriteBool(Handle:bf, bool:bit);
    47  
    48 /**
    49  * Writes a byte to a writable bitbuffer (bf_write).
    50  *
    51  * @param bf			bf_write handle to write to.
    52  * @param byte			Byte to write (value will be written as 8bit).
    53  * @noreturn
    54  * @error				Invalid or incorrect Handle.
    55  */
    56 native BfWriteByte(Handle:bf, byte);
    57 
    58 /**
    59  * Writes a byte to a writable bitbuffer (bf_write).
    60  *
    61  * @param bf			bf_write handle to write to.
    62  * @param chr			Character to write.
    63  * @noreturn
    64  * @error				Invalid or incorrect Handle.
    65  */
    66 native BfWriteChar(Handle:bf, chr);
    67 
    68 /**
    69  * Writes a 16bit integer to a writable bitbuffer (bf_write).
    70  *
    71  * @param bf			bf_write handle to write to.
    72  * @param num			Integer to write (value will be written as 16bit).
    73  * @noreturn
    74  * @error				Invalid or incorrect Handle.
    75  */
    76 native BfWriteShort(Handle:bf, num);
    77 
    78 /**
    79  * Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
    80  *
    81  * @param bf			bf_write handle to write to.
    82  * @param num			Integer to write (value will be written as 16bit).
    83  * @noreturn
    84  * @error				Invalid or incorrect Handle.
    85  */
    86 native BfWriteWord(Handle:bf, num);
    87 
    88 /**
    89  * Writes a normal integer to a writable bitbuffer (bf_write).
    90  *
    91  * @param bf			bf_write handle to write to.
    92  * @param num			Integer to write (value will be written as 32bit).
    93  * @noreturn
    94  * @error				Invalid or incorrect Handle.
    95  */
    96 native BfWriteNum(Handle:bf, num);
    97 
    98 /**
    99  * Writes a floating point number to a writable bitbuffer (bf_write).
   100  *
   101  * @param bf			bf_write handle to write to.
   102  * @param num			Number to write.
   103  * @noreturn
   104  * @error				Invalid or incorrect Handle.
   105  */
   106 native BfWriteFloat(Handle:bf, Float:num);
   107 
   108 /**
   109  * Writes a string to a writable bitbuffer (bf_write).
   110  *
   111  * @param bf			bf_write handle to write to.
   112  * @param string		Text string to write.
   113  * @noreturn
   114  * @error				Invalid or incorrect Handle.
   115  */
   116 native BfWriteString(Handle:bf, const String:string[]);
   117 
   118 /**
   119  * Writes an entity to a writable bitbuffer (bf_write).
   120  * @note This is a wrapper around BfWriteShort().
   121  *
   122  * @param bf			bf_write handle to write to.
   123  * @param ent			Entity index to write.
   124  * @noreturn
   125  * @error				Invalid or incorrect Handle, or invalid entity.
   126  */
   127 native BfWriteEntity(Handle:bf, ent);
   128 
   129 /**
   130  * Writes a bit angle to a writable bitbuffer (bf_write).
   131  *
   132  * @param bf			bf_write handle to write to.
   133  * @param angle			Angle to write.
   134  * @param numBits		Optional number of bits to use.
   135  * @noreturn
   136  * @error				Invalid or incorrect Handle.
   137  */
   138 native BfWriteAngle(Handle:bf, Float:angle, numBits=8);
   139 
   140 /**
   141  * Writes a coordinate to a writable bitbuffer (bf_write).
   142  *
   143  * @param bf			bf_write handle to write to.
   144  * @param coord			Coordinate to write.
   145  * @noreturn
   146  * @error				Invalid or incorrect Handle.
   147  */
   148 native BfWriteCoord(Handle:bf, Float:coord);
   149 
   150 /**
   151  * Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
   152  *
   153  * @param bf			bf_write handle to write to.
   154  * @param coord			Coordinate array to write.
   155  * @noreturn
   156  * @error				Invalid or incorrect Handle.
   157  */
   158 native BfWriteVecCoord(Handle:bf, Float:coord[3]);
   159 
   160 /**
   161  * Writes a 3D normal vector to a writable bitbuffer (bf_write).
   162  *
   163  * @param bf			bf_write handle to write to.
   164  * @param vec			Vector to write.
   165  * @noreturn
   166  * @error				Invalid or incorrect Handle.
   167  */
   168 native BfWriteVecNormal(Handle:bf, Float:vec[3]);
   169 
   170 /**
   171  * Writes a 3D angle vector to a writable bitbuffer (bf_write).
   172  *
   173  * @param bf			bf_write handle to write to.
   174  * @param angles		Angle vector to write.
   175  * @noreturn
   176  * @error				Invalid or incorrect Handle.
   177  */
   178 native BfWriteAngles(Handle:bf, Float:angles[3]);
   179 
   180 /** 
   181  * Reads a single bit from a readable bitbuffer (bf_read).
   182  *
   183  * @param bf			bf_read handle to read from.
   184  * @return				Bit value read.
   185  * @error				Invalid or incorrect Handle.
   186  */
   187 native bool:BfReadBool(Handle:bf);
   188 
   189 /**
   190  * Reads a byte from a readable bitbuffer (bf_read).
   191  *
   192  * @param bf			bf_read handle to read from.
   193  * @return				Byte value read (read as 8bit).
   194  * @error				Invalid or incorrect Handle.
   195  */
   196 native BfReadByte(Handle:bf);
   197 
   198 /**
   199  * Reads a character from a readable bitbuffer (bf_read).
   200  *
   201  * @param bf			bf_read handle to read from.
   202  * @return				Character value read.
   203  * @error				Invalid or incorrect Handle.
   204  */
   205 native BfReadChar(Handle:bf);
   206 
   207 /**
   208  * Reads a 16bit integer from a readable bitbuffer (bf_read).
   209  *
   210  * @param bf			bf_read handle to read from.
   211  * @return				Integer value read (read as 16bit).
   212  * @error				Invalid or incorrect Handle.
   213  */
   214 native BfReadShort(Handle:bf);
   215 
   216 /**
   217  * Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
   218  *
   219  * @param bf			bf_read handle to read from.
   220  * @return				Integer value read (read as 16bit).
   221  * @error				Invalid or incorrect Handle.
   222  */
   223 native BfReadWord(Handle:bf);
   224 
   225 /**
   226  * Reads a normal integer to a readable bitbuffer (bf_read).
   227  *
   228  * @param bf			bf_read handle to read from.
   229  * @return				Integer value read (read as 32bit).
   230  * @error				Invalid or incorrect Handle.
   231  */
   232 native BfReadNum(Handle:bf);
   233 
   234 /**
   235  * Reads a floating point number from a readable bitbuffer (bf_read).
   236  *
   237  * @param bf			bf_read handle to read from.
   238  * @return				Floating point value read.
   239  * @error				Invalid or incorrect Handle.
   240  */
   241 native Float:BfReadFloat(Handle:bf);
   242 
   243 /**
   244  * Reads a string from a readable bitbuffer (bf_read).
   245  *
   246  * @param bf			bf_read handle to read from.
   247  * @param buffer		Destination string buffer.
   248  * @param maxlength		Maximum length of output string buffer.
   249  * @param line			If true the buffer will be copied until it reaches a '\n' or a null terminator.
   250  * @return				Number of bytes written to the buffer.  If the bitbuffer stream overflowed, 
   251  *						that is, had no terminator before the end of the stream, then a negative 
   252  *						number will be returned equal to the number of characters written to the 
   253  *						buffer minus 1.  The buffer will be null terminated regardless of the 
   254  *						return value.
   255  * @error				Invalid or incorrect Handle.
   256  */
   257 native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
   258 
   259 /**
   260  * Reads an entity from a readable bitbuffer (bf_read).
   261  * @note This is a wrapper around BfReadShort().
   262  *
   263  * @param bf			bf_read handle to read from.
   264  * @return				Entity index read.
   265  * @error				Invalid or incorrect Handle.
   266  */
   267 native BfReadEntity(Handle:bf);
   268 
   269 /**
   270  * Reads a bit angle from a readable bitbuffer (bf_read).
   271  *
   272  * @param bf			bf_read handle to read from.
   273  * @param numBits		Optional number of bits to use.
   274  * @return				Angle read.
   275  * @error				Invalid or incorrect Handle.
   276  */
   277 native Float:BfReadAngle(Handle:bf, numBits=8);
   278 
   279 /**
   280  * Reads a coordinate from a readable bitbuffer (bf_read).
   281  *
   282  * @param bf			bf_read handle to read from.
   283  * @return				Coordinate read.
   284  * @error				Invalid or incorrect Handle.
   285  */
   286 native Float:BfReadCoord(Handle:bf);
   287 
   288 /**
   289  * Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
   290  *
   291  * @param bf			bf_read handle to read from.
   292  * @param coord			Destination coordinate array.
   293  * @noreturn
   294  * @error				Invalid or incorrect Handle.
   295  */
   296 native BfReadVecCoord(Handle:bf, Float:coord[3]);
   297 
   298 /**
   299  * Reads a 3D normal vector from a readable bitbuffer (bf_read).
   300  *
   301  * @param bf			bf_read handle to read from.
   302  * @param vec			Destination vector array.
   303  * @noreturn
   304  * @error				Invalid or incorrect Handle.
   305  */
   306 native BfReadVecNormal(Handle:bf, Float:vec[3]);
   307 
   308 /**
   309  * Reads a 3D angle vector from a readable bitbuffer (bf_read).
   310  *
   311  * @param bf			bf_read handle to read from.
   312  * @param angles		Destination angle vector.
   313  * @noreturn
   314  * @error				Invalid or incorrect Handle.
   315  */
   316 native BfReadAngles(Handle:bf, Float:angles[3]);
   317 
   318 /**
   319  * Returns the number of bytes left in a readable bitbuffer (bf_read).
   320  *
   321  * @param bf			bf_read handle to read from.
   322  * @return				Number of bytes left unread.
   323  * @error				Invalid or incorrect Handle.
   324  */
   325 native BfGetNumBytesLeft(Handle:bf);