From: <hi...@us...> - 2013-07-16 15:00:52
|
Revision: 13261 http://sourceforge.net/p/supertuxkart/code/13261 Author: hilnius Date: 2013-07-16 15:00:49 +0000 (Tue, 16 Jul 2013) Log Message: ----------- correcting some bugs in the kart position update protocol Modified Paths: -------------- main/branches/hilnius/src/network/network_world.hpp main/branches/hilnius/src/network/protocols/kart_update_protocol.cpp main/branches/hilnius/src/network/protocols/start_game_protocol.cpp Modified: main/branches/hilnius/src/network/network_world.hpp =================================================================== --- main/branches/hilnius/src/network/network_world.hpp 2013-07-16 14:46:54 UTC (rev 13260) +++ main/branches/hilnius/src/network/network_world.hpp 2013-07-16 15:00:49 UTC (rev 13261) @@ -25,6 +25,7 @@ void controllerAction(Controller* controller, PlayerAction action, int value); + std::string m_self_kart; protected: bool m_running; float m_race_time; Modified: main/branches/hilnius/src/network/protocols/kart_update_protocol.cpp =================================================================== --- main/branches/hilnius/src/network/protocols/kart_update_protocol.cpp 2013-07-16 14:46:54 UTC (rev 13260) +++ main/branches/hilnius/src/network/protocols/kart_update_protocol.cpp 2013-07-16 15:00:49 UTC (rev 13261) @@ -3,6 +3,7 @@ #include "karts/abstract_kart.hpp" #include "modes/world.hpp" #include "network/protocol_manager.hpp" +#include "network/network_world.hpp" KartUpdateProtocol::KartUpdateProtocol() : Protocol(NULL, PROTOCOL_KART_UPDATE) @@ -10,10 +11,15 @@ m_karts = World::getWorld()->getKarts(); for (unsigned int i = 0; i < m_karts.size(); i++) { - if (m_karts[i]->getWorldKartId()) + //if (m_karts[i]->getWorldKartId()) { Log::info("KartUpdateProtocol", "Kart %d has id %d and name %s", i, m_karts[i]->getWorldKartId(), m_karts[i]->getIdent().c_str()); } + if (m_karts[i]->getIdent() == NetworkWorld::getInstance()->m_self_kart) + { + Log::info("KartUpdateProtocol", "My id is %d", i); + m_self_kart_index = i; + } } } Modified: main/branches/hilnius/src/network/protocols/start_game_protocol.cpp =================================================================== --- main/branches/hilnius/src/network/protocols/start_game_protocol.cpp 2013-07-16 14:46:54 UTC (rev 13260) +++ main/branches/hilnius/src/network/protocols/start_game_protocol.cpp 2013-07-16 15:00:49 UTC (rev 13261) @@ -93,7 +93,7 @@ // race startup sequence NetworkWorld::getInstance<NetworkWorld>()->start(); // builds it and starts - race_manager->setNumKarts(m_game_setup->getPlayerCount()+4); + race_manager->setNumKarts(m_game_setup->getPlayerCount()); race_manager->setNumPlayers(m_game_setup->getPlayerCount()); race_manager->setNumLocalPlayers(1); std::vector<NetworkPlayerProfile*> players = m_game_setup->getPlayers(); @@ -119,6 +119,7 @@ race_manager->setPlayerKart(i, rki); race_manager->setLocalKartInfo(new_player_id, profile->kart_name); Log::info("StartGameProtocol", "Self player device added."); // self config + NetworkWorld::getInstance()->m_self_kart = profile->kart_name; } } for (unsigned int i = 0; i < players.size(); i++) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |