1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-07-03 14:34:34 +00:00

Merge branch 'master' of file:///Users/User/code/coding/Aquaria_fg_clean into experimental

This commit is contained in:
fgenesis 2014-05-21 00:04:34 +01:00
commit 7416ec0e15
12 changed files with 49 additions and 32 deletions

View file

@ -2350,6 +2350,8 @@ void Continuity::upgradeHealth()
void Continuity::saveFile(int slot, Vector position, unsigned char *scrShotData, int scrShotWidth, int scrShotHeight)
{
refreshAvatarData(dsq->game->avatar);
if (position.isZero())
{
position = dsq->game->avatar->position;

View file

@ -276,6 +276,8 @@ void Mod::setActive(bool a)
{
if (!active)
{
dsq->unloadMods();
mapRevealMethod = REVEAL_UNSPECIFIED;
setLocalisationModPath("");
name = path = "";

View file

@ -159,7 +159,7 @@ void PathFinding::generatePath(RenderObject *ro, TileVector start, TileVector go
SearchGrid grid;
JPS::PathVector path;
if(JPS::findPath(path, grid, start.x, start.y, goal.x, goal.y, 10))
if(JPS::findPath(path, grid, start.x, start.y, goal.x, goal.y, 1))
{
vp.addPathNode(ro->position, 0);
generateVectorPath(path, vp, offx, offy);

View file

@ -3008,6 +3008,9 @@ luaFunc(entity_playSfx)
sfx.maxdist = lua_tonumber(L, 7);
sfx.relative = false;
sfx.positional = true;
Vector pos = e->position + e->offset;
sfx.x = pos.x;
sfx.y = pos.y;
h = core->sound->playSfx(sfx);
if (fadeOut != 0)

View file

@ -11,10 +11,10 @@
void cocoaMessageBox(const std::string &title, const std::string &msg)
{
@autoreleasepool {
NSString *nstitle = @(title.c_str());
NSString *nsmsg = @(msg.c_str());
NSRunAlertPanel(nstitle, @"%@", nil, nil, nil, nsmsg);
}
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *nstitle = [NSString stringWithUTF8String:title.c_str()];
NSString *nsmsg = [NSString stringWithUTF8String:msg.c_str()];
NSRunAlertPanel(nstitle, @"%@", nil, nil, nil, nsmsg);
[pool drain];
}

View file

@ -727,7 +727,7 @@ void Quad::flipVertical()
void Quad::refreshRepeatTextureToFill()
{
if (repeatingTextureToFill)
if (repeatingTextureToFill && texture)
{
upperLeftTextureCoordinates.x = texOff.x;
upperLeftTextureCoordinates.y = texOff.y;

View file

@ -426,9 +426,9 @@ SET(AQUARIA_SRCS_UNUSED
)
IF(MACOSX)
IF(AQUARIA_USE_SDL)
IF(NOT AQUARIA_USE_SDL2)
SET(COCOA_SRCS "${BBGEDIR}/Cocoa.mm")
ENDIF(AQUARIA_USE_SDL)
ENDIF(NOT AQUARIA_USE_SDL2)
ENDIF(MACOSX)
# Bit Blot Game Engine sources...

View file

@ -21,7 +21,7 @@ File::~File()
}
DiskFile::DiskFile(const char *name /* = NULL */)
: File(name), _fh(NULL), _buf(NULL)
: File(name), _fh(NULL)
{
}

View file

@ -78,7 +78,6 @@ public:
protected:
void *_fh; // FILE*
void *_buf;
};
class MemFile : public File

View file

@ -64,7 +64,7 @@ void ZipDir::load()
if(getFile(fs.m_filename))
continue;
ZipFile *vf = new ZipFile(fs.m_filename, _archiveHandle, (vfspos)fs.m_uncomp_size, fs.m_file_index);
ZipFile *vf = new ZipFile(fs.m_filename, _archiveHandle, fs.m_file_index);
addRecursive(vf, len);
}

View file

@ -8,12 +8,12 @@
VFS_NAMESPACE_START
ZipFile::ZipFile(const char *name, ZipArchiveRef *zref, vfspos uncompSize, unsigned int fileIdx)
ZipFile::ZipFile(const char *name, ZipArchiveRef *zref, unsigned int fileIdx)
: File(joinPath(zref->fullname(), name).c_str())
, _buf(NULL)
, _pos(0)
, _archiveHandle(zref)
, _uncompSize(uncompSize)
, _bufSize(0)
, _fileIdx(fileIdx)
, _mode("rb") // binary mode by default
{
@ -46,7 +46,7 @@ bool ZipFile::isopen() const
bool ZipFile::iseof() const
{
return _pos >= _uncompSize;
return _pos >= _bufSize;
}
void ZipFile::close()
@ -55,6 +55,7 @@ void ZipFile::close()
delete []_buf;
_buf = NULL;
_bufSize = 0;
}
bool ZipFile::seek(vfspos pos, int whence)
@ -75,9 +76,9 @@ bool ZipFile::seek(vfspos pos, int whence)
break;
case SEEK_END:
if(pos >= _uncompSize)
if(pos >= _bufSize)
return false;
_pos = _uncompSize - pos;
_pos = _bufSize - pos;
break;
default:
@ -119,26 +120,32 @@ size_t ZipFile::write(const void *src, size_t bytes)
return 0;
}
#define MZ ((mz_zip_archive*)_archiveHandle->mz)
vfspos ZipFile::size()
{
return (vfspos)_uncompSize;
}
if(_buf && _bufSize)
return _bufSize;
#define MZ ((mz_zip_archive*)_archiveHandle->mz)
if(!_archiveHandle->openRead())
return npos;
// FIXME: this is not 100% safe. The file index may change if the zip file is changed externally while closed
mz_zip_archive_file_stat zstat;
if(!mz_zip_reader_file_stat(MZ, _fileIdx, &zstat))
return npos;
return (vfspos)zstat.m_uncomp_size;
}
bool ZipFile::unpack()
{
delete [] _buf;
close(); // delete the buffer
if(!_archiveHandle->openRead())
{
//assert(0 && "ZipFile unpack: Failed to openRead");
return false; // can happen if the underlying zip file was deleted
}
const vfspos sz = size(); // will reopen the file
if(sz < 0)
return false;
// In case of text data, make sure the buffer is always terminated with '\0'.
// Won't hurt for binary data, so just do it in all cases.
size_t sz = (size_t)size();
_buf = new char[sz + 1];
if(!_buf)
return false;
@ -151,10 +158,14 @@ bool ZipFile::unpack()
return false; // this should not happen
}
_bufSize = sz;
// In case of text data, make sure the buffer is always terminated with '\0'.
// Won't hurt for binary data, so just do it in all cases.
_buf[sz] = 0;
if(_mode.find("b") == std::string::npos) // text mode?
{
_uncompSize = strnNLcpy(_buf, _buf);
_bufSize = (vfspos)strnNLcpy(_buf, _buf);
}
return true;

View file

@ -9,7 +9,7 @@ VFS_NAMESPACE_START
class ZipFile : public File
{
public:
ZipFile(const char *name, ZipArchiveRef *zref, vfspos uncompSize, unsigned int fileIdx);
ZipFile(const char *name, ZipArchiveRef *zref, unsigned int fileIdx);
virtual ~ZipFile();
virtual bool open(const char *mode = NULL);
virtual bool isopen() const;
@ -29,7 +29,7 @@ protected:
char *_buf;
vfspos _pos;
CountedPtr<ZipArchiveRef> _archiveHandle;
vfspos _uncompSize;
vfspos _bufSize;
unsigned int _fileIdx;
std::string _mode;
};