Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
libdoomsday: Removing Qt dependencies; cleanup
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent c1d40ff commit 32079a5
Show file tree
Hide file tree
Showing 44 changed files with 456 additions and 442 deletions.
Expand Up @@ -57,14 +57,14 @@ class LIBDOOMSDAY_PUBLIC ColorPalettes
/**
* Returns @c true iff a ColorPalette with the specified @a name is present.
*/
bool hasColorPalette(de::String name) const;
bool hasColorPalette(const de::String& name) const;

/**
* Returns the ColorPalette associated with @a name.
*
* @see hasColorPalette()
*/
ColorPalette &colorPalette(de::String name) const;
ColorPalette &colorPalette(const de::String& name) const;

/**
* @param newPalette Color palette to add. Ownership of the palette is given
Expand Down
Expand Up @@ -22,6 +22,7 @@

#include <de/ByteOrder>
#include <de/ByteSubArray>
#include <de/Map>

using namespace de;

Expand Down Expand Up @@ -84,7 +85,7 @@ DE_PIMPL(IdTech1TextureLib)
const LumpCatalog & catalog;
Block palette;
Block pnames;
QHash<String, Texture> textures;
Map<String, Texture, String::InsensitiveLessThan> textures;

Impl(Public *i, const LumpCatalog &catalog) : Base(i), catalog(catalog)
{
Expand All @@ -104,11 +105,11 @@ DE_PIMPL(IdTech1TextureLib)
const auto tex1 = catalog.findAll("TEXTURE1");
const auto tex2 = catalog.findAll("TEXTURE2");

QList<LumpCatalog::LumpPos> texturesPos = {tex2.front(), tex1.front()};
texturesPos += tex2.mid(1);
texturesPos += tex1.mid(1);
List<LumpCatalog::LumpPos> texturesPos = {tex2.front(), tex1.front()};
texturesPos << tex2.mid(1);
texturesPos << tex1.mid(1);

foreach (const auto &pos, texturesPos)
for (const auto &pos : texturesPos)
{
const Block lumpData = catalog.read(pos);
const auto *header = reinterpret_cast<const wad::TextureIndex *>(lumpData.data());
Expand Down Expand Up @@ -144,12 +145,12 @@ DE_PIMPL(IdTech1TextureLib)

IdTech1Image composeTexture(const String &textureName) const
{
const auto found = textures.constFind(textureName);
if (found == textures.constEnd())
const auto found = textures.find(textureName);
if (found == textures.end())
{
return IdTech1Image();
}
const auto &texture = *found;
const auto &texture = found->second;

// Blit all the patches into the image.
Image8 image{texture.size};
Expand All @@ -171,7 +172,7 @@ IdTech1TextureLib::IdTech1TextureLib(const LumpCatalog &catalog)

IdTech1Image IdTech1TextureLib::textureImage(const String &name) const
{
return d->composeTexture(name.toUpper());
return d->composeTexture(name);
}

} // namespace res
Expand Up @@ -56,7 +56,7 @@ class LIBDOOMSDAY_PUBLIC ResourceManifest
*
* @param newIdentityKey New identity key (e.g., a lump/file name).
*/
void addIdentityKey(de::String newIdentityKey);
void addIdentityKey(const de::String& newIdentityKey);

/**
* Returns a list of known-names for the associated resource.
Expand Down
3 changes: 0 additions & 3 deletions doomsday/apps/libdoomsday/include/doomsday/resource/patch.h
Expand Up @@ -79,7 +79,6 @@ class LIBDOOMSDAY_PUBLIC Patch
/// ; otherwise perform no clipping (use the pixel dimensions).
ClipToLogicalDimensions = 0x2
};
Q_DECLARE_FLAGS(Flags, Flag)

public:
/**
Expand Down Expand Up @@ -116,8 +115,6 @@ class LIBDOOMSDAY_PUBLIC Patch
static bool recognize(IByteArray const &data);
};

Q_DECLARE_OPERATORS_FOR_FLAGS(Patch::Flags)

typedef Patch::Metadata PatchMetadata;

} // namespace res
Expand Down
11 changes: 6 additions & 5 deletions doomsday/apps/libdoomsday/include/doomsday/resource/sprites.h
Expand Up @@ -25,13 +25,14 @@
#include "../defs/sprite.h"
#include <de/types.h>
#include <de/Record>
#include <de/Hash>

namespace res {

class LIBDOOMSDAY_PUBLIC Sprites
{
public:
typedef QHash<de::dint, defn::CompiledSpriteRecord> SpriteSet; ///< frame => Sprite
typedef de::Hash<int, defn::CompiledSpriteRecord> SpriteSet; ///< frame => Sprite

static Sprites &get();

Expand All @@ -56,12 +57,12 @@ class LIBDOOMSDAY_PUBLIC Sprites
* @see hasSprite(), spritePtr()
*/
defn::CompiledSpriteRecord &sprite(spritenum_t id, de::dint frame);

