From 3d47263417916e4b0c898317dd5d1ce7954dc04b Mon Sep 17 00:00:00 2001 From: pegasusot Date: Thu, 12 Dec 2024 01:00:30 -0300 Subject: [PATCH] Increased character limit for character name --- data/modules/scripts/gamestore/init.lua | 137 +++++++++++++----------- src/game/game.cpp | 2 +- 2 files changed, 73 insertions(+), 66 deletions(-) diff --git a/data/modules/scripts/gamestore/init.lua b/data/modules/scripts/gamestore/init.lua index 433abf34492..3998dde7881 100644 --- a/data/modules/scripts/gamestore/init.lua +++ b/data/modules/scripts/gamestore/init.lua @@ -1484,72 +1484,79 @@ GameStore.canUseHirelingName = function(name) end GameStore.canChangeToName = function(name) - local result = { - ability = false, - } - if name:len() < 3 or name:len() > 18 then - result.reason = "The length of your new name must be between 3 and 18 characters." - return result - end - - local match = name:gmatch("%s+") - local count = 0 - for v in match do - count = count + 1 - end - - local matchtwo = name:match("^%s+") - if matchtwo then - result.reason = "Your new name can't have whitespace at begin." - return result - end - - if count > 1 then - result.reason = "Your new name have more than 1 whitespace." - return result - end - + local result = { + ability = false, + } + + if name:len() < 3 or name:len() > 29 then + result.reason = "The length of your new name must be between 3 and 29 characters." + return result + end + + local match = name:gmatch("%s+") + local count = 0 + for _ in match do + count = count + 1 + end + + local matchtwo = name:match("^%s+") + if matchtwo then + result.reason = "Your new name can't have whitespace at the beginning." + return result + end + + if count > 2 then + result.reason = "Your new name can't have more than 2 spaces." + return result + end + + if name:match("%s%s") then + result.reason = "Your new name can't have consecutive spaces." + return result + end + -- just copied from znote aac. - local words = { "owner", "gamemaster", "hoster", "admin", "staff", "tibia", "account", "god", "anal", "ass", "fuck", "sex", "hitler", "pussy", "dick", "rape", "adm", "cm", "gm", "tutor", "counsellor" } - local split = name:split(" ") - for k, word in ipairs(words) do - for k, nameWord in ipairs(split) do - if nameWord:lower() == word then - result.reason = "You can't use word \"" .. word .. '" in your new name.' - return result - end - end - end - - local tmpName = name:gsub("%s+", "") - for i = 1, #words do - if tmpName:lower():find(words[i]) then - result.reason = "You can't use word \"" .. words[i] .. '" with whitespace in your new name.' - return result - end - end - - if MonsterType(name) then - result.reason = 'Your new name "' .. name .. "\" can't be a monster's name." - return result - elseif Npc(name) then - result.reason = 'Your new name "' .. name .. "\" can't be a npc's name." - return result - end - - local letters = "{}|_*+-=<>0123456789@#%^&()/*'\\.,:;~!\"$" - for i = 1, letters:len() do - local c = letters:sub(i, i) - for i = 1, name:len() do - local m = name:sub(i, i) - if m == c then - result.reason = "You can't use this letter \"" .. c .. '" in your new name.' - return result - end - end - end - result.ability = true - return result + local words = { "owner", "gamemaster", "hoster", "admin", "staff", "tibia", "account", "god", "anal", "ass", "fuck", "sex", "hitler", "pussy", "dick", "rape", "adm", "cm", "gm", "tutor", "counsellor" } + local split = name:split(" ") + for _, word in ipairs(words) do + for _, nameWord in ipairs(split) do + if nameWord:lower() == word then + result.reason = "You can't use the word '" .. word .. "' in your new name." + return result + end + end + end + + local tmpName = name:gsub("%s+", "") + for _, word in ipairs(words) do + if tmpName:lower():find(word) then + result.reason = "You can't use the word '" .. word .. "' even with spaces in your new name." + return result + end + end + + if MonsterType(name) then + result.reason = "Your new name '" .. name .. "' can't be a monster's name." + return result + elseif Npc(name) then + result.reason = "Your new name '" .. name .. "' can't be an NPC's name." + return result + end + + local letters = "{}|_*+-=<>0123456789@#%^&()/*'\\.,:;~!\"$" + for i = 1, letters:len() do + local c = letters:sub(i, i) + for j = 1, name:len() do + local m = name:sub(j, j) + if m == c then + result.reason = "You can't use this character '" .. c .. "' in your new name." + return result + end + end + end + + result.ability = true + return result end -- diff --git a/src/game/game.cpp b/src/game/game.cpp index 5c7dc7aaf16..69c5d09e2f8 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -1092,7 +1092,7 @@ std::string Game::getPlayerNameByGUID(const uint32_t &guid) { ReturnValue Game::getPlayerByNameWildcard(const std::string &s, std::shared_ptr &player) { size_t strlen = s.length(); - if (strlen == 0 || strlen > 20) { + if (strlen == 0 || strlen > 29) { return RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE; }