mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
adjust town event handling after introducing 8th creature in town
This commit is contained in:
@@ -155,7 +155,12 @@ void TownEventDialog::initCreatures()
|
|||||||
{
|
{
|
||||||
auto creatures = params.value("creatures").toList();
|
auto creatures = params.value("creatures").toList();
|
||||||
auto * ctown = town.town;
|
auto * ctown = town.town;
|
||||||
for (int i = 0; i < GameConstants::CREATURES_PER_TOWN; ++i)
|
if (!ctown)
|
||||||
|
ui->creaturesTable->setRowCount(GameConstants::CREATURES_PER_TOWN);
|
||||||
|
else
|
||||||
|
ui->creaturesTable->setRowCount(ctown->creatures.size());
|
||||||
|
|
||||||
|
for (int i = 0; i < ui->creaturesTable->rowCount(); ++i)
|
||||||
{
|
{
|
||||||
QString creatureNames;
|
QString creatureNames;
|
||||||
if (!ctown)
|
if (!ctown)
|
||||||
@@ -239,7 +244,7 @@ QVariantList TownEventDialog::buildingsToVariant()
|
|||||||
QVariantList TownEventDialog::creaturesToVariant()
|
QVariantList TownEventDialog::creaturesToVariant()
|
||||||
{
|
{
|
||||||
QVariantList creaturesList;
|
QVariantList creaturesList;
|
||||||
for (int i = 0; i < GameConstants::CREATURES_PER_TOWN; ++i)
|
for (int i = 0; i < ui->creaturesTable->rowCount(); ++i)
|
||||||
{
|
{
|
||||||
auto * item = static_cast<QSpinBox *>(ui->creaturesTable->cellWidget(i, 1));
|
auto * item = static_cast<QSpinBox *>(ui->creaturesTable->cellWidget(i, 1));
|
||||||
creaturesList.push_back(item->value());
|
creaturesList.push_back(item->value());
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ void NewTurnProcessor::handleTownEvents(const CGTownInstance * town)
|
|||||||
|
|
||||||
for (si32 i=0;i<event.creatures.size();i++) //creature growths
|
for (si32 i=0;i<event.creatures.size();i++) //creature growths
|
||||||
{
|
{
|
||||||
if (!town->creatures.at(i).second.empty() && event.creatures.at(i) > 0)//there is dwelling
|
if (i < town->creatures.size() && !town->creatures.at(i).second.empty() && event.creatures.at(i) > 0)//there is dwelling
|
||||||
{
|
{
|
||||||
sac.creatures[i].first += event.creatures.at(i);
|
sac.creatures[i].first += event.creatures.at(i);
|
||||||
iw.components.emplace_back(ComponentType::CREATURE, town->creatures.at(i).second.back(), event.creatures.at(i));
|
iw.components.emplace_back(ComponentType::CREATURE, town->creatures.at(i).second.back(), event.creatures.at(i));
|
||||||
|
|||||||
Reference in New Issue
Block a user