From: <hi...@us...> - 2013-08-21 19:04:50
|
Revision: 13532 http://sourceforge.net/p/supertuxkart/code/13532 Author: hilnius Date: 2013-08-21 19:04:46 +0000 (Wed, 21 Aug 2013) Log Message: ----------- game no longer crashes at the end of the race, the end of race sequence seems ok for 1 player at least Modified Paths: -------------- main/branches/hilnius/data/gui/skins/Ocean.stkskin main/branches/hilnius/data/gui/skins/Peach.stkskin main/branches/hilnius/src/karts/kart.cpp main/branches/hilnius/src/modes/world.cpp main/branches/hilnius/src/network/protocols/client_lobby_room_protocol.cpp main/branches/hilnius/src/network/protocols/server_lobby_room_protocol.cpp main/branches/hilnius/src/network/stk_peer.hpp main/branches/hilnius/src/race/race_manager.hpp Modified: main/branches/hilnius/data/gui/skins/Ocean.stkskin =================================================================== --- main/branches/hilnius/data/gui/skins/Ocean.stkskin 2013-08-21 13:54:50 UTC (rev 13531) +++ main/branches/hilnius/data/gui/skins/Ocean.stkskin 2013-08-21 19:04:46 UTC (rev 13532) @@ -184,7 +184,7 @@ hborder_out_portion="0.0" vborder_out_portion="0.0" /> <!-- Stateless --> -<element type="rounded_section" image="glass/glass_rsection.png" +<element type="rounded_section" image="ocean/glass_rsection.png" left_border="15" right_border="15" top_border="15" bottom_border="15" hborder_out_portion="0.0" vborder_out_portion="0.0" /> Modified: main/branches/hilnius/data/gui/skins/Peach.stkskin =================================================================== --- main/branches/hilnius/data/gui/skins/Peach.stkskin 2013-08-21 13:54:50 UTC (rev 13531) +++ main/branches/hilnius/data/gui/skins/Peach.stkskin 2013-08-21 19:04:46 UTC (rev 13532) @@ -183,7 +183,7 @@ hborder_out_portion="0.0" vborder_out_portion="0.0" /> <!-- Stateless --> -<element type="rounded_section" image="glass/glass_rsection.png" +<element type="rounded_section" image="peach/glass_rsection.png" left_border="15" right_border="15" top_border="15" bottom_border="15" hborder_out_portion="0.0" vborder_out_portion="0.0" /> Modified: main/branches/hilnius/src/karts/kart.cpp =================================================================== --- main/branches/hilnius/src/karts/kart.cpp 2013-08-21 13:54:50 UTC (rev 13531) +++ main/branches/hilnius/src/karts/kart.cpp 2013-08-21 19:04:46 UTC (rev 13532) @@ -796,30 +796,33 @@ // in modes that support it, start end animation setController(new EndController(this, m_controller->getPlayer(), m_controller)); - GameSlot *slot = unlock_manager->getCurrentSlot(); - const Challenge *challenge = slot->getCurrentChallenge(); - // In case of a GP challenge don't make the end animation depend - // on if the challenge is fulfilled - if(challenge && !challenge->getData()->isGrandPrix()) + if (m_controller->isPlayerController()) // if player is on this computer { - if(challenge->getData()->isChallengeFulfilled()) - m_kart_model->setAnimation(KartModel::AF_WIN_START); + GameSlot *slot = unlock_manager->getCurrentSlot(); + const Challenge *challenge = slot->getCurrentChallenge(); + // In case of a GP challenge don't make the end animation depend + // on if the challenge is fulfilled + if(challenge && !challenge->getData()->isGrandPrix()) + { + if(challenge->getData()->isChallengeFulfilled()) + m_kart_model->setAnimation(KartModel::AF_WIN_START); + else + m_kart_model->setAnimation(KartModel::AF_LOSE_START); + + } + else if(m_race_position<=0.5f*race_manager->getNumberOfKarts() || + m_race_position==1) + m_kart_model->setAnimation(KartModel::AF_WIN_START); else m_kart_model->setAnimation(KartModel::AF_LOSE_START); + RaceGUIBase* m = World::getWorld()->getRaceGUI(); + if(m) + { + m->addMessage((getPosition() == 1 ? _("You won the race!") : _("You finished the race!")) , + this, 2.0f); + } } - else if(m_race_position<=0.5f*race_manager->getNumberOfKarts() || - m_race_position==1) - m_kart_model->setAnimation(KartModel::AF_WIN_START); - else - m_kart_model->setAnimation(KartModel::AF_LOSE_START); - - RaceGUIBase* m = World::getWorld()->getRaceGUI(); - if(m) - { - m->addMessage((getPosition() == 1 ? _("You won the race!") : _("You finished the race!")) , - this, 2.0f); - } } else if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_FOLLOW_LEADER) { Modified: main/branches/hilnius/src/modes/world.cpp =================================================================== --- main/branches/hilnius/src/modes/world.cpp 2013-08-21 13:54:50 UTC (rev 13531) +++ main/branches/hilnius/src/modes/world.cpp 2013-08-21 19:04:46 UTC (rev 13532) @@ -436,11 +436,13 @@ int best_finish_time = -1; std::string highscore_who = ""; StateManager::ActivePlayer* best_player = NULL; - updateHighscores(&best_highscore_rank, &best_finish_time, &highscore_who, + if (!this->isNetworkWorld()) + { + updateHighscores(&best_highscore_rank, &best_finish_time, &highscore_who, &best_player); + unlock_manager->getCurrentSlot()->raceFinished(); + } - unlock_manager->getCurrentSlot()->raceFinished(); - if (m_race_gui) m_race_gui->clearAllMessages(); // we can't delete the race gui here, since it is needed in case of // a restart: the constructor of it creates some textures which assume Modified: main/branches/hilnius/src/network/protocols/client_lobby_room_protocol.cpp =================================================================== --- main/branches/hilnius/src/network/protocols/client_lobby_room_protocol.cpp 2013-08-21 13:54:50 UTC (rev 13531) +++ main/branches/hilnius/src/network/protocols/client_lobby_room_protocol.cpp 2013-08-21 19:04:46 UTC (rev 13532) @@ -78,12 +78,16 @@ NetworkString data = event->data(); assert(data.size()); // assert that data isn't empty uint8_t message_type = data[0]; - if (message_type != 0x03) // kart selection update only here (for now) - return false; + if (message_type != 0x03 && + message_type != 0x06) + return false; // don't treat the event event->removeFront(1); + Log::info("ClientLobbyRoomProtocol", "Synchronous message of type %d", message_type); if (message_type == 0x03) // kart selection update kartSelectionUpdate(event); + else if (message_type == 0x06) // end of race + raceFinished(event); return true; } @@ -100,10 +104,12 @@ NetworkString data = event->data(); assert(data.size()); // assert that data isn't empty uint8_t message_type = data[0]; - if (message_type == 0x03) // kart selection update is synchronous (updates gui) - return false; + if (message_type == 0x03 || + message_type == 0x06) + return false; // don't treat the event + event->removeFront(1); - Log::info("ClientLobbyRoomProtocol", "Message of type %d", message_type); + Log::info("ClientLobbyRoomProtocol", "Asynchronous message of type %d", message_type); if (message_type == 0x01) // new player connected newPlayer(event); else if (message_type == 0x02) // player disconnected @@ -112,14 +118,13 @@ startGame(event); else if (message_type == 0x05) // start selection phase startSelection(event); - else if (message_type == 0x06) // end of race - raceFinished(event); else if (message_type == 0x80) // connection refused connectionRefused(event); else if (message_type == 0x81) // connection accepted connectionAccepted(event); else if (message_type == 0x82) // kart selection refused kartSelectionRefused(event); + return true; } // message else if (event->type == EVENT_TYPE_CONNECTED) @@ -158,7 +163,8 @@ ns.ai8(1).ai8(4).ai32(Online::CurrentUser::get()->getUserID()); m_listener->sendMessage(this, ns); m_state = REQUESTING_CONNECTION; - } break; + } + break; case REQUESTING_CONNECTION: break; case CONNECTED: @@ -168,36 +174,19 @@ NetworkKartSelectionScreen* screen = NetworkKartSelectionScreen::getInstance(); StateManager::get()->pushScreen(screen); m_state = SELECTING_KARTS; - } break; + } + break; case SELECTING_KARTS: break; case PLAYING: { if (NetworkWorld::getInstance<NetworkWorld>()->isRaceOver()) // race is now over, kill race protocols and return to connected state { - Protocol* protocol = NULL; - protocol = m_listener->getProtocol(PROTOCOL_CONTROLLER_EVENTS); - if (protocol) - m_listener->requestTerminate(protocol); - else - Log::error("ClientLobbyRoomProtocol", "No controller events protocol registered."); - - protocol = m_listener->getProtocol(PROTOCOL_KART_UPDATE); - if (protocol) - m_listener->requestTerminate(protocol); - else - Log::error("ClientLobbyRoomProtocol", "No kart update protocol registered."); - - protocol = m_listener->getProtocol(PROTOCOL_GAME_EVENTS); - if (protocol) - m_listener->requestTerminate(protocol); - else - Log::error("ClientLobbyRoomProtocol", "No game events protocol registered."); - Log::info("ClientLobbyRoomProtocol", "Game finished."); m_state = RACE_FINISHED; } - } break; + } + break; case RACE_FINISHED: break; case DONE: @@ -474,7 +463,7 @@ if (data.size() < 5 || data[0] != 4) { Log::error("ClientLobbyRoomProtocol", "A message notifying a kart " - "selection update wasn't formated as expected."); + "selection update wasn't formated as expected."); return; } uint8_t token = data.gui32(1); @@ -507,7 +496,7 @@ if (data.size() < 5 || data[0] != 4) { Log::error("ClientLobbyRoomProtocol", "A message notifying a kart " - "selection update wasn't formated as expected."); + "selection update wasn't formated as expected."); return; } uint8_t token = data.gui32(1); @@ -547,7 +536,32 @@ return; } data.removeFront(5); + Log::error("ClientLobbyRoomProtocol", "Server notified that the race is finished."); + + // stop race protocols + Protocol* protocol = NULL; + protocol = m_listener->getProtocol(PROTOCOL_CONTROLLER_EVENTS); + if (protocol) + m_listener->requestTerminate(protocol); + else + Log::error("ClientLobbyRoomProtocol", "No controller events protocol registered."); + + protocol = m_listener->getProtocol(PROTOCOL_KART_UPDATE); + if (protocol) + m_listener->requestTerminate(protocol); + else + Log::error("ClientLobbyRoomProtocol", "No kart update protocol registered."); + + protocol = m_listener->getProtocol(PROTOCOL_GAME_EVENTS); + if (protocol) + m_listener->requestTerminate(protocol); + else + Log::error("ClientLobbyRoomProtocol", "No game events protocol registered."); + + // finish the race WorldWithRank* ranked_world = (WorldWithRank*)(World::getWorld()); + ranked_world->beginSetKartPositions(); + ranked_world->setPhase(WorldStatus::RESULT_DISPLAY_PHASE); int position = 1; while(data.size()>0) { @@ -567,6 +581,7 @@ data.removeFront(2); position++; } + ranked_world->endSetKartPositions(); m_state = RACE_FINISHED; ranked_world->terminateRace(); } Modified: main/branches/hilnius/src/network/protocols/server_lobby_room_protocol.cpp =================================================================== --- main/branches/hilnius/src/network/protocols/server_lobby_room_protocol.cpp 2013-08-21 13:54:50 UTC (rev 13531) +++ main/branches/hilnius/src/network/protocols/server_lobby_room_protocol.cpp 2013-08-21 19:04:46 UTC (rev 13532) @@ -258,6 +258,28 @@ } Log::info("ServerLobbyRoomProtocol", "End of game message sent"); m_in_race = false; + + // stop race protocols + Protocol* protocol = NULL; + protocol = m_listener->getProtocol(PROTOCOL_CONTROLLER_EVENTS); + if (protocol) + m_listener->requestTerminate(protocol); + else + Log::error("ClientLobbyRoomProtocol", "No controller events protocol registered."); + + protocol = m_listener->getProtocol(PROTOCOL_KART_UPDATE); + if (protocol) + m_listener->requestTerminate(protocol); + else + Log::error("ClientLobbyRoomProtocol", "No kart update protocol registered."); + + protocol = m_listener->getProtocol(PROTOCOL_GAME_EVENTS); + if (protocol) + m_listener->requestTerminate(protocol); + else + Log::error("ClientLobbyRoomProtocol", "No game events protocol registered."); + + // notify the network world that it is stopped NetworkWorld::getInstance()->stop(); } else Modified: main/branches/hilnius/src/network/stk_peer.hpp =================================================================== --- main/branches/hilnius/src/network/stk_peer.hpp 2013-08-21 13:54:50 UTC (rev 13531) +++ main/branches/hilnius/src/network/stk_peer.hpp 2013-08-21 19:04:46 UTC (rev 13532) @@ -45,7 +45,7 @@ bool exists() const; uint32_t getAddress() const; uint16_t getPort() const; - NetworkPlayerProfile* getPlayerProfile() { return (m_player_profile==NULL)?NULL:(*m_player_profile); } + NetworkPlayerProfile* getPlayerProfile() { return (m_player_profile)?(*m_player_profile):NULL; } uint32_t getClientServerToken() const { return *m_client_server_token; } bool isClientServerTokenSet() const { return *m_token_set; } Modified: main/branches/hilnius/src/race/race_manager.hpp =================================================================== --- main/branches/hilnius/src/race/race_manager.hpp 2013-08-21 13:54:50 UTC (rev 13531) +++ main/branches/hilnius/src/race/race_manager.hpp 2013-08-21 19:04:46 UTC (rev 13532) @@ -708,7 +708,7 @@ */ bool allPlayerFinished() const { - return m_num_finished_players==m_player_karts.size(); + return m_num_finished_players == m_player_karts.size(); } // ------------------------------------------------------------------------ void kartFinishedRace(const AbstractKart* kart, float time); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |