From 0253b6ed2b8025ff68f701162b5289437f39e0cf Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Wed, 4 Sep 2013 13:30:14 +0200 Subject: [PATCH] Use C99 integer types instead of Qt's --- src/filesystem.cpp | 60 +++++++++++++++++++++++----------------------- src/global-ibo.h | 2 +- src/graphics.cpp | 8 +++---- src/quadarray.h | 2 +- src/texpool.cpp | 18 +++++++------- src/texpool.h | 2 +- src/tilemap.cpp | 2 +- 7 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/filesystem.cpp b/src/filesystem.cpp index d9ca0a3..b72800d 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -36,16 +36,16 @@ struct RGSS_entryData { - qint64 offset; - quint64 size; - quint32 startMagic; + int64_t offset; + uint64_t size; + uint32_t startMagic; }; struct RGSS_entryHandle { RGSS_entryData data; - quint32 currentMagic; - quint64 currentOffset; + uint32_t currentMagic; + uint64_t currentOffset; PHYSFS_Io *io; RGSS_entryHandle(const RGSS_entryData &data) @@ -71,7 +71,7 @@ struct RGSS_archiveData }; static bool -readUint32(PHYSFS_Io *io, quint32 &result) +readUint32(PHYSFS_Io *io, uint32_t &result) { char buff[4]; PHYSFS_sint64 count = io->read(io, buff, 4); @@ -92,10 +92,10 @@ readUint32(PHYSFS_Io *io, quint32 &result) #define PHYSFS_ALLOC(type) \ static_cast(PHYSFS_getAllocator()->Malloc(sizeof(type))) -static inline quint32 -advanceMagic(quint32 &magic) +static inline uint32_t +advanceMagic(uint32_t &magic) { - quint32 old = magic; + uint32_t old = magic; magic = magic * 7 + 3; @@ -104,10 +104,10 @@ advanceMagic(quint32 &magic) struct MagicState { - quint32 magic; - quint64 offset; + uint32_t magic; + uint64_t offset; - MagicState(quint64 offset = 0) + MagicState(uint64_t offset = 0) : offset(offset) { magic = RGSS_MAGIC; @@ -116,9 +116,9 @@ struct MagicState advanceBlock(); } - quint8 advancePath() + uint8_t advancePath() { - quint8 ret = magic & 0xFF; + uint8_t ret = magic & 0xFF; offset++; advanceBlock(); @@ -126,9 +126,9 @@ struct MagicState return ret; } - quint8 advanceData() + uint8_t advanceData() { - quint8 ret = magic & 0xFF; + uint8_t ret = magic & 0xFF; if (offset++ % 4 == 0) advanceBlock(); @@ -148,21 +148,21 @@ RGSS_ioRead(PHYSFS_Io *self, void *buffer, PHYSFS_uint64 len) { RGSS_entryHandle *entry = static_cast(self->opaque); - quint64 toRead = qMin(entry->data.size - entry->currentOffset, len); - quint64 offs = entry->currentOffset; + uint64_t toRead = min(entry->data.size - entry->currentOffset, len); + uint64_t offs = entry->currentOffset; entry->io->seek(entry->io, entry->data.offset + offs); - quint64 buffI = 0; - for (quint64 o = offs; o < offs + toRead;) + uint64_t buffI = 0; + for (uint64_t o = offs; o < offs + toRead;) { - quint8 bitOffset = (0x8 * (o % 4)); - quint8 magicByte = (entry->currentMagic >> bitOffset) & 0xFF; + uint8_t bitOffset = (0x8 * (o % 4)); + uint8_t magicByte = (entry->currentMagic >> bitOffset) & 0xFF; - quint8 byte; + uint8_t byte; entry->io->read(entry->io, &byte, 1); - ((quint8*) buffer)[buffI++] = byte ^ magicByte; + ((uint8_t*) buffer)[buffI++] = byte ^ magicByte; if (++o % 4 == 0) advanceMagic(entry->currentMagic); @@ -192,8 +192,8 @@ RGSS_ioSeek(PHYSFS_Io *self, PHYSFS_uint64 offset) } /* For each 4 bytes sought, advance magic */ - quint64 dwordsSought = (offset - entry->currentOffset) / 4; - for (quint64 i = 0; i < dwordsSought; ++i) + uint64_t dwordsSought = (offset - entry->currentOffset) / 4; + for (uint64_t i = 0; i < dwordsSought; ++i) advanceMagic(entry->currentMagic); entry->currentOffset = offset; @@ -262,7 +262,7 @@ RGSS_openArchive(PHYSFS_Io *io, const char *, int forWrite) return 0; /* Check header */ - quint32 header1, header2; + uint32_t header1, header2; readUint32(io, header1); readUint32(io, header2); @@ -272,13 +272,13 @@ RGSS_openArchive(PHYSFS_Io *io, const char *, int forWrite) RGSS_archiveData *data = new RGSS_archiveData; data->archiveIo = io; - quint32 magic = RGSS_MAGIC; + uint32_t magic = RGSS_MAGIC; while (true) { /* Read filename length, * if nothing was read, no files remain */ - quint32 nameLen; + uint32_t nameLen; if (!readUint32(io, nameLen)) break; @@ -296,7 +296,7 @@ RGSS_openArchive(PHYSFS_Io *io, const char *, int forWrite) } nameBuf[i] = 0; - quint32 entrySize; + uint32_t entrySize; readUint32(io, entrySize); entrySize ^= advanceMagic(magic); diff --git a/src/global-ibo.h b/src/global-ibo.h index 99ad0e2..b50ef80 100644 --- a/src/global-ibo.h +++ b/src/global-ibo.h @@ -28,7 +28,7 @@ struct GlobalIBO { IBO::ID ibo; - QVector buffer; + QVector buffer; GlobalIBO() { diff --git a/src/graphics.cpp b/src/graphics.cpp index 667bf17..09433e8 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -134,8 +134,8 @@ struct GPUTimer const int iter; uchar ind; - quint64 acc; - qint32 counter; + uint64_t acc; + int32_t counter; bool first; GPUTimer(int iter) @@ -186,8 +186,8 @@ struct CPUTimer { const int iter; - quint64 acc; - qint32 counter; + uint64_t acc; + int32_t counter; sf::Clock clock; CPUTimer(int iter) diff --git a/src/quadarray.h b/src/quadarray.h index 7d93242..65bb476 100644 --- a/src/quadarray.h +++ b/src/quadarray.h @@ -27,7 +27,7 @@ #include "globalstate.h" #include "global-ibo.h" -typedef quint32 index_t; +typedef uint32_t index_t; #define _GL_INDEX_TYPE GL_UNSIGNED_INT struct ColorQuadArray diff --git a/src/texpool.cpp b/src/texpool.cpp index 149af2b..cc5271a 100644 --- a/src/texpool.cpp +++ b/src/texpool.cpp @@ -32,10 +32,10 @@ #include -typedef QPair Size; +typedef QPair Size; typedef QQueue ObjList; -static quint32 byteCount(Size &s) +static uint32_t byteCount(Size &s) { return s.first * s.second * 4; } @@ -62,18 +62,18 @@ struct TexPoolPrivate QLinkedList priorityQueue; /* Maximal allowed cache memory */ - const quint32 maxMemSize; + const uint32_t maxMemSize; /* Current amound of memory consumed by the cache */ - quint32 memSize; + uint32_t memSize; /* Current amount of TexFBOs cached */ - quint16 objCount; + uint16_t objCount; /* Has this pool been disabled? */ bool disabled; - TexPoolPrivate(quint32 maxMemSize) + TexPoolPrivate(uint32_t maxMemSize) : maxMemSize(maxMemSize), memSize(0), objCount(0), @@ -81,7 +81,7 @@ struct TexPoolPrivate {} }; -TexPool::TexPool(quint32 maxMemSize) +TexPool::TexPool(uint32_t maxMemSize) { p = new TexPoolPrivate(maxMemSize); } @@ -158,7 +158,7 @@ void TexPool::release(TexFBO &obj) Size size(obj.width, obj.height); - quint32 newMemSize = p->memSize + byteCount(size); + uint32_t newMemSize = p->memSize + byteCount(size); /* If caching this object would spill over the allowed memory budget, * delete least used objects until we're good again */ @@ -181,7 +181,7 @@ void TexPool::release(TexFBO &obj) TexFBO::fini(last.obj); - quint32 removedMem = byteCount(removedSize); + uint32_t removedMem = byteCount(removedSize); newMemSize -= removedMem; p->memSize -= removedMem; --p->objCount; diff --git a/src/texpool.h b/src/texpool.h index 568119a..d84d373 100644 --- a/src/texpool.h +++ b/src/texpool.h @@ -29,7 +29,7 @@ struct TexPoolPrivate; class TexPool { public: - TexPool(quint32 maxMemSize = 20000000 /* 20 MB */); + TexPool(uint32_t maxMemSize = 20000000 /* 20 MB */); ~TexPool(); TexFBO request(int width, int height); diff --git a/src/tilemap.cpp b/src/tilemap.cpp index c340838..403dafd 100644 --- a/src/tilemap.cpp +++ b/src/tilemap.cpp @@ -245,7 +245,7 @@ struct TilemapPrivate } elem; /* Replica bitmask */ - quint8 replicas; + uint8_t replicas; /* Affected by: autotiles, tileset */ bool atlasSizeDirty;