mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Move some more sources to shared target
This commit is contained in:
parent
4e9aa7dc77
commit
b61c83a19d
12 changed files with 33 additions and 45 deletions
|
@ -391,7 +391,10 @@ add_subdirectory(server)
|
||||||
# a compiler error and you need to instead add it to client_SRCS or common_SRCS.
|
# a compiler error and you need to instead add it to client_SRCS or common_SRCS.
|
||||||
set(independent_SRCS
|
set(independent_SRCS
|
||||||
chat.cpp
|
chat.cpp
|
||||||
|
content_nodemeta.cpp
|
||||||
convert_json.cpp
|
convert_json.cpp
|
||||||
|
craftdef.cpp
|
||||||
|
debug.cpp
|
||||||
face_position_cache.cpp
|
face_position_cache.cpp
|
||||||
gettext_plural_form.cpp
|
gettext_plural_form.cpp
|
||||||
httpfetch.cpp
|
httpfetch.cpp
|
||||||
|
@ -411,11 +414,17 @@ set(independent_SRCS
|
||||||
particles.cpp
|
particles.cpp
|
||||||
profiler.cpp
|
profiler.cpp
|
||||||
serialization.cpp
|
serialization.cpp
|
||||||
|
settings.cpp
|
||||||
staticobject.cpp
|
staticobject.cpp
|
||||||
terminal_chat_console.cpp
|
terminal_chat_console.cpp
|
||||||
texture_override.cpp
|
texture_override.cpp
|
||||||
tileanimation.cpp
|
tileanimation.cpp
|
||||||
|
tool.cpp
|
||||||
|
${common_network_SRCS}
|
||||||
|
${content_SRCS}
|
||||||
|
${database_SRCS}
|
||||||
${threading_SRCS}
|
${threading_SRCS}
|
||||||
|
${util_SRCS}
|
||||||
)
|
)
|
||||||
|
|
||||||
# /!\ Consider carefully before adding files here /!\
|
# /!\ Consider carefully before adding files here /!\
|
||||||
|
@ -423,9 +432,6 @@ set(common_SRCS
|
||||||
clientdynamicinfo.cpp
|
clientdynamicinfo.cpp
|
||||||
collision.cpp
|
collision.cpp
|
||||||
content_mapnode.cpp
|
content_mapnode.cpp
|
||||||
content_nodemeta.cpp
|
|
||||||
craftdef.cpp
|
|
||||||
debug.cpp
|
|
||||||
defaultsettings.cpp
|
defaultsettings.cpp
|
||||||
emerge.cpp
|
emerge.cpp
|
||||||
environment.cpp
|
environment.cpp
|
||||||
|
@ -451,19 +457,14 @@ set(common_SRCS
|
||||||
server.cpp
|
server.cpp
|
||||||
serverenvironment.cpp
|
serverenvironment.cpp
|
||||||
servermap.cpp
|
servermap.cpp
|
||||||
settings.cpp
|
|
||||||
tool.cpp
|
|
||||||
translation.cpp
|
translation.cpp
|
||||||
version.cpp
|
version.cpp
|
||||||
voxel.cpp
|
voxel.cpp
|
||||||
voxelalgorithms.cpp
|
voxelalgorithms.cpp
|
||||||
${common_network_SRCS}
|
|
||||||
${common_SCRIPT_SRCS}
|
${common_SCRIPT_SRCS}
|
||||||
${common_server_SRCS}
|
${common_server_SRCS}
|
||||||
${content_SRCS}
|
|
||||||
${database_SRCS}
|
|
||||||
${mapgen_SRCS}
|
${mapgen_SRCS}
|
||||||
${UTIL_SRCS}
|
${server_network_SRCS}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
|
@ -587,6 +588,9 @@ add_library(EngineCommon OBJECT
|
||||||
${independent_SRCS}
|
${independent_SRCS}
|
||||||
)
|
)
|
||||||
add_dependencies(EngineCommon GenerateVersion)
|
add_dependencies(EngineCommon GenerateVersion)
|
||||||
|
target_link_libraries(EngineCommon
|
||||||
|
sha256
|
||||||
|
)
|
||||||
get_target_property(
|
get_target_property(
|
||||||
IRRLICHT_INCLUDES IrrlichtMt::IrrlichtMt INTERFACE_INCLUDE_DIRECTORIES)
|
IRRLICHT_INCLUDES IrrlichtMt::IrrlichtMt INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
target_include_directories(EngineCommon PRIVATE ${IRRLICHT_INCLUDES})
|
target_include_directories(EngineCommon PRIVATE ${IRRLICHT_INCLUDES})
|
||||||
|
|
|
@ -28,10 +28,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "map_settings_manager.h"
|
#include "map_settings_manager.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
|
|
||||||
#if CHECK_CLIENT_BUILD()
|
|
||||||
#include "client/texturepaths.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// The maximum number of identical world names allowed
|
// The maximum number of identical world names allowed
|
||||||
#define MAX_WORLD_NAMES 100
|
#define MAX_WORLD_NAMES 100
|
||||||
|
|
||||||
|
@ -96,8 +92,7 @@ std::string getSubgamePathEnv()
|
||||||
|
|
||||||
static SubgameSpec getSubgameSpec(const std::string &game_id,
|
static SubgameSpec getSubgameSpec(const std::string &game_id,
|
||||||
const std::string &game_path,
|
const std::string &game_path,
|
||||||
const std::unordered_map<std::string, std::string> &mods_paths,
|
const std::unordered_map<std::string, std::string> &mods_paths)
|
||||||
const std::string &menuicon_path)
|
|
||||||
{
|
{
|
||||||
const auto gamemods_path = game_path + DIR_DELIM + "mods";
|
const auto gamemods_path = game_path + DIR_DELIM + "mods";
|
||||||
// Get meta
|
// Get meta
|
||||||
|
@ -130,7 +125,7 @@ static SubgameSpec getSubgameSpec(const std::string &game_id,
|
||||||
last_mod = conf.get("last_mod");
|
last_mod = conf.get("last_mod");
|
||||||
|
|
||||||
SubgameSpec spec(game_id, game_path, gamemods_path, mods_paths, game_title,
|
SubgameSpec spec(game_id, game_path, gamemods_path, mods_paths, game_title,
|
||||||
menuicon_path, game_author, game_release, first_mod, last_mod);
|
game_author, game_release, first_mod, last_mod);
|
||||||
|
|
||||||
if (conf.exists("name") && !conf.exists("title"))
|
if (conf.exists("name") && !conf.exists("title"))
|
||||||
spec.deprecation_msgs.push_back("\"name\" setting in game.conf is deprecated, please use \"title\" instead");
|
spec.deprecation_msgs.push_back("\"name\" setting in game.conf is deprecated, please use \"title\" instead");
|
||||||
|
@ -191,13 +186,7 @@ SubgameSpec findSubgame(const std::string &id)
|
||||||
mods_paths[fs::AbsolutePath(mod_path)] = mod_path;
|
mods_paths[fs::AbsolutePath(mod_path)] = mod_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string menuicon_path;
|
return getSubgameSpec(id, game_path, mods_paths);
|
||||||
#if CHECK_CLIENT_BUILD()
|
|
||||||
menuicon_path = getImagePath(
|
|
||||||
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return getSubgameSpec(id, game_path, mods_paths, menuicon_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SubgameSpec findWorldSubgame(const std::string &world_path)
|
SubgameSpec findWorldSubgame(const std::string &world_path)
|
||||||
|
@ -206,7 +195,7 @@ SubgameSpec findWorldSubgame(const std::string &world_path)
|
||||||
// See if world contains an embedded game; if so, use it.
|
// See if world contains an embedded game; if so, use it.
|
||||||
std::string world_gamepath = world_path + DIR_DELIM + "game";
|
std::string world_gamepath = world_path + DIR_DELIM + "game";
|
||||||
if (fs::PathExists(world_gamepath))
|
if (fs::PathExists(world_gamepath))
|
||||||
return getSubgameSpec(world_gameid, world_gamepath, {}, "");
|
return getSubgameSpec(world_gameid, world_gamepath, {});
|
||||||
return findSubgame(world_gameid);
|
return findSubgame(world_gameid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,6 @@ struct SubgameSpec
|
||||||
* Map from virtual path to mods path
|
* Map from virtual path to mods path
|
||||||
*/
|
*/
|
||||||
std::unordered_map<std::string, std::string> addon_mods_paths;
|
std::unordered_map<std::string, std::string> addon_mods_paths;
|
||||||
std::string menuicon_path;
|
|
||||||
|
|
||||||
// For logging purposes
|
// For logging purposes
|
||||||
std::vector<const char *> deprecation_msgs;
|
std::vector<const char *> deprecation_msgs;
|
||||||
|
@ -50,7 +49,6 @@ struct SubgameSpec
|
||||||
const std::string &gamemods_path = "",
|
const std::string &gamemods_path = "",
|
||||||
const std::unordered_map<std::string, std::string> &addon_mods_paths = {},
|
const std::unordered_map<std::string, std::string> &addon_mods_paths = {},
|
||||||
const std::string &title = "",
|
const std::string &title = "",
|
||||||
const std::string &menuicon_path = "",
|
|
||||||
const std::string &author = "", int release = 0,
|
const std::string &author = "", int release = 0,
|
||||||
const std::string &first_mod = "",
|
const std::string &first_mod = "",
|
||||||
const std::string &last_mod = "") :
|
const std::string &last_mod = "") :
|
||||||
|
@ -60,8 +58,7 @@ struct SubgameSpec
|
||||||
last_mod(last_mod),
|
last_mod(last_mod),
|
||||||
path(path),
|
path(path),
|
||||||
gamemods_path(gamemods_path),
|
gamemods_path(gamemods_path),
|
||||||
addon_mods_paths(addon_mods_paths),
|
addon_mods_paths(addon_mods_paths)
|
||||||
menuicon_path(menuicon_path)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,13 @@ set(common_network_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mtp/threads.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/mtp/threads.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/networkpacket.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/networkpacket.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/networkprotocol.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/networkprotocol.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/socket.cpp
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
|
|
||||||
|
set(server_network_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/serveropcodes.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/serveropcodes.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/serverpackethandler.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/serverpackethandler.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/socket.cpp
|
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
|
|
||||||
bool is_valid_player_name(std::string_view name) {
|
bool is_valid_player_name(std::string_view name)
|
||||||
|
{
|
||||||
return !name.empty() && name.size() <= PLAYERNAME_SIZE && string_allowed(name, PLAYERNAME_ALLOWED_CHARS);
|
return !name.empty() && name.size() <= PLAYERNAME_SIZE && string_allowed(name, PLAYERNAME_ALLOWED_CHARS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,8 +210,6 @@ void PlayerControl::setMovementFromKeys()
|
||||||
movement_direction = std::atan2(x, y);
|
movement_direction = std::atan2(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CHECK_CLIENT_BUILD()
|
|
||||||
|
|
||||||
u32 PlayerControl::getKeysPressed() const
|
u32 PlayerControl::getKeysPressed() const
|
||||||
{
|
{
|
||||||
u32 keypress_bits =
|
u32 keypress_bits =
|
||||||
|
@ -254,7 +253,6 @@ u32 PlayerControl::getKeysPressed() const
|
||||||
return keypress_bits;
|
return keypress_bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void PlayerControl::unpackKeysPressed(u32 keypress_bits)
|
void PlayerControl::unpackKeysPressed(u32 keypress_bits)
|
||||||
{
|
{
|
||||||
|
|
|
@ -91,11 +91,9 @@ struct PlayerControl
|
||||||
// joystick input.
|
// joystick input.
|
||||||
void setMovementFromKeys();
|
void setMovementFromKeys();
|
||||||
|
|
||||||
#if CHECK_CLIENT_BUILD()
|
|
||||||
// For client use
|
// For client use
|
||||||
u32 getKeysPressed() const;
|
u32 getKeysPressed() const;
|
||||||
inline bool isMoving() const { return movement_speed > 0.001f; }
|
inline bool isMoving() const { return movement_speed > 0.001f; }
|
||||||
#endif
|
|
||||||
|
|
||||||
// For server use
|
// For server use
|
||||||
void unpackKeysPressed(u32 keypress_bits);
|
void unpackKeysPressed(u32 keypress_bits);
|
||||||
|
|
|
@ -37,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "clientdynamicinfo.h"
|
#include "clientdynamicinfo.h"
|
||||||
#include "client/client.h"
|
#include "client/client.h"
|
||||||
#include "client/renderingengine.h"
|
#include "client/renderingengine.h"
|
||||||
|
#include "client/texturepaths.h"
|
||||||
#include "network/networkprotocol.h"
|
#include "network/networkprotocol.h"
|
||||||
#include "content/mod_configuration.h"
|
#include "content/mod_configuration.h"
|
||||||
#include "threading/mutex_auto_lock.h"
|
#include "threading/mutex_auto_lock.h"
|
||||||
|
@ -330,8 +331,9 @@ int ModApiMainMenu::l_get_games(lua_State *L)
|
||||||
lua_pushinteger(L, game.release);
|
lua_pushinteger(L, game.release);
|
||||||
lua_settable(L, top_lvl2);
|
lua_settable(L, top_lvl2);
|
||||||
|
|
||||||
|
auto menuicon = getImagePath(game.path + DIR_DELIM "menu" DIR_DELIM "icon.png");
|
||||||
lua_pushstring(L, "menuicon_path");
|
lua_pushstring(L, "menuicon_path");
|
||||||
lua_pushstring(L, game.menuicon_path.c_str());
|
lua_pushstring(L, menuicon.c_str());
|
||||||
lua_settable(L, top_lvl2);
|
lua_settable(L, top_lvl2);
|
||||||
|
|
||||||
lua_pushstring(L, "addon_mods_paths");
|
lua_pushstring(L, "addon_mods_paths");
|
||||||
|
|
|
@ -29,6 +29,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
// Client translations
|
// Client translations
|
||||||
static Translations client_translations;
|
static Translations client_translations;
|
||||||
Translations *g_client_translations = &client_translations;
|
Translations *g_client_translations = &client_translations;
|
||||||
|
#else
|
||||||
|
Translations *g_client_translations = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::string_view Translations::getFileLanguage(const std::string &filename)
|
const std::string_view Translations::getFileLanguage(const std::string &filename)
|
||||||
|
|
|
@ -28,9 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
class Translations;
|
class Translations;
|
||||||
#if IS_CLIENT_BUILD
|
|
||||||
extern Translations *g_client_translations;
|
extern Translations *g_client_translations;
|
||||||
#endif
|
|
||||||
|
|
||||||
class Translations
|
class Translations
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
set(UTIL_SRCS
|
set(util_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/areastore.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/areastore.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/auth.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/auth.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/colorize.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/colorize.cpp
|
||||||
|
|
|
@ -932,14 +932,9 @@ std::wstring translate_string(std::wstring_view s, Translations *translations)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Translate string client side
|
|
||||||
std::wstring translate_string(std::wstring_view s)
|
std::wstring translate_string(std::wstring_view s)
|
||||||
{
|
{
|
||||||
#if !CHECK_CLIENT_BUILD()
|
|
||||||
return translate_string(s, nullptr);
|
|
||||||
#else
|
|
||||||
return translate_string(s, g_client_translations);
|
return translate_string(s, g_client_translations);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::array<std::wstring_view, 30> disallowed_dir_names = {
|
static const std::array<std::wstring_view, 30> disallowed_dir_names = {
|
||||||
|
|
|
@ -658,7 +658,8 @@ std::wstring translate_string(std::wstring_view s, Translations *translations);
|
||||||
|
|
||||||
std::wstring translate_string(std::wstring_view s);
|
std::wstring translate_string(std::wstring_view s);
|
||||||
|
|
||||||
inline std::wstring unescape_translate(std::wstring_view s) {
|
inline std::wstring unescape_translate(std::wstring_view s)
|
||||||
|
{
|
||||||
return unescape_enriched(translate_string(s));
|
return unescape_enriched(translate_string(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue