Skip to content

Commit 130dd13

Browse files
committed
remove Mod::getMetadataRef
Also make Mod::getMetadata return a const&.
1 parent 493629a commit 130dd13

File tree

12 files changed

+36
-42
lines changed

12 files changed

+36
-42
lines changed

loader/include/Geode/loader/Mod.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ namespace geode {
101101
bool isInternal() const;
102102
bool needsEarlyLoad() const;
103103

104-
[[deprecated("Use Mod::getMetadataRef which is better for efficiency")]]
105-
ModMetadata getMetadata() const; // TODO: remove in v5
106-
ModMetadata const& getMetadataRef() const;
104+
ModMetadata const& getMetadata() const;
107105

108106
std::filesystem::path getTempDir() const;
109107
/**

loader/src/hooks/MenuLayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> {
223223
}
224224

225225
for (auto mod : Loader::get()->getAllMods()) {
226-
if (mod->getMetadataRef().usesDeprecatedIDForm()) {
226+
if (mod->getMetadata().usesDeprecatedIDForm()) {
227227
log::error(
228228
"Mod ID '{}' will be rejected in the future - "
229229
"IDs must match the regex `[a-z0-9\\-_]+\\.[a-z0-9\\-_]+`",

loader/src/load.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using namespace geode::prelude;
2222
});
2323

2424
ipc::listen("loader-info", [](ipc::IPCEvent* event) -> matjson::Value {
25-
return Mod::get()->getMetadataRef();
25+
return Mod::get()->getMetadata();
2626
});
2727

2828
ipc::listen("list-mods", [](ipc::IPCEvent* event) -> matjson::Value {
@@ -37,12 +37,12 @@ using namespace geode::prelude;
3737
if (!dontIncludeLoader) {
3838
res.push_back(
3939
includeRunTimeInfo ? Mod::get()->getRuntimeInfo() :
40-
Mod::get()->getMetadataRef().toJSON()
40+
Mod::get()->getMetadata().toJSON()
4141
);
4242
}
4343

4444
for (auto& mod : Loader::get()->getAllMods()) {
45-
res.push_back(includeRunTimeInfo ? mod->getRuntimeInfo() : mod->getMetadataRef().toJSON());
45+
res.push_back(includeRunTimeInfo ? mod->getRuntimeInfo() : mod->getMetadata().toJSON());
4646
}
4747

4848
return res;

loader/src/loader/LoaderImpl.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ void Loader::Impl::updateModResources(Mod* mod) {
253253
}
254254

255255
// only thing needs previous setup is spritesheets
256-
auto& sheets = mod->getMetadataRef().getSpritesheets();
256+
auto& sheets = mod->getMetadata().getSpritesheets();
257257
if (sheets.empty())
258258
return;
259259

@@ -416,7 +416,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
416416
// invalid target version
417417
// Also this makes it so that when GD updates, outdated mods get shown as
418418
// "Outdated" in the UI instead of "Missing Dependencies"
419-
auto res = node->getMetadataRef().checkGameVersion();
419+
auto res = node->getMetadata().checkGameVersion();
420420
if (!res) {
421421
this->addProblem({
422422
LoadProblem::Type::UnsupportedVersion,
@@ -427,10 +427,10 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
427427
return;
428428
}
429429

430-
auto geodeVerRes = node->getMetadataRef().checkGeodeVersion();
430+
auto geodeVerRes = node->getMetadata().checkGeodeVersion();
431431
if (!geodeVerRes) {
432432
this->addProblem({
433-
node->getMetadataRef().getGeodeVersion() > this->getVersion() ?
433+
node->getMetadata().getGeodeVersion() > this->getVersion() ?
434434
LoadProblem::Type::NeedsNewerGeodeVersion :
435435
LoadProblem::Type::UnsupportedGeodeVersion,
436436
node,
@@ -463,7 +463,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
463463

464464
auto unzipFunction = [this, node]() {
465465
log::debug("Unzipping .geode file");
466-
auto res = this->unzipGeodeFile(node->getMetadataRef());
466+
auto res = this->unzipGeodeFile(node->getMetadata());
467467
return res;
468468
};
469469

@@ -487,7 +487,7 @@ void Loader::Impl::loadModGraph(Mod* node, bool early) {
487487
};
488488

489489
{ // version checking
490-
if (auto reason = node->getMetadataRef().m_impl->m_softInvalidReason) {
490+
if (auto reason = node->getMetadata().m_impl->m_softInvalidReason) {
491491
this->addProblem({
492492
LoadProblem::Type::InvalidFile,
493493
node,
@@ -553,7 +553,7 @@ void Loader::Impl::findProblems() {
553553
log::debug("{}", id);
554554
log::NestScope nest;
555555

556-
for (auto const& dep : mod->getMetadataRef().getDependencies()) {
556+
for (auto const& dep : mod->getMetadata().getDependencies()) {
557557
if (dep.mod && dep.mod->isEnabled() && dep.version.compare(dep.mod->getVersion()))
558558
continue;
559559

@@ -628,7 +628,7 @@ void Loader::Impl::findProblems() {
628628
}
629629
}
630630

631-
for (auto const& dep : mod->getMetadataRef().getIncompatibilities()) {
631+
for (auto const& dep : mod->getMetadata().getIncompatibilities()) {
632632
if (!dep.mod || !dep.version.compare(dep.mod->getVersion()) || !dep.mod->shouldLoad())
633633
continue;
634634
switch(dep.importance) {
@@ -926,7 +926,7 @@ Result<> Loader::Impl::unzipGeodeFile(ModMetadata metadata) {
926926
}
927927

928928
const std::string filename = utils::string::pathToString(entry.path().filename());
929-
if (filename == metadata.getBinaryName() || !isPlatformBinary(metadata.getID(), filename)) {
929+
if (metadata.getBinaryName() == filename || !isPlatformBinary(metadata.getID(), filename)) {
930930
continue;
931931
}
932932

loader/src/loader/Mod.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,7 @@ bool Mod::needsEarlyLoad() const {
7272
return m_impl->needsEarlyLoad();
7373
}
7474

75-
ModMetadata Mod::getMetadata() const {
76-
return m_impl->getMetadata();
77-
}
78-
79-
ModMetadata const& Mod::getMetadataRef() const {
75+
ModMetadata const& Mod::getMetadata() const {
8076
return m_impl->getMetadata();
8177
}
8278

loader/src/server/DownloadManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ bool ModDownloadManager::checkAutoConfirm() {
397397
// If some installed mod is incompatible with this one,
398398
// we need to ask for confirmation
399399
for (auto mod : Loader::get()->getAllMods()) {
400-
for (auto inc : mod->getMetadataRef().getIncompatibilities()) {
400+
for (auto inc : mod->getMetadata().getIncompatibilities()) {
401401
if (inc.id == download.getID() && (!download.getVersion().has_value() || inc.version.compare(download.getVersion().value()))) {
402402
return false;
403403
}

loader/src/ui/GeodeUI.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void geode::openModsList() {
110110
}
111111

112112
void geode::openIssueReportPopup(Mod* mod) {
113-
if (mod->getMetadataRef().getIssues()) {
113+
if (mod->getMetadata().getIssues()) {
114114
MDPopup::create(
115115
"Issue Report",
116116
fmt::format(
@@ -126,7 +126,7 @@ void geode::openIssueReportPopup(Mod* mod) {
126126
return;
127127
}
128128

129-
auto issues = mod->getMetadataRef().getIssues();
129+
auto issues = mod->getMetadata().getIssues();
130130
if (issues && issues->url) {
131131
auto& url = *issues->url;
132132
web::openLinkInBrowser(url);
@@ -151,7 +151,7 @@ void geode::openIssueReportPopup(Mod* mod) {
151151
}
152152

153153
void geode::openSupportPopup(Mod* mod) {
154-
openSupportPopup(mod->getMetadataRef());
154+
openSupportPopup(mod->getMetadata());
155155
}
156156

157157
void geode::openSupportPopup(ModMetadata const& metadata) {

loader/src/ui/mods/list/ModDeveloperList.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ bool ModDeveloperList::init(DevListPopup* popup, ModSource const& source, CCSize
5656

5757
m_source.visit(makeVisitor {
5858
[this, popup, itemSize](Mod* mod) {
59-
for (auto& dev : mod->getMetadataRef().getDevelopers()) {
59+
for (auto& dev : mod->getMetadata().getDevelopers()) {
6060
m_list->m_contentLayer->addChild(ModDeveloperItem::create(popup, dev, itemSize, std::nullopt, false));
6161
}
6262
},

loader/src/ui/mods/list/ModProblemItem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ std::string ModProblemItem::createProblemMessage() {
256256
case LoadProblem::Type::UnsupportedGeodeVersion: {
257257
ss << fmt::format(
258258
"requires Geode {} to run (installed: {})",
259-
m_source->getMetadataRef().getGeodeVersion(),
259+
m_source->getMetadata().getGeodeVersion(),
260260
Loader::get()->getVersion().toNonVString()
261261
);
262262
return ss.str();

loader/src/ui/mods/popups/ConfirmInstall.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void askConfirmModInstalls() {
2020
auto toConfirm = ToConfirm();
2121

2222
// Collect all things we need to ask confirmation for
23-
for (auto download : ModDownloadManager::get()->getDownloads()) {
23+
for (auto& download : ModDownloadManager::get()->getDownloads()) {
2424
auto status = download.getStatus();
2525
if (auto conf = std::get_if<DownloadStatusConfirm>(&status)) {
2626
if (auto dep = download.getDependencyFor()) {
@@ -37,38 +37,38 @@ void askConfirmModInstalls() {
3737
// ones
3838

3939
// If this mod has incompatabilities that are installed, disable them
40-
for (auto inc : conf->version.metadata.getIncompatibilities()) {
40+
for (auto& inc : conf->version.metadata.getIncompatibilities()) {
4141
if (inc.mod && inc.version.compare(conf->version.metadata.getVersion()) && inc.mod->isOrWillBeEnabled()) {
4242
toConfirm.toDisable.insert(inc.mod);
4343
}
44-
for (auto download : ModDownloadManager::get()->getDownloads()) {
44+
for (auto& download : ModDownloadManager::get()->getDownloads()) {
4545
if (download.isDone() && inc.id == download.getID() && inc.version.compare(conf->version.metadata.getVersion())) {
4646
toConfirm.toDisableModId.insert(inc.id);
4747
}
4848
}
4949
}
5050
// If some installed mods are incompatible with this one, disable them
5151
for (auto mod : Loader::get()->getAllMods()) {
52-
for (auto inc : mod->getMetadataRef().getIncompatibilities()) {
53-
if (inc.id == conf->version.metadata.getID() && inc.version.compare(mod->getVersion()) && mod->isOrWillBeEnabled()) {
52+
for (auto& inc : mod->getMetadata().getIncompatibilities()) {
53+
if (conf->version.metadata.getID() == inc.id && inc.version.compare(mod->getVersion()) && mod->isOrWillBeEnabled()) {
5454
toConfirm.toDisable.insert(mod);
5555
}
5656
}
5757
}
5858
// If some newly downloaded mods are incompatible with this one, disable them
59-
for (auto download : ModDownloadManager::get()->getDownloads()) {
59+
for (auto& download : ModDownloadManager::get()->getDownloads()) {
6060
auto status = download.getStatus();
6161
if (auto done = std::get_if<DownloadStatusDone>(&status)) {
62-
for (auto inc : done->version.metadata.getIncompatibilities()) {
63-
if (inc.id == conf->version.metadata.getID() && inc.version.compare(done->version.metadata.getVersion())) {
62+
for (auto& inc : done->version.metadata.getIncompatibilities()) {
63+
if (conf->version.metadata.getID() == inc.id && inc.version.compare(done->version.metadata.getVersion())) {
6464
toConfirm.toDisableModId.insert(download.getID());
6565
}
6666
}
6767
}
6868
}
6969

7070
// If this mod has required dependencies that are disabled, enable them
71-
for (auto dep : conf->version.metadata.getDependencies()) {
71+
for (auto& dep : conf->version.metadata.getDependencies()) {
7272
if (
7373
dep.importance == ModMetadata::Dependency::Importance::Required &&
7474
dep.mod && !dep.mod->isOrWillBeEnabled()

0 commit comments

Comments
 (0)