Rename soccer team to kart team for CTF
This commit is contained in:
@@ -62,8 +62,8 @@ SoccerAI::SoccerAI(AbstractKart *kart)
|
||||
m_world = dynamic_cast<SoccerWorld*>(World::getWorld());
|
||||
m_track = Track::getCurrentTrack();
|
||||
m_cur_team = m_world->getKartTeam(m_kart->getWorldKartId());
|
||||
m_opp_team = (m_cur_team == SOCCER_TEAM_BLUE ?
|
||||
SOCCER_TEAM_RED : SOCCER_TEAM_BLUE);
|
||||
m_opp_team = (m_cur_team == KART_TEAM_BLUE ?
|
||||
KART_TEAM_RED : KART_TEAM_BLUE);
|
||||
|
||||
// Don't call our own setControllerName, since this will add a
|
||||
// billboard showing 'AIBaseController' to the kart.
|
||||
@@ -110,8 +110,8 @@ void SoccerAI::reset()
|
||||
void SoccerAI::update(int ticks)
|
||||
{
|
||||
#ifdef BALL_AIM_DEBUG
|
||||
Vec3 red = m_world->getBallAimPosition(SOCCER_TEAM_RED);
|
||||
Vec3 blue = m_world->getBallAimPosition(SOCCER_TEAM_BLUE);
|
||||
Vec3 red = m_world->getBallAimPosition(KART_TEAM_RED);
|
||||
Vec3 blue = m_world->getBallAimPosition(KART_TEAM_BLUE);
|
||||
m_red_sphere->setPosition(red.toIrrVector());
|
||||
m_blue_sphere->setPosition(blue.toIrrVector());
|
||||
#endif
|
||||
@@ -226,7 +226,7 @@ Vec3 SoccerAI::determineBallAimingPosition()
|
||||
{
|
||||
#ifdef BALL_AIM_DEBUG
|
||||
// Choose your favourite team to watch
|
||||
if (m_world->getKartTeam(m_kart->getWorldKartId()) == SOCCER_TEAM_BLUE)
|
||||
if (m_world->getKartTeam(m_kart->getWorldKartId()) == KART_TEAM_BLUE)
|
||||
{
|
||||
Camera *cam = Camera::getActiveCamera();
|
||||
cam->setMode(Camera::CM_NORMAL);
|
||||
|
||||
@@ -46,10 +46,10 @@ private:
|
||||
SoccerWorld *m_world;
|
||||
|
||||
/** Save the team this AI belongs to. */
|
||||
SoccerTeam m_cur_team;
|
||||
KartTeam m_cur_team;
|
||||
|
||||
/** Save the opposite team of this AI team. */
|
||||
SoccerTeam m_opp_team;
|
||||
KartTeam m_opp_team;
|
||||
|
||||
/** Define which way to handle to ball, either steer with it,
|
||||
* or overtake it (Defense). */
|
||||
|
||||
@@ -467,8 +467,8 @@ bool SoccerWorld::isRaceOver()
|
||||
// One team scored the target goals ...
|
||||
else
|
||||
{
|
||||
return (getScore(SOCCER_TEAM_BLUE) >= m_goal_target ||
|
||||
getScore(SOCCER_TEAM_RED) >= m_goal_target);
|
||||
return (getScore(KART_TEAM_BLUE) >= m_goal_target ||
|
||||
getScore(KART_TEAM_RED) >= m_goal_target);
|
||||
}
|
||||
|
||||
} // isRaceOver
|
||||
@@ -506,11 +506,11 @@ void SoccerWorld::initKartList()
|
||||
if (km->supportColorization() && CVS->isGLSL()) continue;
|
||||
|
||||
float arrow_pos_height = km->getHeight() + 0.5f;
|
||||
SoccerTeam team = getKartTeam(i);
|
||||
KartTeam team = getKartTeam(i);
|
||||
|
||||
arrow_node = irr_driver->addBillboard(
|
||||
core::dimension2d<irr::f32>(0.3f,0.3f),
|
||||
team == SOCCER_TEAM_BLUE ? blue_path : red_path,
|
||||
team == KART_TEAM_BLUE ? blue_path : red_path,
|
||||
m_karts[i]->getNode());
|
||||
|
||||
arrow_node->setPosition(core::vector3df(0, arrow_pos_height, 0));
|
||||
@@ -524,10 +524,10 @@ bool SoccerWorld::getKartSoccerResult(unsigned int kart_id) const
|
||||
if (m_red_scorers.size() == m_blue_scorers.size()) return true;
|
||||
|
||||
bool red_win = m_red_scorers.size() > m_blue_scorers.size();
|
||||
SoccerTeam team = getKartTeam(kart_id);
|
||||
KartTeam team = getKartTeam(kart_id);
|
||||
|
||||
if ((red_win && team == SOCCER_TEAM_RED) ||
|
||||
(!red_win && team == SOCCER_TEAM_BLUE))
|
||||
if ((red_win && team == KART_TEAM_RED) ||
|
||||
(!red_win && team == KART_TEAM_BLUE))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
@@ -540,24 +540,24 @@ std::shared_ptr<AbstractKart> SoccerWorld::createKart
|
||||
int global_player_id, RaceManager::KartType kart_type,
|
||||
PerPlayerDifficulty difficulty)
|
||||
{
|
||||
int cur_red = getTeamNum(SOCCER_TEAM_RED);
|
||||
int cur_blue = getTeamNum(SOCCER_TEAM_BLUE);
|
||||
int cur_red = getTeamNum(KART_TEAM_RED);
|
||||
int cur_blue = getTeamNum(KART_TEAM_BLUE);
|
||||
int pos_index = 0;
|
||||
int position = index + 1;
|
||||
SoccerTeam team = SOCCER_TEAM_BLUE;
|
||||
KartTeam team = KART_TEAM_BLUE;
|
||||
|
||||
if (kart_type == RaceManager::KT_AI)
|
||||
{
|
||||
if (index < m_red_ai)
|
||||
team = SOCCER_TEAM_RED;
|
||||
team = KART_TEAM_RED;
|
||||
else
|
||||
team = SOCCER_TEAM_BLUE;
|
||||
team = KART_TEAM_BLUE;
|
||||
m_kart_team_map[index] = team;
|
||||
}
|
||||
else if (NetworkConfig::get()->isNetworking())
|
||||
{
|
||||
m_kart_team_map[index] = race_manager->getKartInfo(index).getSoccerTeam();
|
||||
team = race_manager->getKartInfo(index).getSoccerTeam();
|
||||
m_kart_team_map[index] = race_manager->getKartInfo(index).getKartTeam();
|
||||
team = race_manager->getKartInfo(index).getKartTeam();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -565,7 +565,7 @@ std::shared_ptr<AbstractKart> SoccerWorld::createKart
|
||||
(race_manager->getNumberOfKarts() - race_manager->getNumPlayers());
|
||||
|
||||
assert(rm_id >= 0);
|
||||
team = race_manager->getKartInfo(rm_id).getSoccerTeam();
|
||||
team = race_manager->getKartInfo(rm_id).getKartTeam();
|
||||
m_kart_team_map[index] = team;
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ std::shared_ptr<AbstractKart> SoccerWorld::createKart
|
||||
|
||||
// Notice: In blender, please set 1,3,5,7... for blue starting position;
|
||||
// 2,4,6,8... for red.
|
||||
if (team == SOCCER_TEAM_BLUE)
|
||||
if (team == KART_TEAM_BLUE)
|
||||
{
|
||||
pos_index = 1 + 2 * cur_blue;
|
||||
}
|
||||
@@ -591,7 +591,7 @@ std::shared_ptr<AbstractKart> SoccerWorld::createKart
|
||||
m_kart_position_map[index] = (unsigned)(pos_index - 1);
|
||||
|
||||
std::shared_ptr<RenderInfo> ri = std::make_shared<RenderInfo>();
|
||||
ri = (team == SOCCER_TEAM_BLUE ? std::make_shared<RenderInfo>(0.66f) :
|
||||
ri = (team == KART_TEAM_BLUE ? std::make_shared<RenderInfo>(0.66f) :
|
||||
std::make_shared<RenderInfo>(1.0f));
|
||||
|
||||
std::shared_ptr<AbstractKart> new_kart;
|
||||
@@ -710,9 +710,9 @@ int SoccerWorld::getBallNode() const
|
||||
} // getBallNode
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
SoccerTeam SoccerWorld::getKartTeam(unsigned int kart_id) const
|
||||
KartTeam SoccerWorld::getKartTeam(unsigned int kart_id) const
|
||||
{
|
||||
std::map<int, SoccerTeam>::const_iterator n =
|
||||
std::map<int, KartTeam>::const_iterator n =
|
||||
m_kart_team_map.find(kart_id);
|
||||
|
||||
assert(n != m_kart_team_map.end());
|
||||
@@ -722,15 +722,15 @@ SoccerTeam SoccerWorld::getKartTeam(unsigned int kart_id) const
|
||||
//-----------------------------------------------------------------------------
|
||||
bool SoccerWorld::isCorrectGoal(unsigned int kart_id, bool first_goal) const
|
||||
{
|
||||
SoccerTeam team = getKartTeam(kart_id);
|
||||
KartTeam team = getKartTeam(kart_id);
|
||||
if (first_goal)
|
||||
{
|
||||
if (team == SOCCER_TEAM_RED)
|
||||
if (team == KART_TEAM_RED)
|
||||
return true;
|
||||
}
|
||||
else if (!first_goal)
|
||||
{
|
||||
if (team == SOCCER_TEAM_BLUE)
|
||||
if (team == KART_TEAM_BLUE)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -751,7 +751,7 @@ void SoccerWorld::updateAIData()
|
||||
m_karts[i]->getController()->isPlayerController())
|
||||
continue;
|
||||
|
||||
if (getKartTeam(m_karts[i]->getWorldKartId()) == SOCCER_TEAM_RED)
|
||||
if (getKartTeam(m_karts[i]->getWorldKartId()) == KART_TEAM_RED)
|
||||
{
|
||||
Vec3 rd = m_karts[i]->getXYZ() - getBallPosition();
|
||||
m_red_kdm.push_back(KartDistanceMap(i, rd.length_2d()));
|
||||
@@ -772,9 +772,9 @@ void SoccerWorld::updateAIData()
|
||||
} // updateAIData
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int SoccerWorld::getAttacker(SoccerTeam team) const
|
||||
int SoccerWorld::getAttacker(KartTeam team) const
|
||||
{
|
||||
if (team == SOCCER_TEAM_BLUE && m_blue_kdm.size() > 1)
|
||||
if (team == KART_TEAM_BLUE && m_blue_kdm.size() > 1)
|
||||
{
|
||||
for (unsigned int i = 1; i < m_blue_kdm.size(); i++)
|
||||
{
|
||||
@@ -785,7 +785,7 @@ int SoccerWorld::getAttacker(SoccerTeam team) const
|
||||
return m_blue_kdm[i].m_kart_id;
|
||||
}
|
||||
}
|
||||
else if (team == SOCCER_TEAM_RED && m_red_kdm.size() > 1)
|
||||
else if (team == KART_TEAM_RED && m_red_kdm.size() > 1)
|
||||
{
|
||||
for (unsigned int i = 1; i < m_red_kdm.size(); i++)
|
||||
{
|
||||
@@ -801,7 +801,7 @@ int SoccerWorld::getAttacker(SoccerTeam team) const
|
||||
} // getAttacker
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int SoccerWorld::getTeamNum(SoccerTeam team) const
|
||||
int SoccerWorld::getTeamNum(KartTeam team) const
|
||||
{
|
||||
int total = 0;
|
||||
if (m_kart_team_map.empty()) return total;
|
||||
@@ -901,7 +901,7 @@ void SoccerWorld::enterRaceOverState()
|
||||
"Blue goal: %d, Blue own goal: %d", red_goal, red_own_goal,
|
||||
blue_goal, blue_own_goal);
|
||||
|
||||
if (getScore(SOCCER_TEAM_BLUE) >= m_goal_target)
|
||||
if (getScore(KART_TEAM_BLUE) >= m_goal_target)
|
||||
Log::verbose("Soccer AI profiling", "Blue team wins");
|
||||
else
|
||||
Log::verbose("Soccer AI profiling", "Red team wins");
|
||||
@@ -925,17 +925,17 @@ void SoccerWorld::setAITeam()
|
||||
int blue_player = 0;
|
||||
for (int i = 0; i < total_player; i++)
|
||||
{
|
||||
SoccerTeam team = race_manager->getKartInfo(i).getSoccerTeam();
|
||||
KartTeam team = race_manager->getKartInfo(i).getKartTeam();
|
||||
|
||||
// Happen in profiling mode
|
||||
if (team == SOCCER_TEAM_NONE)
|
||||
if (team == KART_TEAM_NONE)
|
||||
{
|
||||
race_manager->setKartSoccerTeam(i, SOCCER_TEAM_BLUE);
|
||||
team = SOCCER_TEAM_BLUE;
|
||||
race_manager->setKartTeam(i, KART_TEAM_BLUE);
|
||||
team = KART_TEAM_BLUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
team == SOCCER_TEAM_BLUE ? blue_player++ : red_player++;
|
||||
team == KART_TEAM_BLUE ? blue_player++ : red_player++;
|
||||
}
|
||||
|
||||
int available_ai = total_karts - red_player - blue_player;
|
||||
|
||||
@@ -177,12 +177,12 @@ private:
|
||||
m_blue_goal_slope = m_blue_goal_2.z() / m_blue_goal_2.x();
|
||||
} // updateBallAndGoal
|
||||
|
||||
bool isApproachingGoal(SoccerTeam team) const
|
||||
bool isApproachingGoal(KartTeam team) const
|
||||
{
|
||||
// If the ball lies between the first and last pos, and faces
|
||||
// in front of either of them, (inside angular size of goal)
|
||||
// than it's likely to goal
|
||||
if (team == SOCCER_TEAM_BLUE)
|
||||
if (team == KART_TEAM_BLUE)
|
||||
{
|
||||
if ((m_blue_goal_1.z() > 0.0f || m_blue_goal_3.z() > 0.0f) &&
|
||||
((m_blue_goal_1.x() < 0.0f && m_blue_goal_3.x() > 0.0f) ||
|
||||
@@ -199,7 +199,7 @@ private:
|
||||
return false;
|
||||
} // isApproachingGoal
|
||||
|
||||
Vec3 getAimPosition(SoccerTeam team, bool reverse) const
|
||||
Vec3 getAimPosition(KartTeam team, bool reverse) const
|
||||
{
|
||||
// If it's likely to goal already, aim the ball straight behind
|
||||
// should do the job
|
||||
@@ -218,7 +218,7 @@ private:
|
||||
// y = sqrt(2*m_radius*m2 / (1+m2))
|
||||
float x = 0.0f;
|
||||
float y = 0.0f;
|
||||
if (team == SOCCER_TEAM_BLUE)
|
||||
if (team == KART_TEAM_BLUE)
|
||||
{
|
||||
y = sqrt((m_blue_goal_slope * m_blue_goal_slope * m_radius*2) /
|
||||
(1 + (m_blue_goal_slope * m_blue_goal_slope)));
|
||||
@@ -284,7 +284,7 @@ private:
|
||||
std::vector<ScorerData> m_blue_scorers;
|
||||
std::vector<float> m_blue_score_times;
|
||||
|
||||
std::map<int, SoccerTeam> m_kart_team_map;
|
||||
std::map<int, KartTeam> m_kart_team_map;
|
||||
std::map<int, unsigned int> m_kart_position_map;
|
||||
|
||||
/** Data generated from navmesh */
|
||||
@@ -303,7 +303,7 @@ private:
|
||||
/** Function to update data for AI usage. */
|
||||
void updateAIData();
|
||||
/** Get number of teammates in a team, used by starting position assign. */
|
||||
int getTeamNum(SoccerTeam team) const;
|
||||
int getTeamNum(KartTeam team) const;
|
||||
|
||||
/** Profiling usage */
|
||||
int m_frame_count;
|
||||
@@ -351,20 +351,20 @@ public:
|
||||
bool getKartSoccerResult(unsigned int kart_id) const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Get the team of kart in soccer world (including AIs) */
|
||||
SoccerTeam getKartTeam(unsigned int kart_id) const;
|
||||
KartTeam getKartTeam(unsigned int kart_id) const;
|
||||
// ------------------------------------------------------------------------
|
||||
int getScore(SoccerTeam team) const
|
||||
int getScore(KartTeam team) const
|
||||
{
|
||||
return (int)(team == SOCCER_TEAM_BLUE ? m_blue_scorers.size()
|
||||
return (int)(team == KART_TEAM_BLUE ? m_blue_scorers.size()
|
||||
: m_red_scorers.size());
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
const std::vector<ScorerData>& getScorers(SoccerTeam team) const
|
||||
{ return (team == SOCCER_TEAM_BLUE ? m_blue_scorers : m_red_scorers); }
|
||||
const std::vector<ScorerData>& getScorers(KartTeam team) const
|
||||
{ return (team == KART_TEAM_BLUE ? m_blue_scorers : m_red_scorers); }
|
||||
// ------------------------------------------------------------------------
|
||||
const std::vector<float>& getScoreTimes(SoccerTeam team) const
|
||||
const std::vector<float>& getScoreTimes(KartTeam team) const
|
||||
{
|
||||
return (team == SOCCER_TEAM_BLUE ?
|
||||
return (team == KART_TEAM_BLUE ?
|
||||
m_blue_score_times : m_red_score_times);
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -385,24 +385,24 @@ public:
|
||||
float getBallDiameter() const
|
||||
{ return m_bgd.getDiameter(); }
|
||||
// ------------------------------------------------------------------------
|
||||
bool ballApproachingGoal(SoccerTeam team) const
|
||||
bool ballApproachingGoal(KartTeam team) const
|
||||
{ return m_bgd.isApproachingGoal(team); }
|
||||
// ------------------------------------------------------------------------
|
||||
Vec3 getBallAimPosition(SoccerTeam team, bool reverse = false) const
|
||||
Vec3 getBallAimPosition(KartTeam team, bool reverse = false) const
|
||||
{ return m_bgd.getAimPosition(team, reverse); }
|
||||
// ------------------------------------------------------------------------
|
||||
bool isCorrectGoal(unsigned int kart_id, bool first_goal) const;
|
||||
// ------------------------------------------------------------------------
|
||||
int getBallChaser(SoccerTeam team) const
|
||||
int getBallChaser(KartTeam team) const
|
||||
{
|
||||
// Only AI call this function, so each team should have at least a kart
|
||||
assert(m_blue_kdm.size() > 0 && m_red_kdm.size() > 0);
|
||||
return (team == SOCCER_TEAM_BLUE ? m_blue_kdm[0].m_kart_id :
|
||||
return (team == KART_TEAM_BLUE ? m_blue_kdm[0].m_kart_id :
|
||||
m_red_kdm[0].m_kart_id);
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Get the AI who will attack the other team ball chaser. */
|
||||
int getAttacker(SoccerTeam team) const;
|
||||
int getAttacker(KartTeam team) const;
|
||||
// ------------------------------------------------------------------------
|
||||
void setAITeam();
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -59,11 +59,11 @@ void GameSetup::update(bool remove_disconnected_players)
|
||||
for (uint8_t i = 0; i < (uint8_t)m_players.size(); i++)
|
||||
{
|
||||
bool disconnected = m_players[i].expired();
|
||||
if (race_manager->getKartInfo(i).getSoccerTeam() == SOCCER_TEAM_RED &&
|
||||
if (race_manager->getKartInfo(i).getKartTeam() == KART_TEAM_RED &&
|
||||
!disconnected)
|
||||
red_count++;
|
||||
else if (race_manager->getKartInfo(i).getSoccerTeam() ==
|
||||
SOCCER_TEAM_BLUE && !disconnected)
|
||||
else if (race_manager->getKartInfo(i).getKartTeam() ==
|
||||
KART_TEAM_BLUE && !disconnected)
|
||||
blue_count++;
|
||||
|
||||
if (!disconnected)
|
||||
@@ -227,6 +227,6 @@ void GameSetup::sortPlayersForSoccer()
|
||||
{
|
||||
auto player = m_players[i].lock();
|
||||
assert(player);
|
||||
player->setTeam((SoccerTeam)(i % 2));
|
||||
player->setTeam((KartTeam)(i % 2));
|
||||
}
|
||||
} // sortPlayersForSoccer
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <tuple>
|
||||
|
||||
class STKPeer;
|
||||
enum SoccerTeam : int8_t;
|
||||
enum KartTeam : int8_t;
|
||||
enum PerPlayerDifficulty : uint8_t;
|
||||
|
||||
/*! \class NetworkPlayerProfile
|
||||
@@ -66,14 +66,14 @@ private:
|
||||
/** Overall time if grand prix. */
|
||||
float m_overall_time;
|
||||
|
||||
SoccerTeam m_team;
|
||||
KartTeam m_team;
|
||||
|
||||
public:
|
||||
NetworkPlayerProfile(std::shared_ptr<STKPeer> peer,
|
||||
const irr::core::stringw &name, uint32_t host_id,
|
||||
float default_kart_color, uint32_t online_id,
|
||||
PerPlayerDifficulty per_player_difficulty,
|
||||
uint8_t local_player_id, SoccerTeam team)
|
||||
uint8_t local_player_id, KartTeam team)
|
||||
{
|
||||
m_peer = peer;
|
||||
m_player_name = name;
|
||||
@@ -131,9 +131,9 @@ public:
|
||||
m_overall_time = 0.0f;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void setTeam(SoccerTeam team) { m_team = team; }
|
||||
void setTeam(KartTeam team) { m_team = team; }
|
||||
// ------------------------------------------------------------------------
|
||||
SoccerTeam getTeam() const { return m_team; }
|
||||
KartTeam getTeam() const { return m_team; }
|
||||
|
||||
}; // class NetworkPlayerProfile
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ void ClientLobby::addAllPlayers(Event* event)
|
||||
uint32_t online_id = data.getUInt32();
|
||||
PerPlayerDifficulty ppd = (PerPlayerDifficulty)data.getUInt8();
|
||||
uint8_t local_id = data.getUInt8();
|
||||
SoccerTeam team = (SoccerTeam)data.getUInt8();
|
||||
KartTeam team = (KartTeam)data.getUInt8();
|
||||
auto player = std::make_shared<NetworkPlayerProfile>(peer, player_name,
|
||||
host_id, kart_color, online_id, ppd, local_id, team);
|
||||
std::string kart_name;
|
||||
@@ -606,11 +606,11 @@ void ClientLobby::updatePlayerList(Event* event)
|
||||
NetworkString& data = event->data();
|
||||
unsigned player_count = data.getUInt8();
|
||||
std::vector<std::tuple<uint32_t, uint32_t, uint32_t, core::stringw,
|
||||
int, SoccerTeam> > players;
|
||||
int, KartTeam> > players;
|
||||
for (unsigned i = 0; i < player_count; i++)
|
||||
{
|
||||
std::tuple<uint32_t, uint32_t, uint32_t, core::stringw, int,
|
||||
SoccerTeam> pl;
|
||||
KartTeam> pl;
|
||||
std::get<0>(pl) = data.getUInt32();
|
||||
std::get<1>(pl) = data.getUInt32();
|
||||
std::get<2>(pl) = data.getUInt8();
|
||||
@@ -621,7 +621,7 @@ void ClientLobby::updatePlayerList(Event* event)
|
||||
PerPlayerDifficulty d = (PerPlayerDifficulty)data.getUInt8();
|
||||
if (d == PLAYER_DIFFICULTY_HANDICAP)
|
||||
std::get<3>(pl) = _("%s (handicapped)", std::get<3>(pl));
|
||||
std::get<5>(pl) = (SoccerTeam)data.getUInt8();
|
||||
std::get<5>(pl) = (KartTeam)data.getUInt8();
|
||||
players.push_back(pl);
|
||||
}
|
||||
NetworkingLobby::getInstance()->updatePlayers(players);
|
||||
|
||||
@@ -122,7 +122,7 @@ void LobbyProtocol::configRemoteKart(
|
||||
rki.setPerPlayerDifficulty(profile->getPerPlayerDifficulty());
|
||||
rki.setOnlineId(profile->getOnlineId());
|
||||
if (race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
|
||||
rki.setSoccerTeam(profile->getTeam());
|
||||
rki.setKartTeam(profile->getTeam());
|
||||
// Inform the race manager about the data for this kart.
|
||||
race_manager->setPlayerKart(i, rki);
|
||||
} // for i in players
|
||||
|
||||
@@ -257,10 +257,10 @@ void ServerLobby::changeTeam(Event* event)
|
||||
NetworkString& data = event->data();
|
||||
uint8_t local_id = data.getUInt8();
|
||||
auto& player = event->getPeer()->getPlayerProfiles().at(local_id);
|
||||
if (player->getTeam() == SOCCER_TEAM_BLUE)
|
||||
player->setTeam(SOCCER_TEAM_RED);
|
||||
if (player->getTeam() == KART_TEAM_BLUE)
|
||||
player->setTeam(KART_TEAM_RED);
|
||||
else
|
||||
player->setTeam(SOCCER_TEAM_BLUE);
|
||||
player->setTeam(KART_TEAM_BLUE);
|
||||
updatePlayerList();
|
||||
} // changeTeam
|
||||
|
||||
@@ -813,9 +813,9 @@ void ServerLobby::startSelection(const Event *event)
|
||||
int blue_count = 0;
|
||||
for (auto& player : players)
|
||||
{
|
||||
if (player->getTeam() == SOCCER_TEAM_RED)
|
||||
if (player->getTeam() == KART_TEAM_RED)
|
||||
red_count++;
|
||||
else if (player->getTeam() == SOCCER_TEAM_BLUE)
|
||||
else if (player->getTeam() == KART_TEAM_BLUE)
|
||||
blue_count++;
|
||||
if (red_count != 0 && blue_count != 0)
|
||||
break;
|
||||
@@ -1531,10 +1531,10 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
|
||||
auto player = std::make_shared<NetworkPlayerProfile>
|
||||
(peer, i == 0 && !online_name.empty() ? online_name : name,
|
||||
peer->getHostId(), default_kart_color, i == 0 ? online_id : 0,
|
||||
per_player_difficulty, (uint8_t)i, SOCCER_TEAM_NONE);
|
||||
per_player_difficulty, (uint8_t)i, KART_TEAM_NONE);
|
||||
if (NetworkConfig::get()->hasTeamChoosing() &&
|
||||
race_manager->teamEnabled())
|
||||
player->setTeam((SoccerTeam)(peer->getHostId() % 2));
|
||||
player->setTeam((KartTeam)(peer->getHostId() % 2));
|
||||
peer->addPlayer(player);
|
||||
}
|
||||
|
||||
@@ -1598,7 +1598,7 @@ void ServerLobby::updatePlayerList(bool force_update)
|
||||
race_manager->teamEnabled())
|
||||
pl->addUInt8(profile->getTeam());
|
||||
else
|
||||
pl->addUInt8(SOCCER_TEAM_NONE);
|
||||
pl->addUInt8(KART_TEAM_NONE);
|
||||
}
|
||||
sendMessageToPeers(pl);
|
||||
delete pl;
|
||||
|
||||
@@ -26,11 +26,11 @@
|
||||
#include <vector>
|
||||
#include <irrString.h>
|
||||
|
||||
enum SoccerTeam : int8_t
|
||||
enum KartTeam : int8_t
|
||||
{
|
||||
SOCCER_TEAM_NONE=-1,
|
||||
SOCCER_TEAM_RED=0,
|
||||
SOCCER_TEAM_BLUE=1,
|
||||
KART_TEAM_NONE=-1,
|
||||
KART_TEAM_RED=0,
|
||||
KART_TEAM_BLUE=1,
|
||||
};
|
||||
|
||||
/** Game difficulty per player. */
|
||||
@@ -48,7 +48,7 @@ class RemoteKartInfo
|
||||
int m_local_player_id;
|
||||
int m_global_player_id;
|
||||
int m_host_id;
|
||||
SoccerTeam m_soccer_team;
|
||||
KartTeam m_kart_team;
|
||||
bool m_network_player;
|
||||
PerPlayerDifficulty m_difficulty;
|
||||
float m_default_kart_color;
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
bool network)
|
||||
: m_kart_name(kart_name), m_user_name(user_name),
|
||||
m_local_player_id(player_id), m_global_player_id(-1),
|
||||
m_host_id(host_id), m_soccer_team(SOCCER_TEAM_NONE),
|
||||
m_host_id(host_id), m_kart_team(KART_TEAM_NONE),
|
||||
m_network_player(network),
|
||||
m_difficulty(PLAYER_DIFFICULTY_NORMAL),
|
||||
m_default_kart_color(0.0f), m_online_id(0)
|
||||
@@ -67,13 +67,13 @@ public:
|
||||
RemoteKartInfo(const std::string& kart_name) : m_kart_name(kart_name),
|
||||
m_user_name(""), m_local_player_id(-1),
|
||||
m_global_player_id(-1), m_host_id(-1),
|
||||
m_soccer_team(SOCCER_TEAM_NONE), m_network_player(false),
|
||||
m_kart_team(KART_TEAM_NONE), m_network_player(false),
|
||||
m_difficulty(PLAYER_DIFFICULTY_NORMAL),
|
||||
m_default_kart_color(0.0f), m_online_id(0)
|
||||
{}
|
||||
RemoteKartInfo() : m_kart_name(""), m_user_name(""),
|
||||
m_local_player_id(-1), m_global_player_id(-1),
|
||||
m_host_id(-1), m_soccer_team(SOCCER_TEAM_NONE),
|
||||
m_host_id(-1), m_kart_team(KART_TEAM_NONE),
|
||||
m_network_player(false),
|
||||
m_difficulty(PLAYER_DIFFICULTY_NORMAL),
|
||||
m_default_kart_color(0.0f), m_online_id(0)
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
void setHostId(int id) { m_host_id = id; }
|
||||
void setLocalPlayerId(int id) { m_local_player_id = id; }
|
||||
void setGlobalPlayerId(int id) { m_global_player_id = id; }
|
||||
void setSoccerTeam(SoccerTeam team) { m_soccer_team = team; }
|
||||
void setKartTeam(KartTeam team) { m_kart_team = team; }
|
||||
void setNetworkPlayer(bool value) { m_network_player = value; }
|
||||
void setDefaultKartColor(float value) { m_default_kart_color = value; }
|
||||
void setPerPlayerDifficulty(PerPlayerDifficulty value)
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
bool isNetworkPlayer() const { return m_network_player; }
|
||||
const std::string& getKartName() const { return m_kart_name; }
|
||||
const irr::core::stringw& getPlayerName() const { return m_user_name; }
|
||||
SoccerTeam getSoccerTeam() const { return m_soccer_team; }
|
||||
KartTeam getKartTeam() const { return m_kart_team; }
|
||||
PerPlayerDifficulty getDifficulty() const { return m_difficulty; }
|
||||
float getDefaultKartColor() const { return m_default_kart_color; }
|
||||
uint32_t getOnlineId() const { return m_online_id; }
|
||||
|
||||
@@ -162,12 +162,12 @@ void RaceManager::setPlayerKart(unsigned int player_id,
|
||||
/** Sets additional information for a player to indicate which soccer team it
|
||||
* belongs to.
|
||||
*/
|
||||
void RaceManager::setKartSoccerTeam(unsigned int player_id, SoccerTeam team)
|
||||
void RaceManager::setKartTeam(unsigned int player_id, KartTeam team)
|
||||
{
|
||||
assert(player_id < m_player_karts.size());
|
||||
|
||||
m_player_karts[player_id].setSoccerTeam(team);
|
||||
} // setKartSoccerTeam
|
||||
m_player_karts[player_id].setKartTeam(team);
|
||||
} // setKartTeam
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets the per-player difficulty for a player.
|
||||
|
||||
@@ -370,9 +370,9 @@ public:
|
||||
void setPlayerKart(unsigned int player_id,
|
||||
const RemoteKartInfo& ki);
|
||||
|
||||
/** Sets additional information for a player to indicate which soccer team it belong to
|
||||
/** Sets additional information for a player to indicate which team it belong to
|
||||
*/
|
||||
void setKartSoccerTeam(unsigned int player_id, SoccerTeam team);
|
||||
void setKartTeam(unsigned int player_id, KartTeam team);
|
||||
|
||||
/** Sets the per-player difficulty for a player.
|
||||
*/
|
||||
|
||||
@@ -327,9 +327,9 @@ void NetworkingLobby::updatePlayerPings()
|
||||
continue;
|
||||
int id = m_player_list->getItemID(p.first);
|
||||
m_player_list->renameItem(id, name_with_ping, std::get<1>(p.second));
|
||||
if (std::get<2>(p.second) == SOCCER_TEAM_RED)
|
||||
if (std::get<2>(p.second) == KART_TEAM_RED)
|
||||
m_player_list->markItemRed(id);
|
||||
else if (std::get<2>(p.second) == SOCCER_TEAM_BLUE)
|
||||
else if (std::get<2>(p.second) == KART_TEAM_BLUE)
|
||||
m_player_list->markItemBlue(id);
|
||||
}
|
||||
} // updatePlayerPings
|
||||
@@ -426,7 +426,7 @@ bool NetworkingLobby::onEscapePressed()
|
||||
// ----------------------------------------------------------------------------
|
||||
void NetworkingLobby::updatePlayers(const std::vector<std::tuple<uint32_t,
|
||||
uint32_t, uint32_t, core::stringw,
|
||||
int, SoccerTeam> >& p)
|
||||
int, KartTeam> >& p)
|
||||
{
|
||||
// In GUI-less server this function will be called without proper
|
||||
// initialisation
|
||||
@@ -447,16 +447,16 @@ void NetworkingLobby::updatePlayers(const std::vector<std::tuple<uint32_t,
|
||||
m_player_list->setIcons(icon_bank);
|
||||
icon_bank = NULL;
|
||||
}
|
||||
SoccerTeam cur_team = std::get<5>(q);
|
||||
m_allow_change_team = cur_team != SOCCER_TEAM_NONE;
|
||||
KartTeam cur_team = std::get<5>(q);
|
||||
m_allow_change_team = cur_team != KART_TEAM_NONE;
|
||||
const std::string internal_name =
|
||||
StringUtils::toString(std::get<0>(q)) + "_" +
|
||||
StringUtils::toString(std::get<1>(q)) + "_" +
|
||||
StringUtils::toString(std::get<2>(q));
|
||||
m_player_list->addItem(internal_name, std::get<3>(q), std::get<4>(q));
|
||||
if (cur_team == SOCCER_TEAM_RED)
|
||||
if (cur_team == KART_TEAM_RED)
|
||||
m_player_list->markItemRed(i);
|
||||
else if (cur_team == SOCCER_TEAM_BLUE)
|
||||
else if (cur_team == KART_TEAM_BLUE)
|
||||
m_player_list->markItemBlue(i);
|
||||
m_player_names[internal_name] =
|
||||
std::make_tuple(std::get<3>(q), std::get<4>(q), cur_team);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <utility>
|
||||
|
||||
class Server;
|
||||
enum SoccerTeam : int8_t;
|
||||
enum KartTeam : int8_t;
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
NetworkingLobby();
|
||||
|
||||
float m_ping_update_timer;
|
||||
std::map<std::string, std::tuple<core::stringw, /*icon*/int, SoccerTeam> >
|
||||
std::map<std::string, std::tuple<core::stringw, /*icon*/int, KartTeam> >
|
||||
m_player_names;
|
||||
std::shared_ptr<Server> m_joined_server;
|
||||
std::vector<core::stringw> m_server_info;
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
void updatePlayers(const std::vector<std::tuple<uint32_t/*host id*/,
|
||||
uint32_t/*online id*/, uint32_t/*local player id*/,
|
||||
core::stringw/*player name*/, int/*icon id*/,
|
||||
SoccerTeam> >& p);
|
||||
KartTeam> >& p);
|
||||
void addSplitscreenPlayer(irr::core::stringw name);
|
||||
void cleanAddedPlayers();
|
||||
void initAutoStartTimer(bool grand_prix_started, float start_threshold,
|
||||
|
||||
@@ -337,7 +337,7 @@ void RaceGUI::drawScores()
|
||||
core::recti position(offset_x, offset_y,
|
||||
offset_x + 2*m_minimap_player_size, offset_y + 2*m_minimap_player_size);
|
||||
|
||||
core::stringw score = StringUtils::toWString(sw->getScore((SoccerTeam)i));
|
||||
core::stringw score = StringUtils::toWString(sw->getScore((KartTeam)i));
|
||||
int string_height =
|
||||
GUIEngine::getFont()->getDimension(score.c_str()).Height;
|
||||
core::recti pos(position.UpperLeftCorner.X + 5,
|
||||
|
||||
@@ -1054,8 +1054,8 @@ void RaceResultGUI::backToLobby()
|
||||
RowInfo *ri = &(m_all_row_infos[0]);
|
||||
int current_y = (int)ri->m_y_pos;
|
||||
SoccerWorld* sw = (SoccerWorld*)World::getWorld();
|
||||
const int red_score = sw->getScore(SOCCER_TEAM_RED);
|
||||
const int blue_score = sw->getScore(SOCCER_TEAM_BLUE);
|
||||
const int red_score = sw->getScore(KART_TEAM_RED);
|
||||
const int blue_score = sw->getScore(KART_TEAM_BLUE);
|
||||
|
||||
GUIEngine::Widget *table_area = getWidget("result-table");
|
||||
int height = table_area->m_h + table_area->m_y;
|
||||
@@ -1117,12 +1117,12 @@ void RaceResultGUI::backToLobby()
|
||||
//The red scorers:
|
||||
current_y += rect.Height / 2 + rect.Height / 4;
|
||||
font = GUIEngine::getSmallFont();
|
||||
std::vector<SoccerWorld::ScorerData> scorers = sw->getScorers(SOCCER_TEAM_RED);
|
||||
std::vector<SoccerWorld::ScorerData> scorers = sw->getScorers(KART_TEAM_RED);
|
||||
while (scorers.size() > 10)
|
||||
{
|
||||
scorers.erase(scorers.begin());
|
||||
}
|
||||
std::vector<float> score_times = sw->getScoreTimes(SOCCER_TEAM_RED);
|
||||
std::vector<float> score_times = sw->getScoreTimes(KART_TEAM_RED);
|
||||
while (score_times.size() > 10)
|
||||
{
|
||||
score_times.erase(score_times.begin());
|
||||
@@ -1177,12 +1177,12 @@ void RaceResultGUI::backToLobby()
|
||||
//The blue scorers:
|
||||
current_y = prev_y;
|
||||
current_x += UserConfigParams::m_width / 2 - red_icon->getSize().Width / 2;
|
||||
scorers = sw->getScorers(SOCCER_TEAM_BLUE);
|
||||
scorers = sw->getScorers(KART_TEAM_BLUE);
|
||||
while (scorers.size() > 10)
|
||||
{
|
||||
scorers.erase(scorers.begin());
|
||||
}
|
||||
score_times = sw->getScoreTimes(SOCCER_TEAM_BLUE);
|
||||
score_times = sw->getScoreTimes(KART_TEAM_BLUE);
|
||||
while (score_times.size() > 10)
|
||||
{
|
||||
score_times.erase(score_times.begin());
|
||||
|
||||
@@ -100,14 +100,14 @@ void SoccerSetupScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
{
|
||||
if (m_kart_view_info.size() == 1)
|
||||
{
|
||||
changeTeam(0, SOCCER_TEAM_RED);
|
||||
changeTeam(0, KART_TEAM_RED);
|
||||
}
|
||||
}
|
||||
else if (name == "blue_team")
|
||||
{
|
||||
if (m_kart_view_info.size() == 1)
|
||||
{
|
||||
changeTeam(0, SOCCER_TEAM_BLUE);
|
||||
changeTeam(0, KART_TEAM_BLUE);
|
||||
}
|
||||
}
|
||||
} // eventCallback
|
||||
@@ -149,15 +149,15 @@ void SoccerSetupScreen::beforeAddingWidget()
|
||||
KartViewInfo info;
|
||||
|
||||
int single_team = UserConfigParams::m_soccer_default_team;
|
||||
info.team = (nb_players == 1 ? (SoccerTeam)single_team :
|
||||
(i&1 ? SOCCER_TEAM_BLUE : SOCCER_TEAM_RED));
|
||||
info.team = (nb_players == 1 ? (KartTeam)single_team :
|
||||
(i&1 ? KART_TEAM_BLUE : KART_TEAM_RED));
|
||||
|
||||
// addModel requires loading the RenderInfo first
|
||||
info.support_colorization = kart_model.supportColorization();
|
||||
if (info.support_colorization)
|
||||
{
|
||||
kart_view->getModelViewRenderInfo()->setHue
|
||||
(info.team == SOCCER_TEAM_BLUE ? 0.66f : 1.0f);
|
||||
(info.team == KART_TEAM_BLUE ? 0.66f : 1.0f);
|
||||
}
|
||||
|
||||
core::matrix4 model_location;
|
||||
@@ -198,7 +198,7 @@ void SoccerSetupScreen::beforeAddingWidget()
|
||||
info.view = kart_view;
|
||||
info.confirmed = false;
|
||||
m_kart_view_info.push_back(info);
|
||||
race_manager->setKartSoccerTeam(i, info.team);
|
||||
race_manager->setKartTeam(i, info.team);
|
||||
}
|
||||
|
||||
// Update layout
|
||||
@@ -265,9 +265,9 @@ void SoccerSetupScreen::tearDown()
|
||||
Screen::tearDown();
|
||||
} // tearDown
|
||||
|
||||
void SoccerSetupScreen::changeTeam(int player_id, SoccerTeam team)
|
||||
void SoccerSetupScreen::changeTeam(int player_id, KartTeam team)
|
||||
{
|
||||
if (team == SOCCER_TEAM_NONE)
|
||||
if (team == KART_TEAM_NONE)
|
||||
return;
|
||||
|
||||
if (team == m_kart_view_info[player_id].team)
|
||||
@@ -276,7 +276,7 @@ void SoccerSetupScreen::changeTeam(int player_id, SoccerTeam team)
|
||||
// Change the kart color
|
||||
if (m_kart_view_info[player_id].support_colorization)
|
||||
{
|
||||
const float hue = team == SOCCER_TEAM_RED ? 1.0f : 0.66f;
|
||||
const float hue = team == KART_TEAM_RED ? 1.0f : 0.66f;
|
||||
m_kart_view_info[player_id].view->getModelViewRenderInfo()
|
||||
->setHue(hue);
|
||||
}
|
||||
@@ -291,7 +291,7 @@ void SoccerSetupScreen::changeTeam(int player_id, SoccerTeam team)
|
||||
UserConfigParams::m_soccer_default_team = (int)team;
|
||||
}
|
||||
|
||||
race_manager->setKartSoccerTeam(player_id, team);
|
||||
race_manager->setKartTeam(player_id, team);
|
||||
m_kart_view_info[player_id].team = team;
|
||||
updateKartViewsLayout();
|
||||
}
|
||||
@@ -322,7 +322,7 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action
|
||||
bubble->isFocusedForPlayer(PLAYER_ID_GAME_MASTER))
|
||||
{
|
||||
if (m_kart_view_info[playerId].confirmed == false)
|
||||
changeTeam(playerId, SOCCER_TEAM_RED);
|
||||
changeTeam(playerId, KART_TEAM_RED);
|
||||
|
||||
return EVENT_BLOCK;
|
||||
}
|
||||
@@ -332,7 +332,7 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action
|
||||
bubble->isFocusedForPlayer(PLAYER_ID_GAME_MASTER))
|
||||
{
|
||||
if (m_kart_view_info[playerId].confirmed == false)
|
||||
changeTeam(playerId, SOCCER_TEAM_BLUE);
|
||||
changeTeam(playerId, KART_TEAM_BLUE);
|
||||
|
||||
return EVENT_BLOCK;
|
||||
}
|
||||
@@ -490,7 +490,7 @@ void SoccerSetupScreen::updateKartViewsLayout()
|
||||
for(int i=0 ; i < nb_players ; i++)
|
||||
{
|
||||
const KartViewInfo& view_info = m_kart_view_info[i];
|
||||
const SoccerTeam team = view_info.team;
|
||||
const KartTeam team = view_info.team;
|
||||
|
||||
// Compute the position
|
||||
const int cur_row = cur_kart_per_team[team] / nb_columns;
|
||||
|
||||
@@ -39,10 +39,10 @@ class SoccerSetupScreen : public GUIEngine::Screen,
|
||||
GUIEngine::ModelViewWidget* view;
|
||||
bool confirmed;
|
||||
bool support_colorization;
|
||||
SoccerTeam team;
|
||||
KartTeam team;
|
||||
|
||||
KartViewInfo() : view(), confirmed(false), support_colorization(false),
|
||||
team(SOCCER_TEAM_NONE) {}
|
||||
team(KART_TEAM_NONE) {}
|
||||
};
|
||||
|
||||
AlignedArray<KartViewInfo> m_kart_view_info;
|
||||
@@ -82,7 +82,7 @@ private:
|
||||
bool areAllKartsConfirmed() const;
|
||||
int getNumConfirmedKarts();
|
||||
void updateKartViewsLayout();
|
||||
void changeTeam(int player_id, SoccerTeam team);
|
||||
void changeTeam(int player_id, KartTeam team);
|
||||
void prepareGame();
|
||||
};
|
||||
|
||||
|
||||
@@ -718,8 +718,8 @@ void Track::loadArenaGraph(const XMLNode &node)
|
||||
for (unsigned i = 0; i < pk; i++)
|
||||
{
|
||||
if (!race_manager->getKartInfo(i).isNetworkPlayer() &&
|
||||
race_manager->getKartInfo(i).getSoccerTeam() ==
|
||||
SOCCER_TEAM_BLUE)
|
||||
race_manager->getKartInfo(i).getKartTeam() ==
|
||||
KART_TEAM_BLUE)
|
||||
{
|
||||
m_minimap_invert_x_z = true;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user