Explorar o código

Use the "nullptr" literal.

"nullptr" should be used to denote the null pointer
Alexander Wilms %!s(int64=2) %!d(string=hai) anos
pai
achega
f01ec55d21

+ 1 - 1
AI/VCAI/VCAI.h

@@ -260,7 +260,7 @@ public:
 	//optimization - use one SM for every hero call
 
 	const CGTownInstance * findTownWithTavern() const;
-	bool canRecruitAnyHero(const CGTownInstance * t = NULL) const;
+	bool canRecruitAnyHero(const CGTownInstance * t = nullptr) const;
 
 	Goals::TSubgoal getGoal(HeroPtr h) const;
 	bool canAct(HeroPtr h) const;

+ 1 - 1
client/CMT.cpp

@@ -86,7 +86,7 @@ static void prog_version()
 
 static void prog_help(const po::options_description &opts)
 {
-	auto time = std::time(0);
+	auto time = std::time(nullptr);
 	printf("%s - A Heroes of Might and Magic 3 clone\n", GameConstants::VCMI_VERSION.c_str());
 	printf("Copyright (C) 2007-%d VCMI dev team - see AUTHORS file\n", std::localtime(&time)->tm_year + 1900);
 	printf("This is free software; see the source for copying conditions. There is NO\n");

+ 1 - 1
client/CVideoHandler.cpp

@@ -305,7 +305,7 @@ bool CVideoPlayer::nextFrame()
 						sws_scale(sws, frame->data, frame->linesize,
 								  0, codecContext->height, data, linesize);
 
-						SDL_UpdateYUVTexture(texture, NULL, data[0], linesize[0],
+						SDL_UpdateYUVTexture(texture, nullptr, data[0], linesize[0],
 								data[1], linesize[1],
 								data[2], linesize[2]);
 						av_freep(&data[0]);

+ 1 - 1
client/CVideoHandler.h

@@ -31,7 +31,7 @@ public:
 class IMainVideoPlayer : public IVideoPlayer
 {
 public:
-	virtual void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true, std::function<void()> restart = 0){}
+	virtual void update(int x, int y, SDL_Surface *dst, bool forceRedraw, bool update = true, std::function<void()> restart = nullptr){}
 	virtual bool openAndPlayVideo(const VideoPath & name, int x, int y, bool stopOnKey = false, bool scale = false)
 	{
 		return false;

+ 1 - 1
client/mainmenu/CHighScoreScreen.cpp

@@ -264,7 +264,7 @@ int CHighScoreInputScreen::addEntry(std::string text) {
 		newNode["scenarioName"].String() = calc.calculate().cheater ? CGI->generaltexth->translate("core.genrltxt.260") : calc.parameters[0].scenarioName;
 	newNode["days"].Integer() = calc.calculate().sumDays;
 	newNode["points"].Integer() = calc.calculate().cheater ? 0 : calc.calculate().total;
-	newNode["datetime"].String() = vstd::getFormattedDateTime(std::time(0));
+	newNode["datetime"].String() = vstd::getFormattedDateTime(std::time(nullptr));
 	newNode["posFlag"].Bool() = true;
 
 	baseNode.push_back(newNode);

+ 1 - 1
client/renderSDL/CursorSoftware.cpp

@@ -59,7 +59,7 @@ void CursorSoftware::updateTexture()
 	CSDL_Ext::fillSurface(cursorSurface, CSDL_Ext::toSDL(Colors::TRANSPARENCY));
 
 	cursorImage->draw(cursorSurface);
-	SDL_UpdateTexture(cursorTexture, NULL, cursorSurface->pixels, cursorSurface->pitch);
+	SDL_UpdateTexture(cursorTexture, nullptr, cursorSurface->pixels, cursorSurface->pitch);
 	needUpdate = false;
 }
 

+ 3 - 3
client/renderSDL/SDL_Extensions.cpp

@@ -68,7 +68,7 @@ void CSDL_Ext::updateRect(SDL_Surface *surface, const Rect & rect )
 		logGlobal->error("%sSDL_UpdateTexture %s", __FUNCTION__, SDL_GetError());
 
 	SDL_RenderClear(mainRenderer);
-	if(0 != SDL_RenderCopy(mainRenderer, screenTexture, NULL, NULL))
+	if(0 != SDL_RenderCopy(mainRenderer, screenTexture, nullptr, nullptr))
 		logGlobal->error("%sSDL_RenderCopy %s", __FUNCTION__, SDL_GetError());
 	SDL_RenderPresent(mainRenderer);
 
@@ -813,8 +813,8 @@ void CSDL_Ext::fillRectBlended( SDL_Surface *dst, const Rect & dstrect, const SD
 	uint32_t sdlColor = SDL_MapRGBA(dst->format, color.r, color.g, color.b, color.a);
 
 	SDL_Surface * tmp = SDL_CreateRGBSurface(0, newRect.w, newRect.h, dst->format->BitsPerPixel, dst->format->Rmask, dst->format->Gmask, dst->format->Bmask, dst->format->Amask);
-	SDL_FillRect(tmp, NULL, sdlColor);
-	SDL_BlitSurface(tmp, NULL, dst, &newRect);
+	SDL_FillRect(tmp, nullptr, sdlColor);
+	SDL_BlitSurface(tmp, nullptr, dst, &newRect);
 	SDL_FreeSurface(tmp);
 }
 

+ 1 - 1
launcher/aboutProject/aboutproject_moc.h

@@ -23,7 +23,7 @@ class AboutProjectView : public QWidget
 
 	void changeEvent(QEvent *event) override;
 public:
-	explicit AboutProjectView(QWidget * parent = 0);
+	explicit AboutProjectView(QWidget * parent = nullptr);
 
 public slots:
 

+ 1 - 1
launcher/firstLaunch/firstlaunch_moc.h

@@ -67,7 +67,7 @@ class FirstLaunchView : public QWidget
 	void installMod(const QString & modID);
 
 public:
-	explicit FirstLaunchView(QWidget * parent = 0);
+	explicit FirstLaunchView(QWidget * parent = nullptr);
 
 public slots:
 

+ 1 - 1
launcher/lobby/lobby.h

@@ -194,7 +194,7 @@ class SocketLobby : public QObject
 {
 	Q_OBJECT
 public:
-	explicit SocketLobby(QObject *parent = 0);
+	explicit SocketLobby(QObject *parent = nullptr);
 	void connectServer(const QString & host, int port, const QString & username, int timeout);
 	void disconnectServer();
 	void requestNewSession(const QString & session, int totalPlayers, const QString & pswd, const QMap<QString, QString> & mods);

+ 2 - 2
launcher/modManager/cmodlistmodel_moc.h

@@ -56,7 +56,7 @@ class CModListModel : public QAbstractItemModel, public CModList
 	QVariant getIcon(const CModEntry & mod, int field) const;
 
 public:
-	explicit CModListModel(QObject * parent = 0);
+	explicit CModListModel(QObject * parent = nullptr);
 
 	/// CModListContainer overrides
 	void resetRepositories() override;
@@ -93,5 +93,5 @@ class CModFilterModel : public QSortFilterProxyModel
 public:
 	void setTypeFilter(int filteredType, int filterMask);
 
-	CModFilterModel(CModListModel * model, QObject * parent = 0);
+	CModFilterModel(CModListModel * model, QObject * parent = nullptr);
 };

+ 1 - 1
launcher/modManager/cmodlistview_moc.h

@@ -64,7 +64,7 @@ signals:
 	void modsChanged();
 
 public:
-	explicit CModListView(QWidget * parent = 0);
+	explicit CModListView(QWidget * parent = nullptr);
 	~CModListView();
 
 	void loadScreenshots();

+ 2 - 2
launcher/modManager/imageviewer_moc.h

@@ -23,12 +23,12 @@ class ImageViewer : public QDialog
 
 	void changeEvent(QEvent *event) override;
 public:
-	explicit ImageViewer(QWidget * parent = 0);
+	explicit ImageViewer(QWidget * parent = nullptr);
 	~ImageViewer();
 
 	void setPixmap(QPixmap & pixmap);
 
-	static void showPixmap(QPixmap & pixmap, QWidget * parent = 0);
+	static void showPixmap(QPixmap & pixmap, QWidget * parent = nullptr);
 
 protected:
 	void mousePressEvent(QMouseEvent * event) override;

+ 1 - 1
launcher/settingsView/csettingsview_moc.h

@@ -20,7 +20,7 @@ class CSettingsView : public QWidget
 	Q_OBJECT
 
 public:
-	explicit CSettingsView(QWidget * parent = 0);
+	explicit CSettingsView(QWidget * parent = nullptr);
 	~CSettingsView();
 
 	void loadSettings();

+ 1 - 1
lib/CConsoleHandler.cpp

@@ -134,7 +134,7 @@ LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
 	HMODULE hModule = nullptr;
 	GetModuleFileNameA(hModule, buffer, MAX_PATH);
 	mname = strrchr(buffer, '\\');
-	if (mname != 0)
+	if (mname != nullptr)
 		mname++;
 	else
 		mname = buffer;

+ 1 - 1
lib/StartInfo.h

@@ -140,7 +140,7 @@ struct DLL_LINKAGE StartInfo
 	}
 
 	StartInfo() : mode(INVALID), difficulty(1), seedToBeUsed(0), seedPostInit(0),
-		mapfileChecksum(0), startTimeIso8601(vstd::getDateTimeISO8601Basic(std::time(0))), fileURI("")
+		mapfileChecksum(0), startTimeIso8601(vstd::getDateTimeISO8601Basic(std::time(nullptr))), fileURI("")
 	{
 
 	}

+ 1 - 1
lib/gameState/CGameState.cpp

@@ -573,7 +573,7 @@ void CGameState::initNewGame(const IMapService * mapService, bool allowSavingRan
 
 				const std::string templateName = options->getMapTemplate()->getName();
 				const ui32 seed = scenarioOps->seedToBeUsed;
-				const std::string dt = vstd::getDateTimeISO8601Basic(std::time(0));
+				const std::string dt = vstd::getDateTimeISO8601Basic(std::time(nullptr));
 
 				const std::string fileName = boost::str(boost::format("%s_%s_%d.vmap") % dt % templateName % seed );
 				const auto fullPath = path / fileName;

+ 1 - 1
lib/serializer/CSerializer.h

@@ -54,7 +54,7 @@ struct VectorizedObjectInfo
 class DLL_LINKAGE CSerializer
 {
 	template<typename T>
-	static si32 idToNumber(const T &t, typename std::enable_if<std::is_convertible<T,si32>::value>::type * dummy = 0)
+	static si32 idToNumber(const T &t, typename std::enable_if<std::is_convertible<T,si32>::value>::type * dummy = nullptr)
 	{
 		return t;
 	}

+ 3 - 3
server/CVCMIServer.cpp

@@ -317,7 +317,7 @@ bool CVCMIServer::prepareToStartGame()
 	{
 	case StartInfo::CAMPAIGN:
 		logNetwork->info("Preparing to start new campaign");
-		si->startTimeIso8601 = vstd::getDateTimeISO8601Basic(std::time(0));
+		si->startTimeIso8601 = vstd::getDateTimeISO8601Basic(std::time(nullptr));
 		si->fileURI = mi->fileURI;
 		si->campState->setCurrentMap(campaignMap);
 		si->campState->setCurrentMapBonus(campaignBonus);
@@ -326,7 +326,7 @@ bool CVCMIServer::prepareToStartGame()
 
 	case StartInfo::NEW_GAME:
 		logNetwork->info("Preparing to start new game");
-		si->startTimeIso8601 = vstd::getDateTimeISO8601Basic(std::time(0));
+		si->startTimeIso8601 = vstd::getDateTimeISO8601Basic(std::time(nullptr));
 		si->fileURI = mi->fileURI;
 		gh->init(si.get(), progressTracking);
 		break;
@@ -1125,7 +1125,7 @@ static void handleCommandOptions(int argc, const char * argv[], boost::program_o
 #ifndef SINGLE_PROCESS_APP
 	if(options.count("help"))
 	{
-		auto time = std::time(0);
+		auto time = std::time(nullptr);
 		printf("%s - A Heroes of Might and Magic 3 clone\n", GameConstants::VCMI_VERSION.c_str());
 		printf("Copyright (C) 2007-%d VCMI dev team - see AUTHORS file\n", std::localtime(&time)->tm_year + 1900);
 		printf("This is free software; see the source for copying conditions. There is NO\n");