From: <hik...@us...> - 2008-09-07 13:27:05
|
Revision: 2223 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=2223&view=rev Author: hikerstk Date: 2008-09-07 13:27:00 +0000 (Sun, 07 Sep 2008) Log Message: ----------- Fixed first version of menu synchronisation. Modified Paths: -------------- trunk/supertuxkart/src/game_manager.cpp trunk/supertuxkart/src/gui/char_sel.cpp trunk/supertuxkart/src/gui/start_race_feedback.cpp trunk/supertuxkart/src/gui/start_race_feedback.hpp trunk/supertuxkart/src/main.cpp trunk/supertuxkart/src/network_manager.cpp Modified: trunk/supertuxkart/src/game_manager.cpp =================================================================== --- trunk/supertuxkart/src/game_manager.cpp 2008-09-07 13:25:58 UTC (rev 2222) +++ trunk/supertuxkart/src/game_manager.cpp 2008-09-07 13:27:00 UTC (rev 2223) @@ -40,6 +40,7 @@ #include "user_config.hpp" #include "scene.hpp" #include "history.hpp" +#include "network_manager.hpp" GameManager* game_manager = 0; @@ -103,6 +104,7 @@ music_on = true; } + network_manager->update(dt); if (race_manager->raceIsActive()) { music_on = false; Modified: trunk/supertuxkart/src/gui/char_sel.cpp =================================================================== --- trunk/supertuxkart/src/gui/char_sel.cpp 2008-09-07 13:25:58 UTC (rev 2222) +++ trunk/supertuxkart/src/gui/char_sel.cpp 2008-09-07 13:27:00 UTC (rev 2223) @@ -393,6 +393,7 @@ if(network_manager->getMode()==NetworkManager::NW_CLIENT) { + menu_manager->pushMenu(MENUID_START_RACE_FEEDBACK); } else { Modified: trunk/supertuxkart/src/gui/start_race_feedback.cpp =================================================================== --- trunk/supertuxkart/src/gui/start_race_feedback.cpp 2008-09-07 13:25:58 UTC (rev 2222) +++ trunk/supertuxkart/src/gui/start_race_feedback.cpp 2008-09-07 13:27:00 UTC (rev 2223) @@ -17,22 +17,28 @@ #include <SDL/SDL.h> +#include "start_race_feedback.hpp" #include "widget_manager.hpp" #include "race_manager.hpp" #include "translation.hpp" +#include "network_manager.hpp" -#include "start_race_feedback.hpp" - enum WidgetTokens { WTOK_MSG }; -StartRaceFeedback::StartRaceFeedback() : m_updated( false ) +StartRaceFeedback::StartRaceFeedback() { + m_state = network_manager->getMode()==NetworkManager::NW_NONE ? SRF_LOADING : SRF_NETWORK; + //Add some feedback so people know they are going to start the race widget_manager->reset(); - widget_manager->addTextWgt( WTOK_MSG, 60, 7, _("Loading race...") ); + if(m_state==SRF_NETWORK) + widget_manager->addTextWgt( WTOK_MSG, 60, 7, _("Synchronising network...") ); + else + widget_manager->addTextWgt( WTOK_MSG, 60, 7, _("Loading race...") ); + widget_manager->layout(WGT_AREA_ALL); } @@ -48,9 +54,19 @@ { widget_manager->update(0.0f); - //I consider that in this case, a static variable is cleaner than a - //member variable of this class. -Coz - if( m_updated == true ) race_manager->startNew(); - else m_updated = true; + // Now the text is being displayed, + if(m_state==SRF_NETWORK) + { + if(network_manager->getMode()==NetworkManager::NW_SERVER) + network_manager->sendRaceInformationToClients(); + else + network_manager->waitForRaceInformation(); + m_state = SRF_LOADING; + widget_manager->setWgtText(WTOK_MSG, _("Loading race...") ); + } + + static bool updated=false; + if( updated == true ) race_manager->startNew(); + else updated = true; } Modified: trunk/supertuxkart/src/gui/start_race_feedback.hpp =================================================================== --- trunk/supertuxkart/src/gui/start_race_feedback.hpp 2008-09-07 13:25:58 UTC (rev 2222) +++ trunk/supertuxkart/src/gui/start_race_feedback.hpp 2008-09-07 13:27:00 UTC (rev 2223) @@ -22,8 +22,7 @@ class StartRaceFeedback: public BaseGUI { - bool m_updated; - + enum {SRF_NETWORK, SRF_LOADING} m_state; public: StartRaceFeedback(); ~StartRaceFeedback(); Modified: trunk/supertuxkart/src/main.cpp =================================================================== --- trunk/supertuxkart/src/main.cpp 2008-09-07 13:25:58 UTC (rev 2222) +++ trunk/supertuxkart/src/main.cpp 2008-09-07 13:27:00 UTC (rev 2223) @@ -126,6 +126,7 @@ int handleCmdLine(int argc, char **argv) { int n; + char s[80]; for(int i=1; i<argc; i++) { if(argv[i][0] != '-') continue; @@ -172,9 +173,10 @@ { network_manager->setPort(n); } - else if( sscanf(argv[i], "--numclients=%d", &n) ) + else if( sscanf(argv[i], "--client=%s", s) ) { - network_manager->setNumClients(n); + network_manager->setMode(NetworkManager::NW_CLIENT); + network_manager->setServerIP(s); } #endif else if( (!strcmp(argv[i], "--kart") && i+1<argc )) @@ -531,7 +533,8 @@ if(!network_manager->initialiseConnections()) { - fprintf(stderr, "Problems initialising network connections, aborting.\n"); + fprintf(stderr, "Problems initialising network connections,\n" + "Running in non-network mode.\n"); } // Not replaying Modified: trunk/supertuxkart/src/network_manager.cpp =================================================================== --- trunk/supertuxkart/src/network_manager.cpp 2008-09-07 13:25:58 UTC (rev 2222) +++ trunk/supertuxkart/src/network_manager.cpp 2008-09-07 13:27:00 UTC (rev 2223) @@ -125,7 +125,7 @@ if (enet_host_service (m_host, & event, 5000) > 0 && event.type == ENET_EVENT_TYPE_CONNECT) { - fprintf(stderr, "Connection to %s:%d succeeded.", + fprintf(stderr, "Connection to %s:%d succeeded.\n", m_server_address.c_str(), m_port); enet_host_service(m_host, &event, 1000); } @@ -136,7 +136,7 @@ /* had run out without any significant event. */ enet_peer_reset (peer); - fprintf(stderr, "Connection to '%s:%d' failed.", + fprintf(stderr, "Connection to '%s:%d' failed.\n", m_server_address.c_str(), m_port); } @@ -207,12 +207,14 @@ */ void NetworkManager::sendKartsInformationToServer() { + fprintf(stderr, "Client sending kart information to server\n"); } // sendKartsInformationToServer // ---------------------------------------------------------------------------- /** Receive and store the information from sendKartsInformation() */ void NetworkManager::waitForKartsInformation() { + fprintf(stderr, "Server receiving all kart information\n"); } // waitForKartsInformation // ---------------------------------------------------------------------------- @@ -220,6 +222,7 @@ */ void NetworkManager::sendRaceInformationToClients() { + fprintf(stderr, "server sending race_manager information to all clients\n"); } // sendRaceInformationToClients // ---------------------------------------------------------------------------- @@ -227,5 +230,6 @@ */ void NetworkManager::waitForRaceInformation() { + fprintf(stderr, "Client waiting for race information\n"); } // waitForRaceInformation // ---------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |