From 6a580c81d5f2ef74e152474da77aaffacd5e6673 Mon Sep 17 00:00:00 2001 From: lotodore Date: Fri, 10 Aug 2007 23:52:31 +0000 Subject: [PATCH] This revision manually adds one computer player in network games. Don't start with 7 players. --- src/net/common/serverrecvstate.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/net/common/serverrecvstate.cpp b/src/net/common/serverrecvstate.cpp index 6ff01681..e07841d9 100644 --- a/src/net/common/serverrecvstate.cpp +++ b/src/net/common/serverrecvstate.cpp @@ -322,7 +322,7 @@ ServerRecvStateInit::InternalProcess(ServerRecvThread &server, SessionWrapper se } else if (packet->ToNetPacketStartEvent()) { - /*boost::shared_ptr tmpPlayerData( + boost::shared_ptr tmpPlayerData( new PlayerData(m_curUniquePlayerId++, 0, PLAYER_TYPE_COMPUTER, PLAYER_RIGHTS_NORMAL)); tmpPlayerData->SetName("Computer"); @@ -336,7 +336,7 @@ ServerRecvStateInit::InternalProcess(ServerRecvThread &server, SessionWrapper se static_cast(thisPlayerJoined.get())->SetData(thisPlayerJoinedData); server.SendToAllPlayers(thisPlayerJoined); - server.AddComputerPlayer(tmpPlayerData);*/ + server.AddComputerPlayer(tmpPlayerData); server.InternalStartGame(); server.SetState(SERVER_START_GAME_STATE::Instance()); @@ -734,13 +734,17 @@ ServerRecvStateWaitPlayerAction::Process(ServerRecvThread &server) int retVal; boost::shared_ptr tmpPlayer = GetCurrentPlayer(server.GetGame()); - assert(tmpPlayer); + assert(tmpPlayer.get()); assert(!tmpPlayer->getMyName().empty()); // If the player is computer controlled, let the engine act. if (tmpPlayer->getMyType() == PLAYER_TYPE_COMPUTER) { tmpPlayer->action(); + SendPlayerAction(server, tmpPlayer); + + server.SetState(ServerRecvStateStartRound::Instance()); + retVal = MSG_NET_GAME_SERVER_ACTION; } // If the player we are waiting for left, continue without him. else if (!server.IsPlayerConnected(tmpPlayer->getMyName())) @@ -779,7 +783,7 @@ ServerRecvStateWaitPlayerAction::InternalProcess(ServerRecvThread &server, Sessi Game &curGame = server.GetGame(); boost::shared_ptr tmpPlayer = curGame.getPlayerByUniqueId(session.playerData->GetUniqueId()); - assert(tmpPlayer); // TODO throw exception + assert(tmpPlayer.get()); // TODO throw exception // TODO: check whether this is the correct player // TODO: check game state