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