- reworked completly the JNetwork, JSocket interface (had to ifdef out the PSP socket code)
- added 2 menus to wait for connection and wait for deck selection - tested compilation on Qt Linux, Qt Windows and PSP - deactivated everywhere (NETWORK_SUPPORT to activate).
This commit is contained in:
41
projects/mtg/src/NetworkPlayer.cpp
Normal file
41
projects/mtg/src/NetworkPlayer.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "NetworkPlayer.h"
|
||||
#include <sstream>
|
||||
|
||||
RemotePlayer* RemotePlayer::mInstance = NULL;
|
||||
ProxyPlayer* ProxyPlayer::mInstance = NULL;
|
||||
|
||||
void RegisterNetworkPlayers()
|
||||
{
|
||||
// JNetwork::registerCommand("GetPlayer", ProxyPlayer::Serialize, RemotePlayer::Deserialize);
|
||||
}
|
||||
|
||||
|
||||
RemotePlayer::RemotePlayer(JNetwork* pxNetwork)
|
||||
: Player("remote", "", NULL), mpNetwork(pxNetwork)
|
||||
{
|
||||
mInstance = this;
|
||||
mpNetwork->sendCommand("GetPlayer");
|
||||
}
|
||||
|
||||
void RemotePlayer::Deserialize(istream& in, ostream& out)
|
||||
{
|
||||
// istringstream ss(mInstance->mpNetwork->receiveString());
|
||||
in >> *mInstance;
|
||||
}
|
||||
|
||||
|
||||
ProxyPlayer::ProxyPlayer(Player* pxPlayer, JNetwork* pxNetwork)
|
||||
: mpPlayer(pxPlayer), mpNetwork(pxNetwork)
|
||||
{
|
||||
mInstance = this;
|
||||
JNetwork::registerCommand("GetPlayer", ProxyPlayer::Serialize, RemotePlayer::Deserialize);
|
||||
|
||||
// ostringstream ss;
|
||||
// ss << "Player : " << *mpPlayer;
|
||||
// mpNetwork->send(ss.str());
|
||||
}
|
||||
|
||||
void ProxyPlayer::Serialize(istream& in, ostream& out)
|
||||
{
|
||||
out << *(mInstance->mpPlayer);
|
||||
}
|
||||
Reference in New Issue
Block a user