15 Commits

Author SHA1 Message Date
xawotihs
14d4bede9a Linked mingw32 rcc 2013-12-31 17:45:01 +01:00
xawotihs
8636a99d0d Activates qt resources only on windows as g++ seems to crash on Travis VM. 2013-12-31 17:18:14 +01:00
xawotihs
73cdbd6b88 And again 2013-12-31 16:58:17 +01:00
xawotihs
3482afeb84 Should fix the build of the graphics versions 2013-12-31 16:08:59 +01:00
xawotihs
de40146462 Something is weird with the -- in the travis build script... 2013-12-31 15:49:21 +01:00
xawotihs
94d5a85043 Tries to remove weird characters in travis build file 2013-12-31 00:08:46 +01:00
xawotihs
4811fbcc9f Activates qt resources into graphics Qt build 2013-12-30 23:41:50 +01:00
xawotihs
6fd136a211 Fixed JSfx with JMOD. 2013-12-29 18:37:26 +01:00
xawotihs
d98640fc01 Fixed android JGfx compilation 2013-12-29 12:38:35 +01:00
xawotihs
685317b457 Installs psp HGE lib 2013-12-28 18:02:32 +01:00
xawotihs
a9a59d7b8e Tries to build PSP HGE lib 2013-12-28 17:52:37 +01:00
xawotihs
fe9ad84ee5 More PSP compilation fixes. 2013-12-28 12:15:52 +01:00
xawotihs
3f43648b22 More PSP fixes. 2013-12-28 11:44:00 +01:00
xawotihs
afb4c4605b Fixed PSP cross compilation issues. 2013-12-28 01:05:53 +01:00
xawotihs
fec4468aea Updated JFileSystem implementation to be compatible with Qt resources. 2013-12-28 00:38:02 +01:00
30 changed files with 494 additions and 400 deletions

View File

@@ -12,6 +12,7 @@ install:
- sudo apt-get update -qq
- if [ `uname -m` = x86_64 ]; then sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch jq mingw32-x-gcc mingw32-x-qt; fi
- sudo ln -s /opt/mingw32/bin/moc /opt/mingw32/bin/i686-w64-mingw32-moc
- sudo ln -s /opt/mingw32/bin/rcc /opt/mingw32/bin/i686-w64-mingw32-rcc
- wget -O sdk.lzma http://sourceforge.net/projects/minpspw/files/SDK%20%2B%20devpak/pspsdk%200.11.2/minpspw_0.11.2-amd64.tar.lzma/download
- tar -x --xz -f sdk.lzma
- wget http://dl.google.com/android/ndk/android-ndk-r9-linux-x86_64.tar.bz2 -nv

View File

@@ -1,6 +1,10 @@
#ifndef _J_FILE_SYSTEM_H_
#define _J_FILE_SYSTEM_H_
#ifdef QT_CONFIG
#include <QFile>
#endif
#include "zfsystem.h"
#include <string>
using zip_file_system::filesystem;
@@ -18,13 +22,38 @@ using namespace std;
/// archive file.
///
//////////////////////////////////////////////////////////////////////////
class JFile {
friend class JFileSystem;
filesystem::limited_file_info * mCurrentFileInZip;
izfstream mFile;
#ifdef QT_CONFIG
QFile *mpqFile;
#endif
public:
JFile() : mCurrentFileInZip(0)
#ifdef QT_CONFIG
, mpqFile(0)
#endif
{
};
~JFile() {
#ifdef QT_CONFIG
if(mpqFile) {
mpqFile->close();
delete mpqFile;
}
#endif
if (mFile)
mFile.close();
};
};
class JZipCache {
public:
JZipCache();
~JZipCache();
map<string, filesystem::limited_file_info> dir;
};
class JFileSystem {
@@ -32,23 +61,21 @@ private:
string mSystemFSPath, mUserFSPath;
filesystem * mSystemFS, * mUserFS;
static JFileSystem* mInstance;
izfstream mFile;
map<string,JZipCache *>mZipCache;
unsigned int mZipCachedElementsCount;
string mZipFileName;
int mFileSize;
char *mPassword;
bool mZipAvailable;
void preloadZip(const string& filename);
izfstream mZipFile;
filesystem::limited_file_info * mCurrentFileInZip;
std::vector<std::string>& scanRealFolder(const std::string& folderName, std::vector<std::string>& results);
bool openForRead(izfstream & File, const string & FilePath);
int GetFileSize(izfstream & file);
public:
//////////////////////////////////////////////////////////////////////////
/// Attach ZIP archive to the file system.
///
@@ -83,7 +110,7 @@ public:
/// Open file for reading.
///
//////////////////////////////////////////////////////////////////////////
bool OpenFile(const string &filename);
JFile* OpenFile(const string &filename);
//Fills the vector results with a list of children of the given folder
std::vector<std::string>& scanfolder(const std::string& folderName, std::vector<std::string>& results);
@@ -97,20 +124,19 @@ public:
/// @return Number of bytes read.
///
//////////////////////////////////////////////////////////////////////////
int ReadFile(void *buffer, int size);
int ReadFile(JFile*, void *buffer, int size);
//////////////////////////////////////////////////////////////////////////
/// Get size of file.
///
//////////////////////////////////////////////////////////////////////////
int GetFileSize();
int GetFileSize(izfstream & file);
int GetFileSize(JFile*);
//////////////////////////////////////////////////////////////////////////
/// Close file.
///
//////////////////////////////////////////////////////////////////////////
void CloseFile();
void CloseFile(JFile*);
//////////////////////////////////////////////////////////////////////////
/// Set root for all the following file operations
@@ -124,8 +150,8 @@ public:
void SetUSerRoot(const string& resourceRoot);
string GetUserRoot() { return mUserFSPath; };
bool openForRead(izfstream & File, const string & FilePath);
bool readIntoString(const string & FilePath, string & target);
bool ReadFileLine(JFile*, string&);
bool openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode = ios_base::out );
bool Rename(string from, string to);
@@ -163,4 +189,4 @@ protected:
#endif
#endif

View File

@@ -178,7 +178,6 @@ private:
float mSpacing;
PIXEL_TYPE mColor;
int mBlend;
int mBase;

View File

@@ -44,11 +44,12 @@ bool JAnimator::Load(const char* scriptFile)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false;
if (!fileSystem->OpenFile(scriptFile)) return false;
JFile* jFile = fileSystem->OpenFile(scriptFile);
if (!jFile) return false;
int size = fileSystem->GetFileSize();
int size = fileSystem->GetFileSize(jFile);
char *xmlBuffer = new char[size];
fileSystem->ReadFile(xmlBuffer, size);
fileSystem->ReadFile(jFile, xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
@@ -173,7 +174,7 @@ bool JAnimator::Load(const char* scriptFile)
}
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
delete[] xmlBuffer;
return true;

