3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
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
16 #if defined _bitbuffer_included
19 #define _bitbuffer_included
22 * Writes a single bit to a writable bitbuffer (bf_write).
24 * @param bf bf_write handle to write to.
25 * @param bit Bit to write (true for 1, false for 0).
27 * @error Invalid or incorrect Handle.
29 native BfWriteBool(Handle:bf, bool:bit);
32 * Writes a byte to a writable bitbuffer (bf_write).
34 * @param bf bf_write handle to write to.
35 * @param byte Byte to write (value will be written as 8bit).
37 * @error Invalid or incorrect Handle.
39 native BfWriteByte(Handle:bf, byte);
42 * Writes a byte to a writable bitbuffer (bf_write).
44 * @param bf bf_write handle to write to.
45 * @param chr Character to write.
47 * @error Invalid or incorrect Handle.
49 native BfWriteChar(Handle:bf, chr);
52 * Writes a 16bit integer to a writable bitbuffer (bf_write).
54 * @param bf bf_write handle to write to.
55 * @param num Integer to write (value will be written as 16bit).
57 * @error Invalid or incorrect Handle.
59 native BfWriteShort(Handle:bf, num);
62 * Writes a 16bit unsigned integer to a writable bitbuffer (bf_write).
64 * @param bf bf_write handle to write to.
65 * @param num Integer to write (value will be written as 16bit).
67 * @error Invalid or incorrect Handle.
69 native BfWriteWord(Handle:bf, num);
72 * Writes a normal integer to a writable bitbuffer (bf_write).
74 * @param bf bf_write handle to write to.
75 * @param num Integer to write (value will be written as 32bit).
77 * @error Invalid or incorrect Handle.
79 native BfWriteNum(Handle:bf, num);
82 * Writes a floating point number to a writable bitbuffer (bf_write).
84 * @param bf bf_write handle to write to.
85 * @param num Number to write.
87 * @error Invalid or incorrect Handle.
89 native BfWriteFloat(Handle:bf, Float:num);
92 * Writes a string to a writable bitbuffer (bf_write).
94 * @param bf bf_write handle to write to.
95 * @param string Text string to write.
97 * @error Invalid or incorrect Handle.
99 native BfWriteString(Handle:bf, const String:string[]);
102 * Writes an entity to a writable bitbuffer (bf_write).
103 * @note This is a wrapper around BfWriteShort().
105 * @param bf bf_write handle to write to.
106 * @param ent Entity index to write.
108 * @error Invalid or incorrect Handle, or invalid entity.
110 native BfWriteEntity(Handle:bf, ent);
113 * Writes a bit angle to a writable bitbuffer (bf_write).
115 * @param bf bf_write handle to write to.
116 * @param angle Angle to write.
117 * @param numBits Optional number of bits to use.
119 * @error Invalid or incorrect Handle.
121 native BfWriteAngle(Handle:bf, Float:angle, numBits=8);
124 * Writes a coordinate to a writable bitbuffer (bf_write).
126 * @param bf bf_write handle to write to.
127 * @param coord Coordinate to write.
129 * @error Invalid or incorrect Handle.
131 native BfWriteCoord(Handle:bf, Float:coord);
134 * Writes a 3D vector of coordinates to a writable bitbuffer (bf_write).
136 * @param bf bf_write handle to write to.
137 * @param coord Coordinate array to write.
139 * @error Invalid or incorrect Handle.
141 native BfWriteVecCoord(Handle:bf, Float:coord[3]);
144 * Writes a 3D normal vector to a writable bitbuffer (bf_write).
146 * @param bf bf_write handle to write to.
147 * @param vec Vector to write.
149 * @error Invalid or incorrect Handle.
151 native BfWriteVecNormal(Handle:bf, Float:vec[3]);
154 * Writes a 3D angle vector to a writable bitbuffer (bf_write).
156 * @param bf bf_write handle to write to.
157 * @param angles Angle vector to write.
159 * @error Invalid or incorrect Handle.
161 native BfWriteAngles(Handle:bf, Float:angles[3]);
164 * Reads a single bit from a readable bitbuffer (bf_read).
166 * @param bf bf_read handle to read from.
167 * @return Bit value read.
168 * @error Invalid or incorrect Handle.
170 native bool:BfReadBool(Handle:bf);
173 * Reads a byte from a readable bitbuffer (bf_read).
175 * @param bf bf_read handle to read from.
176 * @return Byte value read (read as 8bit).
177 * @error Invalid or incorrect Handle.
179 native BfReadByte(Handle:bf);
182 * Reads a character from a readable bitbuffer (bf_read).
184 * @param bf bf_read handle to read from.
185 * @return Character value read.
186 * @error Invalid or incorrect Handle.
188 native BfReadChar(Handle:bf);
191 * Reads a 16bit integer from a readable bitbuffer (bf_read).
193 * @param bf bf_read handle to read from.
194 * @return Integer value read (read as 16bit).
195 * @error Invalid or incorrect Handle.
197 native BfReadShort(Handle:bf);
200 * Reads a 16bit unsigned integer from a readable bitbuffer (bf_read).
202 * @param bf bf_read handle to read from.
203 * @return Integer value read (read as 16bit).
204 * @error Invalid or incorrect Handle.
206 native BfReadWord(Handle:bf);
209 * Reads a normal integer to a readable bitbuffer (bf_read).
211 * @param bf bf_read handle to read from.
212 * @return Integer value read (read as 32bit).
213 * @error Invalid or incorrect Handle.
215 native BfReadNum(Handle:bf);
218 * Reads a floating point number from a readable bitbuffer (bf_read).
220 * @param bf bf_read handle to read from.
221 * @return Floating point value read.
222 * @error Invalid or incorrect Handle.
224 native Float:BfReadFloat(Handle:bf);
227 * Reads a string from a readable bitbuffer (bf_read).
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.
234 * @error Invalid or incorrect Handle, destination string buffer was too short.
236 native BfReadString(Handle:bf, String:buffer[], maxlength, bool:line=false);
239 * Reads an entity from a readable bitbuffer (bf_read).
240 * @note This is a wrapper around BfReadShort().
242 * @param bf bf_read handle to read from.
243 * @return Entity index read.
244 * @error Invalid or incorrect Handle.
246 native BfReadEntity(Handle:bf);
249 * Reads a bit angle from a readable bitbuffer (bf_read).
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.
256 native Float:BfReadAngle(Handle:bf, numBits=8);
259 * Reads a coordinate from a readable bitbuffer (bf_read).
261 * @param bf bf_read handle to read from.
262 * @return Coordinate read.
263 * @error Invalid or incorrect Handle.
265 native Float:BfReadCoord(Handle:bf);
268 * Reads a 3D vector of coordinates from a readable bitbuffer (bf_read).
270 * @param bf bf_read handle to read from.
271 * @param coord Destination coordinate array.
273 * @error Invalid or incorrect Handle.
275 native BfReadVecCoord(Handle:bf, Float:coord[3]);
278 * Reads a 3D normal vector from a readable bitbuffer (bf_read).
280 * @param bf bf_read handle to read from.
281 * @param vec Destination vector array.
283 * @error Invalid or incorrect Handle.
285 native BfReadVecNormal(Handle:bf, Float:vec[3]);
288 * Reads a 3D angle vector from a readable bitbuffer (bf_read).
290 * @param bf bf_read handle to read from.
291 * @param angles Destination angle vector.
293 * @error Invalid or incorrect Handle.
295 native BfReadAngles(Handle:bf, Float:angles[3]);