diff --git a/lib/mapping/CMapEditManager.cpp b/lib/mapping/CMapEditManager.cpp index 76315ea1a..2f8d44af9 100644 --- a/lib/mapping/CMapEditManager.cpp +++ b/lib/mapping/CMapEditManager.cpp @@ -198,3 +198,4 @@ CObjectSelection & CMapEditManager::getObjectSelection() CMapUndoManager & CMapEditManager::getUndoManager() { return undoManager; +} diff --git a/lib/rmg/ObstaclePlacer.cpp b/lib/rmg/ObstaclePlacer.cpp index 24d259511..f0b8d4d09 100644 --- a/lib/rmg/ObstaclePlacer.cpp +++ b/lib/rmg/ObstaclePlacer.cpp @@ -36,8 +36,8 @@ void ObstacleProxy::collectPossibleObstacles(const Terrain & terrain) { for(auto temp : handler->getTemplates()) { - if(temp.canBePlacedAt(terrain) && temp.getBlockMapOffset().valid()) - obstaclesBySize[temp.getBlockedOffsets().size()].push_back(temp); + if(temp->canBePlacedAt(terrain) && temp->getBlockMapOffset().valid()) + obstaclesBySize[temp->getBlockedOffsets().size()].push_back(temp); } } } @@ -66,7 +66,6 @@ void ObstacleProxy::placeObject(CMapEditManager * manager, rmg::Object & object) { manager->insertObject(&instance->object()); } - //manager->placeObject(*objIter->first, false, false); } int ObstacleProxy::getWeightedObjects(const int3 & tile, const CMap * map, CRandomGenerator & rand, std::list & allObjects, std::vector> & weightedObjects) @@ -80,9 +79,9 @@ int ObstacleProxy::getWeightedObjects(const int3 & tile, const CMap * map, CRand auto shuffledObstacles = possibleObstacles[i].second; RandomGeneratorUtil::randomShuffle(shuffledObstacles, rand); - for(auto & temp : shuffledObstacles) + for(auto temp : shuffledObstacles) { - auto handler = VLC->objtypeh->getHandlerFor(temp.id, temp.subid); + auto handler = VLC->objtypeh->getHandlerFor(temp->id, temp->subid); auto obj = handler->create(temp); allObjects.emplace_back(*obj); rmg::Object * rmgObject = &allObjects.back(); diff --git a/lib/rmg/ObstaclePlacer.h b/lib/rmg/ObstaclePlacer.h index e7b9cf77a..802f4e2a2 100644 --- a/lib/rmg/ObstaclePlacer.h +++ b/lib/rmg/ObstaclePlacer.h @@ -36,7 +36,7 @@ public: protected: int getWeightedObjects(const int3 & tile, const CMap * map, CRandomGenerator & rand, std::list & allObjects, std::vector> & weightedObjects); - typedef std::vector ObstacleVector; + typedef std::vector> ObstacleVector; std::map obstaclesBySize; typedef std::pair ObstaclePair; std::vector possibleObstacles; diff --git a/mapeditor/graphics.cpp b/mapeditor/graphics.cpp index 794982a2c..46a4d0420 100644 --- a/mapeditor/graphics.cpp +++ b/mapeditor/graphics.cpp @@ -127,10 +127,10 @@ void Graphics::loadHeroAnimations() { for(auto & elem : CGI->heroh->classes.objects) { - for (auto & templ : VLC->objtypeh->getHandlerFor(Obj::HERO, elem->getIndex())->getTemplates()) + for (auto templ : VLC->objtypeh->getHandlerFor(Obj::HERO, elem->getIndex())->getTemplates()) { - if (!heroAnimations.count(templ.animationFile)) - heroAnimations[templ.animationFile] = loadHeroAnimation(templ.animationFile); + if (!heroAnimations.count(templ->animationFile)) + heroAnimations[templ->animationFile] = loadHeroAnimation(templ->animationFile); } } @@ -293,21 +293,21 @@ std::shared_ptr Graphics::getAnimation(const CGObjectInstance* obj) return getAnimation(obj->appearance); } -std::shared_ptr Graphics::getAnimation(const ObjectTemplate & info) +std::shared_ptr Graphics::getAnimation(const std::shared_ptr info) { //the only(?) invisible object - if(info.id == Obj::EVENT) + if(info->id == Obj::EVENT) { return std::shared_ptr(); } - if(info.animationFile.empty()) + if(info->animationFile.empty()) { - logGlobal->warn("Def name for obj (%d,%d) is empty!", info.id, info.subid); + logGlobal->warn("Def name for obj (%d,%d) is empty!", info->id, info->subid); return std::shared_ptr(); } - std::shared_ptr ret = mapObjectAnimations[info.animationFile]; + std::shared_ptr ret = mapObjectAnimations[info->animationFile]; //already loaded if(ret) @@ -316,8 +316,8 @@ std::shared_ptr Graphics::getAnimation(const ObjectTemplate & info) return ret; } - ret = std::make_shared(info.animationFile); - mapObjectAnimations[info.animationFile] = ret; + ret = std::make_shared(info->animationFile); + mapObjectAnimations[info->animationFile] = ret; ret->preload(); return ret; diff --git a/mapeditor/graphics.h b/mapeditor/graphics.h index 270d6356e..d6bfbfadb 100644 --- a/mapeditor/graphics.h +++ b/mapeditor/graphics.h @@ -77,7 +77,7 @@ public: void blueToPlayersAdv(QImage * sur, PlayerColor player); //replaces blue interface colour with a color of player std::shared_ptr getAnimation(const CGObjectInstance * obj); - std::shared_ptr getAnimation(const ObjectTemplate & info); + std::shared_ptr getAnimation(const std::shared_ptr info); }; extern Graphics * graphics; diff --git a/mapeditor/inspector/inspector.cpp b/mapeditor/inspector/inspector.cpp index 51902dc01..2cfc372ad 100644 --- a/mapeditor/inspector/inspector.cpp +++ b/mapeditor/inspector/inspector.cpp @@ -103,7 +103,7 @@ void Initializer::initialize(CGTownInstance * o) if(!o) return; const std::vector castleLevels{"village", "fort", "citadel", "castle", "capitol"}; - int lvl = vstd::find_pos(castleLevels, o->appearance.stringID); + int lvl = vstd::find_pos(castleLevels, o->appearance->stringID); o->builtBuildings.insert(BuildingID::DEFAULT); if(lvl > -1) o->builtBuildings.insert(BuildingID::TAVERN); if(lvl > 0) o->builtBuildings.insert(BuildingID::FORT); diff --git a/mapeditor/mainwindow.cpp b/mapeditor/mainwindow.cpp index ef0d8d1f5..70060ca5b 100644 --- a/mapeditor/mainwindow.cpp +++ b/mapeditor/mainwindow.cpp @@ -381,7 +381,7 @@ void MainWindow::addGroupIntoCatalog(const std::string & groupName, bool useCust auto templ = templates[templateId]; //selecting file - const std::string & afile = templ.editorAnimationFile.empty() ? templ.animationFile : templ.editorAnimationFile; + const std::string & afile = templ->editorAnimationFile.empty() ? templ->animationFile : templ->editorAnimationFile; //creating picture QPixmap preview(128, 128); @@ -402,8 +402,8 @@ void MainWindow::addGroupIntoCatalog(const std::string & groupName, bool useCust QJsonObject data{{"id", QJsonValue(ID)}, {"subid", QJsonValue(secondaryID)}, {"template", QJsonValue(templateId)}, - {"animationEditor", QString::fromStdString(templ.editorAnimationFile)}, - {"animation", QString::fromStdString(templ.animationFile)}, + {"animationEditor", QString::fromStdString(templ->editorAnimationFile)}, + {"animation", QString::fromStdString(templ->animationFile)}, {"preview", jsonFromPixmap(preview)}}; //create object to extract name @@ -422,7 +422,7 @@ void MainWindow::addGroupIntoCatalog(const std::string & groupName, bool useCust { if(useCustomName) itemType->setText(translated); - auto * item = new QStandardItem(QIcon(preview), QString::fromStdString(templ.stringID)); + auto * item = new QStandardItem(QIcon(preview), QString::fromStdString(templ->stringID)); item->setData(data); itemType->appendRow(item); } @@ -992,13 +992,13 @@ void MainWindow::on_actionUpdate_appearance_triggered() if(handler->isStaticObject()) { staticObjects.insert(obj); - if(obj->appearance.canBePlacedAt(terrain)) + if(obj->appearance->canBePlacedAt(terrain)) { controller.scene(mapLevel)->selectionObjectsView.deselectObject(obj); continue; } - for(auto & offset : obj->appearance.getBlockedOffsets()) + for(auto & offset : obj->appearance->getBlockedOffsets()) controller.scene(mapLevel)->selectionTerrainView.select(obj->pos + offset); } else @@ -1006,7 +1006,7 @@ void MainWindow::on_actionUpdate_appearance_triggered() auto app = handler->getOverride(terrain, obj); if(!app) { - if(obj->appearance.canBePlacedAt(terrain)) + if(obj->appearance->canBePlacedAt(terrain)) continue; auto templates = handler->getTemplates(terrain); @@ -1018,7 +1018,7 @@ void MainWindow::on_actionUpdate_appearance_triggered() app = templates.front(); } auto tiles = controller.mapHandler()->getTilesUnderObject(obj); - obj->appearance = app.get(); + obj->appearance = app; controller.mapHandler()->invalidate(tiles); controller.mapHandler()->invalidate(obj); controller.scene(mapLevel)->selectionObjectsView.deselectObject(obj); diff --git a/mapeditor/maphandler.cpp b/mapeditor/maphandler.cpp index edaea9597..e60c97daf 100644 --- a/mapeditor/maphandler.cpp +++ b/mapeditor/maphandler.cpp @@ -214,8 +214,8 @@ bool MapHandler::compareObjectBlitOrder(const CGObjectInstance * a, const CGObje return true; if (!b) return false; - if (a->appearance.printPriority != b->appearance.printPriority) - return a->appearance.printPriority > b->appearance.printPriority; + if (a->appearance->printPriority != b->appearance->printPriority) + return a->appearance->printPriority > b->appearance->printPriority; if(a->pos.y != b->pos.y) return a->pos.y < b->pos.y; diff --git a/mapeditor/objectbrowser.cpp b/mapeditor/objectbrowser.cpp index 713a5e52f..770564480 100644 --- a/mapeditor/objectbrowser.cpp +++ b/mapeditor/objectbrowser.cpp @@ -40,7 +40,7 @@ bool ObjectBrowser::filterAcceptsRow(int source_row, const QModelIndex & source_ auto factory = VLC->objtypeh->getHandlerFor(objId, objSubId); auto templ = factory->getTemplates()[templateId]; - result = result & templ.canBePlacedAt(terrain); + result = result & templ->canBePlacedAt(terrain); //text filter