removed some useless files + improvements in end-race GUI interaction
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13592 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
abef4345c5
commit
71fb252654
@ -215,6 +215,7 @@ void World::reset()
|
||||
m_faster_music_active = false;
|
||||
m_eliminated_karts = 0;
|
||||
m_eliminated_players = 0;
|
||||
m_is_network_world = false;
|
||||
|
||||
for ( KartList::iterator i = m_karts.begin(); i != m_karts.end() ; ++i )
|
||||
{
|
||||
|
@ -86,6 +86,7 @@ ClientNetworkManager::ClientNetworkManager()
|
||||
|
||||
ClientNetworkManager::~ClientNetworkManager()
|
||||
{
|
||||
pthread_cancel(*m_thread_keyboard);
|
||||
}
|
||||
|
||||
void ClientNetworkManager::run()
|
||||
|
@ -16,6 +16,10 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
/*! \file client_network_manager.hpp
|
||||
* \brief Defines a Client Network manager, that will connect to a server.
|
||||
*/
|
||||
|
||||
#ifndef CLIENT_NETWORK_MANAGER_HPP
|
||||
#define CLIENT_NETWORK_MANAGER_HPP
|
||||
|
||||
|
@ -16,6 +16,11 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
/*! \file event.hpp
|
||||
* \brief Contains an interface to store network events, like connections,
|
||||
* disconnections and messages.
|
||||
*/
|
||||
|
||||
#ifndef EVENT_HPP
|
||||
#define EVENT_HPP
|
||||
|
||||
|
@ -1,67 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2013 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "network/http_functions.hpp"
|
||||
|
||||
#include "utils/log.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <curl/curl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
|
||||
namespace HTTP
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
((std::string*)userp)->append((char*)contents, size * nmemb);
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
curl = curl_easy_init();
|
||||
if(!curl)
|
||||
Log::error("HTTP", "Error while loading cURL library.\n");
|
||||
}
|
||||
|
||||
std::string getPage(std::string url)
|
||||
{
|
||||
std::string readBuffer;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
|
||||
res = curl_easy_perform(curl);
|
||||
if(res != CURLE_OK)
|
||||
Log::error("HTTP", "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
|
||||
|
||||
return readBuffer;
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
{
|
||||
curl_easy_cleanup(curl);
|
||||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2013 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HTTP_FUNCTIONS_HPP
|
||||
#define HTTP_FUNCTIONS_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace HTTP
|
||||
{
|
||||
|
||||
void init();
|
||||
void shutdown();
|
||||
|
||||
std::string getPage(std::string url);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif // HTTP_FUNCTIONS_HPP
|
@ -51,7 +51,6 @@ void NetworkWorld::start()
|
||||
void NetworkWorld::stop()
|
||||
{
|
||||
m_running = false;
|
||||
World::getWorld()->setNetworkWorld(false);
|
||||
}
|
||||
|
||||
bool NetworkWorld::isRaceOver()
|
||||
|
@ -164,6 +164,7 @@ void ControllerEventsProtocol::controllerAction(Controller* controller,
|
||||
ns.ai8(serialized_1).ai8(serialized_2).ai8(serialized_3);
|
||||
ns.ai8((uint8_t)(action)).ai32(value);
|
||||
|
||||
Log::info("ControllerEventsProtocol", "Action %d value %d", action, value);
|
||||
m_listener->sendMessage(this, ns, false); // send message to server
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,8 @@ void KartUpdateProtocol::setup()
|
||||
|
||||
void KartUpdateProtocol::update()
|
||||
{
|
||||
if (!World::getWorld())
|
||||
return;
|
||||
static double time = 0;
|
||||
double current_time = Time::getRealTime();
|
||||
if (current_time > time + 0.1) // 10 updates per second
|
||||
|
@ -1,20 +1,21 @@
|
||||
#include "network/protocols/start_game_protocol.hpp"
|
||||
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "network/network_manager.hpp"
|
||||
#include "network/protocol_manager.hpp"
|
||||
#include "network/game_setup.hpp"
|
||||
#include "network/network_world.hpp"
|
||||
#include "network/protocols/synchronization_protocol.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/time.hpp"
|
||||
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "states_screens/kart_selection.hpp"
|
||||
#include "online/current_user.hpp"
|
||||
#include "states_screens/network_kart_selection.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/time.hpp"
|
||||
|
||||
StartGameProtocol::StartGameProtocol(GameSetup* game_setup) :
|
||||
Protocol(NULL, PROTOCOL_START_GAME)
|
||||
@ -166,6 +167,7 @@ void StartGameProtocol::update()
|
||||
// now the synchronization protocol exists.
|
||||
Log::info("StartGameProtocol", "Starting the race loading.");
|
||||
race_manager->startSingleRace("jungle", 1, false);
|
||||
World::getWorld()->setNetworkWorld(true);
|
||||
m_state = LOADING;
|
||||
}
|
||||
}
|
||||
|
@ -36,11 +36,14 @@
|
||||
#include "modes/demo_world.hpp"
|
||||
#include "modes/overworld.hpp"
|
||||
#include "modes/world_with_rank.hpp"
|
||||
#include "network/network_world.hpp"
|
||||
#include "race/highscores.hpp"
|
||||
#include "states_screens/feature_unlocked.hpp"
|
||||
#include "states_screens/main_menu_screen.hpp"
|
||||
#include "states_screens/networking_lobby.hpp"
|
||||
#include "states_screens/network_kart_selection.hpp"
|
||||
#include "states_screens/online_screen.hpp"
|
||||
#include "states_screens/race_setup_screen.hpp"
|
||||
#include "states_screens/server_selection.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
@ -98,8 +101,9 @@ void RaceResultGUI::enableAllButtons()
|
||||
}
|
||||
|
||||
// If we're in a network world, change the buttons text
|
||||
if (NetworkWorld::getInstance()->isRunning())
|
||||
if (World::getWorld()->isNetworkWorld())
|
||||
{
|
||||
Log::info("This work was networked", "This is a network world.");
|
||||
top->setVisible(false);
|
||||
middle->setText( _("Continue.") );
|
||||
middle->setVisible(true);
|
||||
@ -113,6 +117,7 @@ void RaceResultGUI::enableAllButtons()
|
||||
}
|
||||
return;
|
||||
}
|
||||
Log::info("This work was NOT networked", "This is NOT a network world.");
|
||||
|
||||
// If something was unlocked
|
||||
// -------------------------
|
||||
@ -234,11 +239,19 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||
}
|
||||
|
||||
// If we're playing online :
|
||||
if (NetworkWorld::getInstance()->isRunning())
|
||||
if (World::getWorld()->isNetworkWorld())
|
||||
{
|
||||
StateManager::get()->popMenu();
|
||||
if (name == "middle") // Continue button (return to server lobby)
|
||||
{
|
||||
race_manager->exitRace();
|
||||
race_manager->setAIKartOverride("");
|
||||
Screen* newStack[] = {MainMenuScreen::getInstance(),
|
||||
OnlineScreen::getInstance(),
|
||||
ServerSelection::getInstance(),
|
||||
NetworkingLobby::getInstance(),
|
||||
NULL};
|
||||
StateManager::get()->resetAndSetStack( newStack );
|
||||
}
|
||||
if (name == "bottom") // Quit server (return to main menu)
|
||||
{
|
||||
@ -280,6 +293,7 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||
{
|
||||
race_manager->exitRace();
|
||||
race_manager->setAIKartOverride("");
|
||||
NetworkKartSelectionScreen::getInstance()->tearDown(); // be sure to delete the kart selection screen
|
||||
Screen* newStack[] = {MainMenuScreen::getInstance(),
|
||||
RaceSetupScreen::getInstance(),
|
||||
NULL};
|
||||
@ -293,6 +307,7 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
|
||||
{
|
||||
race_manager->exitRace();
|
||||
race_manager->setAIKartOverride("");
|
||||
NetworkKartSelectionScreen::getInstance()->tearDown(); // be sure to delete the kart selection screen
|
||||
StateManager::get()->resetAndGoToScreen(MainMenuScreen::getInstance());
|
||||
|
||||
if (race_manager->raceWasStartedFromOverworld())
|
||||
|
Loading…
Reference in New Issue
Block a user