View File

@@ -49,7 +49,8 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (!fileSystem->OpenFile(fileName))
JFile* jFile = fileSystem->OpenFile(fileName);
if (!jFile)
return 0;
memset(p_wav, 0, sizeof(WAVDATA));
@@ -57,14 +58,14 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
char head[256];
memset(head, 0, 256);
//sceIoRead(fd, head, 20);
fileSystem->ReadFile(head, 20);
fileSystem->ReadFile(jFile, head, 20);
char string[8];
memset(string, 0, 8);
memcpy(string, head, 4);
if (0!=strcmp(string, "RIFF"))
{
//sceIoClose(fd);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
return 0;
}
memset(string, 0, 8);
@@ -72,7 +73,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (0!=strcmp(string, "WAVE"))
{
//sceIoClose(fd);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
return 0;
}
memset(string, 0, 8);
@@ -80,42 +81,42 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (0!=strcmp(string, "fmt"))
{
//sceIoClose(fd);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
return 0;
}
int fmtSize = 0;
memcpy(&fmtSize, head+16, 4);
//sceIoRead(fd, head+20, fmtSize);
fileSystem->ReadFile(head+20,fmtSize );
fileSystem->ReadFile(jFile, head+20,fmtSize );
p_wav->headSize = 20+fmtSize;
while (1)
{
//sceIoRead(fd, head+p_wav->headSize, 4);
fileSystem->ReadFile(head+p_wav->headSize, 4);
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
memset(string, 0, 8);
memcpy(string, head+p_wav->headSize, 4);
p_wav->headSize += 4;
if (0!=strcmp(string, "data"))
{
//sceIoRead(fd, head+p_wav->headSize, 4);
fileSystem->ReadFile(head+p_wav->headSize, 4);
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
memcpy(&fmtSize, head+p_wav->headSize, 4);
p_wav->headSize += 4;
//sceIoRead(fd, head+p_wav->headSize, fmtSize);
fileSystem->ReadFile(head+p_wav->headSize, fmtSize);
fileSystem->ReadFile(jFile, head+p_wav->headSize, fmtSize);
p_wav->headSize += fmtSize;
}
else
{
//sceIoRead(fd, head+p_wav->headSize, 4);
fileSystem->ReadFile(head+p_wav->headSize, 4);
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
p_wav->headSize += 4;
break;
}
if (p_wav->headSize>191)
{
//sceIoClose(fd);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
return 0;
}
}
@@ -126,7 +127,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->channelCount!=1 && p_wav->channelCount!=2)
{
//sceIoClose(fd);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
return 0;
}
memcpy(&p_wav->samplePerSecond, head+24, 4);
@@ -136,7 +137,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->bytePerSample!=1 && p_wav->bytePerSample!=2)
{
//sceIoClose(fd);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
return 0;
}
p_wav->nSample = 44100 / p_wav->samplePerSecond;
@@ -147,17 +148,17 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->soundSize>4096000)
{
//sceIoClose(fd);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
return 0;
}
p_wav->buffer = (char*)malloc(p_wav->soundSize);
memset(p_wav->buffer, 0, p_wav->soundSize);
//sceIoRead(fd, p_wav->buffer, p_wav->soundSize);
fileSystem->ReadFile(p_wav->buffer, p_wav->soundSize);
fileSystem->ReadFile(jFile, p_wav->buffer, p_wav->soundSize);
p_wav->bytePosition = 0;
p_wav->fd = -1;
//sceIoClose(fd);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
}
else
{

View File

@@ -107,7 +107,6 @@ JFileSystem* JFileSystem::GetInstance()
// Tries to set the system and user paths.
// On some OSes, the parameters get overriden by hardcoded values
JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
{
string systemPath = _systemPath;
string userPath = _userPath;
@@ -131,8 +130,8 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
dir.mkdir(USERDIR);
dir.cd(USERDIR);
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
DebugTrace("User path " << userPath);
DebugTrace("System path " << systemPath);
@@ -192,9 +191,6 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
mZipAvailable = false;
mZipCachedElementsCount = 0;
mPassword = NULL;
mFileSize = 0;
mCurrentFileInZip = NULL;
};
void JFileSystem::Destroy()
@@ -208,14 +204,26 @@ void JFileSystem::Destroy()
bool JFileSystem::DirExists(const string& strDirname)
{
return (mSystemFS && mSystemFS->DirExists(strDirname)) || mUserFS->DirExists(strDirname);
return (
(mSystemFS && mSystemFS->DirExists(strDirname))
|| mUserFS->DirExists(strDirname)
#ifdef QT_CONFIG
|| QDir(QString(":/") + strDirname.c_str()).exists()
#endif
);
}
bool JFileSystem::FileExists(const string& strFilename)
{
if (strFilename.length() < 1 ) return false;
return (mSystemFS && mSystemFS->FileExists(strFilename)) || mUserFS->FileExists(strFilename);
return (
(mSystemFS && mSystemFS->FileExists(strFilename))
|| mUserFS->FileExists(strFilename)
#ifdef QT_CONFIG
|| QFile(QString(":/") + strFilename.c_str()).exists()
#endif
);
}
bool JFileSystem::MakeDir(const string & dir)
@@ -275,7 +283,6 @@ bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL
}
mZipAvailable = true;
return true;
}
@@ -285,7 +292,6 @@ void JFileSystem::DetachZipFile()
{
mZipFile.close();
}
mCurrentFileInZip = NULL;
mZipAvailable = false;
}
@@ -307,28 +313,58 @@ bool JFileSystem::openForRead(izfstream & File, const string & FilePath) {
bool JFileSystem::readIntoString(const string & FilePath, string & target)
{
izfstream file;
if (!openForRead(file, FilePath))
return false;
int fileSize = GetFileSize(file);
bool result = false;
// Trying first with a izfstream
do {
izfstream file;
if (!openForRead(file, FilePath))
break;
int fileSize = GetFileSize(file);
#ifndef __MINGW32__
try {
try {
#endif
target.resize((std::string::size_type) fileSize);
target.resize((std::string::size_type) fileSize);
#ifndef __MINGW32__
} catch (bad_alloc&) {
return false;
}
} catch (bad_alloc&) {
break;
}
#endif
if (fileSize)
file.read(&target[0], fileSize);
file.close();
return true;
if (fileSize)
file.read(&target[0], fileSize);
file.close();
result = true;
} while (0);
#ifdef QT_CONFIG
// Now we try with qrc if we haven't finc anything yet
if (!result) do {
string path = string(":/") + FilePath.c_str();
QFile qfile(path.c_str());
qfile.open(QIODevice::ReadOnly);
if(!qfile.isReadable())
break;
int fileSize = qfile.size();
#ifndef __MINGW32__
try {
#endif
target.resize((std::string::size_type) fileSize);
#ifndef __MINGW32__
} catch (bad_alloc&) {
break;
}
#endif
if (fileSize)
qfile.read(&target[0], fileSize);
qfile.close();
result = true;
} while (0);
#endif //QT_CONFIG
return result;
}
bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode)
@@ -374,57 +410,72 @@ bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_bas
return false;
}
bool JFileSystem::OpenFile(const string &filename)
JFile* JFileSystem::OpenFile(const string &filename)
{
mCurrentFileInZip = NULL;
bool result;
JFile* jFile = new JFile();
jFile->mCurrentFileInZip = NULL;
if (!mZipAvailable || !mZipFile)
return openForRead(mFile, filename);
do {
if (!mZipAvailable || !mZipFile) {
result = openForRead(jFile->mFile, filename);
if(!result) {
#ifdef QT_CONFIG
string path = string(":/") + filename.c_str();
jFile->mpqFile = new QFile(path.c_str());
jFile->mpqFile->open(QIODevice::ReadOnly);
result = jFile->mpqFile->isReadable();
#endif
}
break;
}
preloadZip(mZipFileName);
map<string,JZipCache *>::iterator it = mZipCache.find(mZipFileName);
if (it == mZipCache.end())
{
//DetachZipFile();
//return OpenFile(filename);
return openForRead(mFile, filename);
}
JZipCache * zc = it->second;
map<string, filesystem::limited_file_info>::iterator it2 = zc->dir.find(filename);
if (it2 == zc->dir.end())
{
/*DetachZipFile();
preloadZip(mZipFileName);
map<string,JZipCache *>::iterator it = mZipCache.find(mZipFileName);
if (it == mZipCache.end())
{
//DetachZipFile();
//return OpenFile(filename);
result = openForRead(jFile->mFile, filename);
break;
}
JZipCache * zc = it->second;
map<string, filesystem::limited_file_info>::iterator it2 = zc->dir.find(filename);
if (it2 == zc->dir.end())
{
/*DetachZipFile();
return OpenFile(filename); */
return openForRead(mFile, filename);
result = openForRead(jFile->mFile, filename);
break;
}
jFile->mCurrentFileInZip = &(it2->second);
result = true;
} while(0);
if(result)
return jFile;
else {
delete jFile;
return 0;
}
mCurrentFileInZip = &(it2->second);
mFileSize = it2->second.m_Size;
return true;
}
void JFileSystem::CloseFile()
void JFileSystem::CloseFile(JFile* jFile)
{
if (mZipAvailable && mZipFile)
{
mCurrentFileInZip = NULL;
}
if (mFile)
mFile.close();
delete jFile;
}
//returns 0 if less than "size" bits were read
int JFileSystem::ReadFile(void *buffer, int size)
int JFileSystem::ReadFile(JFile* jFile, void *buffer, int size)
{
if (mCurrentFileInZip)
if (jFile->mCurrentFileInZip)
{
assert(mZipFile);
if((size_t)size > mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips
if((size_t)size > jFile->mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips
return 0;
std::streamoff offset = filesystem::SkipLFHdr(mZipFile, mCurrentFileInZip->m_Offset);
std::streamoff offset = filesystem::SkipLFHdr(mZipFile, jFile->mCurrentFileInZip->m_Offset);
if (!mZipFile.seekg(offset))
return 0;
mZipFile.read((char *) buffer, size);
@@ -432,16 +483,43 @@ int JFileSystem::ReadFile(void *buffer, int size)
return size;
}
if (!mFile)
#ifdef QT_CONFIG
if(jFile->mpqFile) {
return jFile->mpqFile->read((char*)buffer, size);
}
#endif
if (!jFile->mFile)
return 0;
assert(!mFile.Zipped() || (size_t)size <= mFile.getUncompSize());
mFile.read((char *)buffer, size);
if (mFile.eof())
assert(!jFile->mFile.Zipped() || (size_t)size <= jFile->mFile.getUncompSize());
jFile->mFile.read((char *)buffer, size);
if (jFile->mFile.eof())
return 0;
return size;
}
bool JFileSystem::ReadFileLine(JFile* jFile, string& s)
{
if(!jFile) return false;
#ifdef QT_CONFIG
if(jFile->mpqFile) {
QString qs = jFile->mpqFile->readLine();
if(qs.isEmpty())
return false;
else {
s = qs.toStdString();
return true;
}
}
#endif
if(!jFile->mFile)
return 0;
assert(!jFile->mFile.Zipped());
return std::getline(jFile->mFile, s);
}
std::vector<std::string>& JFileSystem::scanRealFolder(const std::string& folderName, std::vector<std::string>& results)
{
DIR *dip = opendir(folderName.c_str());
@@ -529,8 +607,17 @@ std::vector<std::string>& JFileSystem::scanfolder(const std::string& _folderName
seen[systemReal[i]] = true;
}
}
#ifdef QT_CONFIG
string path = string(":/") + folderName;
QDir dir(path.c_str());
QStringList list = dir.entryList();
for(int i = 0; i < list.size(); i++)
{
seen[list.at(i).toStdString()] = true;
}
#endif
for(map<string,bool>::iterator it = seen.begin(); it != seen.end(); ++it)
for(map<string,bool>::iterator it = seen.begin(); it != seen.end(); ++it)
{
results.push_back(it->first);
}
@@ -544,12 +631,18 @@ std::vector<std::string> JFileSystem::scanfolder(const std::string& folderName)
return scanfolder(folderName, result);
}
int JFileSystem::GetFileSize()
int JFileSystem::GetFileSize(JFile* jFile)
{
if (mCurrentFileInZip)
return mFileSize;
if (jFile->mCurrentFileInZip)
return jFile->mCurrentFileInZip->m_Size;
return GetFileSize(mFile);
#ifdef QT_CONFIG
if(jFile->mpqFile) {
return jFile->mpqFile->size();
}
#endif
return GetFileSize(jFile->mFile);
}
bool JFileSystem::Rename(string _from, string _to)

View File

@@ -116,25 +116,26 @@ bool JGBKFont::Init(const char* engFileName, const char* chnFileName, int fontsi
int size;
JFileSystem *fileSys = JFileSystem::GetInstance();
if (!fileSys->OpenFile(engFileName))
JFile* jFile = fileSys->OpenFile(engFileName);
if (!jFile)
return false;
size = fileSys->GetFileSize();
size = fileSys->GetFileSize(jFile);
mEngFont = new BYTE[size];
fileSys->ReadFile(mEngFont, size);
fileSys->CloseFile();
fileSys->ReadFile(jFile, mEngFont, size);
fileSys->CloseFile(jFile);
if (!fileSys->OpenFile(chnFileName))
jFile = fileSys->OpenFile(chnFileName);
if (!jFile)
return false;
size = fileSys->GetFileSize();
size = fileSys->GetFileSize(jFile);
mChnFont = new BYTE[size];
fileSys->ReadFile(mChnFont, size);
fileSys->CloseFile();
fileSys->ReadFile(jFile, mChnFont, size);
fileSys->CloseFile(jFile);
return true;
}

View File

@@ -892,9 +892,10 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
{
png_size_t check;
JFileSystem *fileSystem = (JFileSystem*)png_ptr->io_ptr;
JFile* jFile = (JFile*)png_ptr->io_ptr;
JFileSystem* fileSystem = JFileSystem::GetInstance();
check = fileSystem->ReadFile(data, length);
check = fileSystem->ReadFile(jFile, data, length);
if (check != length)
{
@@ -1038,23 +1039,24 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
bits32 = NULL;
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (!fileSystem->OpenFile(filename))
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
{
return;
}
rawsize = fileSystem->GetFileSize();
rawsize = fileSystem->GetFileSize(jFile);
rawdata = new u8[rawsize];
if (!rawdata)
{
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
return;
}
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
cinfo.err = jpeg_std_error(&jerr);
@@ -1362,24 +1364,25 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
u32* line;
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (!fileSystem->OpenFile(filename)) return JGE_ERR_CANT_OPEN_FILE;
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return JGE_ERR_CANT_OPEN_FILE;
//JLOG("PNG opened - creating read struct");
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL) {
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
return JGE_ERR_PNG;
}
//JLOG("Setting error callback func");
png_set_error_fn(png_ptr, (png_voidp) NULL, (png_error_ptr) NULL, PNGCustomWarningFn);
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) {
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_PNG;
}
png_init_io(png_ptr, NULL);
png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
png_set_read_fn(png_ptr, (png_voidp)jFile, PNGCustomReadDataFn);
png_set_sig_bytes(png_ptr, sig_read);
png_read_info(png_ptr, info_ptr);
@@ -1392,7 +1395,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER);
line = (u32*) malloc(width * 4);
if (!line) {
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED;
}
@@ -1430,7 +1433,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
std::ostringstream stream;
stream << "Alloc failed for: Tex Width: " << texWidth << " Tex Height: " << kVerticalBlockSize << ", total bytes: " << texWidth * kVerticalBlockSize * sizeof(PIXEL_TYPE);
JLOG(stream.str().c_str());
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED;
}
@@ -1505,7 +1508,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
//JLOG("Closing PNG");
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
if (done)
{
@@ -1725,9 +1728,9 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
{
JFileSystem *fileSys = (JFileSystem *)ft->UserData;
if (fileSys->ReadFile(buf, size))
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = (JFile*)ft->UserData;
if (fileSys->ReadFile(jFile, buf, size))
return size;
else
return 0;
@@ -1740,15 +1743,17 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
JFileSystem *fileSys = JFileSystem::GetInstance();
if (!fileSys->OpenFile(filename))
JFile* jFile = fileSys->OpenFile(filename);
if (!jFile)
return;
DWORD bkcol;
int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode);
if(result!=0)
textureInfo.mBits=NULL;
fileSys->CloseFile();
fileSys->CloseFile(jFile);
return ;
}
@@ -2262,4 +2267,4 @@ void JRenderer::FillRoundRect(float x, float y, float w, float h, float radius,
void JRenderer::SetImageFilter(JImageFilter* imageFilter)
{
mImageFilter = imageFilter;
}
}

