Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
IonAgorria committed Sep 28, 2023
1 parent 7624040 commit 723f241
Show file tree
Hide file tree
Showing 10 changed files with 264 additions and 125 deletions.
29 changes: 27 additions & 2 deletions Source/Game/GameContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace scripts_export {
#include "BelligerentSelect.h"
#include "qd_textdb.h"
#include "Localization.h"
#include "codepages/codepages.h"

#include <map>
#include <set>
Expand Down Expand Up @@ -602,11 +603,15 @@ void detectGameContent() {
data.mod_name = mod_ini.get("Mod", "name");
data.mod_version = mod_ini.get("Mod", "version");
if (data.mod_name.empty()) {
fprintf(stderr, "Missing name in Mod section at %s, not loading\n", path_ini.c_str());
data.available = false;
fprintf(stderr, "Missing name in Mod section at %s, not loading\n", path_ini.c_str());
data.errors += qdTextDB::instance().getText("Interface.Menu.Mods.ErrorMissingAttribute");
data.errors += " [Mod] name\n";
} else if (data.mod_version.empty()) {
fprintf(stderr, "Missing version in Mod section at %s, not loading\n", path_ini.c_str());
data.available = false;
fprintf(stderr, "Missing version in Mod section at %s, not loading\n", path_ini.c_str());
data.errors += qdTextDB::instance().getText("Interface.Menu.Mods.ErrorMissingAttribute");
data.errors += " [Mod] version\n";
}

//Load optional fields
Expand All @@ -618,6 +623,16 @@ void detectGameContent() {
if (data.mod_description.empty() && locale != "english") {
data.mod_description = mod_ini.get("Mod", "description_english");
}
if (!data.mod_description.empty()) {
data.mod_description = convertToCodepage(data.mod_description.c_str(), "english");
}
} else {
data.mod_description = convertToCodepage(data.mod_description.c_str(), locale);
}
if (!data.mod_description.empty()) {
string_replace_all(data.mod_description, "\\r", "");
string_replace_all(data.mod_description, "\\n", "\n");
string_replace_all(data.mod_description, "\\\\", "\\");
}
data.mod_authors = mod_ini.get("Mod", "authors");
data.mod_url = mod_ini.get("Mod", "url");
Expand All @@ -629,6 +644,8 @@ void detectGameContent() {
if (0 < diff) {
fprintf(stderr, "Minimum game version '%s' requirement not satisfied for %s, not loading\n",
data.content_game_minimum_version.c_str(), data.path.c_str());
data.errors += qdTextDB::instance().getText("Interface.Menu.Mods.ErrorGameTooOld");
data.errors += " " + data.content_game_minimum_version + "\n";
data.available = false;
}
}
Expand Down Expand Up @@ -660,6 +677,7 @@ void detectGameContent() {
data.mod_url = "https://kdlab.com";
} else {
fprintf(stderr, "Mod folder %s has missing info file %s, not loading\n", data.path.c_str(), path_ini.c_str());
data.errors += qdTextDB::instance().getText("Interface.Menu.Mods.ErrorMissingModInfo");
}

//Force disable all mods
Expand All @@ -670,6 +688,7 @@ void detectGameContent() {
//Avoid possible duplicates of ET
if (data.available && is_content_ET && (terGameContentAvailable & PERIMETER_ET)) {
fprintf(stderr, "ET is already loaded when loading ET content at %s, not loading", data.path.c_str());
data.errors += qdTextDB::instance().getText("Interface.Menu.Mods.ErrorDuplicateContent");
data.available = false;
}

Expand Down Expand Up @@ -707,9 +726,13 @@ void detectGameContent() {
if (!getMissingGameContent(terGameContentAvailable, required).empty()) {
fprintf(stderr, "Game content '%s' not installed which is a requirement for %s, not loading\n",
mod.content_required_content.c_str(), mod.path.c_str());
mod.errors += qdTextDB::instance().getText("Interface.Menu.Mods.ErrorRequiredContentMissing");
mod.errors += " " + mod.content_required_content + "\n";
} else {
fprintf(stderr, "Game content '%s' installed but not enabled which is a requirement for %s, not loading\n",
mod.content_required_content.c_str(), mod.path.c_str());
mod.errors += qdTextDB::instance().getText("Interface.Menu.Mods.ErrorRequiredContentDisabled");
mod.errors += " " + mod.content_required_content + "\n";
}
mod.available = mod.enabled = false;
}
Expand All @@ -719,6 +742,8 @@ void detectGameContent() {
if (terGameContentSelect == disallowed) {
fprintf(stderr, "Game content '%s' is enabled which is not compatible for %s, not loading\n",
mod.content_disallowed_content.c_str(), mod.path.c_str());
mod.errors += qdTextDB::instance().getText("Interface.Menu.Mods.ErrorDisallowedContentEnabled");
mod.errors += " " + mod.content_disallowed_content + "\n";
mod.available = mod.enabled = false;
}
}
Expand Down
2 changes: 2 additions & 0 deletions Source/Game/GameContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class ModMetadata {
public:
/// Path for this mod
std::string path = {};
/// Errors when loading mod if any
std::string errors = {};
/// Has campaign missions?
//TODO use this on "Change Campaign"
bool campaign = false;
Expand Down
Loading

0 comments on commit 723f241

Please sign in to comment.