1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-21 19:19:26 +02:00

vstd::unique -> std::unique

This commit is contained in:
Ivan Savenko 2022-12-07 23:36:20 +02:00
parent 4d494b0941
commit facf77b3ae
48 changed files with 91 additions and 122 deletions

View File

@ -535,7 +535,7 @@ void AIGateway::yourTurn()
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
status.startedTurn();
makingTurn = make_unique<boost::thread>(&AIGateway::makeTurn, this);
makingTurn = std::make_unique<boost::thread>(&AIGateway::makeTurn, this);
}
void AIGateway::heroGotLevel(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> & skills, QueryID queryID)

View File

@ -50,7 +50,7 @@ void Nullkiller::init(std::shared_ptr<CCallback> cb, PlayerColor playerID)
new SharedPool<PriorityEvaluator>(
[&]()->std::unique_ptr<PriorityEvaluator>
{
return make_unique<PriorityEvaluator>(this);
return std::make_unique<PriorityEvaluator>(this);
}));
dangerHitMap.reset(new DangerHitMapAnalyzer(this));

View File

@ -608,7 +608,7 @@ void VCAI::yourTurn()
LOG_TRACE(logAi);
NET_EVENT_HANDLER;
status.startedTurn();
makingTurn = make_unique<boost::thread>(&VCAI::makeTurn, this);
makingTurn = std::make_unique<boost::thread>(&VCAI::makeTurn, this);
}
void VCAI::heroGotLevel(const CGHeroInstance * hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> & skills, QueryID queryID)

View File

@ -505,36 +505,6 @@ namespace vstd
ptr = nullptr;
}
#if _MSC_VER >= 1800
using std::make_unique;
#else
template<typename T>
std::unique_ptr<T> make_unique()
{
return std::unique_ptr<T>(new T());
}
template<typename T, typename Arg1>
std::unique_ptr<T> make_unique(Arg1 &&arg1)
{
return std::unique_ptr<T>(new T(std::forward<Arg1>(arg1)));
}
template<typename T, typename Arg1, typename Arg2>
std::unique_ptr<T> make_unique(Arg1 &&arg1, Arg2 &&arg2)
{
return std::unique_ptr<T>(new T(std::forward<Arg1>(arg1), std::forward<Arg2>(arg2)));
}
template<typename T, typename Arg1, typename Arg2, typename Arg3>
std::unique_ptr<T> make_unique(Arg1 &&arg1, Arg2 &&arg2, Arg3 &&arg3)
{
return std::unique_ptr<T>(new T(std::forward<Arg1>(arg1), std::forward<Arg2>(arg2), std::forward<Arg3>(arg3)));
}
template<typename T, typename Arg1, typename Arg2, typename Arg3, typename Arg4>
std::unique_ptr<T> make_unique(Arg1 &&arg1, Arg2 &&arg2, Arg3 &&arg3, Arg4 &&arg4)
{
return std::unique_ptr<T>(new T(std::forward<Arg1>(arg1), std::forward<Arg2>(arg2), std::forward<Arg3>(arg3), std::forward<Arg4>(arg4)));
}
#endif
template <typename Container>
typename Container::const_reference circularAt(const Container &r, size_t index)
{
@ -765,7 +735,6 @@ namespace vstd
using boost::math::round;
}
using vstd::operator-=;
using vstd::make_unique;
#ifdef NO_STD_TOSTRING
namespace std

View File

@ -878,7 +878,7 @@ void processCommand(const std::string &message)
{
std::string URI;
readed >> URI;
std::unique_ptr<CAnimation> anim = make_unique<CAnimation>(URI);
std::unique_ptr<CAnimation> anim = std::make_unique<CAnimation>(URI);
anim->preload();
anim->exportBitmaps(VCMIDirs::get().userExtractedPath());
}

View File

