plugins/include/bitbuffer.inc
author Phong Dang <teame06@gmail.com>
Wed Aug 01 18:22:53 2007 +0000 (2007-08-01)
changeset 1245 bb0611ab4bed
parent 716 9503ad1d8ebb
child 1330 ab94316bb52b
permissions -rw-r--r--
Updated license header.
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  *  This file is part of the SourceMod/SourcePawn SDK.  This file may only be used 
     8  * or modified under the Terms and Conditions of its License Agreement, which is found 
     9  * in LICENSE.txt.  The Terms and Conditions for making SourceMod extensions/plugins 
    10  * may change at any time.  To view the latest information, see:
    11  *   http://www.sourcemod.net/license.php
    12  *
    13  * Version: $Id$
    14  */
    15 
    16 #if defined _bitbuffer_included
    17  #endinput
    18 #endif
    19 #define _bitbuffer_included
    20 
    21 /** 
    22  * Writes a single bit to a writable bitbuffer (bf_write).
    23  *
    24  * @param bf			bf_write handle to write to.
    25  * @param bit			Bit to write (true for 1, false for 0).
    26  * @noreturn
    27  * @error				Invalid or incorrect Handle.
    28  */
    29 native BfWriteBool(Handle:bf, bool:bit);
    30  
    31 /**
    32  * Writes a byte to a writable bitbuffer (bf_write).
    33  *
    34  * @param bf			bf_write handle to write to.
    35  * @param byte			Byte to write (value will be written as 8bit).
    36  * @noreturn
    37  * @error				Invalid or incorrect Handle.
    38  */
    39 native BfWriteByte(Handle:bf, byte);
    40 
    41 /**
    42  * Writes a byte to a writable bitbuffer (bf_write).
    43  *
    44  * @param bf			bf_write handle to write to.
    45  * @param chr			Character to write.
    46  * @noreturn
    47  * @error				Invalid or incorrect Handle.
    48  */
    49 native BfWriteChar(Handle:bf, chr);
    50 
    51 /**
    52  * Writes a 16bit integer to a writable bitbuffer (bf_write).
    53  *
    54  * @param bf			bf_write handle to write to.
    55  * @param num			Integer to write (value will be written as 16bit).
    56  * @noreturn
    57  * @error				Invalid or incorrect Handle.
    58  */
    59 native BfWriteShort(Handle:bf, num);
    60 
    61 /**
    62  * Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
    63  *
    64  * @param bf			bf_write handle to write to.
    65  * @param num			Integer to write (value will be written as 16bit).
    66  * @noreturn
    67  * @error				Invalid or incorrect Handle.
    68  */
    69 native BfWriteWord(Handle:bf, num);
    70 
    71 /**
    72  * Writes a normal integer to a writable bitbuffer (bf_write).
    73  *
    74  * @param bf			bf_write handle to write to.
    75  * @param num			Integer to write (value will be written as 32bit).
    76  * @noreturn
    77  * @error				Invalid or incorrect Handle.
    78  */
    79 native BfWriteNum(Handle:bf, num);
    80 
    81 /**
    82  * Writes a floating point number to a writable bitbuffer (bf_write).
    83  *
    84  * @param bf			bf_write handle to write to.
    85  * @param num			Number to write.
    86  * @noreturn
    87  * @error				Invalid or incorrect Handle.
    88  */
    89 native BfWriteFloat(Handle:bf, Float:num);
    90 
    91 /**
    92  * Writes a string to a writable bitbuffer (bf_write).
    93  *
    94  * @param bf			bf_write handle to write to.
    95  * @param string		Text string to write.
    96  * @noreturn
    97  * @error				Invalid or incorrect Handle.
    98  */
    99 native BfWriteString(Handle:bf, const String:string[]);
   100 
   101 /**
   102  * Writes an entity to a writable bitbuffer (bf_write).
   103  * @note This is a wrapper around BfWriteShort().
   104  *
   105  * @param bf			bf_write handle to write to.
   106  * @param ent			Entity index to write.
   107  * @noreturn
   108  * @error				Invalid or incorrect Handle, or invalid entity.
   109  */
   110 native BfWriteEntity(Handle:bf, ent);
   111 
   112 /**
   113  * Writes a bit angle to a writable bitbuffer (bf_write).
   114  *
   115  * @param bf			bf_write handle to write to.
   116  * @param angle			Angle to write.
   117  * @param numBits		Optional number of bits to use.
   118  * @noreturn
   119  * @error				Invalid or incorrect Handle.
   120  */
   121 native BfWriteAngle(Handle:bf, Float:angle, numBits=8);
   122 
   123 /**
   124  * Writes a coordinate to a writable bitbuffer (bf_write).
   125  *
   126  * @param bf			bf_write handle to write to.
   127  * @param coord			Coordinate to write.
   128  * @noreturn
   129  * @error				Invalid or incorrect Handle.
   130  */
   131 native BfWriteCoord(Handle:bf, Float:coord);
   132 
   133 /**
   134  * Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
   135  *
   136  * @param bf			bf_write handle to write to.
   137  * @param coord			Coordinate array to write.
   138  * @noreturn
   139  * @error				Invalid or incorrect Handle.
   140  */
   141 native BfWriteVecCoord(Handle:bf, Float:coord[3]);
   142 
   143 /**
   144  * Writes a 3D normal vector to a writable bitbuffer (bf_write).
   145  *
   146  * @param bf			bf_write handle to write to.
   147  * @param vec			Vector to write.
   148  * @noreturn
   149  * @error				Invalid or incorrect Handle.
   150  */
   151 native BfWriteVecNormal(Handle:bf, Float:vec[3]);
   152 
   153 /**
   154  * Writes a 3D angle vector to a writable bitbuffer (bf_write).
   155  *
   156  * @param bf			bf_write handle to write to.
   157  * @param angles		Angle vector to write.
   158  * @noreturn
   159  * @error				Invalid or incorrect Handle.
   160  */
   161 native BfWriteAngles(Handle:bf, Float:angles[3]);
   162 
   163 /** 
   164  * Reads a single bit from a readable bitbuffer (bf_read).
   165  *
   166  * @param bf			bf_read handle to read from.
   167  * @return			Bit value read.
   168  * @error				Invalid or incorrect Handle.
   169  */
   170 native bool:BfReadBool(Handle:bf);
   171 
   172 /**
   173  * Reads a byte from a readable bitbuffer (bf_read).
   174  *
   175  * @param bf			bf_read handle to read from.
   176  * @return			Byte value read (read as 8bit).
   177  * @error				Invalid or incorrect Handle.
   178  */
   179 native BfReadByte(Handle:bf);
   180 
   181 /**
   182  * Reads a character from a readable bitbuffer (bf_read).
   183  *
   184  * @param bf			bf_read handle to read from.
   185  * @return			Character value read.
   186  * @error				Invalid or incorrect Handle.
   187  */
   188 native BfReadChar(Handle:bf);
   189 
   190 /**
   191  * Reads a 16bit integer from a readable bitbuffer (bf_read).
   192  *
   193  * @param bf			bf_read handle to read from.
   194  * @return			Integer value read (read as 16bit).
   195  * @error				Invalid or incorrect Handle.
   196  */
   197 native BfReadShort(Handle:bf);
   198 
   199 /**
   200  * Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
   201  *
   202  * @param bf			bf_read handle to read from.
   203  * @return			Integer value read (read as 16bit).
   204  * @error				Invalid or incorrect Handle.
   205  */
   206 native BfReadWord(Handle:bf);
   207 
   208 /**
   209  * Reads a normal integer to a readable bitbuffer (bf_read).
   210  *
   211  * @param bf			bf_read handle to read from.
   212  * @return			Integer value read (read as 32bit).
   213  * @error				Invalid or incorrect Handle.
   214  */
   215 native BfReadNum(Handle:bf);
   216 
   217 /**
   218  * Reads a floating point number from a readable bitbuffer (bf_read).
   219  *
   220  * @param bf			bf_read handle to read from.
   221  * @return			Floating point value read.
   222  * @error				Invalid or incorrect Handle.
   223  */
   224 native Float:BfReadFloat(Handle:bf);
   225 
   226 /**
   227  * Reads a string from a readable bitbuffer (bf_read).
   228  *
   229  * @param bf			bf_read handle to read from.
   230  * @param buffer		Destination string buffer.
   231  * @param maxlength		Maximum length of output string buffer.
   232  * @param line			If true the buffer will be copied until it reaches a '\n' or a null terminator.
   233  * @noreturn
   234  * @error				Invalid or incorrect Handle, destination string buffer was too short.
   235  */
   236 native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
   237 
   238 /**
   239  * Reads an entity from a readable bitbuffer (bf_read).
   240  * @note This is a wrapper around BfReadShort().
   241  *
   242  * @param bf			bf_read handle to read from.
   243  * @return			Entity index read.
   244  * @error				Invalid or incorrect Handle.
   245  */
   246 native BfReadEntity(Handle:bf);
   247 
   248 /**
   249  * Reads a bit angle from a readable bitbuffer (bf_read).
   250  *
   251  * @param bf			bf_read handle to read from.
   252  * @param numBits		Optional number of bits to use.
   253  * @return			Angle read.
   254  * @error				Invalid or incorrect Handle.
   255  */
   256 native Float:BfReadAngle(Handle:bf, numBits=8);
   257 
   258 /**
   259  * Reads a coordinate from a readable bitbuffer (bf_read).
   260  *
   261  * @param bf			bf_read handle to read from.
   262  * @return			Coordinate read.
   263  * @error				Invalid or incorrect Handle.
   264  */
   265 native Float:BfReadCoord(Handle:bf);
   266 
   267 /**
   268  * Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
   269  *
   270  * @param bf			bf_read handle to read from.
   271  * @param coord			Destination coordinate array.
   272  * @noreturn
   273  * @error				Invalid or incorrect Handle.
   274  */
   275 native BfReadVecCoord(Handle:bf, Float:coord[3]);
   276 
   277 /**
   278  * Reads a 3D normal vector from a readable bitbuffer (bf_read).
   279  *
   280  * @param bf			bf_read handle to read from.
   281  * @param vec			Destination vector array.
   282  * @noreturn
   283  * @error				Invalid or incorrect Handle.
   284  */
   285 native BfReadVecNormal(Handle:bf, Float:vec[3]);
   286 
   287 /**
   288  * Reads a 3D angle vector from a readable bitbuffer (bf_read).
   289  *
   290  * @param bf			bf_read handle to read from.
   291  * @param angles		Destination angle vector.
   292  * @noreturn
   293  * @error				Invalid or incorrect Handle.
   294  */
   295 native BfReadAngles(Handle:bf, Float:angles[3]);