Removed m_local_player_karts data structure in RaceManager.
This commit is contained in:
parent
6ffe0cc995
commit
e46c47d5c9
@ -1188,6 +1188,7 @@ void initRest()
|
||||
race_manager = new RaceManager ();
|
||||
// default settings for Quickstart
|
||||
race_manager->setNumLocalPlayers(1);
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setNumLaps (3);
|
||||
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
|
||||
race_manager->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
|
||||
|
@ -335,7 +335,7 @@ void SoccerWorld::initKartList()
|
||||
{
|
||||
scene::ISceneNode *arrowNode;
|
||||
float arrow_pos_height = m_karts[i]->getKartModel()->getHeight()+0.5f;
|
||||
SoccerTeam team = race_manager->getLocalKartInfo(i).getSoccerTeam();
|
||||
SoccerTeam team = race_manager->getKartInfo(i).getSoccerTeam();
|
||||
|
||||
arrowNode = irr_driver->addBillboard(core::dimension2d<irr::f32>(0.3f,0.3f),
|
||||
team==SOCCER_TEAM_RED ? redTeamTexture : blueTeamTexture,
|
||||
@ -353,7 +353,7 @@ void SoccerWorld::initKartList()
|
||||
// Set kart positions, ordering them by team
|
||||
for(unsigned int n=0; n<kart_amount; n++)
|
||||
{
|
||||
SoccerTeam team = race_manager->getLocalKartInfo(n).getSoccerTeam();
|
||||
SoccerTeam team = race_manager->getKartInfo(n).getSoccerTeam();
|
||||
#ifdef DEBUG
|
||||
// In debug mode it's possible to play soccer with a single player
|
||||
// (in artist debug mode). Avoid overwriting memory in this case.
|
||||
@ -375,7 +375,7 @@ int SoccerWorld::getTeamLeader(unsigned int team)
|
||||
{
|
||||
for(unsigned int i = 0; i< m_karts.size(); i++)
|
||||
{
|
||||
if(race_manager->getLocalKartInfo(i).getSoccerTeam() == (SoccerTeam) team)
|
||||
if(race_manager->getKartInfo(i).getSoccerTeam() == (SoccerTeam) team)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
@ -390,7 +390,7 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
|
||||
int posIndex = index;
|
||||
int position = index+1;
|
||||
|
||||
if(race_manager->getLocalKartInfo(index).getSoccerTeam() == SOCCER_TEAM_RED)
|
||||
if(race_manager->getKartInfo(index).getSoccerTeam() == SOCCER_TEAM_RED)
|
||||
{
|
||||
if(index % 2 != 1) posIndex += 1;
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ RaceManager::RaceManager()
|
||||
setTrack("jungle");
|
||||
m_default_ai_list.clear();
|
||||
setNumLocalPlayers(0);
|
||||
setNumPlayers(0);
|
||||
} // RaceManager
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -97,16 +98,6 @@ void RaceManager::reset()
|
||||
m_num_finished_players = 0;
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** \brief Sets a player kart (local and non-local).
|
||||
* \param player_id Id of the player.
|
||||
* \param ki Kart info structure for this player.
|
||||
*/
|
||||
void RaceManager::setPlayerKart(unsigned int player_id, const RemoteKartInfo& ki)
|
||||
{
|
||||
m_player_karts[player_id] = ki;
|
||||
} // setPlayerKart
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Sets the default list of AI karts to use.
|
||||
* \param ai_kart_list List of the identifier of the karts to use.
|
||||
@ -136,6 +127,16 @@ void RaceManager::setDefaultAIKartList(const std::vector<std::string>& ai_list)
|
||||
}
|
||||
} // setDefaultAIKartList
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** \brief Sets a player kart (local and non-local).
|
||||
* \param player_id Id of the player.
|
||||
* \param ki Kart info structure for this player.
|
||||
*/
|
||||
void RaceManager::setPlayerKart(unsigned int player_id, const RemoteKartInfo& ki)
|
||||
{
|
||||
m_player_karts[player_id] = ki;
|
||||
} // setPlayerKart
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Sets information about a kart used by a local player (i.e. on this
|
||||
* computer).
|
||||
@ -146,23 +147,23 @@ void RaceManager::setLocalKartInfo(unsigned int player_id,
|
||||
const std::string& kart)
|
||||
{
|
||||
assert(kart.size() > 0);
|
||||
assert(player_id <m_local_player_karts.size());
|
||||
assert(player_id <getNumLocalPlayers());
|
||||
assert(kart_properties_manager->getKart(kart) != NULL);
|
||||
|
||||
const PlayerProfile* profile = StateManager::get()->getActivePlayerProfile(player_id);
|
||||
m_local_player_karts[player_id] = RemoteKartInfo(player_id, kart, profile->getName(),
|
||||
m_player_karts[player_id] = RemoteKartInfo(player_id, kart, profile->getName(),
|
||||
0, false);
|
||||
} // setLocalKartInfo
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets additional information for a player to indicate which soccer team it belong to
|
||||
*/
|
||||
void RaceManager::setLocalKartSoccerTeam(unsigned int player_id, SoccerTeam team)
|
||||
void RaceManager::setKartSoccerTeam(unsigned int player_id, SoccerTeam team)
|
||||
{
|
||||
assert(player_id < m_local_player_karts.size());
|
||||
assert(player_id < m_player_karts.size());
|
||||
|
||||
m_local_player_karts[player_id].setSoccerTeam(team);
|
||||
}
|
||||
m_player_karts[player_id].setSoccerTeam(team);
|
||||
} // setKartSoccerTeam
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets the per-player difficulty for a player.
|
||||
@ -170,10 +171,10 @@ void RaceManager::setLocalKartSoccerTeam(unsigned int player_id, SoccerTeam team
|
||||
void RaceManager::setPlayerDifficulty(unsigned int player_id,
|
||||
PerPlayerDifficulty difficulty)
|
||||
{
|
||||
assert(player_id < m_local_player_karts.size());
|
||||
assert(player_id < m_player_karts.size());
|
||||
|
||||
m_local_player_karts[player_id].setPerPlayerDifficulty(difficulty);
|
||||
}
|
||||
m_player_karts[player_id].setPerPlayerDifficulty(difficulty);
|
||||
} // setPlayerDifficulty
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Returns a pointer to the kart which has a given GP rank.
|
||||
@ -211,7 +212,7 @@ int RaceManager::getLocalPlayerGPRank(const int player_id) const
|
||||
*/
|
||||
void RaceManager::setNumLocalPlayers(unsigned int n)
|
||||
{
|
||||
m_local_player_karts.resize(n);
|
||||
m_num_local_players = n;
|
||||
} // setNumLocalPlayers
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -884,26 +885,22 @@ void RaceManager::startSingleRace(const std::string &track_ident,
|
||||
race_manager->setupPlayerKartInfo(); // do this setup player kart
|
||||
|
||||
startNew(from_overworld);
|
||||
}
|
||||
} // startSingleRace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Receive and store the information from sendKartsInformation()
|
||||
*/
|
||||
void RaceManager::setupPlayerKartInfo()
|
||||
{
|
||||
|
||||
std::vector<RemoteKartInfo> kart_info;
|
||||
|
||||
// Get the local kart info
|
||||
for(unsigned int i=0; i<getNumLocalPlayers(); i++)
|
||||
kart_info.push_back(getLocalKartInfo(i));
|
||||
for(unsigned int i=0; i<getNumPlayers(); i++)
|
||||
kart_info.push_back(getKartInfo(i));
|
||||
|
||||
// Now sort by (hostid, playerid)
|
||||
std::sort(kart_info.begin(), kart_info.end());
|
||||
|
||||
// Set the player kart information
|
||||
setNumPlayers((int)kart_info.size());
|
||||
|
||||
// Set the global player ID for each player
|
||||
for(unsigned int i=0; i<kart_info.size(); i++)
|
||||
{
|
||||
|
@ -302,10 +302,12 @@ private:
|
||||
MinorRaceModeType m_minor_mode;
|
||||
/** Stores remote kart information about all player karts. */
|
||||
std::vector<RemoteKartInfo> m_player_karts;
|
||||
std::vector<RemoteKartInfo> m_local_player_karts;
|
||||
std::vector<std::string> m_tracks;
|
||||
std::vector<int> m_host_ids;
|
||||
|
||||
/** Number of local players. */
|
||||
unsigned int m_num_local_players;
|
||||
|
||||
/** The number of laps for each track of a GP (only one element
|
||||
* is used if only a single track is used. */
|
||||
std::vector<int> m_num_laps;
|
||||
@ -363,15 +365,13 @@ public:
|
||||
* \name Setting race parameters
|
||||
*/
|
||||
|
||||
/** \brief Stores the information which local players uses which karts.
|
||||
* \param player_id Id of the local player for which the kart is set.
|
||||
* \param kart Kart name this player is using.
|
||||
*/
|
||||
void setLocalKartInfo(unsigned int player_id, const std::string& kart);
|
||||
void setPlayerKart(unsigned int player_id,
|
||||
const RemoteKartInfo& ki);
|
||||
|
||||
/** Sets additional information for a player to indicate which soccer team it belong to
|
||||
*/
|
||||
void setLocalKartSoccerTeam(unsigned int player_id, SoccerTeam team);
|
||||
void setKartSoccerTeam(unsigned int player_id, SoccerTeam team);
|
||||
|
||||
/** Sets the per-player difficulty for a player.
|
||||
*/
|
||||
@ -465,25 +465,16 @@ public:
|
||||
m_time_target = num; }
|
||||
/** \} */
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** \{
|
||||
* \name Getters
|
||||
* Get current race manager state and settings
|
||||
*/
|
||||
const RemoteKartInfo& getLocalKartInfo(unsigned int n) const
|
||||
{
|
||||
return m_local_player_karts[n];
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
const RemoteKartInfo& getKartInfo(unsigned int n) const
|
||||
{
|
||||
return m_player_karts[n];
|
||||
}
|
||||
} // getKartInfo
|
||||
// ------------------------------------------------------------------------
|
||||
unsigned int getNumLocalPlayers() const
|
||||
{
|
||||
return (unsigned int)m_local_player_karts.size();
|
||||
}
|
||||
return m_num_local_players;
|
||||
} // getNumLocalPlayers
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the selected number of karts (selected number of players and
|
||||
* AI karts. */
|
||||
@ -741,8 +732,6 @@ public:
|
||||
*/
|
||||
void setNumPlayers(int num);
|
||||
|
||||
void setPlayerKart(unsigned int player_id,
|
||||
const RemoteKartInfo& ki);
|
||||
void setDefaultAIKartList(const std::vector<std::string> &ai_list);
|
||||
void computeRandomKartList();
|
||||
/** Sets the AI to use. This is used in networking mode to set the karts
|
||||
|
@ -1131,14 +1131,12 @@ void KartSelectionScreen::allPlayersDone()
|
||||
->incrementUseFrequency();
|
||||
}
|
||||
// ---- Give player info to race manager
|
||||
race_manager->setNumPlayers(players.size());
|
||||
race_manager->setNumLocalPlayers( players.size() );
|
||||
|
||||
// ---- Manage 'random kart' selection(s)
|
||||
RandomGenerator random;
|
||||
|
||||
//m_kart_widgets.clearAndDeleteAll();
|
||||
//race_manager->setLocalKartInfo(0, w->getSelectionIDString());
|
||||
|
||||
std::vector<ItemDescription> items = w->getItems();
|
||||
|
||||
// remove the 'random' item itself
|
||||
|
@ -137,10 +137,10 @@ void SoccerSetupScreen::beforeAddingWidget()
|
||||
label_vs->m_h = vs_height;
|
||||
|
||||
// Add the 3D views for the karts
|
||||
int nb_players = race_manager->getNumLocalPlayers();
|
||||
int nb_players = race_manager->getNumPlayers();
|
||||
for(int i=0 ; i < nb_players ; i++)
|
||||
{
|
||||
const RemoteKartInfo& kart_info = race_manager->getLocalKartInfo(i);
|
||||
const RemoteKartInfo& kart_info = race_manager->getKartInfo(i);
|
||||
const std::string& kart_name = kart_info.getKartName();
|
||||
|
||||
const KartProperties* props = kart_properties_manager->getKart(kart_name);
|
||||
@ -176,10 +176,9 @@ void SoccerSetupScreen::beforeAddingWidget()
|
||||
KartViewInfo info;
|
||||
info.view = kart_view;
|
||||
info.confirmed = false;
|
||||
info.local_player_id = i;
|
||||
info.team = i&1 ? SOCCER_TEAM_BLUE : SOCCER_TEAM_RED;
|
||||
m_kart_view_info.push_back(info);
|
||||
race_manager->setLocalKartSoccerTeam(i, info.team);
|
||||
race_manager->setKartSoccerTeam(i, info.team);
|
||||
}
|
||||
|
||||
// Update layout
|
||||
@ -353,7 +352,7 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action
|
||||
|
||||
if(team_switch != SOCCER_TEAM_NONE) // A player wants to change his team?
|
||||
{
|
||||
race_manager->setLocalKartSoccerTeam(playerId, team_switch);
|
||||
race_manager->setKartSoccerTeam(playerId, team_switch);
|
||||
m_kart_view_info[playerId].team = team_switch;
|
||||
updateKartViewsLayout();
|
||||
}
|
||||
|
@ -37,10 +37,9 @@ class SoccerSetupScreen : public GUIEngine::Screen, public GUIEngine::ScreenSing
|
||||
{
|
||||
GUIEngine::ModelViewWidget* view;
|
||||
bool confirmed;
|
||||
int local_player_id;
|
||||
SoccerTeam team;
|
||||
|
||||
KartViewInfo() : view(NULL), confirmed(false), local_player_id(-1), team(SOCCER_TEAM_NONE) {}
|
||||
KartViewInfo() : view(NULL), confirmed(false), team(SOCCER_TEAM_NONE) {}
|
||||
};
|
||||
|
||||
AlignedArray<KartViewInfo> m_kart_view_info;
|
||||
|
Loading…
Reference in New Issue
Block a user