View File

@@ -42,10 +42,11 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
//FILE *file;
JFileSystem *fileSys = JFileSystem::GetInstance();
if (!fileSys->OpenFile(filename)) return;
JFile* jFile = fileSys->OpenFile(filename);
if (!jFile) return;
fileSys->ReadFile((u8 *)buffer, 2048);
fileSys->CloseFile();
fileSys->ReadFile(jFile, (u8 *)buffer, 2048);
fileSys->CloseFile(jFile);
sprintf(filename, "%s.png", fontname);
mTexture = mRenderer->LoadTexture(filename, useVideoRAM);

View File

@@ -96,7 +96,8 @@ bool JMD2Model::Load(char *filename, char *textureName)
// open the model file
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (!fileSystem->OpenFile(filename))
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
return false;
//filePtr = fopen(filename, "rb");
//if (filePtr == NULL)
@@ -107,13 +108,13 @@ bool JMD2Model::Load(char *filename, char *textureName)
//fileLen = ftell(filePtr);
//fseek(filePtr, 0, SEEK_SET);
fileLen = fileSystem->GetFileSize();
fileLen = fileSystem->GetFileSize(jFile);
// read entire file into buffer
buffer = (char*)malloc(fileLen + 1);
//fread(buffer, sizeof(char), fileLen, filePtr);
fileSystem->ReadFile(buffer, fileLen);
fileSystem->CloseFile();
fileSystem->ReadFile(jFile, buffer, fileLen);
fileSystem->CloseFile(jFile);
// extract model file header from buffer
modelHeader = (modelHeader_t*)buffer;

