aboutsummaryrefslogtreecommitdiff
path: root/src/util
Commit message (Expand)AuthorAge
* Value copy / allocation optimizations mostly in server, SAO and serialize codesfan52020-05-27
* Modernize include guards and add missing ones (#9898)Awkor2020-05-23
* Add MetricsBackend with prometheus counter supportLoic Blot2020-04-29
* Fix truncation warning for F1000_MIN, F1000_MAXsfan52020-04-27
* Add server side translations capability (#9733)EvidenceB Kidscode2020-04-25
* Android: fix handling non-latin characters on older Android devices (#9309)Maksim2020-04-17
* Formspecs: Add state-selection to style elements (#9378)Hugues Ross2020-04-11
* GUIHyperText: Fix bug with UTF8 chars in action name + simplify UTF8 stringw ...Jean-Patrick Guerrero2020-03-07
* EnrichedString: Fix substr segfault caused by non-formatted textSmallJoker2020-01-24
* EnrichedString: Fix uninitialized variable m_default_lengthSmallJoker2020-01-23
* StaticText/EnrichedString: Styling support (#9187)SmallJoker2020-01-22
* Android: fix cyrillic characters, update iconv lib (#9117)Maksim2020-01-13
* Formspec: add hypertext elementPierre-Yves Rollo2019-11-03
* Move Quicktune code to util/ (#8871)ANAND2019-09-29
* Fix AreaStore's IDs persistence (#8888)SmallJoker2019-09-21
* util/hex.h: Remove whitespace-only line (#8460)ANAND2019-04-08
* util/hex.h: Reserve result space in hex_encode()starling132019-04-07
* numeric: Fix clang, broken since d5456daSmallJoker2019-02-09
* Use true pitch/yaw/roll rotations without loss of precision by pgimeno (#8019)Paul Ouellette2019-02-07
* DragonFly BSD is somewhat identical to FreeBSD (#8159)Leonid Bobrov2019-02-03
* Drop libgmp on Android and use mini-gmp (#8047)Loïc Blot2019-01-04
* Proselytize the network. Use IEEE F32 (#8030)SmallJoker2019-01-03
* ieee_float: Silence compiler warningSmallJoker2018-12-18
* Network: Send IEEE floats (#7768)SmallJoker2018-12-13
* Add Lua methods 'set_rotation()' and 'get_rotation()' (#7395)CoderForTheBetter2018-11-28
* Light curve: Simplify and improve code, fix darkened daytime sky (#7693)Vitaliy2018-09-16
* Raycast: export exact pointing location (#6304)Dániel Juhász2018-08-16
* Replace auth.txt with SQLite auth database (#7279)Ben Deutsch2018-08-05
* Smoothed yaw rotation for objects (#6825)SmallJoker2018-08-02
* Fix build on gcc 5.0 (#7586)zeuner2018-07-26
* Fix memory leak in guiConfirmRegistrationHybridDog2018-07-06
* Fix buffer overrun in SRP (#7484)red-0012018-06-26
* Fix MurmurHash implementation to really be unaligned (#7482)sfan52018-06-26
* Use server's zoom fov for distant world loading.Lars Hofhansl2018-05-15
* Formspecs: Allow setting alpha value for the box[] elementThomas--S2018-04-23
* Zoom adjustDist(): Improve variable name (#7208)Paramat2018-04-05
* Fix last performance-type-promotion-in-math-fn problemsLoic Blot2018-04-04
* Optimize a little bit isBlockInSight, adjustDist & collisions (#7193)Loïc Blot2018-04-04
* Fix last clang-tidy reported problems for performance-type-promotion-in-math-fnLoic Blot2018-04-03
* Fix various clang-tidy reported performance-type-promotion-in-math-fnLoïc Blot2018-04-03
* Revert "Add an active object step time budget #6721"Lars Hofhansl2018-01-12
* Fix Wstringop-overflow warning from util/srp.cpp (#6855)you2018-01-04
* Fix rounding error in g/set_node caused by truncation to floatrubenwardy2017-12-26
* directiontables: Fix MSVC compiler error (#6785)adrido2017-12-14
* Add an active object step time budget #6721Lars Hofhansl2017-12-06
* Allow zoom to actually show more data.Lars Hofhansl2017-11-15
* Move files to subdirectories (#6599)Vitaliy2017-11-08
* directiontables.cpp: fix a warning reported by VS2017Loic Blot2017-10-17
* Real global textures (#6105)Vitaliy2017-10-15
* Use a Buffer instead of SharedBuffer in ConnectionCommandLoic Blot2017-09-05
> else mark_multiple_occurences(k) mark_multiple_occurences(v) end end nested[x] = nil end end local dumped = {} -- object->varname set local local_defs = {} -- Dumped local definitions as source code lines -- Mutually recursive local functions: local dump_val, dump_or_ref_val -- If x occurs multiple times, dump the local variable rather than -- the value. If it's the first time it's dumped, also dump the -- content in local_defs. function dump_or_ref_val(x) if seen[x] ~= 2 then return dump_val(x) end local var = dumped[x] if var then -- Already referenced return var end -- First occurence, create and register reference local val = dump_val(x) local i = local_index local_index = local_index + 1 var = "_["..i.."]" table.insert(local_defs, var.." = "..val) dumped[x] = var return var end -- Second phase. Dump the object; subparts occuring multiple times -- are dumped in local variables which can be referenced multiple -- times. Care is taken to dump local vars in a sensible order. function dump_val(x) local tp = type(x) if x == nil then return "nil" elseif tp == "number" then return tostring(x) elseif tp == "string" then return string.format("%q", x) elseif tp == "boolean" then return x and "true" or "false" elseif tp == "function" then return string.format("loadstring(%q)", string.dump(x)) elseif tp == "table" then local vals = {} local idx_dumped = {} local np = nest_points[x] for i, v in ipairs(x) do if not np or not np[i] then table.insert(vals, dump_or_ref_val(v)) end idx_dumped[i] = true end for k, v in pairs(x) do if (not np or not np[k]) and not idx_dumped[k] then table.insert(vals, "["..dump_or_ref_val(k).."] = " ..dump_or_ref_val(v)) end end return "{"..table.concat(vals, ", ").."}" else error("Can't serialize data of type "..t) end end local function dump_nest_points() for parent, vals in pairs(nest_points) do for k, v in pairs(vals) do table.insert(local_defs, dump_or_ref_val(parent) .."["..dump_or_ref_val(k).."] = " ..dump_or_ref_val(v)) end end end mark_multiple_occurences(x) local top_level = dump_or_ref_val(x) dump_nest_points() if next(local_defs) then return "local _ = {}\n" ..table.concat(local_defs, "\n") .."\nreturn "..top_level else return "return "..top_level end end -- Deserialization local env = { loadstring = loadstring, } local safe_env = { loadstring = function() end, } function core.deserialize(str, safe) if str:byte(1) == 0x1B then return nil, "Bytecode prohibited" end local f, err = loadstring(str) if not f then return nil, err end setfenv(f, safe and safe_env or env) local good, data = pcall(f) if good then return data else return nil, data end end -- Unit tests local test_in = {cat={sound="nyan", speed=400}, dog={sound="woof"}} local test_out = core.deserialize(core.serialize(test_in)) assert(test_in.cat.sound == test_out.cat.sound) assert(test_in.cat.speed == test_out.cat.speed) assert(test_in.dog.sound == test_out.dog.sound) test_in = {escape_chars="\n\r\t\v\\\"\'", non_european="θשׁ٩∂"} test_out = core.deserialize(core.serialize(test_in)) assert(test_in.escape_chars == test_out.escape_chars) assert(test_in.non_european == test_out.non_european)