Fix wrong prediction of powerup in online soccer
This commit is contained in:
parent
f55331cf65
commit
a0e4835602
@ -355,6 +355,25 @@ void SoccerWorld::reset(bool restart)
|
||||
// ie make this kart less likely to affect gaming result
|
||||
if (UserConfigParams::m_arena_ai_stats)
|
||||
getKart(8)->flyUp();
|
||||
|
||||
// Team will remain unchanged even with live join
|
||||
std::vector<int> red_id, blue_id;
|
||||
for (unsigned int i = 0; i < m_karts.size(); i++)
|
||||
{
|
||||
if (getKartTeam(i) == KART_TEAM_RED)
|
||||
red_id.push_back(i);
|
||||
else
|
||||
blue_id.push_back(i);
|
||||
}
|
||||
|
||||
m_team_icon_draw_id.resize(getNumKarts());
|
||||
if (!Track::getCurrentTrack()->getMinimapInvert())
|
||||
std::swap(red_id, blue_id);
|
||||
int pos = 0;
|
||||
for (int id : red_id)
|
||||
m_team_icon_draw_id[pos++] = id;
|
||||
for (int id : blue_id)
|
||||
m_team_icon_draw_id[pos++] = id;
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -403,15 +422,9 @@ void SoccerWorld::update(int ticks)
|
||||
WorldWithRank::update(ticks);
|
||||
WorldWithRank::updateTrack(ticks);
|
||||
|
||||
std::vector<int> red_id, blue_id;
|
||||
for (unsigned int i = 0; i < m_karts.size(); i++)
|
||||
if (isGoalPhase())
|
||||
{
|
||||
if (getKartTeam(i) == KART_TEAM_RED)
|
||||
red_id.push_back(i);
|
||||
else
|
||||
blue_id.push_back(i);
|
||||
|
||||
if (isGoalPhase())
|
||||
for (unsigned int i = 0; i < m_karts.size(); i++)
|
||||
{
|
||||
auto& kart = m_karts[i];
|
||||
if (kart->isEliminated())
|
||||
@ -427,28 +440,35 @@ void SoccerWorld::update(int ticks)
|
||||
kart->getBody()->proceedToTransform(m_goal_transforms[i]);
|
||||
kart->setTrans(m_goal_transforms[i]);
|
||||
}
|
||||
if (m_ticks_back_to_own_goal - getTicksSinceStart() == 1 &&
|
||||
!isRaceOver())
|
||||
{
|
||||
// Reset all karts and ball
|
||||
resetKartsToSelfGoals();
|
||||
if (UserConfigParams::m_arena_ai_stats)
|
||||
getKart(8)->flyUp();
|
||||
}
|
||||
}
|
||||
if (isGoalPhase() &&
|
||||
m_ticks_back_to_own_goal - getTicksSinceStart() == 1 && !isRaceOver())
|
||||
{
|
||||
// Reset all karts and ball
|
||||
resetKartsToSelfGoals();
|
||||
if (UserConfigParams::m_arena_ai_stats)
|
||||
getKart(8)->flyUp();
|
||||
}
|
||||
|
||||
if (UserConfigParams::m_arena_ai_stats)
|
||||
m_frame_count++;
|
||||
// We only use kart position for spliting team in race gui drawing
|
||||
beginSetKartPositions();
|
||||
|
||||
// FIXME before next release always update soccer kart position to fix
|
||||
// powerup random number
|
||||
/*beginSetKartPositions();
|
||||
int pos = 1;
|
||||
if (!Track::getCurrentTrack()->getMinimapInvert())
|
||||
std::swap(red_id, blue_id);
|
||||
for (int id : red_id)
|
||||
setKartPosition(id, pos++);
|
||||
for (int id : blue_id)
|
||||
setKartPosition(id, pos++);
|
||||
endSetKartPositions();
|
||||
for (unsigned i = 0; i < getNumKarts(); i++)
|
||||
{
|
||||
if (getKart(i)->isEliminated())
|
||||
continue;
|
||||
setKartPosition(i, pos++);
|
||||
}
|
||||
for (unsigned i = 0; i < getNumKarts(); i++)
|
||||
{
|
||||
if (!getKart(i)->isEliminated())
|
||||
continue;
|
||||
setKartPosition(i, pos++);
|
||||
}
|
||||
endSetKartPositions();*/
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -106,6 +106,8 @@ private:
|
||||
|
||||
float m_ball_heading;
|
||||
|
||||
std::vector<int> m_team_icon_draw_id;
|
||||
|
||||
std::vector<btTransform> m_goal_transforms;
|
||||
/** Function to update the location the ball on the polygon map */
|
||||
void updateBallPosition(int ticks);
|
||||
@ -244,6 +246,9 @@ public:
|
||||
int diff = m_ticks_back_to_own_goal - getTicksSinceStart();
|
||||
return diff > 0 && diff < stk_config->time2Ticks(3.0f);
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
AbstractKart* getKartAtDrawingPosition(unsigned int p) const OVERRIDE
|
||||
{ return getKart(m_team_icon_draw_id[p - 1]); }
|
||||
}; // SoccerWorld
|
||||
|
||||
|
||||
|
@ -83,6 +83,10 @@ public:
|
||||
unsigned int position);
|
||||
void endSetKartPositions();
|
||||
AbstractKart* getKartAtPosition(unsigned int p) const;
|
||||
/** Returns the kart at which position (start from 1) to draw race icon
|
||||
* \param p Position of the kart. */
|
||||
virtual AbstractKart* getKartAtDrawingPosition(unsigned int p) const
|
||||
{ return getKartAtPosition(p); }
|
||||
virtual int getScoreForPosition(int p);
|
||||
virtual unsigned int getRescuePositionIndex(AbstractKart *kart) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -66,6 +66,7 @@
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
|
||||
// ============================================================================
|
||||
@ -1460,30 +1461,20 @@ void ClientLobby::changeSpectateTarget(PlayerAction action, int value,
|
||||
return;
|
||||
}
|
||||
|
||||
World::KartList karts = World::getWorld()->getKarts();
|
||||
bool sort_kart_for_position =
|
||||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_FREE_FOR_ALL ||
|
||||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_CAPTURE_THE_FLAG ||
|
||||
RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_SOCCER ||
|
||||
RaceManager::get()->modeHasLaps();
|
||||
if (sort_kart_for_position)
|
||||
{
|
||||
std::sort(karts.begin(), karts.end(), []
|
||||
(const std::shared_ptr<AbstractKart>& a,
|
||||
const std::shared_ptr<AbstractKart>& b)->bool
|
||||
{
|
||||
return a->getPosition() < b->getPosition();
|
||||
});
|
||||
}
|
||||
WorldWithRank* wwr = dynamic_cast<WorldWithRank*>(World::getWorld());
|
||||
if (!wwr)
|
||||
return;
|
||||
std::vector<AbstractKart*> karts;
|
||||
for (unsigned i = 0; i < wwr->getNumKarts(); i++)
|
||||
karts.push_back(wwr->getKartAtDrawingPosition(i + 1));
|
||||
|
||||
const int num_karts = (int)karts.size();
|
||||
int current_idx = -1;
|
||||
if (cam->getKart())
|
||||
{
|
||||
if (sort_kart_for_position)
|
||||
current_idx = cam->getKart()->getPosition() - 1;
|
||||
else
|
||||
current_idx = cam->getKart()->getWorldKartId();
|
||||
auto it = std::find(karts.begin(), karts.end(), cam->getKart());
|
||||
if (it != karts.end())
|
||||
current_idx = (int)std::distance(karts.begin(), it);
|
||||
}
|
||||
if (current_idx < 0 || current_idx >= num_karts)
|
||||
return;
|
||||
@ -1506,7 +1497,7 @@ void ClientLobby::changeSpectateTarget(PlayerAction action, int value,
|
||||
|
||||
if (!karts[current_idx]->isEliminated())
|
||||
{
|
||||
cam->setKart(karts[current_idx].get());
|
||||
cam->setKart(karts[current_idx]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -848,7 +848,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
|
||||
|
||||
for(int position = 1; position <= (int)kart_amount ; position++)
|
||||
{
|
||||
AbstractKart *kart = world->getKartAtPosition(position);
|
||||
AbstractKart *kart = world->getKartAtDrawingPosition(position);
|
||||
|
||||
if (kart->getPosition() == -1)//if position is not set
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user