game no longer crashes at the end of the race, the end of race sequence seems ok for 1 player at least
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/hilnius@13532 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
@@ -184,7 +184,7 @@ when the border that intersect at this corner are enabled.
|
||||
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" />
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ when the border that intersect at this corner are enabled.
|
||||
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" />
|
||||
|
||||
|
||||
@@ -796,29 +796,32 @@ void Kart::finishedRace(float time)
|
||||
// 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);
|
||||
|
||||
}
|
||||
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);
|
||||
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)
|
||||
|
||||
@@ -436,10 +436,12 @@ void World::terminateRace()
|
||||
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
|
||||
|
||||
@@ -78,12 +78,16 @@ bool ClientLobbyRoomProtocol::notifyEvent(Event* event)
|
||||
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 @@ bool ClientLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
|
||||
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 @@ bool ClientLobbyRoomProtocol::notifyEventAsynchronous(Event* event)
|
||||
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 @@ void ClientLobbyRoomProtocol::update()
|
||||
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 @@ void ClientLobbyRoomProtocol::update()
|
||||
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 @@ void ClientLobbyRoomProtocol::startGame(Event* event)
|
||||
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 @@ void ClientLobbyRoomProtocol::startSelection(Event* event)
|
||||
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 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
|
||||
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 @@ void ClientLobbyRoomProtocol::raceFinished(Event* event)
|
||||
data.removeFront(2);
|
||||
position++;
|
||||
}
|
||||
ranked_world->endSetKartPositions();
|
||||
m_state = RACE_FINISHED;
|
||||
ranked_world->terminateRace();
|
||||
}
|
||||
|
||||
@@ -258,6 +258,28 @@ void ServerLobbyRoomProtocol::checkRaceFinished()
|
||||
}
|
||||
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
|
||||
|
||||
@@ -45,7 +45,7 @@ class STKPeer
|
||||
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; }
|
||||
|
||||
|
||||
@@ -708,7 +708,7 @@ public:
|
||||
*/
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user