* Visual Studio fixes (requires VS2013 at the minimum)

This commit is contained in:
Antidote 2014-12-28 20:46:43 -08:00
parent f322f1d7e7
commit 097a507bd0
37 changed files with 168 additions and 99 deletions

View File

@ -1,4 +1,4 @@
CONFIG += staticlib CONFIG += staticlib c++11 c11
TEMPLATE= lib TEMPLATE= lib
DESTDIR = ./lib DESTDIR = ./lib
@ -29,7 +29,6 @@ CONFIG(release, release|debug){
OBJECTS_DIR = obj/release OBJECTS_DIR = obj/release
} }
QMAKE_CXXFLAGS += -std=c++11
INCLUDEPATH += include INCLUDEPATH += include
SOURCES += \ SOURCES += \

View File

@ -674,7 +674,7 @@ private:
atUint8 m_bombFlag; atUint8 m_bombFlag;
std::vector<atUint8> m_unknown1; std::vector<atUint8> m_unknown1;
std::vector<atUint16> m_playerName; std::vector<atUint16> m_playerName;
atUint16 m_valid; bool m_valid;
std::vector<atUint16> m_dungeonDeathTotals; std::vector<atUint16> m_dungeonDeathTotals;
atUint16 m_unknown2; atUint16 m_unknown2;
atUint16 m_deathSaveCount; atUint16 m_deathSaveCount;

View File

@ -153,14 +153,14 @@ struct ALTTPPendants
struct ALTTPAbilities struct ALTTPAbilities
{ {
char Nothing:1; //? bool Nothing:1; //?
char Swim:1; bool Swim:1;
char Dash:1; bool Dash:1;
char Pull:1; bool Pull:1;
char Unknown1:1; //--- bool Unknown1:1; //---
char Talk:1; bool Talk:1;
char Read:1; bool Read:1;
char Unknown2:1; //--- bool Unknown2:1; //---
}; };
struct ALTTPCrystals struct ALTTPCrystals

View File

