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