View File

@@ -47,14 +47,15 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
{
JFileSystem* fileSys = JFileSystem::GetInstance();
if (!fileSys->OpenFile(modelName))
JFile* jFile = fileSys->OpenFile(modelName);
if (!jFile)
return false;
int size = fileSys->GetFileSize();
int size = fileSys->GetFileSize(jFile);
char *buffer = new char[size];
fileSys->ReadFile(buffer, size);
fileSys->CloseFile();
fileSys->ReadFile(jFile, buffer, size);
fileSys->CloseFile(jFile);
Vector3D vert;

View File

@@ -55,11 +55,12 @@ bool JParticleEffect::Load(const char* filename)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false;
if (!fileSystem->OpenFile(filename)) return false;
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return false;
int size = fileSystem->GetFileSize();
int size = fileSystem->GetFileSize(jFile);
char *xmlBuffer = new char[size];
fileSystem->ReadFile(xmlBuffer, size);
fileSystem->ReadFile(jFile, xmlBuffer, size);
TiXmlDocument doc;
@@ -296,7 +297,7 @@ bool JParticleEffect::Load(const char* filename)
}
}
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
delete[] xmlBuffer;
return true;

View File

@@ -93,13 +93,13 @@ bool JResourceManager::LoadResource(const string& resourceName)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(path.c_str());
if (!jFile) return false;
if (!fileSystem->OpenFile(path.c_str())) return false;
int size = fileSystem->GetFileSize();
int size = fileSystem->GetFileSize(jFile);
char *xmlBuffer = new char[size];
fileSystem->ReadFile(xmlBuffer, size);
fileSystem->ReadFile(jFile, xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
@@ -179,7 +179,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
}
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
delete[] xmlBuffer;
// JGERelease();