@ -19,6 +19,7 @@
#include <string> #include <string>
#include <stdarg.h> #include <stdarg.h>
#include "Athena/Utility.hpp" #include "Athena/Utility.hpp"
#include "Athena/Global.hpp"
#define __STRX(x) #x #define __STRX(x) #x
#define __STR(x) __STRX(x) #define __STR(x) __STRX(x)
@ -78,10 +79,18 @@ protected:
}; };
} // error } // error
} // Athena } // Athena
#ifdef _MSC_VER
#define THROW_EXCEPTION(args,...) \
do { \
std::string msg = Athena::utility::sprintf(args, __VA_ARGS__); \
throw Athena::error::Exception(std::string("Exception: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0)
#elif defined(__GNUC__)
#define THROW_EXCEPTION(args...) \ #define THROW_EXCEPTION(args...) \
do { \ do { \
std::string msg = Athena::utility::sprintf(args); \ std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::Exception(std::string("Exception: ")+msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ throw Athena::error::Exception(std::string("Exception: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0) } while(0)
#endif
#endif #endif

View File

@ -52,6 +52,6 @@ private:
} // Athena } // Athena
#define THROW_FILE_NOT_FOUND_EXCEPTION(msg) \ #define THROW_FILE_NOT_FOUND_EXCEPTION(msg) \
do { throw Athena::error::FileNotFoundException(msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0) do { throw Athena::error::FileNotFoundException(msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); } while(0)
#endif #endif

View File

@ -63,7 +63,7 @@ private:
FILE* m_fileHandle; FILE* m_fileHandle;
Endian m_endian; Endian m_endian;
atUint8 m_currentByte; atUint8 m_currentByte;
atUint8 m_bytePosition; atUint64 m_bytePosition;
atUint8 m_bitShift; atUint8 m_bitShift;
bool m_bitValid; bool m_bitValid;
}; };

View File

@ -20,27 +20,33 @@
#include "Athena/Utility.hpp" #include "Athena/Utility.hpp"
#include <iostream> #include <iostream>
#ifndef __PRETTY_FUNCTION__ #ifdef _MSC_VER
# ifdef __FUNCSIG__ #pragma warning(disable : 4996)
# define __PRETTY_FUNCTION__ __FUNCSIG__ #endif
#ifndef AT_PRETTY_FUNCTION
# ifdef __PRETTY_FUNCTION__
# define AT_PRETTY_FUNCTION __PRETTY_FUNCTION__
# elif defined(__FUNCSIG__)
# define AT_PRETTY_FUNCTION __FUNCSIG__
# elif defined(__FUNCTION__) # elif defined(__FUNCTION__)
# define __PRETTY_FUNCTION__ __FUNCTION__ # define AT_PRETTY_FUNCTION __FUNCTION__
# elif defined(__FUNC__) # elif defined(__FUNC__)
# define __PRETTY_FUNCTION__ __FUNC__ # define AT_PRETTY_FUNCTION __FUNC__
# elif defined(__func__) # elif defined(__func__)
# define __PRETTY_FUNCTION__ __func__ # define AT_PRETTY_FUNCTION __func__
# else # else
# define __PRETTY_FUNCTION__ "<unknown>" # define AT_PRETTY_FUNCTION "<unknown>"
# endif # endif
#endif #endif
#ifndef aDebug #ifndef aDebug
#define aDebug() \ #define aDebug() \
std::cout << __FILE__ << "(" << __LINE__ << ") " << __PRETTY_FUNCTION__ << ": " std::cout << __FILE__ << "(" << __LINE__ << ") " << AT_PRETTY_FUNCTION << ": "
#endif #endif
#ifndef aError #ifndef aError
#define aError() \ #define aError() \
std::cerr << __FILE__ << "(" << __LINE__ << ") " << __PRETTY_FUNCTION__ << ": " std::cerr << __FILE__ << "(" << __LINE__ << ") " << AT_PRETTY_FUNCTION << ": "
#endif #endif
#ifndef aPrint #ifndef aPrint

View File

@ -47,9 +47,17 @@ public:
} // error } // error
} // Athena } // Athena
#ifdef _MSC_VER
#define THROW_IO_EXCEPTION(args, ...) \
do { \
std::string msg = Athena::utility::sprintf(args, __VA_ARGS__); \
throw Athena::error::IOException(std::string("IOException: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0)
#elif defined(__GNUC__)
#define THROW_IO_EXCEPTION(args...) \ #define THROW_IO_EXCEPTION(args...) \
do { \ do { \
std::string msg = Athena::utility::sprintf(args); \ std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::IOException(std::string("IOException: ")+msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ throw Athena::error::IOException(std::string("IOException: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0) } while(0)
#endif #endif
#endif

View File

@ -43,10 +43,17 @@ public:
} // error } // error
} // Athena } // Athena
#ifdef _MSC_VER
#define THROW_INVALID_DATA_EXCEPTION(args, ...) \
do { \
std::string msg = Athena::utility::sprintf(args, __VA_ARGS__); \
throw Athena::error::InvalidDataException(std::string("InvalidDataException: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0)
#elif defined(__GNUC__)
#define THROW_INVALID_DATA_EXCEPTION(args...) \ #define THROW_INVALID_DATA_EXCEPTION(args...) \
do { \ do { \
std::string msg = Athena::utility::sprintf(args); \ std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::InvalidDataException(std::string("InvalidDataException: ")+msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ throw Athena::error::InvalidDataException(std::string("InvalidDataException: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0) } while(0)
#endif
#endif // INVALIDDATAEXCEPTION_HPP #endif // INVALIDDATAEXCEPTION_HPP

View File

@ -47,9 +47,17 @@ public:
} // error } // error
} // Athena } // Athena
#ifdef _MSC_VER
#define THROW_INVALID_OPERATION_EXCEPTION(args, ...) \
do { \
std::string msg = Athena::utility::sprintf(args, __VA_ARGS__); \
throw Athena::error::InvalidOperationException(std::string("InvalidOperationException: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0)
#elif defined (__GNUC__)
#define THROW_INVALID_OPERATION_EXCEPTION(args...) \ #define THROW_INVALID_OPERATION_EXCEPTION(args...) \
do { \ do { \
std::string msg = Athena::utility::sprintf(args); \ std::string msg = Athena::utility::sprintf(args); \
throw Athena::error::InvalidOperationException(std::string("InvalidOperationException: ")+msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); \ throw Athena::error::InvalidOperationException(std::string("InvalidOperationException: ")+msg, __FILE__, AT_PRETTY_FUNCTION, __LINE__); \
} while(0) } while(0)
#endif
#endif // __INVALID_OPERATION_EXCEPTION_HPP__ #endif // __INVALID_OPERATION_EXCEPTION_HPP__

View File

@ -31,8 +31,8 @@ class MCSlot;
class MCFile class MCFile
{ {
public: public:
static constexpr char* VERSION_EU_JP = (char*)"AGBZELDA:THE MINISH CAP:ZELDA 3\0"; static const char VERSION_EU_JP[33];
static constexpr char* VERSION_US = (char*)"AGBZELDA:THE MINISH CAP:ZELDA 5\0"; static const char VERSION_US[33];
enum SlotType enum SlotType
{ {
New = 0x54494E49, New = 0x54494E49,
@ -42,7 +42,7 @@ public:
MCFile(); MCFile();
static atUint8* unscramble(atUint8* data, atUint32 length); static atUint8* unscramble(atUint8* data, atUint64 length);
private: private:
MCSlot* m_slots[3]; MCSlot* m_slots[3];
}; };

View File

@ -33,6 +33,6 @@ public:
} // Athena } // Athena
#define THROW_NOT_IMPLEMENTED_EXCEPTION() \ #define THROW_NOT_IMPLEMENTED_EXCEPTION() \
do { throw Athena::error::NotImplementedException("NotImplementedException", __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0) do { throw Athena::error::NotImplementedException("NotImplementedException", __FILE__, AT_PRETTY_FUNCTION, __LINE__); } while(0)
#endif // NOTIMPLEMENTEDEXCEPTION_HPP #endif // NOTIMPLEMENTEDEXCEPTION_HPP

View File

@ -20,6 +20,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <stdarg.h> #include <stdarg.h>
#include "Athena/Global.hpp"
#include "Athena/Types.hpp" #include "Athena/Types.hpp"
namespace Athena namespace Athena

View File

@ -36,7 +36,7 @@ typedef unsigned char uint8_t;
extern "C" { extern "C" {
#endif #endif
int lzo1x_decode(atUint8 *out, atInt32 *outlen, const atUint8* in, atInt32 *inlen); int lzo1x_decode(atUint8 *out, atInt32 *outlen, atUint8 *in, atInt32 *inlen);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -1,11 +1,16 @@
#ifndef WIN32_LARGEFILEWRAPPER_H #ifndef WIN32_LARGEFILEWRAPPER_H
#define WIN32_LARGEFILEWRAPPER_H #define WIN32_LARGEFILEWRAPPER_H
#if defined(_WIN32) && defined(_MSC_VER) #if defined(_MSC_VER)
#include <stdio.h> #include <stdio.h>
#include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifndef off64_t
typedef uint64_t off64_t;
#endif
int fseeko64(FILE* fp, off64_t offset, int whence); int fseeko64(FILE* fp, off64_t offset, int whence);
off64_t ftello64(FILE* fp); off64_t ftello64(FILE* fp);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -52,7 +52,7 @@ ALTTPQuest* ALTTPFile::quest(atUint32 id) const
atUint32 ALTTPFile::questCount() const atUint32 ALTTPFile::questCount() const
{ {
return m_quests.size(); return (atUint32)m_quests.size();
} }
} // zelda } // zelda

View File

@ -317,7 +317,7 @@ atUint8 ALTTPQuest::dungeonKeys(atUint32 id) const
atUint32 ALTTPQuest::dungeonCount() const atUint32 ALTTPQuest::dungeonCount() const
{ {
return m_dungeonKeys.size(); return (atUint32)m_dungeonKeys.size();
} }
@ -414,7 +414,7 @@ atUint8 ALTTPQuest::oldManFlag(atUint32 id)
atUint32 ALTTPQuest::oldManFlagCount() const atUint32 ALTTPQuest::oldManFlagCount() const
{ {
return m_oldManFlags.size(); return (atUint32)m_oldManFlags.size();
} }
void ALTTPQuest::setBombFlag(atUint8 flag) void ALTTPQuest::setBombFlag(atUint8 flag)
@ -450,7 +450,7 @@ atUint8 ALTTPQuest::unknown1(atUint32 id)
atUint32 ALTTPQuest::unknown1Count() const atUint32 ALTTPQuest::unknown1Count() const
{ {
return m_unknown1.size(); return (atUint32)m_unknown1.size();
} }
void ALTTPQuest::setPlayerName(std::vector<atUint16> playerName) void ALTTPQuest::setPlayerName(std::vector<atUint16> playerName)
@ -636,7 +636,7 @@ atUint16 ALTTPQuest::dungeonDeathTotal(atUint32 id) const
atUint16 ALTTPQuest::dungeonDeathTotalCount() const atUint16 ALTTPQuest::dungeonDeathTotalCount() const
{ {
return m_dungeonDeathTotals.size(); return (atUint16)m_dungeonDeathTotals.size();
} }
void ALTTPQuest::setUnknown2(atUint16 val) void ALTTPQuest::setUnknown2(atUint16 val)

View File

@ -177,7 +177,7 @@ bool BinaryReader::readBit()
if (m_position > m_length) if (m_position > m_length)
THROW_IO_EXCEPTION("Position %0.16X outside stream bounds ", m_position); THROW_IO_EXCEPTION("Position %0.16X outside stream bounds ", m_position);
bool ret = (*(atUint8*)(m_data + m_position) & (1 << m_bitPosition)); bool ret = (*(atUint8*)(m_data + m_position) & (1 << m_bitPosition)) != 0;
m_bitPosition++; m_bitPosition++;
if (m_bitPosition > 7) if (m_bitPosition > 7)
@ -444,29 +444,28 @@ void BinaryReader::setProgressCallback(std::function<void (int)> cb)
void BinaryReader::loadData() void BinaryReader::loadData()
{ {
FILE* in; FILE* in;
atUint32 length; atUint64 length;
in = fopen(m_filepath.c_str(), "rb"); in = fopen(m_filepath.c_str(), "rb");
if (!in) if (!in)
THROW_FILE_NOT_FOUND_EXCEPTION(m_filepath); THROW_FILE_NOT_FOUND_EXCEPTION(m_filepath);
rewind(in);
fseek(in, 0, SEEK_END); length = utility::fileSize(m_filepath);
length = ftell(in);
fseek(in, 0, SEEK_SET);
#ifdef HW_RVL #ifdef HW_RVL
m_data = (Uint8*)memalign(32, length); m_data = (Uint8*)memalign(32, length);
#else #else
m_data = new atUint8[length]; m_data = new atUint8[length];
#endif #endif
atUint32 done = 0; atUint64 done = 0;
atUint32 blocksize = BLOCKSZ; atUint64 blocksize = BLOCKSZ;
do do
{ {
if (blocksize > length - done) if (blocksize > length - done)
blocksize = length - done; blocksize = length - done;
atInt32 ret = fread(m_data + done, 1, blocksize, in); atInt64 ret = fread(m_data + done, 1, blocksize, in);
if (ret < 0) if (ret < 0)
THROW_IO_EXCEPTION("Error reading data from disk"); THROW_IO_EXCEPTION("Error reading data from disk");

View File

@ -185,14 +185,14 @@ void BinaryWriter::save(const std::string& filename)
if (!out) if (!out)
THROW_FILE_NOT_FOUND_EXCEPTION(m_filepath); THROW_FILE_NOT_FOUND_EXCEPTION(m_filepath);
atUint32 done = 0; atUint64 done = 0;
atUint32 blocksize = BLOCKSZ; atUint64 blocksize = BLOCKSZ;
do do
{ {
if (blocksize > m_length - done) if (blocksize > m_length - done)
blocksize = m_length - done; blocksize = m_length - done;
atInt32 ret = fwrite(m_data + done, 1, blocksize, out); atInt64 ret = fwrite(m_data + done, 1, blocksize, out);
if (ret < 0) if (ret < 0)
THROW_IO_EXCEPTION("Error writing data to disk"); THROW_IO_EXCEPTION("Error writing data to disk");

View File

@ -108,7 +108,7 @@ atInt32 compressZlib(const atUint8 *src, atUint32 srcLen, atUint8* dst, atUint32
atInt32 decompressLZO(const atUint8* source, atInt32 sourceSize, atUint8* dst, atInt32& dstSize) atInt32 decompressLZO(const atUint8* source, atInt32 sourceSize, atUint8* dst, atInt32& dstSize)
{ {
int size = dstSize; int size = dstSize;
int result = lzo1x_decode(dst, &size, source, &sourceSize); int result = lzo1x_decode(dst, &size, (atUint8*)source, &sourceSize);
dstSize = size; dstSize = size;
return result; return result;
} }

View File

@ -140,7 +140,7 @@ bool FileReader::readBit()
if (!m_bitValid) if (!m_bitValid)
{ {
int size = fread(&m_currentByte, 1, 1, m_fileHandle); size_t size = fread(&m_currentByte, 1, 1, m_fileHandle);
if (size != sizeof(atUint8)) if (size != sizeof(atUint8))
THROW_IO_EXCEPTION("Error reading from file."); THROW_IO_EXCEPTION("Error reading from file.");

View File

@ -18,6 +18,11 @@
#include "Athena/InvalidDataException.hpp" #include "Athena/InvalidDataException.hpp"
#include "Athena/InvalidOperationException.hpp" #include "Athena/InvalidOperationException.hpp"
#include "Athena/IOException.hpp" #include "Athena/IOException.hpp"
#ifdef _MSC_VER
#include "win32_largefilewrapper.h"
#endif
#include "utf8.h" #include "utf8.h"
namespace Athena namespace Athena

View File

@ -18,6 +18,8 @@
namespace Athena namespace Athena
{ {
const char MCFile::VERSION_EU_JP[33] = "AGBZELDA:THE MINISH CAP:ZELDA 3\0";
const char MCFile::VERSION_US[33] = "AGBZELDA:THE MINISH CAP:ZELDA 5\0";
MCFile::MCFile() MCFile::MCFile()
{ {
} }
@ -38,7 +40,7 @@ atUint8* reverse(atUint8* data, atUint32 length)
return data; return data;
} }
atUint8* MCFile::unscramble(atUint8* data, atUint32 length) atUint8* MCFile::unscramble(atUint8* data, atUint64 length)
{ {
if (!data) if (!data)
return nullptr; return nullptr;

View File

@ -40,6 +40,8 @@ MCFile* MCFileReader::readFile()
if (isScrambled) if (isScrambled)
MCFile::unscramble(base::m_data, base::m_length); MCFile::unscramble(base::m_data, base::m_length);
return nullptr;
} }

View File

@ -149,7 +149,7 @@ QList<int> Sprite::stateIds() const
atUint32 Sprite::stateCount() const atUint32 Sprite::stateCount() const
{ {
return m_stateIds.size(); return (atUint32)m_stateIds.size();
} }
void Sprite::setCurrentState(const atUint32 id) void Sprite::setCurrentState(const atUint32 id)
@ -231,7 +231,7 @@ void Sprite::setFrames(QList<SpriteFrame*> frames)
atUint32 Sprite::frameCount() const atUint32 Sprite::frameCount() const
{ {
return m_frames.size(); return (atUint32)m_frames.size();
} }
#ifndef ATHENA_USE_QT #ifndef ATHENA_USE_QT
@ -282,7 +282,7 @@ void Sprite::advanceFrame()
{ {
m_currentFrame++; m_currentFrame++;
if (m_currentFrame >= m_frames.size()) if (m_currentFrame >= m_frames.size())
m_currentFrame = m_frames.size() - 1; m_currentFrame = (atUint32)m_frames.size() - 1;
} }
void Sprite::retreatFrame() void Sprite::retreatFrame()

View File

@ -199,7 +199,7 @@ QList<STexture*> SpriteFile::textures() const
atUint32 SpriteFile::textureCount() const atUint32 SpriteFile::textureCount() const
{ {
return m_textures.size(); return (atUint32)m_textures.size();
} }
void SpriteFile::addSprite(Sprite* sprite) void SpriteFile::addSprite(Sprite* sprite)
@ -297,7 +297,7 @@ QMap<QString, Sprite*> SpriteFile::sprites() const
atUint32 SpriteFile::spriteCount() const atUint32 SpriteFile::spriteCount() const
{ {
return m_sprites.size(); return (atUint32)m_sprites.size();
} }
#ifndef ATHENA_USE_QT #ifndef ATHENA_USE_QT

View File

@ -60,7 +60,7 @@ QList<SpritePart*> SpriteFrame::parts() const
atUint32 SpriteFrame::partCount() const atUint32 SpriteFrame::partCount() const
{ {
return m_parts.size(); return (atUint32)m_parts.size();
} }
float SpriteFrame::frameTime() const float SpriteFrame::frameTime() const

View File

@ -24,6 +24,12 @@
#include <cstdio> #include <cstdio>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef _MSC_VER
#include <functional>
#include <locale>
#define stat64 __stat64
#endif
namespace Athena namespace Athena
{ {
namespace utility namespace utility
@ -294,13 +300,13 @@ std::string vsprintf(const char* fmt, va_list list)
int size = 512; int size = 512;
char* buffer = 0; char* buffer = 0;
buffer = new char[size]; buffer = new char[size];
int nsize = vsnprintf(buffer, size, fmt, list); int nsize = ::vsnprintf(buffer, size, fmt, list);
while(size<=nsize) while(size<=nsize)
{ //fail delete buffer and try again { //fail delete buffer and try again
delete[] buffer; delete[] buffer;
buffer = 0; buffer = 0;
buffer = new char[nsize+1]; //+1 for /0 buffer = new char[nsize+1]; //+1 for /0
nsize = vsnprintf(buffer, size, fmt, list); nsize = ::vsnprintf(buffer, size, fmt, list);
} }
std::string ret(buffer); std::string ret(buffer);
delete[] buffer; delete[] buffer;
@ -373,21 +379,29 @@ atUint64 fileSize(const std::string& filename)
return st.st_size; return st.st_size;
} }
std::string& ltrim(std::string& s) // trim from both ends
{
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
return s;
}
std::string& rtrim(std::string& s)
{
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
return s;
}
std::string &trim(std::string &s) std::string &trim(std::string &s)
{ {
return ltrim(rtrim(s)); // Find first non whitespace char in StrToTrim
std::string::size_type first = s.find_first_not_of( ' ' );
// Check whether something went wrong?
if( first == std::string::npos )
{
first = 0;
}
// Find last non whitespace char from StrToTrim
std::string::size_type last = s.find_last_not_of( ' ' );
// If something didn't go wrong, Last will be recomputed to get real length of substring
if( last != std::string::npos )
{
last = ( last + 1 ) - first;
}
// Copy such a string to TrimmedString
s = s.substr( first, last );
return s;
} }
} // utility } // utility

View File

@ -157,7 +157,7 @@ void WiiFile::addChild(WiiFile *file)
{ {
// add them from the beginning of the path up // add them from the beginning of the path up
tmpName = tmpName.substr(0, tmpName.find('/')); tmpName = tmpName.substr(0, tmpName.find('/'));
for (int i = 0; i < m_children.size(); i++) for (atUint32 i = 0; i < m_children.size(); i++)
{ {
if (!m_children[i]->filename().compare(tmpName)) if (!m_children[i]->filename().compare(tmpName))
{ {
@ -226,7 +226,7 @@ void WiiFile::setParent(WiiFile* parent)
atUint32 WiiFile::fileCount() atUint32 WiiFile::fileCount()
{ {
int ret = m_children.size(); size_t ret = m_children.size();
for (WiiFile* f : m_children) for (WiiFile* f : m_children)
{ {
@ -236,7 +236,7 @@ atUint32 WiiFile::fileCount()
ret += f->fileCount(); ret += f->fileCount();
} }
return ret; return (atUint32)ret;
} }
std::vector<WiiFile *> WiiFile::allChildren() std::vector<WiiFile *> WiiFile::allChildren()

View File

@ -78,7 +78,7 @@ bool WiiSaveWriter::writeSave(WiiSave *save, atUint8 *macAddress, atUint32 ngId,
{ {
totalSize += writeFile(file); totalSize += writeFile(file);
} }
int pos = base::position(); atUint64 pos = base::position();
// Write size data // Write size data
base::seek(0xF0C0 + 0x10, SeekOrigin::Begin); base::seek(0xF0C0 + 0x10, SeekOrigin::Begin);
base::writeUint32(totalSize); base::writeUint32(totalSize);
@ -97,7 +97,7 @@ void WiiSaveWriter::writeBanner(WiiBanner *banner)
{ {
base::setEndian(Endian::BigEndian); base::setEndian(Endian::BigEndian);
base::writeInt64(banner->gameID()); base::writeInt64(banner->gameID());
base::writeInt32((0x60a0+0x1200)*banner->icons().size()); base::writeInt32((0x60a0+0x1200)*(atUint32)banner->icons().size());
base::writeByte((atInt8)banner->permissions()); base::writeByte((atInt8)banner->permissions());
base::seek(1); base::seek(1);
base::writeBytes((atInt8*)MD5_BLANKER, 16); base::writeBytes((atInt8*)MD5_BLANKER, 16);

View File

@ -112,8 +112,8 @@ Normally a search for one byte is matched, then two, then three, all the way up
*/ */
LZLengthOffset LZBase::windowSearch(atUint8* beginSearchPtr, atUint8* searchPosPtr, atUint8* endLABufferPtr, atUint8* startLBPtr) LZLengthOffset LZBase::windowSearch(atUint8* beginSearchPtr, atUint8* searchPosPtr, atUint8* endLABufferPtr, atUint8* startLBPtr)
{ {
atInt32 size=endLABufferPtr-beginSearchPtr;//Size of the entire sliding window atInt32 size=(atUint32)(endLABufferPtr-beginSearchPtr);//Size of the entire sliding window
atInt32 n=endLABufferPtr-searchPosPtr; atInt32 n=(atUint32)(endLABufferPtr-searchPosPtr);
LZLengthOffset result={0,0}; LZLengthOffset result={0,0};
atInt32 temp=0; atInt32 temp=0;
if(n > size)//If the string that is being looked for is bigger than the string that is being searched if(n > size)//If the string that is being looked for is bigger than the string that is being searched

View File

@ -1,5 +1,5 @@
#include "LZ77/LZLookupTable.hpp" #include "LZ77/LZLookupTable.hpp"
#include <algorithm>
LZLookupTable::LZLookupTable() LZLookupTable::LZLookupTable()
{ {

View File

@ -67,7 +67,7 @@ atUint32 LZType10::compress(const atUint8* src, atUint8** dstBuf, atUint32 srcLe
*dstBuf = outbuf.data(); *dstBuf = outbuf.data();
outbuf.save(); outbuf.save();
return outbuf.length(); return (atUint32)outbuf.length();
} }
atUint32 LZType10::decompress(const atUint8* src, atUint8** dst, atUint32 srcLength) atUint32 LZType10::decompress(const atUint8* src, atUint8** dst, atUint32 srcLength)

View File

@ -114,7 +114,7 @@ atUint32 LZType11::compress(const atUint8* src, atUint8** dst, atUint32 srcLengt
outbuff.writeByte(0); outbuff.writeByte(0);
*dst = outbuff.data(); *dst = outbuff.data();
return outbuff.length(); return (atUint32)outbuff.length();
} }
atUint32 LZType11::decompress(const atUint8* src, atUint8** dst, atUint32 srcLength) atUint32 LZType11::decompress(const atUint8* src, atUint8** dst, atUint32 srcLength)

View File

@ -67,11 +67,11 @@ static void copy(LZOContext *c, int cnt) {
register uint8_t *src = c->in; register uint8_t *src = c->in;
register uint8_t *dst = c->out; register uint8_t *dst = c->out;
if (src + cnt > c->in_end) { if (src + cnt > c->in_end) {
cnt = c->in_end - src; cnt = (int)(c->in_end - src);
c->error |= LZO_INPUT_DEPLETED; c->error |= LZO_INPUT_DEPLETED;
} }
if (dst + cnt > c->out_end) { if (dst + cnt > c->out_end) {
cnt = c->out_end - dst; cnt = (int)(c->out_end - dst);
c->error |= LZO_OUTPUT_FULL; c->error |= LZO_OUTPUT_FULL;
} }
@ -111,7 +111,7 @@ static void copy_backptr(LZOContext *c, int back, int cnt) {
return; return;
} }
if (dst + cnt > c->out_end) { if (dst + cnt > c->out_end) {
cnt = c->out_end - dst; cnt = (int)(c->out_end - dst);
c->error |= LZO_OUTPUT_FULL; c->error |= LZO_OUTPUT_FULL;
} }
if (back == 1) { if (back == 1) {
@ -166,7 +166,7 @@ static void copy_backptr(LZOContext *c, int back, int cnt) {
* make sure all buffers are appropriately padded, in must provide * make sure all buffers are appropriately padded, in must provide
* LZO_INPUT_PADDING, out must provide LZO_OUTPUT_PADDING additional bytes * LZO_INPUT_PADDING, out must provide LZO_OUTPUT_PADDING additional bytes
*/ */
int lzo1x_decode(atUint8 *out, atInt32 *outlen, const atUint8 *in, atInt32 *inlen) { int lzo1x_decode(atUint8 *out, atInt32 *outlen, atUint8 *in, atInt32 *inlen) {
enum {COPY, BACKPTR} state = COPY; enum {COPY, BACKPTR} state = COPY;
atInt32 x; atInt32 x;
LZOContext c; LZOContext c;
@ -225,7 +225,7 @@ int lzo1x_decode(atUint8 *out, atInt32 *outlen, const atUint8 *in, atInt32 *inle
copy(&c, cnt); copy(&c, cnt);
x = get_byte(&c); x = get_byte(&c);
} }
*inlen = c.in_end - c.in; *inlen = (atInt32)(c.in_end - c.in);
*outlen = c.out_end - c.out; *outlen = (atInt32)(c.out_end - c.out);
return c.error; return c.error;
} }

View File

@ -84,6 +84,10 @@
#include <malloc.h> #include <malloc.h>
#include <ctype.h> #include <ctype.h>
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#endif
#include "md5.h" #include "md5.h"
namespace MD5Hash namespace MD5Hash
@ -560,7 +564,7 @@ unsigned char * MD5fromFile(unsigned char *dst, const char *src)
do do
{ {
read = fread(buffer, 1, blksize, file); read = (int)fread(buffer, 1, blksize, file);
(void) auth_md5SumCtx(ctx, buffer, read); /* Pass only one block. */ (void) auth_md5SumCtx(ctx, buffer, read); /* Pass only one block. */
} while (read > 0); } while (read > 0);

View File

@ -1,7 +1,7 @@
#include "win32_largefilewrapper.h" #include "win32_largefilewrapper.h"
#include <stdio.h> #include <stdio.h>
#if defined(_WIN32) && defined(_MSC_VER) #if defined(_MSC_VER)
int fseeko64(FILE* fp, off64_t offset, int whence) int fseeko64(FILE* fp, off64_t offset, int whence)
{ {
return _fseeki64(fp, offset, whence); return _fseeki64(fp, offset, whence);