Use C99 integer types instead of Qt's

This commit is contained in:
Jonas Kulla 2013-09-04 13:30:14 +02:00
parent a75dea3ffe
commit 0253b6ed2b
7 changed files with 47 additions and 47 deletions

View File

@ -36,16 +36,16 @@
struct RGSS_entryData struct RGSS_entryData
{ {
qint64 offset; int64_t offset;
quint64 size; uint64_t size;
quint32 startMagic; uint32_t startMagic;
}; };
struct RGSS_entryHandle struct RGSS_entryHandle
{ {
RGSS_entryData data; RGSS_entryData data;
quint32 currentMagic; uint32_t currentMagic;
quint64 currentOffset; uint64_t currentOffset;
PHYSFS_Io *io; PHYSFS_Io *io;
RGSS_entryHandle(const RGSS_entryData &data) RGSS_entryHandle(const RGSS_entryData &data)
@ -71,7 +71,7 @@ struct RGSS_archiveData
}; };
static bool static bool
readUint32(PHYSFS_Io *io, quint32 &result) readUint32(PHYSFS_Io *io, uint32_t &result)
{ {
char buff[4]; char buff[4];
PHYSFS_sint64 count = io->read(io, buff, 4); PHYSFS_sint64 count = io->read(io, buff, 4);
@ -92,10 +92,10 @@ readUint32(PHYSFS_Io *io, quint32 &result)
#define PHYSFS_ALLOC(type) \ #define PHYSFS_ALLOC(type) \
static_cast<type*>(PHYSFS_getAllocator()->Malloc(sizeof(type))) static_cast<type*>(PHYSFS_getAllocator()->Malloc(sizeof(type)))
static inline quint32 static inline uint32_t
advanceMagic(quint32 &magic) advanceMagic(uint32_t &magic)
{ {
quint32 old = magic; uint32_t old = magic;
magic = magic * 7 + 3; magic = magic * 7 + 3;
@ -104,10 +104,10 @@ advanceMagic(quint32 &magic)
struct MagicState struct MagicState
{ {
quint32 magic; uint32_t magic;
quint64 offset; uint64_t offset;
MagicState(quint64 offset = 0) MagicState(uint64_t offset = 0)
: offset(offset) : offset(offset)
{ {
magic = RGSS_MAGIC; magic = RGSS_MAGIC;
@ -116,9 +116,9 @@ struct MagicState
advanceBlock(); advanceBlock();
} }
quint8 advancePath() uint8_t advancePath()
{ {
quint8 ret = magic & 0xFF; uint8_t ret = magic & 0xFF;
offset++; offset++;
advanceBlock(); advanceBlock();
@ -126,9 +126,9 @@ struct MagicState
return ret; return ret;
} }
quint8 advanceData() uint8_t advanceData()
{ {
quint8 ret = magic & 0xFF; uint8_t ret = magic & 0xFF;
if (offset++ % 4 == 0) if (offset++ % 4 == 0)
advanceBlock(); advanceBlock();
@ -148,21 +148,21 @@ RGSS_ioRead(PHYSFS_Io *self, void *buffer, PHYSFS_uint64 len)
{ {
RGSS_entryHandle *entry = static_cast<RGSS_entryHandle*>(self->opaque); RGSS_entryHandle *entry = static_cast<RGSS_entryHandle*>(self->opaque);
quint64 toRead = qMin(entry->data.size - entry->currentOffset, len); uint64_t toRead = min<uint64_t>(entry->data.size - entry->currentOffset, len);
quint64 offs = entry->currentOffset; uint64_t offs = entry->currentOffset;
entry->io->seek(entry->io, entry->data.offset + offs); entry->io->seek(entry->io, entry->data.offset + offs);
quint64 buffI = 0; uint64_t buffI = 0;
for (quint64 o = offs; o < offs + toRead;) for (uint64_t o = offs; o < offs + toRead;)
{ {
quint8 bitOffset = (0x8 * (o % 4)); uint8_t bitOffset = (0x8 * (o % 4));
quint8 magicByte = (entry->currentMagic >> bitOffset) & 0xFF; uint8_t magicByte = (entry->currentMagic >> bitOffset) & 0xFF;
quint8 byte; uint8_t byte;
entry->io->read(entry->io, &byte, 1); entry->io->read(entry->io, &byte, 1);
((quint8*) buffer)[buffI++] = byte ^ magicByte; ((uint8_t*) buffer)[buffI++] = byte ^ magicByte;
if (++o % 4 == 0) if (++o % 4 == 0)
advanceMagic(entry->currentMagic); advanceMagic(entry->currentMagic);
@ -192,8 +192,8 @@ RGSS_ioSeek(PHYSFS_Io *self, PHYSFS_uint64 offset)
} }
/* For each 4 bytes sought, advance magic */ /* For each 4 bytes sought, advance magic */
quint64 dwordsSought = (offset - entry->currentOffset) / 4; uint64_t dwordsSought = (offset - entry->currentOffset) / 4;
for (quint64 i = 0; i < dwordsSought; ++i) for (uint64_t i = 0; i < dwordsSought; ++i)
advanceMagic(entry->currentMagic); advanceMagic(entry->currentMagic);
entry->currentOffset = offset; entry->currentOffset = offset;
@ -262,7 +262,7 @@ RGSS_openArchive(PHYSFS_Io *io, const char *, int forWrite)
return 0; return 0;
/* Check header */ /* Check header */
quint32 header1, header2; uint32_t header1, header2;
readUint32(io, header1); readUint32(io, header1);
readUint32(io, header2); readUint32(io, header2);
@ -272,13 +272,13 @@ RGSS_openArchive(PHYSFS_Io *io, const char *, int forWrite)
RGSS_archiveData *data = new RGSS_archiveData; RGSS_archiveData *data = new RGSS_archiveData;
data->archiveIo = io; data->archiveIo = io;
quint32 magic = RGSS_MAGIC; uint32_t magic = RGSS_MAGIC;
while (true) while (true)
{ {
/* Read filename length, /* Read filename length,
* if nothing was read, no files remain */ * if nothing was read, no files remain */
quint32 nameLen; uint32_t nameLen;
if (!readUint32(io, nameLen)) if (!readUint32(io, nameLen))
break; break;
@ -296,7 +296,7 @@ RGSS_openArchive(PHYSFS_Io *io, const char *, int forWrite)
} }
nameBuf[i] = 0; nameBuf[i] = 0;
quint32 entrySize; uint32_t entrySize;
readUint32(io, entrySize); readUint32(io, entrySize);
entrySize ^= advanceMagic(magic); entrySize ^= advanceMagic(magic);

View File

@ -28,7 +28,7 @@
struct GlobalIBO struct GlobalIBO
{ {
IBO::ID ibo; IBO::ID ibo;
QVector<quint32> buffer; QVector<uint32_t> buffer;
GlobalIBO() GlobalIBO()
{ {

View File

@ -134,8 +134,8 @@ struct GPUTimer
const int iter; const int iter;
uchar ind; uchar ind;
quint64 acc; uint64_t acc;
qint32 counter; int32_t counter;
bool first; bool first;
GPUTimer(int iter) GPUTimer(int iter)
@ -186,8 +186,8 @@ struct CPUTimer
{ {
const int iter; const int iter;
quint64 acc; uint64_t acc;
qint32 counter; int32_t counter;
sf::Clock clock; sf::Clock clock;
CPUTimer(int iter) CPUTimer(int iter)

View File

@ -27,7 +27,7 @@
#include "globalstate.h" #include "globalstate.h"
#include "global-ibo.h" #include "global-ibo.h"
typedef quint32 index_t; typedef uint32_t index_t;
#define _GL_INDEX_TYPE GL_UNSIGNED_INT #define _GL_INDEX_TYPE GL_UNSIGNED_INT
struct ColorQuadArray struct ColorQuadArray

View File

@ -32,10 +32,10 @@
#include <QDebug> #include <QDebug>
typedef QPair<quint16, quint16> Size; typedef QPair<uint16_t, uint16_t> Size;
typedef QQueue<TexFBO> ObjList; typedef QQueue<TexFBO> ObjList;
static quint32 byteCount(Size &s) static uint32_t byteCount(Size &s)
{ {
return s.first * s.second * 4; return s.first * s.second * 4;
} }
@ -62,18 +62,18 @@ struct TexPoolPrivate
QLinkedList<TexFBO> priorityQueue; QLinkedList<TexFBO> priorityQueue;
/* Maximal allowed cache memory */ /* Maximal allowed cache memory */
const quint32 maxMemSize; const uint32_t maxMemSize;
/* Current amound of memory consumed by the cache */ /* Current amound of memory consumed by the cache */
quint32 memSize; uint32_t memSize;
/* Current amount of TexFBOs cached */ /* Current amount of TexFBOs cached */
quint16 objCount; uint16_t objCount;
/* Has this pool been disabled? */ /* Has this pool been disabled? */
bool disabled; bool disabled;
TexPoolPrivate(quint32 maxMemSize) TexPoolPrivate(uint32_t maxMemSize)
: maxMemSize(maxMemSize), : maxMemSize(maxMemSize),
memSize(0), memSize(0),
objCount(0), objCount(0),
@ -81,7 +81,7 @@ struct TexPoolPrivate
{} {}
}; };
TexPool::TexPool(quint32 maxMemSize) TexPool::TexPool(uint32_t maxMemSize)
{ {
p = new TexPoolPrivate(maxMemSize); p = new TexPoolPrivate(maxMemSize);
} }
@ -158,7 +158,7 @@ void TexPool::release(TexFBO &obj)
Size size(obj.width, obj.height); 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, /* If caching this object would spill over the allowed memory budget,
* delete least used objects until we're good again */ * delete least used objects until we're good again */
@ -181,7 +181,7 @@ void TexPool::release(TexFBO &obj)
TexFBO::fini(last.obj); TexFBO::fini(last.obj);
quint32 removedMem = byteCount(removedSize); uint32_t removedMem = byteCount(removedSize);
newMemSize -= removedMem; newMemSize -= removedMem;
p->memSize -= removedMem; p->memSize -= removedMem;
--p->objCount; --p->objCount;

View File

@ -29,7 +29,7 @@ struct TexPoolPrivate;
class TexPool class TexPool
{ {
public: public:
TexPool(quint32 maxMemSize = 20000000 /* 20 MB */); TexPool(uint32_t maxMemSize = 20000000 /* 20 MB */);
~TexPool(); ~TexPool();
TexFBO request(int width, int height); TexFBO request(int width, int height);

View File

@ -245,7 +245,7 @@ struct TilemapPrivate
} elem; } elem;
/* Replica bitmask */ /* Replica bitmask */
quint8 replicas; uint8_t replicas;
/* Affected by: autotiles, tileset */ /* Affected by: autotiles, tileset */
bool atlasSizeDirty; bool atlasSizeDirty;