Merge branch 'removeLocalPlayerInfo'

This commit is contained in:
hiker 2016-01-12 13:15:36 +11:00
commit 409862dbe2
30 changed files with 277 additions and 338 deletions

View File

@ -369,7 +369,7 @@ void ChallengeData::setRace(RaceManager::Difficulty d) const
race_manager->setTrack(m_track_id);
race_manager->setNumLaps(m_num_laps);
race_manager->setNumKarts(m_num_karts[d]);
race_manager->setNumLocalPlayers(1);
race_manager->setNumPlayers(1);
race_manager->setCoinTarget(m_energy[d]);
race_manager->setDifficulty(d);
@ -384,7 +384,7 @@ void ChallengeData::setRace(RaceManager::Difficulty d) const
race_manager->setGrandPrix(*grand_prix_manager->getGrandPrix(m_gp_id));
race_manager->setDifficulty(d);
race_manager->setNumKarts(m_num_karts[d]);
race_manager->setNumLocalPlayers(1);
race_manager->setNumPlayers(1);
}
if (m_ai_kart_ident[d] != "")

View File

@ -32,6 +32,8 @@ Controller::Controller(AbstractKart *kart, StateManager::ActivePlayer *player)
m_controls = &(kart->getControls());
m_kart = kart;
m_player = player;
if(player)
player->setKart(kart);
setControllerName("Controller");
} // Controller

View File

@ -41,6 +41,11 @@ class Material;
*/
class Controller
{
private:
/** If this belongs to a player, it stores the active player data
* structure. Otherwise it is 0. */
StateManager::ActivePlayer *m_player;
protected:
/** Pointer to the kart that is controlled by this controller. */
AbstractKart *m_kart;
@ -49,10 +54,6 @@ protected:
* it commands. */
KartControl *m_controls;
/** If this belongs to a player, it stores the active player data
* structure. Otherwise it is 0. */
StateManager::ActivePlayer *m_player;
/** The name of the controller, mainly used for debugging purposes. */
std::string m_controller_name;

View File

@ -90,7 +90,7 @@ public:
/** Returns if the original controller of the kart was a player
* controller. This way e.g. highscores can still be assigned
* to the right player. */
virtual bool isPlayerController () const {return m_player!=NULL;}
virtual bool isPlayerController () const {return getPlayer()!=NULL;}
virtual void action (PlayerAction action, int value);
virtual void newLap (int lap);

View File

@ -40,11 +40,9 @@
PlayerController::PlayerController(AbstractKart *kart,
StateManager::ActivePlayer *player)
: Controller(kart)
: Controller(kart, player)
{
assert(player != NULL);
m_player = player;
m_player->setKart(kart);
m_penalty_time = 0.0f;
} // PlayerController

View File

@ -466,12 +466,13 @@ void setupRaceStart()
Log::warn("main", "Kart '%s' is unknown so will use the "
"default kart.",
UserConfigParams::m_default_kart.c_str());
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart.getDefaultValue());
race_manager->setPlayerKart(0,
UserConfigParams::m_default_kart.getDefaultValue());
}
else
{
// Set up race manager appropriately
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
}
// ASSIGN should make sure that only input from assigned devices
@ -836,7 +837,7 @@ int handleCmdLine()
// up upon player creation.
if (StateManager::get()->activePlayerCount() > 0)
{
race_manager->setLocalKartInfo(0, s);
race_manager->setPlayerKart(0, s);
}
Log::verbose("main", "You chose to use kart '%s'.",
s.c_str());
@ -1187,7 +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);

View File

@ -421,7 +421,6 @@ void CutsceneWorld::enterRaceOverState()
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumLocalPlayers(0);
race_manager->startSingleRace("featunlocked", 999, race_manager->raceWasStartedFromOverworld());
FeatureUnlockedCutScene* scene =
@ -474,7 +473,6 @@ void CutsceneWorld::enterRaceOverState()
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumLocalPlayers(0);
race_manager->startSingleRace("featunlocked", 999, race_manager->raceWasStartedFromOverworld());
FeatureUnlockedCutScene* scene =

View File

@ -50,8 +50,8 @@ DemoWorld::DemoWorld()
race_manager->setMinorMode (RaceManager::MINOR_MODE_NORMAL_RACE);
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
race_manager->setNumKarts(m_num_karts);
race_manager->setNumLocalPlayers(1);
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
race_manager->setNumPlayers(1);
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
} // DemoWorld
@ -137,7 +137,7 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt)
}
StateManager::get()->enterGameState();
race_manager->setNumLocalPlayers(1);
race_manager->setNumPlayers(1);
InputDevice *device;
// Use keyboard 0 by default in --no-start-screen
@ -150,7 +150,7 @@ bool DemoWorld::updateIdleTimeAndStartDemo(float dt)
m_do_demo = true;
race_manager->setNumKarts(m_num_karts);
race_manager->setLocalKartInfo(0, "tux");
race_manager->setPlayerKart(0, "tux");
race_manager->setupPlayerKartInfo();
race_manager->startSingleRace(m_demo_tracks[0], m_num_laps, false);
m_demo_tracks.push_back(m_demo_tracks[0]);

View File

