From c245822abbf0d472587507b7478ace0a1117b6e8 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 15 Sep 2014 17:42:24 +0200 Subject: [PATCH] Fix r2ed --- .../client/src/interface_v3/lua_ihm_ryzom.cpp | 1 - code/ryzom/common/data_common/r2/r2_misc.lua | 45 ++++++++++++++----- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp index 996bd698a..fe4c6a716 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm_ryzom.cpp @@ -1931,7 +1931,6 @@ void CLuaIHMRyzom::rawDebugInfo(const std::string &dbg) #endif pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(dbg)); } - nldebug("LUA: '%s'", dbg.c_str()); } diff --git a/code/ryzom/common/data_common/r2/r2_misc.lua b/code/ryzom/common/data_common/r2/r2_misc.lua index f3c9fa865..827e91579 100644 --- a/code/ryzom/common/data_common/r2/r2_misc.lua +++ b/code/ryzom/common/data_common/r2/r2_misc.lua @@ -28,12 +28,26 @@ function forEach(table, fn) end end + +------------------------------------------------------------------------------------------------------------ +-- whatever +table.setn = function(table, n) + assert(table) + local mt = getmetatable(table) + if mt ~= nil then + if mt.__next ~= nil then + table.Size = n + end + end +end + ------------------------------------------------------------------------------------------------------------ -- extension to table library : remove all content of a table without deleting the table object function table.clear(tbl) while next(tbl) do - table.remove(tbl, next(tbl)) + tbl[next(tbl)] = nil end + table.setn(tbl, 0) end ------------------------------------------------------------------------------------------------------------ @@ -177,12 +191,12 @@ end ------------------------------------------------------------------------------------------------- -- enclose a string by double quotes function strifyXml(str) - strxml = string.gsub(str, ">", ">") + local strxml = string.gsub(tostring(str), ">", ">") strxml = string.gsub(strxml, "<", "<") strxml = string.gsub(strxml, "&", "&") strxml = string.gsub(strxml, "'", "'") strxml = string.gsub(strxml, '"', """) - return [["]] .. tostring(strxml) .. [["]] + return [["]] .. strxml .. [["]] end ------------------------------------------------------------------------------------------------------------ @@ -261,26 +275,37 @@ end -assert(table.getn ~= nil) -- default lib should have been opened +-- assert(table.getn ~= nil) -- default lib should have been opened + +--if oldTableGetnFunction == nil then +-- oldTableGetnFunction = table.getn +--end +-- +--table.getn = function(table) +-- assert(table) +-- local mt = getmetatable(table) +-- if mt ~= nil then +-- if mt.__next ~= nil then +-- return table.Size +-- end +-- end +-- return oldTableGetnFunction(table) +--end -if oldTableGetnFunction == nil then - oldTableGetnFunction = table.getn -end table.getn = function(table) assert(table) local mt = getmetatable(table) if mt ~= nil then if mt.__next ~= nil then - return table.Size + return table.Size end end - return oldTableGetnFunction(table) + return #table end - -- redefine the hardcoded 'pairs' function to use the redefined 'next' -- hardcoded version uses the C version of next, not the lua one if it has been redefined