View File

@@ -41,11 +41,12 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false;
if (!fileSystem->OpenFile(filename)) return false;
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return false;
int size = fileSystem->GetFileSize();
int size = fileSystem->GetFileSize(jFile);
char *xmlBuffer = new char[size];
fileSystem->ReadFile(xmlBuffer, size);
fileSystem->ReadFile(jFile, xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
@@ -76,7 +77,7 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
}
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
delete[] xmlBuffer;
return true;

View File

@@ -199,15 +199,16 @@ bool JTTFont::Load(const char *filename, int size, int mode)
if (FT_Init_FreeType( &mLibrary ) == 0)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (fileSystem->OpenFile(filename))
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (jFile)
{
mFontBitsSize = fileSystem->GetFileSize();
mFontBitsSize = fileSystem->GetFileSize(jFile);
mFontBits = (FT_Byte*)malloc(mFontBitsSize);
fileSystem->ReadFile(mFontBits, mFontBitsSize);
fileSystem->CloseFile();
fileSystem->ReadFile(jFile, mFontBits, mFontBitsSize);
fileSystem->CloseFile(jFile);
if (FT_New_Memory_Face(mLibrary, mFontBits, mFontBitsSize, 0, &mFace ) == 0)
{

View File

@@ -57,19 +57,20 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap __attribute__((unused)))
// Load font description
JFileSystem* fileSys = JFileSystem::GetInstance();
if (!fileSys->OpenFile(szFont)) return;
JFile* jFile = fileSys->OpenFile(szFont);
if (!jFile) return;
//data=hge->Resource_Load(szFont, &size);
//if(!data) return;
size = fileSys->GetFileSize();
size = fileSys->GetFileSize(jFile);
desc = new char[size+1];
//memcpy(desc,data,size);
fileSys->ReadFile(desc, size);
fileSys->ReadFile(jFile, desc, size);
desc[size]=0;
//hge->Resource_Free(data);
fileSys->CloseFile();
fileSys->CloseFile(jFile);
pdesc=_get_line(desc,linebuf);
if(strcmp(linebuf, FNTHEADERTAG))

View File

@@ -50,46 +50,41 @@ float Random_Float(float min, float max)
hgeParticleSystem::hgeParticleSystem(const char *filename, JQuad *sprite)
{
//void *psi;
//hgeParticleSystemInfo psi;
JFileSystem* fileSys = JFileSystem::GetInstance();
//hge=hgeCreate(HGE_VERSION);
//psi=hge->Resource_Load(filename);
if (!fileSys->OpenFile(filename)) return;
//if(!psi) return;
//memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
//hge->Resource_Free(psi);
// Skip reading the pointer as it may be larger than 4 bytes in the structure
void *dummyPointer;
fileSys->ReadFile(&dummyPointer, 4);
// we're actually trying to read more than the file size now, but it's no problem.
// Note that this fix is only to avoid the largest problems, filling a structure
// by directly reading a file, is really a bad idea ...
fileSys->ReadFile(&(info.nEmission), sizeof(hgeParticleSystemInfo) - 4);
fileSys->CloseFile();
info.sprite=sprite;
// info.fGravityMin *= 100;
// info.fGravityMax *= 100;
// info.fSpeedMin *= 100;
// info.fSpeedMax *= 100;
vecLocation.x=vecPrevLocation.x=0.0f;
vecLocation.y=vecPrevLocation.y=0.0f;
fTx=fTy=0;
fEmissionResidue=0.0f;
nParticlesAlive=0;
fAge=-2.0;
mTimer = 0.0f;
rectBoundingBox.Clear();
bUpdateBoundingBox=false;
JFileSystem* fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(filename);
if (!jFile) return;
//if(!psi) return;
//memcpy(&info, psi, sizeof(hgeParticleSystemInfo));
//hge->Resource_Free(psi);
// Skip reading the pointer as it may be larger than 4 bytes in the structure
void *dummyPointer;
fileSys->ReadFile(jFile, &dummyPointer, 4);
// we're actually trying to read more than the file size now, but it's no problem.
// Note that this fix is only to avoid the largest problems, filling a structure
// by directly reading a file, is really a bad idea ...
fileSys->ReadFile(jFile, &(info.nEmission), sizeof(hgeParticleSystemInfo) - 4);
fileSys->CloseFile(jFile);
info.sprite=sprite;
// info.fGravityMin *= 100;
// info.fGravityMax *= 100;
// info.fSpeedMin *= 100;
// info.fSpeedMax *= 100;
vecLocation.x=vecPrevLocation.x=0.0f;
vecLocation.y=vecPrevLocation.y=0.0f;
fTx=fTy=0;
fEmissionResidue=0.0f;
nParticlesAlive=0;
fAge=-2.0;
mTimer = 0.0f;
rectBoundingBox.Clear();
bUpdateBoundingBox=false;
}
hgeParticleSystem::hgeParticleSystem(hgeParticleSystemInfo *psi)

View File

@@ -1683,20 +1683,21 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
int rawsize, i;
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (!fileSystem->OpenFile(filename)) return;
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return;
rawsize = fileSystem->GetFileSize();
rawsize = fileSystem->GetFileSize(jFile);
rawdata = new BYTE[rawsize];
if (!rawdata)
{
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
return;
}
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
// Initialize libJpeg Object
cinfo.err = jpeg_std_error(&jerr);
@@ -1804,9 +1805,10 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
{
png_size_t check;
JFileSystem *fileSystem = (JFileSystem*)png_ptr->io_ptr;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile *jFile = (JFile*)png_ptr->io_ptr;
check = fileSystem->ReadFile(data, length);
check = fileSystem->ReadFile(jFile, data, length);
if (check != length)
{
@@ -1869,13 +1871,14 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
DWORD* line;
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (!fileSystem->OpenFile(filename))
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
return JGE_ERR_CANT_OPEN_FILE;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (png_ptr == NULL)
{
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
return JGE_ERR_PNG;
}
@@ -1885,14 +1888,14 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
if (info_ptr == NULL)
{
//fclose(fp);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_PNG;
}
png_init_io(png_ptr, NULL);
png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
png_set_read_fn(png_ptr, (png_voidp)jFile, PNGCustomReadDataFn);
png_set_sig_bytes(png_ptr, sig_read);
png_read_info(png_ptr, info_ptr);
@@ -1908,7 +1911,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
if (!line)
{
//fclose(fp);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED;
@@ -1957,7 +1960,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
png_read_end(png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
textureInfo.mBits = buffer;
@@ -2116,9 +2119,10 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
{
JFileSystem *fileSys = (JFileSystem *)ft->UserData;
//return fread(buf, 1, size, (FILE *)ft->UserData);
if (fileSys->ReadFile(buf, size))
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = (JFile*)ft->UserData;
if (fileSys->ReadFile(jFile, buf, size))
return size;
else
return 0;
@@ -2130,17 +2134,18 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
///*
//FILE * fp = fopen(filename, "rb");
JFileSystem *fileSys = JFileSystem::GetInstance();
if (!fileSys->OpenFile(filename))
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile))
return;
//if(fp == NULL)
// return;
DWORD bkcol;
int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode);
if(result!=0)
textureInfo.mBits=NULL;
//fclose(fp);
fileSys->CloseFile();
fileSys->CloseFile(jFile);
return ;//*/
}
#endif //(!defined IOS) && (!defined QT_CONFIG) && (!defined SDL_CONFIG)
@@ -2161,20 +2166,21 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureForm
UIImage *image = NULL;
do {
if (!fileSystem->OpenFile(filename))
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
break;
rawsize = fileSystem->GetFileSize();
rawsize = fileSystem->GetFileSize(jFile);
rawdata = new BYTE[rawsize];
if (!rawdata)
{
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
break;
}
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
texData = [[NSData alloc] initWithBytes:rawdata length:rawsize];
image = [[UIImage alloc] initWithData:texData];
@@ -2254,20 +2260,21 @@ JTexture* JRenderer::LoadTexture(const char* filename, int, int)
JFileSystem* fileSystem = JFileSystem::GetInstance();
do {
if (!fileSystem->OpenFile(filename))
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
break;
rawsize = fileSystem->GetFileSize();
rawsize = fileSystem->GetFileSize(jFile);
rawdata = new BYTE[rawsize];
if (!rawdata)
{
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
break;
}
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
QImage tmpImage = QImage::fromData(rawdata, rawsize);
if(tmpImage.isNull())

View File

@@ -161,15 +161,16 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
if (music)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (fileSystem->OpenFile(fileName))
JFile* jFile = fileSystem->OpenFile(fileName);
if (jFile)
{
int size = fileSystem->GetFileSize();
int size = fileSystem->GetFileSize(jFile);
char *buffer = new char[size];
fileSystem->ReadFile(buffer, size);
fileSystem->ReadFile(jFile, buffer, size);
music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer;
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
}
}
return music;
@@ -281,15 +282,16 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
if (sample)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (fileSystem->OpenFile(fileName))
JFile* jFile = fileSystem->OpenFile(fileName);
if (jFile)
{
int size = fileSystem->GetFileSize();
int size = fileSystem->GetFileSize(jFile);
char *buffer = new char[size];
fileSystem->ReadFile(buffer, size);
fileSystem->ReadFile(jFile, buffer, size);
sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer;
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
}else
sample->mSample = NULL;

View File

@@ -42,6 +42,39 @@ def getFilename():
filename = 'core_' + major + minor + point
return filename
def createQrcFile():
utilities = ZipUtilities()
print "Creating Qt Resource File"
filename = "core.qrc"
f = open(filename, 'w')
f.seek(0,0)
f.write("""<!DOCTYPE RCC><RCC version="1.0">\n<qresource>\n""")
rename = False
if not os.path.isfile('settings/options.txt'):
os.rename('settings/options.orig.txt', 'settings/options.txt')
remame = True
if not os.path.isfile('player/options.txt'):
os.rename('player/options.orig.txt', 'player/options.txt')
rename = True
utilities.addFolderToQrc(f, 'themes')
utilities.addFolderToQrc(f, 'sound')
utilities.addFolderToQrc(f, 'settings')
utilities.addFolderToQrc(f, 'sets')
utilities.addFolderToQrc(f, 'rules')
utilities.addFolderToQrc(f, 'player')
utilities.addFolderToQrc(f, 'packs')
utilities.addFolderToQrc(f, 'lang')
utilities.addFolderToQrc(f, 'graphics')
utilities.addFolderToQrc(f, 'campaigns')
utilities.addFolderToQrc(f, 'ai')
if rename:
os.rename('settings/options.txt', 'settings/options.orig.txt')
os.rename('player/options.txt', 'player/options.orig.txt')
f.seek(0,2)
f.write('</qresource>\n</RCC>\n')
f.close
print >> sys.stderr, 'Created Resource Package for Qt projects: {0}'.format( filename)
def createStandardResFile():
@@ -84,20 +117,37 @@ class ZipUtilities:
print 'Entering folder: ' + str(full_path)
self.addFolderToZip(zip_file, full_path)
def addFolderToQrc(self, qrc, folder):
qrc.seek(0,2)
for file in os.listdir(folder):
if file != '.svn':
full_path = os.path.join(folder, file)
if os.path.isfile(full_path):
print 'File added: ' + str(full_path)
qrc.write('<file>')
qrc.write(full_path)
qrc.write('</file>\n')
elif os.path.isdir(full_path):
print 'Entering folder: ' + str(full_path)
self.addFolderToQrc(qrc, full_path)
def main():
## using optparse instead of argParse for now since python 2.7 may not be installed.
parser = OptionParser()
parser.add_option("-p", "--platform", help="PLATFORM: specify custom build. (eg ios, android, etc)", metavar="PLATFORM", dest="platform")
parser.add_option("-p", "--platform", help="PLATFORM: specify custom build. (eg qt, ios, android, etc)", metavar="PLATFORM", dest="platform")
(options, args) = parser.parse_args()
if (options.platform):
if (options.platform == "ios"):
createIosResFile()
print "reading %s..." % options.platform
if (options.platform == 'ios'):
createIosResFile()
elif (options.platform == 'qt'):
createQrcFile()
else:
createStandardResFile()
createStandardResFile()
else:
createStandardResFile()

View File

@@ -1843,7 +1843,7 @@ int Tournament::getRandomDeck(bool noEasyDecks)
DeckManager *deckManager = DeckManager::GetInstance();
vector<DeckMetaData *> *deckList = deckManager->getAIDeckOrderList();
int deckNumber;
int deckNumber=0;
unsigned int random=0;
int k=0;
bool isDouble=true;

View File

@@ -300,12 +300,12 @@ string GameStateMenu::loadRandomWallpaper()
return wallpaper;
vector<string> wallpapers;
izfstream file;
if (! JFileSystem::GetInstance()->openForRead(file, "graphics/wallpapers.txt"))
JFile* jFile = JFileSystem::GetInstance()->OpenFile("graphics/wallpapers.txt");
if (!jFile)
return wallpaper;
string s;
while (std::getline(file, s))
while (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
{
if (!s.size())
continue;
@@ -313,7 +313,7 @@ string GameStateMenu::loadRandomWallpaper()
s.erase(s.size() - 1); //Handle DOS files
wallpapers.push_back(s);
}
file.close();
JFileSystem::GetInstance()->CloseFile(jFile);
int rnd = rand() % (wallpapers.size());
wallpaper = wallpapers[rnd];
@@ -352,21 +352,21 @@ void GameStateMenu::loadLangMenu()
vector<string> langFiles = JFileSystem::GetInstance()->scanfolder("lang/");
for (size_t i = 0; i < langFiles.size(); ++i)
{
izfstream file;
string filePath = "lang/";
filePath.append(langFiles[i]);
if (! JFileSystem::GetInstance()->openForRead(file, filePath))
JFile* jFile = JFileSystem::GetInstance()->OpenFile(filePath);
if (!jFile)
continue;
string s;
string lang;
if (std::getline(file, s))
if (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
{
lang = getLang(s);
}
file.close();
JFileSystem::GetInstance()->CloseFile(jFile);
if (lang.size())
{

View File

@@ -399,8 +399,8 @@ int MTGAllCards::load(const string &config_file, int set_id)
int lineNumber = 0;
std::string contents;
izfstream file;
if (!JFileSystem::GetInstance()->openForRead(file, config_file))
JFile* jFile = JFileSystem::GetInstance()->OpenFile(config_file);
if (!jFile)
{
DebugTrace("MTGAllCards::load: error loading: " << config_file);
return total_cards;
@@ -408,7 +408,7 @@ int MTGAllCards::load(const string &config_file, int set_id)
string s;
while (getline(file,s))
while (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
{
lineNumber++;
if (!s.size()) continue;
@@ -448,7 +448,7 @@ int MTGAllCards::load(const string &config_file, int set_id)
if (!maxGrade) maxGrade = Constants::GRADE_BORDERLINE; //Default setting for grade is borderline?
if (fileGrade > maxGrade)
{
file.close();
JFileSystem::GetInstance()->CloseFile(jFile);
return total_cards;
}
}
@@ -480,7 +480,7 @@ int MTGAllCards::load(const string &config_file, int set_id)
continue;
}
}
file.close();
JFileSystem::GetInstance()->CloseFile(jFile);
return total_cards;
}

View File

@@ -326,16 +326,16 @@ void OptionLanguage::Reload()
vector<string> langFiles = JFileSystem::GetInstance()->scanfolder("lang/");
for (size_t i = 0; i < langFiles.size(); ++i)
{
izfstream file;
string filePath = "lang/";
filePath.append(langFiles[i]);
if (! JFileSystem::GetInstance()->openForRead(file, filePath))
JFile* jFile = JFileSystem::GetInstance()->OpenFile(filePath);
if (!jFile)
continue;
string s;
string lang;
if (std::getline(file, s))
if (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
{
if (!s.size())
{
@@ -352,7 +352,7 @@ void OptionLanguage::Reload()
lang = s.substr(6);
}
}
file.close();
JFileSystem::GetInstance()->CloseFile(jFile);
if (lang.size())
{

View File

@@ -599,16 +599,17 @@ bool StoryFlow::parse(string path)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (!fileSystem) return false;
if (!fileSystem->OpenFile(path.c_str())) return false;
JFile* jFile = fileSystem->OpenFile(path.c_str());
if (!jFile) return false;
int size = fileSystem->GetFileSize();
int size = fileSystem->GetFileSize(jFile);
char *xmlBuffer = NEW char[size];
fileSystem->ReadFile(xmlBuffer, size);
fileSystem->ReadFile(jFile, xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
fileSystem->CloseFile();
fileSystem->CloseFile(jFile);
delete[] xmlBuffer;
for (TiXmlNode* node = doc.FirstChild(); node; node = node->NextSibling())

View File

@@ -333,8 +333,9 @@ bool WCachedParticles::Attempt(const string& filename, int, int & error)
{
JFileSystem* fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(WResourceManager::Instance()->graphicsFile(filename));
if (!fileSys->OpenFile(WResourceManager::Instance()->graphicsFile(filename)))
if (!jFile)
{
error = CACHE_ERROR_404;
return false;
@@ -345,12 +346,12 @@ bool WCachedParticles::Attempt(const string& filename, int, int & error)
particles = NEW hgeParticleSystemInfo;
// We Skip reading the pointer as it may be larger than 4 bytes in the structure
void *dummyPointer;
fileSys->ReadFile(&dummyPointer, 4);
fileSys->ReadFile(jFile, &dummyPointer, 4);
// we're actually trying to read more than the file size now, but it's no problem.
// Note that this fix is only to avoid the largest problems, filling a structure
// by directly reading a file, is really a bad idea ...
fileSys->ReadFile(&(particles->nEmission), sizeof(hgeParticleSystemInfo) - sizeof(void*));
fileSys->CloseFile();
fileSys->ReadFile(jFile, &(particles->nEmission), sizeof(hgeParticleSystemInfo) - sizeof(void*));
fileSys->CloseFile(jFile);
particles->sprite = NULL;
error = CACHE_ERROR_NONE;

View File

@@ -171,20 +171,22 @@ WFont(inFontID), mTexture(0)
unsigned char height;
} sizeStr = { 0, 0, 0 };
if (!fileSys->OpenFile(engFileName)) return;
size = fileSys->GetFileSize();
JFile* jFile = fileSys->OpenFile(engFileName);
if (!jFile) return;
size = fileSys->GetFileSize(jFile);
mStdFont = NEW u8[size];
fileSys->ReadFile(mStdFont, size);
fileSys->CloseFile();
fileSys->ReadFile(jFile, mStdFont, size);
fileSys->CloseFile(jFile);
if (!fileSys->OpenFile(fontname)) return;
fileSys->ReadFile(&sizeStr, 4); // Works only for little-endian machines (PSP and PC are)
jFile = fileSys->OpenFile(fontname);
if (!jFile) return;
fileSys->ReadFile(jFile, &sizeStr, 4); // Works only for little-endian machines (PSP and PC are)
size = sizeStr.chars * sizeStr.width * sizeStr.height / 2;
mExtraFont = NEW u8[size]; // 4 bits for a pixel
mIndex = NEW u16[65536];
fileSys->ReadFile(mIndex, 65536 * sizeof(u16));
fileSys->ReadFile(mExtraFont, size);
fileSys->CloseFile();
fileSys->ReadFile(jFile, mIndex, 65536 * sizeof(u16));
fileSys->ReadFile(jFile, mExtraFont, size);
fileSys->CloseFile(jFile);
mColor0 = ARGB(255, 255, 255, 255);
mColor = mColor0;
@@ -612,17 +614,19 @@ WGBKFont::WGBKFont(int inFontID, const char *fontname, int lineheight, bool) :
JFileSystem *fileSys = JFileSystem::GetInstance();
int size = 0;
if (!fileSys->OpenFile(fontname)) return;
size = fileSys->GetFileSize();
JFile* jFile = fileSys->OpenFile(fontname);
if (!jFile) return;
size = fileSys->GetFileSize(jFile);
mExtraFont = NEW u8[size];
fileSys->ReadFile(mExtraFont, size);
fileSys->CloseFile();
fileSys->ReadFile(jFile, mExtraFont, size);
fileSys->CloseFile(jFile);
if (!fileSys->OpenFile(engFileName)) return;
size = fileSys->GetFileSize();
jFile = fileSys->OpenFile(engFileName);
if (!jFile) return;
size = fileSys->GetFileSize(jFile);
mStdFont = NEW u8[size];
fileSys->ReadFile(mStdFont, size);
fileSys->CloseFile();
fileSys->ReadFile(jFile, mStdFont, size);
fileSys->CloseFile(jFile);
mIndex = 0;

View File

@@ -15,8 +15,9 @@ CONFIG(console, graphics|console){
}
else:CONFIG(graphics, graphics|console){
folder_01.source = qml/QmlWagic
folder_01.target = /usr/share
folder_01.target = qml
DEPLOYMENTFOLDERS = folder_01
windows:RESOURCES = bin/Res/core.qrc
QT += core gui opengl network
QT -= declarative quick qml
#maemo5:DEFINES += QT_WIDGET

View File

@@ -371,110 +371,3 @@ HEADERS += \
../../JGE/src/tinyxml/tinystr.h\
../../JGE/src/tinyxml/tinyxml.h\
../../JGE/include/vram.h
# maemo 5 packaging
maemo5: {
# Variables
BINDIR = /opt/wagic/bin
RESDIR = /home/user/wagic/Res
USERDIR = MyDocs/.Wagic
ICONDIR = /usr/share
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
INSTALLS += target \
desktop \
icon
target.path = $$BINDIR
desktop.path = $$ICONDIR/applications/hildon
desktop.files += wagic.desktop
icon.path = $$ICONDIR/icons/hicolor/64x64/apps
icon.files += wagic-64x64.png
# Meego/maemo 6 packaging (no launcher)
} else:contains(MEEGO_EDITION,harmattan): {
# Variables
BINDIR = /opt/wagic/bin
RESDIR = /opt/wagic/Res
USERDIR = MyDocs/.Wagic
ICONDIR = /usr/share
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
INSTALLS += target \
desktop \
icon \
policy
target.path = $$BINDIR
desktop.path = /usr/share/applications
desktop.files += debian_harmattan/wagic.desktop
icon.files = wagic-80x80.png
icon.path = /usr/share/icons/hicolor/64x64/apps
policy.files = debian_harmattan/wagic.conf
policy.path = /usr/share/policy/etc/syspart.conf.d
} else:symbian {
TARGET.UID3 = 0xE1D807D3
# Smart Installer package's UID
# This UID is from the protected range
# and therefore the package will fail to install if self-signed
# By default qmake uses the unprotected range value if unprotected UID is defined for the application
# and 0x2002CCCF value if protected UID is given to the application
#symbian:DEPLOYMENT.installer_header = 0x2002CCCF
# Allow network access on Symbian... that's probably pointless
TARGET.CAPABILITY += NetworkServices
RESDIR = some/res/dir
USERDIR = .Wagic
DEFINES += RESDIR=\"$$RESDIR\"
DEFINES += USERDIR=\"$$USERDIR\"
ICON = wagic.svg
} else:android {
DEFINES += Q_WS_ANDROID
RESDIR = Res
USERDIR = /sdcard/Wagic/Res
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
} else:unix {
# Variables
BINDIR = /usr/bin
ICONDIR = /usr/share
RESDIR = Res
USERDIR = .Wagic
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
target.path = $$BINDIR
desktop.path = $$ICONDIR/applications
desktop.files += wagic.desktop
icon.path = $$ICONDIR/icons/hicolor/64x64/apps
icon.files += wagic-64x64.png
INSTALLS += target \
desktop \
icon
} else:windows {
RESDIR = ./Res
USERDIR = .Wagic
DEFINES += RESDIR=\\\"$$RESDIR\\\"
DEFINES += USERDIR=\\\"$$USERDIR\\\"
}

View File

@@ -14,6 +14,7 @@ cd ../..
# we create resource package
cd projects/mtg/bin/Res
python createResourceZip.py
python createResourceZip.py --platform=qt
# if we let the zip here, Wagic will use it in the testsuite
# and we'll get 51 failed test cases
mv core_*.zip ../../../../core.zip
@@ -22,6 +23,7 @@ cd ../../../..
# we're building a PSP binary here
cd JGE
make -j 8
make -j 8 -f Makefile.hge install
cd ..
cd projects/mtg
mkdir objs
@@ -49,6 +51,8 @@ ant debug -f projects/mtg/Android/build.xml
# we're building a Qt version with GUI here
mkdir qt-gui-build
cd qt-gui-build
mv ../projects/mtg/bin/Res/settings/options.orig.txt ../projects/mtg/bin/Res/settings/options.txt
mv ../projects/mtg/bin/Res/player/options.orig.txt ../projects/mtg/bin/Res/player/options.txt
qmake ../projects/mtg/wagic-qt.pro CONFIG+=release CONFIG+=graphics
make -j 8
cd ..
@@ -58,7 +62,7 @@ qmake projects/mtg/wagic-qt.pro CONFIG+=console CONFIG+=debug DEFINES+=CAPTURE_S
make -j 8
# we're cross-compiling a Qt Windows version here,
# PATH is only set here to prevent colision
# PATH is only set here to prevent collision
export PATH="$PATH:/opt/mingw32/bin"
mkdir build
cd build
@@ -76,6 +80,8 @@ cp ../../../projects/mtg/bin/zlib1.dll .
cp /opt/mingw32/bin/libpng15-15.dll .
cd ..
zip win-cross.zip -r release/
mv ../../projects/mtg/bin/Res/settings/options.txt ../../projects/mtg/bin/Res/settings/options.orig.txt
mv ../../projects/mtg/bin/Res/player/options.txt ../../projects/mtg/bin/Res/player/options.orig.txt
cd ../..
# Now we run the testsuite (Res needs to be in the working directory)