@ -56,7 +56,7 @@ OverWorld::~OverWorld()
/** Function to simplify the start process */
void OverWorld::enterOverWorld()
{
race_manager->setNumLocalPlayers(1);
race_manager->setNumPlayers(1);
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode (RaceManager::MINOR_MODE_OVERWORLD);
race_manager->setNumKarts( 1 );
@ -78,7 +78,7 @@ void OverWorld::enterOverWorld()
UserConfigParams::m_default_kart.revertToDefaults();
}
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
// ASSIGN should make sure that only input from assigned devices
// is read.

View File

@ -41,7 +41,7 @@ bool ProfileWorld::m_no_graphics = false;
*/
ProfileWorld::ProfileWorld()
{
race_manager->setNumLocalPlayers(0);
race_manager->setNumPlayers(0);
// Set number of laps so that the end of the race can be detected by
// quering the number of finished karts from the race manager (in laps
// based profiling) - in case of time based profiling, the number of

View File

@ -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;
}

View File

@ -861,7 +861,7 @@ void World::updateWorld(float dt)
if (m_schedule_tutorial)
{
m_schedule_tutorial = false;
race_manager->setNumLocalPlayers(1);
race_manager->setNumPlayers(1);
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
race_manager->setNumKarts( 1 );
@ -883,7 +883,7 @@ void World::updateWorld(float dt)
UserConfigParams::m_default_kart.c_str());
UserConfigParams::m_default_kart.revertToDefaults();
}
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
// ASSIGN should make sure that only input from assigned devices
// is read.

View File

@ -29,8 +29,9 @@
GameSetup::GameSetup()
{
m_race_config = new RaceConfig();
m_local_master = 0;
m_race_config = new RaceConfig();
m_num_local_players = 0;
m_local_master = 0;
} // GameSetup
//-----------------------------------------------------------------------------

View File

@ -46,6 +46,9 @@ private:
/** The race configuration. */
RaceConfig* m_race_config;
/** Stores the number of local players. */
int m_num_local_players;
/** The player id of the local game master, used in
* kart selection screen. */
uint8_t m_local_master;
@ -69,6 +72,12 @@ public:
*/
bool isKartAvailable(std::string kart_name);
// ------------------------------------------------------------------------
/** Sets the number of local players. */
void setNumLocalPlayers(int n) { m_num_local_players = n; }
// ------------------------------------------------------------------------
/** Returns the nunber of local players. */
int getNumLocalPlayers() const { return m_num_local_players; }
// ------------------------------------------------------------------------
/*! \brief Used to know if a kart is playable.
* \param kart_name : Name of the kart to check.
* \return True if the kart is playable (standard kart).

View File

@ -42,6 +42,9 @@ private:
* peer list. */
uint8_t m_global_player_id;
/** Host id of this player. */
uint8_t m_host_id;
/** The selected kart id. */
std::string m_kart_name;
@ -65,6 +68,12 @@ public:
/** Returns the global ID of this player in this race. */
int getGlobalPlayerId() const { return m_global_player_id; }
// ------------------------------------------------------------------------
/** Sets the host id of this player. */
void setHostId(int host_id) { m_host_id = host_id; }
// ------------------------------------------------------------------------
/** Returns the host id of this player. */
uint8_t getHostId() const { return m_host_id; }
// ------------------------------------------------------------------------
/** Sets the kart name for this player. */
void setKartName(const std::string &kart_name) { m_kart_name = kart_name; }
// ------------------------------------------------------------------------

View File

