From 71f011c70d9e104f8f2a70e26535a644382a4f5b Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Wed, 8 Oct 2014 14:21:53 +0200 Subject: [PATCH 01/30] Restmenu: replace len hardcoded content by charsmax and sizeof --- plugins/cstrike/restmenu.sma | 58 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/plugins/cstrike/restmenu.sma b/plugins/cstrike/restmenu.sma index 17980c87..615b2e4a 100755 --- a/plugins/cstrike/restmenu.sma +++ b/plugins/cstrike/restmenu.sma @@ -376,7 +376,7 @@ switchCommand(id, action) for (new b = 2; b < c; ++b) { - read_argv(b, arg, 31) + read_argv(b, arg, charsmax(arg)) if ((a = findMenuId(arg)) != -1) { @@ -418,7 +418,7 @@ public cmdRest(id, level, cid) new cmd[8] - read_argv(1, cmd, 7) + read_argv(1, cmd, charsmax(cmd)) if (equali("on", cmd)) switchCommand(id, 1) @@ -427,7 +427,7 @@ public cmdRest(id, level, cid) else if (equali("list", cmd)) { new arg1[8] - new start = read_argv(2, arg1, 7) ? str_to_num(arg1) : 1 + new start = read_argv(2, arg1, charsmax(arg1)) ? str_to_num(arg1) : 1 if (--start < 0) start = 0 @@ -442,9 +442,9 @@ public cmdRest(id, level, cid) new lName[16], lValue[16], lStatus[16], lOnOff[16] - format(lName, 15, "%L", id, "NAME") - format(lValue, 15, "%L", id, "VALUE") - format(lStatus, 15, "%L", id, "STATUS") + format(lName, charsmax(lName), "%L", id, "NAME") + format(lValue, charsmax(lValue), "%L", id, "VALUE") + format(lStatus, charsmax(lStatus), "%L", id, "STATUS") console_print(id, "^n----- %L: -----", id, "WEAP_RES") console_print(id, " %-32.31s %-10.9s %-9.8s", lName, lValue, lStatus) @@ -453,7 +453,7 @@ public cmdRest(id, level, cid) { for (new a = start; a < end; ++a) { - format(lOnOff, 15, "%L", id, positionBlocked(a) ? "ON" : "OFF") + format(lOnOff, charsmax(lOnOff), "%L", id, positionBlocked(a) ? "ON" : "OFF") console_print(id, "%3d: %-32.31s %-10.9s %-9.8s", a + 1, g_WeaponNames[a], g_Aliases[a], lOnOff) } } @@ -477,15 +477,15 @@ public cmdRest(id, level, cid) } else if (equali("load", cmd)) { - setc(g_blockPos, 112, 0) // Clear current settings + setc(g_blockPos, sizeof(g_blockPos), 0) // Clear current settings new arg1[64] - if (read_argv(2, arg1, 63)) + if (read_argv(2, arg1, charsmax(arg1))) { new configsdir[32] - get_configsdir(configsdir, 31) + get_configsdir(configsdir, charsmax(configsdir)) - format(arg1, 63, "%s/%s", configsdir, arg1) + format(arg1, charsmax(arg1), "%s/%s", configsdir, arg1) } if (loadSettings(arg1)) @@ -522,7 +522,7 @@ displayMenu(id, pos) if (start >= MAXMENUPOS) start = pos = g_Position[id] = 0 - new len = format(menubody, 511, "\y%L\R%d/5^n^n\w", id, "REST_WEAP", pos + 1) + new len = format(menubody, charsmax(menubody), "\y%L\R%d/5^n^n\w", id, "REST_WEAP", pos + 1) new end = start + 7, keys = MENU_KEY_0|MENU_KEY_8, k = 0 if (end > MAXMENUPOS) @@ -531,18 +531,18 @@ displayMenu(id, pos) for (new a = start; a < end; ++a) { keys |= (1< 11) /* Longest buy command has 11 chars so if command is longer then don't care */ + if (read_argv(0, arg, charsmax(arg)) > 11) /* Longest buy command has 11 chars so if command is longer then don't care */ { return PLUGIN_CONTINUE } @@ -638,7 +638,7 @@ public client_command(id) { new key[12], num - read_argv(1, key, 11) + read_argv(1, key, charsmax(key)) num = str_to_num(key) - 1 return checkRest(id, g_InBuyMenu[id], num) @@ -732,7 +732,7 @@ saveSettings(filename[]) { if (positionBlocked(a)) { - format(text, 63, "%-16.15s ; %s", g_Aliases[a], g_WeaponNames[a]) + format(text, charsmax(text), "%-16.15s ; %s", g_Aliases[a], g_WeaponNames[a]) write_file(filename, text) } } @@ -748,15 +748,15 @@ loadSettings(filename[]) new text[16] new a, pos = 0 - format(g_szEquipAmmoRestr, 9, "000000000") - format(g_szWeapRestr, 26, "00000000000000000000000000") + format(g_szEquipAmmoRestr, charsmax(g_szEquipAmmoRestr), "000000000") + format(g_szWeapRestr, charsmax(g_szWeapRestr), "00000000000000000000000000") - while (read_file(filename, pos++, text, 15, a)) + while (read_file(filename, pos++, text, charsmax(test), a)) { if (text[0] == ';' || !a) continue // line is a comment - parse(text, text, 15) + parse(text, text, charsmax(text)) if ((a = findAliasId(text)) != -1) { @@ -785,7 +785,7 @@ public fn_setautobuy(id) for (new i = 1; i < argCount; i++) // Start at parameter 1; parameter 0 is just "cl_setautobuy" { - read_argv(i, arg, 127) + read_argv(i, arg, charsmax(arg)) // Add this parameter to user's autobuy prefs autobuyLen += format(g_Autobuy[id][autobuyLen], AUTOBUYLENGTH - autobuyLen, "%s", arg) @@ -857,7 +857,7 @@ public HookEvent_ShowMenu(id) { new menustring[24] - read_data(4, menustring, 23) + read_data(4, menustring, charsmax(menustring)) /* Early breakouts */ new curidx @@ -950,13 +950,13 @@ public plugin_init() register_event("ShowMenu", "HookEvent_ShowMenu", "b") new configsDir[64]; - get_configsdir(configsDir, 63); + get_configsdir(configsDir, charsmax(configsDir)); #if defined MAPSETTINGS new mapname[32] - get_mapname(mapname, 31) - format(g_saveFile, 63, "%s/weaprest_%s.ini", configsDir, mapname) + get_mapname(mapname, charsmax(mapname)) + format(g_saveFile, charsmax(g_saveFile), "%s/weaprest_%s.ini", configsDir, mapname) #else - format(g_saveFile, 63, "%s/weaprest.ini", configsDir) + format(g_saveFile, charsmax(g_saveFile), "%s/weaprest.ini", configsDir) #endif loadSettings(g_saveFile) } From 0237153dddeab5e8c75284eb82d9e20d835e5162 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Wed, 8 Oct 2014 14:32:03 +0200 Subject: [PATCH 02/30] Stats_logging: Replace len hardcoded contents by charsmax --- plugins/cstrike/stats_logging.sma | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/cstrike/stats_logging.sma b/plugins/cstrike/stats_logging.sma index ddfcf8f2..ff9cdaab 100755 --- a/plugins/cstrike/stats_logging.sma +++ b/plugins/cstrike/stats_logging.sma @@ -41,15 +41,15 @@ public client_disconnect(id) new iUserid = get_user_userid(id) new _max = xmod_get_maxweapons() - get_user_team(id, szTeam, 15) - get_user_name(id, szName, 31) - get_user_authid(id, szAuthid, 31) + get_user_team(id, szTeam, charsmax(szTeam)) + get_user_name(id, szName, charsmax(szName)) + get_user_authid(id, szAuthid, charsmax(szAuthid)) for (new i = 1 ; i < _max ; ++i) { if (get_user_wstats(id, i, iStats, iHits)) { - xmod_get_wpnname(i, szWeapon, 23) + xmod_get_wpnname(i, szWeapon, charsmax(szWeapon)) log_message("^"%s<%d><%s><%s>^" triggered ^"weaponstats^" (weapon ^"%s^") (shots ^"%d^") (hits ^"%d^") (kills ^"%d^") (headshots ^"%d^") (tks ^"%d^") (damage ^"%d^") (deaths ^"%d^")", szName, iUserid, szAuthid, szTeam, szWeapon, iStats[4], iStats[5], iStats[0], iStats[2], iStats[3], iStats[6], iStats[1]) From 91dfec4ef72ffc31330cb42218f806da97b9d130 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Wed, 8 Oct 2014 15:03:51 +0200 Subject: [PATCH 03/30] Statsx: Replace len hardcoded contents by charsmax --- plugins/cstrike/statsx.sma | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/cstrike/statsx.sma b/plugins/cstrike/statsx.sma index 6bc985bf..d3603a6d 100755 --- a/plugins/cstrike/statsx.sma +++ b/plugins/cstrike/statsx.sma @@ -1584,7 +1584,7 @@ endround_stats() public eventTeamScore() { new sTeamID[1 + 1], iTeamScore - read_data(1, sTeamID, 1) + read_data(1, sTeamID, charsmax(sTeamID)) iTeamScore = read_data(2) g_izTeamEventScore[(sTeamID[0] == 'C') ? 1 : 0] = iTeamScore @@ -1637,7 +1637,7 @@ public end_game_stats() public eventSpecMode(id) { new sData[12] - read_data(2, sData, 11) + read_data(2, sData, charsmax(sData)) g_izSpecMode[id] = (sData[10] == '2') return PLUGIN_CONTINUE From 0a4cd13622093f17f09cd1084898032af830a215 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Wed, 8 Oct 2014 21:49:00 +0200 Subject: [PATCH 04/30] Plmenu: replace len hardcoded content by charsmax --- plugins/dod/plmenu.sma | 160 ++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/plugins/dod/plmenu.sma b/plugins/dod/plmenu.sma index 1bd3f420..0ac8cca5 100755 --- a/plugins/dod/plmenu.sma +++ b/plugins/dod/plmenu.sma @@ -59,8 +59,8 @@ public plugin_init() g_coloredMenus = colored_menus() 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) } @@ -117,10 +117,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) log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")", name, get_user_userid(id), authid, name2, userid2, authid2, g_menuSettings[id]) @@ -136,7 +136,7 @@ public actionBanMenu(id, key) else { new tempTime[32]; - formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]); + formatex(tempTime,charsmax(tempTime),"%d",g_menuSettings[id]); client_print(0, print_chat, "%L %s: %L %s %L", LANG_PLAYER, "ADMIN", name, LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime); } } @@ -149,7 +149,7 @@ public actionBanMenu(id, key) else { new tempTime[32]; - formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]); + formatex(tempTime,charsmax(tempTime),"%d",g_menuSettings[id]); client_print(0, print_chat, "%L: %L %s %L", LANG_PLAYER, "ADMIN", LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime); } } @@ -158,7 +158,7 @@ public actionBanMenu(id, key) if (equal("4294967295", authid2)) { new ipa[32] - get_user_ip(player, ipa, 31, 1) + get_user_ip(player, ipa, charsmax(ipa), 1) server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa) if( g_tempBans ) { @@ -199,7 +199,7 @@ displayBanMenu(id,pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody,511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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 @@ -210,38 +210,38 @@ 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 if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s^n\w", b, name) else - len += format(menuBody[len], 511-len, "#. %s^n", name) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s^n", name) } else { keys |= (1<<%s><>^" slap with %d damage ^"%s<%d><%s><>^"", @@ -337,7 +337,7 @@ displaySlapMenu(id,pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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 @@ -347,38 +347,38 @@ displaySlapMenu(id,pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i,name,31) - get_user_team(i,team,7) + get_user_name(i,name,charsmax(name)) + get_user_team(i,team,charsmax(team)) if (!is_user_alive(i) || access(i, ADMIN_IMMUNITY)) { ++b if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s\R%s^n\w", b, name, team) else - 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<<%s><>^" kick ^"%s<%d><%s><>^"", @@ -446,7 +446,7 @@ displayKickMenu(id, pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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 @@ -457,33 +457,33 @@ 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 if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s^n\w", b, name) else - 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_menuOption[id] ? "Allies" : "Axis" ) @@ -547,7 +547,7 @@ displayTeamMenu(id, pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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 @@ -558,36 +558,36 @@ displayTeamMenu(id, pos) for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] - get_user_name(i, name, 31) - iteam = get_user_team(i, team, 7) + get_user_name(i, name, charsmax(name)) + iteam = get_user_team(i, team, charsmax(team)) if ((iteam == (g_menuOption[id] ? 1 : 2)) || access(i, ADMIN_IMMUNITY)) { ++b if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s\R%s^n\w", b, name, team) else - 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, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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 @@ -669,38 +669,38 @@ 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 if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s^n\w", b, name) else - 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 } From 2cc771371a94a5e5e70a34230b6f0b3c19a13fad Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Wed, 8 Oct 2014 22:52:57 +0200 Subject: [PATCH 05/30] Stats: Replace len hardcoded contents by charsmax Note: TOPX is over 8 char len in some languages. --- plugins/dod/stats.sma | 138 +++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/plugins/dod/stats.sma b/plugins/dod/stats.sma index 59421fd6..3400f2a5 100755 --- a/plugins/dod/stats.sma +++ b/plugins/dod/stats.sma @@ -269,9 +269,9 @@ public endGameStats(){ new players[32], inum get_players(players,inum) - new g_Top[8], top = get_cvar_num("dodstats_topvalue") + new g_Top[16], top = get_cvar_num("dodstats_topvalue") for(i = 0; i < inum; ++i){ - format(g_Top,15,"%L",i,"TOPX",top) + format(g_Top,charsmax(g_Top),"%L",i,"TOPX",top) getTop15_steam(i) show_motd(players[i],g_Buffer,g_Top) } @@ -295,18 +295,18 @@ public cmdStats(id){ /* build list of attackers */ getAttackers(id) { new name[MAX_NAME_LENGTH],wpn[32], stats[9],body[8],found=0 - new pos = format(g_Buffer,2047,"%L^n",id,"ATTACKERS") + new pos = format(g_Buffer,charsmax(g_Buffer),"%L^n",id,"ATTACKERS") for(new a = 1; a <= MaxClients; ++a){ - if(get_user_astats(id,a,stats,body,wpn,31)) + if(get_user_astats(id,a,stats,body,wpn,charsmax(wpn))) { found = 1 if (stats[0]) - format(wpn,31," -- %s",wpn) + format(wpn,charsmax(wpn)," -- %s",wpn) else wpn[0] = 0 - get_user_name(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"%s -- %d %L / %d %L%s^n",name,stats[6],id,"DMG",stats[5],id,"HIT_S",wpn) + get_user_name(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s -- %d %L / %d %L%s^n",name,stats[6],id,"DMG",stats[5],id,"HIT_S",wpn) } } return found @@ -316,17 +316,17 @@ getAttackers(id) { /* build list of victims */ getVictims(id) { new name[MAX_NAME_LENGTH],wpn[32], stats[9],body[8],found=0 - new pos = format(g_Buffer,2047,"%L^n",id,"VICTIMS") + new pos = format(g_Buffer,charsmax(g_Buffer),"%L^n",id,"VICTIMS") for(new a = 1; a <= MaxClients; ++a){ - if(get_user_vstats(id,a,stats,body,wpn,31)) + if(get_user_vstats(id,a,stats,body,wpn,charsmax(wpn))) { found = 1 if (stats[1]) - format(wpn,31," -- %s",wpn) + format(wpn,charsmax(wpn)," -- %s",wpn) else wpn[0] = 0 - get_user_name(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"%s -- %d %L / %d %L%s^n",name,stats[6],id,"DMG",stats[5],id,"HITS",wpn) + get_user_name(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s -- %d %L / %d %L%s^n",name,stats[6],id,"DMG",stats[5],id,"HITS",wpn) } } return found @@ -339,19 +339,19 @@ getHits(id,killer) { get_user_astats(id,killer,stats,body) for(new a = 1; a < 8; ++a) if(body[a]) - pos += format(g_Buffer[pos],2047-pos,"%L: %d^n",id,g_bodyParts[a],body[a]) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%L: %d^n",id,g_bodyParts[a],body[a]) } /* build list of hits for say hp */ getMyHits(id,killed) { new name[MAX_NAME_LENGTH], stats[9], body[8], found = 0 - get_user_name(killed,name,31) - new pos = format(g_Buffer,2047,"%L",id,"YOU_HIT",name) + get_user_name(killed,name,charsmax(name)) + new pos = format(g_Buffer,charsmax(g_Buffer),"%L",id,"YOU_HIT",name) get_user_vstats(id,killed,stats,body) for(new a = 1; a < 8; ++a){ if(body[a]){ found = 1 - pos += format(g_Buffer[pos],2047-pos," %L: %d ",id,g_bodyParts[a],body[a]) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos," %L: %d ",id,g_bodyParts[a],body[a]) } } return found @@ -367,9 +367,9 @@ public cmdKiller(id) { return PLUGIN_HANDLED } if (g_Killers[id][0]) { - new name[MAX_NAME_LENGTH], stats[9], body[8], wpn[33], mstats[9], mbody[8] - get_user_name(g_Killers[id][0],name,31) - get_user_astats(id,g_Killers[id][0],stats,body,wpn,31) + new name[MAX_NAME_LENGTH], stats[9], body[8], wpn[32], mstats[9], mbody[8] + get_user_name(g_Killers[id][0],name,charsmax(name)) + get_user_astats(id,g_Killers[id][0],stats,body,wpn,charsmax(wpn)) get_user_vstats(id,g_Killers[id][0],mstats,mbody) client_print(id,print_chat,"%L",id,"KILL_INFO1", name,wpn,float(g_Killers[id][2]) * 0.0254 ) client_print(id,print_chat,"%L",id,"KILL_INFO2", stats[6],stats[5], g_Killers[id][1] ) @@ -415,22 +415,22 @@ showStatsMenu(id,pos){ get_players(g_userPlayers[id],inum) if (start >= inum) start = pos = g_userPosition[id] = 0 - new len = format(menu_body,511,"\y%L\R%d/%d^n\w^n",id,"SERVER_STATS",pos + 1,((inum/max_menupos)+((inum%max_menupos)?1:0))) + new len = format(menu_body,charsmax(menu_body),"\y%L\R%d/%d^n\w^n",id,"SERVER_STATS",pos + 1,((inum/max_menupos)+((inum%max_menupos)?1:0))) new name[MAX_NAME_LENGTH], end = start + max_menupos, keys = (1<<9)|(1<<7) if (end > inum) end = inum for(new a = start; a < end; ++a){ - get_user_name(g_userPlayers[id][a],name,31) + get_user_name(g_userPlayers[id][a],name,charsmax(name)) keys |= (1< get_gametime() ) continue - format( message, sizeof(message)-1, "%L",players[i],g_HeadShots[ random_num(0,6) ] ) - replace( message, sizeof(message)-1, "$vn", victim_name ) - replace( message, sizeof(message)-1, "$wn", weapon ) - replace( message, sizeof(message)-1, "$kn", killer_name ) + format( message, charsmax(message), "%L",players[i],g_HeadShots[ random_num(0,6) ] ) + replace( message, charsmax(message), "$vn", victim_name ) + replace( message, charsmax(message), "$wn", weapon ) + replace( message, charsmax(message), "$kn", killer_name ) set_hudmessage(100, 100, 255, -1.0, 0.19, 0, 6.0, 6.0, 0.5, 0.15, -1) ShowSyncHudMsg(players[i], g_center2_sync, "%s", message) } @@ -770,10 +770,10 @@ public showDoubleKill(){ if ( pos > 2 ) pos = 2 if ( DoubleKill ) { new name[MAX_NAME_LENGTH] - get_user_name(g_prevKillerId,name,31) + get_user_name(g_prevKillerId,name,charsmax(name)) if ( pos == 2 ){ new kills[3] - num_to_str(g_KillCount,kills,2) + num_to_str(g_KillCount,kills,charsmax(kills)) } set_hudmessage(65, 102, 158, -1.0, 0.25, 0, 6.0, 6.0, 0.5, 0.15, -1) for (new i=1;i<=MaxClients;i++){ @@ -795,7 +795,7 @@ public checkKills(param[]){ if ( a > -1 ){ if ( MultiKill ) { new name[MAX_NAME_LENGTH] - get_user_name(id,name,31) + get_user_name(id,name,charsmax(name)) set_hudmessage(255, 0, 100, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, -1) if ( a > 6 ) a = 6 for (new i=1;i<=MaxClients;i++){ @@ -922,28 +922,28 @@ displayStats_steam(id,dest) { new name[MAX_NAME_LENGTH], stats[9], body[8] get_user_wstats(id,0,stats,body) - new pos = copy(g_Buffer,2047,"
")
- pos += format(g_Buffer[pos],2047-pos,"",
+ new pos = copy(g_Buffer,charsmax(g_Buffer),"
")
+ pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"
%L%L%L%L%L%L%L
", dest,"M_KILLS",dest,"M_DEATHS",dest,"M_SCORE",dest,"M_TKS",dest,"M_HITS",dest,"M_SHOTS",dest,"M_HS") - pos += format(g_Buffer[pos],2047-pos,"
%L%L%L%L%L%L%L
%d%d%d%d%d%d%d



", + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%d%d%d%d%d%d%d


", stats[0],stats[1],stats[7],stats[3],stats[5],stats[4],stats[2]) - pos += format(g_Buffer[pos],2047-pos,"", + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"
%L%L%L%L%L%L
", dest,"M_WEAPON",dest,"M_SHOTS",dest,"M_HITS",dest,"M_DAMAGE",dest,"M_KILLS",dest,"M_DEATHS") for(new a = 1; a < DODMAX_WEAPONS; ++a) { if (get_user_wstats(id,a,stats,body)){ if ( xmod_is_melee_wpn(a) ) stats[4] = -1; - xmod_get_wpnname(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"^n", + xmod_get_wpnname(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"^n", name,stats[4],stats[5],stats[6],stats[0],stats[1]) } } - copy(g_Buffer[pos],2047-pos,"
%L%L%L%L%L%L
%s%d%d%d%d%d
%s%d%d%d%d%d
") + copy(g_Buffer[pos],charsmax(g_Buffer)-pos,"") - get_user_name(id,name,31) + get_user_name(id,name,charsmax(name)) show_motd(dest,g_Buffer,name) } @@ -961,23 +961,23 @@ displayRank_steam(id,dest) { new name[MAX_NAME_LENGTH], stats[9], body[8] new rank_pos = get_user_stats(id,stats,body) - new pos = copy(g_Buffer,2047,"
")
+ new pos = copy(g_Buffer,charsmax(g_Buffer),"
")
 
- pos += format(g_Buffer[pos],2047-pos,
+ pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,
                "",dest,"M_KILLS",dest,"M_DEATHS",dest,"M_SCORE",dest,"M_TKS",dest,"M_HITS",dest,"M_SHOTS",dest,"M_HS")
 
- pos += format(g_Buffer[pos],2047-pos,
+ pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,
                "
%L%L%L%L%L%L%L
%d%d%d%d%d%d%d


", stats[0],stats[1],stats[7],stats[3],stats[5],stats[4],stats[2]) - pos += format(g_Buffer[pos],2047-pos,"%L^n%L: %d^n%L: %d^n%L: %d^n%L: %d^n%L: %d^n%L: %d^n%L: %d^n",dest,"M_HITS",dest,g_bodyParts[1],body[1],dest,g_bodyParts[2],body[2],dest,g_bodyParts[3],body[3],dest,g_bodyParts[4],body[4],dest,g_bodyParts[5],body[5],dest,g_bodyParts[6],body[6],dest,g_bodyParts[7],body[7]) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%L^n%L: %d^n%L: %d^n%L: %d^n%L: %d^n%L: %d^n%L: %d^n%L: %d^n",dest,"M_HITS",dest,g_bodyParts[1],body[1],dest,g_bodyParts[2],body[2],dest,g_bodyParts[3],body[3],dest,g_bodyParts[4],body[4],dest,g_bodyParts[5],body[5],dest,g_bodyParts[6],body[6],dest,g_bodyParts[7],body[7]) - pos += format(g_Buffer[pos],2047-pos,"%L %d %L %d",dest,(id==dest)?"M_YOUR_RANK_IS":"M_THEIR_RANK_IS", + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%L %d %L %d",dest,(id==dest)?"M_YOUR_RANK_IS":"M_THEIR_RANK_IS", rank_pos,dest,"M_OF",get_statsnum()) - pos += format(g_Buffer[pos],2047-pos,"
") + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"
") - get_user_name(id,name,31) + get_user_name(id,name,charsmax(name)) show_motd(dest,g_Buffer,name) } @@ -988,8 +988,8 @@ public cmdTop15(id) { return PLUGIN_HANDLED } getTop15_steam(id) - new g_Top[8] - format(g_Top,7,"%L",id,"TOPX",get_cvar_num("dodstats_topvalue")) + new g_Top[16] + format(g_Top,charmax(g_Top),"%L",id,"TOPX",get_cvar_num("dodstats_topvalue")) show_motd(id,g_Buffer,g_Top) return PLUGIN_CONTINUE @@ -999,21 +999,21 @@ public cmdTop15(id) { getTop15_steam(id){ new stats[9], body[8], name[MAX_NAME_LENGTH] - new pos = copy(g_Buffer,2047,"
")
+  new pos = copy(g_Buffer,charsmax(g_Buffer),"
")
 
-  pos += format(g_Buffer[pos],2047-pos,"",
+  pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"
#%L%L%L%L%L%L%L%L
", id,"M_NICK",id,"M_KILLS",id,"M_DEATHS",id,"M_SCORE",id,"M_TKS",id,"M_HITS",id,"M_SHOTS",id,"M_HS") new imax = get_statsnum() new itmax = get_cvar_num("dodstats_topvalue") if (imax > itmax ) imax = itmax for(new a = 0; a < imax; ++a){ - get_stats(a,stats,body,name,31); - replace_all(name, 31, "<", "[") - replace_all(name, 31, ">", "]") - pos += format(g_Buffer[pos],2047-pos,"^n", + get_stats(a,stats,body,name,charsmax(name)); + replace_all(name, charsmax(name), "<", "[") + replace_all(name, charsmax(name), ">", "]") + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"^n", a+1,name,stats[0],stats[1],stats[7],stats[3],stats[5],stats[4],stats[2]) } - pos += format(g_Buffer[pos],2047-pos,"
#%L%L%L%L%L%L%L%L
%d.%s%d%d%d%d%d%d%d
%d.%s%d%d%d%d%d%d%d
") + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"
") } From 9a9dd7a4ad33eec101711b708027f7590885fbe4 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Wed, 8 Oct 2014 23:24:48 +0200 Subject: [PATCH 06/30] Stats_logging: replace len hardcoded content by charsmax --- plugins/dod/stats_logging.sma | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/dod/stats_logging.sma b/plugins/dod/stats_logging.sma index c99fd489..845fd511 100755 --- a/plugins/dod/stats_logging.sma +++ b/plugins/dod/stats_logging.sma @@ -26,13 +26,13 @@ public client_disconnect(id) { remove_task( id ) new szTeam[16],szName[MAX_NAME_LENGTH],szAuthid[32], iStats[9], iHits[8], szWeapon[16] new iUserid = get_user_userid( id ) - get_user_info(id,"team", szTeam, 15 ) + get_user_info(id,"team", szTeam, charsmax(szTeam) ) szTeam[0] -= 32; - get_user_name(id, szName ,31 ) - get_user_authid(id, szAuthid , 31 ) + get_user_name(id, szName ,charsmax(szName) ) + get_user_authid(id, szAuthid , charsmax(szAuthid) ) for(new i = 1 ; i < DODMAX_WEAPONS; ++i ) { if( get_user_wstats( id , i ,iStats , iHits ) ) { - xmod_get_wpnlogname( i , szWeapon , 15 ) + xmod_get_wpnlogname( i , szWeapon , charsmax(szWeapon) ) log_message("^"%s<%d><%s><%s>^" triggered ^"weaponstats^" (weapon ^"%s^") (shots ^"%d^") (hits ^"%d^") (kills ^"%d^") (headshots ^"%d^") (tks ^"%d^") (damage ^"%d^") (deaths ^"%d^") (score ^"%d^")", szName,iUserid,szAuthid,szTeam,szWeapon,iStats[4],iStats[5],iStats[0], iStats[2],iStats[3],iStats[6],iStats[1],iStats[7]) log_message("^"%s<%d><%s><%s>^" triggered ^"weaponstats2^" (weapon ^"%s^") (head ^"%d^") (chest ^"%d^") (stomach ^"%d^") (leftarm ^"%d^") (rightarm ^"%d^") (leftleg ^"%d^") (rightleg ^"%d^")", From 7ba6f728255a0130202a0df7888220eaf6c767f0 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Wed, 8 Oct 2014 23:31:00 +0200 Subject: [PATCH 07/30] Idlekicker: replace len hardcoded content by charsmax --- plugins/ns/idlekicker.sma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ns/idlekicker.sma b/plugins/ns/idlekicker.sma index ba67efb4..2e6479a5 100755 --- a/plugins/ns/idlekicker.sma +++ b/plugins/ns/idlekicker.sma @@ -92,7 +92,7 @@ check_idletime(id) { client_print(id, print_chat, "[AMXX] You have %d seconds to move or you will be kicked for being idle", timeleft) } else if (g_idletime[id] > maxidletime) { new name[MAX_NAME_LENGTH] - get_user_name(id, name, 31) + get_user_name(id, name, charsmax(name)) client_print(0, print_chat, "[AMXX] %s was kicked for being idle longer than %d seconds", name, maxidletime) log_amx("%s was kicked for being idle longer than %d seconds", name, maxidletime) server_cmd("kick #%d ^"You were kicked for being idle longer than %d seconds^"", get_user_userid(id), maxidletime) From d7911d8f3f09e2829676248c59de840ca9933419 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Wed, 8 Oct 2014 23:47:51 +0200 Subject: [PATCH 08/30] Mapchooser: replace len hardcoded content by charsmax --- plugins/ns/mapchooser.sma | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/plugins/ns/mapchooser.sma b/plugins/ns/mapchooser.sma index ae0e4767..7fc95db6 100755 --- a/plugins/ns/mapchooser.sma +++ b/plugins/ns/mapchooser.sma @@ -34,12 +34,12 @@ public plugin_init() register_cvar("amx_extendmap_max","90") register_cvar("amx_extendmap_step","15") - get_localinfo("lastMap",g_lastMap,31) + get_localinfo("lastMap",g_lastMap,charsmax(g_lastMap)) set_localinfo("lastMap","") new maps_ini_file[64]; - get_configsdir(maps_ini_file, 63); - format(maps_ini_file, 63, "%s/maps.ini", maps_ini_file); + get_configsdir(maps_ini_file, charsmax(maps_ini_file)); + format(maps_ini_file, charsmax(maps_ini_file), "%s/maps.ini", maps_ini_file); if ( loadSettings(maps_ini_file) ) set_task(15.0,"voteNextmap",987456,"",0,"b") } @@ -51,7 +51,7 @@ public checkVotes(){ b = a if ( g_voteCount[SELECTMAPS] > g_voteCount[b] ) { new mapname[32] - get_mapname(mapname,31) + get_mapname(mapname,charsmax(mapname)) new Float:steptime = get_cvar_float("amx_extendmap_step") set_cvar_float("mp_timelimit", get_cvar_float("mp_timelimit") + steptime ) client_print(0,print_chat,"Choosing finished. Current map will be extended to next %.0f minutes", steptime ) @@ -62,7 +62,7 @@ public checkVotes(){ if ( g_voteCount[b] && g_voteCount[SELECTMAPS+1] <= g_voteCount[b] ) set_cvar_string("amx_nextmap", g_mapName[g_nextName[b]] ) new smap[32] - get_cvar_string("amx_nextmap",smap,31) + get_cvar_string("amx_nextmap",smap,charsmax(smap)) client_print(0,print_chat,"Choosing finished. The nextmap will be %s", smap ) log_amx("Vote: Voting for the nextmap finished. The nextmap will be %s", smap) } @@ -70,7 +70,7 @@ public checkVotes(){ public countVote(id,key){ if ( get_cvar_float("amx_vote_answers") ) { new name[32] - get_user_name(id,name,31) + get_user_name(id,name,charsmax(name)) if ( key == SELECTMAPS ) client_print(0,print_chat,"%s chose map extending", name ) else if ( key < SELECTMAPS ) @@ -98,7 +98,7 @@ public voteNextmap(){ return g_selected = true new menu[512], a, mkeys = (1< SELECTMAPS) ? SELECTMAPS : g_mapNums for(g_mapVoteNum = 0;g_mapVoteNum Date: Sat, 11 Oct 2014 14:02:15 +0200 Subject: [PATCH 09/30] Miscstats: replace len hardcoded content by sizeof --- plugins/cstrike/miscstats.sma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/cstrike/miscstats.sma b/plugins/cstrike/miscstats.sma index 8fafd3a6..d64a1332 100755 --- a/plugins/cstrike/miscstats.sma +++ b/plugins/cstrike/miscstats.sma @@ -539,7 +539,7 @@ public client_death(killer, victim, wpnindex, hitplace, TK) param[0] = killer param[1] = g_multiKills[killer][0] - set_task(4.0 + float(param[1]), "checkKills", killer, param, 2) + set_task(4.0 + float(param[1]), "checkKills", killer, param, sizeof(param)) } } From 54ab06493a25eb3a04b017e35996ccb5d9f74f57 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 14:07:38 +0200 Subject: [PATCH 10/30] Restmenu: fix a typo error induced by previous commit --- plugins/cstrike/restmenu.sma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/cstrike/restmenu.sma b/plugins/cstrike/restmenu.sma index 615b2e4a..3942fb8c 100755 --- a/plugins/cstrike/restmenu.sma +++ b/plugins/cstrike/restmenu.sma @@ -751,7 +751,7 @@ loadSettings(filename[]) format(g_szEquipAmmoRestr, charsmax(g_szEquipAmmoRestr), "000000000") format(g_szWeapRestr, charsmax(g_szWeapRestr), "00000000000000000000000000") - while (read_file(filename, pos++, text, charsmax(test), a)) + while (read_file(filename, pos++, text, charsmax(text), a)) { if (text[0] == ';' || !a) continue // line is a comment From ee6285c79d7a9b8be7472e0b824e0f23a20940be Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 14:10:36 +0200 Subject: [PATCH 11/30] Statsx: Replace len hardcoded contents by sizeof --- plugins/cstrike/statsx.sma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/cstrike/statsx.sma b/plugins/cstrike/statsx.sma index d3603a6d..62c66a0e 100755 --- a/plugins/cstrike/statsx.sma +++ b/plugins/cstrike/statsx.sma @@ -1347,7 +1347,7 @@ public eventSpawn(id) args[0] = id if (g_iPluginMode & MODE_HUD_DELAY) - set_task(0.1, "delay_spawn", 200 + id, args, 1) + set_task(0.1, "delay_spawn", 200 + id, args, sizeof(args)) else delay_spawn(args) From 8b9c107a038a0d333cc68939c5ef8faf38e4666e Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 14:31:56 +0200 Subject: [PATCH 12/30] Stats: Replace len hardcoded contents by sizeof + fix typo error in previous commit --- plugins/dod/stats.sma | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dod/stats.sma b/plugins/dod/stats.sma index 3400f2a5..bfa29608 100755 --- a/plugins/dod/stats.sma +++ b/plugins/dod/stats.sma @@ -678,7 +678,7 @@ public client_death(killer,victim,wpnindex,hitplace,TK) new param[2] param[0] = killer param[1] = g_multiKills[killer][0] - set_task( 4.0 + float( param[1] ) ,"checkKills",0,param,2) + set_task( 4.0 + float( param[1] ) ,"checkKills",0,param,sizeof(param)) } if ( xmod_is_melee_wpn(wpnindex) && ( KnifeKill || KnifeKillSound ) ){ @@ -989,7 +989,7 @@ public cmdTop15(id) { } getTop15_steam(id) new g_Top[16] - format(g_Top,charmax(g_Top),"%L",id,"TOPX",get_cvar_num("dodstats_topvalue")) + format(g_Top,charsmax(g_Top),"%L",id,"TOPX",get_cvar_num("dodstats_topvalue")) show_motd(id,g_Buffer,g_Top) return PLUGIN_CONTINUE From 8071b895d24aaff1b4747037600b90f2637e29b8 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 14:39:34 +0200 Subject: [PATCH 13/30] Idlekicker: replace len hardcoded content by sizeof --- plugins/ns/idlekicker.sma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ns/idlekicker.sma b/plugins/ns/idlekicker.sma index 2e6479a5..1cc9c3cd 100755 --- a/plugins/ns/idlekicker.sma +++ b/plugins/ns/idlekicker.sma @@ -114,7 +114,7 @@ public playerSpawned(id) { g_spawned[id] = false new sid[1] sid[0] = id - set_task(0.75, "delayedSpawn",_, sid, 1) // Give the player time to drop to the floor when spawning + set_task(0.75, "delayedSpawn",_, sid, sizeof(sid)) // Give the player time to drop to the floor when spawning return PLUGIN_HANDLED } From cff3ab867a3f61159cd8d985c1ba00d6da7e0981 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 16:00:11 +0200 Subject: [PATCH 14/30] Nextmap: replace len hardcoded content by charsmax and sizeof --- plugins/ns/nextmap.sma | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/plugins/ns/nextmap.sma b/plugins/ns/nextmap.sma index 4bbb810b..854f0987 100755 --- a/plugins/ns/nextmap.sma +++ b/plugins/ns/nextmap.sma @@ -74,11 +74,11 @@ public server_changelevel() { // Check if the cvar "amx_nextmap" has changed since the map loaded as it overrides the min/max settings. new szCvarNextMap[32] - get_cvar_string("amx_nextmap", szCvarNextMap, 31) + get_cvar_string("amx_nextmap", szCvarNextMap, charsmax(szCvarNextMap)) if ( !equal(szCvarNextMap, g_mapCycle[g_nextPos][NAME]) ) { if (ValidMap(szCvarNextMap)) { if (g_changeMapDelay) - set_task(INFO_READ_TIME, "changeMap", 0, szCvarNextMap, 32) + set_task(INFO_READ_TIME, "changeMap", 0, szCvarNextMap, sizeof(szCvarNextMap)) else changeMap(szCvarNextMap) return BLOCK_ONCE @@ -89,7 +89,7 @@ public server_changelevel() { getNextValidMap(szNextMap) if (ValidMap(szNextMap)) { if (g_changeMapDelay) - set_task(INFO_READ_TIME, "changeMap", 0, szNextMap, 32) + set_task(INFO_READ_TIME, "changeMap", 0, szNextMap, sizeof(szNextMap)) else changeMap(szNextMap) } else @@ -134,7 +134,7 @@ public getNextValidMap(szNextMap[]) { (g_mapCycle[startPos][MIN] <= g_numPlayers) ? "many" : "few", g_mapCycle[startPos][NAME], g_mapCycle[g_nextPos][NAME]) new szPos[8] - num_to_str(g_nextPos, szPos, 7) + num_to_str(g_nextPos, szPos, charsmax(szPos)) set_localinfo("amx_nextmap_pos", szPos) set_cvar_string("amx_nextmap", g_mapCycle[g_nextPos][NAME]) g_changeMapDelay = true @@ -143,7 +143,7 @@ public getNextValidMap(szNextMap[]) { public voteMap() { new szVoteMap[128] - read_data(2, szVoteMap, 127) // "YO | Cheesy Peteza executed votemap 2 (co_angst 1/5)" + read_data(2, szVoteMap, charsmax(szVoteMap)) // "YO | Cheesy Peteza executed votemap 2 (co_angst 1/5)" new start, end, szData[64] for (new i; i Date: Sat, 11 Oct 2014 16:20:49 +0200 Subject: [PATCH 15/30] Nscommands: replace len hardcoded content by charsmax --- plugins/ns/nscommands.sma | 66 +++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/plugins/ns/nscommands.sma b/plugins/ns/nscommands.sma index 15c39f00..e08b2fd7 100755 --- a/plugins/ns/nscommands.sma +++ b/plugins/ns/nscommands.sma @@ -60,11 +60,11 @@ new g_ScoreInfo_Team; public plugin_init() { register_plugin("NS Commands",AMXX_VERSION_STR,"AMXX Dev Team"); // create our semi-random acknowledgement commands - format(g_TeamOneAck,11,"namx_a%c%c%c%c%c",random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z')); - format(g_TeamTwoAck,11,"namx_b%c%c%c%c%c",random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z')); - format(g_ReadyRoomAck,11,"namx_c%c%c%c%c%c",random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z')); - format(g_AutoAssignAck,11,"namx_d%c%c%c%c%c",random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z')); - format(g_StopCommAck,11,"namx_e%c%c%c%c%c",random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z')); + format(g_TeamOneAck,charsmax(g_TeamOneAck),"namx_a%c%c%c%c%c",random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z')); + format(g_TeamTwoAck,charsmax(g_TeamTwoAck),"namx_b%c%c%c%c%c",random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z')); + format(g_ReadyRoomAck,charsmax(g_ReadyRoomAck),"namx_c%c%c%c%c%c",random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z')); + format(g_AutoAssignAck,charsmax(g_AutoAssignAck),"namx_d%c%c%c%c%c",random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z')); + format(g_StopCommAck,charsmax(g_StopCommAck),"namx_e%c%c%c%c%c",random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z'),random_num('a','z')); // register them.. register_clcmd(g_TeamOneAck,"ack_team_one"); @@ -144,15 +144,15 @@ public cmdRandom(id,level,cid) { return PLUGIN_HANDLED if (read_argc()>1) { // person is specified.. new arg[32] - read_argv(1,arg,31) + read_argv(1,arg,charsmax(arg)) new player = cmd_target(id,arg,CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF) if (!player) return PLUGIN_HANDLED new name[MAX_NAME_LENGTH],name_targ[MAX_NAME_LENGTH]; new auth[32],auth_targ[32]; - get_user_name(id,name,31); - get_user_name(player,name_targ,31); - get_user_authid(id,auth,31); - get_user_authid(player,auth_targ,31); + get_user_name(id,name,charsmax(name)); + get_user_name(player,name_targ,charsmax(name_targ)); + get_user_authid(id,auth,charsmax(auth)); + get_user_authid(player,auth_targ,charsmax(auth_targ)); log_amx("Cmd: ^"%s<%d><%s><>^" random ^"%s<%d><%s><>^"",name,get_user_userid(id),auth, name_targ,get_user_userid(player),auth_targ); show_activity(id, name, "random %s", name_targ); @@ -174,8 +174,8 @@ public cmdRandom(id,level,cid) { } if (cur) { new name[MAX_NAME_LENGTH],auth[32]; - get_user_name(id,name,31); - get_user_authid(id,auth,31); + get_user_name(id,name,charsmax(name)); + get_user_authid(id,auth,charsmax(auth)); log_amx("Cmd: ^"%s<%d><%s><>^" random all",name,get_user_userid(id),auth); show_activity(id, name, "random all"); @@ -210,15 +210,15 @@ public cmdReadyRoom(id,level,cid) { return PLUGIN_HANDLED if (read_argc()>1) { // person is specified.. new arg[32] - read_argv(1,arg,31) + read_argv(1,arg,charsmax(arg)) new player = cmd_target(id,arg,CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF) if (!player) return PLUGIN_HANDLED new name[MAX_NAME_LENGTH],name_targ[MAX_NAME_LENGTH]; new auth[32],auth_targ[32]; - get_user_name(id,name,31); - get_user_name(player,name_targ,31); - get_user_authid(id,auth,31); - get_user_authid(player,auth_targ,31); + get_user_name(id,name,charsmax(name)); + get_user_name(player,name_targ,charsmax(name_targ)); + get_user_authid(id,auth,charsmax(auth)); + get_user_authid(player,auth_targ,charsmax(auth_targ)); log_amx("Cmd: ^"%s<%d><%s><>^" ready room ^"%s<%d><%s><>^"",name,get_user_userid(id),auth, name_targ,get_user_userid(player),auth_targ); show_activity(id, name, "ready room %s", name_targ); @@ -238,8 +238,8 @@ public cmdReadyRoom(id,level,cid) { } if (cur) { new name[MAX_NAME_LENGTH],auth[32]; - get_user_name(id,name,31); - get_user_authid(id,auth,31); + get_user_name(id,name,charsmax(name)); + get_user_authid(id,auth,charsmax(auth)); log_amx("Cmd: ^"%s<%d><%s><>^" ready room all",name,get_user_userid(id),auth); show_activity(id, name, "ready room all"); @@ -273,7 +273,7 @@ public cmdTeamTwo(id,level,cid) { return PLUGIN_HANDLED if (read_argc()>1) { // person is specified.. new arg[32] - read_argv(1,arg,31) + read_argv(1,arg,charsmax(arg)) new player = cmd_target(id,arg,CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF) if (!player) return PLUGIN_HANDLED if (g_Team[player]==2 || g_Team[player]==4 /*i think 4 is team 2 in ava..*/) { @@ -282,10 +282,10 @@ public cmdTeamTwo(id,level,cid) { } new name[MAX_NAME_LENGTH],name_targ[MAX_NAME_LENGTH]; new auth[32],auth_targ[32]; - get_user_name(id,name,31); - get_user_name(player,name_targ,31); - get_user_authid(id,auth,31); - get_user_authid(player,auth_targ,31); + get_user_name(id,name,charsmax(name)); + get_user_name(player,name_targ,charsmax(name_targ)); + get_user_authid(id,auth,charsmax(auth)); + get_user_authid(player,auth_targ,charsmax(auth_targ)); log_amx("Cmd: ^"%s<%d><%s><>^" alien ^"%s<%d><%s><>^"",name,get_user_userid(id),auth, name_targ,get_user_userid(player),auth_targ); show_activity(id, name, "alien %s", name_targ); @@ -301,7 +301,7 @@ public cmdTeamOne(id,level,cid) { return PLUGIN_HANDLED if (read_argc()>1) { // person is specified.. new arg[32] - read_argv(1,arg,31) + read_argv(1,arg,charsmax(arg)) new player = cmd_target(id,arg,CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF) if (!player) return PLUGIN_HANDLED if (g_Team[player]==1 || g_Team[player]==3 /*i think 3 is team 2 in mvm..*/) { @@ -310,10 +310,10 @@ public cmdTeamOne(id,level,cid) { } new name[MAX_NAME_LENGTH],name_targ[MAX_NAME_LENGTH]; new auth[32],auth_targ[32]; - get_user_name(id,name,31); - get_user_name(player,name_targ,31); - get_user_authid(id,auth,31); - get_user_authid(player,auth_targ,31); + get_user_name(id,name,charsmax(name)); + get_user_name(player,name_targ,charsmax(name_targ)); + get_user_authid(id,auth,charsmax(auth)); + get_user_authid(player,auth_targ,charsmax(auth_targ)); log_amx("Cmd: ^"%s<%d><%s><>^" marine ^"%s<%d><%s><>^"",name,get_user_userid(id),auth, name_targ,get_user_userid(player),auth_targ); show_activity(id, name, "marine %s", name_targ); @@ -334,10 +334,10 @@ public cmdUnComm(id,level,cid) { client_cmd(comm, "%s", g_StopCommAck); new name[MAX_NAME_LENGTH],name_targ[MAX_NAME_LENGTH]; new auth[32],auth_targ[32]; - get_user_name(id,name,31); - get_user_name(comm,name_targ,31); - get_user_authid(id,auth,31); - get_user_authid(comm,auth_targ,31); + get_user_name(id,name,charsmax(name)); + get_user_name(comm,name_targ,charsmax(name_targ)); + get_user_authid(id,auth,charsmax(auth)); + get_user_authid(comm,auth_targ,charsmax(auth_targ)); log_amx("Cmd: ^"%s<%d><%s><>^" uncomm ^"%s<%d><%s><>^"",name,get_user_userid(id),auth, name_targ,get_user_userid(comm),auth_targ); show_activity(id, name, "uncomm %s", name_targ); From 8d4a1ca35958eccd1bcc648f1753a8d58a122cb8 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 17:04:12 +0200 Subject: [PATCH 16/30] Restmenu: more use of sizeof --- plugins/cstrike/restmenu.sma | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/cstrike/restmenu.sma b/plugins/cstrike/restmenu.sma index 3942fb8c..cc72f1f2 100755 --- a/plugins/cstrike/restmenu.sma +++ b/plugins/cstrike/restmenu.sma @@ -343,7 +343,7 @@ setWeapon(a, action) findMenuId(name[]) { - for (new i = 0; i < 7 ; ++i) + for (new i = 0; i < sizeof(g_menusNames) ; ++i) if (equali(name, g_menusNames[i])) return i @@ -898,7 +898,7 @@ public HookEvent_ShowMenu(id) return } - for (new i=0; i<6; i++) + for (new i=0; i Date: Sat, 11 Oct 2014 17:46:29 +0200 Subject: [PATCH 17/30] Statsx: more use of sizeof --- plugins/cstrike/statsx.sma | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/cstrike/statsx.sma b/plugins/cstrike/statsx.sma index 62c66a0e..882f1494 100755 --- a/plugins/cstrike/statsx.sma +++ b/plugins/cstrike/statsx.sma @@ -607,7 +607,7 @@ add_attacker_hits(id, iAttacker, sBuffer[MAX_BUFFER_LENGTH + 1]) iLen += formatex(sBuffer[iLen], charsmax(sBuffer) - iLen, "%L:^n", id, "HITS_YOU_IN", t_sName) - for (new i = 1; i < 8; i++) + for (new i = 1; i < sizeof(izBody); i++) { if (!izBody[i]) continue @@ -640,7 +640,7 @@ format_kill_ainfo(id, iKiller, sBuffer[MAX_BUFFER_LENGTH + 1]) if (izStats[STATS_HITS]) { - for (new i = 1; i < 8; i++) + for (new i = 1; i < sizeof(izBody); i++) { if (!izBody[i]) continue @@ -680,7 +680,7 @@ format_kill_vinfo(id, iKiller, sBuffer[MAX_BUFFER_LENGTH + 1]) if (izStats[STATS_HITS]) { - for (new i = 1; i < 8; i++) + for (new i = 1; i < sizeof(izBody); i++) { if (!izBody[i]) continue @@ -757,7 +757,7 @@ format_rankstats(id, sBuffer[MAX_BUFFER_LENGTH + 1], iMyId = 0) new L_BODY_PART[8][32] - for (new i = 1; i < 8; i++) + for (new i = 1; i < sizeof(L_BODY_PART); i++) { formatex(L_BODY_PART[i], charsmax(L_BODY_PART[]), "%L", id, BODY_PART[i]) } @@ -1292,14 +1292,14 @@ public eventStartRound() { g_izTeamEventScore[iTeam] = 0 - for (i = 0; i < 8; i++) + for (i = 0; i < sizeof(g_izTeamGameStats[]); i++) g_izTeamGameStats[iTeam][i] = 0 } // Clear game stats, incl '0' that is sum of all users. for (id = 0; id <= MaxClients; id++) { - for (i = 0; i < 8; i++) + for (i = 0; i < sizeof(g_izUserGameStats[]); i++) g_izUserGameStats[id][i] = 0 } } @@ -1310,7 +1310,7 @@ public eventStartRound() { g_izTeamScore[iTeam] = g_izTeamEventScore[iTeam] - for (i = 0; i < 8; i++) + for (i = 0; i < sizeof(g_izTeamRndStats[]); i++) g_izTeamRndStats[iTeam][i] = 0 } @@ -1319,7 +1319,7 @@ public eventStartRound() { g_izUserRndName[id][0] = 0 - for (i = 0; i < 8; i++) + for (i = 0; i < sizeof(g_izUserRndStats[]); i++) g_izUserRndStats[id][i] = 0 g_fzShowUserStatsTime[id] = 0.0 @@ -1462,7 +1462,7 @@ kill_stats(id) // Update user's team round stats if (iTeam >= 0 && iTeam < MAX_TEAMS) { - for (i = 0; i < 8; i++) + for (i = 0; i < sizeof(izStats); i++) { g_izTeamRndStats[iTeam][i] += izStats[i] g_izTeamGameStats[iTeam][i] += izStats[i] @@ -1474,7 +1474,7 @@ kill_stats(id) // Update user's round stats if (g_izUserUserID[id] == get_user_userid(id)) { - for (i = 0; i < 8; i++) + for (i = 0; i < sizeof(izStats); i++) { g_izUserRndStats[id][i] += izStats[i] g_izUserGameStats[id][i] += izStats[i] @@ -1482,7 +1482,7 @@ kill_stats(id) } else { g_izUserUserID[id] = get_user_userid(id) - for (i = 0; i < 8; i++) + for (i = 0; i < sizeof(izStats); i++) { g_izUserRndStats[id][i] = izStats[i] g_izUserGameStats[id][i] = izStats[i] From 7e9e2b7b584f9938ee1d3957365d72e543c18389 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 17:55:42 +0200 Subject: [PATCH 18/30] Stats: more use of sizeof --- plugins/dod/stats.sma | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dod/stats.sma b/plugins/dod/stats.sma index bfa29608..2e3cebb3 100755 --- a/plugins/dod/stats.sma +++ b/plugins/dod/stats.sma @@ -337,7 +337,7 @@ getHits(id,killer) { new stats[9], body[8], pos = 0 g_Buffer[0] = 0 get_user_astats(id,killer,stats,body) - for(new a = 1; a < 8; ++a) + for(new a = 1; a < sizeof(body); ++a) if(body[a]) pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%L: %d^n",id,g_bodyParts[a],body[a]) } @@ -348,7 +348,7 @@ getMyHits(id,killed) { get_user_name(killed,name,charsmax(name)) new pos = format(g_Buffer,charsmax(g_Buffer),"%L",id,"YOU_HIT",name) get_user_vstats(id,killed,stats,body) - for(new a = 1; a < 8; ++a){ + for(new a = 1; a < sizeof(body); ++a){ if(body[a]){ found = 1 pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos," %L: %d ",id,g_bodyParts[a],body[a]) From 3776650a385e635f9af22904282ce81c799aa4cd Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 18:13:08 +0200 Subject: [PATCH 19/30] Nscommands: remove an hardcoded value --- plugins/ns/nscommands.sma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ns/nscommands.sma b/plugins/ns/nscommands.sma index e08b2fd7..48b0e128 100755 --- a/plugins/ns/nscommands.sma +++ b/plugins/ns/nscommands.sma @@ -123,7 +123,7 @@ public client_connect(id) { } stock UTIL_FindCommander() { new i=1; - while (i<32) { + while (i Date: Sat, 11 Oct 2014 19:05:25 +0200 Subject: [PATCH 20/30] Plmenu: fix typos errors from previous commit --- plugins/dod/plmenu.sma | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dod/plmenu.sma b/plugins/dod/plmenu.sma index 0ac8cca5..46822632 100755 --- a/plugins/dod/plmenu.sma +++ b/plugins/dod/plmenu.sma @@ -737,9 +737,9 @@ load_settings(szFilename[]) { if (text[0] == ';') continue - if (parse(text, g_clcmdName[g_clcmdNum], charsmax(g_clcmdName), g_clcmdCmd[g_clcmdNum], charsmax(g_clcmdCmd), szFlags, charsmax(szFlags), szAccess, charsmax(szAccess)) > 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], charsmax(g_clcmdCmd), "\'", "^"")) + while (replace(g_clcmdCmd[g_clcmdNum], charsmax(g_clcmdCmd[]), "\'", "^"")) { // do nothing } From 93d37a63669b250de7f200b5d486d46f64b16c12 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 19:07:24 +0200 Subject: [PATCH 21/30] 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 } From 59cb65f47a90365b5566d7a4b092292c17252858 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 19:51:57 +0200 Subject: [PATCH 22/30] Timeleft: replace len hardcoded content by charsmax and sizeof --- plugins/ns/timeleft.sma | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/ns/timeleft.sma b/plugins/ns/timeleft.sma index e5196ce4..30ce1cf1 100755 --- a/plugins/ns/timeleft.sma +++ b/plugins/ns/timeleft.sma @@ -30,7 +30,7 @@ public plugin_init() { set_task(0.8,"timeRemain",8648458,"",0,"b") new szMapName[4] - get_mapname(szMapName, 3) + get_mapname(szMapName, charsmax(szMapName)) if (equal(szMapName, "co_")) { register_event("PlayHUDNot", "roundChange", "bc", "1=0", "2>56", "2<59") is_combat = true @@ -40,12 +40,12 @@ public plugin_init() { public sayTheTime(id){ if ( get_cvar_num("amx_time_voice") ){ new mhours[6], mmins[6], whours[32], wmins[32], wpm[6] - get_time("%H",mhours,5) - get_time("%M",mmins,5) + get_time("%H",mhours,charsmax(mhours)) + get_time("%M",mmins,charsmax(mmins)) new mins = str_to_num(mmins) new hrs = str_to_num(mhours) if (mins) - num_to_word(mins,wmins,31) + num_to_word(mins,wmins,charsmax(wmins)) else wmins[0] = 0 if (hrs < 12) @@ -55,13 +55,13 @@ public sayTheTime(id){ wpm = "pm " } if (hrs) - num_to_word(hrs,whours,31) + num_to_word(hrs,whours,charsmax(whours)) else whours = "twelve " client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"",whours,wmins,wpm ) } new ctime[64] - get_time("%m/%d/%Y - %H:%M:%S",ctime,63) + get_time("%m/%d/%Y - %H:%M:%S",ctime,charsmax(ctime)) client_print(0,print_chat, "The time: %s",ctime ) return PLUGIN_CONTINUE } @@ -71,7 +71,7 @@ public sayTimeLeft(id){ new a = get_timeleft() if ( get_cvar_num("amx_time_voice") ) { new svoice[128] - setTimeVoice( svoice , 127 , 0 , a ) + setTimeVoice( svoice , charsmax(svoice) , 0 , a ) client_cmd( id , "%s", svoice ) } client_print(0,print_chat, "Time Left: %d:%02d", (a / 60) , (a % 60) ) @@ -108,20 +108,20 @@ setTimeVoice(text[],len,flags,tmlf){ new temp[7][32] new secs = tmlf % 60 new mins = tmlf / 60 - for(new a = 0;a < 7;++a) + for(new a = 0;a < sizeof(temp);++a) temp[a][0] = 0 if (secs > 0){ - num_to_word(secs,temp[4],31) + num_to_word(secs,temp[4],charsmax(temp[])) if (!(flags & 8)) temp[5] = "seconds " /* there is no "second" in default hl */ } if (mins > 59){ new hours = mins / 60 - num_to_word(hours,temp[0],31) + num_to_word(hours,temp[0],charsmax(temp[])) if (!(flags & 8)) temp[1] = "hours " mins = mins % 60 } if (mins > 0) { - num_to_word(mins ,temp[2],31) + num_to_word(mins ,temp[2],charsmax(temp[])) if (!(flags & 8)) temp[3] = "minutes " } if (!(flags & 4)) temp[6] = "remaining " @@ -163,8 +163,8 @@ public setDisplaying(){ new arg[32], flags[32], num[32] new argc = read_argc() - 1 for(new i; (argc > i < 32); ++i) { - read_argv(i+1,arg,31) - parse(arg,flags,31,num,31) + read_argv(i+1,arg,charsmax(arg)) + parse(arg,flags,charsmax(flags),num,charsmax(num)) g_TimeSet[i][0] = str_to_num(num) g_TimeSet[i][1] = read_flags(flags) g_TimeSet[i+1][0] = 0 @@ -175,7 +175,7 @@ public setDisplaying(){ public timeRemain(param[]){ new gmtm = get_timeleft() new stimel[12] - format(stimel,11,"%02d:%02d",gmtm / 60, gmtm % 60) + format(stimel,charsmax(stimel),"%02d:%02d",gmtm / 60, gmtm % 60) set_cvar_string("amx_timeleft",stimel) if (!is_combat) @@ -196,7 +196,7 @@ public timeRemain(param[]){ new flags = g_TimeSet[tm_set][1] new arg[128] if (flags & 1){ // display white text on bottom - setTimeText(arg,127,tmlf) + setTimeText(arg,charsmax(arg),tmlf) if (flags & 16) // show/speak if current time is less than this set in parameter set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 1.1, 0.1, 0.5, -1) else @@ -204,7 +204,7 @@ public timeRemain(param[]){ show_hudmessage(0, "%s", arg) } if (flags & 2){ // use voice - setTimeVoice(arg,127,flags,tmlf) + setTimeVoice(arg,charsmax(arg),flags,tmlf) client_cmd(0, "%s", arg) } } From 2a5fae43b8238431b2847e63c6af79e4dfe6eb8f Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 20:55:24 +0200 Subject: [PATCH 23/30] Plmenu: replace len hardcoded content by charsmax --- plugins/tfc/plmenu.sma | 160 ++++++++++++++++++++--------------------- 1 file changed, 80 insertions(+), 80 deletions(-) diff --git a/plugins/tfc/plmenu.sma b/plugins/tfc/plmenu.sma index 5ed9b16c..afa41b0c 100755 --- a/plugins/tfc/plmenu.sma +++ b/plugins/tfc/plmenu.sma @@ -61,8 +61,8 @@ public plugin_init() g_coloredMenus = colored_menus() 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) } @@ -118,10 +118,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) log_amx("Ban: ^"%s<%d><%s><>^" ban and kick ^"%s<%d><%s><>^" (minutes ^"%d^")", name, get_user_userid(id), authid, name2, userid2, authid2, g_menuSettings[id]) @@ -137,7 +137,7 @@ public actionBanMenu(id, key) else { new tempTime[32]; - formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]); + formatex(tempTime,charsmax(tempTime),"%d",g_menuSettings[id]); client_print(0, print_chat, "%L %s: %L %s %L", LANG_PLAYER, "ADMIN", name, LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime); } } @@ -150,7 +150,7 @@ public actionBanMenu(id, key) else { new tempTime[32]; - formatex(tempTime,sizeof(tempTime)-1,"%d",g_menuSettings[id]); + formatex(tempTime,charsmax(tempTime),"%d",g_menuSettings[id]); client_print(0, print_chat, "%L: %L %s %L", LANG_PLAYER, "ADMIN", LANG_PLAYER, "BAN", name2, LANG_PLAYER, "FOR_MIN", tempTime); } } @@ -159,7 +159,7 @@ public actionBanMenu(id, key) if (equal("4294967295", authid2)) { new ipa[32] - get_user_ip(player, ipa, 31, 1) + get_user_ip(player, ipa, charsmax(ipa), 1) server_cmd("addip %d %s;writeip", g_menuSettings[id], ipa) if( g_tempBans ) { @@ -200,7 +200,7 @@ displayBanMenu(id, pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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 @@ -210,38 +210,38 @@ 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 if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s^n\w", b, name) else - len += format(menuBody[len], 511-len, "#. %s^n", name) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s^n", name) } else { keys |= (1<<%s><>^" slap with %d damage ^"%s<%d><%s><>^"", @@ -336,7 +336,7 @@ displaySlapMenu(id, pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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 @@ -346,7 +346,7 @@ 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)) new iteam = get_user_team(i) if (!is_user_alive(i) || access(i, ADMIN_IMMUNITY)) @@ -354,31 +354,31 @@ displaySlapMenu(id, pos) ++b if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, g_teamNames[iteam]) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s\R%s^n\w", b, name, g_teamNames[iteam]) else - len += format(menuBody[len], 511-len, "#. %s %s^n", name, g_teamNames[iteam]) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s %s^n", name, g_teamNames[iteam]) } else { keys |= (1<<%s><>^" kick ^"%s<%d><%s><>^"", @@ -446,7 +446,7 @@ displayKickMenu(id, pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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 @@ -456,33 +456,33 @@ 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 if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s^n\w", b, name) else - 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_teamNames[g_menuOption[id]] ) @@ -522,8 +522,8 @@ public actionTeamMenu(id,key) { case 1: client_print(0, print_chat, "%L", LANG_PLAYER, "ADMIN_TRANSF_1", name2, g_teamNames[g_menuOption[id]]) } - new szCmd[2] - format(szCmd,2,"%d",g_menuOption[id]) + new szCmd[3] + format(szCmd,charsmax(szCmd),"%d",g_menuOption[id]) tfc_userkill(player) if (g_menuOption[id] == 5) { @@ -555,7 +555,7 @@ displayTeamMenu(id, pos) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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 @@ -565,7 +565,7 @@ 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 = get_user_team(i) if ((iteam == g_menuOption[id]) || access(i, ADMIN_IMMUNITY)) @@ -573,28 +573,28 @@ displayTeamMenu(id, pos) ++b if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, g_teamNames[iteam]) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s\R%s^n\w", b, name, g_teamNames[iteam]) else - len += format(menuBody[len], 511-len, "#. %s %s^n", name, g_teamNames[iteam]) + len += format(menuBody[len], charsmax(menuBody)-len, "#. %s %s^n", name, g_teamNames[iteam]) } else { keys |= (1<= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 - new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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), g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%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 @@ -675,38 +675,38 @@ 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 if (g_coloredMenus) - len += format(menuBody[len], 511-len, "\d%d. %s^n\w", b, name) + len += format(menuBody[len], charsmax(menuBody)-len, "\d%d. %s^n\w", b, name) else - 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 } From 15b160e51a15298649a4fd01b1fc13dc0ded4d98 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 21:29:10 +0200 Subject: [PATCH 24/30] Stats: Replace len hardcoded contents by charsmax and sizeof --- plugins/tfc/stats.sma | 110 +++++++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/plugins/tfc/stats.sma b/plugins/tfc/stats.sma index 5daa79c4..4ccde47b 100755 --- a/plugins/tfc/stats.sma +++ b/plugins/tfc/stats.sma @@ -222,19 +222,19 @@ public cmdStatsMe(id){ displayStats(id,dest) { new name[32], stats[8], body[8] get_user_wstats(id,0,stats,body) - new pos = format(g_Buffer,2047,"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", + new pos = format(g_Buffer,charsmax(g_Buffer),"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", stats[0],stats[1],stats[3],stats[6],stats[5],stats[4]) new a for( a = 1; a < TFCMAX_WEAPONS; a++) { if (get_user_wstats(id,a,stats,body)){ if ( xmod_is_melee_wpn(a) ) stats[4] = -1; - xmod_get_wpnname(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"%s shots: %d hits: %d damage: %d kills: %d deaths: %d^n", + xmod_get_wpnname(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s shots: %d hits: %d damage: %d kills: %d deaths: %d^n", name,stats[4],stats[5],stats[6],stats[0],stats[1]) } } - get_user_name(id,name,31) + get_user_name(id,name,charsmax(name)) show_motd(dest,g_Buffer,name) } @@ -250,13 +250,13 @@ public cmdRank(id){ displayRank(id,dest) { new name[MAX_NAME_LENGTH], stats[8], body[8] new rank_pos = get_user_stats(id,stats,body) - new pos = format(g_Buffer,2047,"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", + new pos = format(g_Buffer,charsmax(g_Buffer),"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", stats[0],stats[1],stats[3],stats[6],stats[5],stats[4]) - pos += format(g_Buffer[pos],2047-pos,"Hits:^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n^n", + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"Hits:^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n^n", g_bodyParts[1],body[1],g_bodyParts[2],body[2],g_bodyParts[3],body[3], g_bodyParts[4],body[4], g_bodyParts[5],body[5],g_bodyParts[6],body[6],g_bodyParts[7],body[7]) - format(g_Buffer[pos],2047-pos,"%s rank is %d of %d",(id==dest)?"Your":"His", rank_pos,get_statsnum()) - get_user_name(id,name,31) + format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s rank is %d of %d",(id==dest)?"Your":"His", rank_pos,get_statsnum()) + get_user_name(id,name,charsmax(name)) show_motd(dest,g_Buffer,name) } @@ -273,14 +273,14 @@ public cmdTop15(id) { /* get top 15 */ getTop15(){ new stats[8], body[8], name[MAX_NAME_LENGTH] - new pos = copy(g_Buffer,2047,"# nick kills/deaths TKs hits/shots/headshots^n") + new pos = copy(g_Buffer,charsmax(g_Buffer),"# nick kills/deaths TKs hits/shots/headshots^n") new imax = get_statsnum() if (imax > 15) imax = 15 for(new a = 0; a < imax; ++a){ - get_stats(a,stats,body,name,31) - replace_all(name, 31, "<", "[") - replace_all(name, 31, ">", "]") - pos += format(g_Buffer[pos],2047-pos,"%2d. %-28.27s %d/%d %d %d/%d/%d^n",a+1,name,stats[0],stats[1],stats[3],stats[5],stats[4],stats[2]) + get_stats(a,stats,body,name,charsmax(name)) + replace_all(name, charsmax(name), "<", "[") + replace_all(name, charsmax(name), ">", "]") + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%2d. %-28.27s %d/%d %d %d/%d/%d^n",a+1,name,stats[0],stats[1],stats[3],stats[5],stats[4],stats[2]) } } @@ -319,17 +319,17 @@ public cmdStats(id){ /* build list of attackers */ getAttackers(id) { new name[MAX_NAME_LENGTH],wpn[32], stats[8],body[8],found=0 - new pos = copy(g_Buffer,2047,"Attackers:^n") + new pos = copy(g_Buffer,charsmax(g_Buffer),"Attackers:^n") for(new a = 1; a <= MaxClients; ++a){ - if(get_user_astats(id,a,stats,body,wpn,31)){ + if(get_user_astats(id,a,stats,body,wpn,charsmax(wpn))){ found = 1 if (stats[0]) - format(wpn,31," -- %s",wpn) + format(wpn,charsmax(wpn)," -- %s",wpn) else wpn[0] = 0 - get_user_name(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) + get_user_name(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) } } return found @@ -339,16 +339,16 @@ getAttackers(id) { /* build list of victims */ getVictims(id) { new name[MAX_NAME_LENGTH],wpn[32], stats[8],body[8],found=0 - new pos = copy(g_Buffer,2047,"Victims:^n") + new pos = copy(g_Buffer,charsmax(g_Buffer),"Victims:^n") for(new a = 1; a <= MaxClients; ++a){ - if(get_user_vstats(id,a,stats,body,wpn,31)){ + if(get_user_vstats(id,a,stats,body,wpn,charsmax(wpn))){ found = 1 if (stats[1]) - format(wpn,31," -- %s",wpn) + format(wpn,charsmax(wpn)," -- %s",wpn) else wpn[0] = 0 - get_user_name(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) + get_user_name(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) } } return found @@ -359,22 +359,22 @@ getHits(id,killer) { new stats[8], body[8], pos = 0 g_Buffer[0] = 0 get_user_astats(id,killer,stats,body) - for(new a = 1; a < 8; ++a) + for(new a = 1; a < sizeof(body); ++a) if(body[a]) - pos += format(g_Buffer[pos],2047-pos,"%s: %d^n",g_bodyParts[a],body[a]) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s: %d^n",g_bodyParts[a],body[a]) } /* build list of hits for say hp */ getMyHits(id,killed) { new name[MAX_NAME_LENGTH], stats[8], body[8], found = 0 - get_user_name(killed,name,31) - new pos = format(g_Buffer,2047,"You hit %s in:",name) + get_user_name(killed,name,charsmax(name)) + new pos = format(g_Buffer,charsmax(g_Buffer),"You hit %s in:",name) get_user_vstats(id,killed,stats,body) - for(new a = 1; a < 8; ++a){ + for(new a = 1; a < sizeof(body); ++a){ if(body[a]){ found = 1 - pos += format(g_Buffer[pos],2047-pos," %s: %d ",g_bodyParts[a],body[a]) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos," %s: %d ",g_bodyParts[a],body[a]) } } return found @@ -390,9 +390,9 @@ public cmdKiller(id) { return PLUGIN_HANDLED } if (g_Killers[id][0]) { - new name[MAX_NAME_LENGTH], stats[8], body[8], wpn[33], mstats[8], mbody[8] - get_user_name(g_Killers[id][0],name,31) - get_user_astats(id,g_Killers[id][0],stats,body,wpn,31) + new name[MAX_NAME_LENGTH], stats[8], body[8], wpn[32], mstats[8], mbody[8] + get_user_name(g_Killers[id][0],name,charsmax(name)) + get_user_astats(id,g_Killers[id][0],stats,body,wpn,charsmax(wpn)) client_print(id,print_chat,"%s killed you with %s from distance of %.2f meters", name,wpn,float(g_Killers[id][3]) * 0.0254 ) client_print(id,print_chat,"He did %d damage to you with %d hit%s and still had %dhp and %dap", stats[6],stats[5],(stats[5]==1)?"":"s" , g_Killers[id][1],g_Killers[id][2] ) @@ -441,22 +441,22 @@ showStatsMenu(id,pos){ get_players(g_userPlayers[id],inum) if (start >= inum) start = pos = g_userPosition[id] = 0 - new len = format(menu_body,511,"Server Stats %d/%d^n^n",pos + 1,((inum/max_menupos)+((inum%max_menupos)?1:0))) + new len = format(menu_body,charsmax(menu_body),"Server Stats %d/%d^n^n",pos + 1,((inum/max_menupos)+((inum%max_menupos)?1:0))) new name[MAX_NAME_LENGTH], end = start + max_menupos, keys = (1<<9)|(1<<7) if (end > inum) end = inum for(new a = start; a < end; ++a){ - get_user_name(g_userPlayers[id][a],name,31) + get_user_name(g_userPlayers[id][a],name,charsmax(name)) keys |= (1< get_gametime() ) @@ -642,13 +642,13 @@ public showDoubleKill(){ if ( DoubleKill ) { new name[MAX_NAME_LENGTH],message[128] - get_user_name(g_prevKillerId,name,31) - copy( message, 127, g_DoubleKillMsg[pos] ) - replace( message, 127 , "$kn", name ) + get_user_name(g_prevKillerId,name,charsmax(name)) + copy( message, charsmax(message), g_DoubleKillMsg[pos] ) + replace( message, charsmax(message) , "$kn", name ) if ( pos == 2 ){ new kills[3] - num_to_str(g_KillCount,kills,2) - replace( message, 127 , "$kk", kills ) + num_to_str(g_KillCount,kills,charsmax(kills)) + replace( message, charsmax(message) , "$kk", kills ) } set_hudmessage(65, 102, 158, -1.0, 0.25, 0, 6.0, 6.0, 0.5, 0.15, -1) for (new i=1;i<=MaxClients;i++){ @@ -671,7 +671,7 @@ public checkKills(param[]){ if ( a > -1 ){ if ( MultiKill ) { new name[MAX_NAME_LENGTH] - get_user_name(id,name,31) + get_user_name(id,name,charsmax(name)) set_hudmessage(255, 0, 100, 0.05, 0.65, 2, 0.02, 6.0, 0.01, 0.1, -1) if ( a > 6 ) a = 6 for (new i=1;i<=MaxClients;i++){ From 4e343f65bd20bf04de472cbc7799fca4df381bfd Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 22:31:11 +0200 Subject: [PATCH 25/30] Stats_logging: Replace len hardcoded contents by charsmax --- plugins/tfc/stats_logging.sma | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/tfc/stats_logging.sma b/plugins/tfc/stats_logging.sma index 801257fa..e7957629 100755 --- a/plugins/tfc/stats_logging.sma +++ b/plugins/tfc/stats_logging.sma @@ -25,12 +25,12 @@ public client_disconnect(id) { remove_task( id ) new szTeam[16],szName[MAX_NAME_LENGTH],szAuthid[32], iStats[8], iHits[8], szWeapon[24] new iUserid = get_user_userid( id ) - get_user_team(id, szTeam, 15 ) - get_user_name(id, szName ,31 ) - get_user_authid(id, szAuthid , 31 ) + get_user_team(id, szTeam, charsmax(szTeam) ) + get_user_name(id, szName , charsmax(szName) ) + get_user_authid(id, szAuthid , charsmax(szAuthid) ) for(new i = 1 ; i < TFCMAX_WEAPONS ; ++i ) { if( get_user_wstats( id , i ,iStats , iHits ) ) { - xmod_get_wpnlogname( i , szWeapon , 23 ) + xmod_get_wpnlogname( i , szWeapon , charsmax(szWeapon) ) log_message("^"%s<%d><%s><%s>^" triggered ^"weaponstats^" (weapon ^"%s^") (shots ^"%d^") (hits ^"%d^") (kills ^"%d^") (headshots ^"%d^") (tks ^"%d^") (damage ^"%d^") (deaths ^"%d^")", szName,iUserid,szAuthid,szTeam,szWeapon,iStats[4],iStats[5],iStats[0], iStats[2],iStats[3],iStats[6],iStats[1]) From c2ee729380b9e71fb0f2341f369e20c36e29c03d Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 22:41:18 +0200 Subject: [PATCH 26/30] Stats_logging: Replace len hardcoded contents by charsmax --- plugins/ts/stats_logging.sma | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/ts/stats_logging.sma b/plugins/ts/stats_logging.sma index 22144deb..fd6e8ae7 100755 --- a/plugins/ts/stats_logging.sma +++ b/plugins/ts/stats_logging.sma @@ -29,13 +29,13 @@ public client_disconnect(id) { new iUserid = get_user_userid( id ) // team - get_user_info(id,"team", szTeam, 15 ) + get_user_info(id,"team", szTeam, charsmax(szTeam) ) - get_user_name(id, szName ,31 ) - get_user_authid(id, szAuthid , 31 ) + get_user_name(id, szName , charsmax(szName) ) + get_user_authid(id, szAuthid , charsmax(szAuthid) ) for(new i = 1 ; i < TSMAX_WEAPONS ; ++i ) { if( get_user_wstats( id , i ,iStats , iHits ) ) { - xmod_get_wpnlogname( i , szWeapon , 15 ) + xmod_get_wpnlogname( i , szWeapon , charsmax(szWeapon) ) log_message("^"%s<%d><%s><%s>^" triggered ^"weaponstats^" (weapon ^"%s^") (shots ^"%d^") (hits ^"%d^") (kills ^"%d^") (headshots ^"%d^") (tks ^"%d^") (damage ^"%d^") (deaths ^"%d^")", szName,iUserid,szAuthid,szTeam,szWeapon,iStats[4],iStats[5],iStats[0], iStats[2],iStats[3],iStats[6],iStats[1]) From c440929700f7bbb0f99f373a755ac707f9f6972f Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sat, 11 Oct 2014 23:17:20 +0200 Subject: [PATCH 27/30] Stats: Replace len hardcoded contents by charsmax and sizeof --- plugins/ts/stats.sma | 120 +++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/plugins/ts/stats.sma b/plugins/ts/stats.sma index 419dabe3..56439e41 100755 --- a/plugins/ts/stats.sma +++ b/plugins/ts/stats.sma @@ -167,18 +167,18 @@ public cmdStatsMe(id){ public displayStats(id,dest) { new name[32], stats[8], body[8] get_user_wstats(id,0,stats,body) - new pos = format(g_Buffer,2047,"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", + new pos = format(g_Buffer,charsmax(g_Buffer),"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", stats[0],stats[1],stats[3],stats[6],stats[5],stats[4]) for(new a = 1; a < TSMAX_WEAPONS; ++a) { if (get_user_wstats(id,a,stats,body)){ if ( xmod_is_melee_wpn(a) ) stats[4] = -1; - xmod_get_wpnname(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"%s shots: %d hits: %d damage: %d kills: %d deaths: %d^n", + xmod_get_wpnname(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s shots: %d hits: %d damage: %d kills: %d deaths: %d^n", name,stats[4],stats[5],stats[6],stats[0],stats[1]) } } - get_user_name(id,name,31) + get_user_name(id,name,charsmax(name)) show_motd(dest,g_Buffer,name) return PLUGIN_CONTINUE } @@ -193,15 +193,15 @@ public cmdRank(id){ } displayRank(id,dest) { - new name[32], stats[8], body[8] + new name[MAX_NAME_LENGTH], stats[8], body[8] new rank_pos = get_user_stats(id,stats,body) - new pos = format(g_Buffer,2047,"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", + new pos = format(g_Buffer,charsmax(g_Buffer),"Kills: %d^nDeaths: %d^nTKs: %d^nDamage: %d^nHits: %d^nShots: %d^n^n", stats[0],stats[1],stats[3],stats[6],stats[5],stats[4]) - pos += format(g_Buffer[pos],2047-pos,"Hits:^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n^n", + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"Hits:^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n%s: %d^n^n", g_bodyParts[1],body[1],g_bodyParts[2],body[2],g_bodyParts[3],body[3], g_bodyParts[4],body[4], g_bodyParts[5],body[5],g_bodyParts[6],body[6],g_bodyParts[7],body[7]) - format(g_Buffer[pos],2047-pos,"%s rank is %d of %d",(id==dest)?"Your":"His", rank_pos,get_statsnum()) - get_user_name(id,name,31) + format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s rank is %d of %d",(id==dest)?"Your":"His", rank_pos,get_statsnum()) + get_user_name(id,name,charsmax(name)) show_motd(dest,g_Buffer,name) } @@ -218,14 +218,14 @@ public cmdTop15(id) { /* get top 15 */ getTop15(){ new stats[8], body[8], name[MAX_NAME_LENGTH] - new pos = copy(g_Buffer,2047,"# nick kills/deaths TKs hits/shots/headshots^n") + new pos = copy(g_Buffer,charsmax(g_Buffer),"# nick kills/deaths TKs hits/shots/headshots^n") new imax = get_statsnum() if (imax > 15) imax = 15 for(new a = 0; a < imax; ++a){ - get_stats(a,stats,body,name,31) - replace_all(name, 31, "<", "[") - replace_all(name, 31, ">", "]") - pos += format(g_Buffer[pos],2047-pos,"%2d. %-28.27s %d/%d %d %d/%d/%d^n",a+1,name,stats[0],stats[1],stats[3],stats[5],stats[4],stats[2]) + get_stats(a,stats,body,name,charsmax(name)) + replace_all(name, charsmax(name), "<", "[") + replace_all(name, charsmax(name), ">", "]") + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%2d. %-28.27s %d/%d %d %d/%d/%d^n",a+1,name,stats[0],stats[1],stats[3],stats[5],stats[4],stats[2]) } } @@ -261,16 +261,16 @@ public cmdStats(id){ /* build list of attackers */ getAttackers(id) { new name[MAX_NAME_LENGTH],wpn[32], stats[8],body[8],found=0 - new pos = copy(g_Buffer,2047,"Attackers:^n") + new pos = copy(g_Buffer,charsmax(g_Buffer),"Attackers:^n") for(new a = 1; a <= MaxClients; ++a){ - if(get_user_astats(id,a,stats,body,wpn,31)){ + if(get_user_astats(id,a,stats,body,wpn,charsmax(wpn))){ found = 1 if (stats[0]) - format(wpn,31," -- %s",wpn) + format(wpn,charsmax(wpn)," -- %s",wpn) else wpn[0] = 0 - get_user_name(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) + get_user_name(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) } } return found @@ -279,16 +279,16 @@ getAttackers(id) { /* build list of victims */ getVictims(id) { new name[MAX_NAME_LENGTH],wpn[32], stats[8],body[8],found=0 - new pos = copy(g_Buffer,2047,"Victims:^n") + new pos = copy(g_Buffer,charsmax(g_Buffer),"Victims:^n") for(new a = 1; a <= MaxClients; ++a){ - if(get_user_vstats(id,a,stats,body,wpn,31)){ + if(get_user_vstats(id,a,stats,body,wpn,charsmax(wpn))){ found = 1 if (stats[1]) - format(wpn,31," -- %s",wpn) + format(wpn,charsmax(wpn)," -- %s",wpn) else wpn[0] = 0 - get_user_name(a,name,31) - pos += format(g_Buffer[pos],2047-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) + get_user_name(a,name,charsmax(name)) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s -- %d dmg / %d hit(s)%s^n",name,stats[6],stats[5],wpn) } } return found @@ -299,22 +299,22 @@ getHits(id,killer) { new stats[8], body[8], pos = 0 g_Buffer[0] = 0 get_user_astats(id,killer,stats,body) - for(new a = 1; a < 8; ++a) + for(new a = 1; a < sizeof(body); ++a) if(body[a]) - pos += format(g_Buffer[pos],2047-pos,"%s: %d^n",g_bodyParts[a],body[a]) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos,"%s: %d^n",g_bodyParts[a],body[a]) } /* build list of hits for say hp */ getMyHits(id,killed) { new name[MAX_NAME_LENGTH], stats[8], body[8], found = 0 - get_user_name(killed,name,31) - new pos = format(g_Buffer,2047,"You hit %s in:",name) + get_user_name(killed,name,charsmax(name)) + new pos = format(g_Buffer,charsmax(g_Buffer),"You hit %s in:",name) get_user_vstats(id,killed,stats,body) - for(new a = 1; a < 8; ++a){ + for(new a = 1; a < sizeof(body); ++a){ if(body[a]){ found = 1 - pos += format(g_Buffer[pos],2047-pos," %s: %d ",g_bodyParts[a],body[a]) + pos += format(g_Buffer[pos],charsmax(g_Buffer)-pos," %s: %d ",g_bodyParts[a],body[a]) } } return found @@ -324,7 +324,7 @@ public client_damage(attacker,victim,damage,wpnindex,hitplace,TA) { if ( TA ){ if ( TAInfo && is_user_alive(victim) ){ new attacker_name[MAX_NAME_LENGTH] - get_user_name(attacker,attacker_name,31) + get_user_name(attacker,attacker_name,charsmax(attacker_name)) client_print(0,print_chat,"%s attacked a teammate",attacker_name) } return PLUGIN_CONTINUE @@ -341,7 +341,7 @@ public client_damage(attacker,victim,damage,wpnindex,hitplace,TA) { public client_death(killer,victim,wpnindex,hitplace,TK){ new killer_name[MAX_NAME_LENGTH] - get_user_name(killer,killer_name,31) + get_user_name(killer,killer_name,charsmax(killer_name)) if ( TK ){ if ( TAInfo ){ @@ -355,7 +355,7 @@ public client_death(killer,victim,wpnindex,hitplace,TK){ new headshot = ( hitplace == HIT_HEAD ) ? 1:0 new victim_name[MAX_NAME_LENGTH] - get_user_name(victim,victim_name,31) + get_user_name(victim,victim_name,charsmax(victim_name)) if ( killer == victim ){ if ( grenade && GrenadeSuicide ){ @@ -390,11 +390,11 @@ public client_death(killer,victim,wpnindex,hitplace,TK){ else if ( headshot && (HeadShotKill || HeadShotKillSound) && !xmod_is_melee_wpn(wpnindex) ){ if ( HeadShotKill ){ new weapon[32], message[256] - xmod_get_wpnname(wpnindex,weapon,31) - copy( message, sizeof(message)-1, g_HeadShots[ random_num(0,6) ] ) - replace( message, sizeof(message)-1, "$vn", victim_name ) - replace( message, sizeof(message)-1 , "$wn", weapon ) - replace( message, sizeof(message)-1, "$kn", killer_name ) + xmod_get_wpnname(wpnindex,weapon,charsmax(weapon)) + copy( message, charsmax(message), g_HeadShots[ random_num(0,6) ] ) + replace( message, charsmax(message), "$vn", victim_name ) + replace( message, charsmax(message), "$wn", weapon ) + replace( message, charsmax(message), "$kn", killer_name ) set_hudmessage(100, 100, 255, -1.0, 0.29, 0, 6.0, 6.0, 0.5, 0.15, -1) for (new i=1;i<=MaxClients;i++){ if ( g_Killers[i][0] && g_DeathStats[i] > get_gametime() ) @@ -420,26 +420,26 @@ public client_death(killer,victim,wpnindex,hitplace,TK){ if ( FragInfo ){ new kmsg[128] - new pos = format(kmsg,63,"LastKill: %d frag(s)^n",ts_getuserlastfrag(killer)) + new pos = format(kmsg,charsmax(kmsg),"LastKill: %d frag(s)^n",ts_getuserlastfrag(killer)) if ( killFlags ){ - pos += format(kmsg[pos],128-pos,"[") + pos += format(kmsg[pos],charsmax(kmsg)-pos,"[") if ( killFlags & TSKF_STUNTKILL ) - pos += format(kmsg[pos],128-pos," stunt ") + pos += format(kmsg[pos],charsmax(kmsg)-pos," stunt ") if ( killFlags & TSKF_SLIDINGKILL ) - pos += format(kmsg[pos],128-pos," sliding ") + pos += format(kmsg[pos],charsmax(kmsg)-pos," sliding ") if ( killFlags & TSKF_DOUBLEKILL ) - pos += format(kmsg[pos],128-pos," double ") + pos += format(kmsg[pos],charsmax(kmsg)-pos," double ") if ( killFlags & TSKF_ISSPEC ) - pos += format(kmsg[pos],128-pos," spec ") + pos += format(kmsg[pos],charsmax(kmsg)-pos," spec ") if ( killFlags & TSKF_KILLEDSPEC ) - pos += format(kmsg[pos],128-pos," kspec ") + pos += format(kmsg[pos],charsmax(kmsg)-pos," kspec ") - pos += format(kmsg[pos],128-pos,"]") + pos += format(kmsg[pos],charsmax(kmsg)-pos,"]") } set_hudmessage(255,255,255,0.02,0.85,2, 1.5, 3.0, 0.02, 5.0, -1) show_hudmessage(killer, "%s", kmsg) @@ -450,9 +450,9 @@ public client_death(killer,victim,wpnindex,hitplace,TK){ DisplayKillInfo(victim){ if ( ShowKiller ){ - new name[MAX_NAME_LENGTH], stats[8], body[8], wpn[33], mstats[8], mbody[8] - get_user_name(g_Killers[victim][0],name,31) - get_user_astats(victim,g_Killers[victim][0],stats,body,wpn,31) + new name[MAX_NAME_LENGTH], stats[8], body[8], wpn[32], mstats[8], mbody[8] + get_user_name(g_Killers[victim][0],name,charsmax(name)) + get_user_astats(victim,g_Killers[victim][0],stats,body,wpn,charsmax(wpn)) get_user_vstats(victim,g_Killers[victim][0],mstats,mbody) set_hudmessage(220,80,0,0.05,0.15,0, 6.0, 12.0, 1.0, 2.0, -1) getHits(victim,g_Killers[victim][0]) @@ -476,8 +476,8 @@ DisplayAVList(victim){ DisplayKillerHp(victim,con){ if ( KillerHp ){ new name[MAX_NAME_LENGTH], kmsg[128] - get_user_name(g_Killers[victim][0],name,31) - format(kmsg,127,"%s still has %dhp",name,g_Killers[victim][1]) + get_user_name(g_Killers[victim][0],name,charsmax(name)) + format(kmsg,charsmax(kmsg),"%s still has %dhp",name,g_Killers[victim][1]) if ( con ) client_print(victim,print_console, "%s", kmsg) set_hudmessage(255,255,255,0.02,0.9,2, 1.5, 3.0, 0.02, 5.0, -1) show_hudmessage(victim, "%s", kmsg) @@ -503,9 +503,9 @@ public cmdKiller(id) { return PLUGIN_HANDLED } if (g_Killers[id][0]) { - new name[MAX_NAME_LENGTH], stats[8], body[8], wpn[33], mstats[8], mbody[8] - get_user_name(g_Killers[id][0],name,31) - get_user_astats(id,g_Killers[id][0],stats,body,wpn,31) + new name[MAX_NAME_LENGTH], stats[8], body[8], wpn[32], mstats[8], mbody[8] + get_user_name(g_Killers[id][0],name,charsmax(name)) + get_user_astats(id,g_Killers[id][0],stats,body,wpn,charsmax(wpn)) get_user_vstats(id,g_Killers[id][0],mstats,mbody) client_print(id,print_chat,"%s killed you with %s from distance of %.2f meters", name,wpn,float(g_Killers[id][2]) * 0.0254 ) client_print(id,print_chat,"He did %d damage to you with %d hit(s) and still had %dhp", @@ -547,20 +547,20 @@ showStatsMenu(id,pos){ new menu_body[512], inum, k = 0, start = pos * MAX_MENUPOS get_players(g_userPlayers[id],inum) if (start >= inum) start = pos = g_userPosition[id] = 0 - new len = format(menu_body,511,"Server Stats %d/%d^n^n",pos + 1,((inum/MAX_MENUPOS)+((inum%MAX_MENUPOS)?1:0))) + new len = format(menu_body,charsmax(menu_body),"Server Stats %d/%d^n^n",pos + 1,((inum/MAX_MENUPOS)+((inum%MAX_MENUPOS)?1:0))) new name[MAX_NAME_LENGTH], end = start + MAX_MENUPOS, keys = (1<<9)|(1<<7) if (end > inum) end = inum for(new a = start; a < end; ++a){ - get_user_name(g_userPlayers[id][a],name,31) + get_user_name(g_userPlayers[id][a],name,charsmax(name)) keys |= (1< Date: Sun, 12 Oct 2014 00:59:08 +0200 Subject: [PATCH 28/30] Mapchooser: missing MAX_NAME_LENGTH --- plugins/ns/mapchooser.sma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ns/mapchooser.sma b/plugins/ns/mapchooser.sma index 7fc95db6..5c5bd33c 100755 --- a/plugins/ns/mapchooser.sma +++ b/plugins/ns/mapchooser.sma @@ -69,7 +69,7 @@ public checkVotes(){ public countVote(id,key){ if ( get_cvar_float("amx_vote_answers") ) { - new name[32] + new name[MAX_NAME_LENGTH] get_user_name(id,name,charsmax(name)) if ( key == SELECTMAPS ) client_print(0,print_chat,"%s chose map extending", name ) From 2db8156326e460914b21d5aa9aea85d41d046999 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sun, 12 Oct 2014 01:41:58 +0200 Subject: [PATCH 29/30] Plmenu: replace len hardcoded content by charsmax --- plugins/ns/plmenu.sma | 64 +++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/plugins/ns/plmenu.sma b/plugins/ns/plmenu.sma index dc70a14c..af70d5f3 100644 --- a/plugins/ns/plmenu.sma +++ b/plugins/ns/plmenu.sma @@ -151,15 +151,15 @@ public plugin_init() load_settings(clcmds_ini_file) // initialize the ns team names - copy(g_PrettyTeamNames[0], sizeof(g_PrettyTeamNames[]), "Ready Room"); - copy(g_TeamNames[0], sizeof(g_TeamNames[]), "undefinedteam"); - copy(g_TeamCommands[0], sizeof(g_TeamCommands[]), "readyroom;readyroom"); - copy(g_AbbreviatedTeamNames[0], sizeof(g_AbbreviatedTeamNames[]), "RR"); + copy(g_PrettyTeamNames[0], charsmax(g_PrettyTeamNames[]), "Ready Room"); + copy(g_TeamNames[0], charsmax(g_TeamNames[]), "undefinedteam"); + copy(g_TeamCommands[0], charsmax(g_TeamCommands[]), "readyroom;readyroom"); + copy(g_AbbreviatedTeamNames[0], charsmax(g_AbbreviatedTeamNames[]), "RR"); - copy(g_PrettyTeamNames[3], sizeof(g_PrettyTeamNames[]), "Spectators"); - copy(g_TeamNames[3], sizeof(g_TeamNames[]), "spectatorteam"); - copy(g_TeamCommands[3], sizeof(g_TeamCommands[]), "readyroom;readyroom;spectate"); - copy(g_AbbreviatedTeamNames[3], sizeof(g_AbbreviatedTeamNames[]), "SP"); + copy(g_PrettyTeamNames[3], charsmax(g_PrettyTeamNames[]), "Spectators"); + copy(g_TeamNames[3], charsmax(g_TeamNames[]), "spectatorteam"); + copy(g_TeamCommands[3], charsmax(g_TeamCommands[]), "readyroom;readyroom;spectate"); + copy(g_AbbreviatedTeamNames[3], charsmax(g_AbbreviatedTeamNames[]), "SP"); if (g_gametype == NSGame_CantTell || g_gametype == NSGame_Unknown) @@ -172,39 +172,39 @@ public plugin_init() { case NSGame_MarineVAlien: { - copy(g_TeamNames[1], sizeof(g_TeamNames[]), "marine1team"); - copy(g_PrettyTeamNames[1], sizeof(g_PrettyTeamNames[]), "Marines"); - copy(g_AbbreviatedTeamNames[1], sizeof(g_AbbreviatedTeamNames[]), "M"); - copy(g_TeamCommands[1], sizeof(g_TeamCommands[]), "readyroom;readyroom;jointeamone"); + copy(g_TeamNames[1], charsmax(g_TeamNames[]), "marine1team"); + copy(g_PrettyTeamNames[1], charsmax(g_PrettyTeamNames[]), "Marines"); + copy(g_AbbreviatedTeamNames[1], charsmax(g_AbbreviatedTeamNames[]), "M"); + copy(g_TeamCommands[1], charsmax(g_TeamCommands[]), "readyroom;readyroom;jointeamone"); - copy(g_TeamNames[2], sizeof(g_TeamNames[]), "alien1team"); - copy(g_PrettyTeamNames[2], sizeof(g_PrettyTeamNames[]), "Aliens"); - copy(g_AbbreviatedTeamNames[2], sizeof(g_AbbreviatedTeamNames[]), "A"); - copy(g_TeamCommands[2], sizeof(g_TeamCommands[]), "readyroom;readyroom;jointeamtwo"); + copy(g_TeamNames[2], charsmax(g_TeamNames[]), "alien1team"); + copy(g_PrettyTeamNames[2], charsmax(g_PrettyTeamNames[]), "Aliens"); + copy(g_AbbreviatedTeamNames[2], charsmax(g_AbbreviatedTeamNames[]), "A"); + copy(g_TeamCommands[2], charsmax(g_TeamCommands[]), "readyroom;readyroom;jointeamtwo"); } case NSGame_MarineVMarine: { - copy(g_TeamNames[1], sizeof(g_TeamNames[]), "marine1team"); - copy(g_PrettyTeamNames[1], sizeof(g_PrettyTeamNames[]), "Marine Team 1"); - copy(g_AbbreviatedTeamNames[1], sizeof(g_AbbreviatedTeamNames[]), "M1"); - copy(g_TeamCommands[1], sizeof(g_TeamCommands[]), "readyroom;readyroom;jointeamone"); + copy(g_TeamNames[1], charsmax(g_TeamNames[]), "marine1team"); + copy(g_PrettyTeamNames[1], charsmax(g_PrettyTeamNames[]), "Marine Team 1"); + copy(g_AbbreviatedTeamNames[1], charsmax(g_AbbreviatedTeamNames[]), "M1"); + copy(g_TeamCommands[1], charsmax(g_TeamCommands[]), "readyroom;readyroom;jointeamone"); - copy(g_TeamNames[2], sizeof(g_TeamNames[]), "marine2team"); - copy(g_PrettyTeamNames[2], sizeof(g_PrettyTeamNames[]), "Marine Team 2"); - copy(g_AbbreviatedTeamNames[2], sizeof(g_AbbreviatedTeamNames[]), "M2"); - copy(g_TeamCommands[2], sizeof(g_TeamCommands[]), "readyroom;readyroom;jointeamthree"); + copy(g_TeamNames[2], charsmax(g_TeamNames[]), "marine2team"); + copy(g_PrettyTeamNames[2], charsmax(g_PrettyTeamNames[]), "Marine Team 2"); + copy(g_AbbreviatedTeamNames[2], charsmax(g_AbbreviatedTeamNames[]), "M2"); + copy(g_TeamCommands[2], charsmax(g_TeamCommands[]), "readyroom;readyroom;jointeamthree"); } case NSGame_AlienVAlien: { - copy(g_TeamNames[1], sizeof(g_TeamNames[]), "alien1team"); - copy(g_PrettyTeamNames[1], sizeof(g_PrettyTeamNames[]), "Alien Team 1"); - copy(g_AbbreviatedTeamNames[1], sizeof(g_AbbreviatedTeamNames[]), "A1"); - copy(g_TeamCommands[1], sizeof(g_TeamCommands[]), "readyroom;readyroom;jointeamtwo"); + copy(g_TeamNames[1], charsmax(g_TeamNames[]), "alien1team"); + copy(g_PrettyTeamNames[1], charsmax(g_PrettyTeamNames[]), "Alien Team 1"); + copy(g_AbbreviatedTeamNames[1], charsmax(g_AbbreviatedTeamNames[]), "A1"); + copy(g_TeamCommands[1], charsmax(g_TeamCommands[]), "readyroom;readyroom;jointeamtwo"); - copy(g_TeamNames[2], sizeof(g_TeamNames[]), "alien2team"); - copy(g_PrettyTeamNames[2], sizeof(g_PrettyTeamNames[]), "Alien Team 2"); - copy(g_AbbreviatedTeamNames[2], sizeof(g_AbbreviatedTeamNames[]), "A2"); - copy(g_TeamCommands[2], sizeof(g_TeamCommands[]), "readyroom;readyroom;jointeamfour"); + copy(g_TeamNames[2], charsmax(g_TeamNames[]), "alien2team"); + copy(g_PrettyTeamNames[2], charsmax(g_PrettyTeamNames[]), "Alien Team 2"); + copy(g_AbbreviatedTeamNames[2], charsmax(g_AbbreviatedTeamNames[]), "A2"); + copy(g_TeamCommands[2], charsmax(g_TeamCommands[]), "readyroom;readyroom;jointeamfour"); } } From 94a4be95fe9e6cb09570534849e48af44c25e245 Mon Sep 17 00:00:00 2001 From: Freeman-AM Date: Sun, 12 Oct 2014 02:11:07 +0200 Subject: [PATCH 30/30] Nextmap: replace len hardcoded content by charsmax and sizeof --- plugins/ns/nextmap.sma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ns/nextmap.sma b/plugins/ns/nextmap.sma index 854f0987..3aff535d 100755 --- a/plugins/ns/nextmap.sma +++ b/plugins/ns/nextmap.sma @@ -238,7 +238,7 @@ public sayNextMap(){ public sayNextMapTimeLeft(){ new szName[32], szText[128] get_cvar_string("amx_nextmap", szName, charsmax(szName)) - format(szText, 64, "Next Map: %s", szName) + format(szText, charsmax(szText), "Next Map: %s", szName) if (get_cvar_float("mp_timelimit")) { new a = get_timeleft()