- Replaced static parts by per-instance parts of of several classes when they were not threadsafe (AIMomirPlayer, SimpleMenu, Trash, AIAction, MTGCardInstance, ATutorialMessage, MTGRules). The direct consequence is that we could consumme more memory. So, tell me if you have problems with low memory devices (PSP), there are some threadsafe optimizations that could be implemented if needed.
- Reworked the testsuite to be able to work multithreaded. This is deactivated by default everywhere except in QT_CONFIG as one testcase still refuses to pass in multithreaded mode. On my 4 cores linux desktop, the 650 tests passes now in 4 seconds (1 fails). - Replaced usage of CardSelectorSingleton by a card selector per game observer. - Modified the resource manager to be optionnal and per game observer instance instead of being a singleton. Two reasons here : threading AND Open Gl access. I only updated the crashing parts called from the game observer, so most of the code is still using the single instance. Beware of copy-paste concerning resources ... - Cleaned up the game observer constructors - Fixed several problems in action logging code while testing proliferate decks - Cleaned up Threading implementation based on QThread
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <queue>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
class MTGGamePhase;
|
||||
class MTGAbility;
|
||||
class MTGCardInstance;
|
||||
@@ -20,7 +21,8 @@ struct CardGui;
|
||||
class Player;
|
||||
class TargetChooser;
|
||||
class Rules;
|
||||
class TestSuite;
|
||||
class TestSuiteGame;
|
||||
class Trash;
|
||||
using namespace std;
|
||||
|
||||
class GameObserver{
|
||||
@@ -46,6 +48,7 @@ class GameObserver{
|
||||
void nextGamePhase();
|
||||
void shuffleLibrary(Player* p);
|
||||
RandomGenerator randomGenerator;
|
||||
WResourceManager* mResourceManager;
|
||||
|
||||
public:
|
||||
int currentPlayerId;
|
||||
@@ -66,6 +69,8 @@ class GameObserver{
|
||||
time_t startedAt;
|
||||
Rules * mRules;
|
||||
GameType mGameType;
|
||||
MTGCardInstance* ExtraRules;
|
||||
Trash* mTrash;
|
||||
|
||||
TargetChooser * getCurrentTargetChooser();
|
||||
void stackObjectClicked(Interruptible * action);
|
||||
@@ -80,19 +85,19 @@ class GameObserver{
|
||||
void userRequestNextGamePhase(bool allowInterrupt = true, bool log = true);
|
||||
void cleanupPhase();
|
||||
void nextPlayer();
|
||||
void setPlayers(vector<Player *> _players);
|
||||
|
||||
#ifdef TESTSUITE
|
||||
void loadTestSuitePlayer(int playerId, TestSuite* testSuite);
|
||||
void loadTestSuitePlayer(int playerId, TestSuiteGame* testSuite);
|
||||
#endif //TESTSUITE
|
||||
void loadPlayer(int playerId, PlayerType playerType = PLAYER_TYPE_HUMAN, int decknb=0, bool premadeDeck=false);
|
||||
void loadPlayer(int playerId, Player* player);
|
||||
|
||||
Player * currentPlayer;
|
||||
Player * currentActionPlayer;
|
||||
Player * isInterrupting;
|
||||
Player * opponent();
|
||||
Player * currentlyActing();
|
||||
GameObserver();
|
||||
GameObserver(vector<Player *> _players);
|
||||
GameObserver(WResourceManager* resourceManager = NULL);
|
||||
~GameObserver();
|
||||
void gameStateBasedEffects();
|
||||
void enchantmentStatus();
|
||||
@@ -125,6 +130,8 @@ class GameObserver{
|
||||
Player* getPlayer(size_t index) { return players[index];};
|
||||
bool isStarted() { return (mLayers!=NULL);};
|
||||
RandomGenerator* getRandomGenerator() { return &randomGenerator; };
|
||||
WResourceManager* getResourceManager() { if(this) return mResourceManager;else return 0;};
|
||||
CardSelectorBase* getCardSelector() { return mLayers->mCardSelector;};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user