mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Merge pull request #2355 from IvanSavenko/bugfixing
Bugfixing iteration
This commit is contained in:
@@ -394,8 +394,9 @@ void AdventureMapInterface::onPlayerTurnStarted(PlayerColor playerID)
|
|||||||
LOCPLINT->localState->setSelection(LOCPLINT->localState->getWanderingHero(0));
|
LOCPLINT->localState->setSelection(LOCPLINT->localState->getWanderingHero(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
//show new day animation and sound on infobar
|
//show new day animation and sound on infobar, except for 1st day of the game
|
||||||
widget->getInfoBar()->showDate();
|
if (LOCPLINT->cb->getDate(Date::DAY) != 1)
|
||||||
|
widget->getInfoBar()->showDate();
|
||||||
|
|
||||||
onHeroChanged(nullptr);
|
onHeroChanged(nullptr);
|
||||||
Canvas canvas = Canvas::createFromSurface(screen);
|
Canvas canvas = Canvas::createFromSurface(screen);
|
||||||
|
@@ -287,8 +287,28 @@ void CHeroList::updateElement(const CGHeroInstance * hero)
|
|||||||
|
|
||||||
void CHeroList::updateWidget()
|
void CHeroList::updateWidget()
|
||||||
{
|
{
|
||||||
listBox->resize(LOCPLINT->localState->getWanderingHeroes().size());
|
auto & heroes = LOCPLINT->localState->getWanderingHeroes();
|
||||||
listBox->reset();
|
|
||||||
|
listBox->resize(heroes.size());
|
||||||
|
|
||||||
|
for (size_t i = 0; i < heroes.size(); ++i)
|
||||||
|
{
|
||||||
|
auto item = std::dynamic_pointer_cast<CHeroItem>(listBox->getItem(i));
|
||||||
|
|
||||||
|
if (!item)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (item->hero == heroes[i])
|
||||||
|
{
|
||||||
|
item->update();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
listBox->reset();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (LOCPLINT->localState->getCurrentHero())
|
if (LOCPLINT->localState->getCurrentHero())
|
||||||
select(LOCPLINT->localState->getCurrentHero());
|
select(LOCPLINT->localState->getCurrentHero());
|
||||||
|
|
||||||
@@ -364,8 +384,28 @@ void CTownList::updateElement(const CGTownInstance * town)
|
|||||||
|
|
||||||
void CTownList::updateWidget()
|
void CTownList::updateWidget()
|
||||||
{
|
{
|
||||||
listBox->resize(LOCPLINT->localState->getOwnedTowns().size());
|
auto & towns = LOCPLINT->localState->getOwnedTowns();
|
||||||
listBox->reset();
|
|
||||||
|
listBox->resize(towns.size());
|
||||||
|
|
||||||
|
for (size_t i = 0; i < towns.size(); ++i)
|
||||||
|
{
|
||||||
|
auto item = std::dynamic_pointer_cast<CTownItem>(listBox->getItem(i));
|
||||||
|
|
||||||
|
if (!item)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (item->town == towns[i])
|
||||||
|
{
|
||||||
|
item->update();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
listBox->reset();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (LOCPLINT->localState->getCurrentTown())
|
if (LOCPLINT->localState->getCurrentTown())
|
||||||
select(LOCPLINT->localState->getCurrentTown());
|
select(LOCPLINT->localState->getCurrentTown());
|
||||||
|
|
||||||
|
@@ -172,6 +172,15 @@ void EventDispatcher::dispatchClosePopup(const Point & position)
|
|||||||
|
|
||||||
void EventDispatcher::handleLeftButtonClick(const Point & position, bool isPressed)
|
void EventDispatcher::handleLeftButtonClick(const Point & position, bool isPressed)
|
||||||
{
|
{
|
||||||
|
// WARNING: this approach is NOT SAFE
|
||||||
|
// 1) We allow (un)registering elements when list itself is being processed/iterated
|
||||||
|
// 2) To avoid iterator invalidation we create a copy of this list for processing
|
||||||
|
// HOWEVER it is completely possible (as in, actually happen, no just theory) to:
|
||||||
|
// 1) element gets unregistered and deleted from lclickable
|
||||||
|
// 2) element is completely deleted, as in - destructor called, memory freed
|
||||||
|
// 3) new element is created *with exactly same address(!)
|
||||||
|
// 4) new element is registered and code will incorrectly assume that this element is still registered
|
||||||
|
// POSSIBLE SOLUTION: make EventReceivers inherit from create_shared_from this and store weak_ptr's in lists
|
||||||
auto hlp = lclickable;
|
auto hlp = lclickable;
|
||||||
for(auto & i : hlp)
|
for(auto & i : hlp)
|
||||||
{
|
{
|
||||||
|
@@ -29,6 +29,14 @@ AboutProjectView::AboutProjectView(QWidget * parent)
|
|||||||
ui->lineEditOperatingSystem->setText(QSysInfo::prettyProductName());
|
ui->lineEditOperatingSystem->setText(QSysInfo::prettyProductName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AboutProjectView::changeEvent(QEvent *event)
|
||||||
|
{
|
||||||
|
if(event->type() == QEvent::LanguageChange)
|
||||||
|
ui->retranslateUi(this);
|
||||||
|
|
||||||
|
QWidget::changeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
void AboutProjectView::on_updatesButton_clicked()
|
void AboutProjectView::on_updatesButton_clicked()
|
||||||
{
|
{
|
||||||
UpdateDialog::showUpdateDialog(true);
|
UpdateDialog::showUpdateDialog(true);
|
||||||
|
@@ -21,6 +21,7 @@ class AboutProjectView : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
void changeEvent(QEvent *event) override;
|
||||||
public:
|
public:
|
||||||
explicit AboutProjectView(QWidget * parent = 0);
|
explicit AboutProjectView(QWidget * parent = 0);
|
||||||
|
|
||||||
|
@@ -127,7 +127,7 @@ QSize CSettingsView::getPreferredRenderingResolution()
|
|||||||
return QSize(resX, resY);
|
return QSize(resX, resY);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return QApplication::primaryScreen()->geometry().size();
|
return QApplication::primaryScreen()->geometry().size() * QApplication::primaryScreen()->devicePixelRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingsView::fillValidScalingRange()
|
void CSettingsView::fillValidScalingRange()
|
||||||
|
@@ -136,7 +136,7 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
|
|||||||
{
|
{
|
||||||
result.artifactsCount = 163; // + HotA artifacts
|
result.artifactsCount = 163; // + HotA artifacts
|
||||||
result.heroesCount = 178; // + Cove
|
result.heroesCount = 178; // + Cove
|
||||||
result.heroesPortraitsCount = 185; // + Cove
|
result.heroesPortraitsCount = 186; // + Cove
|
||||||
}
|
}
|
||||||
if(hotaVersion == 3)
|
if(hotaVersion == 3)
|
||||||
{
|
{
|
||||||
|
@@ -1735,7 +1735,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(const int3 & mapPosition, const Objec
|
|||||||
if(!object->spells.empty())
|
if(!object->spells.empty())
|
||||||
{
|
{
|
||||||
object->clear();
|
object->clear();
|
||||||
logGlobal->warn("Hero %s subID=%d has spells set twice (in map properties and on adventure map instance). Using the latter set...", object->getNameTextID(), object->subID);
|
logGlobal->debug("Hero %s subID=%d has spells set twice (in map properties and on adventure map instance). Using the latter set...", object->getNameTextID(), object->subID);
|
||||||
}
|
}
|
||||||
|
|
||||||
object->spells.insert(SpellID::PRESET); //placeholder "preset spells"
|
object->spells.insert(SpellID::PRESET); //placeholder "preset spells"
|
||||||
|
@@ -29,7 +29,7 @@ void MapIdentifiersH3M::loadMapping(std::map<IdentifierID, IdentifierID> & resul
|
|||||||
for (auto entry : mapping.Struct())
|
for (auto entry : mapping.Struct())
|
||||||
{
|
{
|
||||||
IdentifierID sourceID (entry.second.Integer());
|
IdentifierID sourceID (entry.second.Integer());
|
||||||
IdentifierID targetID (*VLC->modh->identifiers.getIdentifier(VLC->modh->scopeGame(), identifierName, entry.first));
|
IdentifierID targetID (*VLC->modh->identifiers.getIdentifier(entry.second.meta, identifierName, entry.first));
|
||||||
|
|
||||||
result[sourceID] = targetID;
|
result[sourceID] = targetID;
|
||||||
}
|
}
|
||||||
@@ -39,13 +39,13 @@ void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
|
|||||||
{
|
{
|
||||||
for (auto entryFaction : mapping["buildings"].Struct())
|
for (auto entryFaction : mapping["buildings"].Struct())
|
||||||
{
|
{
|
||||||
FactionID factionID (*VLC->modh->identifiers.getIdentifier(VLC->modh->scopeGame(), "faction", entryFaction.first));
|
FactionID factionID (*VLC->modh->identifiers.getIdentifier(entryFaction.second.meta, "faction", entryFaction.first));
|
||||||
auto buildingMap = entryFaction.second;
|
auto buildingMap = entryFaction.second;
|
||||||
|
|
||||||
for (auto entryBuilding : buildingMap.Struct())
|
for (auto entryBuilding : buildingMap.Struct())
|
||||||
{
|
{
|
||||||
BuildingID sourceID (entryBuilding.second.Integer());
|
BuildingID sourceID (entryBuilding.second.Integer());
|
||||||
BuildingID targetID (*VLC->modh->identifiers.getIdentifier(VLC->modh->scopeGame(), "building." + VLC->factions()->getById(factionID)->getJsonKey(), entryBuilding.first));
|
BuildingID targetID (*VLC->modh->identifiers.getIdentifier(entryBuilding.second.meta, "building." + VLC->factions()->getById(factionID)->getJsonKey(), entryBuilding.first));
|
||||||
|
|
||||||
mappingFactionBuilding[factionID][sourceID] = targetID;
|
mappingFactionBuilding[factionID][sourceID] = targetID;
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
|
|||||||
{
|
{
|
||||||
for (auto entryInner : entryOuter.second.Struct())
|
for (auto entryInner : entryOuter.second.Struct())
|
||||||
{
|
{
|
||||||
auto handler = VLC->objtypeh->getHandlerFor( VLC->modh->scopeGame(), entryOuter.first, entryInner.first);
|
auto handler = VLC->objtypeh->getHandlerFor( entryInner.second.meta, entryOuter.first, entryInner.first);
|
||||||
|
|
||||||
auto entryValues = entryInner.second.Vector();
|
auto entryValues = entryInner.second.Vector();
|
||||||
ObjectTypeIdentifier h3mID{Obj(entryValues[0].Integer()), int32_t(entryValues[1].Integer())};
|
ObjectTypeIdentifier h3mID{Obj(entryValues[0].Integer()), int32_t(entryValues[1].Integer())};
|
||||||
@@ -78,7 +78,7 @@ void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto handler = VLC->objtypeh->getHandlerFor( VLC->modh->scopeGame(), entryOuter.first, entryOuter.first);
|
auto handler = VLC->objtypeh->getHandlerFor( entryOuter.second.meta, entryOuter.first, entryOuter.first);
|
||||||
|
|
||||||
auto entryValues = entryOuter.second.Vector();
|
auto entryValues = entryOuter.second.Vector();
|
||||||
ObjectTypeIdentifier h3mID{Obj(entryValues[0].Integer()), int32_t(entryValues[1].Integer())};
|
ObjectTypeIdentifier h3mID{Obj(entryValues[0].Integer()), int32_t(entryValues[1].Integer())};
|
||||||
@@ -90,7 +90,7 @@ void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
|
|||||||
for (auto entry : mapping["portraits"].Struct())
|
for (auto entry : mapping["portraits"].Struct())
|
||||||
{
|
{
|
||||||
int32_t sourceID = entry.second.Integer();
|
int32_t sourceID = entry.second.Integer();
|
||||||
int32_t targetID = *VLC->modh->identifiers.getIdentifier(VLC->modh->scopeGame(), "hero", entry.first);
|
int32_t targetID = *VLC->modh->identifiers.getIdentifier(entry.second.meta, "hero", entry.first);
|
||||||
int32_t iconID = VLC->heroTypes()->getByIndex(targetID)->getIconIndex();
|
int32_t iconID = VLC->heroTypes()->getByIndex(targetID)->getIconIndex();
|
||||||
|
|
||||||
mappingHeroPortrait[sourceID] = iconID;
|
mappingHeroPortrait[sourceID] = iconID;
|
||||||
|
@@ -299,7 +299,7 @@ void PlayerMessageProcessor::cheatResources(PlayerColor player, std::vector<std:
|
|||||||
}
|
}
|
||||||
|
|
||||||
TResources resources;
|
TResources resources;
|
||||||
resources[EGameResID::GOLD] = baseResourceAmount * 100;
|
resources[EGameResID::GOLD] = baseResourceAmount * 1000;
|
||||||
for (GameResID i = EGameResID::WOOD; i < EGameResID::GOLD; ++i)
|
for (GameResID i = EGameResID::WOOD; i < EGameResID::GOLD; ++i)
|
||||||
resources[i] = baseResourceAmount;
|
resources[i] = baseResourceAmount;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user