|
| 1 | +/* * |
| 2 | + * ============================================================================= |
| 3 | + * Confogl.inc |
| 4 | + * Confogl (C)2011 Confogl Team |
| 5 | + * ============================================================================= |
| 6 | + * |
| 7 | + * This file is part of the Confogl competitive L4D2 plugin suite. |
| 8 | + * |
| 9 | + * This program is free software; you can redistribute it and/or modify it under |
| 10 | + * the terms of the GNU General Public License, version 3.0, as published by the |
| 11 | + * Free Software Foundation. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | + * details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU General Public License along with |
| 19 | + * this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | + * |
| 21 | + * As a special exception, Confogl Team gives you permission to link the |
| 22 | + * code of this program (as well as its derivative works) to "Half-Life 2," the |
| 23 | + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software |
| 24 | + * by the Valve Corporation. You must obey the GNU General Public License in |
| 25 | + * all respects for all other code used. Additionally, Confogl Team grants |
| 26 | + * this exception to all derivative works. Confogl defines further |
| 27 | + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), |
| 28 | + * or <http://www.sourcemod.net/license.php>. |
| 29 | + * |
| 30 | + */ |
| 31 | +#if defined _confogl_Included |
| 32 | + #endinput |
| 33 | +#endif |
| 34 | +#define _confogl_Included |
| 35 | + |
| 36 | +/* Forwards */ |
| 37 | + |
| 38 | +/** |
| 39 | + * @brief Called when matchmode is fully loaded, before map restart. |
| 40 | + * @remarks Called just before confogl_plugins.cfg executes |
| 41 | + * |
| 42 | + * @noreturn |
| 43 | + */ |
| 44 | +forward void LGO_OnMatchModeLoaded(); |
| 45 | + |
| 46 | +/** |
| 47 | + * @brief Called when matchmode is un-loaded, before map restart. |
| 48 | + * @remarks Plugins are unloaded immediately after this call finishes |
| 49 | + * |
| 50 | + * @noreturn |
| 51 | + */ |
| 52 | +forward void LGO_OnMatchModeUnloaded(); |
| 53 | + |
| 54 | +/* NATIVES */ |
| 55 | + |
| 56 | +/** |
| 57 | + * @brief Tells if a confogl match is currently running |
| 58 | + * @remarks Formerly IsPluginEnabled() internally |
| 59 | + * |
| 60 | + * @return True if matchmode is loaded, false otherwise |
| 61 | + */ |
| 62 | +native bool LGO_IsMatchModeLoaded(); |
| 63 | + |
| 64 | +/** |
| 65 | + * @brief Build a filepath relative to the current running config. |
| 66 | + * @remarks Should produce a path in cfg/cfgogl/CONFIG/ or addons/sourcemod/configs/confogl |
| 67 | + * |
| 68 | + * @param buffer Buffer to write the path to |
| 69 | + * @param maxlength Buffer size |
| 70 | + * @param sFileName Name of the file to look for in the config |
| 71 | + * @noreturn |
| 72 | + */ |
| 73 | +native void LGO_BuildConfigPath(char[] buffer, int maxlength, const char[] sFileName); |
| 74 | + |
| 75 | +/** |
| 76 | + * @brief Execute a cfg file for the current config |
| 77 | + * @remarks Should execute the named .cfg in cfg/ or cfg/cfgogl/CURRENT_CONFIG/ |
| 78 | + * |
| 79 | + * @param sFileName Name of the cfg file to execute |
| 80 | + * @noreturn |
| 81 | + */ |
| 82 | +native void LGO_ExecuteConfigCfg(const char[] sFileName); |
| 83 | + |
| 84 | +/** |
| 85 | + * @brief Tells if map data is available |
| 86 | + * @remarks Map data should be available when any map is loaded, after OnMapStart() |
| 87 | + * |
| 88 | + * @return True if map data is available, false if it is not. |
| 89 | + */ |
| 90 | +native bool LGO_IsMapDataAvailable(); |
| 91 | + |
| 92 | +/** |
| 93 | + * @brief Get an Int value from the MapInfo keyvalues for the current map with a specific key |
| 94 | + * @remarks Mapinfo keyvalues is used to store static data about maps |
| 95 | + * |
| 96 | + * @param key Key to read the value from |
| 97 | + * @param defvalue Default value to return if key is not found (default 0) |
| 98 | + * @return Integer value for given key, or defvalue if key is not found |
| 99 | + */ |
| 100 | +native int LGO_GetMapValueInt(const char[] key, const int defvalue = 0); |
| 101 | + |
| 102 | +/** |
| 103 | + * @brief Get a Float value from the MapInfo keyvalues for the current map with a specific key |
| 104 | + * @remarks Mapinfo keyvalues is used to store static data about maps |
| 105 | + * |
| 106 | + * @param key Key to read the value from |
| 107 | + * @param defvalue Default value to return if key is not found (default 0.0) |
| 108 | + * @return Float value for given key, or defvalue if key is not found |
| 109 | + */ |
| 110 | +native float LGO_GetMapValueFloat(const char[] key, const float defvalue = 0.0); |
| 111 | + |
| 112 | +/** |
| 113 | + * @brief Get a Vector from the MapInfo keyvalues for the current map with a specific key |
| 114 | + * @remarks Mapinfo keyvalues is used to store static data about maps |
| 115 | + * |
| 116 | + * @param key Key to read the value from |
| 117 | + * @param vector Vector to store the result in |
| 118 | + * @param defvalue Default value to use if key is not found (default NULL_VECTOR) |
| 119 | + * @noreturn |
| 120 | + */ |
| 121 | +native void LGO_GetMapValueVector(const char[] key, float vector[3], const float defvalue[3] = NULL_VECTOR); |
| 122 | + |
| 123 | +/** |
| 124 | + * @brief Get a String from the MapInfo keyvalues for the current map with a specific key |
| 125 | + * @remarks Mapinfo keyvalues is used to store static data about maps |
| 126 | + * |
| 127 | + * @param key Key to read the value from |
| 128 | + * @param value String to store the result in |
| 129 | + * @param maxlength Maximum length to write to the value String buffer |
| 130 | + * @param defvalue Default value to use if key is not found (default "") |
| 131 | + * @noreturn |
| 132 | + */ |
| 133 | +native void LGO_GetMapValueString(const char[] key, char[] value, int maxlength, const char[] defvalue = ""); |
| 134 | + |
| 135 | +/** |
| 136 | + * @brief Copy a Subsection from the MapInfo keyvalues for the current map |
| 137 | + * @remarks Mapinfo keyvalues is used to store static data about maps |
| 138 | + * |
| 139 | + * @param kv KeyValues Handle to copy to |
| 140 | + * @param section Name of the section to copy |
| 141 | + * @noreturn |
| 142 | + */ |
| 143 | +native void LGO_CopyMapSubsection(KeyValues kv, const char[] section); |
| 144 | + |
| 145 | +public SharedPlugin __pl_confogl = |
| 146 | +{ |
| 147 | + name = "confogl", |
| 148 | + file = "confoglcompmod.smx", |
| 149 | +#if defined REQUIRE_PLUGIN |
| 150 | + required = 1, |
| 151 | +#else |
| 152 | + required = 0, |
| 153 | +#endif |
| 154 | +}; |
| 155 | + |
| 156 | +#if !defined REQUIRE_PLUGIN |
| 157 | +public void __pl_confogl_SetNTVOptional() |
| 158 | +{ |
| 159 | + MarkNativeAsOptional("LGO_BuildConfigPath"); |
| 160 | + MarkNativeAsOptional("LGO_ExecuteConfigCfg"); |
| 161 | + MarkNativeAsOptional("LGO_IsMapDataAvailable"); |
| 162 | + MarkNativeAsOptional("LGO_GetMapValueInt"); |
| 163 | + MarkNativeAsOptional("LGO_GetMapValueFloat"); |
| 164 | + MarkNativeAsOptional("LGO_GetMapValueVector"); |
| 165 | + MarkNativeAsOptional("LGO_GetMapValueString"); |
| 166 | + MarkNativeAsOptional("LGO_CopyMapSubsection"); |
| 167 | + MarkNativeAsOptional("LGO_IsMatchModeLoaded"); |
| 168 | +} |
| 169 | +#endif |
0 commit comments