Index: source/collada/CommonConvert.cpp =================================================================== --- source/collada/CommonConvert.cpp +++ source/collada/CommonConvert.cpp @@ -65,7 +65,7 @@ FColladaErrorHandler::~FColladaErrorHandler() { - xmlSetGenericErrorFunc(NULL, NULL); + xmlSetGenericErrorFunc(nullptr, nullptr); FUError::RemoveErrorCallback(FUError::DEBUG_LEVEL, this, &FColladaErrorHandler::OnError); FUError::RemoveErrorCallback(FUError::WARNING_LEVEL, this, &FColladaErrorHandler::OnError); @@ -97,7 +97,7 @@ { document.reset(FCollada::NewTopDocument()); - const char* newText = NULL; + const char* newText = nullptr; size_t newTextSize = 0; FixBrokenXML(text, &newText, &newTextSize); @@ -140,7 +140,7 @@ { m_Doc.LoadFromText(text); FCDSceneNode* root = m_Doc.GetDocument()->GetVisualSceneRoot(); - REQUIRE(root != NULL, "has root object"); + REQUIRE(root != nullptr, "has root object"); // Find the instance to convert if (! FindSingleInstance(root, m_Instance, m_EntityTransform)) @@ -384,13 +384,13 @@ // so just choose an arbitrary bone and search upwards until we find a // recognised ancestor (or until we fall off the top of the tree) - const Skeleton* skeleton = NULL; + const Skeleton* skeleton = nullptr; const FCDSceneNode* joint = controllerInstance.GetJoint(0); - while (joint && (skeleton = Skeleton::FindSkeleton(joint->GetName().c_str())) == NULL) + while (joint && (skeleton = Skeleton::FindSkeleton(joint->GetName().c_str())) == nullptr) { joint = joint->GetParent(); } - REQUIRE(skeleton != NULL, "recognised skeleton structure"); + REQUIRE(skeleton != nullptr, "recognised skeleton structure"); return *skeleton; } Index: source/collada/DLL.cpp =================================================================== --- source/collada/DLL.cpp +++ source/collada/DLL.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -31,7 +31,7 @@ } static LogFn g_Logger = &default_logger; -static void* g_LoggerCBData = NULL; +static void* g_LoggerCBData = nullptr; EXPORT void set_logger(LogFn logger, void* cb_data) { @@ -43,7 +43,7 @@ else { g_Logger = &default_logger; - g_LoggerCBData = NULL; + g_LoggerCBData = nullptr; } } Index: source/collada/GeomReindex.cpp =================================================================== --- source/collada/GeomReindex.cpp +++ source/collada/GeomReindex.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -186,11 +186,11 @@ if (skin) { FCDSkinControllerVertex* influences = skin->GetVertexInfluence(indicesPosition[i]); - assert(influences != NULL); + assert(influences != nullptr); for (size_t j = 0; j < influences->GetPairCount(); ++j) { FCDJointWeightPair* pair = influences->GetPair(j); - assert(pair != NULL); + assert(pair != nullptr); weights.push_back(*pair); } CanonicaliseWeights(weights); Index: source/collada/PMDConvert.cpp =================================================================== --- source/collada/PMDConvert.cpp +++ source/collada/PMDConvert.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -212,7 +212,7 @@ FCDController* controller = static_cast(converter.GetInstance().GetEntity()); FCDSkinController* skin = controller->GetSkinController(); - REQUIRE(skin != NULL, "is skin controller"); + REQUIRE(skin != nullptr, "is skin controller"); FixSkeletonRoots(controllerInstance); @@ -232,7 +232,7 @@ // Get the skinned mesh for this entity FCDGeometry* baseGeometry = controller->GetBaseGeometry(); - REQUIRE(baseGeometry != NULL, "controller has base geometry"); + REQUIRE(baseGeometry != nullptr, "controller has base geometry"); FCDGeometryPolygons* polys = GetPolysFromGeometry(baseGeometry); // Make sure it doesn't use more bones per vertex than the game can handle @@ -298,7 +298,7 @@ REQUIRE(jointIdx < 0xFE, "sensible number of joints (<254)"); // Find the joint on the skeleton, after checking it really exists - FCDSceneNode* joint = NULL; + FCDSceneNode* joint = nullptr; if (jointIdx < controllerInstance.GetJointCount()) joint = controllerInstance.GetJoint(jointIdx); @@ -569,9 +569,9 @@ REQUIRE(mesh->IsTriangles(), "mesh is made of triangles"); REQUIRE(mesh->GetPolygonsCount() == 1, "mesh has single set of polygons"); FCDGeometryPolygons* polys = mesh->GetPolygons(0); - REQUIRE(polys->FindInput(FUDaeGeometryInput::POSITION) != NULL, "mesh has vertex positions"); - REQUIRE(polys->FindInput(FUDaeGeometryInput::NORMAL) != NULL, "mesh has vertex normals"); - REQUIRE(polys->FindInput(FUDaeGeometryInput::TEXCOORD) != NULL, "mesh has vertex tex coords"); + REQUIRE(polys->FindInput(FUDaeGeometryInput::POSITION) != nullptr, "mesh has vertex positions"); + REQUIRE(polys->FindInput(FUDaeGeometryInput::NORMAL) != nullptr, "mesh has vertex normals"); + REQUIRE(polys->FindInput(FUDaeGeometryInput::TEXCOORD) != nullptr, "mesh has vertex tex coords"); return polys; } Index: source/collada/PSAConvert.cpp =================================================================== --- source/collada/PSAConvert.cpp +++ source/collada/PSAConvert.cpp @@ -72,7 +72,7 @@ FCDController* controller = static_cast(converter.GetInstance().GetEntity()); FCDSkinController* skin = controller->GetSkinController(); - REQUIRE(skin != NULL, "is skin controller"); + REQUIRE(skin != nullptr, "is skin controller"); const Skeleton& skeleton = FindSkeleton(controllerInstance); @@ -220,7 +220,7 @@ for (size_t i = 0; i < controllerInstance.GetJointCount(); ++i) { const FCDSceneNode* joint = controllerInstance.GetJoint(i); - REQUIRE(joint != NULL, "joint exists"); + REQUIRE(joint != nullptr, "joint exists"); int boneId = skeleton.GetBoneID(joint->GetName().c_str()); if (boneId < 0) Index: source/collada/StdSkeletons.h =================================================================== --- source/collada/StdSkeletons.h +++ source/collada/StdSkeletons.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -77,7 +77,7 @@ /** * Tries to find a skeleton that matches the given root bone name. - * Returns NULL if there is no match. + * Returns nullptr if there is no match. */ static const Skeleton* FindSkeleton(const std::string& rootBoneName); Index: source/collada/StdSkeletons.cpp =================================================================== --- source/collada/StdSkeletons.cpp +++ source/collada/StdSkeletons.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -156,9 +156,9 @@ if (IsEquivalent((*skeletonNode)->name, "standard_skeleton")) { - skeleton->m->target = NULL; + skeleton->m->target = nullptr; - LoadSkeletonBones(*skeletonNode, skeleton->m->bones, NULL, ""); + LoadSkeletonBones(*skeletonNode, skeleton->m->bones, nullptr, ""); std::string id (FUXmlParser::ReadNodeProperty(*skeletonNode, "id")); REQUIRE(! id.empty(), "standard_skeleton has id"); @@ -172,7 +172,7 @@ std::string target (FUXmlParser::ReadNodeProperty(*skeletonNode, "target")); const Skeleton* targetSkeleton = g_StandardSkeletons[target]; - REQUIRE(targetSkeleton != NULL, "skeleton target matches some standard_skeleton id"); + REQUIRE(targetSkeleton != nullptr, "skeleton target matches some standard_skeleton id"); skeleton->m->target = targetSkeleton; @@ -181,9 +181,9 @@ // Currently the only supported identifier is a precise name match, // so just look for that xmlNode* identifier = FUXmlParser::FindChildByType(*skeletonNode, "identifier"); - REQUIRE(identifier != NULL, "skeleton has "); + REQUIRE(identifier != nullptr, "skeleton has "); xmlNode* identRoot = FUXmlParser::FindChildByType(identifier, "root"); - REQUIRE(identRoot != NULL, "skeleton identifier has "); + REQUIRE(identRoot != nullptr, "skeleton identifier has "); std::string identRootName (FUXmlParser::ReadNodeContentFull(identRoot)); g_MappedSkeletons[identRootName] = skeleton.release(); @@ -196,7 +196,7 @@ void Skeleton::LoadSkeletonDataFromXml(const char* xmlData, size_t xmlLength, std::string& xmlErrors) { - xmlDoc* doc = NULL; + xmlDoc* doc = nullptr; try { xmlSetGenericErrorFunc(&xmlErrors, &errorHandler); @@ -206,15 +206,15 @@ xmlNode* root = xmlDocGetRootElement(doc); LoadSkeletonData(root); xmlFreeDoc(doc); - doc = NULL; + doc = nullptr; } - xmlSetGenericErrorFunc(NULL, NULL); + xmlSetGenericErrorFunc(nullptr, nullptr); } catch (const ColladaException&) { if (doc) xmlFreeDoc(doc); - xmlSetGenericErrorFunc(NULL, NULL); + xmlSetGenericErrorFunc(nullptr, nullptr); throw; } Index: source/collada/XMLFix.cpp =================================================================== --- source/collada/XMLFix.cpp +++ source/collada/XMLFix.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -60,7 +60,7 @@ if (child->type == XML_ELEMENT_NODE && strcmp((const char*)child->name, name) == 0) return child; } - return NULL; + return nullptr; } static bool applyFBXFixesNode(xmlNode* node) @@ -173,7 +173,7 @@ { // Reserialising the document, then parsing it again inside FCollada, is a bit ugly; // but it's the only way I can see to make it work through FCollada's public API - xmlChar* mem = NULL; + xmlChar* mem = nullptr; int size = -1; xmlDocDumpFormatMemory(doc, &mem, &size, 0); *out = (const char*)mem; Index: source/graphics/ColladaManager.cpp =================================================================== --- source/graphics/ColladaManager.cpp +++ source/graphics/ColladaManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -76,7 +76,7 @@ ~CColladaManagerImpl() { if (dll.IsLoaded()) - set_logger(NULL, NULL); // unregister the log handler + set_logger(nullptr, nullptr); // unregister the log handler UnregisterFileReloadFunc(ReloadChangedFileCB, this); } @@ -283,7 +283,7 @@ for (const VfsPath& path : paths) { // This will cause an assertion failure if *it doesn't exist, - // because fileinfo is not a NULL pointer, which is annoying but that + // because fileinfo is not a nullptr pointer, which is annoying but that // should never happen, unless there really is a problem if (m_VFS->GetFileInfo(path, &fileInfo) != INFO::OK) { @@ -390,7 +390,7 @@ // Check if source (uncached) .pmd/psa exists sourcePath = pathnameNoExtension.ChangeExtension(extn); - if (m_VFS->GetFileInfo(sourcePath, NULL) != INFO::OK) + if (m_VFS->GetFileInfo(sourcePath, nullptr) != INFO::OK) { // Broken reference, the caller will need to handle this return L""; Index: source/graphics/Decal.h =================================================================== --- source/graphics/Decal.h +++ source/graphics/Decal.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -53,7 +53,7 @@ CModelDecal(CTerrain* terrain, const SDecal& decal) : m_Terrain(terrain), m_Decal(decal) { - ENSURE(terrain != NULL); + ENSURE(terrain != nullptr); } /// Dynamic cast Index: source/graphics/Font.h =================================================================== --- source/graphics/Font.h +++ source/graphics/Font.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -46,7 +46,7 @@ * Relatively efficient lookup of GlyphData from 16-bit Unicode codepoint. * This is stored as a sparse 2D array, exploiting the knowledge that a font * typically only supports a small number of 256-codepoint blocks, so most - * elements of m_Data will be NULL. + * elements of m_Data will be nullptr. */ class GlyphMap { @@ -59,9 +59,9 @@ const GlyphData* get(u16 i) const { if (!m_Data[i >> 8]) - return NULL; + return nullptr; if (!m_Data[i >> 8][i & 0xff].defined) - return NULL; + return nullptr; return &m_Data[i >> 8][i & 0xff]; } Index: source/graphics/HFTracer.h =================================================================== --- source/graphics/HFTracer.h +++ source/graphics/HFTracer.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -44,7 +44,7 @@ * (not required to be a unit vector).. The patch is treated as a collection * of two-sided triangles, corresponding to the terrain tiles. * - * If there is an intersection, returns true; and if @p out is not NULL, it + * If there is an intersection, returns true; and if @p out is not nullptr, it * is set to the intersection point. This is guaranteed to be the earliest * tile intersected (starting at @p origin), but not necessarily the earlier * triangle inside that tile. Index: source/graphics/MapGenerator.cpp =================================================================== --- source/graphics/MapGenerator.cpp +++ source/graphics/MapGenerator.cpp @@ -65,7 +65,7 @@ CMapGeneratorWorker::~CMapGeneratorWorker() { // Wait for thread to end - pthread_join(m_WorkerThread, NULL); + pthread_join(m_WorkerThread, nullptr); } void CMapGeneratorWorker::Initialize(const VfsPath& scriptFile, const std::string& settings) @@ -78,7 +78,7 @@ m_Settings = settings; // Launch the worker thread - int ret = pthread_create(&m_WorkerThread, NULL, &RunThread, this); + int ret = pthread_create(&m_WorkerThread, nullptr, &RunThread, this); ENSURE(ret == 0); } @@ -108,7 +108,7 @@ // and can die. The data will be stored in m_MapData already if successful, or m_Progress // will contain an error value on failure. - return NULL; + return nullptr; } bool CMapGeneratorWorker::Run() Index: source/graphics/MapReader.cpp =================================================================== --- source/graphics/MapReader.cpp +++ source/graphics/MapReader.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -149,7 +149,7 @@ { m_ScriptFile = scriptFile; pSimulation2 = pSimulation2_; - pSimContext = pSimulation2 ? &pSimulation2->GetSimContext() : NULL; + pSimContext = pSimulation2 ? &pSimulation2->GetSimContext() : nullptr; m_ScriptSettings.init(rt, settings); pTerrain = pTerrain_; pLightEnv = pLightEnv_; @@ -393,7 +393,7 @@ NONCOPYABLE(CXMLReader); public: CXMLReader(const VfsPath& xml_filename, CMapReader& mapReader) - : m_MapReader(mapReader), nodes(NULL, 0, NULL) + : m_MapReader(mapReader), nodes(nullptr, 0, nullptr) { Init(xml_filename); } @@ -543,7 +543,7 @@ ENSURE(CTerrainTextureManager::IsInitialised()); // we need this for the terrain properties (even when graphics are disabled) CTerrainTextureEntry* texentry = g_TexMan.FindTexture(texture); - m_MapReader.pTerrain->Initialize(patches, NULL); + m_MapReader.pTerrain->Initialize(patches, nullptr); // Fill the heightmap u16* heightmap = m_MapReader.pTerrain->GetHeightMap(); Index: source/graphics/MiniPatch.cpp =================================================================== --- source/graphics/MiniPatch.cpp +++ source/graphics/MiniPatch.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -26,6 +26,6 @@ /////////////////////////////////////////////////////////////////////////////// // Constructor CMiniPatch::CMiniPatch() : - Tex(NULL), Priority(0) + Tex(nullptr), Priority(0) { } Index: source/graphics/Model.h =================================================================== --- source/graphics/Model.h +++ source/graphics/Model.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -186,9 +186,9 @@ /** * Return whether this is a skinned/skeletal model. If it is, Get*BoneMatrices() - * will return valid non-NULL arrays. + * will return valid non-nullptr arrays. */ - bool IsSkinned() { return (m_BoneMatrices != NULL); } + bool IsSkinned() { return (m_BoneMatrices != nullptr); } // return the models bone matrices; 16-byte aligned for SSE reads const CMatrix3D* GetAnimatedBoneMatrices() { @@ -207,7 +207,7 @@ * @param actionpos offset of 'action' event, in range [0, 1] * @param actionpos2 offset of 'action2' event, in range [0, 1] * @param sound offset of 'sound' event, in range [0, 1] - * @return new animation, or NULL on error + * @return new animation, or nullptr on error */ CSkeletonAnim* BuildAnimation(const VfsPath& pathname, const CStr& name, const CStr& ID, int frequency, float speed, float actionpos, float actionpos2, float soundpos); @@ -291,12 +291,12 @@ std::vector m_Props; /** - * The prop point to which the ammo prop is attached, or NULL if none + * The prop point to which the ammo prop is attached, or nullptr if none */ const SPropPoint* m_AmmoPropPoint; /** - * If m_AmmoPropPoint is not NULL, then the index in m_Props of the ammo prop + * If m_AmmoPropPoint is not nullptr, then the index in m_Props of the ammo prop */ size_t m_AmmoLoadedProp; Index: source/graphics/Model.cpp =================================================================== --- source/graphics/Model.cpp +++ source/graphics/Model.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -45,8 +45,8 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // Constructor CModel::CModel(CSkeletonAnimManager& skeletonAnimManager, CSimulation2& simulation) - : m_Flags(0), m_Anim(NULL), m_AnimTime(0), m_Simulation(simulation), - m_BoneMatrices(NULL), m_AmmoPropPoint(NULL), m_AmmoLoadedProp(0), + : m_Flags(0), m_Anim(nullptr), m_AnimTime(0), m_Simulation(simulation), + m_BoneMatrices(nullptr), m_AmmoPropPoint(nullptr), m_AmmoLoadedProp(0), m_SkeletonAnimManager(skeletonAnimManager) { } @@ -259,7 +259,7 @@ { CSkeletonAnimDef* def = m_SkeletonAnimManager.GetAnimation(pathname); if (!def) - return NULL; + return nullptr; CSkeletonAnim* anim = new CSkeletonAnim(); anim->m_Name = name; @@ -450,7 +450,7 @@ // return false on error, else true bool CModel::SetAnimation(CSkeletonAnim* anim, bool once) { - m_Anim = NULL; // in case something fails + m_Anim = nullptr; // in case something fails if (anim) { @@ -542,7 +542,7 @@ void CModel::ShowAmmoProp() { - if (m_AmmoPropPoint == NULL) + if (m_AmmoPropPoint == nullptr) return; // Show the ammo prop, hide all others on the same prop point @@ -557,7 +557,7 @@ void CModel::HideAmmoProp() { - if (m_AmmoPropPoint == NULL) + if (m_AmmoPropPoint == nullptr) return; // Hide the ammo prop, show all others on the same prop point @@ -586,7 +586,7 @@ } } - return NULL; + return nullptr; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////// Index: source/graphics/ModelAbstract.h =================================================================== --- source/graphics/ModelAbstract.h +++ source/graphics/ModelAbstract.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -61,8 +61,8 @@ public: CModelAbstract() - : m_Parent(NULL), m_PositionValid(false), m_ShadingColor(1, 1, 1, 1), m_PlayerID(INVALID_PLAYER), - m_SelectionBoxValid(false), m_CustomSelectionShape(NULL) + : m_Parent(nullptr), m_PositionValid(false), m_ShadingColor(1, 1, 1, 1), m_PlayerID(INVALID_PLAYER), + m_SelectionBoxValid(false), m_CustomSelectionShape(nullptr) { } ~CModelAbstract() @@ -73,13 +73,13 @@ virtual CModelAbstract* Clone() const = 0; /// Dynamic cast - virtual CModel* ToCModel() { return NULL; } + virtual CModel* ToCModel() { return nullptr; } /// Dynamic cast - virtual CModelDecal* ToCModelDecal() { return NULL; } + virtual CModelDecal* ToCModelDecal() { return nullptr; } /// Dynamic cast - virtual CModelParticleEmitter* ToCModelParticleEmitter() { return NULL; } + virtual CModelParticleEmitter* ToCModelParticleEmitter() { return nullptr; } // (This dynamic casting is a bit ugly, but we won't have many subclasses // and this seems the easiest way to integrate with other code that wants @@ -105,7 +105,7 @@ m_SelectionBoxValid = false; } - /// Sets a custom selection shape as described by a @p descriptor. Argument may be NULL + /// Sets a custom selection shape as described by a @p descriptor. Argument may be nullptr /// if you wish to keep the default behaviour of using the recursively-calculated bounding boxes. void SetCustomSelectionShape(CustomSelectionShape* descriptor) { @@ -180,7 +180,7 @@ /// Is the current selection box valid? bool m_SelectionBoxValid; - /// Pointer to a descriptor for a custom-defined selection box shape. If no custom selection box is required, this is NULL + /// Pointer to a descriptor for a custom-defined selection box shape. If no custom selection box is required, this is nullptr /// and the standard recursive-bounding-box-based selection box is used. Otherwise, a custom selection box described by this /// field will be used. /// @see SetCustomSelectionShape Index: source/graphics/ModelDef.h =================================================================== --- source/graphics/ModelDef.h +++ source/graphics/ModelDef.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -156,7 +156,7 @@ * Loads a PMD file. * @param filename VFS path of .pmd file to load * @param name arbitrary name to give the model for debugging purposes (usually pathname) - * @return the model - always non-NULL + * @return the model - always non-nullptr * @throw PSERROR_File if it can't load the model */ static CModelDef* Load(const VfsPath& filename, const VfsPath& name); Index: source/graphics/ModelDef.cpp =================================================================== --- source/graphics/ModelDef.cpp +++ source/graphics/ModelDef.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -227,7 +227,7 @@ // CModelDef Constructor CModelDef::CModelDef() : m_NumVertices(0), m_NumUVsPerVertex(0), m_pVertices(0), m_NumFaces(0), m_pFaces(0), - m_NumBones(0), m_Bones(0), m_InverseBindBoneMatrices(NULL), + m_NumBones(0), m_Bones(0), m_InverseBindBoneMatrices(nullptr), m_NumBlends(0), m_pBlends(0), m_pBlendIndices(0), m_Name(L"[not loaded]") { Index: source/graphics/ObjectEntry.cpp =================================================================== --- source/graphics/ObjectEntry.cpp +++ source/graphics/ObjectEntry.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -40,7 +40,7 @@ #include CObjectEntry::CObjectEntry(CObjectBase* base, CSimulation2& simulation) : - m_Base(base), m_Color(1.0f, 1.0f, 1.0f, 1.0f), m_Model(NULL), m_Outdated(false), m_Simulation(simulation) + m_Base(base), m_Color(1.0f, 1.0f, 1.0f, 1.0f), m_Model(nullptr), m_Outdated(false), m_Simulation(simulation) { } @@ -180,7 +180,7 @@ CSkeletonAnim* anim = new CSkeletonAnim(); anim->m_Name = "idle"; anim->m_ID = ""; - anim->m_AnimDef = NULL; + anim->m_AnimDef = nullptr; anim->m_Frequency = 0; anim->m_Speed = 0.f; anim->m_ActionPos = 0.f; @@ -273,7 +273,7 @@ if (r < 0) return anim; } - return NULL; + return nullptr; } std::vector CObjectEntry::GetAnimations(const CStr& animationName, const CStr& ID) const Index: source/graphics/ObjectManager.cpp =================================================================== --- source/graphics/ObjectManager.cpp +++ source/graphics/ObjectManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -103,7 +103,7 @@ CObjectBase* base = FindObjectBase(objname); if (! base) - return NULL; + return nullptr; return FindObjectVariation(base, selections); } @@ -139,7 +139,7 @@ if (! obj->BuildVariation(selections, choices, *this)) { DeleteObject(obj); - return NULL; + return nullptr; } m_Objects[key] = obj; @@ -151,7 +151,7 @@ { CmpPtr cmpTerrain(m_Simulation, SYSTEM_ENTITY); if (!cmpTerrain) - return NULL; + return nullptr; return cmpTerrain->GetCTerrain(); } Index: source/graphics/Overlay.h =================================================================== --- source/graphics/Overlay.h +++ source/graphics/Overlay.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -79,7 +79,7 @@ SOverlayTexturedLine() : m_Thickness(1.0f), m_Closed(false), m_AlwaysVisible(false), - m_StartCapType(LINECAP_FLAT), m_EndCapType(LINECAP_FLAT), m_SimContext(NULL) + m_StartCapType(LINECAP_FLAT), m_EndCapType(LINECAP_FLAT), m_SimContext(nullptr) { } CTexturePtr m_TextureBase; Index: source/graphics/ShaderProgram.cpp =================================================================== --- source/graphics/ShaderProgram.cpp +++ source/graphics/ShaderProgram.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -307,7 +307,7 @@ if (length > 1) { char* infolog = new char[length]; - pglGetShaderInfoLog(shader, length, NULL, infolog); + pglGetShaderInfoLog(shader, length, nullptr, infolog); if (ok) LOGMESSAGE("Info when compiling shader '%s':\n%s", file.string8(), infolog); @@ -354,7 +354,7 @@ if (length > 1) { char* infolog = new char[length]; - pglGetProgramInfoLog(m_Program, length, NULL, infolog); + pglGetProgramInfoLog(m_Program, length, nullptr, infolog); if (ok) LOGMESSAGE("Info when linking program '%s'+'%s':\n%s", m_VertexFile.string8(), m_FragmentFile.string8(), infolog); @@ -665,7 +665,7 @@ { LOGERROR("CShaderProgram::ConstructARB: '%s'+'%s': ARB shaders not supported on this device", vertexFile.string8(), fragmentFile.string8()); - return NULL; + return nullptr; } #else /*static*/ CShaderProgram* CShaderProgram::ConstructARB(const VfsPath& vertexFile, const VfsPath& fragmentFile, Index: source/graphics/ShaderProgramFFP.cpp =================================================================== --- source/graphics/ShaderProgramFFP.cpp +++ source/graphics/ShaderProgramFFP.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -1164,7 +1164,7 @@ LOGERROR("CShaderProgram::ConstructFFP: '%s': Invalid id", id.c_str()); debug_warn(L"CShaderProgram::ConstructFFP: Invalid id"); - return NULL; + return nullptr; } #else // CONFIG2_GLES @@ -1172,7 +1172,7 @@ /*static*/ CShaderProgram* CShaderProgram::ConstructFFP(const std::string& UNUSED(id), const CShaderDefines& UNUSED(defines)) { debug_warn(L"CShaderProgram::ConstructFFP: FFP not supported on this device"); - return NULL; + return nullptr; } #endif // CONFIG2_GLES Index: source/graphics/SkeletonAnim.h =================================================================== --- source/graphics/SkeletonAnim.h +++ source/graphics/SkeletonAnim.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -38,10 +38,10 @@ CStr m_ID = ""; // frequency of the animation int m_Frequency; - // the raw animation frame data; may be NULL if this is a static 'animation' + // the raw animation frame data; may be nullptr if this is a static 'animation' CSkeletonAnimDef* m_AnimDef; // speed at which this animation runs, as a factor of the AnimDef default speed - // (treated as 0 if m_AnimDef == NULL) + // (treated as 0 if m_AnimDef == nullptr) float m_Speed; // Times during the animation at which the interesting bits happen, // as msec times in the range [0, AnimDef->GetDuration], Index: source/graphics/SkeletonAnimManager.h =================================================================== --- source/graphics/SkeletonAnimManager.h +++ source/graphics/SkeletonAnimManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -47,7 +47,7 @@ CSkeletonAnimDef* GetAnimation(const VfsPath& pathname); private: - // map of all known animations. Value is NULL if it failed to load. + // map of all known animations. Value is nullptr if it failed to load. boost::unordered_map m_Animations; CColladaManager& m_ColladaManager; Index: source/graphics/SkeletonAnimManager.cpp =================================================================== --- source/graphics/SkeletonAnimManager.cpp +++ source/graphics/SkeletonAnimManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -58,7 +58,7 @@ if (iter != m_Animations.end()) return iter->second; - CSkeletonAnimDef* def = NULL; + CSkeletonAnimDef* def = nullptr; // Find the file to load VfsPath psaFilename = m_ColladaManager.GetLoadablePath(name, CColladaManager::PSA); @@ -66,7 +66,7 @@ if (psaFilename.empty()) { LOGERROR("Could not load animation '%s'", pathname.string8()); - def = NULL; + def = nullptr; } else { @@ -86,6 +86,6 @@ LOGERROR("CSkeletonAnimManager::GetAnimation(%s): Failed loading, marked file as bad", pathname.string8()); // Add to map - m_Animations[name] = def; // NULL if failed to load - we won't try loading it again + m_Animations[name] = def; // nullptr if failed to load - we won't try loading it again return def; } Index: source/graphics/TerrainProperties.h =================================================================== --- source/graphics/TerrainProperties.h +++ source/graphics/TerrainProperties.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -69,9 +69,9 @@ public: CTerrainProperties(CTerrainPropertiesPtr parent); - // Create a new object and load the XML file specified. Returns NULL upon + // Create a new object and load the XML file specified. Returns nullptr upon // failure - // The parent pointer may be NULL, for the "root" terrainproperties object. + // The parent pointer may be nullptr, for the "root" terrainproperties object. static CTerrainPropertiesPtr FromXML(const CTerrainPropertiesPtr& parent, const VfsPath& pathname); void LoadXml(XMBElement node, CXeromyces *pFile, const VfsPath& pathname); Index: source/graphics/TextRenderer.h =================================================================== --- source/graphics/TextRenderer.h +++ source/graphics/TextRenderer.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -121,7 +121,7 @@ SBatchRun& operator=(const SBatchRun&); public: SBatchRun() - : text(NULL), owned(false) + : text(nullptr), owned(false) { } Index: source/graphics/TextureConverter.h =================================================================== --- source/graphics/TextureConverter.h +++ source/graphics/TextureConverter.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -161,7 +161,7 @@ /** * Load a texture conversion settings XML file. - * Returns NULL on failure. + * Returns nullptr on failure. */ SettingsFile* LoadSettings(const VfsPath& path) const; Index: source/graphics/TextureConverter.cpp =================================================================== --- source/graphics/TextureConverter.cpp +++ source/graphics/TextureConverter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -97,7 +97,7 @@ { CXeromyces XeroFile; if (XeroFile.Load(m_VFS, path, "texture") != PSRETURN_OK) - return NULL; + return nullptr; // Define all the elements used in the XML file #define EL(x) int el_##x = XeroFile.GetElementID(#x) @@ -121,7 +121,7 @@ if (root.GetNodeName() != el_textures) { LOGERROR("Invalid texture settings file \"%s\" (unrecognised root element)", path.string8()); - return NULL; + return nullptr; } std::unique_ptr settings(new SettingsFile()); @@ -292,10 +292,10 @@ m_WorkerSem = SDL_CreateSemaphore(0); ENSURE(m_WorkerSem); - ret = pthread_mutex_init(&m_WorkerMutex, NULL); + ret = pthread_mutex_init(&m_WorkerMutex, nullptr); ENSURE(ret == 0); - ret = pthread_create(&m_WorkerThread, NULL, &RunThread, this); + ret = pthread_create(&m_WorkerThread, nullptr, &RunThread, this); ENSURE(ret == 0); // Maybe we should share some centralised pool of worker threads? @@ -313,7 +313,7 @@ SDL_SemPost(m_WorkerSem); // Wait for it to shut down cleanly - pthread_join(m_WorkerThread, NULL); + pthread_join(m_WorkerThread, nullptr); // Clean up resources SDL_DestroySemaphore(m_WorkerSem); @@ -602,5 +602,5 @@ #endif - return NULL; + return nullptr; } Index: source/graphics/TextureManager.cpp =================================================================== --- source/graphics/TextureManager.cpp +++ source/graphics/TextureManager.cpp @@ -197,7 +197,7 @@ // Get some flags for later use size_t flags = 0; - (void)ogl_tex_get_format(h, &flags, NULL); + (void)ogl_tex_get_format(h, &flags, nullptr); // Initialise base color from the texture (void)ogl_tex_get_average_color(h, &texture->m_BaseColor); @@ -449,7 +449,7 @@ /** * Return the (cached) settings file with the given filename, - * or NULL if it doesn't exist. + * or nullptr if it doesn't exist. */ CTextureConverter::SettingsFile* GetSettingsFile(const VfsPath& path) { @@ -457,7 +457,7 @@ if (it != m_SettingsFiles.end()) return it->second.get(); - if (m_VFS->GetFileInfo(path, NULL) >= 0) + if (m_VFS->GetFileInfo(path, nullptr) >= 0) { shared_ptr settings(m_TextureConverter.LoadSettings(path)); m_SettingsFiles.insert(std::make_pair(path, settings)); @@ -466,7 +466,7 @@ else { m_SettingsFiles.insert(std::make_pair(path, shared_ptr())); - return NULL; + return nullptr; } } Index: source/graphics/Unit.h =================================================================== --- source/graphics/Unit.h +++ source/graphics/Unit.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -45,7 +45,7 @@ // Attempt to create a unit with the given actor, with a set of // suggested selections (with the rest being randomised using the // given random seed). - // Returns NULL on failure. + // Returns nullptr on failure. static CUnit* Create(const CStrW& actorName, uint32_t seed, const std::set& selections, CObjectManager& objectManager); // destructor @@ -80,9 +80,9 @@ void SetActorSelections(const std::set& selections); private: - // object from which unit was created; never NULL + // object from which unit was created; never nullptr CObjectEntry* m_Object; - // object model representation; never NULL + // object model representation; never nullptr CModelAbstract* m_Model; CUnitAnimation* m_Animation; Index: source/graphics/Unit.cpp =================================================================== --- source/graphics/Unit.cpp +++ source/graphics/Unit.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ if (m_Model->ToCModel()) m_Animation = new CUnitAnimation(m_ID, m_Model->ToCModel(), m_Object); else - m_Animation = NULL; + m_Animation = nullptr; } CUnit::~CUnit() @@ -49,7 +49,7 @@ CObjectBase* base = objectManager.FindObjectBase(actorName); if (! base) - return NULL; + return nullptr; std::set actorSelections = base->CalculateRandomVariation(seed, selections); @@ -59,7 +59,7 @@ CObjectEntry* obj = objectManager.FindObjectVariation(base, selectionsVec); if (! obj) - return NULL; + return nullptr; return new CUnit(obj, objectManager, actorSelections, seed); } Index: source/graphics/UnitAnimation.cpp =================================================================== --- source/graphics/UnitAnimation.cpp +++ source/graphics/UnitAnimation.cpp @@ -64,7 +64,7 @@ state.pastActionPos = false; state.pastSoundPos = false; - ENSURE(state.anim != NULL); // there must always be an idle animation + ENSURE(state.anim != nullptr); // there must always be an idle animation m_AnimStates.push_back(state); @@ -72,7 +72,7 @@ // Detect if this unit has any non-static animations for (CSkeletonAnim* anim : object->GetAnimations(m_State)) - if (anim->m_AnimDef != NULL) + if (anim->m_AnimDef != nullptr) m_AnimStatesAreStatic = false; // Recursively add all props @@ -132,7 +132,7 @@ for (std::vector::iterator it = m_AnimStates.begin(); it != m_AnimStates.end(); ++it) { CSkeletonAnimDef* animDef = it->anim->m_AnimDef; - if (animDef == NULL) + if (animDef == nullptr) continue; // ignore static animations float duration = animDef->GetDuration(); @@ -165,7 +165,7 @@ for (std::vector::iterator it = m_AnimStates.begin(); it != m_AnimStates.end(); ++it) { CSkeletonAnimDef* animDef = it->anim->m_AnimDef; - if (animDef == NULL) + if (animDef == nullptr) continue; // ignore static animations float duration = animDef->GetDuration(); Index: source/graphics/UnitManager.h =================================================================== --- source/graphics/UnitManager.h +++ source/graphics/UnitManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -60,7 +60,7 @@ private: // list of all known units std::vector m_Units; - // graphical object manager; may be NULL if not set up + // graphical object manager; may be nullptr if not set up CObjectManager* m_ObjectManager; }; Index: source/graphics/UnitManager.cpp =================================================================== --- source/graphics/UnitManager.cpp +++ source/graphics/UnitManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -36,7 +36,7 @@ /////////////////////////////////////////////////////////////////////////////// // CUnitManager constructor CUnitManager::CUnitManager() : - m_ObjectManager(NULL) + m_ObjectManager(nullptr) { } @@ -90,7 +90,7 @@ CUnit* CUnitManager::CreateUnit(const CStrW& actorName, uint32_t seed, const std::set& selections) { if (! m_ObjectManager) - return NULL; + return nullptr; CUnit* unit = CUnit::Create(actorName, seed, selections, *m_ObjectManager); if (unit) Index: source/graphics/tests/test_LOSTexture.h =================================================================== --- source/graphics/tests/test_LOSTexture.h +++ source/graphics/tests/test_LOSTexture.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -27,7 +27,7 @@ public: void test_basic() { - CSimulation2 sim(NULL, g_ScriptRuntime, NULL); + CSimulation2 sim(nullptr, g_ScriptRuntime, nullptr); CLOSTexture tex(sim); const ssize_t size = 8; @@ -62,7 +62,7 @@ void test_perf_DISABLED() { - CSimulation2 sim(NULL, g_ScriptRuntime, NULL); + CSimulation2 sim(nullptr, g_ScriptRuntime, nullptr); CLOSTexture tex(sim); const ssize_t size = 257; Index: source/graphics/tests/test_Terrain.h =================================================================== --- source/graphics/tests/test_Terrain.h +++ source/graphics/tests/test_Terrain.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -68,7 +68,7 @@ void test_GetExactGroundLevel() { CTerrain terrain; - terrain.Initialize(4, NULL); + terrain.Initialize(4, nullptr); Set45Slope(terrain); SetHighPlateau(terrain, 20); @@ -96,7 +96,7 @@ void test_GetExactGroundLevelFixed() { CTerrain terrain; - terrain.Initialize(4, NULL); + terrain.Initialize(4, nullptr); Set45Slope(terrain); SetHighPlateau(terrain, 20); @@ -126,7 +126,7 @@ void test_GetExactGroundLevelFixed_max() { CTerrain terrain; - terrain.Initialize(4, NULL); + terrain.Initialize(4, nullptr); SetVertex(terrain, 0, 0, 65535); SetVertex(terrain, 0, 1, 65535); SetVertex(terrain, 1, 0, 65535); @@ -148,7 +148,7 @@ void test_CalcNormal() { CTerrain terrain; - terrain.Initialize(4, NULL); + terrain.Initialize(4, nullptr); Set45Slope(terrain); CVector3D vec; @@ -172,7 +172,7 @@ void test_CalcNormalFixed() { CTerrain terrain; - terrain.Initialize(4, NULL); + terrain.Initialize(4, nullptr); Set45Slope(terrain); CFixedVector3D vec; Index: source/gui/CDropDown.cpp =================================================================== --- source/gui/CDropDown.cpp +++ source/gui/CDropDown.cpp @@ -532,7 +532,7 @@ DrawText(selected, color, pos, bz+0.1f, cliparea); } - bool* scrollbar = NULL; + bool* scrollbar = nullptr; bool old; GUI::GetSettingPointer(this, "scrollbar", scrollbar); Index: source/gui/CGUI.h =================================================================== --- source/gui/CGUI.h +++ source/gui/CGUI.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -160,16 +160,16 @@ /** - * Returns the GUI object with the desired name, or NULL + * Returns the GUI object with the desired name, or nullptr * if no match is found, * * @param Name String name of object - * @return Matching object, or NULL + * @return Matching object, or nullptr */ IGUIObject* FindObjectByName(const CStr& Name) const; /** - * Returns the GUI object under the mouse, or NULL if none. + * Returns the GUI object under the mouse, or nullptr if none. */ IGUIObject* FindObjectUnderMouse() const; @@ -218,7 +218,7 @@ * @param pObject Optional parameter for error output. Used *only* if error parsing fails, * and we need to be able to output which object the error occurred in to aid the user. */ - SGUIText GenerateText(const CGUIString& Text, const CStrW& Font, const float& Width, const float& BufferZone, const IGUIObject* pObject = NULL); + SGUIText GenerateText(const CGUIString& Text, const CStrW& Font, const float& Width, const float& BufferZone, const IGUIObject* pObject = nullptr); /** @@ -282,7 +282,7 @@ /** * Change focus to new object. * Will send LOST_FOCUS/GOT_FOCUS messages as appropriate. - * pObject can be NULL to remove all focus. + * pObject can be nullptr to remove all focus. */ void SetFocusedObject(IGUIObject* pObject); Index: source/gui/CGUI.cpp =================================================================== --- source/gui/CGUI.cpp +++ source/gui/CGUI.cpp @@ -124,7 +124,7 @@ } // Only one object can be hovered - IGUIObject* pNearest = NULL; + IGUIObject* pNearest = nullptr; // TODO Gee: (2004-09-08) Big TODO, don't do the below if the SDL_Event is something like a keypress! try @@ -133,7 +133,7 @@ // TODO Gee: Optimizations needed! // these two recursive function are quite overhead heavy. - // pNearest will after this point at the hovered object, possibly NULL + // pNearest will after this point at the hovered object, possibly nullptr pNearest = FindObjectUnderMouse(); // Now we'll call UpdateMouseOver on *all* objects, @@ -279,7 +279,7 @@ } CGUI::CGUI(const shared_ptr& runtime) - : m_MouseButtons(0), m_FocusedObject(NULL), m_InternalNameNumber(0) + : m_MouseButtons(0), m_FocusedObject(nullptr), m_InternalNameNumber(0) { m_ScriptInterface.reset(new ScriptInterface("Engine", "GUIPage", runtime)); GuiScriptingInit(*m_ScriptInterface); @@ -302,8 +302,8 @@ return (*m_ObjectTypes[str])(); else { - // Error reporting will be handled with the NULL return. - return NULL; + // Error reporting will be handled with the nullptr return. + return nullptr; } } @@ -440,14 +440,14 @@ { map_pObjects::const_iterator it = m_pAllObjects.find(Name); if (it == m_pAllObjects.end()) - return NULL; + return nullptr; else return it->second; } IGUIObject* CGUI::FindObjectUnderMouse() const { - IGUIObject* pNearest = NULL; + IGUIObject* pNearest = nullptr; GUI::RecurseObject(GUIRR_HIDDEN | GUIRR_GHOST, m_BaseObject, &IGUIObject::ChooseMouseOverAndClosest, pNearest); @@ -1373,7 +1373,7 @@ if (m_Sprites.find(name) != m_Sprites.end()) LOGWARNING("GUI sprite name '%s' used more than once; first definition will be discarded", name.c_str()); - SGUIImageEffects* effects = NULL; + SGUIImageEffects* effects = nullptr; for (XMBElement child : Element.GetChildNodes()) { Index: source/gui/CGUISprite.h =================================================================== --- source/gui/CGUISprite.h +++ source/gui/CGUISprite.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -59,7 +59,7 @@ public: SGUIImage() : m_FixedHAspectRatio(0.f), m_RoundCoordinates(true), m_WrapMode(GL_REPEAT), - m_Effects(NULL), m_Border(false), m_DeltaZ(0.f) + m_Effects(nullptr), m_Border(false), m_DeltaZ(0.f) { } Index: source/gui/CInput.cpp =================================================================== --- source/gui/CInput.cpp +++ source/gui/CInput.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -1185,7 +1185,7 @@ // Get pointer of caption, it might be very large, and we don't // want to copy it continuously. - CStrW* pCaption = NULL; + CStrW* pCaption = nullptr; wchar_t mask_char = L'*'; if (mask) { @@ -1197,8 +1197,8 @@ else pCaption = (CStrW*)m_Settings["caption"].m_pSetting; - CGUISpriteInstance* sprite = NULL; - CGUISpriteInstance* sprite_selectarea = NULL; + CGUISpriteInstance* sprite = nullptr; + CGUISpriteInstance* sprite_selectarea = nullptr; int cell_id; GUI::GetSettingPointer(this, "sprite", sprite); Index: source/gui/CList.cpp =================================================================== --- source/gui/CList.cpp +++ source/gui/CList.cpp @@ -338,8 +338,8 @@ { CRect rect = GetListRect(); - CGUISpriteInstance* sprite = NULL; - CGUISpriteInstance* sprite_selectarea = NULL; + CGUISpriteInstance* sprite = nullptr; + CGUISpriteInstance* sprite_selectarea = nullptr; int cell_id; GUI::GetSettingPointer(this, _sprite, sprite); GUI::GetSettingPointer(this, _sprite_selected, sprite_selectarea); Index: source/gui/COList.cpp =================================================================== --- source/gui/COList.cpp +++ source/gui/COList.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -319,8 +319,8 @@ CRect rect = GetListRect(); - CGUISpriteInstance* sprite = NULL; - CGUISpriteInstance* sprite_selectarea = NULL; + CGUISpriteInstance* sprite = nullptr; + CGUISpriteInstance* sprite_selectarea = nullptr; int cell_id; GUI::GetSettingPointer(this, _sprite, sprite); GUI::GetSettingPointer(this, _sprite_selected, sprite_selectarea); @@ -373,7 +373,7 @@ GUI::GetSetting(this, "heading_height", headingHeight); // Draw line above column header - CGUISpriteInstance* sprite_heading = NULL; + CGUISpriteInstance* sprite_heading = nullptr; GUI::GetSettingPointer(this, "sprite_heading", sprite_heading); CRect rect_head(m_CachedActualSize.left, m_CachedActualSize.top, m_CachedActualSize.right, m_CachedActualSize.top + headingHeight); Index: source/gui/GUIManager.cpp =================================================================== --- source/gui/GUIManager.cpp +++ source/gui/GUIManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -30,7 +30,7 @@ #include "scriptinterface/ScriptInterface.h" #include "scriptinterface/ScriptRuntime.h" -CGUIManager* g_GUI = NULL; +CGUIManager* g_GUI = nullptr; // General TODOs: Index: source/gui/GUITooltip.cpp =================================================================== --- source/gui/GUITooltip.cpp +++ source/gui/GUITooltip.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -77,7 +77,7 @@ }; GUITooltip::GUITooltip() -: m_State(ST_IN_MOTION), m_PreviousObject(NULL), m_PreviousTooltipName() +: m_State(ST_IN_MOTION), m_PreviousObject(nullptr), m_PreviousTooltipName() { } Index: source/gui/GUItext.h =================================================================== --- source/gui/GUItext.h +++ source/gui/GUItext.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -92,7 +92,7 @@ STextCall() : m_UseCustomColor(false), m_Bold(false), m_Italic(false), m_Underlined(false), - m_pSpriteCall(NULL) {} + m_pSpriteCall(nullptr) {} /** * Position @@ -131,7 +131,7 @@ bool m_Bold, m_Italic, m_Underlined; /** - * *IF* an icon, then this is not NULL. + * *IF* an icon, then this is not nullptr. */ std::list::pointer m_pSpriteCall; }; @@ -309,12 +309,12 @@ * @param from From character n, * @param to to character n. * @param FirstLine Whether this is the first line of text, to calculate its height correctly - * @param pObject Only for Error outputting, optional! If NULL + * @param pObject Only for Error outputting, optional! If nullptr * then no Errors will be reported! Useful when you need * to make several GenerateTextCall in different phases, * it avoids duplicates. */ - void GenerateTextCall(const CGUI* pGUI, SFeedback& Feedback, CStrIntern DefaultFont, const int& from, const int& to, const bool FirstLine, const IGUIObject* pObject = NULL) const; + void GenerateTextCall(const CGUI* pGUI, SFeedback& Feedback, CStrIntern DefaultFont, const int& from, const int& to, const bool FirstLine, const IGUIObject* pObject = nullptr) const; /** * Words Index: source/gui/GUIutil.cpp =================================================================== --- source/gui/GUIutil.cpp +++ source/gui/GUIutil.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -331,7 +331,7 @@ template PSRETURN GUI::GetSettingPointer(const IGUIObject* pObject, const CStr& Setting, T*& Value) { - ENSURE(pObject != NULL); + ENSURE(pObject != nullptr); std::map::const_iterator it = pObject->m_Settings.find(Setting); if (it == pObject->m_Settings.end()) @@ -342,7 +342,7 @@ return PSRETURN_GUI_InvalidSetting; } - if (it->second.m_pSetting == NULL) + if (it->second.m_pSetting == nullptr) return PSRETURN_GUI_InvalidSetting; #ifndef NDEBUG @@ -358,7 +358,7 @@ template PSRETURN GUI::GetSetting(const IGUIObject* pObject, const CStr& Setting, T& Value) { - T* v = NULL; + T* v = nullptr; PSRETURN ret = GetSettingPointer(pObject, Setting, v); if (ret == PSRETURN_OK) Value = *v; @@ -380,7 +380,7 @@ template PSRETURN GUI::SetSetting(IGUIObject* pObject, const CStr& Setting, const T& Value, const bool& SkipMessage) { - ENSURE(pObject != NULL); + ENSURE(pObject != nullptr); if (!pObject->SettingExists(Setting)) { Index: source/gui/IGUIButtonBehavior.h =================================================================== --- source/gui/IGUIButtonBehavior.h +++ source/gui/IGUIButtonBehavior.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -92,7 +92,7 @@ virtual void ResetStates() { // Notify the gui that we aren't hovered anymore - UpdateMouseOver(NULL); + UpdateMouseOver(nullptr); m_Pressed = false; m_PressedRight = false; } Index: source/gui/IGUIObject.h =================================================================== --- source/gui/IGUIObject.h +++ source/gui/IGUIObject.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -66,7 +66,7 @@ */ struct SGUISetting { - SGUISetting() : m_pSetting(NULL) {} + SGUISetting() : m_pSetting(nullptr) {} void *m_pSetting; EGUISettingType m_Type; @@ -322,7 +322,7 @@ virtual void ResetStates() { // Notify the gui that we aren't hovered anymore - UpdateMouseOver(NULL); + UpdateMouseOver(nullptr); } public: @@ -344,7 +344,7 @@ * NOTE! This will not just return m_pParent, when that is * need use it! There is one exception to it, when the parent is * the top-node (the object that isn't a real object), this - * will return NULL, so that the top-node's children are + * will return nullptr, so that the top-node's children are * seemingly parentless. * * @return Pointer to parent @@ -411,7 +411,7 @@ * being inputted one thing happens, and not, another). * * @param pMouseOver Object that is currently hovered, - * can OF COURSE be NULL too! + * can OF COURSE be nullptr too! */ void UpdateMouseOver(IGUIObject* const& pMouseOver); @@ -427,9 +427,9 @@ * if hovered, if so, then check if this's Z value is greater * than the inputted object... If so then the object is closer * and we'll replace the pointer with this. - * Also Notice input can be NULL, which means the Z value demand - * is out. NOTICE you can't input NULL as const so you'll have - * to set an object to NULL. + * Also Notice input can be nullptr, which means the Z value demand + * is out. NOTICE you can't input nullptr as const so you'll have + * to set an object to nullptr. * * @param pObject Object pointer, can be either the old one, or * the new one. Index: source/gui/IGUIObject.cpp =================================================================== --- source/gui/IGUIObject.cpp +++ source/gui/IGUIObject.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -29,7 +29,7 @@ IGUIObject::IGUIObject() - : m_pGUI(NULL), m_pParent(NULL), m_MouseHovering(false), m_LastClickTime() + : m_pGUI(nullptr), m_pParent(nullptr), m_MouseHovering(false), m_LastClickTime() { AddSetting(GUIST_bool, "enabled"); AddSetting(GUIST_bool, "hidden"); @@ -113,7 +113,7 @@ void IGUIObject::AddToPointersMap(map_pObjects& ObjectMap) { // Just don't do anything about the top node - if (m_pParent == NULL) + if (m_pParent == nullptr) return; // Now actually add this one @@ -269,7 +269,7 @@ return; // Check if we've got competition at all - if (pObject == NULL) + if (pObject == nullptr) { pObject = this; return; @@ -289,8 +289,8 @@ // checks, that could screw it up if (m_pParent) { - if (m_pParent->m_pParent == NULL) - return NULL; + if (m_pParent->m_pParent == nullptr) + return nullptr; } return m_pParent; Index: source/gui/IGUIScrollBar.cpp =================================================================== --- source/gui/IGUIScrollBar.cpp +++ source/gui/IGUIScrollBar.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -20,7 +20,7 @@ #include "GUI.h" #include "maths/MathUtil.h" -IGUIScrollBar::IGUIScrollBar() : m_pStyle(NULL), m_pGUI(NULL), +IGUIScrollBar::IGUIScrollBar() : m_pStyle(nullptr), m_pGUI(nullptr), m_X(300.f), m_Y(300.f), m_ScrollRange(1.f), m_ScrollSpace(0.f), // MaxPos: not 0, due to division. m_Length(200.f), m_Width(20.f), @@ -64,7 +64,7 @@ const SGUIScrollBarStyle* IGUIScrollBar::GetStyle() const { if (!m_pHostObject) - return NULL; + return nullptr; return m_pHostObject->GetScrollBarStyle(m_ScrollBarStyle); } @@ -72,7 +72,7 @@ CGUI* IGUIScrollBar::GetGUI() const { if (!m_pHostObject) - return NULL; + return nullptr; return m_pHostObject->GetGUI(); } Index: source/gui/IGUIScrollBarOwner.cpp =================================================================== --- source/gui/IGUIScrollBarOwner.cpp +++ source/gui/IGUIScrollBarOwner.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -49,14 +49,14 @@ if (!GetGUI()) { // TODO Gee: Output in log - return NULL; + return nullptr; } std::map::const_iterator it = GetGUI()->m_ScrollBarStyles.find(style); if (it == GetGUI()->m_ScrollBarStyles.end()) { // TODO Gee: Output in log - return NULL; + return nullptr; } return &it->second; Index: source/gui/scripting/GuiScriptConversions.cpp =================================================================== --- source/gui/scripting/GuiScriptConversions.cpp +++ source/gui/scripting/GuiScriptConversions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -118,7 +118,7 @@ template<> void ScriptInterface::ToJSVal(JSContext* UNUSED(cx), JS::MutableHandleValue ret, IGUIObject* const& val) { - if (val == NULL) + if (val == nullptr) ret.setNull(); else ret.setObject(*val->GetJSObject()); Index: source/gui/scripting/JSInterface_GUITypes.cpp =================================================================== --- source/gui/scripting/JSInterface_GUITypes.cpp +++ source/gui/scripting/JSInterface_GUITypes.cpp @@ -261,7 +261,7 @@ // Initialise all the types at once: void JSI_GUITypes::init(ScriptInterface& scriptInterface) { - scriptInterface.DefineCustomObjectType(&JSI_GUISize::JSI_class, JSI_GUISize::construct, 1, nullptr, JSI_GUISize::JSI_methods, NULL, NULL); - scriptInterface.DefineCustomObjectType(&JSI_GUIColor::JSI_class, JSI_GUIColor::construct, 1, nullptr, JSI_GUIColor::JSI_methods, NULL, NULL); - scriptInterface.DefineCustomObjectType(&JSI_GUIMouse::JSI_class, JSI_GUIMouse::construct, 1, nullptr, JSI_GUIMouse::JSI_methods, NULL, NULL); + scriptInterface.DefineCustomObjectType(&JSI_GUISize::JSI_class, JSI_GUISize::construct, 1, nullptr, JSI_GUISize::JSI_methods, nullptr, nullptr); + scriptInterface.DefineCustomObjectType(&JSI_GUIColor::JSI_class, JSI_GUIColor::construct, 1, nullptr, JSI_GUIColor::JSI_methods, nullptr, nullptr); + scriptInterface.DefineCustomObjectType(&JSI_GUIMouse::JSI_class, JSI_GUIMouse::construct, 1, nullptr, JSI_GUIMouse::JSI_methods, nullptr, nullptr); } Index: source/gui/scripting/JSInterface_IGUIObject.cpp =================================================================== --- source/gui/scripting/JSInterface_IGUIObject.cpp +++ source/gui/scripting/JSInterface_IGUIObject.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -58,7 +58,7 @@ JSAutoRequest rq(cx); ScriptInterface* pScriptInterface = ScriptInterface::GetScriptInterfaceAndCBData(cx)->pScriptInterface; - IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, obj, &JSI_IGUIObject::JSI_class, NULL); + IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, obj, &JSI_IGUIObject::JSI_class, nullptr); if (!e) return false; @@ -319,7 +319,7 @@ bool JSI_IGUIObject::setProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool UNUSED(strict), JS::MutableHandleValue vp) { - IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, obj, &JSI_IGUIObject::JSI_class, NULL); + IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, obj, &JSI_IGUIObject::JSI_class, nullptr); if (!e) return false; @@ -510,7 +510,7 @@ return false; } } - else if (vp.isObject() && JS_InstanceOf(cx, vpObj, &JSI_GUISize::JSI_class, NULL)) + else if (vp.isObject() && JS_InstanceOf(cx, vpObj, &JSI_GUISize::JSI_class, nullptr)) { CClientArea area; GUI::GetSetting(e, propName, area); @@ -551,7 +551,7 @@ return false; } } - else if (vp.isObject() && JS_InstanceOf(cx, vpObj, &JSI_GUIColor::JSI_class, NULL)) + else if (vp.isObject() && JS_InstanceOf(cx, vpObj, &JSI_GUIColor::JSI_class, nullptr)) { CColor color; JS::RootedValue t(cx); @@ -635,7 +635,7 @@ void JSI_IGUIObject::init(ScriptInterface& scriptInterface) { - scriptInterface.DefineCustomObjectType(&JSI_class, construct, 1, JSI_props, JSI_methods, NULL, NULL); + scriptInterface.DefineCustomObjectType(&JSI_class, construct, 1, JSI_props, JSI_methods, nullptr, nullptr); } bool JSI_IGUIObject::toString(JSContext* cx, uint UNUSED(argc), JS::Value* vp) @@ -645,7 +645,7 @@ JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp)); - IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL); + IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, nullptr); if (!e) return false; @@ -663,7 +663,7 @@ JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp)); - IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL); + IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, nullptr); if (!e) return false; @@ -680,11 +680,11 @@ JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp)); - IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL); + IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, nullptr); if (!e) return false; - e->GetGUI()->SetFocusedObject(NULL); + e->GetGUI()->SetFocusedObject(nullptr); rec.rval().setUndefined(); return true; @@ -697,7 +697,7 @@ JS::RootedObject thisObj(cx, JS_THIS_OBJECT(cx, vp)); - IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, NULL); + IGUIObject* e = (IGUIObject*)JS_GetInstancePrivate(cx, thisObj, &JSI_IGUIObject::JSI_class, nullptr); if (!e) return false; Index: source/lib/allocators/arena.h =================================================================== --- source/lib/allocators/arena.h +++ source/lib/allocators/arena.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -115,7 +115,7 @@ NONCOPYABLE(DynamicArena); public: - DynamicArena(size_t chunkSize) : chunkSize(chunkSize), head(NULL) + DynamicArena(size_t chunkSize) : chunkSize(chunkSize), head(nullptr) { AllocateNewChunk(); } @@ -123,7 +123,7 @@ ~DynamicArena() { ArenaChunk* chunk = head; - while (chunk != NULL) + while (chunk != nullptr) { ArenaChunk* next = chunk->next; free(chunk); Index: source/lib/app_hooks.h =================================================================== --- source/lib/app_hooks.h +++ source/lib/app_hooks.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -173,7 +173,7 @@ /** - * holds a function pointer (allowed to be NULL) for each hook. + * holds a function pointer (allowed to be nullptr) for each hook. * passed to app_hooks_update. **/ struct AppHooks Index: source/lib/code_annotation.h =================================================================== --- source/lib/code_annotation.h +++ source/lib/code_annotation.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -245,7 +245,7 @@ // TODO: support _Printf_format_string_ for VC9+ #endif -// annotate vararg functions that expect to end with an explicit NULL +// annotate vararg functions that expect to end with an explicit nullptr #if GCC_VERSION # define SENTINEL_ARG __attribute__ ((sentinel)) #else Index: source/lib/code_generation.h =================================================================== --- source/lib/code_generation.h +++ source/lib/code_generation.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -101,37 +101,37 @@ }\ catch(std::bad_alloc&)\ {\ - ptr = 0;\ + ptr = nullptr;\ } /** - * delete memory ensuing from new and set the pointer to zero + * delete memory ensuing from new and set the pointer to nullptr * (thus making double-frees safe / a no-op) **/ #define SAFE_DELETE(p)\ STMT(\ - delete (p); /* if p == 0, delete is a no-op */ \ - (p) = 0;\ + delete (p); /* if p == nullptr, delete is a no-op */ \ + (p) = nullptr;\ ) /** - * delete memory ensuing from new[] and set the pointer to zero + * delete memory ensuing from new[] and set the pointer to nullptr * (thus making double-frees safe / a no-op) **/ #define SAFE_ARRAY_DELETE(p)\ STMT(\ - delete[] (p); /* if p == 0, delete is a no-op */ \ - (p) = 0;\ + delete[] (p); /* if p == nullptr, delete is a no-op */ \ + (p) = nullptr;\ ) /** - * free memory ensuing from malloc and set the pointer to zero + * free memory ensuing from malloc and set the pointer to nullptr * (thus making double-frees safe / a no-op) **/ #define SAFE_FREE(p)\ STMT(\ - free((void*)p); /* if p == 0, free is a no-op */ \ - (p) = 0;\ + free((void*)p); /* if p == nullptr, free is a no-op */ \ + (p) = nullptr;\ ) #endif // #ifndef INCLUDED_CODE_GENERATION Index: source/lib/debug.h =================================================================== --- source/lib/debug.h +++ source/lib/debug.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -87,11 +87,11 @@ /** * enable the Suppress button. set automatically by debug_DisplayError if - * it receives a non-NULL suppress pointer. a flag is necessary because + * it receives a non-nullptr suppress pointer. a flag is necessary because * the sys_display_error interface doesn't get that pointer. * rationale for automatic setting: this may prevent someone from * forgetting to specify it, and disabling Suppress despite having - * passed a non-NULL pointer doesn't make much sense. + * passed a non-nullptr pointer doesn't make much sense. **/ DE_ALLOW_SUPPRESS = 2, @@ -185,7 +185,7 @@ * @param file, line, func: location of the error (typically passed as * WIDEN(__FILE__), __LINE__, __func__ from a macro) * @param suppress pointer to a caller-allocated flag that can be used to - * suppress this error. if NULL, this functionality is skipped and the + * suppress this error. if nullptr, this functionality is skipped and the * "Suppress" dialog button will be disabled. * note: this flag is read and written exclusively here; caller only * provides the storage. values: see DEBUG_SUPPRESS above. Index: source/lib/external_libraries/opengl.h =================================================================== --- source/lib/external_libraries/opengl.h +++ source/lib/external_libraries/opengl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the Index: source/lib/file/archive/archive_zip.cpp =================================================================== --- source/lib/file/archive/archive_zip.cpp +++ source/lib/file/archive/archive_zip.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -618,7 +618,7 @@ PFile file(new File); RETURN_STATUS_IF_ERR(file->Open(pathname, O_RDONLY)); - return AddFileOrMemory(fileInfo, pathnameInArchive, file, NULL); + return AddFileOrMemory(fileInfo, pathnameInArchive, file, nullptr); } Status AddMemory(const u8* data, size_t size, time_t mtime, const OsPath& pathnameInArchive) Index: source/lib/file/vfs/vfs.h =================================================================== --- source/lib/file/vfs/vfs.h +++ source/lib/file/vfs/vfs.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -104,7 +104,7 @@ * Retrieve information about a file (similar to POSIX stat). * * @param pathname - * @param pfileInfo receives information about the file. Passing NULL + * @param pfileInfo receives information about the file. Passing nullptr * suppresses warnings if the file doesn't exist. * * @return Status. Index: source/lib/file/vfs/vfs.cpp =================================================================== --- source/lib/file/vfs/vfs.cpp +++ source/lib/file/vfs/vfs.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -221,7 +221,7 @@ { ScopedLock s; VfsDirectory* directory; - WARN_RETURN_STATUS_IF_ERR(vfs_Lookup(pathname, &m_rootDirectory, directory, NULL)); + WARN_RETURN_STATUS_IF_ERR(vfs_Lookup(pathname, &m_rootDirectory, directory, nullptr)); realPathname = directory->AssociatedDirectory()->Path(); return INFO::OK; } Index: source/lib/file/vfs/vfs_lookup.cpp =================================================================== --- source/lib/file/vfs/vfs_lookup.cpp +++ source/lib/file/vfs/vfs_lookup.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -120,7 +120,7 @@ || (createAlways && (subdirectory->AssociatedDirectory()->Flags() & VFS_MOUNT_REPLACEABLE) != 0))) { OsPath currentPath; - if(directory->AssociatedDirectory()) // (is NULL when mounting into root) + if(directory->AssociatedDirectory()) // (is nullptr when mounting into root) currentPath = directory->AssociatedDirectory()->Path(); currentPath = currentPath / subdirectoryName; Index: source/lib/file/vfs/vfs_util.h =================================================================== --- source/lib/file/vfs/vfs_util.h +++ source/lib/file/vfs/vfs_util.h @@ -79,7 +79,7 @@ * @param dircbData * @return Status **/ -extern Status ForEachFile(const PIVFS& fs, const VfsPath& path, FileCallback cb, uintptr_t cbData, const wchar_t* pattern = 0, size_t flags = 0, DirCallback dircb = NULL, uintptr_t dircbData = 0); +extern Status ForEachFile(const PIVFS& fs, const VfsPath& path, FileCallback cb, uintptr_t cbData, const wchar_t* pattern = 0, size_t flags = 0, DirCallback dircb = nullptr, uintptr_t dircbData = 0); /** Index: source/lib/ogl.cpp =================================================================== --- source/lib/ogl.cpp +++ source/lib/ogl.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -58,7 +58,7 @@ } -static const char* exts = NULL; +static const char* exts = nullptr; static bool have_30, have_21, have_20, have_15, have_14, have_13, have_12; @@ -349,12 +349,12 @@ // checking for the extension. // (TODO: this calls ogl_HaveVersion far more times than is necessary - // we should probably use the have_* variables instead) - // Note: the xorg-x11 implementation of glXGetProcAddress doesn't return NULL + // Note: the xorg-x11 implementation of glXGetProcAddress doesn't return nullptr // if the function is unsupported (i.e. the rare case of a driver not reporting // its supported version correctly, see http://trac.wildfiregames.com/ticket/171) #define FUNC(ret, name, params) p##name = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#name); #define FUNC23(pname, ret, nameARB, nameCore, version, params) \ - pname = NULL; \ + pname = nullptr; \ if(ogl_HaveVersion(version)) \ pname = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#nameCore); \ if(!pname) /* use the ARB name if the driver lied about what version it supports */ \ Index: source/lib/regex.h =================================================================== --- source/lib/regex.h +++ source/lib/regex.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -32,7 +32,7 @@ * * @param s input string * @param w pseudo-regex to match against. case-insensitive; - * may contain '?' and/or '*' wildcards. if NULL, matches everything. + * may contain '?' and/or '*' wildcards. if nullptr, matches everything. * * @return 1 if they match, otherwise 0. * Index: source/lib/res/graphics/cursor.cpp =================================================================== --- source/lib/res/graphics/cursor.cpp +++ source/lib/res/graphics/cursor.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -75,7 +75,7 @@ SDL_Surface* scaled_surface = SDL_CreateRGBSurface(0, surface->w * scale, surface->h * scale, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); if(!scaled_surface) return ERR::FAIL; - if(SDL_BlitScaled(surface, NULL, scaled_surface, NULL)) + if(SDL_BlitScaled(surface, nullptr, scaled_surface, nullptr)) return ERR::FAIL; SDL_FreeSurface(surface); surface = scaled_surface; Index: source/lib/res/graphics/ogl_tex.h =================================================================== --- source/lib/res/graphics/ogl_tex.h +++ source/lib/res/graphics/ogl_tex.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -389,7 +389,7 @@ * @return Status * * Note: this memory is freed after a successful ogl_tex_upload for -* this texture. After that, the pointer we retrieve is NULL but +* this texture. After that, the pointer we retrieve is nullptr but * the function doesn't fail (negative return value) by design. * If you still need to get at the data, add a reference before * uploading it or read directly from OpenGL (discouraged). Index: source/lib/res/graphics/ogl_tex.cpp =================================================================== --- source/lib/res/graphics/ogl_tex.cpp +++ source/lib/res/graphics/ogl_tex.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -757,7 +757,7 @@ #else // note: we don't bother checking for GL_S3_s3tc - it is incompatible // and irrelevant (was never widespread). - have_s3tc = ogl_HaveExtensions(0, "GL_ARB_texture_compression", "GL_EXT_texture_compression_s3tc", NULL) == 0; + have_s3tc = ogl_HaveExtensions(0, "GL_ARB_texture_compression", "GL_EXT_texture_compression_s3tc", nullptr) == 0; #endif } if(have_anistropy == -1) @@ -983,7 +983,7 @@ //---------------------------------------------------------------------------- // retrieve texture dimensions and bits per pixel. -// all params are optional and filled if non-NULL. +// all params are optional and filled if non-nullptr. Status ogl_tex_get_size(Handle ht, size_t* w, size_t* h, size_t* bpp) { H_DEREF(ht, OglTex, ot); @@ -1000,7 +1000,7 @@ // retrieve TexFlags and the corresponding OpenGL format. // the latter is determined during ogl_tex_upload and is 0 before that. -// all params are optional and filled if non-NULL. +// all params are optional and filled if non-nullptr. Status ogl_tex_get_format(Handle ht, size_t* flags, GLenum* fmt) { H_DEREF(ht, OglTex, ot); @@ -1019,7 +1019,7 @@ // retrieve pointer to texel data. // // note: this memory is freed after a successful ogl_tex_upload for -// this texture. after that, the pointer we retrieve is NULL but +// this texture. after that, the pointer we retrieve is nullptr but // the function doesn't fail (negative return value) by design. // if you still need to get at the data, add a reference before // uploading it or read directly from OpenGL (discouraged). Index: source/lib/sysdep/os/win/wcursor.cpp =================================================================== --- source/lib/sysdep/os/win/wcursor.cpp +++ source/lib/sysdep/os/win/wcursor.cpp @@ -89,11 +89,11 @@ // (they get drawn as a black square), so refuse to load the // cursor in that case int bpp = 0; - RETURN_STATUS_IF_ERR(gfx::GetVideoMode(NULL, NULL, &bpp, NULL)); + RETURN_STATUS_IF_ERR(gfx::GetVideoMode(nullptr, nullptr, &bpp, nullptr)); if (bpp <= 16) return ERR::FAIL; - return sys_cursor_create_common(w, h, bgra_img, NULL, hx, hy, cursor); + return sys_cursor_create_common(w, h, bgra_img, nullptr, hx, hy, cursor); } Status sys_cursor_create_empty(sys_cursor* cursor) Index: source/lib/sysdep/os/win/wdir_watch.cpp =================================================================== --- source/lib/sysdep/os/win/wdir_watch.cpp +++ source/lib/sysdep/os/win/wdir_watch.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -147,7 +147,7 @@ FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_CREATION; // not set: FILE_NOTIFY_CHANGE_ATTRIBUTES, FILE_NOTIFY_CHANGE_LAST_ACCESS, FILE_NOTIFY_CHANGE_SECURITY - DWORD undefined = 0; // (non-NULL pointer avoids BoundsChecker warning) + DWORD undefined = 0; // (non-nullptr pointer avoids BoundsChecker warning) m_ovl->Internal = 0; WARN_IF_FALSE(ReadDirectoryChangesW(m_dirHandle, m_data, dataSize, watchSubtree, filter, &undefined, m_ovl, 0)); return INFO::OK; Index: source/lib/sysdep/os/win/wdll_delay_load.cpp =================================================================== --- source/lib/sysdep/os/win/wdll_delay_load.cpp +++ source/lib/sysdep/os/win/wdll_delay_load.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -320,12 +320,12 @@ // Call the initial hook. If it exists and returns a function pointer, // abort the rest of the processing and just return it for the call. // - FARPROC pfnRet = NULL; + FARPROC pfnRet = nullptr; if (__pfnDliNotifyHook2) { pfnRet = ((*__pfnDliNotifyHook2)(dliStartProcessing, &dli)); - if (pfnRet != NULL) + if (pfnRet != nullptr) goto HookBypass; } @@ -461,7 +461,7 @@ PFromRva(pidd->rvaUnloadIAT) ); ::FreeLibrary(hmod); - *phmod = NULL; + *phmod = nullptr; delete (ULI*)pui; // changes __puiHead! } Index: source/lib/sysdep/os/win/wposix/waio.cpp =================================================================== --- source/lib/sysdep/os/win/wposix/waio.cpp +++ source/lib/sysdep/os/win/wposix/waio.cpp @@ -539,7 +539,7 @@ { for(int i = 0; i < n; i++) { - if(!cbs[i]) // SUSv3: must ignore NULL entries + if(!cbs[i]) // SUSv3: must ignore nullptr entries continue; if(HasOverlappedIoCompleted((OVERLAPPED*)cbs[i]->ovl)) Index: source/lib/sysdep/os/win/wposix/wfilesystem.cpp =================================================================== --- source/lib/sysdep/os/win/wposix/wfilesystem.cpp +++ source/lib/sysdep/os/win/wposix/wfilesystem.cpp @@ -339,7 +339,7 @@ int wmkdir(const OsPath& path, mode_t UNUSED(mode)) { - if(!CreateDirectoryW(OsString(path).c_str(), (LPSECURITY_ATTRIBUTES)NULL)) + if(!CreateDirectoryW(OsString(path).c_str(), (LPSECURITY_ATTRIBUTES)nullptr)) { errno = ErrnoFromCreateDirectory(); return -1; Index: source/lib/sysdep/os/win/wposix/wtime.cpp =================================================================== --- source/lib/sysdep/os/win/wposix/wtime.cpp +++ source/lib/sysdep/os/win/wposix/wtime.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -215,7 +215,7 @@ "Thu", "Fri", "Sat", - NULL + nullptr }; static const char *full_weekdays[] = { @@ -226,7 +226,7 @@ "Thursday", "Friday", "Saturday", - NULL + nullptr }; static const char *abb_month[] = { @@ -242,7 +242,7 @@ "Oct", "Nov", "Dec", - NULL + nullptr }; static const char *full_month[] = { @@ -258,13 +258,13 @@ "October", "November", "December", - NULL, + nullptr, }; static const char *ampm[] = { "am", "pm", - NULL + nullptr }; /* @@ -277,7 +277,7 @@ { int i = 0; - for (i = 0; strs[i] != NULL; ++i) { + for (i = 0; strs[i] != nullptr; ++i) { size_t len = strlen (strs[i]); if (strncasecmp (*buf, strs[i], len) == 0) { @@ -393,32 +393,32 @@ case 'A' : ret = match_string (&buf, full_weekdays); if (ret < 0) - return NULL; + return nullptr; timeptr->tm_wday = ret; break; case 'a' : ret = match_string (&buf, abb_weekdays); if (ret < 0) - return NULL; + return nullptr; timeptr->tm_wday = ret; break; case 'B' : ret = match_string (&buf, full_month); if (ret < 0) - return NULL; + return nullptr; timeptr->tm_mon = ret; break; case 'b' : case 'h' : ret = match_string (&buf, abb_month); if (ret < 0) - return NULL; + return nullptr; timeptr->tm_mon = ret; break; case 'C' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; timeptr->tm_year = (ret * 100) - tm_year_base; buf = s; break; @@ -426,15 +426,15 @@ abort (); case 'D' : /* %m/%d/%y */ s = strptime (buf, "%m/%d/%y", timeptr); - if (s == NULL) - return NULL; + if (s == nullptr) + return nullptr; buf = s; break; case 'd' : case 'e' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; timeptr->tm_mday = ret; buf = s; break; @@ -442,7 +442,7 @@ case 'k' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; timeptr->tm_hour = ret; buf = s; break; @@ -450,7 +450,7 @@ case 'l' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; if (ret == 12) timeptr->tm_hour = 0; else @@ -460,21 +460,21 @@ case 'j' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; timeptr->tm_yday = ret - 1; buf = s; break; case 'm' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; timeptr->tm_mon = ret - 1; buf = s; break; case 'M' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; timeptr->tm_min = ret; buf = s; break; @@ -482,12 +482,12 @@ if (*buf == '\n') ++buf; else - return NULL; + return nullptr; break; case 'p' : ret = match_string (&buf, ampm); if (ret < 0) - return NULL; + return nullptr; if (timeptr->tm_hour == 0) { if (ret == 1) timeptr->tm_hour = 12; @@ -496,20 +496,20 @@ break; case 'r' : /* %I:%M:%S %p */ s = strptime (buf, "%I:%M:%S %p", timeptr); - if (s == NULL) - return NULL; + if (s == nullptr) + return nullptr; buf = s; break; case 'R' : /* %H:%M */ s = strptime (buf, "%H:%M", timeptr); - if (s == NULL) - return NULL; + if (s == nullptr) + return nullptr; buf = s; break; case 'S' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; timeptr->tm_sec = ret; buf = s; break; @@ -517,60 +517,60 @@ if (*buf == '\t') ++buf; else - return NULL; + return nullptr; break; case 'T' : /* %H:%M:%S */ case 'X' : s = strptime (buf, "%H:%M:%S", timeptr); - if (s == NULL) - return NULL; + if (s == nullptr) + return nullptr; buf = s; break; case 'u' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; timeptr->tm_wday = ret - 1; buf = s; break; case 'w' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; timeptr->tm_wday = ret; buf = s; break; case 'U' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; set_week_number_sun (timeptr, ret); buf = s; break; case 'V' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; set_week_number_mon4 (timeptr, ret); buf = s; break; case 'W' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; set_week_number_mon (timeptr, ret); buf = s; break; case 'x' : s = strptime (buf, "%Y:%m:%d", timeptr); - if (s == NULL) - return NULL; + if (s == nullptr) + return nullptr; buf = s; break; case 'y' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; if (ret < 70) timeptr->tm_year = 100 + ret; else @@ -580,7 +580,7 @@ case 'Y' : ret = strtol (buf, &s, 10); if (s == buf) - return NULL; + return nullptr; timeptr->tm_year = ret - tm_year_base; buf = s; break; @@ -593,20 +593,20 @@ if (*buf == '%') ++buf; else - return NULL; + return nullptr; break; default : if (*buf == '%' || *++buf == c) ++buf; else - return NULL; + return nullptr; break; } } else { if (*buf == c) ++buf; else - return NULL; + return nullptr; } } return (char *)buf; Index: source/lib/sysdep/os/win/wsysdep.cpp =================================================================== --- source/lib/sysdep/os/win/wsysdep.cpp +++ source/lib/sysdep/os/win/wsysdep.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -465,7 +465,7 @@ Status sys_open_url(const std::string& url) { - HINSTANCE r = ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); + HINSTANCE r = ShellExecuteA(nullptr, "open", url.c_str(), nullptr, nullptr, SW_SHOWNORMAL); if ((int)(intptr_t)r > 32) return INFO::OK; @@ -530,7 +530,7 @@ WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieConfig; memset(&ieConfig, 0, sizeof(ieConfig)); - HINTERNET hSession = NULL; + HINTERNET hSession = nullptr; Status err = INFO::SKIPPED; @@ -559,7 +559,7 @@ if(useAutoDetect) { - hSession = WinHttpOpen(NULL, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, + hSession = WinHttpOpen(nullptr, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); if(hSession && WinHttpGetProxyForUrl(hSession, url.c_str(), &autoProxyOptions, &proxyInfo) && proxyInfo.lpszProxy) Index: source/lib/sysdep/os/win/wutil.h =================================================================== --- source/lib/sysdep/os/win/wutil.h +++ source/lib/sysdep/os/win/wutil.h @@ -203,7 +203,7 @@ * 0 if none exist (e.g. it hasn't yet created one). * * enumerates all top-level windows and stops if PID matches. - * once this function returns a non-NULL handle, it will always + * once this function returns a non-nullptr handle, it will always * return that cached value. **/ extern HWND wutil_AppWindow(); Index: source/lib/sysdep/os/win/wutil.cpp =================================================================== --- source/lib/sysdep/os/win/wutil.cpp +++ source/lib/sysdep/os/win/wutil.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -469,7 +469,7 @@ return ERR::_1; TOKEN_PRIVILEGES tp; - if (!LookupPrivilegeValueW(NULL, privilege, &tp.Privileges[0].Luid)) + if (!LookupPrivilegeValueW(nullptr, privilege, &tp.Privileges[0].Luid)) return ERR::_2; tp.PrivilegeCount = 1; tp.Privileges[0].Attributes = enable? SE_PRIVILEGE_ENABLED : 0; Index: source/lib/sysdep/tests/test_rtl.h =================================================================== --- source/lib/sysdep/tests/test_rtl.h +++ source/lib/sysdep/tests/test_rtl.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -29,7 +29,7 @@ void _test_AllocateAligned_helper(size_t size, size_t align) { void* p = rtl_AllocateAligned(size, align); - TS_ASSERT(p != NULL); + TS_ASSERT(p != nullptr); TS_ASSERT_EQUALS((intptr_t)p % align, 0u); memset(p, 0x42, size); rtl_FreeAligned(p); @@ -49,6 +49,6 @@ void test_FreeAligned_null() { - rtl_FreeAligned(NULL); + rtl_FreeAligned(nullptr); } }; Index: source/lib/tests/test_regex.h =================================================================== --- source/lib/tests/test_regex.h +++ source/lib/tests/test_regex.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -30,7 +30,7 @@ void test_regex() { TS_ASSERT_EQUALS(match_wildcard(L"", L""), 1); - TS_ASSERT_EQUALS(match_wildcard(L"a", 0), 1); // NULL matches everything + TS_ASSERT_EQUALS(match_wildcard(L"a", 0), 1); // nullptr matches everything TS_ASSERT_EQUALS(match_wildcard(L"abc", L"abc") , 1); // direct match TS_ASSERT_EQUALS(match_wildcard(L"abc", L"???") , 1); // only ? Index: source/lib/tests/test_secure_crt.h =================================================================== --- source/lib/tests/test_secure_crt.h +++ source/lib/tests/test_secure_crt.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -327,8 +327,8 @@ TEST_PRINTF(d10,4, s10, -1, "", "%d", 1234); TEST_PRINTF(d10,3, s10, -1, "", "%d", 1234); TEST_PRINTF(d10,0, s10, -1, "abcdefghij", "%d", 1234); - TEST_PRINTF(NULL,0, NULL, -1, "", "%d", 1234); - TEST_PRINTF(d10,10, s10, -1, "abcdefghij", NULL); + TEST_PRINTF(nullptr,0, nullptr, -1, "", "%d", 1234); + TEST_PRINTF(d10,10, s10, -1, "abcdefghij", nullptr); } void test_wprintf_overflow() @@ -340,8 +340,8 @@ TEST_WPRINTF(wd10,4, ws10, -1, L"", L"%d", 1234); TEST_WPRINTF(wd10,3, ws10, -1, L"", L"%d", 1234); TEST_WPRINTF(wd10,0, ws10, -1, L"abcdefghij", L"%d", 1234); - TEST_WPRINTF(NULL,0, NULL, -1, L"", L"%d", 1234); - TEST_WPRINTF(wd10,10, ws10, -1, L"abcdefghij", NULL); + TEST_WPRINTF(nullptr,0, nullptr, -1, L"", L"%d", 1234); + TEST_WPRINTF(wd10,10, ws10, -1, L"abcdefghij", nullptr); } void test_printf_strings() Index: source/lib/tex/tex_codec.h =================================================================== --- source/lib/tex/tex_codec.h +++ source/lib/tex/tex_codec.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -102,7 +102,7 @@ * return size of the file header supported by this codec. * * @param file the specific header to return length of (taking its - * variable-length fields into account). if NULL, return minimum + * variable-length fields into account). if nullptr, return minimum * guaranteed header size, i.e. the header without any * variable-length fields. * @return size [bytes] Index: source/lobby/Globals.cpp =================================================================== --- source/lobby/Globals.cpp +++ source/lobby/Globals.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -19,5 +19,5 @@ #include "IXmppClient.h" -IXmppClient *g_XmppClient = NULL; +IXmppClient *g_XmppClient = nullptr; bool g_rankedGame = false; Index: source/lobby/XmppClient.cpp =================================================================== --- source/lobby/XmppClient.cpp +++ source/lobby/XmppClient.cpp @@ -77,7 +77,7 @@ * @param regOpt If we are just registering or not. */ XmppClient::XmppClient(const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, const int historyRequestSize, bool regOpt) - : m_client(NULL), m_mucRoom(NULL), m_registration(NULL), m_username(sUsername), m_password(sPassword), m_room(sRoom), m_nick(sNick), m_initialLoadComplete(false), m_isConnected(false), m_sessionManager() + : m_client(nullptr), m_mucRoom(nullptr), m_registration(nullptr), m_username(sUsername), m_password(sPassword), m_room(sRoom), m_nick(sNick), m_initialLoadComplete(false), m_isConnected(false), m_sessionManager() { // Read lobby configuration from default.cfg std::string sXpartamupp; Index: source/network/NMTCreator.h =================================================================== --- source/network/NMTCreator.h +++ source/network/NMTCreator.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -213,7 +213,7 @@ #define START_NMTS() #define END_NMTS() -#define BAIL_DESERIALIZER return NULL +#define BAIL_DESERIALIZER return nullptr #define START_NMT_CLASS(_nm, _tp) \ START_NMT_CLASS_DERIVED(CNetMessage, _nm, _tp) @@ -241,7 +241,7 @@ /*printf("\t" #_nm " == 0x%x\n", thiz->_nm);*/ #define NMT_FIELD(_tp, _nm) \ - if ((pos=thiz->_nm.Deserialize(pos, end)) == NULL) BAIL_DESERIALIZER; + if ((pos=thiz->_nm.Deserialize(pos, end)) == nullptr) BAIL_DESERIALIZER; #define END_NMT_CLASS() \ return pos; \ Index: source/network/NetClient.h =================================================================== --- source/network/NetClient.h +++ source/network/NetClient.h @@ -107,7 +107,7 @@ * @param server IP address or host name to connect to * @return true on success, false on connection failure */ - bool SetupConnection(const CStr& server, const u16 port, ENetHost* enetClient = NULL); + bool SetupConnection(const CStr& server, const u16 port, ENetHost* enetClient = nullptr); /** * Destroy the connection to the server. @@ -263,10 +263,10 @@ CStrW m_UserName; CStr m_HostingPlayerName; - /// Current network session (or NULL if not connected) + /// Current network session (or nullptr if not connected) CNetClientSession* m_Session; - /// Turn manager associated with the current game (or NULL if we haven't started the game yet) + /// Turn manager associated with the current game (or nullptr if we haven't started the game yet) CNetClientTurnManager* m_ClientTurnManager; /// Unique-per-game identifier of this client, used to identify the sender of simulation commands Index: source/network/NetClient.cpp =================================================================== --- source/network/NetClient.cpp +++ source/network/NetClient.cpp @@ -36,7 +36,7 @@ #include "scriptinterface/ScriptInterface.h" #include "simulation2/Simulation2.h" -CNetClient *g_NetClient = NULL; +CNetClient *g_NetClient = nullptr; /** * Async task for receiving the initial game state when rejoining an @@ -68,15 +68,15 @@ }; CNetClient::CNetClient(CGame* game, bool isLocalClient) : - m_Session(NULL), + m_Session(nullptr), m_UserName(L"anonymous"), - m_HostID((u32)-1), m_ClientTurnManager(NULL), m_Game(game), + m_HostID((u32)-1), m_ClientTurnManager(nullptr), m_Game(game), m_GameAttributes(game->GetSimulation2()->GetScriptInterface().GetContext()), m_IsLocalClient(isLocalClient), m_LastConnectionCheck(0), m_Rejoin(false) { - m_Game->SetTurnManager(NULL); // delete the old local turn manager so we don't accidentally use it + m_Game->SetTurnManager(nullptr); // delete the old local turn manager so we don't accidentally use it void* context = this; @@ -315,7 +315,7 @@ void CNetClient::HandleConnect() { - Update((uint)NMT_CONNECT_COMPLETE, NULL); + Update((uint)NMT_CONNECT_COMPLETE, nullptr); } void CNetClient::HandleDisconnect(u32 reason) Index: source/network/NetHost.h =================================================================== --- source/network/NetHost.h +++ source/network/NetHost.h @@ -87,7 +87,7 @@ /** * Construct an ENet packet by serialising the given message. - * @return NULL on failure + * @return nullptr on failure */ static ENetPacket* CreatePacket(const CNetMessage* message); Index: source/network/NetMessage.h =================================================================== --- source/network/NetMessage.h +++ source/network/NetMessage.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -64,7 +64,7 @@ * @param pStart Message start within the serialized buffer * @param pEnd Message end within the serialized buffer * @return The position in the buffer right after the - * message or NULL if an error occurred + * message or nullptr if an error occurred */ virtual const u8* Deserialize(const u8* pStart, const u8* pEnd); Index: source/network/NetMessage.cpp =================================================================== --- source/network/NetMessage.cpp +++ source/network/NetMessage.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -55,7 +55,7 @@ if (pStart + 3 > pEnd) { LOGERROR("CNetMessage: Corrupt packet (smaller than header)"); - return NULL; + return nullptr; } const u8* pBuffer = pStart; @@ -69,7 +69,7 @@ if (pStart + size != pEnd) { LOGERROR("CNetMessage: Corrupt packet (incorrect size)"); - return NULL; + return nullptr; } return pBuffer; @@ -95,7 +95,7 @@ size_t dataSize, const ScriptInterface& scriptInterface) { - CNetMessage* pNewMessage = NULL; + CNetMessage* pNewMessage = nullptr; CNetMessage header; // Figure out message type Index: source/network/NetServer.cpp =================================================================== --- source/network/NetServer.cpp +++ source/network/NetServer.cpp @@ -66,11 +66,11 @@ */ static const int HOST_SERVICE_TIMEOUT = 50; -CNetServer* g_NetServer = NULL; +CNetServer* g_NetServer = nullptr; static CStr DebugName(CNetServerSession* session) { - if (session == NULL) + if (session == nullptr) return "[unknown host]"; if (session->GetGUID().empty()) return "[unauthed host]"; @@ -96,7 +96,7 @@ // we need to send it onwards to the newly rejoining player // Find the session corresponding to the rejoining host (if any) - CNetServerSession* session = NULL; + CNetServerSession* session = nullptr; for (CNetServerSession* serverSession : m_Server.m_Sessions) { if (serverSession->GetHostID() == m_RejoinerHostID) @@ -135,13 +135,13 @@ m_AutostartPlayers(autostartPlayers), m_LobbyAuth(useLobbyAuth), m_Shutdown(false), - m_ScriptInterface(NULL), - m_NextHostID(1), m_Host(NULL), m_HostGUID(), m_Stats(NULL), + m_ScriptInterface(nullptr), + m_NextHostID(1), m_Host(nullptr), m_HostGUID(), m_Stats(nullptr), m_LastConnectionCheck(0) { m_State = SERVER_STATE_UNCONNECTED; - m_ServerTurnManager = NULL; + m_ServerTurnManager = nullptr; m_ServerName = DEFAULT_SERVER_NAME; } @@ -157,7 +157,7 @@ } // Wait for it to shut down cleanly - pthread_join(m_WorkerThread, NULL); + pthread_join(m_WorkerThread, nullptr); } // Clean up resources @@ -201,12 +201,12 @@ m_State = SERVER_STATE_PREGAME; // Launch the worker thread - int ret = pthread_create(&m_WorkerThread, NULL, &RunThread, this); + int ret = pthread_create(&m_WorkerThread, nullptr, &RunThread, this); ENSURE(ret == 0); #if CONFIG2_MINIUPNPC // Launch the UPnP thread - ret = pthread_create(&m_UPnPThread, NULL, &SetupUPnP, NULL); + ret = pthread_create(&m_UPnPThread, nullptr, &SetupUPnP, nullptr); ENSURE(ret == 0); #endif @@ -231,7 +231,7 @@ // Intermediate variables. struct UPNPUrls urls; struct IGDdatas data; - struct UPNPDev* devlist = NULL; + struct UPNPDev* devlist = nullptr; // Cached root descriptor URL. std::string rootDescURL; @@ -250,9 +250,9 @@ } // No cached URL, or it did not respond. Try getting a valid UPnP device for 10 seconds. #if defined(MINIUPNPC_API_VERSION) && MINIUPNPC_API_VERSION >= 14 - else if ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 2, 0)) != NULL) + else if ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 2, 0)) != nullptr) #else - else if ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 0)) != NULL) + else if ((devlist = upnpDiscover(10000, 0, 0, 0, 0, 0)) != nullptr) #endif { ret = UPNP_GetValidIGD(devlist, &urls, &data, internalIPAddress, sizeof(internalIPAddress)); @@ -261,7 +261,7 @@ else { LOGMESSAGE("Net server: upnpDiscover failed and no working cached URL."); - return NULL; + return nullptr; } switch (ret) @@ -287,7 +287,7 @@ if (ret != UPNPCOMMAND_SUCCESS) { LOGMESSAGE("Net server: GetExternalIPAddress failed with code %d (%s)", ret, strupnperror(ret)); - return NULL; + return nullptr; } LOGMESSAGE("Net server: ExternalIPAddress = %s", externalIPAddress); @@ -298,7 +298,7 @@ { LOGMESSAGE("Net server: AddPortMapping(%s, %s, %s) failed with code %d (%s)", psPort, psPort, internalIPAddress, ret, strupnperror(ret)); - return NULL; + return nullptr; } // Check that the port was actually forwarded. @@ -306,15 +306,15 @@ data.first.servicetype, psPort, protocall, #if defined(MINIUPNPC_API_VERSION) && MINIUPNPC_API_VERSION >= 10 - NULL/*remoteHost*/, + nullptr/*remoteHost*/, #endif - intClient, intPort, NULL/*desc*/, - NULL/*enabled*/, duration); + intClient, intPort, nullptr/*desc*/, + nullptr/*enabled*/, duration); if (ret != UPNPCOMMAND_SUCCESS) { LOGMESSAGE("Net server: GetSpecificPortMappingEntry() failed with code %d (%s)", ret, strupnperror(ret)); - return NULL; + return nullptr; } LOGMESSAGE("Net server: External %s:%s %s is redirected to internal %s:%s (duration=%s)", @@ -331,7 +331,7 @@ freeUPNPDevlist(devlist); - return NULL; + return nullptr; } #endif // CONFIG2_MINIUPNPC @@ -367,7 +367,7 @@ static_cast(data)->Run(); - return NULL; + return nullptr; } void CNetServerWorker::Run() @@ -490,7 +490,7 @@ SetupSession(session); - ENSURE(event.peer->data == NULL); + ENSURE(event.peer->data == nullptr); event.peer->data = session; HandleConnect(session); @@ -511,14 +511,14 @@ // when updating the FSM m_Sessions.erase(remove(m_Sessions.begin(), m_Sessions.end(), session), m_Sessions.end()); - session->Update((uint)NMT_CONNECTION_LOST, NULL); + session->Update((uint)NMT_CONNECTION_LOST, nullptr); delete session; - event.peer->data = NULL; + event.peer->data = nullptr; } if (m_State == SERVER_STATE_LOADING) - CheckGameLoadStatus(NULL); + CheckGameLoadStatus(nullptr); break; } Index: source/network/NetSession.cpp =================================================================== --- source/network/NetSession.cpp +++ source/network/NetSession.cpp @@ -67,8 +67,8 @@ enet_peer_disconnect_now(m_Server, NDR_SERVER_SHUTDOWN); enet_host_destroy(m_Host); - m_Host = NULL; - m_Server = NULL; + m_Host = nullptr; + m_Server = nullptr; } } @@ -82,7 +82,7 @@ if (enetClient != nullptr) host = enetClient; else - host = enet_host_create(NULL, 1, CHANNEL_COUNT, 0, 0); + host = enet_host_create(nullptr, 1, CHANNEL_COUNT, 0, 0); if (!host) return false; @@ -123,8 +123,8 @@ enet_peer_disconnect_now(m_Server, reason); enet_host_destroy(m_Host); - m_Host = NULL; - m_Server = NULL; + m_Host = nullptr; + m_Server = nullptr; SAFE_DELETE(m_Stats); } @@ -254,7 +254,7 @@ void CNetServerSession::Disconnect(u32 reason) { - Update((uint)NMT_CONNECTION_LOST, NULL); + Update((uint)NMT_CONNECTION_LOST, nullptr); enet_peer_disconnect(m_Peer, reason); } Index: source/network/NetStats.cpp =================================================================== --- source/network/NetStats.cpp +++ source/network/NetStats.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -43,7 +43,7 @@ } CNetStatsTable::CNetStatsTable() - : m_Peer(NULL) + : m_Peer(nullptr) { } Index: source/network/Serialization.h =================================================================== --- source/network/Serialization.h +++ source/network/Serialization.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -97,7 +97,7 @@ * @param end A pointer to the end of the message. * * @returns a pointer to the location in the buffer right after the - * serialized object, or NULL if there was a data format error + * serialized object, or nullptr if there was a data format error */ virtual const u8 *Deserialize(const u8 *buffer, const u8 *end) = 0; }; Index: source/network/fsm.cpp =================================================================== --- source/network/fsm.cpp +++ source/network/fsm.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -28,7 +28,7 @@ CFsmEvent::CFsmEvent( unsigned int type ) { m_Type = type; - m_Param = NULL; + m_Param = nullptr; } //----------------------------------------------------------------------------- @@ -37,7 +37,7 @@ //----------------------------------------------------------------------------- CFsmEvent::~CFsmEvent( void ) { - m_Param = NULL; + m_Param = nullptr; } //----------------------------------------------------------------------------- @@ -245,7 +245,7 @@ //----------------------------------------------------------------------------- CFsmEvent* CFsm::AddEvent( unsigned int eventType ) { - CFsmEvent* pEvent = NULL; + CFsmEvent* pEvent = nullptr; // Lookup event by type EventMap::iterator it = m_Events.find( eventType ); @@ -256,7 +256,7 @@ else { pEvent = new CFsmEvent( eventType ); - if ( !pEvent ) return NULL; + if ( !pEvent ) return nullptr; // Store new event into internal map m_Events[ eventType ] = pEvent; @@ -282,14 +282,14 @@ // Make sure we store the event CFsmEvent* pEvent = AddEvent( eventType ); - if ( !pEvent ) return NULL; + if ( !pEvent ) return nullptr; // Create new transition CFsmTransition* pNewTransition = new CFsmTransition( state ); if ( !pNewTransition ) { delete pEvent; - return NULL; + return nullptr; } // Setup new transition @@ -314,7 +314,7 @@ void* pContext ) { CFsmTransition* pTransition = AddTransition( state, eventType, nextState ); - if ( !pTransition ) return NULL; + if ( !pTransition ) return nullptr; // If action specified, register it if ( pAction ) @@ -332,10 +332,10 @@ unsigned int eventType ) const { // Valid state? - if ( !IsValidState( state ) ) return NULL; + if ( !IsValidState( state ) ) return nullptr; // Valid event? - if ( !IsValidEvent( eventType ) ) return NULL; + if ( !IsValidEvent( eventType ) ) return nullptr; // Loop through the list of transitions TransitionList::const_iterator it = m_Transitions.begin(); @@ -356,7 +356,7 @@ } // No transition found - return NULL; + return nullptr; } //----------------------------------------------------------------------------- Index: source/ps/CConsole.cpp =================================================================== --- source/ps/CConsole.cpp +++ source/ps/CConsole.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -548,7 +548,7 @@ JSContext* cx = pScriptInterface->GetContext(); JSAutoRequest rq(cx); - if (szLine == NULL) return; + if (szLine == nullptr) return; if (wcslen(szLine) <= 0) return; ENSURE(wcslen(szLine) < CONSOLE_BUFFER_SIZE); Index: source/ps/CLogger.cpp =================================================================== --- source/ps/CLogger.cpp +++ source/ps/CLogger.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -108,7 +108,7 @@ char buffer[128]; sprintf_s(buffer, ARRAY_SIZE(buffer), " with %d message(s), %d error(s) and %d warning(s).", m_NumberOfMessages,m_NumberOfErrors,m_NumberOfWarnings); - time_t t = time(NULL); + time_t t = time(nullptr); struct tm* now = localtime(&t); char currentDate[17]; sprintf_s(currentDate, ARRAY_SIZE(currentDate), "%04d-%02d-%02d", 1900+now->tm_year, 1+now->tm_mon, now->tm_mday); @@ -266,7 +266,7 @@ // Add each message line separately const char* pos = message; const char* eol; - while ((eol = strchr(pos, '\n')) != NULL) + while ((eol = strchr(pos, '\n')) != nullptr) { if (eol != pos) { Index: source/ps/CStr.cpp =================================================================== --- source/ps/CStr.cpp +++ source/ps/CStr.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -456,7 +456,7 @@ { const u16 *strend = (const u16 *)buffer; while ((const u8 *)strend < bufferend && *strend) strend++; - if ((const u8 *)strend >= bufferend) return NULL; + if ((const u8 *)strend >= bufferend) return nullptr; resize(strend - (const u16 *)buffer); const u16 *ptr = (const u16 *)buffer; @@ -497,7 +497,7 @@ u32 len; Deserialize_int_4(buffer, len); if (buffer + len > bufferend) - return NULL; + return nullptr; *this = std::string(buffer, buffer + len); return buffer + len; } Index: source/ps/CacheLoader.cpp =================================================================== --- source/ps/CacheLoader.cpp +++ source/ps/CacheLoader.cpp @@ -46,7 +46,7 @@ // are some uncached .pmd/psa files in the game with no source .dae. // This test fails (correctly) in that valid situation, so it seems // best to leave the error handling to the caller. - Status err = m_VFS->GetFileInfo(sourcePath, NULL); + Status err = m_VFS->GetFileInfo(sourcePath, nullptr); if (err < 0) { return err; @@ -57,7 +57,7 @@ VfsPath looseCachePath = LooseCachePath(sourcePath, initialHash, version); // If the loose cache file exists, use it - if (m_VFS->GetFileInfo(looseCachePath, NULL) >= 0) + if (m_VFS->GetFileInfo(looseCachePath, nullptr) >= 0) { loadPath = looseCachePath; return INFO::OK; Index: source/ps/ConfigDB.cpp =================================================================== --- source/ps/ConfigDB.cpp +++ source/ps/ConfigDB.cpp @@ -253,7 +253,7 @@ size_t buflen; { // Handle missing files quietly - if (g_VFS->GetFileInfo(m_ConfigFile[ns], NULL) < 0) + if (g_VFS->GetFileInfo(m_ConfigFile[ns], nullptr) < 0) { LOGMESSAGE("Cannot find config file \"%s\" - ignoring", m_ConfigFile[ns].string8()); return false; Index: source/ps/DllLoader.h =================================================================== --- source/ps/DllLoader.h +++ source/ps/DllLoader.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -64,7 +64,7 @@ * Attempt to load a named symbol from the library. If {@link #IsLoaded} is * false, throws PSERROR_DllLoader_DllNotLoaded. If it cannot load the * symbol, throws PSERROR_DllLoader_SymbolNotFound. In both cases, sets fptr - * to NULL. Otherwise, fptr is set to point to the loaded function. + * to nullptr. Otherwise, fptr is set to point to the loaded function. * * @throws PSERROR_DllLoader */ Index: source/ps/DllLoader.cpp =================================================================== --- source/ps/DllLoader.cpp +++ source/ps/DllLoader.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -182,12 +182,12 @@ if (!IsLoaded()) { debug_warn(L"Loading symbol from invalid DLL"); - *fptr = NULL; + *fptr = nullptr; throw PSERROR_DllLoader_DllNotLoaded(); } *fptr = dlsym(m_Handle, name); - if (*fptr == NULL) + if (*fptr == nullptr) throw PSERROR_DllLoader_SymbolNotFound(); } Index: source/ps/Errors.cpp =================================================================== --- source/ps/Errors.cpp +++ source/ps/Errors.cpp @@ -263,187 +263,187 @@ PSERROR_Scripting_DefineType::PSERROR_Scripting_DefineType(const char* msg) : PSERROR_Scripting(msg) { } PSERROR_Scripting_LoadFile::PSERROR_Scripting_LoadFile(const char* msg) : PSERROR_Scripting(msg) { } -PSERROR_CVFSFile_AlreadyLoaded::PSERROR_CVFSFile_AlreadyLoaded() : PSERROR_CVFSFile(NULL) { } +PSERROR_CVFSFile_AlreadyLoaded::PSERROR_CVFSFile_AlreadyLoaded() : PSERROR_CVFSFile(nullptr) { } PSERROR_CVFSFile_AlreadyLoaded::PSERROR_CVFSFile_AlreadyLoaded(const char* msg) : PSERROR_CVFSFile(msg) { } PSRETURN PSERROR_CVFSFile_AlreadyLoaded::getCode() const { return 0x01000001; } -PSERROR_CVFSFile_InvalidBufferAccess::PSERROR_CVFSFile_InvalidBufferAccess() : PSERROR_CVFSFile(NULL) { } +PSERROR_CVFSFile_InvalidBufferAccess::PSERROR_CVFSFile_InvalidBufferAccess() : PSERROR_CVFSFile(nullptr) { } PSERROR_CVFSFile_InvalidBufferAccess::PSERROR_CVFSFile_InvalidBufferAccess(const char* msg) : PSERROR_CVFSFile(msg) { } PSRETURN PSERROR_CVFSFile_InvalidBufferAccess::getCode() const { return 0x01000002; } -PSERROR_CVFSFile_LoadFailed::PSERROR_CVFSFile_LoadFailed() : PSERROR_CVFSFile(NULL) { } +PSERROR_CVFSFile_LoadFailed::PSERROR_CVFSFile_LoadFailed() : PSERROR_CVFSFile(nullptr) { } PSERROR_CVFSFile_LoadFailed::PSERROR_CVFSFile_LoadFailed(const char* msg) : PSERROR_CVFSFile(msg) { } PSRETURN PSERROR_CVFSFile_LoadFailed::getCode() const { return 0x01000003; } -PSERROR_Deserialize_InvalidCharInString::PSERROR_Deserialize_InvalidCharInString() : PSERROR_Deserialize(NULL) { } +PSERROR_Deserialize_InvalidCharInString::PSERROR_Deserialize_InvalidCharInString() : PSERROR_Deserialize(nullptr) { } PSERROR_Deserialize_InvalidCharInString::PSERROR_Deserialize_InvalidCharInString(const char* msg) : PSERROR_Deserialize(msg) { } PSRETURN PSERROR_Deserialize_InvalidCharInString::getCode() const { return 0x02000001; } -PSERROR_Deserialize_OutOfBounds::PSERROR_Deserialize_OutOfBounds() : PSERROR_Deserialize(NULL) { } +PSERROR_Deserialize_OutOfBounds::PSERROR_Deserialize_OutOfBounds() : PSERROR_Deserialize(nullptr) { } PSERROR_Deserialize_OutOfBounds::PSERROR_Deserialize_OutOfBounds(const char* msg) : PSERROR_Deserialize(msg) { } PSRETURN PSERROR_Deserialize_OutOfBounds::getCode() const { return 0x02000002; } -PSERROR_Deserialize_ReadFailed::PSERROR_Deserialize_ReadFailed() : PSERROR_Deserialize(NULL) { } +PSERROR_Deserialize_ReadFailed::PSERROR_Deserialize_ReadFailed() : PSERROR_Deserialize(nullptr) { } PSERROR_Deserialize_ReadFailed::PSERROR_Deserialize_ReadFailed(const char* msg) : PSERROR_Deserialize(msg) { } PSRETURN PSERROR_Deserialize_ReadFailed::getCode() const { return 0x02000003; } -PSERROR_Deserialize_ScriptError::PSERROR_Deserialize_ScriptError() : PSERROR_Deserialize(NULL) { } +PSERROR_Deserialize_ScriptError::PSERROR_Deserialize_ScriptError() : PSERROR_Deserialize(nullptr) { } PSERROR_Deserialize_ScriptError::PSERROR_Deserialize_ScriptError(const char* msg) : PSERROR_Deserialize(msg) { } PSRETURN PSERROR_Deserialize_ScriptError::getCode() const { return 0x02000004; } -PSERROR_DllLoader_DllNotLoaded::PSERROR_DllLoader_DllNotLoaded() : PSERROR_DllLoader(NULL) { } +PSERROR_DllLoader_DllNotLoaded::PSERROR_DllLoader_DllNotLoaded() : PSERROR_DllLoader(nullptr) { } PSERROR_DllLoader_DllNotLoaded::PSERROR_DllLoader_DllNotLoaded(const char* msg) : PSERROR_DllLoader(msg) { } PSRETURN PSERROR_DllLoader_DllNotLoaded::getCode() const { return 0x03000001; } -PSERROR_DllLoader_SymbolNotFound::PSERROR_DllLoader_SymbolNotFound() : PSERROR_DllLoader(NULL) { } +PSERROR_DllLoader_SymbolNotFound::PSERROR_DllLoader_SymbolNotFound() : PSERROR_DllLoader(nullptr) { } PSERROR_DllLoader_SymbolNotFound::PSERROR_DllLoader_SymbolNotFound(const char* msg) : PSERROR_DllLoader(msg) { } PSRETURN PSERROR_DllLoader_SymbolNotFound::getCode() const { return 0x03000002; } -PSERROR_Error_InvalidError::PSERROR_Error_InvalidError() : PSERROR_Error(NULL) { } +PSERROR_Error_InvalidError::PSERROR_Error_InvalidError() : PSERROR_Error(nullptr) { } PSERROR_Error_InvalidError::PSERROR_Error_InvalidError(const char* msg) : PSERROR_Error(msg) { } PSRETURN PSERROR_Error_InvalidError::getCode() const { return 0x04000001; } -PSERROR_File_InvalidType::PSERROR_File_InvalidType() : PSERROR_File(NULL) { } +PSERROR_File_InvalidType::PSERROR_File_InvalidType() : PSERROR_File(nullptr) { } PSERROR_File_InvalidType::PSERROR_File_InvalidType(const char* msg) : PSERROR_File(msg) { } PSRETURN PSERROR_File_InvalidType::getCode() const { return 0x05000001; } -PSERROR_File_InvalidVersion::PSERROR_File_InvalidVersion() : PSERROR_File(NULL) { } +PSERROR_File_InvalidVersion::PSERROR_File_InvalidVersion() : PSERROR_File(nullptr) { } PSERROR_File_InvalidVersion::PSERROR_File_InvalidVersion(const char* msg) : PSERROR_File(msg) { } PSRETURN PSERROR_File_InvalidVersion::getCode() const { return 0x05000002; } -PSERROR_File_OpenFailed::PSERROR_File_OpenFailed() : PSERROR_File(NULL) { } +PSERROR_File_OpenFailed::PSERROR_File_OpenFailed() : PSERROR_File(nullptr) { } PSERROR_File_OpenFailed::PSERROR_File_OpenFailed(const char* msg) : PSERROR_File(msg) { } PSRETURN PSERROR_File_OpenFailed::getCode() const { return 0x05000003; } -PSERROR_File_ReadFailed::PSERROR_File_ReadFailed() : PSERROR_File(NULL) { } +PSERROR_File_ReadFailed::PSERROR_File_ReadFailed() : PSERROR_File(nullptr) { } PSERROR_File_ReadFailed::PSERROR_File_ReadFailed(const char* msg) : PSERROR_File(msg) { } PSRETURN PSERROR_File_ReadFailed::getCode() const { return 0x05000004; } -PSERROR_File_UnexpectedEOF::PSERROR_File_UnexpectedEOF() : PSERROR_File(NULL) { } +PSERROR_File_UnexpectedEOF::PSERROR_File_UnexpectedEOF() : PSERROR_File(nullptr) { } PSERROR_File_UnexpectedEOF::PSERROR_File_UnexpectedEOF(const char* msg) : PSERROR_File(msg) { } PSRETURN PSERROR_File_UnexpectedEOF::getCode() const { return 0x05000005; } -PSERROR_File_WriteFailed::PSERROR_File_WriteFailed() : PSERROR_File(NULL) { } +PSERROR_File_WriteFailed::PSERROR_File_WriteFailed() : PSERROR_File(nullptr) { } PSERROR_File_WriteFailed::PSERROR_File_WriteFailed(const char* msg) : PSERROR_File(msg) { } PSRETURN PSERROR_File_WriteFailed::getCode() const { return 0x05000006; } -PSERROR_GUI_InvalidSetting::PSERROR_GUI_InvalidSetting() : PSERROR_GUI(NULL) { } +PSERROR_GUI_InvalidSetting::PSERROR_GUI_InvalidSetting() : PSERROR_GUI(nullptr) { } PSERROR_GUI_InvalidSetting::PSERROR_GUI_InvalidSetting(const char* msg) : PSERROR_GUI(msg) { } PSRETURN PSERROR_GUI_InvalidSetting::getCode() const { return 0x06000001; } -PSERROR_GUI_JSOpenFailed::PSERROR_GUI_JSOpenFailed() : PSERROR_GUI(NULL) { } +PSERROR_GUI_JSOpenFailed::PSERROR_GUI_JSOpenFailed() : PSERROR_GUI(nullptr) { } PSERROR_GUI_JSOpenFailed::PSERROR_GUI_JSOpenFailed(const char* msg) : PSERROR_GUI(msg) { } PSRETURN PSERROR_GUI_JSOpenFailed::getCode() const { return 0x06000002; } -PSERROR_GUI_NameAmbiguity::PSERROR_GUI_NameAmbiguity() : PSERROR_GUI(NULL) { } +PSERROR_GUI_NameAmbiguity::PSERROR_GUI_NameAmbiguity() : PSERROR_GUI(nullptr) { } PSERROR_GUI_NameAmbiguity::PSERROR_GUI_NameAmbiguity(const char* msg) : PSERROR_GUI(msg) { } PSRETURN PSERROR_GUI_NameAmbiguity::getCode() const { return 0x06000003; } -PSERROR_GUI_NullObjectProvided::PSERROR_GUI_NullObjectProvided() : PSERROR_GUI(NULL) { } +PSERROR_GUI_NullObjectProvided::PSERROR_GUI_NullObjectProvided() : PSERROR_GUI(nullptr) { } PSERROR_GUI_NullObjectProvided::PSERROR_GUI_NullObjectProvided(const char* msg) : PSERROR_GUI(msg) { } PSRETURN PSERROR_GUI_NullObjectProvided::getCode() const { return 0x06000004; } -PSERROR_GUI_ObjectNeedsName::PSERROR_GUI_ObjectNeedsName() : PSERROR_GUI(NULL) { } +PSERROR_GUI_ObjectNeedsName::PSERROR_GUI_ObjectNeedsName() : PSERROR_GUI(nullptr) { } PSERROR_GUI_ObjectNeedsName::PSERROR_GUI_ObjectNeedsName(const char* msg) : PSERROR_GUI(msg) { } PSRETURN PSERROR_GUI_ObjectNeedsName::getCode() const { return 0x06000005; } -PSERROR_GUI_OperationNeedsGUIObject::PSERROR_GUI_OperationNeedsGUIObject() : PSERROR_GUI(NULL) { } +PSERROR_GUI_OperationNeedsGUIObject::PSERROR_GUI_OperationNeedsGUIObject() : PSERROR_GUI(nullptr) { } PSERROR_GUI_OperationNeedsGUIObject::PSERROR_GUI_OperationNeedsGUIObject(const char* msg) : PSERROR_GUI(msg) { } PSRETURN PSERROR_GUI_OperationNeedsGUIObject::getCode() const { return 0x06000006; } -PSERROR_GUI_UnableToParse::PSERROR_GUI_UnableToParse() : PSERROR_GUI(NULL) { } +PSERROR_GUI_UnableToParse::PSERROR_GUI_UnableToParse() : PSERROR_GUI(nullptr) { } PSERROR_GUI_UnableToParse::PSERROR_GUI_UnableToParse(const char* msg) : PSERROR_GUI(msg) { } PSRETURN PSERROR_GUI_UnableToParse::getCode() const { return 0x06000007; } -PSERROR_Game_World_MapLoadFailed::PSERROR_Game_World_MapLoadFailed() : PSERROR_Game_World(NULL) { } +PSERROR_Game_World_MapLoadFailed::PSERROR_Game_World_MapLoadFailed() : PSERROR_Game_World(nullptr) { } PSERROR_Game_World_MapLoadFailed::PSERROR_Game_World_MapLoadFailed(const char* msg) : PSERROR_Game_World(msg) { } PSRETURN PSERROR_Game_World_MapLoadFailed::getCode() const { return 0x07040001; } -PSERROR_I18n_Script_SetupFailed::PSERROR_I18n_Script_SetupFailed() : PSERROR_I18n_Script(NULL) { } +PSERROR_I18n_Script_SetupFailed::PSERROR_I18n_Script_SetupFailed() : PSERROR_I18n_Script(nullptr) { } PSERROR_I18n_Script_SetupFailed::PSERROR_I18n_Script_SetupFailed(const char* msg) : PSERROR_I18n_Script(msg) { } PSRETURN PSERROR_I18n_Script_SetupFailed::getCode() const { return 0x08030001; } -PSERROR_Renderer_VBOFailed::PSERROR_Renderer_VBOFailed() : PSERROR_Renderer(NULL) { } +PSERROR_Renderer_VBOFailed::PSERROR_Renderer_VBOFailed() : PSERROR_Renderer(nullptr) { } PSERROR_Renderer_VBOFailed::PSERROR_Renderer_VBOFailed(const char* msg) : PSERROR_Renderer(msg) { } PSRETURN PSERROR_Renderer_VBOFailed::getCode() const { return 0x09000001; } -PSERROR_Scripting_DefineType_AlreadyExists::PSERROR_Scripting_DefineType_AlreadyExists() : PSERROR_Scripting_DefineType(NULL) { } +PSERROR_Scripting_DefineType_AlreadyExists::PSERROR_Scripting_DefineType_AlreadyExists() : PSERROR_Scripting_DefineType(nullptr) { } PSERROR_Scripting_DefineType_AlreadyExists::PSERROR_Scripting_DefineType_AlreadyExists(const char* msg) : PSERROR_Scripting_DefineType(msg) { } PSRETURN PSERROR_Scripting_DefineType_AlreadyExists::getCode() const { return 0x0a010001; } -PSERROR_Scripting_DefineType_CreationFailed::PSERROR_Scripting_DefineType_CreationFailed() : PSERROR_Scripting_DefineType(NULL) { } +PSERROR_Scripting_DefineType_CreationFailed::PSERROR_Scripting_DefineType_CreationFailed() : PSERROR_Scripting_DefineType(nullptr) { } PSERROR_Scripting_DefineType_CreationFailed::PSERROR_Scripting_DefineType_CreationFailed(const char* msg) : PSERROR_Scripting_DefineType(msg) { } PSRETURN PSERROR_Scripting_DefineType_CreationFailed::getCode() const { return 0x0a010002; } -PSERROR_Scripting_LoadFile_EvalErrors::PSERROR_Scripting_LoadFile_EvalErrors() : PSERROR_Scripting_LoadFile(NULL) { } +PSERROR_Scripting_LoadFile_EvalErrors::PSERROR_Scripting_LoadFile_EvalErrors() : PSERROR_Scripting_LoadFile(nullptr) { } PSERROR_Scripting_LoadFile_EvalErrors::PSERROR_Scripting_LoadFile_EvalErrors(const char* msg) : PSERROR_Scripting_LoadFile(msg) { } PSRETURN PSERROR_Scripting_LoadFile_EvalErrors::getCode() const { return 0x0a020001; } -PSERROR_Scripting_LoadFile_OpenFailed::PSERROR_Scripting_LoadFile_OpenFailed() : PSERROR_Scripting_LoadFile(NULL) { } +PSERROR_Scripting_LoadFile_OpenFailed::PSERROR_Scripting_LoadFile_OpenFailed() : PSERROR_Scripting_LoadFile(nullptr) { } PSERROR_Scripting_LoadFile_OpenFailed::PSERROR_Scripting_LoadFile_OpenFailed(const char* msg) : PSERROR_Scripting_LoadFile(msg) { } PSRETURN PSERROR_Scripting_LoadFile_OpenFailed::getCode() const { return 0x0a020002; } -PSERROR_Scripting_CallFunctionFailed::PSERROR_Scripting_CallFunctionFailed() : PSERROR_Scripting(NULL) { } +PSERROR_Scripting_CallFunctionFailed::PSERROR_Scripting_CallFunctionFailed() : PSERROR_Scripting(nullptr) { } PSERROR_Scripting_CallFunctionFailed::PSERROR_Scripting_CallFunctionFailed(const char* msg) : PSERROR_Scripting(msg) { } PSRETURN PSERROR_Scripting_CallFunctionFailed::getCode() const { return 0x0a000001; } -PSERROR_Scripting_ConversionFailed::PSERROR_Scripting_ConversionFailed() : PSERROR_Scripting(NULL) { } +PSERROR_Scripting_ConversionFailed::PSERROR_Scripting_ConversionFailed() : PSERROR_Scripting(nullptr) { } PSERROR_Scripting_ConversionFailed::PSERROR_Scripting_ConversionFailed(const char* msg) : PSERROR_Scripting(msg) { } PSRETURN PSERROR_Scripting_ConversionFailed::getCode() const { return 0x0a000002; } -PSERROR_Scripting_CreateObjectFailed::PSERROR_Scripting_CreateObjectFailed() : PSERROR_Scripting(NULL) { } +PSERROR_Scripting_CreateObjectFailed::PSERROR_Scripting_CreateObjectFailed() : PSERROR_Scripting(nullptr) { } PSERROR_Scripting_CreateObjectFailed::PSERROR_Scripting_CreateObjectFailed(const char* msg) : PSERROR_Scripting(msg) { } PSRETURN PSERROR_Scripting_CreateObjectFailed::getCode() const { return 0x0a000003; } -PSERROR_Scripting_DefineConstantFailed::PSERROR_Scripting_DefineConstantFailed() : PSERROR_Scripting(NULL) { } +PSERROR_Scripting_DefineConstantFailed::PSERROR_Scripting_DefineConstantFailed() : PSERROR_Scripting(nullptr) { } PSERROR_Scripting_DefineConstantFailed::PSERROR_Scripting_DefineConstantFailed(const char* msg) : PSERROR_Scripting(msg) { } PSRETURN PSERROR_Scripting_DefineConstantFailed::getCode() const { return 0x0a000004; } -PSERROR_Scripting_RegisterFunctionFailed::PSERROR_Scripting_RegisterFunctionFailed() : PSERROR_Scripting(NULL) { } +PSERROR_Scripting_RegisterFunctionFailed::PSERROR_Scripting_RegisterFunctionFailed() : PSERROR_Scripting(nullptr) { } PSERROR_Scripting_RegisterFunctionFailed::PSERROR_Scripting_RegisterFunctionFailed(const char* msg) : PSERROR_Scripting(msg) { } PSRETURN PSERROR_Scripting_RegisterFunctionFailed::getCode() const { return 0x0a000005; } -PSERROR_Scripting_SetupFailed::PSERROR_Scripting_SetupFailed() : PSERROR_Scripting(NULL) { } +PSERROR_Scripting_SetupFailed::PSERROR_Scripting_SetupFailed() : PSERROR_Scripting(nullptr) { } PSERROR_Scripting_SetupFailed::PSERROR_Scripting_SetupFailed(const char* msg) : PSERROR_Scripting(msg) { } PSRETURN PSERROR_Scripting_SetupFailed::getCode() const { return 0x0a000006; } -PSERROR_Scripting_TypeDoesNotExist::PSERROR_Scripting_TypeDoesNotExist() : PSERROR_Scripting(NULL) { } +PSERROR_Scripting_TypeDoesNotExist::PSERROR_Scripting_TypeDoesNotExist() : PSERROR_Scripting(nullptr) { } PSERROR_Scripting_TypeDoesNotExist::PSERROR_Scripting_TypeDoesNotExist(const char* msg) : PSERROR_Scripting(msg) { } PSRETURN PSERROR_Scripting_TypeDoesNotExist::getCode() const { return 0x0a000007; } -PSERROR_Serialize_InvalidCharInString::PSERROR_Serialize_InvalidCharInString() : PSERROR_Serialize(NULL) { } +PSERROR_Serialize_InvalidCharInString::PSERROR_Serialize_InvalidCharInString() : PSERROR_Serialize(nullptr) { } PSERROR_Serialize_InvalidCharInString::PSERROR_Serialize_InvalidCharInString(const char* msg) : PSERROR_Serialize(msg) { } PSRETURN PSERROR_Serialize_InvalidCharInString::getCode() const { return 0x0b000001; } -PSERROR_Serialize_InvalidScriptValue::PSERROR_Serialize_InvalidScriptValue() : PSERROR_Serialize(NULL) { } +PSERROR_Serialize_InvalidScriptValue::PSERROR_Serialize_InvalidScriptValue() : PSERROR_Serialize(nullptr) { } PSERROR_Serialize_InvalidScriptValue::PSERROR_Serialize_InvalidScriptValue(const char* msg) : PSERROR_Serialize(msg) { } PSRETURN PSERROR_Serialize_InvalidScriptValue::getCode() const { return 0x0b000002; } -PSERROR_Serialize_OutOfBounds::PSERROR_Serialize_OutOfBounds() : PSERROR_Serialize(NULL) { } +PSERROR_Serialize_OutOfBounds::PSERROR_Serialize_OutOfBounds() : PSERROR_Serialize(nullptr) { } PSERROR_Serialize_OutOfBounds::PSERROR_Serialize_OutOfBounds(const char* msg) : PSERROR_Serialize(msg) { } PSRETURN PSERROR_Serialize_OutOfBounds::getCode() const { return 0x0b000003; } -PSERROR_Serialize_ScriptError::PSERROR_Serialize_ScriptError() : PSERROR_Serialize(NULL) { } +PSERROR_Serialize_ScriptError::PSERROR_Serialize_ScriptError() : PSERROR_Serialize(nullptr) { } PSERROR_Serialize_ScriptError::PSERROR_Serialize_ScriptError(const char* msg) : PSERROR_Serialize(msg) { } PSRETURN PSERROR_Serialize_ScriptError::getCode() const { return 0x0b000004; } -PSERROR_System_RequiredExtensionsMissing::PSERROR_System_RequiredExtensionsMissing() : PSERROR_System(NULL) { } +PSERROR_System_RequiredExtensionsMissing::PSERROR_System_RequiredExtensionsMissing() : PSERROR_System(nullptr) { } PSERROR_System_RequiredExtensionsMissing::PSERROR_System_RequiredExtensionsMissing(const char* msg) : PSERROR_System(msg) { } PSRETURN PSERROR_System_RequiredExtensionsMissing::getCode() const { return 0x0c000001; } -PSERROR_System_SDLInitFailed::PSERROR_System_SDLInitFailed() : PSERROR_System(NULL) { } +PSERROR_System_SDLInitFailed::PSERROR_System_SDLInitFailed() : PSERROR_System(nullptr) { } PSERROR_System_SDLInitFailed::PSERROR_System_SDLInitFailed(const char* msg) : PSERROR_System(msg) { } PSRETURN PSERROR_System_SDLInitFailed::getCode() const { return 0x0c000002; } -PSERROR_System_VmodeFailed::PSERROR_System_VmodeFailed() : PSERROR_System(NULL) { } +PSERROR_System_VmodeFailed::PSERROR_System_VmodeFailed() : PSERROR_System(nullptr) { } PSERROR_System_VmodeFailed::PSERROR_System_VmodeFailed(const char* msg) : PSERROR_System(msg) { } PSRETURN PSERROR_System_VmodeFailed::getCode() const { return 0x0c000003; } -PSERROR_Xeromyces_XMLOpenFailed::PSERROR_Xeromyces_XMLOpenFailed() : PSERROR_Xeromyces(NULL) { } +PSERROR_Xeromyces_XMLOpenFailed::PSERROR_Xeromyces_XMLOpenFailed() : PSERROR_Xeromyces(nullptr) { } PSERROR_Xeromyces_XMLOpenFailed::PSERROR_Xeromyces_XMLOpenFailed(const char* msg) : PSERROR_Xeromyces(msg) { } PSRETURN PSERROR_Xeromyces_XMLOpenFailed::getCode() const { return 0x0d000001; } -PSERROR_Xeromyces_XMLParseError::PSERROR_Xeromyces_XMLParseError() : PSERROR_Xeromyces(NULL) { } +PSERROR_Xeromyces_XMLParseError::PSERROR_Xeromyces_XMLParseError() : PSERROR_Xeromyces(nullptr) { } PSERROR_Xeromyces_XMLParseError::PSERROR_Xeromyces_XMLParseError(const char* msg) : PSERROR_Xeromyces(msg) { } PSRETURN PSERROR_Xeromyces_XMLParseError::getCode() const { return 0x0d000002; } Index: source/ps/Filesystem.cpp =================================================================== --- source/ps/Filesystem.cpp +++ source/ps/Filesystem.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -38,7 +38,7 @@ bool VfsDirectoryExists(const VfsPath& pathname) { ENSURE(pathname.IsDirectory()); - return g_VFS->GetDirectoryEntries(pathname, NULL, NULL) == INFO::OK; + return g_VFS->GetDirectoryEntries(pathname, nullptr, nullptr) == INFO::OK; } void RegisterFileReloadFunc(FileReloadFunc func, void* obj) Index: source/ps/Game.h =================================================================== --- source/ps/Game.h +++ source/ps/Game.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -144,7 +144,7 @@ /** * Get if the graphics is disabled. * - * @return bool true if the m_GameView is NULL, false otherwise. + * @return bool true if the m_GameView is nullptr, false otherwise. */ inline bool IsGraphicsDisabled() const { Index: source/ps/Game.cpp =================================================================== --- source/ps/Game.cpp +++ source/ps/Game.cpp @@ -57,7 +57,7 @@ /** * Globally accessible pointer to the CGame object. **/ -CGame *g_Game=NULL; +CGame *g_Game=nullptr; /** * Constructor @@ -66,7 +66,7 @@ CGame::CGame(bool disableGraphics, bool replayLog): m_World(new CWorld(this)), m_Simulation2(new CSimulation2(&m_World->GetUnitManager(), g_ScriptRuntime, m_World->GetTerrain())), - m_GameView(disableGraphics ? NULL : new CGameView(this)), + m_GameView(disableGraphics ? nullptr : new CGameView(this)), m_GameStarted(false), m_Paused(false), m_SimRate(1.0f), @@ -74,7 +74,7 @@ m_ViewedPlayerID(-1), m_IsSavedGame(false), m_IsVisualReplay(false), - m_ReplayStream(NULL) + m_ReplayStream(nullptr) { // TODO: should use CDummyReplayLogger unless activated by cmd-line arg, perhaps? if (replayLog) Index: source/ps/GameSetup/GameSetup.cpp =================================================================== --- source/ps/GameSetup/GameSetup.cpp +++ source/ps/GameSetup/GameSetup.cpp @@ -272,7 +272,7 @@ CStrW cursorName = g_CursorName; if (cursorName.empty()) { - cursor_draw(g_VFS, NULL, g_mouse_x, g_yres-g_mouse_y, g_GuiScale, false); + cursor_draw(g_VFS, nullptr, g_mouse_x, g_yres-g_mouse_y, g_GuiScale, false); } else { @@ -819,7 +819,7 @@ try { // this constructor is similar to setlocale(LC_ALL, ""), - // but instead of returning NULL, it throws runtime_error + // but instead of returning nullptr, it throws runtime_error // when the first locale env variable found contains an invalid value std::locale(""); } @@ -880,7 +880,7 @@ #endif // Initialise the low-quality rand function - srand(time(NULL)); // NOTE: this rand should *not* be used for simulation! + srand(time(nullptr)); // NOTE: this rand should *not* be used for simulation! } bool Autostart(const CmdLineArgs& args); @@ -930,7 +930,7 @@ // on anything else.) if (args.Has("dumpSchema")) { - CSimulation2 sim(NULL, g_ScriptRuntime, NULL); + CSimulation2 sim(nullptr, g_ScriptRuntime, nullptr); sim.LoadDefaultScripts(); std::ofstream f("entity.rng", std::ios_base::out | std::ios_base::trunc); f << sim.GenerateSchema(); @@ -1025,8 +1025,8 @@ g_GUI = new CGUIManager(); // (must come after SetVideoMode, since it calls ogl_Init) - if (ogl_HaveExtensions(0, "GL_ARB_vertex_program", "GL_ARB_fragment_program", NULL) != 0 // ARB - && ogl_HaveExtensions(0, "GL_ARB_vertex_shader", "GL_ARB_fragment_shader", NULL) != 0) // GLSL + if (ogl_HaveExtensions(0, "GL_ARB_vertex_program", "GL_ARB_fragment_program", nullptr) != 0 // ARB + && ogl_HaveExtensions(0, "GL_ARB_vertex_shader", "GL_ARB_fragment_shader", nullptr) != 0) // GLSL { DEBUG_DISPLAY_ERROR( L"Your graphics card doesn't appear to be fully compatible with OpenGL shaders." @@ -1042,7 +1042,7 @@ "GL_EXT_draw_range_elements", "GL_ARB_texture_env_combine", "GL_ARB_texture_env_dot3", - NULL); + nullptr); if(missing) { wchar_t buf[500]; @@ -1101,7 +1101,7 @@ // Map Loading failed // Start the engine so we have a GUI - InitPs(true, L"page_pregame.xml", NULL, JS::UndefinedHandleValue); + InitPs(true, L"page_pregame.xml", nullptr, JS::UndefinedHandleValue); // Call script function to do the actual work // (delete game data, switch GUI page, show error, etc.) @@ -1657,7 +1657,7 @@ { if (!g_CheckedIfInDevelopmentCopy) { - g_InDevelopmentCopy = (g_VFS->GetFileInfo(L"config/dev.cfg", NULL) == INFO::OK); + g_InDevelopmentCopy = (g_VFS->GetFileInfo(L"config/dev.cfg", nullptr) == INFO::OK); g_CheckedIfInDevelopmentCopy = true; } return g_InDevelopmentCopy; Index: source/ps/GameSetup/tests/test_CmdLineArgs.h =================================================================== --- source/ps/GameSetup/tests/test_CmdLineArgs.h +++ source/ps/GameSetup/tests/test_CmdLineArgs.h @@ -83,7 +83,7 @@ CmdLineArgs c(ARRAY_SIZE(argv), argv); TS_ASSERT_WSTR_EQUALS(c.GetArg0().string(), L"program"); - CmdLineArgs c2(0, NULL); + CmdLineArgs c2(0, nullptr); TS_ASSERT_WSTR_EQUALS(c2.GetArg0().string(), L""); const char* argv3[] = { "ab/cd/ef/gh/../ij" }; Index: source/ps/Joystick.cpp =================================================================== --- source/ps/Joystick.cpp +++ source/ps/Joystick.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -26,7 +26,7 @@ CJoystick g_Joystick; CJoystick::CJoystick() : - m_Joystick(NULL), m_Deadzone(0) + m_Joystick(nullptr), m_Deadzone(0) { } @@ -75,7 +75,7 @@ bool CJoystick::IsEnabled() { - return (m_Joystick != NULL); + return (m_Joystick != nullptr); } float CJoystick::GetAxisValue(int axis) Index: source/ps/Mod.cpp =================================================================== --- source/ps/Mod.cpp +++ source/ps/Mod.cpp @@ -51,7 +51,7 @@ DirectoryNames modDirs; DirectoryNames modDirsUser; - GetDirectoryEntries(modPath, NULL, &modDirs); + GetDirectoryEntries(modPath, nullptr, &modDirs); // Sort modDirs so that we can do a fast lookup below std::sort(modDirs.begin(), modDirs.end()); @@ -75,7 +75,7 @@ JS_SetProperty(cx, obj, utf8_from_wstring(iter->string()).c_str(), json); } - GetDirectoryEntries(modUserPath, NULL, &modDirsUser); + GetDirectoryEntries(modUserPath, nullptr, &modDirsUser); bool dev = InDevelopmentCopy(); for (DirectoryNames::iterator iter = modDirsUser.begin(); iter != modDirsUser.end(); ++iter) Index: source/ps/ModIo.cpp =================================================================== --- source/ps/ModIo.cpp +++ source/ps/ModIo.cpp @@ -52,7 +52,7 @@ DownloadCallbackData(FILE* _fp) : fp(_fp), md5() { - crypto_generichash_init(&hash_state, NULL, 0U, crypto_generichash_BYTES_MAX); + crypto_generichash_init(&hash_state, nullptr, 0U, crypto_generichash_BYTES_MAX); } FILE* fp; MD5 md5; @@ -107,7 +107,7 @@ // For file downloads, one redirect seems plenty for a CDN serving the files. curl_easy_setopt(m_Curl, CURLOPT_MAXREDIRS, 1L); - m_Headers = NULL; + m_Headers = nullptr; std::string ua = "User-Agent: pyrogenesis "; ua += curl_version(); ua += " (https://play0ad.com/)"; @@ -118,7 +118,7 @@ ENSURE(0 && "Failed to initialize libsodium."); size_t bin_len = 0; - if (sodium_base642bin((unsigned char*)&m_pk, sizeof m_pk, pk_str.c_str(), pk_str.size(), NULL, &bin_len, NULL, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof m_pk) + if (sodium_base642bin((unsigned char*)&m_pk, sizeof m_pk, pk_str.c_str(), pk_str.size(), nullptr, &bin_len, nullptr, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof m_pk) ENSURE(0 && "Failed to decode base64 public key. Please fix your configuration or mod.io will be unusable."); } @@ -774,7 +774,7 @@ const std::string& msg_sig = sig_lines[1]; size_t bin_len = 0; - if (sodium_base642bin((unsigned char*)&sig, sizeof sig, msg_sig.c_str(), msg_sig.size(), NULL, &bin_len, NULL, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof sig) + if (sodium_base642bin((unsigned char*)&sig, sizeof sig, msg_sig.c_str(), msg_sig.size(), nullptr, &bin_len, nullptr, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof sig) FAIL("Failed to decode base64 sig."); cassert(sizeof pk.keynum == sizeof sig.keynum); @@ -790,7 +790,7 @@ // Now verify the global signature (sig || trusted_comment) unsigned char global_sig[crypto_sign_BYTES]; - if (sodium_base642bin(global_sig, sizeof global_sig, sig_lines[3].c_str(), sig_lines[3].size(), NULL, &bin_len, NULL, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof global_sig) + if (sodium_base642bin(global_sig, sizeof global_sig, sig_lines[3].c_str(), sig_lines[3].size(), nullptr, &bin_len, nullptr, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof global_sig) FAIL("Failed to decode base64 global_sig."); const std::string trusted_comment = sig_lines[2].substr(trusted_comment_prefix.size()); Index: source/ps/PreprocessorWrapper.cpp =================================================================== --- source/ps/PreprocessorWrapper.cpp +++ source/ps/PreprocessorWrapper.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -55,7 +55,7 @@ return false; } - bool ret = (memchr(output, '1', len) != NULL); + bool ret = (memchr(output, '1', len) != nullptr); // Free output if it's not inside the source string if (!(output >= input.c_str() && output < input.c_str() + input.size())) Index: source/ps/Profile.cpp =================================================================== --- source/ps/Profile.cpp +++ source/ps/Profile.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2011 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -327,7 +327,7 @@ if( (*it)->name == childName ) return( *it ); - return( NULL ); + return( nullptr ); } const CProfileNode* CProfileNode::GetScriptChild( const char* childName ) const @@ -337,7 +337,7 @@ if( (*it)->name == childName ) return( *it ); - return( NULL ); + return( nullptr ); } CProfileNode* CProfileNode::GetChild( const char* childName ) @@ -494,7 +494,7 @@ It would be nice to do: __attribute__ ((visibility ("default"))) void (*__malloc_initialize_hook)() = malloc_initialize_hook; except that doesn't seem to work in practice, since something (?) resets the -hook to NULL some time while loading the game, after we've set it here - so +hook to nullptr some time while loading the game, after we've set it here - so we just call malloc_initialize_hook once inside CProfileManager::Frame instead and hope nobody deletes our hook after that. */ @@ -544,7 +544,7 @@ static bool alloc_bootstrapped = false; static char alloc_bootstrap_buffer[32]; // sufficient for x86_64 static bool alloc_has_called_dlsym = false; -static void (*libc_free)(void*) = NULL; +static void (*libc_free)(void*) = nullptr; // (We'll only be running a single thread at this point so no need for locking these variables) //#define ALLOC_DEBUG @@ -554,7 +554,7 @@ cpu_AtomicAdd(&alloc_count, 1); static void *(*libc_malloc)(size_t); - if (libc_malloc == NULL) + if (libc_malloc == nullptr) { alloc_has_called_dlsym = true; libc_malloc = (void *(*)(size_t)) dlsym(RTLD_NEXT, "malloc"); @@ -564,7 +564,7 @@ printf("### malloc(%d) = %p\n", sz, ret); #endif - if (libc_free == NULL) + if (libc_free == nullptr) libc_free = (void (*)(void*)) dlsym(RTLD_NEXT, "free"); return ret; @@ -575,7 +575,7 @@ cpu_AtomicAdd(&alloc_count, 1); static void *(*libc_realloc)(void*, size_t); - if (libc_realloc == NULL) + if (libc_realloc == nullptr) { alloc_has_called_dlsym = true; libc_realloc = (void *(*)(void*, size_t)) dlsym(RTLD_NEXT, "realloc"); @@ -592,7 +592,7 @@ cpu_AtomicAdd(&alloc_count, 1); static void *(*libc_calloc)(size_t, size_t); - if (libc_calloc == NULL) + if (libc_calloc == nullptr) { if (alloc_has_called_dlsym && !alloc_bootstrapped) { @@ -611,7 +611,7 @@ printf("### calloc(%d, %d) = %p\n", nm, sz, ret); #endif - if (libc_free == NULL) + if (libc_free == nullptr) libc_free = (void (*)(void*)) dlsym(RTLD_NEXT, "free"); return ret; @@ -621,7 +621,7 @@ { // Might be triggered if free is called before any calloc/malloc calls or if the dlsym call inside // our calloc/malloc function causes a free call. Read the known issue comment block a few lines above. - ENSURE (libc_free != NULL); + ENSURE (libc_free != nullptr); libc_free(ptr); #ifdef ALLOC_DEBUG @@ -677,7 +677,7 @@ } CProfileManager::CProfileManager() : - root(NULL), current(NULL), needs_structural_reset(false) + root(nullptr), current(nullptr), needs_structural_reset(false) { PerformStructuralReset(); } @@ -749,7 +749,7 @@ void CProfileManager::PerformStructuralReset() { delete root; - root = new CProfileNode("root", NULL); + root = new CProfileNode("root", nullptr); root->Call(); current = root; g_ProfileViewer.AddRootTable(root->display_table, true); Index: source/ps/Profiler2.h =================================================================== --- source/ps/Profiler2.h +++ source/ps/Profiler2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -403,7 +403,7 @@ /** * Call in any thread to produce a JSON representation of the buffer * for a given thread. - * Returns NULL on success, or an error string. + * Returns nullptr on success, or an error string. */ const char* ConstructJSONResponse(std::ostream& stream, const std::string& thread); Index: source/ps/Profiler2.cpp =================================================================== --- source/ps/Profiler2.cpp +++ source/ps/Profiler2.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -39,7 +39,7 @@ const u8 CProfiler2::RESYNC_MAGIC[8] = {0x11, 0x22, 0x33, 0x44, 0xf4, 0x93, 0xbe, 0x15}; CProfiler2::CProfiler2() : - m_Initialised(false), m_FrameNumber(0), m_MgContext(NULL), m_GPU(NULL) + m_Initialised(false), m_FrameNumber(0), m_MgContext(nullptr), m_GPU(nullptr) { } @@ -57,7 +57,7 @@ CProfiler2* profiler = (CProfiler2*)request_info->user_data; ENSURE(profiler); - void* handled = (void*)""; // arbitrary non-NULL pointer to indicate successful handling + void* handled = (void*)""; // arbitrary non-nullptr pointer to indicate successful handling const char* header200 = "HTTP/1.1 200 OK\r\n" @@ -128,19 +128,19 @@ } case MG_HTTP_ERROR: - return NULL; + return nullptr; case MG_EVENT_LOG: // Called by Mongoose's cry() LOGERROR("Mongoose error: %s", request_info->log_message); - return NULL; + return nullptr; case MG_INIT_SSL: - return NULL; + return nullptr; default: debug_warn(L"Invalid Mongoose event type"); - return NULL; + return nullptr; } }; @@ -172,7 +172,7 @@ const char *options[] = { "listening_ports", "127.0.0.1:8000", // bind to localhost for security "num_threads", "6", // enough for the browser's parallel connection limit - NULL + nullptr }; m_MgContext = mg_start(MgCallback, this, options); ENSURE(m_MgContext); @@ -200,7 +200,7 @@ if (m_MgContext) { mg_stop(m_MgContext); - m_MgContext = NULL; + m_MgContext = nullptr; } } @@ -228,7 +228,7 @@ if (m_MgContext) { mg_stop(m_MgContext); - m_MgContext = NULL; + m_MgContext = nullptr; } // the destructor is not called for the main thread @@ -282,7 +282,7 @@ { ENSURE(m_Initialised); - ENSURE(pthread_getspecific(m_TLS) == NULL); // mustn't register a thread more than once + ENSURE(pthread_getspecific(m_TLS) == nullptr); // mustn't register a thread more than once ThreadStorage* storage = new ThreadStorage(*this, name); int err = pthread_setspecific(m_TLS, storage); @@ -903,7 +903,7 @@ CScopeLock lock(m_Mutex); // lock against changes to m_Threads or deletions of ThreadStorage - ThreadStorage* storage = NULL; + ThreadStorage* storage = nullptr; for (size_t i = 0; i < m_Threads.size(); ++i) { if (m_Threads[i]->GetName() == thread) @@ -927,7 +927,7 @@ stream << "null]\n]}"; - return NULL; + return nullptr; } void CProfiler2::SaveToFile() Index: source/ps/Profiler2GPU.cpp =================================================================== --- source/ps/Profiler2GPU.cpp +++ source/ps/Profiler2GPU.cpp @@ -771,7 +771,7 @@ ////////////////////////////////////////////////////////////////////////// CProfiler2GPU::CProfiler2GPU(CProfiler2& profiler) : - m_Profiler(profiler), m_ProfilerARB(NULL), m_ProfilerEXT(NULL), m_ProfilerINTEL(NULL) + m_Profiler(profiler), m_ProfilerARB(nullptr), m_ProfilerEXT(nullptr), m_ProfilerINTEL(nullptr) { bool enabledARB = false; bool enabledEXT = false; @@ -860,7 +860,7 @@ #else // CONFIG2_GLES CProfiler2GPU::CProfiler2GPU(CProfiler2& profiler) : - m_Profiler(profiler), m_ProfilerARB(NULL), m_ProfilerEXT(NULL), m_ProfilerINTEL(NULL) + m_Profiler(profiler), m_ProfilerARB(nullptr), m_ProfilerEXT(nullptr), m_ProfilerINTEL(nullptr) { } Index: source/ps/Replay.cpp =================================================================== --- source/ps/Replay.cpp +++ source/ps/Replay.cpp @@ -50,7 +50,7 @@ static const int PROFILE_TURN_INTERVAL = 20; CReplayLogger::CReplayLogger(const ScriptInterface& scriptInterface) : - m_ScriptInterface(scriptInterface), m_Stream(NULL) + m_ScriptInterface(scriptInterface), m_Stream(nullptr) { } @@ -109,7 +109,7 @@ //////////////////////////////////////////////////////////////// CReplayPlayer::CReplayPlayer() : - m_Stream(NULL) + m_Stream(nullptr) { } Index: source/ps/SavedGame.h =================================================================== --- source/ps/SavedGame.h +++ source/ps/SavedGame.h @@ -42,7 +42,7 @@ * @param name Name to save the game with * @param description A user-given description of the save * @param simulation - * @param guiMetadataClone if not NULL, store some UI-related data with the saved game + * @param guiMetadataClone if not nullptr, store some UI-related data with the saved game * @return INFO::OK if successfully saved, else an error Status */ Status Save(const CStrW& name, const CStrW& description, CSimulation2& simulation, const shared_ptr& guiMetadataClone); @@ -53,7 +53,7 @@ * @param prefix Create new numbered file starting with this prefix * @param description A user-given description of the save * @param simulation - * @param guiMetadataClone if not NULL, store some UI-related data with the saved game + * @param guiMetadataClone if not nullptr, store some UI-related data with the saved game * @return INFO::OK if successfully saved, else an error Status */ Status SavePrefix(const CStrW& prefix, const CStrW& description, CSimulation2& simulation, const shared_ptr& guiMetadataClone); Index: source/ps/SavedGame.cpp =================================================================== --- source/ps/SavedGame.cpp +++ source/ps/SavedGame.cpp @@ -70,7 +70,7 @@ WARN_RETURN_STATUS_IF_ERR(g_VFS->GetDirectoryRealPath("cache/", tempSaveFileRealPath)); tempSaveFileRealPath = tempSaveFileRealPath / "temp.0adsave"; - time_t now = time(NULL); + time_t now = time(nullptr); // Construct the serialized state to be saved @@ -248,7 +248,7 @@ continue; // skip this file } - CGameLoader loader(scriptInterface, NULL); + CGameLoader loader(scriptInterface, nullptr); err = archiveReader->ReadEntries(CGameLoader::ReadEntryCallback, (uintptr_t)&loader); if (err < 0) { Index: source/ps/TemplateLoader.cpp =================================================================== --- source/ps/TemplateLoader.cpp +++ source/ps/TemplateLoader.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -27,7 +27,7 @@ static const wchar_t TEMPLATE_ROOT[] = L"simulation/templates/"; static const wchar_t ACTOR_ROOT[] = L"art/actors/"; -static CParamNode NULL_NODE(false); +static CParamNode nullptr_NODE(false); bool CTemplateLoader::LoadTemplateFile(const std::string& templateName, int depth) { @@ -182,7 +182,7 @@ if (!LoadTemplateFile(templateName, 0)) { LOGERROR("Failed to load entity template '%s'", templateName.c_str()); - return NULL_NODE; + return nullptr_NODE; } return m_TemplateFileData[templateName]; Index: source/ps/ThreadUtil.h =================================================================== --- source/ps/ThreadUtil.h +++ source/ps/ThreadUtil.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -51,7 +51,7 @@ public: CMutex() { - int ret = pthread_mutex_init(&m_Mutex, NULL); + int ret = pthread_mutex_init(&m_Mutex, nullptr); ENSURE(ret == 0); } Index: source/ps/UserReport.cpp =================================================================== --- source/ps/UserReport.cpp +++ source/ps/UserReport.cpp @@ -123,7 +123,7 @@ curl_easy_setopt(m_Curl, CURLOPT_POST, 1L); // Set up HTTP headers - m_Headers = NULL; + m_Headers = nullptr; // Set the UA string std::string ua = "User-Agent: 0ad "; ua += curl_version(); @@ -142,7 +142,7 @@ m_WorkerSem = SDL_CreateSemaphore(0); ENSURE(m_WorkerSem); - int ret = pthread_create(&m_WorkerThread, NULL, &RunThread, this); + int ret = pthread_create(&m_WorkerThread, nullptr, &RunThread, this); ENSURE(ret == 0); } @@ -190,7 +190,7 @@ // Wait for it to shut down cleanly // TODO: should have a timeout in case of network hangs - pthread_join(m_WorkerThread, NULL); + pthread_join(m_WorkerThread, nullptr); return true; } @@ -242,7 +242,7 @@ static_cast(data)->Run(); - return NULL; + return nullptr; } void Run() @@ -519,7 +519,7 @@ CUserReporter::CUserReporter() : - m_Worker(NULL) + m_Worker(nullptr) { } @@ -609,7 +609,7 @@ { // Worker failed to shut down in a reasonable time // Leak the resources (since that's better than hanging or crashing) - m_Worker = NULL; + m_Worker = nullptr; } } @@ -642,7 +642,7 @@ // Actual submit shared_ptr report(new CUserReport); - report->m_Time = time(NULL); + report->m_Time = time(nullptr); report->m_Type = type; report->m_Version = version; report->m_Data = data; Index: source/ps/Util.cpp =================================================================== --- source/ps/Util.cpp +++ source/ps/Util.cpp @@ -292,7 +292,7 @@ void WriteBigScreenshot(const VfsPath& extension, int tiles) { // If the game hasn't started yet then use WriteScreenshot to generate the image. - if(g_Game == NULL){ WriteScreenshot(L".bmp"); return; } + if(g_Game == nullptr){ WriteScreenshot(L".bmp"); return; } // get next available numbered filename // note: %04d -> always 4 digits, so sorting by filename works correctly. Index: source/ps/VideoMode.cpp =================================================================== --- source/ps/VideoMode.cpp +++ source/ps/VideoMode.cpp @@ -49,7 +49,7 @@ CVideoMode g_VideoMode; CVideoMode::CVideoMode() : - m_IsFullscreen(false), m_IsInitialised(false), m_Window(NULL), + m_IsFullscreen(false), m_IsInitialised(false), m_Window(nullptr), m_PreferredW(0), m_PreferredH(0), m_PreferredBPP(0), m_PreferredFreq(0), m_ConfigW(0), m_ConfigH(0), m_ConfigBPP(0), m_ConfigFullscreen(false), m_ConfigForceS3TCEnable(true), m_WindowedW(DEFAULT_WINDOW_W), m_WindowedH(DEFAULT_WINDOW_H), m_WindowedX(0), m_WindowedY(0) @@ -104,7 +104,7 @@ } } - if (SDL_SetWindowDisplayMode(m_Window, NULL) < 0) + if (SDL_SetWindowDisplayMode(m_Window, nullptr) < 0) { LOGERROR("SetVideoMode failed in SDL_SetWindowDisplayMode: %dx%d:%d %d (\"%s\")", w, h, bpp, fullscreen ? 1 : 0, SDL_GetError()); @@ -284,7 +284,7 @@ if (m_Window) { SDL_DestroyWindow(m_Window); - m_Window = NULL; + m_Window = nullptr; } } Index: source/ps/World.cpp =================================================================== --- source/ps/World.cpp +++ source/ps/World.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -74,13 +74,13 @@ try { - CTriggerManager* pTriggerManager = NULL; + CTriggerManager* pTriggerManager = nullptr; m_MapReader->LoadMap(mapfilename, rt, settings, m_Terrain, - CRenderer::IsInitialised() ? g_Renderer.GetWaterManager() : NULL, - CRenderer::IsInitialised() ? g_Renderer.GetSkyManager() : NULL, + CRenderer::IsInitialised() ? g_Renderer.GetWaterManager() : nullptr, + CRenderer::IsInitialised() ? g_Renderer.GetSkyManager() : nullptr, &g_LightEnv, m_pGame->GetView(), - m_pGame->GetView() ? m_pGame->GetView()->GetCinema() : NULL, - pTriggerManager, CRenderer::IsInitialised() ? &g_Renderer.GetPostprocManager() : NULL, + m_pGame->GetView() ? m_pGame->GetView()->GetCinema() : nullptr, + pTriggerManager, CRenderer::IsInitialised() ? &g_Renderer.GetPostprocManager() : nullptr, m_pGame->GetSimulation2(), &m_pGame->GetSimulation2()->GetSimContext(), playerID, false); // fails immediately, or registers for delay loading RegMemFun(this, &CWorld::DeleteMapReader, L"CWorld::DeleteMapReader", 5); @@ -97,13 +97,13 @@ void CWorld::RegisterInitRMS(const CStrW& scriptFile, JSRuntime* rt, JS::HandleValue settings, int playerID) { // If scriptFile is empty, a blank map will be generated using settings (no RMS run) - CTriggerManager* pTriggerManager = NULL; + CTriggerManager* pTriggerManager = nullptr; m_MapReader->LoadRandomMap(scriptFile, rt, settings, m_Terrain, - CRenderer::IsInitialised() ? g_Renderer.GetWaterManager() : NULL, - CRenderer::IsInitialised() ? g_Renderer.GetSkyManager() : NULL, + CRenderer::IsInitialised() ? g_Renderer.GetWaterManager() : nullptr, + CRenderer::IsInitialised() ? g_Renderer.GetSkyManager() : nullptr, &g_LightEnv, m_pGame->GetView(), - m_pGame->GetView() ? m_pGame->GetView()->GetCinema() : NULL, - pTriggerManager, CRenderer::IsInitialised() ? &g_Renderer.GetPostprocManager() : NULL, + m_pGame->GetView() ? m_pGame->GetView()->GetCinema() : nullptr, + pTriggerManager, CRenderer::IsInitialised() ? &g_Renderer.GetPostprocManager() : nullptr, m_pGame->GetSimulation2(), playerID); // registers for delay loading RegMemFun(this, &CWorld::DeleteMapReader, L"CWorld::DeleteMapReader", 5); Index: source/ps/XML/RelaxNG.cpp =================================================================== --- source/ps/XML/RelaxNG.cpp +++ source/ps/XML/RelaxNG.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -67,7 +67,7 @@ m_Schema = xmlRelaxNGParse(ctxt); xmlRelaxNGFreeParserCtxt(ctxt); - if (m_Schema == NULL) + if (m_Schema == nullptr) LOGERROR("RelaxNGValidator: Failed to compile schema"); } @@ -79,7 +79,7 @@ }; RelaxNGValidator::RelaxNGValidator() : - m_Schema(NULL) + m_Schema(nullptr) { } @@ -142,8 +142,8 @@ return false; } - xmlDocPtr doc = xmlReadMemory(document.c_str(), (int)document.size(), utf8_from_wstring(filename).c_str(), NULL, XML_PARSE_NONET); - if (doc == NULL) + xmlDocPtr doc = xmlReadMemory(document.c_str(), (int)document.size(), utf8_from_wstring(filename).c_str(), nullptr, XML_PARSE_NONET); + if (doc == nullptr) { LOGERROR("RelaxNGValidator: Failed to parse document '%s'", utf8_from_wstring(filename).c_str()); return false; @@ -157,7 +157,7 @@ bool RelaxNGValidator::ValidateEncoded(xmlDocPtr doc) const { xmlRelaxNGValidCtxtPtr ctxt = xmlRelaxNGNewValidCtxt(m_Schema); - xmlRelaxNGSetValidStructuredErrors(ctxt, &relaxNGErrorHandler, NULL); + xmlRelaxNGSetValidStructuredErrors(ctxt, &relaxNGErrorHandler, nullptr); int ret = xmlRelaxNGValidateDoc(ctxt, doc); xmlRelaxNGFreeValidCtxt(ctxt); @@ -179,5 +179,5 @@ bool RelaxNGValidator::CanValidate() const { - return m_Schema != NULL; + return m_Schema != nullptr; } Index: source/ps/XML/XMLWriter.cpp =================================================================== --- source/ps/XML/XMLWriter.cpp +++ source/ps/XML/XMLWriter.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -82,7 +82,7 @@ enum { EL_ATTR, EL_TEXT, EL_SUBEL }; XMLWriter_File::XMLWriter_File() - : m_Indent(0), m_LastElement(NULL), + : m_Indent(0), m_LastElement(nullptr), m_PrettyPrint(true) { // Encoding is always UTF-8 - that's one of the only two guaranteed to be @@ -132,7 +132,7 @@ void XMLWriter_File::Comment(const char* text) { - ElementStart(NULL, "!-- "); + ElementStart(nullptr, "!-- "); m_Data += escapeComment(text); m_Data += " -->"; --m_Indent; @@ -167,7 +167,7 @@ void XMLWriter_File::ElementEnd(const char* name, int type) { --m_Indent; - m_LastElement = NULL; + m_LastElement = nullptr; switch (type) { @@ -251,7 +251,7 @@ { if (newelement) { - ElementStart(NULL, name); + ElementStart(nullptr, name); m_Data += ">"; ElementText(value, false); ElementEnd(name, EL_TEXT); Index: source/ps/XML/XeroXMB.h =================================================================== --- source/ps/XML/XeroXMB.h +++ source/ps/XML/XeroXMB.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -116,7 +116,7 @@ { public: - XMBFile() : m_Pointer(NULL) {} + XMBFile() : m_Pointer(nullptr) {} // Initialise from the contents of an XMB file. // FileData must remain allocated and unchanged while @@ -201,7 +201,7 @@ typedef XMBElement pointer; // Because we need to construct the object typedef std::forward_iterator_tag iterator_category; - iterator(size_t size, const char* ptr, const char* endptr = NULL) + iterator(size_t size, const char* ptr, const char* endptr = nullptr) : m_Size(size), m_CurItemID(endptr ? size : 0), m_CurPointer(endptr ? endptr : ptr), m_Pointer(ptr) {} XMBElement operator*() const { return XMBElement(m_CurPointer); } XMBElement operator->() const { return **this; } @@ -270,7 +270,7 @@ typedef XMBAttribute pointer; // Because we need to construct the object typedef std::forward_iterator_tag iterator_category; - iterator(size_t size, const char* ptr, const char* endptr = NULL) + iterator(size_t size, const char* ptr, const char* endptr = nullptr) : m_Size(size), m_CurItemID(endptr ? size : 0), m_CurPointer(endptr ? endptr : ptr), m_Pointer(ptr) {} XMBAttribute operator*() const; XMBAttribute operator->() const { return **this; } Index: source/ps/XML/XeroXMB.cpp =================================================================== --- source/ps/XML/XeroXMB.cpp +++ source/ps/XML/XeroXMB.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -89,7 +89,7 @@ { int Length = read(m_Pointer); m_Pointer += 4; - std::string String (m_Pointer); // reads up until the first NULL + std::string String (m_Pointer); // reads up until the first nullptr m_Pointer += Length; return String; } @@ -178,7 +178,7 @@ int XMBElement::GetNodeName() const { - if (m_Pointer == NULL) + if (m_Pointer == nullptr) return -1; return read(m_Pointer + 4); // == ElementName @@ -186,8 +186,8 @@ XMBElementList XMBElement::GetChildNodes() const { - if (m_Pointer == NULL) - return XMBElementList(NULL, 0, NULL); + if (m_Pointer == nullptr) + return XMBElementList(nullptr, 0, nullptr); return XMBElementList( m_Pointer + 20 + read(m_Pointer + 16), // == Children[] @@ -198,8 +198,8 @@ XMBAttributeList XMBElement::GetAttributes() const { - if (m_Pointer == NULL) - return XMBAttributeList(NULL, 0, NULL); + if (m_Pointer == nullptr) + return XMBAttributeList(nullptr, 0, nullptr); return XMBAttributeList( m_Pointer + 24 + read(m_Pointer + 20), // == Attributes[] @@ -211,7 +211,7 @@ CStr8 XMBElement::GetText() const { // Return empty string if there's no text - if (m_Pointer == NULL || read(m_Pointer + 20) == 0) + if (m_Pointer == nullptr || read(m_Pointer + 20) == 0) return CStr8(); return CStr8(m_Pointer + 28); @@ -220,7 +220,7 @@ int XMBElement::GetLineNumber() const { // Make sure there actually was some text to record the line of - if (m_Pointer == NULL || read(m_Pointer + 20) == 0) + if (m_Pointer == nullptr || read(m_Pointer + 20) == 0) return -1; else return read(m_Pointer + 24); Index: source/ps/XML/Xeromyces.cpp =================================================================== --- source/ps/XML/Xeromyces.cpp +++ source/ps/XML/Xeromyces.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -54,7 +54,7 @@ { ENSURE(!g_XeromycesStarted); xmlInitParser(); - xmlSetStructuredErrorFunc(NULL, &errorHandler); + xmlSetStructuredErrorFunc(nullptr, &errorHandler); CScopeLock lock(g_ValidatorCacheLock); g_ValidatorCache.insert(std::make_pair(std::string(), RelaxNGValidator())); g_XeromycesStarted = true; @@ -67,7 +67,7 @@ ClearSchemaCache(); CScopeLock lock(g_ValidatorCacheLock); g_ValidatorCache.clear(); - xmlSetStructuredErrorFunc(NULL, NULL); + xmlSetStructuredErrorFunc(nullptr, nullptr); xmlCleanupParser(); } @@ -165,7 +165,7 @@ return PSRETURN_Xeromyces_XMLOpenFailed; } - xmlDocPtr doc = xmlReadMemory((const char*)input.GetBuffer(), input.GetBufferSize(), CStrW(filename.string()).ToUTF8().c_str(), NULL, + xmlDocPtr doc = xmlReadMemory((const char*)input.GetBuffer(), input.GetBufferSize(), CStrW(filename.string()).ToUTF8().c_str(), nullptr, XML_PARSE_NONET|XML_PARSE_NOCDATA); if (!doc) { @@ -221,7 +221,7 @@ { ENSURE(g_XeromycesStarted); - xmlDocPtr doc = xmlReadMemory(xml, (int)strlen(xml), "(no file)", NULL, XML_PARSE_NONET|XML_PARSE_NOCDATA); + xmlDocPtr doc = xmlReadMemory(xml, (int)strlen(xml), "(no file)", nullptr, XML_PARSE_NONET|XML_PARSE_NOCDATA); if (!doc) { LOGERROR("CXeromyces: Failed to parse XML string"); Index: source/ps/XML/tests/test_XeroXMB.h =================================================================== --- source/ps/XML/tests/test_XeroXMB.h +++ source/ps/XML/tests/test_XeroXMB.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -30,7 +30,7 @@ XMBFile parse(const char* doc) { - xmlDocPtr xmlDoc = xmlReadMemory(doc, int(strlen(doc)), "", NULL, + xmlDocPtr xmlDoc = xmlReadMemory(doc, int(strlen(doc)), "", nullptr, XML_PARSE_NONET|XML_PARSE_NOCDATA); WriteBuffer buffer; PSRETURN ret = CXeromyces::CreateXMB(xmlDoc, buffer); Index: source/ps/scripting/JSInterface_Debug.cpp =================================================================== --- source/ps/scripting/JSInterface_Debug.cpp +++ source/ps/scripting/JSInterface_Debug.cpp @@ -50,7 +50,7 @@ void JSI_Debug::DisplayErrorDialog(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& msg) { - debug_DisplayError(msg.c_str(), DE_NO_DEBUG_INFO, NULL, NULL, NULL, 0, NULL, NULL); + debug_DisplayError(msg.c_str(), DE_NO_DEBUG_INFO, nullptr, nullptr, nullptr, 0, nullptr, nullptr); } // Return the date/time at which the current executable was compiled. Index: source/ps/tests/test_CLogger.h =================================================================== --- source/ps/tests/test_CLogger.h +++ source/ps/tests/test_CLogger.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -75,7 +75,7 @@ void tearDown() { delete logger; - logger = NULL; + logger = nullptr; } void ParseOutput() Index: source/ps/tests/test_CStr.h =================================================================== --- source/ps/tests/test_CStr.h +++ source/ps/tests/test_CStr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -113,7 +113,7 @@ // because GTK+ can change the locale when we're running Atlas. // (If the host system doesn't have the locale we're using for this test // then it'll just stick with the default, which is fine) - char* old = setlocale(LC_NUMERIC, NULL); + char* old = setlocale(LC_NUMERIC, nullptr); setlocale(LC_NUMERIC, "fr_FR.UTF-8"); CStr8 str1("1.234"); Index: source/ps/tests/test_ModIo.h =================================================================== --- source/ps/tests/test_ModIo.h +++ source/ps/tests/test_ModIo.h @@ -97,7 +97,7 @@ const std::string pk_str = "RWTA6VIoth2Q1PFLsRILr3G7NB+mwwO8BSGoXs63X6TQgNGM4cE8Pvd6"; size_t bin_len = 0; - if (sodium_base642bin((unsigned char*)&pk, sizeof pk, pk_str.c_str(), pk_str.size(), NULL, &bin_len, NULL, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof pk) + if (sodium_base642bin((unsigned char*)&pk, sizeof pk, pk_str.c_str(), pk_str.size(), nullptr, &bin_len, nullptr, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof pk) LOGERROR("failed to decode base64 public key"); #define TS_ASSERT_PARSE(input, expected_error) \ @@ -188,7 +188,7 @@ const std::string pk_str = "RWTA6VIoth2Q1PFLsRILr3G7NB+mwwO8BSGoXs63X6TQgNGM4cE8Pvd6"; size_t bin_len = 0; - if (sodium_base642bin((unsigned char*)&pk, sizeof pk, pk_str.c_str(), pk_str.size(), NULL, &bin_len, NULL, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof pk) + if (sodium_base642bin((unsigned char*)&pk, sizeof pk, pk_str.c_str(), pk_str.size(), nullptr, &bin_len, nullptr, sodium_base64_VARIANT_ORIGINAL) != 0 || bin_len != sizeof pk) LOGERROR("failed to decode base64 public key"); Index: source/ps/tests/test_cppformat.h =================================================================== --- source/ps/tests/test_cppformat.h +++ source/ps/tests/test_cppformat.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -51,7 +51,7 @@ TS_ASSERT_EQUALS(fmt::sprintf("T%sT", std::string("abc")), "TabcT"); TS_ASSERT_EQUALS(fmt::sprintf("T%sT", CStr("abc")), "TabcT"); - TS_ASSERT_EQUALS(fmt::sprintf("T%sT", (const char*)NULL), "T(null)T"); + TS_ASSERT_EQUALS(fmt::sprintf("T%sT", (const char*)nullptr), "T(null)T"); TS_ASSERT_EQUALS(fmt::sprintf("T%pT", (void*)0x1234), "T0x1234T"); } Index: source/ps/utf16string.h =================================================================== --- source/ps/utf16string.h +++ source/ps/utf16string.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -68,7 +68,7 @@ { const char_type *end = s+n; const char_type *res = std::find(s, end, a); - return (res != end)?res:NULL; + return (res != end)?res:nullptr; } static char_type* move(char_type* s1, const char_type* s2, size_t n) Index: source/renderer/HWLightingModelRenderer.cpp =================================================================== --- source/renderer/HWLightingModelRenderer.cpp +++ source/renderer/HWLightingModelRenderer.cpp @@ -119,9 +119,9 @@ { m = new ShaderModelRendererInternals; m->cpuLighting = cpuLighting; - m->normals = NULL; + m->normals = nullptr; m->normalsNumVertices = 0; - m->shadermodeldef = NULL; + m->shadermodeldef = nullptr; } ShaderModelVertexRenderer::~ShaderModelVertexRenderer() Index: source/renderer/MikktspaceWrap.cpp =================================================================== --- source/renderer/MikktspaceWrap.cpp +++ source/renderer/MikktspaceWrap.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -44,7 +44,7 @@ m_Interface.m_getPosition = getPosition; m_Interface.m_getNormal = getNormal; m_Interface.m_getTexCoord = getTexCoord; - m_Interface.m_setTSpaceBasic = NULL; + m_Interface.m_setTSpaceBasic = nullptr; m_Interface.m_setTSpace = setTSpace; // set up SMikkTSpaceContext struct Index: source/renderer/ModelRenderer.cpp =================================================================== --- source/renderer/ModelRenderer.cpp +++ source/renderer/ModelRenderer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -650,7 +650,7 @@ texBindings.clear(); texBindingNames.clear(); - CModelDef* currentModeldef = NULL; + CModelDef* currentModeldef = nullptr; CShaderUniforms currentStaticUniforms; for (size_t idx = idxTechStart; idx < idxTechEnd; ++idx) @@ -671,13 +671,13 @@ // reallocate if there are more samplers than expected. if (currentTexs.size() != samplersNum) { - currentTexs.resize(samplersNum, NULL); + currentTexs.resize(samplersNum, nullptr); texBindings.resize(samplersNum, CShaderProgram::Binding()); texBindingNames.resize(samplersNum, CStrIntern()); // ensure they are definitely empty std::fill(texBindings.begin(), texBindings.end(), CShaderProgram::Binding()); - std::fill(currentTexs.begin(), currentTexs.end(), (CTexture*)NULL); + std::fill(currentTexs.begin(), currentTexs.end(), (CTexture*)nullptr); std::fill(texBindingNames.begin(), texBindingNames.end(), CStrIntern()); } Index: source/renderer/PatchRData.cpp =================================================================== --- source/renderer/PatchRData.cpp +++ source/renderer/PatchRData.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -244,7 +244,7 @@ // We've grabbed as many tiles as possible; now we need to start a new layer. // The new layer's texture could come from the back of any non-empty stack; // choose the longest stack as a heuristic to reduce the number of layers - CTerrainTextureEntry* bestTex = NULL; + CTerrainTextureEntry* bestTex = nullptr; size_t bestStackSize = 0; for (size_t k = 0; k < blendStacks.size(); ++k) @@ -965,7 +965,7 @@ } } - CTerrainTextureEntry* bestTex = NULL; + CTerrainTextureEntry* bestTex = nullptr; size_t bestStackSize = 0; for (size_t k = 0; k < blendStacks.size(); ++k) @@ -988,7 +988,7 @@ PROFILE_END("compute batches"); - CVertexBuffer* lastVB = NULL; + CVertexBuffer* lastVB = nullptr; for (BatchesStack::iterator itt = batches.begin(); itt != batches.end(); ++itt) { Index: source/renderer/Renderer.cpp =================================================================== --- source/renderer/Renderer.cpp +++ source/renderer/Renderer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -470,9 +470,9 @@ m_ShadowZBias = 0.02f; m_ShadowMapSize = 0; - m_LightEnv = NULL; + m_LightEnv = nullptr; - m_CurrentScene = NULL; + m_CurrentScene = nullptr; m_hCompositeAlphaMap = 0; @@ -511,14 +511,14 @@ if (!m_Options.m_NoVBO && ogl_HaveExtension("GL_ARB_vertex_buffer_object")) m_Caps.m_VBO = true; - if (0 == ogl_HaveExtensions(0, "GL_ARB_vertex_program", "GL_ARB_fragment_program", NULL)) + if (0 == ogl_HaveExtensions(0, "GL_ARB_vertex_program", "GL_ARB_fragment_program", nullptr)) { m_Caps.m_ARBProgram = true; if (ogl_HaveExtension("GL_ARB_fragment_program_shadow")) m_Caps.m_ARBProgramShadow = true; } - if (0 == ogl_HaveExtensions(0, "GL_ARB_shader_objects", "GL_ARB_shading_language_100", NULL)) + if (0 == ogl_HaveExtensions(0, "GL_ARB_shader_objects", "GL_ARB_shading_language_100", nullptr)) { if (ogl_HaveExtension("GL_ARB_vertex_shader")) m_Caps.m_VertexShader = true; @@ -529,7 +529,7 @@ #if CONFIG2_GLES m_Caps.m_Shadows = true; #else - if (0 == ogl_HaveExtensions(0, "GL_ARB_shadow", "GL_ARB_depth_texture", "GL_EXT_framebuffer_object", NULL)) + if (0 == ogl_HaveExtensions(0, "GL_ARB_shadow", "GL_ARB_depth_texture", "GL_EXT_framebuffer_object", nullptr)) { if (ogl_max_tex_units >= 4) m_Caps.m_Shadows = true; @@ -539,7 +539,7 @@ #if CONFIG2_GLES m_Caps.m_PrettyWater = true; #else - if (0 == ogl_HaveExtensions(0, "GL_ARB_vertex_shader", "GL_ARB_fragment_shader", "GL_EXT_framebuffer_object", NULL)) + if (0 == ogl_HaveExtensions(0, "GL_ARB_vertex_shader", "GL_ARB_fragment_shader", "GL_EXT_framebuffer_object", nullptr)) m_Caps.m_PrettyWater = true; #endif } @@ -1893,7 +1893,7 @@ RenderSubmissions(waterScissor); - m_CurrentScene = NULL; + m_CurrentScene = nullptr; } Scene& CRenderer::GetScene() Index: source/renderer/ShadowMap.cpp =================================================================== --- source/renderer/ShadowMap.cpp +++ source/renderer/ShadowMap.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -447,7 +447,7 @@ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); } glGenTextures(1, &Texture); @@ -467,7 +467,7 @@ } #endif - glTexImage2D(GL_TEXTURE_2D, 0, format, Width, Height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, format, Width, Height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, nullptr); // GLES requires type == UNSIGNED_SHORT or UNSIGNED_INT // set texture parameters Index: source/renderer/SilhouetteRenderer.cpp =================================================================== --- source/renderer/SilhouetteRenderer.cpp +++ source/renderer/SilhouetteRenderer.cpp @@ -367,7 +367,7 @@ if (occluder.isPatch) { CPatch* patch = static_cast(occluder.renderable); - if (!CHFTracer::PatchRayIntersect(patch, pos, cameraPos - pos, NULL)) + if (!CHFTracer::PatchRayIntersect(patch, pos, cameraPos - pos, nullptr)) continue; } else Index: source/renderer/TerrainOverlay.cpp =================================================================== --- source/renderer/TerrainOverlay.cpp +++ source/renderer/TerrainOverlay.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -283,7 +283,7 @@ m_TextureH = round_up_to_pow2(h); glBindTexture(GL_TEXTURE_2D, m_Texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_TextureW, m_TextureH, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_TextureW, m_TextureH, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); Index: source/renderer/TerrainRenderer.cpp =================================================================== --- source/renderer/TerrainRenderer.cpp +++ source/renderer/TerrainRenderer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -216,7 +216,7 @@ glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, one); PROFILE_START("render terrain base"); - CPatchRData::RenderBases(visiblePatches, CShaderDefines(), NULL, true, dummyShader); + CPatchRData::RenderBases(visiblePatches, CShaderDefines(), nullptr, true, dummyShader); PROFILE_END("render terrain base"); // render blends @@ -249,7 +249,7 @@ // render blend passes for each patch PROFILE_START("render terrain blends"); - CPatchRData::RenderBlends(visiblePatches, CShaderDefines(), NULL, true, dummyShader); + CPatchRData::RenderBlends(visiblePatches, CShaderDefines(), nullptr, true, dummyShader); PROFILE_END("render terrain blends"); // Disable second texcoord array @@ -273,7 +273,7 @@ glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA); PROFILE_START("render terrain decals"); - CDecalRData::RenderDecals(visibleDecals, CShaderDefines(), NULL, true, dummyShader); + CDecalRData::RenderDecals(visibleDecals, CShaderDefines(), nullptr, true, dummyShader); PROFILE_END("render terrain decals"); @@ -674,7 +674,7 @@ glGenTextures(1, (GLuint*)&depthTex); WaterMgr->m_depthTT = depthTex; glBindTexture(GL_TEXTURE_2D, WaterMgr->m_depthTT); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, g_Renderer.GetWidth(), g_Renderer.GetHeight(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, g_Renderer.GetWidth(), g_Renderer.GetHeight(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); Index: source/renderer/TexturedLineRData.h =================================================================== --- source/renderer/TexturedLineRData.h +++ source/renderer/TexturedLineRData.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -44,7 +44,7 @@ public: - CTexturedLineRData() : m_VB(NULL), m_VBIndices(NULL) { } + CTexturedLineRData() : m_VB(nullptr), m_VBIndices(nullptr) { } ~CTexturedLineRData() { Index: source/renderer/TexturedLineRData.cpp =================================================================== --- source/renderer/TexturedLineRData.cpp +++ source/renderer/TexturedLineRData.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -71,12 +71,12 @@ if (m_VB) { g_VBMan.Release(m_VB); - m_VB = NULL; + m_VB = nullptr; } if (m_VBIndices) { g_VBMan.Release(m_VBIndices); - m_VBIndices = NULL; + m_VBIndices = nullptr; } if (!line.m_SimContext) Index: source/renderer/VertexArray.cpp =================================================================== --- source/renderer/VertexArray.cpp +++ source/renderer/VertexArray.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -302,7 +302,7 @@ u8* VertexArray::Bind() { if (!m_VB) - return NULL; + return nullptr; u8* base = m_VB->m_Owner->Bind(); base += m_VB->m_Index*m_Stride; Index: source/renderer/VertexBuffer.h =================================================================== --- source/renderer/VertexBuffer.h +++ source/renderer/VertexBuffer.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -33,7 +33,7 @@ * * The class can be used in two modes, depending on the usage parameter: * - * GL_STATIC_DRAW: Call Allocate() with backingStore = NULL. Then call + * GL_STATIC_DRAW: Call Allocate() with backingStore = nullptr. Then call * UpdateChunkVertices() with any pointer - the data will be immediately copied * to the VBO. This should be used for vertex data that rarely changes. * Index: source/renderer/VertexBuffer.cpp =================================================================== --- source/renderer/VertexBuffer.cpp +++ source/renderer/VertexBuffer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -106,7 +106,7 @@ return 0; if (UseStreaming(usage)) - ENSURE(backingStore != NULL); + ENSURE(backingStore != nullptr); // quick check there's enough vertices spare to allocate if (numVertices > m_FreeVertices) @@ -249,17 +249,17 @@ if (needUpload) { // Tell the driver that it can reallocate the whole VBO - pglBufferDataARB(m_Target, m_MaxVertices * m_VertexSize, NULL, m_Usage); + pglBufferDataARB(m_Target, m_MaxVertices * m_VertexSize, nullptr, m_Usage); // (In theory, glMapBufferRange with GL_MAP_INVALIDATE_BUFFER_BIT could be used - // here instead of glBufferData(..., NULL, ...) plus glMapBuffer(), but with + // here instead of glBufferData(..., nullptr, ...) plus glMapBuffer(), but with // current Intel Windows GPU drivers (as of 2015-01) it's much faster if you do // the explicit glBufferData.) while (true) { void* p = pglMapBufferARB(m_Target, GL_WRITE_ONLY); - if (p == NULL) + if (p == nullptr) { // This shouldn't happen unless we run out of virtual address space LOGERROR("glMapBuffer failed"); Index: source/renderer/VertexBufferManager.h =================================================================== --- source/renderer/VertexBufferManager.h +++ source/renderer/VertexBufferManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -38,12 +38,12 @@ * @param numVertices number of vertices in the buffer * @param usage GL_STATIC_DRAW, GL_DYNAMIC_DRAW, GL_STREAM_DRAW * @param target typically GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER - * @param backingStore if usage is STATIC, this is NULL; else for DYNAMIC/STREAM, + * @param backingStore if usage is STATIC, this is nullptr; else for DYNAMIC/STREAM, * this must be a copy of the vertex data that remains valid for the * lifetime of the VBChunk - * @return chunk, or NULL if no free chunks available + * @return chunk, or nullptr if no free chunks available */ - CVertexBuffer::VBChunk* Allocate(size_t vertexSize, size_t numVertices, GLenum usage, GLenum target, void* backingStore = NULL); + CVertexBuffer::VBChunk* Allocate(size_t vertexSize, size_t numVertices, GLenum usage, GLenum target, void* backingStore = nullptr); /// Returns the given @p chunk to its owning buffer void Release(CVertexBuffer::VBChunk* chunk); Index: source/renderer/VertexBufferManager.cpp =================================================================== --- source/renderer/VertexBufferManager.cpp +++ source/renderer/VertexBufferManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -56,7 +56,7 @@ ENSURE(target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER); if (CVertexBuffer::UseStreaming(usage)) - ENSURE(backingStore != NULL); + ENSURE(backingStore != nullptr); // TODO, RC - run some sanity checks on allocation request Index: source/renderer/WaterManager.cpp =================================================================== --- source/renderer/WaterManager.cpp +++ source/renderer/WaterManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -106,11 +106,11 @@ m_Murkiness = 0.45f; m_RepeatPeriod = 16.0f; - m_DistanceHeightmap = NULL; - m_BlurredNormalMap = NULL; - m_WindStrength = NULL; + m_DistanceHeightmap = nullptr; + m_BlurredNormalMap = nullptr; + m_WindStrength = nullptr; - m_ShoreWaves_VBIndices = NULL; + m_ShoreWaves_VBIndices = nullptr; m_WaterEffects = true; m_WaterFancyEffects = false; @@ -265,7 +265,7 @@ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL); + glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, nullptr); glGenTextures(1, &m_RefrFboDepthTexture); glBindTexture(GL_TEXTURE_2D, m_RefrFboDepthTexture); @@ -273,7 +273,7 @@ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL); + glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)m_RefTextureSize, (GLsizei)m_RefTextureSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, nullptr); // Create the Fancy Effects texture glGenTextures(1, &m_FancyTextureNormal); @@ -365,13 +365,13 @@ void WaterManager::Resize() { glBindTexture(GL_TEXTURE_2D, m_FancyTextureNormal); - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_SHORT, nullptr); glBindTexture(GL_TEXTURE_2D, m_FancyTextureOther); - glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL); + glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_SHORT, nullptr); glBindTexture(GL_TEXTURE_2D, m_FancyTextureDepth); - glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, NULL); + glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, (GLsizei)g_Renderer.GetWidth(), (GLsizei)g_Renderer.GetHeight(), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, nullptr); glBindTexture(GL_TEXTURE_2D, 0); } @@ -422,7 +422,7 @@ return; size_t SideSize = m_MapSize*2; - if (m_DistanceHeightmap == NULL) + if (m_DistanceHeightmap == nullptr) m_DistanceHeightmap = new float[SideSize*SideSize]; // Create a manhattan-distance heightmap. @@ -499,7 +499,7 @@ if (m_ShoreWaves_VBIndices) { g_VBMan.Release(m_ShoreWaves_VBIndices); - m_ShoreWaves_VBIndices = NULL; + m_ShoreWaves_VBIndices = nullptr; } if (m_Waviness < 5.0f && m_WaterType != L"ocean") @@ -954,7 +954,7 @@ // used to cache terrain normals since otherwise we'd recalculate them a lot (I'm blurring the "normal" map). // this might be updated to actually cache in the terrain manager but that's not for now. - if (m_BlurredNormalMap == NULL) + if (m_BlurredNormalMap == nullptr) m_BlurredNormalMap = new CVector3D[m_MapSize*m_MapSize]; // It's really slow to calculate normals so cache them first. @@ -1019,7 +1019,7 @@ // This is too slow and should support limited recomputation. void WaterManager::RecomputeWindStrength() { - if (m_WindStrength == NULL) + if (m_WindStrength == nullptr) m_WindStrength = new float[m_MapSize*m_MapSize]; CTerrain* terrain = g_Game->GetWorld()->GetTerrain(); Index: source/scriptinterface/ScriptInterface.cpp =================================================================== --- source/scriptinterface/ScriptInterface.cpp +++ source/scriptinterface/ScriptInterface.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -216,7 +216,7 @@ } JS::RootedValue ret(cx); - if (!JS_StructuredClone(cx, args[0], &ret, NULL, NULL)) + if (!JS_StructuredClone(cx, args[0], &ret, nullptr, nullptr)) return false; args.rval().set(ret); @@ -338,7 +338,7 @@ bool ScriptInterface::MathRandom(double& nbr) { - if (m->m_rng == NULL) + if (m->m_rng == nullptr) return false; nbr = generate_uniform_real(*(m->m_rng), 0.0, 1.0); return true; @@ -357,7 +357,7 @@ // For GC debugging: // JS_SetGCZeal(m_cx, 2, JS_DEFAULT_ZEAL_FREQ); - JS_SetContextPrivate(m_cx, NULL); + JS_SetContextPrivate(m_cx, nullptr); JS_SetErrorReporter(m_runtime->m_rt, ErrorReporter); @@ -375,7 +375,7 @@ opt.setPreserveJitCode(true); JSAutoRequest rq(m_cx); - JS::RootedObject globalRootedVal(m_cx, JS_NewGlobalObject(m_cx, &global_class, NULL, JS::OnNewGlobalHookOption::FireOnNewGlobalHook, opt)); + JS::RootedObject globalRootedVal(m_cx, JS_NewGlobalObject(m_cx, &global_class, nullptr, JS::OnNewGlobalHookOption::FireOnNewGlobalHook, opt)); m_comp = JS_EnterCompartment(m_cx, globalRootedVal); ok = JS_InitStandardClasses(m_cx, globalRootedVal); ENSURE(ok); @@ -557,7 +557,7 @@ ps, fs, // Properties, methods static_ps, static_fs)); // Constructor properties, methods - if (obj == NULL) + if (obj == nullptr) throw PSERROR_Scripting_DefineType_CreationFailed(); CustomType& type = m_CustomObjectTypes[typeName]; @@ -852,7 +852,7 @@ JS::RootedFunction func(m->m_cx); JS::AutoObjectVector emptyScopeChain(m->m_cx); - if (!JS::CompileFunction(m->m_cx, emptyScopeChain, options, NULL, 0, NULL, + if (!JS::CompileFunction(m->m_cx, emptyScopeChain, options, nullptr, 0, nullptr, reinterpret_cast(codeUtf16.c_str()), (uint)(codeUtf16.length()), &func)) return false; @@ -1050,7 +1050,7 @@ JS::RootedValue indentVal(m->m_cx, JS::Int32Value(2)); // Temporary disable the error reporter, so we don't print complaints about cyclic values - JSErrorReporter er = JS_SetErrorReporter(m->m_runtime->m_rt, NULL); + JSErrorReporter er = JS_SetErrorReporter(m->m_runtime->m_rt, nullptr); bool ok = JS_Stringify(m->m_cx, obj, JS::NullPtr(), indentVal, &Stringifier::callback, &str); @@ -1114,22 +1114,22 @@ } ScriptInterface::StructuredClone::StructuredClone() : - m_Data(NULL), m_Size(0) + m_Data(nullptr), m_Size(0) { } ScriptInterface::StructuredClone::~StructuredClone() { if (m_Data) - JS_ClearStructuredClone(m_Data, m_Size, NULL, NULL); + JS_ClearStructuredClone(m_Data, m_Size, nullptr, nullptr); } shared_ptr ScriptInterface::WriteStructuredClone(JS::HandleValue v) const { JSAutoRequest rq(m->m_cx); - u64* data = NULL; + u64* data = nullptr; size_t nbytes = 0; - if (!JS_WriteStructuredClone(m->m_cx, v, &data, &nbytes, NULL, NULL, JS::UndefinedHandleValue)) + if (!JS_WriteStructuredClone(m->m_cx, v, &data, &nbytes, nullptr, nullptr, JS::UndefinedHandleValue)) { debug_warn(L"Writing a structured clone with JS_WriteStructuredClone failed!"); return shared_ptr(); @@ -1144,5 +1144,5 @@ void ScriptInterface::ReadStructuredClone(const shared_ptr& ptr, JS::MutableHandleValue ret) const { JSAutoRequest rq(m->m_cx); - JS_ReadStructuredClone(m->m_cx, ptr->m_Data, ptr->m_Size, JS_STRUCTURED_CLONE_VERSION, ret, NULL, NULL); + JS_ReadStructuredClone(m->m_cx, ptr->m_Data, ptr->m_Size, JS_STRUCTURED_CLONE_VERSION, ret, nullptr, nullptr); } Index: source/simulation2/Simulation2.cpp =================================================================== --- source/simulation2/Simulation2.cpp +++ source/simulation2/Simulation2.cpp @@ -451,8 +451,8 @@ VfsPath mapfilename = VfsPath(mapFile).ChangeExtension(L".pmp"); mapReader->LoadMap(mapfilename, scriptInterface.GetJSRuntime(), JS::UndefinedHandleValue, - m_SecondaryTerrain, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, m_SecondaryContext, INVALID_PLAYER, true); // throws exception on failure + m_SecondaryTerrain, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + nullptr, nullptr, m_SecondaryContext, INVALID_PLAYER, true); // throws exception on failure } LDR_EndRegistering(); @@ -472,7 +472,7 @@ if (primaryStateBefore.state.str() != secondaryStateBefore.state.str() || primaryStateBefore.hash != secondaryStateBefore.hash) { - ReportSerializationFailure(&primaryStateBefore, NULL, &secondaryStateBefore, NULL); + ReportSerializationFailure(&primaryStateBefore, nullptr, &secondaryStateBefore, nullptr); } SerializationTestState primaryStateAfter; Index: source/simulation2/components/CCmpObstruction.cpp =================================================================== --- source/simulation2/components/CCmpObstruction.cpp +++ source/simulation2/components/CCmpObstruction.cpp @@ -427,7 +427,7 @@ virtual void SetDisableBlockMovementPathfinding(bool movementDisabled, bool pathfindingDisabled, int32_t shape) { - flags_t *flags = NULL; + flags_t *flags = nullptr; if (shape == -1) flags = &m_Flags; else if (m_Type == CLUSTER && shape < (int32_t)m_Shapes.size()) @@ -615,9 +615,9 @@ ICmpObstructionManager::FLAG_BLOCK_FOUNDATION); if (m_Type == UNIT) - return !cmpObstructionManager->TestUnitShape(filter, pos.X, pos.Y, m_Clearance, NULL); + return !cmpObstructionManager->TestUnitShape(filter, pos.X, pos.Y, m_Clearance, nullptr); else - return !cmpObstructionManager->TestStaticShape(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, NULL ); + return !cmpObstructionManager->TestStaticShape(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, nullptr ); } virtual std::vector GetEntitiesByFlags(flags_t flags) const Index: source/simulation2/components/CCmpPathfinder.cpp =================================================================== --- source/simulation2/components/CCmpPathfinder.cpp +++ source/simulation2/components/CCmpPathfinder.cpp @@ -42,15 +42,15 @@ void CCmpPathfinder::Init(const CParamNode& UNUSED(paramNode)) { m_MapSize = 0; - m_Grid = NULL; - m_TerrainOnlyGrid = NULL; + m_Grid = nullptr; + m_TerrainOnlyGrid = nullptr; FlushAIPathfinderDirtinessInformation(); m_NextAsyncTicket = 1; m_DebugOverlay = false; - m_AtlasOverlay = NULL; + m_AtlasOverlay = nullptr; m_SameTurnMovesCount = 0; @@ -237,7 +237,7 @@ return &passability; } - return NULL; + return nullptr; } const Grid& CCmpPathfinder::GetPassabilityGrid() @@ -819,7 +819,7 @@ if (!cmpObstructionManager) return ICmpObstruction::FOUNDATION_CHECK_FAIL_ERROR; - if (cmpObstructionManager->TestUnitShape(filter, x, z, r, NULL)) + if (cmpObstructionManager->TestUnitShape(filter, x, z, r, nullptr)) return ICmpObstruction::FOUNDATION_CHECK_FAIL_OBSTRUCTS_FOUNDATION; // Test against terrain and static obstructions: @@ -853,7 +853,7 @@ if (!cmpObstructionManager) return ICmpObstruction::FOUNDATION_CHECK_FAIL_ERROR; - if (cmpObstructionManager->TestStaticShape(filter, x, z, a, w, h, NULL)) + if (cmpObstructionManager->TestStaticShape(filter, x, z, a, w, h, nullptr)) return ICmpObstruction::FOUNDATION_CHECK_FAIL_OBSTRUCTS_FOUNDATION; // Test against terrain: Index: source/simulation2/components/CCmpSelectable.cpp =================================================================== --- source/simulation2/components/CCmpSelectable.cpp +++ source/simulation2/components/CCmpSelectable.cpp @@ -64,8 +64,8 @@ DEFAULT_COMPONENT_ALLOCATOR(Selectable) CCmpSelectable() - : m_DebugBoundingBoxOverlay(NULL), m_DebugSelectionBoxOverlay(NULL), - m_BuildingOverlay(NULL), m_UnitOverlay(NULL), + : m_DebugBoundingBoxOverlay(nullptr), m_DebugSelectionBoxOverlay(nullptr), + m_BuildingOverlay(nullptr), m_UnitOverlay(nullptr), m_FadeBaselineAlpha(0.f), m_FadeDeltaAlpha(0.f), m_FadeProgress(0.f), m_Selected(false), m_Cached(false), m_Visible(false) { Index: source/simulation2/components/CCmpTemplateManager.cpp =================================================================== --- source/simulation2/components/CCmpTemplateManager.cpp +++ source/simulation2/components/CCmpTemplateManager.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -151,7 +151,7 @@ { const CParamNode& fileData = m_templateLoader.GetTemplateFileData(templateName); if (!fileData.IsOk()) - return NULL; + return nullptr; if (!m_DisableValidation) { @@ -166,7 +166,7 @@ } // Refuse to return invalid templates if (!m_TemplateSchemaValidity[templateName]) - return NULL; + return nullptr; } const CParamNode& templateRoot = fileData.GetChild("Entity"); @@ -174,7 +174,7 @@ { // The validator should never let this happen LOGERROR("Invalid root element in entity template '%s'", templateName.c_str()); - return NULL; + return nullptr; } return &templateRoot; @@ -184,7 +184,7 @@ { const CParamNode& templateRoot = m_templateLoader.GetTemplateFileData(templateName).GetChild("Entity"); if (!templateRoot.IsOk()) - return NULL; + return nullptr; return &templateRoot; } @@ -198,7 +198,7 @@ { std::map::const_iterator it = m_LatestTemplates.find(ent); if (it == m_LatestTemplates.end()) - return NULL; + return nullptr; return LoadTemplate(ent, it->second); } Index: source/simulation2/components/CCmpTerritoryManager.cpp =================================================================== --- source/simulation2/components/CCmpTerritoryManager.cpp +++ source/simulation2/components/CCmpTerritoryManager.cpp @@ -119,9 +119,9 @@ virtual void Init(const CParamNode& UNUSED(paramNode)) { - m_Territories = NULL; - m_CostGrid = NULL; - m_DebugOverlay = NULL; + m_Territories = nullptr; + m_CostGrid = nullptr; + m_DebugOverlay = nullptr; // m_DebugOverlay = new TerritoryOverlay(*this); m_BoundaryLinesDirty = true; m_TriggerEvent = true; @@ -417,7 +417,7 @@ PROFILE("CalculateTerritories"); // If the pathfinder hasn't been loaded (e.g. this is called during map initialisation), - // abort the computation (and assume callers can cope with m_Territories == NULL) + // abort the computation (and assume callers can cope with m_Territories == nullptr) CalculateCostGrid(); if (!m_CostGrid) return; Index: source/simulation2/components/CCmpUnitRenderer.cpp =================================================================== --- source/simulation2/components/CCmpUnitRenderer.cpp +++ source/simulation2/components/CCmpUnitRenderer.cpp @@ -184,13 +184,13 @@ SUnit* LookupUnit(tag_t tag) { if (tag.n < 1 || tag.n - 1 >= m_Units.size()) - return NULL; + return nullptr; return &m_Units[tag.n - 1]; } virtual tag_t AddUnit(CEntityHandle entity, CUnit* actor, const CBoundingSphere& boundsApprox, int flags) { - ENSURE(actor != NULL); + ENSURE(actor != nullptr); tag_t tag; if (!m_UnitTagsFree.empty()) @@ -220,7 +220,7 @@ virtual void RemoveUnit(tag_t tag) { SUnit* unit = LookupUnit(tag); - unit->actor = NULL; + unit->actor = nullptr; unit->inWorld = false; m_UnitTagsFree.push_back(tag); } Index: source/simulation2/components/CCmpVisualActor.cpp =================================================================== --- source/simulation2/components/CCmpVisualActor.cpp +++ source/simulation2/components/CCmpVisualActor.cpp @@ -191,7 +191,7 @@ virtual void Init(const CParamNode& paramNode) { - m_Unit = NULL; + m_Unit = nullptr; m_R = m_G = m_B = fixed::FromInt(1); m_ConstructionPreview = paramNode.GetChild("ConstructionPreview").IsOk(); @@ -217,7 +217,7 @@ if (m_Unit) { GetSimContext().GetUnitManager().DeleteUnit(m_Unit); - m_Unit = NULL; + m_Unit = nullptr; } } @@ -642,7 +642,7 @@ void CCmpVisualActor::InitSelectionShapeDescriptor(const CParamNode& paramNode) { // by default, we don't need a custom selection shape and we can just keep the default behaviour - CModelAbstract::CustomSelectionShape* shapeDescriptor = NULL; + CModelAbstract::CustomSelectionShape* shapeDescriptor = nullptr; const CParamNode& shapeNode = paramNode.GetChild("SelectionShape"); if (shapeNode.IsOk()) Index: source/simulation2/components/ICmpObstructionManager.h =================================================================== --- source/simulation2/components/ICmpObstructionManager.h +++ source/simulation2/components/ICmpObstructionManager.h @@ -187,7 +187,7 @@ * @param a angle of rotation (clockwise from +Z direction) * @param w width (size along X axis) * @param h height (size along Z axis) - * @param out if non-NULL, all colliding shapes' entities will be added to this list + * @param out if non-nullptr, all colliding shapes' entities will be added to this list * @return true if there is a collision */ virtual bool TestStaticShape(const IObstructionTestFilter& filter, @@ -202,7 +202,7 @@ * @param x X coordinate of shape's center * @param z Z coordinate of shape's center * @param clearance clearance of the shape's unit - * @param out if non-NULL, all colliding shapes' entities will be added to this list + * @param out if non-nullptr, all colliding shapes' entities will be added to this list * * @return true if there is a collision */ Index: source/simulation2/components/ICmpTemplateManager.h =================================================================== --- source/simulation2/components/ICmpTemplateManager.h +++ source/simulation2/components/ICmpTemplateManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -53,7 +53,7 @@ * based on entity template "foo" with various components removed and a few changed * and added. (This is for constructing foundations of buildings.) * - * @return NULL on error + * @return nullptr on error */ virtual const CParamNode* LoadTemplate(entity_id_t ent, const std::string& templateName) = 0; @@ -61,7 +61,7 @@ * Loads the template XML file identified by 'templateName' (including inheritance * from parent XML files). The templateName syntax is the same as LoadTemplate. * - * @return NULL on error + * @return nullptr on error */ virtual const CParamNode* GetTemplate(const std::string& templateName) = 0; @@ -69,7 +69,7 @@ * Like GetTemplate, except without doing the XML validation (so it's faster but * may return invalid templates). * - * @return NULL on error + * @return nullptr on error */ virtual const CParamNode* GetTemplateWithoutValidation(const std::string& templateName) = 0; @@ -82,7 +82,7 @@ * Returns the template most recently specified for the entity 'ent'. * Used during deserialization. * - * @return NULL on error + * @return nullptr on error */ virtual const CParamNode* LoadLatestTemplate(entity_id_t ent) = 0; Index: source/simulation2/components/ICmpVisual.h =================================================================== --- source/simulation2/components/ICmpVisual.h +++ source/simulation2/components/ICmpVisual.h @@ -75,7 +75,7 @@ virtual CFixedVector3D GetProjectileLaunchPoint() const = 0; /** - * Returns the underlying unit of this visual actor. May return NULL to indicate that no unit exists (e.g. may happen if the + * Returns the underlying unit of this visual actor. May return nullptr to indicate that no unit exists (e.g. may happen if the * game is started without graphics rendering). * Originally intended for introspection purposes in Atlas; for other purposes, consider using a specialized getter first. */ Index: source/simulation2/components/tests/test_ObstructionManager.h =================================================================== --- source/simulation2/components/tests/test_ObstructionManager.h +++ source/simulation2/components/tests/test_ObstructionManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -89,7 +89,7 @@ void tearDown() { delete testHelper; - cmp = NULL; // not our responsibility to deallocate + cmp = nullptr; // not our responsibility to deallocate CXeromyces::Terminate(); } Index: source/simulation2/components/tests/test_Pathfinder.h =================================================================== --- source/simulation2/components/tests/test_Pathfinder.h +++ source/simulation2/components/tests/test_Pathfinder.h @@ -115,7 +115,7 @@ { CTerrain terrain; - CSimulation2 sim2(NULL, g_ScriptRuntime, &terrain); + CSimulation2 sim2(nullptr, g_ScriptRuntime, &terrain); sim2.LoadDefaultScripts(); sim2.ResetState(); @@ -124,7 +124,7 @@ LDR_BeginRegistering(); mapReader->LoadMap(L"maps/skirmishes/Median Oasis (2).pmp", sim2.GetScriptInterface().GetJSRuntime(), JS::UndefinedHandleValue, - &terrain, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + &terrain, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &sim2, &sim2.GetSimContext(), -1, false); LDR_EndRegistering(); TS_ASSERT_OK(LDR_NonprogressiveLoad()); @@ -168,9 +168,9 @@ void test_performance_short_DISABLED() { CTerrain terrain; - terrain.Initialize(5, NULL); + terrain.Initialize(5, nullptr); - CSimulation2 sim2(NULL, g_ScriptRuntime, &terrain); + CSimulation2 sim2(nullptr, g_ScriptRuntime, &terrain); sim2.LoadDefaultScripts(); sim2.ResetState(); @@ -226,7 +226,7 @@ { CTerrain terrain; - CSimulation2 sim2(NULL, g_ScriptRuntime, &terrain); + CSimulation2 sim2(nullptr, g_ScriptRuntime, &terrain); sim2.LoadDefaultScripts(); sim2.ResetState(); @@ -235,7 +235,7 @@ LDR_BeginRegistering(); mapReader->LoadMap(L"maps/scenarios/Peloponnese.pmp", sim2.GetScriptInterface().GetJSRuntime(), JS::UndefinedHandleValue, - &terrain, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + &terrain, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &sim2, &sim2.GetSimContext(), -1, false); LDR_EndRegistering(); TS_ASSERT_OK(LDR_NonprogressiveLoad()); @@ -281,7 +281,7 @@ { CTerrain terrain; - CSimulation2 sim2(NULL, g_ScriptRuntime, &terrain); + CSimulation2 sim2(nullptr, g_ScriptRuntime, &terrain); sim2.LoadDefaultScripts(); sim2.ResetState(); @@ -290,7 +290,7 @@ LDR_BeginRegistering(); mapReader->LoadMap(L"maps/scenarios/Peloponnese.pmp", sim2.GetScriptInterface().GetJSRuntime(), JS::UndefinedHandleValue, - &terrain, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + &terrain, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &sim2, &sim2.GetSimContext(), -1, false); LDR_EndRegistering(); TS_ASSERT_OK(LDR_NonprogressiveLoad()); Index: source/simulation2/components/tests/test_RangeManager.h =================================================================== --- source/simulation2/components/tests/test_RangeManager.h +++ source/simulation2/components/tests/test_RangeManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -42,7 +42,7 @@ virtual void SetTurretParent(entity_id_t UNUSED(id), const CFixedVector3D& UNUSED(pos)) {} virtual entity_id_t GetTurretParent() const {return INVALID_ENTITY;} virtual void UpdateTurretPosition() {} - virtual std::set* GetTurrets() { return NULL; } + virtual std::set* GetTurrets() { return nullptr; } virtual bool IsInWorld() const { return true; } virtual void MoveOutOfWorld() { } virtual void MoveTo(entity_pos_t UNUSED(x), entity_pos_t UNUSED(z)) { } Index: source/simulation2/components/tests/test_TerritoryManager.h =================================================================== --- source/simulation2/components/tests/test_TerritoryManager.h +++ source/simulation2/components/tests/test_TerritoryManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -72,11 +72,11 @@ size_t expectedNumBoundaries = 5; TS_ASSERT_EQUALS(expectedNumBoundaries, boundaries.size()); - STerritoryBoundary* onesOuter = NULL; - STerritoryBoundary* onesInner0 = NULL; // inner border around the neutral tile - STerritoryBoundary* onesInner2 = NULL; // inner border around the '2' tile - STerritoryBoundary* twosOuter = NULL; - STerritoryBoundary* threesOuter = NULL; + STerritoryBoundary* onesOuter = nullptr; + STerritoryBoundary* onesInner0 = nullptr; // inner border around the neutral tile + STerritoryBoundary* onesInner2 = nullptr; // inner border around the '2' tile + STerritoryBoundary* twosOuter = nullptr; + STerritoryBoundary* threesOuter = nullptr; // expected number of points (!) in the inner boundaries for terrain 1 (there are two with the same size) size_t onesInnerNumExpectedPoints = 4; @@ -92,7 +92,7 @@ // rightmost one). if (boundary.points.size() != onesInnerNumExpectedPoints) { - TSM_ASSERT_EQUALS("Found multiple outer boundaries for territory owned by player 1", onesOuter, (STerritoryBoundary*) NULL); + TSM_ASSERT_EQUALS("Found multiple outer boundaries for territory owned by player 1", onesOuter, (STerritoryBoundary*) nullptr); onesOuter = &boundary; } else @@ -101,23 +101,23 @@ if (boundary.points[0].X < 24.f) { // leftmost inner boundary, i.e. onesInner0 - TSM_ASSERT_EQUALS("Found multiple leftmost inner boundaries for territory owned by player 1", onesInner0, (STerritoryBoundary*) NULL); + TSM_ASSERT_EQUALS("Found multiple leftmost inner boundaries for territory owned by player 1", onesInner0, (STerritoryBoundary*) nullptr); onesInner0 = &boundary; } else { - TSM_ASSERT_EQUALS("Found multiple rightmost inner boundaries for territory owned by player 1", onesInner2, (STerritoryBoundary*) NULL); + TSM_ASSERT_EQUALS("Found multiple rightmost inner boundaries for territory owned by player 1", onesInner2, (STerritoryBoundary*) nullptr); onesInner2 = &boundary; } } break; case 2: - TSM_ASSERT_EQUALS("Too many boundaries for territory owned by player 2", twosOuter, (STerritoryBoundary*) NULL); + TSM_ASSERT_EQUALS("Too many boundaries for territory owned by player 2", twosOuter, (STerritoryBoundary*) nullptr); twosOuter = &boundary; break; case 3: - TSM_ASSERT_EQUALS("Too many boundaries for territory owned by player 3", threesOuter, (STerritoryBoundary*) NULL); + TSM_ASSERT_EQUALS("Too many boundaries for territory owned by player 3", threesOuter, (STerritoryBoundary*) nullptr); threesOuter = &boundary; break; @@ -127,11 +127,11 @@ } } - TS_ASSERT_DIFFERS(onesOuter, (STerritoryBoundary*) NULL); - TS_ASSERT_DIFFERS(onesInner0, (STerritoryBoundary*) NULL); - TS_ASSERT_DIFFERS(onesInner2, (STerritoryBoundary*) NULL); - TS_ASSERT_DIFFERS(twosOuter, (STerritoryBoundary*) NULL); - TS_ASSERT_DIFFERS(threesOuter, (STerritoryBoundary*) NULL); + TS_ASSERT_DIFFERS(onesOuter, (STerritoryBoundary*) nullptr); + TS_ASSERT_DIFFERS(onesInner0, (STerritoryBoundary*) nullptr); + TS_ASSERT_DIFFERS(onesInner2, (STerritoryBoundary*) nullptr); + TS_ASSERT_DIFFERS(twosOuter, (STerritoryBoundary*) nullptr); + TS_ASSERT_DIFFERS(threesOuter, (STerritoryBoundary*) nullptr); TS_ASSERT_EQUALS(onesOuter->points.size(), 20U); TS_ASSERT_EQUALS(onesInner0->points.size(), 4U); @@ -172,10 +172,10 @@ size_t expectedNumBoundaries = 4; TS_ASSERT_EQUALS(expectedNumBoundaries, boundaries.size()); - STerritoryBoundary* onesOuter = NULL; - STerritoryBoundary* twosOuter = NULL; - STerritoryBoundary* twosInner = NULL; - STerritoryBoundary* threesOuter = NULL; + STerritoryBoundary* onesOuter = nullptr; + STerritoryBoundary* twosOuter = nullptr; + STerritoryBoundary* twosInner = nullptr; + STerritoryBoundary* threesOuter = nullptr; for (size_t i=0; i < expectedNumBoundaries; i++) { @@ -183,20 +183,20 @@ switch (boundary.owner) { case 1: - TSM_ASSERT_EQUALS("Too many boundaries for territory owned by player 1", onesOuter, (STerritoryBoundary*) NULL); + TSM_ASSERT_EQUALS("Too many boundaries for territory owned by player 1", onesOuter, (STerritoryBoundary*) nullptr); onesOuter = &boundary; break; case 3: - TSM_ASSERT_EQUALS("Too many boundaries for territory owned by player 3", threesOuter, (STerritoryBoundary*) NULL); + TSM_ASSERT_EQUALS("Too many boundaries for territory owned by player 3", threesOuter, (STerritoryBoundary*) nullptr); threesOuter = &boundary; break; case 2: // assign twosOuter first, then twosInner last; we'll swap them afterwards if needed - if (twosOuter == NULL) + if (twosOuter == nullptr) twosOuter = &boundary; - else if (twosInner == NULL) + else if (twosInner == nullptr) twosInner = &boundary; else TS_FAIL("Too many boundaries for territory owned by player 2"); @@ -209,10 +209,10 @@ } } - TS_ASSERT_DIFFERS(onesOuter, (STerritoryBoundary*) NULL); - TS_ASSERT_DIFFERS(twosOuter, (STerritoryBoundary*) NULL); - TS_ASSERT_DIFFERS(twosInner, (STerritoryBoundary*) NULL); - TS_ASSERT_DIFFERS(threesOuter, (STerritoryBoundary*) NULL); + TS_ASSERT_DIFFERS(onesOuter, (STerritoryBoundary*) nullptr); + TS_ASSERT_DIFFERS(twosOuter, (STerritoryBoundary*) nullptr); + TS_ASSERT_DIFFERS(twosInner, (STerritoryBoundary*) nullptr); + TS_ASSERT_DIFFERS(threesOuter, (STerritoryBoundary*) nullptr); TS_ASSERT_EQUALS(onesOuter->points.size(), 8U); TS_ASSERT_EQUALS(twosOuter->points.size(), 22U); Index: source/simulation2/helpers/Grid.h =================================================================== --- source/simulation2/helpers/Grid.h +++ source/simulation2/helpers/Grid.h @@ -35,18 +35,18 @@ class Grid { public: - Grid() : m_W(0), m_H(0), m_Data(NULL), m_DirtyID(0) + Grid() : m_W(0), m_H(0), m_Data(nullptr), m_DirtyID(0) { } - Grid(u16 w, u16 h) : m_W(w), m_H(h), m_Data(NULL), m_DirtyID(0) + Grid(u16 w, u16 h) : m_W(w), m_H(h), m_Data(nullptr), m_DirtyID(0) { if (m_W || m_H) m_Data = new T[m_W * m_H]; reset(); } - Grid(const Grid& g) : m_W(0), m_H(0), m_Data(NULL), m_DirtyID(0) + Grid(const Grid& g) : m_W(0), m_H(0), m_Data(nullptr), m_DirtyID(0) { *this = g; } @@ -72,7 +72,7 @@ memcpy(m_Data, g.m_Data, m_W*m_H*sizeof(T)); } else - m_Data = NULL; + m_Data = nullptr; return *this; } Index: source/simulation2/helpers/HierarchicalPathfinder.cpp =================================================================== --- source/simulation2/helpers/HierarchicalPathfinder.cpp +++ source/simulation2/helpers/HierarchicalPathfinder.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -49,7 +49,7 @@ int regionID = 0; std::vector connect; - u16* pCurrentID = NULL; + u16* pCurrentID = nullptr; u16 LeftID = 0; u16 DownID = 0; bool Checked = false; // prevent some unneccessary RootID calls @@ -321,7 +321,7 @@ return false; } -HierarchicalPathfinder::HierarchicalPathfinder() : m_DebugOverlay(NULL) +HierarchicalPathfinder::HierarchicalPathfinder() : m_DebugOverlay(nullptr) { } @@ -343,7 +343,7 @@ { SAFE_DELETE(m_DebugOverlay); m_DebugOverlayLines.clear(); - m_SimContext = NULL; + m_SimContext = nullptr; } } Index: source/simulation2/helpers/LongPathfinder.cpp =================================================================== --- source/simulation2/helpers/LongPathfinder.cpp +++ source/simulation2/helpers/LongPathfinder.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -330,7 +330,7 @@ // Adjust ip to be a goal cell, if there is one closer than the jump point; // and then return the new ip if there is a goal, // or the old ip if there is a (non-obstruction) jump point - if (goal.NavcellRectContainsGoal(i + 1, j, ip - 1, j, &ip, NULL) || !obstruction) + if (goal.NavcellRectContainsGoal(i + 1, j, ip - 1, j, &ip, nullptr) || !obstruction) return ip; return i; } @@ -341,7 +341,7 @@ bool obstruction; m_JumpPointsLeft[j].Get(m_Width - 1 - i, mip, obstruction); int ip = m_Width - 1 - mip; - if (goal.NavcellRectContainsGoal(i - 1, j, ip + 1, j, &ip, NULL) || !obstruction) + if (goal.NavcellRectContainsGoal(i - 1, j, ip + 1, j, &ip, nullptr) || !obstruction) return ip; return i; } @@ -351,7 +351,7 @@ int jp; bool obstruction; m_JumpPointsUp[i].Get(j, jp, obstruction); - if (goal.NavcellRectContainsGoal(i, j + 1, i, jp - 1, NULL, &jp) || !obstruction) + if (goal.NavcellRectContainsGoal(i, j + 1, i, jp - 1, nullptr, &jp) || !obstruction) return jp; return j; } @@ -362,7 +362,7 @@ bool obstruction; m_JumpPointsDown[i].Get(m_Height - 1 - j, mjp, obstruction); int jp = m_Height - 1 - mjp; - if (goal.NavcellRectContainsGoal(i, j - 1, i, jp + 1, NULL, &jp) || !obstruction) + if (goal.NavcellRectContainsGoal(i, j - 1, i, jp + 1, nullptr, &jp) || !obstruction) return jp; return j; } @@ -372,8 +372,8 @@ LongPathfinder::LongPathfinder() : m_UseJPSCache(false), - m_Grid(NULL), m_GridSize(0), - m_DebugOverlay(NULL), m_DebugGrid(NULL), m_DebugPath(NULL) + m_Grid(nullptr), m_GridSize(0), + m_DebugOverlay(nullptr), m_DebugGrid(nullptr), m_DebugPath(nullptr) { } Index: source/simulation2/helpers/PathGoal.h =================================================================== --- source/simulation2/helpers/PathGoal.h +++ source/simulation2/helpers/PathGoal.h @@ -58,7 +58,7 @@ * min(i0,i1) <= i <= max(i0,i1) * min(j0,j1) <= j <= max(j0,j1), * contains a part of the goal area. - * If so, arguments i and j (if not NULL) are set to the goal navcell nearest + * If so, arguments i and j (if not nullptr) are set to the goal navcell nearest * to (i0, j0), assuming the rect has either width or height = 1. */ bool NavcellRectContainsGoal(int i0, int j0, int i1, int j1, int* i, int* j) const; Index: source/simulation2/helpers/PriorityQueue.h =================================================================== --- source/simulation2/helpers/PriorityQueue.h +++ source/simulation2/helpers/PriorityQueue.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -154,7 +154,7 @@ if (m_List[n].id == id) return &m_List[n]; } - return NULL; + return nullptr; } void promote(ID id, R UNUSED(oldrank), R newrank, H newh) Index: source/simulation2/helpers/Spatial.h =================================================================== --- source/simulation2/helpers/Spatial.h +++ source/simulation2/helpers/Spatial.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -66,7 +66,7 @@ friend struct SerializeSpatialSubdivision; public: - SpatialSubdivision() : m_Divisions(NULL), m_DivisionsW(0), m_DivisionsH(0) + SpatialSubdivision() : m_Divisions(nullptr), m_DivisionsW(0), m_DivisionsH(0) { } ~SpatialSubdivision() @@ -398,12 +398,12 @@ public: FastSpatialSubdivision() : - m_SpatialDivisionsData(NULL), m_ArrayWidth(0) + m_SpatialDivisionsData(nullptr), m_ArrayWidth(0) { } FastSpatialSubdivision(const FastSpatialSubdivision& other) : - m_SpatialDivisionsData(NULL), m_ArrayWidth(0) + m_SpatialDivisionsData(nullptr), m_ArrayWidth(0) { Reset(other.m_ArrayWidth); std::copy(&other.m_SpatialDivisionsData[0], &other.m_SpatialDivisionsData[m_ArrayWidth*m_ArrayWidth], m_SpatialDivisionsData); Index: source/simulation2/scripting/EngineScriptConversions.cpp =================================================================== --- source/simulation2/scripting/EngineScriptConversions.cpp +++ source/simulation2/scripting/EngineScriptConversions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -35,7 +35,7 @@ template<> void ScriptInterface::ToJSVal(JSContext* cx, JS::MutableHandleValue ret, IComponent* const& val) { JSAutoRequest rq(cx); - if (val == NULL) + if (val == nullptr) { ret.setNull(); return; Index: source/simulation2/scripting/MessageTypeConversions.cpp =================================================================== --- source/simulation2/scripting/MessageTypeConversions.cpp +++ source/simulation2/scripting/MessageTypeConversions.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -39,7 +39,7 @@ JSContext* cx = scriptInterface.GetContext(); \ JSAutoRequest rq(cx); \ if (val.isPrimitive()) \ - return NULL; \ + return nullptr; \ JS::RootedObject obj(cx, &val.toObject()); \ JS::RootedValue prop(cx); @@ -47,9 +47,9 @@ type name; \ { \ if (! JS_GetProperty(cx, obj, #name, &prop)) \ - return NULL; \ + return nullptr; \ if (! ScriptInterface::FromJSVal(cx, prop, name)) \ - return NULL; \ + return nullptr; \ } JS::Value CMessage::ToJSValCached(const ScriptInterface& scriptInterface) const @@ -125,7 +125,7 @@ CMessage* CMessageRenderSubmit::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val)) { LOGWARNING("CMessageRenderSubmit::FromJSVal not implemented"); - return NULL; + return nullptr; } //////////////////////////////// @@ -139,7 +139,7 @@ CMessage* CMessageProgressiveLoad::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val)) { LOGWARNING("CMessageProgressiveLoad::FromJSVal not implemented"); - return NULL; + return nullptr; } //////////////////////////////// @@ -243,7 +243,7 @@ CMessage* CMessageInterpolatedPositionChanged::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val)) { LOGWARNING("CMessageInterpolatedPositionChanged::FromJSVal not implemented"); - return NULL; + return nullptr; } //////////////////////////////// @@ -379,7 +379,7 @@ CMessage* CMessageRangeUpdate::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val)) { LOGWARNING("CMessageRangeUpdate::FromJSVal not implemented"); - return NULL; + return nullptr; } //////////////////////////////// @@ -393,7 +393,7 @@ CMessage* CMessagePathResult::FromJSVal(const ScriptInterface& UNUSED(scriptInterface), JS::HandleValue UNUSED(val)) { LOGWARNING("CMessagePathResult::FromJSVal not implemented"); - return NULL; + return nullptr; } //////////////////////////////// @@ -548,5 +548,5 @@ #undef MESSAGE } - return NULL; + return nullptr; } Index: source/simulation2/serialization/StdDeserializer.cpp =================================================================== --- source/simulation2/serialization/StdDeserializer.cpp +++ source/simulation2/serialization/StdDeserializer.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -523,5 +523,5 @@ if (it != m_SerializablePrototypes.end()) ret.set(it->second); else - ret.set(NULL); + ret.set(nullptr); } Index: source/simulation2/system/CmpPtr.h =================================================================== --- source/simulation2/system/CmpPtr.h +++ source/simulation2/system/CmpPtr.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -71,17 +71,17 @@ CmpPtr(CEntityHandle ent) { SEntityComponentCache* cache = ent.GetComponentCache(); - if (cache != NULL && T::GetInterfaceId() < (int)cache->numInterfaces) + if (cache != nullptr && T::GetInterfaceId() < (int)cache->numInterfaces) m = static_cast(cache->interfaces[T::GetInterfaceId()]); else - m = NULL; + m = nullptr; } T* operator->() { return m; } explicit operator bool() const { - return m != NULL; + return m != nullptr; } }; Index: source/simulation2/system/ComponentManager.cpp =================================================================== --- source/simulation2/system/ComponentManager.cpp +++ source/simulation2/system/ComponentManager.cpp @@ -748,7 +748,7 @@ if (it == m_ComponentTypesById.end()) { LOGERROR("Invalid component id %d", cid); - return NULL; + return nullptr; } const ComponentType& ct = it->second; @@ -759,7 +759,7 @@ if (emap1.find(ent.GetId()) != emap1.end()) { LOGERROR("Multiple components for interface %d", ct.iid); - return NULL; + return nullptr; } std::map& emap2 = m_ComponentsByTypeId[cid]; @@ -772,7 +772,7 @@ if (obj.isNull()) { LOGERROR("Script component constructor failed"); - return NULL; + return nullptr; } } @@ -793,7 +793,7 @@ // inserted into the world later on. (Be careful about immediation deletion in that case, too.) SEntityComponentCache* cache = ent.GetComponentCache(); - ENSURE(cache != NULL && ct.iid < (int)cache->numInterfaces && cache->interfaces[ct.iid] == NULL); + ENSURE(cache != nullptr && ct.iid < (int)cache->numInterfaces && cache->interfaces[ct.iid] == nullptr); cache->interfaces[ct.iid] = component; return component; @@ -810,7 +810,7 @@ emap1.insert(std::make_pair(ent.GetId(), &component)); SEntityComponentCache* cache = ent.GetComponentCache(); - ENSURE(cache != NULL && iid < (int)cache->numInterfaces && cache->interfaces[iid] == NULL); + ENSURE(cache != nullptr && iid < (int)cache->numInterfaces && cache->interfaces[iid] == nullptr); cache->interfaces[iid] = &component; } @@ -820,7 +820,7 @@ // so we need space for an extra m_InterfaceIdsByName.size() items SEntityComponentCache* cache = (SEntityComponentCache*)calloc(1, sizeof(SEntityComponentCache) + sizeof(IComponent*) * m_InterfaceIdsByName.size()); - ENSURE(cache != NULL); + ENSURE(cache != nullptr); cache->numInterfaces = m_InterfaceIdsByName.size() + 1; ENSURE(m_ComponentCaches.find(ent) == m_ComponentCaches.end()); @@ -838,7 +838,7 @@ if (allowCreate) return AllocateEntityHandle(ent); else - return CEntityHandle(ent, NULL); + return CEntityHandle(ent, nullptr); } else return CEntityHandle(ent, it->second); @@ -935,7 +935,7 @@ RemoveComponentDynamicSubscriptions(eit->second); m_ComponentTypesById[iit->first].dealloc(eit->second); iit->second.erase(ent); - handle.GetComponentCache()->interfaces[m_ComponentTypesById[iit->first].iid] = NULL; + handle.GetComponentCache()->interfaces[m_ComponentTypesById[iit->first].iid] = nullptr; } } @@ -957,14 +957,14 @@ if ((size_t)iid >= m_ComponentsByInterface.size()) { // Invalid iid - return NULL; + return nullptr; } boost::unordered_map::const_iterator eit = m_ComponentsByInterface[iid].find(ent); if (eit == m_ComponentsByInterface[iid].end()) { // This entity doesn't implement this interface - return NULL; + return nullptr; } return eit->second; Index: source/simulation2/system/ComponentManagerSerialization.cpp =================================================================== --- source/simulation2/system/ComponentManagerSerialization.cpp +++ source/simulation2/system/ComponentManagerSerialization.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -311,7 +311,7 @@ uint32_t numSystemComponentTypes; deserializer.NumberU32_Unbounded("num system component types", numSystemComponentTypes); - ICmpTemplateManager* templateManager = NULL; + ICmpTemplateManager* templateManager = nullptr; CParamNode noParam; for (size_t i = 0; i < numSystemComponentTypes; ++i) @@ -365,7 +365,7 @@ return false; // Try to find the template for this entity - const CParamNode* entTemplate = NULL; + const CParamNode* entTemplate = nullptr; if (templateManager) entTemplate = templateManager->LoadLatestTemplate(ent); Index: source/simulation2/system/ComponentTest.h =================================================================== --- source/simulation2/system/ComponentTest.h +++ source/simulation2/system/ComponentTest.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -54,7 +54,7 @@ public: ComponentTestHelper(shared_ptr runtime) : - m_Context(), m_ComponentManager(m_Context, runtime), m_Cmp(NULL) + m_Context(), m_ComponentManager(m_Context, runtime), m_Cmp(nullptr) { m_ComponentManager.LoadComponentTypes(); } @@ -75,7 +75,7 @@ template T* Add(EComponentTypeId cid, const std::string& xml, entity_id_t ent = 10) { - TS_ASSERT(m_Cmp == NULL); + TS_ASSERT(m_Cmp == nullptr); CEntityHandle handle; if (ent == SYSTEM_ENTITY) @@ -95,7 +95,7 @@ TS_ASSERT_EQUALS(CParamNode::LoadXMLString(m_Param, ("" + xml + "").c_str()), PSRETURN_OK); TS_ASSERT(m_ComponentManager.AddComponent(handle, m_Cid, m_Param.GetChild("test"))); m_Cmp = m_ComponentManager.QueryInterface(ent, T::GetInterfaceId()); - TS_ASSERT(m_Cmp != NULL); + TS_ASSERT(m_Cmp != nullptr); return static_cast (m_Cmp); } @@ -233,7 +233,7 @@ virtual CTerrain* GetCTerrain() { - return NULL; + return nullptr; } virtual void MakeDirty(i32 UNUSED(i0), i32 UNUSED(j0), i32 UNUSED(i1), i32 UNUSED(j1)) Index: source/simulation2/system/Entity.h =================================================================== --- source/simulation2/system/Entity.h +++ source/simulation2/system/Entity.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -79,7 +79,7 @@ class CEntityHandle { public: - CEntityHandle() : m_Id(INVALID_ENTITY), m_ComponentCache(NULL) { } + CEntityHandle() : m_Id(INVALID_ENTITY), m_ComponentCache(nullptr) { } CEntityHandle(entity_id_t id, SEntityComponentCache* componentCache) : m_Id(id), m_ComponentCache(componentCache) { Index: source/simulation2/system/InterfaceScripted.h =================================================================== --- source/simulation2/system/InterfaceScripted.h +++ source/simulation2/system/InterfaceScripted.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -30,7 +30,7 @@ JS_FS_END \ }; \ void ICmp##iname::InterfaceInit(ScriptInterface& scriptInterface) { \ - scriptInterface.DefineCustomObjectType(&class_ICmp##iname, NULL, 0, NULL, methods_ICmp##iname, NULL, NULL); \ + scriptInterface.DefineCustomObjectType(&class_ICmp##iname, nullptr, 0, nullptr, methods_ICmp##iname, nullptr, nullptr); \ } \ bool ICmp##iname::NewJSObject(const ScriptInterface& scriptInterface, JS::MutableHandleObject out) const\ { \ Index: source/simulation2/system/ParamNode.h =================================================================== --- source/simulation2/system/ParamNode.h +++ source/simulation2/system/ParamNode.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -163,7 +163,7 @@ * @param sourceIdentifier Optional; string you can pass along to indicate the source of * the data getting loaded. Used for output to log messages if an error occurs. */ - static void LoadXML(CParamNode& ret, const XMBFile& file, const wchar_t* sourceIdentifier = NULL); + static void LoadXML(CParamNode& ret, const XMBFile& file, const wchar_t* sourceIdentifier = nullptr); /** * Loads the XML data specified by @a path into the node @a ret. @@ -179,7 +179,7 @@ * @param sourceIdentifier Optional; string you can pass along to indicate the source of * the data getting loaded. Used for output to log messages if an error occurs. */ - static PSRETURN LoadXMLString(CParamNode& ret, const char* xml, const wchar_t* sourceIdentifier = NULL); + static PSRETURN LoadXMLString(CParamNode& ret, const char* xml, const wchar_t* sourceIdentifier = nullptr); /** * Returns the (unique) child node with the given name, or a node with IsOk() == false if there is none. @@ -271,7 +271,7 @@ * @param sourceIdentifier Optional; string you can pass along to indicate the source of * the data getting applied. Used for output to log messages if an error occurs. */ - void ApplyLayer(const XMBFile& xmb, const XMBElement& element, const wchar_t* sourceIdentifier = NULL); + void ApplyLayer(const XMBFile& xmb, const XMBElement& element, const wchar_t* sourceIdentifier = nullptr); void ResetScriptVal(); Index: source/simulation2/system/ParamNode.cpp =================================================================== --- source/simulation2/system/ParamNode.cpp +++ source/simulation2/system/ParamNode.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -37,7 +37,7 @@ { } -void CParamNode::LoadXML(CParamNode& ret, const XMBFile& xmb, const wchar_t* sourceIdentifier /*= NULL*/) +void CParamNode::LoadXML(CParamNode& ret, const XMBFile& xmb, const wchar_t* sourceIdentifier /*= nullptr*/) { ret.ApplyLayer(xmb, xmb.GetRoot(), sourceIdentifier); } @@ -52,7 +52,7 @@ LoadXML(ret, xero, path.string().c_str()); } -PSRETURN CParamNode::LoadXMLString(CParamNode& ret, const char* xml, const wchar_t* sourceIdentifier /*=NULL*/) +PSRETURN CParamNode::LoadXMLString(CParamNode& ret, const char* xml, const wchar_t* sourceIdentifier /*=nullptr*/) { CXeromyces xero; PSRETURN ok = xero.LoadString(xml); @@ -64,7 +64,7 @@ return PSRETURN_OK; } -void CParamNode::ApplyLayer(const XMBFile& xmb, const XMBElement& element, const wchar_t* sourceIdentifier /*= NULL*/) +void CParamNode::ApplyLayer(const XMBFile& xmb, const XMBElement& element, const wchar_t* sourceIdentifier /*= nullptr*/) { ResetScriptVal(); @@ -354,7 +354,7 @@ void CParamNode::ToJSVal(JSContext* cx, bool cacheValue, JS::MutableHandleValue ret) const { - if (cacheValue && m_ScriptVal != NULL) + if (cacheValue && m_ScriptVal != nullptr) { ret.set(*m_ScriptVal); return; @@ -435,5 +435,5 @@ void CParamNode::ResetScriptVal() { - m_ScriptVal = NULL; + m_ScriptVal = nullptr; } Index: source/simulation2/system/SimContext.cpp =================================================================== --- source/simulation2/system/SimContext.cpp +++ source/simulation2/system/SimContext.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -24,7 +24,7 @@ #include "ps/Game.h" CSimContext::CSimContext() : - m_ComponentManager(NULL), m_UnitManager(NULL), m_Terrain(NULL) + m_ComponentManager(nullptr), m_UnitManager(nullptr), m_Terrain(nullptr) { } @@ -39,7 +39,7 @@ bool CSimContext::HasUnitManager() const { - return m_UnitManager != NULL; + return m_UnitManager != nullptr; } CUnitManager& CSimContext::GetUnitManager() const Index: source/simulation2/tests/test_CmpTemplateManager.h =================================================================== --- source/simulation2/tests/test_CmpTemplateManager.h +++ source/simulation2/tests/test_CmpTemplateManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -62,22 +62,22 @@ TS_ASSERT(man.AddComponent(hnd1, CID_TemplateManager, noParam)); ICmpTemplateManager* tempMan = static_cast (man.QueryInterface(ent1, IID_TemplateManager)); - TS_ASSERT(tempMan != NULL); + TS_ASSERT(tempMan != nullptr); const CParamNode* basic = tempMan->LoadTemplate(ent2, "basic"); - TS_ASSERT(basic != NULL); + TS_ASSERT(basic != nullptr); TS_ASSERT_WSTR_EQUALS(basic->ToXML(), L"12345"); const CParamNode* inherit2 = tempMan->LoadTemplate(ent2, "inherit2"); - TS_ASSERT(inherit2 != NULL); + TS_ASSERT(inherit2 != nullptr); TS_ASSERT_WSTR_EQUALS(inherit2->ToXML(), L"d2e1f1g2"); const CParamNode* inherit1 = tempMan->LoadTemplate(ent2, "inherit1"); - TS_ASSERT(inherit1 != NULL); + TS_ASSERT(inherit1 != nullptr); TS_ASSERT_WSTR_EQUALS(inherit1->ToXML(), L"d1e1f1"); const CParamNode* actor = tempMan->LoadTemplate(ent2, "actor|example1"); - TS_ASSERT(actor != NULL); + TS_ASSERT(actor != nullptr); TS_ASSERT_WSTR_EQUALS(actor->ToXML(), L"1.0actor.pngactor_mask.png" L"example1falsefalsefalse"); @@ -96,7 +96,7 @@ TS_ASSERT(man.AddComponent(hnd1, CID_TemplateManager, noParam)); ICmpTemplateManager* tempMan = static_cast (man.QueryInterface(ent1, IID_TemplateManager)); - TS_ASSERT(tempMan != NULL); + TS_ASSERT(tempMan != nullptr); tempMan->DisableValidation(); JSContext* cx = man.GetScriptInterface().GetContext(); @@ -157,23 +157,23 @@ TS_ASSERT(man.AddComponent(hnd1, CID_TemplateManager, noParam)); ICmpTemplateManager* tempMan = static_cast (man.QueryInterface(ent1, IID_TemplateManager)); - TS_ASSERT(tempMan != NULL); + TS_ASSERT(tempMan != nullptr); TestLogger logger; - TS_ASSERT(tempMan->LoadTemplate(ent2, "illformed") == NULL); + TS_ASSERT(tempMan->LoadTemplate(ent2, "illformed") == nullptr); - TS_ASSERT(tempMan->LoadTemplate(ent2, "invalid") == NULL); + TS_ASSERT(tempMan->LoadTemplate(ent2, "invalid") == nullptr); - TS_ASSERT(tempMan->LoadTemplate(ent2, "nonexistent") == NULL); + TS_ASSERT(tempMan->LoadTemplate(ent2, "nonexistent") == nullptr); - TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-loop") == NULL); + TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-loop") == nullptr); - TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-broken") == NULL); + TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-broken") == nullptr); - TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-special") == NULL); + TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-special") == nullptr); - TS_ASSERT(tempMan->LoadTemplate(ent2, "preview|nonexistent") == NULL); + TS_ASSERT(tempMan->LoadTemplate(ent2, "preview|nonexistent") == nullptr); } void test_LoadTemplate_multiple() @@ -189,30 +189,30 @@ TS_ASSERT(man.AddComponent(hnd1, CID_TemplateManager, noParam)); ICmpTemplateManager* tempMan = static_cast (man.QueryInterface(ent1, IID_TemplateManager)); - TS_ASSERT(tempMan != NULL); + TS_ASSERT(tempMan != nullptr); const CParamNode* basicA = tempMan->LoadTemplate(ent2, "basic"); - TS_ASSERT(basicA != NULL); + TS_ASSERT(basicA != nullptr); const CParamNode* basicB = tempMan->LoadTemplate(ent2, "basic"); TS_ASSERT(basicA == basicB); const CParamNode* inherit2A = tempMan->LoadTemplate(ent2, "inherit2"); - TS_ASSERT(inherit2A != NULL); + TS_ASSERT(inherit2A != nullptr); const CParamNode* inherit2B = tempMan->LoadTemplate(ent2, "inherit2"); TS_ASSERT(inherit2A == inherit2B); TestLogger logger; - TS_ASSERT(tempMan->LoadTemplate(ent2, "nonexistent") == NULL); - TS_ASSERT(tempMan->LoadTemplate(ent2, "nonexistent") == NULL); + TS_ASSERT(tempMan->LoadTemplate(ent2, "nonexistent") == nullptr); + TS_ASSERT(tempMan->LoadTemplate(ent2, "nonexistent") == nullptr); - TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-loop") == NULL); - TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-loop") == NULL); + TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-loop") == nullptr); + TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-loop") == nullptr); - TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-broken") == NULL); - TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-broken") == NULL); + TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-broken") == nullptr); + TS_ASSERT(tempMan->LoadTemplate(ent2, "inherit-broken") == nullptr); } }; @@ -239,7 +239,7 @@ void test_load_all_DISABLED() // disabled since it's a bit slow and noisy { CTerrain dummy; - CSimulation2 sim(NULL, g_ScriptRuntime, &dummy); + CSimulation2 sim(nullptr, g_ScriptRuntime, &dummy); sim.LoadDefaultScripts(); sim.ResetState(); @@ -252,7 +252,7 @@ std::string name = templates[i]; printf("# %s\n", name.c_str()); const CParamNode* p = cmpTemplateManager->GetTemplate(name); - TS_ASSERT(p != NULL); + TS_ASSERT(p != nullptr); } } }; Index: source/simulation2/tests/test_ComponentManager.h =================================================================== --- source/simulation2/tests/test_ComponentManager.h +++ source/simulation2/tests/test_ComponentManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -157,17 +157,17 @@ CParamNode noParam; man.AddComponent(hnd1, CID_Test1A, noParam); - TS_ASSERT(man.QueryInterface(ent1, IID_Test1) != NULL); - TS_ASSERT(man.QueryInterface(ent1, IID_Test2) == NULL); - TS_ASSERT(man.QueryInterface(ent2, IID_Test1) == NULL); - TS_ASSERT(man.QueryInterface(ent2, IID_Test2) == NULL); + TS_ASSERT(man.QueryInterface(ent1, IID_Test1) != nullptr); + TS_ASSERT(man.QueryInterface(ent1, IID_Test2) == nullptr); + TS_ASSERT(man.QueryInterface(ent2, IID_Test1) == nullptr); + TS_ASSERT(man.QueryInterface(ent2, IID_Test2) == nullptr); man.AddComponent(hnd2, CID_Test1B, noParam); - TS_ASSERT(man.QueryInterface(ent2, IID_Test1) != NULL); - TS_ASSERT(man.QueryInterface(ent2, IID_Test2) == NULL); + TS_ASSERT(man.QueryInterface(ent2, IID_Test1) != nullptr); + TS_ASSERT(man.QueryInterface(ent2, IID_Test2) == nullptr); man.AddComponent(hnd2, CID_Test2A, noParam); - TS_ASSERT(man.QueryInterface(ent2, IID_Test1) != NULL); - TS_ASSERT(man.QueryInterface(ent2, IID_Test2) != NULL); + TS_ASSERT(man.QueryInterface(ent2, IID_Test1) != nullptr); + TS_ASSERT(man.QueryInterface(ent2, IID_Test2) != nullptr); } void test_SendMessage() @@ -436,16 +436,16 @@ TS_ASSERT(man.AddComponent(hnd1, man.LookupCID("TestScript1_AddEntity"), noParam)); - TS_ASSERT(man.QueryInterface(ent2, IID_Test1) == NULL); - TS_ASSERT(man.QueryInterface(ent2, IID_Test2) == NULL); + TS_ASSERT(man.QueryInterface(ent2, IID_Test1) == nullptr); + TS_ASSERT(man.QueryInterface(ent2, IID_Test2) == nullptr); { TestLogger logger; // ignore bogus-template warnings TS_ASSERT_EQUALS(static_cast (man.QueryInterface(ent1, IID_Test1))->GetX(), (int)ent2); } - TS_ASSERT(man.QueryInterface(ent2, IID_Test1) != NULL); - TS_ASSERT(man.QueryInterface(ent2, IID_Test2) != NULL); + TS_ASSERT(man.QueryInterface(ent2, IID_Test1) != nullptr); + TS_ASSERT(man.QueryInterface(ent2, IID_Test2) != nullptr); TS_ASSERT_EQUALS(static_cast (man.QueryInterface(ent2, IID_Test1))->GetX(), 999); TS_ASSERT_EQUALS(static_cast (man.QueryInterface(ent2, IID_Test2))->GetX(), 12345); @@ -469,16 +469,16 @@ TS_ASSERT(man.AddComponent(hnd1, man.LookupCID("TestScript1_AddLocalEntity"), noParam)); - TS_ASSERT(man.QueryInterface(ent2, IID_Test1) == NULL); - TS_ASSERT(man.QueryInterface(ent2, IID_Test2) == NULL); + TS_ASSERT(man.QueryInterface(ent2, IID_Test1) == nullptr); + TS_ASSERT(man.QueryInterface(ent2, IID_Test2) == nullptr); { TestLogger logger; // ignore bogus-template warnings TS_ASSERT_EQUALS(static_cast (man.QueryInterface(ent1, IID_Test1))->GetX(), (int)ent2); } - TS_ASSERT(man.QueryInterface(ent2, IID_Test1) != NULL); - TS_ASSERT(man.QueryInterface(ent2, IID_Test2) != NULL); + TS_ASSERT(man.QueryInterface(ent2, IID_Test1) != nullptr); + TS_ASSERT(man.QueryInterface(ent2, IID_Test2) != nullptr); TS_ASSERT_EQUALS(static_cast (man.QueryInterface(ent2, IID_Test1))->GetX(), 999); TS_ASSERT_EQUALS(static_cast (man.QueryInterface(ent2, IID_Test2))->GetX(), 12345); @@ -497,11 +497,11 @@ TS_ASSERT(man.AddComponent(hnd1, man.LookupCID("TestScript1_DestroyEntity"), noParam)); - TS_ASSERT(man.QueryInterface(ent1, IID_Test1) != NULL); + TS_ASSERT(man.QueryInterface(ent1, IID_Test1) != nullptr); static_cast (man.QueryInterface(ent1, IID_Test1))->GetX(); - TS_ASSERT(man.QueryInterface(ent1, IID_Test1) != NULL); + TS_ASSERT(man.QueryInterface(ent1, IID_Test1) != nullptr); man.FlushDestroyedComponents(); - TS_ASSERT(man.QueryInterface(ent1, IID_Test1) == NULL); + TS_ASSERT(man.QueryInterface(ent1, IID_Test1) == nullptr); } void test_script_messages() @@ -694,17 +694,17 @@ CComponentManager man2(context2, g_ScriptRuntime); man2.LoadComponentTypes(); - TS_ASSERT(man2.QueryInterface(ent1, IID_Test1) == NULL); - TS_ASSERT(man2.QueryInterface(ent1, IID_Test2) == NULL); - TS_ASSERT(man2.QueryInterface(ent2, IID_Test1) == NULL); - TS_ASSERT(man2.QueryInterface(ent3, IID_Test2) == NULL); + TS_ASSERT(man2.QueryInterface(ent1, IID_Test1) == nullptr); + TS_ASSERT(man2.QueryInterface(ent1, IID_Test2) == nullptr); + TS_ASSERT(man2.QueryInterface(ent2, IID_Test1) == nullptr); + TS_ASSERT(man2.QueryInterface(ent3, IID_Test2) == nullptr); TS_ASSERT(man2.DeserializeState(stateStream)); TS_ASSERT_EQUALS(static_cast (man2.QueryInterface(ent1, IID_Test1))->GetX(), 11000); TS_ASSERT_EQUALS(static_cast (man2.QueryInterface(ent1, IID_Test2))->GetX(), 21000); TS_ASSERT_EQUALS(static_cast (man2.QueryInterface(ent2, IID_Test1))->GetX(), 1234); - TS_ASSERT(man2.QueryInterface(ent3, IID_Test2) == NULL); + TS_ASSERT(man2.QueryInterface(ent3, IID_Test2) == nullptr); } void test_script_serialization() @@ -791,7 +791,7 @@ man2.LoadComponentTypes(); TS_ASSERT(man2.LoadScript(L"simulation/components/test-serialize.js")); - TS_ASSERT(man2.QueryInterface(ent1, IID_Test1) == NULL); + TS_ASSERT(man2.QueryInterface(ent1, IID_Test1) == nullptr); TS_ASSERT(man2.DeserializeState(stateStream)); TS_ASSERT_EQUALS(static_cast (man2.QueryInterface(ent1, IID_Test1))->GetX(), 1234); { Index: source/simulation2/tests/test_Serializer.h =================================================================== --- source/simulation2/tests/test_Serializer.h +++ source/simulation2/tests/test_Serializer.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -289,7 +289,7 @@ // TODO: test exceptions more thoroughly - void helper_script_roundtrip(const char* msg, const char* input, const char* expected, size_t expstreamlen = 0, const char* expstream = NULL, const char* debug = NULL) + void helper_script_roundtrip(const char* msg, const char* input, const char* expected, size_t expstreamlen = 0, const char* expstream = nullptr, const char* debug = nullptr) { ScriptInterface script("Test", "Test", g_ScriptRuntime); JSContext* cx = script.GetContext(); @@ -835,7 +835,7 @@ CTerrain terrain; - CSimulation2 sim2(NULL, g_ScriptRuntime, &terrain); + CSimulation2 sim2(nullptr, g_ScriptRuntime, &terrain); sim2.LoadDefaultScripts(); sim2.ResetState(); @@ -844,7 +844,7 @@ LDR_BeginRegistering(); mapReader->LoadMap(L"maps/skirmishes/Greek Acropolis (2).pmp", sim2.GetScriptInterface().GetJSRuntime(), JS::UndefinedHandleValue, - &terrain, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + &terrain, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &sim2, &sim2.GetSimContext(), -1, false); LDR_EndRegistering(); TS_ASSERT_OK(LDR_NonprogressiveLoad()); Index: source/simulation2/tests/test_Simulation2.h =================================================================== --- source/simulation2/tests/test_Simulation2.h +++ source/simulation2/tests/test_Simulation2.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -57,7 +57,7 @@ void test_AddEntity() { - CSimulation2 sim(NULL, g_ScriptRuntime, &m_Terrain); + CSimulation2 sim(nullptr, g_ScriptRuntime, &m_Terrain); TS_ASSERT(sim.LoadScripts(L"simulation/components/addentity/")); sim.ResetState(true, true); @@ -77,7 +77,7 @@ void test_DestroyEntity() { - CSimulation2 sim(NULL, g_ScriptRuntime, &m_Terrain); + CSimulation2 sim(nullptr, g_ScriptRuntime, &m_Terrain); TS_ASSERT(sim.LoadScripts(L"simulation/components/addentity/")); sim.ResetState(true, true); @@ -102,8 +102,8 @@ sim.FlushDestroyedEntities(); // actually delete it - TS_ASSERT(sim.QueryInterface(ent2, IID_Test1) == NULL); - TS_ASSERT(sim.QueryInterface(ent2, IID_Test2) == NULL); + TS_ASSERT(sim.QueryInterface(ent2, IID_Test1) == nullptr); + TS_ASSERT(sim.QueryInterface(ent2, IID_Test2) == nullptr); sim.FlushDestroyedEntities(); // nothing in the queue @@ -119,8 +119,8 @@ sim.DestroyEntity(ent3); // mark it for deletion twice sim.DestroyEntity(ent3); sim.FlushDestroyedEntities(); - TS_ASSERT(sim.QueryInterface(ent3, IID_Test1) == NULL); - TS_ASSERT(sim.QueryInterface(ent3, IID_Test2) == NULL); + TS_ASSERT(sim.QueryInterface(ent3, IID_Test1) == nullptr); + TS_ASSERT(sim.QueryInterface(ent3, IID_Test2) == nullptr); // Messages mustn't get sent to the destroyed components (else we'll crash) CMessageTurnStart msg; @@ -129,7 +129,7 @@ void test_hotload_scripts() { - CSimulation2 sim(NULL, g_ScriptRuntime, &m_Terrain); + CSimulation2 sim(nullptr, g_ScriptRuntime, &m_Terrain); TS_ASSERT_OK(CreateDirectories(DataDir()/"mods"/"_test.sim"/"simulation"/"components"/"hotload"/"", 0700)); Index: source/soundmanager/SoundManager.cpp =================================================================== --- source/soundmanager/SoundManager.cpp +++ source/soundmanager/SoundManager.cpp @@ -32,7 +32,7 @@ #include "ps/Profiler2.h" #include "ps/XML/Xeromyces.h" -ISoundManager* g_SoundManager = NULL; +ISoundManager* g_SoundManager = nullptr; #define SOURCE_NUM 64 @@ -49,7 +49,7 @@ m_DeadItems = new ItemsList; m_Shutdown = false; - int ret = pthread_create(&m_WorkerThread, NULL, &RunThread, this); + int ret = pthread_create(&m_WorkerThread, nullptr, &RunThread, this); ENSURE(ret == 0); } @@ -76,7 +76,7 @@ } - pthread_join(m_WorkerThread, NULL); + pthread_join(m_WorkerThread, nullptr); return true; } @@ -110,7 +110,7 @@ static_cast(data)->Run(); - return NULL; + return nullptr; } void Run() @@ -201,7 +201,7 @@ void ISoundManager::CloseGame() { if (CSoundManager* aSndMgr = (CSoundManager*)g_SoundManager) - aSndMgr->SetAmbientItem(NULL); + aSndMgr->SetAmbientItem(nullptr); } void CSoundManager::al_ReportError(ALenum err, const char* caller, int line) @@ -283,7 +283,7 @@ if (m_PlayListItems) delete m_PlayListItems; - if (m_ALSourceBuffer != NULL) + if (m_ALSourceBuffer != nullptr) delete[] m_ALSourceBuffer; if (m_Context) @@ -303,7 +303,7 @@ { Status ret = INFO::OK; - m_Device = alcOpenDevice(NULL); + m_Device = alcOpenDevice(nullptr); if (m_Device) { ALCint attribs[] = {ALC_STEREO_SOURCES, 16, 0}; @@ -323,7 +323,7 @@ for (int x = 0; x < SOURCE_NUM; x++) { m_ALSourceBuffer[x].ALSource = sourceList[x]; - m_ALSourceBuffer[x].SourceItem = NULL; + m_ALSourceBuffer[x].SourceItem = nullptr; } m_Enabled = true; } @@ -416,7 +416,7 @@ { if (m_ALSourceBuffer[x].ALSource == theSource) { - m_ALSourceBuffer[x].SourceItem = NULL; + m_ALSourceBuffer[x].SourceItem = nullptr; return; } } @@ -442,7 +442,7 @@ if (m_Enabled) { if (m_PlayingPlaylist) - SetMusicItem(NULL); + SetMusicItem(nullptr); m_PlayingPlaylist = false; m_LoopingPlaylist = false; @@ -466,7 +466,7 @@ if (aSnd) SetMusicItem(aSnd); else - SetMusicItem(NULL); + SetMusicItem(nullptr); } } } @@ -515,17 +515,17 @@ return CSoundManager::ItemForData(itemData); } - return NULL; + return nullptr; } ISoundItem* CSoundManager::ItemForData(CSoundData* itemData) { AL_CHECK; - ISoundItem* answer = NULL; + ISoundItem* answer = nullptr; AL_CHECK; - if (m_Enabled && (itemData != NULL)) + if (m_Enabled && (itemData != nullptr)) { if (itemData->IsOneShot()) { @@ -594,7 +594,7 @@ ISoundItem* CSoundManager::ItemForEntity(entity_id_t UNUSED(source), CSoundData* sndData) { - ISoundItem* currentItem = NULL; + ISoundItem* currentItem = nullptr; if (m_Enabled) currentItem = ItemForData(sndData); @@ -634,7 +634,7 @@ if (m_CurrentTune && !isEnabled) { m_CurrentTune->FadeAndDelete(1.00); - m_CurrentTune = NULL; + m_CurrentTune = nullptr; } m_MusicEnabled = isEnabled; } @@ -650,7 +650,7 @@ { LOGERROR("Failed to load sound group '%s'", groupPath.string8()); delete group; - group = NULL; + group = nullptr; } // Cache the sound group (or the null, if it failed) m_SoundGroups[groupPath.string()] = group; @@ -672,7 +672,7 @@ UNUSED2(looping); ISoundItem* aSnd = LoadItem(itemPath); - if (aSnd != NULL) + if (aSnd != nullptr) SetMusicItem(aSnd); } } @@ -683,7 +683,7 @@ { UNUSED2(looping); ISoundItem* aSnd = LoadItem(itemPath); - if (aSnd != NULL) + if (aSnd != nullptr) SetAmbientItem(aSnd); } } @@ -753,7 +753,7 @@ if (m_CurrentTune) { m_CurrentTune->FadeAndDelete(2.00); - m_CurrentTune = NULL; + m_CurrentTune = nullptr; } IdleTask(); @@ -792,7 +792,7 @@ if (m_CurrentEnvirons) { m_CurrentEnvirons->FadeAndDelete(3.00); - m_CurrentEnvirons = NULL; + m_CurrentEnvirons = nullptr; } IdleTask(); Index: source/soundmanager/data/SoundData.cpp =================================================================== --- source/soundmanager/data/SoundData.cpp +++ source/soundmanager/data/SoundData.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -59,7 +59,7 @@ { Path fExt = itemPath.Extension(); DataMap::iterator itemFind; - CSoundData* answer = NULL; + CSoundData* answer = nullptr; if ((itemFind = CSoundData::sSoundData.find(itemPath.string())) != sSoundData.end()) { @@ -94,7 +94,7 @@ { LOGERROR("could not initialize ogg data at %s", itemPath.string8()); delete oggAnswer; - return NULL; + return nullptr; } return oggAnswer; Index: source/soundmanager/data/ogg.cpp =================================================================== --- source/soundmanager/data/ogg.cpp +++ source/soundmanager/data/ogg.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -219,7 +219,7 @@ : adapter(adapter) { m_fileEOF = false; - info = NULL; + info = nullptr; } Status Close() Index: source/soundmanager/items/CBufferItem.cpp =================================================================== --- source/soundmanager/items/CBufferItem.cpp +++ source/soundmanager/items/CBufferItem.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -107,13 +107,13 @@ return; AL_CHECK; - if (m_SoundData != NULL) + if (m_SoundData != nullptr) { CSoundData::ReleaseSoundData(m_SoundData); m_SoundData = 0; } AL_CHECK; - if (itemData != NULL) + if (itemData != nullptr) { m_SoundData = itemData->IncrementCount(); alSourceQueueBuffers(m_ALSource, m_SoundData->GetBufferCount(),(const ALuint *) m_SoundData->GetBufferPtr()); Index: source/soundmanager/items/CSoundItem.cpp =================================================================== --- source/soundmanager/items/CSoundItem.cpp +++ source/soundmanager/items/CSoundItem.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -63,13 +63,13 @@ void CSoundItem::Attach(CSoundData* itemData) { - if (m_SoundData != NULL) + if (m_SoundData != nullptr) { CSoundData::ReleaseSoundData(m_SoundData); m_SoundData = 0; } - if (itemData != NULL) + if (itemData != nullptr) { AL_CHECK; alSourcei(m_ALSource, AL_BUFFER, 0); Index: source/soundmanager/items/CStreamItem.cpp =================================================================== --- source/soundmanager/items/CStreamItem.cpp +++ source/soundmanager/items/CStreamItem.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -78,7 +78,7 @@ if (m_LastPlay) return (proc_state != AL_STOPPED); } - else if (m_SoundData != NULL) + else if (m_SoundData != nullptr) { COggData* theData = (COggData*)m_SoundData; @@ -117,13 +117,13 @@ void CStreamItem::Attach(CSoundData* itemData) { - if (m_SoundData != NULL) + if (m_SoundData != nullptr) { CSoundData::ReleaseSoundData(m_SoundData); m_SoundData = 0; } - if (itemData != NULL) + if (itemData != nullptr) { m_SoundData = itemData->IncrementCount(); alSourceQueueBuffers(m_ALSource, m_SoundData->GetBufferCount(), (const ALuint *)m_SoundData->GetBufferPtr()); Index: source/soundmanager/scripting/SoundGroup.cpp =================================================================== --- source/soundmanager/scripting/SoundGroup.cpp +++ source/soundmanager/scripting/SoundGroup.cpp @@ -248,7 +248,7 @@ VfsPath thePath = m_filepath/filenames[i]; CSoundData* itemData = CSoundData::SoundDataFromFile(thePath); - if (itemData == NULL) + if (itemData == nullptr) HandleError(L"error loading sound", thePath, ERR::FAIL); else snd_group.push_back(itemData->IncrementCount()); Index: source/tools/atlas/GameInterface/ActorViewer.cpp =================================================================== --- source/tools/atlas/GameInterface/ActorViewer.cpp +++ source/tools/atlas/GameInterface/ActorViewer.cpp @@ -261,7 +261,7 @@ // Create a tiny empty piece of terrain, just so we can put shadows // on it without having to think too hard - m.Terrain.Initialize(2, NULL); + m.Terrain.Initialize(2, nullptr); CTerrainTextureEntry* tex = g_TexMan.FindTexture("whiteness"); if (tex) { Index: source/tools/atlas/GameInterface/Brushes.h =================================================================== --- source/tools/atlas/GameInterface/Brushes.h +++ source/tools/atlas/GameInterface/Brushes.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -48,7 +48,7 @@ ssize_t m_W, m_H; CVector3D m_Centre; private: - TerrainOverlay* m_TerrainOverlay; // NULL if rendering is not enabled + TerrainOverlay* m_TerrainOverlay; // nullptr if rendering is not enabled std::vector m_Data; }; Index: source/tools/atlas/GameInterface/Brushes.cpp =================================================================== --- source/tools/atlas/GameInterface/Brushes.cpp +++ source/tools/atlas/GameInterface/Brushes.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -70,7 +70,7 @@ }; Brush::Brush() -: m_W(0), m_H(0), m_TerrainOverlay(NULL) +: m_W(0), m_H(0), m_TerrainOverlay(nullptr) { } @@ -124,7 +124,7 @@ else if (!enabled && m_TerrainOverlay) { delete m_TerrainOverlay; - m_TerrainOverlay = NULL; + m_TerrainOverlay = nullptr; } } Index: source/tools/atlas/GameInterface/CommandProc.h =================================================================== --- source/tools/atlas/GameInterface/CommandProc.h +++ source/tools/atlas/GameInterface/CommandProc.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -97,7 +97,7 @@ dCommandName* msg; public: // Ensure msg is initialised to something 'safe' - cCommandName_base : msg(NULL) {} + cCommandName_base : msg(nullptr) {} // MergeIntoPrevious should be overridden by mergeable commands, and implemented // to update 'prev' to include the effects of 'this'. (A subclass overriding @@ -149,7 +149,7 @@ protected: \ d##t* msg; \ public: \ - c##t##_base() : msg(NULL) {} \ + c##t##_base() : msg(nullptr) {} \ void MergeIntoPrevious(void*) { debug_warn(L"MergeIntoPrevious unimplemented in command " WIDEN(#t)); } \ }; \ struct c##t : public c##t##_base @@ -166,7 +166,7 @@ { \ /* (msg was allocated in mDoCommand(), using SHAREABLE_NEW) */ \ AtlasMessage::ShareableDelete(msg); \ - msg = NULL; \ + msg = nullptr; \ } \ virtual void Merge(Command* prev) { MergeIntoPrevious(static_cast(prev)); } \ virtual const char* GetType() const { return #t; } \ Index: source/tools/atlas/GameInterface/CommandProc.cpp =================================================================== --- source/tools/atlas/GameInterface/CommandProc.cpp +++ source/tools/atlas/GameInterface/CommandProc.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -50,9 +50,9 @@ CommandProc::CommandProc() { - // Start the list with a NULL, so m_CurrentCommand can point at + // Start the list with a nullptr, so m_CurrentCommand can point at // something even when the command stack is empty - m_Commands.push_back(NULL); + m_Commands.push_back(nullptr); m_CurrentCommand = m_Commands.begin(); } Index: source/tools/atlas/GameInterface/GameLoop.cpp =================================================================== --- source/tools/atlas/GameInterface/GameLoop.cpp +++ source/tools/atlas/GameInterface/GameLoop.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -64,7 +64,7 @@ } -MessagePasser* AtlasMessage::g_MessagePasser = NULL; +MessagePasser* AtlasMessage::g_MessagePasser = nullptr; static InputProcessor g_Input; @@ -129,7 +129,7 @@ state.args = args; state.running = true; state.view = AtlasView::GetView_None(); - state.glCanvas = NULL; + state.glCanvas = nullptr; double last_activity = timer_Time(); @@ -161,7 +161,7 @@ { IMessage* msg; - while ((msg = msgPasser->Retrieve()) != NULL) + while ((msg = msgPasser->Retrieve()) != nullptr) { recent_activity = true; @@ -268,7 +268,7 @@ } } - return NULL; + return nullptr; } bool BeginAtlas(const CmdLineArgs& args, const DllLoader& dll) @@ -310,14 +310,14 @@ // Run the engine loop in a new thread pthread_t engineThread; - pthread_create(&engineThread, NULL, RunEngine, reinterpret_cast(const_cast(&args))); + pthread_create(&engineThread, nullptr, RunEngine, reinterpret_cast(const_cast(&args))); // Start Atlas UI on main thread // (required for wxOSX/Cocoa compatibility - see http://trac.wildfiregames.com/ticket/500) Atlas_StartWindow(L"ScenarioEditor"); // Wait for the engine to exit - pthread_join(engineThread, NULL); + pthread_join(engineThread, nullptr); // TODO: delete all remaining messages, to avoid memory leak warnings @@ -326,7 +326,7 @@ // Clean up AtlasView::DestroyViews(); - AtlasMessage::g_MessagePasser = NULL; + AtlasMessage::g_MessagePasser = nullptr; return true; } Index: source/tools/atlas/GameInterface/Handlers/CommandHandlers.cpp =================================================================== --- source/tools/atlas/GameInterface/Handlers/CommandHandlers.cpp +++ source/tools/atlas/GameInterface/Handlers/CommandHandlers.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -26,7 +26,7 @@ MESSAGEHANDLER(DoCommand) { - Command* c = NULL; + Command* c = nullptr; cmdHandlers::const_iterator it = GetCmdHandlers().find("c" + *msg->name); if (it != GetCmdHandlers().end()) { Index: source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp =================================================================== --- source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp +++ source/tools/atlas/GameInterface/Handlers/GraphicsSetupHandlers.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -77,7 +77,7 @@ // should be checked.) // So, make sure it's loaded: SDL_InitSubSystem(SDL_INIT_VIDEO); - SDL_GL_LoadLibrary(NULL); // NULL = use default + SDL_GL_LoadLibrary(nullptr); // nullptr = use default // (it shouldn't hurt if this is called multiple times, I think) } Index: source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp =================================================================== --- source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp +++ source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp @@ -54,7 +54,7 @@ if (g_Game) { delete g_Game; - g_Game = NULL; + g_Game = nullptr; } g_Game = new CGame(false, false); Index: source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp =================================================================== --- source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp +++ source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -161,7 +161,7 @@ MESSAGEHANDLER(GuiSwitchPage) { - g_GUI->SwitchPage(*msg->page, NULL, JS::UndefinedHandleValue); + g_GUI->SwitchPage(*msg->page, nullptr, JS::UndefinedHandleValue); } MESSAGEHANDLER(GuiMouseButtonEvent) Index: source/tools/atlas/GameInterface/Handlers/TerrainHandlers.cpp =================================================================== --- source/tools/atlas/GameInterface/Handlers/TerrainHandlers.cpp +++ source/tools/atlas/GameInterface/Handlers/TerrainHandlers.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2012 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -220,7 +220,7 @@ CTerrainTextureEntry* GetTexEntry(ssize_t x, ssize_t y) { if (size_t(x) >= size_t(m_VertsPerSide-1) || size_t(y) >= size_t(m_VertsPerSide-1)) - return NULL; + return nullptr; return get(x, y).tex; } Index: source/tools/atlas/GameInterface/MessagePasserImpl.cpp =================================================================== --- source/tools/atlas/GameInterface/MessagePasserImpl.cpp +++ source/tools/atlas/GameInterface/MessagePasserImpl.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2013 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -30,7 +30,7 @@ MessagePasserImpl::MessagePasserImpl() -: m_Trace(false), m_Semaphore(NULL) +: m_Trace(false), m_Semaphore(nullptr) { int tries = 0; while (tries++ < 16) // some arbitrary cut-off point to avoid infinite loops @@ -98,7 +98,7 @@ // since there's only one thread adding items and one thread consuming; // but it's not worthwhile yet.) - IMessage* msg = NULL; + IMessage* msg = nullptr; { CScopeLock lock(m_Mutex); @@ -180,7 +180,7 @@ } // Clean up - qry->m_Semaphore = NULL; + qry->m_Semaphore = nullptr; } bool MessagePasserImpl::IsEmpty() Index: source/tools/atlas/GameInterface/MessagesSetup.h =================================================================== --- source/tools/atlas/GameInterface/MessagesSetup.h +++ source/tools/atlas/GameInterface/MessagesSetup.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2009 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -125,7 +125,7 @@ struct mBlah : public IMessage { const char* GetName() const { return "Blah"; } mBlah(int in0_, bool in1_) : in0(in0_), in1(in1_) {} - static mBlah* CtorType (int, bool) { return NULL; } // This doesn't do anything useful - it's just to make template-writing easier + static mBlah* CtorType (int, bool) { return nullptr; } // This doesn't do anything useful - it's just to make template-writing easier const Shareable in0; const Shareable in1; } @@ -135,14 +135,14 @@ MESSAGESTRUCT(name) \ m##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, vals) ) \ : BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORINIT, ~, vals) {} \ - static m##name* CtorType( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORTYPES, ~, vals) ) { return NULL; } \ + static m##name* CtorType( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORTYPES, ~, vals) ) { return nullptr; } \ BOOST_PP_SEQ_FOR_EACH_I(B_CONSTMEMBERS, ~, vals) \ } #define MESSAGE_WITHOUT_INPUTS(name, vals) \ MESSAGESTRUCT(name) \ m##name() {} \ - static m##name* CtorType() { return NULL; } \ + static m##name* CtorType() { return nullptr; } \ } #define MESSAGE(name, vals) \ @@ -168,7 +168,7 @@ #define QUERY_WITHOUT_INPUTS(name, in_vals, out_vals) \ QUERYSTRUCT(name) \ q##name() {} \ - static q##name* CtorType() { return NULL; } \ + static q##name* CtorType() { return nullptr; } \ BOOST_PP_SEQ_FOR_EACH_I(B_MEMBERS, ~, out_vals) /* other members */ \ } @@ -176,7 +176,7 @@ QUERYSTRUCT(name) \ q##name( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORARGS, ~, in_vals) ) \ : BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORINIT, ~, in_vals) {} \ - static q##name* CtorType( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORTYPES, ~, in_vals) ) { return NULL; } \ + static q##name* CtorType( BOOST_PP_SEQ_FOR_EACH_I(B_CONSTRUCTORTYPES, ~, in_vals) ) { return nullptr; } \ BOOST_PP_SEQ_FOR_EACH_I(B_CONSTMEMBERS, ~, in_vals) \ BOOST_PP_SEQ_FOR_EACH_I(B_MEMBERS, ~, out_vals) \ } Index: source/tools/atlas/GameInterface/Shareable.h =================================================================== --- source/tools/atlas/GameInterface/Shareable.h +++ source/tools/atlas/GameInterface/Shareable.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2015 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -142,7 +142,7 @@ public: enum { TypeIsShareable = 1 }; - Shareable() : buf(NULL), length(0) {} + Shareable() : buf(nullptr), length(0) {} Shareable(const wrapped_type& rhs) { @@ -168,7 +168,7 @@ } Shareable(const Shareable& rhs) - : buf(NULL), length(0) + : buf(nullptr), length(0) { *this = rhs; } @@ -206,21 +206,21 @@ // reasonably safe to assume there's no exceptions or other confusingness.) void Unalloc() { - if (array == NULL) + if (array == nullptr) return; for (size_t i = 0; i < size; ++i) array[i].~element_type(); ShareableFreeFptr(array); - array = NULL; + array = nullptr; size = 0; } public: enum { TypeIsShareable = 1 }; - Shareable() : array(NULL), size(0) {} + Shareable() : array(nullptr), size(0) {} Shareable(const wrapped_type& rhs) { @@ -248,7 +248,7 @@ } Shareable(const Shareable& rhs) - : array(NULL), size(0) + : array(nullptr), size(0) { *this = rhs; } @@ -292,7 +292,7 @@ // (TODO - this is probably not really safely shareable, due to unspecified calling conventions) template struct Callback { - Callback() : cb(NULL), cbdata(NULL) {} + Callback() : cb(nullptr), cbdata(nullptr) {} Callback(void (*cb) (const T*, void*), void* cbdata) : cb(cb), cbdata(cbdata) {} void (*cb) (const T*, void*); void* cbdata; Index: source/tools/atlas/GameInterface/SimState.cpp =================================================================== --- source/tools/atlas/GameInterface/SimState.cpp +++ source/tools/atlas/GameInterface/SimState.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -29,7 +29,7 @@ if (! g_Game->GetSimulation2()->SerializeState(simState->stream)) { delete simState; - return NULL; + return nullptr; } return simState; Index: source/tools/atlas/GameInterface/View.h =================================================================== --- source/tools/atlas/GameInterface/View.h +++ source/tools/atlas/GameInterface/View.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -43,7 +43,7 @@ virtual void DrawCinemaPathTool() { }; virtual void DrawOverlays() { }; virtual CCamera& GetCamera() = 0; - virtual CSimulation2* GetSimulation2() { return NULL; } + virtual CSimulation2* GetSimulation2() { return nullptr; } virtual entity_id_t GetEntityId(AtlasMessage::ObjectID obj) { return (entity_id_t)obj; } virtual bool WantsHighFramerate() { return false; } virtual void SetEnabled(bool UNUSED(enabled)) {} @@ -54,7 +54,7 @@ virtual void SetParam(const std::wstring& name, const AtlasMessage::Color& value); virtual void SetParam(const std::wstring& name, const std::wstring& value); - // These always return a valid (not NULL) object + // These always return a valid (not nullptr) object static AtlasView* GetView(int /*eRenderView*/ view); static AtlasView* GetView_None(); static AtlasViewGame* GetView_Game(); Index: source/tools/atlas/GameInterface/View.cpp =================================================================== --- source/tools/atlas/GameInterface/View.cpp +++ source/tools/atlas/GameInterface/View.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2018 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -459,9 +459,9 @@ ////////////////////////////////////////////////////////////////////////// -AtlasViewNone* view_None = NULL; -AtlasViewGame* view_Game = NULL; -AtlasViewActor* view_Actor = NULL; +AtlasViewNone* view_None = nullptr; +AtlasViewGame* view_Game = nullptr; +AtlasViewActor* view_Actor = nullptr; AtlasView::~AtlasView() { @@ -503,7 +503,7 @@ void AtlasView::DestroyViews() { - delete view_None; view_None = NULL; - delete view_Game; view_Game = NULL; - delete view_Actor; view_Actor = NULL; + delete view_None; view_None = nullptr; + delete view_Game; view_Game = nullptr; + delete view_Actor; view_Actor = nullptr; }