mirror of
https://github.com/luanti-org/luanti.git
synced 2025-11-01 07:45:26 +01:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -62,7 +62,7 @@ if(WIN32)
|
||||
elseif(APPLE)
|
||||
# Random placeholders; this isn't usually used and may not work
|
||||
# See https://github.com/toabi/minetest-mac/
|
||||
set(SHAREDIR "share/${PROJECT_NAME}")
|
||||
set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
|
||||
set(BINDIR "bin")
|
||||
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
||||
set(EXAMPLE_CONF_DIR ${DOCDIR})
|
||||
@@ -78,17 +78,58 @@ elseif(UNIX) # Linux, BSD etc
|
||||
set(ICONDIR "unix/icons")
|
||||
set(LOCALEDIR "locale")
|
||||
else()
|
||||
set(SHAREDIR "share/${PROJECT_NAME}")
|
||||
set(BINDIR "bin")
|
||||
set(DOCDIR "share/doc/${PROJECT_NAME}")
|
||||
set(MANDIR "share/man")
|
||||
set(SHAREDIR "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}")
|
||||
set(BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
|
||||
set(DOCDIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}")
|
||||
set(MANDIR "${CMAKE_INSTALL_PREFIX}/share/man")
|
||||
set(EXAMPLE_CONF_DIR ${DOCDIR})
|
||||
set(XDG_APPS_DIR "share/applications")
|
||||
set(ICONDIR "share/icons")
|
||||
set(LOCALEDIR "share/locale")
|
||||
set(XDG_APPS_DIR "${CMAKE_INSTALL_PREFIX}/share/applications")
|
||||
set(ICONDIR "${CMAKE_INSTALL_PREFIX}/share/icons")
|
||||
set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/locale")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CUSTOM_SHAREDIR "" CACHE STRING "Directory to install data files into")
|
||||
if(NOT CUSTOM_SHAREDIR STREQUAL "")
|
||||
set(SHAREDIR "${CUSTOM_SHAREDIR}")
|
||||
message(STATUS "Using SHAREDIR=${SHAREDIR}")
|
||||
endif()
|
||||
set(CUSTOM_BINDIR "" CACHE STRING "Directory to install binaries into")
|
||||
if(NOT CUSTOM_BINDIR STREQUAL "")
|
||||
set(BINDIR "${CUSTOM_BINDIR}")
|
||||
message(STATUS "Using BINDIR=${BINDIR}")
|
||||
endif()
|
||||
set(CUSTOM_DOCDIR "" CACHE STRING "Directory to install documentation into")
|
||||
if(NOT CUSTOM_DOCDIR STREQUAL "")
|
||||
set(DOCDIR "${CUSTOM_DOCDIR}")
|
||||
message(STATUS "Using DOCDIR=${DOCDIR}")
|
||||
endif()
|
||||
set(CUSTOM_MANDIR "" CACHE STRING "Directory to install manpages into")
|
||||
if(NOT CUSTOM_MANDIR STREQUAL "")
|
||||
set(MANDIR "${CUSTOM_MANDIR}")
|
||||
message(STATUS "Using MANDIR=${MANDIR}")
|
||||
endif()
|
||||
set(CUSTOM_EXAMPLE_CONF_DIR "" CACHE STRING "Directory to install example config file into")
|
||||
if(NOT CUSTOM_EXAMPLE_CONF_DIR STREQUAL "")
|
||||
set(EXAMPLE_CONF_DIR "${CUSTOM_EXAMPLE_CONF_DIR}")
|
||||
message(STATUS "Using EXAMPLE_CONF_DIR=${EXAMPLE_CONF_DIR}")
|
||||
endif()
|
||||
set(CUSTOM_XDG_APPS_DIR "" CACHE STRING "Directory to install .desktop files into")
|
||||
if(NOT CUSTOM_XDG_APPS_DIR STREQUAL "")
|
||||
set(XDG_APPS_DIR "${CUSTOM_XDG_APPS_DIR}")
|
||||
message(STATUS "Using XDG_APPS_DIR=${XDG_APPS_DIR}")
|
||||
endif()
|
||||
set(CUSTOM_ICONDIR "" CACHE STRING "Directory to install icons into")
|
||||
if(NOT CUSTOM_ICONDIR STREQUAL "")
|
||||
set(ICONDIR "${CUSTOM_ICONDIR}")
|
||||
message(STATUS "Using ICONDIR=${ICONDIR}")
|
||||
endif()
|
||||
set(CUSTOM_LOCALEDIR "" CACHE STRING "Directory to install l10n files into")
|
||||
if(NOT CUSTOM_LOCALEDIR STREQUAL "")
|
||||
set(LOCALEDIR "${CUSTOM_LOCALEDIR}")
|
||||
message(STATUS "Using LOCALEDIR=${LOCALEDIR}")
|
||||
endif()
|
||||
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/builtin" DESTINATION "${SHAREDIR}")
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/games/minimal" DESTINATION "${SHAREDIR}/games")
|
||||
set(MINETEST_GAME_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/games/minetest_game")
|
||||
|
||||
@@ -387,4 +387,112 @@ minetest.register_chatcommand("mods", {
|
||||
end
|
||||
minetest.chat_send_player(name, response)
|
||||
end,
|
||||
})
|
||||
})
|
||||
|
||||
local function handle_give_command(cmd, giver, receiver, stackstring)
|
||||
minetest.log("action", giver.." invoked "..cmd..', stackstring="'
|
||||
..stackstring..'"')
|
||||
minetest.log(cmd..' invoked, stackstring="'..stackstring..'"')
|
||||
local itemstack = ItemStack(stackstring)
|
||||
if itemstack:is_empty() then
|
||||
minetest.chat_send_player(giver, 'error: cannot give an empty item')
|
||||
return
|
||||
elseif not itemstack:is_known() then
|
||||
minetest.chat_send_player(giver, 'error: cannot give an unknown item')
|
||||
return
|
||||
end
|
||||
local receiverref = minetest.env:get_player_by_name(receiver)
|
||||
if receiverref == nil then
|
||||
minetest.chat_send_player(giver, receiver..' is not a known player')
|
||||
return
|
||||
end
|
||||
local leftover = receiverref:get_inventory():add_item("main", itemstack)
|
||||
if leftover:is_empty() then
|
||||
partiality = ""
|
||||
elseif leftover:get_count() == itemstack:get_count() then
|
||||
partiality = "could not be "
|
||||
else
|
||||
partiality = "partially "
|
||||
end
|
||||
-- The actual item stack string may be different from what the "giver"
|
||||
-- entered (e.g. big numbers are always interpreted as 2^16-1).
|
||||
stackstring = itemstack:to_string()
|
||||
if giver == receiver then
|
||||
minetest.chat_send_player(giver, '"'..stackstring
|
||||
..'" '..partiality..'added to inventory.');
|
||||
else
|
||||
minetest.chat_send_player(giver, '"'..stackstring
|
||||
..'" '..partiality..'added to '..receiver..'\'s inventory.');
|
||||
minetest.chat_send_player(receiver, '"'..stackstring
|
||||
..'" '..partiality..'added to inventory.');
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("give", {
|
||||
params = "<name> <itemstring>",
|
||||
description = "give item to player",
|
||||
privs = {give=true},
|
||||
func = function(name, param)
|
||||
local toname, itemstring = string.match(param, "^([^ ]+) +(.+)$")
|
||||
if not toname or not itemstring then
|
||||
minetest.chat_send_player(name, "name and itemstring required")
|
||||
return
|
||||
end
|
||||
handle_give_command("/give", name, toname, itemstring)
|
||||
end,
|
||||
})
|
||||
minetest.register_chatcommand("giveme", {
|
||||
params = "<itemstring>",
|
||||
description = "give item to yourself",
|
||||
privs = {give=true},
|
||||
func = function(name, param)
|
||||
local itemstring = string.match(param, "(.+)$")
|
||||
if not itemstring then
|
||||
minetest.chat_send_player(name, "itemstring required")
|
||||
return
|
||||
end
|
||||
handle_give_command("/giveme", name, name, itemstring)
|
||||
end,
|
||||
})
|
||||
minetest.register_chatcommand("spawnentity", {
|
||||
params = "<entityname>",
|
||||
description = "spawn entity at your position",
|
||||
privs = {give=true, interact=true},
|
||||
func = function(name, param)
|
||||
local entityname = string.match(param, "(.+)$")
|
||||
if not entityname then
|
||||
minetest.chat_send_player(name, "entityname required")
|
||||
return
|
||||
end
|
||||
print('/spawnentity invoked, entityname="'..entityname..'"')
|
||||
local player = minetest.env:get_player_by_name(name)
|
||||
if player == nil then
|
||||
print("Unable to spawn entity, player is nil")
|
||||
return true -- Handled chat message
|
||||
end
|
||||
local p = player:getpos()
|
||||
p.y = p.y + 1
|
||||
minetest.env:add_entity(p, entityname)
|
||||
minetest.chat_send_player(name, '"'..entityname
|
||||
..'" spawned.');
|
||||
end,
|
||||
})
|
||||
minetest.register_chatcommand("pulverize", {
|
||||
params = "",
|
||||
description = "delete item in hand",
|
||||
privs = {},
|
||||
func = function(name, param)
|
||||
local player = minetest.env:get_player_by_name(name)
|
||||
if player == nil then
|
||||
print("Unable to pulverize, player is nil")
|
||||
return true -- Handled chat message
|
||||
end
|
||||
if player:get_wielded_item():is_empty() then
|
||||
minetest.chat_send_player(name, 'Unable to pulverize, no item in hand.')
|
||||
else
|
||||
player:set_wielded_item(nil)
|
||||
minetest.chat_send_player(name, 'An item was pulverized.')
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
@@ -1722,133 +1722,24 @@ function on_punchnode(p, node)
|
||||
end
|
||||
minetest.register_on_punchnode(on_punchnode)
|
||||
|
||||
local function handle_give_command(cmd, giver, receiver, stackstring)
|
||||
if not minetest.get_player_privs(giver)["give"] then
|
||||
minetest.chat_send_player(giver, "error: you don't have permission to give")
|
||||
return
|
||||
end
|
||||
minetest.debug("DEBUG: "..cmd..' invoked, stackstring="'..stackstring..'"')
|
||||
minetest.log(cmd..' invoked, stackstring="'..stackstring..'"')
|
||||
local itemstack = ItemStack(stackstring)
|
||||
if itemstack:is_empty() then
|
||||
minetest.chat_send_player(giver, 'error: cannot give an empty item')
|
||||
return
|
||||
elseif not itemstack:is_known() then
|
||||
minetest.chat_send_player(giver, 'error: cannot give an unknown item')
|
||||
return
|
||||
end
|
||||
local receiverref = minetest.env:get_player_by_name(receiver)
|
||||
if receiverref == nil then
|
||||
minetest.chat_send_player(giver, receiver..' is not a known player')
|
||||
return
|
||||
end
|
||||
local leftover = receiverref:get_inventory():add_item("main", itemstack)
|
||||
if leftover:is_empty() then
|
||||
partiality = ""
|
||||
elseif leftover:get_count() == itemstack:get_count() then
|
||||
partiality = "could not be "
|
||||
else
|
||||
partiality = "partially "
|
||||
end
|
||||
-- The actual item stack string may be different from what the "giver"
|
||||
-- entered (e.g. big numbers are always interpreted as 2^16-1).
|
||||
stackstring = itemstack:to_string()
|
||||
if giver == receiver then
|
||||
minetest.chat_send_player(giver, '"'..stackstring
|
||||
..'" '..partiality..'added to inventory.');
|
||||
else
|
||||
minetest.chat_send_player(giver, '"'..stackstring
|
||||
..'" '..partiality..'added to '..receiver..'\'s inventory.');
|
||||
minetest.chat_send_player(receiver, '"'..stackstring
|
||||
..'" '..partiality..'added to inventory.');
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_chat_message(function(name, message)
|
||||
--print("default on_chat_message: name="..dump(name).." message="..dump(message))
|
||||
local cmd = "/giveme"
|
||||
if message:sub(0, #cmd) == cmd then
|
||||
local stackstring = string.match(message, cmd.." (.*)")
|
||||
if stackstring == nil then
|
||||
minetest.chat_send_player(name, 'usage: '..cmd..' stackstring')
|
||||
return true -- Handled chat message
|
||||
end
|
||||
handle_give_command(cmd, name, name, stackstring)
|
||||
return true
|
||||
end
|
||||
local cmd = "/give"
|
||||
if message:sub(0, #cmd) == cmd then
|
||||
local receiver, stackstring = string.match(message, cmd.." ([%a%d_-]+) (.*)")
|
||||
if receiver == nil or stackstring == nil then
|
||||
minetest.chat_send_player(name, 'usage: '..cmd..' name stackstring')
|
||||
return true -- Handled chat message
|
||||
end
|
||||
handle_give_command(cmd, name, receiver, stackstring)
|
||||
return true
|
||||
end
|
||||
local cmd = "/spawnentity"
|
||||
if message:sub(0, #cmd) == cmd then
|
||||
if not minetest.get_player_privs(name)["give"] then
|
||||
minetest.chat_send_player(name, "you don't have permission to spawn (give)")
|
||||
return true -- Handled chat message
|
||||
end
|
||||
if not minetest.get_player_privs(name)["interact"] then
|
||||
minetest.chat_send_player(name, "you don't have permission to interact")
|
||||
return true -- Handled chat message
|
||||
end
|
||||
local entityname = string.match(message, cmd.." (.*)")
|
||||
if entityname == nil then
|
||||
minetest.chat_send_player(name, 'usage: '..cmd..' entityname')
|
||||
return true -- Handled chat message
|
||||
end
|
||||
print(cmd..' invoked, entityname="'..entityname..'"')
|
||||
local player = minetest.env:get_player_by_name(name)
|
||||
if player == nil then
|
||||
print("Unable to spawn entity, player is nil")
|
||||
return true -- Handled chat message
|
||||
end
|
||||
local p = player:getpos()
|
||||
p.y = p.y + 1
|
||||
minetest.env:add_entity(p, entityname)
|
||||
minetest.chat_send_player(name, '"'..entityname
|
||||
..'" spawned.');
|
||||
return true -- Handled chat message
|
||||
end
|
||||
local cmd = "/pulverize"
|
||||
if message:sub(0, #cmd) == cmd then
|
||||
local player = minetest.env:get_player_by_name(name)
|
||||
if player == nil then
|
||||
print("Unable to pulverize, player is nil")
|
||||
return true -- Handled chat message
|
||||
end
|
||||
if player:get_wielded_item():is_empty() then
|
||||
minetest.chat_send_player(name, 'Unable to pulverize, no item in hand.')
|
||||
else
|
||||
player:set_wielded_item(nil)
|
||||
minetest.chat_send_player(name, 'An item was pulverized.')
|
||||
end
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
||||
--
|
||||
-- Test some things
|
||||
--
|
||||
|
||||
local function test_get_craft_result()
|
||||
print("test_get_craft_result()")
|
||||
minetest.log("info", "test_get_craft_result()")
|
||||
-- normal
|
||||
local input = {
|
||||
method = "normal",
|
||||
width = 2,
|
||||
items = {"", "default:coal_lump", "", "default:stick"}
|
||||
}
|
||||
print("torch crafting input: "..dump(input))
|
||||
minetest.log("info", "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))
|
||||
minetest.log("info", "torch crafting output: "..dump(output))
|
||||
minetest.log("info", "torch crafting decremented input: "..dump(decremented_input))
|
||||
assert(output.item)
|
||||
print("torch crafting output.item:to_table(): "..dump(output.item:to_table()))
|
||||
minetest.log("info", "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
|
||||
@@ -1857,10 +1748,10 @@ local function test_get_craft_result()
|
||||
width = 1,
|
||||
items = {"default:coal_lump"}
|
||||
}
|
||||
print("coal fuel input: "..dump(input))
|
||||
minetest.log("info", "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))
|
||||
minetest.log("info", "coal fuel output: "..dump(output))
|
||||
minetest.log("info", "coal fuel decremented input: "..dump(decremented_input))
|
||||
assert(output.time)
|
||||
assert(output.time > 0)
|
||||
-- cook
|
||||
@@ -1869,14 +1760,14 @@ local function test_get_craft_result()
|
||||
width = 1,
|
||||
items = {"default:cobble"}
|
||||
}
|
||||
print("cobble cooking input: "..dump(output))
|
||||
minetest.log("info", "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))
|
||||
minetest.log("info", "cobble cooking output: "..dump(output))
|
||||
minetest.log("info", "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()))
|
||||
minetest.log("info", "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
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
project(minetest)
|
||||
cmake_minimum_required( VERSION 2.6 )
|
||||
|
||||
if(RUN_IN_PLACE)
|
||||
add_definitions ( -DRUN_IN_PLACE )
|
||||
endif(RUN_IN_PLACE)
|
||||
|
||||
# Set some random things default to not being visible in the GUI
|
||||
mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
|
||||
mark_as_advanced(JTHREAD_INCLUDE_DIR JTHREAD_LIBRARY)
|
||||
@@ -139,13 +135,15 @@ else()
|
||||
#set(CLIENT_PLATFORM_LIBS -lXxf86vm)
|
||||
# This way Xxf86vm is found on OpenBSD too
|
||||
find_library(XXF86VM_LIBRARY Xxf86vm)
|
||||
mark_as_advanced(XXF86VM_LIBRARY)
|
||||
set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY})
|
||||
endif()
|
||||
|
||||
find_package(Jthread REQUIRED)
|
||||
find_package(Sqlite3 REQUIRED)
|
||||
|
||||
# TODO: Create proper find script for Lua
|
||||
# Do not use system-wide installation of Lua, because it'll likely be a
|
||||
# different version and/or has different build options.
|
||||
set(LUA_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lua/src")
|
||||
set(LUA_LIBRARY "lua")
|
||||
|
||||
|
||||
@@ -4,16 +4,18 @@
|
||||
#define CMAKE_CONFIG_H
|
||||
|
||||
#define CMAKE_PROJECT_NAME "@PROJECT_NAME@"
|
||||
#define CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
|
||||
#define CMAKE_VERSION_STRING "@VERSION_STRING@"
|
||||
#define CMAKE_RUN_IN_PLACE @RUN_IN_PLACE@
|
||||
#define CMAKE_USE_GETTEXT @USE_GETTEXT@
|
||||
#define CMAKE_USE_SOUND @USE_SOUND@
|
||||
#define CMAKE_STATIC_SHAREDIR "@SHAREDIR@"
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define CMAKE_BUILD_TYPE "Release"
|
||||
#else
|
||||
#define CMAKE_BUILD_TYPE "Debug"
|
||||
#endif
|
||||
#define CMAKE_USE_GETTEXT @USE_GETTEXT@
|
||||
#define CMAKE_USE_SOUND @USE_SOUND@
|
||||
#define CMAKE_BUILD_INFO "VER=@VERSION_STRING@ BUILD_TYPE="CMAKE_BUILD_TYPE" RUN_IN_PLACE=@RUN_IN_PLACE@ USE_GETTEXT=@USE_GETTEXT@ USE_SOUND=@USE_SOUND@ INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@"
|
||||
#define CMAKE_BUILD_INFO "VER=@VERSION_STRING@ BUILD_TYPE="CMAKE_BUILD_TYPE" RUN_IN_PLACE=@RUN_IN_PLACE@ USE_GETTEXT=@USE_GETTEXT@ USE_SOUND=@USE_SOUND@ STATIC_SHAREDIR=@SHAREDIR@"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -8,9 +8,10 @@
|
||||
|
||||
#define PROJECT_NAME "Minetest"
|
||||
#define VERSION_STRING "unknown"
|
||||
#define BUILD_TYPE "unknown"
|
||||
#define RUN_IN_PLACE 0
|
||||
#define USE_GETTEXT 0
|
||||
#define USE_SOUND 0
|
||||
#define STATIC_SHAREDIR ""
|
||||
#define BUILD_INFO "non-cmake"
|
||||
|
||||
#ifdef USE_CMAKE_CONFIG_H
|
||||
@@ -19,12 +20,14 @@
|
||||
#define PROJECT_NAME CMAKE_PROJECT_NAME
|
||||
#undef VERSION_STRING
|
||||
#define VERSION_STRING CMAKE_VERSION_STRING
|
||||
#undef BUILD_INFO
|
||||
#define BUILD_INFO CMAKE_BUILD_INFO
|
||||
#undef RUN_IN_PLACE
|
||||
#define RUN_IN_PLACE CMAKE_RUN_IN_PLACE
|
||||
#undef USE_GETTEXT
|
||||
#define USE_GETTEXT CMAKE_USE_GETTEXT
|
||||
#undef USE_SOUND
|
||||
#define USE_SOUND CMAKE_USE_SOUND
|
||||
#undef STATIC_SHAREDIR
|
||||
#define STATIC_SHAREDIR CMAKE_STATIC_SHAREDIR
|
||||
#undef BUILD_INFO
|
||||
#define BUILD_INFO CMAKE_BUILD_INFO
|
||||
#endif
|
||||
|
||||
@@ -45,6 +45,7 @@ if(DEFAULT_DLOPEN)
|
||||
else()
|
||||
option(LUA_USE_DLOPEN "Enable dlopen support." OFF)
|
||||
endif()
|
||||
mark_as_advanced(LUA_USE_DLOPEN)
|
||||
|
||||
if(DEFAULT_POSIX)
|
||||
else()
|
||||
@@ -55,6 +56,7 @@ if(DEFAULT_ANSI)
|
||||
else()
|
||||
option(LUA_ANSI "Disable non-ansi features." OFF)
|
||||
endif()
|
||||
mark_as_advanced(LUA_ANSI)
|
||||
|
||||
#
|
||||
# Lua version
|
||||
|
||||
@@ -878,7 +878,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Initialize debug streams
|
||||
#define DEBUGFILE "debug.txt"
|
||||
#ifdef RUN_IN_PLACE
|
||||
#if RUN_IN_PLACE
|
||||
std::string logfile = DEBUGFILE;
|
||||
#else
|
||||
std::string logfile = porting::path_user+DIR_DELIM+DEBUGFILE;
|
||||
@@ -962,7 +962,7 @@ int main(int argc, char *argv[])
|
||||
// Legacy configuration file location
|
||||
filenames.push_back(porting::path_user +
|
||||
DIR_DELIM + ".." + DIR_DELIM + "minetest.conf");
|
||||
#ifdef RUN_IN_PLACE
|
||||
#if RUN_IN_PLACE
|
||||
// Try also from a lower level (to aid having the same configuration
|
||||
// for many RUN_IN_PLACE installs)
|
||||
filenames.push_back(porting::path_user +
|
||||
|
||||
@@ -29,6 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "filesys.h"
|
||||
#include "log.h"
|
||||
#include "util/string.h"
|
||||
#include <list>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "CoreFoundation/CoreFoundation.h"
|
||||
@@ -154,7 +155,7 @@ bool detectMSVCBuildDir(char *c_path)
|
||||
|
||||
void initializePaths()
|
||||
{
|
||||
#ifdef RUN_IN_PLACE
|
||||
#if RUN_IN_PLACE
|
||||
/*
|
||||
Use relative paths if RUN_IN_PLACE
|
||||
*/
|
||||
@@ -252,19 +253,41 @@ void initializePaths()
|
||||
#elif defined(linux)
|
||||
#include <unistd.h>
|
||||
|
||||
char buf[BUFSIZ];
|
||||
memset(buf, 0, BUFSIZ);
|
||||
// Get path to executable
|
||||
assert(readlink("/proc/self/exe", buf, BUFSIZ-1) != -1);
|
||||
|
||||
pathRemoveFile(buf, '/');
|
||||
std::string bindir = "";
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
memset(buf, 0, BUFSIZ);
|
||||
assert(readlink("/proc/self/exe", buf, BUFSIZ-1) != -1);
|
||||
pathRemoveFile(buf, '/');
|
||||
bindir = buf;
|
||||
}
|
||||
|
||||
path_share = std::string(buf) + "/../share/" + PROJECT_NAME;
|
||||
//path_share = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME;
|
||||
if (!fs::PathExists(path_share)) {
|
||||
dstream<<"WARNING: system-wide share not found at \""<<path_share<<"\"";
|
||||
path_share = std::string(buf) + "/..";
|
||||
dstream<<"WARNING: Using \""<<path_share<<"\" instead."<<std::endl;
|
||||
// Find share directory from these.
|
||||
// It is identified by containing the subdirectory "builtin".
|
||||
std::list<std::string> trylist;
|
||||
std::string static_sharedir = STATIC_SHAREDIR;
|
||||
if(static_sharedir != "" && static_sharedir != ".")
|
||||
trylist.push_back(static_sharedir);
|
||||
trylist.push_back(bindir + "/../share/" + PROJECT_NAME);
|
||||
trylist.push_back(bindir + "/..");
|
||||
|
||||
for(std::list<std::string>::const_iterator i = trylist.begin();
|
||||
i != trylist.end(); i++)
|
||||
{
|
||||
const std::string &trypath = *i;
|
||||
if(!fs::PathExists(trypath) || !fs::PathExists(trypath + "/builtin")){
|
||||
dstream<<"WARNING: system-wide share not found at \""
|
||||
<<trypath<<"\""<<std::endl;
|
||||
continue;
|
||||
}
|
||||
// Warn if was not the first alternative
|
||||
if(i != trylist.begin()){
|
||||
dstream<<"WARNING: system-wide share found at \""
|
||||
<<trypath<<"\""<<std::endl;
|
||||
}
|
||||
path_share = trypath;
|
||||
break;
|
||||
}
|
||||
|
||||
path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;
|
||||
@@ -297,7 +320,7 @@ void initializePaths()
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
|
||||
path_share = std::string(INSTALL_PREFIX) + "/share/" + PROJECT_NAME;
|
||||
path_share = STATIC_SHAREDIR;
|
||||
path_user = std::string(getenv("HOME")) + "/." + PROJECT_NAME;
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user