Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use std::make_{unique,shared} instead of raw new #3535

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ivis_opengl/gfx_api_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3075,7 +3075,7 @@ bool gl_context::getScreenshot(std::function<void (std::unique_ptr<iV_Image>)> c
return false;
}

auto image = std::unique_ptr<iV_Image>(new iV_Image());
auto image = std::make_unique<iV_Image>();
auto width = m_viewport[2];
auto height = m_viewport[3];
bool allocateResult = image->allocate(width, height, channelsPerPixel); // RGB
Expand Down
4 changes: 2 additions & 2 deletions lib/ivis_opengl/gfx_api_image_basis_priv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ static std::vector<std::unique_ptr<iV_BaseImage>> loadiVImagesFromFile_Basis_Dat
ASSERT_OR_RETURN({}, format == basist::transcoder_texture_format::cTFRGBA32, "Unsupported uncompressed format: %u", (unsigned)format);
numBlocksOrPixels = level_info.m_orig_width * level_info.m_orig_height;

uncompressedOutput = std::unique_ptr<iV_Image>(new iV_Image());
uncompressedOutput = std::make_unique<iV_Image>();
if (!uncompressedOutput->allocate(level_info.m_orig_width, level_info.m_orig_height, 4, false)) // hard-coded for RGBA32 for now
{
debug(LOG_ERROR, "Failed to allocate memory for uncompressed image buffer");
Expand All @@ -421,7 +421,7 @@ static std::vector<std::unique_ptr<iV_BaseImage>> loadiVImagesFromFile_Basis_Dat
numBlocksOrPixels = level_info.m_total_blocks;
uint32_t outputSize = numBlocksOrPixels * bytes_per_block_or_pixel;

compressedOutput = std::unique_ptr<iV_CompressedImage>(new iV_CompressedImage());
compressedOutput = std::make_unique<iV_CompressedImage>();
if (!compressedOutput->allocate(internalFormat, outputSize, level_info.m_width, level_info.m_height, level_info.m_orig_width, level_info.m_orig_height, false))
{
debug(LOG_ERROR, "Failed to allocate memory for buffer");
Expand Down
2 changes: 1 addition & 1 deletion lib/ivis_opengl/gfx_api_image_compress_priv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ static std::unique_ptr<iV_CompressedImage> compressImageEtcPak(const iV_Image& i

size_t outputSize = gfx_api::format_memory_size(desiredFormat, originalWidth, originalHeight);

std::unique_ptr<iV_CompressedImage> compressedOutput = std::unique_ptr<iV_CompressedImage>(new iV_CompressedImage());
std::unique_ptr<iV_CompressedImage> compressedOutput = std::make_unique<iV_CompressedImage>();
if (!compressedOutput->allocate(desiredFormat, outputSize, alignedWidth, alignedHeight, originalWidth, originalHeight, false))
{
debug(LOG_ERROR, "Failed to allocate memory for buffer");
Expand Down
28 changes: 14 additions & 14 deletions lib/ivis_opengl/textdraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,13 +1067,13 @@ static bool inline initializeCJKFontsIfNeeded()
uint32_t horizDPI = static_cast<uint32_t>(DEFAULT_DPI * _horizScaleFactor);
uint32_t vertDPI = static_cast<uint32_t>(DEFAULT_DPI * _vertScaleFactor);
try {
cjkFonts->regular = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, CJK_FONT_PATH, 12 * 64, horizDPI, vertDPI, 400));
cjkFonts->regularBold = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, CJK_FONT_PATH, 12 * 64, horizDPI, vertDPI, 700));
cjkFonts->bold = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, CJK_FONT_PATH, 21 * 64, horizDPI, vertDPI, 400));
cjkFonts->medium = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, CJK_FONT_PATH, 16 * 64, horizDPI, vertDPI, 400));
cjkFonts->mediumBold = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, CJK_FONT_PATH, 16 * 64, horizDPI, vertDPI, 700));
cjkFonts->small = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, CJK_FONT_PATH, 9 * 64, horizDPI, vertDPI, 400));
cjkFonts->smallBold = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, CJK_FONT_PATH, 9 * 64, horizDPI, vertDPI, 700));
cjkFonts->regular = std::make_unique<FTFace>(getGlobalFTlib().lib, CJK_FONT_PATH, 12 * 64, horizDPI, vertDPI, 400);
cjkFonts->regularBold = std::make_unique<FTFace>(getGlobalFTlib().lib, CJK_FONT_PATH, 12 * 64, horizDPI, vertDPI, 700);
cjkFonts->bold = std::make_unique<FTFace>(getGlobalFTlib().lib, CJK_FONT_PATH, 21 * 64, horizDPI, vertDPI, 400);
cjkFonts->medium = std::make_unique<FTFace>(getGlobalFTlib().lib, CJK_FONT_PATH, 16 * 64, horizDPI, vertDPI, 400);
cjkFonts->mediumBold = std::make_unique<FTFace>(getGlobalFTlib().lib, CJK_FONT_PATH, 16 * 64, horizDPI, vertDPI, 700);
cjkFonts->small = std::make_unique<FTFace>(getGlobalFTlib().lib, CJK_FONT_PATH, 9 * 64, horizDPI, vertDPI, 400);
cjkFonts->smallBold = std::make_unique<FTFace>(getGlobalFTlib().lib, CJK_FONT_PATH, 9 * 64, horizDPI, vertDPI, 700);
}
catch (const std::exception &e) {
debug(LOG_ERROR, "Failed to load font:\n%s", e.what());
Expand Down Expand Up @@ -1175,13 +1175,13 @@ void iV_TextInit(unsigned int horizScalePercentage, unsigned int vertScalePercen
}

try {
baseFonts->regular = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, "fonts/DejaVuSans.ttf", 12 * 64, horizDPI, vertDPI));
baseFonts->regularBold = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, "fonts/DejaVuSans-Bold.ttf", 12 * 64, horizDPI, vertDPI));
baseFonts->bold = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, "fonts/DejaVuSans-Bold.ttf", 21 * 64, horizDPI, vertDPI));
baseFonts->medium = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, "fonts/DejaVuSans.ttf", 16 * 64, horizDPI, vertDPI));
baseFonts->mediumBold = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, "fonts/DejaVuSans-Bold.ttf", 16 * 64, horizDPI, vertDPI));
baseFonts->small = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, "fonts/DejaVuSans.ttf", 9 * 64, horizDPI, vertDPI));
baseFonts->smallBold = std::unique_ptr<FTFace>(new FTFace(getGlobalFTlib().lib, "fonts/DejaVuSans-Bold.ttf", 9 * 64, horizDPI, vertDPI));
baseFonts->regular = std::make_unique<FTFace>(getGlobalFTlib().lib, "fonts/DejaVuSans.ttf", 12 * 64, horizDPI, vertDPI);
baseFonts->regularBold = std::make_unique<FTFace>(getGlobalFTlib().lib, "fonts/DejaVuSans-Bold.ttf", 12 * 64, horizDPI, vertDPI);
baseFonts->bold = std::make_unique<FTFace>(getGlobalFTlib().lib, "fonts/DejaVuSans-Bold.ttf", 21 * 64, horizDPI, vertDPI);
baseFonts->medium = std::make_unique<FTFace>(getGlobalFTlib().lib, "fonts/DejaVuSans.ttf", 16 * 64, horizDPI, vertDPI);
baseFonts->mediumBold = std::make_unique<FTFace>(getGlobalFTlib().lib, "fonts/DejaVuSans-Bold.ttf", 16 * 64, horizDPI, vertDPI);
baseFonts->small = std::make_unique<FTFace>(getGlobalFTlib().lib, "fonts/DejaVuSans.ttf", 9 * 64, horizDPI, vertDPI);
baseFonts->smallBold = std::make_unique<FTFace>(getGlobalFTlib().lib, "fonts/DejaVuSans-Bold.ttf", 9 * 64, horizDPI, vertDPI);
}
catch (const std::exception &e) {
// Log lots of details:
Expand Down
2 changes: 1 addition & 1 deletion lib/netplay/netplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ struct PlayerReference

void disconnect()
{
detached = std::unique_ptr<PLAYER>(new PLAYER(NetPlay.players[index]));
detached = std::make_unique<PLAYER>(NetPlay.players[index]);
detached->wzFiles = std::make_shared<std::vector<WZFile>>();
}

Expand Down
4 changes: 2 additions & 2 deletions lib/netplay/netreplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ bool NETreplaySaveStart(std::string const& subdir, ReplayOptionsHandler const &o
latestWriteBuffer.reserve(minBufferSizeToQueue);
if (desiredBufferSize != std::numeric_limits<size_t>::max())
{
saveThread = std::unique_ptr<wz::thread>(new wz::thread(replaySaveThreadFunc, replaySaveHandle));
saveThread = std::make_unique<wz::thread>(replaySaveThreadFunc, replaySaveHandle);
}
else
{
Expand Down Expand Up @@ -415,7 +415,7 @@ bool NETreplayLoadNetMessage(std::unique_ptr<NetMessage> &message, uint8_t &play
return false;
}

message = std::unique_ptr<NetMessage>(new NetMessage(type));
message = std::make_unique<NetMessage>(type);
message->data.resize(len);
size_t messageRead = WZ_PHYSFS_readBytes(replayLoadHandle, message->data.data(), message->data.size());
if (messageRead != message->data.size())
Expand Down
2 changes: 1 addition & 1 deletion lib/netplay/nettypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ bool NETloadReplay(std::string const &filename, ReplayOptionsHandler& optionsHan
return false;
}
// Add special REPLAY_ENDED message to the end of the host's gameQueue
newMessage = std::unique_ptr<NetMessage>(new NetMessage(REPLAY_ENDED));
newMessage = std::make_unique<NetMessage>(REPLAY_ENDED);
gameQueues[NetPlay.hostPlayer]->pushMessage(*newMessage);
NETreplayLoadStop();
bIsReplay = true;
Expand Down
6 changes: 3 additions & 3 deletions lib/sdl/gfx_api_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ SDL_gfx_api_Impl_Factory::SDL_gfx_api_Impl_Factory(SDL_Window* _window, SDL_gfx_

std::unique_ptr<gfx_api::backend_Null_Impl> SDL_gfx_api_Impl_Factory::createNullBackendImpl() const
{
return std::unique_ptr<gfx_api::backend_Null_Impl>(new sdl_Null_Impl());
return std::make_unique<sdl_Null_Impl>();
}

std::unique_ptr<gfx_api::backend_OpenGL_Impl> SDL_gfx_api_Impl_Factory::createOpenGLBackendImpl() const
{
ASSERT_OR_RETURN(nullptr, window != nullptr, "Invalid SDL_Window*");
return std::unique_ptr<gfx_api::backend_OpenGL_Impl>(new sdl_OpenGL_Impl(window, config.useOpenGLES, config.useOpenGLESLibrary));
return std::make_unique<sdl_OpenGL_Impl>(window, config.useOpenGLES, config.useOpenGLESLibrary);
}

#if defined(WZ_VULKAN_ENABLED)
std::unique_ptr<gfx_api::backend_Vulkan_Impl> SDL_gfx_api_Impl_Factory::createVulkanBackendImpl() const
{
ASSERT_OR_RETURN(nullptr, window != nullptr, "Invalid SDL_Window*");
#if defined(HAVE_SDL_VULKAN_H)
return std::unique_ptr<gfx_api::backend_Vulkan_Impl>(new sdl_Vulkan_Impl(window, config.allowImplicitLayers));
return std::make_unique<sdl_Vulkan_Impl>(window, config.allowImplicitLayers);
#else // !defined(HAVE_SDL_VULKAN_H)
SDL_version compiled_version;
SDL_VERSION(&compiled_version);
Expand Down
2 changes: 1 addition & 1 deletion lib/sound/oggvorbis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ WZVorbisDecoder* WZVorbisDecoder::fromFilename(const char* fileName)
debug(LOG_ERROR, "sound_LoadTrackFromFile: PHYSFS_openRead(\"%s\") failed with error: %s\n", fileName, WZ_PHYSFS_getLastError());
return nullptr;
}
std::unique_ptr<OggVorbis_File> ovf = std::unique_ptr<OggVorbis_File>(new OggVorbis_File());
std::unique_ptr<OggVorbis_File> ovf = std::make_unique<OggVorbis_File>();
// https://xiph.org/vorbis/doc/vorbisfile/ov_open_callbacks.html
const int error = ov_open_callbacks(fileHandle, ovf.get(), nullptr, 0, wz_oggVorbis_callbacks);
if (error != 0)
Expand Down
4 changes: 2 additions & 2 deletions lib/widget/paragraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,14 +480,14 @@ std::vector<std::vector<FlowLayoutFragment>> Paragraph::calculateLinesLayout()
void Paragraph::addText(std::string const &text)
{
layoutDirty = true;
elements.push_back(std::unique_ptr<ParagraphTextElement>(new ParagraphTextElement(text, textStyle)));
elements.push_back(std::make_unique<ParagraphTextElement>(text, textStyle));
}

void Paragraph::addWidget(const std::shared_ptr<WIDGET> &widget, int32_t aboveBase)
{
layoutDirty = true;
attach(widget);
elements.push_back(std::unique_ptr<ParagraphWidgetElement>(new ParagraphWidgetElement(widget, aboveBase)));
elements.push_back(std::make_unique<ParagraphWidgetElement>(widget, aboveBase));
}

void Paragraph::geometryChanged()
Expand Down
2 changes: 1 addition & 1 deletion lib/widget/paragraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class WzCachedText
{
if (!cachedText)
{
cachedText = std::unique_ptr<WzText>(new WzText(text, font));
cachedText = std::make_unique<WzText>(text, font);
}

cacheExpireAt = realTime + (cacheDurationMs * GAME_TICKS_PER_SEC) / 1000;
Expand Down
4 changes: 2 additions & 2 deletions lib/wzmaplib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ set_target_properties(wzmaplib PROPERTIES VERSION "${WZMAPLIB_VERSION_STRING}")

set_target_properties(wzmaplib
PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
Expand Down Expand Up @@ -170,7 +170,7 @@ if (libzip_FOUND AND libzip_LINK_TEST)
set_property(TARGET ZipIOProvider PROPERTY FOLDER "lib")
set_target_properties(ZipIOProvider
PROPERTIES
CXX_STANDARD 11
CXX_STANDARD 14
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
Expand Down
6 changes: 3 additions & 3 deletions lib/wzmaplib/include/wzmaplib/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ std::string to_string(MapType mapType);
class Map
{
private:
Map(const std::string& mapFolderPath, MapType mapType, uint32_t mapMaxPlayers, std::shared_ptr<LoggingProtocol> logger, std::shared_ptr<IOProvider> mapIO = std::shared_ptr<IOProvider>(new StdIOProvider()));
Map(const std::string& mapFolderPath, MapType mapType, uint32_t mapMaxPlayers, std::shared_ptr<LoggingProtocol> logger, std::shared_ptr<IOProvider> mapIO = std::make_shared<StdIOProvider>());

public:
// Construct an empty Map, for modification
Expand All @@ -138,10 +138,10 @@ class Map
// - seed (a seed used for random script-based maps generation)
// - a logger
// - a WzMap::IOProvider
static std::shared_ptr<Map> loadFromPath(const std::string& mapFolderPath, MapType mapType, uint32_t mapMaxPlayers, uint32_t seed, std::shared_ptr<LoggingProtocol> logger = nullptr, std::shared_ptr<IOProvider> mapIO = std::shared_ptr<IOProvider>(new StdIOProvider()));
static std::shared_ptr<Map> loadFromPath(const std::string& mapFolderPath, MapType mapType, uint32_t mapMaxPlayers, uint32_t seed, std::shared_ptr<LoggingProtocol> logger = nullptr, std::shared_ptr<IOProvider> mapIO = std::make_shared<StdIOProvider>());

// Export a map to a specified folder path in a specified output format (version)
static bool exportMapToPath(Map& map, const std::string& mapFolderPath, MapType mapType, uint32_t mapMaxPlayers, OutputFormat format, std::shared_ptr<LoggingProtocol> logger = nullptr, std::shared_ptr<IOProvider> mapIO = std::shared_ptr<IOProvider>(new StdIOProvider()));
static bool exportMapToPath(Map& map, const std::string& mapFolderPath, MapType mapType, uint32_t mapMaxPlayers, OutputFormat format, std::shared_ptr<LoggingProtocol> logger = nullptr, std::shared_ptr<IOProvider> mapIO = std::make_shared<StdIOProvider>());

// High-level data loading functions

Expand Down
4 changes: 2 additions & 2 deletions lib/wzmaplib/include/wzmaplib/map_package.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ class MapPackage
// The default StdIOProvider will assume pathToMapPackage is a path to an extracted map package (i.e. standard filesystem I/O)
//
// To load from an archive (.zip/.wz), create a custom implementation of WzMap::IOProvider that supports compressed archive files that you initialize with the path to the zip. An example of this (which uses libzip) is available in `plugins/ZipIOProvider`. You would then set `pathToMapPackage` to be the root path inside the zip. (In the case of plugins\ZipIOProvider, literally "/" or "").
static std::unique_ptr<MapPackage> loadPackage(const std::string& pathToMapPackage, std::shared_ptr<LoggingProtocol> logger = nullptr, std::shared_ptr<IOProvider> mapIO = std::shared_ptr<IOProvider>(new StdIOProvider()));
static std::unique_ptr<MapPackage> loadPackage(const std::string& pathToMapPackage, std::shared_ptr<LoggingProtocol> logger = nullptr, std::shared_ptr<IOProvider> mapIO = std::make_shared<StdIOProvider>());

// Construct a new MapPackage object (which can then be exported)
MapPackage(const LevelDetails& levelDetails, MapType mapType, std::shared_ptr<Map> map);

// Export the currently-loaded map package to a specified path in a specified format
// Can convert both the LevelFormat and the WzMap::OutputFormat
bool exportMapPackageFiles(std::string basePath, LevelFormat levelFormat, WzMap::OutputFormat mapOutputFormat,
optional<std::string> mapFolderRelativePathOverride = nullopt, bool copyAdditionalFilesFromOriginalLoadedPackage = false, std::shared_ptr<LoggingProtocol> logger = nullptr, std::shared_ptr<IOProvider> exportIO = std::shared_ptr<IOProvider>(new StdIOProvider()));
optional<std::string> mapFolderRelativePathOverride = nullopt, bool copyAdditionalFilesFromOriginalLoadedPackage = false, std::shared_ptr<LoggingProtocol> logger = nullptr, std::shared_ptr<IOProvider> exportIO = std::make_shared<StdIOProvider>());

// High-level data loading functions

Expand Down
4 changes: 2 additions & 2 deletions lib/wzmaplib/src/map_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ MapPackage::MapPackage()
// The default StdIOProvider will assume pathToMapPackage is a path to an extracted map package (i.e. standard filesystem I/O)
//
// To load from an archive (.zip/.wz), create a custom implementation of WzMap::IOProvider that supports compressed archive files that you initialize with the path to the zip. An example of this (which uses libzip) is available in `plugins/ZipIOProvider`. You would then set `pathToMapPackage` to be the root path inside the zip. (In the case of plugins\ZipIOProvider, literally `/`).
std::unique_ptr<MapPackage> MapPackage::loadPackage(const std::string& pathToMapPackage, std::shared_ptr<LoggingProtocol> logger /*= nullptr*/, std::shared_ptr<IOProvider> pMapIO /*= std::shared_ptr<IOProvider>(new StdIOProvider())*/)
std::unique_ptr<MapPackage> MapPackage::loadPackage(const std::string& pathToMapPackage, std::shared_ptr<LoggingProtocol> logger /*= nullptr*/, std::shared_ptr<IOProvider> pMapIO /*= std::make_shared<StdIOProvider>()*/)
{
LoggingProtocol* pCustomLogger = logger.get();
if (!pMapIO)
Expand Down Expand Up @@ -1287,7 +1287,7 @@ static bool copyFile_IOProviders(const std::string& readPath, const std::string&
// Export the currently-loaded map package to a specified path in a specified format
// Can convert both the LevelFormat and the WzMap::OutputFormat
bool MapPackage::exportMapPackageFiles(std::string basePath, LevelFormat levelFormat, WzMap::OutputFormat mapOutputFormat,
optional<std::string> mapFolderRelativePathOverride /*= nullopt*/, bool copyAdditionalFilesFromOriginalLoadedPackage /*= false*/, std::shared_ptr<LoggingProtocol> logger /*= nullptr*/, std::shared_ptr<IOProvider> exportIO /*= std::shared_ptr<IOProvider>(new StdIOProvider())*/)
optional<std::string> mapFolderRelativePathOverride /*= nullopt*/, bool copyAdditionalFilesFromOriginalLoadedPackage /*= false*/, std::shared_ptr<LoggingProtocol> logger /*= nullptr*/, std::shared_ptr<IOProvider> exportIO /*= std::make_shared<StdIOProvider>()*/)
{
LoggingProtocol* pCustomLogger = logger.get();
if (!exportIO)
Expand Down
4 changes: 2 additions & 2 deletions lib/wzmaplib/src/map_preview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ bool plotStructurePreviewWzMap(Map &wzMap, const MapPreviewColorScheme& colorSch
MapPlayerColorProvider* pPlayerColorProvider = colorScheme.playerColorProvider.get();
if (!pPlayerColorProvider)
{
defaultPlayerColorProvider = std::unique_ptr<MapPlayerColorProvider>(new MapPlayerColorProvider());
defaultPlayerColorProvider = std::make_unique<MapPlayerColorProvider>();
pPlayerColorProvider = defaultPlayerColorProvider.get();
}

Expand Down Expand Up @@ -295,7 +295,7 @@ std::unique_ptr<MapPreviewImage> generate2DMapPreview(Map& wzMap, const MapPrevi

const TilesetColorScheme& clrSch = colorScheme.tilesetColors;

std::unique_ptr<MapPreviewImage> result = std::unique_ptr<MapPreviewImage>(new MapPreviewImage());
std::unique_ptr<MapPreviewImage> result = std::make_unique<MapPreviewImage>();
result->width = mapData->width;
result->height = mapData->height;
result->channels = 3;
Expand Down
8 changes: 4 additions & 4 deletions src/activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ class ActivityDatabase : public ActivityDBProtocol
// Caller is expected to handle thrown exceptions
ActivityDatabase(const std::string& activityDatabasePath)
{
db = std::unique_ptr<SQLite::Database>(new SQLite::Database(activityDatabasePath, SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE));
db = std::make_unique<SQLite::Database>(activityDatabasePath, SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
db->exec("PRAGMA journal_mode=WAL");
createTables();
query_findValueByName = std::unique_ptr<SQLite::Statement>(new SQLite::Statement(*db, "SELECT value FROM general_kv_storage WHERE name = ?"));
query_insertValueForName = std::unique_ptr<SQLite::Statement>(new SQLite::Statement(*db, "INSERT OR IGNORE INTO general_kv_storage(name, value) VALUES(?, ?)"));
query_updateValueForName = std::unique_ptr<SQLite::Statement>(new SQLite::Statement(*db, "UPDATE general_kv_storage SET value = ? WHERE name = ?"));
query_findValueByName = std::make_unique<SQLite::Statement>(*db, "SELECT value FROM general_kv_storage WHERE name = ?");
query_insertValueForName = std::make_unique<SQLite::Statement>(*db, "INSERT OR IGNORE INTO general_kv_storage(name, value) VALUES(?, ?)");
query_updateValueForName = std::make_unique<SQLite::Statement>(*db, "UPDATE general_kv_storage SET value = ? WHERE name = ?");
}
public:
// Must be thread-safe
Expand Down
Loading
Loading