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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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/file/archive/archive_zip.cpp =================================================================== --- source/lib/file/archive/archive_zip.cpp +++ source/lib/file/archive/archive_zip.cpp @@ -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 @@ -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 @@ -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 @@ -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 @@ -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/pch/pch_warnings.h =================================================================== --- source/lib/pch/pch_warnings.h +++ source/lib/pch/pch_warnings.h @@ -42,7 +42,7 @@ # pragma warning(disable:4718) // recursive call has no side effects, deleting # pragma warning(disable:4786) // identifier truncated to 255 chars # pragma warning(disable:4996) // function is deprecated -# pragma warning(disable:6011) // dereferencing NULL pointer +# pragma warning(disable:6011) // dereferencing nullptr pointer # pragma warning(disable:6246) // local declaration hides declaration of the same name in outer scope # pragma warning(disable:6326) // potential comparison of a constant with another constant # pragma warning(disable:6334) // sizeof operator applied to an expression with an operator might yield unexpected results Index: source/lib/regex.h =================================================================== --- source/lib/regex.h +++ source/lib/regex.h @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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/Preprocessor.h =================================================================== --- source/ps/Preprocessor.h +++ source/ps/Preprocessor.h @@ -108,10 +108,10 @@ /// Token length in bytes size_t Length; - Token () : Type (TK_ERROR), Allocated (0), String (NULL), Length (0) + Token () : Type (TK_ERROR), Allocated (0), String (nullptr), Length (0) { } - Token (Kind iType) : Type (iType), Allocated (0), String (NULL), Length (0) + Token (Kind iType) : Type (iType), Allocated (0), String (nullptr), Length (0) { } Token (Kind iType, const char *iString, size_t iLength) : @@ -191,8 +191,8 @@ bool Expanding; Macro (const Token &iName) : - Name (iName), NumArgs (0), Args (NULL), Next (NULL), - ExpandFunc (NULL), Expanding (false) + Name (iName), NumArgs (0), Args (nullptr), Next (nullptr), + ExpandFunc (nullptr), Expanding (false) { } ~Macro () @@ -385,7 +385,7 @@ * @param iToken * Macro name * @return - * The macro object or NULL if a macro with this name does not exist + * The macro object or nullptr if a macro with this name does not exist */ Macro *IsDefined (const Token &iToken); @@ -418,13 +418,13 @@ * @param iError * The error string. * @param iToken - * If not NULL contains the erroneous token + * If not nullptr contains the erroneous token */ - void Error (int iLine, const char *iError, const Token *iToken = NULL); + void Error (int iLine, const char *iError, const Token *iToken = nullptr); public: /// Create an empty preprocessor object - CPreprocessor () : MacroList (NULL) + CPreprocessor () : MacroList (nullptr) { } /// Destroy the preprocessor object @@ -501,7 +501,7 @@ * reasons, but this should not be a problem unless you will want * to store the returned pointer for long time in which case you * might want to realloc() it. - * If an error has been encountered, the function returns NULL. + * If an error has been encountered, the function returns nullptr. * In some cases the function may return an unallocated address * that's *inside* the source buffer. You must free() the result * string only if the returned address is not inside the source text. @@ -511,7 +511,7 @@ /** * An error handler function type. * The default implementation just drops a note to stderr and - * then the parser ends, returning NULL. + * then the parser ends, returning nullptr. * @param iData * User-specific pointer from the corresponding CPreprocessor object. * @param iLine @@ -519,7 +519,7 @@ * @param iError * The error string. * @param iToken - * If not NULL contains the erroneous token + * If not nullptr contains the erroneous token * @param iTokenLen * The length of iToken. iToken is never zero-terminated! */ Index: source/ps/Preprocessor.cpp =================================================================== --- source/ps/Preprocessor.cpp +++ source/ps/Preprocessor.cpp @@ -219,7 +219,7 @@ for (int j = NumArgs - 1; j >= 0; j--) cpp.Undef (Args [j].String, Args [j].Length); - cpp.MacroList = NULL; + cpp.MacroList = nullptr; return xt; } @@ -241,7 +241,7 @@ CPreprocessor::ErrorHandlerFunc CPreprocessor::ErrorHandler = DefaultError; -CPreprocessor::CPreprocessor (const Token &iToken, int iLine) : MacroList (NULL) +CPreprocessor::CPreprocessor (const Token &iToken, int iLine) : MacroList (nullptr) { Source = iToken.String; SourceEnd = iToken.String + iToken.Length; @@ -260,7 +260,7 @@ if (iToken) ErrorHandler (ErrorData, iLine, iError, iToken->String, iToken->Length); else - ErrorHandler (ErrorData, iLine, iError, NULL, 0); + ErrorHandler (ErrorData, iLine, iError, nullptr, 0); } CPreprocessor::Token CPreprocessor::GetToken (bool iExpand) @@ -401,7 +401,7 @@ if (cur->Name == iToken) return cur; - return NULL; + return nullptr; } CPreprocessor::Token CPreprocessor::ExpandMacro (const Token &iToken) @@ -409,7 +409,7 @@ Macro *cur = IsDefined (iToken); if (cur && !cur->Expanding) { - Token *args = NULL; + Token *args = nullptr; int nargs = 0; int old_line = Line; @@ -679,7 +679,7 @@ Token t; t = cpp.GetExpression (r, iLine); - cpp.MacroList = NULL; + cpp.MacroList = nullptr; if (t.Type == Token::TK_ERROR) return false; @@ -703,7 +703,7 @@ { // Try to expand the macro Macro *m = IsDefined (*vt); - if (m != NULL && !m->Expanding) + if (m != nullptr && !m->Expanding) { Token x = ExpandMacro (*vt); m->Expanding = true; @@ -814,7 +814,7 @@ // Suppose we'll leave by the wrong path oNumArgs = 0; - oArgs = NULL; + oArgs = nullptr; Token t; do @@ -827,7 +827,7 @@ if (t.Type != Token::TK_PUNCTUATION || t.String [0] != '(') { oNumArgs = 0; - oArgs = NULL; + oArgs = nullptr; return t; } @@ -1008,7 +1008,7 @@ // Restore the macro list MacroList = defined.Next; - defined.Next = NULL; + defined.Next = nullptr; if (!rc) return false; @@ -1195,7 +1195,7 @@ if ((*cur)->Name == name) { Macro *next = (*cur)->Next; - (*cur)->Next = NULL; + (*cur)->Next = nullptr; delete (*cur); *cur = next; return true; @@ -1308,7 +1308,7 @@ { Token retval = Parse (Token (Token::TK_TEXT, iSource, iLength)); if (retval.Type == Token::TK_ERROR) - return NULL; + return nullptr; oLength = retval.Length; retval.Allocated = 0; Index: source/ps/PreprocessorWrapper.cpp =================================================================== --- source/ps/PreprocessorWrapper.cpp +++ source/ps/PreprocessorWrapper.cpp @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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/third_party/mikktspace/mikktspace.cpp =================================================================== --- source/third_party/mikktspace/mikktspace.cpp +++ source/third_party/mikktspace/mikktspace.cpp @@ -253,10 +253,10 @@ tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThreshold) { // count nr_triangles - int * piTriListIn = NULL, * piGroupTrianglesBuffer = NULL; - STriInfo * pTriInfos = NULL; - SGroup * pGroups = NULL; - STSpace * psTspace = NULL; + int * piTriListIn = nullptr, * piGroupTrianglesBuffer = nullptr; + STriInfo * pTriInfos = nullptr; + SGroup * pGroups = nullptr; + STSpace * psTspace = nullptr; int iNrTrianglesIn = 0, f=0, t=0, i=0; int iNrTSPaces = 0, iTotTris = 0, iDegenTriangles = 0, iNrMaxGroups = 0; int iNrActiveGroups = 0, index = 0; @@ -265,11 +265,11 @@ const float fThresCos = (float) cos((fAngularThreshold*(float)M_PI)/180.0f); // verify all call-backs have been set - if ( pContext->m_pInterface->m_getNumFaces==NULL || - pContext->m_pInterface->m_getNumVerticesOfFace==NULL || - pContext->m_pInterface->m_getPosition==NULL || - pContext->m_pInterface->m_getNormal==NULL || - pContext->m_pInterface->m_getTexCoord==NULL ) + if ( pContext->m_pInterface->m_getNumFaces==nullptr || + pContext->m_pInterface->m_getNumVerticesOfFace==nullptr || + pContext->m_pInterface->m_getPosition==nullptr || + pContext->m_pInterface->m_getNormal==nullptr || + pContext->m_pInterface->m_getTexCoord==nullptr ) return TFALSE; // count triangles on supported faces @@ -284,10 +284,10 @@ // allocate memory for an index list piTriListIn = (int *) malloc(sizeof(int)*3*iNrTrianglesIn); pTriInfos = (STriInfo *) malloc(sizeof(STriInfo)*iNrTrianglesIn); - if (piTriListIn==NULL || pTriInfos==NULL) + if (piTriListIn==nullptr || pTriInfos==nullptr) { - if (piTriListIn!=NULL) free(piTriListIn); - if (pTriInfos!=NULL) free(pTriInfos); + if (piTriListIn!=nullptr) free(piTriListIn); + if (pTriInfos!=nullptr) free(pTriInfos); return TFALSE; } @@ -336,10 +336,10 @@ iNrMaxGroups = iNrTrianglesIn*3; pGroups = (SGroup *) malloc(sizeof(SGroup)*iNrMaxGroups); piGroupTrianglesBuffer = (int *) malloc(sizeof(int)*iNrTrianglesIn*3); - if (pGroups==NULL || piGroupTrianglesBuffer==NULL) + if (pGroups==nullptr || piGroupTrianglesBuffer==nullptr) { - if (pGroups!=NULL) free(pGroups); - if (piGroupTrianglesBuffer!=NULL) free(piGroupTrianglesBuffer); + if (pGroups!=nullptr) free(pGroups); + if (piGroupTrianglesBuffer!=nullptr) free(piGroupTrianglesBuffer); free(piTriListIn); free(pTriInfos); return TFALSE; @@ -352,7 +352,7 @@ // psTspace = (STSpace *) malloc(sizeof(STSpace)*iNrTSPaces); - if (psTspace==NULL) + if (psTspace==nullptr) { free(piTriListIn); free(pTriInfos); @@ -428,9 +428,9 @@ const STSpace * pTSpace = &psTspace[index]; float tang[] = {pTSpace->vOs.x, pTSpace->vOs.y, pTSpace->vOs.z}; float bitang[] = {pTSpace->vOt.x, pTSpace->vOt.y, pTSpace->vOt.z}; - if (pContext->m_pInterface->m_setTSpace!=NULL) + if (pContext->m_pInterface->m_setTSpace!=nullptr) pContext->m_pInterface->m_setTSpace(pContext, tang, bitang, pTSpace->fMagS, pTSpace->fMagT, pTSpace->bOrient, f, i); - if (pContext->m_pInterface->m_setTSpaceBasic!=NULL) + if (pContext->m_pInterface->m_setTSpaceBasic!=nullptr) pContext->m_pInterface->m_setTSpaceBasic(pContext, tang, pTSpace->bOrient==TTRUE ? 1.0f : (-1.0f), f, i); ++index; @@ -477,8 +477,8 @@ { // Generate bounding box - int * piHashTable=NULL, * piHashCount=NULL, * piHashOffsets=NULL, * piHashCount2=NULL; - STmpVert * pTmpVert = NULL; + int * piHashTable=nullptr, * piHashCount=nullptr, * piHashOffsets=nullptr, * piHashCount2=nullptr; + STmpVert * pTmpVert = nullptr; int i=0, iChannel=0, k=0, e=0; int iMaxCount=0; SVec3 vMin = GetPosition(pContext, 0), vMax = vMin, vDim; @@ -516,12 +516,12 @@ piHashOffsets = (int *) malloc(sizeof(int)*g_iCells); piHashCount2 = (int *) malloc(sizeof(int)*g_iCells); - if (piHashTable==NULL || piHashCount==NULL || piHashOffsets==NULL || piHashCount2==NULL) + if (piHashTable==nullptr || piHashCount==nullptr || piHashOffsets==nullptr || piHashCount2==nullptr) { - if (piHashTable!=NULL) free(piHashTable); - if (piHashCount!=NULL) free(piHashCount); - if (piHashOffsets!=NULL) free(piHashOffsets); - if (piHashCount2!=NULL) free(piHashCount2); + if (piHashTable!=nullptr) free(piHashTable); + if (piHashCount!=nullptr) free(piHashCount); + if (piHashOffsets!=nullptr) free(piHashOffsets); + if (piHashCount2!=nullptr) free(piHashCount2); GenerateSharedVerticesIndexListSlow(piTriList_in_and_out, pContext, iNrTrianglesIn); return; } @@ -550,7 +550,7 @@ const SVec3 vP = GetPosition(pContext, index); const float fVal = iChannel==0 ? vP.x : (iChannel==1 ? vP.y : vP.z); const int iCell = FindGridCell(fMin, fMax, fVal); - int * pTable = NULL; + int * pTable = nullptr; assert(piHashCount2[iCell]AssignedGroup[i] == pGroup) return TTRUE; - else if(pMyTriInfo->AssignedGroup[i]!=NULL) return TFALSE; + else if(pMyTriInfo->AssignedGroup[i]!=nullptr) return TFALSE; if ((pMyTriInfo->iFlag&GROUP_WITH_ANY)!=0) { // first to group with a group-with-anything triangle // determines it's orientation. // This is the only existing order dependency in the code!! - if ( pMyTriInfo->AssignedGroup[0] == NULL && - pMyTriInfo->AssignedGroup[1] == NULL && - pMyTriInfo->AssignedGroup[2] == NULL ) + if ( pMyTriInfo->AssignedGroup[0] == nullptr && + pMyTriInfo->AssignedGroup[1] == nullptr && + pMyTriInfo->AssignedGroup[2] == nullptr ) { pMyTriInfo->iFlag &= (~ORIENT_PRESERVING); pMyTriInfo->iFlag |= (pGroup->bOrientPreservering ? ORIENT_PRESERVING : 0); @@ -1214,9 +1214,9 @@ const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, const SMikkTSpaceContext * pContext) { - STSpace * pSubGroupTspace = NULL; - SSubGroup * pUniSubGroups = NULL; - int * pTmpMembers = NULL; + STSpace * pSubGroupTspace = nullptr; + SSubGroup * pUniSubGroups = nullptr; + int * pTmpMembers = nullptr; int iMaxNrFaces=0, iUniqueTspaces=0, g=0, i=0; for (g=0; ghttp_headers array, // and if the header is present in the array, returns its value. If it is -// not present, NULL is returned. +// not present, nullptr is returned. const char *mg_get_header(const struct mg_connection *, const char *name); @@ -218,11 +218,11 @@ // MD5 hash given strings. -// Buffer 'buf' must be 33 bytes long. Varargs is a NULL terminated list of +// Buffer 'buf' must be 33 bytes long. Varargs is a nullptr terminated list of // asciiz strings. When function returns, buf will contain human-readable // MD5 hash. Example: // char buf[33]; -// mg_md5(buf, "aa", "bb", NULL); +// mg_md5(buf, "aa", "bb", nullptr); void mg_md5(char *buf, ...); Index: source/third_party/mongoose/mongoose.cpp =================================================================== --- source/third_party/mongoose/mongoose.cpp +++ source/third_party/mongoose/mongoose.cpp @@ -283,7 +283,7 @@ #define DEBUG_TRACE(x) do { \ flockfile(stdout); \ printf("*** %lu.%p.%s.%d: ", \ - (unsigned long) time(NULL), (void *) pthread_self(), \ + (unsigned long) time(nullptr), (void *) pthread_self(), \ __func__, __LINE__); \ printf x; \ putchar('\n'); \ @@ -376,38 +376,38 @@ #define ERR_error_string (* (char * (*)(unsigned long,char *)) crypto_sw[4].ptr) // set_ssl_option() function updates this array. -// It loads SSL library dynamically and changes NULLs to the actual addresses +// It loads SSL library dynamically and changes nullptrs to the actual addresses // of respective functions. The macros above (like SSL_connect()) are really // just calling these functions indirectly via the pointer. static struct ssl_func ssl_sw[] = { - {"SSL_free", NULL}, - {"SSL_accept", NULL}, - {"SSL_connect", NULL}, - {"SSL_read", NULL}, - {"SSL_write", NULL}, - {"SSL_get_error", NULL}, - {"SSL_set_fd", NULL}, - {"SSL_new", NULL}, - {"SSL_CTX_new", NULL}, - {"SSLv23_server_method", NULL}, - {"SSL_library_init", NULL}, - {"SSL_CTX_use_PrivateKey_file", NULL}, - {"SSL_CTX_use_certificate_file",NULL}, - {"SSL_CTX_set_default_passwd_cb",NULL}, - {"SSL_CTX_free", NULL}, - {"SSL_load_error_strings", NULL}, - {"SSL_CTX_use_certificate_chain_file", NULL}, - {NULL, NULL} + {"SSL_free", nullptr}, + {"SSL_accept", nullptr}, + {"SSL_connect", nullptr}, + {"SSL_read", nullptr}, + {"SSL_write", nullptr}, + {"SSL_get_error", nullptr}, + {"SSL_set_fd", nullptr}, + {"SSL_new", nullptr}, + {"SSL_CTX_new", nullptr}, + {"SSLv23_server_method", nullptr}, + {"SSL_library_init", nullptr}, + {"SSL_CTX_use_PrivateKey_file", nullptr}, + {"SSL_CTX_use_certificate_file",nullptr}, + {"SSL_CTX_set_default_passwd_cb",nullptr}, + {"SSL_CTX_free", nullptr}, + {"SSL_load_error_strings", nullptr}, + {"SSL_CTX_use_certificate_chain_file", nullptr}, + {nullptr, nullptr} }; // Similar array as ssl_sw. These functions could be located in different lib. static struct ssl_func crypto_sw[] = { - {"CRYPTO_num_locks", NULL}, - {"CRYPTO_set_locking_callback", NULL}, - {"CRYPTO_set_id_callback", NULL}, - {"ERR_get_error", NULL}, - {"ERR_error_string", NULL}, - {NULL, NULL} + {"CRYPTO_num_locks", nullptr}, + {"CRYPTO_set_locking_callback", nullptr}, + {"CRYPTO_set_id_callback", nullptr}, + {"ERR_get_error", nullptr}, + {"ERR_error_string", nullptr}, + {nullptr, nullptr} }; #endif // NO_SSL_DL @@ -463,28 +463,28 @@ static const char *config_options[] = { "C", "cgi_extensions", ".cgi,.pl,.php", - "E", "cgi_environment", NULL, - "G", "put_delete_passwords_file", NULL, - "I", "cgi_interpreter", NULL, - "P", "protect_uri", NULL, + "E", "cgi_environment", nullptr, + "G", "put_delete_passwords_file", nullptr, + "I", "cgi_interpreter", nullptr, + "P", "protect_uri", nullptr, "R", "authentication_domain", "mydomain.com", "S", "ssi_extensions", ".shtml,.shtm", - "a", "access_log_file", NULL, - "c", "ssl_chain_file", NULL, + "a", "access_log_file", nullptr, + "c", "ssl_chain_file", nullptr, "d", "enable_directory_listing", "yes", - "e", "error_log_file", NULL, - "g", "global_passwords_file", NULL, + "e", "error_log_file", nullptr, + "g", "global_passwords_file", nullptr, "i", "index_files", "index.html,index.htm,index.cgi", "k", "enable_keep_alive", "no", - "l", "access_control_list", NULL, + "l", "access_control_list", nullptr, "M", "max_request_size", "16384", - "m", "extra_mime_types", NULL, + "m", "extra_mime_types", nullptr, "p", "listening_ports", "8080", "r", "document_root", ".", - "s", "ssl_certificate", NULL, + "s", "ssl_certificate", nullptr, "t", "num_threads", "10", - "u", "run_as_user", NULL, - NULL + "u", "run_as_user", nullptr, + nullptr }; #define ENTRIES_PER_CONFIG_OPTION 3 @@ -530,14 +530,14 @@ static void *call_user(struct mg_connection *conn, enum mg_event event) { conn->request_info.user_data = conn->ctx->user_data; - return conn->ctx->user_callback == NULL ? NULL : + return conn->ctx->user_callback == nullptr ? nullptr : conn->ctx->user_callback(event, conn, &conn->request_info); } static int get_option_index(const char *name) { int i; - for (i = 0; config_options[i] != NULL; i += ENTRIES_PER_CONFIG_OPTION) { + for (i = 0; config_options[i] != nullptr; i += ENTRIES_PER_CONFIG_OPTION) { if (strcmp(config_options[i], name) == 0 || strcmp(config_options[i + 1], name) == 0) { return i / ENTRIES_PER_CONFIG_OPTION; @@ -549,8 +549,8 @@ const char *mg_get_option(const struct mg_context *ctx, const char *name) { int i; if ((i = get_option_index(name)) == -1) { - return NULL; - } else if (ctx->config[i] == NULL) { + return nullptr; + } else if (ctx->config[i] == nullptr) { return ""; } else { return ctx->config[i]; @@ -572,20 +572,20 @@ // I suppose this is fine, since function cannot disappear in the // same way string option can. conn->request_info.log_message = buf; - if (call_user(conn, MG_EVENT_LOG) == NULL) { - fp = conn->ctx->config[ERROR_LOG_FILE] == NULL ? NULL : + if (call_user(conn, MG_EVENT_LOG) == nullptr) { + fp = conn->ctx->config[ERROR_LOG_FILE] == nullptr ? nullptr : mg_fopen(conn->ctx->config[ERROR_LOG_FILE], "a+"); - if (fp != NULL) { + if (fp != nullptr) { flockfile(fp); - timestamp = time(NULL); + timestamp = time(nullptr); (void) fprintf(fp, "[%010lu] [error] [client %s] ", (unsigned long) timestamp, inet_ntoa(conn->client.rsa.u.sin.sin_addr)); - if (conn->request_info.request_method != NULL) { + if (conn->request_info.request_method != nullptr) { (void) fprintf(fp, "%s %s: ", conn->request_info.request_method, conn->request_info.uri); @@ -599,14 +599,14 @@ } } } - conn->request_info.log_message = NULL; + conn->request_info.log_message = nullptr; } // Return OpenSSL error message static const char *ssl_error(void) { unsigned long err; err = ERR_get_error(); - return err == 0 ? "" : ERR_error_string(err, NULL); + return err == 0 ? "" : ERR_error_string(err, nullptr); } // Return fake connection structure. Used for logging, if connection @@ -656,7 +656,7 @@ static char * mg_strndup(const char *ptr, size_t len) { char *p; - if ((p = (char *) malloc(len + 1)) != NULL) { + if ((p = (char *) malloc(len + 1)) != nullptr) { mg_strlcpy(p, ptr, len + 1); } @@ -757,7 +757,7 @@ } -// Return HTTP header value, or NULL if not found. +// Return HTTP header value, or nullptr if not found. static const char *get_header(const struct mg_request_info *ri, const char *name) { int i; @@ -766,7 +766,7 @@ if (!mg_strcasecmp(name, ri->http_headers[i].name)) return ri->http_headers[i].value; - return NULL; + return nullptr; } const char *mg_get_header(const struct mg_connection *conn, const char *name) { @@ -774,19 +774,19 @@ } // A helper function for traversing comma separated list of values. -// It returns a list pointer shifted to the next value, of NULL if the end +// It returns a list pointer shifted to the next value, of nullptr if the end // of the list found. // Value is stored in val vector. If value has form "x=y", then eq_val // vector is initialized to point to the "y" part, and val vector length // is adjusted to point only to "x". static const char *next_option(const char *list, struct vec *val, struct vec *eq_val) { - if (list == NULL || *list == '\0') { + if (list == nullptr || *list == '\0') { // End of the list - list = NULL; + list = nullptr; } else { val->ptr = list; - if ((list = strchr(val->ptr, ',')) != NULL) { + if ((list = strchr(val->ptr, ',')) != nullptr) { // Comma found. Store length and shift the list ptr val->len = list - val->ptr; list++; @@ -796,12 +796,12 @@ val->len = list - val->ptr; } - if (eq_val != NULL) { + if (eq_val != nullptr) { // Value has form "x=y", adjust pointers and lengths // so that val points to "x", and eq_val points to "y". eq_val->len = 0; eq_val->ptr = (const char *) memchr(val->ptr, '=', val->len); - if (eq_val->ptr != NULL) { + if (eq_val->ptr != nullptr) { eq_val->ptr++; // Skip over '=' character eq_val->len = val->ptr + val->len - eq_val->ptr; val->len = (eq_val->ptr - val->ptr) - 1; @@ -818,7 +818,7 @@ path_len = strlen(path); - while ((ext_list = next_option(ext_list, &ext_vec, NULL)) != NULL) + while ((ext_list = next_option(ext_list, &ext_vec, nullptr)) != nullptr) if (ext_vec.len < path_len && mg_strncasecmp(path + path_len - ext_vec.len, ext_vec.ptr, ext_vec.len) == 0) @@ -833,8 +833,8 @@ static int should_keep_alive(const struct mg_connection *conn) { const char *http_version = conn->request_info.http_version; const char *header = mg_get_header(conn, "Connection"); - return (header == NULL && http_version && !strcmp(http_version, "1.1")) || - (header != NULL && !mg_strcasecmp(header, "keep-alive")); + return (header == nullptr && http_version && !strcmp(http_version, "1.1")) || + (header != nullptr && !mg_strcasecmp(header, "keep-alive")); } static const char *suggest_connection_header(const struct mg_connection *conn) { @@ -849,7 +849,7 @@ conn->request_info.status_code = status; - if (call_user(conn, MG_HTTP_ERROR) == NULL) { + if (call_user(conn, MG_HTTP_ERROR) == nullptr) { buf[0] = '\0'; len = 0; @@ -876,9 +876,9 @@ #if defined(_WIN32) && !defined(__SYMBIAN32__) static int pthread_mutex_init(pthread_mutex_t *mutex, void *unused) { - unused = NULL; - *mutex = CreateMutex(NULL, FALSE, NULL); - return *mutex == NULL ? -1 : 0; + unused = nullptr; + *mutex = CreateMutex(nullptr, FALSE, nullptr); + return *mutex == nullptr ? -1 : 0; } static int pthread_mutex_destroy(pthread_mutex_t *mutex) { @@ -894,10 +894,10 @@ } static int pthread_cond_init(pthread_cond_t *cv, const void *unused) { - unused = NULL; - cv->signal = CreateEvent(NULL, FALSE, FALSE, NULL); - cv->broadcast = CreateEvent(NULL, TRUE, FALSE, NULL); - return cv->signal != NULL && cv->broadcast != NULL ? 0 : -1; + unused = nullptr; + cv->signal = CreateEvent(nullptr, FALSE, FALSE, nullptr); + cv->broadcast = CreateEvent(nullptr, TRUE, FALSE, nullptr); + return cv->signal != nullptr && cv->broadcast != nullptr ? 0 : -1; } static int pthread_cond_wait(pthread_cond_t *cv, pthread_mutex_t *mutex) { @@ -967,7 +967,7 @@ // match the original, something is fishy, reject. MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, (int) wbuf_len); WideCharToMultiByte(CP_UTF8, 0, wbuf, (int) wbuf_len, buf2, sizeof(buf2), - NULL, NULL); + nullptr, nullptr); if (strcmp(buf, buf2) != 0) { wbuf[0] = L'\0'; } @@ -984,7 +984,7 @@ SystemTimeToFileTime(&st, &ft); t = SYS2UNIX_TIME(ft.dwLowDateTime, ft.dwHighDateTime); - if (ptime != NULL) { + if (ptime != nullptr) { *ptime = t; } @@ -997,8 +997,8 @@ SYSTEMTIME st; TIME_ZONE_INFORMATION tzinfo; - if (ptm == NULL) { - return NULL; + if (ptm == nullptr) { + return nullptr; } * (int64_t *) &ft = t; @@ -1085,18 +1085,18 @@ (void) MultiByteToWideChar(CP_UTF8, 0, buf, -1, wbuf, sizeof(wbuf)); - return CreateDirectoryW(wbuf, NULL) ? 0 : -1; + return CreateDirectoryW(wbuf, nullptr) ? 0 : -1; } // Implementation of POSIX opendir/closedir/readdir for Windows. static DIR * opendir(const char *name) { - DIR *dir = NULL; + DIR *dir = nullptr; wchar_t wpath[PATH_MAX]; DWORD attrs; - if (name == NULL) { + if (name == nullptr) { SetLastError(ERROR_BAD_ARGUMENTS); - } else if ((dir = (DIR *) malloc(sizeof(*dir))) == NULL) { + } else if ((dir = (DIR *) malloc(sizeof(*dir))) == nullptr) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); } else { to_unicode(name, wpath, ARRAY_SIZE(wpath)); @@ -1108,7 +1108,7 @@ dir->result.d_name[0] = '\0'; } else { free(dir); - dir = NULL; + dir = nullptr; } } @@ -1118,7 +1118,7 @@ static int closedir(DIR *dir) { int result = 0; - if (dir != NULL) { + if (dir != nullptr) { if (dir->handle != INVALID_HANDLE_VALUE) result = FindClose(dir->handle) ? 0 : -1; @@ -1139,7 +1139,7 @@ result = &dir->result; (void) WideCharToMultiByte(CP_UTF8, 0, dir->info.cFileName, -1, result->d_name, - sizeof(result->d_name), NULL, NULL); + sizeof(result->d_name), nullptr, nullptr); if (!FindNextFileW(dir->handle, &dir->info)) { (void) FindClose(dir->handle); @@ -1186,7 +1186,7 @@ STARTUPINFOA si; PROCESS_INFORMATION pi; - envp = NULL; // Unused + envp = nullptr; // Unused (void) memset(&si, 0, sizeof(si)); (void) memset(&pi, 0, sizeof(pi)); @@ -1204,10 +1204,10 @@ // If CGI file is a script, try to read the interpreter line interp = conn->ctx->config[CGI_INTERPRETER]; - if (interp == NULL) { + if (interp == nullptr) { buf[2] = '\0'; mg_snprintf(conn, cmdline, sizeof(cmdline), "%s%c%s", dir, DIRSEP, prog); - if ((fp = fopen(cmdline, "r")) != NULL) { + if ((fp = fopen(cmdline, "r")) != nullptr) { (void) fgets(buf, sizeof(buf), fp); if (buf[0] != '#' || buf[1] != '!') { // First line does not start with "#!". Do not set interpreter. @@ -1227,7 +1227,7 @@ interp, interp[0] == '\0' ? "" : " ", dir, DIRSEP, prog); DEBUG_TRACE(("Running [%s]", cmdline)); - if (CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, + if (CreateProcessA(nullptr, cmdline, nullptr, nullptr, TRUE, CREATE_NEW_PROCESS_GROUP, envblk, dir, &si, &pi) == 0) { cry(conn, "%s: CreateProcess(%s): %d", __func__, cmdline, ERRNO); @@ -1296,7 +1296,7 @@ pid_t pid; const char *interp; - envblk = NULL; // Unused + envblk = nullptr; // Unused if ((pid = fork()) == -1) { // Parent @@ -1316,11 +1316,11 @@ // Execute CGI program. No need to lock: new process interp = conn->ctx->config[CGI_INTERPRETER]; - if (interp == NULL) { - (void) execle(prog, prog, NULL, envp); + if (interp == nullptr) { + (void) execle(prog, prog, nullptr, envp); cry(conn, "%s: execle(%s): %s", __func__, prog, strerror(ERRNO)); } else { - (void) execle(interp, interp, prog, NULL, envp); + (void) execle(interp, interp, prog, nullptr, envp); cry(conn, "%s: execle(%s %s): %s", __func__, interp, prog, strerror(ERRNO)); } @@ -1359,9 +1359,9 @@ // How many bytes we send in this iteration k = len - sent > INT_MAX ? INT_MAX : (int) (len - sent); - if (ssl != NULL) { + if (ssl != nullptr) { n = SSL_write(ssl, buf + sent, k); - } else if (fp != NULL) { + } else if (fp != nullptr) { n = fwrite(buf + sent, 1, (size_t)k, fp); if (ferror(fp)) n = -1; @@ -1383,9 +1383,9 @@ static int pull(FILE *fp, SOCKET sock, SSL *ssl, char *buf, int len) { int nread; - if (ssl != NULL) { + if (ssl != nullptr) { nread = SSL_read(ssl, buf, len); - } else if (fp != NULL) { + } else if (fp != nullptr) { // Use read() instead of fread(), because if we're reading from the CGI // pipe, fread() may block until IO buffer is filled up. We cannot afford // to block and must pass all read bytes immediately to the client. @@ -1436,7 +1436,7 @@ // We have returned all buffered data. Read new data from the remote socket. while (len > 0) { - n = pull(NULL, conn->client.sock, conn->ssl, (char *) buf, (int) len); + n = pull(nullptr, conn->client.sock, conn->ssl, (char *) buf, (int) len); if (n <= 0) { break; } @@ -1450,7 +1450,7 @@ } int mg_write(struct mg_connection *conn, const void *buf, size_t len) { - return (int) push(NULL, conn->client.sock, conn->ssl, + return (int) push(nullptr, conn->client.sock, conn->ssl, (const char *) buf, (int64_t) len); } @@ -1499,7 +1499,7 @@ // Scan given buffer and fetch the value of the given variable. // It can be specified in query string, or in the POST data. -// Return NULL if the variable not found, or allocated 0-terminated value. +// Return nullptr if the variable not found, or allocated 0-terminated value. // It is caller's responsibility to free the returned value. int mg_get_var(const char *buf, size_t buf_len, const char *name, char *dst, size_t dst_len) { @@ -1512,7 +1512,7 @@ dst[0] = '\0'; // buf is "var1=val1&var2=val2...". Find variable first - for (p = buf; p != NULL && p + name_len < e; p++) { + for (p = buf; p != nullptr && p + name_len < e; p++) { if ((p == buf || p[-1] == '&') && p[name_len] == '=' && !mg_strncasecmp(name, p, name_len)) { @@ -1521,7 +1521,7 @@ // Point s to the end of the value s = (const char *) memchr(p, '&', (size_t)(e - p)); - if (s == NULL) { + if (s == nullptr) { s = e; } assert(s >= p); @@ -1543,17 +1543,17 @@ int name_len, len = -1; dst[0] = '\0'; - if ((s = mg_get_header(conn, "Cookie")) == NULL) { + if ((s = mg_get_header(conn, "Cookie")) == nullptr) { return 0; } name_len = strlen(cookie_name); end = s + strlen(s); - for (; (s = strstr(s, cookie_name)) != NULL; s += name_len) + for (; (s = strstr(s, cookie_name)) != nullptr; s += name_len) if (s[name_len] == '=') { s += name_len + 1; - if ((p = strchr(s, ' ')) == NULL) + if ((p = strchr(s, ' ')) == nullptr) p = end; if (p[-1] == ';') p--; @@ -1582,9 +1582,9 @@ uri = conn->request_info.uri; len_of_matched_uri = 0; - root = next_option(conn->ctx->config[DOCUMENT_ROOT], document_root, NULL); + root = next_option(conn->ctx->config[DOCUMENT_ROOT], document_root, nullptr); - while ((root = next_option(root, &uri_vec, &path_vec)) != NULL) { + while ((root = next_option(root, &uri_vec, &path_vec)) != nullptr) { if (memcmp(uri, uri_vec.ptr, uri_vec.len) == 0) { *document_root = path_vec; len_of_matched_uri = uri_vec.len; @@ -1612,21 +1612,21 @@ } static int sslize(struct mg_connection *conn, int (*func)(SSL *)) { - return (conn->ssl = SSL_new(conn->ctx->ssl_ctx)) != NULL && + return (conn->ssl = SSL_new(conn->ctx->ssl_ctx)) != nullptr && SSL_set_fd(conn->ssl, conn->client.sock) == 1 && func(conn->ssl) == 1; } static struct mg_connection *mg_connect(struct mg_connection *conn, const char *host, int port, int use_ssl) { - struct mg_connection *newconn = NULL; + struct mg_connection *newconn = nullptr; struct sockaddr_in sin; struct hostent *he; int sock; - if (conn->ctx->ssl_ctx == NULL && use_ssl) { + if (conn->ctx->ssl_ctx == nullptr && use_ssl) { cry(conn, "%s: SSL is not initialized", __func__); - } else if ((he = gethostbyname(host)) == NULL) { + } else if ((he = gethostbyname(host)) == nullptr) { cry(conn, "%s: gethostbyname(%s): %s", __func__, host, strerror(ERRNO)); } else if ((sock = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { cry(conn, "%s: socket: %s", __func__, strerror(ERRNO)); @@ -1639,7 +1639,7 @@ strerror(ERRNO)); closesocket(sock); } else if ((newconn = (struct mg_connection *) - calloc(1, sizeof(*newconn))) == NULL) { + calloc(1, sizeof(*newconn))) == nullptr) { cry(conn, "%s: calloc: %s", __func__, strerror(ERRNO)); closesocket(sock); } else { @@ -1785,7 +1785,7 @@ {".asf", 4, "video/x-ms-asf", 14}, {".avi", 4, "video/x-msvideo", 15}, {".bmp", 4, "image/bmp", 9}, - {NULL, 0, NULL, 0} + {nullptr, 0, nullptr, 0} }; // Look at the "path" extension and figure what mime type it has. @@ -1801,7 +1801,7 @@ // Scan user-defined mime types first, in case user wants to // override default mime types. list = ctx->config[EXTRA_MIME_TYPES]; - while ((list = next_option(list, &ext_vec, &mime_vec)) != NULL) { + while ((list = next_option(list, &ext_vec, &mime_vec)) != nullptr) { // ext now points to the path suffix ext = path + path_len - ext_vec.len; if (mg_strncasecmp(ext, ext_vec.ptr, ext_vec.len) == 0) { @@ -1811,7 +1811,7 @@ } // Now scan built-in mime types - for (i = 0; builtin_mime_types[i].extension != NULL; i++) { + for (i = 0; builtin_mime_types[i].extension != nullptr; i++) { ext = path + (path_len - builtin_mime_types[i].ext_len); if (path_len > builtin_mime_types[i].ext_len && mg_strcasecmp(ext, builtin_mime_types[i].extension) == 0) { @@ -2035,7 +2035,7 @@ MD5Init(&ctx); va_start(ap, buf); - while ((p = va_arg(ap, const char *)) != NULL) { + while ((p = va_arg(ap, const char *)) != nullptr) { MD5Update(&ctx, (const unsigned char *) p, (unsigned) strlen(p)); } va_end(ap); @@ -2050,9 +2050,9 @@ const char *qop, const char *response) { char ha2[32 + 1], expected_response[32 + 1]; - // Some of the parameters may be NULL - if (method == NULL || nonce == NULL || nc == NULL || cnonce == NULL || - qop == NULL || response == NULL) { + // Some of the parameters may be nullptr + if (method == nullptr || nonce == nullptr || nc == nullptr || cnonce == nullptr || + qop == nullptr || response == nullptr) { return 0; } @@ -2060,14 +2060,14 @@ // TODO(lsm): check for authentication timeout if (// strcmp(dig->uri, c->ouri) != 0 || strlen(response) != 32 - // || now - strtoul(dig->nonce, NULL, 10) > 3600 + // || now - strtoul(dig->nonce, nullptr, 10) > 3600 ) { return 0; } - mg_md5(ha2, method, ":", uri, NULL); + mg_md5(ha2, method, ":", uri, nullptr); mg_md5(expected_response, ha1, ":", nonce, ":", nc, - ":", cnonce, ":", qop, ":", ha2, NULL); + ":", cnonce, ":", qop, ":", ha2, nullptr); return mg_strcasecmp(response, expected_response) == 0; } @@ -2081,10 +2081,10 @@ struct mgstat st; FILE *fp; - if (ctx->config[GLOBAL_PASSWORDS_FILE] != NULL) { + if (ctx->config[GLOBAL_PASSWORDS_FILE] != nullptr) { // Use global passwords file fp = mg_fopen(ctx->config[GLOBAL_PASSWORDS_FILE], "r"); - if (fp == NULL) + if (fp == nullptr) cry(fc(ctx), "fopen(%s): %s", ctx->config[GLOBAL_PASSWORDS_FILE], strerror(ERRNO)); } else if (!mg_stat(path, &st) && st.is_directory) { @@ -2114,7 +2114,7 @@ char *name, *value, *s; const char *auth_header; - if ((auth_header = mg_get_header(conn, "Authorization")) == NULL || + if ((auth_header = mg_get_header(conn, "Authorization")) == nullptr || mg_strncasecmp(auth_header, "Digest ", 7) != 0) { return 0; } @@ -2164,7 +2164,7 @@ } // CGI needs it as REMOTE_USER - if (ah->user != NULL) { + if (ah->user != nullptr) { conn->request_info.remote_user = mg_strdup(ah->user); } else { return 0; @@ -2183,7 +2183,7 @@ } // Loop over passwords file - while (fgets(line, sizeof(line), fp) != NULL) { + while (fgets(line, sizeof(line), fp) != nullptr) { if (sscanf(line, "%[^:]:%[^:]:%s", f_user, f_domain, ha1) != 3) { continue; } @@ -2207,26 +2207,26 @@ const char *list; int authorized; - fp = NULL; + fp = nullptr; authorized = 1; list = conn->ctx->config[PROTECT_URI]; - while ((list = next_option(list, &uri_vec, &filename_vec)) != NULL) { + while ((list = next_option(list, &uri_vec, &filename_vec)) != nullptr) { if (!memcmp(conn->request_info.uri, uri_vec.ptr, uri_vec.len)) { (void) mg_snprintf(conn, fname, sizeof(fname), "%.*s", (int) filename_vec.len, filename_vec.ptr); - if ((fp = mg_fopen(fname, "r")) == NULL) { + if ((fp = mg_fopen(fname, "r")) == nullptr) { cry(conn, "%s: cannot open %s: %s", __func__, fname, strerror(errno)); } break; } } - if (fp == NULL) { + if (fp == nullptr) { fp = open_auth_file(conn, path); } - if (fp != NULL) { + if (fp != nullptr) { authorized = authorize(conn, fp); (void) fclose(fp); } @@ -2242,17 +2242,17 @@ "WWW-Authenticate: Digest qop=\"auth\", " "realm=\"%s\", nonce=\"%lu\"\r\n\r\n", conn->ctx->config[AUTHENTICATION_DOMAIN], - (unsigned long) time(NULL)); + (unsigned long) time(nullptr)); } static int is_authorized_for_put(struct mg_connection *conn) { FILE *fp; int ret = 0; - fp = conn->ctx->config[PUT_DELETE_PASSWORDS_FILE] == NULL ? NULL : + fp = conn->ctx->config[PUT_DELETE_PASSWORDS_FILE] == nullptr ? nullptr : mg_fopen(conn->ctx->config[PUT_DELETE_PASSWORDS_FILE], "r"); - if (fp != NULL) { + if (fp != nullptr) { ret = authorize(conn, fp); (void) fclose(fp); } @@ -2267,38 +2267,38 @@ FILE *fp, *fp2; found = 0; - fp = fp2 = NULL; + fp = fp2 = nullptr; // Regard empty password as no password - remove user record. - if (pass != NULL && pass[0] == '\0') { - pass = NULL; + if (pass != nullptr && pass[0] == '\0') { + pass = nullptr; } (void) snprintf(tmp, sizeof(tmp), "%s.tmp", fname); // Create the file if does not exist - if ((fp = mg_fopen(fname, "a+")) != NULL) { + if ((fp = mg_fopen(fname, "a+")) != nullptr) { (void) fclose(fp); } // Open the given file and temporary file - if ((fp = mg_fopen(fname, "r")) == NULL) { + if ((fp = mg_fopen(fname, "r")) == nullptr) { return 0; - } else if ((fp2 = mg_fopen(tmp, "w+")) == NULL) { + } else if ((fp2 = mg_fopen(tmp, "w+")) == nullptr) { fclose(fp); return 0; } // Copy the stuff to temporary file - while (fgets(line, sizeof(line), fp) != NULL) { + while (fgets(line, sizeof(line), fp) != nullptr) { if (sscanf(line, "%[^:]:%[^:]:%*s", u, d) != 2) { continue; } if (!strcmp(u, user) && !strcmp(d, domain)) { found++; - if (pass != NULL) { - mg_md5(ha1, user, ":", domain, ":", pass, NULL); + if (pass != nullptr) { + mg_md5(ha1, user, ":", domain, ":", pass, nullptr); fprintf(fp2, "%s:%s:%s\n", user, domain, ha1); } } else { @@ -2307,8 +2307,8 @@ } // If new user, just add it - if (!found && pass != NULL) { - mg_md5(ha1, user, ":", domain, ":", pass, NULL); + if (!found && pass != nullptr) { + mg_md5(ha1, user, ":", domain, ":", pass, nullptr); (void) fprintf(fp2, "%s:%s:%s\n", user, domain, ha1); } @@ -2336,7 +2336,7 @@ for (; *src != '\0' && dst < end; src++, dst++) { if (isalnum(*(const unsigned char *) src) || - strchr(dont_escape, * (const unsigned char *) src) != NULL) { + strchr(dont_escape, * (const unsigned char *) src) != nullptr) { *dst = *src; } else if (dst + 2 < end) { dst[0] = '%'; @@ -2389,7 +2389,7 @@ const char *query_string = a->conn->request_info.query_string; int cmp_result = 0; - if (query_string == NULL) { + if (query_string == nullptr) { query_string = "na"; } @@ -2417,12 +2417,12 @@ DIR *dirp; struct de de; - if ((dirp = opendir(dir)) == NULL) { + if ((dirp = opendir(dir)) == nullptr) { return 0; } else { de.conn = conn; - while ((dp = readdir(dirp)) != NULL) { + while ((dp = readdir(dirp)) != nullptr) { // Do not show current dir and passwords file if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..") || @@ -2457,12 +2457,12 @@ static void dir_scan_callback(struct de *de, void *data) { struct dir_scan_data *dsd = (struct dir_scan_data *) data; - if (dsd->entries == NULL || dsd->num_entries >= dsd->arr_size) { + if (dsd->entries == nullptr || dsd->num_entries >= dsd->arr_size) { dsd->arr_size *= 2; dsd->entries = (struct de *) realloc(dsd->entries, dsd->arr_size * sizeof(dsd->entries[0])); } - if (dsd->entries == NULL) { + if (dsd->entries == nullptr) { // TODO(lsm): propagate an error to the caller dsd->num_entries = 0; } else { @@ -2476,7 +2476,7 @@ static void handle_directory_request(struct mg_connection *conn, const char *dir) { int i, sort_direction; - struct dir_scan_data data = { NULL, 0, 128 }; + struct dir_scan_data data = { nullptr, 0, 128 }; if (!scan_directory(conn, dir, &data, dir_scan_callback)) { send_http_error(conn, 500, "Cannot open directory", @@ -2484,7 +2484,7 @@ return; } - sort_direction = conn->request_info.query_string != NULL && + sort_direction = conn->request_info.query_string != nullptr && conn->request_info.query_string[1] == 'd' ? 'a' : 'd'; mg_printf(conn, "%s", @@ -2559,7 +2559,7 @@ struct mgstat *stp) { char date[64], lm[64], etag[64], range[64]; const char *msg = "OK", *hdr; - time_t curtime = time(NULL); + time_t curtime = time(nullptr); int64_t cl, r1, r2; struct vec mime_vec; FILE *fp; @@ -2570,7 +2570,7 @@ conn->request_info.status_code = 200; range[0] = '\0'; - if ((fp = mg_fopen(path, "rb")) == NULL) { + if ((fp = mg_fopen(path, "rb")) == nullptr) { send_http_error(conn, 500, http_500_error, "fopen(%s): %s", path, strerror(ERRNO)); return; @@ -2580,7 +2580,7 @@ // If Range: header specified, act accordingly r1 = r2 = 0; hdr = mg_get_header(conn, "Range"); - if (hdr != NULL && (n = parse_range_header(hdr, &r1, &r2)) > 0) { + if (hdr != nullptr && (n = parse_range_header(hdr, &r1, &r2)) > 0) { conn->request_info.status_code = 206; (void) fseeko(fp, (off_t) r1, SEEK_SET); cl = n == 2 ? r2 - r1 + 1: cl - r1; @@ -2716,7 +2716,7 @@ // Traverse index files list. For each entry, append it to the given // path and see if the file exists. If it exists, break the loop - while ((list = next_option(list, &filename_vec, NULL)) != NULL) { + while ((list = next_option(list, &filename_vec, nullptr)) != nullptr) { // Ignore too long entries that may overflow path buffer if (filename_vec.len > path_len - n) @@ -2746,7 +2746,7 @@ static int is_not_modified(const struct mg_connection *conn, const struct mgstat *stp) { const char *ims = mg_get_header(conn, "If-Modified-Since"); - return ims != NULL && stp->mtime <= parse_date_string(ims); + return ims != nullptr && stp->mtime <= parse_date_string(ims); } static int forward_body_data(struct mg_connection *conn, FILE *fp, @@ -2756,14 +2756,14 @@ int to_read, nread, buffered_len, success = 0; expect = mg_get_header(conn, "Expect"); - assert(fp != NULL); + assert(fp != nullptr); if (conn->content_len == -1) { send_http_error(conn, 411, "Length Required", ""); - } else if (expect != NULL && mg_strcasecmp(expect, "100-continue")) { + } else if (expect != nullptr && mg_strcasecmp(expect, "100-continue")) { send_http_error(conn, 417, "Expectation Failed", ""); } else { - if (expect != NULL) { + if (expect != nullptr) { (void) mg_printf(conn, "%s", "HTTP/1.1 100 Continue\r\n\r\n"); } @@ -2785,7 +2785,7 @@ if ((int64_t) to_read > conn->content_len - conn->consumed_content) { to_read = (int) (conn->content_len - conn->consumed_content); } - nread = pull(NULL, conn->client.sock, conn->ssl, buf, to_read); + nread = pull(nullptr, conn->client.sock, conn->ssl, buf, to_read); if (nread <= 0 || push(fp, sock, ssl, buf, nread) != nread) { break; } @@ -2808,7 +2808,7 @@ #if !defined(NO_CGI) // This structure helps to create an environment for the spawned CGI program. // Environment is an array of "VARIABLE=VALUE\0" ASCIIZ strings, -// last element must be NULL. +// last element must be nullptr. // However, on Windows there is a requirement that all these VARIABLE=VALUE\0 // strings must reside in a contiguous buffer. The end of the buffer is // marked by two '\0' characters. @@ -2884,41 +2884,41 @@ // SCRIPT_NAME assert(conn->request_info.uri[0] == '/'); slash = strrchr(conn->request_info.uri, '/'); - if ((s = strrchr(prog, '/')) == NULL) + if ((s = strrchr(prog, '/')) == nullptr) s = prog; addenv(blk, "SCRIPT_NAME=%.*s%s", slash - conn->request_info.uri, conn->request_info.uri, s); addenv(blk, "SCRIPT_FILENAME=%s", prog); addenv(blk, "PATH_TRANSLATED=%s", prog); - addenv(blk, "HTTPS=%s", conn->ssl == NULL ? "off" : "on"); + addenv(blk, "HTTPS=%s", conn->ssl == nullptr ? "off" : "on"); - if ((s = mg_get_header(conn, "Content-Type")) != NULL) + if ((s = mg_get_header(conn, "Content-Type")) != nullptr) addenv(blk, "CONTENT_TYPE=%s", s); - if (conn->request_info.query_string != NULL) + if (conn->request_info.query_string != nullptr) addenv(blk, "QUERY_STRING=%s", conn->request_info.query_string); - if ((s = mg_get_header(conn, "Content-Length")) != NULL) + if ((s = mg_get_header(conn, "Content-Length")) != nullptr) addenv(blk, "CONTENT_LENGTH=%s", s); - if ((s = getenv("PATH")) != NULL) + if ((s = getenv("PATH")) != nullptr) addenv(blk, "PATH=%s", s); #if defined(_WIN32) - if ((s = getenv("COMSPEC")) != NULL) + if ((s = getenv("COMSPEC")) != nullptr) addenv(blk, "COMSPEC=%s", s); - if ((s = getenv("SYSTEMROOT")) != NULL) + if ((s = getenv("SYSTEMROOT")) != nullptr) addenv(blk, "SYSTEMROOT=%s", s); #else - if ((s = getenv("LD_LIBRARY_PATH")) != NULL) + if ((s = getenv("LD_LIBRARY_PATH")) != nullptr) addenv(blk, "LD_LIBRARY_PATH=%s", s); #endif // _WIN32 - if ((s = getenv("PERLLIB")) != NULL) + if ((s = getenv("PERLLIB")) != nullptr) addenv(blk, "PERLLIB=%s", s); - if (conn->request_info.remote_user != NULL) { + if (conn->request_info.remote_user != nullptr) { addenv(blk, "REMOTE_USER=%s", conn->request_info.remote_user); addenv(blk, "%s", "AUTH_TYPE=Digest"); } @@ -2939,11 +2939,11 @@ // Add user-specified variables s = conn->ctx->config[CGI_ENVIRONMENT]; - while ((s = next_option(s, &var_vec, NULL)) != NULL) { + while ((s = next_option(s, &var_vec, nullptr)) != nullptr) { addenv(blk, "%.*s", var_vec.len, var_vec.ptr); } - blk->vars[blk->nvars++] = NULL; + blk->vars[blk->nvars++] = nullptr; blk->buf[blk->len++] = '\0'; assert(blk->nvars < (int) ARRAY_SIZE(blk->vars)); @@ -2966,7 +2966,7 @@ // directory containing executable program, 'p' must point to the // executable program name relative to 'dir'. (void) mg_snprintf(conn, dir, sizeof(dir), "%s", prog); - if ((p = strrchr(dir, DIRSEP)) != NULL) { + if ((p = strrchr(dir, DIRSEP)) != nullptr) { *p++ = '\0'; } else { dir[0] = '.', dir[1] = '\0'; @@ -2975,7 +2975,7 @@ pid = (pid_t) -1; fd_stdin[0] = fd_stdin[1] = fd_stdout[0] = fd_stdout[1] = -1; - in = out = NULL; + in = out = nullptr; if (pipe(fd_stdin) != 0 || pipe(fd_stdout) != 0) { send_http_error(conn, 500, http_500_error, @@ -2984,15 +2984,15 @@ } else if ((pid = spawn_process(conn, p, blk.buf, blk.vars, fd_stdin[0], fd_stdout[1], dir)) == (pid_t) -1) { goto done; - } else if ((in = fdopen(fd_stdin[1], "wb")) == NULL || - (out = fdopen(fd_stdout[0], "rb")) == NULL) { + } else if ((in = fdopen(fd_stdin[1], "wb")) == nullptr || + (out = fdopen(fd_stdout[0], "rb")) == nullptr) { send_http_error(conn, 500, http_500_error, "fopen: %s", strerror(ERRNO)); goto done; } - setbuf(in, NULL); - setbuf(out, NULL); + setbuf(in, nullptr); + setbuf(out, nullptr); // spawn_process() must close those! // If we don't mark them as closed, close() attempt before @@ -3002,7 +3002,7 @@ // Send POST data to the CGI process if needed if (!strcmp(conn->request_info.request_method, "POST") && - !forward_body_data(conn, in, INVALID_SOCKET, NULL)) { + !forward_body_data(conn, in, INVALID_SOCKET, nullptr)) { goto done; } @@ -3011,7 +3011,7 @@ // Do not send anything back to client, until we buffer in all // HTTP headers. data_len = 0; - headers_len = read_request(out, INVALID_SOCKET, NULL, + headers_len = read_request(out, INVALID_SOCKET, nullptr, buf, sizeof(buf), &data_len); if (headers_len <= 0) { send_http_error(conn, 500, http_500_error, @@ -3025,7 +3025,7 @@ // Make up and send the status line status = get_header(&ri, "Status"); - conn->request_info.status_code = status == NULL ? 200 : atoi(status); + conn->request_info.status_code = status == nullptr ? 200 : atoi(status); (void) mg_printf(conn, "HTTP/1.1 %d OK\r\n", conn->request_info.status_code); // Send headers @@ -3053,13 +3053,13 @@ (void) close(fd_stdout[1]); } - if (in != NULL) { + if (in != nullptr) { (void) fclose(in); } else if (fd_stdin[1] != -1) { (void) close(fd_stdin[1]); } - if (out != NULL) { + if (out != nullptr) { (void) fclose(out); } else if (fd_stdout[0] != -1) { (void) close(fd_stdout[0]); @@ -3076,7 +3076,7 @@ struct mgstat st; int len, res = 1; - for (s = p = path + 2; (p = strchr(s, DIRSEP)) != NULL; s = ++p) { + for (s = p = path + 2; (p = strchr(s, DIRSEP)) != nullptr; s = ++p) { len = p - path; if (len >= (int) sizeof(buf)) { res = -1; @@ -3115,19 +3115,19 @@ } else if (rc == -1) { send_http_error(conn, 500, http_500_error, "put_dir(%s): %s", path, strerror(ERRNO)); - } else if ((fp = mg_fopen(path, "wb+")) == NULL) { + } else if ((fp = mg_fopen(path, "wb+")) == nullptr) { send_http_error(conn, 500, http_500_error, "fopen(%s): %s", path, strerror(ERRNO)); } else { set_close_on_exec(fileno(fp)); range = mg_get_header(conn, "Content-Range"); r1 = r2 = 0; - if (range != NULL && parse_range_header(range, &r1, &r2) > 0) { + if (range != nullptr && parse_range_header(range, &r1, &r2) > 0) { conn->request_info.status_code = 206; // TODO(lsm): handle seek error (void) fseeko(fp, (off_t) r1, SEEK_SET); } - if (forward_body_data(conn, fp, INVALID_SOCKET, NULL)) + if (forward_body_data(conn, fp, INVALID_SOCKET, nullptr)) (void) mg_printf(conn, "HTTP/1.1 %d OK\r\n\r\n", conn->request_info.status_code); (void) fclose(fp); @@ -3158,7 +3158,7 @@ } else if (sscanf(tag, " \"%[^\"]\"", file_name) == 1) { // File name is relative to the currect document (void) mg_snprintf(conn, path, sizeof(path), "%s", ssi); - if ((p = strrchr(path, DIRSEP)) != NULL) { + if ((p = strrchr(path, DIRSEP)) != nullptr) { p[1] = '\0'; } (void) mg_snprintf(conn, path + strlen(path), @@ -3168,7 +3168,7 @@ return; } - if ((fp = mg_fopen(path, "rb")) == NULL) { + if ((fp = mg_fopen(path, "rb")) == nullptr) { cry(conn, "Cannot open SSI #include: [%s]: fopen(%s): %s", tag, path, strerror(ERRNO)); } else { @@ -3190,7 +3190,7 @@ if (sscanf(tag, " \"%[^\"]\"", cmd) != 1) { cry(conn, "Bad SSI #exec: [%s]", tag); - } else if ((fp = popen(cmd, "r")) == NULL) { + } else if ((fp = popen(cmd, "r")) == nullptr) { cry(conn, "Cannot SSI #exec: [%s]: %s", cmd, strerror(ERRNO)); } else { send_file_data(conn, fp, INT64_MAX); @@ -3268,7 +3268,7 @@ const char *path) { FILE *fp; - if ((fp = mg_fopen(path, "rb")) == NULL) { + if ((fp = mg_fopen(path, "rb")) == nullptr) { send_http_error(conn, 500, http_500_error, "fopen(%s): %s", path, strerror(ERRNO)); } else { @@ -3340,7 +3340,7 @@ // If it is a directory, print directory entries too if Depth is not 0 if (st->is_directory && !mg_strcasecmp(conn->ctx->config[ENABLE_DIRECTORY_LISTING], "yes") && - (depth == NULL || strcmp(depth, "0") != 0)) { + (depth == nullptr || strcmp(depth, "0") != 0)) { scan_directory(conn, path, conn, &print_dav_dir_entry); } @@ -3357,7 +3357,7 @@ int uri_len; struct mgstat st; - if ((conn->request_info.query_string = strchr(ri->uri, '?')) != NULL) { + if ((conn->request_info.query_string = strchr(ri->uri, '?')) != nullptr) { * conn->request_info.query_string++ = '\0'; } uri_len = strlen(ri->uri); @@ -3368,18 +3368,18 @@ DEBUG_TRACE(("%s", ri->uri)); if (!check_authorization(conn, path)) { send_authorization_request(conn); - } else if (call_user(conn, MG_NEW_REQUEST) != NULL) { + } else if (call_user(conn, MG_NEW_REQUEST) != nullptr) { // Do nothing, callback has served the request } else if (!strcmp(ri->request_method, "OPTIONS")) { send_options(conn); } else if (strstr(path, PASSWORDS_FILE_NAME)) { // Do not allow to view passwords files send_http_error(conn, 403, "Forbidden", "Access Forbidden"); - } else if (conn->ctx->config[DOCUMENT_ROOT] == NULL) { + } else if (conn->ctx->config[DOCUMENT_ROOT] == nullptr) { send_http_error(conn, 404, "Not Found", "Not Found"); } else if ((!strcmp(ri->request_method, "PUT") || !strcmp(ri->request_method, "DELETE")) && - (conn->ctx->config[PUT_DELETE_PASSWORDS_FILE] == NULL || + (conn->ctx->config[PUT_DELETE_PASSWORDS_FILE] == nullptr || !is_authorized_for_put(conn))) { send_authorization_request(conn); } else if (!strcmp(ri->request_method, "PUT")) { @@ -3428,7 +3428,7 @@ static void close_all_listening_sockets(struct mg_context *ctx) { struct socket *sp, *tmp; - for (sp = ctx->listening_sockets; sp != NULL; sp = tmp) { + for (sp = ctx->listening_sockets; sp != nullptr; sp = tmp) { tmp = sp->next; (void) closesocket(sp->sock); free(sp); @@ -3455,7 +3455,7 @@ } assert(len > 0 && len <= (int) vec->len); - if (strchr("sp,", vec->ptr[len]) == NULL) { + if (strchr("sp,", vec->ptr[len]) == nullptr) { return 0; } @@ -3475,12 +3475,12 @@ struct vec vec; struct socket so, *listener; - while (success && (list = next_option(list, &vec, NULL)) != NULL) { + while (success && (list = next_option(list, &vec, nullptr)) != nullptr) { if (!parse_port_string(&vec, &so)) { cry(fc(ctx), "%s: %.*s: invalid port spec. Expecting list of: %s", __func__, (int) vec.len, vec.ptr, "[IP_ADDRESS:]PORT[s|p]"); success = 0; - } else if (so.is_ssl && ctx->ssl_ctx == NULL) { + } else if (so.is_ssl && ctx->ssl_ctx == nullptr) { cry(fc(ctx), "Cannot add SSL socket, is -ssl_certificate option set?"); success = 0; } else if ((sock = socket(PF_INET, SOCK_STREAM, 6)) == INVALID_SOCKET || @@ -3506,7 +3506,7 @@ (int) vec.len, vec.ptr, strerror(ERRNO)); success = 0; } else if ((listener = (struct socket *) - calloc(1, sizeof(*listener))) == NULL) { + calloc(1, sizeof(*listener))) == nullptr) { closesocket(sock); cry(fc(ctx), "%s: %s", __func__, strerror(ERRNO)); success = 0; @@ -3530,7 +3530,7 @@ FILE *fp) { const char *header_value; - if ((header_value = mg_get_header(conn, header)) == NULL) { + if ((header_value = mg_get_header(conn, header)) == nullptr) { (void) fprintf(fp, "%s", " -"); } else { (void) fprintf(fp, " \"%s\"", header_value); @@ -3542,10 +3542,10 @@ FILE *fp; char date[64]; - fp = conn->ctx->config[ACCESS_LOG_FILE] == NULL ? NULL : + fp = conn->ctx->config[ACCESS_LOG_FILE] == nullptr ? nullptr : mg_fopen(conn->ctx->config[ACCESS_LOG_FILE], "a+"); - if (fp == NULL) + if (fp == nullptr) return; (void) strftime(date, sizeof(date), "%d/%b/%Y:%H:%M:%S %z", @@ -3558,7 +3558,7 @@ (void) fprintf(fp, "%s - %s [%s] \"%s %s HTTP/%s\" %d %" INT64_FMT, inet_ntoa(conn->client.rsa.u.sin.sin_addr), - ri->remote_user == NULL ? "-" : ri->remote_user, + ri->remote_user == nullptr ? "-" : ri->remote_user, date, ri->request_method ? ri->request_method : "-", ri->uri ? ri->uri : "-", @@ -3586,7 +3586,7 @@ struct vec vec; const char *list = ctx->config[ACCESS_CONTROL_LIST]; - if (list == NULL) { + if (list == nullptr) { return 1; } @@ -3595,7 +3595,7 @@ // If any ACL is set, deny by default allowed = '-'; - while ((list = next_option(list, &vec, NULL)) != NULL) { + while ((list = next_option(list, &vec, nullptr)) != nullptr) { mask = 32; if (sscanf(vec.ptr, "%c%d.%d.%d.%d%n", &flag, &a, &b, &c, &d, &n) != 5) { @@ -3638,10 +3638,10 @@ const char *uid = ctx->config[RUN_AS_USER]; int success = 0; - if (uid == NULL) { + if (uid == nullptr) { success = 1; } else { - if ((pw = getpwnam(uid)) == NULL) { + if ((pw = getpwnam(uid)) == nullptr) { cry(fc(ctx), "%s: unknown user [%s]", __func__, uid); } else if (setgid(pw->pw_gid) == -1) { cry(fc(ctx), "%s: setgid(%s): %s", __func__, uid, strerror(errno)); @@ -3662,7 +3662,7 @@ static void ssl_locking_callback(int mode, int mutex_num, const char *file, int line) { line = 0; // Unused - file = NULL; // Unused + file = nullptr; // Unused if (mode & CRYPTO_LOCK) { (void) pthread_mutex_lock(&ssl_mutexes[mutex_num]); @@ -3682,12 +3682,12 @@ void *dll_handle; struct ssl_func *fp; - if ((dll_handle = dlopen(dll_name, RTLD_LAZY)) == NULL) { + if ((dll_handle = dlopen(dll_name, RTLD_LAZY)) == nullptr) { cry(fc(ctx), "%s: cannot load %s", __func__, dll_name); return 0; } - for (fp = sw; fp->name != NULL; fp++) { + for (fp = sw; fp->name != nullptr; fp++) { #ifdef _WIN32 // GetProcAddress() returns pointer to function u.fp = (void (*)(void)) dlsym(dll_handle, fp->name); @@ -3696,7 +3696,7 @@ // function pointers. We need to use a union to make a cast. u.p = dlsym(dll_handle, fp->name); #endif // _WIN32 - if (u.fp == NULL) { + if (u.fp == nullptr) { cry(fc(ctx), "%s: %s: cannot find %s", __func__, dll_name, fp->name); return 0; } else { @@ -3716,7 +3716,7 @@ const char *pem = ctx->config[SSL_CERTIFICATE]; const char *chain = ctx->config[SSL_CHAIN_FILE]; - if (pem == NULL) { + if (pem == nullptr) { return 1; } @@ -3731,41 +3731,41 @@ SSL_library_init(); SSL_load_error_strings(); - if ((CTX = SSL_CTX_new(SSLv23_server_method())) == NULL) { + if ((CTX = SSL_CTX_new(SSLv23_server_method())) == nullptr) { cry(fc(ctx), "SSL_CTX_new error: %s", ssl_error()); - } else if (ctx->user_callback != NULL) { + } else if (ctx->user_callback != nullptr) { memset(&request_info, 0, sizeof(request_info)); request_info.user_data = ctx->user_data; ctx->user_callback(MG_INIT_SSL, (struct mg_connection *) CTX, &request_info); } - if (CTX != NULL && SSL_CTX_use_certificate_file(CTX, pem, + if (CTX != nullptr && SSL_CTX_use_certificate_file(CTX, pem, SSL_FILETYPE_PEM) == 0) { cry(fc(ctx), "%s: cannot open %s: %s", __func__, pem, ssl_error()); return 0; - } else if (CTX != NULL && SSL_CTX_use_PrivateKey_file(CTX, pem, + } else if (CTX != nullptr && SSL_CTX_use_PrivateKey_file(CTX, pem, SSL_FILETYPE_PEM) == 0) { - cry(fc(ctx), "%s: cannot open %s: %s", NULL, pem, ssl_error()); + cry(fc(ctx), "%s: cannot open %s: %s", nullptr, pem, ssl_error()); return 0; } - if (CTX != NULL && chain != NULL && + if (CTX != nullptr && chain != nullptr && SSL_CTX_use_certificate_chain_file(CTX, chain) == 0) { - cry(fc(ctx), "%s: cannot open %s: %s", NULL, chain, ssl_error()); + cry(fc(ctx), "%s: cannot open %s: %s", nullptr, chain, ssl_error()); return 0; } // Initialize locking callbacks, needed for thread safety. // http://www.openssl.org/support/faq.html#PROG1 size = sizeof(pthread_mutex_t) * CRYPTO_num_locks(); - if ((ssl_mutexes = (pthread_mutex_t *) malloc((size_t)size)) == NULL) { + if ((ssl_mutexes = (pthread_mutex_t *) malloc((size_t)size)) == nullptr) { cry(fc(ctx), "%s: cannot allocate mutexes: %s", __func__, ssl_error()); return 0; } for (i = 0; i < CRYPTO_num_locks(); i++) { - pthread_mutex_init(&ssl_mutexes[i], NULL); + pthread_mutex_init(&ssl_mutexes[i], nullptr); } CRYPTO_set_locking_callback(&ssl_locking_callback); @@ -3779,13 +3779,13 @@ static void uninitialize_ssl(struct mg_context *ctx) { int i; - if (ctx->ssl_ctx != NULL) { - CRYPTO_set_locking_callback(NULL); + if (ctx->ssl_ctx != nullptr) { + CRYPTO_set_locking_callback(nullptr); for (i = 0; i < CRYPTO_num_locks(); i++) { pthread_mutex_destroy(&ssl_mutexes[i]); } - CRYPTO_set_locking_callback(NULL); - CRYPTO_set_id_callback(NULL); + CRYPTO_set_locking_callback(nullptr); + CRYPTO_set_id_callback(nullptr); } } #endif // !NO_SSL @@ -3793,7 +3793,7 @@ static int set_gpass_option(struct mg_context *ctx) { struct mgstat mgstat; const char *path = ctx->config[GLOBAL_PASSWORDS_FILE]; - return path == NULL || mg_stat(path, &mgstat) == 0; + return path == nullptr || mg_stat(path, &mgstat) == 0; } static int set_acl_option(struct mg_context *ctx) { @@ -3805,10 +3805,10 @@ struct mg_request_info *ri = &conn->request_info; // Reset request info attributes. DO NOT TOUCH is_ssl, remote_ip, remote_port - if (ri->remote_user != NULL) { + if (ri->remote_user != nullptr) { free((void *) ri->remote_user); } - ri->remote_user = ri->request_method = ri->uri = ri->http_version = NULL; + ri->remote_user = ri->request_method = ri->uri = ri->http_version = nullptr; ri->num_headers = 0; ri->status_code = -1; @@ -3838,7 +3838,7 @@ // when server decide to close the connection; then when client // does recv() it gets no data back. do { - n = pull(NULL, sock, NULL, buf, sizeof(buf)); + n = pull(nullptr, sock, nullptr, buf, sizeof(buf)); } while (n > 0); // Now we know that our FIN is ACK-ed, safe to close @@ -3848,7 +3848,7 @@ static void close_connection(struct mg_connection *conn) { if (conn->ssl) { SSL_free(conn->ssl); - conn->ssl = NULL; + conn->ssl = nullptr; } if (conn->client.sock != INVALID_SOCKET) { @@ -3899,15 +3899,15 @@ int port, is_ssl, len, i, n; DEBUG_TRACE(("URL: %s", ri->uri)); - if (ri->uri == NULL || + if (ri->uri == nullptr || ri->uri[0] == '/' || (len = parse_url(ri->uri, host, &port)) == 0) { return; } - if (conn->peer == NULL) { + if (conn->peer == nullptr) { is_ssl = !strcmp(ri->request_method, "CONNECT"); - if ((conn->peer = mg_connect(conn, host, port, is_ssl)) == NULL) { + if ((conn->peer = mg_connect(conn, host, port, is_ssl)) == nullptr) { return; } conn->peer->client.is_ssl = is_ssl; @@ -3927,11 +3927,11 @@ // Read and forward body data if any if (!strcmp(ri->request_method, "POST")) { - forward_body_data(conn, NULL, conn->peer->client.sock, conn->peer->ssl); + forward_body_data(conn, nullptr, conn->peer->client.sock, conn->peer->ssl); } // Read data from the target and forward it to the client - while ((n = pull(NULL, conn->peer->client.sock, conn->peer->ssl, + while ((n = pull(nullptr, conn->peer->client.sock, conn->peer->ssl, buf, sizeof(buf))) > 0) { if (mg_write(conn, buf, (size_t)n) != n) { break; @@ -3941,7 +3941,7 @@ if (!conn->peer->client.is_ssl) { close_connection(conn->peer); free(conn->peer); - conn->peer = NULL; + conn->peer = nullptr; } } @@ -3963,7 +3963,7 @@ // If next request is not pipelined, read it in if ((conn->request_len = get_request_len(conn->buf, conn->data_len)) == 0) { - conn->request_len = read_request(NULL, conn->client.sock, conn->ssl, + conn->request_len = read_request(nullptr, conn->client.sock, conn->ssl, conn->buf, conn->buf_size, &conn->data_len); } assert(conn->data_len >= conn->request_len); @@ -3989,8 +3989,8 @@ } else { // Request is valid, handle it cl = get_header(ri, "Content-Length"); - conn->content_len = cl == NULL ? -1 : strtoll(cl, NULL, 10); - conn->birth_time = time(NULL); + conn->content_len = cl == nullptr ? -1 : strtoll(cl, nullptr, 10); + conn->birth_time = time(nullptr); if (conn->client.is_proxy) { handle_proxy_request(conn); } else { @@ -3999,7 +3999,7 @@ log_access(conn); discard_current_request_from_buffer(conn); } - // conn->peer is not NULL only for SSL-ed proxy connections + // conn->peer is not nullptr only for SSL-ed proxy connections } while (conn->ctx->stop_flag == 0 && (conn->peer || (keep_alive_enabled && should_keep_alive(conn)))); } @@ -4041,12 +4041,12 @@ conn = (struct mg_connection *) calloc(1, sizeof(*conn) + buf_size); conn->buf_size = buf_size; conn->buf = (char *) (conn + 1); - assert(conn != NULL); + assert(conn != nullptr); // Call consume_socket() even when ctx->stop_flag > 0, to let it signal // sq_empty condvar to wake up the master waiting in produce_socket() while (consume_socket(ctx, &conn->client)) { - conn->birth_time = time(NULL); + conn->birth_time = time(nullptr); conn->ctx = ctx; // Fill in IP, port info early so even if SSL setup below fails, @@ -4133,14 +4133,14 @@ max_fd = -1; // Add listening sockets to the read set - for (sp = ctx->listening_sockets; sp != NULL; sp = sp->next) { + for (sp = ctx->listening_sockets; sp != nullptr; sp = sp->next) { add_to_set(sp->sock, &read_set, &max_fd); } tv.tv_sec = 0; tv.tv_usec = 200 * 1000; - if (select(max_fd + 1, &read_set, NULL, NULL, &tv) < 0) { + if (select(max_fd + 1, &read_set, nullptr, nullptr, &tv) < 0) { #ifdef _WIN32 // On windows, if read_set and write_set are empty, // select() returns "Invalid parameter" error @@ -4148,7 +4148,7 @@ sleep(1); #endif // _WIN32 } else { - for (sp = ctx->listening_sockets; sp != NULL; sp = sp->next) { + for (sp = ctx->listening_sockets; sp != nullptr; sp = sp->next) { if (ctx->stop_flag == 0 && FD_ISSET(sp->sock, &read_set)) { accept_new_connection(sp, ctx); } @@ -4191,16 +4191,16 @@ // Deallocate config parameters for (i = 0; i < NUM_OPTIONS; i++) { - if (ctx->config[i] != NULL) + if (ctx->config[i] != nullptr) free(ctx->config[i]); } // Deallocate SSL context - if (ctx->ssl_ctx != NULL) { + if (ctx->ssl_ctx != nullptr) { SSL_CTX_free(ctx->ssl_ctx); } #ifndef NO_SSL - if (ssl_mutexes != NULL) { + if (ssl_mutexes != nullptr) { free(ssl_mutexes); } #endif // !NO_SSL @@ -4240,24 +4240,24 @@ ctx->user_callback = user_callback; ctx->user_data = user_data; - while (options && (name = *options++) != NULL) { + while (options && (name = *options++) != nullptr) { if ((i = get_option_index(name)) == -1) { cry(fc(ctx), "Invalid option: %s", name); free_context(ctx); - return NULL; - } else if ((value = *options++) == NULL) { - cry(fc(ctx), "%s: option value cannot be NULL", name); + return nullptr; + } else if ((value = *options++) == nullptr) { + cry(fc(ctx), "%s: option value cannot be nullptr", name); free_context(ctx); - return NULL; + return nullptr; } ctx->config[i] = mg_strdup(value); DEBUG_TRACE(("[%s] -> [%s]", name, value)); } // Set default value if needed - for (i = 0; config_options[i * ENTRIES_PER_CONFIG_OPTION] != NULL; i++) { + for (i = 0; config_options[i * ENTRIES_PER_CONFIG_OPTION] != nullptr; i++) { default_value = config_options[i * ENTRIES_PER_CONFIG_OPTION + 2]; - if (ctx->config[i] == NULL && default_value != NULL) { + if (ctx->config[i] == nullptr && default_value != nullptr) { ctx->config[i] = mg_strdup(default_value); DEBUG_TRACE(("Setting default: [%s] -> [%s]", config_options[i * ENTRIES_PER_CONFIG_OPTION + 1], @@ -4277,7 +4277,7 @@ #endif !set_acl_option(ctx)) { free_context(ctx); - return NULL; + return nullptr; } #if !defined(_WIN32) && !defined(__SYMBIAN32__) @@ -4288,10 +4288,10 @@ (void) signal(SIGCHLD, SIG_IGN); #endif // !_WIN32 - (void) pthread_mutex_init(&ctx->mutex, NULL); - (void) pthread_cond_init(&ctx->cond, NULL); - (void) pthread_cond_init(&ctx->sq_empty, NULL); - (void) pthread_cond_init(&ctx->sq_full, NULL); + (void) pthread_mutex_init(&ctx->mutex, nullptr); + (void) pthread_cond_init(&ctx->cond, nullptr); + (void) pthread_cond_init(&ctx->sq_empty, nullptr); + (void) pthread_cond_init(&ctx->sq_full, nullptr); // Start master (listening) thread start_thread(ctx, (mg_thread_func_t) master_thread, ctx); Index: source/third_party/tinygettext/src/iconv.cpp =================================================================== --- source/third_party/tinygettext/src/iconv.cpp +++ source/third_party/tinygettext/src/iconv.cpp @@ -122,7 +122,7 @@ { if (errno == EILSEQ || errno == EINVAL) { // invalid multibyte sequence - tinygettext_iconv(cd, NULL, NULL, NULL, NULL); // reset state + tinygettext_iconv(cd, nullptr, nullptr, nullptr, nullptr); // reset state // FIXME: Could try to skip the invalid byte and continue log_error << "error: tinygettext:iconv: invalid multibyte sequence in: \"" << text << "\"" << std::endl; Index: source/third_party/tinygettext/src/language.cpp =================================================================== --- source/third_party/tinygettext/src/language.cpp +++ source/third_party/tinygettext/src/language.cpp @@ -284,7 +284,7 @@ { "zh", "HK", 0, "Chinese (Hong Kong)" }, { "zh", "TW", 0, "Chinese (traditional)" }, { "zu", 0, 0, "Zulu" }, - { NULL, 0, 0, NULL } + { nullptr, 0, 0, nullptr } }; //*} @@ -374,7 +374,7 @@ if (language_map.empty()) { // Init language_map - for(int i = 0; languages[i].language != NULL; ++i) + for(int i = 0; languages[i].language != nullptr; ++i) language_map[languages[i].language].push_back(&languages[i]); } 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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; }