aboutsummaryrefslogtreecommitdiff
path: root/src/content_mapnode.h
Commit message (Collapse)AuthorAge
* Update Copyright YearsSfan52013-02-24
|
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
|
* Fix map deserialization and remove old serialization codePerttu Ahola2012-07-23
|
* Switch the license to be LGPLv2/later, with small parts still remaining as ↵Perttu Ahola2012-06-05
| | | | GPLv2/later, by agreement of major contributors
* The huge item definition and item namespace unification patch (itemdef), see ↵Kahrl2012-01-12
| | | | http://c55.me/minetest/wiki/doku.php?id=changes:itemdef
* Add node definitions in Lua and do not use content_mapnode_init anymore ↵Kahrl2011-11-29
| | | | (except in test.cpp)
* Do not expose CONTENT_* stuff in content_mapnode.h and use a name converter ↵Perttu Ahola2011-11-29
| | | | wrapper in old code
* Node definition namesPerttu Ahola2011-11-29
|
* Completely generalized mesh generation; ContentFeatures serializationPerttu Ahola2011-11-29
|
* GameDef compilesPerttu Ahola2011-11-29
|
* Create framework for getting rid of global definitions of ↵Perttu Ahola2011-11-29
| | | | node/tool/item/whatever types
* Move ContentFeatures to mapnode_contentfeatures.{h,cpp} and clean stuffPerttu Ahola2011-11-29
|
* Merge remote-tracking branch 'marktraceur/master'Perttu Ahola2011-09-26
|\
| * Adding (most) of the sapling functionality. It has yet to work, since ↵Mark Holmquist2011-09-23
| | | | | | | | MEET_OTHER was not implemented at the time of this commit. Hopefully it will work when merged with celeron's latest.
* | added locking chests - clean patchdarkrose2011-09-22
|/
* Removed Spacessfan52011-09-11
|
* Added Apple Treessfan52011-09-11
|
* lava!Perttu Ahola2011-08-15
|
* Changing CONTENT_LADDER to be an extended blockMark Holmquist2011-08-01
|
* Added ladders--they don't have any use yet, thoughMark Holmquist2011-08-01
|
* Added MaterialItem conversion from old content type namespace to newPerttu Ahola2011-07-31
|
* Fixed handling of inventory in creative mode (normal inventory is not ↵Perttu Ahola2011-07-30
| | | | trashed anymore), fixed mese pick speed, added some forgotten stuff
* changed jungletree/junglegrass content ids to extended rangePerttu Ahola2011-07-24
|
* merged jungle and bluish shadowsPerttu Ahola2011-07-23
|\
| * Jungle biome/whatever thingPerttu Ahola2011-07-23
| |
* | merged the content type extension and deltaPerttu Ahola2011-07-23
|\|
| * Merge branch 'master' of https://github.com/erlehmann/minetest-delta.git ↵Sebastian Rühl2011-06-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | into upstream_merge Conflicts: .gitignore CMakeLists.txt data/heart.png src/CMakeLists.txt src/game.cpp src/guiMainMenu.cpp src/inventory.cpp src/map.cpp src/mapblock.cpp src/mapnode.cpp src/mapnode.h src/materials.cpp src/server.cpp Signed-off-by: Sebastian Rühl <bahamada_basti@yahoo.de>
* | extended content-type rangePerttu Ahola2011-07-23
|/
* New map generator added (and SQLite, messed up the commits at that time...) ↵Perttu Ahola2011-06-25
| | | | (import from temporary git repo)
* Moved some mapnode content stuff from mapnode.{h,cpp} and digging property ↵Perttu Ahola2011-06-17
stuff from material.cpp to content_mapnode.{h,cpp}
n class="hl opt">, "&:") rstr = string.gsub(rstr, "\n", "&n") return rstr end ------ local read_table, string_to_value, unescape_chars function read_table(t, file) local line, ks, vs, kv, vv, vt while true do line = file:read("*l") if not line then file:close() error("Unexpected EOF or read error!") end if line=="E" then -- done with this table return end ks, vs = string.match(line, "^(.*[^&]):(.+)$") if not ks or not vs then file:close() error("Unable to parse line: '"..line.."'!") end kv = string_to_value(ks) vv, vt = string_to_value(vs, true) if vt then read_table(vv, file) end -- put read value in table t[kv] = vv end end -- returns: value, is_table function string_to_value(str, table_allow) local first = string.sub(str, 1,1) local rest = string.sub(str, 2) if first=="T" then if table_allow then return {}, true else file:close() error("Table not allowed in key component!") end elseif first=="N" then local num = tonumber(rest) if num then return num else file:close() error("Unable to parse number: '"..rest.."'!") end elseif first=="B" then if rest=="0" then return false elseif rest=="1" then return true else file:close() error("Unable to parse boolean: '"..rest.."'!") end elseif first=="S" then return unescape_chars(rest) else file:close() error("Unknown literal type '"..first.."' for literal '"..str.."'!") end end function unescape_chars(str) --TODO local rstr = string.gsub(str, "&:", ":") rstr = string.gsub(rstr, "&n", "\n") rstr = string.gsub(rstr, "&&", "&") return rstr end ------ --[[ config = { skip_empty_tables = false -- if true, does not store empty tables -- On next read, keys that mapped to empty tables resolve to nil } ]] -- Writes the passed table into the passed file descriptor, and closes the file local function write_to_fd(root_table, file, config) file:write("LUA_SER v=1\n") write_table(root_table, file, config) file:write("E\nEND_SER\n") file:close() end -- Reads the file contents from the passed file descriptor and returns the table on success -- Throws errors when something is wrong. Closes the file. -- config: see above local function read_from_fd(file) local first_line = file:read("*l") if first_line ~= "LUA_SER v=1" then file:close() error("Expected header, got '"..first_line.."' instead!") end local t = {} read_table(t, file) local last_line = file:read("*l") file:close() if last_line ~= "END_SER" then error("Missing END_SER, got '"..last_line.."' instead!") end return t end -- Opens the passed filename and serializes root_table into it -- config: see above function write_to_file(root_table, filename, config) -- try opening the file local file, err = io.open(filename, "w") if not file then error("Failed opening file '"..filename.."' for write:\n"..err) end write_to_fd(root_table, file, config) return true end -- Opens the passed filename, and returns its deserialized contents function read_from_file(filename) -- try opening the file local file, err = io.open(filename, "r") if not file then error("Failed opening file '"..filename.."' for read:\n"..err) end return read_from_fd(file) end --[[ simple unit test local testtable = { key = "value", [1] = "eins", [true] = { a = "b", c = false, }, ["es:cape1"] = "foo:bar", ["es&ca\npe2"] = "baz&bam\nbim", ["es&&ca&\npe3"] = "baz&&bam&\nbim", ["es&:cape4"] = "foo\n:bar" } local config = {} --write_to_file(testtable, "test_out", config) local t = read_from_file("test_out") write_to_file(t, "test_out_2", config) local t2 = read_from_file("test_out_2") write_to_file(t2, "test_out_3", config) -- test_out_2 and test_out_3 should be equal --]] return { read_from_fd = read_from_fd, write_to_fd = write_to_fd, read_from_file = read_from_file, write_to_file = write_to_file, }