Compare commits

..

32 Commits

Author SHA1 Message Date
xawotihs 25c844c1f5 Activates SDL build in travis 2014-02-10 22:57:53 +01:00
xawotihs 34492d9096 Adds Threading implementation on SDL 2014-02-03 23:08:17 +01:00
xawotihs 30d92eb68c Should fix issue #497 with the broken freezing the game. 2014-01-18 22:50:16 +01:00
xawotihs 6e6a0fd5c2 OMG I so hate shells 2014-01-18 16:00:14 +01:00
xawotihs cd4a980182 More debug 2014-01-18 15:26:09 +01:00
xawotihs aad54fd98d Adds debug in build script 2014-01-18 14:57:23 +01:00
xawotihs 6b7a49506c Should fix the stringifying issue 2014-01-18 14:23:26 +01:00
xawotihs 7ecf67c176 And again 2014-01-18 13:37:43 +01:00
xawotihs 77aeb2d0ac Fixed release name 2014-01-18 13:29:50 +01:00
xawotihs 7a9f989104 Adds some URL error log 2014-01-18 12:46:27 +01:00
xawotihs ae06bebd24 Merge branch 'github_downloader' 2014-01-18 12:11:08 +01:00
xawotihs 042fb7b376 Tries to fix Android compilation 2014-01-18 11:18:27 +01:00
xawotihs c3583ade01 Updated resource name and URL for android project 2014-01-17 23:25:48 +01:00
xawotihs f97d9805dd Removed build number in released filename and added computation of resource URL based on release name. 2014-01-17 21:50:10 +01:00
xawotihs 1d33de59a9 Fixed compilation issue 2014-01-12 22:56:53 +01:00
xawotihs 0c4b09891b Removed hardcoded testing values and used 32 bits file size instead of 64 bits. 2014-01-12 22:40:45 +01:00
xawotihs 25955303e7 Adds a Downloader component to JGE able to download and cache files. 2014-01-12 22:16:35 +01:00
Rolzad73 27b75eecb0 Merge pull request #600 from WagicProject/android_build_update
update android build tools version
2014-01-09 12:33:11 -08:00
Rolzad73 e40921cf13 update android build tools version 2014-01-09 14:57:06 -05:00
Rolzad73 083cebcc7e updated credits text 2014-01-09 14:46:58 -05:00
Rolzad73 a722736335 Merge pull request #599 from WagicProject/android_travis_explicit
Attempt to make android tools fetching for TravisCI explicit and futureproof
2014-01-08 08:40:47 -08:00
Rolzad73 c483c20c81 attempt to make android tools fetching for TravisCI explicit and futureproof 2014-01-08 11:14:47 -05:00
Dmitry Panin dec1caa43c Revert "Fixed issue with multiple basic abilities in TargetChooser"
This reverts commit d9816c7ad0.
2014-01-04 18:40:59 -08:00
Dmitry Panin 9526e22118 Fixed grave pact 2014-01-04 18:14:15 -08:00
Dmitry Panin d9816c7ad0 Fixed issue with multiple basic abilities in TargetChooser
E.g. card create[trample;haste] wasn't handled properly
2014-01-04 18:13:22 -08:00
Dmitry Panin 8e327a27df Fixed formatting 2014-01-04 18:13:22 -08:00
xawotihs 43fe67d7d8 Adds executioners_swing tests in _tests.txt 2013-12-31 18:38:30 +01:00
Xawotihs a63991bb4e Merge pull request #598 from bjornsnoen/master
Damager keyword
2013-12-31 09:11:20 -08:00
Bjørn Snoen 928ca3497a More code compliance. New tests. 2013-12-21 19:31:32 +01:00
Bjørn Snoen 60219411f6 Coding style compliance 2013-12-21 14:33:44 +01:00
Bjørn Snoen 642f5bb515 Fixed indentation mistakes 2013-12-21 11:18:18 +01:00
Bjørn Snoen 20e878a102 Made damager keyword work. Fixed Executioner's Swing in mtg.txt 2013-12-21 11:05:15 +01:00
53 changed files with 1323 additions and 553 deletions
+2 -3
View File
@@ -12,15 +12,14 @@ 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
- wget http://dl.google.com/android/android-sdk_r22-linux.tgz -nv
- tar --absolute-names -jxf android-ndk-r9-linux-x86_64.tar.bz2
- tar -zxf android-sdk_r22-linux.tgz
- $ANDROID list sdk -a
- echo yes | $ANDROID update sdk -a --filter 1,2,5,19 --no-ui --force > log.txt
- $ANDROID list sdk --extended -a
- echo yes | $ANDROID update sdk -a --filter "tools","platform-tools","build-tools-19.0.1","android-10" --no-ui --force > log.txt
- sudo pip install pyjavaproperties
script: ./travis-script.sh
env:
+128
View File
@@ -0,0 +1,128 @@
#ifndef DOWNLOADER_H
#define DOWNLOADER_H
//-------------------------------------------------------------------------------------
//
// This class handles download of remote resources (any kind of file)
// All the resources are stored locally in the userPath
// For every resources, the downloader verifies if the resource was modifed
// on the server before downloading the update. The Downloader maintains a catalogue
// of resource downloaded to be able to check if they need to be updated.
//
// The interface can be used completly synchronously by the application and some
// context or message loop is needed in the implementation of this interface
//
// Note that the Downloader could in theory by implemented on top of JNetwork.
//
//-------------------------------------------------------------------------------------
#include <string>
#include <ostream>
#include <istream>
#include <fstream>
#include <map>
#include "Threading.h"
#ifdef QT_CONFIG
#include <QObject>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#endif
using namespace std;
class DownloadRequest
#ifdef QT_CONFIG
: public QObject
#endif
{
#ifdef QT_CONFIG
Q_OBJECT
private slots:
#endif
void fileDownloaded();
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
#ifdef QT_CONFIG
signals:
void percentChanged(int percent);
void statusChanged(int);
#endif
public:
typedef enum {
NOT_PRESENT,
DOWNLOADING,
DOWNLOADED,
DOWNLOAD_ERROR
} DownloadStatus;
protected:
string mLocalPath;
string mRemoteResourceURL;
// previous one is the original, next one can change after redirection
string mRequestedRemoteResourceURL;
string mETag;
DownloadStatus mDownloadStatus;
bool mUpgradeAvailable;
size_t mTotalSize;
size_t mCurrentSize;
ofstream mFile;
#ifdef QT_CONFIG
QNetworkReply* mNetworkReply;
static QNetworkAccessManager networkAccessManager;
#endif
public:
DownloadRequest(string localPath="",
string remoteResourceURL="",
string ETag = "",
DownloadStatus downloadStatus=NOT_PRESENT,
size_t totalSize = 0,
size_t currentSize = 0);
~DownloadRequest();
static bool NetworkIsAccessible();
string getTempLocalPath() const { return (mLocalPath+".tmp"); };
string getLocalPath() const { return mLocalPath; };
string getRemoteResource() const { return mRemoteResourceURL; };
string getETag() const { return mETag; };
void startGet();
void startHead();
DownloadStatus getDownloadStatus() const { return mDownloadStatus; };
bool upgradeAvailable() const { return mUpgradeAvailable; };
void getSizes(size_t& totalSize, size_t&currentSize) {
totalSize = mTotalSize;
currentSize = mCurrentSize;
};
friend ostream& operator<<(ostream& out, const DownloadRequest& d);
friend istream& operator>>(istream&, DownloadRequest&);
friend class Downloader;
};
class Downloader
{
protected:
Downloader(string globalRemoteURL="", string localCacheRecords="");
virtual ~Downloader();
static Downloader* mInstance;
string mGlobalRemoteURL;
string mLocalCacheRecords;
boost::mutex mMutex;
map<string, DownloadRequest*> mRequestMap;
public:
static Downloader* GetInstance();
static void Release();
void Update();
DownloadRequest* Get(string localPath, string remoteResourceURL="");
friend ostream& operator<<(ostream& out, const Downloader& d);
friend istream& operator>>(istream&, Downloader&);
};
#endif // DOWNLOADER_H
+12 -37
View File
@@ -1,10 +1,6 @@
#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;
@@ -22,38 +18,13 @@ 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 {
@@ -61,21 +32,23 @@ 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.
///
@@ -110,7 +83,7 @@ public:
/// Open file for reading.
///
//////////////////////////////////////////////////////////////////////////
JFile* OpenFile(const string &filename);
bool 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);
@@ -124,19 +97,20 @@ public:
/// @return Number of bytes read.
///
//////////////////////////////////////////////////////////////////////////
int ReadFile(JFile*, void *buffer, int size);
int ReadFile(void *buffer, int size);
//////////////////////////////////////////////////////////////////////////
/// Get size of file.
///
//////////////////////////////////////////////////////////////////////////
int GetFileSize(JFile*);
int GetFileSize();
int GetFileSize(izfstream & file);
//////////////////////////////////////////////////////////////////////////
/// Close file.
///
//////////////////////////////////////////////////////////////////////////
void CloseFile(JFile*);
void CloseFile();
//////////////////////////////////////////////////////////////////////////
/// Set root for all the following file operations
@@ -150,10 +124,11 @@ 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);
bool Remove(string aFile);
//Returns true if strFilename exists somewhere in the fileSystem
bool FileExists(const string& strFilename);
+1
View File
@@ -178,6 +178,7 @@ private:
float mSpacing;
PIXEL_TYPE mColor;
int mBlend;
int mBase;
+221 -1
View File
@@ -1,7 +1,7 @@
#ifndef THREADING_H
#define THREADING_H
#if !defined(PSP) && !defined(QT_CONFIG) && !(__cplusplus > 199711L)
#if !defined(PSP) && !defined(QT_CONFIG) && !(__cplusplus > 199711L) && !defined(SDL_CONFIG)
#include <boost/date_time.hpp>
#ifdef WIN32
@@ -611,6 +611,226 @@ namespace boost
}
}
#elif defined(SDL_CONFIG)
#include "SDL_thread.h"
#include "SDL_timer.h"
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include "../include/JLogger.h"
namespace boost
{
template <class Mutex>
struct unique_lock
{
unique_lock(Mutex& inMutex) : mMutex(&inMutex)
{
mMutex->lock();
}
~unique_lock()
{
mMutex->unlock();
}
Mutex* mMutex;
};
class mutex
{
public:
typedef unique_lock<mutex> scoped_lock;
mutex()
: mpSDLMutex(0)
{
mpSDLMutex = SDL_CreateMutex();
}
~mutex()
{
SDL_DestroyMutex(mpSDLMutex);
}
void lock()
{
SDL_mutexP(mpSDLMutex);
}
void unlock()
{
SDL_mutexV(mpSDLMutex);
}
SDL_mutex* mpSDLMutex;
private:
mutex(mutex const&);
mutex& operator=(mutex const&);
};
class recursive_mutex
{
public:
typedef unique_lock<recursive_mutex> scoped_lock;
recursive_mutex()
: mpSDLMutex(0)
{
mpSDLMutex = SDL_CreateMutex();
}
~recursive_mutex()
{
SDL_DestroyMutex(mpSDLMutex);
}
void lock()
{
SDL_mutexP(mpSDLMutex);
}
void unlock()
{
SDL_mutexV(mpSDLMutex);
}
SDL_mutex* mpSDLMutex;
private:
recursive_mutex(recursive_mutex const&);
recursive_mutex& operator=(recursive_mutex const&);
};
/**
** Emulating boost::thread configuration glue, with some shortcuts
** This detail namespace is a distillation of boost's thread.hpp, thread_data.hpp.
*/
namespace detail
{
struct thread_data_base
{
thread_data_base()
{
}
virtual ~thread_data_base()
{
}
virtual void run() = 0;
};
typedef boost::shared_ptr<detail::thread_data_base> thread_data_ptr;
template<typename F>
class thread_data : public detail::thread_data_base
{
public:
thread_data(F f_) : f(f_)
{
}
void run()
{
f();
}
private:
F f;
void operator=(thread_data&);
thread_data(thread_data&);
};
} //namespace detail
/**
** A simplistic implementation of boost::thread, using QThread.
**
*/
class thread
{
/*
** Helper class for sceKernelStartThread, which passes args by value, not by reference
** We use this struct to wrap any pointers that we want to pass to the worker thread.
*/
struct CallbackData
{
CallbackData(detail::thread_data_ptr inThreadInfo)
: mThreadInfo(inThreadInfo)
{
}
detail::thread_data_ptr mThreadInfo;
};
public:
thread()
{
}
template <class F,class A1>
thread(F f, A1 a1) : mThreadInfo(make_thread_info(boost::bind(boost::type<void>(), f, a1)))
{
mpSDLThread = SDL_CreateThread(ThreadProc, &mThreadInfo);
}
~thread()
{
}
void join()
{
int status;
SDL_WaitThread(mpSDLThread, &status);
}
private:
static int ThreadProc(void *inParam)
{
detail::thread_data_ptr* threadInfo = reinterpret_cast<detail::thread_data_ptr* >(inParam);
CallbackData callbackData(*threadInfo);
LOG("Entering thread::ThreadProc");
callbackData.mThreadInfo->run();
return 0;
}
template<typename F>
static inline detail::thread_data_ptr make_thread_info(F f)
{
return detail::thread_data_ptr(new detail::thread_data<F>(f));
}
detail::thread_data_ptr mThreadInfo;
SDL_Thread* mpSDLThread;
};
namespace posix_time
{
typedef unsigned int milliseconds;
}
/**
** boost's platform neutral sleep call.
*/
namespace this_thread
{
inline void sleep(boost::posix_time::milliseconds const& time)
{
SDL_Delay(time);
}
}
}
#endif
#endif // THREADING_H
+298
View File
@@ -0,0 +1,298 @@
#include "DebugRoutines.h"
#include "JFileSystem.h"
#include "Downloader.h"
#define RECORDS_DEFAULT_FILE "cache/records.txt"
#ifdef QT_CONFIG
QNetworkAccessManager DownloadRequest::networkAccessManager;
#endif
DownloadRequest::DownloadRequest(string localPath,
string remoteResourceURL,
string ETag,
DownloadStatus downloadStatus,
size_t totalSize,
size_t currentSize):
mLocalPath(localPath),
mRemoteResourceURL(remoteResourceURL),
mRequestedRemoteResourceURL(remoteResourceURL),
mETag(ETag),
mDownloadStatus(downloadStatus),
mUpgradeAvailable(false),
mTotalSize(totalSize),
mCurrentSize(currentSize)
{
}
DownloadRequest::~DownloadRequest()
{
}
void DownloadRequest::startHead()
{
#ifdef QT_CONFIG
QNetworkRequest request(QUrl(QString(mRequestedRemoteResourceURL.c_str())));
request.setRawHeader("If-None-Match", mETag.c_str());
mNetworkReply = networkAccessManager.head(request);
connect(mNetworkReply, SIGNAL(finished()), SLOT(fileDownloaded()));
#endif
}
void DownloadRequest::startGet()
{
#ifdef QT_CONFIG
mNetworkReply = networkAccessManager.get(QNetworkRequest(QUrl(QString(mRequestedRemoteResourceURL.c_str()))));
#endif
mFile.close();
JFileSystem::GetInstance()->Remove(getTempLocalPath());
JFileSystem::GetInstance()->openForWrite(mFile, getTempLocalPath());
#ifdef QT_CONFIG
connect(mNetworkReply, SIGNAL(downloadProgress(qint64, qint64)),
SLOT(downloadProgress(qint64, qint64)));
connect(mNetworkReply, SIGNAL(finished()), SLOT(fileDownloaded()));
#endif
}
void DownloadRequest::fileDownloaded()
{
do {
QByteArray eTagByteArray = mNetworkReply->rawHeader("ETag");
if(!eTagByteArray.isEmpty()) {
string oldETag = mETag;
mETag = QString(eTagByteArray).toStdString();
if(oldETag!="" && oldETag != mETag)
mUpgradeAvailable = true;
}
// let's check some error
if(mNetworkReply->error() != QNetworkReply::NoError) {
DebugTrace(mNetworkReply->errorString().toStdString());
mDownloadStatus = DownloadRequest::DOWNLOAD_ERROR;
mFile.close();
JFileSystem::GetInstance()->Remove(getTempLocalPath());
break;
}
// check if we're getting redirected
QVariant redirectionTarget = mNetworkReply->attribute(QNetworkRequest::RedirectionTargetAttribute);
if (!redirectionTarget.isNull()) {
QUrl newUrl = QUrl(mRequestedRemoteResourceURL.c_str()).resolved(redirectionTarget.toUrl());
DebugTrace(string("Redirect to ")+ newUrl.toString().toStdString());
mRequestedRemoteResourceURL = newUrl.toString().toStdString();
mNetworkReply->deleteLater();
if(mFile.is_open())
startGet();
else
startHead();
return;
}
if(mFile.is_open())
{
QByteArray byteArray = mNetworkReply->readAll();
mFile.write(byteArray.constData(), byteArray.size());
mFile.close();
if(!JFileSystem::GetInstance()->Rename(getTempLocalPath(), mLocalPath)) {
mDownloadStatus = DownloadRequest::DOWNLOAD_ERROR;
break;
}
}
mDownloadStatus = DownloadRequest::DOWNLOADED;
} while(0);
Downloader::GetInstance()->Update();
mNetworkReply->deleteLater();
emit statusChanged((int)mDownloadStatus);
}
void DownloadRequest::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
{
QByteArray byteArray = mNetworkReply->readAll();
mFile.write(byteArray.constData(), byteArray.size());
mCurrentSize = bytesReceived;
mTotalSize = bytesTotal;
int percent = 0;
if(bytesTotal)
percent = (bytesReceived/bytesTotal)*100;
emit percentChanged(percent);
}
Downloader* Downloader::mInstance = 0;
Downloader::Downloader(string globalRemoteURL, string localcacheRecords):
mGlobalRemoteURL(globalRemoteURL),
mLocalCacheRecords(localcacheRecords)
{
JFileSystem::GetInstance()->MakeDir("cache");
izfstream downloadRecords;
if(mLocalCacheRecords.empty())
mLocalCacheRecords = RECORDS_DEFAULT_FILE;
if(JFileSystem::GetInstance()->openForRead(downloadRecords, mLocalCacheRecords))
{// File exists, let's read it.
downloadRecords >> (*this);
}
JFileSystem::GetInstance()->CloseFile();
}
Downloader::~Downloader()
{
map<string, DownloadRequest*>::iterator ite;
for(ite = mRequestMap.begin(); ite != mRequestMap.end(); ite++)
{
delete (*ite).second;
}
mRequestMap.erase(mRequestMap.begin(), mRequestMap.end());
}
Downloader* Downloader::GetInstance()
{
if(!mInstance)
{
mInstance = new Downloader();
}
return mInstance;
}
void Downloader::Release()
{
if(mInstance)
{
delete mInstance;
mInstance = 0;
}
}
bool DownloadRequest::NetworkIsAccessible()
{
bool result = false;
#ifdef QT_CONFIG
networkAccessManager.setNetworkAccessible(QNetworkAccessManager::Accessible);
result = networkAccessManager.networkAccessible();
#endif
return result;
}
DownloadRequest* Downloader::Get(string localPath, string remoteResourceURL)
{
map<string, DownloadRequest*>::iterator ite = mRequestMap.find(localPath);
if(ite == mRequestMap.end())
{ // request does not exist, let's create it
DownloadRequest* request = new DownloadRequest(localPath, remoteResourceURL);
std::pair<std::map<string,DownloadRequest*>::iterator,bool> ret;
ret = mRequestMap.insert ( std::pair<string,DownloadRequest*>(localPath, request) );
if (ret.second==false) {
DebugTrace("Downloader::Get Error inserting request in Map");
return 0;
}
ite = ret.first;
}
// Now, we can check the server
if((*ite).second->getDownloadStatus() == DownloadRequest::NOT_PRESENT ||
(*ite).second->upgradeAvailable())
{ // File is not here or an update is available, let's get it
(*ite).second->startGet();
(*ite).second->mDownloadStatus = DownloadRequest::DOWNLOADING;
}
else if ((*ite).second->getDownloadStatus() == DownloadRequest::DOWNLOADED)
{ // File is here, let's check if there is some update without blocking the playback
(*ite).second->startHead();
}
return (*ite).second;
}
void Downloader::Update()
{
ofstream downloadRecords;
if(JFileSystem::GetInstance()->openForWrite(downloadRecords, mLocalCacheRecords))
{
downloadRecords << (*this);
}
downloadRecords.close();
}
ostream& operator<<(ostream& out, const DownloadRequest& d)
{
// HEAD request fails, so this line erase cache record after upgrade check :(
// if(d.getDownloadStatus() == DownloadRequest::DOWNLOADED)
{
out << "localPath=" << d.mLocalPath << endl;
out << "remoteResource=" << d.mRemoteResourceURL << endl;
out << "ETag=" << d.mETag << endl;
out << "upgradeAvailable=" << d.mUpgradeAvailable <<endl;
}
return out;
}
istream& operator>>(istream& in, DownloadRequest& d)
{
string s;
while(std::getline(in, s))
{
size_t limiter = s.find("=");
string areaS;
if (limiter != string::npos)
{
areaS = s.substr(0, limiter);
if (areaS.compare("localPath") == 0)
{
d.mLocalPath = s.substr(limiter + 1);
}
else if (areaS.compare("remoteResource") == 0)
{
d.mRemoteResourceURL = s.substr(limiter + 1);
d.mRequestedRemoteResourceURL = d.mRemoteResourceURL;
}
else if (areaS.compare("ETag") == 0)
{
d.mETag = s.substr(limiter + 1);
d.mDownloadStatus = DownloadRequest::DOWNLOADED;
}
else if (areaS.compare("upgradeAvailable") == 0)
{
d.mUpgradeAvailable = (bool)atoi(s.substr(limiter + 1).c_str());
break;
}
}
}
return in;
}
ostream& operator<<(ostream& out, const Downloader& d)
{
map<string, DownloadRequest*>::const_iterator ite;
for(ite = d.mRequestMap.begin(); ite != d.mRequestMap.end(); ite++)
{
out << (*(*ite).second) << endl;
}
return out;
}
istream& operator>>(istream& in, Downloader& d)
{
while(!in.eof())
{
DownloadRequest* downloadRequest = new DownloadRequest();
in >> (*downloadRequest);
if(!downloadRequest->getLocalPath().empty() &&
!downloadRequest->getRemoteResource().empty() &&
!downloadRequest->getETag().empty()) {
d.mRequestMap[downloadRequest->getLocalPath()] = downloadRequest;
} else {
delete downloadRequest;
}
}
return in;
}
+4 -5
View File
@@ -44,12 +44,11 @@ bool JAnimator::Load(const char* scriptFile)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(scriptFile);
if (!jFile) return false;
if (!fileSystem->OpenFile(scriptFile)) return false;
int size = fileSystem->GetFileSize(jFile);
int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size);
fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
@@ -174,7 +173,7 @@ bool JAnimator::Load(const char* scriptFile)
}
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
delete[] xmlBuffer;
return true;
+16 -17
View File
@@ -49,8 +49,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(fileName);
if (!jFile)
if (!fileSystem->OpenFile(fileName))
return 0;
memset(p_wav, 0, sizeof(WAVDATA));
@@ -58,14 +57,14 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
char head[256];
memset(head, 0, 256);
//sceIoRead(fd, head, 20);
fileSystem->ReadFile(jFile, head, 20);
fileSystem->ReadFile(head, 20);
char string[8];
memset(string, 0, 8);
memcpy(string, head, 4);
if (0!=strcmp(string, "RIFF"))
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
memset(string, 0, 8);
@@ -73,7 +72,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (0!=strcmp(string, "WAVE"))
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
memset(string, 0, 8);
@@ -81,42 +80,42 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (0!=strcmp(string, "fmt"))
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
int fmtSize = 0;
memcpy(&fmtSize, head+16, 4);
//sceIoRead(fd, head+20, fmtSize);
fileSystem->ReadFile(jFile, head+20,fmtSize );
fileSystem->ReadFile(head+20,fmtSize );
p_wav->headSize = 20+fmtSize;
while (1)
{
//sceIoRead(fd, head+p_wav->headSize, 4);
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
fileSystem->ReadFile(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(jFile, head+p_wav->headSize, 4);
fileSystem->ReadFile(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(jFile, head+p_wav->headSize, fmtSize);
fileSystem->ReadFile(head+p_wav->headSize, fmtSize);
p_wav->headSize += fmtSize;
}
else
{
//sceIoRead(fd, head+p_wav->headSize, 4);
fileSystem->ReadFile(jFile, head+p_wav->headSize, 4);
fileSystem->ReadFile(head+p_wav->headSize, 4);
p_wav->headSize += 4;
break;
}
if (p_wav->headSize>191)
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
}
@@ -127,7 +126,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->channelCount!=1 && p_wav->channelCount!=2)
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
memcpy(&p_wav->samplePerSecond, head+24, 4);
@@ -137,7 +136,7 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->bytePerSample!=1 && p_wav->bytePerSample!=2)
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return 0;
}
p_wav->nSample = 44100 / p_wav->samplePerSecond;
@@ -148,17 +147,17 @@ char loadWaveData(WAVDATA* p_wav, char* fileName, char memLoad) // WAVE加载,
if (p_wav->soundSize>4096000)
{
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
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(jFile, p_wav->buffer, p_wav->soundSize);
fileSystem->ReadFile(p_wav->buffer, p_wav->soundSize);
p_wav->bytePosition = 0;
p_wav->fd = -1;
//sceIoClose(fd);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
}
else
{
+79 -166
View File
@@ -107,6 +107,7 @@ 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;
@@ -130,8 +131,8 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
dir.mkdir(USERDIR);
dir.cd(USERDIR);
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
userPath = QDir::toNativeSeparators(dir.absolutePath()).toStdString();
systemPath = QDir::toNativeSeparators(sysDir.absolutePath()).toStdString();
DebugTrace("User path " << userPath);
DebugTrace("System path " << systemPath);
@@ -191,6 +192,9 @@ JFileSystem::JFileSystem(const string & _userPath, const string & _systemPath)
mZipAvailable = false;
mZipCachedElementsCount = 0;
mPassword = NULL;
mFileSize = 0;
mCurrentFileInZip = NULL;
};
void JFileSystem::Destroy()
@@ -204,26 +208,14 @@ void JFileSystem::Destroy()
bool JFileSystem::DirExists(const string& strDirname)
{
return (
(mSystemFS && mSystemFS->DirExists(strDirname))
|| mUserFS->DirExists(strDirname)
#ifdef QT_CONFIG
|| QDir(QString(":/") + strDirname.c_str()).exists()
#endif
);
return (mSystemFS && mSystemFS->DirExists(strDirname)) || mUserFS->DirExists(strDirname);
}
bool JFileSystem::FileExists(const string& strFilename)
{
if (strFilename.length() < 1 ) return false;
return (
(mSystemFS && mSystemFS->FileExists(strFilename))
|| mUserFS->FileExists(strFilename)
#ifdef QT_CONFIG
|| QFile(QString(":/") + strFilename.c_str()).exists()
#endif
);
return (mSystemFS && mSystemFS->FileExists(strFilename)) || mUserFS->FileExists(strFilename);
}
bool JFileSystem::MakeDir(const string & dir)
@@ -283,6 +275,7 @@ bool JFileSystem::AttachZipFile(const string &zipfile, char *password /* = NULL
}
mZipAvailable = true;
return true;
}
@@ -292,6 +285,7 @@ void JFileSystem::DetachZipFile()
{
mZipFile.close();
}
mCurrentFileInZip = NULL;
mZipAvailable = false;
}
@@ -313,58 +307,28 @@ bool JFileSystem::openForRead(izfstream & File, const string & FilePath) {
bool JFileSystem::readIntoString(const string & FilePath, string & target)
{
bool result = false;
// Trying first with a izfstream
do {
izfstream file;
if (!openForRead(file, FilePath))
break;
int fileSize = GetFileSize(file);
izfstream file;
if (!openForRead(file, FilePath))
return false;
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&) {
break;
}
} catch (bad_alloc&) {
return false;
}
#endif
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;
if (fileSize)
file.read(&target[0], fileSize);
file.close();
return true;
}
bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_base::openmode mode)
@@ -410,72 +374,57 @@ bool JFileSystem::openForWrite(ofstream & File, const string & FilePath, ios_bas
return false;
}
JFile* JFileSystem::OpenFile(const string &filename)
bool JFileSystem::OpenFile(const string &filename)
{
bool result;
JFile* jFile = new JFile();
jFile->mCurrentFileInZip = NULL;
mCurrentFileInZip = NULL;
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;
}
if (!mZipAvailable || !mZipFile)
return openForRead(mFile, filename);
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); */
result = openForRead(jFile->mFile, filename);
break;
}
jFile->mCurrentFileInZip = &(it2->second);
result = true;
} while(0);
if(result)
return jFile;
else {
delete jFile;
return 0;
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();
return OpenFile(filename); */
return openForRead(mFile, filename);
}
mCurrentFileInZip = &(it2->second);
mFileSize = it2->second.m_Size;
return true;
}
void JFileSystem::CloseFile(JFile* jFile)
void JFileSystem::CloseFile()
{
delete jFile;
if (mZipAvailable && mZipFile)
{
mCurrentFileInZip = NULL;
}
if (mFile)
mFile.close();
}
//returns 0 if less than "size" bits were read
int JFileSystem::ReadFile(JFile* jFile, void *buffer, int size)
int JFileSystem::ReadFile(void *buffer, int size)
{
if (jFile->mCurrentFileInZip)
if (mCurrentFileInZip)
{
assert(mZipFile);
if((size_t)size > jFile->mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips
if((size_t)size > mCurrentFileInZip->m_Size) //only support "store" method for zip inside zips
return 0;
std::streamoff offset = filesystem::SkipLFHdr(mZipFile, jFile->mCurrentFileInZip->m_Offset);
std::streamoff offset = filesystem::SkipLFHdr(mZipFile, mCurrentFileInZip->m_Offset);
if (!mZipFile.seekg(offset))
return 0;
mZipFile.read((char *) buffer, size);
@@ -483,43 +432,16 @@ int JFileSystem::ReadFile(JFile* jFile, void *buffer, int size)
return size;
}
#ifdef QT_CONFIG
if(jFile->mpqFile) {
return jFile->mpqFile->read((char*)buffer, size);
}
#endif
if (!jFile->mFile)
if (!mFile)
return 0;
assert(!jFile->mFile.Zipped() || (size_t)size <= jFile->mFile.getUncompSize());
jFile->mFile.read((char *)buffer, size);
if (jFile->mFile.eof())
assert(!mFile.Zipped() || (size_t)size <= mFile.getUncompSize());
mFile.read((char *)buffer, size);
if (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());
@@ -607,17 +529,8 @@ 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);
}
@@ -631,18 +544,12 @@ std::vector<std::string> JFileSystem::scanfolder(const std::string& folderName)
return scanfolder(folderName, result);
}
int JFileSystem::GetFileSize(JFile* jFile)
int JFileSystem::GetFileSize()
{
if (jFile->mCurrentFileInZip)
return jFile->mCurrentFileInZip->m_Size;
if (mCurrentFileInZip)
return mFileSize;
#ifdef QT_CONFIG
if(jFile->mpqFile) {
return jFile->mpqFile->size();
}
#endif
return GetFileSize(jFile->mFile);
return GetFileSize(mFile);
}
bool JFileSystem::Rename(string _from, string _to)
@@ -650,7 +557,13 @@ bool JFileSystem::Rename(string _from, string _to)
string from = mUserFSPath + _from;
string to = mUserFSPath + _to;
std::remove(to.c_str());
return rename(from.c_str(), to.c_str()) ? true: false;
return (rename(from.c_str(), to.c_str()) == 0);
}
bool JFileSystem::Remove(string aFile)
{
string toRemove = mUserFSPath + aFile;
return (std::remove(toRemove.c_str()) == 0);
}
int JFileSystem::GetFileSize(izfstream & file)
+9 -10
View File
@@ -116,26 +116,25 @@ bool JGBKFont::Init(const char* engFileName, const char* chnFileName, int fontsi
int size;
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(engFileName);
if (!jFile)
if (!fileSys->OpenFile(engFileName))
return false;
size = fileSys->GetFileSize(jFile);
size = fileSys->GetFileSize();
mEngFont = new BYTE[size];
fileSys->ReadFile(jFile, mEngFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mEngFont, size);
fileSys->CloseFile();
jFile = fileSys->OpenFile(chnFileName);
if (!jFile)
if (!fileSys->OpenFile(chnFileName))
return false;
size = fileSys->GetFileSize(jFile);
size = fileSys->GetFileSize();
mChnFont = new BYTE[size];
fileSys->ReadFile(jFile, mChnFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mChnFont, size);
fileSys->CloseFile();
return true;
}
+21 -26
View File
@@ -892,10 +892,9 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
{
png_size_t check;
JFile* jFile = (JFile*)png_ptr->io_ptr;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFileSystem *fileSystem = (JFileSystem*)png_ptr->io_ptr;
check = fileSystem->ReadFile(jFile, data, length);
check = fileSystem->ReadFile(data, length);
if (check != length)
{
@@ -1039,24 +1038,23 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
bits32 = NULL;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
if (!fileSystem->OpenFile(filename))
{
return;
}
rawsize = fileSystem->GetFileSize(jFile);
rawsize = fileSystem->GetFileSize();
rawdata = new u8[rawsize];
if (!rawdata)
{
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return;
}
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
cinfo.err = jpeg_std_error(&jerr);
@@ -1364,25 +1362,24 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char* filename, int mode,
u32* line;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return JGE_ERR_CANT_OPEN_FILE;
if (!fileSystem->OpenFile(filename)) 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(jFile);
fileSystem->CloseFile();
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(jFile);
fileSystem->CloseFile();
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)jFile, PNGCustomReadDataFn);
png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
png_set_sig_bytes(png_ptr, sig_read);
png_read_info(png_ptr, info_ptr);
@@ -1395,7 +1392,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(jFile);
fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED;
}
@@ -1433,7 +1430,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(jFile);
fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED;
}
@@ -1508,7 +1505,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(jFile);
fileSystem->CloseFile();
if (done)
{
@@ -1728,9 +1725,9 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
{
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = (JFile*)ft->UserData;
if (fileSys->ReadFile(jFile, buf, size))
JFileSystem *fileSys = (JFileSystem *)ft->UserData;
if (fileSys->ReadFile(buf, size))
return size;
else
return 0;
@@ -1743,17 +1740,15 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(filename);
if (!jFile)
if (!fileSys->OpenFile(filename))
return;
DWORD bkcol;
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode);
int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
if(result!=0)
textureInfo.mBits=NULL;
fileSys->CloseFile(jFile);
fileSys->CloseFile();
return ;
}
@@ -2267,4 +2262,4 @@ void JRenderer::FillRoundRect(float x, float y, float w, float h, float radius,
void JRenderer::SetImageFilter(JImageFilter* imageFilter)
{
mImageFilter = imageFilter;
}
}
+3 -4
View File
@@ -42,11 +42,10 @@ JLBFont::JLBFont(const char *fontname, int lineheight, bool useVideoRAM)
//FILE *file;
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(filename);
if (!jFile) return;
if (!fileSys->OpenFile(filename)) return;
fileSys->ReadFile(jFile, (u8 *)buffer, 2048);
fileSys->CloseFile(jFile);
fileSys->ReadFile((u8 *)buffer, 2048);
fileSys->CloseFile();
sprintf(filename, "%s.png", fontname);
mTexture = mRenderer->LoadTexture(filename, useVideoRAM);
+4 -5
View File
@@ -96,8 +96,7 @@ bool JMD2Model::Load(char *filename, char *textureName)
// open the model file
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
if (!fileSystem->OpenFile(filename))
return false;
//filePtr = fopen(filename, "rb");
//if (filePtr == NULL)
@@ -108,13 +107,13 @@ bool JMD2Model::Load(char *filename, char *textureName)
//fileLen = ftell(filePtr);
//fseek(filePtr, 0, SEEK_SET);
fileLen = fileSystem->GetFileSize(jFile);
fileLen = fileSystem->GetFileSize();
// read entire file into buffer
buffer = (char*)malloc(fileLen + 1);
//fread(buffer, sizeof(char), fileLen, filePtr);
fileSystem->ReadFile(jFile, buffer, fileLen);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(buffer, fileLen);
fileSystem->CloseFile();
// extract model file header from buffer
modelHeader = (modelHeader_t*)buffer;
+4 -5
View File
@@ -47,15 +47,14 @@ bool JOBJModel::Load(const char *modelName, const char *textureName)
{
JFileSystem* fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(modelName);
if (!jFile)
if (!fileSys->OpenFile(modelName))
return false;
int size = fileSys->GetFileSize(jFile);
int size = fileSys->GetFileSize();
char *buffer = new char[size];
fileSys->ReadFile(jFile, buffer, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(buffer, size);
fileSys->CloseFile();
Vector3D vert;
+4 -5
View File
@@ -55,12 +55,11 @@ bool JParticleEffect::Load(const char* filename)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return false;
if (!fileSystem->OpenFile(filename)) return false;
int size = fileSystem->GetFileSize(jFile);
int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size);
fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc;
@@ -297,7 +296,7 @@ bool JParticleEffect::Load(const char* filename)
}
}
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
delete[] xmlBuffer;
return true;
+5 -5
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;
int size = fileSystem->GetFileSize(jFile);
if (!fileSystem->OpenFile(path.c_str())) return false;
int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size);
fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
@@ -179,7 +179,7 @@ bool JResourceManager::LoadResource(const string& resourceName)
}
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
delete[] xmlBuffer;
// JGERelease();
+4 -5
View File
@@ -41,12 +41,11 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (fileSystem == NULL) return false;
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return false;
if (!fileSystem->OpenFile(filename)) return false;
int size = fileSystem->GetFileSize(jFile);
int size = fileSystem->GetFileSize();
char *xmlBuffer = new char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size);
fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
@@ -77,7 +76,7 @@ bool JSpline::Load(const char *filename, float xscale, float yscale)
}
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
delete[] xmlBuffer;
return true;
+5 -6
View File
@@ -199,16 +199,15 @@ bool JTTFont::Load(const char *filename, int size, int mode)
if (FT_Init_FreeType( &mLibrary ) == 0)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (jFile)
JFileSystem* fileSystem = JFileSystem::GetInstance();
if (fileSystem->OpenFile(filename))
{
mFontBitsSize = fileSystem->GetFileSize(jFile);
mFontBitsSize = fileSystem->GetFileSize();
mFontBits = (FT_Byte*)malloc(mFontBitsSize);
fileSystem->ReadFile(jFile, mFontBits, mFontBitsSize);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(mFontBits, mFontBitsSize);
fileSystem->CloseFile();
if (FT_New_Memory_Face(mLibrary, mFontBits, mFontBitsSize, 0, &mFace ) == 0)
{
+18 -11
View File
@@ -9,11 +9,11 @@
#include <QtDeclarative>
#include "qmlapplicationviewer.h"
#endif //QT_WIDGET
#include "filedownloader.h"
#include "Downloader.h"
#include "GameApp.h"
#include "corewrapper.h"
QWidget* g_glwidget = NULL;
WagicCore* g_glwidget = NULL;
static const struct { LocalKeySym keysym; JButton keycode; } gDefaultBindings[] =
{
@@ -69,18 +69,25 @@ int main(int argc, char* argv[])
#endif //QT_WIDGET
if(argc >= 2 && string(argv[1]) == "testsuite")
{
int result = 0;
result += WagicCore::runTestSuite();
return result;
}
app->setApplicationName(WagicCore::getApplicationName());
FileDownloader fileDownloader(USERDIR, WAGIC_RESOURCE_NAME);
DownloadRequest* downloadRequest = NULL;
#ifdef WAGIC_RESOURCE_URL
Downloader*downloader = Downloader::GetInstance();
downloadRequest = downloader->Get(
"core.zip",
WAGIC_RESOURCE_URL
);
#endif
#ifdef QT_WIDGET
g_glwidget = new WagicCore();
g_glwidget->connect(&fileDownloader, SIGNAL(finished(int)), SLOT(start(int)));
if(!downloadRequest || downloadRequest->getDownloadStatus() == DownloadRequest::DOWNLOADED)
{
g_glwidget->start(0);
}
else
{
g_glwidget->connect(downloadRequest, SIGNAL(statusChanged(int)), SLOT(start(int)));
}
#else
qmlRegisterType<WagicCore>("CustomComponents", 1, 0, "WagicCore");
+14 -1
View File
@@ -78,7 +78,20 @@ extern "C" void Java_org_libsdl_app_SDLActivity_nativeResume(
{
if (!g_engine)
return;
g_engine->Resume();
g_engine->Resume();
}
#include "Wagic_Version.h"
extern "C" jstring Java_org_libsdl_app_SDLActivity_getResourceName(
JNIEnv* env, jclass cls)
{
return env->NewStringUTF (WAGIC_RESOURCE_NAME);
}
extern "C" jstring Java_org_libsdl_app_SDLActivity_getResourceUrl(
JNIEnv* env, jclass cls)
{
return env->NewStringUTF (WAGIC_RESOURCE_URL);
}
#endif
+4 -5
View File
@@ -57,20 +57,19 @@ hgeFont::hgeFont(const char *szFont, bool bMipmap __attribute__((unused)))
// Load font description
JFileSystem* fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(szFont);
if (!jFile) return;
if (!fileSys->OpenFile(szFont)) return;
//data=hge->Resource_Load(szFont, &size);
//if(!data) return;
size = fileSys->GetFileSize(jFile);
size = fileSys->GetFileSize();
desc = new char[size+1];
//memcpy(desc,data,size);
fileSys->ReadFile(jFile, desc, size);
fileSys->ReadFile(desc, size);
desc[size]=0;
//hge->Resource_Free(data);
fileSys->CloseFile(jFile);
fileSys->CloseFile();
pdesc=_get_line(desc,linebuf);
if(strcmp(linebuf, FNTHEADERTAG))
+40 -35
View File
@@ -50,41 +50,46 @@ float Random_Float(float min, float max)
hgeParticleSystem::hgeParticleSystem(const char *filename, JQuad *sprite)
{
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;
//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;
}
hgeParticleSystem::hgeParticleSystem(hgeParticleSystemInfo *psi)
+29 -36
View File
@@ -1683,21 +1683,20 @@ void JRenderer::LoadJPG(TextureInfo &textureInfo, const char *filename, int mode
int rawsize, i;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile) return;
if (!fileSystem->OpenFile(filename)) return;
rawsize = fileSystem->GetFileSize(jFile);
rawsize = fileSystem->GetFileSize();
rawdata = new BYTE[rawsize];
if (!rawdata)
{
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
return;
}
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
// Initialize libJpeg Object
cinfo.err = jpeg_std_error(&jerr);
@@ -1805,10 +1804,9 @@ static void PNGCustomReadDataFn(png_structp png_ptr, png_bytep data, png_size_t
{
png_size_t check;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile *jFile = (JFile*)png_ptr->io_ptr;
JFileSystem *fileSystem = (JFileSystem*)png_ptr->io_ptr;
check = fileSystem->ReadFile(jFile, data, length);
check = fileSystem->ReadFile(data, length);
if (check != length)
{
@@ -1871,14 +1869,13 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
DWORD* line;
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
if (!fileSystem->OpenFile(filename))
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(jFile);
fileSystem->CloseFile();
return JGE_ERR_PNG;
}
@@ -1888,14 +1885,14 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
if (info_ptr == NULL)
{
//fclose(fp);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
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)jFile, PNGCustomReadDataFn);
png_set_read_fn(png_ptr, (png_voidp)fileSystem, PNGCustomReadDataFn);
png_set_sig_bytes(png_ptr, sig_read);
png_read_info(png_ptr, info_ptr);
@@ -1911,7 +1908,7 @@ int JRenderer::LoadPNG(TextureInfo &textureInfo, const char *filename, int mode
if (!line)
{
//fclose(fp);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
png_destroy_read_struct(&png_ptr, png_infopp_NULL, png_infopp_NULL);
return JGE_ERR_MALLOC_FAILED;
@@ -1960,7 +1957,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(jFile);
fileSystem->CloseFile();
textureInfo.mBits = buffer;
@@ -2119,10 +2116,9 @@ int JRenderer::image_readgif(void * handle, TextureInfo &textureInfo, DWORD * bg
int image_gif_read(GifFileType * ft, GifByteType * buf, int size)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = (JFile*)ft->UserData;
if (fileSys->ReadFile(jFile, buf, size))
JFileSystem *fileSys = (JFileSystem *)ft->UserData;
//return fread(buf, 1, size, (FILE *)ft->UserData);
if (fileSys->ReadFile(buf, size))
return size;
else
return 0;
@@ -2134,18 +2130,17 @@ void JRenderer::LoadGIF(TextureInfo &textureInfo, const char *filename, int mode
///*
//FILE * fp = fopen(filename, "rb");
JFileSystem *fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile))
if (!fileSys->OpenFile(filename))
return;
//if(fp == NULL)
// return;
DWORD bkcol;
int result = image_readgif(jFile, textureInfo, &bkcol, image_gif_read, mode);
int result = image_readgif(fileSys, textureInfo, &bkcol, image_gif_read, mode);
if(result!=0)
textureInfo.mBits=NULL;
//fclose(fp);
fileSys->CloseFile(jFile);
fileSys->CloseFile();
return ;//*/
}
#endif //(!defined IOS) && (!defined QT_CONFIG) && (!defined SDL_CONFIG)
@@ -2166,21 +2161,20 @@ JTexture* JRenderer::LoadTexture(const char* filename, int mode, int TextureForm
UIImage *image = NULL;
do {
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
if (!fileSystem->OpenFile(filename))
break;
rawsize = fileSystem->GetFileSize(jFile);
rawsize = fileSystem->GetFileSize();
rawdata = new BYTE[rawsize];
if (!rawdata)
{
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
break;
}
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
texData = [[NSData alloc] initWithBytes:rawdata length:rawsize];
image = [[UIImage alloc] initWithData:texData];
@@ -2260,21 +2254,20 @@ JTexture* JRenderer::LoadTexture(const char* filename, int, int)
JFileSystem* fileSystem = JFileSystem::GetInstance();
do {
JFile* jFile = fileSystem->OpenFile(filename);
if (!jFile)
if (!fileSystem->OpenFile(filename))
break;
rawsize = fileSystem->GetFileSize(jFile);
rawsize = fileSystem->GetFileSize();
rawdata = new BYTE[rawsize];
if (!rawdata)
{
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
break;
}
fileSystem->ReadFile(jFile, rawdata, rawsize);
fileSystem->CloseFile(jFile);
fileSystem->ReadFile(rawdata, rawsize);
fileSystem->CloseFile();
QImage tmpImage = QImage::fromData(rawdata, rawsize);
if(tmpImage.isNull())
+8 -10
View File
@@ -161,16 +161,15 @@ JMusic *JSoundSystem::LoadMusic(const char *fileName)
if (music)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(fileName);
if (jFile)
if (fileSystem->OpenFile(fileName))
{
int size = fileSystem->GetFileSize(jFile);
int size = fileSystem->GetFileSize();
char *buffer = new char[size];
fileSystem->ReadFile(jFile, buffer, size);
fileSystem->ReadFile(buffer, size);
music->mTrack = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer;
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
}
}
return music;
@@ -282,16 +281,15 @@ JSample *JSoundSystem::LoadSample(const char *fileName)
if (sample)
{
JFileSystem* fileSystem = JFileSystem::GetInstance();
JFile* jFile = fileSystem->OpenFile(fileName);
if (jFile)
if (fileSystem->OpenFile(fileName))
{
int size = fileSystem->GetFileSize(jFile);
int size = fileSystem->GetFileSize();
char *buffer = new char[size];
fileSystem->ReadFile(jFile, buffer, size);
fileSystem->ReadFile(buffer, size);
sample->mSample = FSOUND_Sample_Load(FSOUND_UNMANAGED, buffer, FSOUND_LOADMEMORY, 0, size);
delete[] buffer;
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
}else
sample->mSample = NULL;
@@ -80,7 +80,6 @@ public class SDLActivity extends Activity implements OnKeyListener
public Boolean mErrorHappened = false;
public final static String RES_FOLDER = Environment.getExternalStorageDirectory().getPath() + "/Wagic/Res/";
public static String RES_FILENAME = "core_0184.zip";
public static final String RES_URL = "http://wagic.googlecode.com/files/";
public String systemFolder = Environment.getExternalStorageDirectory().getPath() + "/Wagic/Res/";
private String userFolder;
@@ -307,7 +306,7 @@ public class SDLActivity extends Activity implements OnKeyListener
private void startDownload()
{
String url = RES_URL + RES_FILENAME;
String url = getResourceUrl();
if (!checkStorageState())
{
Log.e(TAG, "Error in initializing storage space.");
@@ -437,7 +436,7 @@ public class SDLActivity extends Activity implements OnKeyListener
mContext = this.getApplicationContext();
// get the current version of the app to set the core filename
String versionCodeString = getApplicationCode();
RES_FILENAME = "core_" + versionCodeString + ".zip";
RES_FILENAME = getResourceName();
StorageOptions.determineStorageOptions();
checkStorageLocationPreference();
@@ -525,6 +524,9 @@ public class SDLActivity extends Activity implements OnKeyListener
}
// C functions we call
public static native String getResourceUrl();
public static native String getResourceName();
public static native void nativeInit();
public static native void nativeQuit();
+4 -54
View File
@@ -42,39 +42,6 @@ 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():
@@ -117,37 +84,20 @@ 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 qt, ios, android, etc)", metavar="PLATFORM", dest="platform")
parser.add_option("-p", "--platform", help="PLATFORM: specify custom build. (eg ios, android, etc)", metavar="PLATFORM", dest="platform")
(options, args) = parser.parse_args()
if (options.platform):
print "reading %s..." % options.platform
if (options.platform == 'ios'):
createIosResFile()
elif (options.platform == 'qt'):
createQrcFile()
if (options.platform == "ios"):
createIosResFile()
else:
createStandardResFile()
createStandardResFile()
else:
createStandardResFile()
+3 -3
View File
@@ -28204,7 +28204,7 @@ subtype=Equipment
[card]
name=Executioner's Swing
text=Target creature that dealt damage this turn gets -5/-5 until end of turn.
target=creature[damaged]
target=creature[damager]
auto=-5/-5 ueot
mana={W}{B}
type=Instant
@@ -37166,7 +37166,7 @@ type=Sorcery
[/card]
[card]
name=Grave Pact
auto=@movedTo(creature|mygraveyard) from(mybattlefield):ability$!name(sacrifice) notatarget(creature|mybattlefield) sacrifice!$ opponent
auto=@movedTo(creature|graveyard) from(mybattlefield):ability$!name(sacrifice) notatarget(creature|mybattlefield) sacrifice!$ opponent
text=Whenever a creature you control dies, each other player sacrifices a creature.
mana={1}{B}{B}{B}
type=Enchantment
@@ -104298,4 +104298,4 @@ type=Land Creature
subtype=Forest Dryad
power=1
toughness=1
[/card]
[/card]
+3
View File
@@ -308,6 +308,9 @@ evil_presence3.txt
evil_presence_i647.txt
evil_presence_i647_2.txt
exaltedsourcekilled.txt
executioners_swing.txt
executioners_swing2.txt
executioners_swing3.txt
explore.txt
Faceless_Butcher.txt
fading.txt
@@ -0,0 +1,42 @@
#NAME: Executioner's Swing
#DESC: Checks targetability
#DESC: Test that can target creature that damaged creature this turn
[INIT]
combatattackers
[PLAYER1]
inplay:Grizzly Bears
[PLAYER2]
inplay:Flying Men,Swamp,Plains
hand:Executioner's Swing
[DO]
Grizzly Bears
next
Flying Men
next
next
next
# second main
# kill bear
yes
Swamp
Plains
Executioner's Swing
Grizzly Bears
endinterruption
[ASSERT]
secondmain
[PLAYER1]
graveyard:Grizzly Bears
[PLAYER2]
graveyard:Executioner's Swing,Flying Men
inplay:Plains,Swamp
[END]
@@ -0,0 +1,42 @@
#NAME: Executioner's Swing
#DESC: Checks targetability
#DESC: Test that can target creature that damaged player
[INIT]
combatattackers
[PLAYER1]
inplay:Grizzly Bears
[PLAYER2]
inplay:Swamp,Plains
hand:Executioner's Swing
[DO]
Grizzly Bears
next
next
next
next
# second main
# kill bear
yes
Swamp
Plains
Executioner's Swing
Grizzly Bears
endinterruption
[ASSERT]
secondmain
[PLAYER1]
graveyard:Grizzly Bears
[PLAYER2]
graveyard:Executioner's Swing
inplay:Plains,Swamp
life:18
[END]
@@ -0,0 +1,34 @@
#NAME: Executioner's Swing
#DESC: Checks targetability
#DESC: Prove that can't target passive creature
[INIT]
secondmain
[PLAYER1]
inplay:Grizzly Bears
[PLAYER2]
manapool:{B}{W}
hand:Executioner's Swing
[DO]
# attempt to kill bear
yes
Swamp
Plains
Executioner's Swing
Grizzly Bears
endinterruption
[ASSERT]
secondmain
[PLAYER1]
inplay:Grizzly Bears
[PLAYER2]
hand:Executioner's Swing
manapool:{W}{B}
[END]
+4 -2
View File
@@ -3,7 +3,7 @@
<property file="build.properties" />
<property file="build.number.properties" />
<property environment="env"/>
<path id="groovy.class.path" >
<fileset dir="${groovy.dir}" />
</path>
@@ -90,7 +90,9 @@ Author: Michael Nguyen
#define WAGIC_RESOURCE_VERSION VERSION_FILE(WAGIC_VERSION_MAJOR, WAGIC_VERSION_MEDIUM, WAGIC_VERSION_MINOR)
#define WAGIC_VERSION_STRING VERSION_STRINGIFY(WAGIC_VERSION)
#define WAGIC_CORE_VERSION_STRING "core_" VERSION_STRINGIFY(WAGIC_RESOURCE_VERSION)
#define WAGIC_RESOURCE_NAME WAGIC_CORE_VERSION_STRING ".zip"
#define WAGIC_RESOURCE_NAME "Wagic-core.zip"
#define WAGIC_RELEASE_NAME "${env.RELEASE_NAME}"
#define WAGIC_RESOURCE_URL "https://github.com/WagicProject/wagic/releases/download/" WAGIC_RELEASE_NAME "/" WAGIC_RESOURCE_NAME
#endif
+1
View File
@@ -64,6 +64,7 @@ class CardDescriptor: public MTGCardInstance
string compareName;
int CDopponentDamaged;
int CDcontrollerDamaged;
int CDdamager;
};
#endif
+1
View File
@@ -65,6 +65,7 @@ public:
bool wasDealtDamage;
bool damageToOpponent;
bool damageToController;
bool damageToCreature;
bool mPropertiesChangedSinceLastUpdate;
int reduxamount;
int flanked;
+6 -4
View File
@@ -4723,14 +4723,15 @@ void AVanishing::Update(float dt)
int AVanishing::resolve()
{
return 1;
}
const string AVanishing::getMenuText()
{
if(counterName.find("fade") != string::npos)
return "Fading";
if (counterName.find("fade") != string::npos)
{
return "Fading";
}
return "Vanishing";
}
@@ -5703,7 +5704,8 @@ void ATutorialMessage::Update(float dt)
mElapsed += dt;
IconButtonsController::Update(dt);
if(!mUserCloseRequest)
IconButtonsController::Update(dt);
if (mIsImage)
return;
+19 -7
View File
@@ -23,6 +23,7 @@ CardDescriptor::CardDescriptor()
colorComparisonMode = COMPARISON_NONE;
CDopponentDamaged = 0;
CDcontrollerDamaged = 0;
CDdamager = 0;
}
int CardDescriptor::init()
@@ -226,16 +227,27 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card)
{
match = NULL;
}
if(CDopponentDamaged == -1 || CDopponentDamaged == 1)
{
Player * p = card->controller()->opponent();//controller()->opponent();
if ((CDopponentDamaged == -1 && card->damageToOpponent && card->controller() == p) || (CDopponentDamaged == 1 && !card->damageToOpponent && card->controller() == p)
|| (CDopponentDamaged == -1 && card->damageToController && card->controller() == p->opponent()) || (CDopponentDamaged == 1 && !card->damageToController && card->controller() == p->opponent()))
if ((CDdamager == -1 && (card->damageToOpponent || card->damageToController || card->damageToCreature))
|| (CDdamager == 1 && !(card->damageToOpponent || card->damageToController || card->damageToCreature)))
{
match = NULL;
}
if ((CDcontrollerDamaged == -1 && card->damageToController && card->controller() == p) || (CDcontrollerDamaged == 1 && !card->damageToController && card->controller() == p)
|| (CDcontrollerDamaged == -1 && card->damageToOpponent && card->controller() == p->opponent()) || (CDcontrollerDamaged == 1 && !card->damageToOpponent && card->controller() == p->opponent()))
if(CDopponentDamaged == -1 || CDopponentDamaged == 1)
{
Player * p = card->controller()->opponent();//controller()->opponent();
if ((CDopponentDamaged == -1 && card->damageToOpponent && card->controller() == p)
|| (CDopponentDamaged == 1 && !card->damageToOpponent && card->controller() == p)
|| (CDopponentDamaged == -1 && card->damageToController && card->controller() == p->opponent())
|| (CDopponentDamaged == 1 && !card->damageToController && card->controller() == p->opponent()))
{
match = NULL;
}
if ((CDcontrollerDamaged == -1 && card->damageToController && card->controller() == p)
|| (CDcontrollerDamaged == 1 && !card->damageToController && card->controller() == p)
|| (CDcontrollerDamaged == -1 && card->damageToOpponent && card->controller() == p->opponent())
|| (CDcontrollerDamaged == 1 && !card->damageToOpponent && card->controller() == p->opponent()))
{
match = NULL;
}
+12
View File
@@ -1224,6 +1224,18 @@ bool CardGui::FilterCard(MTGCard * _card,string filter)
cd.CDcontrollerDamaged = 1;
}
}
//creature dealt damage to anything
else if (attribute.find("damager") != string::npos)
{
if (minus)
{
cd.CDdamager = -1;
}
else
{
cd.CDdamager = 1;
}
}
else if (attribute.find("multicolor") != string::npos)
{
//card is multicolored?
+3 -1
View File
@@ -192,8 +192,10 @@ int Damage::resolve()
//return the left over amount after effects have been applied to them.
a = target->dealDamage(damage);
target->damageCount += damage;//the amount must be the actual damage so i changed this from 1 to damage, this fixes pdcount and odcount
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE){
((MTGCardInstance*)target)->wasDealtDamage = true;
((MTGCardInstance*)source)->damageToCreature = true;
}
if (target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER)
{
if(target == source->controller())
+1
View File
@@ -795,6 +795,7 @@ void GameObserver::gameStateBasedEffects()
c->wasDealtDamage = false;
c->damageToController = false;
c->damageToOpponent = false;
c->damageToCreature = false;
c->isAttacking = NULL;
}
for (int t = 0; t < nbcards; t++)
+1 -1
View File
@@ -1843,7 +1843,7 @@ int Tournament::getRandomDeck(bool noEasyDecks)
DeckManager *deckManager = DeckManager::GetInstance();
vector<DeckMetaData *> *deckList = deckManager->getAIDeckOrderList();
int deckNumber=0;
int deckNumber;
unsigned int random=0;
int k=0;
bool isDouble=true;
+8 -8
View File
@@ -300,12 +300,12 @@ string GameStateMenu::loadRandomWallpaper()
return wallpaper;
vector<string> wallpapers;
JFile* jFile = JFileSystem::GetInstance()->OpenFile("graphics/wallpapers.txt");
if (!jFile)
izfstream file;
if (! JFileSystem::GetInstance()->openForRead(file, "graphics/wallpapers.txt"))
return wallpaper;
string s;
while (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
while (std::getline(file, s))
{
if (!s.size())
continue;
@@ -313,7 +313,7 @@ string GameStateMenu::loadRandomWallpaper()
s.erase(s.size() - 1); //Handle DOS files
wallpapers.push_back(s);
}
JFileSystem::GetInstance()->CloseFile(jFile);
file.close();
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]);
JFile* jFile = JFileSystem::GetInstance()->OpenFile(filePath);
if (!jFile)
if (! JFileSystem::GetInstance()->openForRead(file, filePath))
continue;
string s;
string lang;
if (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
if (std::getline(file, s))
{
lang = getLang(s);
}
JFileSystem::GetInstance()->CloseFile(jFile);
file.close();
if (lang.size())
{
+17 -12
View File
@@ -215,34 +215,39 @@ void GameStateOptions::Render()
const char * const CreditsText[] = {
"Wagic, The Homebrew?! by Wololo",
"",
"updates, new cards, and more on http://wololo.net/wagic",
"Updates, new cards, and more on http://wololo.net/wagic",
"Many thanks to the people who help this project",
"",
"",
"Art: Ilya B, Julio, Jeck, J, Kaioshin, Lakeesha",
"Art:",
"Ilya B, Julio, Jeck, J, Kaioshin, Lakeesha",
"Check themeinfo.txt for the full credits of each theme!",
"",
"Dev Team:",
"Abrasax, Almosthumane, Daddy32, DJardin, Dr.Solomat,",
"J, Jeck, kevlahnota, Leungclj, linshier, Mootpoint, Mnguyen,",
"Psyringe, Salmelo, Superhiro, Wololo, Yeshua, Zethfox",
"Abrasax, Almosthumane, Daddy32, DJardin, Dr.Solomat, J, Jeck,",
"kevlahnota, Leungclj, linshier, Mootpoint, Mnguyen, Psyringe,",
"Rolzad73, Salmelo, Superhiro, Wololo, Yeshua, Zethfox",
"",
"Music by Celestial Aeon Project, http://www.jamendo.com",
"",
"Deck Builders: Abrasax, AzureKnight, colarchon",
"Excessum, Hehotfarv, Jeremy, Jog1118, JonyAS",
"Lachaux, Link17, Muddobbers, Nakano, Niegen",
"Kaioshin, Psyringe, r1c47, Superhiro, Szei",
"Thanatos02, Whismer, Wololo",
"Deck Builders:",
"Abrasax, AzureKnight, colarchon, Excessum, Hehotfarv,",
"Jeremy, Jog1118, JonyAS, Lachaux, Link17, Muddobbers,",
"Nakano, Niegen, Kaioshin, Psyringe, r1c47, Superhiro,",
"Szei, Thanatos02, Whismer, Wololo",
"",
"Thanks also go to Dr.Watson, Orine, Raphael, Sakya, Tyranid",
"for their help.",
"",
"Thanks to everyone who contributes code/content on the forums!",
"",
"Developed with the JGE++ Library (http://code.google.com/p/wagic)",
"",
"Source:",
"http://code.google.com/p/wagic (2009-2013)",
"https://github.com/WagicProject/wagic (2013- )",
"",
"Developed with the JGE++ Library",
"SFX From www.soundsnap.com",
"",
"",
"This work is not related to or endorsed by Wizards of the Coast, Inc",
+1
View File
@@ -158,6 +158,7 @@ void MTGCardInstance::initMTGCI()
auras = 0;
damageToOpponent = false;
damageToController = false;
damageToCreature = false;
wasDealtDamage = false;
isDualWielding = false;
suspended = false;
+5 -5
View File
@@ -399,8 +399,8 @@ int MTGAllCards::load(const string &config_file, int set_id)
int lineNumber = 0;
std::string contents;
JFile* jFile = JFileSystem::GetInstance()->OpenFile(config_file);
if (!jFile)
izfstream file;
if (!JFileSystem::GetInstance()->openForRead(file, config_file))
{
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 (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
while (getline(file,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)
{
JFileSystem::GetInstance()->CloseFile(jFile);
file.close();
return total_cards;
}
}
@@ -480,7 +480,7 @@ int MTGAllCards::load(const string &config_file, int set_id)
continue;
}
}
JFileSystem::GetInstance()->CloseFile(jFile);
file.close();
return total_cards;
}
+4 -4
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]);
JFile* jFile = JFileSystem::GetInstance()->OpenFile(filePath);
if (!jFile)
if (! JFileSystem::GetInstance()->openForRead(file, filePath))
continue;
string s;
string lang;
if (JFileSystem::GetInstance()->ReadFileLine(jFile, s))
if (std::getline(file, s))
{
if (!s.size())
{
@@ -352,7 +352,7 @@ void OptionLanguage::Reload()
lang = s.substr(6);
}
}
JFileSystem::GetInstance()->CloseFile(jFile);
file.close();
if (lang.size())
{
+4 -5
View File
@@ -599,17 +599,16 @@ bool StoryFlow::parse(string path)
JFileSystem *fileSystem = JFileSystem::GetInstance();
if (!fileSystem) 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(jFile);
int size = fileSystem->GetFileSize();
char *xmlBuffer = NEW char[size];
fileSystem->ReadFile(jFile, xmlBuffer, size);
fileSystem->ReadFile(xmlBuffer, size);
TiXmlDocument doc;
doc.Parse(xmlBuffer);
fileSystem->CloseFile(jFile);
fileSystem->CloseFile();
delete[] xmlBuffer;
for (TiXmlNode* node = doc.FirstChild(); node; node = node->NextSibling())
+12
View File
@@ -485,6 +485,18 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
cd->CDcontrollerDamaged = 1;
}
}
//creature dealt damage to anything
else if (attribute.find("damager") != string::npos)
{
if (minus)
{
cd->CDdamager = -1;
}
else
{
cd->CDdamager = 1;
}
}
else if (attribute.find("multicolor") != string::npos)
{
//card is multicolored?
+4 -5
View File
@@ -333,9 +333,8 @@ bool WCachedParticles::Attempt(const string& filename, int, int & error)
{
JFileSystem* fileSys = JFileSystem::GetInstance();
JFile* jFile = fileSys->OpenFile(WResourceManager::Instance()->graphicsFile(filename));
if (!jFile)
if (!fileSys->OpenFile(WResourceManager::Instance()->graphicsFile(filename)))
{
error = CACHE_ERROR_404;
return false;
@@ -346,12 +345,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(jFile, &dummyPointer, 4);
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(jFile, &(particles->nEmission), sizeof(hgeParticleSystemInfo) - sizeof(void*));
fileSys->CloseFile(jFile);
fileSys->ReadFile(&(particles->nEmission), sizeof(hgeParticleSystemInfo) - sizeof(void*));
fileSys->CloseFile();
particles->sprite = NULL;
error = CACHE_ERROR_NONE;
+17 -21
View File
@@ -171,22 +171,20 @@ WFont(inFontID), mTexture(0)
unsigned char height;
} sizeStr = { 0, 0, 0 };
JFile* jFile = fileSys->OpenFile(engFileName);
if (!jFile) return;
size = fileSys->GetFileSize(jFile);
if (!fileSys->OpenFile(engFileName)) return;
size = fileSys->GetFileSize();
mStdFont = NEW u8[size];
fileSys->ReadFile(jFile, mStdFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mStdFont, size);
fileSys->CloseFile();
jFile = fileSys->OpenFile(fontname);
if (!jFile) return;
fileSys->ReadFile(jFile, &sizeStr, 4); // Works only for little-endian machines (PSP and PC are)
if (!fileSys->OpenFile(fontname)) return;
fileSys->ReadFile(&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(jFile, mIndex, 65536 * sizeof(u16));
fileSys->ReadFile(jFile, mExtraFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mIndex, 65536 * sizeof(u16));
fileSys->ReadFile(mExtraFont, size);
fileSys->CloseFile();
mColor0 = ARGB(255, 255, 255, 255);
mColor = mColor0;
@@ -614,19 +612,17 @@ WGBKFont::WGBKFont(int inFontID, const char *fontname, int lineheight, bool) :
JFileSystem *fileSys = JFileSystem::GetInstance();
int size = 0;
JFile* jFile = fileSys->OpenFile(fontname);
if (!jFile) return;
size = fileSys->GetFileSize(jFile);
if (!fileSys->OpenFile(fontname)) return;
size = fileSys->GetFileSize();
mExtraFont = NEW u8[size];
fileSys->ReadFile(jFile, mExtraFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mExtraFont, size);
fileSys->CloseFile();
jFile = fileSys->OpenFile(engFileName);
if (!jFile) return;
size = fileSys->GetFileSize(jFile);
if (!fileSys->OpenFile(engFileName)) return;
size = fileSys->GetFileSize();
mStdFont = NEW u8[size];
fileSys->ReadFile(jFile, mStdFont, size);
fileSys->CloseFile(jFile);
fileSys->ReadFile(mStdFont, size);
fileSys->CloseFile();
mIndex = 0;
+1 -2
View File
@@ -15,9 +15,8 @@ CONFIG(console, graphics|console){
}
else:CONFIG(graphics, graphics|console){
folder_01.source = qml/QmlWagic
folder_01.target = qml
folder_01.target = /usr/share
DEPLOYMENTFOLDERS = folder_01
windows:RESOURCES = bin/Res/core.qrc
QT += core gui opengl network
QT -= declarative quick qml
#maemo5:DEFINES += QT_WIDGET
+111 -2
View File
@@ -41,8 +41,8 @@ INCLUDEPATH += ../../Boost
INCLUDEPATH += include
unix:!symbian:LIBS += -lz
win32:LIBS += ../../JGE/Dependencies/lib/fmodvc.lib
win32:LIBS += ../../JGE/Dependencies/lib/zlibd.lib
windows:LIBS += ../../JGE/Dependencies/lib/fmodvc.lib
windows:LIBS += ../../JGE/Dependencies/lib/zlibd.lib
PRECOMPILED_HEADER = include/PrecompiledHeader.h
#DEFINES += TRACK_OBJECT_USAGE
@@ -283,6 +283,7 @@ HEADERS += \
# JGE, could probably be moved outside
SOURCES += \
../../JGE/src/Downloader.cpp\
../../JGE/src/Encoding.cpp\
../../JGE/src/JAnimator.cpp\
../../JGE/src/JApp.cpp\
@@ -320,6 +321,7 @@ SOURCES += \
../../JGE/src/zipFS/zstream.cpp
HEADERS += \
../../JGE/include/Downloader.h\
../../JGE/include/Threading.h\
../../JGE/include/decoder_prx.h\
../../JGE/include/DebugRoutines.h\
@@ -371,3 +373,110 @@ 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\\\"
}
+17 -8
View File
@@ -5,6 +5,21 @@ echo PSPDEV = $PSPDEV
echo psp-config = `psp-config --psp-prefix`
echo ls = `ls`
echo pwd = `pwd`
# computing potential release name
echo TRAVIS_PULL_REQUEST = $TRAVIS_PULL_REQUEST
echo TRAVIS_BRANCH = $TRAVIS_BRANCH
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
if [ "$TRAVIS_BRANCH" = "alphas" ]; then
export RELEASE_NAME="alpha-${TRAVIS_BUILD_NUMBER}"
else if [ "$TRAVIS_BRANCH" = "master" ]; then
export RELEASE_NAME="latest-master"
fi
fi
fi
echo RELEASE_NAME = $RELEASE_NAME
# updating versions with the TRAVIS build numbers
cd projects/mtg/
@@ -14,7 +29,6 @@ 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
@@ -23,7 +37,6 @@ 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
@@ -51,9 +64,7 @@ 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
qmake ../projects/mtg/wagic-SDL.pro CONFIG+=release CONFIG+=graphics
make -j 8
cd ..
@@ -62,7 +73,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 collision
# PATH is only set here to prevent colision
export PATH="$PATH:/opt/mingw32/bin"
mkdir build
cd build
@@ -80,8 +91,6 @@ 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)
+8 -8
View File
@@ -10,28 +10,28 @@ if [ "$TRAVIS_BRANCH" == "alphas" ]; then
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @core.zip \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-core-${TRAVIS_BUILD_NUMBER}.zip"
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-core.zip"
echo -e "Uploading android package\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @projects/mtg/Android/bin/Wagic-debug.apk \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-android-${TRAVIS_BUILD_NUMBER}.apk"
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-android.apk"
echo -e "Uploading PSP package\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @projects/mtg/psprelease.zip \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-psp-${TRAVIS_BUILD_NUMBER}.zip"
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-psp.zip"
echo -e "Uploading Windows package\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @build/win-cross/win-cross.zip \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-windows-${TRAVIS_BUILD_NUMBER}.zip"
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-windows.zip"
echo -e "Done uploading\n"
fi
@@ -71,28 +71,28 @@ if [ "$TRAVIS_BRANCH" == "master" ]; then
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @core.zip \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-core-${TRAVIS_BUILD_NUMBER}.zip"
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-core.zip"
echo -e "Uploading android package\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @projects/mtg/Android/bin/Wagic-debug.apk \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-android-${TRAVIS_BUILD_NUMBER}.apk"
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-android.apk"
echo -e "Uploading PSP package\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @projects/mtg/psprelease.zip \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-psp-${TRAVIS_BUILD_NUMBER}.zip"
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-psp.zip"
echo -e "Uploading Windows package\n"
curl -X POST -H "Authorization: token ${GH_TOKEN}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/zip" \
--data-binary @build/win-cross/win-cross.zip \
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-windows-${TRAVIS_BUILD_NUMBER}.zip"
"https://uploads.github.com/repos/WagicProject/wagic/releases/${IDDI}/assets?name=Wagic-windows.zip"
echo -e "Done uploading\n"
fi