Browse Source

Remove the std namespace from uint32_t

Again to help older compileres that aren't C++11 aware.
pull/734/head
Anders Jenbo 6 years ago
parent
commit
a3505ab904
  1. 2
      Source/codec.cpp
  2. 20
      Source/mpqapi.cpp
  3. 2
      Source/sha.cpp
  4. 2
      SourceX/display.cpp
  5. 2
      SourceX/display.h

2
Source/codec.cpp

@ -66,7 +66,7 @@ error:
void codec_init_key(int unused, char *pszPassword)
{
char key[136]; // last 64 bytes are the SHA1
std::uint32_t rand_state = 0x7058;
uint32_t rand_state = 0x7058;
for (std::size_t i = 0; i < sizeof(key); ++i) {
rand_state = rand_state * 214013 + 2531011;
key[i] = rand_state >> 16; // Downcasting to char keeps the 2 least-significant bytes

20
Source/mpqapi.cpp

@ -262,11 +262,11 @@ private:
memset(&fhdr, 0, sizeof(fhdr));
fhdr.signature = SDL_SwapLE32('\x1AQPM');
fhdr.headersize = SDL_SwapLE32(32);
fhdr.filesize = SDL_SwapLE32(static_cast<std::uint32_t>(size));
fhdr.filesize = SDL_SwapLE32(static_cast<uint32_t>(size));
fhdr.version = SDL_SwapLE16(0);
fhdr.sectorsizeid = SDL_SwapLE16(3);
fhdr.hashoffset = SDL_SwapLE32(static_cast<std::uint32_t>(kMpqHashEntryOffset));
fhdr.blockoffset = SDL_SwapLE32(static_cast<std::uint32_t>(kMpqBlockEntryOffset));
fhdr.hashoffset = SDL_SwapLE32(static_cast<uint32_t>(kMpqHashEntryOffset));
fhdr.blockoffset = SDL_SwapLE32(static_cast<uint32_t>(kMpqBlockEntryOffset));
fhdr.hashcount = SDL_SwapLE32(2048);
fhdr.blockcount = SDL_SwapLE32(2048);
@ -514,9 +514,9 @@ BOOL mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, DWORD d
str_ptr = tmp + 1;
Hash(str_ptr, 3);
constexpr std::uint32_t kSectorSize = 4096;
const std::uint32_t num_sectors = (dwLen + (kSectorSize - 1)) / kSectorSize;
const std::uint32_t offset_table_bytesize = sizeof(std::uint32_t) * (num_sectors + 1);
constexpr uint32_t kSectorSize = 4096;
const uint32_t num_sectors = (dwLen + (kSectorSize - 1)) / kSectorSize;
const uint32_t offset_table_bytesize = sizeof(uint32_t) * (num_sectors + 1);
pBlk->offset = mpqapi_find_free_block(dwLen + offset_table_bytesize, &pBlk->sizealloc);
pBlk->sizefile = dwLen;
pBlk->flags = 0x80000100;
@ -524,7 +524,7 @@ BOOL mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, DWORD d
// We populate the table of sector offset while we write the data.
// We can't pre-populate it because we don't know the compressed sector sizes yet.
// First offset is the start of the first sector, last offset is the end of the last sector.
std::unique_ptr<std::uint32_t[]> sectoroffsettable(new std::uint32_t[num_sectors + 1]);
std::unique_ptr<uint32_t[]> sectoroffsettable(new uint32_t[num_sectors + 1]);
#ifdef CAN_SEEKP_BEYOND_EOF
if (!cur_archive.stream.seekp(pBlk->offset + offset_table_bytesize, std::ios::beg))
@ -550,11 +550,11 @@ BOOL mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, DWORD d
#endif
const BYTE *src = pbData;
std::uint32_t destsize = offset_table_bytesize;
uint32_t destsize = offset_table_bytesize;
BYTE mpq_buf[kSectorSize];
std::size_t cur_sector = 0;
while (true) {
std::uint32_t len = std::min(dwLen, kSectorSize);
uint32_t len = std::min(dwLen, kSectorSize);
memcpy(mpq_buf, src, len);
src += len;
len = PkwareCompress(mpq_buf, len);
@ -577,7 +577,7 @@ BOOL mpqapi_write_file_contents(const char *pszName, const BYTE *pbData, DWORD d
return FALSE;
if (destsize < pBlk->sizealloc) {
const std::uint32_t block_size = pBlk->sizealloc - destsize;
const uint32_t block_size = pBlk->sizealloc - destsize;
if (block_size >= 1024) {
pBlk->sizealloc = destsize;
mpqapi_alloc_block(pBlk->sizealloc + pBlk->offset, block_size);

2
Source/sha.cpp

@ -12,7 +12,7 @@ namespace {
/*
* Diablo-"SHA1" circular left shift, portable version.
*/
std::uint32_t SHA1CircularShift(std::uint32_t bits, std::uint32_t word) {
uint32_t SHA1CircularShift(uint32_t bits, uint32_t word) {
assert(bits < 32);
assert(bits > 0);

2
SourceX/display.cpp

@ -24,7 +24,7 @@ extern BOOL was_window_init; /** defined in dx.cpp */
extern SDL_Surface *renderer_texture_surface; /** defined in dx.cpp */
#ifdef USE_SDL1
void SetVideoMode(int width, int height, int bpp, std::uint32_t flags) {
void SetVideoMode(int width, int height, int bpp, uint32_t flags) {
SDL_Log("Setting video mode %dx%d bpp=%u flags=0x%08X", width, height, bpp, flags);
SDL_SetVideoMode(width, height, bpp, flags);
const auto &current = *SDL_GetVideoInfo();

2
SourceX/display.h

@ -18,7 +18,7 @@ extern SDL_Surface *pal_surface;
extern unsigned int pal_surface_palette_version;
#ifdef USE_SDL1
void SetVideoMode(int width, int height, int bpp, std::uint32_t flags);
void SetVideoMode(int width, int height, int bpp, uint32_t flags);
bool IsFullScreen();
void SetVideoModeToPrimary(bool fullscreen = IsFullScreen());
#endif

Loading…
Cancel
Save