@ -71,7 +71,7 @@ void CMessage::init()
{
for(int i=0; i<PlayerColor::PLAYER_LIMIT_I; i++)
{
dialogBorders[i] = make_unique<CAnimation>("DIALGBOX");
dialogBorders[i] = std::make_unique<CAnimation>("DIALGBOX");
dialogBorders[i]->preload();
for(int j=0; j < dialogBorders[i]->size(0); j++)

View File

@ -456,7 +456,7 @@ void CMusicHandler::queueNext(CMusicHandler *owner, const std::string & setName,
{
try
{
queueNext(make_unique<MusicEntry>(owner, setName, musicURI, looped, fromStart));
queueNext(std::make_unique<MusicEntry>(owner, setName, musicURI, looped, fromStart));
}
catch(std::exception &e)
{

View File

@ -129,7 +129,7 @@ void CServerHandler::resetStateForLobby(const StartInfo::EMode mode, const std::
{
hostClientId = -1;
state = EClientState::NONE;
th = make_unique<CStopWatch>();
th = std::make_unique<CStopWatch>();
packsForLobbyScreen.clear();
c.reset();
si = std::make_shared<StartInfo>();

View File

@ -764,7 +764,7 @@ scripting::Pool * CClient::getContextPool() const
void CClient::reinitScripting()
{
clientEventBus = make_unique<events::EventBus>();
clientEventBus = std::make_unique<events::EventBus>();
#if SCRIPTING_ENABLED
clientScripts.reset(new scripting::PoolImpl(this));
#endif

View File

@ -2824,7 +2824,7 @@ void CBattleInterface::requestAutofightingAIToTakeAction()
boost::thread aiThread([&]()
{
auto ba = make_unique<BattleAction>(curInt->autofightingAI->activeStack(activeStack));
auto ba = std::make_unique<BattleAction>(curInt->autofightingAI->activeStack(activeStack));
if(curInt->cb->battleIsFinished())
{

View File

@ -49,10 +49,10 @@ void CCursorHandler::initCursor()
cursors =
{
make_unique<CAnimImage>("CRADVNTR", 0),
make_unique<CAnimImage>("CRCOMBAT", 0),
make_unique<CAnimImage>("CRDEFLT", 0),
make_unique<CAnimImage>("CRSPELL", 0)
std::make_unique<CAnimImage>("CRADVNTR", 0),
std::make_unique<CAnimImage>("CRCOMBAT", 0),
std::make_unique<CAnimImage>("CRDEFLT", 0),
std::make_unique<CAnimImage>("CRSPELL", 0)
};
currentCursor = cursors.at(int(ECursor::DEFAULT)).get();

View File

@ -169,7 +169,7 @@ void RandomMapTab::updateMapInfoByHost()
// Generate header info
mapInfo = std::make_shared<CMapInfo>();
mapInfo->isRandomMap = true;
mapInfo->mapHeader = make_unique<CMapHeader>();
mapInfo->mapHeader = std::make_unique<CMapHeader>();
mapInfo->mapHeader->version = EMapFormat::SOD;
mapInfo->mapHeader->name = CGI->generaltexth->allTexts[740];
mapInfo->mapHeader->description = CGI->generaltexth->allTexts[741];

View File

@ -140,7 +140,7 @@ void CMapHandler::initTerrainGraphics()
//no rotation and basic setup
for(auto & type : files)
{
animation[type.first][0] = make_unique<CAnimation>(type.second);
animation[type.first][0] = std::make_unique<CAnimation>(type.second);
animation[type.first][0]->preload();
const size_t views = animation[type.first][0]->size(0);
cache[type.first].resize(views);
@ -153,7 +153,7 @@ void CMapHandler::initTerrainGraphics()
{
for(auto & type : files)
{
animation[type.first][rotation] = make_unique<CAnimation>(type.second);
animation[type.first][rotation] = std::make_unique<CAnimation>(type.second);
animation[type.first][rotation]->preload();
const size_t views = animation[type.first][rotation]->size(0);
@ -1347,7 +1347,7 @@ CMapHandler::CMapHandler()
tilesW = tilesH = 0;
offsetX = offsetY = 0;
egdeAnimation = make_unique<CAnimation>("EDG");
egdeAnimation = std::make_unique<CAnimation>("EDG");
egdeAnimation->preload();
}

View File

@ -274,7 +274,7 @@ void CHeroArtPlace::select ()
}
}
CCS->curh->dragAndDropCursor(make_unique<CAnimImage>("artifact", ourArt->artType->getIconIndex()));
CCS->curh->dragAndDropCursor(std::make_unique<CAnimImage>("artifact", ourArt->artType->getIconIndex()));
ourOwner->commonInfo->src.setTo(this, false);
ourOwner->markPossibleSlots(ourArt);
@ -749,7 +749,7 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact
commonInfo->src.art = dst.getArt();
commonInfo->src.slotID = dst.slot;
assert(commonInfo->src.AOH);
CCS->curh->dragAndDropCursor(make_unique<CAnimImage>("artifact", dst.getArt()->artType->getIconIndex()));
CCS->curh->dragAndDropCursor(std::make_unique<CAnimImage>("artifact", dst.getArt()->artType->getIconIndex()));
markPossibleSlots(dst.getArt());
}
}

View File

@ -188,7 +188,7 @@ void CTradeWindow::CTradeableItem::clickLeft(tribool down, bool previousState)
aw->arts->markPossibleSlots(art);
//aw->arts->commonInfo->dst.AOH = aw->arts;
CCS->curh->dragAndDropCursor(make_unique<CAnimImage>("artifact", art->artType->iconIndex));
CCS->curh->dragAndDropCursor(std::make_unique<CAnimImage>("artifact", art->artType->iconIndex));
aw->arts->artifactsOnAltar.erase(art);
setID(-1);

View File

@ -40,7 +40,7 @@ public:
auto storage = std::make_shared<PreHandlerStorage>(std::move(handler));
preHandlers[tag].push_back(storage);
return make_unique<PreSubscription>(tag, storage);
return std::make_unique<PreSubscription>(tag, storage);
}
std::unique_ptr<EventSubscription> subscribeAfter(BusTag tag, PostHandler && handler)
@ -49,7 +49,7 @@ public:
auto storage = std::make_shared<PostHandlerStorage>(std::move(handler));
postHandlers[tag].push_back(storage);
return make_unique<PostSubscription>(tag, storage);
return std::make_unique<PostSubscription>(tag, storage);
}
void executeEvent(const EventBus * bus, E & event, const ExecHandler & execHandler)

View File

@ -175,7 +175,7 @@ private:
#define RAII_TRACE(logger, onEntry, onLeave) \
std::unique_ptr<vstd::CTraceLogger> ctl00; \
if(logger->isTraceEnabled()) \
ctl00 = make_unique<vstd::CTraceLogger>(logger, onEntry, onLeave);
ctl00 = std::make_unique<vstd::CTraceLogger>(logger, onEntry, onLeave);
#define LOG_TRACE(logger) RAII_TRACE(logger, \
boost::str(boost::format("Entering %s.") % BOOST_CURRENT_FUNCTION), \

View File

@ -28,7 +28,7 @@
void CModListView::setupModModel()
{
modModel = new CModListModel(this);
manager = vstd::make_unique<CModManager>(modModel);
manager = std::make_unique<CModManager>(modModel);
connect(manager.get(), &CModManager::extraResolutionsEnabledChanged,
this, &CModListView::extraResolutionsEnabledChanged);

View File

@ -1018,7 +1018,7 @@ TurnInfo::TurnInfo(const CGHeroInstance * Hero, const int turn)
: hero(Hero), maxMovePointsLand(-1), maxMovePointsWater(-1)
{
bonuses = hero->getAllBonuses(Selector::days(turn), Selector::all, nullptr, "");
bonusCache = make_unique<BonusCache>(bonuses);
bonusCache = std::make_unique<BonusCache>(bonuses);
nativeTerrain = hero->getNativeTerrain();
}

View File

@ -22,7 +22,7 @@ namespace events
SubscriptionRegistry<ApplyDamage> * ApplyDamage::getRegistry()
{
static std::unique_ptr<SubscriptionRegistry<ApplyDamage>> Instance = make_unique<SubscriptionRegistry<ApplyDamage>>();
static std::unique_ptr<SubscriptionRegistry<ApplyDamage>> Instance = std::make_unique<SubscriptionRegistry<ApplyDamage>>();
return Instance.get();
}

View File

@ -20,7 +20,7 @@ namespace events
SubscriptionRegistry<GameResumed> * GameResumed::getRegistry()
{
static std::unique_ptr<SubscriptionRegistry<GameResumed>> Instance = make_unique<SubscriptionRegistry<GameResumed>>();
static std::unique_ptr<SubscriptionRegistry<GameResumed>> Instance = std::make_unique<SubscriptionRegistry<GameResumed>>();
return Instance.get();
}

View File

@ -21,7 +21,7 @@ namespace events
SubscriptionRegistry<ObjectVisitEnded> * ObjectVisitEnded::getRegistry()
{
static std::unique_ptr<Sub> Instance = make_unique<Sub>();
static std::unique_ptr<Sub> Instance = std::make_unique<Sub>();
return Instance.get();
}

View File

@ -21,7 +21,7 @@ namespace events
SubscriptionRegistry<ObjectVisitStarted> * ObjectVisitStarted::getRegistry()
{
static std::unique_ptr<Sub> Instance = make_unique<Sub>();
static std::unique_ptr<Sub> Instance = std::make_unique<Sub>();
return Instance.get();
}

View File

@ -20,7 +20,7 @@ namespace events
SubscriptionRegistry<PlayerGotTurn> * PlayerGotTurn::getRegistry()
{
static std::unique_ptr<SubscriptionRegistry<PlayerGotTurn>> Instance = make_unique<SubscriptionRegistry<PlayerGotTurn>>();
static std::unique_ptr<SubscriptionRegistry<PlayerGotTurn>> Instance = std::make_unique<SubscriptionRegistry<PlayerGotTurn>>();
return Instance.get();
}

View File

@ -20,7 +20,7 @@ namespace events
SubscriptionRegistry<TurnStarted> * TurnStarted::getRegistry()
{
static std::unique_ptr<SubscriptionRegistry<TurnStarted>> Instance = make_unique<SubscriptionRegistry<TurnStarted>>();
static std::unique_ptr<SubscriptionRegistry<TurnStarted>> Instance = std::make_unique<SubscriptionRegistry<TurnStarted>>();
return Instance.get();
}

View File

@ -177,13 +177,13 @@ std::unique_ptr<CInputStream> CArchiveLoader::load(const ResourceID & resourceNa
if (entry.compressedSize != 0) //compressed data
{
auto fileStream = make_unique<CFileInputStream>(archive, entry.offset, entry.compressedSize);
auto fileStream = std::make_unique<CFileInputStream>(archive, entry.offset, entry.compressedSize);
return make_unique<CCompressedStream>(std::move(fileStream), false, entry.fullSize);
return std::make_unique<CCompressedStream>(std::move(fileStream), false, entry.fullSize);
}
else
{
return make_unique<CFileInputStream>(archive, entry.offset, entry.fullSize);
return std::make_unique<CFileInputStream>(archive, entry.offset, entry.fullSize);
}
}

View File

@ -31,7 +31,7 @@ std::unique_ptr<CInputStream> CFilesystemLoader::load(const ResourceID & resourc
assert(fileList.count(resourceName));
bfs::path file = baseDirectory / fileList.at(resourceName);
logGlobal->trace("loading %s", file.string());
return make_unique<CFileInputStream>(file);
return std::make_unique<CFileInputStream>(file);
}
bool CFilesystemLoader::existsResource(const ResourceID & resourceName) const

View File

@ -177,7 +177,7 @@ void CResourceHandler::initialize()
if (globalResourceHandler.rootLoader)
return;
globalResourceHandler.rootLoader = vstd::make_unique<CFilesystemList>();
globalResourceHandler.rootLoader = std::make_unique<CFilesystemList>();
knownLoaders["root"] = globalResourceHandler.rootLoader.get();
knownLoaders["saves"] = new CFilesystemLoader("SAVES/", VCMIDirs::get().userSavePath());
knownLoaders["config"] = new CFilesystemLoader("CONFIG/", VCMIDirs::get().userConfigPath());

View File

@ -20,8 +20,8 @@ CBasicLogConfigurator::CBasicLogConfigurator(boost::filesystem::path filePath, C
void CBasicLogConfigurator::configureDefault()
{
CLogger::getGlobalLogger()->addTarget(make_unique<CLogConsoleTarget>(console));
CLogger::getGlobalLogger()->addTarget(make_unique<CLogFileTarget>(filePath, appendToLogFile));
CLogger::getGlobalLogger()->addTarget(std::make_unique<CLogConsoleTarget>(console));
CLogger::getGlobalLogger()->addTarget(std::make_unique<CLogFileTarget>(filePath, appendToLogFile));
appendToLogFile = true;
}
@ -52,7 +52,7 @@ void CBasicLogConfigurator::configure()
CLogger::getGlobalLogger()->clearTargets();
// Add console target
auto consoleTarget = make_unique<CLogConsoleTarget>(console);
auto consoleTarget = std::make_unique<CLogConsoleTarget>(console);
const JsonNode & consoleNode = loggingNode["console"];
if(!consoleNode.isNull())
{
@ -80,7 +80,7 @@ void CBasicLogConfigurator::configure()
CLogger::getGlobalLogger()->addTarget(std::move(consoleTarget));
// Add file target
auto fileTarget = make_unique<CLogFileTarget>(filePath, appendToLogFile);
auto fileTarget = std::make_unique<CLogFileTarget>(filePath, appendToLogFile);
const JsonNode & fileNode = loggingNode["file"];
if(!fileNode.isNull())
{

View File

@ -70,7 +70,7 @@ CCampaignHeader CCampaignHandler::getHeader( const std::string & name)
std::unique_ptr<CCampaign> CCampaignHandler::getCampaign( const std::string & name )
{
auto ret = make_unique<CCampaign>();
auto ret = std::make_unique<CCampaign>();
std::vector<std::vector<ui8>> file = getFile(name, false);

View File

@ -712,7 +712,7 @@ void CMap::initTerrain()
CMapEditManager * CMap::getEditManager()
{
if(!editManager) editManager = make_unique<CMapEditManager>(this);
if(!editManager) editManager = std::make_unique<CMapEditManager>(this);
return editManager.get();
}

View File

@ -123,24 +123,24 @@ CMap * CMapEditManager::getMap()
void CMapEditManager::clearTerrain(CRandomGenerator * gen)
{
execute(make_unique<CClearTerrainOperation>(map, gen ? gen : &(this->gen)));
execute(std::make_unique<CClearTerrainOperation>(map, gen ? gen : &(this->gen)));
}
void CMapEditManager::drawTerrain(TerrainId terType, CRandomGenerator * gen)
{
execute(make_unique<CDrawTerrainOperation>(map, terrainSel, terType, gen ? gen : &(this->gen)));
execute(std::make_unique<CDrawTerrainOperation>(map, terrainSel, terType, gen ? gen : &(this->gen)));
terrainSel.clearSelection();
}
void CMapEditManager::drawRoad(RoadId roadType, CRandomGenerator* gen)
{
execute(make_unique<CDrawRoadsOperation>(map, terrainSel, roadType, gen ? gen : &(this->gen)));
execute(std::make_unique<CDrawRoadsOperation>(map, terrainSel, roadType, gen ? gen : &(this->gen)));
terrainSel.clearSelection();
}
void CMapEditManager::drawRiver(RiverId riverType, CRandomGenerator* gen)
{
execute(make_unique<CDrawRiversOperation>(map, terrainSel, riverType, gen ? gen : &(this->gen)));
execute(std::make_unique<CDrawRiversOperation>(map, terrainSel, riverType, gen ? gen : &(this->gen)));
terrainSel.clearSelection();
}
@ -148,35 +148,35 @@ void CMapEditManager::drawRiver(RiverId riverType, CRandomGenerator* gen)
void CMapEditManager::insertObject(CGObjectInstance * obj)
{
execute(make_unique<CInsertObjectOperation>(map, obj));
execute(std::make_unique<CInsertObjectOperation>(map, obj));
}
void CMapEditManager::insertObjects(std::set<CGObjectInstance*>& objects)
{
auto composedOperation = make_unique<CComposedOperation>(map);
auto composedOperation = std::make_unique<CComposedOperation>(map);
for (auto obj : objects)
{
composedOperation->addOperation(make_unique<CInsertObjectOperation>(map, obj));
composedOperation->addOperation(std::make_unique<CInsertObjectOperation>(map, obj));
}
execute(std::move(composedOperation));
}
void CMapEditManager::moveObject(CGObjectInstance * obj, const int3 & pos)
{
execute(make_unique<CMoveObjectOperation>(map, obj, pos));
execute(std::make_unique<CMoveObjectOperation>(map, obj, pos));
}
void CMapEditManager::removeObject(CGObjectInstance * obj)
{
execute(make_unique<CRemoveObjectOperation>(map, obj));
execute(std::make_unique<CRemoveObjectOperation>(map, obj));
}
void CMapEditManager::removeObjects(std::set<CGObjectInstance*> & objects)
{
auto composedOperation = make_unique<CComposedOperation>(map);
auto composedOperation = std::make_unique<CComposedOperation>(map);
for (auto obj : objects)
{
composedOperation->addOperation(make_unique<CRemoveObjectOperation>(map, obj));
composedOperation->addOperation(std::make_unique<CRemoveObjectOperation>(map, obj));
}
execute(std::move(composedOperation));
}

View File

@ -49,7 +49,7 @@ void CMapInfo::saveInit(ResourceID file)
CLoadFile lf(*CResourceHandler::get()->getResourceName(file), MINIMAL_SERIALIZATION_VERSION);
lf.checkMagicBytes(SAVEGAME_MAGIC);
mapHeader = make_unique<CMapHeader>();
mapHeader = std::make_unique<CMapHeader>();
lf >> *(mapHeader.get()) >> scenarioOptionsOfSave;
fileURI = file.getName();
countPlayers();

View File

@ -551,12 +551,12 @@ CClearTerrainOperation::CClearTerrainOperation(CMap* map, CRandomGenerator* gen)
{
CTerrainSelection terrainSel(map);
terrainSel.selectRange(MapRect(int3(0, 0, 0), map->width, map->height));
addOperation(make_unique<CDrawTerrainOperation>(map, terrainSel, Terrain::WATER, gen));
addOperation(std::make_unique<CDrawTerrainOperation>(map, terrainSel, Terrain::WATER, gen));
if(map->twoLevel)
{
terrainSel.clearSelection();
terrainSel.selectRange(MapRect(int3(0, 0, 1), map->width, map->height));
addOperation(make_unique<CDrawTerrainOperation>(map, terrainSel, Terrain::ROCK, gen));
addOperation(std::make_unique<CDrawTerrainOperation>(map, terrainSel, Terrain::ROCK, gen));
}
}

View File

@ -52,7 +52,7 @@ std::unique_ptr<CMap> CMapLoaderH3M::loadMap()
std::unique_ptr<CMapHeader> CMapLoaderH3M::loadMapHeader()
{
// Read header
mapHeader = make_unique<CMapHeader>();
mapHeader = std::make_unique<CMapHeader>();
readHeader();
return std::move(mapHeader);

View File

@ -340,7 +340,7 @@ const std::string CMapFormatJson::OBJECTS_FILE_NAME = "objects.json";
CMapFormatJson::CMapFormatJson():
fileVersionMajor(0), fileVersionMinor(0),
mapObjectResolver(make_unique<MapObjectResolver>(this)),
mapObjectResolver(std::make_unique<MapObjectResolver>(this)),
map(nullptr), mapHeader(nullptr)
{
@ -1191,7 +1191,7 @@ void CMapLoaderJson::readObjects()
//get raw data
for(auto & p : data.Struct())
loaders.push_back(vstd::make_unique<MapObjectLoader>(this, p));
loaders.push_back(std::make_unique<MapObjectLoader>(this, p));
for(auto & ptr : loaders)
ptr->construct();

View File

@ -42,7 +42,7 @@ void CLoadFile::openNextFile(const boost::filesystem::path & fname, int minimalV
try
{
fName = fname.string();
sfile = make_unique<FileStream>(fname, std::ios::in | std::ios::binary);
sfile = std::make_unique<FileStream>(fname, std::ios::in | std::ios::binary);
sfile->exceptions(std::ifstream::failbit | std::ifstream::badbit); //we throw a lot anyway
if(!(*sfile))

View File

@ -39,7 +39,7 @@ void CSaveFile::openNextFile(const boost::filesystem::path &fname)
fName = fname;
try
{
sfile = make_unique<FileStream>(fname, std::ios::out | std::ios::binary);
sfile = std::make_unique<FileStream>(fname, std::ios::out | std::ios::binary);
sfile->exceptions(std::ifstream::failbit | std::ifstream::badbit); //we throw a lot anyway
if(!(*sfile))

View File

@ -19,8 +19,8 @@ CLoadIntegrityValidator::CLoadIntegrityValidator(const boost::filesystem::path &
: serializer(this), foundDesync(false)
{
registerTypes(serializer);
primaryFile = make_unique<CLoadFile>(primaryFileName, minimalVersion);
controlFile = make_unique<CLoadFile>(controlFileName, minimalVersion);
primaryFile = std::make_unique<CLoadFile>(primaryFileName, minimalVersion);
controlFile = std::make_unique<CLoadFile>(controlFileName, minimalVersion);
assert(primaryFile->serializer.fileVersion == controlFile->serializer.fileVersion);
serializer.fileVersion = primaryFile->serializer.fileVersion;

View File

@ -138,8 +138,8 @@ public:
// register the relation between classes
bti->children.push_back(dti);
dti->parents.push_back(bti);
casters[std::make_pair(bti, dti)] = make_unique<const PointerCaster<Base, Derived>>();
casters[std::make_pair(dti, bti)] = make_unique<const PointerCaster<Derived, Base>>();
casters[std::make_pair(bti, dti)] = std::make_unique<const PointerCaster<Base, Derived>>();
casters[std::make_pair(dti, bti)] = std::make_unique<const PointerCaster<Derived, Base>>();
}
ui16 getTypeID(const std::type_info *type, bool throws = false) const;

View File

@ -405,9 +405,9 @@ ISpellMechanicsFactory::~ISpellMechanicsFactory()
std::unique_ptr<ISpellMechanicsFactory> ISpellMechanicsFactory::get(const CSpell * s)
{
if(s->hasBattleEffects())
return make_unique<ConfigurableMechanicsFactory>(s);
return std::make_unique<ConfigurableMechanicsFactory>(s);
else
return make_unique<FallbackMechanicsFactory>(s);
return std::make_unique<FallbackMechanicsFactory>(s);
}
///Mechanics
@ -759,24 +759,24 @@ std::unique_ptr<IAdventureSpellMechanics> IAdventureSpellMechanics::createMechan
switch (s->id)
{
case SpellID::SUMMON_BOAT:
return make_unique<SummonBoatMechanics>(s);
return std::make_unique<SummonBoatMechanics>(s);
case SpellID::SCUTTLE_BOAT:
return make_unique<ScuttleBoatMechanics>(s);
return std::make_unique<ScuttleBoatMechanics>(s);
case SpellID::DIMENSION_DOOR:
return make_unique<DimensionDoorMechanics>(s);
return std::make_unique<DimensionDoorMechanics>(s);
case SpellID::FLY:
case SpellID::WATER_WALK:
case SpellID::VISIONS:
case SpellID::DISGUISE:
return make_unique<AdventureSpellMechanics>(s); //implemented using bonus system
return std::make_unique<AdventureSpellMechanics>(s); //implemented using bonus system
case SpellID::TOWN_PORTAL:
return make_unique<TownPortalMechanics>(s);
return std::make_unique<TownPortalMechanics>(s);
case SpellID::VIEW_EARTH:
return make_unique<ViewEarthMechanics>(s);
return std::make_unique<ViewEarthMechanics>(s);
case SpellID::VIEW_AIR:
return make_unique<ViewAirMechanics>(s);
return std::make_unique<ViewAirMechanics>(s);
default:
return s->combat ? std::unique_ptr<IAdventureSpellMechanics>() : make_unique<AdventureSpellMechanics>(s);
return s->combat ? std::unique_ptr<IAdventureSpellMechanics>() : std::make_unique<AdventureSpellMechanics>(s);
}
}

View File

@ -400,7 +400,7 @@ const TargetConditionItemFactory * TargetConditionItemFactory::getDefault()
static std::unique_ptr<TargetConditionItemFactory> singleton;
if(!singleton)
singleton = make_unique<DefaultTargetConditionItemFactory>();
singleton = std::make_unique<DefaultTargetConditionItemFactory>();
return singleton.get();
}

View File

@ -52,7 +52,7 @@ Registry::~Registry() = default;
Registry * GlobalRegistry::get()
{
static std::unique_ptr<Registry> Instance = make_unique<detail::RegistryImpl>();
static std::unique_ptr<Registry> Instance = std::make_unique<detail::RegistryImpl>();
return Instance.get();
}

View File

@ -65,7 +65,7 @@ void MapHandler::initTerrainGraphics()
{
for(auto & type : files)
{
animation[type.first] = make_unique<Animation>(type.second);
animation[type.first] = std::make_unique<Animation>(type.second);
animation[type.first]->preload();
const size_t views = animation[type.first]->size(0);
cache[type.first].resize(views);

View File

@ -71,7 +71,7 @@ void ResourceConverter::splitDefFile(const std::string & fileName, const bfs::pa
{
if(CResourceHandler::get()->existsResource(ResourceID("SPRITES/" + fileName)))
{
std::unique_ptr<Animation> anim = make_unique<Animation>(fileName);
std::unique_ptr<Animation> anim = std::make_unique<Animation>(fileName);
anim->preload();
anim->exportBitmaps(pathToQString(VCMIDirs::get().userExtractedPath()));
@ -88,4 +88,4 @@ void ResourceConverter::splitDefFiles(bool deleteOriginals)
for(std::string defFilename : {"TwCrPort.def", "CPRSMALL.def", "FlagPort.def", "ITPA.def", "ITPt.def", "Un32.def", "Un44.def"})
splitDefFile(defFilename, spritesPath, deleteOriginals);
}
}

View File

@ -731,7 +731,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance * heroAttacker, con
//Check how many battle queries were created (number of players blocked by battle)
const int queriedPlayers = battleQuery ? (int)boost::count(queries.allQueries(), battleQuery) : 0;
finishingBattle = make_unique<FinishingBattleHelper>(battleQuery, queriedPlayers);
finishingBattle = std::make_unique<FinishingBattleHelper>(battleQuery, queriedPlayers);
CasualtiesAfterBattle cab1(bEndArmy1, gs->curB), cab2(bEndArmy2, gs->curB); //calculate casualties before deleting battle
ChangeSpells cs; //for Eagle Eye
@ -1669,7 +1669,7 @@ CGameHandler::~CGameHandler()
void CGameHandler::reinitScripting()
{
serverEventBus = make_unique<events::EventBus>();
serverEventBus = std::make_unique<events::EventBus>();
#if SCRIPTING_ENABLED
serverScripts.reset(new scripting::PoolImpl(this, spellEnv));
#endif
@ -1929,7 +1929,7 @@ void CGameHandler::newTurn()
NewTurn::Hero hth;
hth.id = h->id;
auto ti = make_unique<TurnInfo>(h, 1);
auto ti = std::make_unique<TurnInfo>(h, 1);
// TODO: this code executed when bonuses of previous day not yet updated (this happen in NewTurn::applyGs). See issue 2356
hth.move = h->maxMovePointsCached(gs->map->getTile(h->visitablePos()).terType->isLand(), ti.get());
hth.mana = h->getManaNewTurn();
@ -2349,7 +2349,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
tmh.movePoints = h->movement;
//check if destination tile is available
auto pathfinderHelper = make_unique<CPathfinderHelper>(gs, h, PathfinderOptions());
auto pathfinderHelper = std::make_unique<CPathfinderHelper>(gs, h, PathfinderOptions());
pathfinderHelper->updateTurnInfo(0);
auto ti = pathfinderHelper->getTurnInfo();

View File

@ -156,7 +156,7 @@ void CVCMIServer::run()
{
if(!restartGameplay)
{
this->announceLobbyThread = vstd::make_unique<boost::thread>(&CVCMIServer::threadAnnounceLobby, this);
this->announceLobbyThread = std::make_unique<boost::thread>(&CVCMIServer::threadAnnounceLobby, this);
#if !defined(VCMI_ANDROID) && !defined(VCMI_IOS)
if(cmdLineOptions.count("enable-shm"))
{
@ -172,7 +172,7 @@ void CVCMIServer::run()
startAsyncAccept();
if(!remoteConnectionsThread && cmdLineOptions.count("lobby"))
{
remoteConnectionsThread = vstd::make_unique<boost::thread>(&CVCMIServer::establishRemoteConnections, this);
remoteConnectionsThread = std::make_unique<boost::thread>(&CVCMIServer::establishRemoteConnections, this);
}
#if defined(VCMI_ANDROID)
@ -418,7 +418,7 @@ void CVCMIServer::threadHandleClient(std::shared_ptr<CConnection> c)
// if(state != ENDING_AND_STARTING_GAME)
if(c->connected)
{
auto lcd = vstd::make_unique<LobbyClientDisconnected>();
auto lcd = std::make_unique<LobbyClientDisconnected>();
lcd->c = c;
lcd->clientId = c->connectionID;
handleReceivedPack(std::move(lcd));
@ -453,7 +453,7 @@ void CVCMIServer::announcePack(std::unique_ptr<CPackForLobby> pack)
void CVCMIServer::announceMessage(const std::string & txt)
{
logNetwork->info("Show message: %s", txt);
auto cm = vstd::make_unique<LobbyShowMessage>();
auto cm = std::make_unique<LobbyShowMessage>();
cm->message = txt;
addToAnnounceQueue(std::move(cm));
}
@ -461,7 +461,7 @@ void CVCMIServer::announceMessage(const std::string & txt)
void CVCMIServer::announceTxt(const std::string & txt, const std::string & playerName)
{
logNetwork->info("%s says: %s", playerName, txt);
auto cm = vstd::make_unique<LobbyChatMessage>();
auto cm = std::make_unique<LobbyChatMessage>();
cm->playerName = playerName;
cm->message = txt;
addToAnnounceQueue(std::move(cm));
@ -709,7 +709,7 @@ void CVCMIServer::updateAndPropagateLobbyState()
}
}
auto lus = vstd::make_unique<LobbyUpdateState>();
auto lus = std::make_unique<LobbyUpdateState>();
lus->state = *this;
addToAnnounceQueue(std::move(lus));
}

View File

@ -158,7 +158,7 @@ void LobbyClientDisconnected::applyOnServerAfterAnnounce(CVCMIServer * srv)
}
else if(c == srv->hostClient)
{
auto ph = vstd::make_unique<LobbyChangeHost>();
auto ph = std::make_unique<LobbyChangeHost>();
auto newHost = *RandomGeneratorUtil::nextItem(srv->connections, CRandomGenerator::getDefault());
ph->newHostConnectionId = newHost->connectionID;
srv->addToAnnounceQueue(std::move(ph));