Compare commits
74 Commits
0.4.dev-20
...
0.4.dev-20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a8eb68142e | ||
|
|
81554fbf72 | ||
|
|
a435cfcd82 | ||
|
|
7631918a12 | ||
|
|
e070f1e525 | ||
|
|
430d6e1cca | ||
|
|
3a0562bebc | ||
|
|
c3658e7c79 | ||
|
|
b0f81c3253 | ||
|
|
31c171fc1e | ||
|
|
e9c123b1b9 | ||
|
|
037b259197 | ||
|
|
a569961e0f | ||
|
|
7eabde6aee | ||
|
|
ed772da0cc | ||
|
|
f48882213e | ||
|
|
1cd2076d42 | ||
|
|
816b9c8d71 | ||
|
|
3bea1a944e | ||
|
|
3e419ffb38 | ||
|
|
a149c6ecde | ||
|
|
3f18e9a2da | ||
|
|
4b0494062e | ||
|
|
a09d86dd3c | ||
|
|
3ccb0f691b | ||
|
|
1709fd854a | ||
|
|
7bf446f671 | ||
|
|
e4bc76f55c | ||
|
|
81c5e5200b | ||
|
|
9c3830dd35 | ||
|
|
bf8cfce50e | ||
|
|
b235e4d290 | ||
|
|
b8cf6dee3e | ||
|
|
35df1ee253 | ||
|
|
353f9fd43c | ||
|
|
3899f83da8 | ||
|
|
5f3c70061d | ||
|
|
aba7134301 | ||
|
|
d7447cdf9e | ||
|
|
ff8d2bbc36 | ||
|
|
70c98c9972 | ||
|
|
45f32838b9 | ||
|
|
7d6e80a423 | ||
|
|
f3ec1452cd | ||
|
|
29f03756bd | ||
|
|
fe8c5546f0 | ||
|
|
c4315a7afa | ||
|
|
704782c95b | ||
|
|
67059e1932 | ||
|
|
e2ea711136 | ||
|
|
74aa598769 | ||
|
|
747ff7daf8 | ||
|
|
1f670fc688 | ||
|
|
388906ac70 | ||
|
|
49d9745dc4 | ||
|
|
7c15d793ac | ||
|
|
d90cb3511c | ||
|
|
5100272dc3 | ||
|
|
afda9810f1 | ||
|
|
22df8b81b3 | ||
|
|
7a427c9070 | ||
|
|
a35e4bdbda | ||
|
|
0aeb5adb8f | ||
|
|
9c5cc217bf | ||
|
|
24603d7ad3 | ||
|
|
1eac6ff8ff | ||
|
|
8742b3dab2 | ||
|
|
93cdc9b9dc | ||
|
|
8ed74a3429 | ||
|
|
07a5e59ae7 | ||
|
|
f8c2f1cf54 | ||
|
|
b1f043d010 | ||
|
|
251c0c8508 | ||
|
|
3214daca4c |
@@ -12,7 +12,7 @@ set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
|
||||
# Also remember to set PROTOCOL_VERSION in clientserver.h when releasing
|
||||
set(VERSION_MAJOR 0)
|
||||
set(VERSION_MINOR 4)
|
||||
set(VERSION_PATCH dev-20120408)
|
||||
set(VERSION_PATCH dev-20120606)
|
||||
if(VERSION_EXTRA)
|
||||
set(VERSION_PATCH ${VERSION_PATCH}-${VERSION_EXTRA})
|
||||
endif()
|
||||
|
||||
@@ -260,8 +260,8 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
@@ -269,7 +269,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
|
||||
@@ -84,12 +84,9 @@ minetest.builtin_auth_handler = {
|
||||
-- always has an empty password, otherwise use default, which is
|
||||
-- usually empty too)
|
||||
local new_password_hash = ""
|
||||
if not minetest.is_singleplayer() then
|
||||
new_password_hash = minetest.get_password_hash(name, minetest.setting_get("default_password"))
|
||||
end
|
||||
-- Add player to authentication table if not there already
|
||||
-- If not in authentication table, return nil
|
||||
if not minetest.auth_table[name] then
|
||||
minetest.builtin_auth_handler.create_auth(name, minetest.get_password_hash(name, minetest.setting_get("default_password")))
|
||||
return nil
|
||||
end
|
||||
-- Figure out what privileges the player should have.
|
||||
-- Take a copy of the privilege table
|
||||
|
||||
@@ -10,6 +10,7 @@ print = minetest.debug
|
||||
math.randomseed(os.time())
|
||||
|
||||
-- Load other files
|
||||
dofile(minetest.get_modpath("__builtin").."/serialize.lua")
|
||||
dofile(minetest.get_modpath("__builtin").."/misc_helpers.lua")
|
||||
dofile(minetest.get_modpath("__builtin").."/item.lua")
|
||||
dofile(minetest.get_modpath("__builtin").."/misc_register.lua")
|
||||
@@ -19,4 +20,5 @@ dofile(minetest.get_modpath("__builtin").."/misc.lua")
|
||||
dofile(minetest.get_modpath("__builtin").."/privileges.lua")
|
||||
dofile(minetest.get_modpath("__builtin").."/auth.lua")
|
||||
dofile(minetest.get_modpath("__builtin").."/chatcommands.lua")
|
||||
dofile(minetest.get_modpath("__builtin").."/static_spawn.lua")
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ function minetest.register_chatcommand(cmd, def)
|
||||
end
|
||||
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
local cmd, param = string.match(message, "/([^ ]+) *(.*)")
|
||||
local cmd, param = string.match(message, "^/([^ ]+) *(.*)")
|
||||
if not param then
|
||||
param = ""
|
||||
end
|
||||
@@ -101,9 +101,10 @@ minetest.register_chatcommand("privs", {
|
||||
if param == "" then
|
||||
param = name
|
||||
else
|
||||
if not minetest.check_player_privs(name, {privs=true}) then
|
||||
--[[if not minetest.check_player_privs(name, {privs=true}) then
|
||||
minetest.chat_send_player(name, "Privileges of "..param.." are hidden from you.")
|
||||
end
|
||||
return
|
||||
end]]
|
||||
end
|
||||
minetest.chat_send_player(name, "Privileges of "..param..": "..minetest.privs_to_string(minetest.get_player_privs(param), ' '))
|
||||
end,
|
||||
@@ -111,8 +112,13 @@ minetest.register_chatcommand("privs", {
|
||||
minetest.register_chatcommand("grant", {
|
||||
params = "<name> <privilege>|all",
|
||||
description = "Give privilege to player",
|
||||
privs = {privs=true},
|
||||
privs = {},
|
||||
func = function(name, param)
|
||||
if not minetest.check_player_privs(name, {privs=true}) and
|
||||
not minetest.check_player_privs(name, {basic_privs=true}) then
|
||||
minetest.chat_send_player(name, "Your privileges are insufficient.")
|
||||
return
|
||||
end
|
||||
local grantname, grantprivstr = string.match(param, "([^ ]+) (.+)")
|
||||
if not grantname or not grantprivstr then
|
||||
minetest.chat_send_player(name, "Invalid parameters (see /help grant)")
|
||||
@@ -125,6 +131,10 @@ minetest.register_chatcommand("grant", {
|
||||
local privs = minetest.get_player_privs(grantname)
|
||||
local privs_known = true
|
||||
for priv, _ in pairs(grantprivs) do
|
||||
if priv ~= "interact" and priv ~= "shout" and priv ~= "interact_extra" and not minetest.check_player_privs(name, {privs=true}) then
|
||||
minetest.chat_send_player(name, "Your privileges are insufficient.")
|
||||
return
|
||||
end
|
||||
if not minetest.registered_privileges[priv] then
|
||||
minetest.chat_send_player(name, "Unknown privilege: "..priv)
|
||||
privs_known = false
|
||||
@@ -144,8 +154,13 @@ minetest.register_chatcommand("grant", {
|
||||
minetest.register_chatcommand("revoke", {
|
||||
params = "<name> <privilege>|all",
|
||||
description = "Remove privilege from player",
|
||||
privs = {privs=true},
|
||||
privs = {},
|
||||
func = function(name, param)
|
||||
if not minetest.check_player_privs(name, {privs=true}) and
|
||||
not minetest.check_player_privs(name, {basic_privs=true}) then
|
||||
minetest.chat_send_player(name, "Your privileges are insufficient.")
|
||||
return
|
||||
end
|
||||
local revokename, revokeprivstr = string.match(param, "([^ ]+) (.+)")
|
||||
if not revokename or not revokeprivstr then
|
||||
minetest.chat_send_player(name, "Invalid parameters (see /help revoke)")
|
||||
@@ -153,6 +168,12 @@ minetest.register_chatcommand("revoke", {
|
||||
end
|
||||
local revokeprivs = minetest.string_to_privs(revokeprivstr)
|
||||
local privs = minetest.get_player_privs(revokename)
|
||||
for priv, _ in pairs(revokeprivs) do
|
||||
if priv ~= "interact" and priv ~= "shout" and priv ~= "interact_extra" and not minetest.check_player_privs(name, {privs=true}) then
|
||||
minetest.chat_send_player(name, "Your privileges are insufficient.")
|
||||
return
|
||||
end
|
||||
end
|
||||
if revokeprivstr == "all" then
|
||||
privs = {}
|
||||
else
|
||||
@@ -302,7 +323,7 @@ minetest.register_chatcommand("set", {
|
||||
privs = {server=true},
|
||||
func = function(name, param)
|
||||
local arg, setname, setvalue = string.match(param, "(-[n]) ([^ ]+) (.+)")
|
||||
if arg and arg == "n" and setname and setvalue then
|
||||
if arg and arg == "-n" and setname and setvalue then
|
||||
minetest.setting_set(setname, setvalue)
|
||||
minetest.chat_send_player(name, setname.." = "..setvalue)
|
||||
return
|
||||
|
||||
111
builtin/item.lua
111
builtin/item.lua
@@ -158,12 +158,12 @@ function minetest.item_place_node(itemstack, placer, pointed_thing)
|
||||
-- Add node and update
|
||||
minetest.env:add_node(pos, newnode)
|
||||
|
||||
-- Set metadata owner
|
||||
if def.metadata_name ~= "" then
|
||||
minetest.env:get_meta(pos):set_owner(placer:get_player_name())
|
||||
-- Run callback
|
||||
if def.after_place_node then
|
||||
def.after_place_node(pos, placer)
|
||||
end
|
||||
|
||||
-- Run script hook
|
||||
-- Run script hook (deprecated)
|
||||
local _, callback
|
||||
for _, callback in ipairs(minetest.registered_on_placenodes) do
|
||||
callback(pos, newnode, placer)
|
||||
@@ -229,7 +229,7 @@ function minetest.node_dig(pos, node, digger)
|
||||
minetest.debug("node_dig")
|
||||
|
||||
local def = ItemStack({name=node.name}):get_definition()
|
||||
if not def.diggable then
|
||||
if not def.diggable or (def.can_dig and not def.can_dig(pos,digger)) then
|
||||
minetest.debug("not diggable")
|
||||
minetest.log("info", digger:get_player_name() .. " tried to dig "
|
||||
.. node.name .. " which is not diggable "
|
||||
@@ -237,15 +237,6 @@ function minetest.node_dig(pos, node, digger)
|
||||
return
|
||||
end
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if meta ~= nil and not meta:get_allow_removal() then
|
||||
minetest.debug("dig prevented by metadata")
|
||||
minetest.log("info", digger:get_player_name() .. " tried to dig "
|
||||
.. node.name .. ", but removal is disabled by metadata "
|
||||
.. minetest.pos_to_string(pos))
|
||||
return
|
||||
end
|
||||
|
||||
minetest.log('action', digger:get_player_name() .. " digs "
|
||||
.. node.name .. " at " .. minetest.pos_to_string(pos))
|
||||
|
||||
@@ -259,23 +250,81 @@ function minetest.node_dig(pos, node, digger)
|
||||
wielded:add_wear(dp.wear)
|
||||
digger:set_wielded_item(wielded)
|
||||
|
||||
-- Add dropped items
|
||||
local _, dropped_item
|
||||
for _, dropped_item in ipairs(drops) do
|
||||
digger:get_inventory():add_item("main", dropped_item)
|
||||
-- Add dropped items to object's inventory
|
||||
if digger:get_inventory() then
|
||||
local _, dropped_item
|
||||
for _, dropped_item in ipairs(drops) do
|
||||
digger:get_inventory():add_item("main", dropped_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local oldnode = nil
|
||||
local oldmetadata = nil
|
||||
if def.after_dig_node then
|
||||
oldnode = node;
|
||||
oldmetadata = minetest.env:get_meta(pos):to_table()
|
||||
end
|
||||
|
||||
-- Remove node and update
|
||||
minetest.env:remove_node(pos)
|
||||
|
||||
-- Run callback
|
||||
if def.after_dig_node then
|
||||
def.after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||
end
|
||||
|
||||
-- Run script hook
|
||||
-- Run script hook (deprecated)
|
||||
local _, callback
|
||||
for _, callback in ipairs(minetest.registered_on_dignodes) do
|
||||
callback(pos, node, digger)
|
||||
end
|
||||
end
|
||||
|
||||
function minetest.node_metadata_inventory_move_allow_all(pos, from_list,
|
||||
from_index, to_list, to_index, count, player)
|
||||
minetest.log("verbose", "node_metadata_inventory_move_allow_all")
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
local from_stack = inv:get_stack(from_list, from_index)
|
||||
local taken_items = from_stack:take_item(count)
|
||||
inv:set_stack(from_list, from_index, from_stack)
|
||||
|
||||
local to_stack = inv:get_stack(to_list, to_index)
|
||||
to_stack:add_item(taken_items)
|
||||
inv:set_stack(to_list, to_index, to_stack)
|
||||
end
|
||||
|
||||
function minetest.node_metadata_inventory_offer_allow_all(pos, listname, index, stack, player)
|
||||
minetest.log("verbose", "node_metadata_inventory_offer_allow_all")
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local the_stack = inv:get_stack(listname, index)
|
||||
the_stack:add_item(stack)
|
||||
inv:set_stack(listname, index, the_stack)
|
||||
return ItemStack("")
|
||||
end
|
||||
|
||||
function minetest.node_metadata_inventory_take_allow_all(pos, listname, index, count, player)
|
||||
minetest.log("verbose", "node_metadata_inventory_take_allow_all")
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local the_stack = inv:get_stack(listname, index)
|
||||
local taken_items = the_stack:take_item(count)
|
||||
inv:set_stack(listname, index, the_stack)
|
||||
return taken_items
|
||||
end
|
||||
|
||||
-- This is used to allow mods to redefine minetest.item_place and so on
|
||||
-- NOTE: This is not the preferred way. Preferred way is to provide enough
|
||||
-- callbacks to not require redefining global functions. -celeron55
|
||||
local function redef_wrapper(table, name)
|
||||
return function(...)
|
||||
return table[name](...)
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Item definition defaults
|
||||
--
|
||||
@@ -295,12 +344,19 @@ minetest.nodedef_default = {
|
||||
tool_capabilities = nil,
|
||||
|
||||
-- Interaction callbacks
|
||||
on_place = minetest.item_place,
|
||||
on_drop = minetest.item_drop,
|
||||
on_place = redef_wrapper(minetest, 'item_place'), -- minetest.item_place
|
||||
on_drop = redef_wrapper(minetest, 'item_drop'), -- minetest.item_drop
|
||||
on_use = nil,
|
||||
can_dig = nil,
|
||||
|
||||
on_punch = minetest.node_punch,
|
||||
on_dig = minetest.node_dig,
|
||||
on_punch = redef_wrapper(minetest, 'node_punch'), -- minetest.node_punch
|
||||
on_dig = redef_wrapper(minetest, 'node_dig'), -- minetest.node_dig
|
||||
|
||||
on_receive_fields = nil,
|
||||
|
||||
on_metadata_inventory_move = minetest.node_metadata_inventory_move_allow_all,
|
||||
on_metadata_inventory_offer = minetest.node_metadata_inventory_offer_allow_all,
|
||||
on_metadata_inventory_take = minetest.node_metadata_inventory_take_allow_all,
|
||||
|
||||
-- Node properties
|
||||
drawtype = "normal",
|
||||
@@ -321,7 +377,6 @@ minetest.nodedef_default = {
|
||||
diggable = true,
|
||||
climbable = false,
|
||||
buildable_to = false,
|
||||
metadata_name = "",
|
||||
liquidtype = "none",
|
||||
liquid_alternative_flowing = "",
|
||||
liquid_alternative_source = "",
|
||||
@@ -346,8 +401,8 @@ minetest.craftitemdef_default = {
|
||||
tool_capabilities = nil,
|
||||
|
||||
-- Interaction callbacks
|
||||
on_place = minetest.item_place,
|
||||
on_drop = minetest.item_drop,
|
||||
on_place = redef_wrapper(minetest, 'item_place'), -- minetest.item_place
|
||||
on_drop = redef_wrapper(minetest, 'item_drop'), -- minetest.item_drop
|
||||
on_use = nil,
|
||||
}
|
||||
|
||||
@@ -364,8 +419,8 @@ minetest.tooldef_default = {
|
||||
tool_capabilities = nil,
|
||||
|
||||
-- Interaction callbacks
|
||||
on_place = minetest.item_place,
|
||||
on_drop = minetest.item_drop,
|
||||
on_place = redef_wrapper(minetest, 'item_place'), -- minetest.item_place
|
||||
on_drop = redef_wrapper(minetest, 'item_drop'), -- minetest.item_drop
|
||||
on_use = nil,
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ function minetest.get_connected_players()
|
||||
-- This could be optimized a bit, but leave that for later
|
||||
local list = {}
|
||||
for _, obj in pairs(minetest.env:get_objects_inside_radius({x=0,y=0,z=0}, 1000000)) do
|
||||
if obj:get_player_name() then
|
||||
if obj:is_player() then
|
||||
table.insert(list, obj)
|
||||
end
|
||||
end
|
||||
@@ -55,11 +55,47 @@ function minetest.hash_node_position(pos)
|
||||
return (pos.z+32768)*65536*65536 + (pos.y+32768)*65536 + pos.x+32768
|
||||
end
|
||||
|
||||
function minetest.get_node_group(name, group)
|
||||
if not minetest.registered_nodes[name] or not
|
||||
minetest.registered_nodes[name].groups[group] then
|
||||
function minetest.get_item_group(name, group)
|
||||
if not minetest.registered_items[name] or not
|
||||
minetest.registered_items[name].groups[group] then
|
||||
return 0
|
||||
end
|
||||
return minetest.registered_nodes[name].groups[group]
|
||||
return minetest.registered_items[name].groups[group]
|
||||
end
|
||||
|
||||
function minetest.get_node_group(name, group)
|
||||
return minetest.get_item_group(name, group)
|
||||
end
|
||||
|
||||
function minetest.string_to_pos(value)
|
||||
local p = {}
|
||||
p.x, p.y, p.z = string.match(value, "^([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+)$")
|
||||
if p.x and p.y and p.z then
|
||||
p.x = tonumber(p.x)
|
||||
p.y = tonumber(p.y)
|
||||
p.z = tonumber(p.z)
|
||||
return p
|
||||
end
|
||||
local p = {}
|
||||
p.x, p.y, p.z = string.match(value, "^%( *([%d.-]+)[, ] *([%d.-]+)[, ] *([%d.-]+) *%)$")
|
||||
if p.x and p.y and p.z then
|
||||
p.x = tonumber(p.x)
|
||||
p.y = tonumber(p.y)
|
||||
p.z = tonumber(p.z)
|
||||
return p
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
assert(minetest.string_to_pos("10.0, 5, -2").x == 10)
|
||||
assert(minetest.string_to_pos("( 10.0, 5, -2)").z == -2)
|
||||
assert(minetest.string_to_pos("asd, 5, -2)") == nil)
|
||||
|
||||
function minetest.setting_get_pos(name)
|
||||
local value = minetest.setting_get(name)
|
||||
if not value then
|
||||
return nil
|
||||
end
|
||||
return minetest.string_to_pos(value)
|
||||
end
|
||||
|
||||
|
||||
@@ -301,8 +301,6 @@ end
|
||||
|
||||
minetest.registered_on_chat_messages, minetest.register_on_chat_message = make_registration()
|
||||
minetest.registered_globalsteps, minetest.register_globalstep = make_registration()
|
||||
minetest.registered_on_placenodes, minetest.register_on_placenode = make_registration()
|
||||
minetest.registered_on_dignodes, minetest.register_on_dignode = make_registration()
|
||||
minetest.registered_on_punchnodes, minetest.register_on_punchnode = make_registration()
|
||||
minetest.registered_on_generateds, minetest.register_on_generated = make_registration()
|
||||
minetest.registered_on_newplayers, minetest.register_on_newplayer = make_registration()
|
||||
@@ -311,4 +309,16 @@ minetest.registered_on_respawnplayers, minetest.register_on_respawnplayer = make
|
||||
minetest.registered_on_joinplayers, minetest.register_on_joinplayer = make_registration()
|
||||
minetest.registered_on_leaveplayers, minetest.register_on_leaveplayer = make_registration()
|
||||
|
||||
minetest.registered_on_placenodes = {}
|
||||
minetest.register_on_placenode = function(callback)
|
||||
minetest.log("info", debug.traceback())
|
||||
minetest.log("info", "WARNING: minetest.register_on_placenode is deprecated. Use on_construct or after_place_node in node definition instead.")
|
||||
table.insert(minetest.registered_on_placenodes, callback)
|
||||
end
|
||||
minetest.registered_on_dignodes = {}
|
||||
minetest.register_on_dignode = function(callback)
|
||||
minetest.log("info", debug.traceback())
|
||||
minetest.log("info", "WARNING: minetest.register_on_dignode is deprecated. Use on_destruct or after_dig_node in node definition instead.")
|
||||
table.insert(minetest.registered_on_dignodes, callback)
|
||||
end
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ minetest.register_privilege("teleport", "Can use /teleport command")
|
||||
minetest.register_privilege("bring", "Can teleport other players")
|
||||
minetest.register_privilege("settime", "Can use /time")
|
||||
minetest.register_privilege("privs", "Can modify privileges")
|
||||
minetest.register_privilege("basic_privs", "Can modify 'shout' and 'interact' privileges")
|
||||
minetest.register_privilege("server", "Can do server maintenance stuff")
|
||||
minetest.register_privilege("shout", "Can speak in chat")
|
||||
minetest.register_privilege("ban", "Can ban and unban players")
|
||||
|
||||
207
builtin/serialize.lua
Normal file
207
builtin/serialize.lua
Normal file
@@ -0,0 +1,207 @@
|
||||
-- Minetest: builtin/serialize.lua
|
||||
|
||||
-- https://github.com/fab13n/metalua/blob/no-dll/src/lib/serialize.lua
|
||||
-- Copyright (c) 2006-2997 Fabien Fleutot <metalua@gmail.com>
|
||||
-- License: MIT
|
||||
--------------------------------------------------------------------------------
|
||||
-- Serialize an object into a source code string. This string, when passed as
|
||||
-- an argument to deserialize(), returns an object structurally identical
|
||||
-- to the original one. The following are currently supported:
|
||||
-- * strings, numbers, booleans, nil
|
||||
-- * tables thereof. Tables can have shared part, but can't be recursive yet.
|
||||
-- Caveat: metatables and environments aren't saved.
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local no_identity = { number=1, boolean=1, string=1, ['nil']=1 }
|
||||
|
||||
function minetest.serialize(x)
|
||||
|
||||
local gensym_max = 0 -- index of the gensym() symbol generator
|
||||
local seen_once = { } -- element->true set of elements seen exactly once in the table
|
||||
local multiple = { } -- element->varname set of elements seen more than once
|
||||
local nested = { } -- transient, set of elements currently being traversed
|
||||
local nest_points = { }
|
||||
local nest_patches = { }
|
||||
|
||||
local function gensym()
|
||||
gensym_max = gensym_max + 1 ; return gensym_max
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- nest_points are places where a table appears within itself, directly or not.
|
||||
-- for instance, all of these chunks create nest points in table x:
|
||||
-- "x = { }; x[x] = 1", "x = { }; x[1] = x", "x = { }; x[1] = { y = { x } }".
|
||||
-- To handle those, two tables are created by mark_nest_point:
|
||||
-- * nest_points [parent] associates all keys and values in table parent which
|
||||
-- create a nest_point with boolean `true'
|
||||
-- * nest_patches contain a list of { parent, key, value } tuples creating
|
||||
-- a nest point. They're all dumped after all the other table operations
|
||||
-- have been performed.
|
||||
--
|
||||
-- mark_nest_point (p, k, v) fills tables nest_points and nest_patches with
|
||||
-- informations required to remember that key/value (k,v) create a nest point
|
||||
-- in table parent. It also marks `parent' as occuring multiple times, since
|
||||
-- several references to it will be required in order to patch the nest
|
||||
-- points.
|
||||
-----------------------------------------------------------------------------
|
||||
local function mark_nest_point (parent, k, v)
|
||||
local nk, nv = nested[k], nested[v]
|
||||
assert (not nk or seen_once[k] or multiple[k])
|
||||
assert (not nv or seen_once[v] or multiple[v])
|
||||
local mode = (nk and nv and "kv") or (nk and "k") or ("v")
|
||||
local parent_np = nest_points [parent]
|
||||
local pair = { k, v }
|
||||
if not parent_np then parent_np = { }; nest_points [parent] = parent_np end
|
||||
parent_np [k], parent_np [v] = nk, nv
|
||||
table.insert (nest_patches, { parent, k, v })
|
||||
seen_once [parent], multiple [parent] = nil, true
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- First pass, list the tables and functions which appear more than once in x
|
||||
-----------------------------------------------------------------------------
|
||||
local function mark_multiple_occurences (x)
|
||||
if no_identity [type(x)] then return end
|
||||
if seen_once [x] then seen_once [x], multiple [x] = nil, true
|
||||
elseif multiple [x] then -- pass
|
||||
else seen_once [x] = true end
|
||||
|
||||
if type (x) == 'table' then
|
||||
nested [x] = true
|
||||
for k, v in pairs (x) do
|
||||
if nested[k] or nested[v] then mark_nest_point (x, k, v) else
|
||||
mark_multiple_occurences (k)
|
||||
mark_multiple_occurences (v)
|
||||
end
|
||||
end
|
||||
nested [x] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local dumped = { } -- multiply occuring values already dumped in localdefs
|
||||
local localdefs = { } -- already dumped local definitions as source code lines
|
||||
|
||||
-- mutually recursive functions:
|
||||
local dump_val, dump_or_ref_val
|
||||
|
||||
--------------------------------------------------------------------
|
||||
-- if x occurs multiple times, dump the local var rather than the
|
||||
-- value. If it's the first time it's dumped, also dump the content
|
||||
-- in localdefs.
|
||||
--------------------------------------------------------------------
|
||||
function dump_or_ref_val (x)
|
||||
if nested[x] then return 'false' end -- placeholder for recursive reference
|
||||
if not multiple[x] then return dump_val (x) end
|
||||
local var = dumped [x]
|
||||
if var then return "_[" .. var .. "]" end -- already referenced
|
||||
local val = dump_val(x) -- first occurence, create and register reference
|
||||
var = gensym()
|
||||
table.insert(localdefs, "_["..var.."]="..val)
|
||||
dumped [x] = var
|
||||
return "_[" .. var .. "]"
|
||||
end
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Second pass, dump the object; subparts occuring multiple times are dumped
|
||||
-- in local variables which can be referenced multiple times;
|
||||
-- care is taken to dump locla vars in asensible order.
|
||||
-----------------------------------------------------------------------------
|
||||
function dump_val(x)
|
||||
local t = type(x)
|
||||
if x==nil then return 'nil'
|
||||
elseif t=="number" then return tostring(x)
|
||||
elseif t=="string" then return string.format("%q", x)
|
||||
elseif t=="boolean" then return x and "true" or "false"
|
||||
elseif t=="table" then
|
||||
local acc = { }
|
||||
local idx_dumped = { }
|
||||
local np = nest_points [x]
|
||||
for i, v in ipairs(x) do
|
||||
if np and np[v] then
|
||||
table.insert (acc, 'false') -- placeholder
|
||||
else
|
||||
table.insert (acc, dump_or_ref_val(v))
|
||||
end
|
||||
idx_dumped[i] = true
|
||||
end
|
||||
for k, v in pairs(x) do
|
||||
if np and (np[k] or np[v]) then
|
||||
--check_multiple(k); check_multiple(v) -- force dumps in localdefs
|
||||
elseif not idx_dumped[k] then
|
||||
table.insert (acc, "[" .. dump_or_ref_val(k) .. "] = " .. dump_or_ref_val(v))
|
||||
end
|
||||
end
|
||||
return "{ "..table.concat(acc,", ").." }"
|
||||
else
|
||||
error ("Can't serialize data of type "..t)
|
||||
end
|
||||
end
|
||||
|
||||
local function dump_nest_patches()
|
||||
for _, entry in ipairs(nest_patches) do
|
||||
local p, k, v = unpack (entry)
|
||||
assert (multiple[p])
|
||||
local set = dump_or_ref_val (p) .. "[" .. dump_or_ref_val (k) .. "] = " ..
|
||||
dump_or_ref_val (v) .. " -- rec "
|
||||
table.insert (localdefs, set)
|
||||
end
|
||||
end
|
||||
|
||||
mark_multiple_occurences (x)
|
||||
local toplevel = dump_or_ref_val (x)
|
||||
dump_nest_patches()
|
||||
|
||||
if next (localdefs) then
|
||||
return "local _={ }\n" ..
|
||||
table.concat (localdefs, "\n") ..
|
||||
"\nreturn " .. toplevel
|
||||
else
|
||||
return "return " .. toplevel
|
||||
end
|
||||
end
|
||||
|
||||
-- Deserialization.
|
||||
-- http://stackoverflow.com/questions/5958818/loading-serialized-data-into-a-table
|
||||
--
|
||||
|
||||
local function stringtotable(sdata)
|
||||
if sdata:byte(1) == 27 then return nil, "binary bytecode prohibited" end
|
||||
local f, message = assert(loadstring(sdata))
|
||||
if not f then return nil, message end
|
||||
setfenv(f, table)
|
||||
return f()
|
||||
end
|
||||
|
||||
function minetest.deserialize(sdata)
|
||||
local table = {}
|
||||
local okay,results = pcall(stringtotable, sdata)
|
||||
if okay then
|
||||
return results
|
||||
end
|
||||
print('error:'.. results)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Run some unit tests
|
||||
local function unit_test()
|
||||
function unitTest(name, success)
|
||||
if not success then
|
||||
error(name .. ': failed')
|
||||
end
|
||||
end
|
||||
|
||||
unittest_input = {cat={sound="nyan", speed=400}, dog={sound="woof"}}
|
||||
unittest_output = minetest.deserialize(minetest.serialize(unittest_input))
|
||||
|
||||
unitTest("test 1a", unittest_input.cat.sound == unittest_output.cat.sound)
|
||||
unitTest("test 1b", unittest_input.cat.speed == unittest_output.cat.speed)
|
||||
unitTest("test 1c", unittest_input.dog.sound == unittest_output.dog.sound)
|
||||
|
||||
unittest_input = {escapechars="\n\r\t\v\\\"\'\[\]", noneuropean="θשׁ٩∂"}
|
||||
unittest_output = minetest.deserialize(minetest.serialize(unittest_input))
|
||||
unitTest("test 3a", unittest_input.escapechars == unittest_output.escapechars)
|
||||
unitTest("test 3b", unittest_input.noneuropean == unittest_output.noneuropean)
|
||||
end
|
||||
unit_test() -- Run it
|
||||
unit_test = nil -- Hide it
|
||||
|
||||
33
builtin/static_spawn.lua
Normal file
33
builtin/static_spawn.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
-- Minetest: builtin/static_spawn.lua
|
||||
|
||||
local function warn_invalid_static_spawnpoint()
|
||||
if minetest.setting_get("static_spawnpoint") and
|
||||
not minetest.setting_get_pos("static_spawnpoint") then
|
||||
minetest.log('error', "The static_spawnpoint setting is invalid: \""..
|
||||
minetest.setting_get("static_spawnpoint").."\"")
|
||||
end
|
||||
end
|
||||
|
||||
warn_invalid_static_spawnpoint()
|
||||
|
||||
local function put_player_in_spawn(obj)
|
||||
warn_invalid_static_spawnpoint()
|
||||
local static_spawnpoint = minetest.setting_get_pos("static_spawnpoint")
|
||||
if not static_spawnpoint then
|
||||
return false
|
||||
end
|
||||
minetest.log('action', "Moving "..obj:get_player_name()..
|
||||
" to static spawnpoint at "..
|
||||
minetest.pos_to_string(static_spawnpoint))
|
||||
obj:setpos(static_spawnpoint)
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_on_newplayer(function(obj)
|
||||
put_player_in_spawn(obj)
|
||||
end)
|
||||
|
||||
minetest.register_on_respawnplayer(function(obj)
|
||||
return put_player_in_spawn(obj)
|
||||
end)
|
||||
|
||||
415
doc/lua_api.txt
415
doc/lua_api.txt
@@ -25,7 +25,7 @@ If you have any difficulty in understanding this, please read:
|
||||
Startup
|
||||
--------
|
||||
Mods are loaded during server startup from the mod load paths by running
|
||||
the init.lua scripts.
|
||||
the init.lua scripts in a shared environment.
|
||||
|
||||
Mod load path
|
||||
-------------
|
||||
@@ -59,6 +59,12 @@ This happens if the following directory exists:
|
||||
Mods should be then be placed in:
|
||||
$world/game/mods/
|
||||
|
||||
Modpack support
|
||||
----------------
|
||||
Mods can be put in a subdirectory, if the parent directory, which otherwise
|
||||
should be a mod, contains a file named modpack.txt. This file shall be
|
||||
empty, except for lines starting with #, which are comments.
|
||||
|
||||
Mod directory structure
|
||||
------------------------
|
||||
mods
|
||||
@@ -180,11 +186,60 @@ Examples of sound parameter tables:
|
||||
-- Play connected to an object, looped
|
||||
{
|
||||
object = <an ObjectRef>,
|
||||
gain = 1.0, -- default
|
||||
max_hear_distance = 32, -- default
|
||||
gain = 1.0, -- default
|
||||
max_hear_distance = 32, -- default
|
||||
loop = true, -- only sounds connected to objects can be looped
|
||||
}
|
||||
|
||||
SimpleSoundSpec:
|
||||
eg. ""
|
||||
eg. "default_place_node"
|
||||
eg. {}
|
||||
eg. {name="default_place_node"}
|
||||
eg. {name="default_place_node", gain=1.0}
|
||||
|
||||
Registered definitions of stuff
|
||||
--------------------------------
|
||||
Anything added using certain minetest.register_* functions get added to
|
||||
the global minetest.registered_* tables.
|
||||
|
||||
minetest.register_entity(name, prototype table)
|
||||
-> minetest.registered_entities[name]
|
||||
|
||||
minetest.register_node(name, node definition)
|
||||
-> minetest.registered_items[name]
|
||||
-> minetest.registered_nodes[name]
|
||||
|
||||
minetest.register_tool(name, item definition)
|
||||
-> minetest.registered_items[name]
|
||||
|
||||
minetest.register_craftitem(name, item definition)
|
||||
-> minetest.registered_items[name]
|
||||
|
||||
Note that in some cases you will stumble upon things that are not contained
|
||||
in these tables (eg. when a mod has been removed). Always check for
|
||||
existence before trying to access the fields.
|
||||
|
||||
Example: If you want to check the drawtype of a node, you could do:
|
||||
|
||||
local function get_nodedef_field(nodename, fieldname)
|
||||
if not minetest.registered_nodes[nodename] then
|
||||
return nil
|
||||
end
|
||||
return minetest.registered_nodes[nodename][fieldname]
|
||||
end
|
||||
local drawtype = get_nodedef_field(nodename, "drawtype")
|
||||
|
||||
Example: minetest.get_item_group(name, group) has been implemented as:
|
||||
|
||||
function minetest.get_item_group(name, group)
|
||||
if not minetest.registered_items[name] or not
|
||||
minetest.registered_items[name].groups[group] then
|
||||
return 0
|
||||
end
|
||||
return minetest.registered_items[name].groups[group]
|
||||
end
|
||||
|
||||
Nodes
|
||||
------
|
||||
Nodes are the bulk data of the world: cubes and other things that take the
|
||||
@@ -193,11 +248,10 @@ are quite static.
|
||||
|
||||
The definition of a node is stored and can be accessed by name in
|
||||
minetest.registered_nodes[node.name]
|
||||
See "Registered definitions of stuff".
|
||||
|
||||
Please note that for unknown nodes (eg. a node of an uninstalled mod) the
|
||||
minetest.registered_nodes field for the node is nil.
|
||||
|
||||
Nodes are passed by value in Lua. They are represented by a table:
|
||||
Nodes are passed by value between Lua and the engine.
|
||||
They are represented by a table:
|
||||
{name="name", param1=num, param2=num}
|
||||
|
||||
param1 and param2 are 8 bit and 4 bit integers, respectively. The engine
|
||||
@@ -224,6 +278,8 @@ param2 is reserved for the engine when any of these are used:
|
||||
^ The rotation of the node is stored in param2. Furnaces and chests are
|
||||
rotated this way. Can be made by using minetest.dir_to_facedir().
|
||||
|
||||
Nodes can also contain extra data. See "Node Metadata".
|
||||
|
||||
Representations of simple things
|
||||
--------------------------------
|
||||
Position/vector:
|
||||
@@ -231,29 +287,6 @@ Position/vector:
|
||||
Currently the API does not provide any helper functions for addition,
|
||||
subtraction and whatever; you can define those that you need yourself.
|
||||
|
||||
stackstring/itemstring: A stack of items in serialized format.
|
||||
eg. 'default:dirt 5'
|
||||
eg. 'default:pick_wood 21323'
|
||||
eg. 'default:apple'
|
||||
|
||||
item: A stack of items in Lua table format.
|
||||
eg. {name="default:dirt", count=5, wear=0, metadata=""}
|
||||
^ 5 dirt nodes
|
||||
eg. {name="default:pick_wood", count=1, wear=21323, metadata=""}
|
||||
^ a wooden pick about 1/3 weared out
|
||||
eg. {name="default:apple", count=1, wear=0, metadata=""}
|
||||
^ an apple.
|
||||
|
||||
Any time an item must be passed to a function, it can be an
|
||||
ItemStack (see below), an itemstring or a table in the above format.
|
||||
|
||||
SimpleSoundSpec:
|
||||
eg. ""
|
||||
eg. "default_place_node"
|
||||
eg. {}
|
||||
eg. {name="default_place_node"}
|
||||
eg. {name="default_place_node", gain=1.0}
|
||||
|
||||
Items
|
||||
------
|
||||
Node (register_node):
|
||||
@@ -263,6 +296,28 @@ Tool (register_tool):
|
||||
Craftitem (register_craftitem):
|
||||
A miscellaneous item
|
||||
|
||||
Items and item stacks can exist in three formats:
|
||||
|
||||
Serialized; This is called stackstring or itemstring:
|
||||
eg. 'default:dirt 5'
|
||||
eg. 'default:pick_wood 21323'
|
||||
eg. 'default:apple'
|
||||
|
||||
Table format:
|
||||
eg. {name="default:dirt", count=5, wear=0, metadata=""}
|
||||
^ 5 dirt nodes
|
||||
eg. {name="default:pick_wood", count=1, wear=21323, metadata=""}
|
||||
^ a wooden pick about 1/3 weared out
|
||||
eg. {name="default:apple", count=1, wear=0, metadata=""}
|
||||
^ an apple.
|
||||
|
||||
ItemStack:
|
||||
C++ native format with many helper methods. Useful for converting between
|
||||
formats. See the Class reference section for details.
|
||||
|
||||
When an item must be passed to a function, it can usually be in any of
|
||||
these formats.
|
||||
|
||||
Groups
|
||||
-------
|
||||
In a number of places, there is a group table. Groups define the
|
||||
@@ -282,6 +337,9 @@ Usage:
|
||||
- When not defined, the rating of a group defaults to 0. Thus when you
|
||||
read groups, you must interpret nil and 0 as the same value, 0.
|
||||
|
||||
You can read the rating of a group for an item or a node by using
|
||||
minetest.get_item_group(itemname, groupname)
|
||||
|
||||
Groups of items
|
||||
----------------
|
||||
Groups of items can define what kind of an item it is (eg. wool).
|
||||
@@ -305,8 +363,7 @@ effective towards.
|
||||
|
||||
Groups in crafting recipes
|
||||
---------------------------
|
||||
- Not implemented yet. (TODO)
|
||||
- Will probably look like this:
|
||||
An example:
|
||||
{
|
||||
output = 'food:meat_soup_raw',
|
||||
recipe = {
|
||||
@@ -314,7 +371,7 @@ Groups in crafting recipes
|
||||
{'group:water'},
|
||||
{'group:bowl'},
|
||||
},
|
||||
preserve = {'group:bowl'},
|
||||
preserve = {'group:bowl'}, -- Not implemented yet (TODO)
|
||||
}
|
||||
|
||||
Special groups
|
||||
@@ -346,7 +403,7 @@ Valid ratings for these are 0, 1, 2 and 3, unless otherwise stated.
|
||||
Can be added to nodes that shouldn't logically be breakable by the
|
||||
hand but are. Somewhat similar to dig_immediate, but times are more
|
||||
like {[1]=3.50,[2]=2.00,[3]=0.70} and this does not override the
|
||||
speed of a tool if the tool can dig at a larger speed than this
|
||||
speed of a tool if the tool can dig at a faster speed than this
|
||||
suggests for the hand.
|
||||
|
||||
Examples of custom groups
|
||||
@@ -402,9 +459,9 @@ it's useful item. (eg. iron ore to drop a lump of iron).
|
||||
Determines how many uses the tool has when it is used for digging a node,
|
||||
of this group, of the maximum level. For lower leveled nodes, the use count
|
||||
is multiplied by 3^leveldiff.
|
||||
- uses=10, leveldiff=0 -> actual_uses=10
|
||||
- uses=10, leveldiff=1 -> actual_uses=30
|
||||
- uses=10, leveldiff=2 -> actual_uses=90
|
||||
- uses=10, leveldiff=0 -> actual uses: 10
|
||||
- uses=10, leveldiff=1 -> actual uses: 30
|
||||
- uses=10, leveldiff=2 -> actual uses: 90
|
||||
|
||||
**Maximum level**
|
||||
Tells what is the maximum level of a node of this group that the tool will
|
||||
@@ -414,7 +471,7 @@ be able to dig.
|
||||
List of digging times for different ratings of the group, for nodes of the
|
||||
maximum level.
|
||||
* For example, as a lua table, ''times={2=2.00, 3=0.70}''. This would
|
||||
result the tool to be able to dig nodes that have a rating of 2 or 3
|
||||
result in the tool to be able to dig nodes that have a rating of 2 or 3
|
||||
for this group, and unable to dig the rating 1, which is the toughest.
|
||||
Unless there is a matching group that enables digging otherwise.
|
||||
* For entities, damage equals the amount of nodes dug in the time spent
|
||||
@@ -460,7 +517,7 @@ Entity damage mechanism
|
||||
Damage calculation:
|
||||
- Take the time spent after the last hit
|
||||
- Limit time to full_punch_interval
|
||||
- Take the damage groups, assume a node has them
|
||||
- Take the damage groups and imagine a bunch of nodes that have them
|
||||
- Damage in HP is the amount of nodes destroyed in this time.
|
||||
|
||||
Client predicts damage based on damage groups. Because of this, it is able to
|
||||
@@ -469,28 +526,119 @@ pre-defined somehow (eg. by defining a sprite animation) (not implemented;
|
||||
TODO).
|
||||
- Currently a smoke puff will appear when an entity dies.
|
||||
|
||||
The group **immortal** will completely disable normal damage.
|
||||
The group **immortal** completely disables normal damage.
|
||||
|
||||
Entities can define a special armor group, which is **punch_operable**. This
|
||||
group will disable the regular damage mechanism for players punching it by hand
|
||||
or a non-tool item.
|
||||
group disables the regular damage mechanism for players punching it by hand or
|
||||
a non-tool item, so that it can do something else than take damage.
|
||||
|
||||
On the Lua side, every punch calls ''entity:on_punch(puncher,
|
||||
time_from_last_punch, tool_capabilities, direction)''. This should never be
|
||||
called directly, because damage is usually not handled by the entity itself.
|
||||
* ''puncher'' is the object performing the punch. Can be nil. Should never be
|
||||
accessed unless absolutely required.
|
||||
accessed unless absolutely required, to encourage interoperability.
|
||||
* ''time_from_last_punch'' is time from last punch (by puncher) or nil.
|
||||
* ''tool_capabilities'' can be nil.
|
||||
* ''direction'' is a unit vector, pointing from the source of the punch to
|
||||
the punched object.
|
||||
|
||||
To punch an entity/object in Lua, call ''object:punch(puncher, time_from_last_punch, tool_capabilities, direction)''.
|
||||
To punch an entity/object in Lua, call ''object:punch(puncher,
|
||||
time_from_last_punch, tool_capabilities, direction)''.
|
||||
* Return value is tool wear.
|
||||
* Parameters are equal to the above callback.
|
||||
* If ''direction'' is nil and ''puncher'' is not nil, ''direction'' will be
|
||||
automatically filled in based on the location of ''puncher''.
|
||||
|
||||
Node Metadata
|
||||
-------------
|
||||
The instance of a node in the world normally only contains the three values
|
||||
mentioned in "Nodes". However, it is possible to insert extra data into a
|
||||
node. It is called "node metadata"; See "NodeMetaRef".
|
||||
|
||||
Metadata contains two things:
|
||||
- A key-value store
|
||||
- An inventory
|
||||
|
||||
Some of the values in the key-value store are handled specially:
|
||||
- formspec: Defines a right-click inventory menu. See "Formspec".
|
||||
- infotext: Text shown on the screen when the node is pointed at
|
||||
|
||||
Example stuff:
|
||||
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"list[context;main;0,0;8,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Chest");
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
print(dump(meta:to_table()))
|
||||
meta:from_table({
|
||||
inventory = {
|
||||
main = {[1] = "default:dirt", [2] = "", [3] = "", [4] = "", [5] = "", [6] = "", [7] = "", [8] = "", [9] = "", [10] = "", [11] = "", [12] = "", [13] = "", [14] = "default:cobble", [15] = "", [16] = "", [17] = "", [18] = "", [19] = "", [20] = "default:cobble", [21] = "", [22] = "", [23] = "", [24] = "", [25] = "", [26] = "", [27] = "", [28] = "", [29] = "", [30] = "", [31] = "", [32] = ""}
|
||||
},
|
||||
fields = {
|
||||
formspec = "invsize[8,9;]list[context;main;0,0;8,4;]list[current_player;main;0,5;8,4;]",
|
||||
infotext = "Chest"
|
||||
}
|
||||
})
|
||||
|
||||
Formspec
|
||||
--------
|
||||
Formspec defines a menu. Currently not much else than inventories are
|
||||
supported. It is a string, with a somewhat strange format.
|
||||
|
||||
Spaces and newlines can be inserted between the blocks, as is used in the
|
||||
examples.
|
||||
|
||||
Examples:
|
||||
- Chest:
|
||||
invsize[8,9;]
|
||||
list[context;main;0,0;8,4;]
|
||||
list[current_player;main;0,5;8,4;]
|
||||
- Furnace:
|
||||
invsize[8,9;]
|
||||
list[context;fuel;2,3;1,1;]
|
||||
list[context;src;2,1;1,1;]
|
||||
list[context;dst;5,1;2,2;]
|
||||
list[current_player;main;0,5;8,4;]
|
||||
- Minecraft-like player inventory
|
||||
invsize[8,7.5;]
|
||||
image[1,0.6;1,2;player.png]
|
||||
list[current_player;main;0,3.5;8,4;]
|
||||
list[current_player;craft;3,0;3,3;]
|
||||
list[current_player;craftpreview;7,1;1,1;]
|
||||
|
||||
Elements:
|
||||
|
||||
invsize[<W>,<H>;]
|
||||
^ Define the size of the menu in inventory slots
|
||||
|
||||
list[<inventory location>;<list name>;<X>,<Y>;<W>,<H>;]
|
||||
^ Show an inventory list
|
||||
|
||||
image[<X>,<Y>;<W>,<H>;<texture name>]
|
||||
^ Show an image
|
||||
^ Position and size units are inventory slots
|
||||
|
||||
field[<X>,<Y>;<W>,<H>;<name>;<label>;<default>]
|
||||
^ Textual field; will be sent to server when a button is clicked
|
||||
^ Position and size units are inventory slots
|
||||
^ Not implemented
|
||||
|
||||
button[<X>,<Y>;<W>,<H>;<name>;<label>]
|
||||
^ Clickable button. When clicked, fields will be sent.
|
||||
^ Button will be visible as a field, with the value "active".
|
||||
^ Position and size units are inventory slots
|
||||
^ Not implemented
|
||||
|
||||
Inventory location:
|
||||
- "context": Selected node metadata (deprecated: "current_name")
|
||||
- "current_player": Player to whom the menu is shown
|
||||
- "player:<name>": Any player
|
||||
- "nodemeta:<X>,<Y>,<Z>": Any node metadata
|
||||
|
||||
Helper functions
|
||||
-----------------
|
||||
dump2(obj, name="_", dumped={})
|
||||
@@ -503,6 +651,7 @@ string:trim()
|
||||
^ eg. string.trim("\n \t\tfoo bar\t ") == "foo bar"
|
||||
minetest.pos_to_string({x=X,y=Y,z=Z}) -> "(X,Y,Z)"
|
||||
^ Convert position to a printable string
|
||||
minetest.string_to_pos(string) -> position
|
||||
|
||||
minetest namespace reference
|
||||
-----------------------------
|
||||
@@ -514,7 +663,7 @@ minetest.get_worldpath() -> eg. "/home/user/.minetest/world"
|
||||
minetest.is_singleplayer()
|
||||
|
||||
minetest.debug(line)
|
||||
^ Goes to dstream
|
||||
^ Always printed to stderr and logfile (print() is redirected here)
|
||||
minetest.log(line)
|
||||
minetest.log(loglevel, line)
|
||||
^ loglevel one of "error", "action", "info", "verbose"
|
||||
@@ -527,17 +676,32 @@ minetest.register_tool(name, item definition)
|
||||
minetest.register_craftitem(name, item definition)
|
||||
minetest.register_alias(name, convert_to)
|
||||
minetest.register_craft(recipe)
|
||||
|
||||
Global callback registration functions: (Call these only at load time)
|
||||
minetest.register_globalstep(func(dtime))
|
||||
^ Called every server step, usually interval of 0.05s
|
||||
minetest.register_on_placenode(func(pos, newnode, placer))
|
||||
^ Called when a node has been placed
|
||||
^ Deprecated: Use on_construct or after_place_node in node definition instead
|
||||
minetest.register_on_dignode(func(pos, oldnode, digger))
|
||||
^ Called when a node has been dug. digger can be nil.
|
||||
^ Deprecated: Use on_destruct or after_dig_node in node definition instead
|
||||
minetest.register_on_punchnode(func(pos, node, puncher))
|
||||
^ Called when a node is punched
|
||||
minetest.register_on_generated(func(minp, maxp, blockseed))
|
||||
^ Called after generating a piece of world. Modifying nodes inside the area
|
||||
is a bit faster than usually.
|
||||
minetest.register_on_newplayer(func(ObjectRef))
|
||||
^ Called after a new player has been created
|
||||
minetest.register_on_dieplayer(func(ObjectRef))
|
||||
^ Called when a player dies
|
||||
minetest.register_on_respawnplayer(func(ObjectRef))
|
||||
^ Called when player is to be respawned
|
||||
^ Called _before_ repositioning of player occurs
|
||||
^ return true in func to disable regular player placement
|
||||
^ currently called _before_ repositioning of player occurs
|
||||
minetest.register_on_chat_message(func(name, message))
|
||||
|
||||
Other registration functions:
|
||||
minetest.register_chatcommand(cmd, chatcommand definition)
|
||||
minetest.register_privilege(name, definition)
|
||||
^ definition: "description text"
|
||||
@@ -552,6 +716,7 @@ Setting-related:
|
||||
minetest.setting_set(name, value)
|
||||
minetest.setting_get(name) -> string or nil
|
||||
minetest.setting_getbool(name) -> boolean value or nil
|
||||
minetest.setting_get_pos(name) -> position or nil
|
||||
minetest.add_to_creative_inventory(itemstring)
|
||||
|
||||
Authentication:
|
||||
@@ -592,6 +757,14 @@ minetest.dir_to_wallmounted(dir)
|
||||
minetest.get_node_drops(nodename, toolname)
|
||||
^ Returns list of item names.
|
||||
^ Note: This will be removed or modified in a future version.
|
||||
minetest.get_craft_result(input) -> output, decremented_input
|
||||
^ input.method = 'normal' or 'cooking' or 'fuel'
|
||||
^ input.width = for example 3
|
||||
^ input.items = for example { stack 1, stack 2, stack 3, stack 4,
|
||||
stack 5, stack 6, stack 7, stack 8, stack 9 }
|
||||
^ output.item = ItemStack, if unsuccessful: empty ItemStack
|
||||
^ output.time = number, if unsuccessful: 0
|
||||
^ decremented_input = like input
|
||||
|
||||
Defaults for the on_* item definition functions:
|
||||
(These return the leftover itemstack)
|
||||
@@ -628,11 +801,25 @@ Random:
|
||||
minetest.get_connected_players() -> list of ObjectRefs
|
||||
minetest.hash_node_position({x=,y=,z=}) -> 48-bit integer
|
||||
^ Gives a unique hash number for a node position (16+16+16=48bit)
|
||||
minetest.get_item_group(name, group) -> rating
|
||||
^ Get rating of a group of an item. (0 = not in group)
|
||||
minetest.get_node_group(name, group) -> rating
|
||||
^ Get rating of a group of a node. (0 = not in group)
|
||||
^ Deprecated: An alias for the former.
|
||||
minetest.serialize(table) -> string
|
||||
^ Convert a table containing tables, strings, numbers, booleans and nils
|
||||
into string form readable by minetest.deserialize
|
||||
^ Example: serialize({foo='bar'}) -> 'return { ["foo"] = "bar" }'
|
||||
minetest.deserialize(string) -> table
|
||||
^ Convert a string returned by minetest.deserialize into a table
|
||||
^ String is loaded in an empty sandbox environment.
|
||||
^ Will load functions, but they cannot access the global environment.
|
||||
^ Example: deserialize('return { ["foo"] = "bar" }') -> {foo='bar'}
|
||||
^ Example: deserialize('print("foo")') -> nil (function call fails)
|
||||
^ error:[string "print("foo")"]:1: attempt to call global 'print' (a nil value)
|
||||
|
||||
Global objects:
|
||||
minetest.env - environment reference
|
||||
minetest.env - EnvRef of the server environment and world.
|
||||
^ Using this you can access nodes and entities
|
||||
|
||||
Global tables:
|
||||
minetest.registered_items
|
||||
@@ -665,16 +852,26 @@ EnvRef: basically ServerEnvironment and ServerMap combined.
|
||||
methods:
|
||||
- set_node(pos, node)
|
||||
- add_node(pos, node): alias set_node(pos, node)
|
||||
- remove_node(pos): equivalent to set_node(pos, "air")
|
||||
^ Set node at position (node = {name="foo", param1=0, param2=0})
|
||||
- remove_node(pos)
|
||||
^ Equivalent to set_node(pos, "air")
|
||||
- get_node(pos)
|
||||
^ Returns {name="ignore", ...} for unloaded area
|
||||
- get_node_or_nil(pos)
|
||||
^ Returns nil for unloaded area
|
||||
- get_node_light(pos, timeofday) -> 0...15 or nil
|
||||
^ timeofday: nil = current time, 0 = night, 0.5 = day
|
||||
|
||||
- place_node(pos, node)
|
||||
^ Place node with the same effects that a player would cause
|
||||
- dig_node(pos)
|
||||
^ Dig node with the same effects that a player would cause
|
||||
- punch_node(pos)
|
||||
^ Punch node with the same effects that a player would cause
|
||||
|
||||
- add_entity(pos, name): Spawn Lua-defined entity at position
|
||||
^ Returns ObjectRef, or nil if failed
|
||||
- add_item(pos, itemstring): Spawn item
|
||||
- add_item(pos, item): Spawn item
|
||||
^ Returns ObjectRef, or nil if failed
|
||||
- get_meta(pos) -- Get a NodeMetaRef at that position
|
||||
- get_player_by_name(name) -- Get an ObjectRef to a player
|
||||
@@ -691,27 +888,20 @@ Deprecated:
|
||||
- add_rat(pos): Add C++ rat object (no-op)
|
||||
- add_firefly(pos): Add C++ firefly object (no-op)
|
||||
|
||||
NodeMetaRef (this stuff is subject to change in a future version)
|
||||
NodeMetaRef: Node metadata - reference extra data and functionality stored
|
||||
in a node
|
||||
- Can be gotten via minetest.env:get_nodemeta(pos)
|
||||
methods:
|
||||
- get_type()
|
||||
- allows_text_input()
|
||||
- set_text(text) -- eg. set the text of a sign
|
||||
- get_text()
|
||||
- get_owner()
|
||||
- set_owner(string)
|
||||
Generic node metadata specific:
|
||||
- set_infotext(infotext)
|
||||
- get_inventory() -> InvRef
|
||||
- set_inventory_draw_spec(string)
|
||||
- set_allow_text_input(bool)
|
||||
- set_allow_removal(bool)
|
||||
- set_enforce_owner(bool)
|
||||
- is_inventory_modified()
|
||||
- reset_inventory_modified()
|
||||
- is_text_modified()
|
||||
- reset_text_modified()
|
||||
- set_string(name, value)
|
||||
- get_string(name)
|
||||
- set_int(name, value)
|
||||
- get_int(name)
|
||||
- set_float(name, value)
|
||||
- get_float(name)
|
||||
- get_inventory() -> InvRef
|
||||
- to_table() -> nil or {fields = {...}, inventory = {list1 = {}, ...}}
|
||||
- from_table(nil or {})
|
||||
^ See "Node Metadata"
|
||||
|
||||
ObjectRef: Moving things in the game are generally these
|
||||
(basically reference to a C++ ServerActiveObject)
|
||||
@@ -748,13 +938,15 @@ LuaEntitySAO-only: (no-op for other objects)
|
||||
- get_entity_name() (DEPRECATED: Will be removed in a future version)
|
||||
- get_luaentity()
|
||||
Player-only: (no-op for other objects)
|
||||
- get_player_name(): will return nil if is not a player
|
||||
- is_player(): true for players, false for others
|
||||
- get_player_name(): returns "" if is not a player
|
||||
- get_look_dir(): get camera direction as a unit vector
|
||||
- get_look_pitch(): pitch in radians
|
||||
- get_look_yaw(): yaw in radians (wraps around pretty randomly as of now)
|
||||
|
||||
InvRef: Reference to an inventory
|
||||
methods:
|
||||
- is_empty(listname): return true if list is empty
|
||||
- get_size(listname): get size of a list
|
||||
- set_size(listname, size): set size of a list
|
||||
- get_stack(listname, i): get a copy of stack index i in list
|
||||
@@ -908,9 +1100,13 @@ Item definition (register_node, register_craftitem, register_tool)
|
||||
choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0}
|
||||
}
|
||||
}
|
||||
on_drop = func(itemstack, dropper, pos),
|
||||
|
||||
on_place = func(itemstack, placer, pointed_thing),
|
||||
^ default: minetest.item_place
|
||||
on_drop = func(itemstack, dropper, pos),
|
||||
^ default: minetest.item_drop
|
||||
on_use = func(itemstack, user, pointed_thing),
|
||||
^ default: nil
|
||||
^ Function must return either nil if no item shall be removed from
|
||||
inventory, or an itemstack to replace the original itemstack.
|
||||
eg. itemstack:take_item(); return itemstack
|
||||
@@ -942,7 +1138,6 @@ Node definition (register_node)
|
||||
buildable_to = false,
|
||||
drop = "",
|
||||
-- alternatively drop = { max_items = ..., items = { ... } }
|
||||
metadata_name = "",
|
||||
liquidtype = "none",
|
||||
liquid_alternative_flowing = "",
|
||||
liquid_alternative_source = "",
|
||||
@@ -957,21 +1152,87 @@ Node definition (register_node)
|
||||
dig = <SimpleSoundSpec>, -- "__group" = group-based sound (default)
|
||||
dug = <SimpleSoundSpec>,
|
||||
},
|
||||
|
||||
on_construct = func(pos),
|
||||
^ Node constructor; always called after adding node
|
||||
^ Can set up metadata and stuff like that
|
||||
^ default: nil
|
||||
on_destruct = func(pos),
|
||||
^ Node destructor; always called before removing node
|
||||
^ default: nil
|
||||
after_destruct = func(pos, oldnode),
|
||||
^ Node destructor; always called after removing node
|
||||
^ default: nil
|
||||
|
||||
after_place_node = func(pos, placer),
|
||||
^ Called after constructing node when node was placed using
|
||||
minetest.item_place_node / minetest.env:place_node
|
||||
^ default: nil
|
||||
after_dig_node = func(pos, oldnode, oldmetadata, digger),
|
||||
^ oldmetadata is in table format
|
||||
^ Called after destructing node when node was dug using
|
||||
minetest.node_dig / minetest.env:dig_node
|
||||
^ default: nil
|
||||
can_dig = function(pos,player)
|
||||
^ returns true if node can be dug, or false if not
|
||||
^ default: nil
|
||||
|
||||
on_punch = func(pos, node, puncher),
|
||||
^ default: minetest.node_punch
|
||||
^ By default: does nothing
|
||||
on_dig = func(pos, node, digger),
|
||||
^ default: minetest.node_dig
|
||||
^ By default: checks privileges, wears out tool and removes node
|
||||
|
||||
on_receive_fields = func(pos, formname, fields, sender),
|
||||
^ fields = {name1 = value1, name2 = value2, ...}
|
||||
^ Called when an UI form (eg. sign text input) returns data
|
||||
^ default: nil
|
||||
|
||||
on_metadata_inventory_move = func(pos, from_list, from_index,
|
||||
to_list, to_index, count, player),
|
||||
^ Called when a player wants to move items inside the metadata
|
||||
^ Should move items, or some items, if permitted. If not, should do
|
||||
nothing.
|
||||
^ The engine ensures the action is valid, i.e. the stack fits at the
|
||||
given position
|
||||
^ default: minetest.node_metadata_inventory_move_allow_all
|
||||
|
||||
on_metadata_inventory_offer = func(pos, listname, index, stack, player),
|
||||
^ Called when a player wants to put something into the metadata
|
||||
inventory
|
||||
^ Should check if the action is permitted (the engine ensures the
|
||||
action is valid, i.e. the stack fits at the given position)
|
||||
^ If permitted, modify the metadata inventory and return the
|
||||
"leftover" stack (normally nil).
|
||||
^ If not permitted, return itemstack.
|
||||
^ default: minetest.node_metadata_inventory_offer_allow_all
|
||||
|
||||
on_metadata_inventory_take = func(pos, listname, index, count, player),
|
||||
^ Called when a player wants to take something out of the metadata
|
||||
inventory
|
||||
^ Should check if the action is permitted (the engine ensures the
|
||||
action is valid, i.e. there's a stack of at least “count” items at
|
||||
that position)
|
||||
^ If permitted, modify the metadata inventory and return the
|
||||
stack of items
|
||||
^ If not permitted, return nil.
|
||||
^ default: minetest.node_metadata_inventory_take_allow_all
|
||||
}
|
||||
|
||||
Recipe: (register_craft)
|
||||
Recipe for register_craft: (shaped)
|
||||
{
|
||||
output = 'default:pick_stone',
|
||||
recipe = {
|
||||
{'default:cobble', 'default:cobble', 'default:cobble'},
|
||||
{'', 'default:stick', ''},
|
||||
{'', 'default:stick', ''},
|
||||
{'', 'default:stick', ''}, -- Also groups; eg. 'group:crumbly'
|
||||
},
|
||||
replacements = <optional list of item pairs,
|
||||
replace one input item with another item on crafting>
|
||||
}
|
||||
|
||||
Recipe (shapeless):
|
||||
Recipe for register_craft (shapeless)
|
||||
{
|
||||
type = "shapeless",
|
||||
output = 'mushrooms:mushroom_stew',
|
||||
@@ -984,13 +1245,13 @@ Recipe (shapeless):
|
||||
replace one input item with another item on crafting>
|
||||
}
|
||||
|
||||
Recipe (tool repair):
|
||||
Recipe for register_craft (tool repair)
|
||||
{
|
||||
type = "toolrepair",
|
||||
additional_wear = -0.02,
|
||||
}
|
||||
|
||||
Recipe (cooking):
|
||||
Recipe for register_craft (cooking)
|
||||
{
|
||||
type = "cooking",
|
||||
output = "default:glass",
|
||||
@@ -998,7 +1259,7 @@ Recipe (cooking):
|
||||
cooktime = 3,
|
||||
}
|
||||
|
||||
Recipe (furnace fuel):
|
||||
Recipe for register_craft (furnace fuel)
|
||||
{
|
||||
type = "fuel",
|
||||
recipe = "default:leaves",
|
||||
|
||||
@@ -1112,6 +1112,21 @@ minetest.register_node("default:sign_wall", {
|
||||
groups = {choppy=2,dig_immediate=2},
|
||||
legacy_wallmounted = true,
|
||||
sounds = default.node_sound_defaults(),
|
||||
on_construct = function(pos)
|
||||
--local n = minetest.env:get_node(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec", "hack:sign_text_input")
|
||||
meta:set_string("infotext", "\"\"")
|
||||
end,
|
||||
on_receive_fields = function(pos, formname, fields, sender)
|
||||
--print("Sign at "..minetest.pos_to_string(pos).." got "..dump(fields))
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
fields.text = fields.text or ""
|
||||
print((sender:get_player_name() or "").." wrote \""..fields.text..
|
||||
"\" to sign at "..minetest.pos_to_string(pos))
|
||||
meta:set_string("text", fields.text)
|
||||
meta:set_string("infotext", '"'..fields.text..'"')
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("default:chest", {
|
||||
@@ -1119,32 +1134,312 @@ minetest.register_node("default:chest", {
|
||||
tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
|
||||
"default_chest_side.png", "default_chest_side.png", "default_chest_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
metadata_name = "chest",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"list[current_name;main;0,0;8,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Chest")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index,
|
||||
to_list, to_index, count, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff in chest at "..minetest.pos_to_string(pos))
|
||||
return minetest.node_metadata_inventory_move_allow_all(
|
||||
pos, from_list, from_index, to_list, to_index, count, player)
|
||||
end,
|
||||
on_metadata_inventory_offer = function(pos, listname, index, stack, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to chest at "..minetest.pos_to_string(pos))
|
||||
return minetest.node_metadata_inventory_offer_allow_all(
|
||||
pos, listname, index, stack, player)
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, count, player)
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from chest at "..minetest.pos_to_string(pos))
|
||||
return minetest.node_metadata_inventory_take_allow_all(
|
||||
pos, listname, index, count, player)
|
||||
end,
|
||||
})
|
||||
|
||||
local function has_locked_chest_privilege(meta, player)
|
||||
if player:get_player_name() ~= meta:get_string("owner") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_node("default:chest_locked", {
|
||||
description = "Locked Chest",
|
||||
tile_images = {"default_chest_top.png", "default_chest_top.png", "default_chest_side.png",
|
||||
"default_chest_side.png", "default_chest_side.png", "default_chest_lock.png"},
|
||||
paramtype2 = "facedir",
|
||||
metadata_name = "locked_chest",
|
||||
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("owner", placer:get_player_name() or "")
|
||||
meta:set_string("infotext", "Locked Chest (owned by "..
|
||||
meta:get_string("owner")..")")
|
||||
end,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"list[current_name;main;0,0;8,4;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
meta:set_string("infotext", "Locked Chest")
|
||||
meta:set_string("owner", "")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("main", 8*4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
return inv:is_empty("main")
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index,
|
||||
to_list, to_index, count, player)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if not has_locked_chest_privilege(meta, player) then
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" tried to access a locked chest belonging to "..
|
||||
meta:get_string("owner").." at "..
|
||||
minetest.pos_to_string(pos))
|
||||
return
|
||||
end
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff in locked chest at "..minetest.pos_to_string(pos))
|
||||
return minetest.node_metadata_inventory_move_allow_all(
|
||||
pos, from_list, from_index, to_list, to_index, count, player)
|
||||
end,
|
||||
on_metadata_inventory_offer = function(pos, listname, index, stack, player)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if not has_locked_chest_privilege(meta, player) then
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" tried to access a locked chest belonging to "..
|
||||
meta:get_string("owner").." at "..
|
||||
minetest.pos_to_string(pos))
|
||||
return stack
|
||||
end
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" moves stuff to locked chest at "..minetest.pos_to_string(pos))
|
||||
return minetest.node_metadata_inventory_offer_allow_all(
|
||||
pos, listname, index, stack, player)
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, count, player)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if not has_locked_chest_privilege(meta, player) then
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" tried to access a locked chest belonging to "..
|
||||
meta:get_string("owner").." at "..
|
||||
minetest.pos_to_string(pos))
|
||||
return
|
||||
end
|
||||
minetest.log("action", player:get_player_name()..
|
||||
" takes stuff from locked chest at "..minetest.pos_to_string(pos))
|
||||
return minetest.node_metadata_inventory_take_allow_all(
|
||||
pos, listname, index, count, player)
|
||||
end,
|
||||
})
|
||||
|
||||
default.furnace_inactive_formspec =
|
||||
"invsize[8,9;]"..
|
||||
"image[2,2;1,1;default_furnace_fire_bg.png]"..
|
||||
"list[current_name;fuel;2,3;1,1;]"..
|
||||
"list[current_name;src;2,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]"
|
||||
|
||||
minetest.register_node("default:furnace", {
|
||||
description = "Furnace",
|
||||
tile_images = {"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"},
|
||||
paramtype2 = "facedir",
|
||||
metadata_name = "furnace",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec", default.furnace_inactive_formspec)
|
||||
meta:set_string("infotext", "Furnace")
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("fuel", 1)
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("fuel") then
|
||||
return false
|
||||
elseif not inv:is_empty("dst") then
|
||||
return false
|
||||
elseif not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("default:furnace_active", {
|
||||
description = "Furnace",
|
||||
tile_images = {"default_furnace_side.png", "default_furnace_side.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png", "default_furnace_side.png", "default_furnace_front_active.png"},
|
||||
paramtype2 = "facedir",
|
||||
light_source = 8,
|
||||
drop = "default:furnace",
|
||||
groups = {cracky=2},
|
||||
legacy_facedir_simple = true,
|
||||
sounds = default.node_sound_stone_defaults(),
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("formspec", default.furnace_inactive_formspec)
|
||||
meta:set_string("infotext", "Furnace");
|
||||
local inv = meta:get_inventory()
|
||||
inv:set_size("fuel", 1)
|
||||
inv:set_size("src", 1)
|
||||
inv:set_size("dst", 4)
|
||||
end,
|
||||
can_dig = function(pos,player)
|
||||
local meta = minetest.env:get_meta(pos);
|
||||
local inv = meta:get_inventory()
|
||||
if not inv:is_empty("fuel") then
|
||||
return false
|
||||
elseif not inv:is_empty("dst") then
|
||||
return false
|
||||
elseif not inv:is_empty("src") then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
})
|
||||
|
||||
function hacky_swap_node(pos,name)
|
||||
local node = minetest.env:get_node(pos)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local meta0 = meta:to_table()
|
||||
if node.name == name then
|
||||
return
|
||||
end
|
||||
node.name = name
|
||||
local meta0 = meta:to_table()
|
||||
minetest.env:set_node(pos,node)
|
||||
meta = minetest.env:get_meta(pos)
|
||||
meta:from_table(meta0)
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"default:furnace","default:furnace_active"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
for i, name in ipairs({
|
||||
"fuel_totaltime",
|
||||
"fuel_time",
|
||||
"src_totaltime",
|
||||
"src_time"
|
||||
}) do
|
||||
if meta:get_string(name) == "" then
|
||||
meta:set_float(name, 0.0)
|
||||
end
|
||||
end
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
local srclist = inv:get_list("src")
|
||||
local cooked = nil
|
||||
|
||||
if srclist then
|
||||
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
|
||||
end
|
||||
|
||||
local was_active = false
|
||||
|
||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||
was_active = true
|
||||
meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
|
||||
meta:set_float("src_time", meta:get_float("src_time") + 1)
|
||||
if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
|
||||
-- check if there's room for output in "dst" list
|
||||
if inv:room_for_item("dst",cooked.item) then
|
||||
-- Put result in "dst" list
|
||||
inv:add_item("dst", cooked.item)
|
||||
-- take stuff from "src" list
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack:take_item()
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
else
|
||||
print("Could not insert '"..cooked.item.."'")
|
||||
end
|
||||
meta:set_string("src_time", 0)
|
||||
end
|
||||
end
|
||||
|
||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||
local percent = math.floor(meta:get_float("fuel_time") /
|
||||
meta:get_float("fuel_totaltime") * 100)
|
||||
meta:set_string("infotext","Furnace active: "..percent.."%")
|
||||
hacky_swap_node(pos,"default:furnace_active")
|
||||
meta:set_string("formspec",
|
||||
"invsize[8,9;]"..
|
||||
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||
(100-percent)..":default_furnace_fire_fg.png]"..
|
||||
"list[current_name;fuel;2,3;1,1;]"..
|
||||
"list[current_name;src;2,1;1,1;]"..
|
||||
"list[current_name;dst;5,1;2,2;]"..
|
||||
"list[current_player;main;0,5;8,4;]")
|
||||
return
|
||||
end
|
||||
|
||||
local fuel = nil
|
||||
local cooked = nil
|
||||
local fuellist = inv:get_list("fuel")
|
||||
local srclist = inv:get_list("src")
|
||||
|
||||
if srclist then
|
||||
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
|
||||
end
|
||||
if fuellist then
|
||||
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
||||
end
|
||||
|
||||
if fuel.time <= 0 then
|
||||
meta:set_string("infotext","Furnace out of fuel")
|
||||
hacky_swap_node(pos,"default:furnace")
|
||||
meta:set_string("formspec", default.furnace_inactive_formspec)
|
||||
return
|
||||
end
|
||||
|
||||
if cooked.item:is_empty() then
|
||||
if was_active then
|
||||
meta:set_string("infotext","Furnace is empty")
|
||||
hacky_swap_node(pos,"default:furnace")
|
||||
meta:set_string("formspec", default.furnace_inactive_formspec)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
meta:set_string("fuel_totaltime", fuel.time)
|
||||
meta:set_string("fuel_time", 0)
|
||||
|
||||
local stack = inv:get_stack("fuel", 1)
|
||||
stack:take_item()
|
||||
inv:set_stack("fuel", 1, stack)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("default:cobble", {
|
||||
@@ -1526,6 +1821,57 @@ minetest.register_on_chat_message(function(name, message)
|
||||
end
|
||||
end)
|
||||
|
||||
--
|
||||
-- Test some things
|
||||
--
|
||||
|
||||
local function test_get_craft_result()
|
||||
print("test_get_craft_result()")
|
||||
-- normal
|
||||
local input = {
|
||||
method = "normal",
|
||||
width = 2,
|
||||
items = {"", "default:coal_lump", "", "default:stick"}
|
||||
}
|
||||
print("torch crafting input: "..dump(input))
|
||||
local output, decremented_input = minetest.get_craft_result(input)
|
||||
print("torch crafting output: "..dump(output))
|
||||
print("torch crafting decremented input: "..dump(decremented_input))
|
||||
assert(output.item)
|
||||
print("torch crafting output.item:to_table(): "..dump(output.item:to_table()))
|
||||
assert(output.item:get_name() == "default:torch")
|
||||
assert(output.item:get_count() == 4)
|
||||
-- fuel
|
||||
local input = {
|
||||
method = "fuel",
|
||||
width = 1,
|
||||
items = {"default:coal_lump"}
|
||||
}
|
||||
print("coal fuel input: "..dump(input))
|
||||
local output, decremented_input = minetest.get_craft_result(input)
|
||||
print("coal fuel output: "..dump(output))
|
||||
print("coal fuel decremented input: "..dump(decremented_input))
|
||||
assert(output.time)
|
||||
assert(output.time > 0)
|
||||
-- cook
|
||||
local input = {
|
||||
method = "cooking",
|
||||
width = 1,
|
||||
items = {"default:cobble"}
|
||||
}
|
||||
print("cobble cooking input: "..dump(output))
|
||||
local output, decremented_input = minetest.get_craft_result(input)
|
||||
print("cobble cooking output: "..dump(output))
|
||||
print("cobble cooking decremented input: "..dump(decremented_input))
|
||||
assert(output.time)
|
||||
assert(output.time > 0)
|
||||
assert(output.item)
|
||||
print("cobble cooking output.item:to_table(): "..dump(output.item:to_table()))
|
||||
assert(output.item:get_name() == "default:stone")
|
||||
assert(output.item:get_count() == 1)
|
||||
end
|
||||
test_get_craft_result()
|
||||
|
||||
--
|
||||
-- Done, print some random stuff
|
||||
--
|
||||
|
||||
BIN
games/minimal/mods/default/textures/default_furnace_fire_bg.png
Normal file
BIN
games/minimal/mods/default/textures/default_furnace_fire_bg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 313 B |
BIN
games/minimal/mods/default/textures/default_furnace_fire_fg.png
Normal file
BIN
games/minimal/mods/default/textures/default_furnace_fire_fg.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 865 B |
Binary file not shown.
|
After Width: | Height: | Size: 376 B |
@@ -6,6 +6,11 @@
|
||||
|
||||
experimental = {}
|
||||
|
||||
function experimental.print_to_everything(msg)
|
||||
minetest.log("action", msg)
|
||||
minetest.chat_send_all(msg)
|
||||
end
|
||||
|
||||
--[[
|
||||
experimental.player_visual_index = 0
|
||||
function switch_player_visual()
|
||||
@@ -97,235 +102,10 @@ function on_step(dtime)
|
||||
end
|
||||
minetest.register_globalstep(on_step)
|
||||
|
||||
-- An example furnace-thing implemented in Lua
|
||||
|
||||
--[[
|
||||
minetest.register_node("experimental:luafurnace", {
|
||||
tile_images = {"default_lava.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png", "default_furnace_side.png",
|
||||
"default_furnace_side.png", "default_furnace_front.png"},
|
||||
--inventory_image = "furnace_front.png",
|
||||
inventory_image = minetest.inventorycube("default_furnace_front.png"),
|
||||
paramtype = "facedir_simple",
|
||||
metadata_name = "generic",
|
||||
material = minetest.digprop_stonelike(3.0),
|
||||
})
|
||||
|
||||
minetest.register_on_placenode(function(pos, newnode, placer)
|
||||
if newnode.name == "experimental:luafurnace" then
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:inventory_set_list("fuel", {""})
|
||||
meta:inventory_set_list("src", {""})
|
||||
meta:inventory_set_list("dst", {"","","",""})
|
||||
meta:set_inventory_draw_spec(
|
||||
"invsize[8,9;]"
|
||||
.."list[current_name;fuel;2,3;1,1;]"
|
||||
.."list[current_name;src;2,1;1,1;]"
|
||||
.."list[current_name;dst;5,1;2,2;]"
|
||||
.."list[current_player;main;0,5;8,4;]"
|
||||
)
|
||||
|
||||
local total_cooked = 0;
|
||||
meta:set_string("total_cooked", total_cooked)
|
||||
meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"experimental:luafurnace"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
for i, name in ipairs({
|
||||
"fuel_totaltime",
|
||||
"fuel_time",
|
||||
"src_totaltime",
|
||||
"src_time"
|
||||
}) do
|
||||
if not meta:get_string(name) then
|
||||
meta:set_string(name, 0)
|
||||
end
|
||||
end
|
||||
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
local fuelitem = inv:get_stack("fuel", 1):peek_item()
|
||||
local srcitem = inv:get_stack("src", 1):peek_item()
|
||||
--print("fuelitem="..dump(fuelitem))
|
||||
--print("srcitem="..dump(srcitem))
|
||||
|
||||
local was_active = false
|
||||
|
||||
local src_cooktime = -1
|
||||
local result_stackstring = nil
|
||||
|
||||
if srcitem then
|
||||
local prop = get_item_definition(srcitem)
|
||||
if prop and prop.cookresult_itemstring ~= "" then
|
||||
result_stackstring = prop.cookresult_itemstring
|
||||
src_cooktime = prop.furnace_cooktime or 3
|
||||
end
|
||||
end
|
||||
|
||||
print("src_cooktime="..dump(src_cooktime))
|
||||
print("result_stackstring="..dump(result_stackstring))
|
||||
|
||||
if tonumber(meta:get_string("fuel_time")) < tonumber(meta:get_string("fuel_totaltime")) then
|
||||
was_active = true
|
||||
meta:set_string("fuel_time", tonumber(meta:get_string("fuel_time")) + 1)
|
||||
meta:set_string("src_time", tonumber(meta:get_string("src_time")) + 1)
|
||||
--print("result_stackstring="..dump(result_stackstring))
|
||||
--print('tonumber(meta:get_string("src_time"))='..dump(tonumber(meta:get_string("src_time"))))
|
||||
--print("src_cooktime="..dump(src_cooktime))
|
||||
if result_stackstring and tonumber(meta:get_string("src_time")) >= src_cooktime and src_cooktime >= 0 then
|
||||
-- Put result in "dst" list
|
||||
success = inv:autoinsert_stackstring("dst", result_stackstring)
|
||||
if not success then
|
||||
print("Could not autoinsert '"..result_stackstring.."'")
|
||||
end
|
||||
-- If succeeded, take stuff from "src" list
|
||||
if success then
|
||||
srcstack = inv:get_stack("src", 1)
|
||||
srcstack:take_item()
|
||||
inv:set_stack("src", 1, srcstack)
|
||||
end
|
||||
meta:set_string("src_time", 0)
|
||||
end
|
||||
end
|
||||
|
||||
if tonumber(meta:get_string("fuel_time")) < tonumber(meta:get_string("fuel_totaltime")) then
|
||||
meta:set_infotext("Furnace active: "..(tonumber(meta:get_string("fuel_time"))/tonumber(meta:get_string("fuel_totaltime"))*100).."%")
|
||||
return
|
||||
end
|
||||
|
||||
local srcitem = inv:get_stack("src", 1):peek_item()
|
||||
|
||||
local src_cooktime = 0
|
||||
local result_stackstring = nil
|
||||
|
||||
if srcitem then
|
||||
local prop = get_item_definition(srcitem)
|
||||
if prop and prop.cookresult_itemstring ~= "" then
|
||||
result_stackstring = prop.cookresult_itemstring
|
||||
src_cooktime = prop.furnace_cooktime or 3
|
||||
end
|
||||
end
|
||||
|
||||
local fuelitem = inv:get_stack("fuel", 1):peek_item()
|
||||
|
||||
if not result_stackstring or not fuelitem then
|
||||
if was_active then
|
||||
meta:set_infotext("Furnace is empty")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local burntime = -1
|
||||
if fuelitem then
|
||||
local prop = get_item_definition(fuelitem)
|
||||
if prop then
|
||||
burntime = prop.furnace_burntime or -1
|
||||
end
|
||||
end
|
||||
|
||||
if burntime <= 0 then
|
||||
meta:set_infotext("Furnace out of fuel")
|
||||
return
|
||||
end
|
||||
|
||||
meta:set_string("fuel_totaltime", burntime)
|
||||
meta:set_string("fuel_time", 0)
|
||||
|
||||
local stack = inv:get_stack("fuel", 1)
|
||||
stack:take_item()
|
||||
inv:set_stack("fuel", 1, stack)
|
||||
end,
|
||||
})
|
||||
minetest.register_abm({
|
||||
nodenames = {"experimental:luafurnace"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
local fuellist = meta:inventory_get_list("fuel")
|
||||
local srclist = meta:inventory_get_list("src")
|
||||
local dstlist = meta:inventory_get_list("dst")
|
||||
if fuellist == nil or srclist == nil or dstlist == nil then
|
||||
return
|
||||
end
|
||||
_, srcitem = stackstring_take_item(srclist[1])
|
||||
_, fuelitem = stackstring_take_item(fuellist[1])
|
||||
if not srcitem or not fuelitem then return end
|
||||
if fuelitem.type == "node" then
|
||||
local prop = minetest.registered_nodes[fuelitem.name]
|
||||
if prop == nil then return end
|
||||
if prop.furnace_burntime < 0 then return end
|
||||
else
|
||||
return
|
||||
end
|
||||
local resultstack = nil
|
||||
if srcitem.type == "node" then
|
||||
local prop = minetest.registered_nodes[srcitem.name]
|
||||
if prop == nil then return end
|
||||
if prop.cookresult_item == "" then return end
|
||||
resultstack = prop.cookresult_item
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
if resultstack == nil then
|
||||
return
|
||||
end
|
||||
|
||||
dstlist[1], success = stackstring_put_stackstring(dstlist[1], resultstack)
|
||||
if not success then
|
||||
return
|
||||
end
|
||||
|
||||
fuellist[1], _ = stackstring_take_item(fuellist[1])
|
||||
srclist[1], _ = stackstring_take_item(srclist[1])
|
||||
|
||||
meta:inventory_set_list("fuel", fuellist)
|
||||
meta:inventory_set_list("src", srclist)
|
||||
meta:inventory_set_list("dst", dstlist)
|
||||
|
||||
local total_cooked = meta:get_string("total_cooked")
|
||||
total_cooked = tonumber(total_cooked) + 1
|
||||
meta:set_string("total_cooked", total_cooked)
|
||||
meta:set_infotext("Lua Furnace: total cooked: "..total_cooked)
|
||||
end,
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = 'node "experimental:luafurnace" 1',
|
||||
recipe = {
|
||||
{'node "default:cobble"', 'node "default:cobble"', 'node "default:cobble"'},
|
||||
{'node "default:cobble"', 'node "default:steel_ingot"', 'node "default:cobble"'},
|
||||
{'node "default:cobble"', 'node "default:cobble"', 'node "default:cobble"'},
|
||||
}
|
||||
})
|
||||
--]]
|
||||
|
||||
--
|
||||
-- Random stuff
|
||||
--
|
||||
|
||||
--[[
|
||||
minetest.register_tool("experimental:horribletool", {
|
||||
image = "default_lava.png",
|
||||
basetime = 2.0
|
||||
dt_weight = 0.2
|
||||
dt_crackiness = 0.2
|
||||
dt_crumbliness = 0.2
|
||||
dt_cuttability = 0.2
|
||||
basedurability = 50
|
||||
dd_weight = -5
|
||||
dd_crackiness = -5
|
||||
dd_crumbliness = -5
|
||||
dd_cuttability = -5
|
||||
})
|
||||
--]]
|
||||
|
||||
--
|
||||
-- TNT (not functional)
|
||||
--
|
||||
@@ -662,6 +442,68 @@ minetest.register_abm({
|
||||
end,
|
||||
})--]]
|
||||
|
||||
minetest.register_node("experimental:tester_node_1", {
|
||||
description = "Tester Node 1",
|
||||
tile_images = {"wieldhand.png"},
|
||||
groups = {oddly_breakable_by_hand=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
|
||||
on_construct = function(pos)
|
||||
experimental.print_to_everything("experimental:tester_node_1:on_construct("..minetest.pos_to_string(pos)..")")
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
meta:set_string("mine", "test")
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
experimental.print_to_everything("experimental:tester_node_1:after_place_node("..minetest.pos_to_string(pos)..")")
|
||||
local meta = minetest.env:get_meta(pos)
|
||||
if meta:get_string("mine") == "test" then
|
||||
experimental.print_to_everything("correct metadata found")
|
||||
else
|
||||
experimental.print_to_everything("incorrect metadata found")
|
||||
end
|
||||
end,
|
||||
|
||||
on_destruct = function(pos)
|
||||
experimental.print_to_everything("experimental:tester_node_1:on_destruct("..minetest.pos_to_string(pos)..")")
|
||||
end,
|
||||
|
||||
after_destruct = function(pos)
|
||||
experimental.print_to_everything("experimental:tester_node_1:after_destruct("..minetest.pos_to_string(pos)..")")
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
experimental.print_to_everything("experimental:tester_node_1:after_dig_node("..minetest.pos_to_string(pos)..")")
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craftitem("experimental:tester_tool_1", {
|
||||
description = "Tester Tool 1",
|
||||
inventory_image = "experimental_tester_tool_1.png",
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
--print(dump(pointed_thing))
|
||||
if pointed_thing.type == "node" then
|
||||
if minetest.env:get_node(pointed_thing.under).name == "experimental:tester_node_1" then
|
||||
local p = pointed_thing.under
|
||||
minetest.log("action", "Tester tool used at "..minetest.pos_to_string(p))
|
||||
minetest.env:dig_node(p)
|
||||
else
|
||||
local p = pointed_thing.above
|
||||
minetest.log("action", "Tester tool used at "..minetest.pos_to_string(p))
|
||||
minetest.env:place_node(p, {name="experimental:tester_node_1"})
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = 'experimental:tester_tool_1',
|
||||
recipe = {
|
||||
{'group:crumbly'},
|
||||
{'group:crumbly'},
|
||||
}
|
||||
})
|
||||
|
||||
minetest.log("experimental modname="..dump(minetest.get_current_modname()))
|
||||
minetest.log("experimental modpath="..dump(minetest.get_modpath("experimental")))
|
||||
minetest.log("experimental worldpath="..dump(minetest.get_worldpath()))
|
||||
|
||||
@@ -11,5 +11,6 @@ minetest.register_on_newplayer(function(player)
|
||||
player:get_inventory():add_item('main', 'default:pick_mese')
|
||||
player:get_inventory():add_item('main', 'default:mese 99')
|
||||
player:get_inventory():add_item('main', 'default:water_source 99')
|
||||
player:get_inventory():add_item('main', 'experimental:tester_tool_1')
|
||||
end)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# Uncomment settings by removing the preceding #.
|
||||
#
|
||||
# Further documentation:
|
||||
# http://celeron.55.lt/~celeron55/minetest/wiki/doku.php
|
||||
# http://c55.me/minetest/wiki/doku.php
|
||||
#
|
||||
# NOTE: This file might not be up-to-date, refer to the
|
||||
# defaultsettings.cpp file for an up-to-date list:
|
||||
@@ -16,6 +16,7 @@
|
||||
#
|
||||
# A vim command to convert most of defaultsettings.cpp to conf file format:
|
||||
# :'<,'>s/\tg_settings\.setDefault("\([^"]*\)", "\([^"]*\)");.*/#\1 = \2/g
|
||||
# Note: Some of the settings are implemented in Lua
|
||||
|
||||
#
|
||||
# Client and server
|
||||
@@ -149,6 +150,8 @@
|
||||
#unlimited_player_transfer_distance = true
|
||||
# Whether to enable players killing each other
|
||||
#enable_pvp = true
|
||||
# If this is set, players will always (re)spawn at the given position
|
||||
#static_spawnpoint = 0, 10, 0
|
||||
|
||||
# Profiler data print interval. #0 = disable.
|
||||
#profiler_print_interval = 0
|
||||
@@ -161,14 +164,21 @@
|
||||
#max_simultaneous_block_sends_per_client = 2
|
||||
# how many blocks are flying in the wire simultaneously per server
|
||||
#max_simultaneous_block_sends_server_total = 8
|
||||
# From how far blocks are sent to clients (value * 16 nodes)
|
||||
#max_block_send_distance = 10
|
||||
# From how far blocks are generated for clients (value * 16 nodes)
|
||||
#max_block_generate_distance = 6
|
||||
# Interval of sending time of day to clients
|
||||
#time_send_interval = 5
|
||||
# Length of day/night cycle. 72=20min, 360=4min, 1=24hour, 0=day/night/whatever stays unchanged
|
||||
#time_speed = 96
|
||||
#server_unload_unused_data_timeout = 29
|
||||
# Interval of saving important changes in the world
|
||||
#server_map_save_interval = 5.3
|
||||
# To reduce lag, block transfers are slowed down when a player is building something.
|
||||
# This determines how long they are slowed down after placing or removing a node.
|
||||
#full_block_send_enable_min_time_from_building = 2.0
|
||||
|
||||
# Length of a server tick in dedicated server
|
||||
#dedicated_server_step = 0.05
|
||||
# Can be set to true to disable shutting down on invalid world data
|
||||
#ignore_world_load_errors = false
|
||||
|
||||
901
po/minetest.pot
901
po/minetest.pot
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: minetest\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2011-08-02 12:36+0200\n"
|
||||
"POT-Creation-Date: 2012-06-04 23:25+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -17,461 +17,278 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:84
|
||||
msgid "KEYBINDINGS"
|
||||
#: src/guiConfirmMenu.cpp:120
|
||||
msgid "Yes"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:94
|
||||
msgid "Forward"
|
||||
#: src/guiConfirmMenu.cpp:126
|
||||
msgid "No"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:111
|
||||
msgid "Backward"
|
||||
#: src/guiCreateWorld.cpp:116
|
||||
msgid "World name"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:127 src/guiKeyChangeMenu.h:38
|
||||
msgid "Left"
|
||||
#: src/guiCreateWorld.cpp:135
|
||||
msgid "Game"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:142 src/guiKeyChangeMenu.h:38
|
||||
msgid "Right"
|
||||
#: src/guiCreateWorld.cpp:159
|
||||
msgid "Create"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:158
|
||||
msgid "Use"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:173
|
||||
msgid "Sneak"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:189
|
||||
msgid "Jump"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:204
|
||||
msgid "Inventory"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:220
|
||||
msgid "Chat"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:236
|
||||
msgid "Toggle fly"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:251
|
||||
msgid "Toggle fast"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:266
|
||||
msgid "Range select"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:283
|
||||
msgid "Print stacks"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:298
|
||||
msgid "Save"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:304 src/guiKeyChangeMenu.h:33
|
||||
#: src/guiCreateWorld.cpp:165 src/guiKeyChangeMenu.cpp:374 src/keycode.cpp:221
|
||||
msgid "Cancel"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:537 src/guiKeyChangeMenu.cpp:542
|
||||
#: src/guiKeyChangeMenu.cpp:547 src/guiKeyChangeMenu.cpp:552
|
||||
#: src/guiKeyChangeMenu.cpp:557 src/guiKeyChangeMenu.cpp:562
|
||||
#: src/guiKeyChangeMenu.cpp:567 src/guiKeyChangeMenu.cpp:572
|
||||
#: src/guiKeyChangeMenu.cpp:577 src/guiKeyChangeMenu.cpp:582
|
||||
#: src/guiKeyChangeMenu.cpp:587 src/guiKeyChangeMenu.cpp:592
|
||||
#: src/guiKeyChangeMenu.cpp:597
|
||||
#: src/guiDeathScreen.cpp:96
|
||||
msgid "You died."
|
||||
msgstr ""
|
||||
|
||||
#: src/guiDeathScreen.cpp:104
|
||||
msgid "Respawn"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:111
|
||||
msgid "Keybindings. (If this menu screws up, remove stuff from minetest.conf)"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:121
|
||||
msgid "Forward"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:138
|
||||
msgid "Backward"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:154 src/keycode.cpp:226
|
||||
msgid "Left"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:169 src/keycode.cpp:226
|
||||
msgid "Right"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:185
|
||||
msgid "Use"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:200
|
||||
msgid "Sneak"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:216
|
||||
msgid "Jump"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:231
|
||||
msgid "Drop"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:246
|
||||
msgid "Inventory"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:262
|
||||
msgid "Chat"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:276
|
||||
msgid "Command"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:290
|
||||
msgid "Console"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:306
|
||||
msgid "Toggle fly"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:321
|
||||
msgid "Toggle fast"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:336
|
||||
msgid "Range select"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:353
|
||||
msgid "Print stacks"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:368
|
||||
msgid "Save"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.cpp:626 src/guiKeyChangeMenu.cpp:631
|
||||
#: src/guiKeyChangeMenu.cpp:636 src/guiKeyChangeMenu.cpp:641
|
||||
#: src/guiKeyChangeMenu.cpp:646 src/guiKeyChangeMenu.cpp:651
|
||||
#: src/guiKeyChangeMenu.cpp:656 src/guiKeyChangeMenu.cpp:661
|
||||
#: src/guiKeyChangeMenu.cpp:666 src/guiKeyChangeMenu.cpp:671
|
||||
#: src/guiKeyChangeMenu.cpp:676 src/guiKeyChangeMenu.cpp:681
|
||||
#: src/guiKeyChangeMenu.cpp:686 src/guiKeyChangeMenu.cpp:691
|
||||
#: src/guiKeyChangeMenu.cpp:696 src/guiKeyChangeMenu.cpp:701
|
||||
msgid "press Key"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:33
|
||||
msgid "Left Button"
|
||||
#: src/guiMainMenu.cpp:217
|
||||
msgid "Singleplayer"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:33
|
||||
msgid "Middle Button"
|
||||
#: src/guiMainMenu.cpp:218
|
||||
msgid "Multiplayer"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:33
|
||||
msgid "Right Button"
|
||||
#: src/guiMainMenu.cpp:219
|
||||
msgid "Advanced"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:33
|
||||
msgid "X Button 1"
|
||||
#: src/guiMainMenu.cpp:220
|
||||
msgid "Settings"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:34
|
||||
msgid "Back"
|
||||
#: src/guiMainMenu.cpp:221
|
||||
msgid "Credits"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:34
|
||||
msgid "Clear"
|
||||
#: src/guiMainMenu.cpp:252
|
||||
msgid "Select World:"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:34
|
||||
msgid "Return"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:34
|
||||
msgid "Tab"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:34
|
||||
msgid "X Button 2"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:35
|
||||
msgid "Capital"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:35
|
||||
msgid "Control"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:35
|
||||
msgid "Kana"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:35
|
||||
msgid "Menu"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:35
|
||||
msgid "Pause"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:35
|
||||
msgid "Shift"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:36
|
||||
msgid "Convert"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:36
|
||||
msgid "Escape"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:36
|
||||
msgid "Final"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:36
|
||||
msgid "Junja"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:36
|
||||
msgid "Kanji"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:36
|
||||
msgid "Nonconvert"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:37
|
||||
msgid "Accept"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:37
|
||||
msgid "End"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:37
|
||||
msgid "Home"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:37
|
||||
msgid "Mode Change"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:37
|
||||
msgid "Next"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:37
|
||||
msgid "Priot"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:37
|
||||
msgid "Space"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:38
|
||||
msgid "Down"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:38
|
||||
msgid "Execute"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:38
|
||||
msgid "Print"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:38
|
||||
msgid "Select"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:38
|
||||
msgid "Up"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:39
|
||||
#: src/guiMainMenu.cpp:274 src/keycode.cpp:227
|
||||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:39
|
||||
msgid "Help"
|
||||
#: src/guiMainMenu.cpp:281
|
||||
msgid "New"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:39
|
||||
msgid "Insert"
|
||||
#: src/guiMainMenu.cpp:289
|
||||
msgid "Configure"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:39
|
||||
msgid "Snapshot"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:42
|
||||
msgid "Left Windows"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:43
|
||||
msgid "Apps"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:43
|
||||
msgid "Numpad 0"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:43
|
||||
msgid "Numpad 1"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:43
|
||||
msgid "Right Windows"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:43
|
||||
msgid "Sleep"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:44
|
||||
msgid "Numpad 2"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:44
|
||||
msgid "Numpad 3"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:44
|
||||
msgid "Numpad 4"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:44
|
||||
msgid "Numpad 5"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:44
|
||||
msgid "Numpad 6"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:44
|
||||
msgid "Numpad 7"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:45
|
||||
msgid "Numpad *"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:45
|
||||
msgid "Numpad +"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:45
|
||||
msgid "Numpad -"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:45
|
||||
msgid "Numpad /"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:45
|
||||
msgid "Numpad 8"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:45
|
||||
msgid "Numpad 9"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:49
|
||||
msgid "Num Lock"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:49
|
||||
msgid "Scroll Lock"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:50
|
||||
msgid "Left Shift"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:50
|
||||
msgid "Right Shight"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:51
|
||||
msgid "Left Control"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:51
|
||||
msgid "Left Menu"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:51
|
||||
msgid "Right Control"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:51
|
||||
msgid "Right Menu"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:53
|
||||
msgid "Comma"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:53
|
||||
msgid "Minus"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:53
|
||||
msgid "Period"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:53
|
||||
msgid "Plus"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:57
|
||||
msgid "Attn"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:57
|
||||
msgid "CrSel"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:58
|
||||
msgid "Erase OEF"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:58
|
||||
msgid "ExSel"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:58
|
||||
msgid "OEM Clear"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:58
|
||||
msgid "PA1"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:58
|
||||
#: src/guiMainMenu.cpp:304 src/keycode.cpp:246
|
||||
msgid "Play"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiKeyChangeMenu.h:58
|
||||
msgid "Zoom"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:181
|
||||
msgid "Name/Password"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:206
|
||||
msgid "Address/Port"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:228
|
||||
msgid "Leave address blank to start a local server."
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:235
|
||||
msgid "Fancy trees"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:241
|
||||
msgid "Smooth Lighting"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:249
|
||||
msgid "Start Game / Connect"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:258
|
||||
msgid "Change keys"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:281
|
||||
#: src/guiMainMenu.cpp:315 src/guiMainMenu.cpp:492
|
||||
msgid "Creative Mode"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:287
|
||||
#: src/guiMainMenu.cpp:321 src/guiMainMenu.cpp:498
|
||||
msgid "Enable Damage"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:295
|
||||
msgid "Delete map"
|
||||
#: src/guiMainMenu.cpp:341 src/guiMainMenu.cpp:414
|
||||
msgid "Name/Password"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMessageMenu.cpp:94 src/guiTextInputMenu.cpp:112
|
||||
#: src/guiMainMenu.cpp:368 src/guiMainMenu.cpp:441
|
||||
msgid "Address/Port"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:394 src/guiMainMenu.cpp:473
|
||||
msgid "Start Game / Connect"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:464
|
||||
msgid "Leave address blank to start a local server."
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:505 src/guiMainMenu.cpp:833
|
||||
msgid "Delete world"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:512
|
||||
msgid "Create world"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:546
|
||||
msgid "Fancy trees"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:552
|
||||
msgid "Smooth Lighting"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:558
|
||||
msgid "3D Clouds"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:564
|
||||
msgid "Opaque water"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:573
|
||||
msgid "Change keys"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:804
|
||||
msgid "Address required."
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:822
|
||||
msgid "Cannot delete world: Nothing selected"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:837
|
||||
msgid "Files to be deleted"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:853
|
||||
msgid "Cannot create world: No games found"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:866
|
||||
msgid "Nothing here"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMainMenu.cpp:915
|
||||
msgid "Failed to delete all world files"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiMessageMenu.cpp:109 src/guiTextInputMenu.cpp:123
|
||||
msgid "Proceed"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiPasswordChange.cpp:103
|
||||
#: src/guiPasswordChange.cpp:108
|
||||
msgid "Old Password"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiPasswordChange.cpp:120
|
||||
#: src/guiPasswordChange.cpp:125
|
||||
msgid "New Password"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiPasswordChange.cpp:136
|
||||
#: src/guiPasswordChange.cpp:141
|
||||
msgid "Confirm Password"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiPasswordChange.cpp:153
|
||||
#: src/guiPasswordChange.cpp:158
|
||||
msgid "Change"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiPasswordChange.cpp:162
|
||||
#: src/guiPasswordChange.cpp:167
|
||||
msgid "Passwords do not match!"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiPauseMenu.cpp:111
|
||||
#: src/guiPauseMenu.cpp:118
|
||||
msgid "Continue"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiPauseMenu.cpp:118
|
||||
#: src/guiPauseMenu.cpp:127
|
||||
msgid "Change Password"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiPauseMenu.cpp:125
|
||||
msgid "Disconnect"
|
||||
#: src/guiPauseMenu.cpp:135
|
||||
msgid "Exit to Menu"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiPauseMenu.cpp:132
|
||||
#: src/guiPauseMenu.cpp:142
|
||||
msgid "Exit to OS"
|
||||
msgstr ""
|
||||
|
||||
#: src/guiPauseMenu.cpp:139
|
||||
#: src/guiPauseMenu.cpp:149
|
||||
msgid ""
|
||||
"Default Controls:\n"
|
||||
"- WASD: Walk\n"
|
||||
@@ -485,3 +302,325 @@ msgid ""
|
||||
"- ESC: This menu\n"
|
||||
"- T: Chat\n"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:221
|
||||
msgid "Left Button"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:221
|
||||
msgid "Middle Button"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:221
|
||||
msgid "Right Button"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:221
|
||||
msgid "X Button 1"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:222
|
||||
msgid "Back"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:222
|
||||
msgid "Clear"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:222
|
||||
msgid "Return"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:222
|
||||
msgid "Tab"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:222
|
||||
msgid "X Button 2"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:223
|
||||
msgid "Capital"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:223
|
||||
msgid "Control"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:223
|
||||
msgid "Kana"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:223
|
||||
msgid "Menu"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:223
|
||||
msgid "Pause"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:223
|
||||
msgid "Shift"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:224
|
||||
msgid "Convert"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:224
|
||||
msgid "Escape"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:224
|
||||
msgid "Final"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:224
|
||||
msgid "Junja"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:224
|
||||
msgid "Kanji"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:224
|
||||
msgid "Nonconvert"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:225
|
||||
msgid "Accept"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:225
|
||||
msgid "End"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:225
|
||||
msgid "Home"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:225
|
||||
msgid "Mode Change"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:225
|
||||
msgid "Next"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:225
|
||||
msgid "Prior"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:225
|
||||
msgid "Space"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:226
|
||||
msgid "Down"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:226
|
||||
msgid "Execute"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:226
|
||||
msgid "Print"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:226
|
||||
msgid "Select"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:226
|
||||
msgid "Up"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:227
|
||||
msgid "Help"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:227
|
||||
msgid "Insert"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:227
|
||||
msgid "Snapshot"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:230
|
||||
msgid "Left Windows"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:231
|
||||
msgid "Apps"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:231
|
||||
msgid "Numpad 0"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:231
|
||||
msgid "Numpad 1"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:231
|
||||
msgid "Right Windows"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:231
|
||||
msgid "Sleep"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:232
|
||||
msgid "Numpad 2"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:232
|
||||
msgid "Numpad 3"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:232
|
||||
msgid "Numpad 4"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:232
|
||||
msgid "Numpad 5"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:232
|
||||
msgid "Numpad 6"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:232
|
||||
msgid "Numpad 7"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:233
|
||||
msgid "Numpad *"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:233
|
||||
msgid "Numpad +"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:233
|
||||
msgid "Numpad -"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:233
|
||||
msgid "Numpad /"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:233
|
||||
msgid "Numpad 8"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:233
|
||||
msgid "Numpad 9"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:237
|
||||
msgid "Num Lock"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:237
|
||||
msgid "Scroll Lock"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:238
|
||||
msgid "Left Shift"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:238
|
||||
msgid "Right Shift"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:239
|
||||
msgid "Left Control"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:239
|
||||
msgid "Left Menu"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:239
|
||||
msgid "Right Control"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:239
|
||||
msgid "Right Menu"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:241
|
||||
msgid "Comma"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:241
|
||||
msgid "Minus"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:241
|
||||
msgid "Period"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:241
|
||||
msgid "Plus"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:245
|
||||
msgid "Attn"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:245
|
||||
msgid "CrSel"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:246
|
||||
msgid "Erase OEF"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:246
|
||||
msgid "ExSel"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:246
|
||||
msgid "OEM Clear"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:246
|
||||
msgid "PA1"
|
||||
msgstr ""
|
||||
|
||||
#: src/keycode.cpp:246
|
||||
msgid "Zoom"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.cpp:1379
|
||||
msgid "Main Menu"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.cpp:1601
|
||||
msgid "Failed to initialize world"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.cpp:1613
|
||||
msgid "No world selected and no address provided. Nothing to do."
|
||||
msgstr ""
|
||||
|
||||
#: src/main.cpp:1621
|
||||
msgid "Could not find or load game \""
|
||||
msgstr ""
|
||||
|
||||
#: src/main.cpp:1635
|
||||
msgid "Invalid gamespec."
|
||||
msgstr ""
|
||||
|
||||
#: src/main.cpp:1675
|
||||
msgid "Connection error (timed out?)"
|
||||
msgstr ""
|
||||
|
||||
#: src/main.cpp:1686
|
||||
msgid ""
|
||||
"\n"
|
||||
"Check debug.txt for details."
|
||||
msgstr ""
|
||||
|
||||
@@ -177,6 +177,7 @@ set(common_SRCS
|
||||
content_mapnode.cpp
|
||||
collision.cpp
|
||||
nodemetadata.cpp
|
||||
nodetimer.cpp
|
||||
serverobject.cpp
|
||||
noise.cpp
|
||||
porting.cpp
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -38,6 +38,13 @@ static inline bool is_base64(unsigned char c) {
|
||||
return (isalnum(c) || (c == '+') || (c == '/'));
|
||||
}
|
||||
|
||||
bool base64_is_valid(std::string const& s)
|
||||
{
|
||||
for(int i=0; i<s.size(); i++)
|
||||
if(!is_base64(s[i])) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
|
||||
std::string ret;
|
||||
int i = 0;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <string>
|
||||
|
||||
bool base64_is_valid(std::string const& s);
|
||||
std::string base64_encode(unsigned char const* , unsigned int len);
|
||||
std::string base64_decode(std::string const& s);
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -1740,33 +1740,23 @@ void Client::interact(u8 action, const PointedThing& pointed)
|
||||
Send(0, data, true);
|
||||
}
|
||||
|
||||
void Client::sendSignNodeText(v3s16 p, std::string text)
|
||||
void Client::sendNodemetaFields(v3s16 p, const std::string &formname,
|
||||
const std::map<std::string, std::string> &fields)
|
||||
{
|
||||
/*
|
||||
u16 command
|
||||
v3s16 p
|
||||
u16 textlen
|
||||
textdata
|
||||
*/
|
||||
std::ostringstream os(std::ios_base::binary);
|
||||
u8 buf[12];
|
||||
|
||||
// Write command
|
||||
writeU16(buf, TOSERVER_SIGNNODETEXT);
|
||||
os.write((char*)buf, 2);
|
||||
|
||||
// Write p
|
||||
writeV3S16(buf, p);
|
||||
os.write((char*)buf, 6);
|
||||
|
||||
u16 textlen = text.size();
|
||||
// Write text length
|
||||
writeS16(buf, textlen);
|
||||
os.write((char*)buf, 2);
|
||||
writeU16(os, TOSERVER_NODEMETA_FIELDS);
|
||||
writeV3S16(os, p);
|
||||
os<<serializeString(formname);
|
||||
writeU16(os, fields.size());
|
||||
for(std::map<std::string, std::string>::const_iterator
|
||||
i = fields.begin(); i != fields.end(); i++){
|
||||
const std::string &name = i->first;
|
||||
const std::string &value = i->second;
|
||||
os<<serializeString(name);
|
||||
os<<serializeLongString(value);
|
||||
}
|
||||
|
||||
// Write text
|
||||
os.write((char*)text.c_str(), textlen);
|
||||
|
||||
// Make data buffer
|
||||
std::string s = os.str();
|
||||
SharedBuffer<u8> data((u8*)s.c_str(), s.size());
|
||||
@@ -2348,32 +2338,41 @@ ClientEvent Client::getClientEvent()
|
||||
|
||||
void Client::afterContentReceived()
|
||||
{
|
||||
verbosestream<<"Client::afterContentReceived() started"<<std::endl;
|
||||
assert(m_itemdef_received);
|
||||
assert(m_nodedef_received);
|
||||
assert(m_media_received);
|
||||
|
||||
|
||||
// remove the information about which checksum each texture
|
||||
// ought to have
|
||||
m_media_name_sha1_map.clear();
|
||||
|
||||
// Rebuild inherited images and recreate textures
|
||||
verbosestream<<"Rebuilding images and textures"<<std::endl;
|
||||
m_tsrc->rebuildImagesAndTextures();
|
||||
|
||||
// Update texture atlas
|
||||
verbosestream<<"Updating texture atlas"<<std::endl;
|
||||
if(g_settings->getBool("enable_texture_atlas"))
|
||||
m_tsrc->buildMainAtlas(this);
|
||||
|
||||
// Update node aliases
|
||||
verbosestream<<"Updating node aliases"<<std::endl;
|
||||
m_nodedef->updateAliases(m_itemdef);
|
||||
|
||||
// Update node textures
|
||||
verbosestream<<"Updating node textures"<<std::endl;
|
||||
m_nodedef->updateTextures(m_tsrc);
|
||||
|
||||
// Update item textures and meshes
|
||||
verbosestream<<"Updating item textures and meshes"<<std::endl;
|
||||
m_itemdef->updateTexturesAndMeshes(this);
|
||||
|
||||
// Start mesh update thread after setting up content definitions
|
||||
verbosestream<<"Starting mesh update thread"<<std::endl;
|
||||
m_mesh_update_thread.Start();
|
||||
|
||||
verbosestream<<"Client::afterContentReceived() done"<<std::endl;
|
||||
}
|
||||
|
||||
float Client::getRTT(void)
|
||||
|
||||
13
src/client.h
13
src/client.h
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -210,11 +210,12 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
|
||||
|
||||
void interact(u8 action, const PointedThing& pointed);
|
||||
|
||||
void sendSignNodeText(v3s16 p, std::string text);
|
||||
void sendNodemetaFields(v3s16 p, const std::string &formname,
|
||||
const std::map<std::string, std::string> &fields);
|
||||
void sendInventoryAction(InventoryAction *a);
|
||||
void sendChatMessage(const std::wstring &message);
|
||||
void sendChangePassword(const std::wstring oldpassword,
|
||||
const std::wstring newpassword);
|
||||
const std::wstring newpassword);
|
||||
void sendDamage(u8 damage);
|
||||
void sendRespawn();
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -415,7 +415,7 @@ enum ToServerCommand
|
||||
wstring message
|
||||
*/
|
||||
|
||||
TOSERVER_SIGNNODETEXT = 0x33,
|
||||
TOSERVER_SIGNNODETEXT = 0x33, // obsolete
|
||||
/*
|
||||
u16 command
|
||||
v3s16 p
|
||||
@@ -484,6 +484,20 @@ enum ToServerCommand
|
||||
s32[len] sound_id
|
||||
*/
|
||||
|
||||
TOSERVER_NODEMETA_FIELDS = 0x3b,
|
||||
/*
|
||||
u16 command
|
||||
v3s16 p
|
||||
u16 len
|
||||
u8[len] form name (reserved for future use)
|
||||
u16 number of fields
|
||||
for each field:
|
||||
u16 len
|
||||
u8[len] field name
|
||||
u32 len
|
||||
u8[len] field value
|
||||
*/
|
||||
|
||||
TOSERVER_REQUEST_MEDIA = 0x40,
|
||||
/*
|
||||
u16 command
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
171
src/clouds.cpp
171
src/clouds.cpp
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -213,8 +213,7 @@ void Clouds::render()
|
||||
|
||||
v2f p0 = v2f(xi,zi)*cloud_size + world_center_of_drawing_in_noise_f;
|
||||
|
||||
video::S3DVertex v[4] =
|
||||
{
|
||||
video::S3DVertex v[4] = {
|
||||
video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 1),
|
||||
video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 1),
|
||||
video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 0),
|
||||
@@ -236,88 +235,88 @@ void Clouds::render()
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0: // top
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Normal = v3f(0,1,0);
|
||||
}
|
||||
v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz;
|
||||
v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz;
|
||||
v[2].Pos.X= rx; v[2].Pos.Y= ry; v[2].Pos.Z= rz;
|
||||
v[3].Pos.X= rx; v[3].Pos.Y= ry, v[3].Pos.Z=-rz;
|
||||
break;
|
||||
case 1: // back
|
||||
if(CONTAINS(xi, zi-1, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi, zi-1, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
}
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Color=c_side_1;
|
||||
v[j].Normal = v3f(0,0,-1);
|
||||
}
|
||||
v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz;
|
||||
v[1].Pos.X= rx; v[1].Pos.Y= ry; v[1].Pos.Z=-rz;
|
||||
v[2].Pos.X= rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz;
|
||||
v[3].Pos.X=-rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz;
|
||||
break;
|
||||
case 2: //right
|
||||
if(CONTAINS(xi+1, zi, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi+1, zi, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
}
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Color=c_side_2;
|
||||
v[j].Normal = v3f(1,0,0);
|
||||
}
|
||||
v[0].Pos.X= rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz;
|
||||
v[1].Pos.X= rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz;
|
||||
v[2].Pos.X= rx; v[2].Pos.Y=-ry; v[2].Pos.Z= rz;
|
||||
v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz;
|
||||
break;
|
||||
case 3: // front
|
||||
if(CONTAINS(xi, zi+1, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi, zi+1, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
}
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Color=c_side_1;
|
||||
v[j].Normal = v3f(0,0,-1);
|
||||
}
|
||||
v[0].Pos.X= rx; v[0].Pos.Y= ry; v[0].Pos.Z= rz;
|
||||
v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz;
|
||||
v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z= rz;
|
||||
v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z= rz;
|
||||
break;
|
||||
case 4: // left
|
||||
if(CONTAINS(xi-1, zi, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi-1, zi, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
}
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Color=c_side_2;
|
||||
v[j].Normal = v3f(-1,0,0);
|
||||
}
|
||||
v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z= rz;
|
||||
v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z=-rz;
|
||||
v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz;
|
||||
v[3].Pos.X=-rx; v[3].Pos.Y=-ry, v[3].Pos.Z= rz;
|
||||
break;
|
||||
case 5: // bottom
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Color=c_bottom;
|
||||
v[j].Normal = v3f(0,-1,0);
|
||||
}
|
||||
v[0].Pos.X= rx; v[0].Pos.Y=-ry; v[0].Pos.Z= rz;
|
||||
v[1].Pos.X=-rx; v[1].Pos.Y=-ry; v[1].Pos.Z= rz;
|
||||
v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz;
|
||||
v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz;
|
||||
break;
|
||||
case 0: // top
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Normal.set(0,1,0);
|
||||
}
|
||||
v[0].Pos.set(-rx, ry,-rz);
|
||||
v[1].Pos.set(-rx, ry, rz);
|
||||
v[2].Pos.set( rx, ry, rz);
|
||||
v[3].Pos.set( rx, ry,-rz);
|
||||
break;
|
||||
case 1: // back
|
||||
if(CONTAINS(xi, zi-1, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi, zi-1, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
}
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Color = c_side_1;
|
||||
v[j].Normal.set(0,0,-1);
|
||||
}
|
||||
v[0].Pos.set(-rx, ry,-rz);
|
||||
v[1].Pos.set( rx, ry,-rz);
|
||||
v[2].Pos.set( rx,-ry,-rz);
|
||||
v[3].Pos.set(-rx,-ry,-rz);
|
||||
break;
|
||||
case 2: //right
|
||||
if(CONTAINS(xi+1, zi, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi+1, zi, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
}
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Color = c_side_2;
|
||||
v[j].Normal.set(1,0,0);
|
||||
}
|
||||
v[0].Pos.set( rx, ry,-rz);
|
||||
v[1].Pos.set( rx, ry, rz);
|
||||
v[2].Pos.set( rx,-ry, rz);
|
||||
v[3].Pos.set( rx,-ry,-rz);
|
||||
break;
|
||||
case 3: // front
|
||||
if(CONTAINS(xi, zi+1, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi, zi+1, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
}
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Color = c_side_1;
|
||||
v[j].Normal.set(0,0,-1);
|
||||
}
|
||||
v[0].Pos.set( rx, ry, rz);
|
||||
v[1].Pos.set(-rx, ry, rz);
|
||||
v[2].Pos.set(-rx,-ry, rz);
|
||||
v[3].Pos.set( rx,-ry, rz);
|
||||
break;
|
||||
case 4: // left
|
||||
if(CONTAINS(xi-1, zi, cloud_radius_i)){
|
||||
u32 j = GETINDEX(xi-1, zi, cloud_radius_i);
|
||||
if(grid[j])
|
||||
continue;
|
||||
}
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Color = c_side_2;
|
||||
v[j].Normal.set(-1,0,0);
|
||||
}
|
||||
v[0].Pos.set(-rx, ry, rz);
|
||||
v[1].Pos.set(-rx, ry,-rz);
|
||||
v[2].Pos.set(-rx,-ry,-rz);
|
||||
v[3].Pos.set(-rx,-ry, rz);
|
||||
break;
|
||||
case 5: // bottom
|
||||
for(int j=0;j<4;j++){
|
||||
v[j].Color = c_bottom;
|
||||
v[j].Normal.set(0,-1,0);
|
||||
}
|
||||
v[0].Pos.set( rx,-ry, rz);
|
||||
v[1].Pos.set(-rx,-ry, rz);
|
||||
v[2].Pos.set(-rx,-ry,-rz);
|
||||
v[3].Pos.set( rx,-ry,-rz);
|
||||
break;
|
||||
}
|
||||
|
||||
v3f pos = v3f(p0.X,m_cloud_y,p0.Y);
|
||||
v3f pos(p0.X, m_cloud_y, p0.Y);
|
||||
|
||||
for(u16 i=0; i<4; i++)
|
||||
v[i].Pos += pos;
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -353,9 +353,11 @@ SharedBuffer<u8> IncomingSplitBuffer::insert(BufferedPacket &p, bool reliable)
|
||||
<<" != sp->reliable="<<sp->reliable
|
||||
<<std::endl;
|
||||
|
||||
// If chunk already exists, cancel
|
||||
// If chunk already exists, ignore it.
|
||||
// Sometimes two identical packets may arrive when there is network
|
||||
// lag and the server re-sends stuff.
|
||||
if(sp->chunks.find(chunk_num) != NULL)
|
||||
throw AlreadyExistsException("Chunk already in buffer");
|
||||
return SharedBuffer<u8>();
|
||||
|
||||
// Cut chunk data out of packet
|
||||
u32 chunkdatasize = p.data.getSize() - headersize;
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -868,7 +868,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||
if(n_plus_z_plus_y.getContent() == thiscontent)
|
||||
is_rail_z_plus_y[1] = true;
|
||||
|
||||
|
||||
bool is_rail_x_all[] = {false, false};
|
||||
bool is_rail_z_all[] = {false, false};
|
||||
is_rail_x_all[0]=is_rail_x[0] || is_rail_x_minus_y[0] || is_rail_x_plus_y[0];
|
||||
@@ -876,30 +875,69 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||
is_rail_z_all[0]=is_rail_z[0] || is_rail_z_minus_y[0] || is_rail_z_plus_y[0];
|
||||
is_rail_z_all[1]=is_rail_z[1] || is_rail_z_minus_y[1] || is_rail_z_plus_y[1];
|
||||
|
||||
bool is_straight = (is_rail_x_all[0] && is_rail_x_all[1]) || (is_rail_z_all[0] && is_rail_z_all[1]);//is really straight, rails on both sides
|
||||
int adjacencies = is_rail_x_all[0] + is_rail_x_all[1] + is_rail_z_all[0] + is_rail_z_all[1];
|
||||
// reasonable default, flat straight unrotated rail
|
||||
bool is_straight = true;
|
||||
int adjacencies = 0;
|
||||
int angle = 0;
|
||||
u8 tileindex = 0;
|
||||
|
||||
if (is_rail_x_plus_y[0] || is_rail_x_plus_y[1] || is_rail_z_plus_y[0] || is_rail_z_plus_y[1]) //is straight because sloped
|
||||
// check for sloped rail
|
||||
if (is_rail_x_plus_y[0] || is_rail_x_plus_y[1] || is_rail_z_plus_y[0] || is_rail_z_plus_y[1])
|
||||
{
|
||||
adjacencies = 5; //5 means sloped
|
||||
is_straight = true;
|
||||
is_straight = true; // sloped is always straight
|
||||
}
|
||||
else
|
||||
{
|
||||
// is really straight, rails on both sides
|
||||
is_straight = (is_rail_x_all[0] && is_rail_x_all[1]) || (is_rail_z_all[0] && is_rail_z_all[1]);
|
||||
adjacencies = is_rail_x_all[0] + is_rail_x_all[1] + is_rail_z_all[0] + is_rail_z_all[1];
|
||||
}
|
||||
|
||||
// Assign textures
|
||||
u8 tileindex = 0; // straight
|
||||
if(adjacencies < 2)
|
||||
tileindex = 0; // straight
|
||||
else if(adjacencies == 2)
|
||||
{
|
||||
if(is_straight)
|
||||
tileindex = 0; // straight
|
||||
else
|
||||
switch (adjacencies) {
|
||||
case 1:
|
||||
if(is_rail_x_all[0] || is_rail_x_all[1])
|
||||
angle = 90;
|
||||
break;
|
||||
case 2:
|
||||
if(!is_straight)
|
||||
tileindex = 1; // curved
|
||||
}
|
||||
else if(adjacencies == 3)
|
||||
if(is_rail_x_all[0] && is_rail_x_all[1])
|
||||
angle = 90;
|
||||
if(is_rail_z_all[0] && is_rail_z_all[1]){
|
||||
if (n_minus_z_plus_y.getContent() == thiscontent) angle = 180;
|
||||
}
|
||||
else if(is_rail_x_all[0] && is_rail_z_all[0])
|
||||
angle = 270;
|
||||
else if(is_rail_x_all[0] && is_rail_z_all[1])
|
||||
angle = 180;
|
||||
else if(is_rail_x_all[1] && is_rail_z_all[1])
|
||||
angle = 90;
|
||||
break;
|
||||
case 3:
|
||||
// here is where the potential to 'switch' a junction is, but not implemented at present
|
||||
tileindex = 2; // t-junction
|
||||
else if(adjacencies == 4)
|
||||
if(!is_rail_x_all[1])
|
||||
angle=180;
|
||||
if(!is_rail_z_all[0])
|
||||
angle=90;
|
||||
if(!is_rail_z_all[1])
|
||||
angle=270;
|
||||
break;
|
||||
case 4:
|
||||
tileindex = 3; // crossing
|
||||
break;
|
||||
case 5: //sloped
|
||||
if(is_rail_z_plus_y[0])
|
||||
angle = 180;
|
||||
if(is_rail_x_plus_y[0])
|
||||
angle = 90;
|
||||
if(is_rail_x_plus_y[1])
|
||||
angle = -90;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
TileSpec tile = getNodeTileN(n, p, tileindex, data);
|
||||
tile.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
|
||||
@@ -928,61 +966,10 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
||||
ap.x0(), ap.y0()),
|
||||
};
|
||||
|
||||
|
||||
// Rotate textures
|
||||
int angle = 0;
|
||||
|
||||
if(adjacencies == 1)
|
||||
{
|
||||
if(is_rail_x_all[0] || is_rail_x_all[1])
|
||||
angle = 90;
|
||||
}
|
||||
if(adjacencies == 2)
|
||||
{
|
||||
if(is_rail_x_all[0] && is_rail_x_all[1])
|
||||
{
|
||||
angle = 90;
|
||||
}
|
||||
if(is_rail_z_all[0] && is_rail_z_all[1])
|
||||
{
|
||||
if (n_minus_z_plus_y.getContent() == thiscontent) angle = 180;
|
||||
}
|
||||
else if(is_rail_x_all[0] && is_rail_z_all[0])
|
||||
angle = 270;
|
||||
else if(is_rail_x_all[0] && is_rail_z_all[1])
|
||||
angle = 180;
|
||||
else if(is_rail_x_all[1] && is_rail_z_all[1])
|
||||
angle = 90;
|
||||
}
|
||||
if(adjacencies == 3)
|
||||
{
|
||||
if(!is_rail_x_all[0])
|
||||
angle=0;
|
||||
if(!is_rail_x_all[1])
|
||||
angle=180;
|
||||
if(!is_rail_z_all[0])
|
||||
angle=90;
|
||||
if(!is_rail_z_all[1])
|
||||
angle=270;
|
||||
}
|
||||
//adjacencies 4: Crossing
|
||||
if(adjacencies == 5) //sloped
|
||||
{
|
||||
if(is_rail_z_plus_y[0])
|
||||
angle = 180;
|
||||
if(is_rail_x_plus_y[0])
|
||||
angle = 90;
|
||||
if(is_rail_x_plus_y[1])
|
||||
angle = -90;
|
||||
}
|
||||
|
||||
if(angle != 0) {
|
||||
for(u16 i=0; i<4; i++)
|
||||
vertices[i].Pos.rotateXZBy(angle);
|
||||
}
|
||||
|
||||
for(s32 i=0; i<4; i++)
|
||||
{
|
||||
if(angle != 0)
|
||||
vertices[i].Pos.rotateXZBy(angle);
|
||||
vertices[i].Pos += intToFloat(p, BS);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
/*
|
||||
Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "content_nodemeta.h"
|
||||
|
||||
#include <map>
|
||||
#include "inventory.h"
|
||||
#include "log.h"
|
||||
#include "utility.h"
|
||||
#include "craftdef.h"
|
||||
#include "gamedef.h"
|
||||
|
||||
class Inventory;
|
||||
#include <sstream>
|
||||
|
||||
#define NODEMETA_GENERIC 1
|
||||
#define NODEMETA_SIGN 14
|
||||
@@ -34,809 +29,167 @@ class Inventory;
|
||||
#define NODEMETA_FURNACE 16
|
||||
#define NODEMETA_LOCKABLE_CHEST 17
|
||||
|
||||
core::map<u16, NodeMetadata::Factory> NodeMetadata::m_types;
|
||||
core::map<std::string, NodeMetadata::Factory2> NodeMetadata::m_names;
|
||||
// Returns true if node timer must be set
|
||||
static bool content_nodemeta_deserialize_legacy_body(
|
||||
std::istream &is, s16 id, NodeMetadata *meta)
|
||||
{
|
||||
meta->clear();
|
||||
|
||||
class SignNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
SignNodeMetadata(IGameDef *gamedef, std::string text);
|
||||
//~SignNodeMetadata();
|
||||
|
||||
virtual u16 typeId() const;
|
||||
virtual const char* typeName() const
|
||||
{ return "sign"; }
|
||||
static NodeMetadata* create(std::istream &is, IGameDef *gamedef);
|
||||
static NodeMetadata* create(IGameDef *gamedef);
|
||||
virtual NodeMetadata* clone(IGameDef *gamedef);
|
||||
virtual void serializeBody(std::ostream &os);
|
||||
virtual std::string infoText();
|
||||
|
||||
virtual bool allowsTextInput(){ return true; }
|
||||
virtual std::string getText(){ return m_text; }
|
||||
virtual void setText(const std::string &t){ m_text = t; }
|
||||
|
||||
private:
|
||||
std::string m_text;
|
||||
};
|
||||
|
||||
class ChestNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
ChestNodeMetadata(IGameDef *gamedef);
|
||||
~ChestNodeMetadata();
|
||||
|
||||
virtual u16 typeId() const;
|
||||
virtual const char* typeName() const
|
||||
{ return "chest"; }
|
||||
static NodeMetadata* create(std::istream &is, IGameDef *gamedef);
|
||||
static NodeMetadata* create(IGameDef *gamedef);
|
||||
virtual NodeMetadata* clone(IGameDef *gamedef);
|
||||
virtual void serializeBody(std::ostream &os);
|
||||
virtual std::string infoText();
|
||||
virtual Inventory* getInventory() {return m_inventory;}
|
||||
virtual bool nodeRemovalDisabled();
|
||||
virtual std::string getInventoryDrawSpecString();
|
||||
|
||||
private:
|
||||
Inventory *m_inventory;
|
||||
};
|
||||
|
||||
class LockingChestNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
LockingChestNodeMetadata(IGameDef *gamedef);
|
||||
~LockingChestNodeMetadata();
|
||||
|
||||
virtual u16 typeId() const;
|
||||
virtual const char* typeName() const
|
||||
{ return "locked_chest"; }
|
||||
static NodeMetadata* create(std::istream &is, IGameDef *gamedef);
|
||||
static NodeMetadata* create(IGameDef *gamedef);
|
||||
virtual NodeMetadata* clone(IGameDef *gamedef);
|
||||
virtual void serializeBody(std::ostream &os);
|
||||
virtual std::string infoText();
|
||||
virtual Inventory* getInventory() {return m_inventory;}
|
||||
virtual bool nodeRemovalDisabled();
|
||||
virtual std::string getInventoryDrawSpecString();
|
||||
|
||||
virtual std::string getOwner(){ return m_text; }
|
||||
virtual void setOwner(std::string t){ m_text = t; }
|
||||
|
||||
private:
|
||||
Inventory *m_inventory;
|
||||
std::string m_text;
|
||||
};
|
||||
|
||||
class FurnaceNodeMetadata : public NodeMetadata
|
||||
{
|
||||
public:
|
||||
FurnaceNodeMetadata(IGameDef *gamedef);
|
||||
~FurnaceNodeMetadata();
|
||||
|
||||
virtual u16 typeId() const;
|
||||
virtual const char* typeName() const
|
||||
{ return "furnace"; }
|
||||
virtual NodeMetadata* clone(IGameDef *gamedef);
|
||||
static NodeMetadata* create(std::istream &is, IGameDef *gamedef);
|
||||
static NodeMetadata* create(IGameDef *gamedef);
|
||||
virtual void serializeBody(std::ostream &os);
|
||||
virtual std::string infoText();
|
||||
virtual Inventory* getInventory() {return m_inventory;}
|
||||
virtual void inventoryModified();
|
||||
virtual bool step(float dtime);
|
||||
virtual bool nodeRemovalDisabled();
|
||||
virtual std::string getInventoryDrawSpecString();
|
||||
|
||||
protected:
|
||||
bool getCookResult(bool remove, std::string &cookresult, float &cooktime);
|
||||
bool getBurnResult(bool remove, float &burntime);
|
||||
|
||||
private:
|
||||
Inventory *m_inventory;
|
||||
std::string m_infotext;
|
||||
float m_step_accumulator;
|
||||
float m_fuel_totaltime;
|
||||
float m_fuel_time;
|
||||
float m_src_totaltime;
|
||||
float m_src_time;
|
||||
};
|
||||
|
||||
/*
|
||||
SignNodeMetadata
|
||||
*/
|
||||
|
||||
// Prototype
|
||||
SignNodeMetadata proto_SignNodeMetadata(NULL, "");
|
||||
|
||||
SignNodeMetadata::SignNodeMetadata(IGameDef *gamedef, std::string text):
|
||||
NodeMetadata(gamedef),
|
||||
m_text(text)
|
||||
{
|
||||
NodeMetadata::registerType(typeId(), typeName(), create, create);
|
||||
}
|
||||
u16 SignNodeMetadata::typeId() const
|
||||
{
|
||||
return NODEMETA_SIGN;
|
||||
}
|
||||
NodeMetadata* SignNodeMetadata::create(std::istream &is, IGameDef *gamedef)
|
||||
{
|
||||
std::string text = deSerializeString(is);
|
||||
return new SignNodeMetadata(gamedef, text);
|
||||
}
|
||||
NodeMetadata* SignNodeMetadata::create(IGameDef *gamedef)
|
||||
{
|
||||
return new SignNodeMetadata(gamedef, "");
|
||||
}
|
||||
NodeMetadata* SignNodeMetadata::clone(IGameDef *gamedef)
|
||||
{
|
||||
return new SignNodeMetadata(gamedef, m_text);
|
||||
}
|
||||
void SignNodeMetadata::serializeBody(std::ostream &os)
|
||||
{
|
||||
os<<serializeString(m_text);
|
||||
}
|
||||
std::string SignNodeMetadata::infoText()
|
||||
{
|
||||
return std::string("\"")+m_text+"\"";
|
||||
}
|
||||
|
||||
/*
|
||||
ChestNodeMetadata
|
||||
*/
|
||||
|
||||
// Prototype
|
||||
ChestNodeMetadata proto_ChestNodeMetadata(NULL);
|
||||
|
||||
ChestNodeMetadata::ChestNodeMetadata(IGameDef *gamedef):
|
||||
NodeMetadata(gamedef)
|
||||
{
|
||||
NodeMetadata::registerType(typeId(), typeName(), create, create);
|
||||
m_inventory = NULL;
|
||||
}
|
||||
ChestNodeMetadata::~ChestNodeMetadata()
|
||||
{
|
||||
delete m_inventory;
|
||||
}
|
||||
u16 ChestNodeMetadata::typeId() const
|
||||
{
|
||||
return NODEMETA_CHEST;
|
||||
}
|
||||
NodeMetadata* ChestNodeMetadata::create(std::istream &is, IGameDef *gamedef)
|
||||
{
|
||||
ChestNodeMetadata *d = new ChestNodeMetadata(gamedef);
|
||||
d->m_inventory = new Inventory(gamedef->idef());
|
||||
d->m_inventory->deSerialize(is);
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* ChestNodeMetadata::create(IGameDef *gamedef)
|
||||
{
|
||||
ChestNodeMetadata *d = new ChestNodeMetadata(gamedef);
|
||||
d->m_inventory = new Inventory(gamedef->idef());
|
||||
d->m_inventory->addList("0", 8*4);
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* ChestNodeMetadata::clone(IGameDef *gamedef)
|
||||
{
|
||||
ChestNodeMetadata *d = new ChestNodeMetadata(gamedef);
|
||||
d->m_inventory = new Inventory(*m_inventory);
|
||||
return d;
|
||||
}
|
||||
void ChestNodeMetadata::serializeBody(std::ostream &os)
|
||||
{
|
||||
m_inventory->serialize(os);
|
||||
}
|
||||
std::string ChestNodeMetadata::infoText()
|
||||
{
|
||||
return "Chest";
|
||||
}
|
||||
bool ChestNodeMetadata::nodeRemovalDisabled()
|
||||
{
|
||||
/*
|
||||
Disable removal if chest contains something
|
||||
*/
|
||||
InventoryList *list = m_inventory->getList("0");
|
||||
if(list == NULL)
|
||||
return false;
|
||||
if(list->getUsedSlots() == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
std::string ChestNodeMetadata::getInventoryDrawSpecString()
|
||||
{
|
||||
return
|
||||
"invsize[8,9;]"
|
||||
"list[current_name;0;0,0;8,4;]"
|
||||
"list[current_player;main;0,5;8,4;]";
|
||||
}
|
||||
|
||||
/*
|
||||
LockingChestNodeMetadata
|
||||
*/
|
||||
|
||||
// Prototype
|
||||
LockingChestNodeMetadata proto_LockingChestNodeMetadata(NULL);
|
||||
|
||||
LockingChestNodeMetadata::LockingChestNodeMetadata(IGameDef *gamedef):
|
||||
NodeMetadata(gamedef)
|
||||
{
|
||||
NodeMetadata::registerType(typeId(), typeName(), create, create);
|
||||
m_inventory = NULL;
|
||||
}
|
||||
LockingChestNodeMetadata::~LockingChestNodeMetadata()
|
||||
{
|
||||
delete m_inventory;
|
||||
}
|
||||
u16 LockingChestNodeMetadata::typeId() const
|
||||
{
|
||||
return NODEMETA_LOCKABLE_CHEST;
|
||||
}
|
||||
NodeMetadata* LockingChestNodeMetadata::create(std::istream &is, IGameDef *gamedef)
|
||||
{
|
||||
LockingChestNodeMetadata *d = new LockingChestNodeMetadata(gamedef);
|
||||
d->setOwner(deSerializeString(is));
|
||||
d->m_inventory = new Inventory(gamedef->idef());
|
||||
d->m_inventory->deSerialize(is);
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* LockingChestNodeMetadata::create(IGameDef *gamedef)
|
||||
{
|
||||
LockingChestNodeMetadata *d = new LockingChestNodeMetadata(gamedef);
|
||||
d->m_inventory = new Inventory(gamedef->idef());
|
||||
d->m_inventory->addList("0", 8*4);
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* LockingChestNodeMetadata::clone(IGameDef *gamedef)
|
||||
{
|
||||
LockingChestNodeMetadata *d = new LockingChestNodeMetadata(gamedef);
|
||||
d->m_inventory = new Inventory(*m_inventory);
|
||||
return d;
|
||||
}
|
||||
void LockingChestNodeMetadata::serializeBody(std::ostream &os)
|
||||
{
|
||||
os<<serializeString(m_text);
|
||||
m_inventory->serialize(os);
|
||||
}
|
||||
std::string LockingChestNodeMetadata::infoText()
|
||||
{
|
||||
return "Locking Chest";
|
||||
}
|
||||
bool LockingChestNodeMetadata::nodeRemovalDisabled()
|
||||
{
|
||||
/*
|
||||
Disable removal if chest contains something
|
||||
*/
|
||||
InventoryList *list = m_inventory->getList("0");
|
||||
if(list == NULL)
|
||||
return false;
|
||||
if(list->getUsedSlots() == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
std::string LockingChestNodeMetadata::getInventoryDrawSpecString()
|
||||
{
|
||||
return
|
||||
"invsize[8,9;]"
|
||||
"list[current_name;0;0,0;8,4;]"
|
||||
"list[current_player;main;0,5;8,4;]";
|
||||
}
|
||||
|
||||
/*
|
||||
FurnaceNodeMetadata
|
||||
*/
|
||||
|
||||
// Prototype
|
||||
FurnaceNodeMetadata proto_FurnaceNodeMetadata(NULL);
|
||||
|
||||
FurnaceNodeMetadata::FurnaceNodeMetadata(IGameDef *gamedef):
|
||||
NodeMetadata(gamedef)
|
||||
{
|
||||
NodeMetadata::registerType(typeId(), typeName(), create, create);
|
||||
|
||||
m_inventory = NULL;
|
||||
|
||||
m_infotext = "Furnace is inactive";
|
||||
|
||||
m_step_accumulator = 0;
|
||||
m_fuel_totaltime = 0;
|
||||
m_fuel_time = 0;
|
||||
m_src_totaltime = 0;
|
||||
m_src_time = 0;
|
||||
}
|
||||
FurnaceNodeMetadata::~FurnaceNodeMetadata()
|
||||
{
|
||||
delete m_inventory;
|
||||
}
|
||||
u16 FurnaceNodeMetadata::typeId() const
|
||||
{
|
||||
return NODEMETA_FURNACE;
|
||||
}
|
||||
NodeMetadata* FurnaceNodeMetadata::clone(IGameDef *gamedef)
|
||||
{
|
||||
FurnaceNodeMetadata *d = new FurnaceNodeMetadata(m_gamedef);
|
||||
d->m_inventory = new Inventory(*m_inventory);
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* FurnaceNodeMetadata::create(std::istream &is, IGameDef *gamedef)
|
||||
{
|
||||
FurnaceNodeMetadata *d = new FurnaceNodeMetadata(gamedef);
|
||||
|
||||
d->m_inventory = new Inventory(gamedef->idef());
|
||||
d->m_inventory->deSerialize(is);
|
||||
|
||||
int temp = 0;
|
||||
is>>temp;
|
||||
d->m_fuel_totaltime = (float)temp/10;
|
||||
temp = 0;
|
||||
is>>temp;
|
||||
d->m_fuel_time = (float)temp/10;
|
||||
temp = 0;
|
||||
is>>temp;
|
||||
d->m_src_totaltime = (float)temp/10;
|
||||
temp = 0;
|
||||
is>>temp;
|
||||
d->m_src_time = (float)temp/10;
|
||||
|
||||
if(is.eof())
|
||||
if(id == NODEMETA_GENERIC) // GenericNodeMetadata (0.4-dev)
|
||||
{
|
||||
// Old furnaces didn't serialize src_totaltime and src_time
|
||||
d->m_src_totaltime = 0;
|
||||
d->m_src_time = 0;
|
||||
d->m_infotext = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
// New furnaces also serialize the infotext (so that the
|
||||
// client doesn't need to have the list of cooking recipes).
|
||||
d->m_infotext = deSerializeJsonString(is);
|
||||
}
|
||||
meta->getInventory()->deSerialize(is);
|
||||
deSerializeLongString(is); // m_text
|
||||
deSerializeString(is); // m_owner
|
||||
|
||||
return d;
|
||||
}
|
||||
NodeMetadata* FurnaceNodeMetadata::create(IGameDef *gamedef)
|
||||
{
|
||||
FurnaceNodeMetadata *d = new FurnaceNodeMetadata(gamedef);
|
||||
d->m_inventory = new Inventory(gamedef->idef());
|
||||
d->m_inventory->addList("fuel", 1);
|
||||
d->m_inventory->addList("src", 1);
|
||||
d->m_inventory->addList("dst", 4);
|
||||
return d;
|
||||
}
|
||||
void FurnaceNodeMetadata::serializeBody(std::ostream &os)
|
||||
{
|
||||
m_inventory->serialize(os);
|
||||
os<<itos(m_fuel_totaltime*10)<<" ";
|
||||
os<<itos(m_fuel_time*10)<<" ";
|
||||
os<<itos(m_src_totaltime*10)<<" ";
|
||||
os<<itos(m_src_time*10)<<" ";
|
||||
os<<serializeJsonString(m_infotext);
|
||||
}
|
||||
std::string FurnaceNodeMetadata::infoText()
|
||||
{
|
||||
return m_infotext;
|
||||
}
|
||||
bool FurnaceNodeMetadata::nodeRemovalDisabled()
|
||||
{
|
||||
/*
|
||||
Disable removal if furnace is not empty
|
||||
*/
|
||||
InventoryList *list[3] = {m_inventory->getList("src"),
|
||||
m_inventory->getList("dst"), m_inventory->getList("fuel")};
|
||||
|
||||
for(int i = 0; i < 3; i++) {
|
||||
if(list[i] == NULL)
|
||||
continue;
|
||||
if(list[i]->getUsedSlots() == 0)
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
void FurnaceNodeMetadata::inventoryModified()
|
||||
{
|
||||
infostream<<"Furnace inventory modification callback"<<std::endl;
|
||||
}
|
||||
bool FurnaceNodeMetadata::step(float dtime)
|
||||
{
|
||||
if(dtime > 60.0)
|
||||
infostream<<"Furnace stepping a long time ("<<dtime<<")"<<std::endl;
|
||||
|
||||
InventoryList *dst_list = m_inventory->getList("dst");
|
||||
assert(dst_list);
|
||||
|
||||
// Update at a fixed frequency
|
||||
const float interval = 2.0;
|
||||
m_step_accumulator += dtime;
|
||||
bool changed = false;
|
||||
while(m_step_accumulator > interval)
|
||||
{
|
||||
m_step_accumulator -= interval;
|
||||
dtime = interval;
|
||||
|
||||
//infostream<<"Furnace step dtime="<<dtime<<std::endl;
|
||||
|
||||
bool changed_this_loop = false;
|
||||
|
||||
// Check
|
||||
// 1. if the source item is cookable
|
||||
// 2. if there is room for the cooked item
|
||||
std::string cookresult;
|
||||
float cooktime;
|
||||
bool cookable = getCookResult(false, cookresult, cooktime);
|
||||
ItemStack cookresult_item;
|
||||
bool room_available = false;
|
||||
if(cookable)
|
||||
{
|
||||
cookresult_item.deSerialize(cookresult, m_gamedef->idef());
|
||||
room_available = dst_list->roomForItem(cookresult_item);
|
||||
}
|
||||
|
||||
// Step fuel time
|
||||
bool burning = (m_fuel_time < m_fuel_totaltime);
|
||||
if(burning)
|
||||
{
|
||||
changed_this_loop = true;
|
||||
m_fuel_time += dtime;
|
||||
}
|
||||
|
||||
std::string infotext;
|
||||
if(room_available)
|
||||
{
|
||||
float burntime;
|
||||
if(burning)
|
||||
{
|
||||
changed_this_loop = true;
|
||||
m_src_time += dtime;
|
||||
m_src_totaltime = cooktime;
|
||||
infotext = "Furnace is cooking";
|
||||
}
|
||||
else if(getBurnResult(true, burntime))
|
||||
{
|
||||
// Fuel inserted
|
||||
changed_this_loop = true;
|
||||
m_fuel_time = 0;
|
||||
m_fuel_totaltime = burntime;
|
||||
//m_src_time += dtime;
|
||||
//m_src_totaltime = cooktime;
|
||||
infotext = "Furnace is cooking";
|
||||
}
|
||||
else
|
||||
{
|
||||
m_src_time = 0;
|
||||
m_src_totaltime = 0;
|
||||
infotext = "Furnace is out of fuel";
|
||||
}
|
||||
if(m_src_totaltime > 0.001 && m_src_time >= m_src_totaltime)
|
||||
{
|
||||
// One item fully cooked
|
||||
changed_this_loop = true;
|
||||
dst_list->addItem(cookresult_item);
|
||||
getCookResult(true, cookresult, cooktime); // decrement source
|
||||
m_src_totaltime = 0;
|
||||
m_src_time = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not cookable or no room available
|
||||
m_src_totaltime = 0;
|
||||
m_src_time = 0;
|
||||
if(cookable)
|
||||
infotext = "Furnace is overloaded";
|
||||
else if(burning)
|
||||
infotext = "Furnace is active";
|
||||
else
|
||||
{
|
||||
infotext = "Furnace is inactive";
|
||||
m_fuel_totaltime = 0;
|
||||
m_fuel_time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Do this so it doesn't always show (0%) for weak fuel
|
||||
if(m_fuel_totaltime > 3) {
|
||||
infotext += " (";
|
||||
infotext += itos(m_fuel_time/m_fuel_totaltime*100);
|
||||
infotext += "%)";
|
||||
}
|
||||
|
||||
if(infotext != m_infotext)
|
||||
{
|
||||
m_infotext = infotext;
|
||||
changed_this_loop = true;
|
||||
}
|
||||
|
||||
if(burning && m_fuel_time >= m_fuel_totaltime)
|
||||
{
|
||||
m_fuel_time = 0;
|
||||
m_fuel_totaltime = 0;
|
||||
}
|
||||
|
||||
if(changed_this_loop)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_step_accumulator = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
std::string FurnaceNodeMetadata::getInventoryDrawSpecString()
|
||||
{
|
||||
return
|
||||
"invsize[8,9;]"
|
||||
"list[current_name;fuel;2,3;1,1;]"
|
||||
"list[current_name;src;2,1;1,1;]"
|
||||
"list[current_name;dst;5,1;2,2;]"
|
||||
"list[current_player;main;0,5;8,4;]";
|
||||
}
|
||||
bool FurnaceNodeMetadata::getCookResult(bool remove,
|
||||
std::string &cookresult, float &cooktime)
|
||||
{
|
||||
std::vector<ItemStack> items;
|
||||
InventoryList *src_list = m_inventory->getList("src");
|
||||
assert(src_list);
|
||||
items.push_back(src_list->getItem(0));
|
||||
|
||||
CraftInput ci(CRAFT_METHOD_COOKING, 1, items);
|
||||
CraftOutput co;
|
||||
bool found = m_gamedef->getCraftDefManager()->getCraftResult(
|
||||
ci, co, remove, m_gamedef);
|
||||
if(remove)
|
||||
src_list->changeItem(0, ci.items[0]);
|
||||
|
||||
cookresult = co.item;
|
||||
cooktime = co.time;
|
||||
return found;
|
||||
}
|
||||
bool FurnaceNodeMetadata::getBurnResult(bool remove, float &burntime)
|
||||
{
|
||||
std::vector<ItemStack> items;
|
||||
InventoryList *fuel_list = m_inventory->getList("fuel");
|
||||
assert(fuel_list);
|
||||
items.push_back(fuel_list->getItem(0));
|
||||
|
||||
CraftInput ci(CRAFT_METHOD_FUEL, 1, items);
|
||||
CraftOutput co;
|
||||
bool found = m_gamedef->getCraftDefManager()->getCraftResult(
|
||||
ci, co, remove, m_gamedef);
|
||||
if(remove)
|
||||
fuel_list->changeItem(0, ci.items[0]);
|
||||
|
||||
burntime = co.time;
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
GenericNodeMetadata
|
||||
*/
|
||||
|
||||
class GenericNodeMetadata : public NodeMetadata
|
||||
{
|
||||
private:
|
||||
Inventory *m_inventory;
|
||||
std::string m_text;
|
||||
std::string m_owner;
|
||||
|
||||
std::string m_infotext;
|
||||
std::string m_inventorydrawspec;
|
||||
bool m_allow_text_input;
|
||||
bool m_removal_disabled;
|
||||
bool m_enforce_owner;
|
||||
|
||||
bool m_inventory_modified;
|
||||
bool m_text_modified;
|
||||
|
||||
std::map<std::string, std::string> m_stringvars;
|
||||
|
||||
public:
|
||||
u16 typeId() const
|
||||
{
|
||||
return NODEMETA_GENERIC;
|
||||
}
|
||||
const char* typeName() const
|
||||
{
|
||||
return "generic";
|
||||
}
|
||||
|
||||
GenericNodeMetadata(IGameDef *gamedef):
|
||||
NodeMetadata(gamedef),
|
||||
|
||||
m_inventory(NULL),
|
||||
m_text(""),
|
||||
m_owner(""),
|
||||
|
||||
m_infotext("GenericNodeMetadata"),
|
||||
m_inventorydrawspec(""),
|
||||
m_allow_text_input(false),
|
||||
m_removal_disabled(false),
|
||||
m_enforce_owner(false),
|
||||
|
||||
m_inventory_modified(false),
|
||||
m_text_modified(false)
|
||||
{
|
||||
NodeMetadata::registerType(typeId(), typeName(), create, create);
|
||||
}
|
||||
virtual ~GenericNodeMetadata()
|
||||
{
|
||||
delete m_inventory;
|
||||
}
|
||||
NodeMetadata* clone(IGameDef *gamedef)
|
||||
{
|
||||
GenericNodeMetadata *d = new GenericNodeMetadata(m_gamedef);
|
||||
|
||||
d->m_inventory = new Inventory(*m_inventory);
|
||||
d->m_text = m_text;
|
||||
d->m_owner = m_owner;
|
||||
|
||||
d->m_infotext = m_infotext;
|
||||
d->m_inventorydrawspec = m_inventorydrawspec;
|
||||
d->m_allow_text_input = m_allow_text_input;
|
||||
d->m_removal_disabled = m_removal_disabled;
|
||||
d->m_enforce_owner = m_enforce_owner;
|
||||
d->m_inventory_modified = m_inventory_modified;
|
||||
d->m_text_modified = m_text_modified;
|
||||
return d;
|
||||
}
|
||||
static NodeMetadata* create(IGameDef *gamedef)
|
||||
{
|
||||
GenericNodeMetadata *d = new GenericNodeMetadata(gamedef);
|
||||
d->m_inventory = new Inventory(gamedef->idef());
|
||||
return d;
|
||||
}
|
||||
static NodeMetadata* create(std::istream &is, IGameDef *gamedef)
|
||||
{
|
||||
GenericNodeMetadata *d = new GenericNodeMetadata(gamedef);
|
||||
|
||||
d->m_inventory = new Inventory(gamedef->idef());
|
||||
d->m_inventory->deSerialize(is);
|
||||
d->m_text = deSerializeLongString(is);
|
||||
d->m_owner = deSerializeString(is);
|
||||
|
||||
d->m_infotext = deSerializeString(is);
|
||||
d->m_inventorydrawspec = deSerializeString(is);
|
||||
d->m_allow_text_input = readU8(is);
|
||||
d->m_removal_disabled = readU8(is);
|
||||
d->m_enforce_owner = readU8(is);
|
||||
meta->setString("infotext",deSerializeString(is));
|
||||
meta->setString("formspec",deSerializeString(is));
|
||||
readU8(is); // m_allow_text_input
|
||||
readU8(is); // m_allow_removal
|
||||
readU8(is); // m_enforce_owner
|
||||
|
||||
int num_vars = readU32(is);
|
||||
for(int i=0; i<num_vars; i++){
|
||||
std::string name = deSerializeString(is);
|
||||
std::string var = deSerializeLongString(is);
|
||||
d->m_stringvars[name] = var;
|
||||
meta->setString(name, var);
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
void serializeBody(std::ostream &os)
|
||||
{
|
||||
m_inventory->serialize(os);
|
||||
os<<serializeLongString(m_text);
|
||||
os<<serializeString(m_owner);
|
||||
|
||||
os<<serializeString(m_infotext);
|
||||
os<<serializeString(m_inventorydrawspec);
|
||||
writeU8(os, m_allow_text_input);
|
||||
writeU8(os, m_removal_disabled);
|
||||
writeU8(os, m_enforce_owner);
|
||||
|
||||
int num_vars = m_stringvars.size();
|
||||
writeU32(os, num_vars);
|
||||
for(std::map<std::string, std::string>::iterator
|
||||
i = m_stringvars.begin(); i != m_stringvars.end(); i++){
|
||||
os<<serializeString(i->first);
|
||||
os<<serializeLongString(i->second);
|
||||
}
|
||||
}
|
||||
|
||||
std::string infoText()
|
||||
{
|
||||
return m_infotext;
|
||||
}
|
||||
Inventory* getInventory()
|
||||
{
|
||||
return m_inventory;
|
||||
}
|
||||
void inventoryModified()
|
||||
{
|
||||
m_inventory_modified = true;
|
||||
}
|
||||
bool step(float dtime)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool nodeRemovalDisabled()
|
||||
else if(id == NODEMETA_SIGN) // SignNodeMetadata
|
||||
{
|
||||
return m_removal_disabled;
|
||||
meta->setString("text", deSerializeString(is));
|
||||
//meta->setString("infotext","\"${text}\"");
|
||||
meta->setString("infotext",
|
||||
std::string("\"") + meta->getString("text") + "\"");
|
||||
meta->setString("formspec","hack:sign_text_input");
|
||||
return false;
|
||||
}
|
||||
std::string getInventoryDrawSpecString()
|
||||
else if(id == NODEMETA_CHEST) // ChestNodeMetadata
|
||||
{
|
||||
return m_inventorydrawspec;
|
||||
}
|
||||
bool allowsTextInput()
|
||||
{
|
||||
return m_allow_text_input;
|
||||
}
|
||||
std::string getText()
|
||||
{
|
||||
return m_text;
|
||||
}
|
||||
void setText(const std::string &t)
|
||||
{
|
||||
m_text = t;
|
||||
m_text_modified = true;
|
||||
}
|
||||
std::string getOwner()
|
||||
{
|
||||
if(m_enforce_owner)
|
||||
return m_owner;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
void setOwner(std::string t)
|
||||
{
|
||||
m_owner = t;
|
||||
}
|
||||
|
||||
/* Interface for GenericNodeMetadata */
|
||||
meta->getInventory()->deSerialize(is);
|
||||
|
||||
void setInfoText(const std::string &text)
|
||||
{
|
||||
infostream<<"GenericNodeMetadata::setInfoText(\""
|
||||
<<text<<"\")"<<std::endl;
|
||||
m_infotext = text;
|
||||
// Rename inventory list "0" to "main"
|
||||
Inventory *inv = meta->getInventory();
|
||||
if(!inv->getList("main") && inv->getList("0")){
|
||||
inv->getList("0")->setName("main");
|
||||
}
|
||||
assert(inv->getList("main") && !inv->getList("0"));
|
||||
|
||||
meta->setString("formspec","invsize[8,9;]"
|
||||
"list[current_name;main;0,0;8,4;]"
|
||||
"list[current_player;main;0,5;8,4;]");
|
||||
return false;
|
||||
}
|
||||
void setInventoryDrawSpec(const std::string &text)
|
||||
else if(id == NODEMETA_LOCKABLE_CHEST) // LockingChestNodeMetadata
|
||||
{
|
||||
m_inventorydrawspec = text;
|
||||
}
|
||||
void setAllowTextInput(bool b)
|
||||
{
|
||||
m_allow_text_input = b;
|
||||
}
|
||||
void setRemovalDisabled(bool b)
|
||||
{
|
||||
m_removal_disabled = b;
|
||||
}
|
||||
void setEnforceOwner(bool b)
|
||||
{
|
||||
m_enforce_owner = b;
|
||||
}
|
||||
bool isInventoryModified()
|
||||
{
|
||||
return m_inventory_modified;
|
||||
}
|
||||
void resetInventoryModified()
|
||||
{
|
||||
m_inventory_modified = false;
|
||||
}
|
||||
bool isTextModified()
|
||||
{
|
||||
return m_text_modified;
|
||||
}
|
||||
void resetTextModified()
|
||||
{
|
||||
m_text_modified = false;
|
||||
}
|
||||
void setString(const std::string &name, const std::string &var)
|
||||
{
|
||||
m_stringvars[name] = var;
|
||||
}
|
||||
std::string getString(const std::string &name)
|
||||
{
|
||||
std::map<std::string, std::string>::iterator i;
|
||||
i = m_stringvars.find(name);
|
||||
if(i == m_stringvars.end())
|
||||
return "";
|
||||
return i->second;
|
||||
}
|
||||
};
|
||||
meta->setString("owner", deSerializeString(is));
|
||||
meta->getInventory()->deSerialize(is);
|
||||
|
||||
// Prototype
|
||||
GenericNodeMetadata proto_GenericNodeMetadata(NULL);
|
||||
// Rename inventory list "0" to "main"
|
||||
Inventory *inv = meta->getInventory();
|
||||
if(!inv->getList("main") && inv->getList("0")){
|
||||
inv->getList("0")->setName("main");
|
||||
}
|
||||
assert(inv->getList("main") && !inv->getList("0"));
|
||||
|
||||
meta->setString("formspec","invsize[8,9;]"
|
||||
"list[current_name;main;0,0;8,4;]"
|
||||
"list[current_player;main;0,5;8,4;]");
|
||||
return false;
|
||||
}
|
||||
else if(id == NODEMETA_FURNACE) // FurnaceNodeMetadata
|
||||
{
|
||||
meta->getInventory()->deSerialize(is);
|
||||
int temp = 0;
|
||||
is>>temp;
|
||||
meta->setString("fuel_totaltime", ftos((float)temp/10));
|
||||
temp = 0;
|
||||
is>>temp;
|
||||
meta->setString("fuel_time", ftos((float)temp/10));
|
||||
temp = 0;
|
||||
is>>temp;
|
||||
//meta->setString("src_totaltime", ftos((float)temp/10));
|
||||
temp = 0;
|
||||
is>>temp;
|
||||
meta->setString("src_time", ftos((float)temp/10));
|
||||
|
||||
meta->setString("formspec","invsize[8,9;]"
|
||||
"list[current_name;fuel;2,3;1,1;]"
|
||||
"list[current_name;src;2,1;1,1;]"
|
||||
"list[current_name;dst;5,1;2,2;]"
|
||||
"list[current_player;main;0,5;8,4;]");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw SerializationError("Unknown legacy node metadata");
|
||||
}
|
||||
}
|
||||
|
||||
static bool content_nodemeta_deserialize_legacy_meta(
|
||||
std::istream &is, NodeMetadata *meta)
|
||||
{
|
||||
// Read id
|
||||
s16 id = readS16(is);
|
||||
|
||||
// Read data
|
||||
std::string data = deSerializeString(is);
|
||||
std::istringstream tmp_is(data, std::ios::binary);
|
||||
return content_nodemeta_deserialize_legacy_body(tmp_is, id, meta);
|
||||
}
|
||||
|
||||
void content_nodemeta_deserialize_legacy(std::istream &is,
|
||||
NodeMetadataList *meta, NodeTimerList *timers,
|
||||
IGameDef *gamedef)
|
||||
{
|
||||
meta->clear();
|
||||
timers->clear();
|
||||
|
||||
u16 version = readU16(is);
|
||||
|
||||
if(version > 1)
|
||||
{
|
||||
infostream<<__FUNCTION_NAME<<": version "<<version<<" not supported"
|
||||
<<std::endl;
|
||||
throw SerializationError(__FUNCTION_NAME);
|
||||
}
|
||||
|
||||
u16 count = readU16(is);
|
||||
|
||||
for(u16 i=0; i<count; i++)
|
||||
{
|
||||
u16 p16 = readU16(is);
|
||||
|
||||
v3s16 p(0,0,0);
|
||||
p.Z += p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
|
||||
p16 -= p.Z * MAP_BLOCKSIZE * MAP_BLOCKSIZE;
|
||||
p.Y += p16 / MAP_BLOCKSIZE;
|
||||
p16 -= p.Y * MAP_BLOCKSIZE;
|
||||
p.X += p16;
|
||||
|
||||
if(meta->get(p) != NULL)
|
||||
{
|
||||
infostream<<"WARNING: "<<__FUNCTION_NAME<<": "
|
||||
<<"already set data at position"
|
||||
<<"("<<p.X<<","<<p.Y<<","<<p.Z<<"): Ignoring."
|
||||
<<std::endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
NodeMetadata *data = new NodeMetadata(gamedef);
|
||||
bool need_timer = content_nodemeta_deserialize_legacy_meta(is, data);
|
||||
meta->set(p, data);
|
||||
|
||||
if(need_timer)
|
||||
timers->set(p, NodeTimer(1., 0.));
|
||||
}
|
||||
}
|
||||
|
||||
void content_nodemeta_serialize_legacy(std::ostream &os, NodeMetadataList *meta)
|
||||
{
|
||||
// Sorry, I was too lazy to implement this. --kahrl
|
||||
writeU16(os, 1); // version
|
||||
writeU16(os, 0); // count
|
||||
}
|
||||
|
||||
// END
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -21,6 +21,17 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#define CONTENT_NODEMETA_HEADER
|
||||
|
||||
#include "nodemetadata.h"
|
||||
#include "nodetimer.h"
|
||||
|
||||
/*
|
||||
Legacy nodemeta definitions
|
||||
*/
|
||||
|
||||
void content_nodemeta_deserialize_legacy(std::istream &is,
|
||||
NodeMetadataList *meta, NodeTimerList *timers,
|
||||
IGameDef *gamedef);
|
||||
|
||||
void content_nodemeta_serialize_legacy(std::ostream &os, NodeMetadataList *meta);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
102
src/craftdef.cpp
102
src/craftdef.cpp
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -27,6 +27,26 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "gamedef.h"
|
||||
#include "inventory.h"
|
||||
|
||||
// Check if input matches recipe
|
||||
// Takes recipe groups into account
|
||||
static bool inputItemMatchesRecipe(const std::string &inp_name,
|
||||
const std::string &rec_name, IItemDefManager *idef)
|
||||
{
|
||||
// Exact name
|
||||
if(inp_name == rec_name)
|
||||
return true;
|
||||
|
||||
// Group
|
||||
if(rec_name.substr(0,6) == "group:" && idef->isKnown(inp_name)){
|
||||
std::string rec_group = rec_name.substr(6);
|
||||
const struct ItemDefinition &def = idef->get(inp_name);
|
||||
if(itemgroup_get(def.groups, rec_group) != 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Didn't match
|
||||
return false;
|
||||
}
|
||||
|
||||
// Deserialize an itemstring then return the name of the item
|
||||
static std::string craftGetItemName(const std::string &itemstring, IGameDef *gamedef)
|
||||
@@ -260,6 +280,7 @@ std::string CraftOutput::dump() const
|
||||
/*
|
||||
CraftReplacements
|
||||
*/
|
||||
|
||||
std::string CraftReplacements::dump() const
|
||||
{
|
||||
std::ostringstream os(std::ios::binary);
|
||||
@@ -276,6 +297,27 @@ std::string CraftReplacements::dump() const
|
||||
return os.str();
|
||||
}
|
||||
|
||||
void CraftReplacements::serialize(std::ostream &os) const
|
||||
{
|
||||
writeU16(os, pairs.size());
|
||||
for(u32 i=0; i<pairs.size(); i++)
|
||||
{
|
||||
os<<serializeString(pairs[i].first);
|
||||
os<<serializeString(pairs[i].second);
|
||||
}
|
||||
}
|
||||
|
||||
void CraftReplacements::deSerialize(std::istream &is)
|
||||
{
|
||||
pairs.clear();
|
||||
u32 count = readU16(is);
|
||||
for(u32 i=0; i<count; i++)
|
||||
{
|
||||
std::string first = deSerializeString(is);
|
||||
std::string second = deSerializeString(is);
|
||||
pairs.push_back(std::make_pair(first, second));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
CraftDefinition
|
||||
@@ -381,9 +423,9 @@ bool CraftDefinitionShaped::check(const CraftInput &input, IGameDef *gamedef) co
|
||||
unsigned int rec_x = rec_min_x + x;
|
||||
unsigned int rec_y = rec_min_y + y;
|
||||
|
||||
if(
|
||||
inp_names[inp_y * inp_width + inp_x] !=
|
||||
rec_names[rec_y * rec_width + rec_x]
|
||||
if(!inputItemMatchesRecipe(
|
||||
inp_names[inp_y * inp_width + inp_x],
|
||||
rec_names[rec_y * rec_width + rec_x], gamedef->idef())
|
||||
){
|
||||
return false;
|
||||
}
|
||||
@@ -418,12 +460,7 @@ void CraftDefinitionShaped::serializeBody(std::ostream &os) const
|
||||
writeU16(os, recipe.size());
|
||||
for(u32 i=0; i<recipe.size(); i++)
|
||||
os<<serializeString(recipe[i]);
|
||||
writeU16(os, replacements.pairs.size());
|
||||
for(u32 i=0; i<replacements.pairs.size(); i++)
|
||||
{
|
||||
os<<serializeString(replacements.pairs[i].first);
|
||||
os<<serializeString(replacements.pairs[i].second);
|
||||
}
|
||||
replacements.serialize(os);
|
||||
}
|
||||
|
||||
void CraftDefinitionShaped::deSerializeBody(std::istream &is, int version)
|
||||
@@ -436,14 +473,7 @@ void CraftDefinitionShaped::deSerializeBody(std::istream &is, int version)
|
||||
u32 count = readU16(is);
|
||||
for(u32 i=0; i<count; i++)
|
||||
recipe.push_back(deSerializeString(is));
|
||||
replacements.pairs.clear();
|
||||
count = readU16(is);
|
||||
for(u32 i=0; i<count; i++)
|
||||
{
|
||||
std::string first = deSerializeString(is);
|
||||
std::string second = deSerializeString(is);
|
||||
replacements.pairs.push_back(std::make_pair(first, second));
|
||||
}
|
||||
replacements.deSerialize(is);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -497,12 +527,7 @@ void CraftDefinitionShapeless::serializeBody(std::ostream &os) const
|
||||
writeU16(os, recipe.size());
|
||||
for(u32 i=0; i<recipe.size(); i++)
|
||||
os<<serializeString(recipe[i]);
|
||||
writeU16(os, replacements.pairs.size());
|
||||
for(u32 i=0; i<replacements.pairs.size(); i++)
|
||||
{
|
||||
os<<serializeString(replacements.pairs[i].first);
|
||||
os<<serializeString(replacements.pairs[i].second);
|
||||
}
|
||||
replacements.serialize(os);
|
||||
}
|
||||
|
||||
void CraftDefinitionShapeless::deSerializeBody(std::istream &is, int version)
|
||||
@@ -514,14 +539,7 @@ void CraftDefinitionShapeless::deSerializeBody(std::istream &is, int version)
|
||||
u32 count = readU16(is);
|
||||
for(u32 i=0; i<count; i++)
|
||||
recipe.push_back(deSerializeString(is));
|
||||
replacements.pairs.clear();
|
||||
count = readU16(is);
|
||||
for(u32 i=0; i<count; i++)
|
||||
{
|
||||
std::string first = deSerializeString(is);
|
||||
std::string second = deSerializeString(is);
|
||||
replacements.pairs.push_back(std::make_pair(first, second));
|
||||
}
|
||||
replacements.deSerialize(is);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -664,7 +682,7 @@ CraftOutput CraftDefinitionCooking::getOutput(const CraftInput &input, IGameDef
|
||||
|
||||
void CraftDefinitionCooking::decrementInput(CraftInput &input, IGameDef *gamedef) const
|
||||
{
|
||||
craftDecrementInput(input, gamedef);
|
||||
craftDecrementOrReplaceInput(input, replacements, gamedef);
|
||||
}
|
||||
|
||||
std::string CraftDefinitionCooking::dump() const
|
||||
@@ -672,7 +690,8 @@ std::string CraftDefinitionCooking::dump() const
|
||||
std::ostringstream os(std::ios::binary);
|
||||
os<<"(cooking, output=\""<<output
|
||||
<<"\", recipe=\""<<recipe
|
||||
<<"\", cooktime="<<cooktime<<")";
|
||||
<<"\", cooktime="<<cooktime<<")"
|
||||
<<", replacements="<<replacements.dump()<<")";
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@@ -681,6 +700,7 @@ void CraftDefinitionCooking::serializeBody(std::ostream &os) const
|
||||
os<<serializeString(output);
|
||||
os<<serializeString(recipe);
|
||||
writeF1000(os, cooktime);
|
||||
replacements.serialize(os);
|
||||
}
|
||||
|
||||
void CraftDefinitionCooking::deSerializeBody(std::istream &is, int version)
|
||||
@@ -690,6 +710,7 @@ void CraftDefinitionCooking::deSerializeBody(std::istream &is, int version)
|
||||
output = deSerializeString(is);
|
||||
recipe = deSerializeString(is);
|
||||
cooktime = readF1000(is);
|
||||
replacements.deSerialize(is);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -725,14 +746,15 @@ CraftOutput CraftDefinitionFuel::getOutput(const CraftInput &input, IGameDef *ga
|
||||
|
||||
void CraftDefinitionFuel::decrementInput(CraftInput &input, IGameDef *gamedef) const
|
||||
{
|
||||
craftDecrementInput(input, gamedef);
|
||||
craftDecrementOrReplaceInput(input, replacements, gamedef);
|
||||
}
|
||||
|
||||
std::string CraftDefinitionFuel::dump() const
|
||||
{
|
||||
std::ostringstream os(std::ios::binary);
|
||||
os<<"(fuel, recipe=\""<<recipe
|
||||
<<"\", burntime="<<burntime<<")";
|
||||
<<"\", burntime="<<burntime<<")"
|
||||
<<", replacements="<<replacements.dump()<<")";
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@@ -740,6 +762,7 @@ void CraftDefinitionFuel::serializeBody(std::ostream &os) const
|
||||
{
|
||||
os<<serializeString(recipe);
|
||||
writeF1000(os, burntime);
|
||||
replacements.serialize(os);
|
||||
}
|
||||
|
||||
void CraftDefinitionFuel::deSerializeBody(std::istream &is, int version)
|
||||
@@ -748,6 +771,7 @@ void CraftDefinitionFuel::deSerializeBody(std::istream &is, int version)
|
||||
"unsupported CraftDefinitionFuel version");
|
||||
recipe = deSerializeString(is);
|
||||
burntime = readF1000(is);
|
||||
replacements.deSerialize(is);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -106,6 +106,8 @@ struct CraftReplacements
|
||||
pairs(pairs_)
|
||||
{}
|
||||
std::string dump() const;
|
||||
void serialize(std::ostream &os) const;
|
||||
void deSerialize(std::istream &is);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -270,8 +272,9 @@ class CraftDefinitionCooking: public CraftDefinition
|
||||
CraftDefinitionCooking(
|
||||
const std::string &output_,
|
||||
const std::string &recipe_,
|
||||
float cooktime_):
|
||||
output(output_), recipe(recipe_), cooktime(cooktime_)
|
||||
float cooktime_,
|
||||
const CraftReplacements &replacements_):
|
||||
output(output_), recipe(recipe_), cooktime(cooktime_), replacements(replacements_)
|
||||
{}
|
||||
virtual ~CraftDefinitionCooking(){}
|
||||
|
||||
@@ -293,6 +296,8 @@ class CraftDefinitionCooking: public CraftDefinition
|
||||
std::string recipe;
|
||||
// Time in seconds
|
||||
float cooktime;
|
||||
// Replacement items for decrementInput()
|
||||
CraftReplacements replacements;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -305,8 +310,10 @@ class CraftDefinitionFuel: public CraftDefinition
|
||||
CraftDefinitionFuel():
|
||||
recipe(""), burntime()
|
||||
{}
|
||||
CraftDefinitionFuel(std::string recipe_, float burntime_):
|
||||
recipe(recipe_), burntime(burntime_)
|
||||
CraftDefinitionFuel(std::string recipe_,
|
||||
float burntime_,
|
||||
const CraftReplacements &replacements_):
|
||||
recipe(recipe_), burntime(burntime_), replacements(replacements_)
|
||||
{}
|
||||
virtual ~CraftDefinitionFuel(){}
|
||||
|
||||
@@ -326,6 +333,8 @@ class CraftDefinitionFuel: public CraftDefinition
|
||||
std::string recipe;
|
||||
// Time in seconds
|
||||
float burntime;
|
||||
// Replacement items for decrementInput()
|
||||
CraftReplacements replacements;
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -25,7 +25,6 @@ void set_default_settings(Settings *settings)
|
||||
|
||||
settings->setDefault("port", "");
|
||||
settings->setDefault("name", "");
|
||||
settings->setDefault("footprints", "false");
|
||||
|
||||
// Client stuff
|
||||
|
||||
@@ -137,5 +136,6 @@ void set_default_settings(Settings *settings)
|
||||
settings->setDefault("server_map_save_interval", "5.3");
|
||||
settings->setDefault("full_block_send_enable_min_time_from_building", "2.0");
|
||||
settings->setDefault("dedicated_server_step", "0.05");
|
||||
settings->setDefault("ignore_world_load_errors", "false");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -633,13 +633,15 @@ class ABMHandler
|
||||
i->timer -= trigger_interval;
|
||||
actual_interval = trigger_interval;
|
||||
}
|
||||
ActiveABM aabm;
|
||||
aabm.abm = abm;
|
||||
float intervals = actual_interval / trigger_interval;
|
||||
if(intervals == 0)
|
||||
continue;
|
||||
float chance = abm->getTriggerChance();
|
||||
if(chance == 0)
|
||||
chance = 1;
|
||||
aabm.chance = 1.0 / pow((float)1.0/chance, (float)intervals);
|
||||
ActiveABM aabm;
|
||||
aabm.abm = abm;
|
||||
aabm.chance = chance / intervals;
|
||||
if(aabm.chance == 0)
|
||||
aabm.chance = 1;
|
||||
// Trigger neighbors
|
||||
@@ -771,18 +773,11 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime)
|
||||
// Activate stored objects
|
||||
activateObjects(block);
|
||||
|
||||
// Run node metadata
|
||||
bool changed = block->m_node_metadata->step((float)dtime_s);
|
||||
if(changed)
|
||||
{
|
||||
MapEditEvent event;
|
||||
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
|
||||
event.p = block->getPos();
|
||||
m_map->dispatchEvent(&event);
|
||||
|
||||
block->raiseModified(MOD_STATE_WRITE_NEEDED,
|
||||
"node metadata modified in activateBlock");
|
||||
}
|
||||
// Run node timers
|
||||
std::map<v3s16, f32> elapsed_timers =
|
||||
block->m_node_timers.step((float)dtime_s);
|
||||
if(!elapsed_timers.empty())
|
||||
errorstream<<"Node timers don't work yet!"<<std::endl;
|
||||
|
||||
/* Handle ActiveBlockModifiers */
|
||||
ABMHandler abmhandler(m_abms, dtime_s, this, false);
|
||||
@@ -1062,18 +1057,11 @@ void ServerEnvironment::step(float dtime)
|
||||
block->raiseModified(MOD_STATE_WRITE_AT_UNLOAD,
|
||||
"Timestamp older than 60s (step)");
|
||||
|
||||
// Run node metadata
|
||||
bool changed = block->m_node_metadata->step(dtime);
|
||||
if(changed)
|
||||
{
|
||||
MapEditEvent event;
|
||||
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
|
||||
event.p = p;
|
||||
m_map->dispatchEvent(&event);
|
||||
|
||||
block->raiseModified(MOD_STATE_WRITE_NEEDED,
|
||||
"node metadata modified in step");
|
||||
}
|
||||
// Run node timers
|
||||
std::map<v3s16, f32> elapsed_timers =
|
||||
block->m_node_timers.step(dtime);
|
||||
if(!elapsed_timers.empty())
|
||||
errorstream<<"Node timers don't work yet!"<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1746,6 +1734,15 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
|
||||
force_delete = true;
|
||||
} else {
|
||||
u16 new_id = pending_delete ? id : 0;
|
||||
// If static counterpart already exists, remove it first.
|
||||
// This shouldn't happen, but happens rarely for some
|
||||
// unknown reason. Unsuccessful attempts have been made to
|
||||
// find said reason.
|
||||
if(new_id && block->m_static_objects.m_active.find(new_id)){
|
||||
infostream<<"ServerEnv: WARNING: Performing hack #83274"
|
||||
<<std::endl;
|
||||
block->m_static_objects.remove(new_id);
|
||||
}
|
||||
block->m_static_objects.insert(new_id, s_obj);
|
||||
|
||||
// Only mark block as modified if data changed considerably
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Part of Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Part of Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -4,16 +4,16 @@ Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
Copyright (C) 2012 Jonathan Neuschäfer <j.neuschaefer@gmx.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -4,16 +4,16 @@ Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
Copyright (C) 2012 Jonathan Neuschäfer <j.neuschaefer@gmx.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
110
src/game.cpp
110
src/game.cpp
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -103,7 +103,9 @@ struct TextDestNodeMetadata : public TextDest
|
||||
std::string ntext = wide_to_narrow(text);
|
||||
infostream<<"Changing text of a sign node: "
|
||||
<<ntext<<std::endl;
|
||||
m_client->sendSignNodeText(m_p, ntext);
|
||||
std::map<std::string, std::string> fields;
|
||||
fields["text"] = ntext;
|
||||
m_client->sendNodemetaFields(m_p, "", fields);
|
||||
}
|
||||
|
||||
v3s16 m_p;
|
||||
@@ -130,6 +132,28 @@ class MainRespawnInitiator: public IRespawnInitiator
|
||||
Client *m_client;
|
||||
};
|
||||
|
||||
/* Form update callback */
|
||||
|
||||
class NodeMetadataFormSource: public IFormSource
|
||||
{
|
||||
public:
|
||||
NodeMetadataFormSource(ClientMap *map, v3s16 p):
|
||||
m_map(map),
|
||||
m_p(p)
|
||||
{
|
||||
}
|
||||
std::string getForm()
|
||||
{
|
||||
NodeMetadata *meta = m_map->getNodeMetadata(m_p);
|
||||
if(!meta)
|
||||
return "";
|
||||
return meta->getString("formspec");
|
||||
}
|
||||
|
||||
ClientMap *m_map;
|
||||
v3s16 m_p;
|
||||
};
|
||||
|
||||
/*
|
||||
Hotbar draw routine
|
||||
*/
|
||||
@@ -1567,24 +1591,19 @@ void the_game(
|
||||
|
||||
GUIInventoryMenu *menu =
|
||||
new GUIInventoryMenu(guienv, guiroot, -1,
|
||||
&g_menumgr, v2s16(8,7),
|
||||
&g_menumgr,
|
||||
&client, gamedef);
|
||||
|
||||
InventoryLocation inventoryloc;
|
||||
inventoryloc.setCurrentPlayer();
|
||||
|
||||
core::array<GUIInventoryMenu::DrawSpec> draw_spec;
|
||||
draw_spec.push_back(GUIInventoryMenu::DrawSpec(
|
||||
"list", inventoryloc, "main",
|
||||
v2s32(0, 3), v2s32(8, 4)));
|
||||
draw_spec.push_back(GUIInventoryMenu::DrawSpec(
|
||||
"list", inventoryloc, "craft",
|
||||
v2s32(3, 0), v2s32(3, 3)));
|
||||
draw_spec.push_back(GUIInventoryMenu::DrawSpec(
|
||||
"list", inventoryloc, "craftpreview",
|
||||
v2s32(7, 1), v2s32(1, 1)));
|
||||
|
||||
menu->setDrawSpec(draw_spec);
|
||||
menu->setFormSpec(
|
||||
"invsize[8,7.5;]"
|
||||
//"image[1,0.6;1,2;player.png]"
|
||||
"list[current_player;main;0,3.5;8,4;]"
|
||||
"list[current_player;craft;3,0;3,3;]"
|
||||
"list[current_player;craftpreview;7,1;1,1;]"
|
||||
, inventoryloc);
|
||||
|
||||
menu->drop();
|
||||
}
|
||||
@@ -2195,7 +2214,7 @@ void the_game(
|
||||
ClientMap &map = client.getEnv().getClientMap();
|
||||
NodeMetadata *meta = map.getNodeMetadata(nodepos);
|
||||
if(meta){
|
||||
infotext = narrow_to_wide(meta->infoText());
|
||||
infotext = narrow_to_wide(meta->getString("infotext"));
|
||||
} else {
|
||||
MapNode n = map.getNode(nodepos);
|
||||
if(nodedef->get(n).tname_tiles[0] == "unknown_block.png"){
|
||||
@@ -2320,35 +2339,8 @@ void the_game(
|
||||
{
|
||||
infostream<<"Ground right-clicked"<<std::endl;
|
||||
|
||||
// If metadata provides an inventory view, activate it
|
||||
if(meta && meta->getInventoryDrawSpecString() != "" && !random_input)
|
||||
{
|
||||
infostream<<"Launching custom inventory view"<<std::endl;
|
||||
|
||||
InventoryLocation inventoryloc;
|
||||
inventoryloc.setNodeMeta(nodepos);
|
||||
|
||||
|
||||
/*
|
||||
Create menu
|
||||
*/
|
||||
|
||||
core::array<GUIInventoryMenu::DrawSpec> draw_spec;
|
||||
v2s16 invsize =
|
||||
GUIInventoryMenu::makeDrawSpecArrayFromString(
|
||||
draw_spec,
|
||||
meta->getInventoryDrawSpecString(),
|
||||
inventoryloc);
|
||||
|
||||
GUIInventoryMenu *menu =
|
||||
new GUIInventoryMenu(guienv, guiroot, -1,
|
||||
&g_menumgr, invsize,
|
||||
&client, gamedef);
|
||||
menu->setDrawSpec(draw_spec);
|
||||
menu->drop();
|
||||
}
|
||||
// If metadata provides text input, activate text input
|
||||
else if(meta && meta->allowsTextInput() && !random_input)
|
||||
// sign special case, at least until formspec is properly implemented
|
||||
if(meta && meta->getString("formspec") == "hack:sign_text_input" && !random_input)
|
||||
{
|
||||
infostream<<"Launching metadata text input"<<std::endl;
|
||||
|
||||
@@ -2356,12 +2348,32 @@ void the_game(
|
||||
|
||||
TextDest *dest = new TextDestNodeMetadata(nodepos, &client);
|
||||
|
||||
std::wstring wtext = narrow_to_wide(meta->getText());
|
||||
std::wstring wtext = narrow_to_wide(meta->getString("text"));
|
||||
|
||||
(new GUITextInputMenu(guienv, guiroot, -1,
|
||||
&g_menumgr, dest,
|
||||
wtext))->drop();
|
||||
}
|
||||
// If metadata provides an inventory view, activate it
|
||||
else if(meta && meta->getString("formspec") != "" && !random_input)
|
||||
{
|
||||
infostream<<"Launching custom inventory view"<<std::endl;
|
||||
|
||||
InventoryLocation inventoryloc;
|
||||
inventoryloc.setNodeMeta(nodepos);
|
||||
|
||||
/* Create menu */
|
||||
|
||||
GUIInventoryMenu *menu =
|
||||
new GUIInventoryMenu(guienv, guiroot, -1,
|
||||
&g_menumgr,
|
||||
&client, gamedef);
|
||||
menu->setFormSpec(meta->getString("formspec"),
|
||||
inventoryloc);
|
||||
menu->setFormSource(new NodeMetadataFormSource(
|
||||
&client.getEnv().getClientMap(), nodepos));
|
||||
menu->drop();
|
||||
}
|
||||
// Otherwise report right click to server
|
||||
else
|
||||
{
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include <IGUIStaticText.h>
|
||||
#include <IGUIFont.h>
|
||||
#include "log.h"
|
||||
#include "tile.h" // ITextureSource
|
||||
|
||||
void drawItemStack(video::IVideoDriver *driver,
|
||||
gui::IGUIFont *font,
|
||||
@@ -123,27 +124,26 @@ void drawItemStack(video::IVideoDriver *driver,
|
||||
GUIInventoryMenu::GUIInventoryMenu(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
IMenuManager *menumgr,
|
||||
v2s16 menu_size,
|
||||
InventoryManager *invmgr,
|
||||
IGameDef *gamedef
|
||||
):
|
||||
):
|
||||
GUIModalMenu(env, parent, id, menumgr),
|
||||
m_menu_size(menu_size),
|
||||
m_invmgr(invmgr),
|
||||
m_gamedef(gamedef)
|
||||
m_gamedef(gamedef),
|
||||
m_form_src(NULL),
|
||||
m_selected_item(NULL),
|
||||
m_selected_amount(0),
|
||||
m_selected_dragging(false),
|
||||
m_tooltip_element(NULL)
|
||||
{
|
||||
m_selected_item = NULL;
|
||||
m_selected_amount = 0;
|
||||
m_selected_dragging = false;
|
||||
m_tooltip_element = NULL;
|
||||
}
|
||||
|
||||
GUIInventoryMenu::~GUIInventoryMenu()
|
||||
{
|
||||
removeChildren();
|
||||
|
||||
if(m_selected_item)
|
||||
delete m_selected_item;
|
||||
delete m_selected_item;
|
||||
delete m_form_src;
|
||||
}
|
||||
|
||||
void GUIInventoryMenu::removeChildren()
|
||||
@@ -178,60 +178,96 @@ void GUIInventoryMenu::regenerateGui(v2u32 screensize)
|
||||
// Remove children
|
||||
removeChildren();
|
||||
|
||||
/*padding = v2s32(24,24);
|
||||
spacing = v2s32(60,56);
|
||||
imgsize = v2s32(48,48);*/
|
||||
|
||||
padding = v2s32(screensize.Y/40, screensize.Y/40);
|
||||
spacing = v2s32(screensize.Y/12, screensize.Y/13);
|
||||
imgsize = v2s32(screensize.Y/15, screensize.Y/15);
|
||||
|
||||
v2s32 size(100,100);
|
||||
s32 helptext_h = 15;
|
||||
|
||||
v2s32 size(
|
||||
padding.X*2+spacing.X*(m_menu_size.X-1)+imgsize.X,
|
||||
padding.Y*2+spacing.Y*(m_menu_size.Y-1)+imgsize.Y + helptext_h
|
||||
);
|
||||
|
||||
core::rect<s32> rect(
|
||||
screensize.X/2 - size.X/2,
|
||||
screensize.Y/2 - size.Y/2,
|
||||
screensize.X/2 + size.X/2,
|
||||
screensize.Y/2 + size.Y/2
|
||||
);
|
||||
|
||||
DesiredRect = rect;
|
||||
recalculateAbsolutePosition(false);
|
||||
|
||||
core::rect<s32> rect;
|
||||
v2s32 basepos = getBasePos();
|
||||
|
||||
m_draw_spec.clear();
|
||||
for(u16 i=0; i<m_init_draw_spec.size(); i++)
|
||||
/* Convert m_init_draw_spec to m_inventorylists */
|
||||
|
||||
m_inventorylists.clear();
|
||||
m_images.clear();
|
||||
|
||||
Strfnd f(m_formspec_string);
|
||||
while(f.atend() == false)
|
||||
{
|
||||
DrawSpec &s = m_init_draw_spec[i];
|
||||
if(s.type == "list")
|
||||
std::string type = trim(f.next("["));
|
||||
if(type == "invsize")
|
||||
{
|
||||
m_draw_spec.push_back(ListDrawSpec(s.name, s.subname,
|
||||
basepos + v2s32(spacing.X*s.pos.X, spacing.Y*s.pos.Y),
|
||||
s.geom));
|
||||
v2f invsize;
|
||||
invsize.X = stof(f.next(","));
|
||||
invsize.Y = stof(f.next(";"));
|
||||
infostream<<"invsize ("<<invsize.X<<","<<invsize.Y<<")"<<std::endl;
|
||||
f.next("]");
|
||||
|
||||
padding = v2s32(screensize.Y/40, screensize.Y/40);
|
||||
spacing = v2s32(screensize.Y/12, screensize.Y/13);
|
||||
imgsize = v2s32(screensize.Y/15, screensize.Y/15);
|
||||
size = v2s32(
|
||||
padding.X*2+spacing.X*(invsize.X-1.0)+imgsize.X,
|
||||
padding.Y*2+spacing.Y*(invsize.Y-1.0)+imgsize.Y + (helptext_h-5)
|
||||
);
|
||||
rect = core::rect<s32>(
|
||||
screensize.X/2 - size.X/2,
|
||||
screensize.Y/2 - size.Y/2,
|
||||
screensize.X/2 + size.X/2,
|
||||
screensize.Y/2 + size.Y/2
|
||||
);
|
||||
DesiredRect = rect;
|
||||
recalculateAbsolutePosition(false);
|
||||
basepos = getBasePos();
|
||||
}
|
||||
else if(type == "list")
|
||||
{
|
||||
std::string name = f.next(";");
|
||||
InventoryLocation loc;
|
||||
if(name == "context" || name == "current_name")
|
||||
loc = m_current_inventory_location;
|
||||
else
|
||||
loc.deSerialize(name);
|
||||
std::string listname = f.next(";");
|
||||
v2s32 pos = basepos;
|
||||
pos.X += stof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y += stof(f.next(";")) * (float)spacing.Y;
|
||||
v2s32 geom;
|
||||
geom.X = stoi(f.next(","));
|
||||
geom.Y = stoi(f.next(";"));
|
||||
infostream<<"list inv="<<name<<", listname="<<listname
|
||||
<<", pos=("<<pos.X<<","<<pos.Y<<")"
|
||||
<<", geom=("<<geom.X<<","<<geom.Y<<")"
|
||||
<<std::endl;
|
||||
f.next("]");
|
||||
m_inventorylists.push_back(ListDrawSpec(loc, listname, pos, geom));
|
||||
}
|
||||
else if(type == "image")
|
||||
{
|
||||
v2s32 pos = basepos;
|
||||
pos.X += stof(f.next(",")) * (float)spacing.X;
|
||||
pos.Y += stof(f.next(";")) * (float)spacing.Y;
|
||||
v2s32 geom;
|
||||
geom.X = stof(f.next(",")) * (float)imgsize.X;
|
||||
geom.Y = stof(f.next(";")) * (float)imgsize.Y;
|
||||
std::string name = f.next("]");
|
||||
infostream<<"image name="<<name
|
||||
<<", pos=("<<pos.X<<","<<pos.Y<<")"
|
||||
<<", geom=("<<geom.X<<","<<geom.Y<<")"
|
||||
<<std::endl;
|
||||
m_images.push_back(ImageDrawSpec(name, pos, geom));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore others
|
||||
std::string ts = f.next("]");
|
||||
infostream<<"Unknown DrawSpec: type="<<type<<", data=\""<<ts<<"\""
|
||||
<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
m_draw_spec.clear();
|
||||
m_draw_spec.push_back(ListDrawSpec("main",
|
||||
basepos + v2s32(spacing.X*0, spacing.Y*3), v2s32(8, 4)));
|
||||
m_draw_spec.push_back(ListDrawSpec("craft",
|
||||
basepos + v2s32(spacing.X*3, spacing.Y*0), v2s32(3, 3)));
|
||||
m_draw_spec.push_back(ListDrawSpec("craftresult",
|
||||
basepos + v2s32(spacing.X*7, spacing.Y*1), v2s32(1, 1)));
|
||||
*/
|
||||
|
||||
// Add children
|
||||
{
|
||||
core::rect<s32> rect(0, 0, size.X-padding.X*2, helptext_h);
|
||||
rect = rect + v2s32(size.X/2 - rect.getWidth()/2,
|
||||
size.Y-rect.getHeight()-15);
|
||||
size.Y-rect.getHeight()-5);
|
||||
const wchar_t *text =
|
||||
L"Left click: Move all items, Right click: Move single item";
|
||||
Environment->addStaticText(text, rect, false, true, this, 256);
|
||||
@@ -253,9 +289,9 @@ GUIInventoryMenu::ItemSpec GUIInventoryMenu::getItemAtPos(v2s32 p) const
|
||||
{
|
||||
core::rect<s32> imgrect(0,0,imgsize.X,imgsize.Y);
|
||||
|
||||
for(u32 i=0; i<m_draw_spec.size(); i++)
|
||||
for(u32 i=0; i<m_inventorylists.size(); i++)
|
||||
{
|
||||
const ListDrawSpec &s = m_draw_spec[i];
|
||||
const ListDrawSpec &s = m_inventorylists[i];
|
||||
|
||||
for(s32 i=0; i<s.geom.X*s.geom.Y; i++)
|
||||
{
|
||||
@@ -284,8 +320,21 @@ void GUIInventoryMenu::drawList(const ListDrawSpec &s, int phase)
|
||||
font = skin->getFont();
|
||||
|
||||
Inventory *inv = m_invmgr->getInventory(s.inventoryloc);
|
||||
assert(inv);
|
||||
if(!inv){
|
||||
infostream<<"GUIInventoryMenu::drawList(): WARNING: "
|
||||
<<"The inventory location "
|
||||
<<"\""<<s.inventoryloc.dump()<<"\" doesn't exist"
|
||||
<<std::endl;
|
||||
return;
|
||||
}
|
||||
InventoryList *ilist = inv->getList(s.listname);
|
||||
if(!ilist){
|
||||
infostream<<"GUIInventoryMenu::drawList(): WARNING: "
|
||||
<<"The inventory list \""<<s.listname<<"\" @ \""
|
||||
<<s.inventoryloc.dump()<<"\" doesn't exist"
|
||||
<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
core::rect<s32> imgrect(0,0,imgsize.X,imgsize.Y);
|
||||
|
||||
@@ -380,6 +429,14 @@ void GUIInventoryMenu::drawSelectedItem()
|
||||
|
||||
void GUIInventoryMenu::drawMenu()
|
||||
{
|
||||
if(m_form_src){
|
||||
std::string newform = m_form_src->getForm();
|
||||
if(newform != m_formspec_string){
|
||||
m_formspec_string = newform;
|
||||
regenerateGui(m_screensize_old);
|
||||
}
|
||||
}
|
||||
|
||||
updateSelectedItem();
|
||||
|
||||
gui::IGUISkin* skin = Environment->getSkin();
|
||||
@@ -399,9 +456,26 @@ void GUIInventoryMenu::drawMenu()
|
||||
*/
|
||||
|
||||
for(int phase=0; phase<=1; phase++)
|
||||
for(u32 i=0; i<m_draw_spec.size(); i++)
|
||||
for(u32 i=0; i<m_inventorylists.size(); i++)
|
||||
{
|
||||
drawList(m_draw_spec[i], phase);
|
||||
drawList(m_inventorylists[i], phase);
|
||||
}
|
||||
|
||||
for(u32 i=0; i<m_images.size(); i++)
|
||||
{
|
||||
const ImageDrawSpec &spec = m_images[i];
|
||||
video::ITexture *texture =
|
||||
m_gamedef->tsrc()->getTextureRaw(spec.name);
|
||||
// Image size on screen
|
||||
core::rect<s32> imgrect(0, 0, spec.geom.X, spec.geom.Y);
|
||||
// Image rectangle on screen
|
||||
core::rect<s32> rect = imgrect + spec.pos;
|
||||
const video::SColor color(255,255,255,255);
|
||||
const video::SColor colors[] = {color,color,color,color};
|
||||
driver->draw2DImage(texture, rect,
|
||||
core::rect<s32>(core::position2d<s32>(0,0),
|
||||
core::dimension2di(texture->getOriginalSize())),
|
||||
NULL/*&AbsoluteClippingRect*/, colors, true);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -450,9 +524,9 @@ void GUIInventoryMenu::updateSelectedItem()
|
||||
// If craftresult is nonempty and nothing else is selected, select it now.
|
||||
if(!m_selected_item)
|
||||
{
|
||||
for(u32 i=0; i<m_draw_spec.size(); i++)
|
||||
for(u32 i=0; i<m_inventorylists.size(); i++)
|
||||
{
|
||||
const ListDrawSpec &s = m_draw_spec[i];
|
||||
const ListDrawSpec &s = m_inventorylists[i];
|
||||
if(s.listname == "craftpreview")
|
||||
{
|
||||
Inventory *inv = m_invmgr->getInventory(s.inventoryloc);
|
||||
@@ -526,16 +600,35 @@ bool GUIInventoryMenu::OnEvent(const SEvent& event)
|
||||
u32 s_count = 0;
|
||||
|
||||
if(s.isValid())
|
||||
{
|
||||
do{ // breakable
|
||||
inv_s = m_invmgr->getInventory(s.inventoryloc);
|
||||
assert(inv_s);
|
||||
|
||||
if(!inv_s){
|
||||
errorstream<<"InventoryMenu: The selected inventory location "
|
||||
<<"\""<<s.inventoryloc.dump()<<"\" doesn't exist"
|
||||
<<std::endl;
|
||||
s.i = -1; // make it invalid again
|
||||
break;
|
||||
}
|
||||
|
||||
InventoryList *list = inv_s->getList(s.listname);
|
||||
if(list != NULL && (u32) s.i < list->getSize())
|
||||
s_count = list->getItem(s.i).count;
|
||||
else
|
||||
if(list == NULL){
|
||||
errorstream<<"InventoryMenu: The selected inventory list \""
|
||||
<<s.listname<<"\" does not exist"<<std::endl;
|
||||
s.i = -1; // make it invalid again
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if((u32)s.i >= list->getSize()){
|
||||
errorstream<<"InventoryMenu: The selected inventory list \""
|
||||
<<s.listname<<"\" is too small (i="<<s.i<<", size="
|
||||
<<list->getSize()<<")"<<std::endl;
|
||||
s.i = -1; // make it invalid again
|
||||
break;
|
||||
}
|
||||
|
||||
s_count = list->getItem(s.i).count;
|
||||
}while(0);
|
||||
|
||||
bool identical = (m_selected_item != NULL) && s.isValid() &&
|
||||
(inv_selected == inv_s) &&
|
||||
@@ -788,88 +881,3 @@ bool GUIInventoryMenu::OnEvent(const SEvent& event)
|
||||
return Parent ? Parent->OnEvent(event) : false;
|
||||
}
|
||||
|
||||
/*
|
||||
Here is an example traditional set-up sequence for a DrawSpec list:
|
||||
|
||||
std::string furnace_inv_id = "nodemetadata:0,1,2";
|
||||
core::array<GUIInventoryMenu::DrawSpec> draw_spec;
|
||||
draw_spec.push_back(GUIInventoryMenu::DrawSpec(
|
||||
"list", furnace_inv_id, "fuel",
|
||||
v2s32(2, 3), v2s32(1, 1)));
|
||||
draw_spec.push_back(GUIInventoryMenu::DrawSpec(
|
||||
"list", furnace_inv_id, "src",
|
||||
v2s32(2, 1), v2s32(1, 1)));
|
||||
draw_spec.push_back(GUIInventoryMenu::DrawSpec(
|
||||
"list", furnace_inv_id, "dst",
|
||||
v2s32(5, 1), v2s32(2, 2)));
|
||||
draw_spec.push_back(GUIInventoryMenu::DrawSpec(
|
||||
"list", "current_player", "main",
|
||||
v2s32(0, 5), v2s32(8, 4)));
|
||||
setDrawSpec(draw_spec);
|
||||
|
||||
Here is the string for creating the same DrawSpec list (a single line,
|
||||
spread to multiple lines here):
|
||||
|
||||
GUIInventoryMenu::makeDrawSpecArrayFromString(
|
||||
draw_spec,
|
||||
"nodemetadata:0,1,2",
|
||||
"invsize[8,9;]"
|
||||
"list[current_name;fuel;2,3;1,1;]"
|
||||
"list[current_name;src;2,1;1,1;]"
|
||||
"list[current_name;dst;5,1;2,2;]"
|
||||
"list[current_player;main;0,5;8,4;]");
|
||||
|
||||
Returns inventory menu size defined by invsize[].
|
||||
*/
|
||||
v2s16 GUIInventoryMenu::makeDrawSpecArrayFromString(
|
||||
core::array<GUIInventoryMenu::DrawSpec> &draw_spec,
|
||||
const std::string &data,
|
||||
const InventoryLocation ¤t_location)
|
||||
{
|
||||
v2s16 invsize(8,9);
|
||||
Strfnd f(data);
|
||||
while(f.atend() == false)
|
||||
{
|
||||
std::string type = trim(f.next("["));
|
||||
//infostream<<"type="<<type<<std::endl;
|
||||
if(type == "list")
|
||||
{
|
||||
std::string name = f.next(";");
|
||||
InventoryLocation loc;
|
||||
if(name == "current_name")
|
||||
loc = current_location;
|
||||
else
|
||||
loc.deSerialize(name);
|
||||
std::string subname = f.next(";");
|
||||
s32 pos_x = stoi(f.next(","));
|
||||
s32 pos_y = stoi(f.next(";"));
|
||||
s32 geom_x = stoi(f.next(","));
|
||||
s32 geom_y = stoi(f.next(";"));
|
||||
infostream<<"list name="<<name<<", subname="<<subname
|
||||
<<", pos=("<<pos_x<<","<<pos_y<<")"
|
||||
<<", geom=("<<geom_x<<","<<geom_y<<")"
|
||||
<<std::endl;
|
||||
draw_spec.push_back(GUIInventoryMenu::DrawSpec(
|
||||
type, loc, subname,
|
||||
v2s32(pos_x,pos_y),v2s32(geom_x,geom_y)));
|
||||
f.next("]");
|
||||
}
|
||||
else if(type == "invsize")
|
||||
{
|
||||
invsize.X = stoi(f.next(","));
|
||||
invsize.Y = stoi(f.next(";"));
|
||||
infostream<<"invsize ("<<invsize.X<<","<<invsize.Y<<")"<<std::endl;
|
||||
f.next("]");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ignore others
|
||||
std::string ts = f.next("]");
|
||||
infostream<<"Unknown DrawSpec: type="<<type<<", data=\""<<ts<<"\""
|
||||
<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return invsize;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -30,6 +30,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
class IGameDef;
|
||||
class InventoryManager;
|
||||
|
||||
class IFormSource
|
||||
{
|
||||
public:
|
||||
virtual ~IFormSource(){}
|
||||
virtual std::string getForm() = 0;
|
||||
};
|
||||
|
||||
void drawItemStack(video::IVideoDriver *driver,
|
||||
gui::IGUIFont *font,
|
||||
const ItemStack &item,
|
||||
@@ -70,12 +77,12 @@ class GUIInventoryMenu : public GUIModalMenu
|
||||
}
|
||||
ListDrawSpec(const InventoryLocation &a_inventoryloc,
|
||||
const std::string &a_listname,
|
||||
v2s32 a_pos, v2s32 a_geom)
|
||||
v2s32 a_pos, v2s32 a_geom):
|
||||
inventoryloc(a_inventoryloc),
|
||||
listname(a_listname),
|
||||
pos(a_pos),
|
||||
geom(a_geom)
|
||||
{
|
||||
inventoryloc = a_inventoryloc;
|
||||
listname = a_listname;
|
||||
pos = a_pos;
|
||||
geom = a_geom;
|
||||
}
|
||||
|
||||
InventoryLocation inventoryloc;
|
||||
@@ -83,50 +90,45 @@ class GUIInventoryMenu : public GUIModalMenu
|
||||
v2s32 pos;
|
||||
v2s32 geom;
|
||||
};
|
||||
public:
|
||||
struct DrawSpec
|
||||
{
|
||||
DrawSpec()
|
||||
{
|
||||
}
|
||||
DrawSpec(const std::string &a_type,
|
||||
const InventoryLocation &a_name,
|
||||
const std::string &a_subname,
|
||||
v2s32 a_pos,
|
||||
v2s32 a_geom)
|
||||
{
|
||||
type = a_type;
|
||||
name = a_name;
|
||||
subname = a_subname;
|
||||
pos = a_pos;
|
||||
geom = a_geom;
|
||||
}
|
||||
|
||||
std::string type;
|
||||
InventoryLocation name;
|
||||
std::string subname;
|
||||
struct ImageDrawSpec
|
||||
{
|
||||
ImageDrawSpec()
|
||||
{
|
||||
}
|
||||
ImageDrawSpec(const std::string &a_name,
|
||||
v2s32 a_pos, v2s32 a_geom):
|
||||
name(a_name),
|
||||
pos(a_pos),
|
||||
geom(a_geom)
|
||||
{
|
||||
}
|
||||
std::string name;
|
||||
v2s32 pos;
|
||||
v2s32 geom;
|
||||
};
|
||||
|
||||
// See .cpp for format
|
||||
static v2s16 makeDrawSpecArrayFromString(
|
||||
core::array<GUIInventoryMenu::DrawSpec> &draw_spec,
|
||||
const std::string &data,
|
||||
const InventoryLocation ¤t_location);
|
||||
|
||||
public:
|
||||
GUIInventoryMenu(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
IMenuManager *menumgr,
|
||||
v2s16 menu_size,
|
||||
InventoryManager *invmgr,
|
||||
IGameDef *gamedef
|
||||
);
|
||||
~GUIInventoryMenu();
|
||||
|
||||
void setDrawSpec(core::array<DrawSpec> &init_draw_spec)
|
||||
void setFormSpec(const std::string &formspec_string,
|
||||
InventoryLocation current_inventory_location)
|
||||
{
|
||||
m_init_draw_spec = init_draw_spec;
|
||||
m_formspec_string = formspec_string;
|
||||
m_current_inventory_location = current_inventory_location;
|
||||
regenerateGui(m_screensize_old);
|
||||
}
|
||||
|
||||
// form_src is deleted by this GUIInventoryMenu
|
||||
void setFormSource(IFormSource *form_src)
|
||||
{
|
||||
m_form_src = form_src;
|
||||
}
|
||||
|
||||
void removeChildren();
|
||||
@@ -149,8 +151,6 @@ class GUIInventoryMenu : public GUIModalMenu
|
||||
return padding + AbsoluteRect.UpperLeftCorner;
|
||||
}
|
||||
|
||||
v2s16 m_menu_size;
|
||||
|
||||
v2s32 padding;
|
||||
v2s32 spacing;
|
||||
v2s32 imgsize;
|
||||
@@ -158,8 +158,12 @@ class GUIInventoryMenu : public GUIModalMenu
|
||||
InventoryManager *m_invmgr;
|
||||
IGameDef *m_gamedef;
|
||||
|
||||
core::array<DrawSpec> m_init_draw_spec;
|
||||
core::array<ListDrawSpec> m_draw_spec;
|
||||
std::string m_formspec_string;
|
||||
InventoryLocation m_current_inventory_location;
|
||||
IFormSource *m_form_src;
|
||||
|
||||
core::array<ListDrawSpec> m_inventorylists;
|
||||
core::array<ImageDrawSpec> m_images;
|
||||
|
||||
ItemSpec *m_selected_item;
|
||||
u32 m_selected_amount;
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
Copyright (C) 2011 teddydestodes <derkomtur@schattengang.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -105,14 +105,14 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
|
||||
v2s32 topleft(0, 0);
|
||||
changeCtype("");
|
||||
{
|
||||
core::rect < s32 > rect(0, 0, 500, 20);
|
||||
core::rect < s32 > rect(0, 0, 600, 40);
|
||||
rect += topleft + v2s32(25, 3);
|
||||
//gui::IGUIStaticText *t =
|
||||
Environment->addStaticText(wgettext("KEYBINDINGS (If this menu screws up, see minetest.conf)"),
|
||||
Environment->addStaticText(wgettext("Keybindings. (If this menu screws up, remove stuff from minetest.conf)"),
|
||||
rect, false, true, this, -1);
|
||||
//t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT);
|
||||
}
|
||||
v2s32 offset(25, 40);
|
||||
v2s32 offset(25, 60);
|
||||
// buttons
|
||||
|
||||
{
|
||||
@@ -299,7 +299,7 @@ void GUIKeyChangeMenu::regenerateGui(v2u32 screensize)
|
||||
}
|
||||
|
||||
//next col
|
||||
offset = v2s32(250, 40);
|
||||
offset = v2s32(250, 60);
|
||||
{
|
||||
core::rect < s32 > rect(0, 0, 100, 20);
|
||||
rect += topleft + v2s32(offset.X, offset.Y);
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
Copyright (C) 2011 teddydestodes <derkomtur@schattengang.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-12 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -214,11 +214,11 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
||||
rect += m_topleft_client + v2s32(0, -30);
|
||||
gui::IGUITabControl *e = Environment->addTabControl(
|
||||
rect, this, true, true, GUI_ID_TAB_CONTROL);
|
||||
e->addTab(L"Singleplayer");
|
||||
e->addTab(L"Multiplayer");
|
||||
e->addTab(L"Advanced");
|
||||
e->addTab(L"Settings");
|
||||
e->addTab(L"Credits");
|
||||
e->addTab(wgettext("Singleplayer"));
|
||||
e->addTab(wgettext("Multiplayer"));
|
||||
e->addTab(wgettext("Advanced"));
|
||||
e->addTab(wgettext("Settings"));
|
||||
e->addTab(wgettext("Credits"));
|
||||
e->setActiveTab(m_data->selected_tab);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,16 @@ Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
You should have received a copy of the GNU Lesser General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
@@ -81,19 +81,29 @@ void GUIMessageMenu::regenerateGui(v2u32 screensize)
|
||||
|
||||
v2s32 size = rect.getSize();
|
||||
|
||||
gui::IGUISkin *skin = Environment->getSkin();
|
||||
gui::IGUIFont *font = skin->getFont();
|
||||
s32 msg_h = font->getDimension(m_message_text.c_str()).Height;
|
||||
s32 msg_w = font->getDimension(m_message_text.c_str()).Width;
|
||||
if(msg_h > 200)
|
||||
msg_h = 200;
|
||||
if(msg_w > 540)
|
||||
msg_w = 540;
|
||||
|
||||
/*
|
||||
Add stuff
|
||||
*/
|
||||
{
|
||||
core::rect<s32> rect(0, 0, 400, 70);
|
||||
rect = rect + v2s32(size.X/2-400/2, size.Y/2-50/2-25);
|
||||
Environment->addStaticText(m_message_text.c_str(), rect, false,
|
||||
true, this, 256);
|
||||
core::rect<s32> rect(0, 0, msg_w, msg_h);
|
||||
rect += v2s32(size.X/2-msg_w/2, size.Y/2-30/2 - msg_h/2);
|
||||
Environment->addStaticText(m_message_text.c_str(),
|
||||
rect, false, true, this, -1);
|
||||
}
|
||||
changeCtype("");
|
||||
int bw = 140;
|
||||
{
|
||||
core::rect<s32> rect(0, 0, 140, 30);
|
||||
rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+45);
|
||||
core::rect<s32> rect(0, 0, bw, 30);
|
||||
rect = rect + v2s32(size.X/2-bw/2, size.Y/2-30/2+5 + msg_h/2);
|
||||
gui::IGUIElement *e =
|
||||
Environment->addButton(rect, this, 257,
|
||||
wgettext("Proceed"));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user