Fixed compilation on Windows and avoid crashing when the TestSuite is interrupted.
This commit is contained in:
@@ -60,7 +60,7 @@ protected:
|
|||||||
bool load();
|
bool load();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~TestSuiteGame();
|
virtual ~TestSuiteGame();
|
||||||
TestSuiteGame(TestSuite* testsuite);
|
TestSuiteGame(TestSuite* testsuite);
|
||||||
TestSuiteGame(TestSuite* testsuite, string _filename);
|
TestSuiteGame(TestSuite* testsuite, string _filename);
|
||||||
void initGame();
|
void initGame();
|
||||||
@@ -90,6 +90,7 @@ public:
|
|||||||
unsigned int seed;
|
unsigned int seed;
|
||||||
int nbFailed, nbTests, nbAIFailed, nbAITests;
|
int nbFailed, nbTests, nbAIFailed, nbAITests;
|
||||||
TestSuite(const char * filename);
|
TestSuite(const char * filename);
|
||||||
|
~TestSuite();
|
||||||
void initGame(GameObserver* g);
|
void initGame(GameObserver* g);
|
||||||
void pregameTests();
|
void pregameTests();
|
||||||
int loadNext();
|
int loadNext();
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
#include "DamagerDamaged.h"
|
#include "DamagerDamaged.h"
|
||||||
|
|
||||||
class CardView;
|
class CardView;
|
||||||
class AttackerDamaged;
|
struct AttackerDamaged;
|
||||||
class DamagerDamaged;
|
struct DamagerDamaged;
|
||||||
typedef DamagerDamaged DefenserDamaged;
|
typedef DamagerDamaged DefenserDamaged;
|
||||||
|
|
||||||
template<class T> void trash(T*);
|
template<class T> void trash(T*);
|
||||||
|
|||||||
@@ -447,11 +447,23 @@ void TestSuite::handleResults(bool wasAI, int error)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TestSuite::~TestSuite()
|
||||||
|
{
|
||||||
|
mProcessing = false;
|
||||||
|
while(mWorkerThread.size())
|
||||||
|
{
|
||||||
|
mWorkerThread.back().join();
|
||||||
|
mWorkerThread.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
observer = 0;
|
||||||
|
}
|
||||||
|
|
||||||
TestSuite::TestSuite(const char * filename)
|
TestSuite::TestSuite(const char * filename)
|
||||||
: TestSuiteGame(this), mRules(0), mProcessing(false)
|
: TestSuiteGame(0), mRules(0), mProcessing(false)
|
||||||
{
|
{
|
||||||
timerLimit = 0;
|
timerLimit = 0;
|
||||||
|
testsuite = this;
|
||||||
|
|
||||||
std::string s;
|
std::string s;
|
||||||
nbfiles = 0;
|
nbfiles = 0;
|
||||||
@@ -731,25 +743,20 @@ void TestSuite::ThreadProc(void* inParam)
|
|||||||
{
|
{
|
||||||
string filename;
|
string filename;
|
||||||
float counter = 1.0f;
|
float counter = 1.0f;
|
||||||
// while(instance->mProcessing)
|
while(instance->mProcessing && (filename = instance->getNextFile()) != "")
|
||||||
{
|
{
|
||||||
while((filename = instance->getNextFile()) != "")
|
TestSuiteGame theGame(instance, filename);
|
||||||
|
if(theGame.isOK)
|
||||||
{
|
{
|
||||||
TestSuiteGame theGame(instance, filename);
|
theGame.observer->loadTestSuitePlayer(0, &theGame);
|
||||||
if(theGame.isOK)
|
theGame.observer->loadTestSuitePlayer(1, &theGame);
|
||||||
{
|
|
||||||
theGame.observer->loadTestSuitePlayer(0, &theGame);
|
|
||||||
theGame.observer->loadTestSuitePlayer(1, &theGame);
|
|
||||||
|
|
||||||
theGame.observer->startGame(theGame.gameType, instance->mRules);
|
theGame.observer->startGame(theGame.gameType, instance->mRules);
|
||||||
theGame.initGame();
|
theGame.initGame();
|
||||||
|
|
||||||
while(!theGame.observer->gameOver)
|
while(!theGame.observer->gameOver)
|
||||||
theGame.observer->Update(counter++);
|
theGame.observer->Update(counter++);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::this_thread::sleep(100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG("Leaving TestSuite::ThreadProc");
|
LOG("Leaving TestSuite::ThreadProc");
|
||||||
|
|||||||
Reference in New Issue
Block a user