From 722a23c818ccc7ec50f40303e1b00707c938e3bd Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 15 Nov 2014 15:22:37 -0800 Subject: [PATCH 1/2] Redo menu methodmaps. --- core/logic/smn_menus.cpp | 41 ++ plugins/include/menus.inc | 485 +++++++++++++----- sourcepawn/compiler/sc1.cpp | 15 +- .../tests/ok-typed-vararg-in-new-function.sp | 3 + 4 files changed, 411 insertions(+), 133 deletions(-) create mode 100644 sourcepawn/compiler/tests/ok-typed-vararg-in-new-function.sp diff --git a/core/logic/smn_menus.cpp b/core/logic/smn_menus.cpp index a69a2f53..ae07bc09 100644 --- a/core/logic/smn_menus.cpp +++ b/core/logic/smn_menus.cpp @@ -1645,6 +1645,47 @@ REGISTER_NATIVES(menuNatives) {"SetVoteResultCallback", SetVoteResultCallback}, {"VoteMenu", VoteMenu}, {"SetMenuNoVoteButton", SetMenuNoVoteButton}, + + // Transitional syntax support. + {"Panel.Panel", CreatePanel}, + {"Panel.TextRemaining.get", GetPanelTextRemaining}, + {"Panel.CurrentKey.get", GetPanelCurrentKey}, + {"Panel.CurrentKey.set", SetPanelCurrentKey}, + {"Panel.Style", GetPanelStyle}, + {"Panel.CanDrawFlags", CanPanelDrawFlags}, + {"Panel.SetTitle", SetPanelTitle}, + {"Panel.SetKeys", SetPanelKeys}, + {"Panel.Send", SendPanelToClient}, + {"Panel.DrawItem", DrawPanelItem}, + {"Panel.DrawText", DrawPanelText}, + + {"Menu.Menu", CreateMenu}, + {"Menu.Display", DisplayMenu}, + {"Menu.DisplayAt", DisplayMenuAtItem}, + {"Menu.AddItem", AddMenuItem}, + {"Menu.InsertItem", InsertMenuItem}, + {"Menu.RemoveItem", RemoveMenuItem}, + {"Menu.RemoveAllItems", RemoveAllMenuItems}, + {"Menu.GetItem", GetMenuItem}, + {"Menu.GetTitle", GetMenuTitle}, + {"Menu.SetTitle", SetMenuTitle}, + {"Menu.ToPanel", CreatePanelFromMenu}, + {"Menu.Cancel", CancelMenu}, + {"Menu.DisplayVote", VoteMenu}, + {"Menu.Pagination.get", GetMenuPagination}, + {"Menu.Pagination.set", SetMenuPagination}, + {"Menu.OptionFlags.get", GetMenuOptionFlags}, + {"Menu.OptionFlags.set", SetMenuOptionFlags}, + {"Menu.ExitButton.get", GetMenuExitButton}, + {"Menu.ExitButton.set", SetMenuExitButton}, + {"Menu.ExitBackButton.get", GetMenuExitBackButton}, + {"Menu.ExitBackButton.set", SetMenuExitBackButton}, + {"Menu.NoVoteButton.set", SetMenuNoVoteButton}, + {"Menu.VoteResultCallback.set", SetVoteResultCallback}, + {"Menu.ItemCount.get", GetMenuItemCount}, + {"Menu.Style.get", GetMenuStyle}, + {"Menu.Selection.get", GetMenuSelectionPosition}, + {NULL, NULL}, }; diff --git a/plugins/include/menus.inc b/plugins/include/menus.inc index fb41f023..22ba0a09 100644 --- a/plugins/include/menus.inc +++ b/plugins/include/menus.inc @@ -153,6 +153,294 @@ enum MenuSource */ typedef MenuHandler = function int (Menu menu, MenuAction action, int param1, int param2); +// Panels are used for drawing raw menus without any extra helper functions. +// Handles must be closed via delete or CloseHandle(). +methodmap Panel < Handle +{ + // Constructor for a new Panel. + // + // @param hStyle MenuStyle Handle, or null to use the default style. + public native Panel(Handle hStyle = null); + + // Sets the panel's title. + // + // @param text Text to set as the title. + // @param onlyIfEmpty If true, the title will only be set if no title is set. + public native void SetTitle(const char[] text, bool onlyIfEmpty=false); + + // Draws an item on a panel. If the item takes up a slot, the position + // is returned. + // + // @param text Display text to use. If not a raw line, + // the style may automatically add color markup. + // No numbering or newlines are needed. + // @param style ITEMDRAW style flags. + // @return A slot position, or 0 if item was a rawline or could not be drawn. + public native void DrawItem(const char[] text, style=ITEMDRAW_DEFAULT); + + // Draws a raw line of text on a panel, without any markup other than a + // newline. + // + // @param text Display text to use. + // @return True on success, false if raw lines are not supported. + public native bool DrawText(const char[] text); + + // Returns whether or not the given drawing flags are supported by + // the menu style. + // + // @param style ITEMDRAW style flags. + // @return True if item is drawable, false otherwise. + public native bool CanDrawFlags(int style); + + // Sets the selectable key map of a panel. This is not supported by + // all styles (only by Radio, as of this writing). + // + // @param keys An integer where each bit N allows key + // N+1 to be selected. If no keys are selectable, + // then key 0 (bit 9) is automatically set. + // @return True if supported, false otherwise. + public native bool SetKeys(int keys); + + // Sends a panel to a client. Unlike full menus, the handler + // function will only receive the following actions, both of + // which will have null for a menu, and the client as param1. + // + // MenuAction_Select (param2 will be the key pressed) + // MenuAction_Cancel (param2 will be the reason) + // + // Also, if the menu fails to display, no callbacks will be called. + // + // @param client A client to draw to. + // @param handler The MenuHandler function to catch actions with. + // @param time Time to hold the menu for. + // @return True on success, false on failure. + public native bool Send(int client, MenuHandler handler, int time); + + // Returns the amount of text the menu can still hold. If this is + // limit is reached or overflowed, the text is silently truncated. + // + // Radio menus: Currently 511 characters (512 bytes). + // Valve menus: Currently -1 (no meaning). + property int TextRemaining { + public native get(); + } + + // Returns or sets the current key position, starting at 1. This cannot be + // used to traverse backwards. + property int CurrentKey { + public native get(); + public native set(int key); + } + + // Returns the panel's style. Style handles are global and cannot be closed. + property Handle Style { + public native get(); + } +}; + +// A menu is a helper object for managing in-game menus. +methodmap Menu < Handle +{ + // Creates a new, empty menu using the default style. + // + // @param handler Function which will receive menu actions. + // @param actions Optionally set which actions to receive. Select, + // Cancel, and End will always be received regardless + // of whether they are set or not. They are also + // the only default actions. + public native Menu(MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT); + + // Displays a menu to a client. + // + // @param client Client index. + // @param time Maximum time to leave menu on the screen. + // @return True on success, false on failure. + // @error Client not in game. + public native bool Display(int client, int time); + + // Displays a menu to a client, starting from the given item. + // + // @param client Client index. + // @param first_item First item to begin drawing from. + // @param time Maximum time to leave menu on the screen. + // @return True on success, false on failure. + // @error Client not in game. + /// + public native bool DisplayAt(int client, int first_item, int time); + + // Appends a new item to the end of a menu. + // + // @param info Item information string. + // @param display Default item display string. + // @param style Drawing style flags. Anything other than DEFAULT or + // DISABLED will be completely ignored when paginating. + // @return True on success, false on failure. + // @error Item limit reached. + public native bool AddItem(const char[] info, const char[] display, int style=ITEMDRAW_DEFAULT); + + // Inserts an item into the menu before a certain position; the new item will + // be at the given position and all next items pushed forward. + // + // @param position Position, starting from 0. + // @param info Item information string. + // @param display Default item display string. + // @param style Drawing style flags. Anything other than DEFAULT or + // DISABLED will be completely ignored when paginating. + // @return True on success, false on failure. + // @error Invalid menu position. + public native bool InsertItem(int position, const char[] info, + const char[] display, int style=ITEMDRAW_DEFAULT); + + // Removes an item from the menu. + // + // @param position Position, starting from 0. + // @return True on success, false on failure. + // @error Invalid menu position. + public native bool RemoveItem(int position); + + // Removes all items from a menu. + public native void RemoveAllItems(); + + // Retrieves information about a menu item. + // + // @param position Position, starting from 0. + // @param infoBuf Info buffer. + // @param infoBufLen Maximum length of the info buffer. + // @param style By-reference variable to store drawing flags. + // @param dispBuf Display buffer. + // @param dispBufLen Maximum length of the display buffer. + // @return True on success, false if position is invalid. + public native bool GetItem(int position, char[] infoBuf, int infoBufLen, + int &style=0, char[] dispBuf="", int dispBufLen=0); + + // Sets the menu's default title/instruction message. + // + // @param fmt Message string format + // @param ... Message string arguments. + public native void SetTitle(const char[] fmt, any ...); + + // Returns the text of a menu's title. + // + // @param menu Menu Handle. + // @param buffer Buffer to store title. + // @param maxlength Maximum length of the buffer. + // @return Number of bytes written. + public native void GetTitle(char[] buffer, int maxlength); + + // Creates a raw MenuPanel based off the menu's style. + // The Handle must be freed with CloseHandle(). + // + // @param menu Menu Handle. + // @return A new MenuPanel Handle. + public native Panel ToPanel(); + + // Cancels a menu from displaying on all clients. While the + // cancellation is in progress, this menu cannot be re-displayed + // to any clients. + // + // The menu may still exist on the client's screen after this command. + // This simply verifies that the menu is not being used anywhere. + // + // If any vote is in progress on a menu, it will be cancelled. + public native void Cancel(); + + // Broadcasts a menu to a list of clients. The most selected item will be + // returned through MenuAction_End. On a tie, a random item will be returned + // from a list of the tied items. + // + // Note that MenuAction_VoteEnd and MenuAction_VoteStart are both + // default callbacks and do not need to be enabled. + // + // @param clients Array of clients to broadcast to. + // @param numClients Number of clients in the array. + // @param time Maximum time to leave menu on the screen. + // @param flags Optional voting flags. + // @return True on success, false if this menu already has a + // vote session in progress. + // @error A vote is already in progress. + public native bool DisplayVote(int[] clients, int numClients, int time, int flags=0); + + // Sends a vote menu to all clients. See VoteMenu() for more information. + // + // @param time Maximum time to leave menu on the screen. + // @param flags Optional voting flags. + // @return True on success, false if this menu already has a + // vote session in progress. + public bool DisplayVoteToAll(int time, int flags=0) { + int total = 0; + int[] players = new int[MaxClients]; + for (int i = 1; i <= MaxClients; i++) { + if (!IsClientInGame(i) || IsFakeClient(i)) + continue + players[total++] = i; + } + return this.DisplayVote(players, total, time, flags); + } + + // Get or set the menu's pagination. + // + // If pgination is MENU_NO_PAGINATION, and the exit button flag is set, + // then the exit button flag is removed. It can be re-applied if desired. + property int Pagination { + public native get(); + public native set(int value); + } + + // Get or set the menu's option flags. + // + // If a certain bit is not supported, it will be stripped before being set. + property int OptionFlags { + public native get(); + public native set(int value); + } + + // Returns whether or not the menu has an exit button. By default, menus + // have an exit button. + property bool ExitButton { + public native get(); + public native set(bool value); + } + + // Controls whether or not the menu has an "exit back" button. By default, + // menus do not have an exit back button. + // + // Exit Back buttons appear as "Back" on page 1 of paginated menus and have + // functionality defined by the user in MenuEnd_ExitBack. + property bool ExitBackButton { + public native get(); + public native set(bool value); + } + + // Sets whether or not the menu has a "no vote" button in slot 1. + // By default, menus do not have a no vote button. + property bool NoVoteButton { + public native set(bool value); + } + + // Sets an advanced vote handling callback. If this callback is set, + // MenuAction_VoteEnd will not be called. + property VoteHandler VoteResultCallback { + public native set(VoteHandler handler); + } + + // Returns the number of items in a menu. + property int ItemCount { + public native get(); + } + + // Returns the menu style. The Handle is global and cannot be closed. + property Handle Style { + public native get(); + } + + // Returns the first item on the page of a currently selected menu. + // + // This is only valid inside a MenuAction_Select callback. + property int Selection { + public native get(); + } +} + /** * Creates a new, empty menu using the default style. * @@ -163,7 +451,7 @@ typedef MenuHandler = function int (Menu menu, MenuAction action, int param1, in * the only default actions. * @return A new menu Handle. */ -native Menu:CreateMenu(MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT); +native Menu CreateMenu(MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT); /** * Displays a menu to a client. @@ -174,7 +462,7 @@ native Menu:CreateMenu(MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFA * @return True on success, false on failure. * @error Invalid Handle or client not in game. */ -native bool:DisplayMenu(Handle:menu, client, time); +native bool DisplayMenu(Handle menu, int client, int time); /** * Displays a menu to a client, starting from the given item. @@ -186,7 +474,7 @@ native bool:DisplayMenu(Handle:menu, client, time); * @return True on success, false on failure. * @error Invalid Handle or client not in game. */ -native bool:DisplayMenuAtItem(Handle:menu, client, first_item, time); +native bool DisplayMenuAtItem(Handle menu, int client, int first_item, int time); /** * Appends a new item to the end of a menu. @@ -199,10 +487,10 @@ native bool:DisplayMenuAtItem(Handle:menu, client, first_item, time); * @return True on success, false on failure. * @error Invalid Handle or item limit reached. */ -native AddMenuItem(Handle:menu, - const String:info[], - const String:display[], - style=ITEMDRAW_DEFAULT); +native bool AddMenuItem(Handle menu, + const char[] info, + const char[] display, + int style=ITEMDRAW_DEFAULT); /** * Inserts an item into the menu before a certain position; the new item will @@ -217,11 +505,11 @@ native AddMenuItem(Handle:menu, * @return True on success, false on failure. * @error Invalid Handle or menu position. */ -native bool:InsertMenuItem(Handle:menu, +native bool InsertMenuItem(Handle menu, position, - const String:info[], - const String:display[], - style=ITEMDRAW_DEFAULT); + const char[] info, + const char[] display, + int style=ITEMDRAW_DEFAULT); /** * Removes an item from the menu. @@ -231,16 +519,15 @@ native bool:InsertMenuItem(Handle:menu, * @return True on success, false on failure. * @error Invalid Handle or menu position. */ -native bool:RemoveMenuItem(Handle:menu, position); +native bool RemoveMenuItem(Handle menu, int position); /** * Removes all items from a menu. * * @param menu Menu Handle. - * @noreturn * @error Invalid Handle or menu position. */ -native RemoveAllMenuItems(Handle:menu); +native void RemoveAllMenuItems(Handle menu); /** * Retrieves information about a menu item. @@ -255,13 +542,13 @@ native RemoveAllMenuItems(Handle:menu); * @return True on success, false if position is invalid. * @error Invalid Handle. */ -native bool:GetMenuItem(Handle:menu, - position, - String:infoBuf[], - infoBufLen, - &style=0, - String:dispBuf[]="", - dispBufLen=0); +native bool GetMenuItem(Handle menu, + int position, + char[] infoBuf, + int infoBufLen, + int &style=0, + char[] dispBuf="", + int dispBufLen=0); /** * Returns the first item on the page of a currently selected menu. @@ -274,7 +561,7 @@ native bool:GetMenuItem(Handle:menu, * position. * @error Not called from inside a MenuAction_Select callback. */ -native GetMenuSelectionPosition(); +native int GetMenuSelectionPosition(); /** * Returns the number of items in a menu. @@ -283,7 +570,7 @@ native GetMenuSelectionPosition(); * @return Number of items in the menu. * @error Invalid Handle. */ -native GetMenuItemCount(Handle:menu); +native int GetMenuItemCount(Handle menu); /** * Sets whether the menu should be paginated or not. @@ -297,7 +584,7 @@ native GetMenuItemCount(Handle:menu); * low. * @error Invalid Handle. */ -native bool:SetMenuPagination(Handle:menu, itemsPerPage); +native bool SetMenuPagination(Handle menu, int itemsPerPage); /** * Returns a menu's pagination setting. @@ -306,7 +593,7 @@ native bool:SetMenuPagination(Handle:menu, itemsPerPage); * @return Pagination setting. * @error Invalid Handle. */ -native GetMenuPagination(Handle:menu); +native int GetMenuPagination(Handle menu); /** * Returns a menu's MenuStyle Handle. The Handle @@ -316,7 +603,7 @@ native GetMenuPagination(Handle:menu); * @return Handle to the menu's draw style. * @error Invalid Handle. */ -native Handle:GetMenuStyle(Handle:menu); +native Handle GetMenuStyle(Handle menu); /** * Sets the menu's default title/instruction message. @@ -324,10 +611,9 @@ native Handle:GetMenuStyle(Handle:menu); * @param menu Menu Handle. * @param fmt Message string format * @param ... Message string arguments. - * @noreturn * @error Invalid Handle. */ -native SetMenuTitle(Handle:menu, const String:fmt[], any:...); +native void SetMenuTitle(Handle menu, const char[] fmt, any ...); /** * Returns the text of a menu's title. @@ -338,7 +624,7 @@ native SetMenuTitle(Handle:menu, const String:fmt[], any:...); * @return Number of bytes written. * @error Invalid Handle/ */ -native GetMenuTitle(Handle:menu, String:buffer[], maxlength); +native int GetMenuTitle(Handle menu, char[] buffer, int maxlength); /** * Creates a raw MenuPanel based off the menu's style. @@ -348,7 +634,7 @@ native GetMenuTitle(Handle:menu, String:buffer[], maxlength); * @return A new MenuPanel Handle. * @error Invalid Handle. */ -native Handle:CreatePanelFromMenu(Handle:menu); +native Panel CreatePanelFromMenu(Handle menu); /** * Returns whether or not the menu has an exit button. @@ -358,7 +644,7 @@ native Handle:CreatePanelFromMenu(Handle:menu); * @return True if the menu has an exit button; false otherwise. * @error Invalid Handle. */ -native bool:GetMenuExitButton(Handle:menu); +native bool GetMenuExitButton(Handle menu); /** * Sets whether or not the menu has an exit button. By default, paginated menus @@ -376,7 +662,7 @@ native bool:GetMenuExitButton(Handle:menu); * @return True if allowed; false on failure. * @error Invalid Handle. */ -native bool:SetMenuExitButton(Handle:menu, bool:button); +native bool SetMenuExitButton(Handle menu, bool button); /** * Returns whether or not the menu has an "exit back" button. By default, @@ -389,7 +675,7 @@ native bool:SetMenuExitButton(Handle:menu, bool:button); * @return True if the menu has an exit back button; false otherwise. * @error Invalid Handle. */ -native bool:GetMenuExitBackButton(Handle:menu); +native bool GetMenuExitBackButton(Handle menu); /** * Sets whether or not the menu has an "exit back" button. By default, menus @@ -402,7 +688,7 @@ native bool:GetMenuExitBackButton(Handle:menu); * @param button True to enable the button, false to remove it. * @error Invalid Handle. */ -native SetMenuExitBackButton(Handle:menu, bool:button); +native void SetMenuExitBackButton(Handle menu, bool button); /** * Sets whether or not the menu has a "no vote" button in slot 1. @@ -413,7 +699,7 @@ native SetMenuExitBackButton(Handle:menu, bool:button); * @return True if allowed; false on failure. * @error Invalid Handle. */ -native bool:SetMenuNoVoteButton(Handle:menu, bool:button); +native bool SetMenuNoVoteButton(Handle menu, bool button); /** * Cancels a menu from displaying on all clients. While the @@ -426,10 +712,9 @@ native bool:SetMenuNoVoteButton(Handle:menu, bool:button); * If any vote is in progress on a menu, it will be cancelled. * * @param menu Menu Handle. - * @noreturn * @error Invalid Handle. */ -native CancelMenu(Handle:menu); +native void CancelMenu(Handle menu); /** * Retrieves a menu's option flags. @@ -438,7 +723,7 @@ native CancelMenu(Handle:menu); * @return A bitstring of MENUFLAG bits. * @error Invalid Handle. */ -native GetMenuOptionFlags(Handle:menu); +native int GetMenuOptionFlags(Handle menu); /** * Sets a menu's option flags. @@ -449,10 +734,9 @@ native GetMenuOptionFlags(Handle:menu); * * @param menu Menu Handle. * @param flags A new bitstring of MENUFLAG bits. - * @noreturn * @error Invalid Handle. */ -native void SetMenuOptionFlags(Handle:menu, flags); +native void SetMenuOptionFlags(Handle menu, int flags); /** * Returns whether a vote is in progress. @@ -460,15 +744,14 @@ native void SetMenuOptionFlags(Handle:menu, flags); * @param menu Deprecated; no longer used. * @return True if a vote is in progress, false otherwise. */ -native bool:IsVoteInProgress(Handle:menu=INVALID_HANDLE); +native bool IsVoteInProgress(Handle menu=INVALID_HANDLE); /** * Cancels the vote in progress. * - * @noreturn * @error If no vote is in progress. */ -native CancelVote(); +native void CancelVote(); /** * Broadcasts a menu to a list of clients. The most selected item will be @@ -487,7 +770,7 @@ native CancelVote(); * in progress. * @error Invalid Handle, or a vote is already in progress. */ -native bool:VoteMenu(Handle:menu, clients[], numClients, time, flags=0); +native bool VoteMenu(Handle menu, int[] clients, int numClients, int time, int flags=0); /** * Sends a vote menu to all clients. See VoteMenu() for more information. @@ -499,7 +782,7 @@ native bool:VoteMenu(Handle:menu, clients[], numClients, time, flags=0); * in progress. * @error Invalid Handle. */ -stock bool:VoteMenuToAll(Handle:menu, time, flags=0) +stock bool VoteMenuToAll(Handle menu, int time, int flags=0) { new total; decl players[MaxClients]; @@ -515,6 +798,7 @@ stock bool:VoteMenuToAll(Handle:menu, time, flags=0) return VoteMenu(menu, players, total, time, flags); } + /** * Callback for when a vote has ended and results are available. * @@ -525,7 +809,6 @@ stock bool:VoteMenuToAll(Handle:menu, time, flags=0) * @param num_items Number of unique items that were selected. * @param item_info Array of items, sorted by count. Use VOTEINFO_ITEM * defines. - * @noreturn */ typedef VoteHandler = function void ( Menu menu, @@ -542,65 +825,9 @@ typedef VoteHandler = function void ( * * @param menu Menu Handle. * @param callback Callback function. - * @noreturn * @error Invalid Handle or callback. */ -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(); - } - } -} +native void SetVoteResultCallback(Handle menu, VoteHandler callback); /** * Returns the number of seconds you should "wait" before displaying @@ -609,7 +836,7 @@ methodmap Menu < Handle { * * @return Number of seconds to wait, or 0 for none. */ -native CheckVoteDelay(); +native int CheckVoteDelay(); /** * Returns whether a client is in the pool of clients allowed @@ -620,7 +847,7 @@ native CheckVoteDelay(); * @return True if client is allowed to vote, false otherwise. * @error If no vote is in progress or client index is invalid. */ -native bool:IsClientInVotePool(client); +native bool IsClientInVotePool(int client); /** * Redraws the current vote menu to a client in the voting pool. @@ -629,10 +856,10 @@ native bool:IsClientInVotePool(client); * @param revotes True to allow revotes, false otherwise. * @return True on success, false if the client is in the vote pool * but cannot vote again. - * @error No vote in progress, client is not in the voting pool, + * @error No vote in progress, int client is not in the voting pool, * or client index is invalid. */ -native bool:RedrawClientVoteMenu(client, bool:revotes=true); +native bool RedrawClientVoteMenu(int client, bool revotes=true); /** * Returns a style's global Handle. @@ -640,7 +867,7 @@ native bool:RedrawClientVoteMenu(client, bool:revotes=true); * @param style Menu Style. * @return A Handle, or INVALID_HANDLE if not found or unusable. */ -native Handle:GetMenuStyleHandle(MenuStyle:style); +native Handle GetMenuStyleHandle(MenuStyle style); /** * Creates a MenuPanel from a MenuStyle. Panels are used for drawing raw @@ -651,7 +878,7 @@ native Handle:GetMenuStyleHandle(MenuStyle:style); * @return A new MenuPanel Handle. * @error Invalid Handle other than INVALID_HANDLE. */ -native Handle:CreatePanel(Handle:hStyle=INVALID_HANDLE); +native Panel CreatePanel(Handle hStyle=INVALID_HANDLE); /** * Creates a Menu from a MenuStyle. The Handle must be closed with @@ -666,7 +893,7 @@ native Handle:CreatePanel(Handle:hStyle=INVALID_HANDLE); * @return A new menu Handle. * @error Invalid Handle other than INVALID_HANDLE. */ -native Handle:CreateMenuEx(Handle:hStyle=INVALID_HANDLE, MenuHandler:handler, MenuAction:actions=MENU_ACTIONS_DEFAULT); +native Menu CreateMenuEx(Handle hStyle=INVALID_HANDLE, MenuHandler handler, MenuAction actions=MENU_ACTIONS_DEFAULT); /** * Returns whether a client is viewing a menu. @@ -674,9 +901,9 @@ native Handle:CreateMenuEx(Handle:hStyle=INVALID_HANDLE, MenuHandler:handler, Me * @param client Client index. * @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style. * @return A MenuSource value. - * @error Invalid Handle other than INVALID_HANDLE. + * @error Invalid Handle other than null. */ -native MenuSource:GetClientMenu(client, Handle:hStyle=INVALID_HANDLE); +native MenuSource GetClientMenu(int client, Handle hStyle=null); /** * Cancels a menu on a client. This will only affect non-external menus. @@ -687,7 +914,7 @@ native MenuSource:GetClientMenu(client, Handle:hStyle=INVALID_HANDLE); * the cancellation process. * @return True if a menu was cancelled, false otherwise. */ -native bool:CancelClientMenu(client, bool:autoIgnore=false, Handle:hStyle=INVALID_HANDLE); +native bool CancelClientMenu(int client, bool autoIgnore=false, Handle hStyle=INVALID_HANDLE); /** * Returns a style's maximum items per page. @@ -696,7 +923,7 @@ native bool:CancelClientMenu(client, bool:autoIgnore=false, Handle:hStyle=INVALI * @return Maximum items per page. * @error Invalid Handle other than INVALID_HANDLE. */ -native GetMaxPageItems(Handle:hStyle=INVALID_HANDLE); +native int GetMaxPageItems(Handle hStyle=INVALID_HANDLE); /** * Returns a MenuPanel's parent style. @@ -705,7 +932,7 @@ native GetMaxPageItems(Handle:hStyle=INVALID_HANDLE); * @return The MenuStyle Handle that created the panel. * @error Invalid Handle. */ -native Handle:GetPanelStyle(Handle:panel); +native Handle GetPanelStyle(Handle panel); /** * Sets the panel's title. @@ -713,10 +940,9 @@ native Handle:GetPanelStyle(Handle:panel); * @param panel A MenuPanel Handle. * @param text Text to set as the title. * @param onlyIfEmpty If true, the title will only be set if no title is set. - * @noreturn * @error Invalid Handle. */ -native Handle:SetPanelTitle(Handle:panel, const String:text[], bool:onlyIfEmpty=false); +native void SetPanelTitle(Handle panel, const char[] text, bool onlyIfEmpty=false); /** * Draws an item on a panel. If the item takes up a slot, the position @@ -730,7 +956,7 @@ native Handle:SetPanelTitle(Handle:panel, const String:text[], bool:onlyIfEmpty= * @return A slot position, or 0 if item was a rawline or could not be drawn. * @error Invalid Handle. */ -native DrawPanelItem(Handle:panel, const String:text[], style=ITEMDRAW_DEFAULT); +native int DrawPanelItem(Handle panel, const char[] text, style=ITEMDRAW_DEFAULT); /** * Draws a raw line of text on a panel, without any markup other than a newline. @@ -741,7 +967,7 @@ native DrawPanelItem(Handle:panel, const String:text[], style=ITEMDRAW_DEFAULT); * @return True on success, false if raw lines are not supported. * @error Invalid Handle. */ -native DrawPanelText(Handle:panel, const String:text[]); +native bool DrawPanelText(Handle panel, const char[] text); /** * Returns whether or not the given drawing flags are supported by @@ -752,7 +978,7 @@ native DrawPanelText(Handle:panel, const String:text[]); * @return True if item is drawable, false otherwise. * @error Invalid Handle. */ -native CanPanelDrawFlags(Handle:panel, style); +native bool CanPanelDrawFlags(Handle panel, style); /** * Sets the selectable key map of a panel. This is not supported by @@ -764,7 +990,7 @@ native CanPanelDrawFlags(Handle:panel, style); * then key 0 (bit 9) is automatically set. * @return True if supported, false otherwise. */ -native bool:SetPanelKeys(Handle:panel, keys); +native bool SetPanelKeys(Handle panel, int keys); /** * Sends a panel to a client. Unlike full menus, the handler @@ -784,7 +1010,7 @@ native bool:SetPanelKeys(Handle:panel, keys); * @return True on success, false on failure. * @error Invalid Handle. */ -native bool:SendPanelToClient(Handle:panel, client, MenuHandler:handler, time); +native bool SendPanelToClient(Handle panel, int client, MenuHandler handler, int time); /** * @brief Returns the amount of text the menu can still hold. If this is @@ -798,7 +1024,7 @@ native bool:SendPanelToClient(Handle:panel, client, MenuHandler:handler, time); * or -1 if there is no known limit. * @error Invalid Handle. */ -native GetPanelTextRemaining(Handle:panel); +native int GetPanelTextRemaining(Handle panel); /** * @brief Returns the current key position. @@ -807,7 +1033,7 @@ native GetPanelTextRemaining(Handle:panel); * @return Current key position starting at 1. * @error Invalid Handle. */ -native GetPanelCurrentKey(Handle:panel); +native int GetPanelCurrentKey(Handle panel); /** * @brief Sets the next key position. This cannot be used @@ -819,7 +1045,7 @@ native GetPanelCurrentKey(Handle:panel); * @return True on success, false otherwise. * @error Invalid Handle. */ -native bool:SetPanelCurrentKey(Handle:panel, key); +native bool SetPanelCurrentKey(Handle panel, int key); /** * @brief Redraws menu text from inside a MenuAction_DisplayItem callback. @@ -827,7 +1053,7 @@ native bool:SetPanelCurrentKey(Handle:panel, key); * @param text Menu text to draw. * @return Item position; must be returned via the callback. */ -native RedrawMenuItem(const String:text[]); +native int RedrawMenuItem(const char[] text); /** * This function is provided for legacy code only. Some older plugins may use @@ -847,7 +1073,7 @@ native RedrawMenuItem(const String:text[]); * @return True on success, false on failure. * @error Invalid client index, or radio menus not supported. */ -native bool:InternalShowMenu(client, const String:str[], time, keys=-1, MenuHandler:handler=INVALID_FUNCTION); +native bool InternalShowMenu(int client, const char[] str, int time, int keys=-1, MenuHandler handler=INVALID_FUNCTION); /** * Retrieves voting information from MenuAction_VoteEnd. @@ -855,9 +1081,8 @@ native bool:InternalShowMenu(client, const String:str[], time, keys=-1, MenuHand * @param param2 Second parameter of MenuAction_VoteEnd. * @param winningVotes Number of votes received by the winning option. * @param totalVotes Number of total votes received. - * @noreturn */ -stock GetMenuVoteInfo(param2, &winningVotes, &totalVotes) +stock void GetMenuVoteInfo(param2, &winningVotes, &totalVotes) { winningVotes = param2 & 0xFFFF; totalVotes = param2 >> 16; @@ -871,7 +1096,7 @@ stock GetMenuVoteInfo(param2, &winningVotes, &totalVotes) * @return True if voting is allowed, false if voting is in progress * or the cooldown is active. */ -stock bool:IsNewVoteAllowed() +stock bool IsNewVoteAllowed() { if (IsVoteInProgress() || CheckVoteDelay() != 0) { diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index 892cd32b..0cc07861 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -3414,7 +3414,14 @@ static int parse_new_decl(declinfo_t *decl, const token_t *first, int flags) if (!parse_new_typeexpr(&decl->type, first, flags)) return FALSE; + decl->type.is_new = TRUE; + if (flags & DECLMASK_NAMED_DECL) { + if ((flags & DECLFLAG_ARGUMENT) && matchtoken(tELLIPS)) { + decl->type.ident = iVARARGS; + return TRUE; + } + if ((flags & DECLFLAG_MAYBE_FUNCTION) && matchtoken(tOPERATOR)) { decl->opertok = operatorname(decl->name); if (decl->opertok == 0) @@ -3428,8 +3435,6 @@ static int parse_new_decl(declinfo_t *decl, const token_t *first, int flags) } } - decl->type.is_new = TRUE; - if (flags & DECLMASK_NAMED_DECL) { if (matchtoken('[')) { if (decl->type.numdim == 0) @@ -3516,7 +3521,11 @@ int parse_decl(declinfo_t *decl, int flags) // Otherwise, we have to eat a symbol to tell. if (matchsymbol(&ident)) { - if (lexpeek(tSYMBOL) || lexpeek(tOPERATOR) || lexpeek('&')) { + if (lexpeek(tSYMBOL) || + lexpeek(tOPERATOR) || + lexpeek('&') || + lexpeek(tELLIPS)) + { // A new-style declaration only allows array dims or a symbol name, so // this is a new-style declaration. return parse_new_decl(decl, &ident.tok, flags); diff --git a/sourcepawn/compiler/tests/ok-typed-vararg-in-new-function.sp b/sourcepawn/compiler/tests/ok-typed-vararg-in-new-function.sp new file mode 100644 index 00000000..62b1d66a --- /dev/null +++ b/sourcepawn/compiler/tests/ok-typed-vararg-in-new-function.sp @@ -0,0 +1,3 @@ +methodmap X { + public native void egg(any ...); +}; From 1328984e0b4cb2ca0ee85eaf9326ab97df910483 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 15 Nov 2014 16:30:45 -0800 Subject: [PATCH 2/2] Update plugins for transitional methods. --- plugins/admin-sql-prefetch.sp | 30 +++---- plugins/admin-sql-threaded.sp | 66 +++++++-------- plugins/adminhelp.sp | 4 +- plugins/adminmenu.sp | 18 ++-- plugins/adminmenu/dynamicmenu.sp | 38 ++++----- plugins/basebans/ban.sp | 60 ++++++------- plugins/basechat.sp | 12 +-- plugins/basecomm/forwards.sp | 4 +- plugins/basecomm/gag.sp | 38 ++++----- plugins/basecommands.sp | 10 +-- plugins/basecommands/execcfg.sp | 18 ++-- plugins/basecommands/kick.sp | 14 ++-- plugins/basecommands/map.sp | 22 ++--- plugins/basecommands/who.sp | 14 ++-- plugins/basetriggers.sp | 6 +- plugins/basevotes.sp | 42 +++++----- plugins/basevotes/voteban.sp | 24 +++--- plugins/basevotes/votekick.sp | 24 +++--- plugins/basevotes/votemap.sp | 52 ++++++------ plugins/clientprefs.sp | 12 +-- plugins/funcommands.sp | 12 +-- plugins/funcommands/beacon.sp | 14 ++-- plugins/funcommands/blind.sp | 28 +++---- plugins/funcommands/drug.sp | 24 +++--- plugins/funcommands/fire.sp | 28 +++---- plugins/funcommands/gravity.sp | 28 +++---- plugins/funcommands/ice.sp | 28 +++---- plugins/funcommands/noclip.sp | 14 ++-- plugins/funcommands/timebomb.sp | 14 ++-- plugins/funvotes.sp | 34 ++++---- plugins/funvotes/votealltalk.sp | 12 +-- plugins/funvotes/voteburn.sp | 24 +++--- plugins/funvotes/voteff.sp | 12 +-- plugins/funvotes/votegravity.sp | 14 ++-- plugins/funvotes/voteslay.sp | 24 +++--- plugins/mapchooser.sp | 134 +++++++++++++++--------------- plugins/nextmap.sp | 4 +- plugins/nominations.sp | 2 +- plugins/playercommands/rename.sp | 18 ++-- plugins/playercommands/slap.sp | 50 +++++------ plugins/playercommands/slay.sp | 20 ++--- plugins/randomcycle.sp | 6 +- plugins/sql-admin-manager.sp | 98 +++++++++++----------- plugins/testsuite/benchmark.sp | 2 +- plugins/testsuite/callfunctest.sp | 12 +-- plugins/testsuite/fwdtest1.sp | 24 +++--- plugins/testsuite/sqltest.sp | 40 ++++----- plugins/testsuite/structtest.sp | 12 +-- 48 files changed, 620 insertions(+), 620 deletions(-) diff --git a/plugins/admin-sql-prefetch.sp b/plugins/admin-sql-prefetch.sp index 15972c64..1068df57 100644 --- a/plugins/admin-sql-prefetch.sp +++ b/plugins/admin-sql-prefetch.sp @@ -58,7 +58,7 @@ public OnRebuildAdminCache(AdminCachePart:part) db = SQL_Connect("default", true, error, sizeof(error)); } - if (db == INVALID_HANDLE) + if (db == null) { LogError("Could not connect to database \"default\": %s", error); return; @@ -73,7 +73,7 @@ public OnRebuildAdminCache(AdminCachePart:part) FetchUsers(db); } - CloseHandle(db); + delete db; } FetchUsers(Handle:db) @@ -82,7 +82,7 @@ FetchUsers(Handle:db) new Handle:hQuery; Format(query, sizeof(query), "SELECT id, authtype, identity, password, flags, name, immunity FROM sm_admins"); - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { SQL_GetError(db, error, sizeof(error)); LogError("FetchUsers() query failed: %s", query); @@ -155,7 +155,7 @@ FetchUsers(Handle:db) new Handle:hGroupQuery; Format(query, sizeof(query), "SELECT ag.admin_id AS id, g.name FROM sm_admins_groups ag JOIN sm_groups g ON ag.group_id = g.id ORDER BY id, inherit_order ASC"); - if ((hGroupQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hGroupQuery = SQL_Query(db, query)) == null) { SQL_GetError(db, error, sizeof(error)); LogError("FetchUsers() query failed: %s", query); @@ -181,9 +181,9 @@ FetchUsers(Handle:db) } } - CloseHandle(hQuery); - CloseHandle(hGroupQuery); - CloseHandle(htAdmins); + delete hQuery; + delete hGroupQuery; + delete htAdmins; } FetchGroups(Handle:db) @@ -193,7 +193,7 @@ FetchGroups(Handle:db) Format(query, sizeof(query), "SELECT flags, name, immunity_level FROM sm_groups"); - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { decl String:error[255]; SQL_GetError(db, error, sizeof(error)); @@ -239,7 +239,7 @@ FetchGroups(Handle:db) SetAdmGroupImmunityLevel(gid, immunity); } - CloseHandle(hQuery); + delete hQuery; /** * Get immunity in a big lump. This is a nasty query but it gets the job done. @@ -249,7 +249,7 @@ FetchGroups(Handle:db) len += Format(query[len], sizeof(query)-len, " LEFT JOIN sm_groups g1 ON g1.id = gi.group_id "); len += Format(query[len], sizeof(query)-len, " LEFT JOIN sm_groups g2 ON g2.id = gi.other_id"); - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { decl String:error[255]; SQL_GetError(db, error, sizeof(error)); @@ -279,14 +279,14 @@ FetchGroups(Handle:db) #endif } - CloseHandle(hQuery); + delete hQuery; /** * Fetch overrides in a lump query. */ Format(query, sizeof(query), "SELECT g.name, go.type, go.name, go.access FROM sm_group_overrides go LEFT JOIN sm_groups g ON go.group_id = g.id"); - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { decl String:error[255]; SQL_GetError(db, error, sizeof(error)); @@ -330,7 +330,7 @@ FetchGroups(Handle:db) AddAdmGroupCmdOverride(gid, cmd, o_type, o_rule); } - CloseHandle(hQuery); + delete hQuery; } FetchOverrides(Handle:db) @@ -340,7 +340,7 @@ FetchOverrides(Handle:db) Format(query, sizeof(query), "SELECT type, name, flags FROM sm_overrides"); - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { decl String:error[255]; SQL_GetError(db, error, sizeof(error)); @@ -372,6 +372,6 @@ FetchOverrides(Handle:db) } } - CloseHandle(hQuery); + delete hQuery; } diff --git a/plugins/admin-sql-threaded.sp b/plugins/admin-sql-threaded.sp index 158b826f..e41215c9 100644 --- a/plugins/admin-sql-threaded.sp +++ b/plugins/admin-sql-threaded.sp @@ -67,7 +67,7 @@ public Plugin:myinfo = * powers. */ -new Handle:hDatabase = INVALID_HANDLE; /** Database connection */ +new Handle:hDatabase = null; /** Database connection */ new g_sequence = 0; /** Global unique sequence number */ new ConnectLock = 0; /** Connect sequence number */ new RebuildCachePart[3] = {0}; /** Cache part sequence numbers */ @@ -81,10 +81,10 @@ public OnMapEnd() /** * Clean up on map end just so we can start a fresh connection when we need it later. */ - if (hDatabase != INVALID_HANDLE) + if (hDatabase != null) { - CloseHandle(hDatabase); - hDatabase = INVALID_HANDLE; + delete hDatabase; + hDatabase = null; } } @@ -110,11 +110,11 @@ public OnDatabaseConnect(Handle:owner, Handle:hndl, const String:error[], any:da /** * If this happens to be an old connection request, ignore it. */ - if (data != ConnectLock || hDatabase != INVALID_HANDLE) + if (data != ConnectLock || hDatabase != null) { - if (hndl != INVALID_HANDLE) + if (hndl != null) { - CloseHandle(hndl); + delete hndl; } return; } @@ -126,7 +126,7 @@ public OnDatabaseConnect(Handle:owner, Handle:hndl, const String:error[], any:da * See if the connection is valid. If not, don't un-mark the caches * as needing rebuilding, in case the next connection request works. */ - if (hDatabase == INVALID_HANDLE) + if (hDatabase == null) { LogError("Failed to connect to database: %s", error); return; @@ -206,7 +206,7 @@ public Action:OnClientPreAdminCheck(client) * we just have to hope either the database is waiting or someone will type * sm_reloadadmins. */ - if (hDatabase == INVALID_HANDLE) + if (hDatabase == null) { return Plugin_Continue; } @@ -248,7 +248,7 @@ public OnReceiveUserGroups(Handle:owner, Handle:hndl, const String:error[], any: */ if (PlayerSeq[client] != sequence) { - CloseHandle(pk); + delete pk; return; } @@ -260,21 +260,21 @@ public OnReceiveUserGroups(Handle:owner, Handle:hndl, const String:error[], any: if (GetUserAdmin(client) != adm) { NotifyPostAdminCheck(client); - CloseHandle(pk); + delete pk; return; } /** * See if we got results. */ - if (hndl == INVALID_HANDLE) + if (hndl == null) { decl String:query[255]; ReadPackString(pk, query, sizeof(query)); LogError("SQL error receiving user: %s", error); LogError("Query dump: %s", query); NotifyPostAdminCheck(client); - CloseHandle(pk); + delete pk; return; } @@ -301,7 +301,7 @@ public OnReceiveUserGroups(Handle:owner, Handle:hndl, const String:error[], any: * We're DONE! Omg. */ NotifyPostAdminCheck(client); - CloseHandle(pk); + delete pk; } public OnReceiveUser(Handle:owner, Handle:hndl, const String:error[], any:data) @@ -318,14 +318,14 @@ public OnReceiveUser(Handle:owner, Handle:hndl, const String:error[], any:data) if (PlayerSeq[client] != sequence) { /* Discard everything, since we're out of sequence. */ - CloseHandle(pk); + delete pk; return; } /** * If we need to use the results, make sure they succeeded. */ - if (hndl == INVALID_HANDLE) + if (hndl == null) { decl String:query[255]; ReadPackString(pk, query, sizeof(query)); @@ -333,7 +333,7 @@ public OnReceiveUser(Handle:owner, Handle:hndl, const String:error[], any:data) LogError("Query dump: %s", query); RunAdminCacheChecks(client); NotifyPostAdminCheck(client); - CloseHandle(pk); + delete pk; return; } @@ -342,7 +342,7 @@ public OnReceiveUser(Handle:owner, Handle:hndl, const String:error[], any:data) { RunAdminCacheChecks(client); NotifyPostAdminCheck(client); - CloseHandle(pk); + delete pk; return; } @@ -443,7 +443,7 @@ public OnReceiveUser(Handle:owner, Handle:hndl, const String:error[], any:data) if (!id || !group_count) { NotifyPostAdminCheck(client); - CloseHandle(pk); + delete pk; return; } @@ -553,25 +553,25 @@ public OnReceiveGroupImmunity(Handle:owner, Handle:hndl, const String:error[], a if (RebuildCachePart[_:AdminCache_Groups] != sequence) { /* Discard everything, since we're out of sequence. */ - CloseHandle(pk); + delete pk; return; } /** * If we need to use the results, make sure they succeeded. */ - if (hndl == INVALID_HANDLE) + if (hndl == null) { decl String:query[255]; ReadPackString(pk, query, sizeof(query)); LogError("SQL error receiving group immunity: %s", error); LogError("Query dump: %s", query); - CloseHandle(pk); + delete pk; return; } /* We're done with the pack forever. */ - CloseHandle(pk); + delete pk; while (SQL_FetchRow(hndl)) { @@ -610,20 +610,20 @@ public OnReceiveGroupOverrides(Handle:owner, Handle:hndl, const String:error[], if (RebuildCachePart[_:AdminCache_Groups] != sequence) { /* Discard everything, since we're out of sequence. */ - CloseHandle(pk); + delete pk; return; } /** * If we need to use the results, make sure they succeeded. */ - if (hndl == INVALID_HANDLE) + if (hndl == null) { decl String:query[255]; ReadPackString(pk, query, sizeof(query)); LogError("SQL error receiving group overrides: %s", error); LogError("Query dump: %s", query); - CloseHandle(pk); + delete pk; return; } @@ -696,20 +696,20 @@ public OnReceiveGroups(Handle:owner, Handle:hndl, const String:error[], any:data if (RebuildCachePart[_:AdminCache_Groups] != sequence) { /* Discard everything, since we're out of sequence. */ - CloseHandle(pk); + delete pk; return; } /** * If we need to use the results, make sure they succeeded. */ - if (hndl == INVALID_HANDLE) + if (hndl == null) { decl String:query[255]; ReadPackString(pk, query, sizeof(query)); LogError("SQL error receiving groups: %s", error); LogError("Query dump: %s", query); - CloseHandle(pk); + delete pk; return; } @@ -792,27 +792,27 @@ public OnReceiveOverrides(Handle:owner, Handle:hndl, const String:error[], any:d if (RebuildCachePart[_:AdminCache_Overrides] != sequence) { /* Discard everything, since we're out of sequence. */ - CloseHandle(pk); + delete pk; return; } /** * If we need to use the results, make sure they succeeded. */ - if (hndl == INVALID_HANDLE) + if (hndl == null) { decl String:query[255]; ReadPackString(pk, query, sizeof(query)); LogError("SQL error receiving overrides: %s", error); LogError("Query dump: %s", query); - CloseHandle(pk); + delete pk; return; } /** * We're done with you, now. */ - CloseHandle(pk); + delete pk; decl String:type[64]; decl String:name[64]; diff --git a/plugins/adminhelp.sp b/plugins/adminhelp.sp index 3e927229..eb965974 100644 --- a/plugins/adminhelp.sp +++ b/plugins/adminhelp.sp @@ -118,7 +118,7 @@ public Action:HelpCmd(client, args) if (i == 0) { PrintToConsole(client, "%t", "No commands available"); - CloseHandle(CmdIter); + delete CmdIter; return Plugin_Handled; } } @@ -149,7 +149,7 @@ public Action:HelpCmd(client, args) } } - CloseHandle(CmdIter); + delete CmdIter; return Plugin_Handled; } diff --git a/plugins/adminmenu.sp b/plugins/adminmenu.sp index 0d4212e6..e3f7e06c 100644 --- a/plugins/adminmenu.sp +++ b/plugins/adminmenu.sp @@ -46,8 +46,8 @@ public Plugin:myinfo = }; /* Forwards */ -new Handle:hOnAdminMenuReady = INVALID_HANDLE; -new Handle:hOnAdminMenuCreated = INVALID_HANDLE; +new Handle:hOnAdminMenuReady = null; +new Handle:hOnAdminMenuCreated = null; /* Menus */ TopMenu hAdminMenu; @@ -182,7 +182,7 @@ public __AddTargetsToMenu2(Handle:plugin, numParams) return UTIL_AddTargetsToMenu2(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3)); } -public Action:Command_DisplayMenu(client, args) +public Action:Command_DisplayMenu(int client, int args) { if (client == 0) { @@ -194,11 +194,11 @@ public Action:Command_DisplayMenu(client, args) return Plugin_Handled; } -stock UTIL_AddTargetsToMenu2(Handle:menu, source_client, flags) +stock int UTIL_AddTargetsToMenu2(Menu menu, source_client, flags) { - decl String:user_id[12]; - decl String:name[MAX_NAME_LENGTH]; - decl String:display[MAX_NAME_LENGTH+12]; + char user_id[12]; + char name[MAX_NAME_LENGTH]; + char display[MAX_NAME_LENGTH+12]; new num_clients; @@ -242,14 +242,14 @@ stock UTIL_AddTargetsToMenu2(Handle:menu, source_client, flags) IntToString(GetClientUserId(i), user_id, sizeof(user_id)); GetClientName(i, name, sizeof(name)); Format(display, sizeof(display), "%s (%s)", name, user_id); - AddMenuItem(menu, user_id, display); + menu.AddItem(user_id, display); num_clients++; } return num_clients; } -stock UTIL_AddTargetsToMenu(Handle:menu, source_client, bool:in_game_only, bool:alive_only) +stock UTIL_AddTargetsToMenu(Menu menu, source_client, bool:in_game_only, bool:alive_only) { new flags = 0; diff --git a/plugins/adminmenu/dynamicmenu.sp b/plugins/adminmenu/dynamicmenu.sp index f1178b8c..0bc11d44 100644 --- a/plugins/adminmenu/dynamicmenu.sp +++ b/plugins/adminmenu/dynamicmenu.sp @@ -336,7 +336,7 @@ ParseConfigs() CloseHandle(g_groupList[groupListName]); } - if (g_groupList[groupListCommand] != INVALID_HANDLE) + if (g_groupList[groupListCommand] != null) { CloseHandle(g_groupList[groupListCommand]); } @@ -457,8 +457,8 @@ public ParamCheck(client) { GetArrayArray(outputItem[Item_submenus], g_currentPlace[client][Place_ReplaceNum] - 1, outputSubmenu[0]); - new Handle:itemMenu = CreateMenu(Menu_Selection); - SetMenuExitBackButton(itemMenu, true); + Menu itemMenu = CreateMenu(Menu_Selection); + itemMenu.ExitBackButton = true; if ((outputSubmenu[Submenu_type] == SubMenu_Group) || (outputSubmenu[Submenu_type] == SubMenu_GroupPlayer)) { @@ -469,7 +469,7 @@ public ParamCheck(client) { GetArrayString(g_groupList[groupListName], i, nameBuffer, sizeof(nameBuffer)); GetArrayString(g_groupList[groupListCommand], i, commandBuffer, sizeof(commandBuffer)); - AddMenuItem(itemMenu, commandBuffer, nameBuffer); + itemMenu.AddItem(commandBuffer, nameBuffer); } } @@ -490,7 +490,7 @@ public ParamCheck(client) if (IsMapValid(readData)) { - AddMenuItem(itemMenu, readData, readData); + itemMenu.AddItem(readData, readData); } } } @@ -516,32 +516,32 @@ public ParamCheck(client) { new userid = GetClientUserId(i); Format(infoBuffer, sizeof(infoBuffer), "#%i", userid); - AddMenuItem(itemMenu, infoBuffer, nameBuffer); + itemMenu.AddItem(infoBuffer, nameBuffer); } case UserId2: { new userid = GetClientUserId(i); Format(infoBuffer, sizeof(infoBuffer), "%i", userid); - AddMenuItem(itemMenu, infoBuffer, nameBuffer); + itemMenu.AddItem(infoBuffer, nameBuffer); } case SteamId: { if (GetClientAuthId(i, AuthId_Steam2, infoBuffer, sizeof(infoBuffer))) - AddMenuItem(itemMenu, infoBuffer, nameBuffer); + itemMenu.AddItem(infoBuffer, nameBuffer); } case IpAddress: { GetClientIP(i, infoBuffer, sizeof(infoBuffer)); - AddMenuItem(itemMenu, infoBuffer, nameBuffer); + itemMenu.AddItem(infoBuffer, nameBuffer); } case Name: { - AddMenuItem(itemMenu, nameBuffer, nameBuffer); + itemMenu.AddItem(nameBuffer, nameBuffer); } default: //assume client id { Format(temp,3,"%i",i); - AddMenuItem(itemMenu, temp, nameBuffer); + itemMenu.AddItem(temp, nameBuffer); } } } @@ -549,8 +549,8 @@ public ParamCheck(client) } else if (outputSubmenu[Submenu_type] == SubMenu_OnOff) { - AddMenuItem(itemMenu, "1", "On"); - AddMenuItem(itemMenu, "0", "Off"); + itemMenu.AddItem("1", "On"); + itemMenu.AddItem("0", "Off"); } else { @@ -567,16 +567,16 @@ public ParamCheck(client) if (CheckCommandAccess(client, admin, 0)) { - AddMenuItem(itemMenu, value, text); + itemMenu.AddItem(value, text); } } ResetPack(outputSubmenu[Submenu_listdata]); } - SetMenuTitle(itemMenu, outputSubmenu[Submenu_title]); + itemMenu.SetTitle(outputSubmenu[Submenu_title]); - DisplayMenu(itemMenu, client, MENU_TIME_FOREVER); + itemMenu.Display(client, MENU_TIME_FOREVER); } else { @@ -602,11 +602,11 @@ public ParamCheck(client) } } -public Menu_Selection(Handle:menu, MenuAction:action, param1, param2) +public Menu_Selection(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } if (action == MenuAction_Select) @@ -614,7 +614,7 @@ public Menu_Selection(Handle:menu, MenuAction:action, param1, param2) new String:unquotedinfo[NAME_LENGTH]; /* Get item info */ - new bool:found = GetMenuItem(menu, param2, unquotedinfo, sizeof(unquotedinfo)); + new bool:found = menu.GetItem(param2, unquotedinfo, sizeof(unquotedinfo)); if (!found) { diff --git a/plugins/basebans/ban.sp b/plugins/basebans/ban.sp index 86f9bec8..2ce3320f 100644 --- a/plugins/basebans/ban.sp +++ b/plugins/basebans/ban.sp @@ -83,49 +83,49 @@ PrepareBan(client, target, time, const String:reason[]) DisplayBanTargetMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_BanPlayerList); + Menu menu = CreateMenu(MenuHandler_BanPlayerList); decl String:title[100]; Format(title, sizeof(title), "%T:", "Ban player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu2(menu, client, COMMAND_FILTER_NO_BOTS|COMMAND_FILTER_CONNECTED); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } DisplayBanTimeMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_BanTimeList); + Menu menu = CreateMenu(MenuHandler_BanTimeList); decl String:title[100]; Format(title, sizeof(title), "%T: %N", "Ban player", client, g_BanTarget[client]); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; - AddMenuItem(menu, "0", "Permanent"); - AddMenuItem(menu, "10", "10 Minutes"); - AddMenuItem(menu, "30", "30 Minutes"); - AddMenuItem(menu, "60", "1 Hour"); - AddMenuItem(menu, "240", "4 Hours"); - AddMenuItem(menu, "1440", "1 Day"); - AddMenuItem(menu, "10080", "1 Week"); + menu.AddItem("0", "Permanent"); + menu.AddItem("10", "10 Minutes"); + menu.AddItem("30", "30 Minutes"); + menu.AddItem("60", "1 Hour"); + menu.AddItem("240", "4 Hours"); + menu.AddItem("1440", "1 Day"); + menu.AddItem("10080", "1 Week"); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } DisplayBanReasonMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_BanReasonList); + Menu menu = CreateMenu(MenuHandler_BanReasonList); decl String:title[100]; Format(title, sizeof(title), "%T: %N", "Ban reason", client, g_BanTarget[client]); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; //Add custom chat reason entry first - AddMenuItem(menu, "", "Custom reason (type in chat)"); + menu.AddItem("", "Custom reason (type in chat)"); //Loading configurable entries from the kv-file decl String:reasonName[100]; @@ -139,14 +139,14 @@ DisplayBanReasonMenu(client) g_hKvBanReasons.GetString(NULL_STRING, reasonFull, sizeof(reasonFull)); //Add entry - AddMenuItem(menu, reasonFull, reasonName); + menu.AddItem(reasonFull, reasonName); } while (g_hKvBanReasons.GotoNextKey(false)); //Reset kvHandle g_hKvBanReasons.Rewind(); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } public AdminMenu_Ban(Handle:topmenu, @@ -169,11 +169,11 @@ public AdminMenu_Ban(Handle:topmenu, } } -public MenuHandler_BanReasonList(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_BanReasonList(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -194,18 +194,18 @@ public MenuHandler_BanReasonList(Handle:menu, MenuAction:action, param1, param2) { decl String:info[64]; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); PrepareBan(param1, g_BanTarget[param1], g_BanTime[param1], info); } } } -public MenuHandler_BanPlayerList(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_BanPlayerList(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -219,7 +219,7 @@ public MenuHandler_BanPlayerList(Handle:menu, MenuAction:action, param1, param2) decl String:info[32], String:name[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name)); + menu.GetItem(param2, info, sizeof(info), _, name, sizeof(name)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) @@ -239,11 +239,11 @@ public MenuHandler_BanPlayerList(Handle:menu, MenuAction:action, param1, param2) } } -public MenuHandler_BanTimeList(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_BanTimeList(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -256,7 +256,7 @@ public MenuHandler_BanTimeList(Handle:menu, MenuAction:action, param1, param2) { decl String:info[32]; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); g_BanTime[param1] = StringToInt(info); DisplayBanReasonMenu(param1); diff --git a/plugins/basechat.sp b/plugins/basechat.sp index b05cc613..0499e3c4 100644 --- a/plugins/basechat.sp +++ b/plugins/basechat.sp @@ -393,15 +393,15 @@ SendPrivateChat(client, target, const String:message[]) LogAction(client, -1, "\"%L\" triggered sm_psay to \"%L\" (text %s)", client, target, message); } -SendPanelToAll(from, String:message[]) +void SendPanelToAll(int from, char[] message) { - decl String:title[100]; + char title[100]; Format(title, 64, "%N:", from); ReplaceString(message, 192, "\\n", "\n"); - new Handle:mSayPanel = CreatePanel(); - SetPanelTitle(mSayPanel, title); + Panel mSayPanel = CreatePanel(); + mSayPanel.SetTitle(title); DrawPanelItem(mSayPanel, "", ITEMDRAW_SPACER); DrawPanelText(mSayPanel, message); DrawPanelItem(mSayPanel, "", ITEMDRAW_SPACER); @@ -417,10 +417,10 @@ SendPanelToAll(from, String:message[]) } } - CloseHandle(mSayPanel); + delete mSayPanel; } -public Handler_DoNothing(Handle:menu, MenuAction:action, param1, param2) +public Handler_DoNothing(Menu menu, MenuAction action, int param1, int param2) { /* Do nothing */ } diff --git a/plugins/basecomm/forwards.sp b/plugins/basecomm/forwards.sp index 3df76416..f16c67a7 100644 --- a/plugins/basecomm/forwards.sp +++ b/plugins/basecomm/forwards.sp @@ -35,7 +35,7 @@ { static Handle:hForward; - if(hForward == INVALID_HANDLE) + if(hForward == null) { hForward = CreateGlobalForward("BaseComm_OnClientMute", ET_Ignore, Param_Cell, Param_Cell); } @@ -50,7 +50,7 @@ { static Handle:hForward; - if(hForward == INVALID_HANDLE) + if(hForward == null) { hForward = CreateGlobalForward("BaseComm_OnClientGag", ET_Ignore, Param_Cell, Param_Cell); } diff --git a/plugins/basecomm/gag.sp b/plugins/basecomm/gag.sp index 15e21463..edf4c2d6 100644 --- a/plugins/basecomm/gag.sp +++ b/plugins/basecomm/gag.sp @@ -43,12 +43,12 @@ enum CommType DisplayGagTypesMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_GagTypes); + Menu menu = CreateMenu(MenuHandler_GagTypes); decl String:title[100]; Format(title, sizeof(title), "%T: %N", "Choose Type", client, g_GagTarget[client]); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; new target = g_GagTarget[client]; @@ -79,28 +79,28 @@ DisplayGagTypesMenu(client) AddTranslatedMenuItem(menu, "5", "UnSilence Player", client); } - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } -AddTranslatedMenuItem(Handle:menu, const String:opt[], const String:phrase[], client) +void AddTranslatedMenuItem(Menu menu, const char[] opt, const char[] phrase, int client) { - decl String:buffer[128]; + char buffer[128]; Format(buffer, sizeof(buffer), "%T", phrase, client); - AddMenuItem(menu, opt, buffer); + menu.AddItem(opt, buffer); } -DisplayGagPlayerMenu(client) +void DisplayGagPlayerMenu(int client) { - new Handle:menu = CreateMenu(MenuHandler_GagPlayer); + Menu menu = CreateMenu(MenuHandler_GagPlayer); - decl String:title[100]; + char title[100]; Format(title, sizeof(title), "%T:", "Gag/Mute player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, false); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } public AdminMenu_Gag(Handle:topmenu, @@ -120,11 +120,11 @@ public AdminMenu_Gag(Handle:topmenu, } } -public MenuHandler_GagPlayer(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_GagPlayer(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -138,7 +138,7 @@ public MenuHandler_GagPlayer(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) @@ -157,11 +157,11 @@ public MenuHandler_GagPlayer(Handle:menu, MenuAction:action, param1, param2) } } -public MenuHandler_GagTypes(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_GagTypes(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -175,7 +175,7 @@ public MenuHandler_GagTypes(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new CommType:type; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); type = CommType:StringToInt(info); decl String:name[MAX_NAME_LENGTH]; diff --git a/plugins/basecommands.sp b/plugins/basecommands.sp index 24593358..015bf135 100644 --- a/plugins/basecommands.sp +++ b/plugins/basecommands.sp @@ -48,7 +48,7 @@ public Plugin:myinfo = TopMenu hTopMenu; -new Handle:g_MapList; +Menu g_MapList; new Handle:g_ProtectedVars; #include "basecommands/kick.sp" @@ -82,8 +82,8 @@ public OnPluginStart() } g_MapList = CreateMenu(MenuHandler_ChangeMap, MenuAction_Display); - SetMenuTitle(g_MapList, "%T", "Please select a map", LANG_SERVER); - SetMenuExitBackButton(g_MapList, true); + g_MapList.SetTitle("%T", "Please select a map", LANG_SERVER); + g_MapList.ExitBackButton = true; char mapListPath[PLATFORM_MAX_PATH]; BuildPath(Path_SM, mapListPath, sizeof(mapListPath), "configs/adminmenu_maplist.ini"); @@ -284,7 +284,7 @@ public Action:Command_Cvar(client, args) } ConVar hndl = FindConVar(cvarname); - if (hndl == INVALID_HANDLE) + if (hndl == null) { ReplyToCommand(client, "[SM] %t", "Unable to find cvar", cvarname); return Plugin_Handled; @@ -336,7 +336,7 @@ public Action:Command_ResetCvar(client, args) GetCmdArg(1, cvarname, sizeof(cvarname)); ConVar hndl = FindConVar(cvarname); - if (hndl == INVALID_HANDLE) + if (hndl == null) { ReplyToCommand(client, "[SM] %t", "Unable to find cvar", cvarname); return Plugin_Handled; diff --git a/plugins/basecommands/execcfg.sp b/plugins/basecommands/execcfg.sp index a1bcbee7..58ac5308 100644 --- a/plugins/basecommands/execcfg.sp +++ b/plugins/basecommands/execcfg.sp @@ -31,7 +31,7 @@ * Version: $Id$ */ -new Handle:g_ConfigMenu = INVALID_HANDLE; +Menu g_ConfigMenu = null; PerformExec(client, String:path[]) { @@ -61,11 +61,11 @@ public AdminMenu_ExecCFG(Handle:topmenu, } else if (action == TopMenuAction_SelectOption) { - DisplayMenu(g_ConfigMenu, param, MENU_TIME_FOREVER); + g_ConfigMenu.Display(param, MENU_TIME_FOREVER); } } -public MenuHandler_ExecCFG(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_ExecCFG(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_Cancel) { @@ -78,7 +78,7 @@ public MenuHandler_ExecCFG(Handle:menu, MenuAction:action, param1, param2) { decl String:path[256]; - GetMenuItem(menu, param2, path, sizeof(path)); + menu.GetItem(param2, path, sizeof(path)); PerformExec(param1, path); } @@ -116,14 +116,14 @@ ParseConfigs() config_parser.OnLeaveSection = EndSection; config_parser.OnKeyValue = KeyValue; - if (g_ConfigMenu != INVALID_HANDLE) + if (g_ConfigMenu != null) { - CloseHandle(g_ConfigMenu); + delete g_ConfigMenu; } g_ConfigMenu = CreateMenu(MenuHandler_ExecCFG, MenuAction_Display); - SetMenuTitle(g_ConfigMenu, "%T", "Choose Config", LANG_SERVER); - SetMenuExitBackButton(g_ConfigMenu, true); + g_ConfigMenu.SetTitle("%T", "Choose Config", LANG_SERVER); + g_ConfigMenu.ExitBackButton = true; decl String:configPath[256]; BuildPath(Path_SM, configPath, sizeof(configPath), "configs/adminmenu_cfgs.txt"); @@ -155,7 +155,7 @@ public SMCResult NewSection(SMCParser smc, const char[] name, bool opt_quotes) public SMCResult KeyValue(SMCParser smc, const char[] key, const char[] value, bool key_quotes, bool value_quotes) { - AddMenuItem(g_ConfigMenu, key, value); + g_ConfigMenu.AddItem(key, value); } public SMCResult EndSection(SMCParser smc) diff --git a/plugins/basecommands/kick.sp b/plugins/basecommands/kick.sp index bbedf2d4..8277ded9 100644 --- a/plugins/basecommands/kick.sp +++ b/plugins/basecommands/kick.sp @@ -47,16 +47,16 @@ PerformKick(client, target, const String:reason[]) DisplayKickMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Kick); + Menu menu = CreateMenu(MenuHandler_Kick); decl String:title[100]; Format(title, sizeof(title), "%T:", "Kick player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, false, false); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } public AdminMenu_Kick(Handle:topmenu, @@ -76,11 +76,11 @@ public AdminMenu_Kick(Handle:topmenu, } } -public MenuHandler_Kick(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Kick(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -94,7 +94,7 @@ public MenuHandler_Kick(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/basecommands/map.sp b/plugins/basecommands/map.sp index f1c19818..3ba59e88 100644 --- a/plugins/basecommands/map.sp +++ b/plugins/basecommands/map.sp @@ -31,7 +31,7 @@ * Version: $Id$ */ -public MenuHandler_ChangeMap(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_ChangeMap(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_Cancel) { @@ -44,7 +44,7 @@ public MenuHandler_ChangeMap(Handle:menu, MenuAction:action, param1, param2) { decl String:map[64]; - GetMenuItem(menu, param2, map, sizeof(map)); + menu.GetItem(param2, map, sizeof(map)); ShowActivity2(param1, "[SM] ", "%t", "Changing map", map); @@ -75,7 +75,7 @@ public AdminMenu_Map(Handle:topmenu, } else if (action == TopMenuAction_SelectOption) { - DisplayMenu(g_MapList, param, MENU_TIME_FOREVER); + g_MapList.Display(param, MENU_TIME_FOREVER); } } @@ -119,10 +119,10 @@ public Action:Timer_ChangeMap(Handle:timer, Handle:dp) return Plugin_Stop; } -new Handle:g_map_array = INVALID_HANDLE; +new Handle:g_map_array = null; new g_map_serial = -1; -LoadMapList(Handle:menu) +int LoadMapList(Menu menu) { new Handle:map_array; @@ -130,25 +130,25 @@ LoadMapList(Handle:menu) g_map_serial, "sm_map menu", MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_NO_DEFAULT|MAPLIST_FLAG_MAPSFOLDER)) - != INVALID_HANDLE) + != null) { g_map_array = map_array; } - if (g_map_array == INVALID_HANDLE) + if (g_map_array == null) { return 0; } RemoveAllMenuItems(menu); - decl String:map_name[64]; - new map_count = GetArraySize(g_map_array); + char map_name[64]; + int map_count = GetArraySize(g_map_array); - for (new i = 0; i < map_count; i++) + for (int i = 0; i < map_count; i++) { GetArrayString(g_map_array, i, map_name, sizeof(map_name)); - AddMenuItem(menu, map_name, map_name); + menu.AddItem(map_name, map_name); } return map_count; diff --git a/plugins/basecommands/who.sp b/plugins/basecommands/who.sp index a06487b3..74a65abb 100644 --- a/plugins/basecommands/who.sp +++ b/plugins/basecommands/who.sp @@ -89,16 +89,16 @@ PerformWho(client, target, ReplySource:reply, bool:is_admin) DisplayWhoMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Who); + Menu menu = CreateMenu(MenuHandler_Who); decl String:title[100]; Format(title, sizeof(title), "%T:", "Identify player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu2(menu, 0, COMMAND_FILTER_CONNECTED); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } public AdminMenu_Who(Handle:topmenu, @@ -118,11 +118,11 @@ public AdminMenu_Who(Handle:topmenu, } } -public MenuHandler_Who(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Who(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -136,7 +136,7 @@ public MenuHandler_Who(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/basetriggers.sp b/plugins/basetriggers.sp index ec4c95ef..8753a408 100644 --- a/plugins/basetriggers.sp +++ b/plugins/basetriggers.sp @@ -52,7 +52,7 @@ ConVar g_Cvar_TriggerShow; ConVar g_Cvar_TimeleftInterval; ConVar g_Cvar_FriendlyFire; -new Handle:g_Timer_TimeShow = INVALID_HANDLE; +Handle g_Timer_TimeShow = null; ConVar g_Cvar_WinLimit; ConVar g_Cvar_FragLimit; @@ -167,7 +167,7 @@ public ConVarChange_TimeleftInterval(Handle:convar, const String:oldValue[], con if (newval < 1.0) { - if (g_Timer_TimeShow != INVALID_HANDLE) + if (g_Timer_TimeShow != null) { KillTimer(g_Timer_TimeShow); } @@ -175,7 +175,7 @@ public ConVarChange_TimeleftInterval(Handle:convar, const String:oldValue[], con return; } - if (g_Timer_TimeShow != INVALID_HANDLE) + if (g_Timer_TimeShow != null) { KillTimer(g_Timer_TimeShow); g_Timer_TimeShow = CreateTimer(newval, Timer_DisplayTimeleft, _, TIMER_REPEAT); diff --git a/plugins/basevotes.sp b/plugins/basevotes.sp index 5aea62a8..ac04b6c8 100644 --- a/plugins/basevotes.sp +++ b/plugins/basevotes.sp @@ -49,7 +49,7 @@ public Plugin:myinfo = #define VOTE_NO "###no###" #define VOTE_YES "###yes###" -new Handle:g_hVoteMenu = INVALID_HANDLE; +Menu g_hVoteMenu = null; ConVar g_Cvar_Limits[3] = {null, ...}; //new Handle:g_Cvar_VoteSay = INVALID_HANDLE; @@ -99,7 +99,7 @@ public OnPluginStart() /* g_Cvar_Show = FindConVar("sm_vote_show"); - if (g_Cvar_Show == INVALID_HANDLE) + if (g_Cvar_Show == null) { g_Cvar_Show = CreateConVar("sm_vote_show", "1", "Show player's votes? Default on.", 0, true, 0.0, true, 1.0); } @@ -119,8 +119,8 @@ public OnPluginStart() g_SelectedMaps = CreateArray(33); g_MapList = CreateMenu(MenuHandler_Map, MenuAction_DrawItem|MenuAction_Display); - SetMenuTitle(g_MapList, "%T", "Please select a map", LANG_SERVER); - SetMenuExitBackButton(g_MapList, true); + g_MapList.SetTitle("%T", "Please select a map", LANG_SERVER); + g_MapList.ExitBackButton = true; decl String:mapListPath[PLATFORM_MAX_PATH]; BuildPath(Path_SM, mapListPath, sizeof(mapListPath), "configs/adminmenu_maplist.ini"); @@ -200,28 +200,28 @@ public Action:Command_Vote(client, args) g_voteType = voteType:question; g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL); - SetMenuTitle(g_hVoteMenu, "%s?", g_voteArg); + g_hVoteMenu.SetTitle("%s?", g_voteArg); if (answerCount < 2) { - AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes"); - AddMenuItem(g_hVoteMenu, VOTE_NO, "No"); + g_hVoteMenu.AddItem(VOTE_YES, "Yes"); + g_hVoteMenu.AddItem(VOTE_NO, "No"); } else { for (new i = 0; i < answerCount; i++) { - AddMenuItem(g_hVoteMenu, answers[i], answers[i]); + g_hVoteMenu.AddItem(answers[i], answers[i]); } } - SetMenuExitButton(g_hVoteMenu, false); - VoteMenuToAll(g_hVoteMenu, 20); + g_hVoteMenu.ExitButton = false; + g_hVoteMenu.DisplayVoteToAll(20); return Plugin_Handled; } -public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2) +public Handler_VoteCallback(Menu menu, MenuAction action, param1, param2) { if (action == MenuAction_End) { @@ -231,20 +231,20 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2) { if (g_voteType != voteType:question) { - decl String:title[64]; - GetMenuTitle(menu, title, sizeof(title)); + char title[64]; + menu.GetTitle(title, sizeof(title)); - decl String:buffer[255]; + char buffer[255]; Format(buffer, sizeof(buffer), "%T", title, param1, g_voteInfo[VOTE_NAME]); - new Handle:panel = Handle:param2; - SetPanelTitle(panel, buffer); + Panel panel = Panel:param2; + panel.SetTitle(buffer); } } else if (action == MenuAction_DisplayItem) { decl String:display[64]; - GetMenuItem(menu, param2, "", 0, _, display, sizeof(display)); + menu.GetItem(param2, "", 0, _, display, sizeof(display)); if (strcmp(display, "No") == 0 || strcmp(display, "Yes") == 0) { @@ -269,7 +269,7 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2) int votes, totalVotes; GetMenuVoteInfo(param2, votes, totalVotes); - GetMenuItem(menu, param1, item, sizeof(item), _, display, sizeof(display)); + menu.GetItem(param1, item, sizeof(item), _, display, sizeof(display)); if (strcmp(item, VOTE_NO) == 0 && param1 == 1) { @@ -362,7 +362,7 @@ VoteSelect(Handle:menu, param1, param2 = 0) { decl String:voter[64], String:junk[64], String:choice[64]; GetClientName(param1, voter, sizeof(voter)); - GetMenuItem(menu, param2, junk, sizeof(junk), _, choice, sizeof(choice)); + menu.GetItem(param2, junk, sizeof(junk), _, choice, sizeof(choice)); PrintToChatAll("[SM] %T", "Vote Select", LANG_SERVER, voter, choice); } } @@ -370,8 +370,8 @@ VoteSelect(Handle:menu, param1, param2 = 0) VoteMenuClose() { - CloseHandle(g_hVoteMenu); - g_hVoteMenu = INVALID_HANDLE; + delete g_hVoteMenu; + g_hVoteMenu = null; } Float:GetVotePercent(votes, totalVotes) diff --git a/plugins/basevotes/voteban.sp b/plugins/basevotes/voteban.sp index 9598284c..b6299a4a 100644 --- a/plugins/basevotes/voteban.sp +++ b/plugins/basevotes/voteban.sp @@ -45,25 +45,25 @@ DisplayVoteBanMenu(client, target) g_voteType = voteType:ban; g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL); - SetMenuTitle(g_hVoteMenu, "Voteban Player"); - AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes"); - AddMenuItem(g_hVoteMenu, VOTE_NO, "No"); - SetMenuExitButton(g_hVoteMenu, false); - VoteMenuToAll(g_hVoteMenu, 20); + g_hVoteMenu.SetTitle("Voteban Player"); + g_hVoteMenu.AddItem(VOTE_YES, "Yes"); + g_hVoteMenu.AddItem(VOTE_NO, "No"); + g_hVoteMenu.ExitButton = false; + g_hVoteMenu.DisplayVoteToAll(20); } DisplayBanTargetMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Ban); + Menu menu = CreateMenu(MenuHandler_Ban); decl String:title[100]; Format(title, sizeof(title), "%T:", "Ban vote", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, false, false); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } public AdminMenu_VoteBan(Handle:topmenu, @@ -88,11 +88,11 @@ public AdminMenu_VoteBan(Handle:topmenu, } } -public MenuHandler_Ban(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Ban(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -106,7 +106,7 @@ public MenuHandler_Ban(Handle:menu, MenuAction:action, param1, param2) decl String:info[32], String:name[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name)); + menu.GetItem(param2, info, sizeof(info), _, name, sizeof(name)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/basevotes/votekick.sp b/plugins/basevotes/votekick.sp index 4fe69172..de1f104e 100644 --- a/plugins/basevotes/votekick.sp +++ b/plugins/basevotes/votekick.sp @@ -45,26 +45,26 @@ DisplayVoteKickMenu(client, target) g_voteType = voteType:kick; g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL); - SetMenuTitle(g_hVoteMenu, "Votekick Player"); - AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes"); - AddMenuItem(g_hVoteMenu, VOTE_NO, "No"); - SetMenuExitButton(g_hVoteMenu, false); - VoteMenuToAll(g_hVoteMenu, 20); + g_hVoteMenu.SetTitle("Votekick Player"); + g_hVoteMenu.AddItem(VOTE_YES, "Yes"); + g_hVoteMenu.AddItem(VOTE_NO, "No"); + g_hVoteMenu.ExitButton = false; + g_hVoteMenu.DisplayVoteToAll(20); } DisplayKickTargetMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Kick); + Menu menu = CreateMenu(MenuHandler_Kick); decl String:title[100]; Format(title, sizeof(title), "%T:", "Kick vote", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, false, false); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } public AdminMenu_VoteKick(Handle:topmenu, @@ -89,11 +89,11 @@ public AdminMenu_VoteKick(Handle:topmenu, } } -public MenuHandler_Kick(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Kick(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -107,7 +107,7 @@ public MenuHandler_Kick(Handle:menu, MenuAction:action, param1, param2) decl String:info[32], String:name[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name)); + menu.GetItem(param2, info, sizeof(info), _, name, sizeof(name)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/basevotes/votemap.sp b/plugins/basevotes/votemap.sp index 1b3db34b..58fba333 100644 --- a/plugins/basevotes/votemap.sp +++ b/plugins/basevotes/votemap.sp @@ -31,7 +31,7 @@ * Version: $Id$ */ -new Handle:g_MapList = INVALID_HANDLE; +Menu g_MapList; new g_mapCount; new Handle:g_SelectedMaps; @@ -50,23 +50,23 @@ DisplayVoteMapMenu(client, mapCount, String:maps[5][]) { strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), maps[0]); - SetMenuTitle(g_hVoteMenu, "Change Map To"); - AddMenuItem(g_hVoteMenu, maps[0], "Yes"); - AddMenuItem(g_hVoteMenu, VOTE_NO, "No"); + g_hVoteMenu.SetTitle("Change Map To"); + g_hVoteMenu.AddItem(maps[0], "Yes"); + g_hVoteMenu.AddItem(VOTE_NO, "No"); } else { g_voteInfo[VOTE_NAME][0] = '\0'; - SetMenuTitle(g_hVoteMenu, "Map Vote"); + g_hVoteMenu.SetTitle("Map Vote"); for (new i = 0; i < mapCount; i++) { - AddMenuItem(g_hVoteMenu, maps[i], maps[i]); + g_hVoteMenu.AddItem(maps[i], maps[i]); } } - SetMenuExitButton(g_hVoteMenu, false); - VoteMenuToAll(g_hVoteMenu, 20); + g_hVoteMenu.ExitButton = false; + g_hVoteMenu.DisplayVoteToAll(20); } ResetMenu() @@ -77,25 +77,25 @@ ResetMenu() ConfirmVote(client) { - new Handle:menu = CreateMenu(MenuHandler_Confirm); + Menu menu = CreateMenu(MenuHandler_Confirm); decl String:title[100]; Format(title, sizeof(title), "%T:", "Confirm Vote", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; decl String:itemtext[256]; Format(itemtext, sizeof(itemtext), "%T", "Start the Vote", client); - AddMenuItem(menu, "Confirm", itemtext); + menu.AddItem("Confirm", itemtext); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } -public MenuHandler_Confirm(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Confirm(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; g_VoteMapInUse = false; } else if (action == MenuAction_Cancel) @@ -123,7 +123,7 @@ public MenuHandler_Confirm(Handle:menu, MenuAction:action, param1, param2) } } -public MenuHandler_Map(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Map(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_Cancel) { @@ -141,7 +141,7 @@ public MenuHandler_Map(Handle:menu, MenuAction:action, param1, param2) { decl String:info[32], String:name[32]; - GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name)); + menu.GetItem(param2, info, sizeof(info), _, name, sizeof(name)); if (FindStringInArray(g_SelectedMaps, info) != -1) { @@ -156,14 +156,14 @@ public MenuHandler_Map(Handle:menu, MenuAction:action, param1, param2) { decl String:info[32], String:name[32]; - GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name)); + menu.GetItem(param2, info, sizeof(info), _, name, sizeof(name)); PushArrayString(g_SelectedMaps, info); /* Redisplay the list */ if (GetArraySize(g_SelectedMaps) < 5) { - DisplayMenu(g_MapList, param1, MENU_TIME_FOREVER); + g_MapList.Display(param1, MENU_TIME_FOREVER); } else { @@ -197,7 +197,7 @@ public AdminMenu_VoteMap(Handle:topmenu, { ResetMenu(); g_VoteMapInUse = true; - DisplayMenu(g_MapList, param, MENU_TIME_FOREVER); + g_MapList.Display(param, MENU_TIME_FOREVER); } else { @@ -260,10 +260,10 @@ public Action:Command_Votemap(client, args) return Plugin_Handled; } -new Handle:g_map_array = INVALID_HANDLE; +new Handle:g_map_array = null; new g_map_serial = -1; -LoadMapList(Handle:menu) +int LoadMapList(Menu menu) { new Handle:map_array; @@ -271,25 +271,25 @@ LoadMapList(Handle:menu) g_map_serial, "sm_votemap menu", MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_NO_DEFAULT|MAPLIST_FLAG_MAPSFOLDER)) - != INVALID_HANDLE) + != null) { g_map_array = map_array; } - if (g_map_array == INVALID_HANDLE) + if (g_map_array == null) { return 0; } RemoveAllMenuItems(menu); - decl String:map_name[64]; + char map_name[64]; new map_count = GetArraySize(g_map_array); for (new i = 0; i < map_count; i++) { GetArrayString(g_map_array, i, map_name, sizeof(map_name)); - AddMenuItem(menu, map_name, map_name); + menu.AddItem(map_name, map_name); } return map_count; diff --git a/plugins/clientprefs.sp b/plugins/clientprefs.sp index 209e0e19..9fde9a45 100644 --- a/plugins/clientprefs.sp +++ b/plugins/clientprefs.sp @@ -86,7 +86,7 @@ public Action:Command_Cookie(client, args) } } - CloseHandle(iter); + delete iter; return Plugin_Handled; } @@ -102,7 +102,7 @@ public Action:Command_Cookie(client, args) new Handle:cookie = FindClientCookie(name); - if (cookie == INVALID_HANDLE) + if (cookie == null) { ReplyToCommand(client, "[SM] %t", "Cookie not Found", name); return Plugin_Handled; @@ -113,7 +113,7 @@ public Action:Command_Cookie(client, args) if (access == CookieAccess_Private) { ReplyToCommand(client, "[SM] %t", "Cookie not Found", name); - CloseHandle(cookie); + delete cookie; return Plugin_Handled; } @@ -125,14 +125,14 @@ public Action:Command_Cookie(client, args) GetClientCookie(client, cookie, value, sizeof(value)); ReplyToCommand(client, "[SM] %t", "Cookie Value", name, value); - CloseHandle(cookie); + delete cookie; return Plugin_Handled; } if (access == CookieAccess_Protected) { ReplyToCommand(client, "[SM] %t", "Protected Cookie", name); - CloseHandle(cookie); + delete cookie; return Plugin_Handled; } @@ -141,7 +141,7 @@ public Action:Command_Cookie(client, args) GetCmdArg(2, value, sizeof(value)); SetClientCookie(client, cookie, value); - CloseHandle(cookie); + delete cookie; ReplyToCommand(client, "[SM] %t", "Cookie Changed Value", name, value); return Plugin_Handled; diff --git a/plugins/funcommands.sp b/plugins/funcommands.sp index 8b92efbe..73b5f8b3 100644 --- a/plugins/funcommands.sp +++ b/plugins/funcommands.sp @@ -95,7 +95,7 @@ new EngineVersion:g_GameEngine = Engine_Unknown; public OnPluginStart() { - if (FindPluginByFile("basefuncommands.smx") != INVALID_HANDLE) + if (FindPluginByFile("basefuncommands.smx") != null) { ThrowError("This plugin replaces basefuncommands. You cannot run both at once."); } @@ -180,7 +180,7 @@ HookEvents( ) public OnMapStart() { new Handle:gameConfig = LoadGameConfigFile("funcommands.games"); - if (gameConfig == INVALID_HANDLE) + if (gameConfig == null) { SetFailState("Unable to load game config funcommands.games"); return; @@ -237,7 +237,7 @@ public OnMapStart() g_HaloSprite = PrecacheModel(buffer); } - CloseHandle(gameConfig); + delete gameConfig; } public OnMapEnd() @@ -289,10 +289,10 @@ public OnAdminMenuReady(Handle aTopMenu) } } -AddTranslatedMenuItem(Handle:menu, const String:opt[], const String:phrase[], client) +void AddTranslatedMenuItem(Menu menu, const char[] opt, const char[] phrase, int client) { - decl String:buffer[128]; + char buffer[128]; Format(buffer, sizeof(buffer), "%T", phrase, client); - AddMenuItem(menu, opt, buffer); + menu.AddItem(opt, buffer); } diff --git a/plugins/funcommands/beacon.sp b/plugins/funcommands/beacon.sp index 1402d823..bb4fe3da 100644 --- a/plugins/funcommands/beacon.sp +++ b/plugins/funcommands/beacon.sp @@ -141,23 +141,23 @@ public AdminMenu_Beacon(Handle:topmenu, DisplayBeaconMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Beacon); + Menu menu = CreateMenu(MenuHandler_Beacon); decl String:title[100]; Format(title, sizeof(title), "%T:", "Beacon player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } -public MenuHandler_Beacon(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Beacon(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -171,7 +171,7 @@ public MenuHandler_Beacon(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/funcommands/blind.sp b/plugins/funcommands/blind.sp index c048a82e..77842438 100644 --- a/plugins/funcommands/blind.sp +++ b/plugins/funcommands/blind.sp @@ -103,39 +103,39 @@ public AdminMenu_Blind(Handle:topmenu, DisplayBlindMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Blind); + Menu menu = CreateMenu(MenuHandler_Blind); decl String:title[100]; Format(title, sizeof(title), "%T:", "Blind player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } DisplayAmountMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Amount); + Menu menu = CreateMenu(MenuHandler_Amount); decl String:title[100]; Format(title, sizeof(title), "%T: %N", "Blind amount", client, GetClientOfUserId(g_BlindTarget[client])); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTranslatedMenuItem(menu, "255", "Fully blind", client); AddTranslatedMenuItem(menu, "240", "Half blind", client); AddTranslatedMenuItem(menu, "0", "No blind", client); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } -public MenuHandler_Blind(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Blind(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -149,7 +149,7 @@ public MenuHandler_Blind(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) @@ -177,11 +177,11 @@ public MenuHandler_Blind(Handle:menu, MenuAction:action, param1, param2) return; } -public MenuHandler_Amount(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Amount(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -195,7 +195,7 @@ public MenuHandler_Amount(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new amount, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); amount = StringToInt(info); if ((target = GetClientOfUserId(g_BlindTarget[param1])) == 0) diff --git a/plugins/funcommands/drug.sp b/plugins/funcommands/drug.sp index 9be66e29..5750abb5 100644 --- a/plugins/funcommands/drug.sp +++ b/plugins/funcommands/drug.sp @@ -85,14 +85,14 @@ KillDrug(client) KillDrugTimer(client) { KillTimer(g_DrugTimers[client]); - g_DrugTimers[client] = INVALID_HANDLE; + g_DrugTimers[client] = null; } KillAllDrugs() { for (new i = 1; i <= MaxClients; i++) { - if (g_DrugTimers[i] != INVALID_HANDLE) + if (g_DrugTimers[i] != null) { if(IsClientInGame(i)) { @@ -112,7 +112,7 @@ PerformDrug(client, target, toggle) { case (2): { - if (g_DrugTimers[target] == INVALID_HANDLE) + if (g_DrugTimers[target] == null) { CreateDrug(target); LogAction(client, target, "\"%L\" drugged \"%L\"", client, target); @@ -126,7 +126,7 @@ PerformDrug(client, target, toggle) case (1): { - if (g_DrugTimers[target] == INVALID_HANDLE) + if (g_DrugTimers[target] == null) { CreateDrug(target); LogAction(client, target, "\"%L\" drugged \"%L\"", client, target); @@ -135,7 +135,7 @@ PerformDrug(client, target, toggle) case (0): { - if (g_DrugTimers[target] != INVALID_HANDLE) + if (g_DrugTimers[target] != null) { KillDrug(target); LogAction(client, target, "\"%L\" undrugged \"%L\"", client, target); @@ -222,23 +222,23 @@ public AdminMenu_Drug(Handle:topmenu, DisplayDrugMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Drug); + Menu menu = CreateMenu(MenuHandler_Drug); decl String:title[100]; Format(title, sizeof(title), "%T:", "Drug player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } -public MenuHandler_Drug(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Drug(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -252,7 +252,7 @@ public MenuHandler_Drug(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/funcommands/fire.sp b/plugins/funcommands/fire.sp index 1e73a4fb..03eaec4f 100644 --- a/plugins/funcommands/fire.sp +++ b/plugins/funcommands/fire.sp @@ -247,37 +247,37 @@ public AdminMenu_FireBomb(Handle:topmenu, DisplayBurnMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Burn); + Menu menu = CreateMenu(MenuHandler_Burn); decl String:title[100]; Format(title, sizeof(title), "%T:", "Burn player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } DisplayFireBombMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_FireBomb); + Menu menu = CreateMenu(MenuHandler_FireBomb); decl String:title[100]; Format(title, sizeof(title), "%T:", "FireBomb player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } -public MenuHandler_Burn(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Burn(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -291,7 +291,7 @@ public MenuHandler_Burn(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) @@ -318,11 +318,11 @@ public MenuHandler_Burn(Handle:menu, MenuAction:action, param1, param2) } } -public MenuHandler_FireBomb(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_FireBomb(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -336,7 +336,7 @@ public MenuHandler_FireBomb(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/funcommands/gravity.sp b/plugins/funcommands/gravity.sp index 69c20614..1ac7584c 100644 --- a/plugins/funcommands/gravity.sp +++ b/plugins/funcommands/gravity.sp @@ -58,26 +58,26 @@ public AdminMenu_Gravity(Handle:topmenu, DisplayGravityMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Gravity); + Menu menu = CreateMenu(MenuHandler_Gravity); decl String:title[100]; Format(title, sizeof(title), "%T:", "Gravity player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } DisplayGravityAmountMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_GravityAmount); + Menu menu = CreateMenu(MenuHandler_GravityAmount); decl String:title[100]; Format(title, sizeof(title), "%T: %N", "Gravity amount", client, GetClientOfUserId(g_GravityTarget[client])); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTranslatedMenuItem(menu, "4.0", "Gravity Very High", client); AddTranslatedMenuItem(menu, "2.0", "Gravity High", client); @@ -85,14 +85,14 @@ DisplayGravityAmountMenu(client) AddTranslatedMenuItem(menu, "0.5", "Gravity Low", client); AddTranslatedMenuItem(menu, "0.1", "Gravity Very Low", client); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } -public MenuHandler_Gravity(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Gravity(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -106,7 +106,7 @@ public MenuHandler_Gravity(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) @@ -134,11 +134,11 @@ public MenuHandler_Gravity(Handle:menu, MenuAction:action, param1, param2) return; } -public MenuHandler_GravityAmount(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_GravityAmount(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -152,7 +152,7 @@ public MenuHandler_GravityAmount(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new Float:amount, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); amount = StringToFloat(info); if ((target = GetClientOfUserId(g_GravityTarget[param1])) == 0) diff --git a/plugins/funcommands/ice.sp b/plugins/funcommands/ice.sp index 8de9701d..3f55c567 100644 --- a/plugins/funcommands/ice.sp +++ b/plugins/funcommands/ice.sp @@ -361,37 +361,37 @@ public AdminMenu_FreezeBomb(Handle:topmenu, DisplayFreezeMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Freeze); + Menu menu = CreateMenu(MenuHandler_Freeze); decl String:title[100]; Format(title, sizeof(title), "%T:", "Freeze player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } DisplayFreezeBombMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_FreezeBomb); + Menu menu = CreateMenu(MenuHandler_FreezeBomb); decl String:title[100]; Format(title, sizeof(title), "%T:", "FreezeBomb player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } -public MenuHandler_Freeze(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Freeze(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -405,7 +405,7 @@ public MenuHandler_Freeze(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) @@ -433,11 +433,11 @@ public MenuHandler_Freeze(Handle:menu, MenuAction:action, param1, param2) } } -public MenuHandler_FreezeBomb(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_FreezeBomb(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -451,7 +451,7 @@ public MenuHandler_FreezeBomb(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/funcommands/noclip.sp b/plugins/funcommands/noclip.sp index 5bc5e85b..d259daea 100644 --- a/plugins/funcommands/noclip.sp +++ b/plugins/funcommands/noclip.sp @@ -66,23 +66,23 @@ public AdminMenu_NoClip(Handle:topmenu, DisplayNoClipMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_NoClip); + Menu menu = CreateMenu(MenuHandler_NoClip); decl String:title[100]; Format(title, sizeof(title), "%T:", "NoClip player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } -public MenuHandler_NoClip(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_NoClip(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -96,7 +96,7 @@ public MenuHandler_NoClip(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/funcommands/timebomb.sp b/plugins/funcommands/timebomb.sp index cc659cf0..8f41fce2 100644 --- a/plugins/funcommands/timebomb.sp +++ b/plugins/funcommands/timebomb.sp @@ -232,23 +232,23 @@ public AdminMenu_TimeBomb(Handle:topmenu, DisplayTimeBombMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_TimeBomb); + Menu menu = CreateMenu(MenuHandler_TimeBomb); decl String:title[100]; Format(title, sizeof(title), "%T:", "TimeBomb player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } -public MenuHandler_TimeBomb(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_TimeBomb(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -262,7 +262,7 @@ public MenuHandler_TimeBomb(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/funvotes.sp b/plugins/funvotes.sp index d975ab2c..43753eb4 100644 --- a/plugins/funvotes.sp +++ b/plugins/funvotes.sp @@ -51,14 +51,14 @@ public Plugin:myinfo = #define VOTE_NO "###no###" #define VOTE_YES "###yes###" -new Handle:g_hVoteMenu = INVALID_HANDLE; +Menu g_hVoteMenu = null; ConVar g_Cvar_Limits[5] = {null, ...}; ConVar g_Cvar_Gravity; ConVar g_Cvar_Alltalk; ConVar g_Cvar_FF; -// new Handle:g_Cvar_Show = INVALID_HANDLE; +// new Handle:g_Cvar_Show = null; enum voteType { @@ -93,7 +93,7 @@ TopMenu hTopMenu; public OnPluginStart() { - if (FindPluginByFile("basefunvotes.smx") != INVALID_HANDLE) + if (FindPluginByFile("basefunvotes.smx") != null) { ThrowError("This plugin replaces basefuncommands. You cannot run both at once."); } @@ -121,7 +121,7 @@ public OnPluginStart() /* g_Cvar_Show = FindConVar("sm_vote_show"); - if (g_Cvar_Show == INVALID_HANDLE) + if (g_Cvar_Show == null) { g_Cvar_Show = CreateConVar("sm_vote_show", "1", "Show player's votes? Default on.", 0, true, 0.0, true, 1.0); } @@ -161,7 +161,7 @@ public OnAdminMenuReady(Handle aTopMenu) } } -public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2) +public Handler_VoteCallback(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { @@ -169,23 +169,23 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2) } else if (action == MenuAction_Display) { - decl String:title[64]; - GetMenuTitle(menu, title, sizeof(title)); + char title[64]; + menu.GetTitle(title, sizeof(title)); - decl String:buffer[255]; + char buffer[255]; Format(buffer, sizeof(buffer), "%T", title, param1, g_voteInfo[VOTE_NAME]); - new Handle:panel = Handle:param2; - SetPanelTitle(panel, buffer); + Panel panel = Panel:param2; + panel.SetTitle(buffer); } else if (action == MenuAction_DisplayItem) { - decl String:display[64]; - GetMenuItem(menu, param2, "", 0, _, display, sizeof(display)); + char display[64]; + menu.GetItem(param2, "", 0, _, display, sizeof(display)); if (strcmp(display, VOTE_NO) == 0 || strcmp(display, VOTE_YES) == 0) { - decl String:buffer[255]; + char buffer[255]; Format(buffer, sizeof(buffer), "%T", display, param1); return RedrawMenuItem(buffer); @@ -206,7 +206,7 @@ public Handler_VoteCallback(Handle:menu, MenuAction:action, param1, param2) int votes, totalVotes; GetMenuVoteInfo(param2, votes, totalVotes); - GetMenuItem(menu, param1, item, sizeof(item)); + menu.GetItem(param1, item, sizeof(item)); if (strcmp(item, VOTE_NO) == 0 && param1 == 1) { @@ -285,7 +285,7 @@ VoteSelect(Handle:menu, param1, param2 = 0) { decl String:voter[64], String:junk[64], String:choice[64]; GetClientName(param1, voter, sizeof(voter)); - GetMenuItem(menu, param2, junk, sizeof(junk), _, choice, sizeof(choice)); + menu.GetItem(param2, junk, sizeof(junk), _, choice, sizeof(choice)); PrintToChatAll("[SM] %T", "Vote Select", LANG_SERVER, voter, choice); } } @@ -293,8 +293,8 @@ VoteSelect(Handle:menu, param1, param2 = 0) VoteMenuClose() { - CloseHandle(g_hVoteMenu); - g_hVoteMenu = INVALID_HANDLE; + delete g_hVoteMenu; + g_hVoteMenu = null; } Float:GetVotePercent(votes, totalVotes) diff --git a/plugins/funvotes/votealltalk.sp b/plugins/funvotes/votealltalk.sp index 51fefd75..788e2d36 100644 --- a/plugins/funvotes/votealltalk.sp +++ b/plugins/funvotes/votealltalk.sp @@ -54,17 +54,17 @@ DisplayVoteAllTalkMenu(client) if (g_Cvar_Alltalk.BoolValue) { - SetMenuTitle(g_hVoteMenu, "Votealltalk Off"); + g_hVoteMenu.SetTitle("Votealltalk Off"); } else { - SetMenuTitle(g_hVoteMenu, "Votealltalk On"); + g_hVoteMenu.SetTitle("Votealltalk On"); } - AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes"); - AddMenuItem(g_hVoteMenu, VOTE_NO, "No"); - SetMenuExitButton(g_hVoteMenu, false); - VoteMenuToAll(g_hVoteMenu, 20); + g_hVoteMenu.AddItem(VOTE_YES, "Yes"); + g_hVoteMenu.AddItem(VOTE_NO, "No"); + g_hVoteMenu.ExitButton = false; + g_hVoteMenu.DisplayVoteToAll(20); } diff --git a/plugins/funvotes/voteburn.sp b/plugins/funvotes/voteburn.sp index fccb145f..862047d2 100644 --- a/plugins/funvotes/voteburn.sp +++ b/plugins/funvotes/voteburn.sp @@ -48,25 +48,25 @@ DisplayVoteBurnMenu(client, target, String:name[]) g_voteType = voteType:burn; g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL); - SetMenuTitle(g_hVoteMenu, "Voteburn player"); - AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes"); - AddMenuItem(g_hVoteMenu, VOTE_NO, "No"); - SetMenuExitButton(g_hVoteMenu, false); - VoteMenuToAll(g_hVoteMenu, 20); + g_hVoteMenu.SetTitle("Voteburn player"); + g_hVoteMenu.AddItem(VOTE_YES, "Yes"); + g_hVoteMenu.AddItem(VOTE_NO, "No"); + g_hVoteMenu.ExitButton = false; + g_hVoteMenu.DisplayVoteToAll(20); } DisplayBurnTargetMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Burn); + Menu menu = CreateMenu(MenuHandler_Burn); decl String:title[100]; Format(title, sizeof(title), "%T:", "Burn vote", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } public AdminMenu_VoteBurn(Handle:topmenu, @@ -91,11 +91,11 @@ public AdminMenu_VoteBurn(Handle:topmenu, } } -public MenuHandler_Burn(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Burn(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -109,7 +109,7 @@ public MenuHandler_Burn(Handle:menu, MenuAction:action, param1, param2) decl String:info[32], String:name[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name)); + menu.GetItem(param2, info, sizeof(info), _, name, sizeof(name)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/funvotes/voteff.sp b/plugins/funvotes/voteff.sp index 9fbb045c..66952ff6 100644 --- a/plugins/funvotes/voteff.sp +++ b/plugins/funvotes/voteff.sp @@ -54,17 +54,17 @@ DisplayVoteFFMenu(client) if (g_Cvar_FF.BoolValue) { - SetMenuTitle(g_hVoteMenu, "Voteff Off"); + g_hVoteMenu.SetTitle("Voteff Off"); } else { - SetMenuTitle(g_hVoteMenu, "Voteff On"); + g_hVoteMenu.SetTitle("Voteff On"); } - AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes"); - AddMenuItem(g_hVoteMenu, VOTE_NO, "No"); - SetMenuExitButton(g_hVoteMenu, false); - VoteMenuToAll(g_hVoteMenu, 20); + g_hVoteMenu.AddItem(VOTE_YES, "Yes"); + g_hVoteMenu.AddItem(VOTE_NO, "No"); + g_hVoteMenu.ExitButton = false; + g_hVoteMenu.DisplayVoteToAll(20); } public AdminMenu_VoteFF(Handle:topmenu, diff --git a/plugins/funvotes/votegravity.sp b/plugins/funvotes/votegravity.sp index d3de3572..81832a0e 100644 --- a/plugins/funvotes/votegravity.sp +++ b/plugins/funvotes/votegravity.sp @@ -45,23 +45,23 @@ DisplayVoteGravityMenu(client,count,String:items[5][]) { strcopy(g_voteInfo[VOTE_NAME], sizeof(g_voteInfo[]), items[0]); - SetMenuTitle(g_hVoteMenu, "Change Gravity To"); - AddMenuItem(g_hVoteMenu, items[0], "Yes"); - AddMenuItem(g_hVoteMenu, VOTE_NO, "No"); + g_hVoteMenu.SetTitle("Change Gravity To"); + g_hVoteMenu.AddItem(items[0], "Yes"); + g_hVoteMenu.AddItem(VOTE_NO, "No"); } else { g_voteInfo[VOTE_NAME][0] = '\0'; - SetMenuTitle(g_hVoteMenu, "Gravity Vote"); + g_hVoteMenu.SetTitle("Gravity Vote"); for (new i = 0; i < count; i++) { - AddMenuItem(g_hVoteMenu, items[i], items[i]); + g_hVoteMenu.AddItem(items[i], items[i]); } } - SetMenuExitButton(g_hVoteMenu, false); - VoteMenuToAll(g_hVoteMenu, 20); + g_hVoteMenu.ExitButton = false; + g_hVoteMenu.DisplayVoteToAll(20); } public AdminMenu_VoteGravity(Handle:topmenu, diff --git a/plugins/funvotes/voteslay.sp b/plugins/funvotes/voteslay.sp index 5536429a..59724022 100644 --- a/plugins/funvotes/voteslay.sp +++ b/plugins/funvotes/voteslay.sp @@ -49,25 +49,25 @@ DisplayVoteSlayMenu(client, target, String:name[]) g_voteType = voteType:slay; g_hVoteMenu = CreateMenu(Handler_VoteCallback, MenuAction:MENU_ACTIONS_ALL); - SetMenuTitle(g_hVoteMenu, "Voteslay Player"); - AddMenuItem(g_hVoteMenu, VOTE_YES, "Yes"); - AddMenuItem(g_hVoteMenu, VOTE_NO, "No"); - SetMenuExitButton(g_hVoteMenu, false); - VoteMenuToAll(g_hVoteMenu, 20); + g_hVoteMenu.SetTitle("Voteslay Player"); + g_hVoteMenu.AddItem(VOTE_YES, "Yes"); + g_hVoteMenu.AddItem(VOTE_NO, "No"); + g_hVoteMenu.ExitButton = false; + g_hVoteMenu.DisplayVoteToAll(20); } DisplaySlayTargetMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Slay); + Menu menu = CreateMenu(MenuHandler_Slay); decl String:title[100]; Format(title, sizeof(title), "%T:", "Slay vote", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } public AdminMenu_VoteSlay(Handle:topmenu, @@ -92,11 +92,11 @@ public AdminMenu_VoteSlay(Handle:topmenu, } } -public MenuHandler_Slay(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Slay(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -110,7 +110,7 @@ public MenuHandler_Slay(Handle:menu, MenuAction:action, param1, param2) decl String:info[32], String:name[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info), _, name, sizeof(name)); + menu.GetItem(param2, info, sizeof(info), _, name, sizeof(name)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/mapchooser.sp b/plugins/mapchooser.sp index b17677ce..6de66496 100644 --- a/plugins/mapchooser.sp +++ b/plugins/mapchooser.sp @@ -73,12 +73,12 @@ new Handle:g_VoteTimer = INVALID_HANDLE; new Handle:g_RetryTimer = INVALID_HANDLE; /* Data Handles */ -new Handle:g_MapList = INVALID_HANDLE; -new Handle:g_NominateList = INVALID_HANDLE; -new Handle:g_NominateOwners = INVALID_HANDLE; -new Handle:g_OldMapList = INVALID_HANDLE; -new Handle:g_NextMapList = INVALID_HANDLE; -new Handle:g_VoteMenu = INVALID_HANDLE; +new Handle:g_MapList = null; +new Handle:g_NominateList = null; +new Handle:g_NominateOwners = null; +new Handle:g_OldMapList = null; +new Handle:g_NextMapList = null; +Menu g_VoteMenu; new g_Extends; new g_TotalRounds; @@ -91,8 +91,8 @@ new g_mapFileSerial = -1; new MapChange:g_ChangeTime; -new Handle:g_NominationsResetForward = INVALID_HANDLE; -new Handle:g_MapVoteStartedForward = INVALID_HANDLE; +new Handle:g_NominationsResetForward = null; +new Handle:g_MapVoteStartedForward = null; /* Upper bound of how many team there could be */ #define MAXTEAMS 10 @@ -200,7 +200,7 @@ public OnConfigsExecuted() g_mapFileSerial, "mapchooser", MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_MAPSFOLDER) - != INVALID_HANDLE) + != null) { if (g_mapFileSerial == -1) @@ -244,8 +244,8 @@ public OnMapEnd() g_ChangeMapAtRoundEnd = false; g_ChangeMapInProgress = false; - g_VoteTimer = INVALID_HANDLE; - g_RetryTimer = INVALID_HANDLE; + g_VoteTimer = null; + g_RetryTimer = null; decl String:map[PLATFORM_MAX_PATH]; GetCurrentMap(map, sizeof(map)); @@ -319,14 +319,14 @@ SetupTimeleftTimer() new startTime = g_Cvar_StartTime.IntValue * 60; if (time - startTime < 0 && g_Cvar_EndOfMapVote.BoolValue && !g_MapVoteCompleted && !g_HasVoteStarted) { - InitiateVote(MapChange_MapEnd, INVALID_HANDLE); + InitiateVote(MapChange_MapEnd, null); } else { - if (g_VoteTimer != INVALID_HANDLE) + if (g_VoteTimer != null) { KillTimer(g_VoteTimer); - g_VoteTimer = INVALID_HANDLE; + g_VoteTimer = null; } //g_VoteTimer = CreateTimer(float(time - startTime), Timer_StartMapVote, _, TIMER_FLAG_NO_MAPCHANGE); @@ -344,11 +344,11 @@ public Action:Timer_StartMapVote(Handle:timer, Handle:data) if (timer == g_RetryTimer) { g_WaitingForVote = false; - g_RetryTimer = INVALID_HANDLE; + g_RetryTimer = null; } else { - g_VoteTimer = INVALID_HANDLE; + g_VoteTimer = null; } if (!GetArraySize(g_MapList) || !g_Cvar_EndOfMapVote.BoolValue || g_MapVoteCompleted || g_HasVoteStarted) @@ -464,7 +464,7 @@ public CheckWinLimit(winner_score) { if (winner_score >= (winlimit - g_Cvar_StartRounds.IntValue)) { - InitiateVote(MapChange_MapEnd, INVALID_HANDLE); + InitiateVote(MapChange_MapEnd, null); } } } @@ -479,7 +479,7 @@ public CheckMaxRounds(roundcount) { if (roundcount >= (maxrounds - g_Cvar_StartRounds.IntValue)) { - InitiateVote(MapChange_MapEnd, INVALID_HANDLE); + InitiateVote(MapChange_MapEnd, null); } } } @@ -511,13 +511,13 @@ public Event_PlayerDeath(Event event, const String:name[], bool:dontBroadcast) if (GetClientFrags(fragger) >= (g_Cvar_Fraglimit.IntValue - g_Cvar_StartFrags.IntValue)) { - InitiateVote(MapChange_MapEnd, INVALID_HANDLE); + InitiateVote(MapChange_MapEnd, null); } } public Action:Command_Mapvote(client, args) { - InitiateVote(MapChange_MapEnd, INVALID_HANDLE); + InitiateVote(MapChange_MapEnd, null); return Plugin_Handled; } @@ -529,7 +529,7 @@ public Action:Command_Mapvote(client, args) * @param inputlist Optional list of maps to use for the vote, otherwise an internal list of nominations + random maps will be used. * @param noSpecials Block special vote options like extend/nochange (upgrade this to bitflags instead?) */ -InitiateVote(MapChange:when, Handle:inputlist=INVALID_HANDLE) +InitiateVote(MapChange:when, Handle:inputlist=null) { g_WaitingForVote = true; @@ -557,9 +557,9 @@ InitiateVote(MapChange:when, Handle:inputlist=INVALID_HANDLE) g_WaitingForVote = false; g_HasVoteStarted = true; - g_VoteMenu = CreateMenu(Handler_MapVoteMenu, MenuAction:MENU_ACTIONS_ALL); - SetMenuTitle(g_VoteMenu, "Vote Nextmap"); - SetVoteResultCallback(g_VoteMenu, Handler_MapVoteFinished); + g_VoteMenu = new Menu(Handler_MapVoteMenu, MenuAction:MENU_ACTIONS_ALL); + g_VoteMenu.SetTitle("Vote Nextmap"); + g_VoteMenu.VoteResultCallback = Handler_MapVoteFinished; /* Call OnMapVoteStarted() Forward */ Call_StartForward(g_MapVoteStartedForward); @@ -575,7 +575,7 @@ InitiateVote(MapChange:when, Handle:inputlist=INVALID_HANDLE) char map[PLATFORM_MAX_PATH]; /* No input given - User our internal nominations and maplist */ - if (inputlist == INVALID_HANDLE) + if (inputlist == null) { int nominateCount = GetArraySize(g_NominateList); int voteSize = g_Cvar_IncludeMaps.IntValue; @@ -587,7 +587,7 @@ InitiateVote(MapChange:when, Handle:inputlist=INVALID_HANDLE) for (new i=0; i 1) @@ -790,25 +790,25 @@ public Handler_MapVoteFinished(Handle:menu, { /* Insufficient Winning margin - Lets do a runoff */ g_VoteMenu = CreateMenu(Handler_MapVoteMenu, MenuAction:MENU_ACTIONS_ALL); - SetMenuTitle(g_VoteMenu, "Runoff Vote Nextmap"); + g_VoteMenu.SetTitle("Runoff Vote Nextmap"); SetVoteResultCallback(g_VoteMenu, Handler_VoteFinishedGeneric); char map[PLATFORM_MAX_PATH]; char info1[PLATFORM_MAX_PATH]; char info2[PLATFORM_MAX_PATH]; - GetMenuItem(menu, item_info[0][VOTEINFO_ITEM_INDEX], map, sizeof(map), _, info1, sizeof(info1)); - AddMenuItem(g_VoteMenu, map, info1); - GetMenuItem(menu, item_info[1][VOTEINFO_ITEM_INDEX], map, sizeof(map), _, info2, sizeof(info2)); - AddMenuItem(g_VoteMenu, map, info2); + menu.GetItem(item_info[0][VOTEINFO_ITEM_INDEX], map, sizeof(map), _, info1, sizeof(info1)); + g_VoteMenu.AddItem(map, info1); + menu.GetItem(item_info[1][VOTEINFO_ITEM_INDEX], map, sizeof(map), _, info2, sizeof(info2)); + g_VoteMenu.AddItem(map, info2); int voteDuration = g_Cvar_VoteDuration.IntValue; - SetMenuExitButton(g_VoteMenu, false); - VoteMenuToAll(g_VoteMenu, voteDuration); + g_VoteMenu.ExitButton = false; + g_VoteMenu.DisplayVoteToAll(voteDuration); /* Notify */ - new Float:map1percent = float(item_info[0][VOTEINFO_ITEM_VOTES])/ float(num_votes) * 100; - new Float:map2percent = float(item_info[1][VOTEINFO_ITEM_VOTES])/ float(num_votes) * 100; + float map1percent = float(item_info[0][VOTEINFO_ITEM_VOTES])/ float(num_votes) * 100; + float map2percent = float(item_info[1][VOTEINFO_ITEM_VOTES])/ float(num_votes) * 100; PrintToChatAll("[SM] %t", "Starting Runoff", g_Cvar_RunOffPercent.FloatValue, info1, map1percent, info2, map2percent); @@ -821,14 +821,14 @@ public Handler_MapVoteFinished(Handle:menu, Handler_VoteFinishedGeneric(menu, num_votes, num_clients, client_info, num_items, item_info); } -public Handler_MapVoteMenu(Handle:menu, MenuAction:action, param1, param2) +public Handler_MapVoteMenu(Menu menu, MenuAction action, int param1, int param2) { switch (action) { case MenuAction_End: { - g_VoteMenu = INVALID_HANDLE; - CloseHandle(menu); + g_VoteMenu = null; + delete menu; } case MenuAction_Display: @@ -836,16 +836,16 @@ public Handler_MapVoteMenu(Handle:menu, MenuAction:action, param1, param2) decl String:buffer[255]; Format(buffer, sizeof(buffer), "%T", "Vote Nextmap", param1); - new Handle:panel = Handle:param2; - SetPanelTitle(panel, buffer); + Panel panel = Panel:param2; + panel.SetTitle(buffer); } case MenuAction_DisplayItem: { - if (GetMenuItemCount(menu) - 1 == param2) + if (menu.ItemCount - 1 == param2) { - decl String:map[PLATFORM_MAX_PATH], String:buffer[255]; - GetMenuItem(menu, param2, map, sizeof(map)); + char map[PLATFORM_MAX_PATH], buffer[255]; + menu.GetItem(param2, map, sizeof(map)); if (strcmp(map, VOTE_EXTEND, false) == 0) { Format(buffer, sizeof(buffer), "%T", "Extend Map", param1); @@ -864,9 +864,9 @@ public Handler_MapVoteMenu(Handle:menu, MenuAction:action, param1, param2) // If we receive 0 votes, pick at random. if (param1 == VoteCancel_NoVotes && g_Cvar_NoVoteMode.BoolValue) { - new count = GetMenuItemCount(menu); + new count = menu.ItemCount; decl String:map[PLATFORM_MAX_PATH]; - GetMenuItem(menu, 0, map, sizeof(map)); + menu.GetItem(0, map, sizeof(map)); // Make sure the first map in the menu isn't one of the special items. // This would mean there are no real maps in the menu, because the special items are added after all maps. Don't do anything if that's the case. @@ -874,13 +874,13 @@ public Handler_MapVoteMenu(Handle:menu, MenuAction:action, param1, param2) { // Get a random map from the list. new item = GetRandomInt(0, count - 1); - GetMenuItem(menu, item, map, sizeof(map)); + menu.GetItem(item, map, sizeof(map)); // Make sure it's not one of the special items. while (strcmp(map, VOTE_EXTEND, false) == 0 || strcmp(map, VOTE_DONTCHANGE, false) == 0) { item = GetRandomInt(0, count - 1); - GetMenuItem(menu, item, map, sizeof(map)); + menu.GetItem(item, map, sizeof(map)); } SetNextMap(map); @@ -905,7 +905,7 @@ public Action:Timer_ChangeMap(Handle:hTimer, Handle:dp) new String:map[PLATFORM_MAX_PATH]; - if (dp == INVALID_HANDLE) + if (dp == null) { if (!GetNextMap(map, sizeof(map))) { @@ -964,7 +964,7 @@ CreateNextVote() RemoveFromArray(tempMaps, b); } - CloseHandle(tempMaps); + delete tempMaps; } bool:CanVoteStart() @@ -1149,7 +1149,7 @@ public Native_GetExcludeMapList(Handle:plugin, numParams) { new Handle:array = Handle:GetNativeCell(1); - if (array == INVALID_HANDLE) + if (array == null) { return; } @@ -1170,7 +1170,7 @@ public Native_GetNominatedMapList(Handle:plugin, numParams) new Handle:maparray = Handle:GetNativeCell(1); new Handle:ownerarray = Handle:GetNativeCell(2); - if (maparray == INVALID_HANDLE) + if (maparray == null) return; decl String:map[PLATFORM_MAX_PATH]; @@ -1181,7 +1181,7 @@ public Native_GetNominatedMapList(Handle:plugin, numParams) PushArrayString(maparray, map); // If the optional parameter for an owner list was passed, then we need to fill that out as well - if(ownerarray != INVALID_HANDLE) + if(ownerarray != null) { new index = GetArrayCell(g_NominateOwners, i); PushArrayCell(ownerarray, index); diff --git a/plugins/nextmap.sp b/plugins/nextmap.sp index 365545af..8dd6624a 100644 --- a/plugins/nextmap.sp +++ b/plugins/nextmap.sp @@ -47,7 +47,7 @@ public Plugin myinfo = }; int g_MapPos = -1; -Handle g_MapList = INVALID_HANDLE; +Handle g_MapList = null; int g_MapListSerial = -1; int g_CurrentMapStartTime; @@ -130,7 +130,7 @@ void FindAndSetNextMap() g_MapListSerial, "mapcyclefile", MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_NO_DEFAULT) - == INVALID_HANDLE) + == null) { if (g_MapListSerial == -1) { diff --git a/plugins/nominations.sp b/plugins/nominations.sp index 0790fe22..b142fc18 100644 --- a/plugins/nominations.sp +++ b/plugins/nominations.sp @@ -85,7 +85,7 @@ public void OnConfigsExecuted() g_mapFileSerial, "nominations", MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_MAPSFOLDER) - == INVALID_HANDLE) + == null) { if (g_mapFileSerial == -1) { diff --git a/plugins/playercommands/rename.sp b/plugins/playercommands/rename.sp index c0c21097..2afd3765 100644 --- a/plugins/playercommands/rename.sp +++ b/plugins/playercommands/rename.sp @@ -73,25 +73,25 @@ public AdminMenu_Rename(Handle:topmenu, } } -DisplayRenameTargetMenu(client) +DisplayRenameTargetMenu(int client) { - new Handle:menu = CreateMenu(MenuHandler_Rename); + Menu menu = CreateMenu(MenuHandler_Rename); - decl String:title[100]; + char title[100]; Format(title, sizeof(title), "%T:", "Rename player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } -public MenuHandler_Rename(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Rename(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -105,7 +105,7 @@ public MenuHandler_Rename(Handle:menu, MenuAction:action, param1, param2) decl String:info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/playercommands/slap.sp b/plugins/playercommands/slap.sp index 53f3ec86..c561f54e 100644 --- a/plugins/playercommands/slap.sp +++ b/plugins/playercommands/slap.sp @@ -41,36 +41,36 @@ PerformSlap(client, target, damage) DisplaySlapDamageMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_SlapDamage); + Menu menu = CreateMenu(MenuHandler_SlapDamage); - decl String:title[100]; + char title[100]; Format(title, sizeof(title), "%T:", "Slap damage", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; - AddMenuItem(menu, "0", "0"); - AddMenuItem(menu, "1", "1"); - AddMenuItem(menu, "5", "5"); - AddMenuItem(menu, "10", "10"); - AddMenuItem(menu, "20", "20"); - AddMenuItem(menu, "50", "50"); - AddMenuItem(menu, "99", "99"); + menu.AddItem("0", "0"); + menu.AddItem("1", "1"); + menu.AddItem("5", "5"); + menu.AddItem("10", "10"); + menu.AddItem("20", "20"); + menu.AddItem("50", "50"); + menu.AddItem("99", "99"); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } DisplaySlapTargetMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Slap); + Menu menu = CreateMenu(MenuHandler_Slap); - decl String:title[100]; + char title[100]; Format(title, sizeof(title), "%T: %d damage", "Slap player", client, g_SlapDamage[client]); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } public AdminMenu_Slap(Handle:topmenu, @@ -90,11 +90,11 @@ public AdminMenu_Slap(Handle:topmenu, } } -public MenuHandler_SlapDamage(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_SlapDamage(Menu menu, MenuAction action, param1, param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -105,20 +105,20 @@ public MenuHandler_SlapDamage(Handle:menu, MenuAction:action, param1, param2) } else if (action == MenuAction_Select) { - decl String:info[32]; + char info[32]; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); g_SlapDamage[param1] = StringToInt(info); DisplaySlapTargetMenu(param1); } } -public MenuHandler_Slap(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Slap(Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -129,10 +129,10 @@ public MenuHandler_Slap(Handle:menu, MenuAction:action, param1, param2) } else if (action == MenuAction_Select) { - decl String:info[32]; + char info[32]; new userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/playercommands/slay.sp b/plugins/playercommands/slay.sp index 7e05ce8e..e5f19290 100644 --- a/plugins/playercommands/slay.sp +++ b/plugins/playercommands/slay.sp @@ -39,16 +39,16 @@ PerformSlay(client, target) DisplaySlayMenu(client) { - new Handle:menu = CreateMenu(MenuHandler_Slay); + Menu menu = CreateMenu(MenuHandler_Slay); - decl String:title[100]; + char title[100]; Format(title, sizeof(title), "%T:", "Slay player", client); - SetMenuTitle(menu, title); - SetMenuExitBackButton(menu, true); + menu.SetTitle(title); + menu.ExitBackButton = true; AddTargetsToMenu(menu, client, true, true); - DisplayMenu(menu, client, MENU_TIME_FOREVER); + menu.Display(client, MENU_TIME_FOREVER); } public AdminMenu_Slay(Handle:topmenu, @@ -68,11 +68,11 @@ public AdminMenu_Slay(Handle:topmenu, } } -public MenuHandler_Slay(Handle:menu, MenuAction:action, param1, param2) +public MenuHandler_Slay(Menu menu, MenuAction action, param1, param2) { if (action == MenuAction_End) { - CloseHandle(menu); + delete menu; } else if (action == MenuAction_Cancel) { @@ -83,10 +83,10 @@ public MenuHandler_Slay(Handle:menu, MenuAction:action, param1, param2) } else if (action == MenuAction_Select) { - decl String:info[32]; - new userid, target; + char info[32]; + int userid, target; - GetMenuItem(menu, param2, info, sizeof(info)); + menu.GetItem(param2, info, sizeof(info)); userid = StringToInt(info); if ((target = GetClientOfUserId(userid)) == 0) diff --git a/plugins/randomcycle.sp b/plugins/randomcycle.sp index 69e7da40..46dab7f9 100644 --- a/plugins/randomcycle.sp +++ b/plugins/randomcycle.sp @@ -45,8 +45,8 @@ public Plugin:myinfo = ConVar g_Cvar_ExcludeMaps; -new Handle:g_MapList = INVALID_HANDLE; -new Handle:g_OldMapList = INVALID_HANDLE; +new Handle:g_MapList = null; +new Handle:g_OldMapList = null; new g_mapListSerial = -1; public OnPluginStart() @@ -66,7 +66,7 @@ public OnConfigsExecuted() g_mapListSerial, "randomcycle", MAPLIST_FLAG_CLEARARRAY|MAPLIST_FLAG_MAPSFOLDER) - == INVALID_HANDLE) + == null) { if (g_mapListSerial == -1) { diff --git a/plugins/sql-admin-manager.sp b/plugins/sql-admin-manager.sp index 563abfc9..6ef9c380 100644 --- a/plugins/sql-admin-manager.sp +++ b/plugins/sql-admin-manager.sp @@ -76,7 +76,7 @@ Handle:Connect() db = SQL_Connect("default", true, error, sizeof(error)); } - if (db == INVALID_HANDLE) + if (db == null) { LogError("Could not connect to database: %s", error); } @@ -159,7 +159,7 @@ public Action:Command_CreateTables(args) { new client = 0; new Handle:db = Connect(); - if (db == INVALID_HANDLE) + if (db == null) { ReplyToCommand(client, "[SM] %t", "Could not connect to database"); return Plugin_Handled; @@ -177,7 +177,7 @@ public Action:Command_CreateTables(args) ReplyToCommand(client, "[SM] Unknown driver type '%s', cannot create tables.", ident); } - CloseHandle(db); + delete db; return Plugin_Handled; } @@ -188,7 +188,7 @@ bool:GetUpdateVersion(client, Handle:db, versions[4]) new Handle:hQuery; Format(query, sizeof(query), "SELECT cfg_value FROM sm_config WHERE cfg_key = 'admin_version'"); - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { DoError(client, db, query, "Version lookup query failed"); return false; @@ -208,7 +208,7 @@ bool:GetUpdateVersion(client, Handle:db, versions[4]) } } - CloseHandle(hQuery); + delete hQuery; if (current_version[3] < versions[3]) { @@ -232,7 +232,7 @@ UpdateSQLite(client, Handle:db) new Handle:hQuery; Format(query, sizeof(query), "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'sm_config'"); - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { DoError(client, db, query, "Table lookup query failed"); return; @@ -240,7 +240,7 @@ UpdateSQLite(client, Handle:db) new bool:found = SQL_FetchRow(hQuery); - CloseHandle(hQuery); + delete hQuery; new versions[4]; if (found) @@ -298,7 +298,7 @@ UpdateMySQL(client, Handle:db) new Handle:hQuery; Format(query, sizeof(query), "SHOW TABLES"); - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { DoError(client, db, query, "Table lookup query failed"); return; @@ -314,7 +314,7 @@ UpdateMySQL(client, Handle:db) found = true; } } - CloseHandle(hQuery); + delete hQuery; new versions[4]; @@ -365,7 +365,7 @@ public Action:Command_UpdateTables(args) { new client = 0; new Handle:db = Connect(); - if (db == INVALID_HANDLE) + if (db == null) { ReplyToCommand(client, "[SM] %t", "Could not connect to database"); return Plugin_Handled; @@ -383,7 +383,7 @@ public Action:Command_UpdateTables(args) ReplyToCommand(client, "[SM] Unknown driver type, cannot upgrade."); } - CloseHandle(db); + delete db; return Plugin_Handled; } @@ -408,7 +408,7 @@ public Action:Command_SetAdminGroups(client, args) } new Handle:db = Connect(); - if (db == INVALID_HANDLE) + if (db == null) { ReplyToCommand(client, "[SM] %t", "Could not connect to database"); return Plugin_Handled; @@ -427,7 +427,7 @@ public Action:Command_SetAdminGroups(client, args) safe_identity); new Handle:hQuery; - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { return DoError(client, db, query, "Admin lookup query failed"); } @@ -435,14 +435,14 @@ public Action:Command_SetAdminGroups(client, args) if (!SQL_FetchRow(hQuery)) { ReplyToCommand(client, "[SM] %t", "SQL Admin not found"); - CloseHandle(hQuery); - CloseHandle(db); + delete hQuery; + delete db; return Plugin_Handled; } new id = SQL_FetchInt(hQuery, 0); - CloseHandle(hQuery); + delete hQuery; /** * First delete all of the user's existing groups. @@ -456,7 +456,7 @@ public Action:Command_SetAdminGroups(client, args) if (args < 3) { ReplyToCommand(client, "[SM] %t", "SQL Admin groups reset"); - CloseHandle(db); + delete db; return Plugin_Handled; } @@ -464,7 +464,7 @@ public Action:Command_SetAdminGroups(client, args) new Handle:hAddQuery, Handle:hFindQuery; Format(query, sizeof(query), "SELECT id FROM sm_groups WHERE name = ?"); - if ((hFindQuery = SQL_PrepareQuery(db, query, error, sizeof(error))) == INVALID_HANDLE) + if ((hFindQuery = SQL_PrepareQuery(db, query, error, sizeof(error))) == null) { return DoStmtError(client, db, query, error, "Group search prepare failed"); } @@ -473,9 +473,9 @@ public Action:Command_SetAdminGroups(client, args) sizeof(query), "INSERT INTO sm_admins_groups (admin_id, group_id, inherit_order) VALUES (%d, ?, ?)", id); - if ((hAddQuery = SQL_PrepareQuery(db, query, error, sizeof(error))) == INVALID_HANDLE) + if ((hAddQuery = SQL_PrepareQuery(db, query, error, sizeof(error))) == null) { - CloseHandle(hFindQuery); + delete hFindQuery; return DoStmtError(client, db, query, error, "Add admin group prepare failed"); } @@ -502,9 +502,9 @@ public Action:Command_SetAdminGroups(client, args) } } - CloseHandle(hAddQuery); - CloseHandle(hFindQuery); - CloseHandle(db); + delete hAddQuery; + delete hFindQuery; + delete db; if (inherit_order == 1) { @@ -525,7 +525,7 @@ public Action:Command_DelGroup(client, args) } new Handle:db = Connect(); - if (db == INVALID_HANDLE) + if (db == null) { ReplyToCommand(client, "[SM] %t", "Could not connect to database"); return Plugin_Handled; @@ -550,7 +550,7 @@ public Action:Command_DelGroup(client, args) new Handle:hQuery; Format(query, sizeof(query), "SELECT id FROM sm_groups WHERE name = '%s'", safe_name); - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { return DoError(client, db, query, "Group retrieval query failed"); } @@ -558,14 +558,14 @@ public Action:Command_DelGroup(client, args) if (!SQL_FetchRow(hQuery)) { ReplyToCommand(client, "[SM] %t", "SQL Group not found"); - CloseHandle(hQuery); - CloseHandle(db); + delete hQuery; + delete db; return Plugin_Handled; } new id = SQL_FetchInt(hQuery, 0); - CloseHandle(hQuery); + delete hQuery; /* Delete admin inheritance for this group */ Format(query, sizeof(query), "DELETE FROM sm_admins_groups WHERE group_id = %d", id); @@ -597,7 +597,7 @@ public Action:Command_DelGroup(client, args) ReplyToCommand(client, "[SM] %t", "SQL Group deleted"); - CloseHandle(db); + delete db; return Plugin_Handled; } @@ -623,7 +623,7 @@ public Action:Command_AddGroup(client, args) } new Handle:db = Connect(); - if (db == INVALID_HANDLE) + if (db == null) { ReplyToCommand(client, "[SM] %t", "Could not connect to database"); return Plugin_Handled; @@ -637,7 +637,7 @@ public Action:Command_AddGroup(client, args) new Handle:hQuery; decl String:query[256]; Format(query, sizeof(query), "SELECT id FROM sm_groups WHERE name = '%s'", safe_name); - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { return DoError(client, db, query, "Group retrieval query failed"); } @@ -645,12 +645,12 @@ public Action:Command_AddGroup(client, args) if (SQL_GetRowCount(hQuery) > 0) { ReplyToCommand(client, "[SM] %t", "SQL Group already exists"); - CloseHandle(hQuery); - CloseHandle(db); + delete hQuery; + delete db; return Plugin_Handled; } - CloseHandle(hQuery); + delete hQuery; decl String:flags[30]; decl String:safe_flags[64]; @@ -671,7 +671,7 @@ public Action:Command_AddGroup(client, args) ReplyToCommand(client, "[SM] %t", "SQL Group added"); - CloseHandle(db); + delete db; return Plugin_Handled; } @@ -697,7 +697,7 @@ public Action:Command_DelAdmin(client, args) } new Handle:db = Connect(); - if (db == INVALID_HANDLE) + if (db == null) { ReplyToCommand(client, "[SM] %t", "Could not connect to database"); return Plugin_Handled; @@ -716,7 +716,7 @@ public Action:Command_DelAdmin(client, args) safe_identity); new Handle:hQuery; - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { return DoError(client, db, query, "Admin lookup query failed"); } @@ -724,14 +724,14 @@ public Action:Command_DelAdmin(client, args) if (!SQL_FetchRow(hQuery)) { ReplyToCommand(client, "[SM] %t", "SQL Admin not found"); - CloseHandle(hQuery); - CloseHandle(db); + delete hQuery; + delete db; return Plugin_Handled; } new id = SQL_FetchInt(hQuery, 0); - CloseHandle(hQuery); + delete hQuery; /* Delete group bindings */ Format(query, sizeof(query), "DELETE FROM sm_admins_groups WHERE admin_id = %d", id); @@ -746,7 +746,7 @@ public Action:Command_DelAdmin(client, args) return DoError(client, db, query, "Admin deletion query failed"); } - CloseHandle(db); + delete db; ReplyToCommand(client, "[SM] %t", "SQL Admin deleted"); @@ -792,7 +792,7 @@ public Action:Command_AddAdmin(client, args) decl String:query[256]; new Handle:hQuery; new Handle:db = Connect(); - if (db == INVALID_HANDLE) + if (db == null) { ReplyToCommand(client, "[SM] %t", "Could not connect to database"); return Plugin_Handled; @@ -801,7 +801,7 @@ public Action:Command_AddAdmin(client, args) SQL_EscapeString(db, identity, safe_identity, sizeof(safe_identity)); Format(query, sizeof(query), "SELECT id FROM sm_admins WHERE authtype = '%s' AND identity = '%s'", authtype, identity); - if ((hQuery = SQL_Query(db, query)) == INVALID_HANDLE) + if ((hQuery = SQL_Query(db, query)) == null) { return DoError(client, db, query, "Admin retrieval query failed"); } @@ -809,12 +809,12 @@ public Action:Command_AddAdmin(client, args) if (SQL_GetRowCount(hQuery) > 0) { ReplyToCommand(client, "[SM] %t", "SQL Admin already exists"); - CloseHandle(hQuery); - CloseHandle(db); + delete hQuery; + delete db; return Plugin_Handled; } - CloseHandle(hQuery); + delete hQuery; decl String:alias[64]; decl String:safe_alias[140]; @@ -852,7 +852,7 @@ public Action:Command_AddAdmin(client, args) ReplyToCommand(client, "[SM] %t", "SQL Admin added"); - CloseHandle(db); + delete db; return Plugin_Handled; } @@ -878,7 +878,7 @@ stock Action:DoError(client, Handle:db, const String:query[], const String:msg[] SQL_GetError(db, error, sizeof(error)); LogError("%s: %s", msg, error); LogError("Query dump: %s", query); - CloseHandle(db); + delete db; ReplyToCommand(client, "[SM] %t", "Failed to query database"); return Plugin_Handled; } @@ -887,7 +887,7 @@ stock Action:DoStmtError(client, Handle:db, const String:query[], const String:e { LogError("%s: %s", msg, error); LogError("Query dump: %s", query); - CloseHandle(db); + delete db; ReplyToCommand(client, "[SM] %t", "Failed to query database"); return Plugin_Handled; } diff --git a/plugins/testsuite/benchmark.sp b/plugins/testsuite/benchmark.sp index 7d39dfab..a5da3289 100644 --- a/plugins/testsuite/benchmark.sp +++ b/plugins/testsuite/benchmark.sp @@ -18,7 +18,7 @@ public Plugin:myinfo = #define STRING_RPLC_LOOPS 2000 new Float:g_dict_time -new Handle:g_Prof = INVALID_HANDLE +new Handle:g_Prof = null public OnPluginStart() { diff --git a/plugins/testsuite/callfunctest.sp b/plugins/testsuite/callfunctest.sp index e983d9a1..1429f8a6 100644 --- a/plugins/testsuite/callfunctest.sp +++ b/plugins/testsuite/callfunctest.sp @@ -63,7 +63,7 @@ public OnReentrantCallReceived(num, String:str[]) PrintToServer("num = %d (expected: %d)", num, 7); PrintToServer("str[] = \"%s\" (expected: \"%s\")", str, "nana"); - new Function:func = GetFunctionByName(INVALID_HANDLE, "OnReentrantCallReceivedTwo"); + new Function:func = GetFunctionByName(null, "OnReentrantCallReceivedTwo"); if (func == INVALID_FUNCTION) { @@ -73,7 +73,7 @@ public OnReentrantCallReceived(num, String:str[]) PrintToServer("Calling OnReentrantCallReceivedTwo..."); - Call_StartFunction(INVALID_HANDLE, func); + Call_StartFunction(null, func); Call_PushFloat(8.0); err = Call_Finish(ret); @@ -105,7 +105,7 @@ public Action:Command_CallFunc(args) new err; new ret; - new Function:func = GetFunctionByName(INVALID_HANDLE, "OnCallFuncReceived"); + new Function:func = GetFunctionByName(null, "OnCallFuncReceived"); if (func == INVALID_FUNCTION) { @@ -115,7 +115,7 @@ public Action:Command_CallFunc(args) PrintToServer("Calling OnCallFuncReceived..."); - Call_StartFunction(INVALID_HANDLE, func); + Call_StartFunction(null, func); Call_PushCell(5); Call_PushFloat(7.17); Call_PushString(what); @@ -146,7 +146,7 @@ public Action:Command_CallFunc(args) public Action:Command_ReentrantCallFunc(args) { new err, ret; - new Function:func = GetFunctionByName(INVALID_HANDLE, "OnReentrantCallReceived"); + new Function:func = GetFunctionByName(null, "OnReentrantCallReceived"); if (func == INVALID_FUNCTION) { @@ -156,7 +156,7 @@ public Action:Command_ReentrantCallFunc(args) PrintToServer("Calling OnReentrantCallReceived..."); - Call_StartFunction(INVALID_HANDLE, func); + Call_StartFunction(null, func); Call_PushCell(7); Call_PushString("nana"); err = Call_Finish(ret); diff --git a/plugins/testsuite/fwdtest1.sp b/plugins/testsuite/fwdtest1.sp index 5e9a8efe..e2de47e0 100644 --- a/plugins/testsuite/fwdtest1.sp +++ b/plugins/testsuite/fwdtest1.sp @@ -9,8 +9,8 @@ public Plugin:myinfo = url = "http://www.sourcemod.net/" }; -new Handle:g_GlobalFwd = INVALID_HANDLE; -new Handle:g_PrivateFwd = INVALID_HANDLE; +new Handle:g_GlobalFwd = null; +new Handle:g_PrivateFwd = null; public OnPluginStart() { @@ -22,20 +22,20 @@ public OnPluginStart() public OnPluginEnd() { - CloseHandle(g_GlobalFwd); - CloseHandle(g_PrivateFwd); + delete g_GlobalFwd; + delete g_PrivateFwd; } public Action:Command_CreateGlobalForward(args) { - if (g_GlobalFwd != INVALID_HANDLE) + if (g_GlobalFwd != null) { - CloseHandle(g_GlobalFwd); + delete g_GlobalFwd; } g_GlobalFwd = CreateGlobalForward("OnGlobalForward", ET_Ignore, Param_Any, Param_Cell, Param_Float, Param_String, Param_Array, Param_CellByRef, Param_FloatByRef); - if (g_GlobalFwd == INVALID_HANDLE) + if (g_GlobalFwd == null) { PrintToServer("Failed to create global forward!"); } @@ -48,14 +48,14 @@ public Action:Command_CreatePrivateForward(args) new Handle:pl; new Function:func; - if (g_PrivateFwd != INVALID_HANDLE) + if (g_PrivateFwd != null) { - CloseHandle(g_PrivateFwd); + delete g_PrivateFwd; } g_PrivateFwd = CreateForward(ET_Hook, Param_Cell, Param_String, Param_VarArgs); - if (g_PrivateFwd == INVALID_HANDLE) + if (g_PrivateFwd == null) { PrintToServer("Failed to create private forward!") } @@ -92,7 +92,7 @@ public Action:Command_ExecGlobalForward(args) new Float:b = 4.215; new err, ret; - if (g_GlobalFwd == INVALID_HANDLE) + if (g_GlobalFwd == null) { PrintToServer("Failed to execute global forward. Create it first."); return Plugin_Handled; @@ -124,7 +124,7 @@ public Action:Command_ExecPrivateForward(args) { new err, ret; - if (g_PrivateFwd == INVALID_HANDLE) + if (g_PrivateFwd == null) { PrintToServer("Failed to execute private forward. Create it first."); return Plugin_Handled; diff --git a/plugins/testsuite/sqltest.sp b/plugins/testsuite/sqltest.sp index 1f5ac978..04bcff40 100644 --- a/plugins/testsuite/sqltest.sp +++ b/plugins/testsuite/sqltest.sp @@ -20,7 +20,7 @@ public OnPluginStart() RegServerCmd("sql_test_txn", Command_TestTxn) new Handle:hibernate = FindConVar("sv_hibernate_when_empty"); - if (hibernate != INVALID_HANDLE) { + if (hibernate != null) { ServerCommand("sv_hibernate_when_empty 0"); } } @@ -63,23 +63,23 @@ public Action:Command_TestSql1(args) { new String:error[255] new Handle:db = SQL_DefConnect(error, sizeof(error)) - if (db == INVALID_HANDLE) + if (db == null) { PrintToServer("Failed to connect: %s", error) return Plugin_Handled } new Handle:query = SQL_Query(db, "SELECT * FROM gab") - if (query == INVALID_HANDLE) + if (query == null) { SQL_GetError(db, error, sizeof(error)) PrintToServer("Failed to query: %s", error) } else { PrintQueryData(query) - CloseHandle(query) + delete query } - CloseHandle(db) + delete db return Plugin_Handled; } @@ -88,14 +88,14 @@ public Action:Command_TestSql2(args) { new String:error[255] new Handle:db = SQL_DefConnect(error, sizeof(error)) - if (db == INVALID_HANDLE) + if (db == null) { PrintToServer("Failed to connect: %s", error) return Plugin_Handled } new Handle:stmt = SQL_PrepareQuery(db, "SELECT * FROM gab WHERE gaben > ?", error, sizeof(error)) - if (stmt == INVALID_HANDLE) + if (stmt == null) { PrintToServer("Failed to prepare query: %s", error) } else { @@ -107,22 +107,22 @@ public Action:Command_TestSql2(args) } else { PrintQueryData(stmt) } - CloseHandle(stmt) + delete stmt } - CloseHandle(db) + delete db return Plugin_Handled; } -new Handle:g_ThreadedHandle = INVALID_HANDLE; +new Handle:g_ThreadedHandle = null; public CallbackTest3(Handle:owner, Handle:hndl, const String:error[], any:data) { PrintToServer("CallbackTest1() (owner %x) (hndl %x) (error \"%s\") (data %d)", owner, hndl, error, data); - if (g_ThreadedHandle != INVALID_HANDLE && hndl != INVALID_HANDLE) + if (g_ThreadedHandle != null && hndl != null) { - CloseHandle(hndl); + delete hndl; } else { g_ThreadedHandle = hndl; } @@ -130,7 +130,7 @@ public CallbackTest3(Handle:owner, Handle:hndl, const String:error[], any:data) public Action:Command_TestSql3(args) { - if (g_ThreadedHandle != INVALID_HANDLE) + if (g_ThreadedHandle != null) { PrintToServer("A threaded connection already exists, run the next test"); return Plugin_Handled; @@ -149,14 +149,14 @@ public Action:Command_TestSql4(args) { SQL_LockDatabase(g_ThreadedHandle); new Handle:query = SQL_Query(g_ThreadedHandle, "SELECT * FROM gab") - if (query == INVALID_HANDLE) + if (query == null) { new String:error[255]; SQL_GetError(g_ThreadedHandle, error, sizeof(error)) PrintToServer("Failed to query: %s", error) } else { PrintQueryData(query) - CloseHandle(query) + delete query } SQL_UnlockDatabase(g_ThreadedHandle); @@ -165,7 +165,7 @@ public Action:Command_TestSql4(args) public CallbackTest5(Handle:owner, Handle:hndl, const String:error[], any:data) { - if (hndl == INVALID_HANDLE) + if (hndl == null) { PrintToServer("Failed to query: %s", error) } else { @@ -176,7 +176,7 @@ public CallbackTest5(Handle:owner, Handle:hndl, const String:error[], any:data) public CallbackTest6(Handle:owner, Handle:hndl, const String:error[], any:data) { - if (hndl == INVALID_HANDLE) + if (hndl == null) { PrintToServer("Failed to query: %s", error) } else { @@ -187,7 +187,7 @@ public CallbackTest6(Handle:owner, Handle:hndl, const String:error[], any:data) public CallbackTest7(Handle:owner, Handle:hndl, const String:error[], any:data) { - if (hndl == INVALID_HANDLE) + if (hndl == null) { PrintToServer("Failed to query: %s", error) } else { @@ -266,7 +266,7 @@ public Action:Command_TestTxn(args) { new String:error[256]; new Handle:db = SQL_Connect("storage-local", false, error, sizeof(error)); - if (db == INVALID_HANDLE) { + if (db == null) { ThrowError("ERROR: %s", error); return Plugin_Handled; } @@ -305,7 +305,7 @@ public Action:Command_TestTxn(args) // Make sure the transaction was rolled back - COUNT should be 5. txn = SQL_CreateTransaction(); - AssertEq("CloneHandle", _:CloneHandle(txn), _:INVALID_HANDLE); + AssertEq("CloneHandle", _:CloneHandle(txn), _:null); txn.AddQuery("SELECT COUNT(id) FROM egg"); SQL_ExecuteTransaction( db, diff --git a/plugins/testsuite/structtest.sp b/plugins/testsuite/structtest.sp index 8a96c781..369d55dc 100644 --- a/plugins/testsuite/structtest.sp +++ b/plugins/testsuite/structtest.sp @@ -40,7 +40,7 @@ public Action:Command_GetString(args) LogMessage("Value of %s: %s", arg2, value); - CloseHandle(strct); + delete strct; return Plugin_Handled; } @@ -61,7 +61,7 @@ public Action:Command_SetString(args) new Handle:strct = GetWeaponStruct(arg1); SetStructString(strct, arg2, value); - CloseHandle(strct); + delete strct; return Plugin_Handled; @@ -84,7 +84,7 @@ public Action:Command_GetInt(args) LogMessage("Value of %s: %i", arg2, value); - CloseHandle(strct); + delete strct; return Plugin_Handled; } @@ -106,7 +106,7 @@ public Action:Command_SetInt(args) SetStructInt(strct, arg2, StringToInt(value)); - CloseHandle(strct); + delete strct; return Plugin_Handled; } @@ -128,7 +128,7 @@ public Action:Command_GetFloat(args) LogMessage("Value of %s: %f", arg2, value); - CloseHandle(strct); + delete strct; return Plugin_Handled; } @@ -150,7 +150,7 @@ public Action:Command_SetFloat(args) SetStructFloat(strct, arg2, StringToFloat(value)); - CloseHandle(strct); + delete strct; return Plugin_Handled; }