/**
* Returns a pointer to the identified Sprite, or @c nullptr.
*/
defn::CompiledSpriteRecord const *spritePtr(spritenum_t id, de::dint frame) const;

SpriteSet const *tryFindSpriteSet(spritenum_t id) const;

/**
Expand All @@ -77,10 +78,10 @@ class LIBDOOMSDAY_PUBLIC Sprites
public:
/// Returns a value in the range [0..Sprite::MAX_VIEWS] if @a angleCode can be
/// interpreted as a sprite view (angle) index; otherwise @c -1
static de::dint toSpriteAngle(QChar angleCode);
static de::dint toSpriteAngle(de::Char angleCode);

/// Returns @c true if @a name is a well-formed sprite name.
static bool isValidSpriteName(de::String name);
static bool isValidSpriteName(const de::String& name);

private:
DE_PRIVATE(d)
Expand Down
30 changes: 15 additions & 15 deletions doomsday/apps/libdoomsday/include/doomsday/resource/textures.h
Expand Up @@ -26,28 +26,28 @@

#include <de/types.h>

#include <QHash>
#include <QSet>
#include <de/Map>
#include <de/Set>

namespace res {

struct TextureSchemeHashKey
{
de::String scheme;
//struct TextureSchemeHashKey
//{
// de::String scheme;

TextureSchemeHashKey(de::String const &s) : scheme(s) {}
bool operator == (TextureSchemeHashKey const &other) const {
return !scheme.compare(other.scheme, Qt::CaseInsensitive);
}
};
// TextureSchemeHashKey(de::String const &s) : scheme(s) {}
// bool operator == (TextureSchemeHashKey const &other) const {
// return !scheme.compare(other.scheme, Qt::CaseInsensitive);
// }
//};

LIBDOOMSDAY_PUBLIC uint qHash(TextureSchemeHashKey const &key);
//LIBDOOMSDAY_PUBLIC uint qHash(TextureSchemeHashKey const &key);

class LIBDOOMSDAY_PUBLIC Textures
{
public:
typedef QHash<TextureSchemeHashKey, TextureScheme *> TextureSchemes;
typedef QSet<Texture *> AllTextures;
typedef Map<de::String, TextureScheme *, de::String::InsensitiveLessThan> TextureSchemes;
typedef Set<Texture *> AllTextures;

static Textures &get();

Expand Down Expand Up @@ -162,7 +162,7 @@ class LIBDOOMSDAY_PUBLIC Textures
* Returns the total number of manifest schemes in the collection.
*/
inline de::dint textureSchemeCount() const {
return allTextureSchemes().count();
return allTextureSchemes().size();
}

