aboutsummaryrefslogtreecommitdiff
path: root/builtin
Commit message (Expand)AuthorAge
* Update creditsCraig Robbins2015-03-29
* Remove duplicate code since 8ca08a850ff2494652aa0ac2daa3d00f03aa4e7aLoic Blot2015-03-25
* Save creative_mode and enable_damage setting for each world in world.mtfz722015-03-18
* Android: Fix auto-entry of server address and port in mainmenuest312015-03-16
* Radius parameter for /deleteblocks hereSmallJoker2015-03-05
* Add /setpassword and /clearpassword loggingest312015-02-27
* Fix serialization of floating point numbersShadowNinja2015-02-21
* Add modname convention checkingNovatux2015-02-18
* Server: announce MIN/MAX protocol version supported to serverlist. Client: ch...est312015-02-18
* Use fixed size for builtin menus on non-android platformsPerttu Ahola2015-02-18
* Fix unused (and so, broken) enable_rollback_recording. This option must be re...Loic Blot2015-02-18
* Fix map_seed not changed when creating a new world after login to anotherfz722015-02-18
* Fix minetest.item_eat's replace_with_item, fixes #2292rubenwardy2015-02-16
* Fix issue #2278, Connection sent before address data loadingLoic Blot2015-02-14
* Fix crash on passing false as value in table to table.copy(t)est312015-02-14
* Minor fixes in translationsngosang2015-02-12
* Fix store.lua bug: default screenshotRui2015-02-12
* Fix tab_mods.lua: default screenshot patchRui2015-02-12
* Fix 'Download complete' dialog in the mods storengosang2015-02-11
* Hud: Modify Y-positioning of health/breath starbars to prevent overlapping wi...kwolekr2015-02-08
* Change assignment to global in a function to warningrubenwardy2015-02-04
* Prevent null concatenation when /deleteblocks is provided an incorrect formatkwolekr2015-01-27
* Fix imprecise serialization of large numbersShadowNinja2015-01-25
* Allow filter and mipmap drop down menues to be translatedCraig Robbins2015-01-21
* Reorganize supported video driver query mechanismskwolekr2015-01-18
* Revert "Fix style on settings tab"kwolekr2015-01-18
* Fix style on settings tabjeanpatrick.guerrero@gmail.com2015-01-18
* Simplify deleteblocks chat command argument parsingkwolekr2015-01-15
* Add ability to delete MapBlocks from mapkwolekr2015-01-15
* Fix typo in `serialize.lua`.Diego Martínez2015-01-15
* Add missing return value for filter/mipmap dropdown in mainmenukilbith2015-01-15
* Small tweaking (alignement - client tab)kilbith2015-01-15
* Reorganizing client and server tabsjeanpatrick.guerrero@gmail.com2015-01-15
* builtin: Unify register wrapper functions and wrap clear_registered_* functio...kwolekr2015-01-13
* Remove builtin_biome.lua from builtin and add simple biome minimalparamat2015-01-11
* Remove automatic consistent formspec size <-> font size (now has to be done m...sapier2015-01-09
* Add registered_ores and registered_decorationsShadowNinja2015-01-05
* Fix off-by-one error in `string:split` implementation.Diego Martínez2015-01-04
* Fix forgotten favourite list image update of simple menusapier2015-01-04
* Re-add lost way to debug simple menu on PCsapier2015-01-04
* Add core.get_mapgen_names() to Main Menu API (and use it)kwolekr2014-12-29
* Expose mapgen parameters on scripting initkwolekr2014-12-29
* Ignore downloaded public serverlist if public_serverlist is falseKahrl2014-12-30
* Faster string.split implementation.Diego Martinez2014-12-28
* MainMenu: Save 'hide gamemods' and 'hide modpack contents' checkbox state (fi...fz722014-12-28
* Temporarily set default biome in builtinkwolekr2014-12-18
* Remove vertlabels from main menu and relayout a bitKahrl2014-12-13
* Display serverlist flags as iconsKahrl2014-12-13
* Revert "Adjust the values of dirs1 and dirs2 so that rotate_and_place orients...Craig Robbins2014-12-12
* Fix undeclared globals in functions and shorten lines in misc_helpers.lua.paramat2014-12-11
>(true); TEST(testMtsSerializeDeserialize, ndef); TEST(testLuaTableSerialize, ndef); TEST(testFileSerializeDeserialize, ndef); ndef->resetNodeResolveState(); } //////////////////////////////////////////////////////////////////////////////// void TestSchematic::testMtsSerializeDeserialize(const NodeDefManager *ndef) { static const v3s16 size(7, 6, 4); static const u32 volume = size.X * size.Y * size.Z; std::stringstream ss(std::ios_base::binary | std::ios_base::in | std::ios_base::out); std::vector<std::string> names; names.emplace_back("foo"); names.emplace_back("bar"); names.emplace_back("baz"); names.emplace_back("qux"); Schematic schem, schem2; schem.flags = 0; schem.size = size; schem.schemdata = new MapNode[volume]; schem.slice_probs = new u8[size.Y]; for (size_t i = 0; i != volume; i++) schem.schemdata[i] = MapNode(test_schem1_data[i], MTSCHEM_PROB_ALWAYS, 0); for (s16 y = 0; y != size.Y; y++) schem.slice_probs[y] = MTSCHEM_PROB_ALWAYS; UASSERT(schem.serializeToMts(&ss, names)); ss.seekg(0); names.clear(); UASSERT(schem2.deserializeFromMts(&ss, &names)); UASSERTEQ(size_t, names.size(), 4); UASSERTEQ(std::string, names[0], "foo"); UASSERTEQ(std::string, names[1], "bar"); UASSERTEQ(std::string, names[2], "baz"); UASSERTEQ(std::string, names[3], "qux"); UASSERT(schem2.size == size); for (size_t i = 0; i != volume; i++) UASSERT(schem2.schemdata[i] == schem.schemdata[i]); for (s16 y = 0; y != size.Y; y++) UASSERTEQ(u8, schem2.slice_probs[y], schem.slice_probs[y]); } void TestSchematic::testLuaTableSerialize(const NodeDefManager *ndef) { static const v3s16 size(3, 3, 3); static const u32 volume = size.X * size.Y * size.Z; Schematic schem; schem.flags = 0; schem.size = size; schem.schemdata = new MapNode[volume]; schem.slice_probs = new u8[size.Y]; for (size_t i = 0; i != volume; i++) schem.schemdata[i] = MapNode(test_schem2_data[i], test_schem2_prob[i], 0); for (s16 y = 0; y != size.Y; y++) schem.slice_probs[y] = MTSCHEM_PROB_ALWAYS; std::vector<std::string> names; names.emplace_back("air"); names.emplace_back("default:lava_source"); names.emplace_back("default:glass"); std::ostringstream ss(std::ios_base::binary); UASSERT(schem.serializeToLua(&ss, names, false, 0)); UASSERTEQ(std::string, ss.str(), expected_lua_output); } void TestSchematic::testFileSerializeDeserialize(const NodeDefManager *ndef) { static const v3s16 size(3, 3, 3); static const u32 volume = size.X * size.Y * size.Z; static const content_t content_map[] = { CONTENT_AIR, t_CONTENT_STONE, t_CONTENT_LAVA, }; static const content_t content_map2[] = { CONTENT_AIR, t_CONTENT_STONE, t_CONTENT_WATER, }; StringMap replace_names; replace_names["default:lava"] = "default:water"; Schematic schem1, schem2; //// Construct the schematic to save schem1.flags = 0; schem1.size = size; schem1.schemdata = new MapNode[volume]; schem1.slice_probs = new u8[size.Y]; schem1.slice_probs[0] = 80; schem1.slice_probs[1] = 160; schem1.slice_probs[2] = 240; for (size_t i = 0; i != volume; i++) { content_t c = content_map[test_schem2_data[i]]; schem1.schemdata[i] = MapNode(c, test_schem2_prob[i], 0); } std::string temp_file = getTestTempFile(); UASSERT(schem1.saveSchematicToFile(temp_file, ndef)); UASSERT(schem2.loadSchematicFromFile(temp_file, ndef, &replace_names)); UASSERT(schem2.size == size); UASSERT(schem2.slice_probs[0] == 80); UASSERT(schem2.slice_probs[1] == 160); UASSERT(schem2.slice_probs[2] == 240); for (size_t i = 0; i != volume; i++) { content_t c = content_map2[test_schem2_data[i]]; UASSERT(schem2.schemdata[i] == MapNode(c, test_schem2_prob[i], 0)); } } // Should form a cross-shaped-thing...? const content_t TestSchematic::test_schem1_data[7 * 6 * 4] = { 3, 3, 1, 1, 1, 3, 3, // Y=0, Z=0 3, 0, 1, 2, 1, 0, 3, // Y=1, Z=0 3, 0, 1, 2, 1, 0, 3, // Y=2, Z=0 3, 1, 1, 2, 1, 1, 3, // Y=3, Z=0 3, 2, 2, 2, 2, 2, 3, // Y=4, Z=0 3, 1, 1, 2, 1, 1, 3, // Y=5, Z=0 0, 0, 1, 1, 1, 0, 0, // Y=0, Z=1 0, 0, 1, 2, 1, 0, 0, // Y=1, Z=1 0, 0, 1, 2, 1, 0, 0, // Y=2, Z=1 1, 1, 1, 2, 1, 1, 1, // Y=3, Z=1 1, 2, 2, 2, 2, 2, 1, // Y=4, Z=1 1, 1, 1, 2, 1, 1, 1, // Y=5, Z=1 0, 0, 1, 1, 1, 0, 0, // Y=0, Z=2 0, 0, 1, 2, 1, 0, 0, // Y=1, Z=2 0, 0, 1, 2, 1, 0, 0, // Y=2, Z=2 1, 1, 1, 2, 1, 1, 1, // Y=3, Z=2 1, 2, 2, 2, 2, 2, 1, // Y=4, Z=2 1, 1, 1, 2, 1, 1, 1, // Y=5, Z=2 3, 3, 1, 1, 1, 3, 3, // Y=0, Z=3 3, 0, 1, 2, 1, 0, 3, // Y=1, Z=3 3, 0, 1, 2, 1, 0, 3, // Y=2, Z=3 3, 1, 1, 2, 1, 1, 3, // Y=3, Z=3 3, 2, 2, 2, 2, 2, 3, // Y=4, Z=3 3, 1, 1, 2, 1, 1, 3, // Y=5, Z=3 }; const content_t TestSchematic::test_schem2_data[3 * 3 * 3] = { 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 2, 1, 2, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, }; const u8 TestSchematic::test_schem2_prob[3 * 3 * 3] = { 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, }; const char *TestSchematic::expected_lua_output = "schematic = {\n" "\tsize = {x=3, y=3, z=3},\n" "\tyslice_prob = {\n" "\t\t{ypos=0, prob=254},\n" "\t\t{ypos=1, prob=254},\n" "\t\t{ypos=2, prob=254},\n" "\t},\n" "\tdata = {\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"default:glass\", prob=254, param2=0, force_place=true},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"default:glass\", prob=254, param2=0, force_place=true},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"default:glass\", prob=254, param2=0, force_place=true},\n" "\t\t{name=\"default:lava_source\", prob=254, param2=0, force_place=true},\n" "\t\t{name=\"default:glass\", prob=254, param2=0, force_place=true},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"default:glass\", prob=254, param2=0, force_place=true},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"default:glass\", prob=254, param2=0, force_place=true},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t\t{name=\"air\", prob=0, param2=0},\n" "\t},\n" "}\n";