aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content/content.cpp7
-rw-r--r--src/content/content.h7
-rw-r--r--src/content/subgames.cpp46
-rw-r--r--src/content/subgames.h10
-rw-r--r--src/script/lua_api/l_mainmenu.cpp11
-rw-r--r--src/server.cpp3
6 files changed, 70 insertions, 14 deletions
diff --git a/src/content/content.cpp b/src/content/content.cpp
index 66ef83d42..e576943ff 100644
--- a/src/content/content.cpp
+++ b/src/content/content.cpp
@@ -96,7 +96,12 @@ void parseContentInfo(ContentSpec &spec)
Settings conf;
if (!conf_path.empty() && conf.readConfigFile(conf_path.c_str())) {
- if (conf.exists("name"))
+ if (conf.exists("title"))
+ spec.title = conf.get("title");
+ else if (spec.type == "game" && conf.exists("name"))
+ spec.title = conf.get("name");
+
+ if (spec.type != "game" && conf.exists("name"))
spec.name = conf.get("name");
if (conf.exists("description"))
diff --git a/src/content/content.h b/src/content/content.h
index e246ed411..ce09a2eb9 100644
--- a/src/content/content.h
+++ b/src/content/content.h
@@ -27,7 +27,14 @@ struct ContentSpec
std::string type;
std::string author;
u32 release = 0;
+
+ /// Technical name / Id
std::string name;
+
+ /// Human-readable title
+ std::string title;
+
+ /// Short description
std::string desc;
std::string path;
};
diff --git a/src/content/subgames.cpp b/src/content/subgames.cpp
index 23355990e..d0de926ef 100644
--- a/src/content/subgames.cpp
+++ b/src/content/subgames.cpp
@@ -17,6 +17,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <common/c_internal.h>
#include "content/subgames.h"
#include "porting.h"
#include "filesys.h"
@@ -45,6 +46,25 @@ bool getGameMinetestConfig(const std::string &game_path, Settings &conf)
}
+
+void SubgameSpec::checkAndLog() const
+{
+ // Log deprecation messages
+ auto handling_mode = get_deprecated_handling_mode();
+ if (!deprecation_msgs.empty() && handling_mode != DeprecatedHandlingMode::Ignore) {
+ std::ostringstream os;
+ os << "Game " << title << " at " << path << ":" << std::endl;
+ for (auto msg : deprecation_msgs)
+ os << "\t" << msg << std::endl;
+
+ if (handling_mode == DeprecatedHandlingMode::Error)
+ throw ModError(os.str());
+ else
+ warningstream << os.str();
+ }
+}
+
+
struct GameFindPath
{
std::string path;
@@ -121,11 +141,13 @@ SubgameSpec findSubgame(const std::string &id)
Settings conf;
conf.readConfigFile(conf_path.c_str());
- std::string game_name;
- if (conf.exists("name"))
- game_name = conf.get("name");
+ std::string game_title;
+ if (conf.exists("title"))
+ game_title = conf.get("title");
+ else if (conf.exists("name"))
+ game_title = conf.get("name");
else
- game_name = id;
+ game_title = id;
std::string game_author;
if (conf.exists("author"))
@@ -140,8 +162,14 @@ SubgameSpec findSubgame(const std::string &id)
menuicon_path = getImagePath(
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
#endif
- return SubgameSpec(id, game_path, gamemod_path, mods_paths, game_name,
+
+ SubgameSpec spec(id, game_path, gamemod_path, mods_paths, game_title,
menuicon_path, game_author, game_release);
+
+ if (conf.exists("name") && !conf.exists("title"))
+ spec.deprecation_msgs.push_back("\"name\" setting in game.conf is deprecated, please use \"title\" instead");
+
+ return spec;
}
SubgameSpec findWorldSubgame(const std::string &world_path)
@@ -159,10 +187,12 @@ SubgameSpec findWorldSubgame(const std::string &world_path)
std::string conf_path = world_gamepath + DIR_DELIM + "game.conf";
conf.readConfigFile(conf_path.c_str());
- if (conf.exists("name"))
- gamespec.name = conf.get("name");
+ if (conf.exists("title"))
+ gamespec.title = conf.get("title");
+ else if (conf.exists("name"))
+ gamespec.title = conf.get("name");
else
- gamespec.name = world_gameid;
+ gamespec.title = world_gameid;
return gamespec;
}
diff --git a/src/content/subgames.h b/src/content/subgames.h
index d36b4952f..d5d168243 100644
--- a/src/content/subgames.h
+++ b/src/content/subgames.h
@@ -29,7 +29,7 @@ class Settings;
struct SubgameSpec
{
std::string id;
- std::string name;
+ std::string title;
std::string author;
int release;
std::string path;
@@ -41,20 +41,24 @@ struct SubgameSpec
std::unordered_map<std::string, std::string> addon_mods_paths;
std::string menuicon_path;
+ // For logging purposes
+ std::vector<const char *> deprecation_msgs;
+
SubgameSpec(const std::string &id = "", const std::string &path = "",
const std::string &gamemods_path = "",
const std::unordered_map<std::string, std::string> &addon_mods_paths = {},
- const std::string &name = "",
+ const std::string &title = "",
const std::string &menuicon_path = "",
const std::string &author = "", int release = 0) :
id(id),
- name(name), author(author), release(release), path(path),
+ title(title), author(author), release(release), path(path),
gamemods_path(gamemods_path), addon_mods_paths(addon_mods_paths),
menuicon_path(menuicon_path)
{
}
bool isValid() const { return (!id.empty() && !path.empty()); }
+ void checkAndLog() const;
};
SubgameSpec findSubgame(const std::string &id);
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index db031dde5..4d9fa5b14 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -304,7 +304,11 @@ int ModApiMainMenu::l_get_games(lua_State *L)
lua_settable(L, top_lvl2);
lua_pushstring(L, "name");
- lua_pushstring(L, game.name.c_str());
+ lua_pushstring(L, game.title.c_str());
+ lua_settable(L, top_lvl2);
+
+ lua_pushstring(L, "title");
+ lua_pushstring(L, game.title.c_str());
lua_settable(L, top_lvl2);
lua_pushstring(L, "author");
@@ -356,6 +360,11 @@ int ModApiMainMenu::l_get_content_info(lua_State *L)
lua_pushstring(L, spec.author.c_str());
lua_setfield(L, -2, "author");
+ if (!spec.title.empty()) {
+ lua_pushstring(L, spec.title.c_str());
+ lua_setfield(L, -2, "title");
+ }
+
lua_pushinteger(L, spec.release);
lua_setfield(L, -2, "release");
diff --git a/src/server.cpp b/src/server.cpp
index d93f300d2..b6330c96a 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -440,6 +440,7 @@ void Server::init()
m_script->loadMod(getBuiltinLuaPath() + DIR_DELIM "init.lua", BUILTIN_MOD_NAME);
+ m_gamespec.checkAndLog();
m_modmgr->loadMods(m_script);
// Read Textures and calculate sha1 sums
@@ -3109,7 +3110,7 @@ std::string Server::getStatusString()
// Version
os << "version: " << g_version_string;
// Game
- os << " | game: " << (m_gamespec.name.empty() ? m_gamespec.id : m_gamespec.name);
+ os << " | game: " << (m_gamespec.title.empty() ? m_gamespec.id : m_gamespec.title);
// Uptime
os << " | uptime: " << duration_to_string((int) m_uptime_counter->get());
// Max lag estimate