Skip to content

Commit

Permalink
Cleanup|libdoomsday: Whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jul 29, 2016
1 parent 385623e commit 8df03bc
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 96 deletions.
Expand Up @@ -66,7 +66,7 @@ class LIBDOOMSDAY_PUBLIC Materials
* @see hasMaterialManifest(), MaterialManifest::hasMaterial()
*/
inline bool hasMaterial(de::Uri const &path) const {
if(hasMaterialManifest(path)) return materialManifest(path).hasMaterial();
if (hasMaterialManifest(path)) return materialManifest(path).hasMaterial();
return false;
}

Expand Down
48 changes: 24 additions & 24 deletions doomsday/apps/libdoomsday/src/filesys/readfile.cpp
Expand Up @@ -58,30 +58,30 @@ size_t M_ReadFile(const char* name, char** buffer)

AutoStr *M_ReadFileIntoString(ddstring_t const *path, dd_bool *isCustom)
{
if(isCustom) *isCustom = false;
if (isCustom) *isCustom = false;

if(Str_StartsWith(path, "LumpIndex:"))
if (Str_StartsWith(path, "LumpIndex:"))
{
bool isNumber;
lumpnum_t const lumpNum = String(Str_Text(path) + 10).toInt(&isNumber);
LumpIndex const &lumpIndex = App_FileSystem().nameIndex();
if(isNumber && lumpIndex.hasLump(lumpNum))
if (isNumber && lumpIndex.hasLump(lumpNum))
{
File1 &lump = lumpIndex.lump(lumpNum);
if(isCustom)
if (isCustom)
{
/// @todo Custom status for contained files is not inherited from the container?
*isCustom = (lump.isContained()? lump.container().hasCustom() : lump.hasCustom());
}

// Ignore zero-length lumps.
if(!lump.size()) return 0;
if (!lump.size()) return 0;

// Ensure the resulting string is terminated.
AutoStr *string = Str_PartAppend(AutoStr_NewStd(), (char const *)lump.cache(), 0, lump.size());
lump.unlock();

if(Str_IsEmpty(string))
if (Str_IsEmpty(string))
return 0;

return string;
Expand All @@ -90,28 +90,28 @@ AutoStr *M_ReadFileIntoString(ddstring_t const *path, dd_bool *isCustom)
return 0;
}

if(Str_StartsWith(path, "Lumps:"))
if (Str_StartsWith(path, "Lumps:"))
{
char const *lumpName = Str_Text(path) + 6;
LumpIndex const &lumpIndex = App_FileSystem().nameIndex();
if(!lumpIndex.contains(String(lumpName) + ".lmp"))
if (!lumpIndex.contains(String(lumpName) + ".lmp"))
return 0;

File1 &lump = lumpIndex[lumpIndex.findLast(String(lumpName) + ".lmp")];
if(isCustom)
if (isCustom)
{
/// @todo Custom status for contained files is not inherited from the container?
*isCustom = (lump.isContained()? lump.container().hasCustom() : lump.hasCustom());
}

// Ignore zero-length lumps.
if(!lump.size()) return 0;
if (!lump.size()) return 0;

// Ensure the resulting string is terminated.
AutoStr *string = Str_PartAppend(AutoStr_NewStd(), (char const *)lump.cache(), 0, lump.size());
lump.unlock();

if(Str_IsEmpty(string))
if (Str_IsEmpty(string))
return 0;

return string;
Expand All @@ -122,7 +122,7 @@ AutoStr *M_ReadFileIntoString(ddstring_t const *path, dd_bool *isCustom)
{
QScopedPointer<FileHandle> hndl(&App_FileSystem().openFile(Str_Text(path), "rb"));

if(isCustom)
if (isCustom)
{
/// @todo Custom status for contained files is not inherited from the container?
File1 &file = hndl->file();
Expand All @@ -131,7 +131,7 @@ AutoStr *M_ReadFileIntoString(ddstring_t const *path, dd_bool *isCustom)

// Ignore zero-length lumps.
AutoStr *string = nullptr;
if(size_t lumpLength = hndl->length())
if (size_t lumpLength = hndl->length())
{
// Read in the whole thing and ensure the resulting string is terminated.
Block buffer;
Expand All @@ -142,25 +142,25 @@ AutoStr *M_ReadFileIntoString(ddstring_t const *path, dd_bool *isCustom)

App_FileSystem().releaseFile(hndl->file());

if(!string || Str_IsEmpty(string))
if (!string || Str_IsEmpty(string))
return 0;

return string;
}
catch(FS1::NotFoundError const &)
catch (FS1::NotFoundError const &)
{} // Ignore this error.


// Perhaps a local file known to the native file system?
char *readBuf = 0;
if(size_t bytesRead = M_ReadFile(Str_Text(path), &readBuf))
if (size_t bytesRead = M_ReadFile(Str_Text(path), &readBuf))
{
// Ensure the resulting string is terminated.
AutoStr *string = Str_PartAppend(AutoStr_New(), readBuf, 0, int(bytesRead));
Z_Free(readBuf);

// Ignore zero-length files.
if(Str_IsEmpty(string))
if (Str_IsEmpty(string))
return 0;

return string;
Expand All @@ -187,21 +187,21 @@ static size_t FileReader(const char* name, char** buffer)
// First try with LZSS.
LZFILE *file = lzOpen((char*) name, "rp");

if(NULL != file)
if (NULL != file)
{
#define BSIZE 1024

char readBuf[BSIZE];

// Read 1kb pieces until file ends.
while(!lzEOF(file))
while (!lzEOF(file))
{
size_t bytesRead = lzRead(readBuf, BSIZE, file);
char* newBuf;

// Allocate more memory.
newBuf = (char*) Z_Malloc(length + bytesRead, PU_APPSTATIC, 0);
if(buf != NULL)
if (buf != NULL)
{
memcpy(newBuf, buf, length);
Z_Free(buf);
Expand All @@ -221,20 +221,20 @@ static size_t FileReader(const char* name, char** buffer)
}

handle = open(name, O_RDONLY | O_BINARY, 0666);
if(handle == -1)
if (handle == -1)
{
LOG_RES_WARNING("Failed opening \"%s\" for reading") << name;
return length;
}

if(-1 == fstat(handle, &fileinfo))
if (-1 == fstat(handle, &fileinfo))
{
LOG_RES_ERROR("Couldn't read file \"%s\"") << name;
return 0;
}

length = fileinfo.st_size;
if(!length)
if (!length)
{
*buffer = 0;
return 0;
Expand All @@ -245,7 +245,7 @@ static size_t FileReader(const char* name, char** buffer)

size_t bytesRead = read(handle, buf, length);
close(handle);
if(bytesRead < length)
if (bytesRead < length)
{
LOG_RES_ERROR("Couldn't read file \"%s\"") << name;
}
Expand Down
12 changes: 6 additions & 6 deletions doomsday/apps/libdoomsday/src/resource/colorpalettes.cpp
Expand Up @@ -68,7 +68,7 @@ dint ColorPalettes::colorPaletteCount() const
ColorPalette &ColorPalettes::colorPalette(Id const &id) const
{
auto found = d->colorPalettes.find(id.isNone()? d->defaultColorPalette : id);
if(found != d->colorPalettes.end()) return *found.value();
if (found != d->colorPalettes.end()) return *found.value();
/// @throw MissingResourceError An unknown/invalid id was specified.
throw Resources::MissingResourceError("ColorPalettes::colorPalette",
"Invalid ID " + id.asText());
Expand All @@ -77,7 +77,7 @@ ColorPalette &ColorPalettes::colorPalette(Id const &id) const
String ColorPalettes::colorPaletteName(ColorPalette &palette) const
{
QList<String> const names = d->colorPaletteNames.keys(&palette);
if(!names.isEmpty())
if (!names.isEmpty())
{
return names.first();
}
Expand All @@ -92,26 +92,26 @@ bool ColorPalettes::hasColorPalette(String name) const
ColorPalette &ColorPalettes::colorPalette(String name) const
{
auto found = d->colorPaletteNames.find(name);
if(found != d->colorPaletteNames.end()) return *found.value();
if (found != d->colorPaletteNames.end()) return *found.value();
/// @throw MissingResourceError An unknown name was specified.
throw Resources::MissingResourceError("ColorPalettes::colorPalette", "Unknown name '" + name + "'");
}

void ColorPalettes::addColorPalette(res::ColorPalette &newPalette, String const &name)
{
// Do we already own this palette?
if(d->colorPalettes.contains(newPalette.id()))
if (d->colorPalettes.contains(newPalette.id()))
return;

d->colorPalettes.insert(newPalette.id(), &newPalette);

if(!name.isEmpty())
if (!name.isEmpty())
{
d->colorPaletteNames.insert(name, &newPalette);
}

// If this is the first palette automatically set it as the default.
if(d->colorPalettes.count() == 1)
if (d->colorPalettes.count() == 1)
{
d->defaultColorPalette = newPalette.id();
}
Expand Down
36 changes: 18 additions & 18 deletions doomsday/apps/libdoomsday/src/resource/composite.cpp
Expand Up @@ -40,7 +40,7 @@ static String readAndPercentEncodeRawName(de::Reader &from)
{
/// @attention The raw ASCII name is not necessarily terminated.
char asciiName[9];
for(int i = 0; i < 8; ++i) { from >> asciiName[i]; }
for (int i = 0; i < 8; ++i) { from >> asciiName[i]; }
asciiName[8] = 0;

// WAD format allows characters not typically permitted in native paths.
Expand All @@ -62,8 +62,8 @@ void Composite::Component::setOrigin(const Vector2i &origin)

bool Composite::Component::operator == (Component const &other) const
{
if(lumpNum() != other.lumpNum()) return false;
if(origin() != other.origin()) return false;
if (lumpNum() != other.lumpNum()) return false;
if (origin() != other.origin()) return false;
return true;
}

Expand Down Expand Up @@ -110,14 +110,14 @@ Composite::Composite(String const &percentEncodedName,

bool Composite::operator == (Composite const &other) const
{
if(dimensions() != other.dimensions()) return false;
if(logicalDimensions() != other.logicalDimensions()) return false;
if(componentCount() != other.componentCount()) return false;
if (dimensions() != other.dimensions()) return false;
if (logicalDimensions() != other.logicalDimensions()) return false;
if (componentCount() != other.componentCount()) return false;

// Check each component also.
for(int i = 0; i < componentCount(); ++i)
for (int i = 0; i < componentCount(); ++i)
{
if(components()[i] != other.components()[i]) return false;
if (components()[i] != other.components()[i]) return false;
}

return true;
Expand Down Expand Up @@ -193,7 +193,7 @@ Composite *Composite::constructFrom(de::Reader &reader,
pctex->d->logicalDimensions =
pctex->d->dimensions = Vector2ui(dimensions[0], dimensions[1]);

if(format == DoomFormat)
if (format == DoomFormat)
{
// Next is some more unused junk from a previous format version.
dint32 unused32;
Expand All @@ -212,7 +212,7 @@ Composite *Composite::constructFrom(de::Reader &reader,
pctex->d->logicalDimensions.y));

int foundComponentCount = 0;
for(dint16 i = 0; i < componentCount; ++i)
for (dint16 i = 0; i < componentCount; ++i)
{
Component comp;

Expand All @@ -223,7 +223,7 @@ Composite *Composite::constructFrom(de::Reader &reader,
dint16 pnamesIndex;
reader >> pnamesIndex;

if(pnamesIndex < 0 || pnamesIndex >= patchNames.count())
if (pnamesIndex < 0 || pnamesIndex >= patchNames.count())
{
LOG_RES_WARNING("Invalid PNAMES index %i in composite texture \"%s\", ignoring.")
<< pnamesIndex << pctex->d->name;
Expand All @@ -232,30 +232,30 @@ Composite *Composite::constructFrom(de::Reader &reader,
{
comp.setLumpNum(patchNames[pnamesIndex].lumpNum());

if(comp.lumpNum() >= 0)
if (comp.lumpNum() >= 0)
{
/// There is now one more found component.
foundComponentCount += 1;

File1 &file = App_FileSystem().lump(comp.lumpNum());

// If this a "custom" component - the whole texture is.
if(file.container().hasCustom())
if (file.container().hasCustom())
{
pctex->d->flags |= Custom;
}

// If this is a Patch - unite the geometry of the component.
ByteRefArray fileData = ByteRefArray(file.cache(), file.size());
if(res::Patch::recognize(fileData))
if (res::Patch::recognize(fileData))
{
try
{
auto info = res::Patch::loadMetadata(fileData);
geom |= QRect(QPoint(comp.origin().x, comp.origin().y),
QSize(info.dimensions.x, info.dimensions.y));
}
catch(IByteArray::OffsetError const &)
catch (IByteArray::OffsetError const &)
{
LOG_RES_WARNING("Component image \"%s\" (#%i) does not appear to be a valid Patch. "
"It may be missing from composite texture \"%s\".")
Expand All @@ -281,13 +281,13 @@ Composite *Composite::constructFrom(de::Reader &reader,
}

// Clip and apply the final height.
if(geom.top() < 0) geom.setTop(0);
if(geom.height() > int(pctex->d->logicalDimensions.y))
if (geom.top() < 0) geom.setTop(0);
if (geom.height() > int(pctex->d->logicalDimensions.y))
{
pctex->d->dimensions.y = geom.height();
}

if(!foundComponentCount)
if (!foundComponentCount)
{
LOG_RES_WARNING("Zero valid component images in composite texture %s (will be ignored).")
<< pctex->d->name;
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/libdoomsday/src/resource/databundle.cpp
Expand Up @@ -313,7 +313,7 @@ DENG2_PIMPL(DataBundle), public Lockable
// WAD files sometimes come with a matching TXT file.
if (format == Pwad || format == Iwad)
{
if(File const *wadTxt = root.tryLocate<File const>(
if (File const *wadTxt = root.tryLocate<File const>(
dataFilePath.fileNamePath() / dataFilePath.fileNameWithoutExtension() + ".txt"))
{
Block txt;
Expand Down Expand Up @@ -410,7 +410,7 @@ DENG2_PIMPL(DataBundle), public Lockable
subset = VAR_REQUIRES;
}
container->packageMetadata().insertToSortedArray(subset, new TextValue(versionedPackageId));

/*
qDebug() << container->d->versionedPackageId
<< "[" << container->d->pkgLink->objectNamespace().gets("package.tags", "") << "]"
Expand Down Expand Up @@ -532,7 +532,7 @@ DENG2_PIMPL(DataBundle), public Lockable

if (Info::BlockElement const *english = rootBlock.findAs<Info::BlockElement>("english"))
{
if(english->blockType() == "language")
if (english->blockType() == "language")
{
// Doomsday must understand the version number.
meta.set(VAR_VERSION, Version(english->keyValue("version")).asText());
Expand Down

0 comments on commit 8df03bc

Please sign in to comment.