plugins/include/datapack.inc
author Asher Baker <asherkin@gmail.com>
Thu Apr 26 16:58:18 2012 +0100 (2012-04-26)
changeset 3488 bee90c8ef6c3
parent 2289 44045ead61cd
child 4207 32fb4b86bd84
permissions -rw-r--r--
Fixed client serials not being unique on Windows (bug 5285, r=psychonic).
dvander@428
     1
/**
ds@475
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
ds@1947
     4
 * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
ds@1330
     5
 * =============================================================================
ds@1330
     6
 *
ds@1330
     7
 * This file is part of the SourceMod/SourcePawn SDK.
dvander@428
     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>.
dvander@428
    29
 *
dvander@428
    30
 * Version: $Id$
dvander@428
    31
 */
dvander@428
    32
dvander@428
    33
#if defined _datapack_included
dvander@428
    34
 #endinput
dvander@428
    35
#endif
dvander@428
    36
#define _datapack_included
dvander@428
    37
dvander@428
    38
/**
dvander@428
    39
 * Creates a new data pack.
dvander@428
    40
 *
ds@475
    41
 * @return			A Handle to the data pack.  Must be closed with CloseHandle().
dvander@428
    42
 */
dvander@428
    43
native Handle:CreateDataPack();
dvander@428
    44
dvander@428
    45
/**
dvander@428
    46
 * Packs a normal cell into a data pack.
dvander@428
    47
 *
dvander@428
    48
 * @param pack		Handle to the data pack.
dvander@428
    49
 * @param cell		Cell to add.
dvander@428
    50
 * @noreturn
dvander@428
    51
 * @error			Invalid handle.
dvander@428
    52
 */
dvander@428
    53
native WritePackCell(Handle:pack, cell);
dvander@428
    54
dvander@428
    55
/**
faluco@461
    56
 * Packs a float into a data pack.
faluco@461
    57
 *
faluco@461
    58
 * @param pack		Handle to the data pack.
faluco@461
    59
 * @param val		Float to add.
faluco@461
    60
 * @noreturn
faluco@461
    61
 * @error			Invalid handle.
faluco@461
    62
 */
faluco@461
    63
native WritePackFloat(Handle:pack, Float:val);
faluco@461
    64
faluco@461
    65
/**
faluco@461
    66
 * Packs a string into a data pack.
faluco@461
    67
 *
faluco@461
    68
 * @param pack		Handle to the data pack.
faluco@461
    69
 * @param str		String to add.
faluco@461
    70
 * @noreturn
faluco@461
    71
 * @error			Invalid handle.
faluco@461
    72
 */
dvander@1015
    73
native WritePackString(Handle:pack, const String:str[]);
faluco@461
    74
faluco@461
    75
/**
dvander@428
    76
 * Reads a cell from a data pack.
dvander@428
    77
 *
dvander@428
    78
 * @param pack		Handle to the data pack.
dvander@428
    79
 * @return			Cell value.
dvander@428
    80
 * @error			Invalid handle, or bounds error.
dvander@428
    81
 */
dvander@428
    82
native ReadPackCell(Handle:pack);
dvander@428
    83
dvander@428
    84
/**
faluco@461
    85
 * Reads a float from a data pack.
faluco@461
    86
 *
faluco@461
    87
 * @param pack		Handle to the data pack.
faluco@461
    88
 * @return			Float value.
faluco@461
    89
 * @error			Invalid handle, or bounds error.
faluco@461
    90
 */
faluco@461
    91
native Float:ReadPackFloat(Handle:pack);
faluco@461
    92
faluco@461
    93
/**
faluco@461
    94
 * Reads a string from a data pack.
faluco@461
    95
 *
faluco@461
    96
 * @param pack		Handle to the data pack.
faluco@461
    97
 * @param buffer	Destination string buffer.
faluco@461
    98
 * @param maxlen	Maximum length of output string buffer.
faluco@461
    99
 * @noreturn
faluco@461
   100
 * @error			Invalid handle, or bounds error.
faluco@461
   101
 */
faluco@461
   102
native ReadPackString(Handle:pack, String:buffer[], maxlen);
faluco@461
   103
faluco@461
   104
/**
dvander@428
   105
 * Resets the position in a data pack.
dvander@428
   106
 *
dvander@428
   107
 * @param pack		Handle to the data pack.
dvander@428
   108
 * @param clear		If true, clears the contained data.
dvander@428
   109
 * @noreturn
ds@475
   110
 * @error			Invalid handle.
dvander@428
   111
 */
dvander@428
   112
native ResetPack(Handle:pack, bool:clear=false);
dvander@428
   113
dvander@428
   114
/**
dvander@428
   115
 * Returns the read or write position in a data pack.
dvander@428
   116
 *
dvander@428
   117
 * @param pack		Handle to the data pack.
dvander@428
   118
 * @return			Numerical position in the data pack.
ds@475
   119
 * @error			Invalid handle.
dvander@428
   120
 */
dvander@428
   121
native GetPackPosition(Handle:pack);
dvander@428
   122
dvander@428
   123
/**
dvander@428
   124
 * Sets the read/write position in a data pack.
dvander@428
   125
 *
dvander@428
   126
 * @param pack		Handle to the data pack.
dvander@428
   127
 * @param position	New position to set.
dvander@428
   128
 * @noreturn
faluco@461
   129
 * @error			Invalid handle, or position is beyond the pack bounds.
dvander@428
   130
 */
faluco@461
   131
native SetPackPosition(Handle:pack, position);
faluco@461
   132
faluco@461
   133
/**
faluco@461
   134
 * Returns whether or not a specified number of bytes from the data pack
faluco@461
   135
 *  position to the end can be read.
faluco@461
   136
 *
faluco@461
   137
 * @param pack		Handle to the data pack.
faluco@461
   138
 * @param bytes		Number of bytes to simulate reading.
ds@475
   139
 * @return			True if can be read, false otherwise.
ds@475
   140
 * @error			Invalid handle.
faluco@461
   141
 */
faluco@461
   142
native bool:IsPackReadable(Handle:pack, bytes);