2024-10-28 15:57:39 +01:00
|
|
|
// Luanti
|
|
|
|
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
// Copyright (C) 2018 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
|
2018-03-16 08:41:33 +01:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-05-07 16:44:46 +01:00
|
|
|
#include "content/mod_configuration.h"
|
2020-04-27 08:31:37 +02:00
|
|
|
#include <memory>
|
2018-03-16 08:41:33 +01:00
|
|
|
|
|
|
|
class ServerScripting;
|
|
|
|
|
|
|
|
/**
|
2024-03-12 14:13:24 +01:00
|
|
|
* Manages server mods
|
2018-03-16 08:41:33 +01:00
|
|
|
*
|
|
|
|
* All new calls to this class must be tested in test_servermodmanager.cpp
|
|
|
|
*/
|
2022-05-07 16:44:46 +01:00
|
|
|
class ServerModManager
|
2018-03-16 08:41:33 +01:00
|
|
|
{
|
2022-05-07 16:44:46 +01:00
|
|
|
ModConfiguration configuration;
|
|
|
|
|
2018-03-16 08:41:33 +01:00
|
|
|
public:
|
2024-03-12 14:13:24 +01:00
|
|
|
|
2018-03-16 08:41:33 +01:00
|
|
|
/**
|
|
|
|
* Creates a ServerModManager which targets worldpath
|
|
|
|
* @param worldpath
|
|
|
|
*/
|
|
|
|
ServerModManager(const std::string &worldpath);
|
2024-03-12 14:13:24 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an empty ServerModManager. For testing purposes.
|
|
|
|
* Note: definition looks like this so it isn't accidentally used.
|
|
|
|
*/
|
|
|
|
explicit ServerModManager(std::nullptr_t) {};
|
|
|
|
|
|
|
|
void loadMods(ServerScripting &script);
|
2018-03-16 08:41:33 +01:00
|
|
|
const ModSpec *getModSpec(const std::string &modname) const;
|
|
|
|
void getModNames(std::vector<std::string> &modlist) const;
|
2022-05-07 16:44:46 +01:00
|
|
|
|
|
|
|
inline const std::vector<ModSpec> &getMods() const {
|
|
|
|
return configuration.getMods();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline const std::vector<ModSpec> &getUnsatisfiedMods() const {
|
|
|
|
return configuration.getUnsatisfiedMods();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool isConsistent() const {
|
|
|
|
return configuration.isConsistent();
|
|
|
|
}
|
|
|
|
|
2022-08-19 12:31:36 +01:00
|
|
|
inline std::string getUnsatisfiedModsError() const {
|
|
|
|
return configuration.getUnsatisfiedModsError();
|
2022-05-07 16:44:46 +01:00
|
|
|
}
|
|
|
|
|
2021-02-23 19:39:15 +01:00
|
|
|
/**
|
|
|
|
* Recursively gets all paths of mod folders that can contain media files.
|
|
|
|
*
|
|
|
|
* Result is ordered in descending priority, ie. files from an earlier path
|
|
|
|
* should not be replaced by files from a latter one.
|
|
|
|
*
|
|
|
|
* @param paths result vector
|
|
|
|
*/
|
2018-03-16 08:41:33 +01:00
|
|
|
void getModsMediaPaths(std::vector<std::string> &paths) const;
|
|
|
|
};
|