@ -375,17 +375,17 @@ void ClientLobbyRoomProtocol::disconnectedPlayer(Event* event)
* \param event : Event providing the information.
*
* Format of the data :
* Byte 0 1 2 3 7 8
* ---------------------------------------------------------
* Size | 1 | 1 | 1 | 4 | |
* Data | 1 | 0 <= race id < 16 | 4 | priv token | playernames* |
* ---------------------------------------------------------
* Byte 0 1 2 3 7 8
* ------------------------------------------------------------------
* Size | 1 | 1 | 1 | 4 | 1 | |
* Data | 1 | 0 <= race id < 16 | 4 | priv token | hostid | playernames* |
* ------------------------------------------------------------------
*/
void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
{
NetworkString &data = event->data();
// At least 12 bytes should remain now
if (data.size() < 7|| data[0] != 1 || data[2] != 4)
if (data.size() < 8|| data[0] != 1 || data[2] != 4)
{
Log::error("ClientLobbyRoomProtocol",
"A message notifying an accepted connection wasn't "
@ -406,8 +406,13 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
else
name = PlayerManager::getCurrentPlayer()->getName();
uint8_t my_player_id = data.getUInt8(1);
uint8_t my_host_id = data.getUInt8(7);
STKHost::get()->setMyHostId(my_host_id);
NetworkPlayerProfile* profile = new NetworkPlayerProfile(my_player_id, name);
profile->setHostId(my_host_id);
STKHost::get()->getGameSetup()->setLocalMaster(my_player_id);
m_setup->setNumLocalPlayers(1);
m_setup->addPlayer(profile);
// connection token
uint32_t token = data.gui32(3);
@ -417,21 +422,22 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
// Add all players
// ===============
int n = 7;
int n = 8;
while (n < data.size())
{
if (data[n] != 1 )
Log::error("ClientLobbyRoomProtocol",
"Bad format in players list.");
uint8_t race_player_id = data[n + 1];
uint8_t player_id = data[n + 1];
irr::core::stringw name;
int bytes_read = data.decodeStringW(n + 2, &name);
uint8_t host_id = data.getUInt8(n+2+bytes_read);
NetworkPlayerProfile* profile2 =
new NetworkPlayerProfile(race_player_id, name);
new NetworkPlayerProfile(player_id, name);
m_setup->addPlayer(profile2);
n += bytes_read+2;
n += bytes_read+3;
// Inform the network lobby of all players so that the GUI can
// show all currently connected players.
NetworkingLobby::getInstance()->addPlayer(profile2);

View File

@ -58,6 +58,7 @@ ServerLobbyRoomProtocol::~ServerLobbyRoomProtocol()
void ServerLobbyRoomProtocol::setup()
{
m_setup = STKHost::get()->setupNewGame();
m_setup->setNumLocalPlayers(0); // no local players on a server
m_next_player_id.setAtomic(0);
// In case of LAN we don't need our public address or register with the
@ -455,12 +456,14 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
if(m_setup->getLocalMasterID()==0)
m_setup->setLocalMaster(new_player_id);
int new_host_id = STKHost::get()->getPeerCount();
// Notify everybody that there is a new player
// -------------------------------------------
NetworkString message(8);
// size of id -- id -- size of local id -- local id;
message.ai8(LE_NEW_PLAYER_CONNECTED).ai8(1).ai8(new_player_id)
.encodeString(name_u8);
.encodeString(name_u8).addUInt8(new_host_id);
ProtocolManager::getInstance()->sendMessageExcept(this, peer, message);
// Now answer to the peer that just connected
@ -478,17 +481,19 @@ void ServerLobbyRoomProtocol::connectionRequested(Event* event)
NetworkString message_ack(13 + players.size() * 7);
// connection success -- size of token -- token
message_ack.ai8(LE_CONNECTION_ACCEPTED).ai8(1).ai8(new_player_id).ai8(4)
.ai32(token);
.ai32(token).addUInt8(new_host_id);
// Add all players so that this user knows (this new player is only added
// to the list of players later, so the new player's info is not included)
for (unsigned int i = 0; i < players.size(); i++)
{
message_ack.ai8(1).ai8(players[i]->getGlobalPlayerId())
.encodeString(players[i]->getName());
.encodeString(players[i]->getName())
.addUInt8(players[i]->getHostId());
}
sendMessage(peer, message_ack);
NetworkPlayerProfile* profile = new NetworkPlayerProfile(new_player_id, name);
profile->setHostId(new_host_id);
m_setup->addPlayer(profile);
peer->setPlayerProfile(profile);
peer->setClientServerToken(token);

View File

@ -59,33 +59,36 @@ void StartGameProtocol::setup()
// ---------------------
// builds it and starts
NetworkWorld::getInstance<NetworkWorld>()->start();
// The number of karts includes the AI karts, which are not supported atn
race_manager->setNumKarts(m_game_setup->getPlayerCount());
race_manager->setNumPlayers(m_game_setup->getPlayerCount());
race_manager->setNumLocalPlayers(1);
// Set number of global and local players.
race_manager->setNumPlayers(m_game_setup->getPlayerCount(),
m_game_setup->getNumLocalPlayers());
// Create the kart information for the race manager:
// -------------------------------------------------
std::vector<NetworkPlayerProfile*> players = m_game_setup->getPlayers();
int local_player_id = 0;
for (unsigned int i = 0; i < players.size(); i++)
{
NetworkPlayerProfile* profile = players[i];
bool is_me = profile->getGlobalPlayerId()
== STKHost::get()->getGameSetup()->getLocalMasterID();
bool is_local = profile->getHostId()
== STKHost::get()->getMyHostId();
RemoteKartInfo rki(profile->getGlobalPlayerId(),
profile->getKartName(),
profile->getName(),
/*hostid*/profile->getGlobalPlayerId(),
!is_me);
profile->getHostId(),
!is_local);
rki.setPerPlayerDifficulty(profile->getPerPlayerDifficulty());
rki.setLocalPlayerId(0);
// FIXME: for now (only one local player) the global player id
// can be used as host id.
rki.setHostId(profile->getGlobalPlayerId());
rki.setLocalPlayerId(local_player_id);
if(is_local) local_player_id++;
// Inform the race manager about the data for this kart.
race_manager->setPlayerKart(i, rki);
if(is_me)
if(is_local)
{
PlayerProfile* profile_to_use = PlayerManager::getCurrentPlayer();
assert(profile_to_use);
@ -103,10 +106,10 @@ void StartGameProtocol::setup()
StateManager::get()->getActivePlayer(new_player_id);
device->setPlayer(ap);
input_manager->getDeviceManager()->setSinglePlayer(ap);
race_manager->setLocalKartInfo(new_player_id,
profile->getKartName());
race_manager->setPlayerKart(new_player_id,
profile->getKartName());
NetworkWorld::getInstance()->setSelfKart(profile->getKartName());
} // if is_me
} // if is_local
else
{
StateManager::get()->createActivePlayer( NULL, NULL );

View File

@ -215,6 +215,9 @@ void STKHost::create()
*/
STKHost::STKHost(uint32_t server_id, uint32_t host_id)
{
// Will be overwritten with the correct value once a connection with the
// server is made.
m_host_id = 0;
init();
m_network = new Network(/*peer_count*/1, /*channel_limit*/2,
@ -236,6 +239,7 @@ STKHost::STKHost(uint32_t server_id, uint32_t host_id)
STKHost::STKHost(const irr::core::stringw &server_name)
{
init();
m_host_id = 0; // indicates a server host.
ENetAddress addr;
addr.host = STKHost::HOST_ANY;

View File

@ -74,6 +74,9 @@ private:
/** The list of peers connected to this instance. */
std::vector<STKPeer*> m_peers;
/** Host id of this host. */
uint8_t m_host_id;
/** Stores data about the online game to play. */
GameSetup* m_game_setup;
@ -197,7 +200,6 @@ public:
// --------------------------------------------------------------------
/** Returns a const reference to the list of peers. */
const std::vector<STKPeer*> &getPeers() { return m_peers; }
// --------------------------------------------------------------------
/** Returns the number of currently connected peers. */
unsigned int getPeerCount() { return (int)m_peers.size(); }
@ -214,6 +216,12 @@ public:
return m_is_registered;
} // isRegistered
// --------------------------------------------------------------------
/** Sets the global host id of this host. */
void setMyHostId(uint8_t my_host_id) { m_host_id = my_host_id; }
// --------------------------------------------------------------------
/** Returns the host id of this host. */
uint8_t getMyHostId() const { return m_host_id; }
// --------------------------------------------------------------------
}; // class STKHost
#endif // STK_HOST_HPP

View File

@ -264,7 +264,7 @@ void History::Load()
fgets(s, 1023, fd);
if(sscanf(s, "numplayers: %d",&n)!=1)
Log::fatal("History", "No number of players found in history file.");
race_manager->setNumLocalPlayers(n);
race_manager->setNumPlayers(n);
fgets(s, 1023, fd);
if(sscanf(s, "difficulty: %d",&n)!=1)
@ -297,7 +297,7 @@ void History::Load()
m_kart_ident.push_back(s1);
if(i<race_manager->getNumPlayers())
{
race_manager->setLocalKartInfo(i, s1);
race_manager->setPlayerKart(i, s1);
}
} // for i<nKarts
// FIXME: The model information is currently ignored

View File

@ -77,7 +77,7 @@ RaceManager::RaceManager()
setReverseTrack(false);
setTrack("jungle");
m_default_ai_list.clear();
setNumLocalPlayers(0);
setNumPlayers(0);
} // RaceManager
//-----------------------------------------------------------------------------
@ -89,7 +89,8 @@ RaceManager::~RaceManager()
//-----------------------------------------------------------------------------
/** Resets the race manager in preparation for a new race. It sets the
* counter of finished karts to zero.
* counter of finished karts to zero. It is called by world when
* restarting a race.
*/
void RaceManager::reset()
{
@ -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,33 +127,36 @@ void RaceManager::setDefaultAIKartList(const std::vector<std::string>& ai_list)
}
} // setDefaultAIKartList
// ----------------------------------------------------------------------------
/** Sets information about a kart used by a local player (i.e. on this
* computer).
* \param player_id Id of this player.
* \param kart The kart this player uses.
//-----------------------------------------------------------------------------
/** \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::setLocalKartInfo(unsigned int player_id,
const std::string& kart)
void RaceManager::setPlayerKart(unsigned int player_id, const RemoteKartInfo& ki)
{
assert(kart.size() > 0);
assert(player_id <m_local_player_karts.size());
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(),
0, false);
} // setLocalKartInfo
m_player_karts[player_id] = ki;
} // setPlayerKart
// ----------------------------------------------------------------------------
void RaceManager::setPlayerKart(unsigned int player_id,
const std::string &kart_name)
{
const PlayerProfile* profile =
StateManager::get()->getActivePlayerProfile(player_id);
RemoteKartInfo rki(player_id, kart_name, profile->getName(), 0, false);
m_player_karts[player_id] = rki;
} // setPlayerKart
//-----------------------------------------------------------------------------
/** Sets additional information for a player to indicate which soccer team it belong to
/** Sets additional information for a player to indicate which soccer team it
* belongs 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 +164,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.
@ -205,22 +199,17 @@ int RaceManager::getLocalPlayerGPRank(const int player_id) const
} // getLocalPlayerGPRank
//-----------------------------------------------------------------------------
/** Sets the number of local players, i.e. the number of players on this
* computer.
* \param n Number of local players.
*/
void RaceManager::setNumLocalPlayers(unsigned int n)
{
m_local_player_karts.resize(n);
} // setNumLocalPlayers
//-----------------------------------------------------------------------------
/** Sets the number of players.
/** Sets the number of players and optional the number of local players.
* \param num Number of players.
* \param local_players Number of local players, only used from networking.
*/
void RaceManager::setNumPlayers(int num)
void RaceManager::setNumPlayers(int players, int local_players)
{
m_player_karts.resize(num);
m_player_karts.resize(players);
if(local_players>-1)
m_num_local_players = local_players;
else
m_num_local_players = players;
} // setNumPlayers
// ----------------------------------------------------------------------------
@ -307,7 +296,16 @@ void RaceManager::computeRandomKartList()
} // computeRandomKartList
//-----------------------------------------------------------------------------
/** \brief Starts a new race or GP (or other mode).
* It sets up the list of player karts, AI karts, GP tracks if relevant
* etc.
* \pre The list of AI karts to use must be set up first. This is
* usually being done by a call to computeRandomKartList() from
* NetworkManager::setupPlayerKartInfo, but could be done differently
* (e.g. depending on user command line options to test certain AIs)
* \param from_overworld True if the race/GP is started from overworld
* (used to return to overworld at end of race/GP).
*/
void RaceManager::startNew(bool from_overworld)
{
m_started_from_overworld = from_overworld;
@ -384,8 +382,8 @@ void RaceManager::startNew(bool from_overworld)
}
}
// Then the players, which start behind the AI karts
// -------------------------------------------------
// Then add the players, which start behind the AI karts
// -----------------------------------------------------
for(unsigned int i = 0; i < m_player_karts.size(); i++)
{
KartType kt= m_player_karts[i].isNetworkPlayer() ? KT_NETWORK_PLAYER
@ -545,6 +543,10 @@ void RaceManager::startNextRace()
} // startNextRace
//-----------------------------------------------------------------------------
/** \brief Start the next race or go back to the start screen
* If there are more races to do, starts the next race, otherwise
* calls exitRace to finish the race.
*/
void RaceManager::next()
{
PropertyAnimator::get()->clear();
@ -568,6 +570,8 @@ void RaceManager::next()
} // next
//-----------------------------------------------------------------------------
/** Saves the current GP to the config.
*/
void RaceManager::saveGP()
{
// If Player 1 has already saved a GP, we adapt it
@ -698,7 +702,10 @@ void RaceManager::computeGPRanks()
} // computeGPRanks
//-----------------------------------------------------------------------------
/** \brief Exit a race (and don't start the next one)
* \note In GP, displays the GP result screen first
* \param delete_world If set deletes the world.
*/
void RaceManager::exitRace(bool delete_world)
{
// Only display the grand prix result screen if all tracks
@ -713,7 +720,7 @@ void RaceManager::exitRace(bool delete_world)
}
StateManager::get()->resetAndGoToScreen( MainMenuScreen::getInstance() );
bool someHumanPlayerWon = false;
bool some_human_player_won = false;
const unsigned int kart_status_count = (unsigned int)m_kart_status.size();
const int loserThreshold = 3;
@ -735,7 +742,7 @@ void RaceManager::exitRace(bool delete_world)
if (m_kart_status[i].m_kart_type == KT_PLAYER ||
m_kart_status[i].m_kart_type == KT_NETWORK_PLAYER)
{
someHumanPlayerWon = true;
some_human_player_won = true;
}
}
else if (rank >= loserThreshold)
@ -759,9 +766,8 @@ void RaceManager::exitRace(bool delete_world)
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumLocalPlayers(0);
if (someHumanPlayerWon)
if (some_human_player_won)
{
race_manager->startSingleRace("gpwin", 999, race_manager->raceWasStartedFromOverworld());
GrandPrixWin* scene = GrandPrixWin::getInstance();
@ -835,7 +841,10 @@ void RaceManager::kartFinishedRace(const AbstractKart *kart, float time)
} // kartFinishedRace
//-----------------------------------------------------------------------------
/** \brief Rerun the same race again
* This is called after a race is finished, and it will adjust
* the number of points and the overall time before restarting the race.
*/
void RaceManager::rerunRace()
{
// Subtract last score from all karts:
@ -848,7 +857,9 @@ void RaceManager::rerunRace()
} // rerunRace
//-----------------------------------------------------------------------------
/** \brief Higher-level method to start a GP without having to care about
* the exact startup sequence
*/
void RaceManager::startGP(const GrandPrixData &gp, bool from_overworld,
bool continue_saved_gp)
{
@ -884,33 +895,13 @@ 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()
*/
/** Fills up the remaining kart slots with AI karts.
v*/
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));
// 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++)
{
kart_info[i].setGlobalPlayerId(i);
setPlayerKart(i, kart_info[i]);
}
computeRandomKartList();
} // setupPlayerKartInfo

