From 8119428d41854b6d1d48265a68b58675a6bc6a46 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Thu, 4 Oct 2012 19:35:02 -0300 Subject: [PATCH] Fix issue #90 --- modules/corelib/string.lua | 4 ++++ modules/gamelib/game.lua | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/corelib/string.lua b/modules/corelib/string.lua index c3627dce..88bd869a 100644 --- a/modules/corelib/string.lua +++ b/modules/corelib/string.lua @@ -20,6 +20,10 @@ function string:starts(start) return string.sub(self, 1, #start) == start end +function string.ends(s, test) + return test =='' or string.sub(s,-string.len(test)) == test +end + function string:trim() return string.match(self, '^%s*(.*%S)') or '' end diff --git a/modules/gamelib/game.lua b/modules/gamelib/game.lua index 401a01e7..809a935f 100644 --- a/modules/gamelib/game.lua +++ b/modules/gamelib/game.lua @@ -10,7 +10,7 @@ function g_game.isCreatureNameFormatEnabled() end function g_game.chooseRsa(host) - if host:match('.*\.tibia\.com') or host:match('.*\.cipsoft\.com') then + if string.ends(host, '.tibia.com') or string.ends(host, '.cipsoft.com') then g_game.setRsa(CIPSOFT_RSA) else g_game.setRsa(OTSERV_RSA)