plugins/include/bitbuffer.inc
author David Anderson <dvander@alliedmods.net>
Tue Nov 27 02:19:39 2007 +0000 (2007-11-27)
changeset 1729 0f60cc4ce8bb
parent 1330 ab94316bb52b
child 1750 0f73390b01be
permissions -rw-r--r--
added amb1191 - absolute paths
     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.
     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  * @noreturn
   251  * @error				Invalid or incorrect Handle, destination string buffer was too short.
   252  */
   253 native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
   254 
   255 /**
   256  * Reads an entity from a readable bitbuffer (bf_read).
   257  * @note This is a wrapper around BfReadShort().
   258  *
   259  * @param bf			bf_read handle to read from.
   260  * @return			Entity index read.
   261  * @error				Invalid or incorrect Handle.
   262  */
   263 native BfReadEntity(Handle:bf);
   264 
   265 /**
   266  * Reads a bit angle from a readable bitbuffer (bf_read).
   267  *
   268  * @param bf			bf_read handle to read from.
   269  * @param numBits		Optional number of bits to use.
   270  * @return			Angle read.
   271  * @error				Invalid or incorrect Handle.
   272  */
   273 native Float:BfReadAngle(Handle:bf, numBits=8);
   274 
   275 /**
   276  * Reads a coordinate from a readable bitbuffer (bf_read).
   277  *
   278  * @param bf			bf_read handle to read from.
   279  * @return			Coordinate read.
   280  * @error				Invalid or incorrect Handle.
   281  */
   282 native Float:BfReadCoord(Handle:bf);
   283 
   284 /**
   285  * Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
   286  *
   287  * @param bf			bf_read handle to read from.
   288  * @param coord			Destination coordinate array.
   289  * @noreturn
   290  * @error				Invalid or incorrect Handle.
   291  */
   292 native BfReadVecCoord(Handle:bf, Float:coord[3]);
   293 
   294 /**
   295  * Reads a 3D normal vector from a readable bitbuffer (bf_read).
   296  *
   297  * @param bf			bf_read handle to read from.
   298  * @param vec			Destination vector array.
   299  * @noreturn
   300  * @error				Invalid or incorrect Handle.
   301  */
   302 native BfReadVecNormal(Handle:bf, Float:vec[3]);
   303 
   304 /**
   305  * Reads a 3D angle vector from a readable bitbuffer (bf_read).
   306  *
   307  * @param bf			bf_read handle to read from.
   308  * @param angles		Destination angle vector.
   309  * @noreturn
   310  * @error				Invalid or incorrect Handle.
   311  */
   312 native BfReadAngles(Handle:bf, Float:angles[3]);