View File

@ -56,14 +56,12 @@ static const std::string IDENT_CUTSCENE ("CUTSCENE" );
* manager stores the GP information, but World queries only track
* and number of laps, so in case of GP this information is taken from
* the GrandPrix object), and local player information (number of local
* players, and selected karts). The local player information is read
* from the NetworkManager, gathered on the server (from all clients and
* the server, see NetworkManager::setupPlayerKartInfo), and then the
* combined information distributed to all RaceManagers in all clients
* and server. Even in no networking mode, the data flow is the same:
* information about local players is stored here, then processed by
* NetworkManager::setupPlayerKartInfo and the 'global' information about
* player karts is set in the RaceManager, to be used by World later on.
* players, and selected karts).
* Information about player karts (which player selected which kart,
* player ids) is stored in a RemoteKartInfo structure and used later
* to initialise the KartStatus array (startNew()). The KartStatus array
* stores information about all karts (player and AI), and is used to
* determine the order in which karts are started (see startNextRace()).
* 2) when a race is started, it creates the world, and keeps track of
* score during the race. When a race is finished, it deletes the world,
* and (depending on race mode) starts the next race by creating a new
@ -302,10 +300,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;
@ -354,35 +354,19 @@ public:
RaceManager();
~RaceManager();
/** Resets the race manager. It is called by world when restarting a race.
*/
void reset();
/**
* \{
* \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 std::string &kart_name);
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.
*/
void setPlayerDifficulty(unsigned int player_id, PerPlayerDifficulty difficulty);
/** Sets the number of local players playing on this computer (including
* split screen).
* \param n Number of local players.
*/
void setNumLocalPlayers(unsigned int n);
/** In case of non GP mode set the track to use.
* \param track Pointer to the track to use.
*/
@ -398,11 +382,6 @@ public:
* doesn't exist */
int getLocalPlayerGPRank(const int playerID) const;
bool hasTimeTarget() const { return m_has_time_target; }
void setMaxGoal(int maxGoal){ m_goal_target = maxGoal; }
int getMaxGoal(){ return m_goal_target; }
/** Sort karts and update the m_gp_rank KartStatus member, in preparation
* for future calls to RaceManager::getKartGPRank or
@ -415,86 +394,103 @@ public:
*/
void setDifficulty(Difficulty diff);
static Difficulty convertDifficulty(const std::string &difficulty);
void startNew(bool from_overworld);
void next();
void rerunRace();
void exitRace(bool delete_world=true);
void startGP(const GrandPrixData &gp, bool from_overworld,
bool continue_saved_gp);
void saveGP();
void startSingleRace(const std::string &track_ident, const int num_laps,
bool from_overworld);
void setupPlayerKartInfo();
void kartFinishedRace(const AbstractKart* kart, float time);
void setNumPlayers(int players, int local_players=-1);
void setDefaultAIKartList(const std::vector<std::string> &ai_list);
void computeRandomKartList();
// ------------------------------------------------------------------------
void setCoinTarget(int num) { m_coin_target = num; }
bool hasTimeTarget() const { return m_has_time_target; }
// ------------------------------------------------------------------------
void setMaxGoal(int maxGoal){ m_goal_target = maxGoal; }
// ------------------------------------------------------------------------
int getMaxGoal(){ return m_goal_target; }
// ------------------------------------------------------------------------
void setCoinTarget(int num) { m_coin_target = num; }
// ------------------------------------------------------------------------
void setGrandPrix(const GrandPrixData &gp)
{
m_grand_prix = gp;
setCoinTarget(0);
}
} // setGrandPrix
// ------------------------------------------------------------------------
void setAIKartOverride(const std::string& kart)
{
m_ai_kart_override = kart;
}
} // setAIKartOverride
// ------------------------------------------------------------------------
void setAISuperPower(AISuperPower superpower)
{
m_ai_superpower = superpower;
}
} // setAISuperPower
// ------------------------------------------------------------------------
AISuperPower getAISuperPower() const { return m_ai_superpower; }
// ------------------------------------------------------------------------
void setNumLaps(int num) {
void setNumLaps(int num)
{
m_num_laps.clear();
m_num_laps.push_back(num);
}
} // setNumLaps
// ------------------------------------------------------------------------
void setReverseTrack(bool r_t)
{
m_reverse_track.clear();
m_reverse_track.push_back(r_t);
}
} // setReverseTrack
// ------------------------------------------------------------------------
void setMajorMode(MajorRaceModeType mode) { m_major_mode = mode; }
void setMajorMode(MajorRaceModeType mode) { m_major_mode = mode; }
// ------------------------------------------------------------------------
void setMinorMode(MinorRaceModeType mode) { m_minor_mode = mode;
m_has_time_target = false; }
void setMinorMode(MinorRaceModeType mode)
{
m_minor_mode = mode;
m_has_time_target = false;
} // setMinorMode
// ------------------------------------------------------------------------
void setNumKarts(int num)
{
m_num_karts = num;
m_ai_kart_override = "";
m_ai_superpower = SUPERPOWER_NONE;
}
} // setNumKarts
// ------------------------------------------------------------------------
void setTimeTarget(float num) { m_has_time_target = true;
m_time_target = num; }
/** \} */
// ------------------------------------------------------------------------
/** \{
* \name Getters
* Get current race manager state and settings
*/
const RemoteKartInfo& getLocalKartInfo(unsigned int n) const
void setTimeTarget(float num)
{
return m_local_player_karts[n];
}
m_has_time_target = true;
m_time_target = num;
} // setTimeTarget
// ------------------------------------------------------------------------
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. */
unsigned int getNumberOfKarts() const {return m_num_karts; }
// ------------------------------------------------------------------------
MajorRaceModeType getMajorMode() const { return m_major_mode; }
// ------------------------------------------------------------------------
MinorRaceModeType getMinorMode() const { return m_minor_mode; }
// ------------------------------------------------------------------------
unsigned int getNumPlayers() const { return (unsigned int) m_player_karts.size(); }
unsigned int getNumPlayers() const
{
return (unsigned int) m_player_karts.size();
} // getNumPlayers
// ------------------------------------------------------------------------
/** \brief Returns the number lf laps.
* In case of FTL or battle mode always return 9999, since they don't
@ -502,10 +498,10 @@ public:
* would be set (otherwise we would need many more tests in calls to
* getNumLaps).
*/
int getNumLaps() const
int getNumLaps() const
{
if(m_minor_mode==MINOR_MODE_3_STRIKES ||
m_minor_mode==MINOR_MODE_FOLLOW_LEADER )
m_minor_mode==MINOR_MODE_FOLLOW_LEADER )
return 9999;
return m_num_laps[m_track_number];
} // getNumLaps
@ -541,49 +537,49 @@ public:
int getKartGPRank(const int kart_id)const
{
return m_kart_status[kart_id].m_gp_rank;
}
} // getKartGPRank
// ------------------------------------------------------------------------
const std::string& getKartIdent(int kart) const
{
return m_kart_status[kart].m_ident;
}
} // getKartIdent
// ------------------------------------------------------------------------
int getKartScore(int krt) const { return m_kart_status[krt].m_score; }
// ------------------------------------------------------------------------
int getKartPrevScore(int krt) const
{
return m_kart_status[krt].m_last_score;
}
} // getKartPrevScore
// ------------------------------------------------------------------------
int getKartLocalPlayerId(int k) const
{
return m_kart_status[k].m_local_player_id;
}
} // getKartLocalPlayerId
// ------------------------------------------------------------------------
int getKartGlobalPlayerId(int k) const
{
return m_kart_status[k].m_global_player_id;
}
} // getKartGlobalPlayerId
// ------------------------------------------------------------------------
float getOverallTime(int kart) const
{
return m_kart_status[kart].m_overall_time;
}
} // getOverallTime
// ------------------------------------------------------------------------
float getKartRaceTime(int kart) const
{
return m_kart_status[kart].m_last_time;
}
} // getKartRaceTime
// ------------------------------------------------------------------------
KartType getKartType(int kart) const
{
return m_kart_status[kart].m_kart_type;
}
} // getKartType
// ------------------------------------------------------------------------
PerPlayerDifficulty getPlayerDifficulty(int kart) const
{
return m_kart_status[kart].m_difficulty;
}
} // getPlayerDifficulty
// ------------------------------------------------------------------------
int getCoinTarget() const { return m_coin_target; }
// ------------------------------------------------------------------------
@ -592,14 +588,14 @@ public:
int getTrackNumber() const { return m_track_number; }
// ------------------------------------------------------------------------
/** Returns the list of AI karts to use. Used for networking, and for
* the --ai= command line option. */
* the --ai= command line option. */
const std::vector<std::string>& getAIKartList() const
{
return m_ai_kart_list;
}
} // getAIKartList
// ------------------------------------------------------------------------
/** \brief get information about given mode (returns true if 'mode' is of
* linear races type) */
* linear races type) */
bool isLinearRaceMode()
{
const int id = (int)m_minor_mode;
@ -608,7 +604,6 @@ public:
if(id > 999 && id < 2000) return true;
else return false;
} // isLinearRaceMode
// ------------------------------------------------------------------------
/** \brief Returns true if the current mode is a battle mode. */
bool isBattleMode()
@ -621,12 +616,10 @@ public:
} // isBattleMode
// ------------------------------------------------------------------------
bool isTutorialMode()
{
return m_minor_mode == MINOR_MODE_TUTORIAL;
}
} // isTutorialMode
// ------------------------------------------------------------------------
/** \brief Returns true if the current mode has laps. */
bool modeHasLaps()
@ -649,132 +642,50 @@ public:
m_minor_mode != MINOR_MODE_SOCCER &&
m_minor_mode != MINOR_MODE_FOLLOW_LEADER;
} // modeHasHighscore
/** \} */
// ------------------------------------------------------------------------
/**
* \{
* \name Controlling race
* Start, stop, continue, restart races
*/
/**
* \brief Starts a new race or GP (or other mode).
* It sets up the list of player karts, AI karts, GP tracks if relevant
* etc.
* \pre The list of AI karts to use must be set up first. This is
* usually being done by a call to computeRandomKartList() from
* NetworkManager::setupPlayerKartInfo, but could be done differently
* (e.g. depending on user command line options to test certain AIs)
*/
void startNew(bool from_overworld);
/** \brief Start the next race or go back to the start screen
* If there are more races to do, starts the next race, otherwise
* calls exitRace to finish the race.
*/
void next();
/** \brief Rerun the same race again
* This is called after a race is finished, and it will adjust
* the number of points and the overall time before restarting the race.
*/
void rerunRace();
/** \brief Exit a race (and don't start the next one)
* \note In GP, displays the GP result screen first
* \note Deletes the world.
*/
void exitRace(bool delete_world=true);
/**
* \brief Higher-level method to start a GP without having to care about
* the exact startup sequence
*/
void startGP(const GrandPrixData &gp, bool from_overworld,
bool continue_saved_gp);
/** Saves the current GP to the config */
void saveGP();
/**
* \brief Higher-level method to start a GP without having to care about
* the exact startup sequence.
* \param trackIdent Internal name of the track to race on
* \param num_laps Number of laps to race, or -1 if number of laps is
* not relevant in current mode
*/
void startSingleRace(const std::string &track_ident, const int num_laps,
bool from_overworld);
/** Receive and store the information from sendKartsInformation()
*/
void setupPlayerKartInfo();
bool raceWasStartedFromOverworld() const
{
return m_started_from_overworld;
}
} // raceWasStartedFromOverworld
/** \} */
// ------------------------------------------------------------------------
/**
* \{
* \name Callbacks from the race classes
* These methods are to be used by the classes that manage the various
* races, to let the race manager know about current status
*/
/** \name Callbacks from the race classes
* These methods are to be used by the classes that manage the various
* races, to let the race manager know about current status
*/
bool allPlayerFinished() const
{
return m_num_finished_players == m_player_karts.size();
}
} // allPlayerFinished
// ------------------------------------------------------------------------
void kartFinishedRace(const AbstractKart* kart, float time);
/** \} */
/**
* \{
* \name For internal use
* Functions for internal use by RaceManager or its close friends;
* You shouldn't need to call any of those from higher-level code.
*/
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
* that will be used by the server to the client. It will take precedence
* over the random selection. */
void setAIKartList(const std::vector<std::string>& rkl)
{
m_ai_kart_list = rkl;
}
/** \} */
} // setAIKartList
// ------------------------------------------------------------------------
bool haveKartLastPositionOnOverworld()
{
return m_have_kart_last_position_on_overworld;
}
} // haveKartLastPositionOnOverworld
// ------------------------------------------------------------------------
void setKartLastPositionOnOverworld(Vec3 pos)
void setKartLastPositionOnOverworld(const Vec3 &pos)
{
m_have_kart_last_position_on_overworld = true;
m_kart_last_position_on_overworld = pos;
}
} // setKartLastPositionOnOverworld
// ------------------------------------------------------------------------
void clearKartLastPositionOnOverworld()
{
m_have_kart_last_position_on_overworld = false;
}
} // clearKartLastPositionOnOverworld
// ------------------------------------------------------------------------
Vec3 getKartLastPositionOnOverworld()
{
return m_kart_last_position_on_overworld;
}
} // getKartLastPositionOnOverworld
}; // RaceManager

