NULL to nullptr

This commit is contained in:
Arthur Ice
2013-05-04 18:06:58 -07:00
parent e1c2657b11
commit 7560b6b0a7
216 changed files with 4151 additions and 4151 deletions
+1 -1
View File
@@ -63,7 +63,7 @@ struct Texture {
class Model {
public:
Model() { IncludeInMap = false; verts = NULL; vert_count = 0; polys = NULL; poly_count = 0; tex = NULL; tex_count = 0; name = NULL; }
Model() { IncludeInMap = false; verts = nullptr; vert_count = 0; polys = nullptr; poly_count = 0; tex = nullptr; tex_count = 0; name = nullptr; }
~Model() {}
Vertex **verts;
+4 -4
View File
@@ -120,7 +120,7 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
archive = new PFSLoader();
FILE *s3df = fopen(bufs, "rb");
if(s3df == NULL) {
if(s3df == nullptr) {
// One day we may try EQG, but not today.
printf("Unable to open s3d file '%s'.\n", bufs);
return(false);
@@ -133,7 +133,7 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
fileloader = new WLDLoader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) {
if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
printf("Error reading WLD from %s\n", bufs);
return(false);
}
@@ -173,7 +173,7 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
}
if(tree==NULL) {
if(tree==nullptr) {
printf("No BSP Tree. Bailing out\n");
return(false);
}
@@ -200,7 +200,7 @@ bool BuildWaterMap(const char *shortname, long DefaultRegionType) {
sprintf(bufm, "%s.wtr", shortname);
FILE *WaterFile = fopen(bufm, "wb");
if(WaterFile == NULL) {
if(WaterFile == nullptr) {
printf("Failed to open %s for writing\n", bufm);
return(false);
}
+50 -50
View File
@@ -100,10 +100,10 @@ int main(int argc, char *argv[]) {
}
QTBuilder::QTBuilder() {
_root = NULL;
_root = nullptr;
faceCount = 0;
faceBlock = NULL;
faceBlock = nullptr;
#ifdef COUNT_MACTHES
gEasyMatches = 0;
@@ -114,12 +114,12 @@ QTBuilder::QTBuilder() {
}
QTBuilder::~QTBuilder() {
if(_root != NULL)
if(_root != nullptr)
delete _root;
_root = NULL;
if(faceBlock != NULL)
_root = nullptr;
if(faceBlock != nullptr)
delete [] faceBlock;
faceBlock = NULL;
faceBlock = nullptr;
}
bool QTBuilder::build(const char *shortname) {
@@ -138,12 +138,12 @@ bool QTBuilder::build(const char *shortname) {
archive = new PFSLoader();
fff = fopen(bufs, "rb");
if(fff != NULL)
if(fff != nullptr)
FileType = S3D;
else {
sprintf(bufs, "%s.eqg", shortname);
fff = fopen(bufs, "rb");
if(fff != NULL)
if(fff != nullptr)
FileType = EQG;
}
@@ -160,17 +160,17 @@ bool QTBuilder::build(const char *shortname) {
switch(FileType) {
case S3D:
fileloader = new WLDLoader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) {
if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
printf("Error reading WLD from %s\n", bufs);
return(false);
}
break;
case EQG:
fileloader = new ZonLoader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) {
if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
delete fileloader;
fileloader = new Zonv4Loader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) {
if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
printf("Error reading ZON/TER from %s\n", bufs);
return(false);
}
@@ -296,7 +296,7 @@ bool QTBuilder::build(const char *shortname) {
printf("Building quadtree.\n");
_root = new QTNode(this, minx, maxx, miny, maxy);
if(_root == NULL) {
if(_root == nullptr) {
printf("Unable to allocate new QTNode.\n");
return(false);
}
@@ -332,13 +332,13 @@ bool QTBuilder::build(const char *shortname) {
bool QTBuilder::writeMap(const char *file) {
if(_root == NULL)
if(_root == nullptr)
return(false);
printf("Writing map file.\n");
FILE *out = fopen(file, "wb");
if(out == NULL) {
if(out == nullptr) {
printf("Unable to open output file '%s'.\n", file);
return(1);
}
@@ -370,7 +370,7 @@ bool QTBuilder::writeMap(const char *file) {
//make our node blocks to write out...
nodeHeader *nodes = new nodeHeader[head.node_count];
unsigned long *facelist = new unsigned long[head.facelist_count];
if(nodes == NULL || facelist == NULL) {
if(nodes == nullptr || facelist == nullptr) {
printf("Error allocating temporary memory for output.\n");
fclose(out);
return(1); //no memory
@@ -404,10 +404,10 @@ bool QTBuilder::writeMap(const char *file) {
QTNode::QTNode(QTBuilder *b, float Tminx, float Tmaxx, float Tminy, float Tmaxy) {
node1 = NULL;
node2 = NULL;
node3 = NULL;
node4 = NULL;
node1 = nullptr;
node2 = nullptr;
node3 = nullptr;
node4 = nullptr;
minx = Tminx;
maxx = Tmaxx;
miny = Tminy;
@@ -423,18 +423,18 @@ QTNode::~QTNode() {
}
void QTNode::clearNodes() {
if(node1 != NULL)
if(node1 != nullptr)
delete node1;
if(node2 != NULL)
if(node2 != nullptr)
delete node2;
if(node3 != NULL)
if(node3 != nullptr)
delete node3;
if(node4 != NULL)
if(node4 != nullptr)
delete node4;
node1 = NULL;
node2 = NULL;
node3 = NULL;
node4 = NULL;
node1 = nullptr;
node2 = nullptr;
node3 = nullptr;
node4 = nullptr;
}
//assumes that both supplied arrays are big enough per countNodes/Facelists
@@ -463,25 +463,25 @@ void QTNode::fillBlocks(nodeHeader *heads, unsigned long *flist, unsigned long &
//branch node.
head->flags = 0;
if(node1 != NULL) {
if(node1 != nullptr) {
head->nodes[0] = hindex;
node1->fillBlocks(heads, flist, hindex, findex);
} else {
head->nodes[0] = NODE_NONE;
}
if(node2 != NULL) {
if(node2 != nullptr) {
head->nodes[1] = hindex;
node2->fillBlocks(heads, flist, hindex, findex);
} else {
head->nodes[1] = NODE_NONE;
}
if(node3 != NULL) {
if(node3 != nullptr) {
head->nodes[2] = hindex;
node3->fillBlocks(heads, flist, hindex, findex);
} else {
head->nodes[2] = NODE_NONE;
}
if(node4 != NULL) {
if(node4 != nullptr) {
head->nodes[3] = hindex;
node4->fillBlocks(heads, flist, hindex, findex);
} else {
@@ -492,26 +492,26 @@ void QTNode::fillBlocks(nodeHeader *heads, unsigned long *flist, unsigned long &
unsigned long QTNode::countNodes() const {
unsigned long c = 1;
if(node1 != NULL)
if(node1 != nullptr)
c += node1->countNodes();
if(node2 != NULL)
if(node2 != nullptr)
c += node2->countNodes();
if(node3 != NULL)
if(node3 != nullptr)
c += node3->countNodes();
if(node4 != NULL)
if(node4 != nullptr)
c += node4->countNodes();
return(c);
}
unsigned long QTNode::countFacelists() const {
unsigned long c = final? faces.size() : 0;
if(node1 != NULL)
if(node1 != nullptr)
c += node1->countFacelists();
if(node2 != NULL)
if(node2 != nullptr)
c += node2->countFacelists();
if(node3 != NULL)
if(node3 != nullptr)
c += node3->countFacelists();
if(node4 != NULL)
if(node4 != nullptr)
c += node4->countFacelists();
return(c);
}
@@ -607,13 +607,13 @@ printf("Stopping (empty) on box (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d
depth++;
if(node1 != NULL)
if(node1 != nullptr)
node1->divideYourself(depth);
if(node2 != NULL)
if(node2 != nullptr)
node2->divideYourself(depth);
if(node3 != NULL)
if(node3 != nullptr)
node3->divideYourself(depth);
if(node4 != NULL)
if(node4 != nullptr)
node4->divideYourself(depth);
@@ -854,7 +854,7 @@ void QTNode::doSplit() {
node2 = new QTNode(builder, minx, midx, midy, maxy);
node3 = new QTNode(builder, minx, midx, miny, midy);
node4 = new QTNode(builder, midx, maxx, miny, midy);
if(node1 == NULL || node2 == NULL || node3 == NULL || node4 == NULL) {
if(node1 == nullptr || node2 == nullptr || node3 == nullptr || node4 == nullptr) {
printf("Error: unable to allocate new QTNode, giving up.\n");
return;
}
@@ -876,19 +876,19 @@ void QTNode::doSplit() {
//clean up empty sets.
if(node1->faces.size() == 0) {
delete node1;
node1 = NULL;
node1 = nullptr;
}
if(node2->faces.size() == 0) {
delete node2;
node2 = NULL;
node2 = nullptr;
}
if(node3->faces.size() == 0) {
delete node3;
node3 = NULL;
node3 = nullptr;
}
if(node4->faces.size() == 0) {
delete node4;
node4 = NULL;
node4 = nullptr;
}
}
@@ -1178,8 +1178,8 @@ void QTBuilder::AddPlaceable(FileLoader *fileloader, char *ZoneFileName, bool Li
for(int i = 0; i < fileloader->model_data.plac_count; ++i) {
if(fileloader->model_data.placeable[i]->model==-1) continue;
// The model pointer should only really be NULL for the zone model, as we process that separately.
if(fileloader->model_data.models[fileloader->model_data.placeable[i]->model] == NULL) continue;
// The model pointer should only really be nullptr for the zone model, as we process that separately.
if(fileloader->model_data.models[fileloader->model_data.placeable[i]->model] == nullptr) continue;
if(ListPlaceable)
printf("Placeable Object %4d @ (%9.2f, %9.2f, %9.2f uses model %4d %s\n",i,
fileloader->model_data.placeable[i]->y,
+2 -2
View File
@@ -125,9 +125,9 @@ int AddModelName(Content_3D *C3D, string ModelName)
DATLoader::DATLoader()
{
this->buffer = NULL;
this->buffer = nullptr;
this->buf_len = -1;
this->archive = NULL;
this->archive = nullptr;
this->status = 0;
}
+2 -2
View File
@@ -9,8 +9,8 @@
#include <netinet/in.h>
#endif
#ifndef NULL
#define NULL 0
#ifndef nullptr
#define nullptr 0
#endif
typedef unsigned long uint32;
+6 -6
View File
@@ -70,12 +70,12 @@ bool ProcessZoneFile(const char *shortname) {
archive = new PFSLoader();
fff = fopen(bufs, "rb");
if(fff != NULL)
if(fff != nullptr)
FileType = S3D;
else {
sprintf(bufs, "%s.eqg", shortname);
fff = fopen(bufs, "rb");
if(fff != NULL)
if(fff != nullptr)
FileType = EQG;
}
@@ -94,7 +94,7 @@ bool ProcessZoneFile(const char *shortname) {
switch(FileType) {
case S3D:
fileloader = new WLDLoader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) {
if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
printf("Error reading WLD from %s\n", bufs);
return(false);
}
@@ -102,10 +102,10 @@ bool ProcessZoneFile(const char *shortname) {
case EQG:
fileloader = new ZonLoader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) {
if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
delete fileloader;
fileloader = new Zonv4Loader();
if(fileloader->Open(NULL, (char *) shortname, archive) == 0) {
if(fileloader->Open(nullptr, (char *) shortname, archive) == 0) {
printf("Error reading ZON/TER from %s\n", bufs);
return(false);
}
@@ -131,7 +131,7 @@ void ListPlaceable(FileLoader *fileloader, char *ZoneFileName) {
for(int i = 0; i < fileloader->model_data.plac_count; ++i) {
if(fileloader->model_data.placeable[i]->model==-1) continue;
if(fileloader->model_data.models[fileloader->model_data.placeable[i]->model] == NULL) continue;
if(fileloader->model_data.models[fileloader->model_data.placeable[i]->model] == nullptr) continue;
printf("Placeable Object %4d @ (%9.2f, %9.2f, %9.2f uses model %4d %s\n",i,
fileloader->model_data.placeable[i]->y,
fileloader->model_data.placeable[i]->x,
+3 -3
View File
@@ -67,7 +67,7 @@ inline void Lower(char *str) {
PFSLoader::PFSLoader() {
// Set the status of the loader that nothing is loaded.
this->buffer = NULL;
this->buffer = nullptr;
this->buf_len = -1;
this->status = 0;
}
@@ -195,7 +195,7 @@ int PFSLoader::Close()
else
return 0;
this->buffer = NULL;
this->buffer = nullptr;
this->buf_len = -1;
this->status = 0;
@@ -214,7 +214,7 @@ const char *PFSLoader::FindExtension(const char *ext) {
if(!strcmp(this->filenames[i]+(flen-elen), ext))
return(this->filenames[i]);
}
return(NULL);
return(nullptr);
}
int PFSLoader::GetFile(char *name, uchar **buf, int *len) {
+4 -4
View File
@@ -10,9 +10,9 @@
//#define DEBUGTER
TERLoader::TERLoader() {
this->buffer = NULL;
this->buffer = nullptr;
this->buf_len = -1;
this->archive = NULL;
this->archive = nullptr;
this->status = 0;
}
@@ -84,8 +84,8 @@ int TERLoader::Open(char *base_path, char *zone_name, Archive *archive) {
return 0;
for(i = 0; i < thdr->mat_count; ++i) {
mlist[i].name = NULL;
mlist[i].basetex = NULL;
mlist[i].name = nullptr;
mlist[i].basetex = nullptr;
}
StartOfNameList = buffer;
+8 -8
View File
@@ -25,7 +25,7 @@ FRAG_CONSTRUCTOR(Data03) {
tex->filenames = new char *[count];
tex->frame_count = count;
tex->current_frame = 0;
tex->archive = NULL;
tex->archive = nullptr;
tex->flags = 0;
for(i = 0; i < count; ++i) {
@@ -64,7 +64,7 @@ FRAG_CONSTRUCTOR(Data04) {
tex = new Texture;
tex->frame_count = count;
tex->current_frame = 0;
tex->archive = NULL;
tex->archive = nullptr;
tex->filenames = new char *[count];
tex->flags = 0;
@@ -272,7 +272,7 @@ FRAG_CONSTRUCTOR(Data30) {
tex->current_frame = 0;
tex->filenames = new char *[1];
tex->filenames[0] = "collide.dds";
tex->archive = NULL;
tex->archive = nullptr;
tex->flags = 1;
this->frag = (void *) tex;
return;
@@ -478,19 +478,19 @@ int WLDLoader::Open(char *base_path, char *zone_name, Archive *archive) {
#ifdef DEBUGWLD
printf("Zone: %s\n", zone_name);
#endif
this->model_data.zone_model = NULL;
this->model_data.zone_model = nullptr;
this->model_data.plac_count = 0;
this->model_data.placeable = 0;
this->obj_loader = this->plac_loader = NULL;
this->obj_loader = this->plac_loader = nullptr;
this->clear_plac = 0;
filename = new char[strlen(zone_name) + 5];
sprintf(filename, "%s.wld", zone_name);
if(!GetFile(&buffer, &buf_len, NULL, filename, archive)) {
if(!GetFile(&buffer, &buf_len, nullptr, filename, archive)) {
delete[] filename;
return 0;
}
@@ -635,7 +635,7 @@ int WLDLoader::Open(char *base_path, char *zone_name, Archive *archive) {
sprintf(filename, "%s_obj", zone_name);
this->obj_loader = new WLDLoader();
this->obj_loader->Open(NULL, filename, obj_archive);
this->obj_loader->Open(nullptr, filename, obj_archive);
delete[] filename;
@@ -643,7 +643,7 @@ int WLDLoader::Open(char *base_path, char *zone_name, Archive *archive) {
this->model_data.models = this->obj_loader->model_data.models;
this->plac_loader = new WLDLoader();
this->plac_loader->Open(NULL, "objects", archive);
this->plac_loader->Open(nullptr, "objects", archive);
if(this->model_data.plac_count) {
delete this->model_data.placeable[0];
+9 -9
View File
@@ -12,9 +12,9 @@
//#define DEBUGPLAC
ZonLoader::ZonLoader() {
this->buffer = NULL;
this->buffer = nullptr;
this->buf_len = -1;
this->archive = NULL;
this->archive = nullptr;
this->status = 0;
}
@@ -112,7 +112,7 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
#ifdef DEBUGEQG
printf("Found .TER file %s\n", (char *)buffer);
#endif
this->terloader.Open(NULL, (char *) buffer, archive);
this->terloader.Open(nullptr, (char *) buffer, archive);
buffer = StartOfModelNames;
this->model_data.zone_model = terloader.model_data.zone_model;
@@ -267,11 +267,11 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
//
if(!(strcmp(model_names[j]+strlen(model_names[j])-3, "ter"))) {
// printf("Skipping .TER file at model number %d\n", j);
this->model_data.models[j] = NULL;
this->model_data.models[j] = nullptr;
continue;
}
// printf("Attempting to open MOD file %s\n", model_names[j]); fflush(stdout);
if(model_loaders[j].Open(NULL, model_names[j], archive)) {
if(model_loaders[j].Open(nullptr, model_names[j], archive)) {
this->model_data.models[j] = new Model;
this->model_data.models[j]->vert_count = model_loaders[j].model_data.zone_model->vert_count;
@@ -305,7 +305,7 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
for(k = 0; k < j; ++k) {
if(!this->model_data.models[k]) {
#ifdef DEBUGEQG
printf("NULL this->model_data.models[k])\n");
printf("nullptr this->model_data.models[k])\n");
#endif
continue;
}
@@ -324,7 +324,7 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
}
}
}
else this->model_data.models[j] = NULL;
else this->model_data.models[j] = nullptr;
}
// printf("Tex count is %i %X\n", tex_count, tex_count);
@@ -336,7 +336,7 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
for(i = 0; i < this->model_data.model_count; ++i) {
if(!this->model_data.models[i]) {
#ifdef DEBUGEQG
printf("NULL this->model_data.models[i])\n");
printf("nullptr this->model_data.models[i])\n");
#endif
continue;
}
@@ -364,7 +364,7 @@ int ZonLoader::Open(char *base_path, char *zone_name, Archive *archive) {
for(i = 0; i < this->model_data.model_count; ++i) {
if(!this->model_data.models[i]) {
#ifdef DEBUGEQG
printf(">NULL this->model_data.models[i])\n");
printf(">nullptr this->model_data.models[i])\n");
#endif
continue;
}
+4 -4
View File
@@ -13,9 +13,9 @@ string GetToken(uchar *&Buffer, int &Position);
Zonv4Loader::Zonv4Loader()
{
this->buffer = NULL;
this->buffer = nullptr;
this->buf_len = -1;
this->archive = NULL;
this->archive = nullptr;
this->status = 0;
}
@@ -94,7 +94,7 @@ int Zonv4Loader::Open(char *base_path, char *zone_name, Archive *archive)
}
}
this->datloader.Open(NULL, ZonName, archive);
this->datloader.Open(nullptr, ZonName, archive);
this->model_data.zone_model = datloader.model_data.zone_model;
@@ -118,7 +118,7 @@ int Zonv4Loader::Open(char *base_path, char *zone_name, Archive *archive)
++str;
}
if(model_loaders[i].Open(NULL, tmp, archive))
if(model_loaders[i].Open(nullptr, tmp, archive))
{
this->model_data.models[i] = new Model;
this->model_data.models[i]->vert_count = model_loaders[i].model_data.zone_model->vert_count;