Merge branch 'master' into fix-null-func
Conflicts: sourcepawn/compiler/sc5.scp
This commit is contained in:
@@ -68,7 +68,7 @@ stock ByteCountToCells(size)
|
||||
* NOT be auto-intialized.
|
||||
* @return New Handle to the array object.
|
||||
*/
|
||||
native Handle:CreateArray(blocksize=1, startsize=0);
|
||||
native ArrayList:CreateArray(blocksize=1, startsize=0);
|
||||
|
||||
/**
|
||||
* Clears an array of all entries. This is the same as ResizeArray(0).
|
||||
@@ -281,3 +281,27 @@ native FindStringInArray(Handle:array, const String:item[]);
|
||||
* @error Invalid Handle
|
||||
*/
|
||||
native FindValueInArray(Handle:array, any:item);
|
||||
|
||||
methodmap ArrayList < Handle {
|
||||
public ArrayList() = CreateArray;
|
||||
public Clear() = ClearArray;
|
||||
public Clone() = CloneArray;
|
||||
public Resize() = ResizeArray;
|
||||
public Push() = PushArrayCell;
|
||||
public PushString() = PushArrayString;
|
||||
public PushArray() = PushArrayArray;
|
||||
public Get() = GetArrayCell;
|
||||
public GetString() = GetArrayString;
|
||||
public GetArray() = GetArrayArray;
|
||||
public Set() = SetArrayCell;
|
||||
public SetString() = SetArrayString;
|
||||
public SetArray() = SetArrayArray;
|
||||
public ShiftUp() = ShiftArrayUp;
|
||||
public Erase() = RemoveFromArray;
|
||||
public SwapAt() = SwapArrayItems;
|
||||
public FindString() = FindStringInArray;
|
||||
public FindValue() = FindValueInArray;
|
||||
property int Length {
|
||||
public get() = GetArraySize;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -80,7 +80,7 @@ forward bool:OnClientConnect(client, String:rejectmsg[], maxlen);
|
||||
* @param client Client index.
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnClientConnected(client);
|
||||
forward void OnClientConnected(client);
|
||||
|
||||
/**
|
||||
* Called when a client is entering the game.
|
||||
@@ -96,7 +96,7 @@ forward OnClientConnected(client);
|
||||
* @param client Client index.
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnClientPutInServer(client);
|
||||
forward void OnClientPutInServer(client);
|
||||
|
||||
/**
|
||||
* Called when a client is disconnecting from the server.
|
||||
@@ -104,7 +104,7 @@ forward OnClientPutInServer(client);
|
||||
* @param client Client index.
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnClientDisconnect(client);
|
||||
forward void OnClientDisconnect(client);
|
||||
|
||||
/**
|
||||
* Called when a client is disconnected from the server.
|
||||
@@ -112,7 +112,7 @@ forward OnClientDisconnect(client);
|
||||
* @param client Client index.
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnClientDisconnect_Post(client);
|
||||
forward void OnClientDisconnect_Post(client);
|
||||
|
||||
/**
|
||||
* Called when a client is sending a command.
|
||||
@@ -132,7 +132,7 @@ forward Action:OnClientCommand(client, args);
|
||||
* @param client Client index.
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnClientSettingsChanged(client);
|
||||
forward void OnClientSettingsChanged(client);
|
||||
|
||||
/**
|
||||
* Called when a client receives a Steam ID. The state of a client's
|
||||
@@ -145,7 +145,7 @@ forward OnClientSettingsChanged(client);
|
||||
* @param auth Client auth string.
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnClientAuthorized(client, const String:auth[]);
|
||||
forward void OnClientAuthorized(client, const String:auth[]);
|
||||
|
||||
/**
|
||||
* Called once a client is authorized and fully in-game, but
|
||||
@@ -180,7 +180,7 @@ forward Action:OnClientPreAdminCheck(client);
|
||||
* @param client Client index.
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnClientPostAdminFilter(client);
|
||||
forward void OnClientPostAdminFilter(client);
|
||||
|
||||
/**
|
||||
* Called once a client is authorized and fully in-game, and
|
||||
@@ -192,7 +192,7 @@ forward OnClientPostAdminFilter(client);
|
||||
* @param client Client index.
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnClientPostAdminCheck(client);
|
||||
forward void OnClientPostAdminCheck(client);
|
||||
|
||||
/**
|
||||
* This function will be deprecated in a future release. Use the MaxClients variable instead.
|
||||
|
||||
@@ -968,4 +968,4 @@ forward Action:OnClientSayCommand(client, const String:command[], const String:s
|
||||
* @param sArgs Chat argument string.
|
||||
*
|
||||
*/
|
||||
forward OnClientSayCommand_Post(client, const String:command[], const String:sArgs[]);
|
||||
forward void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs);
|
||||
|
||||
@@ -360,6 +360,18 @@ native bool:KeyValuesToFile(Handle:kv, const String:file[]);
|
||||
*/
|
||||
native bool:FileToKeyValues(Handle:kv, const String:file[]);
|
||||
|
||||
/**
|
||||
* Converts a given string to a KeyValues tree. The string is read into
|
||||
* the current postion of the tree.
|
||||
*
|
||||
* @param kv KeyValues Handle.
|
||||
* @param buffer String buffer to load into the KeyValues.
|
||||
* @param resourceName The resource name of the KeyValues, used for error tracking purposes.
|
||||
* @return True on success, false otherwise.
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native bool:StringToKeyValues(Handle:kv, const String:buffer[], const String:resourceName[]="StringToKeyValues");
|
||||
|
||||
/**
|
||||
* Sets whether or not the KeyValues parser will read escape sequences.
|
||||
* For example, \n would be read as a literal newline. This defaults
|
||||
|
||||
@@ -98,12 +98,12 @@ native bool:EndOfMapVoteEnabled();
|
||||
* Called when mapchooser removes a nomination from its list.
|
||||
* Nominations cleared on map start will not trigger this forward
|
||||
*/
|
||||
forward OnNominationRemoved(const String:map[], owner);
|
||||
forward void OnNominationRemoved(const char[] map, int owner);
|
||||
|
||||
/**
|
||||
* Called when mapchooser starts a Map Vote.
|
||||
*/
|
||||
forward OnMapVoteStarted();
|
||||
forward void OnMapVoteStarted();
|
||||
|
||||
|
||||
public SharedPlugin:__pl_mapchooser =
|
||||
|
||||
@@ -152,7 +152,7 @@ enum MenuSource
|
||||
* @param param2 Second action parameter (usually the item).
|
||||
* @noreturn
|
||||
*/
|
||||
functag public MenuHandler(Handle:menu, MenuAction:action, param1, param2);
|
||||
functag public MenuHandler(Menu:menu, MenuAction:action, param1, param2);
|
||||
|
||||
/**
|
||||
* Creates a new, empty menu using the default style.
|
||||
@@ -164,7 +164,7 @@ functag public MenuHandler(Handle:menu, MenuAction:action, param1, param2);
|
||||
* the only default actions.
|
||||
* @return A new menu Handle.
|
||||
*/
|
||||
native Handle:CreateMenu(MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT);
|
||||
native Menu:CreateMenu(MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT);
|
||||
|
||||
/**
|
||||
* Displays a menu to a client.
|
||||
@@ -453,7 +453,7 @@ native GetMenuOptionFlags(Handle:menu);
|
||||
* @noreturn
|
||||
* @error Invalid Handle.
|
||||
*/
|
||||
native SetMenuOptionFlags(Handle:menu, flags);
|
||||
native void SetMenuOptionFlags(Handle:menu, flags);
|
||||
|
||||
/**
|
||||
* Returns whether a vote is in progress.
|
||||
@@ -528,7 +528,7 @@ stock bool:VoteMenuToAll(Handle:menu, time, flags=0)
|
||||
* defines.
|
||||
* @noreturn
|
||||
*/
|
||||
functag public VoteHandler(Handle:menu,
|
||||
functag public VoteHandler(Menu:menu,
|
||||
num_votes,
|
||||
num_clients,
|
||||
const client_info[][2],
|
||||
@@ -546,6 +546,61 @@ functag public VoteHandler(Handle:menu,
|
||||
*/
|
||||
native SetVoteResultCallback(Handle:menu, VoteHandler:callback);
|
||||
|
||||
methodmap Menu < Handle {
|
||||
public Menu() = CreateMenu;
|
||||
public Display() = DisplayMenu;
|
||||
public DisplayAt() = DisplayMenuAtItem;
|
||||
public AddItem() = AddMenuItem;
|
||||
public InsertItem() = InsertMenuItem;
|
||||
public RemoveItem() = RemoveMenuItem;
|
||||
public RemoveAllItems() = RemoveAllMenuItems;
|
||||
public GetItem() = GetMenuItem;
|
||||
public GetTitle() = GetMenuTitle;
|
||||
public SetTitle() = SetMenuTitle;
|
||||
public ToPanel() = CreatePanelFromMenu;
|
||||
public Cancel() = CancelMenu;
|
||||
public DisplayVote() = VoteMenu;
|
||||
public DisplayVoteToAll() = VoteMenuToAll;
|
||||
|
||||
property int Pagination {
|
||||
public get() = GetMenuPagination;
|
||||
public set(int value) {
|
||||
SetMenuPagination(this, value);
|
||||
}
|
||||
}
|
||||
property int OptionFlags {
|
||||
public get() = GetMenuOptionFlags;
|
||||
public set() = SetMenuOptionFlags;
|
||||
}
|
||||
property bool ExitButton {
|
||||
public get() = GetMenuExitButton;
|
||||
public set(bool value) {
|
||||
SetMenuExitButton(this, value);
|
||||
}
|
||||
}
|
||||
property bool ExitBackButton {
|
||||
public get() = GetMenuExitBackButton;
|
||||
public set(bool value) {
|
||||
SetMenuExitBackButton(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
public SetNoVoteButton() = SetMenuNoVoteButton;
|
||||
public SetVoteResultCallback() = SetVoteResultCallback;
|
||||
|
||||
property int ItemCount {
|
||||
public get() = GetMenuItemCount;
|
||||
}
|
||||
property Handle Style {
|
||||
public get() = GetMenuStyle;
|
||||
}
|
||||
property int SelectionPosition {
|
||||
public get() {
|
||||
return GetMenuSelectionPosition();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the number of seconds you should "wait" before displaying
|
||||
* a publicly invocable menu. This number is the time remaining until
|
||||
|
||||
@@ -172,7 +172,7 @@ forward void OnMapStart();
|
||||
/**
|
||||
* Called right before a map ends.
|
||||
*/
|
||||
forward OnMapEnd();
|
||||
forward void OnMapEnd();
|
||||
|
||||
/**
|
||||
* Called when the map has loaded, servercfgfile (server.cfg) has been
|
||||
@@ -201,20 +201,20 @@ forward void OnConfigsExecuted();
|
||||
*
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnAutoConfigsBuffered();
|
||||
forward void OnAutoConfigsBuffered();
|
||||
|
||||
/**
|
||||
* @deprecated Use OnConfigsExecuted() instead.
|
||||
*/
|
||||
#pragma deprecated Use OnConfigsExecuted() instead
|
||||
forward OnServerCfg();
|
||||
forward void OnServerCfg();
|
||||
|
||||
/**
|
||||
* Called after all plugins have been loaded. This is called once for
|
||||
* every plugin. If a plugin late loads, it will be called immediately
|
||||
* after OnPluginStart().
|
||||
*/
|
||||
forward OnAllPluginsLoaded();
|
||||
forward void OnAllPluginsLoaded();
|
||||
|
||||
/**
|
||||
* Returns the calling plugin's Handle.
|
||||
@@ -461,7 +461,7 @@ native GetExtensionFileStatus(const String:name[], String:error[]="", maxlength=
|
||||
*
|
||||
* @param name Library name.
|
||||
*/
|
||||
forward OnLibraryAdded(const String:name[]);
|
||||
forward void OnLibraryAdded(const String:name[]);
|
||||
|
||||
/**
|
||||
* Called right before a library is removed that the current plugin references
|
||||
@@ -470,7 +470,7 @@ forward OnLibraryAdded(const String:name[]);
|
||||
*
|
||||
* @param name Library name.
|
||||
*/
|
||||
forward OnLibraryRemoved(const String:name[]);
|
||||
forward void OnLibraryRemoved(const String:name[]);
|
||||
|
||||
#define MAPLIST_FLAG_MAPSFOLDER (1<<0) /**< On failure, use all maps in the maps folder. */
|
||||
#define MAPLIST_FLAG_CLEARARRAY (1<<1) /**< If an input array is specified, clear it before adding. */
|
||||
@@ -564,7 +564,7 @@ forward bool:OnClientFloodCheck(client);
|
||||
* @param blocked True if client flooded last "say", false otherwise.
|
||||
* @noreturn
|
||||
*/
|
||||
forward OnClientFloodResult(client, bool:blocked);
|
||||
forward void OnClientFloodResult(client, bool:blocked);
|
||||
|
||||
/**
|
||||
* Feature types.
|
||||
|
||||
+64
-70
@@ -35,8 +35,9 @@
|
||||
#include <mapchooser>
|
||||
|
||||
#pragma semicolon 1
|
||||
#pragma newdecls required
|
||||
|
||||
public Plugin:myinfo =
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Map Nominations",
|
||||
author = "AlliedModders LLC",
|
||||
@@ -45,12 +46,12 @@ public Plugin:myinfo =
|
||||
url = "http://www.sourcemod.net/"
|
||||
};
|
||||
|
||||
new Handle:g_Cvar_ExcludeOld = INVALID_HANDLE;
|
||||
new Handle:g_Cvar_ExcludeCurrent = INVALID_HANDLE;
|
||||
Handle g_Cvar_ExcludeOld = null;
|
||||
Handle g_Cvar_ExcludeCurrent = null;
|
||||
|
||||
new Handle:g_MapList = INVALID_HANDLE;
|
||||
new Handle:g_MapMenu = INVALID_HANDLE;
|
||||
new g_mapFileSerial = -1;
|
||||
Menu g_MapMenu = null;
|
||||
Handle g_MapList = null;
|
||||
int g_mapFileSerial = -1;
|
||||
|
||||
#define MAPSTATUS_ENABLED (1<<0)
|
||||
#define MAPSTATUS_DISABLED (1<<1)
|
||||
@@ -58,14 +59,14 @@ new g_mapFileSerial = -1;
|
||||
#define MAPSTATUS_EXCLUDE_PREVIOUS (1<<3)
|
||||
#define MAPSTATUS_EXCLUDE_NOMINATED (1<<4)
|
||||
|
||||
new Handle:g_mapTrie;
|
||||
StringMap g_mapTrie = null;
|
||||
|
||||
public OnPluginStart()
|
||||
public void OnPluginStart()
|
||||
{
|
||||
LoadTranslations("common.phrases");
|
||||
LoadTranslations("nominations.phrases");
|
||||
|
||||
new arraySize = ByteCountToCells(33);
|
||||
int arraySize = ByteCountToCells(33);
|
||||
g_MapList = CreateArray(arraySize);
|
||||
|
||||
g_Cvar_ExcludeOld = CreateConVar("sm_nominate_excludeold", "1", "Specifies if the current map should be excluded from the Nominations list", 0, true, 0.00, true, 1.0);
|
||||
@@ -75,10 +76,10 @@ public OnPluginStart()
|
||||
|
||||
RegAdminCmd("sm_nominate_addmap", Command_Addmap, ADMFLAG_CHANGEMAP, "sm_nominate_addmap <mapname> - Forces a map to be on the next mapvote.");
|
||||
|
||||
g_mapTrie = CreateTrie();
|
||||
g_mapTrie = StringMap();
|
||||
}
|
||||
|
||||
public OnConfigsExecuted()
|
||||
public void OnConfigsExecuted()
|
||||
{
|
||||
if (ReadMapList(g_MapList,
|
||||
g_mapFileSerial,
|
||||
@@ -95,12 +96,12 @@ public OnConfigsExecuted()
|
||||
BuildMapMenu();
|
||||
}
|
||||
|
||||
public OnNominationRemoved(const String:map[], owner)
|
||||
public void OnNominationRemoved(const char[] map, int owner)
|
||||
{
|
||||
new status;
|
||||
int status;
|
||||
|
||||
/* Is the map in our list? */
|
||||
if (!GetTrieValue(g_mapTrie, map, status))
|
||||
if (!g_mapTrie.GetValue(map, status))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -111,10 +112,10 @@ public OnNominationRemoved(const String:map[], owner)
|
||||
return;
|
||||
}
|
||||
|
||||
SetTrieValue(g_mapTrie, map, MAPSTATUS_ENABLED);
|
||||
g_mapTrie.SetValue(map, MAPSTATUS_ENABLED);
|
||||
}
|
||||
|
||||
public Action:Command_Addmap(client, args)
|
||||
public Action Command_Addmap(int client, int args)
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
@@ -122,18 +123,18 @@ public Action:Command_Addmap(client, args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:mapname[64];
|
||||
char mapname[64];
|
||||
GetCmdArg(1, mapname, sizeof(mapname));
|
||||
|
||||
|
||||
new status;
|
||||
if (!GetTrieValue(g_mapTrie, mapname, status))
|
||||
int status;
|
||||
if (!g_mapTrie.GetValue(mapname, status))
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Map was not found", mapname);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new NominateResult:result = NominateMap(mapname, true, 0);
|
||||
NominateResult result = NominateMap(mapname, true, 0);
|
||||
|
||||
if (result > Nominate_Replaced)
|
||||
{
|
||||
@@ -144,7 +145,7 @@ public Action:Command_Addmap(client, args)
|
||||
}
|
||||
|
||||
|
||||
SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
g_mapTrie.SetValue(mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
|
||||
|
||||
ReplyToCommand(client, "%t", "Map Inserted", mapname);
|
||||
@@ -153,7 +154,7 @@ public Action:Command_Addmap(client, args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public OnClientSayCommand_Post(client, const String:command[], const String:sArgs[])
|
||||
public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs)
|
||||
{
|
||||
if (!client)
|
||||
{
|
||||
@@ -162,7 +163,7 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg
|
||||
|
||||
if (strcmp(sArgs, "nominate", false) == 0)
|
||||
{
|
||||
new ReplySource:old = SetCmdReplySource(SM_REPLY_TO_CHAT);
|
||||
ReplySource old = SetCmdReplySource(SM_REPLY_TO_CHAT);
|
||||
|
||||
AttemptNominate(client);
|
||||
|
||||
@@ -170,7 +171,7 @@ public OnClientSayCommand_Post(client, const String:command[], const String:sArg
|
||||
}
|
||||
}
|
||||
|
||||
public Action:Command_Nominate(client, args)
|
||||
public Action Command_Nominate(int client, int args)
|
||||
{
|
||||
if (!client)
|
||||
{
|
||||
@@ -183,11 +184,11 @@ public Action:Command_Nominate(client, args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
decl String:mapname[64];
|
||||
char mapname[64];
|
||||
GetCmdArg(1, mapname, sizeof(mapname));
|
||||
|
||||
new status;
|
||||
if (!GetTrieValue(g_mapTrie, mapname, status))
|
||||
int status;
|
||||
if (!g_mapTrie.GetValue(mapname, status))
|
||||
{
|
||||
ReplyToCommand(client, "%t", "Map was not found", mapname);
|
||||
return Plugin_Handled;
|
||||
@@ -213,7 +214,7 @@ public Action:Command_Nominate(client, args)
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
new NominateResult:result = NominateMap(mapname, false, client);
|
||||
NominateResult result = NominateMap(mapname, false, client);
|
||||
|
||||
if (result > Nominate_Replaced)
|
||||
{
|
||||
@@ -231,43 +232,39 @@ public Action:Command_Nominate(client, args)
|
||||
|
||||
/* Map was nominated! - Disable the menu item and update the trie */
|
||||
|
||||
SetTrieValue(g_mapTrie, mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
g_mapTrie.SetValue(mapname, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
|
||||
decl String:name[64];
|
||||
char name[64];
|
||||
GetClientName(client, name, sizeof(name));
|
||||
PrintToChatAll("[SM] %t", "Map Nominated", name, mapname);
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
AttemptNominate(client)
|
||||
void AttemptNominate(int client)
|
||||
{
|
||||
SetMenuTitle(g_MapMenu, "%T", "Nominate Title", client);
|
||||
DisplayMenu(g_MapMenu, client, MENU_TIME_FOREVER);
|
||||
g_MapMenu.SetTitle("%T", "Nominate Title", client);
|
||||
g_MapMenu.Display(client, MENU_TIME_FOREVER);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
BuildMapMenu()
|
||||
void BuildMapMenu()
|
||||
{
|
||||
if (g_MapMenu != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(g_MapMenu);
|
||||
g_MapMenu = INVALID_HANDLE;
|
||||
}
|
||||
delete g_MapMenu;
|
||||
|
||||
ClearTrie(g_mapTrie);
|
||||
g_mapTrie.Clear();
|
||||
|
||||
g_MapMenu = CreateMenu(Handler_MapSelectMenu, MENU_ACTIONS_DEFAULT|MenuAction_DrawItem|MenuAction_DisplayItem);
|
||||
g_MapMenu = Menu(Handler_MapSelectMenu, MENU_ACTIONS_DEFAULT|MenuAction_DrawItem|MenuAction_DisplayItem);
|
||||
|
||||
decl String:map[64];
|
||||
char map[64];
|
||||
|
||||
new Handle:excludeMaps = INVALID_HANDLE;
|
||||
decl String:currentMap[32];
|
||||
ArrayList excludeMaps;
|
||||
char currentMap[32];
|
||||
|
||||
if (GetConVarBool(g_Cvar_ExcludeOld))
|
||||
{
|
||||
excludeMaps = CreateArray(ByteCountToCells(33));
|
||||
excludeMaps = ArrayList(ByteCountToCells(33));
|
||||
GetExcludeMapList(excludeMaps);
|
||||
}
|
||||
|
||||
@@ -277,9 +274,9 @@ BuildMapMenu()
|
||||
}
|
||||
|
||||
|
||||
for (new i = 0; i < GetArraySize(g_MapList); i++)
|
||||
for (int i = 0; i < GetArraySize(g_MapList); i++)
|
||||
{
|
||||
new status = MAPSTATUS_ENABLED;
|
||||
int status = MAPSTATUS_ENABLED;
|
||||
|
||||
GetArrayString(g_MapList, i, map, sizeof(map));
|
||||
|
||||
@@ -294,36 +291,33 @@ BuildMapMenu()
|
||||
/* Dont bother with this check if the current map check passed */
|
||||
if (GetConVarBool(g_Cvar_ExcludeOld) && status == MAPSTATUS_ENABLED)
|
||||
{
|
||||
if (FindStringInArray(excludeMaps, map) != -1)
|
||||
if (excludeMaps.FindString(map) != -1)
|
||||
{
|
||||
status = MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_PREVIOUS;
|
||||
}
|
||||
}
|
||||
|
||||
AddMenuItem(g_MapMenu, map, map);
|
||||
SetTrieValue(g_mapTrie, map, status);
|
||||
g_MapMenu.AddItem(map, map);
|
||||
g_mapTrie.SetValue(map, status);
|
||||
}
|
||||
|
||||
SetMenuExitButton(g_MapMenu, true);
|
||||
|
||||
if (excludeMaps != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(excludeMaps);
|
||||
}
|
||||
g_MapMenu.ExitButton = true;
|
||||
|
||||
delete excludeMaps;
|
||||
}
|
||||
|
||||
public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2)
|
||||
public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int param2)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case MenuAction_Select:
|
||||
{
|
||||
decl String:map[64], String:name[64];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
char map[64], name[64];
|
||||
menu.GetItem(param2, map, sizeof(map));
|
||||
|
||||
GetClientName(param1, name, 64);
|
||||
|
||||
new NominateResult:result = NominateMap(map, false, param1);
|
||||
NominateResult result = NominateMap(map, false, param1);
|
||||
|
||||
/* Don't need to check for InvalidMap because the menu did that already */
|
||||
if (result == Nominate_AlreadyInVote)
|
||||
@@ -337,7 +331,7 @@ public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
g_mapTrie.SetValue(map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
|
||||
|
||||
if (result == Nominate_Replaced)
|
||||
{
|
||||
@@ -350,12 +344,12 @@ public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2)
|
||||
|
||||
case MenuAction_DrawItem:
|
||||
{
|
||||
decl String:map[64];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
char map[64];
|
||||
menu.GetItem(param2, map, sizeof(map));
|
||||
|
||||
new status;
|
||||
int status;
|
||||
|
||||
if (!GetTrieValue(g_mapTrie, map, status))
|
||||
if (!g_mapTrie.GetValue(map, status))
|
||||
{
|
||||
LogError("Menu selection of item not in trie. Major logic problem somewhere.");
|
||||
return ITEMDRAW_DEFAULT;
|
||||
@@ -372,18 +366,18 @@ public Handler_MapSelectMenu(Handle:menu, MenuAction:action, param1, param2)
|
||||
|
||||
case MenuAction_DisplayItem:
|
||||
{
|
||||
decl String:map[64];
|
||||
GetMenuItem(menu, param2, map, sizeof(map));
|
||||
char map[64];
|
||||
menu.GetItem(param2, map, sizeof(map));
|
||||
|
||||
new status;
|
||||
int status;
|
||||
|
||||
if (!GetTrieValue(g_mapTrie, map, status))
|
||||
if (!g_mapTrie.GetValue(map, status))
|
||||
{
|
||||
LogError("Menu selection of item not in trie. Major logic problem somewhere.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
decl String:display[100];
|
||||
char display[100];
|
||||
|
||||
if ((status & MAPSTATUS_DISABLED) == MAPSTATUS_DISABLED)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
|
||||
#include <sourcemod>
|
||||
|
||||
public Plugin:myinfo =
|
||||
{
|
||||
name = "KeyValues test",
|
||||
author = "AlliedModders LLC",
|
||||
description = "KeyValues test",
|
||||
version = SOURCEMOD_VERSION,
|
||||
url = "http://www.sourcemod.net/"
|
||||
};
|
||||
|
||||
|
||||
public OnPluginStart()
|
||||
{
|
||||
RegServerCmd("test_keyvalues", RunTests);
|
||||
}
|
||||
|
||||
public Action:RunTests(argc)
|
||||
{
|
||||
new String:validKv[] =
|
||||
"\"root\" \
|
||||
{ \
|
||||
\"child\" \"value\" \
|
||||
\"subkey\" { \
|
||||
subchild subvalue \
|
||||
subfloat 1.0 \
|
||||
} \
|
||||
}";
|
||||
|
||||
new Handle:kv = CreateKeyValues("");
|
||||
|
||||
if (!StringToKeyValues(kv, validKv))
|
||||
ThrowError("Valid kv not read correctly!");
|
||||
|
||||
decl String:value[128];
|
||||
KvGetString(kv, "child", value, sizeof(value));
|
||||
|
||||
if (!StrEqual(value, "value"))
|
||||
ThrowError("Child kv should have 'value' but has: '%s'", value);
|
||||
|
||||
if (!KvJumpToKey(kv, "subkey"))
|
||||
ThrowError("No sub kv subkey exists!");
|
||||
|
||||
KvGetString(kv, "subchild", value, sizeof(value));
|
||||
|
||||
if (!StrEqual(value, "subvalue"))
|
||||
ThrowError("Subkv subvalue should have 'subvalue' but has: '%s'", value);
|
||||
|
||||
new Float:subfloat = KvGetFloat(kv, "subfloat");
|
||||
|
||||
if (subfloat != 1.0)
|
||||
ThrowError( "Subkv subfloat should have 1.0 but has: %f", subfloat)
|
||||
|
||||
CloseHandle(kv);
|
||||
|
||||
PrintToServer("KeyValue tests passed!");
|
||||
}
|
||||
Reference in New Issue
Block a user