subgame.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. Minetest
  3. Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #ifndef SUBGAME_HEADER
  17. #define SUBGAME_HEADER
  18. #include <string>
  19. #include <set>
  20. #include <vector>
  21. class Settings;
  22. #define WORLDNAME_BLACKLISTED_CHARS "/\\"
  23. struct SubgameSpec
  24. {
  25. std::string id; // "" = game does not exist
  26. std::string path; // path to game
  27. std::string gamemods_path; //path to mods of the game
  28. std::set<std::string> addon_mods_paths; //paths to addon mods for this game
  29. std::string name;
  30. std::string menuicon_path;
  31. SubgameSpec(const std::string &id_="",
  32. const std::string &path_="",
  33. const std::string &gamemods_path_="",
  34. const std::set<std::string> &addon_mods_paths_=std::set<std::string>(),
  35. const std::string &name_="",
  36. const std::string &menuicon_path_=""):
  37. id(id_),
  38. path(path_),
  39. gamemods_path(gamemods_path_),
  40. addon_mods_paths(addon_mods_paths_),
  41. name(name_),
  42. menuicon_path(menuicon_path_)
  43. {}
  44. bool isValid() const
  45. {
  46. return (id != "" && path != "");
  47. }
  48. };
  49. // minetest.conf
  50. bool getGameMinetestConfig(const std::string &game_path, Settings &conf);
  51. // game.conf
  52. bool getGameConfig(const std::string &game_path, Settings &conf);
  53. std::string getGameName(const std::string &game_path);
  54. SubgameSpec findSubgame(const std::string &id);
  55. SubgameSpec findWorldSubgame(const std::string &world_path);
  56. std::set<std::string> getAvailableGameIds();
  57. std::vector<SubgameSpec> getAvailableGames();
  58. bool getWorldExists(const std::string &world_path);
  59. std::string getWorldGameId(const std::string &world_path,
  60. bool can_be_legacy=false);
  61. struct WorldSpec
  62. {
  63. std::string path;
  64. std::string name;
  65. std::string gameid;
  66. WorldSpec(
  67. const std::string &path_="",
  68. const std::string &name_="",
  69. const std::string &gameid_=""
  70. ):
  71. path(path_),
  72. name(name_),
  73. gameid(gameid_)
  74. {}
  75. bool isValid() const
  76. {
  77. return (name != "" && path != "" && gameid != "");
  78. }
  79. };
  80. std::vector<WorldSpec> getAvailableWorlds();
  81. // Create world directory and world.mt if they don't exist
  82. bool initializeWorld(const std::string &path, const std::string &gameid);
  83. #endif