Luanti 5.15.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
12
14{
15 std::string id;
16 std::string title;
17 std::string author;
19 std::string first_mod; // "" <=> no mod
20 std::string last_mod; // "" <=> no mod
21 std::string path;
22 std::string gamemods_path;
23
27 std::unordered_map<std::string, std::string> addon_mods_paths;
28
29 // For logging purposes
30 std::vector<const char *> deprecation_msgs;
31
32 SubgameSpec(const std::string &id = "", const std::string &path = "",
33 const std::string &gamemods_path = "",
34 const std::unordered_map<std::string, std::string> &addon_mods_paths = {},
35 const std::string &title = "",
36 const std::string &author = "", int release = 0,
37 const std::string &first_mod = "",
38 const std::string &last_mod = "") :
39 id(id),
43 path(path),
46 {
47 }
48
49 bool isValid() const { return (!id.empty() && !path.empty()); }
50 void checkAndLog() const;
51};
52
53SubgameSpec findSubgame(const std::string &id);
54SubgameSpec findWorldSubgame(const std::string &world_path);
55
56std::set<std::string> getAvailableGameIds();
57std::vector<SubgameSpec> getAvailableGames();
58// Get the list of paths to mods in the environment variable $MINETEST_MOD_PATH
59std::vector<std::string> getEnvModPaths();
60
61bool getWorldExists(const std::string &world_path);
63std::string getWorldName(const std::string &world_path, const std::string &default_name);
64std::string getWorldGameId(const std::string &world_path, bool can_be_legacy = false);
65
67{
68 std::string path;
69 std::string name;
70 std::string gameid;
71
72 WorldSpec(const std::string &path = "", const std::string &name = "",
73 const std::string &gameid = "") :
74 path(path),
76 {
77 }
78
79 bool isValid() const
80 {
81 return (!name.empty() && !path.empty() && !gameid.empty());
82 }
83};
84
85std::vector<WorldSpec> getAvailableWorlds();
86
87// loads the subgame's config and creates world directory
88// and world.mt if they don't exist
89void loadGameConfAndInitWorld(const std::string &path, const std::string &name,
90 const SubgameSpec &gamespec, bool create_world);
Definition subgames.h:14
std::string gamemods_path
Definition subgames.h:22
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:32
std::string title
Definition subgames.h:16
std::string first_mod
Definition subgames.h:19
std::unordered_map< std::string, std::string > addon_mods_paths
Map from virtual path to mods path.
Definition subgames.h:27
void checkAndLog() const
Definition subgames.cpp:35
std::string author
Definition subgames.h:17
bool isValid() const
Definition subgames.h:49
std::string last_mod
Definition subgames.h:20
std::vector< const char * > deprecation_msgs
Definition subgames.h:30
std::string id
Definition subgames.h:15
int release
Definition subgames.h:18
std::string path
Definition subgames.h:21
Definition subgames.h:67
bool isValid() const
Definition subgames.h:79
WorldSpec(const std::string &path="", const std::string &name="", const std::string &gameid="")
Definition subgames.h:72
std::string gameid
Definition subgames.h:70
std::string path
Definition subgames.h:68
std::string name
Definition subgames.h:69
std::vector< SubgameSpec > getAvailableGames()
Definition subgames.cpp:228
std::vector< WorldSpec > getAvailableWorlds()
Definition subgames.cpp:286
std::string getWorldGameId(const std::string &world_path, bool can_be_legacy=false)
Definition subgames.cpp:262
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:248
void loadGameConfAndInitWorld(const std::string &path, const std::string &name, const SubgameSpec &gamespec, bool create_world)
Definition subgames.cpp:334
std::vector< std::string > getEnvModPaths()
Definition subgames.cpp:414
bool getWorldExists(const std::string &world_path)
Definition subgames.cpp:238