Cleaned up Network code (hope that fixes the PSP compilation problems)

Added random seed logging
This commit is contained in:
Xawotihs@gmail.com
2013-01-25 21:47:16 +00:00
parent 4bf419fbaf
commit 2ba5eb0022
10 changed files with 39 additions and 56 deletions

View File

@@ -40,6 +40,7 @@ class GameObserver{
list<string> loadingList;
list<string>::iterator loadingite;
RandomGenerator randomGenerator;
unsigned int mSeed;
WResourceManager* mResourceManager;
JGE* mJGE;
DeckManager* mDeckManager;
@@ -143,7 +144,7 @@ class GameObserver{
logAction(players[playerId], s);
};
void logAction(MTGCardInstance* card, MTGGameZone* zone, size_t index, int result);
bool load(const string& s, bool undo = false
bool load(const string& s, bool undo = false, bool swapPlayers = false
#ifdef TESTSUITE
, TestSuiteGame* testgame = 0
#endif

View File

@@ -31,7 +31,6 @@ private:
Credits * credits;
int mGamePhase;
Player * mCurrentPlayer;
GameObserver * game;
DeckMenu * deckmenu;
DeckMenu * opponentMenu;

View File

@@ -73,7 +73,7 @@ public:
void initPlayers(GameObserver *observer);
bool canChooseDeck(); //True if the players get to select their decks, false if the decks are automatically generated by the mode
void addExtraRules(GameObserver *observer);
void initGame(GameObserver* observer);
void initGame(GameObserver* observer, bool currentPlayerSet = false);
//second part of the initialization, needs to happen after the first update call
void postUpdateInit(GameObserver* observer);
void cleanup();

View File

@@ -73,11 +73,12 @@ protected:
list<int> usedRandomValues;
bool log;
public:
RandomGenerator(bool doLog = false) : log(doLog) {};
RandomGenerator(unsigned int seed = -1, bool doLog = false) : log(doLog) { if(seed != -1) srand(seed);};
void loadRandValues(string s);
ostream& saveUsedRandValues(ostream& out) const;
ostream& saveLoadedRandValues(ostream& out);
int random();
void setSeed(unsigned int seed) { srand(seed); };
template<typename Iter> void random_shuffle(Iter first, Iter last)
{
ptrdiff_t i, n;