/**
Expand Down Expand Up @@ -200,7 +200,7 @@ class LIBDOOMSDAY_PUBLIC Textures
*/
inline TextureManifest &declareTexture(
de::Uri const &uri,
Texture::Flags flags,
de::Flags flags,
de::Vec2ui const &dimensions,
de::Vec2i const &origin,
de::dint uniqueId,
Expand Down
6 changes: 3 additions & 3 deletions doomsday/apps/libdoomsday/include/doomsday/world/materials.h
Expand Up @@ -129,7 +129,7 @@ class LIBDOOMSDAY_PUBLIC Materials
/**
* Returns @c true iff a MaterialScheme exists with the symbolic @a name.
*/
bool isKnownMaterialScheme(de::String name) const;
bool isKnownMaterialScheme(const de::String& name) const;

/**
* Lookup a material resource scheme by symbolic name.
Expand All @@ -141,7 +141,7 @@ class LIBDOOMSDAY_PUBLIC Materials
*
* @see knownMaterialScheme()
*/
MaterialScheme &materialScheme(de::String name) const;
MaterialScheme &materialScheme(const de::String& name) const;

/**
* Returns the total number of material manifest schemes in the collection.
Expand All @@ -153,7 +153,7 @@ class LIBDOOMSDAY_PUBLIC Materials
*
* @param func Callback to make for each MaterialScheme.
*/
de::LoopResult forAllMaterialSchemes(std::function<de::LoopResult (MaterialScheme &)> func) const;
de::LoopResult forAllMaterialSchemes(const std::function<de::LoopResult (MaterialScheme &)>& func) const;

/**
* Lookup a material manifest group by unique @a number.
Expand Down
8 changes: 4 additions & 4 deletions doomsday/apps/libdoomsday/src/defs/sprite.cpp
Expand Up @@ -53,7 +53,7 @@ CompiledSprite::CompiledSprite(Record const &spriteDef)
++viewCount;

int angle = iter->first.value->asInt();
if (views.size() <= angle) views.resize(angle + 1);
if (views.sizei() <= angle) views.resize(angle + 1);

Record const &viewDef = iter->second->as<RecordValue>().dereference();
auto &view = views[angle];
Expand Down Expand Up @@ -126,7 +126,7 @@ bool Sprite::hasView(dint angle) const

//return viewsDict().contains(NumberValue(angle));

return (angle < cmpl.views.size() && !cmpl.views.at(angle).uri.isEmpty());
return (angle < cmpl.views.sizei() && !cmpl.views.at(angle).uri.isEmpty());

/*for (Value const *val : geta("views").elements())
{
Expand Down Expand Up @@ -178,7 +178,7 @@ Sprite::View Sprite::view(de::dint angle) const
if (cmpl.frontOnly) angle = 0;

View v;
if (angle < cmpl.views.size())
if (angle < cmpl.views.sizei())
{
v.material = &cmpl.views.at(angle).uri;
v.mirrorX = cmpl.views.at(angle).mirrorX;
Expand All @@ -194,7 +194,7 @@ Sprite::View Sprite::view(de::dint angle) const
de::Uri const &Sprite::viewMaterial(de::dint angle) const
{
auto const &cmpl = def().compiled();
if (angle < cmpl.views.size())
if (angle < cmpl.views.sizei())
{
return cmpl.views.at(angle).uri;
}
Expand Down
22 changes: 11 additions & 11 deletions doomsday/apps/libdoomsday/src/filesys/fs_main.cpp
Expand Up @@ -683,7 +683,7 @@ bool FS1::checkFileId(de::Uri const &path)

// Calculate the identifier.
FileId fileId = FileId::fromPath(path.compose());
FileIds::iterator place = qLowerBound(d->fileIds.begin(), d->fileIds.end(), fileId);
FileIds::iterator place = std::lower_bound(d->fileIds.begin(), d->fileIds.end(), fileId);
if (place != d->fileIds.end() && *place == fileId) return false;

LOGDEV_RES_XVERBOSE_DEBUGONLY("checkFileId \"%s\" => %s", fileId.path() << fileId); /* path() is debug-only */
Expand Down Expand Up @@ -912,7 +912,7 @@ File1 &FS1::interpret(FileHandle &hndl, String filePath, FileInfo const &info)
FileTypes const &fileTypes = DD_FileTypes();
DE_FOR_EACH_CONST(FileTypes, i, fileTypes)
{
if (NativeFileType const *fileType = dynamic_cast<NativeFileType const *>(*i))
if (NativeFileType const *fileType = dynamic_cast<NativeFileType const *>(i->second))
{
// Already tried this?
if (fileType == &ftypeGuess) continue;
Expand Down Expand Up @@ -1083,7 +1083,7 @@ void FS1::printDirectory(Path path)
PathList found;
if (findAllPaths(path, 0, found))
{
qSort(found.begin(), found.end());
found.sort();

DE_FOR_EACH_CONST(PathList, i, found)
{
Expand Down Expand Up @@ -1164,7 +1164,7 @@ D_CMD(ListLumps)

LumpIndex const &lumpIndex = App_FileSystem().nameIndex();
int const numRecords = lumpIndex.size();
int const numIndexDigits = de::max(3, M_NumDigits(numRecords));
// int const numIndexDigits = de::max(3, M_NumDigits(numRecords));

LOG_RES_MSG("LumpIndex %p (%i records):") << &lumpIndex << numRecords;

Expand All @@ -1175,12 +1175,12 @@ D_CMD(ListLumps)
String containerPath = NativePath(lump.container().composePath()).pretty();
String lumpPath = NativePath(lump.composePath()).pretty();

LOG_RES_MSG(String("%1 - \"%2:%3\" (size: %4 bytes%5)")
.arg(idx++, numIndexDigits, 10, QChar('0'))
.arg(containerPath)
.arg(lumpPath)
.arg(lump.info().size)
.arg(lump.info().isCompressed()? " compressed" : ""));
LOG_RES_MSG(String::format("%04s - \"%s:%s\" (size: %zu bytes%s)",
idx++,
containerPath.c_str(),
lumpPath.c_str(),
lump.info().size,
lump.info().isCompressed() ? " compressed" : ""));
}
LOG_RES_MSG("---End of lumps---");

Expand Down Expand Up @@ -1219,7 +1219,7 @@ D_CMD(ListFiles)
<< NativePath(file.composePath()).pretty()
<< fileCount << (fileCount != 1 ? "files" : "file")
<< (file.hasStartup()? ", startup" : "")
<< (crc? QString(" [%1]").arg(crc, 0, 16) : "");
<< (crc? String::format(" [%x]", crc).c_str() : "");

totalFiles += fileCount;
++totalPackages;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/libdoomsday/src/filesys/fs_util.cpp
Expand Up @@ -261,7 +261,7 @@ dd_bool F_ToNativeSlashes(ddstring_t* dstStr, const ddstring_t* srcStr)
static bool F_IsRelativeToBase(char const *path, char const *base)
{
DE_ASSERT(path != 0 && base != 0);
return !qstrnicmp(path, base, strlen(base));
return !iCmpStrNCase(path, base, strlen(base));
}

/**
Expand Down
17 changes: 9 additions & 8 deletions doomsday/apps/libdoomsday/src/filesys/idgameslink.cpp
Expand Up @@ -56,7 +56,8 @@ DE_PIMPL(IdgamesLink)

Impl(Public *i) : Base(i)
{
localRootPath = "/remote/" + QUrl(self().address()).host();
//localRootPath = "/remote/" + QUrl(self().address()).host();
DE_ASSERT_FAIL("Need to use Uri to parse host");
}

String packageIdentifierForFileEntry(FileEntry const &entry) const
Expand Down Expand Up @@ -176,23 +177,23 @@ void IdgamesLink::parseRepositoryIndex(const Block &data)
if (!currentPath)
{
// This should be a directory path.
auto match = reDir.match(line);
if (match.hasMatch())
RegExpMatch match;
if (reDir.match(line, match))
{
currentPath = match.captured(1);
//qDebug() << "[WebRepositoryLink] Parsing path:" << currentPath;

ignore = !reIncludedPaths.match(currentPath).hasMatch();
ignore = !reIncludedPaths.hasMatch(currentPath);
}
}
else if (!ignore && reTotal.match(line).hasMatch())
else if (!ignore && reTotal.hasMatch(line))
{
// Ignore directory sizes.
}
else if (!ignore)
{
auto match = reFile.match(line);
if (match.hasMatch())
RegExpMatch match;
if (reFile.match(line, match))
{
bool const isFolder = (match.captured(1) == DE_STR("d"));
if (!isFolder)
Expand All @@ -202,7 +203,7 @@ void IdgamesLink::parseRepositoryIndex(const Block &data)
continue;

auto &entry = tree->insert((currentPath / name).lower());
entry.size = match.captured(2).toULongLong(nullptr, 10);;
entry.size = std::strtoull(match.captured(2), nullptr, 10);
entry.modTime = Time::fromText(match.captured(3), Time::UnixLsStyleDateTime);
}
}
Expand Down

0 comments on commit 32079a5

Please sign in to comment.