diff --git a/src/config.cpp b/src/config.cpp index 4c98527..ea96897 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -26,6 +26,8 @@ void ExtGenConfig::reset() saltOverride = false; for (int i = 0; i < FEATURE_NUM; i++) salts[i] = ~(uint64_t)0; + saltOverrideStronghold = false; + saltStronghold = ~(uint64_t)0; } void ExtGenConfig::load(QSettings& settings) @@ -38,6 +40,8 @@ void ExtGenConfig::load(QSettings& settings) QVariant v = QVariant::fromValue(~(qulonglong)0); salts[st] = settings.value(QString("world/salt_") + struct2str(st), v).toULongLong(); } + saltOverrideStronghold = settings.value("world/saltOverrideStronghold", saltOverrideStronghold).toBool(); + saltStronghold = settings.value("world/saltStronghold", (qulonglong)saltStronghold).toULongLong(); } void ExtGenConfig::save(QSettings& settings) @@ -51,6 +55,9 @@ void ExtGenConfig::save(QSettings& settings) if (salt <= MASK48) settings.setValue(QString("world/salt_") + struct2str(st), (qulonglong)salt); } + settings.setValue("world/saltOverrideStronghold", saltOverrideStronghold); + if (saltStronghold <= MASK48) + settings.setValue("world/saltStronghold", (qulonglong)saltStronghold); } bool WorldInfo::equals(const WorldInfo& wi) const diff --git a/src/config.h b/src/config.h index ee169fc..a8bbb6a 100644 --- a/src/config.h +++ b/src/config.h @@ -23,6 +23,8 @@ struct ExtGenConfig bool estimateTerrain; bool saltOverride; uint64_t salts[FEATURE_NUM]; + bool saltOverrideStronghold; + uint64_t saltStronghold; ExtGenConfig() { reset(); } diff --git a/src/extgendialog.cpp b/src/extgendialog.cpp index e3f233e..dc1f761 100644 --- a/src/extgendialog.cpp +++ b/src/extgendialog.cpp @@ -10,33 +10,47 @@ ExtGenDialog::ExtGenDialog(QWidget *parent, ExtGenConfig *extgen) , ui(new Ui::ExtGenDialog) , checkSalts{} , lineSalts{} + , checkSaltsStronghold(nullptr) + , lineSaltsStronghold(nullptr) { ui->setupUi(this); int stv[] = { + // Stronghold first + // Overworld + Ancient_City, Desert_Pyramid, - Jungle_Pyramid, - Swamp_Hut, Igloo, - Village, - Ocean_Ruin, - Shipwreck, - Monument, + Jungle_Pyramid, Mansion, + // Mineshaft, + Monument, + Ocean_Ruin, Outpost, - Ancient_City, Ruined_Portal, - Ruined_Portal_N, + Shipwreck, + Swamp_Hut, Treasure, - //Mineshaft, - Fortress, + Trial_Chambers, + Village, + + // Nether Bastion, + Fortress, + Ruined_Portal_N, + + // End End_City, End_Gateway, }; QGridLayout *grid = new QGridLayout(ui->groupSalts); - for (size_t i = 0; i < sizeof(stv)/sizeof(stv[0]); i++) + + grid->addWidget((checkSaltsStronghold = new QCheckBox("stronghold")), 0, 0); + grid->addWidget((lineSaltsStronghold = new QLineEdit()), 0, 1); + connect(checkSaltsStronghold, &QCheckBox::toggled, this, &ExtGenDialog::updateToggles); + + for (size_t i = 1; i < sizeof(stv)/sizeof(stv[0]); i++) { int st = stv[i]; grid->addWidget((checkSalts[st] = new QCheckBox(struct2str(st))), i, 0); @@ -68,6 +82,9 @@ void ExtGenDialog::initSettings(ExtGenConfig *extgen) // start checked, otherwise Qt doesn't respond to initial uncheck ui->groupSalts->setChecked(true); + checkSaltsStronghold->setChecked(extgen->saltOverrideStronghold); + lineSaltsStronghold->setText(QString::asprintf("%" PRIu64, extgen->saltStronghold & MASK48)); + for (int i = 0; i < FEATURE_NUM; i++) { if (!checkSalts[i]) @@ -94,6 +111,9 @@ ExtGenConfig ExtGenDialog::getSettings() extgen.experimentalVers = ui->checkExperimental->isChecked(); extgen.estimateTerrain = ui->checkEstimate->isChecked(); extgen.saltOverride = ui->groupSalts->isChecked(); + + extgen.saltOverrideStronghold = checkSaltsStronghold->isChecked(); + extgen.saltStronghold = lineSaltsStronghold->text().toULongLong(); for (int i = 0; i < FEATURE_NUM; i++) { @@ -126,6 +146,9 @@ void ExtGenDialog::on_buttonBox_clicked(QAbstractButton *button) void ExtGenDialog::updateToggles() { + if (checkSaltsStronghold) + lineSaltsStronghold->setEnabled(checkSaltsStronghold->isChecked()); + for (int i = 0; i < FEATURE_NUM; i++) { if (!checkSalts[i]) diff --git a/src/extgendialog.h b/src/extgendialog.h index 4e557df..0c41a23 100644 --- a/src/extgendialog.h +++ b/src/extgendialog.h @@ -35,6 +35,8 @@ private slots: Ui::ExtGenDialog *ui; QCheckBox *checkSalts[FEATURE_NUM]; QLineEdit *lineSalts[FEATURE_NUM]; + QCheckBox *checkSaltsStronghold; + QLineEdit *lineSaltsStronghold; ExtGenConfig extgen; }; diff --git a/src/world.cpp b/src/world.cpp index fd6d484..3e39657 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -1090,7 +1090,12 @@ struct SpawnStronghold : public Scheduled if (world->isdel) return; StrongholdIter sh; - initFirstStronghold(&sh, wi.mc, wi.seed); + uint64_t seedForStronghold = wi.seed; + if (g_extgen.saltOverride && g_extgen.saltOverrideStronghold && g_extgen.saltStronghold <= MASK48) + { + seedForStronghold = g_extgen.saltStronghold; + } + initFirstStronghold(&sh, wi.mc, seedForStronghold); // note: pointer to atomic pointer QAtomicPointer *shpp = &world->strongholds;