Fix ranking messed up in network when finishing race
This commit is contained in:
parent
e78dbe2cce
commit
fb13eb105e
@ -511,7 +511,7 @@ bool CaptureTheFlag::isRaceOver()
|
||||
} // isRaceOver
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void CaptureTheFlag::loseFlagForKart(unsigned int kart_id)
|
||||
void CaptureTheFlag::loseFlagForKart(int kart_id)
|
||||
{
|
||||
if (!(m_red_holder == kart_id || m_blue_holder == kart_id))
|
||||
return;
|
||||
|
@ -130,7 +130,7 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
const Vec3& getBlueFlag() const { return (Vec3&)m_blue_trans.getOrigin(); }
|
||||
// ------------------------------------------------------------------------
|
||||
void loseFlagForKart(unsigned int kart_id);
|
||||
void loseFlagForKart(int kart_id);
|
||||
|
||||
}; // CaptureTheFlag
|
||||
|
||||
|
@ -111,7 +111,7 @@ void GameSetup::update(bool remove_disconnected_players)
|
||||
continue;
|
||||
}
|
||||
AbstractKart* k = World::getWorld()->getKart(i);
|
||||
if (!k->isEliminated())
|
||||
if (!k->isEliminated() && !k->hasFinishedRace())
|
||||
{
|
||||
CaptureTheFlag* ctf = dynamic_cast<CaptureTheFlag*>
|
||||
(World::getWorld());
|
||||
@ -122,7 +122,7 @@ void GameSetup::update(bool remove_disconnected_players)
|
||||
false/*notify_of_elimination*/);
|
||||
k->setPosition(
|
||||
World::getWorld()->getCurrentNumKarts() + 1);
|
||||
k->finishedRace(World::getWorld()->getTime());
|
||||
k->finishedRace(World::getWorld()->getTime(), true/*from_server*/);
|
||||
NetworkString p(PROTOCOL_GAME_EVENTS);
|
||||
p.setSynchronous(true);
|
||||
p.addUInt8(GameEventsProtocol::GE_PLAYER_DISCONNECT).addUInt8(i);
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "network/rewind_manager.hpp"
|
||||
#include "network/stk_host.hpp"
|
||||
#include "network/stk_peer.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -26,6 +27,7 @@
|
||||
*/
|
||||
GameEventsProtocol::GameEventsProtocol() : Protocol(PROTOCOL_GAME_EVENTS)
|
||||
{
|
||||
m_last_finished_position = 1;
|
||||
} // GameEventsProtocol
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -147,7 +149,7 @@ void GameEventsProtocol::eliminatePlayer(const NetworkString &data)
|
||||
World::getWorld()->getKart(kartid)->setPosition(
|
||||
World::getWorld()->getCurrentNumKarts() + 1);
|
||||
World::getWorld()->getKart(kartid)->finishedRace(
|
||||
World::getWorld()->getTime());
|
||||
World::getWorld()->getTime(), true/*from_server*/);
|
||||
} // eliminatePlayer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -183,6 +185,11 @@ void GameEventsProtocol::kartFinishedRace(const NetworkString &ns)
|
||||
float time = ns.getFloat();
|
||||
World::getWorld()->getKart(kart_id)->finishedRace(time,
|
||||
/*from_server*/true);
|
||||
if (race_manager->modeHasLaps())
|
||||
{
|
||||
World::getWorld()->getKart(kart_id)
|
||||
->setPosition(m_last_finished_position++);
|
||||
}
|
||||
} // kartFinishedRace
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -21,6 +21,8 @@ public:
|
||||
GE_STARTUP_BOOST = 8,
|
||||
}; // GameEventType
|
||||
private:
|
||||
int m_last_finished_position;
|
||||
|
||||
void eliminatePlayer(const NetworkString &ns);
|
||||
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user