Trying to make rejoin work, still broken due to change of unique id during game.
This commit is contained in:
+4
-1
@@ -81,6 +81,7 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
string myGuid;
|
||||
unsigned uniqueId = 0;
|
||||
PlayerType type = PLAYER_TYPE_COMPUTER;
|
||||
int myStartCash = startCash;
|
||||
|
||||
if (player_i != player_end) {
|
||||
uniqueId = (*player_i)->GetUniqueId();
|
||||
@@ -88,11 +89,13 @@ Game::Game(GuiInterface* gui, boost::shared_ptr<EngineFactory> factory,
|
||||
myName = (*player_i)->GetName();
|
||||
myAvatarFile = (*player_i)->GetAvatarFile();
|
||||
myGuid = (*player_i)->GetGuid();
|
||||
if ((*player_i)->GetStartCash() > 0)
|
||||
myStartCash = (*player_i)->GetStartCash();
|
||||
++player_i;
|
||||
}
|
||||
|
||||
// create player objects
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = myFactory->createPlayer(i, uniqueId, type, myName, myAvatarFile, startCash, startQuantityPlayers > i, 0);
|
||||
boost::shared_ptr<PlayerInterface> tmpPlayer = myFactory->createPlayer(i, uniqueId, type, myName, myAvatarFile, myStartCash, startQuantityPlayers > i, 0);
|
||||
tmpPlayer->setIsConnected(true);
|
||||
tmpPlayer->setMyGuid(myGuid);
|
||||
|
||||
|
||||
@@ -43,6 +43,9 @@ public:
|
||||
unsigned getMyUniqueID() const {
|
||||
return myUniqueID;
|
||||
}
|
||||
void setMyUniqueID(unsigned newId) {
|
||||
myUniqueID = newId;
|
||||
}
|
||||
|
||||
void setMyGuid(const std::string &theValue) {
|
||||
myGuid = theValue;
|
||||
|
||||
@@ -54,9 +54,17 @@ ClientPlayer::getMyID() const
|
||||
return myID;
|
||||
}
|
||||
|
||||
void
|
||||
ClientPlayer::setMyUniqueID(unsigned newId)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
myUniqueID = newId;
|
||||
}
|
||||
|
||||
unsigned
|
||||
ClientPlayer::getMyUniqueID() const
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(m_syncMutex);
|
||||
return myUniqueID;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
void setHand(HandInterface *);
|
||||
|
||||
int getMyID() const;
|
||||
void setMyUniqueID(unsigned newId);
|
||||
unsigned getMyUniqueID() const;
|
||||
void setMyGuid(const std::string &theValue);
|
||||
std::string getMyGuid() const;
|
||||
@@ -152,7 +153,7 @@ private:
|
||||
|
||||
// Konstanten
|
||||
const int myID;
|
||||
const unsigned myUniqueID;
|
||||
unsigned myUniqueID;
|
||||
std::string myGuid;
|
||||
const PlayerType myType;
|
||||
std::string myName;
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
virtual void setHand(HandInterface *) =0;
|
||||
|
||||
virtual int getMyID() const =0;
|
||||
virtual void setMyUniqueID(unsigned newId) =0;
|
||||
virtual unsigned getMyUniqueID() const =0;
|
||||
|
||||
virtual void setMyGuid(const std::string &theValue) =0;
|
||||
|
||||
Reference in New Issue
Block a user