mirror of https://github.com/libAthena/athena.git
* Fixed some bugs
This commit is contained in:
parent
ebca406d71
commit
304baa45bb
|
@ -18,6 +18,10 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#define __STRX(x) #x
|
||||
#define __STR(x) __STRX(x)
|
||||
#define __LINE_STRING__ __STR(__LINE__)
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
namespace error
|
||||
|
@ -53,4 +57,10 @@ protected:
|
|||
|
||||
} // error
|
||||
} // zelda
|
||||
#define THROW_EXCEPTION(msg) \
|
||||
do \
|
||||
{ \
|
||||
throw zelda::error::Exception(__LINE_STRING__ " " __FILE__ " " msg); \
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define INVALIDDATAEXCEPTION_HPP
|
||||
|
||||
#include "Exception.hpp"
|
||||
#include <sstream>
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
|
@ -20,10 +21,17 @@ class InvalidDataException : public Exception
|
|||
{
|
||||
public:
|
||||
inline InvalidDataException(const std::string& error)
|
||||
: Exception("InvalidDataException: " + error)
|
||||
: Exception(error)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#define THROW_INVALID_DATA(msg) \
|
||||
do \
|
||||
{ \
|
||||
throw zelda::error::InvalidDataException(__LINE_STRING__ " " __FILE__ " " msg); \
|
||||
} while(0)
|
||||
#endif // INVALIDDATAEXCEPTION_HPP
|
||||
|
|
|
@ -24,6 +24,8 @@ SkywardSwordFileReader::SkywardSwordFileReader(const std::string& filename)
|
|||
SkywardSwordFile* SkywardSwordFileReader::read()
|
||||
{
|
||||
SkywardSwordFile* file = NULL;
|
||||
try
|
||||
{
|
||||
if (base::length() != 0xFBE0)
|
||||
throw zelda::error::InvalidOperationException("SSFileReader::read -> File not the expected size of 0xFBE0");
|
||||
|
||||
|
@ -51,6 +53,13 @@ SkywardSwordFile* SkywardSwordFileReader::read()
|
|||
base::seek(pos, base::Beginning);
|
||||
file->addQuest(q);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete file;
|
||||
file = NULL;
|
||||
throw;
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ SpriteFileReader::SpriteFileReader(const std::string& filepath)
|
|||
|
||||
Sakura::SpriteFile* SpriteFileReader::readFile()
|
||||
{
|
||||
Sakura::SpriteFile* ret = NULL;
|
||||
try
|
||||
{
|
||||
Uint32 magic = base::readUInt32();
|
||||
|
||||
if (magic != Sakura::SpriteFile::Magic)
|
||||
|
@ -48,7 +51,7 @@ Sakura::SpriteFile* SpriteFileReader::readFile()
|
|||
Uint16 spriteCount = base::readUInt16();
|
||||
|
||||
// Lets go ahead and create or new container.
|
||||
Sakura::SpriteFile* ret = new Sakura::SpriteFile(width, height, originX, originY);
|
||||
ret = new Sakura::SpriteFile(width, height, originX, originY);
|
||||
|
||||
// The next four bytes are reserved to keep the header 32 byte aligned.
|
||||
// This isn't necessary for most systems, but it's eventually planned
|
||||
|
@ -141,6 +144,13 @@ Sakura::SpriteFile* SpriteFileReader::readFile()
|
|||
}
|
||||
|
||||
ret->setSprites(sprites);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete ret;
|
||||
ret = NULL;
|
||||
throw;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ WiiSaveReader::WiiSaveReader(const std::string& filename)
|
|||
WiiSave* WiiSaveReader::readSave()
|
||||
{
|
||||
WiiSave* ret = new WiiSave;
|
||||
try
|
||||
{
|
||||
if (length() < 0xF0C0)
|
||||
throw error::InvalidOperationException("WiiSaveReader::readSave -> Not a valid WiiSave");
|
||||
|
||||
|
@ -98,6 +100,14 @@ WiiSave* WiiSaveReader::readSave()
|
|||
ret->setFiles(files);
|
||||
|
||||
readCerts(totalSize);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete ret;
|
||||
ret = NULL;
|
||||
throw;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -154,7 +164,7 @@ WiiBanner* WiiSaveReader::readBanner()
|
|||
gameId = base::readUInt64();
|
||||
bannerSize = base::readUInt32();
|
||||
permissions = base::readByte();
|
||||
/* unk =*/ base::readByte();
|
||||
/* unk =*/ base::readByte();
|
||||
base::seek(0x10);
|
||||
// skip padding
|
||||
base::seek(2);
|
||||
|
|
Loading…
Reference in New Issue