Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
subgames.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include <string>
8#include <set>
9#include <unordered_map>
10#include <vector>
11
12class Settings;
13
15{
16 std::string id;
17 std::string title;
18 std::string author;
20 std::string first_mod; // "" <=> no mod
21 std::string last_mod; // "" <=> no mod
22 std::string path;
23 std::string gamemods_path;
24
28 std::unordered_map<std::string, std::string> addon_mods_paths;
29
30 // For logging purposes
31 std::vector<const char *> deprecation_msgs;
32
33 SubgameSpec(const std::string &id = "", const std::string &path = "",
34 const std::string &gamemods_path = "",
35 const std::unordered_map<std::string, std::string> &addon_mods_paths = {},
36 const std::string &title = "",
37 const std::string &author = "", int release = 0,
38 const std::string &first_mod = "",
39 const std::string &last_mod = "") :
40 id(id),
44 path(path),
47 {
48 }
49
50 bool isValid() const { return (!id.empty() && !path.empty()); }
51 void checkAndLog() const;
52};
53
54SubgameSpec findSubgame(const std::string &id);
55SubgameSpec findWorldSubgame(const std::string &world_path);
56
57std::set<std::string> getAvailableGameIds();
58std::vector<SubgameSpec> getAvailableGames();
59// Get the list of paths to mods in the environment variable $MINETEST_MOD_PATH
60std::vector<std::string> getEnvModPaths();
61
62bool getWorldExists(const std::string &world_path);
64std::string getWorldName(const std::string &world_path, const std::string &default_name);
65std::string getWorldGameId(const std::string &world_path, bool can_be_legacy = false);
66
68{
69 std::string path;
70 std::string name;
71 std::string gameid;
72
73 WorldSpec(const std::string &path = "", const std::string &name = "",
74 const std::string &gameid = "") :
75 path(path),
77 {
78 }
79
80 bool isValid() const
81 {
82 return (!name.empty() && !path.empty() && !gameid.empty());
83 }
84};
85
86std::vector<WorldSpec> getAvailableWorlds();
87
88// loads the subgame's config and creates world directory
89// and world.mt if they don't exist
90void loadGameConfAndInitWorld(const std::string &path, const std::string &name,
91 const SubgameSpec &gamespec, bool create_world);
Definition settings.h:109
Definition subgames.h:15
std::string gamemods_path
Definition subgames.h:23
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 &title="", const std::string &author="", int release=0, const std::string &first_mod="", const std::string &last_mod="")
Definition subgames.h:33
std::string title
Definition subgames.h:17
std::string first_mod
Definition subgames.h:20
std::unordered_map< std::string, std::string > addon_mods_paths
Map from virtual path to mods path.
Definition subgames.h:28
void checkAndLog() const
Definition subgames.cpp:35
std::string author
Definition subgames.h:18
bool isValid() const
Definition subgames.h:50
std::string last_mod
Definition subgames.h:21
std::vector< const char * > deprecation_msgs
Definition subgames.h:31
std::string id
Definition subgames.h:16
int release
Definition subgames.h:19
std::string path
Definition subgames.h:22
Definition subgames.h:68
bool isValid() const
Definition subgames.h:80
WorldSpec(const std::string &path="", const std::string &name="", const std::string &gameid="")
Definition subgames.h:73
std::string gameid
Definition subgames.h:71
std::string path
Definition subgames.h:69
std::string name
Definition subgames.h:70
std::vector< SubgameSpec > getAvailableGames()
Definition subgames.cpp:228
std::vector< WorldSpec > getAvailableWorlds()
Definition subgames.cpp:284
std::string getWorldGameId(const std::string &world_path, bool can_be_legacy=false)
Definition subgames.cpp:260
std::set< std::string > getAvailableGameIds()
Definition subgames.cpp:191
SubgameSpec findWorldSubgame(const std::string &world_path)
Definition subgames.cpp:181
SubgameSpec findSubgame(const std::string &id)
Definition subgames.cpp:125
std::string getWorldName(const std::string &world_path, const std::string &default_name)
Try to get the displayed name of a world.
Definition subgames.cpp:246
void loadGameConfAndInitWorld(const std::string &path, const std::string &name, const SubgameSpec &gamespec, bool create_world)
Definition subgames.cpp:332
std::vector< std::string > getEnvModPaths()
Definition subgames.cpp:412
bool getWorldExists(const std::string &world_path)
Definition subgames.cpp:238