00001 //////////////////////////////////////////////////////////////////////////////// 00002 // Scorched3D (c) 2000-2009 00003 // 00004 // This file is part of Scorched3D. 00005 // 00006 // Scorched3D is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // Scorched3D is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with Scorched3D; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 //////////////////////////////////////////////////////////////////////////////// 00020 00021 #include <client/ClientWaitState.h> 00022 #include <client/ScorchedClient.h> 00023 #include <client/ClientState.h> 00024 #include <tank/TankContainer.h> 00025 #include <coms/ComsMessageSender.h> 00026 #include <coms/ComsPlayerReadyMessage.h> 00027 00028 ClientWaitState *ClientWaitState::instance_ = 0; 00029 00030 ClientWaitState *ClientWaitState::instance() 00031 { 00032 if (!instance_) 00033 { 00034 instance_ = new ClientWaitState; 00035 } 00036 return instance_; 00037 } 00038 00039 ClientWaitState::ClientWaitState() : 00040 GameStateI("ClientWaitState") 00041 { 00042 } 00043 00044 ClientWaitState::~ClientWaitState() 00045 { 00046 } 00047 00048 void ClientWaitState::enterState(const unsigned state) 00049 { 00050 00051 } 00052 00053 void ClientWaitState::sendClientReady() 00054 { 00055 ScorchedClient::instance()->getGameState().stimulate(ClientState::StimWait); 00056 00057 // move into player or main state place 00058 // The server will move the client into the main state 00059 // when all clients+server are ready 00060 std::map<unsigned int, Tank *> &playingTanks = 00061 ScorchedClient::instance()->getTankContainer().getPlayingTanks(); 00062 std::map<unsigned int, Tank *>::iterator itor; 00063 for (itor = playingTanks.begin(); 00064 itor != playingTanks.end(); 00065 itor++) 00066 { 00067 Tank *current = (*itor).second; 00068 00069 if (current->getDestinationId() == 00070 ScorchedClient::instance()->getTankContainer().getCurrentDestinationId()) 00071 { 00072 ComsPlayerReadyMessage readyMessage(current->getPlayerId()); 00073 ComsMessageSender::sendToServer(readyMessage); 00074 } 00075 } 00076 }
1.5.3