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