diff --git a/contrib/bobtoolz/DBrush.cpp b/contrib/bobtoolz/DBrush.cpp index 377dd4cd..5f6febe6 100644 --- a/contrib/bobtoolz/DBrush.cpp +++ b/contrib/bobtoolz/DBrush.cpp @@ -48,8 +48,8 @@ DBrush::DBrush(){ bBoundsBuilt = false; - QER_entity = NULL; - QER_brush = NULL; + QER_entity = nullptr; + QER_brush = nullptr; } DBrush::~DBrush(){ @@ -315,7 +315,7 @@ DPlane* DBrush::HasPlane( DPlane* chkPlane ) const { return plane; } } - return NULL; + return nullptr; } bool DBrush::IsCutByPlane( DPlane *cuttingPlane ){ @@ -380,14 +380,14 @@ scene::Node* DBrush::BuildInRadiant( bool allowDestruction, int* changeCnt, scen } } if ( kill ) { - return NULL; + return nullptr; } } //+djbob: fixed bug when brush had no faces "phantom brush" in radiant. if ( faceList.size() < 4 ) { globalErrorStream() << "Possible Phantom Brush Found, will not rebuild\n"; - return NULL; + return nullptr; } //-djbob @@ -420,8 +420,8 @@ void DBrush::selectInRadiant() const { void DBrush::CutByPlane( DPlane *cutPlane, DBrush **newBrush1, DBrush **newBrush2 ){ if ( !IsCutByPlane( cutPlane ) ) { - *newBrush1 = NULL; - *newBrush2 = NULL; + *newBrush1 = nullptr; + *newBrush2 = nullptr; return; } @@ -430,12 +430,12 @@ void DBrush::CutByPlane( DPlane *cutPlane, DBrush **newBrush1, DBrush **newBrush for ( DPlane *plane : faceList ) { - b1->AddFace( plane->points[0], plane->points[1], plane->points[2], NULL ); - b2->AddFace( plane->points[0], plane->points[1], plane->points[2], NULL ); + b1->AddFace( plane->points[0], plane->points[1], plane->points[2], nullptr ); + b2->AddFace( plane->points[0], plane->points[1], plane->points[2], nullptr ); } - b1->AddFace( cutPlane->points[0], cutPlane->points[1], cutPlane->points[2], NULL ); - b2->AddFace( cutPlane->points[2], cutPlane->points[1], cutPlane->points[0], NULL ); + b1->AddFace( cutPlane->points[0], cutPlane->points[1], cutPlane->points[2], nullptr ); + b2->AddFace( cutPlane->points[2], cutPlane->points[1], cutPlane->points[0], nullptr ); b1->RemoveRedundantPlanes(); b2->RemoveRedundantPlanes(); @@ -636,7 +636,7 @@ DPlane* DBrush::HasPlaneInverted( DPlane *chkPlane ){ } } } - return NULL; + return nullptr; } bool DBrush::HasTexture( const char *textureName ){ @@ -675,12 +675,12 @@ void DBrush::BuildFromWinding( DWinding *w ){ for ( i = 0; i < w2->numpoints; ++i ) VectorAdd( w2->p[i], wPlane->normal, w2->p[i] ); - AddFace( w2->p[0], w2->p[1], w2->p[2], NULL ); - AddFace( w->p[2], w->p[1], w->p[0], NULL ); + AddFace( w2->p[0], w2->p[1], w2->p[2], nullptr ); + AddFace( w->p[2], w->p[1], w->p[0], nullptr ); for ( i = 0; i < w->numpoints - 1; ++i ) - AddFace( w2->p[i], w->p[i], w->p[i + 1], NULL ); - AddFace( w2->p[w->numpoints - 1], w->p[w->numpoints - 1], w->p[0], NULL ); + AddFace( w2->p[i], w->p[i], w->p[i + 1], nullptr ); + AddFace( w2->p[w->numpoints - 1], w->p[w->numpoints - 1], w->p[0], nullptr ); delete wPlane; delete w2; @@ -821,7 +821,7 @@ DPlane* DBrush::AddFace( const vec3_t va, const vec3_t vb, const vec3_t vc, cons DPlane* DBrush::FindPlaneWithClosestNormal( vec_t* normal ) { vec_t bestDot = -2; - DPlane* bestDotPlane = NULL; + DPlane* bestDotPlane = nullptr; for ( DPlane *plane : faceList ) { vec_t dot = DotProduct( plane->normal, normal ); if ( dot > bestDot ) { diff --git a/contrib/bobtoolz/DBrush.h b/contrib/bobtoolz/DBrush.h index 543e6ec6..53e8d4be 100644 --- a/contrib/bobtoolz/DBrush.h +++ b/contrib/bobtoolz/DBrush.h @@ -71,7 +71,7 @@ public: int BuildPoints(); void BuildBounds(); void BuildFromWinding( DWinding* w ); - scene::Node* BuildInRadiant( bool allowDestruction, int* changeCnt, scene::Node* entity = NULL ); + scene::Node* BuildInRadiant( bool allowDestruction, int* changeCnt, scene::Node* entity = nullptr ); void selectInRadiant() const; void ResetChecks( const std::vector& exclusionList ); diff --git a/contrib/bobtoolz/DEntity.cpp b/contrib/bobtoolz/DEntity.cpp index 6d5feadc..5169a8fb 100644 --- a/contrib/bobtoolz/DEntity.cpp +++ b/contrib/bobtoolz/DEntity.cpp @@ -53,7 +53,7 @@ DEntity::DEntity( const char *classname, int ID ){ SetClassname( classname ); m_nID = ID; - QER_Entity = NULL; + QER_Entity = nullptr; } DEntity::~DEntity(){ @@ -152,7 +152,7 @@ bool DEntity::LoadFromPrt( char *filename ){ } } if ( build ) { - brush->BuildInRadiant( false, NULL ); + brush->BuildInRadiant( false, nullptr ); } } @@ -267,7 +267,7 @@ bool* DEntity::BuildDuplicateList(){ } void DEntity::SelectBrushes( bool *selectList ){ - if ( selectList == NULL ) { + if ( selectList == nullptr ) { return; } @@ -385,7 +385,7 @@ void DEntity::BuildInRadiant( bool allowDestruction ){ Node_getTraversable( GlobalSceneGraph().root() )->insert( node ); for ( DBrush *brush : brushList ) - brush->BuildInRadiant( allowDestruction, NULL, node.get_pointer() ); + brush->BuildInRadiant( allowDestruction, nullptr, node.get_pointer() ); for ( DPatch *patch : patchList ) patch->BuildInRadiant( node.get_pointer() ); @@ -395,7 +395,7 @@ void DEntity::BuildInRadiant( bool allowDestruction ){ else { for ( DBrush *brush : brushList ) - brush->BuildInRadiant( allowDestruction, NULL ); + brush->BuildInRadiant( allowDestruction, nullptr ); for ( DPatch *patch : patchList ) patch->BuildInRadiant(); @@ -473,7 +473,7 @@ bool DEntity::ResetTextures( const char* textureName, float fScale[2], float reset = true; if ( rebuild ) { Node_getTraversable( *brush->QER_entity )->erase( *brush->QER_brush ); - brush->BuildInRadiant( false, NULL, brush->QER_entity ); + brush->BuildInRadiant( false, nullptr, brush->QER_entity ); } } } @@ -507,7 +507,7 @@ DEPair* DEntity::FindEPairByKey( const char* keyname ){ void DEntity::RemoveFromRadiant(){ Node_getTraversable( GlobalSceneGraph().root() )->erase( *QER_Entity ); - QER_Entity = NULL; + QER_Entity = nullptr; } void DEntity::SpawnString( const char* key, const char* defaultstring, const char** out ){ @@ -560,5 +560,5 @@ DBrush* DEntity::FindBrushByPointer( scene::Node& brush ) { return pBrush; } } - return NULL; + return nullptr; } diff --git a/contrib/bobtoolz/DMap.cpp b/contrib/bobtoolz/DMap.cpp index 25a13fde..5104fb7a 100644 --- a/contrib/bobtoolz/DMap.cpp +++ b/contrib/bobtoolz/DMap.cpp @@ -76,7 +76,7 @@ void DMap::ClearEntities(){ } DEntity* DMap::GetEntityForID( int ID ){ - DEntity* findEntity = NULL; + DEntity* findEntity = nullptr; for ( DEntity *entity : entityList ) { diff --git a/contrib/bobtoolz/DPatch.h b/contrib/bobtoolz/DPatch.h index bd5cf92f..ed69fe35 100644 --- a/contrib/bobtoolz/DPatch.h +++ b/contrib/bobtoolz/DPatch.h @@ -67,7 +67,7 @@ public: scene::Node* QER_entity{}; scene::Node* QER_brush{}; void LoadFromPatch( scene::Instance& patch ); - void BuildInRadiant( scene::Node* entity = NULL ); + void BuildInRadiant( scene::Node* entity = nullptr ); void SetTexture( const char* textureName ); char texture[256]; int width = MIN_PATCH_WIDTH, height = MIN_PATCH_HEIGHT; diff --git a/contrib/bobtoolz/DShape.cpp b/contrib/bobtoolz/DShape.cpp index b6fccffc..5956750a 100644 --- a/contrib/bobtoolz/DShape.cpp +++ b/contrib/bobtoolz/DShape.cpp @@ -293,7 +293,7 @@ DBrush* DShape::GetBoundingCube_Ext( vec3_t min, vec3_t max, const char *texture DBrush* DShape::GetBoundingCube( vec3_t min, vec3_t max, const char *textureName, DEntity* ent, bool* bUseFaces ){ DBrush* pB; - if ( ent == NULL ) { + if ( ent == nullptr ) { pB = m_Container.GetWorldSpawn()->NewBrush(); } else{ @@ -350,7 +350,7 @@ bool DShape::BuildPit( vec3_t min, vec3_t max ){ return false; } - srand( time( NULL ) ); + srand( time( nullptr ) ); vec3_t centre; VectorAdd( min, max, centre ); diff --git a/contrib/bobtoolz/DShape.h b/contrib/bobtoolz/DShape.h index fff8f2ee..ada0ea33 100644 --- a/contrib/bobtoolz/DShape.h +++ b/contrib/bobtoolz/DShape.h @@ -47,7 +47,7 @@ public: void Commit(); private: - DBrush* GetBoundingCube( vec3_t min, vec3_t max, const char* textureName, DEntity* ent = NULL, bool* bUseFaces = bFacesAll ); + DBrush* GetBoundingCube( vec3_t min, vec3_t max, const char* textureName, DEntity* ent = nullptr, bool* bUseFaces = bFacesAll ); DMap m_Container; }; diff --git a/contrib/bobtoolz/DTrainDrawer.cpp b/contrib/bobtoolz/DTrainDrawer.cpp index e39588a0..fbedd58a 100644 --- a/contrib/bobtoolz/DTrainDrawer.cpp +++ b/contrib/bobtoolz/DTrainDrawer.cpp @@ -181,7 +181,7 @@ public: const char* targetname; vec3_t vOrigin; - e.SpawnString( "targetname", NULL, &targetname ); + e.SpawnString( "targetname", nullptr, &targetname ); e.SpawnVector( "origin", "0 0 0", vOrigin ); if ( !strcmp( classname, "info_train_spline_main" ) ) { @@ -190,7 +190,7 @@ public: return; } - e.SpawnString( "target", NULL, &target ); + e.SpawnString( "target", nullptr, &target ); if ( !target ) { drawer.AddControlPoint( targetname, vOrigin ); @@ -198,7 +198,7 @@ public: else { splinePoint_t* pSP = drawer.AddSplinePoint( targetname, target, vOrigin ); - e.SpawnString( "control", NULL, &control ); + e.SpawnString( "control", nullptr, &control ); if ( control ) { AddSplineControl( control, pSP ); @@ -207,7 +207,7 @@ public: char buffer[32]; sprintf( buffer, "control%i", j ); - e.SpawnString( buffer, NULL, &control ); + e.SpawnString( buffer, nullptr, &control ); if ( !control ) { break; } diff --git a/contrib/bobtoolz/DTreePlanter.cpp b/contrib/bobtoolz/DTreePlanter.cpp index 61478f16..445d6fff 100644 --- a/contrib/bobtoolz/DTreePlanter.cpp +++ b/contrib/bobtoolz/DTreePlanter.cpp @@ -58,8 +58,8 @@ SignalHandlerResult DTreePlanter::mouseDown( const WindowVector& position, Butto if ( m_autoLink ) { - const scene::Path* pLastEntity = NULL; - const scene::Path* pThisEntity = NULL; + const scene::Path* pLastEntity = nullptr; + const scene::Path* pThisEntity = nullptr; int entpos; for ( int i = 0; i < 256; ++i ) { diff --git a/contrib/bobtoolz/DWinding.cpp b/contrib/bobtoolz/DWinding.cpp index 567e5e6b..2db093b6 100644 --- a/contrib/bobtoolz/DWinding.cpp +++ b/contrib/bobtoolz/DWinding.cpp @@ -114,7 +114,7 @@ void DWinding::RemoveColinearPoints(){ } DPlane* DWinding::WindingPlane(){ - auto *newPlane = new DPlane( p[0], p[1], p[2], NULL ); + auto *newPlane = new DPlane( p[0], p[1], p[2], nullptr ); return newPlane; } @@ -410,7 +410,7 @@ void DWinding::ClipWindingEpsilon( DPlane* chopPlane, vec_t epsilon, DWinding ** sides[i] = sides[0]; dists[i] = dists[0]; - *front = *back = NULL; + *front = *back = nullptr; if ( !counts[0] ) { *back = CopyWinding(); @@ -509,7 +509,7 @@ bool DWinding::ChopWinding( DPlane* chopPlane ){ delete[] p; p = f->p; - f->p = NULL; + f->p = nullptr; numpoints = f->numpoints; delete f; diff --git a/contrib/bobtoolz/ScriptParser.cpp b/contrib/bobtoolz/ScriptParser.cpp index 71c37f52..052ab0a9 100644 --- a/contrib/bobtoolz/ScriptParser.cpp +++ b/contrib/bobtoolz/ScriptParser.cpp @@ -21,10 +21,10 @@ #include CScriptParser::CScriptParser() : - m_pScript( NULL ), - m_pScriptSection( NULL ), - m_pLastScriptSection( NULL ), - m_pToken( NULL ) { + m_pScript( nullptr ), + m_pScriptSection( nullptr ), + m_pLastScriptSection( nullptr ), + m_pToken( nullptr ) { ClearBuffer(); } @@ -35,21 +35,21 @@ CScriptParser::~CScriptParser() { void CScriptParser::ClearBuffer() { if ( m_pScript ) { delete[] m_pScript; - m_pScript = NULL; + m_pScript = nullptr; } if ( m_pToken ) { delete[] m_pToken; - m_pToken = NULL; + m_pToken = nullptr; } - m_pScriptSection = NULL; - m_pLastScriptSection = NULL; + m_pScriptSection = nullptr; + m_pLastScriptSection = nullptr; memset( m_breakChars, 0, sizeof( m_breakChars ) ); } const char* CScriptParser::MakeToken( const char* pToken ) { if ( m_pToken ) { delete[] m_pToken; - m_pToken = NULL; + m_pToken = nullptr; } if ( !pToken ) { @@ -207,7 +207,7 @@ void CScriptParser::UndoGetToken() { return; } m_pScriptSection = m_pLastScriptSection; - m_pLastScriptSection = NULL; + m_pLastScriptSection = nullptr; } void CScriptParser::ResetParseSession() { @@ -216,12 +216,12 @@ void CScriptParser::ResetParseSession() { } m_pScriptSection = m_pScript; - m_pLastScriptSection = NULL; + m_pLastScriptSection = nullptr; } char* CScriptParser::GetBufferCopy() { if ( !m_pScript ) { - return NULL; + return nullptr; } int len = static_cast( strlen( m_pScript ) ); diff --git a/contrib/bobtoolz/bobToolz-GTK.cpp b/contrib/bobtoolz/bobToolz-GTK.cpp index d0e466ce..18127135 100644 --- a/contrib/bobtoolz/bobToolz-GTK.cpp +++ b/contrib/bobtoolz/bobToolz-GTK.cpp @@ -208,7 +208,7 @@ public: case 11: return ""; case 12: return "bobtoolz_turnedge.png"; } - return NULL; + return nullptr; } virtual EType getType() const override { switch ( mIndex ) { @@ -234,7 +234,7 @@ public: case 10: return "Split Patch Columns"; case 12: return "Flip Terrain"; } - return NULL; + return nullptr; } virtual const char* getTooltip() const override { switch ( mIndex ) { @@ -250,7 +250,7 @@ public: case 10: return "Split Patch Columns"; case 12: return "Flip Terrain (Turn Edge)"; } - return NULL; + return nullptr; } virtual void activate() const override { diff --git a/contrib/bobtoolz/bsploader.cpp b/contrib/bobtoolz/bsploader.cpp index 67ff1f41..b56a73b5 100644 --- a/contrib/bobtoolz/bsploader.cpp +++ b/contrib/bobtoolz/bsploader.cpp @@ -14,17 +14,17 @@ int numbrushes; int numbrushsides; int numleafbrushes; -byte *visBytes = NULL; -dnode_t *dnodes = NULL; -dplane_t *dplanes = NULL; -dleaf_t *dleafs = NULL; -qdrawVert_t *drawVerts = NULL; -int *drawVertsIndices = NULL; -dsurface_t *drawSurfaces = NULL; -int *dleafsurfaces = NULL; -dbrush_t *dbrushes = NULL; -dbrushside_t *dbrushsides = NULL; -int *dleafbrushes = NULL; +byte *visBytes = nullptr; +dnode_t *dnodes = nullptr; +dplane_t *dplanes = nullptr; +dleaf_t *dleafs = nullptr; +qdrawVert_t *drawVerts = nullptr; +int *drawVertsIndices = nullptr; +dsurface_t *drawSurfaces = nullptr; +int *dleafsurfaces = nullptr; +dbrush_t *dbrushes = nullptr; +dbrushside_t *dbrushsides = nullptr; +int *dleafbrushes = nullptr; #define IBSP_IDENT ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' ) #define IBSP_VERSION_Q3 46 diff --git a/contrib/bobtoolz/cportals.cpp b/contrib/bobtoolz/cportals.cpp index d60f2096..1baff49e 100644 --- a/contrib/bobtoolz/cportals.cpp +++ b/contrib/bobtoolz/cportals.cpp @@ -107,7 +107,7 @@ void CPortals::Purge(){ if ( node ) { delete[] node; } - node = NULL; + node = nullptr; node_count = 0; } @@ -124,7 +124,7 @@ void CPortals::Load(){ in = fopen( fn, "rt" ); - if ( in == NULL ) { + if ( in == nullptr ) { globalErrorStream() << " ERROR - could not open file.\n"; return; @@ -311,13 +311,13 @@ void CPortals::Load(){ } CBspNode::CBspNode(){ - portal = NULL; + portal = nullptr; portal_count = 0; portal_next = 0; } CBspNode::~CBspNode(){ - if ( portal != NULL ) { + if ( portal != nullptr ) { delete[] portal; } } diff --git a/contrib/bobtoolz/funchandlers-GTK.cpp b/contrib/bobtoolz/funchandlers-GTK.cpp index 6fe87361..e3f9481f 100644 --- a/contrib/bobtoolz/funchandlers-GTK.cpp +++ b/contrib/bobtoolz/funchandlers-GTK.cpp @@ -226,7 +226,7 @@ void DoResetTextures(){ const char* texName; if ( 1 /*g_SelectedFaceTable.m_pfnGetSelectedFaceCount() != 1*/ ) { - texName = NULL; + texName = nullptr; } else { @@ -664,7 +664,7 @@ void DoCaulkSelection() { world.LoadSelectedBrushes(); world.LoadSelectedPatches(); - world.ResetTextures( NULL, fScale, fShift, 0, "textures/common/caulk", true, bResetScale, bResetShift, false, true ); + world.ResetTextures( nullptr, fScale, fShift, 0, "textures/common/caulk", true, bResetScale, bResetShift, false, true ); } void DoTreePlanter() { @@ -865,7 +865,7 @@ void DoFlipTerrain() { for ( i = 0; i < 2; ++i ) { newBrushes[i]->RemoveRedundantPlanes(); - newBrushes[i]->BuildInRadiant( false, NULL, brushes[i]->path().parent().get_pointer() ); + newBrushes[i]->BuildInRadiant( false, nullptr, brushes[i]->path().parent().get_pointer() ); Path_deleteTop( brushes[i]->path() ); delete newBrushes[i]; } diff --git a/contrib/bobtoolz/misc.cpp b/contrib/bobtoolz/misc.cpp index 58da0e9f..071efb35 100644 --- a/contrib/bobtoolz/misc.cpp +++ b/contrib/bobtoolz/misc.cpp @@ -194,7 +194,7 @@ void StartBSP(){ char command[1024]; sprintf( command, "%s -nowater -fulldetail %s", exename, mapname ); - Q_Exec( NULL, command, NULL, false, true ); + Q_Exec( nullptr, command, nullptr, false, true ); } class EntityWriteMiniPrt diff --git a/contrib/bobtoolz/shapes.cpp b/contrib/bobtoolz/shapes.cpp index 4a92bc39..d16fb63d 100644 --- a/contrib/bobtoolz/shapes.cpp +++ b/contrib/bobtoolz/shapes.cpp @@ -574,7 +574,7 @@ void BuildDoorsX2( vec3_t min, vec3_t max, Node_getEntity( pEDoor2 )->setKeyValue( "angle", "90" ); } - srand( (unsigned)time( NULL ) ); + srand( (unsigned)time( nullptr ) ); char teamname[256]; sprintf( teamname, "t%i", rand() ); @@ -679,7 +679,7 @@ void BuildApertureDoors( scene::Instance& brushinstance, const class ApertureDoo g_vector3_axes[ vector3_min_abs_component_index( normal ) ], g_vector3_axes[ vector3_max_abs_component_index( normal ) ] ) ) * radius + vector3_from_array( center ); - srand( (unsigned)time( NULL ) ); + srand( (unsigned)time( nullptr ) ); char teamname[256]; sprintf( teamname, "t%i", rand() ); EntityClass* doorClass = GlobalEntityClassManager().findOrInsert( "func_door", true ); diff --git a/contrib/meshtex/GeneralFunctionDialog.cpp b/contrib/meshtex/GeneralFunctionDialog.cpp index cb424e35..fbf11fdd 100644 --- a/contrib/meshtex/GeneralFunctionDialog.cpp +++ b/contrib/meshtex/GeneralFunctionDialog.cpp @@ -332,8 +332,8 @@ GeneralFunctionDialog::Apply() // OK read the remaining info from the widgets. MeshEntity::GeneralFunctionFactors s, t; - MeshEntity::GeneralFunctionFactors *sFactors = NULL; - MeshEntity::GeneralFunctionFactors *tFactors = NULL; + MeshEntity::GeneralFunctionFactors *sFactors = nullptr; + MeshEntity::GeneralFunctionFactors *tFactors = nullptr; if (sApply) { // S axis is affected, so read the S factors. @@ -362,8 +362,8 @@ GeneralFunctionDialog::Apply() alignCol.maxSlice = !col_num_align->isEnabled(); alignCol.index = col_num_align->value(); MeshEntity::RefSliceDescriptor row, col; - MeshEntity::RefSliceDescriptor *refRow = NULL; - MeshEntity::RefSliceDescriptor *refCol = NULL; + MeshEntity::RefSliceDescriptor *refRow = nullptr; + MeshEntity::RefSliceDescriptor *refCol = nullptr; if ( row_ref->isChecked() ) { // Reference row is specified, so get that info. diff --git a/contrib/meshtex/GenericMainMenu.cpp b/contrib/meshtex/GenericMainMenu.cpp index 8baa5b11..3d82301d 100644 --- a/contrib/meshtex/GenericMainMenu.cpp +++ b/contrib/meshtex/GenericMainMenu.cpp @@ -80,7 +80,7 @@ GenericMainMenu::CommandDialogShow(const std::string& commandString) // than an assert. GenericDialog *dialog; if (dialogMapIter == _dialogMap.end() || - (dialog = dialogMapIter->second) == NULL) + (dialog = dialogMapIter->second) == nullptr) { std::string message(commandString + ": " + DIALOG_INTERNAL_ERROR); GenericPluginUI::ErrorReportDialog(DIALOG_ERROR_TITLE, message.c_str()); diff --git a/contrib/meshtex/GenericPluginUI.cpp b/contrib/meshtex/GenericPluginUI.cpp index d0bf4fd9..c25bc8d7 100644 --- a/contrib/meshtex/GenericPluginUI.cpp +++ b/contrib/meshtex/GenericPluginUI.cpp @@ -33,8 +33,8 @@ * subclasses of GenericPluginUI can be created. */ GenericPluginUI::GenericPluginUI() : - _window(NULL), - _mainMenu(NULL) + _window(nullptr), + _mainMenu(nullptr) { } @@ -45,7 +45,7 @@ GenericPluginUI::GenericPluginUI() : GenericPluginUI::~GenericPluginUI() { // Remove any reference to the menu object. - if (_mainMenu != NULL) + if (_mainMenu != nullptr) { delete _mainMenu; } @@ -92,7 +92,7 @@ GenericPluginUI::SetWindow(QWidget *window) // Set it as the parent for every dialog window. for ( const auto& [name, ptr] : _dialogMap ) { - if (ptr.get() != NULL) + if (ptr.get() != nullptr) { ptr->SetWindow(window); } @@ -107,9 +107,9 @@ GenericPluginUI::SetWindow(QWidget *window) GenericMainMenu * GenericPluginUI::MainMenu() { - if (_mainMenu == NULL) + if (_mainMenu == nullptr) { - return NULL; + return nullptr; } return _mainMenu->get(); } @@ -127,7 +127,7 @@ GenericPluginUI::Dialog(const std::string& key) DialogMap::const_iterator dialogMapIter = _dialogMap.find(key); if (dialogMapIter == _dialogMap.end()) { - return NULL; + return nullptr; } return dialogMapIter->second; } diff --git a/contrib/meshtex/MainMenu.cpp b/contrib/meshtex/MainMenu.cpp index 08b708cd..6caaac7a 100644 --- a/contrib/meshtex/MainMenu.cpp +++ b/contrib/meshtex/MainMenu.cpp @@ -74,7 +74,7 @@ MainMenu::MainMenu(SmartPointer& setScaleDialog, _commandMeshVisitor(*this) { // Like _commandMeshVisitor, the callbacks for the Help and About commands - // also specify functions on this object. + // also specify functions on this object. const CommandCallbackMethod commandHelp(*this); const CommandCallbackMethod @@ -92,7 +92,7 @@ MainMenu::MainMenu(SmartPointer& setScaleDialog, // The next few groups of commands are all similar "preset function" // commands. They will each trigger the CommandMeshVisitor callback when // selected in the menu. CommandMeshVisitor needs a visitor object to apply - // to the selected meshes, which we are specifying here. + // to the selected meshes, which we are specifying here. AddMeshVisitorEntry("S&T Align Auto", "STMinMaxAlignAuto", SmartPointer( new PresetFuncVisitor(&MeshEntity::MinMaxAlignAutoScale, @@ -168,7 +168,7 @@ MainMenu::CommandMeshVisitor(const std::string& commandString) VisitorMap::const_iterator visitorMapIter = _visitorMap.find(commandString); MeshVisitor *meshVisitor; if (visitorMapIter == _visitorMap.end() || - (meshVisitor = visitorMapIter->second) == NULL) + (meshVisitor = visitorMapIter->second) == nullptr) { // That's odd, there isn't one. Bail out. std::string message(commandString + ": " + DIALOG_INTERNAL_ERROR); @@ -183,7 +183,7 @@ MainMenu::CommandMeshVisitor(const std::string& commandString) GlobalSelectionSystem().foreachSelected(*meshVisitor); if (meshVisitor->GetVisitedCount() == 0) { - // Warn if there weren't any meshes selected (so nothing happened). + // Warn if there weren't any meshes selected (so nothing happened). GenericPluginUI::WarningReportDialog(DIALOG_WARNING_TITLE, DIALOG_NOMESHES_MSG); } diff --git a/contrib/meshtex/MeshEntity.cpp b/contrib/meshtex/MeshEntity.cpp index 2d0d304d..3cc996fb 100644 --- a/contrib/meshtex/MeshEntity.cpp +++ b/contrib/meshtex/MeshEntity.cpp @@ -156,7 +156,7 @@ MeshEntity::MeshEntity(scene::Node& mesh, const char *shaderName = GlobalPatchCreator().Patch_getShader(_mesh); IShader *shader = GlobalShaderSystem().getShaderForName(shaderName); qtexture_t *texture = shader->getTexture(); - if (texture != NULL) + if (texture != nullptr) { _naturalTexUnits[S_TEX_AXIS] = texture->width / 2.0f; _naturalTexUnits[T_TEX_AXIS] = texture->height / 2.0f; @@ -166,7 +166,7 @@ MeshEntity::MeshEntity(scene::Node& mesh, // Check for valid mesh; bail if not. if (_numSlices[ROW_SLICE_TYPE] < 3 || _numSlices[COL_SLICE_TYPE] < 3 || - texture == NULL) + texture == nullptr) { _valid = false; _errorReportCallback(ERROR_BAD_MESH); @@ -239,7 +239,7 @@ MeshEntity::GetInfo(const int *refRow, size_t bufferOffset = 0; // Get reference row info if requested; this will be written into the message // buffer as well as sent to the row callback (if any). - if (refRow != NULL) + if (refRow != nullptr) { ReportSliceTexInfo(ROW_SLICE_TYPE, *refRow, _naturalAxis[ROW_SLICE_TYPE], messageBuffer + bufferOffset, @@ -250,7 +250,7 @@ MeshEntity::GetInfo(const int *refRow, } // Get reference column info if requested; this will be written into the // message buffer as well as sent to the column callback (if any). - if (refCol != NULL) + if (refCol != nullptr) { ReportSliceTexInfo(COL_SLICE_TYPE, *refCol, _naturalAxis[COL_SLICE_TYPE], messageBuffer + bufferOffset, @@ -390,7 +390,7 @@ MeshEntity::SetScale(SliceType sliceType, CreateUndoPoint(); // Check for bad inputs. Also convert from natural scale to raw scale. - if (alignSlice != NULL && !alignSlice->maxSlice) + if (alignSlice != nullptr && !alignSlice->maxSlice) { if (alignSlice->index < 0 || alignSlice->index >= (int)SliceSize(sliceType)) @@ -399,7 +399,7 @@ MeshEntity::SetScale(SliceType sliceType, return; } } - if (refSlice != NULL && !refSlice->designation.maxSlice) + if (refSlice != nullptr && !refSlice->designation.maxSlice) { if (refSlice->designation.index < 0 || refSlice->designation.index >= (int)_numSlices[sliceType]) @@ -534,8 +534,8 @@ MeshEntity::GeneralFunction(const GeneralFunctionFactors *sFactors, // the input factors care about distances. AllocatedMatrix rowDistances(_meshData.x(), _meshData.y()); AllocatedMatrix colDistances(_meshData.x(), _meshData.y()); - if ((sFactors != NULL && sFactors->rowDistance != 0.0f) || - (tFactors != NULL && tFactors->rowDistance != 0.0f)) + if ((sFactors != nullptr && sFactors->rowDistance != 0.0f) || + (tFactors != nullptr && tFactors->rowDistance != 0.0f)) { GenScaledDistanceValues(ROW_SLICE_TYPE, alignColInt, @@ -544,8 +544,8 @@ MeshEntity::GeneralFunction(const GeneralFunctionFactors *sFactors, 1.0f, rowDistances); } - if ((sFactors != NULL && sFactors->colDistance != 0.0f) || - (tFactors != NULL && tFactors->colDistance != 0.0f)) + if ((sFactors != nullptr && sFactors->colDistance != 0.0f) || + (tFactors != nullptr && tFactors->colDistance != 0.0f)) { GenScaledDistanceValues(COL_SLICE_TYPE, alignRowInt, @@ -556,14 +556,14 @@ MeshEntity::GeneralFunction(const GeneralFunctionFactors *sFactors, } // Modify the S axis if requested. - if (sFactors != NULL) + if (sFactors != nullptr) { GeneralFunctionInt(*sFactors, S_TEX_AXIS, alignRowInt, alignColInt, surfaceValues, rowDistances, colDistances); } // Modify the T axis if requested. - if (tFactors != NULL) + if (tFactors != nullptr) { GeneralFunctionInt(*tFactors, T_TEX_AXIS, alignRowInt, alignColInt, surfaceValues, rowDistances, colDistances); @@ -678,7 +678,7 @@ int MeshEntity::InternalSliceDesignation(const SliceDesignation *sliceDesignation, SliceType sliceType) { - if (sliceDesignation != NULL) + if (sliceDesignation != nullptr) { // Interpret "max slice" if necessary. if (sliceDesignation->maxSlice) @@ -715,7 +715,7 @@ MeshEntity::InternalRefSliceDescriptor(const RefSliceDescriptor *refSlice, SliceType sliceType, RefSliceDescriptorInt& refSliceInt) { - if (refSlice != NULL) + if (refSlice != nullptr) { // Preserve totalLengthOnly. refSliceInt.totalLengthOnly = refSlice->totalLengthOnly; @@ -726,7 +726,7 @@ MeshEntity::InternalRefSliceDescriptor(const RefSliceDescriptor *refSlice, else { // NULL if unspecified. - return NULL; + return nullptr; } } @@ -898,7 +898,7 @@ MeshEntity::ReportSliceTexInfo(SliceType sliceType, // Send texture info to callback if one is provided. bool infscale = (info.scale > FLT_MAX || info.scale < -FLT_MAX); - if (texInfoCallback != NULL) + if (texInfoCallback != nullptr) { if (!infscale) { @@ -913,7 +913,7 @@ MeshEntity::ReportSliceTexInfo(SliceType sliceType, } // Write texture info to buffer if one is provided. - if (messageBuffer != NULL) + if (messageBuffer != nullptr) { if (!infscale) { @@ -1557,7 +1557,7 @@ MeshEntity::GenScaledDistanceValues(SliceType sliceType, // Pick the slices that we will measure. int firstSlice, lastSlice; - if (refSlice != NULL && !refSlice->totalLengthOnly) + if (refSlice != nullptr && !refSlice->totalLengthOnly) { // If a reference slice is provided, and totalLengthOnly is false, then we // will only need to measure the reference slice. The values generated for @@ -1669,7 +1669,7 @@ MeshEntity::GenScaledDistanceValues(SliceType sliceType, // If there's a reference slice, we're going to need to know the total slice // length, so save that away. float refTotalLength; - if (refSlice != NULL) + if (refSlice != nullptr) { refTotalLength = MatrixElement(values, sliceType, refSlice->index, SliceSize(sliceType) - 1) - @@ -1695,7 +1695,7 @@ MeshEntity::GenScaledDistanceValues(SliceType sliceType, { // In this case we've just been passed in the value to divide by. scaleFactor = rawScaleOrTiles; - if (refSlice != NULL) + if (refSlice != nullptr) { // However if there's a reference slice, adjust the divisor by the // ratio of this slice's length to the reference slice's length. @@ -1733,7 +1733,7 @@ MeshEntity::GenScaledDistanceValues(SliceType sliceType, // reference slice. Now we have to copy the reference slice's values to all // other slices. // (These loops also copy the reference slice to itself, which is fine.) - if (refSlice != NULL && !refSlice->totalLengthOnly) + if (refSlice != nullptr && !refSlice->totalLengthOnly) { for (unsigned slice = 0; slice < _numSlices[sliceType]; ++slice) { diff --git a/contrib/meshtex/PluginModule.cpp b/contrib/meshtex/PluginModule.cpp index 7c7e22a3..9419273a 100644 --- a/contrib/meshtex/PluginModule.cpp +++ b/contrib/meshtex/PluginModule.cpp @@ -100,7 +100,7 @@ const char * PluginModule::QERPluginGetCommandList() { // Bail out if the plugin menu doesn't exist. - if (UIInstance().MainMenu() == NULL) + if (UIInstance().MainMenu() == nullptr) { return ""; } @@ -118,7 +118,7 @@ const char * PluginModule::QERPluginGetCommandTitleList() { // Bail out if the plugin menu doesn't exist. - if (UIInstance().MainMenu() == NULL) + if (UIInstance().MainMenu() == nullptr) { return ""; } @@ -143,7 +143,7 @@ PluginModule::QERPluginDispatch(const char *command, bool bSingleBrush) { // Bail out if the plugin menu doesn't exist. - if (UIInstance().MainMenu() == NULL) + if (UIInstance().MainMenu() == nullptr) { // XXX This shouldn't happen; might as well drop an ASSERT or error // message in here. First make sure there's no odd Radiant-exiting diff --git a/contrib/meshtex/SetScaleDialog.cpp b/contrib/meshtex/SetScaleDialog.cpp index 1ee3b55a..e7bace49 100644 --- a/contrib/meshtex/SetScaleDialog.cpp +++ b/contrib/meshtex/SetScaleDialog.cpp @@ -61,13 +61,13 @@ SetScaleDialog::SetScaleVisitor::SetScaleVisitor( bool SetScaleDialog::SetScaleVisitor::Execute(MeshEntity& meshEntity) const { - if (_rowArgs != NULL) + if (_rowArgs != nullptr) { meshEntity.SetScale(MeshEntity::ROW_SLICE_TYPE, _rowArgs->alignSlice, _rowArgs->refSlice, _rowArgs->naturalScale, _rowArgs->scaleOrTiles); } - if (_colArgs != NULL) + if (_colArgs != nullptr) { meshEntity.SetScale(MeshEntity::COL_SLICE_TYPE, _colArgs->alignSlice, _colArgs->refSlice, @@ -309,8 +309,8 @@ SetScaleDialog::Apply() MeshEntity::SliceDesignation alignCol, alignRow; MeshEntity::RefSliceDescriptor refRow, refCol; SetScaleVisitor::SliceArgs row, col; - SetScaleVisitor::SliceArgs *rowArgs = NULL; - SetScaleVisitor::SliceArgs *colArgs = NULL; + SetScaleVisitor::SliceArgs *rowArgs = nullptr; + SetScaleVisitor::SliceArgs *colArgs = nullptr; if (sApply) { // S axis is affected, so read the S info. @@ -326,7 +326,7 @@ SetScaleDialog::Apply() alignCol.maxSlice = !col_num_align->isEnabled(); alignCol.index = col_num_align->value(); row.alignSlice = &alignCol; - row.refSlice = NULL; + row.refSlice = nullptr; if ( row_ref->isChecked() ) { // Reference row is specified, so get that info. @@ -352,7 +352,7 @@ SetScaleDialog::Apply() alignRow.maxSlice = !row_num_align->isEnabled(); alignRow.index = row_num_align->value(); col.alignSlice = &alignRow; - col.refSlice = NULL; + col.refSlice = nullptr; if ( col_ref->isChecked() ) { // Reference column is specified, so get that info. diff --git a/contrib/prtview/portals.cpp b/contrib/prtview/portals.cpp index 0459fb78..2afdb7a1 100644 --- a/contrib/prtview/portals.cpp +++ b/contrib/prtview/portals.cpp @@ -106,7 +106,7 @@ void CPortals::Purge(){ /* delete[] node; - node = NULL; + node = nullptr; node_count = 0; */ } @@ -125,7 +125,7 @@ void CPortals::Load(){ in = fopen( fn.c_str(), "rt" ); - if ( in == NULL ) { + if ( in == nullptr ) { globalErrorStream() << " ERROR - could not open file.\n"; return; diff --git a/contrib/prtview/prtview.cpp b/contrib/prtview/prtview.cpp index 01913bf2..2d8e5c9f 100644 --- a/contrib/prtview/prtview.cpp +++ b/contrib/prtview/prtview.cpp @@ -173,7 +173,7 @@ static const char *PLUGIN_COMMANDS = Q3R_CMD_LOAD; -QWidget *g_pRadiantWnd = NULL; +QWidget *g_pRadiantWnd = nullptr; const char* QERPlug_Init( void *hApp, void* pMainWidget ){ g_pRadiantWnd = static_cast( pMainWidget ); diff --git a/contrib/ufoaiplug/ufoai.cpp b/contrib/ufoaiplug/ufoai.cpp index 7c93eb66..9ce6baa2 100644 --- a/contrib/ufoaiplug/ufoai.cpp +++ b/contrib/ufoaiplug/ufoai.cpp @@ -74,7 +74,7 @@ const char* getCommandTitleList(){ return ""; } void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush ){ - const char *message = NULL; + const char *message = nullptr; if ( string_equal( command, "About" ) ) { GlobalRadiant().m_pfnMessageBox( g_mainwnd, "UFO:AI Plugin (http://ufoai.sf.net)" @@ -130,7 +130,7 @@ void dispatch( const char* command, float* vMin, float* vMax, bool bSingleBrush filter_nodraw(); } - if ( message != NULL ) { + if ( message != nullptr ) { GlobalRadiant().m_pfnMessageBox( g_mainwnd, message, "Note", EMessageBoxType::Info, 0 ); diff --git a/contrib/ufoaiplug/ufoai_gtk.cpp b/contrib/ufoaiplug/ufoai_gtk.cpp index 208ca798..2213c509 100644 --- a/contrib/ufoaiplug/ufoai_gtk.cpp +++ b/contrib/ufoaiplug/ufoai_gtk.cpp @@ -60,7 +60,7 @@ public: case 10: return "ufoai_weaponclip.png"; case 11: return "ufoai_nodraw.png"; } - return NULL; + return nullptr; } virtual EType getType() const override { switch ( mIndex ) @@ -89,7 +89,7 @@ public: case 10: return "WeaponClip"; case 11: return "NoDraw"; } - return NULL; + return nullptr; } virtual const char* getTooltip() const override { switch ( mIndex ) @@ -107,7 +107,7 @@ public: case 10: return "Hide weaponClip brushes"; case 11: return "Hide noDraw brushes"; } - return NULL; + return nullptr; } virtual void activate() const override { @@ -149,5 +149,5 @@ const IToolbarButton* GetToolbarButton( std::size_t index ){ * @brief */ const IToolbarButton* GetToolbarNoButton( std::size_t index ){ - return NULL; + return nullptr; } diff --git a/contrib/ufoaiplug/ufoai_level.cpp b/contrib/ufoaiplug/ufoai_level.cpp index 9f5576b9..bdae54a9 100644 --- a/contrib/ufoaiplug/ufoai_level.cpp +++ b/contrib/ufoaiplug/ufoai_level.cpp @@ -55,7 +55,7 @@ public: * @brief */ Entity* Scene_FindEntityByClass( const char* name ){ - Entity* entity = NULL; + Entity* entity = nullptr; GlobalSceneGraph().traverse( EntityFindByClassname( name, entity ) ); return entity; } @@ -206,21 +206,21 @@ void check_map_values( const char **returnMsg ){ // singleplayer map? count = 0; - get_team_count( "info_human_start", &count, NULL ); + get_team_count( "info_human_start", &count, nullptr ); if ( !count ) { strncat( message, "No singleplayer start positions (info_human_start)\n", sizeof( message ) - strlen( message ) - 1 ); } // singleplayer map? count = 0; - get_team_count( "info_2x2_start", &count, NULL ); + get_team_count( "info_2x2_start", &count, nullptr ); if ( !count ) { strncat( message, "No singleplayer start positions for 2x2 units (info_2x2_start)\n", sizeof( message ) - strlen( message ) - 1 ); } // search for civilians count = 0; - get_team_count( "info_civilian_start", &count, NULL ); + get_team_count( "info_civilian_start", &count, nullptr ); if ( !count ) { strncat( message, "No civilian start positions (info_civilian_start)\n", sizeof( message ) - strlen( message ) - 1 ); } diff --git a/libs/commandlib.cpp b/libs/commandlib.cpp index 21e5d5f3..59732027 100644 --- a/libs/commandlib.cpp +++ b/libs/commandlib.cpp @@ -50,7 +50,7 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){ { default: if ( waitfor ) { - waitpid( pid, NULL, 0 ); + waitpid( pid, nullptr, 0 ); } break; case -1: @@ -60,7 +60,7 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *, bool, bool waitfor ){ // XXX : if we run q3map2 with '-connect' - redirect stdout and stderr // to /dev/null - aka build monitoring - as it's already going to // be written to stdout via 'radiant/console.cpp → Sys_print - if ( cmdline != NULL && ( strstr( cmdline, "q3map2" ) != NULL ) && ( strstr( cmdline, "-connect" ) != NULL ) ) { + if ( cmdline != nullptr && ( strstr( cmdline, "q3map2" ) != nullptr ) && ( strstr( cmdline, "-connect" ) != nullptr ) ) { int devNullFd = open( "/dev/null", 0 ); if ( devNullFd != -1 ) { dup2( devNullFd, 1 ); @@ -128,11 +128,11 @@ bool Q_Exec( const char *cmd, char *cmdline, const char *execdir, bool bCreateCo if ( CreateProcess( pCmd, pCmdline, - NULL, - NULL, + nullptr, + nullptr, FALSE, dwCreationFlags, - NULL, + nullptr, execdir, &startupinfo, &ProcessInformation diff --git a/libs/gtkutil/filechooser.cpp b/libs/gtkutil/filechooser.cpp index 700f67fe..501e22db 100644 --- a/libs/gtkutil/filechooser.cpp +++ b/libs/gtkutil/filechooser.cpp @@ -130,7 +130,7 @@ const char* file_dialog( QWidget* parent, bool open, const char* title, const ch } // we should add all important paths as shortcut folder... - // gtk_file_chooser_add_shortcut_folder( GTK_FILE_CHOOSER( dialog ), "/tmp/", NULL ); + // gtk_file_chooser_add_shortcut_folder( GTK_FILE_CHOOSER( dialog ), "/tmp/", nullptr ); QString filter; diff --git a/libs/gtkutil/glfont.cpp b/libs/gtkutil/glfont.cpp index bbcdce25..1442b1bc 100644 --- a/libs/gtkutil/glfont.cpp +++ b/libs/gtkutil/glfont.cpp @@ -437,16 +437,16 @@ GLFont *glfont_create( const char* font_string ){ int firstbitmap; fontInfo = XLoadQueryFont( dpy, "-*-fixed-*-*-*-*-8-*-*-*-*-*-*-*" ); - if ( fontInfo == NULL ) { + if ( fontInfo == nullptr ) { // try to load other fonts fontInfo = XLoadQueryFont( dpy, "-*-fixed-*-*-*-*-*-*-*-*-*-*-*-*" ); // any font will do ! - if ( fontInfo == NULL ) { + if ( fontInfo == nullptr ) { fontInfo = XLoadQueryFont( dpy, "-*-*-*-*-*-*-*-*-*-*-*-*-*-*" ); } - if ( fontInfo == NULL ) { + if ( fontInfo == nullptr ) { ERROR_MESSAGE( "couldn't create font" ); } } @@ -585,7 +585,7 @@ public: #else font_ascent_pango_units = pango_layout_get_baseline( layout ); #endif - pango_layout_get_extents( layout, NULL, &log_rect ); + pango_layout_get_extents( layout, nullptr, &log_rect ); g_object_unref( G_OBJECT( layout ) ); font_descent_pango_units = log_rect.height - font_ascent_pango_units; @@ -630,7 +630,7 @@ public: layout = pango_layout_new( ft2_context ); pango_layout_set_width( layout, -1 ); // -1 no wrapping. All text on one line. pango_layout_set_text( layout, s, -1 ); // -1 null-terminated string. - pango_layout_get_extents( layout, NULL, &log_rect ); + pango_layout_get_extents( layout, nullptr, &log_rect ); if ( log_rect.width > 0 && log_rect.height > 0 ) { bitmap.rows = font_ascent + font_descent; diff --git a/libs/modulesystem/singletonmodule.cpp b/libs/modulesystem/singletonmodule.cpp index e1d55ce7..c481c593 100644 --- a/libs/modulesystem/singletonmodule.cpp +++ b/libs/modulesystem/singletonmodule.cpp @@ -35,7 +35,7 @@ public: typedef NullType Type; STRING_CONSTANT( Name, "" ); void* getTable(){ - return NULL; + return nullptr; } }; diff --git a/libs/profile/file.cpp b/libs/profile/file.cpp index a219a2b3..9547e855 100644 --- a/libs/profile/file.cpp +++ b/libs/profile/file.cpp @@ -50,7 +50,7 @@ MemStream::MemStream(){ m_nPosition = 0; m_nBufferSize = 0; m_nFileSize = 0; - m_pBuffer = NULL; + m_pBuffer = nullptr; m_bAutoDelete = true; } @@ -59,14 +59,14 @@ MemStream::MemStream( size_type nLen ){ m_nPosition = 0; m_nBufferSize = 0; m_nFileSize = 0; - m_pBuffer = NULL; + m_pBuffer = nullptr; m_bAutoDelete = true; GrowFile( nLen ); } FileStream::FileStream(){ - m_hFile = NULL; + m_hFile = nullptr; m_bCloseOnDelete = false; } @@ -82,7 +82,7 @@ MemStream::~MemStream(){ } FileStream::~FileStream(){ - if ( m_hFile != NULL && m_bCloseOnDelete ) { + if ( m_hFile != nullptr && m_bCloseOnDelete ) { Close(); } } @@ -95,10 +95,10 @@ char* MemStream::ReadString( char* pBuf, size_type nMax ){ unsigned char ch; if ( nMax <= 0 ) { - return NULL; + return nullptr; } if ( m_nPosition >= m_nFileSize ) { - return NULL; + return nullptr; } while ( ( --nMax ) ) @@ -235,7 +235,7 @@ bool FileStream::Open( const char *filename, const char *mode ){ m_hFile = fopen( filename, mode ); m_bCloseOnDelete = true; - return ( m_hFile != NULL ); + return ( m_hFile != nullptr ); } void MemStream::Close(){ @@ -246,15 +246,15 @@ void MemStream::Close(){ if ( m_pBuffer && m_bAutoDelete ) { free( m_pBuffer ); } - m_pBuffer = NULL; + m_pBuffer = nullptr; } void FileStream::Close(){ - if ( m_hFile != NULL ) { + if ( m_hFile != nullptr ) { fclose( m_hFile ); } - m_hFile = NULL; + m_hFile = nullptr; m_bCloseOnDelete = false; } @@ -304,7 +304,7 @@ void MemStream::GrowFile( size_type nNewLen ){ // allocate new buffer unsigned char* lpNew; - if ( m_pBuffer == NULL ) { + if ( m_pBuffer == nullptr ) { lpNew = static_cast( malloc( nNewBufferSize ) ); } else{ @@ -321,7 +321,7 @@ void MemStream::Flush(){ } void FileStream::Flush(){ - if ( m_hFile == NULL ) { + if ( m_hFile == nullptr ) { return; } @@ -333,12 +333,12 @@ void MemStream::Abort(){ } void FileStream::Abort(){ - if ( m_hFile != NULL ) { + if ( m_hFile != nullptr ) { // close but ignore errors if ( m_bCloseOnDelete ) { fclose( m_hFile ); } - m_hFile = NULL; + m_hFile = nullptr; m_bCloseOnDelete = false; } } diff --git a/libs/profile/profile.cpp b/libs/profile/profile.cpp index cd4df30b..17f11bc7 100644 --- a/libs/profile/profile.cpp +++ b/libs/profile/profile.cpp @@ -56,7 +56,7 @@ bool read_var( const char *filename, const char *section, const char *key, char rc = fopen( filename, "rt" ); - if ( rc == NULL ) { + if ( rc == nullptr ) { return false; } @@ -75,7 +75,7 @@ bool read_var( const char *filename, const char *section, const char *key, char { ptr = strchr( line, '=' ); - if ( ptr == NULL ) { + if ( ptr == nullptr ) { // reached the end of the section fclose( rc ); return false; @@ -112,7 +112,7 @@ bool save_var( const char *filename, const char *section, const char *key, const rc = fopen( filename, "rb" ); - if ( rc != NULL ) { + if ( rc != nullptr ) { unsigned int len; void *buf; @@ -130,13 +130,13 @@ bool save_var( const char *filename, const char *section, const char *key, const // TTimo: changed to binary writing. It doesn't seem to affect linux version, and win32 version was happending a lot of '\n' rc = fopen( filename, "wb" ); - if ( rc == NULL ) { + if ( rc == nullptr ) { return false; } // First we need to find the section found = false; - while ( old_rc.ReadString( line, 1024 ) != NULL ) + while ( old_rc.ReadString( line, 1024 ) != nullptr ) { fputs( line, rc ); @@ -158,11 +158,11 @@ bool save_var( const char *filename, const char *section, const char *key, const fprintf( rc, "%s=%s\n", key, value ); - while ( old_rc.ReadString( line, 1024 ) != NULL ) + while ( old_rc.ReadString( line, 1024 ) != nullptr ) { ptr = strchr( line, '=' ); - if ( ptr != NULL ) { + if ( ptr != nullptr ) { *ptr = '\0'; if ( strcmp( line, key ) == 0 ) { @@ -179,7 +179,7 @@ bool save_var( const char *filename, const char *section, const char *key, const } } - while ( old_rc.ReadString( line, 1024 ) != NULL ) + while ( old_rc.ReadString( line, 1024 ) != nullptr ) fputs( line, rc ); fclose( rc ); @@ -213,7 +213,7 @@ bool profile_save_buffer( const char * rc_path, const char *name, void *buffer, f = fopen( filename, "wb" ); - if ( f != NULL ) { + if ( f != nullptr ) { if ( fwrite( buffer, size, 1, f ) == 1 ) { ret = true; } @@ -233,7 +233,7 @@ bool profile_load_buffer( const char * rc_path, const char *name, void *buffer, f = fopen( filename, "rb" ); - if ( f != NULL ) { + if ( f != nullptr ) { fseek( f, 0, SEEK_END ); len = ftell( f ); rewind( f ); diff --git a/libs/uniquenames.h b/libs/uniquenames.h index e4f95d7e..bae23ce6 100644 --- a/libs/uniquenames.h +++ b/libs/uniquenames.h @@ -99,7 +99,7 @@ inline name_t name_read( const char* name ){ const char* end = name + strlen( name ); for ( const char* p = end; end != name; --p ) { - if ( strrchr( "1234567890", *p ) == NULL ) { + if ( strrchr( "1234567890", *p ) == nullptr ) { break; } end = p; diff --git a/libs/xml/xmltextags.cpp b/libs/xml/xmltextags.cpp index 310f403f..2b5b9bbe 100644 --- a/libs/xml/xmltextags.cpp +++ b/libs/xml/xmltextags.cpp @@ -44,7 +44,7 @@ bool XmlTagBuilder::CreateXmlDocument( const char* savefile ){ writer = xmlNewTextWriterDoc( &doc, 0 ); // begin a new UTF-8 formatted xml document - xmlTextWriterStartDocument( writer, NULL, "UTF-8", NULL ); + xmlTextWriterStartDocument( writer, nullptr, "UTF-8", nullptr ); // create the root node with stock and custom elements xmlTextWriterStartElement( writer, (const xmlChar*)"root" ); @@ -122,8 +122,8 @@ bool XmlTagBuilder::AddShaderNode( const char* shader, TextureType textureType, returns TRUE if the node was added successfully or FALSE when failed */ - xmlNodeSetPtr nodePtr = NULL; - xmlXPathObjectPtr xpathPtr = NULL; + xmlNodeSetPtr nodePtr = nullptr; + xmlXPathObjectPtr xpathPtr = nullptr; switch ( textureType ) { @@ -149,11 +149,11 @@ bool XmlTagBuilder::AddShaderNode( const char* shader, TextureType textureType, switch ( nodeShaderType ) { case NodeShaderType::SHADER: - newnode = xmlNewNode( NULL, (const xmlChar*)"shader" ); + newnode = xmlNewNode( nullptr, (const xmlChar*)"shader" ); break; case NodeShaderType::TEXTURE: default: - newnode = xmlNewNode( NULL, (const xmlChar*)"texture" ); + newnode = xmlNewNode( nullptr, (const xmlChar*)"texture" ); break; }; @@ -161,7 +161,7 @@ bool XmlTagBuilder::AddShaderNode( const char* shader, TextureType textureType, xmlSetProp( newnode, (const xmlChar*)"path", (const xmlChar*)shader ); xmlNodeSetContent( newnode, (const xmlChar*)"\n " ); - if ( nodePtr->nodeTab[0]->children->next == NULL ) { // there are no shaders yet + if ( nodePtr->nodeTab[0]->children->next == nullptr ) { // there are no shaders yet // add spaces newtext = xmlNewText( (const xmlChar*)" " ); xmlAddChild( nodeParent->children, newtext ); @@ -327,12 +327,12 @@ bool XmlTagBuilder::AddShaderTag( const char* shader, const char* content, NodeT } if ( !xmlXPathNodeSetIsEmpty( nodePtr ) ) { // node was found - xmlNodePtr newnode = xmlNewNode( NULL, (const xmlChar*)"tag" ); + xmlNodePtr newnode = xmlNewNode( nullptr, (const xmlChar*)"tag" ); xmlNodePtr nodeParent = nodePtr->nodeTab[0]; newnode = xmlDocCopyNode( newnode, doc, 1 ); xmlNodeSetContent( newnode, (const xmlChar*)content ); - if ( nodePtr->nodeTab[0]->children->next == NULL ) { // shader node has NO children + if ( nodePtr->nodeTab[0]->children->next == nullptr ) { // shader node has NO children // add spaces xmlNodePtr newtext = xmlNewText( (const xmlChar*)" " ); xmlAddChild( nodeParent->children, newtext ); @@ -476,7 +476,7 @@ void XmlTagBuilder::GetShaderTags( const char* shader, std::vector const char* expression; - if ( shader == NULL ) { // get all tags from all shaders + if ( shader == nullptr ) { // get all tags from all shaders expression = "/root/*/*/tag"; } else { diff --git a/plugins/image/jpeg.cpp b/plugins/image/jpeg.cpp index 19a0de18..4baeaf3b 100644 --- a/plugins/image/jpeg.cpp +++ b/plugins/image/jpeg.cpp @@ -224,7 +224,7 @@ static void jpeg_buffer_src( j_decompress_ptr cinfo, void* buffer, int bufsize ) * This makes it unsafe to use this manager and a different source * manager serially with the same JPEG object. Caveat programmer. */ - if ( cinfo->src == NULL ) { /* first time for this JPEG object? */ + if ( cinfo->src == nullptr ) { /* first time for this JPEG object? */ cinfo->src = (struct jpeg_source_mgr *) ( *cinfo->mem->alloc_small )( (j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof( my_source_mgr ) ); @@ -243,7 +243,7 @@ static void jpeg_buffer_src( j_decompress_ptr cinfo, void* buffer, int bufsize ) src->src_buffer = (JOCTET *)buffer; src->src_size = bufsize; src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ - src->pub.next_input_byte = NULL; /* until buffer loaded */ + src->pub.next_input_byte = nullptr; /* until buffer loaded */ } // ============================================================================= diff --git a/plugins/image/ktx.cpp b/plugins/image/ktx.cpp index 35705244..0cd8d7ad 100644 --- a/plugins/image/ktx.cpp +++ b/plugins/image/ktx.cpp @@ -324,7 +324,7 @@ Image* LoadKTXBuff( PointerInputStream& istream ){ auto *image = new RGBAImage( width, height ); if ( type ) { - KTX_Decoder* decoder = NULL; + KTX_Decoder* decoder = nullptr; switch ( type ) { case KTX_TYPE_UNSIGNED_BYTE: diff --git a/plugins/imagepng/plugin.cpp b/plugins/imagepng/plugin.cpp index f539e1e6..9502e87a 100644 --- a/plugins/imagepng/plugin.cpp +++ b/plugins/imagepng/plugin.cpp @@ -58,7 +58,7 @@ Image* LoadPNGBuff( unsigned char* fbuffer ){ // http://www.libpng.org/pub/png/libpng-manual.html png_structp png_ptr = png_create_read_struct - ( PNG_LIBPNG_VER_STRING, (png_voidp)NULL, + ( PNG_LIBPNG_VER_STRING, (png_voidp)nullptr, user_error_fn, user_warning_fn ); if ( !png_ptr ) { globalErrorStream() << "libpng error: png_create_read_struct\n"; @@ -67,14 +67,14 @@ Image* LoadPNGBuff( unsigned char* fbuffer ){ png_infop info_ptr = png_create_info_struct( png_ptr ); if ( !info_ptr ) { - png_destroy_read_struct( &png_ptr, (png_infopp)NULL, (png_infopp)NULL ); + png_destroy_read_struct( &png_ptr, (png_infopp)nullptr, (png_infopp)nullptr ); globalErrorStream() << "libpng error: png_create_info_struct (info_ptr)\n"; return 0; } png_infop end_info = png_create_info_struct( png_ptr ); if ( !end_info ) { - png_destroy_read_struct( &png_ptr, &info_ptr, (png_infopp)NULL ); + png_destroy_read_struct( &png_ptr, &info_ptr, (png_infopp)nullptr ); globalErrorStream() << "libpng error: png_create_info_struct (end_info)\n"; return 0; } @@ -159,7 +159,7 @@ Image* LoadPNGBuff( unsigned char* fbuffer ){ png_read_end( png_ptr, info_ptr ); /* free up the memory structure */ - png_destroy_read_struct( &png_ptr, &info_ptr, NULL ); + png_destroy_read_struct( &png_ptr, &info_ptr, nullptr ); free( row_pointers ); diff --git a/radiant/environment.cpp b/radiant/environment.cpp index a5514271..26646f4b 100644 --- a/radiant/environment.cpp +++ b/radiant/environment.cpp @@ -126,10 +126,10 @@ void gamedetect(){ { // TODO add more games to this - if ( gamedetect_check_game( "q3.game", "baseq3/pak0.pk3", NULL, buf, p - buf ) ) { + if ( gamedetect_check_game( "q3.game", "baseq3/pak0.pk3", nullptr, buf, p - buf ) ) { return; } - if ( gamedetect_check_game( "q1.game", "id1/pak0.pak", NULL, buf, p - buf ) ) { + if ( gamedetect_check_game( "q1.game", "id1/pak0.pak", nullptr, buf, p - buf ) ) { return; } // try to detect Nexuiz installs @@ -145,12 +145,12 @@ void gamedetect(){ } // try to detect Q2World installs - if ( gamedetect_check_game( "q2w.game", "default/quake2world.version", NULL, buf, p - buf ) ) { + if ( gamedetect_check_game( "q2w.game", "default/quake2world.version", nullptr, buf, p - buf ) ) { return; } // try to detect Warsow installs - if ( gamedetect_check_game( "warsow.game", "basewsw/dedicated_autoexec.cfg", NULL, buf, p - buf ) ) { + if ( gamedetect_check_game( "warsow.game", "basewsw/dedicated_autoexec.cfg", nullptr, buf, p - buf ) ) { return; } diff --git a/radiant/feedback.cpp b/radiant/feedback.cpp index e42b253f..eade0fab 100644 --- a/radiant/feedback.cpp +++ b/radiant/feedback.cpp @@ -253,7 +253,7 @@ void CDbgDlg::Init(){ e->Release(); m_feedbackElements.clear(); - if ( m_clist != NULL ) { + if ( m_clist != nullptr ) { m_clist->clear(); } } diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index e65f60d5..34204225 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -185,10 +185,10 @@ void HomePaths_Realise(){ qSHGetKnownFolderPath = (qSHGetKnownFolderPath_t *) GetProcAddress( shfolder, "SHGetKnownFolderPath" ); } else{ - qSHGetKnownFolderPath = NULL; + qSHGetKnownFolderPath = nullptr; } - CoInitializeEx( NULL, COINIT_APARTMENTTHREADED ); - if ( qSHGetKnownFolderPath && qSHGetKnownFolderPath( qFOLDERID_SavedGames, qKF_FLAG_CREATE | qKF_FLAG_NO_ALIAS, NULL, &mydocsdirw ) == S_OK ) { + CoInitializeEx( nullptr, COINIT_APARTMENTTHREADED ); + if ( qSHGetKnownFolderPath && qSHGetKnownFolderPath( qFOLDERID_SavedGames, qKF_FLAG_CREATE | qKF_FLAG_NO_ALIAS, nullptr, &mydocsdirw ) == S_OK ) { memset( mydocsdir, 0, sizeof( mydocsdir ) ); wcstombs( mydocsdir, mydocsdirw, sizeof( mydocsdir ) - 1 ); CoTaskMemFree( mydocsdirw ); @@ -204,7 +204,7 @@ void HomePaths_Realise(){ if ( shfolder ) { FreeLibrary( shfolder ); } - if ( SUCCEEDED( SHGetFolderPath( NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir ) ) ) { + if ( SUCCEEDED( SHGetFolderPath( nullptr, CSIDL_PERSONAL, nullptr, 0, mydocsdir ) ) ) { path( DirectoryCleaned( mydocsdir ), "My Games/", ( prefix + 1 ), '/' ); // win32: only add it if it already exists if ( file_is_directory( path ) ) { @@ -642,12 +642,12 @@ void Radiant_Restart(){ const auto mapname = StringStream( makeQuoted( Map_Name( g_map ) ) ); char *argv[] = { string_clone( environment_get_app_filepath() ), - Map_Unnamed( g_map )? NULL : string_clone( mapname ), - NULL }; + Map_Unnamed( g_map )? nullptr : string_clone( mapname ), + nullptr }; #ifdef WIN32 const int status = !_spawnv( P_NOWAIT, argv[0], argv ); #else - const int status = posix_spawn( NULL, argv[0], NULL, NULL, argv, environ ); + const int status = posix_spawn( nullptr, argv[0], nullptr, nullptr, argv, environ ); #endif // quit if radiant successfully started diff --git a/radiant/map.cpp b/radiant/map.cpp index e40c5def..deb5b1cd 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -1595,7 +1595,7 @@ tryDecompile: str << ' ' << makeQuoted( filename ); // run - Q_Exec( NULL, str.c_str(), NULL, false, true ); + Q_Exec( nullptr, str.c_str(), nullptr, false, true ); // rebuild filename as "filenamewithoutext_converted.map" str( PathExtensionless( filename ), "_converted.map" ); @@ -2263,7 +2263,7 @@ void map_autocaulk_selected(){ << " -autocaulk -fulldetail " << makeQuoted( filename ); // run - Q_Exec( NULL, str.c_str(), NULL, false, true ); + Q_Exec( nullptr, str.c_str(), nullptr, false, true ); } typedef std::map CaulkMap; diff --git a/radiant/qe3.cpp b/radiant/qe3.cpp index d359ded2..5a2e26f3 100644 --- a/radiant/qe3.cpp +++ b/radiant/qe3.cpp @@ -265,7 +265,7 @@ void RunBSP( size_t buildIdx ){ globalOutputStream() << "Writing the compile script to '" << batpath << "'\n"; if( g_WatchBSP0_DumpLog ) globalOutputStream() << "The build output will be saved in '" << junkpath << "'\n"; - Q_Exec( batpath, NULL, NULL, true, false ); + Q_Exec( batpath, nullptr, nullptr, true, false ); } } diff --git a/radiant/server.cpp b/radiant/server.cpp index 4e0bb8ba..e9b955f6 100644 --- a/radiant/server.cpp +++ b/radiant/server.cpp @@ -108,12 +108,12 @@ const char* FormatGetLastError(){ FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, GetLastError(), MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language buf, FORMAT_BUFSIZE, - NULL + nullptr ); return buf; } diff --git a/radiant/texmanip.cpp b/radiant/texmanip.cpp index 917df8ef..c9dab33b 100644 --- a/radiant/texmanip.cpp +++ b/radiant/texmanip.cpp @@ -34,7 +34,7 @@ #include #include "stream/textstream.h" -static byte *row1 = NULL, *row2 = NULL; +static byte *row1 = nullptr, *row2 = nullptr; static int rowsize = 0; void R_ResampleTextureLerpLine( const byte *in, byte *out, int inwidth, int outwidth, int bytesperpixel ){ diff --git a/radiant/watchbsp.cpp b/radiant/watchbsp.cpp index d450a6a1..d652de1e 100644 --- a/radiant/watchbsp.cpp +++ b/radiant/watchbsp.cpp @@ -91,10 +91,10 @@ private: public: CWatchBSP(){ m_bBSPPlugin = false; - m_pListenSocket = NULL; - m_pInSocket = NULL; + m_pListenSocket = nullptr; + m_pInSocket = nullptr; m_eState = EIdle; - m_xmlInputBuffer = NULL; + m_xmlInputBuffer = nullptr; m_bNeedCtxtInit = true; m_monitoring_timer.callOnTimeout( [this](){ RoutineProcessing(); } ); m_monitoring_timer.setInterval( 25 ); @@ -274,8 +274,7 @@ void BuildMonitor_Construct(){ } void BuildMonitor_Destroy(){ - delete g_pWatchBSP; - g_pWatchBSP = NULL; + delete std::exchange( g_pWatchBSP, nullptr ); } CWatchBSP *GetWatchBSP(){ @@ -531,15 +530,15 @@ static xmlSAXHandler saxParser = { void CWatchBSP::Reset(){ if ( m_pInSocket ) { Net_Disconnect( m_pInSocket ); - m_pInSocket = NULL; + m_pInSocket = nullptr; } if ( m_pListenSocket ) { Net_Disconnect( m_pListenSocket ); - m_pListenSocket = NULL; + m_pListenSocket = nullptr; } if ( m_xmlInputBuffer ) { xmlFreeParserInputBuffer( m_xmlInputBuffer ); - m_xmlInputBuffer = NULL; + m_xmlInputBuffer = nullptr; } m_eState = EIdle; m_monitoring_timer.stop(); @@ -555,7 +554,7 @@ bool CWatchBSP::SetupListening(){ globalOutputStream() << "Setting up\n"; Net_Setup(); m_pListenSocket = Net_ListenSocket( 39000 ); - if ( m_pListenSocket == NULL ) { + if ( m_pListenSocket == nullptr ) { return false; } globalOutputStream() << "Listening...\n"; @@ -577,7 +576,7 @@ void CWatchBSP::DoEBeginStep(){ globalOutputStream() << "=== running build command ===\n" << m_commands[m_iCurrentStep] << '\n'; - if ( !Q_Exec( NULL, const_cast( m_commands[m_iCurrentStep].c_str() ), NULL, true, false ) ) { + if ( !Q_Exec( nullptr, const_cast( m_commands[m_iCurrentStep].c_str() ), nullptr, true, false ) ) { const auto msg = StringStream( "Failed to execute the following command: ", m_commands[m_iCurrentStep], "\nCheck that the file exists and that you don't run out of system resources.\n" ); globalOutputStream() << msg; @@ -655,10 +654,10 @@ void CWatchBSP::RoutineProcessing(){ // unsigned int size = msg.size; //++timo just a check strcpy( m_xmlBuf, NMSG_ReadString( &msg ) ); if ( m_bNeedCtxtInit ) { - m_xmlParserCtxt = NULL; - m_xmlParserCtxt = xmlCreatePushParserCtxt( &saxParser, &m_message_info, m_xmlBuf, static_cast( strlen( m_xmlBuf ) ), NULL ); + m_xmlParserCtxt = nullptr; + m_xmlParserCtxt = xmlCreatePushParserCtxt( &saxParser, &m_message_info, m_xmlBuf, static_cast( strlen( m_xmlBuf ) ), nullptr ); - if ( m_xmlParserCtxt == NULL ) { + if ( m_xmlParserCtxt == nullptr ) { globalErrorStream() << "Failed to create the XML parser (incoming stream began with: " << m_xmlBuf << ")\n"; EndMonitoringLoop(); } @@ -674,7 +673,7 @@ void CWatchBSP::RoutineProcessing(){ // error or connection closed/reset // NOTE: if we get an error down the XML stream we don't reach here Net_Disconnect( m_pInSocket ); - m_pInSocket = NULL; + m_pInSocket = nullptr; globalOutputStream() << "Connection closed.\n"; #if 0 if ( m_bBSPPlugin ) { diff --git a/radiant/xmlstuff.h b/radiant/xmlstuff.h index 2d589ffe..adc8d88a 100644 --- a/radiant/xmlstuff.h +++ b/radiant/xmlstuff.h @@ -69,7 +69,7 @@ public: virtual void saxEndElement( message_info_t* ctx, const xmlChar* name ) = 0; virtual void saxCharacters( message_info_t* ctx, const xmlChar* ch, int len ) = 0; virtual const char* getName(){ - return NULL; + return nullptr; } virtual IGL2DWindow* Highlight(){ return 0; diff --git a/tools/quake3/common/cmdlib.cpp b/tools/quake3/common/cmdlib.cpp index f7d6c5e6..905bce04 100644 --- a/tools/quake3/common/cmdlib.cpp +++ b/tools/quake3/common/cmdlib.cpp @@ -157,7 +157,7 @@ void SafeRead( FILE *f, MemBuffer& buffer ){ void SafeWrite( FILE *f, const void *buffer, int count ){ - if ( buffer != NULL && fwrite( buffer, 1, count, f ) != (size_t)count ) { + if ( buffer != nullptr && fwrite( buffer, 1, count, f ) != (size_t)count ) { Error( "File write failure" ); } } diff --git a/tools/quake3/common/inout.cpp b/tools/quake3/common/inout.cpp index 23b6b968..7289b48c 100644 --- a/tools/quake3/common/inout.cpp +++ b/tools/quake3/common/inout.cpp @@ -68,7 +68,7 @@ xmlNodePtr xml_NodeForVec( const Vector3& v ){ char buf[1024]; sprintf( buf, "%f %f %f", v[0], v[1], v[2] ); - ret = xmlNewNode( NULL, (const xmlChar*)"point" ); + ret = xmlNewNode( nullptr, (const xmlChar*)"point" ); xmlNodeAddContent( ret, (const xmlChar*)buf ); return ret; } @@ -114,14 +114,14 @@ void xml_Select( const char *msg, int entitynum, int brushnum, bool bError ){ // now build a proper "select" XML node sprintf( buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg ); - node = xmlNewNode( NULL, (const xmlChar*)"select" ); + node = xmlNewNode( nullptr, (const xmlChar*)"select" ); xmlNodeAddContent( node, (const xmlChar*)buf ); level[0] = (int)'0' + ( bError ? SYS_ERR : SYS_WRN ); level[1] = 0; xmlSetProp( node, (const xmlChar*)"level", (const xmlChar *)level ); // a 'select' information sprintf( buf, "%i %i", entitynum, brushnum ); - select = xmlNewNode( NULL, (const xmlChar*)"brush" ); + select = xmlNewNode( nullptr, (const xmlChar*)"brush" ); xmlNodeAddContent( select, (const xmlChar*)buf ); xmlAddChild( node, select ); xml_SendNode( node ); @@ -140,14 +140,14 @@ void xml_Point( const char *msg, const Vector3& pt ){ char buf[1024]; char level[2]; - node = xmlNewNode( NULL, (const xmlChar*)"pointmsg" ); + node = xmlNewNode( nullptr, (const xmlChar*)"pointmsg" ); xmlNodeAddContent( node, (const xmlChar*)msg ); level[0] = (int)'0' + SYS_ERR; level[1] = 0; xmlSetProp( node, (const xmlChar*)"level", (const xmlChar *)level ); // a 'point' node sprintf( buf, "%g %g %g", pt[0], pt[1], pt[2] ); - point = xmlNewNode( NULL, (const xmlChar*)"point" ); + point = xmlNewNode( nullptr, (const xmlChar*)"point" ); xmlNodeAddContent( point, (const xmlChar*)buf ); xmlAddChild( node, point ); xml_SendNode( node ); @@ -163,7 +163,7 @@ void xml_Winding( const char *msg, const Vector3 p[], int numpoints, bool die ){ char smlbuf[128]; char level[2]; - node = xmlNewNode( NULL, (const xmlChar*)"windingmsg" ); + node = xmlNewNode( nullptr, (const xmlChar*)"windingmsg" ); xmlNodeAddContent( node, (const xmlChar*)msg ); level[0] = (int)'0' + SYS_ERR; level[1] = 0; @@ -180,7 +180,7 @@ void xml_Winding( const char *msg, const Vector3 p[], int numpoints, bool die ){ strcat( buf, smlbuf ); } - winding = xmlNewNode( NULL, (const xmlChar*)"winding" ); + winding = xmlNewNode( nullptr, (const xmlChar*)"winding" ); xmlNodeAddContent( winding, (const xmlChar*)buf ); xmlAddChild( node, winding ); xml_SendNode( node ); @@ -265,7 +265,7 @@ void Broadcast_Shutdown(){ Sys_Printf( "Disconnecting\n" ); xml_message_flush(); Net_Disconnect( brdcst_socket ); - brdcst_socket = NULL; + brdcst_socket = nullptr; } set_console_colour_for_flag( SYS_STD ); //restore default on exit } @@ -276,11 +276,11 @@ static void xml_message_flush(){ if( mesege_len == 0 ) return; - xmlNodePtr node = xmlNewNode( NULL, (const xmlChar*)"message" ); + xmlNodePtr node = xmlNewNode( nullptr, (const xmlChar*)"message" ); { mesege[mesege_len] = '\0'; mesege_len = 0; - gchar* utf8 = g_locale_to_utf8( mesege, -1, NULL, NULL, NULL ); + gchar* utf8 = g_locale_to_utf8( mesege, -1, nullptr, nullptr, nullptr ); xmlNodeAddContent( node, (const xmlChar*)utf8 ); g_free( utf8 ); } @@ -342,7 +342,7 @@ static void FPrintf( int flag, char *buf ){ if ( !bGotXML ) { // initialize doc = xmlNewDoc( (const xmlChar*)"1.0" ); - doc->children = xmlNewDocRawNode( doc, NULL, (const xmlChar*)"q3map_feedback", NULL ); + doc->children = xmlNewDocRawNode( doc, nullptr, (const xmlChar*)"q3map_feedback", nullptr ); bGotXML = true; } xml_message_push( flag & ~( SYS_NOXMLflag | SYS_VRBflag ), buf, strlen( buf ) ); diff --git a/tools/quake3/common/jpeg.cpp b/tools/quake3/common/jpeg.cpp index e070cfd6..c35bff1e 100644 --- a/tools/quake3/common/jpeg.cpp +++ b/tools/quake3/common/jpeg.cpp @@ -216,7 +216,7 @@ static void jpeg_buffer_src( j_decompress_ptr cinfo, void* buffer, int bufsize ) * This makes it unsafe to use this manager and a different source * manager serially with the same JPEG object. Caveat programmer. */ - if ( cinfo->src == NULL ) { /* first time for this JPEG object? */ + if ( cinfo->src == nullptr ) { /* first time for this JPEG object? */ cinfo->src = (struct jpeg_source_mgr *) ( *cinfo->mem->alloc_small )( (j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof( my_source_mgr ) ); @@ -235,7 +235,7 @@ static void jpeg_buffer_src( j_decompress_ptr cinfo, void* buffer, int bufsize ) src->src_buffer = (JOCTET *)buffer; src->src_size = bufsize; src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ - src->pub.next_input_byte = NULL; /* until buffer loaded */ + src->pub.next_input_byte = nullptr; /* until buffer loaded */ } // ============================================================================= diff --git a/tools/quake3/common/qimagelib.cpp b/tools/quake3/common/qimagelib.cpp index e776d062..00aa03a9 100644 --- a/tools/quake3/common/qimagelib.cpp +++ b/tools/quake3/common/qimagelib.cpp @@ -202,8 +202,8 @@ void LoadLBM( const char *filename, byte **picture, byte **palette ){ int chunktype, chunklength; // qiet compiler warnings - picbuffer = NULL; - cmapbuffer = NULL; + picbuffer = nullptr; + cmapbuffer = nullptr; // // load the LBM @@ -892,7 +892,7 @@ void LoadTGABuffer( const byte *f, const size_t dataSize, byte **pic, int *width unsigned char palette[256 * 4]; const byte * const enddata = f + dataSize; - *pic = NULL; + *pic = nullptr; // abort if it is too small to parse if ( dataSize < 19 ) { @@ -1357,7 +1357,7 @@ static const KTX_UncompressedFormat_t KTX_UncompressedFormats[] = { KTX_TYPE_UNSIGNED_SHORT_4_4_4_4, KTX_FORMAT_RGBA, 2, KTX_DecodeRGBA4 }, { KTX_TYPE_UNSIGNED_SHORT_5_5_5_1, KTX_FORMAT_RGBA, 2, KTX_DecodeRGBA5 }, { KTX_TYPE_UNSIGNED_SHORT_5_6_5, KTX_FORMAT_RGB, 2, KTX_DecodeRGB5 }, - { 0, 0, 0, NULL } + { 0, 0, 0, nullptr } }; static bool KTX_DecodeETC1( const byte* in, size_t inSize, unsigned int width, unsigned int height, byte* out ){ diff --git a/tools/quake3/common/qstringops.h b/tools/quake3/common/qstringops.h index 4dbcab91..41239e16 100644 --- a/tools/quake3/common/qstringops.h +++ b/tools/quake3/common/qstringops.h @@ -29,7 +29,7 @@ inline bool strEmpty( const char* string ){ return *string == '\0'; } inline bool strEmptyOrNull( const char* string ){ - return string == NULL || *string == '\0'; + return string == nullptr || *string == '\0'; } inline void strClear( char* string ){ *string = '\0'; @@ -94,7 +94,7 @@ inline const char *strIstr( const char* haystack, const char* needle ) { return haystack; } } while ( *haystack++ ); - return NULL; + return nullptr; } inline char *strIstr( char* haystack, const char* needle ) { diff --git a/tools/quake3/common/vfs.cpp b/tools/quake3/common/vfs.cpp index 84cd1da3..41c6a974 100644 --- a/tools/quake3/common/vfs.cpp +++ b/tools/quake3/common/vfs.cpp @@ -105,7 +105,7 @@ char g_strLoadedFileLocation[1024]; static void vfsInitPakFile( const char *filename ){ unzFile uf = unzOpen( filename ); - if ( uf != NULL ) { + if ( uf != nullptr ) { VFS_PAK& pak = g_paks.emplace_front( uf, filename ); if ( unzGoToFirstFile( uf ) == UNZ_OK ) { @@ -113,7 +113,7 @@ static void vfsInitPakFile( const char *filename ){ char filename_inzip[256]; unz_file_info file_info; - if ( unzGetCurrentFileInfo( uf, &file_info, filename_inzip, std::size( filename_inzip ), NULL, 0, NULL, 0 ) != UNZ_OK ) { + if ( unzGetCurrentFileInfo( uf, &file_info, filename_inzip, std::size( filename_inzip ), nullptr, 0, nullptr, 0 ) != UNZ_OK ) { break; } @@ -160,9 +160,9 @@ void vfsInitDirectory( const char *path ){ const CopiedString pathCleaned = g_strDirs.emplace_back( StringStream( DirectoryCleaned( path ) ) ); if ( g_bUsePak ) { - dir = g_dir_open( path, 0, NULL ); + dir = g_dir_open( path, 0, nullptr ); - if ( dir != NULL ) { + if ( dir != nullptr ) { std::vector paks; const char* name; while ( ( name = g_dir_read_name( dir ) ) ) @@ -205,9 +205,9 @@ std::vector vfsListShaderFiles( const char *shaderPath ){ }; /* search in dirs */ for ( const auto& strdir : g_strDirs ){ - GDir *dir = g_dir_open( StringStream( strdir, shaderPath, '/' ), 0, NULL ); + GDir *dir = g_dir_open( StringStream( strdir, shaderPath, '/' ), 0, nullptr ); - if ( dir != NULL ) { + if ( dir != nullptr ) { const char* name; while ( ( name = g_dir_read_name( dir ) ) ) { @@ -271,7 +271,7 @@ MemBuffer vfsLoadFile( const char *filename, int index /* = 0 */ ){ MemBuffer buffer; FILE *f = fopen( filename, "rb" ); - if ( f != NULL ) { + if ( f != nullptr ) { fseek( f, 0, SEEK_END ); buffer = MemBuffer( ftell( f ) ); rewind( f ); diff --git a/tools/quake3/q3map2/autopk3.cpp b/tools/quake3/q3map2/autopk3.cpp index 478e5079..25357665 100644 --- a/tools/quake3/q3map2/autopk3.cpp +++ b/tools/quake3/q3map2/autopk3.cpp @@ -67,7 +67,7 @@ static inline void tex2list( StrList& texlist, const StrList& EXtex, const StrLi /* exclude */ if( !StrList_find( texlist, token ) && !StrList_find( EXtex, token ) && - ( rEXtex == NULL || + ( rEXtex == nullptr || !StrList_find( *rEXtex, token ) ) ){ texlist.emplace_back( token ); } @@ -443,7 +443,7 @@ int pk3BSPMain( Args& args ){ /* get an image */ GetToken( false ); if ( token[ 0 ] != '*' && token[ 0 ] != '$' ) { - tex2list( pk3Textures, ex.textures, NULL ); + tex2list( pk3Textures, ex.textures, nullptr ); } } else if ( striEqual( token, "animMap" ) || @@ -452,14 +452,14 @@ int pk3BSPMain( Args& args ){ GetToken( false );// skip num while ( TokenAvailable() ){ GetToken( false ); - tex2list( pk3Textures, ex.textures, NULL ); + tex2list( pk3Textures, ex.textures, nullptr ); } } else if ( striEqual( token, "videoMap" ) ){ hasmap = true; GetToken( false ); FixDOSName( token ); - if ( strchr( token, '/' ) == NULL ){ + if ( strchr( token, '/' ) == nullptr ){ strcpy( token, stream( "video/", token ) ); } if( !StrList_find( pk3Videos, token ) && @@ -486,7 +486,7 @@ int pk3BSPMain( Args& args ){ char* const skysidestring = token + strcatQ( token, "_@@.tga", std::size( token ) ) - 6; for( const auto *side : { "up", "dn", "lf", "rt", "bk", "ft" } ){ memcpy( skysidestring, side, 2 ); - tex2list( pk3Textures, ex.textures, NULL ); + tex2list( pk3Textures, ex.textures, nullptr ); } } /* skip rest of line */ @@ -788,7 +788,7 @@ int repackBSPMain( Args& args ){ if( dbg ) Sys_Printf( "%s\n", token ); - if ( strchr( token, '\\') != NULL ){ + if ( strchr( token, '\\') != nullptr ){ Sys_FPrintf( SYS_WRN, "WARNING1: %s : %s : shader name with backslash\n", file.c_str(), token ); } @@ -839,7 +839,7 @@ int repackBSPMain( Args& args ){ hasmap = true; text.GetToken( false ); FixDOSName( token ); - if ( strchr( token, '/' ) == NULL ){ + if ( strchr( token, '/' ) == nullptr ){ strcpy( token, stream( "video/", token ) ); } if( !StrList_find( pk3Videos, token ) && @@ -913,7 +913,7 @@ int repackBSPMain( Args& args ){ //pure textures (shader ones are done) for ( auto& s : pk3Shaders ){ if ( !s.empty() ){ - if ( strchr( s, '\\') != NULL ){ + if ( strchr( s, '\\') != nullptr ){ Sys_FPrintf( SYS_WRN, "WARNING2: %s : bsp shader path with backslash\n", s.c_str() ); s = stream( PathCleaned( s ) ); //what if theres properly slashed one in the list? diff --git a/tools/quake3/q3map2/brush.cpp b/tools/quake3/q3map2/brush.cpp index a5c60194..6e87f082 100644 --- a/tools/quake3/q3map2/brush.cpp +++ b/tools/quake3/q3map2/brush.cpp @@ -46,7 +46,7 @@ sideRef_t *AllocSideRef( const side_t *side, sideRef_t *next ){ /* dummy check */ - if ( side == NULL ) { + if ( side == nullptr ) { return next; } @@ -720,7 +720,7 @@ static std::pair SplitBrush( const brush_t& brush, int planenu side_t& cs = b[i].sides.emplace_back(); cs.planenum = planenum ^ i ^ 1; - cs.shaderInfo = NULL; + cs.shaderInfo = nullptr; if ( i == 0 ) { cs.winding = midwinding; // copy } diff --git a/tools/quake3/q3map2/bsp.cpp b/tools/quake3/q3map2/bsp.cpp index 38f24ec9..e09007de 100644 --- a/tools/quake3/q3map2/bsp.cpp +++ b/tools/quake3/q3map2/bsp.cpp @@ -43,9 +43,9 @@ static void autocaulk_write(){ FILE* file = SafeOpenWrite( filename, "wt" ); int fslime = 0; - ApplySurfaceParm( "slime", &fslime, NULL, NULL ); + ApplySurfaceParm( "slime", &fslime, nullptr, nullptr ); int flava = 0; - ApplySurfaceParm( "lava", &flava, NULL, NULL ); + ApplySurfaceParm( "lava", &flava, nullptr, nullptr ); // many setups have nodraw shader nonsolid, including vQ3; and nondrawnonsolid also... fall back to caulk in such case // it would be better to decide in Radiant, as it has configurable per game common shaders, but it has no solidity info const bool nodraw_is_solid = ShaderInfoForShader( "textures/common/nodraw" ).compileFlags & C_SOLID; @@ -156,7 +156,7 @@ static void SetCloneModelNumbers(){ for ( std::size_t i = 1; i < entities.size(); ++i ) { /* only entities with brushes or patches get a model number */ - if ( entities[ i ].brushes.empty() && entities[ i ].patches == NULL ) { + if ( entities[ i ].brushes.empty() && entities[ i ].patches == nullptr ) { continue; } @@ -176,7 +176,7 @@ static void SetCloneModelNumbers(){ for ( std::size_t i = 1; i < entities.size(); ++i ) { /* only entities with brushes or patches get a model number */ - if ( entities[ i ].brushes.empty() && entities[ i ].patches == NULL ) { + if ( entities[ i ].brushes.empty() && entities[ i ].patches == nullptr ) { continue; } @@ -207,7 +207,7 @@ static void SetCloneModelNumbers(){ /* nuke the brushes/patches for this entity (fixme: leak!) */ auto *leak = new brushlist_t( std::move( entities[ i ].brushes ) ); // are brushes referenced elsewhere, so we do not nuke them really? - entities[ i ].patches = NULL; + entities[ i ].patches = nullptr; } } } @@ -234,10 +234,10 @@ static void FixBrushSides( const entity_t& e ){ } /* walk sideref list */ - for ( const sideRef_t *sideRef = ds.sideRef; sideRef != NULL; sideRef = sideRef->next ) + for ( const sideRef_t *sideRef = ds.sideRef; sideRef != nullptr; sideRef = sideRef->next ) { /* get bsp brush side */ - if ( sideRef->side == NULL || sideRef->side->outputNum < 0 ) { + if ( sideRef->side == nullptr || sideRef->side->outputNum < 0 ) { continue; } bspBrushSide_t& side = bspBrushSides[ sideRef->side->outputNum ]; @@ -406,7 +406,7 @@ static void ProcessWorldModel( entity_t& e ){ /* get light */ if ( light.classname_is( "light" ) ) { /* get flare shader */ - const char *flareShader = NULL; + const char *flareShader = nullptr; if ( light.read_keyvalue( flareShader, "_flareshader" ) || light.boolForKey( "_flare" ) ) { /* get specifics */ const Vector3 origin( light.vectorForKey( "origin" ) ); @@ -418,7 +418,7 @@ static void ProcessWorldModel( entity_t& e ){ if ( light.read_keyvalue( value, "target" ) ) { /* get target light */ const entity_t *target = FindTargetEntity( value ); - if ( target != NULL ) { + if ( target != nullptr ) { normal = VectorNormalized( target->vectorForKey( "origin" ) - origin ); } } @@ -544,7 +544,7 @@ static void ProcessModels(){ { /* get entity */ entity_t& entity = entities[ entityNum ]; - if ( entity.brushes.empty() && entity.patches == NULL ) { + if ( entity.brushes.empty() && entity.patches == nullptr ) { continue; } diff --git a/tools/quake3/q3map2/bspfile_abstract.cpp b/tools/quake3/q3map2/bspfile_abstract.cpp index 0c685729..423ddc57 100644 --- a/tools/quake3/q3map2/bspfile_abstract.cpp +++ b/tools/quake3/q3map2/bspfile_abstract.cpp @@ -59,7 +59,7 @@ void SwapBlock( int *block, int size ){ /* dummy check */ - if ( block == NULL ) { + if ( block == nullptr ) { return; } @@ -192,7 +192,7 @@ static void SwapBSPFile(){ void LoadBSPFile( const char *filename ){ /* dummy check */ - if ( g_game == NULL || g_game->load == NULL ) { + if ( g_game == nullptr || g_game->load == nullptr ) { Error( "LoadBSPFile: unsupported BSP file format" ); } @@ -208,7 +208,7 @@ void LoadBSPFile( const char *filename ){ void LoadBSPFilePartially( const char *filename ){ /* dummy check */ - if ( g_game == NULL || g_game->load == NULL ) { + if ( g_game == nullptr || g_game->load == nullptr ) { Error( "LoadBSPFile: unsupported BSP file format" ); } @@ -230,7 +230,7 @@ void WriteBSPFile( const char *filename ){ Sys_Printf( "Writing %s\n", filename ); /* dummy check */ - if ( g_game == NULL || g_game->write == NULL ) { + if ( g_game == nullptr || g_game->write == nullptr ) { Error( "WriteBSPFile: unsupported BSP file format" ); } @@ -617,7 +617,7 @@ entity_t *FindTargetEntity( const char *target ){ } /* nada */ - return NULL; + return nullptr; } @@ -630,25 +630,25 @@ entity_t *FindTargetEntity( const char *target ){ void GetEntityShadowFlags( const entity_t *ent, const entity_t *ent2, int *castShadows, int *recvShadows ){ /* get cast shadows */ - if ( castShadows != NULL ) { - ( ent != NULL && ent->read_keyvalue( *castShadows, "_castShadows", "_cs" ) ) || - ( ent2 != NULL && ent2->read_keyvalue( *castShadows, "_castShadows", "_cs" ) ); + if ( castShadows != nullptr ) { + ( ent != nullptr && ent->read_keyvalue( *castShadows, "_castShadows", "_cs" ) ) || + ( ent2 != nullptr && ent2->read_keyvalue( *castShadows, "_castShadows", "_cs" ) ); } /* receive */ - if ( recvShadows != NULL ) { - ( ent != NULL && ent->read_keyvalue( *recvShadows, "_receiveShadows", "_rs" ) ) || - ( ent2 != NULL && ent2->read_keyvalue( *recvShadows, "_receiveShadows", "_rs" ) ); + if ( recvShadows != nullptr ) { + ( ent != nullptr && ent->read_keyvalue( *recvShadows, "_receiveShadows", "_rs" ) ) || + ( ent2 != nullptr && ent2->read_keyvalue( *recvShadows, "_receiveShadows", "_rs" ) ); } /* vortex: game-specific default entity keys */ if ( striEqual( g_game->magic, "dq" ) || striEqual( g_game->magic, "prophecy" ) ) { /* vortex: deluxe quake default shadow flags */ if ( ent->classname_is( "func_wall" ) ) { - if ( recvShadows != NULL ) { + if ( recvShadows != nullptr ) { *recvShadows = 1; } - if ( castShadows != NULL ) { + if ( castShadows != nullptr ) { *castShadows = 1; } } diff --git a/tools/quake3/q3map2/convert_bsp.cpp b/tools/quake3/q3map2/convert_bsp.cpp index c7c6a506..580074d6 100644 --- a/tools/quake3/q3map2/convert_bsp.cpp +++ b/tools/quake3/q3map2/convert_bsp.cpp @@ -135,7 +135,7 @@ int AnalyzeBSP( Args& args ){ { 128 * 128 * 3, 1, "IBSP LUMP_LIGHTMAPS" }, { 256 * 256 * 3, 1, "IBSP LUMP_LIGHTMAPS (256 x 256)" }, { 512 * 512 * 3, 1, "IBSP LUMP_LIGHTMAPS (512 x 512)" }, - { 0, 0, NULL } + { 0, 0, nullptr } }; @@ -973,7 +973,7 @@ static void PseudoCompileBSP( bool need_tree ){ { /* get entity */ entity_t& entity = entities[ entityNum ]; - if ( entity.brushes.empty() && entity.patches == NULL ) { + if ( entity.brushes.empty() && entity.patches == nullptr ) { continue; } @@ -1011,7 +1011,7 @@ static void PseudoCompileBSP( bool need_tree ){ continue; } /* shader? */ - if ( side.shaderInfo == NULL ) { + if ( side.shaderInfo == nullptr ) { continue; } /* save this winding as a visible surface */ @@ -1050,7 +1050,7 @@ int ConvertBSPMain( Args& args ){ /* set default */ convertFunc = ConvertBSPToASE; - convertGame = NULL; + convertGame = nullptr; map_allowed = false; force_bsp = false; force_map = false; @@ -1087,7 +1087,7 @@ int ConvertBSPMain( Args& args ){ { convertGame = GetGame( fmt ); map_allowed = false; - if ( convertGame == NULL ) { + if ( convertGame == nullptr ) { Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", fmt ); } } @@ -1143,8 +1143,8 @@ int ConvertBSPMain( Args& args ){ } path_set_extension( source, ".map" ); Sys_Printf( "Loading %s\n", source ); - LoadMapFile( source, false, convertGame == NULL ); - PseudoCompileBSP( convertGame != NULL ); + LoadMapFile( source, false, convertGame == nullptr ); + PseudoCompileBSP( convertGame != nullptr ); } else { @@ -1155,7 +1155,7 @@ int ConvertBSPMain( Args& args ){ } /* bsp format convert? */ - if ( convertGame != NULL ) { + if ( convertGame != nullptr ) { /* set global game */ g_game = convertGame; diff --git a/tools/quake3/q3map2/convert_map.cpp b/tools/quake3/q3map2/convert_map.cpp index ea5afbfd..7ea01e41 100644 --- a/tools/quake3/q3map2/convert_map.cpp +++ b/tools/quake3/q3map2/convert_map.cpp @@ -268,7 +268,7 @@ static void ConvertBrushFast( FILE *f, int bspBrushNum, const Vector3& origin, b const plane_t& buildPlane = mapplanes[ buildSide.planenum ]; /* dummy check */ - if ( buildSide.shaderInfo == NULL || buildSide.winding.empty() ) { + if ( buildSide.shaderInfo == nullptr || buildSide.winding.empty() ) { continue; } @@ -360,7 +360,7 @@ static void ConvertBrush( FILE *f, int bspBrushNum, const Vector3& origin, bool const plane_t& buildPlane = mapplanes[ buildSide.planenum ]; /* dummy check */ - if ( buildSide.shaderInfo == NULL || buildSide.winding.empty() ) { + if ( buildSide.shaderInfo == nullptr || buildSide.winding.empty() ) { continue; } diff --git a/tools/quake3/q3map2/decals.cpp b/tools/quake3/q3map2/decals.cpp index 2603579f..c353e24f 100644 --- a/tools/quake3/q3map2/decals.cpp +++ b/tools/quake3/q3map2/decals.cpp @@ -376,7 +376,7 @@ void ProcessDecals(){ } /* any patches? */ - if ( e.patches == NULL ) { + if ( e.patches == nullptr ) { Sys_Warning( "Decal entity without any patch meshes, ignoring.\n" ); e.epairs.clear(); continue; @@ -386,13 +386,13 @@ void ProcessDecals(){ e2 = FindTargetEntity( e.valueForKey( "target" ) ); /* no target? */ - if ( e2 == NULL ) { + if ( e2 == nullptr ) { Sys_Warning( "Decal entity without a valid target, ignoring.\n" ); continue; } /* walk entity patches */ - for ( parseMesh_t *p = e.patches; p != NULL; p = e.patches ) + for ( parseMesh_t *p = e.patches; p != nullptr; p = e.patches ) { /* setup projector */ Vector3 origin; @@ -589,7 +589,7 @@ static void ProjectDecalOntoWinding( decalProjector_t *dp, mapDrawSurface_t *ds, static void ProjectDecalOntoFace( decalProjector_t *dp, mapDrawSurface_t *ds ){ /* dummy check */ - if ( ds->sideRef == NULL || ds->sideRef->side == NULL ) { + if ( ds->sideRef == nullptr || ds->sideRef->side == nullptr ) { return; } @@ -677,7 +677,7 @@ static void ProjectDecalOntoPatch( decalProjector_t *dp, mapDrawSurface_t *ds ){ static void ProjectDecalOntoTriangles( decalProjector_t *dp, mapDrawSurface_t *ds ){ /* triangle surfaces without shaders don't get marks by default */ - if ( ds->type == ESurfaceType::Triangles && ds->shaderInfo->shaderText == NULL ) { + if ( ds->type == ESurfaceType::Triangles && ds->shaderInfo->shaderText == nullptr ) { return; } diff --git a/tools/quake3/q3map2/facebsp.cpp b/tools/quake3/q3map2/facebsp.cpp index 4a806125..ddaffb0f 100644 --- a/tools/quake3/q3map2/facebsp.cpp +++ b/tools/quake3/q3map2/facebsp.cpp @@ -61,7 +61,7 @@ static void SelectSplitPlaneNum( const node_t *node, const facelist_t& list, int } const float dist = blockSize[ i ] * ( floor( node->minmax.mins[ i ] / blockSize[ i ] ) + 1 ); if ( node->minmax.maxs[ i ] > dist ) { - *splitPlaneNum = FindFloatPlane( g_vector3_axes[i], dist, 0, NULL ); + *splitPlaneNum = FindFloatPlane( g_vector3_axes[i], dist, 0, nullptr ); return; } } diff --git a/tools/quake3/q3map2/fog.cpp b/tools/quake3/q3map2/fog.cpp index a702721a..6299533e 100644 --- a/tools/quake3/q3map2/fog.cpp +++ b/tools/quake3/q3map2/fog.cpp @@ -90,8 +90,8 @@ static void SplitMeshByPlane( mesh_t *in, const Plane3f& plane, mesh_t **front, } } - *front = NULL; - *back = NULL; + *front = nullptr; + *back = nullptr; if ( !c_front ) { *back = in; @@ -359,7 +359,7 @@ static bool ChopFaceSurfaceByBrush( const entity_t& e, mapDrawSurface_t *ds, con /* dummy check */ - if ( ds->sideRef == NULL || ds->sideRef->side == NULL ) { + if ( ds->sideRef == nullptr || ds->sideRef->side == nullptr ) { return false; } @@ -417,7 +417,7 @@ static bool ChopFaceSurfaceByBrush( const entity_t& e, mapDrawSurface_t *ds, con /* build a drawsurf for it */ newds = DrawSurfaceForSide( e, *ds->mapBrush, *s, w ); - if ( newds == NULL ) { + if ( newds == nullptr ) { return false; } @@ -470,7 +470,7 @@ void FogDrawSurfaces( const entity_t& e ){ } /* global fog doesn't have a brush */ - if ( fog.brush == NULL ) { + if ( fog.brush == nullptr ) { /* don't re-fog already fogged surfaces */ if ( ds->fogNum >= 0 ) { continue; @@ -545,7 +545,7 @@ int FogForPoint( const Vector3& point, float epsilon ){ for ( size_t i = 0; i < mapFogs.size(); ++i ) { /* sof2: global fog doesn't reference a brush */ - if ( mapFogs[ i ].brush == NULL ) { + if ( mapFogs[ i ].brush == nullptr ) { fogNum = i; continue; } @@ -591,7 +591,7 @@ int FogForBounds( const MinMax& minmax, float epsilon ){ for ( size_t i = 0; i < mapFogs.size(); ++i ) { /* sof2: global fog doesn't reference a brush */ - if ( mapFogs[ i ].brush == NULL ) { + if ( mapFogs[ i ].brush == nullptr ) { fogNum = i; continue; } @@ -683,10 +683,10 @@ void CreateMapFogs(){ /* set up fog */ fog_t& fog = mapFogs.emplace_back(); fog.si = ShaderInfoForShaderNull( globalFog ); - if ( fog.si == NULL ) { + if ( fog.si == nullptr ) { Error( "Invalid shader \"%s\" referenced trying to add global fog", globalFog ); } - fog.brush = NULL; + fog.brush = nullptr; fog.visibleSide = -1; /* set as default fog */ @@ -694,7 +694,7 @@ void CreateMapFogs(){ /* mark all worldspawn brushes as fogged */ for ( brush_t& brush : entities[ 0 ].brushes ) - ApplySurfaceParm( "fog", &brush.contentFlags, NULL, &brush.compileFlags ); + ApplySurfaceParm( "fog", &brush.contentFlags, nullptr, &brush.compileFlags ); } /* emit some stats */ diff --git a/tools/quake3/q3map2/image.cpp b/tools/quake3/q3map2/image.cpp index f0c06b1b..8779941d 100644 --- a/tools/quake3/q3map2/image.cpp +++ b/tools/quake3/q3map2/image.cpp @@ -53,7 +53,7 @@ static void LoadDDSBuffer( byte *buffer, int size, byte **pixels, int *width, in /* dummy check */ - if ( buffer == NULL || size <= 0 || pixels == NULL || width == NULL || height == NULL ) { + if ( buffer == nullptr || size <= 0 || pixels == nullptr || width == nullptr || height == nullptr ) { return; } @@ -126,7 +126,7 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in byte **rowPointers; /* dummy check */ - if ( buffer == NULL || size <= 0 || pixels == NULL || width == NULL || height == NULL ) { + if ( buffer == nullptr || size <= 0 || pixels == nullptr || width == nullptr || height == nullptr ) { return; } @@ -142,23 +142,23 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in } /* create png structs */ - png = png_create_read_struct( PNG_LIBPNG_VER_STRING, NULL, NULL, NULL ); - if ( png == NULL ) { + png = png_create_read_struct( PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr ); + if ( png == nullptr ) { Sys_Warning( "Unable to create PNG read struct\n" ); return; } info = png_create_info_struct( png ); - if ( info == NULL ) { + if ( info == nullptr ) { Sys_Warning( "Unable to create PNG info struct\n" ); - png_destroy_read_struct( &png, NULL, NULL ); + png_destroy_read_struct( &png, nullptr, nullptr ); return; } end = png_create_info_struct( png ); - if ( end == NULL ) { + if ( end == nullptr ) { Sys_Warning( "Unable to create PNG end info struct\n" ); - png_destroy_read_struct( &png, &info, NULL ); + png_destroy_read_struct( &png, &info, nullptr ); return; } @@ -183,7 +183,7 @@ static void LoadPNGBuffer( byte *buffer, int size, byte **pixels, int *width, in /* read image header chunk */ png_get_IHDR( png, info, - &w, &h, &bitDepth, &colorType, NULL, NULL, NULL ); + &w, &h, &bitDepth, &colorType, nullptr, nullptr, nullptr ); /* the following will probably bork on certain types of png images, but hey... */ @@ -243,7 +243,7 @@ static struct construct_default_image static const image_t *ImageFind( const char *name ){ /* dummy check */ if ( strEmptyOrNull( name ) ) { - return NULL; + return nullptr; } /* search list */ @@ -255,7 +255,7 @@ static const image_t *ImageFind( const char *name ){ } /* no matching image found */ - return NULL; + return nullptr; } diff --git a/tools/quake3/q3map2/leakfile.cpp b/tools/quake3/q3map2/leakfile.cpp index 0f5cf471..9f423120 100644 --- a/tools/quake3/q3map2/leakfile.cpp +++ b/tools/quake3/q3map2/leakfile.cpp @@ -63,7 +63,7 @@ static xmlNodePtr LeakFile( const tree_t& tree ){ xmlNodePtr xml_node, point; if ( !tree.outside_node.occupied ) { - return NULL; + return nullptr; } Sys_FPrintf( SYS_VRB, "--- LeakFile ---\n" ); @@ -74,7 +74,7 @@ static xmlNodePtr LeakFile( const tree_t& tree ){ const auto filename = StringStream( source, ".lin" ); linefile = SafeOpenWrite( filename, "wt" ); - xml_node = xmlNewNode( NULL, (const xmlChar*)"polyline" ); + xml_node = xmlNewNode( nullptr, (const xmlChar*)"polyline" ); count = 0; node = &tree.outside_node; @@ -123,7 +123,7 @@ void Leak_feedback( const tree_t& tree ){ Sys_FPrintf( SYS_NOXMLflag | SYS_ERR, "******* leaked *******\n" ); Sys_FPrintf( SYS_NOXMLflag | SYS_ERR, "**********************\n" ); xmlNodePtr polyline = LeakFile( tree ); - xmlNodePtr leaknode = xmlNewNode( NULL, (const xmlChar*)"message" ); + xmlNodePtr leaknode = xmlNewNode( nullptr, (const xmlChar*)"message" ); xmlNodeAddContent( leaknode, (const xmlChar*)"MAP LEAKED\n" ); xmlAddChild( leaknode, polyline ); char level[ 2 ]; diff --git a/tools/quake3/q3map2/light.cpp b/tools/quake3/q3map2/light.cpp index 0f05b661..051a8800 100644 --- a/tools/quake3/q3map2/light.cpp +++ b/tools/quake3/q3map2/light.cpp @@ -487,7 +487,7 @@ static void CreateEntityLights(){ if ( e.read_keyvalue( target, "target" ) ) { /* get target */ const entity_t *e2 = FindTargetEntity( target ); - if ( e2 == NULL ) { + if ( e2 == nullptr ) { Sys_Warning( "light at (%i %i %i) has missing target\n", (int) light.origin[ 0 ], (int) light.origin[ 1 ], (int) light.origin[ 2 ] ); light.photons *= pointScale; @@ -1189,7 +1189,7 @@ void LightingAtSample( trace_t *trace, byte styles[ MAX_LIGHTMAPS ], Vector3 (&c } /* ydnar: trace to all the list of lights pre-stored in tw */ - for ( i = 0; i < trace->numLights && trace->lights[ i ] != NULL; ++i ) + for ( i = 0; i < trace->numLights && trace->lights[ i ] != nullptr; ++i ) { /* set light */ trace->light = trace->lights[ i ]; @@ -1503,9 +1503,9 @@ static void TraceGrid( int num ){ trace.forceSunlight = false; trace.recvShadows = WORLDSPAWN_RECV_SHADOWS; trace.numSurfaces = 0; - trace.surfaces = NULL; + trace.surfaces = nullptr; trace.numLights = 0; - trace.lights = NULL; + trace.lights = nullptr; /* clear */ numCon = 0; @@ -1821,7 +1821,7 @@ static void WriteBSPFileAfterLight( const char *bspFileName ){ /* open shader file */ FILE *file = fopen( mapShaderFile.c_str(), "at" ); // append to existing file - if ( file == NULL ) { + if ( file == nullptr ) { Sys_Warning( "Unable to open map shader file %s for writing\n", mapShaderFile.c_str() ); return; } diff --git a/tools/quake3/q3map2/light_bounce.cpp b/tools/quake3/q3map2/light_bounce.cpp index 29df2953..242d3961 100644 --- a/tools/quake3/q3map2/light_bounce.cpp +++ b/tools/quake3/q3map2/light_bounce.cpp @@ -172,7 +172,7 @@ bool RadSampleImage( const byte *pixels, int width, int height, const Vector2& s color.set( 255 ); /* dummy check */ - if ( pixels == NULL || width < 1 || height < 1 ) { + if ( pixels == nullptr || width < 1 || height < 1 ) { return false; } @@ -223,7 +223,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, alpha = 0; /* dummy check */ - if ( rw == NULL || rw->numVerts < 3 ) { + if ( rw == nullptr || rw->numVerts < 3 ) { return; } @@ -231,7 +231,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, samples = 0; /* sample vertex colors if no lightmap or this is the initial pass */ - if ( lm == NULL || lm->radLuxels[ lightmapNum ] == NULL || !bouncing ) { + if ( lm == nullptr || lm->radLuxels[ lightmapNum ] == nullptr || !bouncing ) { for ( samples = 0; samples < rw->numVerts; ++samples ) { /* multiply by texture color */ @@ -366,7 +366,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw /* dummy check */ - if ( rw == NULL || rw->numVerts < 3 ) { + if ( rw == nullptr || rw->numVerts < 3 ) { return; } diff --git a/tools/quake3/q3map2/light_trace.cpp b/tools/quake3/q3map2/light_trace.cpp index d66bbccd..f296b09f 100644 --- a/tools/quake3/q3map2/light_trace.cpp +++ b/tools/quake3/q3map2/light_trace.cpp @@ -93,17 +93,17 @@ namespace int noDrawContentFlags, noDrawSurfaceFlags, noDrawCompileFlags; int numTraceInfos = 0, maxTraceInfos = 0, firstTraceInfo = 0; -traceInfo_t *traceInfos = NULL; +traceInfo_t *traceInfos = nullptr; int numTraceWindings = 0, maxTraceWindings = 0, deadWinding = -1; -traceWinding_t *traceWindings = NULL; +traceWinding_t *traceWindings = nullptr; int numTraceTriangles = 0, maxTraceTriangles = 0, deadTriangle = -1; -traceTriangle_t *traceTriangles = NULL; +traceTriangle_t *traceTriangles = nullptr; int headNodeNum = 0, skyboxNodeNum = 0, maxTraceDepth = 0, numTraceLeafNodes = 0; int numTraceNodes = 0, maxTraceNodes = 0; -traceNode_t *traceNodes = NULL; +traceNode_t *traceNodes = nullptr; } @@ -703,19 +703,19 @@ static void SubdivideTraceNode_r( int nodeNum, int depth ){ node->numItems = 0; node->maxItems = 0; free( node->items ); - node->items = NULL; + node->items = nullptr; /* check children */ if ( frontNode->numItems <= 0 ) { frontNode->maxItems = 0; free( frontNode->items ); - frontNode->items = NULL; + frontNode->items = nullptr; } if ( backNode->numItems <= 0 ) { backNode->maxItems = 0; free( backNode->items ); - backNode->items = NULL; + backNode->items = nullptr; } /* subdivide children */ @@ -830,7 +830,7 @@ static void PopulateWithBSPModel( const bspModel_t& model, const Matrix4& transf /* get surface and info */ const bspDrawSurface_t& ds = bspDrawSurfaces[ model.firstBSPSurface + i ]; const surfaceInfo_t& info = surfaceInfos[ model.firstBSPSurface + i ]; - if ( info.si == NULL ) { + if ( info.si == nullptr ) { continue; } @@ -1005,7 +1005,7 @@ static void PopulateWithPicoModel( int castShadows, const std::vectorgetShaderName() ); - if ( ti.si == NULL ) { + if ( ti.si == nullptr ) { continue; } @@ -1064,7 +1064,7 @@ static void PopulateTraceNodes(){ /* get shadow flags */ int castShadows = ENTITY_CAST_SHADOWS; - GetEntityShadowFlags( &e, NULL, &castShadows, NULL ); + GetEntityShadowFlags( &e, nullptr, &castShadows, nullptr ); /* early out? */ if ( !castShadows ) { @@ -1356,7 +1356,7 @@ static bool TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace /* most surfaces are completely opaque */ if ( !( si->compileFlags & ( C_ALPHASHADOW | C_LIGHTFILTER ) ) || - si->lightImage == NULL || si->lightImage->pixels == NULL ) { + si->lightImage == nullptr || si->lightImage->pixels == nullptr ) { trace->hit = trace->origin + trace->direction * depth; trace->color.set( 0 ); trace->opaque = true; diff --git a/tools/quake3/q3map2/light_ydnar.cpp b/tools/quake3/q3map2/light_ydnar.cpp index 66549d58..7178762d 100644 --- a/tools/quake3/q3map2/light_ydnar.cpp +++ b/tools/quake3/q3map2/light_ydnar.cpp @@ -488,7 +488,7 @@ static int ClusterForPointExtFilter( const Vector3& point, float epsilon, int nu cluster = ClusterForPointExt( point, epsilon ); /* check if filtering is necessary */ - if ( cluster < 0 || numClusters <= 0 || clusters == NULL ) { + if ( cluster < 0 || numClusters <= 0 || clusters == nullptr ) { return cluster; } @@ -709,16 +709,16 @@ static int MapSingleLuxel( rawLightmap_t *lm, const surfaceInfo_t *info, const b const int y = std::clamp( int( dv.lightmap[ 0 ][ 1 ] ), 0, lm->sh - 1 ); /* set shader and cluster list */ - if ( info != NULL ) { + if ( info != nullptr ) { si = info->si; numClusters = info->numSurfaceClusters; clusters = &surfaceClusters[ info->firstSurfaceCluster ]; } else { - si = NULL; + si = nullptr; numClusters = 0; - clusters = NULL; + clusters = nullptr; } /* get luxel, origin, cluster, and normal */ @@ -728,14 +728,14 @@ static int MapSingleLuxel( rawLightmap_t *lm, const surfaceInfo_t *info, const b int& cluster = lm->getSuperCluster( x, y ); /* don't attempt to remap occluded luxels for planar surfaces */ - if ( cluster == CLUSTER_OCCLUDED && lm->plane != NULL ) { + if ( cluster == CLUSTER_OCCLUDED && lm->plane != nullptr ) { return cluster; } /* only average the normal for premapped luxels */ else if ( cluster >= 0 ) { /* do bumpmap calculations */ - if ( stv != NULL ) { + if ( stv != nullptr ) { PerturbNormal( dv, si, pNormal, stv, ttv ); } else{ @@ -753,7 +753,7 @@ static int MapSingleLuxel( rawLightmap_t *lm, const surfaceInfo_t *info, const b /* get origin */ /* axial lightmap projection */ - if ( lm->vecs != NULL ) { + if ( lm->vecs != nullptr ) { /* calculate an origin for the sample from the lightmap vectors */ origin = lm->origin; for ( i = 0; i < 3; ++i ) @@ -779,7 +779,7 @@ static int MapSingleLuxel( rawLightmap_t *lm, const surfaceInfo_t *info, const b //1) Test the sample origin to see if it lays on the wrong side of any edge (x/y) //2) if it does, nudge it onto the correct side. - if ( worldverts != NULL && lightmapTriangleCheck ) { + if ( worldverts != nullptr && lightmapTriangleCheck ) { Plane3f hostplane; PlaneFromPoints( hostplane, worldverts[0], worldverts[1], worldverts[2] ); @@ -809,7 +809,7 @@ static int MapSingleLuxel( rawLightmap_t *lm, const surfaceInfo_t *info, const b //////////////////////// /* planar surfaces have precalculated lightmap vectors for nudging */ - if ( lm->plane != NULL ) { + if ( lm->plane != nullptr ) { vecs[ 0 ] = lm->vecs[ 0 ]; vecs[ 1 ] = lm->vecs[ 1 ]; vecs[ 2 ] = lm->plane->normal(); @@ -818,7 +818,7 @@ static int MapSingleLuxel( rawLightmap_t *lm, const surfaceInfo_t *info, const b /* non-planar surfaces must calculate them */ else { - if ( plane != NULL ) { + if ( plane != nullptr ) { vecs[ 2 ] = plane->normal(); } else{ @@ -828,7 +828,7 @@ static int MapSingleLuxel( rawLightmap_t *lm, const surfaceInfo_t *info, const b } /* push the origin off the surface a bit */ - if ( si != NULL ) { + if ( si != nullptr ) { lightmapSampleOffset = si->lightmapSampleOffset; } else{ @@ -876,7 +876,7 @@ static int MapSingleLuxel( rawLightmap_t *lm, const surfaceInfo_t *info, const b } /* as a last resort, if still in solid, try drawvert origin offset by normal (except in dark mode) */ - if ( pointCluster < 0 && si != NULL && !dark ) { + if ( pointCluster < 0 && si != nullptr && !dark ) { nudged = dv.xyz + dv.normal * lightmapSampleOffset; pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters ); if ( pointCluster >= 0 ) { @@ -987,7 +987,7 @@ static void MapTriangle_r( rawLightmap_t *lm, const surfaceInfo_t *info, const T static bool MapTriangle( rawLightmap_t *lm, const surfaceInfo_t *info, const TriRef& tri, bool mapNonAxial ){ Plane3f plane; /* get plane if possible */ - if ( lm->plane != NULL ) { + if ( lm->plane != nullptr ) { plane = *lm->plane; } /* otherwise make one from the points */ @@ -996,21 +996,21 @@ static bool MapTriangle( rawLightmap_t *lm, const surfaceInfo_t *info, const Tri } /* this must not happen in the first place, but it does and spreads result of division by zero in MapSingleLuxel all over the map during -bounce */ - if( lm->vecs != NULL && plane.normal()[lm->axisNum] == 0 ){ + if( lm->vecs != nullptr && plane.normal()[lm->axisNum] == 0 ){ Sys_Warning( "plane[lm->axisNum] == 0\n" ); return false; } Vector3 *stv, *ttv, stvStatic[ 3 ], ttvStatic[ 3 ]; /* check to see if we need to calculate texture->world tangent vectors */ - if ( info->si->normalImage != NULL && CalcTangentVectors( tri, stvStatic, ttvStatic ) ) { + if ( info->si->normalImage != nullptr && CalcTangentVectors( tri, stvStatic, ttvStatic ) ) { stv = stvStatic; ttv = ttvStatic; } else { - stv = NULL; - ttv = NULL; + stv = nullptr; + ttv = nullptr; } const Vector3 worldverts[ 3 ] = { tri[ 0 ]->xyz, tri[ 1 ]->xyz, tri[ 2 ]->xyz }; @@ -1085,8 +1085,8 @@ static void MapQuad_r( rawLightmap_t *lm, const surfaceInfo_t *info, const QuadR LerpDrawVert( *quad[ max + 2 ], *quad[ ( max + 3 ) % 4 ] ) }; /* map the vertexes */ - MapSingleLuxel( lm, info, mid[ 0 ], plane, 1, stv, ttv, NULL ); - MapSingleLuxel( lm, info, mid[ 1 ], plane, 1, stv, ttv, NULL ); + MapSingleLuxel( lm, info, mid[ 0 ], plane, 1, stv, ttv, nullptr ); + MapSingleLuxel( lm, info, mid[ 1 ], plane, 1, stv, ttv, nullptr ); /* 0 and 2 */ if ( max == 0 ) { @@ -1121,7 +1121,7 @@ static void MapQuad_r( rawLightmap_t *lm, const surfaceInfo_t *info, const QuadR static bool MapQuad( rawLightmap_t *lm, const surfaceInfo_t *info, const QuadRef& quad ){ Plane3f plane; /* get plane if possible */ - if ( lm->plane != NULL ) { + if ( lm->plane != nullptr ) { plane = *lm->plane; } /* otherwise make one from the points */ @@ -1136,21 +1136,21 @@ static bool MapQuad( rawLightmap_t *lm, const surfaceInfo_t *info, const QuadRef Vector3 *stv, *ttv, stvStatic[ 4 ], ttvStatic[ 4 ]; /* check to see if we need to calculate texture->world tangent vectors */ - if ( info->si->normalImage != NULL && CalcTangentVectors( quad, stvStatic, ttvStatic ) ) { + if ( info->si->normalImage != nullptr && CalcTangentVectors( quad, stvStatic, ttvStatic ) ) { stv = stvStatic; ttv = ttvStatic; } else { - stv = NULL; - ttv = NULL; + stv = nullptr; + ttv = nullptr; } /* map the vertexes */ - MapSingleLuxel( lm, info, *quad[ 0 ], &plane, 1, stv, ttv, NULL ); - MapSingleLuxel( lm, info, *quad[ 1 ], &plane, 1, stv, ttv, NULL ); - MapSingleLuxel( lm, info, *quad[ 2 ], &plane, 1, stv, ttv, NULL ); - MapSingleLuxel( lm, info, *quad[ 3 ], &plane, 1, stv, ttv, NULL ); + MapSingleLuxel( lm, info, *quad[ 0 ], &plane, 1, stv, ttv, nullptr ); + MapSingleLuxel( lm, info, *quad[ 1 ], &plane, 1, stv, ttv, nullptr ); + MapSingleLuxel( lm, info, *quad[ 2 ], &plane, 1, stv, ttv, nullptr ); + MapSingleLuxel( lm, info, *quad[ 3 ], &plane, 1, stv, ttv, nullptr ); /* subdivide the quad */ MapQuad_r( lm, info, quad, &plane, stv, ttv ); @@ -1374,7 +1374,7 @@ void MapRawLightmap( int rawLightmapNum ){ } /* non-planar surfaces stop here */ - if ( lm->plane == NULL ) { + if ( lm->plane == nullptr ) { return; } @@ -1440,7 +1440,7 @@ void MapRawLightmap( int rawLightmapNum ){ } /* map the fake vert */ - MapSingleLuxel( lm, NULL, fake, lm->plane, pass, NULL, NULL, NULL ); + MapSingleLuxel( lm, nullptr, fake, lm->plane, pass, nullptr, nullptr, nullptr ); } } } @@ -1576,7 +1576,7 @@ static float DirtForSample( trace_t *trace ){ if ( !dirty ) { return 1.0f; } - if ( trace == NULL || trace->cluster < 0 ) { + if ( trace == nullptr || trace->cluster < 0 ) { return 0.0f; } @@ -1975,7 +1975,7 @@ static void SubsampleRawLuxel_r( rawLightmap_t *lm, trace_t *trace, const Vector if ( cluster[ b ] < 0 ) { continue; } - SubsampleRawLuxel_r( lm, trace, origin[ b ], x, y, ( bias * 0.5f ), luxel[ b ], lightDeluxel ? &deluxel[ b ] : NULL ); + SubsampleRawLuxel_r( lm, trace, origin[ b ], x, y, ( bias * 0.5f ), luxel[ b ], lightDeluxel ? &deluxel[ b ] : nullptr ); } } @@ -2093,7 +2093,7 @@ static void CreateTraceLightsForBounds( const MinMax& minmax, const Vector3 *nor const float radius = vector3_length( minmax.maxs - origin ); /* get length of normal vector */ - if ( normal != NULL ) { + if ( normal != nullptr ) { length = vector3_length( *normal ); } else @@ -2125,7 +2125,7 @@ static void CreateTraceLightsForBounds( const MinMax& minmax, const Vector3 *nor } /* check against pvs cluster */ - if ( numClusters > 0 && clusters != NULL ) { + if ( numClusters > 0 && clusters != nullptr ) { for ( i = 0; i < numClusters; ++i ) { if ( ClusterVisible( light.cluster, clusters[ i ] ) ) { @@ -2175,7 +2175,7 @@ static void CreateTraceLightsForBounds( const MinMax& minmax, const Vector3 *nor } /* make last night null */ - trace->lights[ trace->numLights ] = NULL; + trace->lights[ trace->numLights ] = nullptr; } @@ -2267,7 +2267,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){ } /* create a culled light list for this raw lightmap */ - CreateTraceLightsForBounds( lm->minmax, ( lm->plane == NULL? NULL : &lm->plane->normal() ), lm->numLightClusters, lm->lightClusters, LightFlags::Surfaces, &trace ); + CreateTraceLightsForBounds( lm->minmax, ( lm->plane == nullptr? nullptr : &lm->plane->normal() ), lm->numLightClusters, lm->lightClusters, LightFlags::Surfaces, &trace ); /* ----------------------------------------------------------------- fill pass @@ -2347,7 +2347,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){ tmplm.superDeluxels = safe_malloc( ldSize ); } else{ - tmplm.superDeluxels = NULL; + tmplm.superDeluxels = nullptr; } /* clear luxels */ @@ -2384,7 +2384,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){ size = lm->sw * lm->sh * sizeof( *lm->superLuxels[0] ); for ( lightmapNum = 1; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { - if ( lm->superLuxels[ lightmapNum ] != NULL ) { + if ( lm->superLuxels[ lightmapNum ] != nullptr ) { memset( lm->superLuxels[ lightmapNum ], 0, size ); } } @@ -2433,7 +2433,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){ /* allocate sampling flags storage */ if ( lightSamples > 1 || lightRandomSamples ) { size = lm->sw * lm->sh * sizeof( *lm->superFlags ); - if ( lm->superFlags == NULL ) { + if ( lm->superFlags == nullptr ) { lm->superFlags = safe_malloc( size ); } memset( lm->superFlags, 0, size ); @@ -2569,10 +2569,10 @@ void IlluminateRawLightmap( int rawLightmapNum ){ /* subsample it */ if ( lightRandomSamples ) { - RandomSubsampleRawLuxel( lm, &trace, origin, sx, sy, 0.5f * lightSamplesSearchBoxSize, lightLuxel, deluxemap ? lightDeluxel : NULL ); + RandomSubsampleRawLuxel( lm, &trace, origin, sx, sy, 0.5f * lightSamplesSearchBoxSize, lightLuxel, deluxemap ? lightDeluxel : nullptr ); } else{ - SubsampleRawLuxel_r( lm, &trace, origin, sx, sy, 0.25f * lightSamplesSearchBoxSize, lightLuxel, deluxemap ? lightDeluxel : NULL ); + SubsampleRawLuxel_r( lm, &trace, origin, sx, sy, 0.25f * lightSamplesSearchBoxSize, lightLuxel, deluxemap ? lightDeluxel : nullptr ); } flag |= FLAG_ALREADY_SUBSAMPLED; @@ -2604,7 +2604,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){ } /* allocate sampling lightmap storage */ - if ( lm->superLuxels[ lightmapNum ] == NULL ) { + if ( lm->superLuxels[ lightmapNum ] == nullptr ) { /* allocate sampling lightmap storage */ size = lm->sw * lm->sh * sizeof( *lm->superLuxels[0] ); lm->superLuxels[ lightmapNum ] = safe_calloc( size ); @@ -2743,7 +2743,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){ for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { /* early out */ - if ( lm->superLuxels[ lightmapNum ] == NULL ) { + if ( lm->superLuxels[ lightmapNum ] == nullptr ) { continue; } @@ -2770,7 +2770,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){ for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { /* early out */ - if ( lm->superLuxels[ lightmapNum ] == NULL ) { + if ( lm->superLuxels[ lightmapNum ] == nullptr ) { continue; } @@ -2807,7 +2807,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){ for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { /* early out */ - if ( lm->superLuxels[ lightmapNum ] == NULL ) { + if ( lm->superLuxels[ lightmapNum ] == nullptr ) { continue; } @@ -2910,7 +2910,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){ for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { /* early out */ - if ( lm->superLuxels[ lightmapNum ] == NULL ) { + if ( lm->superLuxels[ lightmapNum ] == nullptr ) { continue; } for ( y = 0; y < lm->sh; ++y ) @@ -2977,9 +2977,9 @@ void IlluminateVertexes( int num ){ ----------------------------------------------------------------- */ /* calculate vertex lighting for surfaces without lightmaps */ - if ( lm == NULL || cpmaHack ) { + if ( lm == nullptr || cpmaHack ) { /* setup trace */ - trace.testOcclusion = ( cpmaHack && lm != NULL ) ? false : !noTrace; + trace.testOcclusion = ( cpmaHack && lm != nullptr ) ? false : !noTrace; trace.forceSunlight = info->si->forceSunlight; trace.recvShadows = info->recvShadows; trace.numSurfaces = 1; @@ -3225,7 +3225,7 @@ void IlluminateVertexes( int num ){ for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { /* early out */ - if ( lm->superLuxels[ lightmapNum ] == NULL ) { + if ( lm->superLuxels[ lightmapNum ] == nullptr ) { continue; } @@ -3359,7 +3359,7 @@ void SetupBrushesFlags( int mask_any, int test_any, int mask_all, int test_all ) /* get shader info */ const shaderInfo_t *si = ShaderInfoForShaderNull( bspShaders[ side.shaderNum ].shader ); - if ( si == NULL ) { + if ( si == nullptr ) { continue; } @@ -3772,7 +3772,7 @@ float FloodLightForSample( trace_t *trace, float floodLightDistance, bool floodL /* dummy check */ //if( !dirty ) // return 1.0f; - if ( trace == NULL || trace->cluster < 0 ) { + if ( trace == nullptr || trace->cluster < 0 ) { return 0.0f; } @@ -4031,7 +4031,7 @@ static void FloodlightIlluminateLightmap( rawLightmap_t *lm ){ for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { /* early out */ - if ( lm->superLuxels[ lightmapNum ] == NULL ) { + if ( lm->superLuxels[ lightmapNum ] == nullptr ) { continue; } diff --git a/tools/quake3/q3map2/lightmaps_ydnar.cpp b/tools/quake3/q3map2/lightmaps_ydnar.cpp index 77fd9e26..254133a4 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.cpp +++ b/tools/quake3/q3map2/lightmaps_ydnar.cpp @@ -224,11 +224,11 @@ int ImportLightmapsMain( Args& args ){ } /* parse file into an image */ - pixels = NULL; + pixels = nullptr; LoadTGABuffer( buffer.data(), buffer.size(), &pixels, &width, &height ); /* sanity check it */ - if ( pixels == NULL ) { + if ( pixels == nullptr ) { Sys_Warning( "Unable to load image %s\n", filename ); continue; } @@ -295,10 +295,10 @@ static void FinishRawLightmap( rawLightmap_t *lm ){ const shaderInfo_t *bsi = surfaceInfos[ b ].si; /* dummy check */ - if ( asi == NULL ) { + if ( asi == nullptr ) { return true; } - if ( bsi == NULL ) { + if ( bsi == nullptr ) { return false; } @@ -340,7 +340,7 @@ static void FinishRawLightmap( rawLightmap_t *lm ){ lm->sh = lm->h * superSample; /* manipulate origin/vecs for supersampling */ - if ( superSample > 1 && lm->vecs != NULL ) { + if ( superSample > 1 && lm->vecs != nullptr ) { /* calc inverse supersample */ is = 1.0f / superSample; @@ -361,7 +361,7 @@ static void FinishRawLightmap( rawLightmap_t *lm ){ /* allocate bsp lightmap storage */ size = lm->w * lm->h * sizeof( *( lm->bspLuxels[ 0 ] ) ); - if ( lm->bspLuxels[ 0 ] == NULL ) { + if ( lm->bspLuxels[ 0 ] == nullptr ) { lm->bspLuxels[ 0 ] = safe_malloc( size ); } memset( lm->bspLuxels[ 0 ], 0, size ); @@ -369,7 +369,7 @@ static void FinishRawLightmap( rawLightmap_t *lm ){ /* allocate radiosity lightmap storage */ if ( bounce ) { size = lm->w * lm->h * sizeof( *lm->radLuxels[ 0 ] ); - if ( lm->radLuxels[ 0 ] == NULL ) { + if ( lm->radLuxels[ 0 ] == nullptr ) { lm->radLuxels[ 0 ] = safe_malloc( size ); } memset( lm->radLuxels[ 0 ], 0, size ); @@ -377,42 +377,42 @@ static void FinishRawLightmap( rawLightmap_t *lm ){ /* allocate sampling lightmap storage */ size = lm->sw * lm->sh * sizeof( *lm->superLuxels[ 0 ] ); - if ( lm->superLuxels[ 0 ] == NULL ) { + if ( lm->superLuxels[ 0 ] == nullptr ) { lm->superLuxels[ 0 ] = safe_malloc( size ); } memset( lm->superLuxels[ 0 ], 0, size ); /* allocate origin map storage */ size = lm->sw * lm->sh * sizeof( *lm->superOrigins ); - if ( lm->superOrigins == NULL ) { + if ( lm->superOrigins == nullptr ) { lm->superOrigins = safe_malloc( size ); } memset( lm->superOrigins, 0, size ); /* allocate normal map storage */ size = lm->sw * lm->sh * sizeof( *lm->superNormals ); - if ( lm->superNormals == NULL ) { + if ( lm->superNormals == nullptr ) { lm->superNormals = safe_malloc( size ); } memset( lm->superNormals, 0, size ); /* allocate dirt map storage */ size = lm->sw * lm->sh * sizeof( *lm->superDirt ); - if ( lm->superDirt == NULL ) { + if ( lm->superDirt == nullptr ) { lm->superDirt = safe_malloc( size ); } memset( lm->superDirt, 0, size ); /* allocate floodlight map storage */ size = lm->sw * lm->sh * sizeof( *lm->superFloodLight ); - if ( lm->superFloodLight == NULL ) { + if ( lm->superFloodLight == nullptr ) { lm->superFloodLight = safe_malloc( size ); } memset( lm->superFloodLight, 0, size ); /* allocate cluster map storage */ size = lm->sw * lm->sh * sizeof( *lm->superClusters ); - if ( lm->superClusters == NULL ) { + if ( lm->superClusters == nullptr ) { lm->superClusters = safe_malloc( size ); } size = lm->sw * lm->sh; @@ -424,14 +424,14 @@ static void FinishRawLightmap( rawLightmap_t *lm ){ if ( deluxemap ) { /* allocate sampling deluxel storage */ size = lm->sw * lm->sh * sizeof( *lm->superDeluxels ); - if ( lm->superDeluxels == NULL ) { + if ( lm->superDeluxels == nullptr ) { lm->superDeluxels = safe_malloc( size ); } memset( lm->superDeluxels, 0, size ); /* allocate bsp deluxel storage */ size = lm->w * lm->h * sizeof( *lm->bspDeluxels ); - if ( lm->bspDeluxels == NULL ) { + if ( lm->bspDeluxels == nullptr ) { lm->bspDeluxels = safe_malloc( size ); } memset( lm->bspDeluxels, 0, size ); @@ -609,7 +609,7 @@ static bool AddSurfaceToRawLightmap( int num, rawLightmap_t *lm ){ /* plane check (fixme: allow merging of nonplanars) */ if ( !info->si->lmMergable ) { - if ( info->plane == NULL || lm->plane == NULL ) { + if ( info->plane == nullptr || lm->plane == nullptr ) { return false; } @@ -626,8 +626,8 @@ static bool AddSurfaceToRawLightmap( int num, rawLightmap_t *lm ){ } /* set plane */ - if ( info->plane == NULL ) { - lm->plane = NULL; + if ( info->plane == nullptr ) { + lm->plane = nullptr; } /* add surface to lightmap bounds */ @@ -689,7 +689,7 @@ static bool AddSurfaceToRawLightmap( int num, rawLightmap_t *lm ){ lm->actualSampleSize = sampleSize; /* fixme: copy rounded mins/maxes to lightmap record? */ - if ( lm->plane == NULL ) { + if ( lm->plane == nullptr ) { lm->minmax = { mins, maxs }; } @@ -800,19 +800,19 @@ static bool AddSurfaceToRawLightmap( int num, rawLightmap_t *lm ){ else { /* lightmap vectors are useless on a non-planar surface */ - lm->vecs = NULL; + lm->vecs = nullptr; } /* add to counts */ if ( ds->surfaceType == MST_PATCH ) { numPatchesLightmapped++; - if ( lm->plane != NULL ) { + if ( lm->plane != nullptr ) { numPlanarPatchesLightmapped++; } } else { - if ( lm->plane != NULL ) { + if ( lm->plane != nullptr ) { numPlanarsLightmapped++; } else{ @@ -883,13 +883,13 @@ struct CompareSurfaceInfo } /* then plane */ - if ( aInfo.plane == NULL && bInfo.plane != NULL ) { + if ( aInfo.plane == nullptr && bInfo.plane != nullptr ) { return false; } - else if ( aInfo.plane != NULL && bInfo.plane == NULL ) { + else if ( aInfo.plane != nullptr && bInfo.plane == nullptr ) { return true; } - else if ( aInfo.plane != NULL && bInfo.plane != NULL ) { + else if ( aInfo.plane != nullptr && bInfo.plane != nullptr ) { for ( int i = 0; i < 3; ++i ) { if ( aInfo.plane->normal()[ i ] < bInfo.plane->normal()[ i ] ) { @@ -985,14 +985,14 @@ void SetupSurfaceLightmaps(){ /* basic setup */ info->modelindex = i; - info->lm = NULL; - info->plane = NULL; + info->lm = nullptr; + info->plane = nullptr; info->firstSurfaceCluster = numSurfaceClusters; { /* get extra data */ const surfaceExtra_t& se = GetSurfaceExtra( num ); info->si = se.si; - if ( info->si == NULL ) { + if ( info->si == nullptr ) { info->si = &ShaderInfoForShader( bspShaders[ ds->shaderNum ].shader ); } info->parentSurfaceNum = se.parentSurfaceNum; @@ -1080,7 +1080,7 @@ void SetupSurfaceLightmaps(){ /* get info and attempt early out */ num = sortSurfaces[ i ]; info = &surfaceInfos[ num ]; - if ( !info->hasLightmap || info->lm != NULL || info->parentSurfaceNum >= 0 ) { + if ( !info->hasLightmap || info->lm != nullptr || info->parentSurfaceNum >= 0 ) { continue; } @@ -1130,7 +1130,7 @@ void SetupSurfaceLightmaps(){ /* get info and attempt early out */ num2 = sortSurfaces[ j ]; info2 = &surfaceInfos[ num2 ]; - if ( !info2->hasLightmap || info2->lm != NULL ) { + if ( !info2->hasLightmap || info2->lm != nullptr ) { continue; } @@ -1350,7 +1350,7 @@ static bool CompareBSPLuxels( rawLightmap_t *a, int aNum, rawLightmap_t *b, int if ( a->customWidth != b->customWidth || a->customHeight != b->customHeight || a->brightness != b->brightness || a->solid[ aNum ] != b->solid[ bNum ] || - a->bspLuxels[ aNum ] == NULL || b->bspLuxels[ bNum ] == NULL ) { + a->bspLuxels[ aNum ] == nullptr || b->bspLuxels[ bNum ] == nullptr ) { return false; } @@ -1427,7 +1427,7 @@ static bool MergeBSPLuxels( rawLightmap_t *a, int aNum, rawLightmap_t *b, int bN if ( a->customWidth != b->customWidth || a->customHeight != b->customHeight || a->brightness != b->brightness || a->solid[ aNum ] != b->solid[ bNum ] || - a->bspLuxels[ aNum ] == NULL || b->bspLuxels[ bNum ] == NULL ) { + a->bspLuxels[ aNum ] == nullptr || b->bspLuxels[ bNum ] == nullptr ) { return false; } @@ -1802,7 +1802,7 @@ static bool TestOutLightmapStamp( rawLightmap_t *lm, int lightmapNum, outLightma static void SetupOutLightmap( rawLightmap_t *lm, outLightmap_t *olm ){ /* dummy check */ - if ( lm == NULL || olm == NULL ) { + if ( lm == nullptr || olm == nullptr ) { return; } @@ -1872,13 +1872,13 @@ static void FindOutLightmaps( rawLightmap_t *lm, bool fastAllocate ){ } /* don't store twinned lightmaps */ - if ( lm->twins[ lightmapNum ] != NULL ) { + if ( lm->twins[ lightmapNum ] != nullptr ) { continue; } /* if this is a styled lightmap, try some normalized locations first */ ok = false; - if ( lightmapNum > 0 && outLightmaps != NULL ) { + if ( lightmapNum > 0 && outLightmaps != nullptr ) { /* loop twice */ for ( j = 0; j < 2; ++j ) { @@ -2030,7 +2030,7 @@ static void FindOutLightmaps( rawLightmap_t *lm, bool fastAllocate ){ numOutLightmaps += LIGHTMAP_RESERVE_COUNT; olm = safe_malloc( numOutLightmaps * sizeof( outLightmap_t ) ); - if ( outLightmaps != NULL && numOutLightmaps > LIGHTMAP_RESERVE_COUNT ) { + if ( outLightmaps != nullptr && numOutLightmaps > LIGHTMAP_RESERVE_COUNT ) { memcpy( olm, outLightmaps, ( numOutLightmaps - LIGHTMAP_RESERVE_COUNT ) * sizeof( outLightmap_t ) ); free( outLightmaps ); } @@ -2205,9 +2205,9 @@ static void FillOutLightmap( outLightmap_t *olm ){ int x, y; int ofs; int cnt, filled; - byte *lightBitsNew = NULL; - Vector3b *lightBytesNew = NULL; - Vector3b *dirBytesNew = NULL; + byte *lightBitsNew = nullptr; + Vector3b *lightBytesNew = nullptr; + Vector3b *dirBytesNew = nullptr; const size_t size = olm->customWidth * olm->customHeight * sizeof( Vector3b ); lightBitsNew = safe_malloc( ( olm->customWidth * olm->customHeight + 8 ) / 8 ); @@ -2372,12 +2372,12 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { /* early outs */ - if ( lm->superLuxels[ lightmapNum ] == NULL ) { + if ( lm->superLuxels[ lightmapNum ] == nullptr ) { continue; } /* allocate bsp luxel storage */ - if ( lm->bspLuxels[ lightmapNum ] == NULL ) { + if ( lm->bspLuxels[ lightmapNum ] == nullptr ) { const size_t size = lm->w * lm->h * sizeof( *( lm->bspLuxels[ 0 ] ) ); lm->bspLuxels[ lightmapNum ] = safe_calloc( size ); } @@ -2385,7 +2385,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ /* allocate radiosity lightmap storage */ if ( bounce ) { const size_t size = lm->w * lm->h * sizeof( *lm->radLuxels[ 0 ] ); - if ( lm->radLuxels[ lightmapNum ] == NULL ) { + if ( lm->radLuxels[ lightmapNum ] == nullptr ) { lm->radLuxels[ lightmapNum ] = safe_malloc( size ); } memset( lm->radLuxels[ lightmapNum ], 0, size ); @@ -2767,7 +2767,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { /* early outs */ - if ( lm->superLuxels[ lightmapNum ] == NULL ) { + if ( lm->superLuxels[ lightmapNum ] == nullptr ) { continue; } @@ -2807,7 +2807,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ { for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { - rawLightmaps[ i ].twins[ lightmapNum ] = NULL; + rawLightmaps[ i ].twins[ lightmapNum ] = nullptr; rawLightmaps[ i ].twinNums[ lightmapNum ] = -1; rawLightmaps[ i ].numStyledTwins = 0; } @@ -2823,8 +2823,8 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { /* early outs */ - if ( lm->bspLuxels[ lightmapNum ] == NULL || - lm->twins[ lightmapNum ] != NULL ) { + if ( lm->bspLuxels[ lightmapNum ] == nullptr || + lm->twins[ lightmapNum ] != nullptr ) { continue; } @@ -2838,8 +2838,8 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ for ( lightmapNum2 = 0; lightmapNum2 < MAX_LIGHTMAPS; ++lightmapNum2 ) { /* early outs */ - if ( lm2->bspLuxels[ lightmapNum2 ] == NULL || - lm2->twins[ lightmapNum2 ] != NULL ) { + if ( lm2->bspLuxels[ lightmapNum2 ] == nullptr || + lm2->twins[ lightmapNum2 ] != nullptr ) { continue; } @@ -2877,7 +2877,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ timer.start(); /* allocate a new sorted list */ - if ( sortLightmaps == NULL ) { + if ( sortLightmaps == nullptr ) { sortLightmaps = safe_malloc( numRawLightmaps * sizeof( int ) ); } @@ -2900,14 +2900,14 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ timer.start(); /* kill all existing output lightmaps */ - if ( outLightmaps != NULL ) { + if ( outLightmaps != nullptr ) { for ( i = 0; i < numOutLightmaps; ++i ) { free( outLightmaps[ i ].lightBits ); free( outLightmaps[ i ].bspLightBytes ); } free( outLightmaps ); - outLightmaps = NULL; + outLightmaps = nullptr; } numLightmapShaders = 0; @@ -2933,7 +2933,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ { /* get twin */ lm2 = lm->twins[ lightmapNum ]; - if ( lm2 == NULL ) { + if ( lm2 == nullptr ) { continue; } lightmapNum2 = lm->twinNums[ lightmapNum ]; @@ -3064,7 +3064,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ ds = &bspDrawSurfaces[ i ]; info = &surfaceInfos[ i ]; lm = info->lm; - olm = NULL; + olm = nullptr; /* handle surfaces with identical parent */ if ( info->parentSurfaceNum >= 0 ) { @@ -3095,7 +3095,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ } /* handle vertex lit or approximated surfaces */ - else if ( lm == NULL || lm->outLightmapNums[ 0 ] < 0 ) { + else if ( lm == nullptr || lm->outLightmapNums[ 0 ] < 0 ) { for ( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; ++lightmapNum ) { ds->lightmapNum[ lightmapNum ] = -3; @@ -3183,7 +3183,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ } /* surfaces with styled lightmaps and a style marker get a custom generated shader (fixme: make this work with external lightmaps) */ - if ( olm != NULL && lm != NULL && lm->styles[ 1 ] != LS_NONE && g_game->load != LoadRBSPFile ) { //% info->si->styleMarker > 0 ) + if ( olm != nullptr && lm != nullptr && lm->styles[ 1 ] != LS_NONE && g_game->load != LoadRBSPFile ) { //% info->si->styleMarker > 0 ) char key[ 32 ], styleStage[ 512 ], styleStages[ 4096 ], rgbGen[ 128 ], alphaGen[ 128 ]; @@ -3215,7 +3215,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ } /* get rgbgen string */ - if ( rgbGenValues[ style ] == NULL ) { + if ( rgbGenValues[ style ] == nullptr ) { sprintf( key, "_style%drgbgen", style ); rgbGenValues[ style ] = entities[ 0 ].valueForKey( key ); if ( strEmpty( rgbGenValues[ style ] ) ) { @@ -3231,7 +3231,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ } /* get alphagen string */ - if ( alphaGenValues[ style ] == NULL ) { + if ( alphaGenValues[ style ] == nullptr ) { sprintf( key, "_style%dalphagen", style ); alphaGenValues[ style ] = entities[ 0 ].valueForKey( key ); } @@ -3298,7 +3298,7 @@ void StoreSurfaceLightmaps( bool fastAllocate, bool storeForReal ){ } /* devise a custom shader for this surface (fixme: make this work with light styles) */ - else if ( olm != NULL && lm != NULL && !externalLightmaps && + else if ( olm != nullptr && lm != nullptr && !externalLightmaps && ( olm->customWidth != g_game->lightmapSize || olm->customHeight != g_game->lightmapSize ) ) { /* get output lightmap */ olm = &outLightmaps[ lm->outLightmapNums[ 0 ] ]; diff --git a/tools/quake3/q3map2/map.cpp b/tools/quake3/q3map2/map.cpp index 819d9732..b06a3928 100644 --- a/tools/quake3/q3map2/map.cpp +++ b/tools/quake3/q3map2/map.cpp @@ -474,7 +474,7 @@ static void SetBrushContents( brush_t& b ){ /* get the content/compile flags for every side in the brush */ for ( ++s; s != b.sides.cend(); ++s ) { - if ( s->shaderInfo == NULL ) { + if ( s->shaderInfo == nullptr ) { continue; } //% if( s->contentFlags != contentFlags || s->compileFlags != compileFlags ) @@ -627,7 +627,7 @@ void AddBrushBevels(){ } } - s.planenum = FindFloatPlane( plane, 0, NULL ); + s.planenum = FindFloatPlane( plane, 0, nullptr ); s.contentFlags = sides[ 0 ].contentFlags; /* handle bevel surfaceflags */ for ( const side_t& side : sides ) { @@ -839,8 +839,8 @@ static void FinishBrush( bool noCollapseGroups, entity_t& mapEnt ){ b.original = &b; /* link colorMod volume brushes to the entity directly */ - if ( b.contentShader != NULL && - b.contentShader->colorMod != NULL && + if ( b.contentShader != nullptr && + b.contentShader->colorMod != nullptr && b.contentShader->colorMod->type == EColorMod::Volume ) { mapEnt.colorModBrushes.push_back( &b ); } @@ -1232,7 +1232,7 @@ static void AdjustBrushesForOrigin( entity_t& ent ){ const float newdist = -plane3_distance_to_point( mapplanes[ side.planenum ].plane, ent.originbrush_origin ); /* find a new plane */ - side.planenum = FindFloatPlane( mapplanes[ side.planenum ].normal(), newdist, 0, NULL ); + side.planenum = FindFloatPlane( mapplanes[ side.planenum ].normal(), newdist, 0, nullptr ); side.plane.dist() = -plane3_distance_to_point( side.plane, ent.originbrush_origin ); } @@ -1241,7 +1241,7 @@ static void AdjustBrushesForOrigin( entity_t& ent ){ } /* walk patch list */ - for ( parseMesh_t *p = ent.patches; p != NULL; p = p->next ) + for ( parseMesh_t *p = ent.patches; p != nullptr; p = p->next ) { for ( bspDrawVert_t& vert : Span( p->mesh.verts, p->mesh.width * p->mesh.height ) ) vert.xyz -= ent.originbrush_origin; @@ -1286,14 +1286,14 @@ static void MoveBrushesToWorld( entity_t& ent ){ } /* move patches */ - if ( ent.patches != NULL ) { + if ( ent.patches != nullptr ) { parseMesh_t *pm; - for ( pm = ent.patches; pm->next != NULL; pm = pm->next ){}; + for ( pm = ent.patches; pm->next != nullptr; pm = pm->next ){}; pm->next = entities[ 0 ].patches; entities[ 0 ].patches = ent.patches; - ent.patches = NULL; + ent.patches = nullptr; } } @@ -1347,7 +1347,7 @@ static void LoadEntityIndexMap( entity_t& e ){ /* this only works with bmodel ents */ - if ( e.brushes.empty() && e.patches == NULL ) { + if ( e.brushes.empty() && e.patches == nullptr ) { return; } @@ -1400,7 +1400,7 @@ static void LoadEntityIndexMap( entity_t& e ){ else { /* load it */ - Load256Image( indexMapFilename, &pixels, NULL, &w, &h ); + Load256Image( indexMapFilename, &pixels, nullptr, &w, &h ); /* debug code */ //% Sys_Printf( "-------------------------------" ); @@ -1450,11 +1450,11 @@ static void LoadEntityIndexMap( entity_t& e ){ for ( int i = 0; i < 256 && !strEmpty( offset ); ++i ) { const char *space = strchr( offset, ' ' ); - if ( space == NULL ) { + if ( space == nullptr ) { space = offset + strlen( offset ); } im->offsets[ i ] = atof( String64( StringRange( offset, space ) ) ); - if ( space == NULL ) { + if ( space == nullptr ) { break; } offset = space + 1; @@ -1464,7 +1464,7 @@ static void LoadEntityIndexMap( entity_t& e ){ /* store the index map in every brush/patch in the entity */ for ( brush_t& b : e.brushes ) b.im = im; - for ( parseMesh_t *p = e.patches; p != NULL; p = p->next ) + for ( parseMesh_t *p = e.patches; p != nullptr; p = p->next ) p->im = im; } @@ -1577,7 +1577,7 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups, int mapEntit } /* get explicit shadow flags */ - GetEntityShadowFlags( &mapEnt, NULL, &castShadows, &recvShadows ); + GetEntityShadowFlags( &mapEnt, nullptr, &castShadows, &recvShadows ); /* ydnar: get lightmap scaling value for this entity */ const float lightmapScale = std::max( 0.f, mapEnt.floatForKey( "lightmapscale", "_lightmapscale", "_ls" ) ); @@ -1619,7 +1619,7 @@ static bool ParseMapEntity( bool onlyLights, bool noCollapseGroups, int mapEntit brush.shadeAngleDegrees = shadeAngle; } - for ( parseMesh_t *patch = mapEnt.patches; patch != NULL; patch = patch->next ) + for ( parseMesh_t *patch = mapEnt.patches; patch != nullptr; patch = patch->next ) { patch->entityNum = mapEnt.mapEntityNum; patch->castShadows = castShadows; diff --git a/tools/quake3/q3map2/minimap.cpp b/tools/quake3/q3map2/minimap.cpp index 2c3c3f50..56cedaaa 100644 --- a/tools/quake3/q3map2/minimap.cpp +++ b/tools/quake3/q3map2/minimap.cpp @@ -482,7 +482,7 @@ int MiniMapBSPMain( Args& args ){ autolevel = false; minimap.samples = 1; - minimap.sample_offsets = NULL; + minimap.sample_offsets = nullptr; minimap.boost = 1.0; minimap.brightness = 0.0; minimap.contrast = 1.0; @@ -508,7 +508,7 @@ int MiniMapBSPMain( Args& args ){ minimap.samples = atoi( args.takeNext() ); Sys_Printf( "Random samples set to %i\n", minimap.samples ); free( minimap.sample_offsets ); - minimap.sample_offsets = NULL; + minimap.sample_offsets = nullptr; } while( args.takeArg( "-border" ) ) { border = atof( args.takeNext() ); diff --git a/tools/quake3/q3map2/model.cpp b/tools/quake3/q3map2/model.cpp index 0d74c532..a68bd5f1 100644 --- a/tools/quake3/q3map2/model.cpp +++ b/tools/quake3/q3map2/model.cpp @@ -405,7 +405,7 @@ static void make_brush_sides( const Plane3f plane, const Plane3f (&p)[3], const buildBrush.sides[0].shaderInfo = &si; buildBrush.sides[0].surfaceFlags = si.surfaceFlags; for ( size_t i = 1; i < N; ++i ) - buildBrush.sides[i].shaderInfo = NULL; // don't emit these faces as draw surfaces, should make smaller BSPs; hope this works + buildBrush.sides[i].shaderInfo = nullptr; // don't emit these faces as draw surfaces, should make smaller BSPs; hope this works } points[3] = points[0]; // for cyclic usage @@ -415,7 +415,7 @@ static void make_brush_sides( const Plane3f plane, const Plane3f (&p)[3], const buildBrush.sides[2].planenum = FindFloatPlane( p[1], 2, &points[1] ); // p[1] contains points[1] and points[2] buildBrush.sides[3].planenum = FindFloatPlane( p[2], 2, &points[2] ); // p[2] contains points[2] and points[0] (copied to points[3]) if constexpr( N == 5 ) - buildBrush.sides[4].planenum = FindFloatPlane( reverse, 0, NULL ); + buildBrush.sides[4].planenum = FindFloatPlane( reverse, 0, nullptr ); } static void ClipModel( int spawnFlags, float clipDepth, shaderInfo_t& si, const mapDrawSurface_t *ds, const char *modelName, entity_t& entity ){ @@ -960,7 +960,7 @@ default_CLIPMODEL: /* add to entity */ if ( CreateBrushWindings( buildBrush ) ) { AddBrushBevels(); - //% EmitBrushes( buildBrush, NULL, NULL ); + //% EmitBrushes( buildBrush, nullptr, nullptr ); brush_t& newBrush = entity.brushes.emplace_front( buildBrush ); newBrush.original = &newBrush; entity.numBrushes++; @@ -994,7 +994,7 @@ void InsertModel( const char *name, const char *skin, int frame, const Matrix4& /* get model */ model = LoadModel( name, frame ); - if ( model == NULL ) { + if ( model == nullptr ) { return; } @@ -1017,7 +1017,7 @@ void InsertModel( const char *name, const char *skin, int frame, const Matrix4& char format[64]; skinfilenextptr = strchr( skinfileptr, '\r' ); - if ( skinfilenextptr != NULL ) { + if ( skinfilenextptr != nullptr ) { strClear( skinfilenextptr++ ); if( *skinfilenextptr == '\n' ) // handle \r\n ++skinfilenextptr; @@ -1025,7 +1025,7 @@ void InsertModel( const char *name, const char *skin, int frame, const Matrix4& else { skinfilenextptr = strchr( skinfileptr, '\n' ); - if ( skinfilenextptr != NULL ) { + if ( skinfilenextptr != nullptr ) { strClear( skinfilenextptr++ ); } else{ @@ -1080,7 +1080,7 @@ void InsertModel( const char *name, const char *skin, int frame, const Matrix4& /* handle .skin file */ if ( !skins.empty() ) { - picoShaderName = NULL; + picoShaderName = nullptr; for( const auto& skin : skins ) { if ( striEqual( surface.m_shader.c_str(), skin.from ) ) { @@ -1089,15 +1089,15 @@ void InsertModel( const char *name, const char *skin, int frame, const Matrix4& break; } } - if ( picoShaderName == NULL ) { + if ( picoShaderName == nullptr ) { Sys_FPrintf( SYS_VRB, "Skin file: not mapping %s\n", surface.m_shader.c_str() ); continue; } } /* handle shader remapping */ - if( remaps != NULL ){ - const char* to = NULL; + if( remaps != nullptr ){ + const char* to = nullptr; size_t fromlen = 0; for( const auto& rm : *remaps ) { @@ -1109,7 +1109,7 @@ void InsertModel( const char *name, const char *skin, int frame, const Matrix4& fromlen = strlen( rm.from ); } } - if( to != NULL ){ + if( to != nullptr ){ Sys_FPrintf( SYS_VRB, ( fromlen == 0? "Globbing '%s' to '%s'\n" : "Remapping '%s' to '%s'\n" ), picoShaderName, to ); picoShaderName = to; } @@ -1331,7 +1331,7 @@ void AddTriangleModels( entity_t& eparent ){ /* split the string */ char *split = strchr( remap.from, ';' ); - if ( split == NULL ) { + if ( split == nullptr ) { Sys_Warning( "Shader _remap key found in misc_model without a ; character: '%s'\n", remap.from ); continue; } diff --git a/tools/quake3/q3map2/patch.cpp b/tools/quake3/q3map2/patch.cpp index 52deb025..184e4a97 100644 --- a/tools/quake3/q3map2/patch.cpp +++ b/tools/quake3/q3map2/patch.cpp @@ -441,7 +441,7 @@ void PatchMapDrawSurfs( entity_t& e ){ //% Sys_Printf( "Longest curve: %f Iterations: %d\n", mesh.mesh.longestCurve, mesh.mesh.maxIterations ); /* create drawsurf */ - mapDrawSurface_t *ds = DrawSurfaceForMesh( e, &mesh.mesh, NULL ); /* ydnar */ + mapDrawSurface_t *ds = DrawSurfaceForMesh( e, &mesh.mesh, nullptr ); /* ydnar */ ds->bounds = bounds; } diff --git a/tools/quake3/q3map2/path_init.cpp b/tools/quake3/q3map2/path_init.cpp index 3e2aa191..d1ab7b73 100644 --- a/tools/quake3/q3map2/path_init.cpp +++ b/tools/quake3/q3map2/path_init.cpp @@ -56,7 +56,7 @@ static CopiedString LokiGetHomeDir(){ const char *home = getenv( "HOME" ); /* look up home dir in password database */ - if( home == NULL ) + if( home == nullptr ) { struct passwd pw, *pwp; char buf[ 4096 ]; @@ -96,7 +96,7 @@ static void LokiInitPaths( const char *argv0, CopiedString& homePath, CopiedStri auto temp = StringStream( argv0 ); /* do some path divining */ - if ( strEmpty( path_get_last_separator( temp ) ) && path != NULL ) { + if ( strEmpty( path_get_last_separator( temp ) ) && path != nullptr ) { /* This code has a special behavior when q3map2 is a symbolic link. @@ -127,7 +127,7 @@ static void LokiInitPaths( const char *argv0, CopiedString& homePath, CopiedStri /* find next chunk */ last = strchr( path, ':' ); - if ( last == NULL ) { + if ( last == nullptr ) { last = path + strlen( path ); } @@ -177,7 +177,7 @@ static void LokiInitPaths( const char *argv0, CopiedString& homePath, CopiedStri const game_t *GetGame( const char *arg ){ /* dummy check */ if ( strEmptyOrNull( arg ) ) { - return NULL; + return nullptr; } /* joke */ @@ -202,7 +202,7 @@ const game_t *GetGame( const char *arg ){ /* no matching game */ Sys_Warning( "Game \"%s\" is unknown.\n", arg ); HelpGames(); - return NULL; + return nullptr; } @@ -314,7 +314,7 @@ void InitPaths( Args& args ){ /* -game */ while ( args.takeArg( "-game" ) ) { g_game = GetGame( args.takeNext() ); - if ( g_game == NULL ) { + if ( g_game == nullptr ) { g_game = &g_games[ 0 ]; } } diff --git a/tools/quake3/q3map2/portals.cpp b/tools/quake3/q3map2/portals.cpp index 3b329c0a..6defab7b 100644 --- a/tools/quake3/q3map2/portals.cpp +++ b/tools/quake3/q3map2/portals.cpp @@ -158,7 +158,7 @@ static void MakeHeadnodePortals( tree_t& tree ){ tree.outside_node.planenum = PLANENUM_LEAF; tree.outside_node.brushlist.clear(); - tree.outside_node.portals = NULL; + tree.outside_node.portals = nullptr; tree.outside_node.opaque = false; for ( int i = 0; i < 3; ++i ) @@ -385,7 +385,7 @@ static void SplitNodePortals( node_t *node ){ } } - node->portals = NULL; + node->portals = nullptr; } @@ -554,7 +554,7 @@ EFloodEntities FloodEntities( tree_t& tree ){ } #endif /* also allow bmodel entities outside, as they could be on a moving path that will go into the map */ - if ( !e.brushes.empty() || e.patches != NULL || e.classname_is( "_decal" ) ) { //_decal primitive is freed at this point + if ( !e.brushes.empty() || e.patches != nullptr || e.classname_is( "_decal" ) ) { //_decal primitive is freed at this point continue; } diff --git a/tools/quake3/q3map2/shaders.cpp b/tools/quake3/q3map2/shaders.cpp index 9cfc4d42..5dadb4c1 100644 --- a/tools/quake3/q3map2/shaders.cpp +++ b/tools/quake3/q3map2/shaders.cpp @@ -47,7 +47,7 @@ static int numCustSurfaceParms; void ColorMod( const colorMod_t *colormod, int numVerts, bspDrawVert_t *drawVerts ){ /* dummy check */ - if ( colormod == NULL || numVerts < 1 || drawVerts == NULL ) { + if ( colormod == nullptr || numVerts < 1 || drawVerts == nullptr ) { return; } @@ -56,7 +56,7 @@ void ColorMod( const colorMod_t *colormod, int numVerts, bspDrawVert_t *drawVert for ( bspDrawVert_t& dv : Span( drawVerts, numVerts ) ) { /* walk colorMod list */ - for ( const colorMod_t *cm = colormod; cm != NULL; cm = cm->next ) + for ( const colorMod_t *cm = colormod; cm != nullptr; cm = cm->next ) { float c; /* default */ @@ -301,7 +301,7 @@ void WriteMapShaderFile(){ /* open shader file */ FILE *file = fopen( mapShaderFile.c_str(), "wt" ); - if ( file == NULL ) { + if ( file == nullptr ) { Sys_Warning( "Unable to open map shader file %s for writing\n", mapShaderFile.c_str() ); return; } @@ -352,7 +352,7 @@ const shaderInfo_t& CustomShader( const shaderInfo_t *si, const char *find, char /* dummy check */ - if ( si == NULL ) { + if ( si == nullptr ) { return ShaderInfoForShader( "default" ); } @@ -427,7 +427,7 @@ const shaderInfo_t& CustomShader( const shaderInfo_t *si, const char *find, char } /* default shader text */ - else if ( srcShaderText == NULL ) { + else if ( srcShaderText == nullptr ) { srcShaderText = temp; sprintf( temp, "\n" "{ // Q3Map2 defaulted\n" @@ -651,22 +651,22 @@ static void LoadShaderImages( shaderInfo_t& si ){ si.shaderImage = ImageLoad( si.editorImagePath ); /* then try shadername */ - if ( si.shaderImage == NULL ) { + if ( si.shaderImage == nullptr ) { si.shaderImage = ImageLoad( si.shader ); } /* then try implicit image path (note: new behavior!) */ - if ( si.shaderImage == NULL ) { + if ( si.shaderImage == nullptr ) { si.shaderImage = ImageLoad( si.implicitImagePath ); } /* then try lightimage (note: new behavior!) */ - if ( si.shaderImage == NULL ) { + if ( si.shaderImage == nullptr ) { si.shaderImage = ImageLoad( si.lightImagePath ); } /* otherwise, use default image */ - if ( si.shaderImage == NULL ) { + if ( si.shaderImage == nullptr ) { si.shaderImage = ImageLoad( DEFAULT_IMAGE ); if ( g_warnImage && !strEqual( si.shader, "noshader" ) ) { Sys_Warning( "Couldn't find image for shader %s\n", si.shader.c_str() ); @@ -678,14 +678,14 @@ static void LoadShaderImages( shaderInfo_t& si ){ /* load normalmap image (ok if this is NULL) */ si.normalImage = ImageLoad( si.normalImagePath ); - if ( si.normalImage != NULL ) { + if ( si.normalImage != nullptr ) { Sys_FPrintf( SYS_VRB, "Shader %s has\n" " NM %s\n", si.shader.c_str(), si.normalImagePath.c_str() ); } } /* if no light image, reuse shader image */ - if ( si.lightImage == NULL ) { + if ( si.lightImage == nullptr ) { si.lightImage = si.shaderImage; } @@ -723,7 +723,7 @@ static void LoadShaderImages( shaderInfo_t& si ){ shaderInfo_t *ShaderInfoForShaderNull( const char *shaderName ){ if ( strEqual( shaderName, "noshader" ) ) { - return NULL; + return nullptr; } return &ShaderInfoForShader( shaderName ); } @@ -1494,14 +1494,14 @@ static void ParseShaderFile( const char *filename ){ cm = safe_calloc( sizeof( *cm ) ); /* attach to shader */ - if ( si.colorMod == NULL ) { + if ( si.colorMod == nullptr ) { si.colorMod = cm; } else { - for ( cm2 = si.colorMod; cm2 != NULL; cm2 = cm2->next ) + for ( cm2 = si.colorMod; cm2 != nullptr; cm2 = cm2->next ) { - if ( cm2->next == NULL ) { + if ( cm2->next == nullptr ) { cm2->next = cm; break; } diff --git a/tools/quake3/q3map2/surface.cpp b/tools/quake3/q3map2/surface.cpp index 100152f5..a23fc711 100644 --- a/tools/quake3/q3map2/surface.cpp +++ b/tools/quake3/q3map2/surface.cpp @@ -70,12 +70,12 @@ static void FinishSurface( mapDrawSurface_t *ds ){ /* dummy check */ - if ( ds == NULL || ds->shaderInfo == NULL ) { + if ( ds == nullptr || ds->shaderInfo == nullptr ) { return; } /* ydnar: rocking tek-fu celshading */ - if ( ds->celShader != NULL ) { + if ( ds->celShader != nullptr ) { MakeCelSurface( ds, ds->celShader ); } @@ -108,21 +108,21 @@ mapDrawSurface_t *CloneSurface( mapDrawSurface_t *src, shaderInfo_t *si ){ /* dummy check */ - if ( src == NULL || si == NULL ) { - return NULL; + if ( src == nullptr || si == nullptr ) { + return nullptr; } /* allocate a new surface */ ds = AllocDrawSurface( src->type ); - if ( ds == NULL ) { - return NULL; + if ( ds == nullptr ) { + return nullptr; } /* copy it */ memcpy( ds, src, sizeof( *ds ) ); /* destroy side reference */ - ds->sideRef = NULL; + ds->sideRef = nullptr; /* set shader */ ds->shaderInfo = si; @@ -152,26 +152,26 @@ mapDrawSurface_t *CloneSurface( mapDrawSurface_t *src, shaderInfo_t *si ){ static mapDrawSurface_t *MakeCelSurface( mapDrawSurface_t *src, shaderInfo_t *si ){ /* dummy check */ - if ( src == NULL || si == NULL ) { - return NULL; + if ( src == nullptr || si == nullptr ) { + return nullptr; } /* don't create cel surfaces for certain types of shaders */ if ( ( src->shaderInfo->compileFlags & C_TRANSLUCENT ) || ( src->shaderInfo->compileFlags & C_SKY ) ) { - return NULL; + return nullptr; } /* make a copy */ mapDrawSurface_t *ds = CloneSurface( src, si ); - if ( ds == NULL ) { - return NULL; + if ( ds == nullptr ) { + return nullptr; } /* do some fixups for celshading */ ds->planar = false; ds->planeNum = -1; - ds->celShader = NULL; /* don't cel shade cels :P */ + ds->celShader = nullptr; /* don't cel shade cels :P */ /* return the surface */ return ds; @@ -186,14 +186,14 @@ static mapDrawSurface_t *MakeCelSurface( mapDrawSurface_t *src, shaderInfo_t *si static mapDrawSurface_t *MakeSkyboxSurface( mapDrawSurface_t *src ){ /* dummy check */ - if ( src == NULL ) { - return NULL; + if ( src == nullptr ) { + return nullptr; } /* make a copy */ mapDrawSurface_t *ds = CloneSurface( src, src->shaderInfo ); - if ( ds == NULL ) { - return NULL; + if ( ds == nullptr ) { + return nullptr; } /* set parent */ @@ -229,10 +229,10 @@ void ClearSurface( mapDrawSurface_t *ds ){ ds->planeNum = -1; ds->numVerts = 0; free( ds->verts ); - ds->verts = NULL; + ds->verts = nullptr; ds->numIndexes = 0; free( ds->indexes ); - ds->indexes = NULL; + ds->indexes = nullptr; } @@ -244,7 +244,7 @@ void ClearSurface( mapDrawSurface_t *ds ){ void TidyEntitySurfaces( const entity_t& e ){ int i, j, deleted; - mapDrawSurface_t *out, *in = NULL; + mapDrawSurface_t *out, *in = nullptr; /* note it */ @@ -571,7 +571,7 @@ void ClassifyEntitySurfaces( const entity_t& e ){ static byte GetShaderIndexForPoint( const indexMap_t *im, const MinMax& eMinmax, const Vector3& point ){ /* early out if no indexmap */ - if ( im == NULL ) { + if ( im == nullptr ) { return 0; } @@ -620,7 +620,7 @@ static byte GetShaderIndexForPoint( const indexMap_t *im, const MinMax& eMinmax, static shaderInfo_t& GetIndexedShader( const shaderInfo_t *parent, const indexMap_t *im, int numPoints, byte *shaderIndexes ){ /* early out if bad data */ - if ( im == NULL || numPoints <= 0 || shaderIndexes == NULL ) { + if ( im == nullptr || numPoints <= 0 || shaderIndexes == nullptr ) { return ShaderInfoForShader( "default" ); } @@ -706,7 +706,7 @@ mapDrawSurface_t *DrawSurfaceForSide( const entity_t& e, const brush_t& b, const /* ydnar: don't make a drawsurf for culled sides */ if ( s.culled ) { - return NULL; + return nullptr; } /* range check */ @@ -718,7 +718,7 @@ mapDrawSurface_t *DrawSurfaceForSide( const entity_t& e, const brush_t& b, const si = s.shaderInfo; /* ydnar: gs mods: check for indexed shader */ - if ( si->indexed && b.im != NULL ) { + if ( si->indexed && b.im != nullptr ) { /* indexed */ indexed = true; @@ -757,7 +757,7 @@ mapDrawSurface_t *DrawSurfaceForSide( const entity_t& e, const brush_t& b, const ds->shaderInfo = si; ds->mapBrush = &b; - ds->sideRef = AllocSideRef( &s, NULL ); + ds->sideRef = AllocSideRef( &s, nullptr ); ds->fogNum = -1; ds->sampleSize = b.lightmapSampleSize; ds->lightmapScale = b.lightmapScale; @@ -861,12 +861,12 @@ mapDrawSurface_t *DrawSurfaceForMesh( const entity_t& e, parseMesh_t *p, mesh_t /* get mesh and shader shader */ - if ( mesh == NULL ) { + if ( mesh == nullptr ) { mesh = &p->mesh; } si = p->shaderInfo; - if ( mesh == NULL || si == NULL ) { - return NULL; + if ( mesh == nullptr || si == nullptr ) { + return nullptr; } /* get vertex count */ @@ -901,7 +901,7 @@ mapDrawSurface_t *DrawSurfaceForMesh( const entity_t& e, parseMesh_t *p, mesh_t FreeMesh( copy ); /* ydnar: gs mods: check for indexed shader */ - if ( si->indexed && p->im != NULL ) { + if ( si->indexed && p->im != nullptr ) { /* indexed */ indexed = true; @@ -1030,7 +1030,7 @@ mapDrawSurface_t *DrawSurfaceForMesh( const entity_t& e, parseMesh_t *p, mesh_t mapDrawSurface_t *DrawSurfaceForFlare( int entNum, const Vector3& origin, const Vector3& normal, const Vector3& color, const char *flareShader, int lightStyle ){ /* emit flares? */ if ( !emitFlares ) { - return NULL; + return nullptr; } /* allocate drawsurface */ @@ -1187,7 +1187,7 @@ void SubdivideFaceSurfaces( const entity_t& e ){ for ( mapDrawSurface_t& ds : Span( mapDrawSurfs + e.firstDrawSurf, mapDrawSurfs + numMapDrawSurfs ) ) { /* only subdivide brush sides */ - if ( ds.type != ESurfaceType::Face || ds.mapBrush == NULL || ds.sideRef == NULL || ds.sideRef->side == NULL ) { + if ( ds.type != ESurfaceType::Face || ds.mapBrush == nullptr || ds.sideRef == nullptr || ds.sideRef->side == nullptr ) { continue; } @@ -1197,7 +1197,7 @@ void SubdivideFaceSurfaces( const entity_t& e ){ /* check subdivision for shader */ const shaderInfo_t *si = side.shaderInfo; - if ( si == NULL ) { + if ( si == nullptr ) { continue; } @@ -1287,7 +1287,7 @@ static int g_numHiddenFaces, g_numCoinFaces; static bool SideInBrush( side_t& side, const brush_t& b ){ /* ignore sides w/o windings or shaders */ - if ( side.winding.empty() || side.shaderInfo == NULL ) { + if ( side.winding.empty() || side.shaderInfo == nullptr ) { return true; } @@ -1358,7 +1358,7 @@ static void CullSides( entity_t& e ){ } /* original check */ - if ( b1->original == b2->original && b1->original != NULL ) { + if ( b1->original == b2->original && b1->original != nullptr ) { continue; } @@ -1382,7 +1382,7 @@ static void CullSides( entity_t& e ){ continue; } const int numPoints = w1.size(); - if ( side1.shaderInfo == NULL ) { + if ( side1.shaderInfo == nullptr ) { continue; } @@ -1394,7 +1394,7 @@ static void CullSides( entity_t& e ){ if ( w2.empty() ) { continue; } - if ( side2.shaderInfo == NULL ) { + if ( side2.shaderInfo == nullptr ) { continue; } if ( w1.size() != w2.size() ) { @@ -1539,7 +1539,7 @@ void ClipSidesIntoTree( entity_t& e, const tree_t& tree ){ /* shader? */ const shaderInfo_t *si = side.shaderInfo; - if ( si == NULL ) { + if ( si == nullptr ) { continue; } @@ -1631,7 +1631,7 @@ static int AddReferenceToTree_r( mapDrawSurface_t *ds, node_t *node, bool skybox /* dummy check */ - if ( node == NULL ) { + if ( node == nullptr ) { return 0; } @@ -1742,7 +1742,7 @@ static int FilterWindingIntoTree_r( winding_t& w, mapDrawSurface_t *ds, node_t * const shaderInfo_t *si = ds->shaderInfo; /* ydnar: is this the head node? */ - if ( node->parent == NULL && si != NULL && si->minmax.valid() ) { + if ( node->parent == nullptr && si != nullptr && si->minmax.valid() ) { static bool warned = false; if ( !warned ) { Sys_Warning( "this map uses the deformVertexes move hack\n" ); @@ -2050,7 +2050,7 @@ static int FindDrawIndexes( int numIndexes, const int *indexes ){ /* dummy check */ - if ( numIndexes < 3 || numBSPDrawIndexes < numIndexes || indexes == NULL ) { + if ( numIndexes < 3 || numBSPDrawIndexes < numIndexes || indexes == nullptr ) { return numBSPDrawIndexes; } @@ -2216,14 +2216,14 @@ static void EmitPatchSurface( const entity_t& e, mapDrawSurface_t *ds ){ /* set it up */ out.surfaceType = MST_PATCH; if ( debugSurfaces ) { - out.shaderNum = EmitShader( "debugsurfaces", NULL, NULL ); + out.shaderNum = EmitShader( "debugsurfaces", nullptr, nullptr ); } else if ( patchMeta || forcePatchMeta ) { /* patch meta requires that we have nodraw patches for collision */ int surfaceFlags = ds->shaderInfo->surfaceFlags; int contentFlags = ds->shaderInfo->contentFlags; - ApplySurfaceParm( "nodraw", &contentFlags, &surfaceFlags, NULL ); - ApplySurfaceParm( "pointlight", &contentFlags, &surfaceFlags, NULL ); + ApplySurfaceParm( "nodraw", &contentFlags, &surfaceFlags, nullptr ); + ApplySurfaceParm( "pointlight", &contentFlags, &surfaceFlags, nullptr ); /* we don't want this patch getting lightmapped */ ds->lightmapVecs[ 2 ].set( 0 ); @@ -2525,7 +2525,7 @@ static void EmitTriangleSurface( mapDrawSurface_t *ds ){ /* set it up */ if ( debugSurfaces ) { - out.shaderNum = EmitShader( "debugsurfaces", NULL, NULL ); + out.shaderNum = EmitShader( "debugsurfaces", nullptr, nullptr ); } else{ out.shaderNum = EmitShader( ds->shaderInfo->shader, &ds->shaderInfo->contentFlags, &ds->shaderInfo->surfaceFlags ); @@ -2648,7 +2648,7 @@ static void MakeDebugPortalSurfs_r( const node_t *node, shaderInfo_t& si ){ mapDrawSurface_t *ds = AllocDrawSurface( ESurfaceType::Face ); ds->shaderInfo = &si; ds->planar = true; - ds->planeNum = FindFloatPlane( p->plane.plane, 0, NULL ); + ds->planeNum = FindFloatPlane( p->plane.plane, 0, nullptr ); ds->lightmapVecs[ 2 ] = p->plane.normal(); ds->fogNum = -1; ds->numVerts = w.size(); @@ -2865,7 +2865,7 @@ static int AddSurfaceModelsToTriangle_r( mapDrawSurface_t *ds, const surfaceMode } /* insert the model */ - InsertModel( model.model.c_str(), NULL, 0, transform, NULL, ds->celShader, entity, ds->castShadows, ds->recvShadows, 0, ds->lightmapScale, 0, 0, clipDepthGlobal ); + InsertModel( model.model.c_str(), nullptr, 0, transform, nullptr, ds->celShader, entity, ds->castShadows, ds->recvShadows, 0, ds->lightmapScale, 0, 0, clipDepthGlobal ); /* return to sender */ return 1; @@ -2906,7 +2906,7 @@ static int AddSurfaceModelsToTriangle_r( mapDrawSurface_t *ds, const surfaceMode static int AddSurfaceModels( mapDrawSurface_t *ds, entity_t& entity ){ /* dummy check */ - if ( ds == NULL || ds->shaderInfo == NULL || ds->shaderInfo->surfaceModels.empty() ) { + if ( ds == nullptr || ds->shaderInfo == nullptr || ds->shaderInfo->surfaceModels.empty() ) { return 0; } diff --git a/tools/quake3/q3map2/surface_extra.cpp b/tools/quake3/q3map2/surface_extra.cpp index 6bae34bd..3dd64e34 100644 --- a/tools/quake3/q3map2/surface_extra.cpp +++ b/tools/quake3/q3map2/surface_extra.cpp @@ -68,7 +68,7 @@ void SetSurfaceExtra( const mapDrawSurface_t& ds ){ /* copy out the relevant bits */ se.mds = &ds; se.si = ds.shaderInfo; - se.parentSurfaceNum = ds.parent != NULL ? ds.parent->outputNum : -1; + se.parentSurfaceNum = ds.parent != nullptr ? ds.parent->outputNum : -1; se.entityNum = ds.entityNum; se.castShadows = ds.castShadows; se.recvShadows = ds.recvShadows; @@ -130,7 +130,7 @@ void WriteSurfaceExtraFile( const char *path ){ } /* valid map drawsurf? */ - if ( se->mds == NULL ) { + if ( se->mds == nullptr ) { fprintf( sf, "\n" ); } else @@ -146,7 +146,7 @@ void WriteSurfaceExtraFile( const char *path ){ fprintf( sf, "{\n" ); /* shader */ - if ( se->si != NULL ) { + if ( se->si != nullptr ) { fprintf( sf, "\tshader %s\n", se->si->shader.c_str() ); } diff --git a/tools/quake3/q3map2/surface_foliage.cpp b/tools/quake3/q3map2/surface_foliage.cpp index d166d84d..cce395b2 100644 --- a/tools/quake3/q3map2/surface_foliage.cpp +++ b/tools/quake3/q3map2/surface_foliage.cpp @@ -157,7 +157,7 @@ static void SubdivideFoliageTriangle_r( mapDrawSurface_t *ds, const foliage_t& f void Foliage( mapDrawSurface_t *src, entity_t& entity ){ /* get shader */ shaderInfo_t *si = src->shaderInfo; - if ( si == NULL || si->foliage.empty() ) { + if ( si == nullptr || si->foliage.empty() ) { return; } @@ -251,7 +251,7 @@ void Foliage( mapDrawSurface_t *src, entity_t& entity ){ const int oldNumMapDrawSurfs = numMapDrawSurfs; /* add the model to the bsp */ - InsertModel( foliage.model.c_str(), NULL, 0, matrix4_scale_for_vec3( Vector3( foliage.scale ) ), NULL, NULL, entity, src->castShadows, src->recvShadows, 0, src->lightmapScale, 0, 0, clipDepthGlobal ); + InsertModel( foliage.model.c_str(), nullptr, 0, matrix4_scale_for_vec3( Vector3( foliage.scale ) ), nullptr, nullptr, entity, src->castShadows, src->recvShadows, 0, src->lightmapScale, 0, 0, clipDepthGlobal ); /* walk each new surface */ for ( int i = oldNumMapDrawSurfs; i < numMapDrawSurfs; ++i ) diff --git a/tools/quake3/q3map2/surface_fur.cpp b/tools/quake3/q3map2/surface_fur.cpp index fa06cbbe..c4d8337a 100644 --- a/tools/quake3/q3map2/surface_fur.cpp +++ b/tools/quake3/q3map2/surface_fur.cpp @@ -47,7 +47,7 @@ void Fur( mapDrawSurface_t *ds ){ /* dummy check */ - if ( ds == NULL || ds->fur || ds->shaderInfo->furNumLayers < 1 ) { + if ( ds == nullptr || ds->fur || ds->shaderInfo->furNumLayers < 1 ) { return; } @@ -75,7 +75,7 @@ void Fur( mapDrawSurface_t *ds ){ { /* clone the surface */ mapDrawSurface_t *fur = CloneSurface( ds, ds->shaderInfo ); - if ( fur == NULL ) { + if ( fur == nullptr ) { return; } diff --git a/tools/quake3/q3map2/surface_meta.cpp b/tools/quake3/q3map2/surface_meta.cpp index a37baae9..e04655b2 100644 --- a/tools/quake3/q3map2/surface_meta.cpp +++ b/tools/quake3/q3map2/surface_meta.cpp @@ -310,7 +310,7 @@ static void SurfaceToMetaTriangles( mapDrawSurface_t *ds ){ /* build a metatriangle */ metaTriangle_t src; src.si = ds->shaderInfo; - src.side = ( ds->sideRef != NULL ? ds->sideRef->side : NULL ); + src.side = ( ds->sideRef != nullptr ? ds->sideRef->side : nullptr ); src.entityNum = ds->entityNum; src.surfaceNum = ds->surfaceNum; src.planeNum = ds->planeNum; @@ -742,7 +742,7 @@ void StripFaceSurface( mapDrawSurface_t *ds ){ { /* ydnar: find smallest coordinate */ int least = 0; - if ( ds->shaderInfo != NULL && !ds->shaderInfo->autosprite ) { + if ( ds->shaderInfo != nullptr && !ds->shaderInfo->autosprite ) { for ( int i = 0; i < ds->numVerts; ++i ) { /* get points */ @@ -1522,7 +1522,7 @@ static void MetaTrianglesToSurface( int *fOld, int *numAdded ){ for ( auto& seed : metaTriangles ) { /* skip this triangle if it has already been merged */ - if ( seed.si == NULL ) { + if ( seed.si == nullptr ) { continue; } @@ -1545,7 +1545,7 @@ static void MetaTrianglesToSurface( int *fOld, int *numAdded ){ ds->verts = verts; ds->indexes = indexes; ds->lightmapAxis = seed.lightmapAxis; - ds->sideRef = AllocSideRef( seed.side, NULL ); + ds->sideRef = AllocSideRef( seed.side, nullptr ); ds->minmax.clear(); @@ -1574,7 +1574,7 @@ static void MetaTrianglesToSurface( int *fOld, int *numAdded ){ } } /* mark triangle as used */ - triangle.si = NULL; + triangle.si = nullptr; /* remove from cloud */ if( auto it = std::ranges::find( testCloud, &triangle ); it != testCloud.cend() ){ testCloud.erase( it ); @@ -1615,7 +1615,7 @@ static void MetaTrianglesToSurface( int *fOld, int *numAdded ){ for ( metaTriangle_t *test : testCloud ) { /* skip this triangle if it has already been merged */ - if ( test->si == NULL ) { + if ( test->si == nullptr ) { continue; } diff --git a/tools/quake3/q3map2/vis.cpp b/tools/quake3/q3map2/vis.cpp index 9ba8473a..164e91a4 100644 --- a/tools/quake3/q3map2/vis.cpp +++ b/tools/quake3/q3map2/vis.cpp @@ -521,7 +521,7 @@ static fixedWinding_t *TryMergeWinding( fixedWinding_t *f1, fixedWinding_t *f2, // // find a common edge // - p1 = p2 = NULL; // stop compiler warning + p1 = p2 = nullptr; // stop compiler warning j = 0; // for ( i = 0; i < f1->numpoints; ++i ) @@ -551,7 +551,7 @@ static fixedWinding_t *TryMergeWinding( fixedWinding_t *f1, fixedWinding_t *f2, } if ( i == f1->numpoints ) { - return NULL; // no matching edges + return nullptr; // no matching edges } // @@ -564,7 +564,7 @@ static fixedWinding_t *TryMergeWinding( fixedWinding_t *f1, fixedWinding_t *f2, back = &f2->points[( j + 2 ) % f2->numpoints]; dot = vector3_dot( *back - *p1, normal ); if ( dot > CONTINUOUS_EPSILON ) { - return NULL; // not a convex polygon + return nullptr; // not a convex polygon } keep1 = ( dot < -CONTINUOUS_EPSILON ); @@ -574,7 +574,7 @@ static fixedWinding_t *TryMergeWinding( fixedWinding_t *f1, fixedWinding_t *f2, back = &f2->points[( j + f2->numpoints - 1 ) % f2->numpoints]; dot = vector3_dot( *back - *p2, normal ); if ( dot > CONTINUOUS_EPSILON ) { - return NULL; // not a convex polygon + return nullptr; // not a convex polygon } keep2 = ( dot < -CONTINUOUS_EPSILON ); diff --git a/tools/quake3/q3map2/visflow.cpp b/tools/quake3/q3map2/visflow.cpp index cd274dc2..1e85787f 100644 --- a/tools/quake3/q3map2/visflow.cpp +++ b/tools/quake3/q3map2/visflow.cpp @@ -92,7 +92,7 @@ static fixedWinding_t *AllocStackWinding( pstack_t *stack ){ Error( "AllocStackWinding: failed" ); - return NULL; + return nullptr; } static void FreeStackWinding( fixedWinding_t *w, pstack_t *stack ){ @@ -148,7 +148,7 @@ static fixedWinding_t *VisChopWinding( fixedWinding_t *in, pstack_t *stack, con } if ( !counts[0] ) { FreeStackWinding( in, stack ); - return NULL; + return nullptr; } sides[i] = sides[0]; @@ -345,7 +345,7 @@ static fixedWinding_t *ClipToSeperators( fixedWinding_t *source, fixedWinding_t d = plane3_distance_to_point( plane, stack->portal->origin ); //if completely at the back of the separator plane if ( d < -stack->portal->radius ) { - return NULL; + return nullptr; } //if completely on the front of the separator plane if ( d > stack->portal->radius ) { @@ -357,7 +357,7 @@ static fixedWinding_t *ClipToSeperators( fixedWinding_t *source, fixedWinding_t // target = VisChopWinding( target, stack, plane ); if ( !target ) { - return NULL; // target is not visible + return nullptr; // target is not visible } break; // optimization by Antony Suter @@ -389,9 +389,9 @@ static void RecursiveLeafFlow( int leafnum, threaddata_t *thread, pstack_t *prev prevstack->next = &stack; - stack.next = NULL; + stack.next = nullptr; stack.leaf = leaf; - stack.portal = NULL; + stack.portal = nullptr; stack.depth = prevstack->depth + 1; #ifdef SEPERATORCACHE @@ -460,7 +460,7 @@ static void RecursiveLeafFlow( int leafnum, threaddata_t *thread, pstack_t *prev backplane = plane3_flipped( p->plane ); stack.portal = p; - stack.next = NULL; + stack.next = nullptr; stack.freewindings[0] = 1; stack.freewindings[1] = 1; stack.freewindings[2] = 1; @@ -579,7 +579,7 @@ static void RecursiveLeafFlow( int leafnum, threaddata_t *thread, pstack_t *prev // flow through it for real RecursiveLeafFlow( p->leaf, thread, &stack ); // - stack.next = NULL; + stack.next = nullptr; } } @@ -646,7 +646,7 @@ static void RecursivePassageFlow( vportal_t *portal, threaddata_t *thread, pstac prevstack->next = &stack; - stack.next = NULL; + stack.next = nullptr; stack.depth = prevstack->depth + 1; vis = (long *)thread->base->portalvis; @@ -700,7 +700,7 @@ static void RecursivePassageFlow( vportal_t *portal, threaddata_t *thread, pstac // flow through it for real RecursivePassageFlow( p, thread, &stack ); - stack.next = NULL; + stack.next = nullptr; } } @@ -771,9 +771,9 @@ static void RecursivePassagePortalFlow( vportal_t *portal, threaddata_t *thread, prevstack->next = &stack; - stack.next = NULL; + stack.next = nullptr; stack.leaf = leaf; - stack.portal = NULL; + stack.portal = nullptr; stack.depth = prevstack->depth + 1; #ifdef SEPERATORCACHE @@ -830,7 +830,7 @@ static void RecursivePassagePortalFlow( vportal_t *portal, threaddata_t *thread, backplane = plane3_flipped( p->plane ); stack.portal = p; - stack.next = NULL; + stack.next = nullptr; stack.freewindings[0] = 1; stack.freewindings[1] = 1; stack.freewindings[2] = 1; @@ -949,7 +949,7 @@ static void RecursivePassagePortalFlow( vportal_t *portal, threaddata_t *thread, // flow through it for real RecursivePassagePortalFlow( p, thread, &stack ); // - stack.next = NULL; + stack.next = nullptr; } } @@ -1032,7 +1032,7 @@ static fixedWinding_t *PassageChopWinding( fixedWinding_t *in, fixedWinding_t *o } if ( !counts[0] ) { - return NULL; + return nullptr; } sides[i] = sides[0]; @@ -1243,7 +1243,7 @@ void CreatePassages( int portalnum ){ return; } - lastpassage = NULL; + lastpassage = nullptr; for ( const vportal_t *target : Span( leafs[portal->leaf].portals, leafs[portal->leaf].numportals ) ) { if ( target->removed ) { @@ -1254,7 +1254,7 @@ void CreatePassages( int portalnum ){ numseperators = AddSeperators( portal->winding, target->winding, false, seperators, MAX_SEPERATORS * 2 ); numseperators += AddSeperators( target->winding, portal->winding, true, &seperators[numseperators], MAX_SEPERATORS * 2 - numseperators ); - passage->next = NULL; + passage->next = nullptr; if ( lastpassage ) { lastpassage->next = passage; } @@ -1325,7 +1325,7 @@ void CreatePassages( int portalnum ){ } - if ( res == NULL ) { + if ( res == nullptr ) { break; } } diff --git a/tools/quake3/q3map2/writebsp.cpp b/tools/quake3/q3map2/writebsp.cpp index aec98df8..fc1c059e 100644 --- a/tools/quake3/q3map2/writebsp.cpp +++ b/tools/quake3/q3map2/writebsp.cpp @@ -41,7 +41,7 @@ int EmitShader( const char *shader, const int *contentFlags, const int *surfaceFlags ){ /* handle special cases */ - if ( shader == NULL ) { + if ( shader == nullptr ) { shader = "noshader"; } @@ -49,10 +49,10 @@ int EmitShader( const char *shader, const int *contentFlags, const int *surfaceF for ( size_t i = 0; i < bspShaders.size(); ++i ) { /* ydnar: handle custom surface/content flags */ - if ( surfaceFlags != NULL && bspShaders[ i ].surfaceFlags != *surfaceFlags ) { + if ( surfaceFlags != nullptr && bspShaders[ i ].surfaceFlags != *surfaceFlags ) { continue; } - if ( contentFlags != NULL && bspShaders[ i ].contentFlags != *contentFlags ) { + if ( contentFlags != nullptr && bspShaders[ i ].contentFlags != *contentFlags ) { continue; } if ( !doingBSP ){ @@ -76,13 +76,13 @@ int EmitShader( const char *shader, const int *contentFlags, const int *surfaceF strcpy( bspShader.shader, si.shader ); /* handle custom content/surface flags */ - bspShader.surfaceFlags = ( surfaceFlags != NULL )? *surfaceFlags : si.surfaceFlags; - bspShader.contentFlags = ( contentFlags != NULL )? *contentFlags : si.contentFlags; + bspShader.surfaceFlags = ( surfaceFlags != nullptr )? *surfaceFlags : si.surfaceFlags; + bspShader.contentFlags = ( contentFlags != nullptr )? *contentFlags : si.contentFlags; /* recursively emit any damage shaders */ if ( !strEmptyOrNull( si.damageShader ) ) { Sys_FPrintf( SYS_VRB, "Shader %s has damage shader %s\n", si.shader.c_str(), si.damageShader ); - EmitShader( si.damageShader, NULL, NULL ); + EmitShader( si.damageShader, nullptr, nullptr ); } /* return index */ @@ -364,10 +364,10 @@ void EndBSPFile( bool do_write ){ void EmitBrushes( brushlist_t& brushes, int *firstBrush, int *numBrushes ){ /* set initial brush */ - if ( firstBrush != NULL ) { + if ( firstBrush != nullptr ) { *firstBrush = bspBrushes.size(); } - if ( numBrushes != NULL ) { + if ( numBrushes != nullptr ) { *numBrushes = 0; } @@ -377,7 +377,7 @@ void EmitBrushes( brushlist_t& brushes, int *firstBrush, int *numBrushes ){ /* get bsp brush */ b.outputNum = bspBrushes.size(); bspBrush_t& db = bspBrushes.emplace_back(); - if ( numBrushes != NULL ) { + if ( numBrushes != nullptr ) { ( *numBrushes )++; } @@ -402,10 +402,10 @@ void EmitBrushes( brushlist_t& brushes, int *firstBrush, int *numBrushes ){ cp.shaderNum = EmitShader( side.shaderInfo->shader, &side.shaderInfo->contentFlags, &side.shaderInfo->surfaceFlags ); } else if( side.bevel ) { /* emit surfaceFlags for bevels to get correct physics at walkable brush edges and vertices */ - cp.shaderNum = EmitShader( NULL, NULL, &side.surfaceFlags ); + cp.shaderNum = EmitShader( nullptr, nullptr, &side.surfaceFlags ); } else{ - cp.shaderNum = EmitShader( NULL, NULL, NULL ); + cp.shaderNum = EmitShader( nullptr, nullptr, nullptr ); } } } @@ -428,7 +428,7 @@ void EmitFogs(){ strcpy( bspFog.shader, fog.si->shader ); /* global fog doesn't have an associated brush */ - if ( fog.brush == NULL ) { + if ( fog.brush == nullptr ) { bspFog.brushNum = -1; bspFog.visibleSide = -1; }