Work on dedicated server. This svn revision is totally broken, it is part of a complete redesign of the server.

There is a lobby thread for the server, and each game has its own game processing thread and a sender thread. Connections can be accepted from different sources, i.e. TCP/SCTP over IPv4, IPv6, all those work well in parallel.
This commit is contained in:
lotodore
2007-08-15 13:28:28 +00:00
parent ab0dd1d065
commit 59b7438376
12 changed files with 1561 additions and 797 deletions
+10 -13
View File
@@ -344,12 +344,12 @@ ClientStateStartSession::Process(ClientThread &client)
{
ClientContext &context = client.GetContext();
NetPacketJoinGame::Data initData;
NetPacketInit::Data initData;
initData.password = context.GetPassword();
initData.playerName = context.GetPlayerName();
boost::shared_ptr<NetPacket> packet(new NetPacketJoinGame);
((NetPacketJoinGame *)packet.get())->SetData(initData);
boost::shared_ptr<NetPacket> packet(new NetPacketInit);
((NetPacketInit *)packet.get())->SetData(initData);
client.GetSender().Send(context.GetSocket(), packet);
@@ -435,19 +435,16 @@ ClientStateWaitSession::InternalProcess(ClientThread &client, boost::shared_ptr<
int retVal = MSG_SOCK_INTERNAL_PENDING;
ClientContext &context = client.GetContext();
if (packet->ToNetPacketJoinGameAck())
if (packet->ToNetPacketInitAck())
{
// Everything is fine - we joined the game.
// Initialize game configuration.
NetPacketJoinGameAck::Data joinGameAckData;
packet->ToNetPacketJoinGameAck()->GetData(joinGameAckData);
client.SetGameData(joinGameAckData.gameData);
client.SetGuiPlayerId(joinGameAckData.yourPlayerUniqueId);
// Everything is fine - we are in the lobby.
NetPacketInitAck::Data initAckData;
packet->ToNetPacketInitAck()->GetData(initAckData);
client.SetGuiPlayerId(initAckData.yourPlayerUniqueId);
// TODO: Type Human is fixed here.
// Player number is 0 on join. Will be set when the game starts.
// Player number is 0 on init. Will be set when the game starts.
boost::shared_ptr<PlayerData> playerData(
new PlayerData(joinGameAckData.yourPlayerUniqueId, 0, joinGameAckData.ptype, joinGameAckData.prights));
new PlayerData(initAckData.yourPlayerUniqueId, 0, PLAYER_TYPE_HUMAN, PLAYER_RIGHTS_NORMAL));
playerData->SetName(context.GetPlayerName());
client.AddPlayerData(playerData);