From 93d37a63669b250de7f200b5d486d46f64b16c12 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 19:07:24 +0200 Subject: [PATCH] Plmenu: replace len hardcoded content by charsmax --- plugins/ns/plmenu.sma | 172 +++++++++++++++++++++--------------------- 1 file changed, 86 insertions(+), 86 deletions(-) diff --git a/plugins/ns/plmenu.sma b/plugins/ns/plmenu.sma index 6663ad80..dc70a14c 100644 --- a/plugins/ns/plmenu.sma +++ b/plugins/ns/plmenu.sma @@ -1,15 +1,15 @@ -// vim: set ts=4 sw=4 tw=99 noet: -// -// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO"). -// Copyright (C) The AMX Mod X Development Team. -// -// This software is licensed under the GNU General Public License, version 3 or higher. -// Additional exceptions apply. For full license details, see LICENSE.txt or visit: -// https://alliedmods.net/amxmodx-license - -// -// Players Menu Plugin -// +// vim: set ts=4 sw=4 tw=99 noet: +// +// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO"). +// Copyright (C) The AMX Mod X Development Team. +// +// This software is licensed under the GNU General Public License, version 3 or higher. +// Additional exceptions apply. For full license details, see LICENSE.txt or visit: +// https://alliedmods.net/amxmodx-license + +// +// Players Menu Plugin +// #include #include @@ -146,8 +146,8 @@ public plugin_init() g_gametype = ns_get_gameplay(); new clcmds_ini_file[64] - get_configsdir(clcmds_ini_file, 63) - format(clcmds_ini_file, 63, "%s/clcmds.ini", clcmds_ini_file) + get_configsdir(clcmds_ini_file, charsmax(clcmds_ini_file)) + format(clcmds_ini_file, charsmax(clcmds_ini_file), "%s/clcmds.ini", clcmds_ini_file) load_settings(clcmds_ini_file) // initialize the ns team names @@ -306,10 +306,10 @@ public actionBanMenu(id, key) new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] new name[MAX_NAME_LENGTH], name2[MAX_NAME_LENGTH], authid[32], authid2[32] - get_user_name(player, name2, 31) - get_user_authid(id, authid, 31) - get_user_authid(player, authid2, 31) - get_user_name(id, name, 31) + get_user_name(player, name2, charsmax(name2)) + get_user_authid(id, authid, charsmax(authid)) + get_user_authid(player, authid2, charsmax(authid2)) + get_user_name(id, name, charsmax(name)) new userid2 = get_user_userid(player) @@ -325,7 +325,7 @@ public actionBanMenu(id, key) else { new tempTime[32]; - formatex(tempTime,sizeof(tempTime)-1,"%d",banTime); + formatex(tempTime,charsmax(tempTime),"%d",banTime); for (new i = 1; i <= MaxClients; i++) { show_activity_id(i, id, name, "%L %s %L", i, "BAN", name2, i, "FOR_MIN", tempTime); @@ -341,7 +341,7 @@ public actionBanMenu(id, key) { /* END OF MODIFICATIONS BY MISTAGEE */ new ipa[32] - get_user_ip(player, ipa, 31, 1) + get_user_ip(player, ipa, charsmax(ipa), 1) server_cmd("addip %d %s;writeip", banTime, ipa) if( g_tempBans ) @@ -383,7 +383,7 @@ displayBanMenu(id, pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, "%L %d/%d^n^n", id, "BAN_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) + new len = format(menuBody, charsmax(menuBody), "%L %d/%d^n^n", id, "BAN_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) new end = start + 7 new keys = MENU_KEY_0|MENU_KEY_8 @@ -393,35 +393,35 @@ displayBanMenu(id, pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i, name, 31) + get_user_name(i, name, charsmax(name)) if (is_user_bot(i) || access(i, ADMIN_IMMUNITY)) { ++b - len += format(menuBody[len], 511-len, "#. %s^n", name) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s^n", name) } else { keys |= (1< 1 && g_menuOption[id] < aSize -1) @@ -524,7 +524,7 @@ displaySlapMenu(id, pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, "%L %d/%d^n^n", id, "SLAP_SLAY_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) + new len = format(menuBody, charsmax(menuBody), "%L %d/%d^n^n", id, "SLAP_SLAY_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) new end = start + 7 new keys = MENU_KEY_0|MENU_KEY_8 @@ -534,37 +534,37 @@ displaySlapMenu(id, pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i, name, 31) + get_user_name(i, name, charsmax(name)) - get_user_team(i, team, 3) + get_user_team(i, team, charsmax(team)) if (!is_user_alive(i) || access(i, ADMIN_IMMUNITY)) { ++b - len += format(menuBody[len], 511-len, "#. %s %s^n", name, team) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s %s^n", name, team) } else { keys |= (1<= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, "%L %d/%d^n^n", id, "KICK_MENU", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0))) + new len = format(menuBody, charsmax(menuBody), "%L %d/%d^n^n", id, "KICK_MENU", pos + 1, (g_menuPlayersNum[id] / 8 + ((g_menuPlayersNum[id] % 8) ? 1 : 0))) new end = start + 8 new keys = MENU_KEY_0 @@ -651,30 +651,30 @@ displayKickMenu(id, pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i, name, 31) + get_user_name(i, name, charsmax(name)) if (access(i, ADMIN_IMMUNITY)) { ++b - len += format(menuBody[len], 511-len, "#. %s^n", name) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s^n", name) } else { keys |= (1<<%s><>^" transfer ^"%s<%d><%s><>^" (team ^"%s^")", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2, g_PrettyTeamNames[g_menuOption[id]]) @@ -745,7 +745,7 @@ displayTeamMenu(id, pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, "%L %d/%d^n^n", id, "TEAM_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) + new len = format(menuBody, charsmax(menuBody), "%L %d/%d^n^n", id, "TEAM_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) new end = start + 7 new keys = MENU_KEY_0|MENU_KEY_8 @@ -755,34 +755,34 @@ displayTeamMenu(id, pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i, name, 31) + get_user_name(i, name, charsmax(name)) - iteam = GetNSTeam(i, team, 3) + iteam = GetNSTeam(i, team, charsmax(team)) if (iteam == g_menuOption[id] || access(i, ADMIN_IMMUNITY)) { ++b - len += format(menuBody[len], 511-len, "#. %s %s^n", name, team) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s %s^n", name, team) } else { keys |= (1<= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, "%L %d/%d^n^n", id, "CL_CMD_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) + new len = format(menuBody, charsmax(menuBody), "%L %d/%d^n^n", id, "CL_CMD_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) new end = start + 7 new keys = MENU_KEY_0|MENU_KEY_8 @@ -875,35 +875,35 @@ displayClcmdMenu(id, pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i, name, 31) + get_user_name(i, name, charsmax(name)) if (!g_menuSelectNum[id] || access(i, ADMIN_IMMUNITY)) { ++b - len += format(menuBody[len], 511-len, "#. %s^n", name) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s^n", name) } else { keys |= (1< 3) + if (parse(text, g_clcmdName[g_clcmdNum], charsmax(g_clcmdName[]), g_clcmdCmd[g_clcmdNum], charsmax(g_clcmdCmd[]), szFlags, charsmax(szFlags), szAccess, charsmax(szAccess)) > 3) { - while (replace(g_clcmdCmd[g_clcmdNum], 63, "\'", "^"")) + while (replace(g_clcmdCmd[g_clcmdNum], charsmax(g_clcmdCmd[]), "\'", "^"")) { // do nothing }