View File

@ -190,8 +190,8 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin
assert(device != NULL);
// Set up race manager appropriately
race_manager->setNumLocalPlayers(1);
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
race_manager->setNumPlayers(1);
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
race_manager->setReverseTrack(false);
//int id = StateManager::get()->createActivePlayer( unlock_manager->getCurrentPlayer(), device );

View File

@ -55,7 +55,7 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i
{
if (name == "startTutorial")
{
race_manager->setNumLocalPlayers(1);
race_manager->setNumPlayers(1);
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
race_manager->setNumKarts( 1 );
@ -76,7 +76,7 @@ void HelpScreen1::eventCallback(Widget* widget, const std::string& name, const i
UserConfigParams::m_default_kart.c_str());
UserConfigParams::m_default_kart.revertToDefaults();
}
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
// ASSIGN should make sure that only input from assigned devices
// is read.

View File

@ -1131,14 +1131,11 @@ void KartSelectionScreen::allPlayersDone()
->incrementUseFrequency();
}
// ---- Give player info to race manager
race_manager->setNumLocalPlayers( players.size() );
race_manager->setNumPlayers(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
@ -1197,7 +1194,7 @@ void KartSelectionScreen::allPlayersDone()
}
}
race_manager->setLocalKartInfo(n, selected_kart);
race_manager->setPlayerKart(n, selected_kart);
// Set per player difficulty if needed
if (m_multiplayer && UserConfigParams::m_per_player_difficulty &&

View File

@ -414,7 +414,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
}
else if (selection == "startTutorial")
{
race_manager->setNumLocalPlayers(1);
race_manager->setNumPlayers(1);
race_manager->setMajorMode (RaceManager::MAJOR_MODE_SINGLE);
race_manager->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL);
race_manager->setNumKarts( 1 );
@ -435,7 +435,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
UserConfigParams::m_default_kart.c_str());
UserConfigParams::m_default_kart.revertToDefaults();
}
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
// ASSIGN should make sure that only input from assigned devices
// is read.
@ -457,7 +457,6 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts( 0 );
race_manager->setNumPlayers(0);
race_manager->setNumLocalPlayers(0);
race_manager->startSingleRace("introcutscene", 999, false);
std::vector<std::string> parts;

View File

@ -293,7 +293,6 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts( 0 );
race_manager->setNumPlayers(0);
race_manager->setNumLocalPlayers(0);
race_manager->startSingleRace("endcutscene", 999, false);
std::vector<std::string> parts;
@ -311,7 +310,6 @@ void RaceResultGUI::eventCallback(GUIEngine::Widget* widget,
race_manager->setMinorMode(RaceManager::MINOR_MODE_CUTSCENE);
race_manager->setNumKarts(0);
race_manager->setNumPlayers(0);
race_manager->setNumLocalPlayers(0);
race_manager->startSingleRace("featunlocked", 999, race_manager->raceWasStartedFromOverworld());
FeatureUnlockedCutScene* scene =

View File

@ -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();
}

View File

@ -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;