plugins/include/datapack.inc
author Scott Ehlert <ds@alliedmods.net>
Sun Mar 30 07:00:22 2008 +0000 (2008-03-30)
changeset 1952 b7aa2b626807
child 2289 44045ead61cd
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 _datapack_included
ds@1952
    34
 #endinput
ds@1952
    35
#endif
ds@1952
    36
#define _datapack_included
ds@1952
    37
ds@1952
    38
/**
ds@1952
    39
 * Creates a new data pack.
ds@1952
    40
 *
ds@1952
    41
 * @return			A Handle to the data pack.  Must be closed with CloseHandle().
ds@1952
    42
 */
ds@1952
    43
native Handle:CreateDataPack();
ds@1952
    44
ds@1952
    45
/**
ds@1952
    46
 * Packs a normal cell into a data pack.
ds@1952
    47
 *
ds@1952
    48
 * @param pack		Handle to the data pack.
ds@1952
    49
 * @param cell		Cell to add.
ds@1952
    50
 * @noreturn
ds@1952
    51
 * @error			Invalid handle.
ds@1952
    52
 */
ds@1952
    53
native WritePackCell(Handle:pack, cell);
ds@1952
    54
ds@1952
    55
/**
ds@1952
    56
 * Packs a float into a data pack.
ds@1952
    57
 *
ds@1952
    58
 * @param pack		Handle to the data pack.
ds@1952
    59
 * @param val		Float to add.
ds@1952
    60
 * @noreturn
ds@1952
    61
 * @error			Invalid handle.
ds@1952
    62
 */
ds@1952
    63
native WritePackFloat(Handle:pack, Float:val);
ds@1952
    64
ds@1952
    65
/**
ds@1952
    66
 * Packs a string into a data pack.
ds@1952
    67
 *
ds@1952
    68
 * @param pack		Handle to the data pack.
ds@1952
    69
 * @param str		String to add.
ds@1952
    70
 * @noreturn
ds@1952
    71
 * @error			Invalid handle.
ds@1952
    72
 */
ds@1952
    73
native WritePackString(Handle:pack, const String:str[]);
ds@1952
    74
ds@1952
    75
/**
ds@1952
    76
 * Reads a cell from a data pack.
ds@1952
    77
 *
ds@1952
    78
 * @param pack		Handle to the data pack.
ds@1952
    79
 * @return			Cell value.
ds@1952
    80
 * @error			Invalid handle, or bounds error.
ds@1952
    81
 */
ds@1952
    82
native ReadPackCell(Handle:pack);
ds@1952
    83
ds@1952
    84
/**
ds@1952
    85
 * Reads a float from a data pack.
ds@1952
    86
 *
ds@1952
    87
 * @param pack		Handle to the data pack.
ds@1952
    88
 * @return			Float value.
ds@1952
    89
 * @error			Invalid handle, or bounds error.
ds@1952
    90
 */
ds@1952
    91
native Float:ReadPackFloat(Handle:pack);
ds@1952
    92
ds@1952
    93
/**
ds@1952
    94
 * Reads a string from a data pack.
ds@1952
    95
 *
ds@1952
    96
 * @param pack		Handle to the data pack.
ds@1952
    97
 * @param buffer	Destination string buffer.
ds@1952
    98
 * @param maxlen	Maximum length of output string buffer.
ds@1952
    99
 * @noreturn
ds@1952
   100
 * @error			Invalid handle, or bounds error.
ds@1952
   101
 */
ds@1952
   102
native ReadPackString(Handle:pack, String:buffer[], maxlen);
ds@1952
   103
ds@1952
   104
/**
ds@1952
   105
 * Resets the position in a data pack.
ds@1952
   106
 *
ds@1952
   107
 * @param pack		Handle to the data pack.
ds@1952
   108
 * @param clear		If true, clears the contained data.
ds@1952
   109
 * @noreturn
ds@1952
   110
 * @error			Invalid handle.
ds@1952
   111
 */
ds@1952
   112
native ResetPack(Handle:pack, bool:clear=false);
ds@1952
   113
ds@1952
   114
/**
ds@1952
   115
 * Returns the read or write position in a data pack.
ds@1952
   116
 *
ds@1952
   117
 * @param pack		Handle to the data pack.
ds@1952
   118
 * @return			Numerical position in the data pack.
ds@1952
   119
 * @error			Invalid handle.
ds@1952
   120
 */
ds@1952
   121
native GetPackPosition(Handle:pack);
ds@1952
   122
ds@1952
   123
/**
ds@1952
   124
 * Sets the read/write position in a data pack.
ds@1952
   125
 *
ds@1952
   126
 * @param pack		Handle to the data pack.
ds@1952
   127
 * @param position	New position to set.
ds@1952
   128
 * @noreturn
ds@1952
   129
 * @error			Invalid handle, or position is beyond the pack bounds.
ds@1952
   130
 */
ds@1952
   131
native SetPackPosition(Handle:pack, position);
ds@1952
   132
ds@1952
   133
/**
ds@1952
   134
 * Returns whether or not a specified number of bytes from the data pack
ds@1952
   135
 *  position to the end can be read.
ds@1952
   136
 *
ds@1952
   137
 * @param pack		Handle to the data pack.
ds@1952
   138
 * @param bytes		Number of bytes to simulate reading.
ds@1952
   139
 * @return			True if can be read, false otherwise.
ds@1952
   140
 * @error			Invalid handle.
ds@1952
   141
 */
ds@1952
   142
native bool:IsPackReadable(Handle:pack, bytes);