Replaced setLocalKartInfo with setPlayerKart. Updated some docs.
This commit is contained in:
parent
6816b08af1
commit
e7dd7f4d1a
@ -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());
|
||||
|
@ -51,7 +51,7 @@ DemoWorld::DemoWorld()
|
||||
race_manager->setDifficulty(RaceManager::DIFFICULTY_HARD);
|
||||
race_manager->setNumKarts(m_num_karts);
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
|
||||
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
|
||||
|
||||
} // DemoWorld
|
||||
|
||||
@ -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]);
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -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).
|
||||
|
@ -412,6 +412,7 @@ void ClientLobbyRoomProtocol::connectionAccepted(Event* event)
|
||||
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);
|
||||
|
@ -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
|
||||
|
@ -59,12 +59,13 @@ 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());
|
||||
// setNumPlayers by default sets number of local players to
|
||||
// number of players - so avoid this to keep the original number:
|
||||
race_manager->setNumPlayers(1,
|
||||
/*local players*/race_manager->getNumLocalPlayers());
|
||||
|
||||
// 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:
|
||||
// -------------------------------------------------
|
||||
@ -105,8 +106,8 @@ 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_local
|
||||
else
|
||||
|
@ -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
|
||||
|
@ -138,22 +138,14 @@ void RaceManager::setPlayerKart(unsigned int player_id, const RemoteKartInfo& ki
|
||||
} // setPlayerKart
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** 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.
|
||||
*/
|
||||
void RaceManager::setLocalKartInfo(unsigned int player_id,
|
||||
const std::string& kart)
|
||||
void RaceManager::setPlayerKart(unsigned int player_id,
|
||||
const std::string &kart_name)
|
||||
{
|
||||
assert(kart.size() > 0);
|
||||
assert(player_id <getNumLocalPlayers());
|
||||
assert(kart_properties_manager->getKart(kart) != NULL);
|
||||
|
||||
const PlayerProfile* profile = StateManager::get()->getActivePlayerProfile(player_id);
|
||||
m_player_karts[player_id] = RemoteKartInfo(player_id, kart, profile->getName(),
|
||||
0, false);
|
||||
} // setLocalKartInfo
|
||||
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
|
||||
@ -209,7 +201,7 @@ int RaceManager::getLocalPlayerGPRank(const int player_id) const
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets the number of players and optional the number of local players.
|
||||
* \param num Number of players.
|
||||
* \param local_players
|
||||
* \param local_players Number of local players, only used from networking.
|
||||
*/
|
||||
void RaceManager::setNumPlayers(int players, int local_players)
|
||||
{
|
||||
@ -390,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
|
||||
@ -906,26 +898,10 @@ void RaceManager::startSingleRace(const std::string &track_ident,
|
||||
} // 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<getNumPlayers(); i++)
|
||||
kart_info.push_back(getKartInfo(i));
|
||||
|
||||
// Now sort by (hostid, playerid)
|
||||
std::sort(kart_info.begin(), kart_info.end());
|
||||
|
||||
// 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
|
||||
|
||||
|
@ -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
|
||||
@ -357,7 +355,7 @@ public:
|
||||
~RaceManager();
|
||||
|
||||
void reset();
|
||||
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);
|
||||
|
||||
|
@ -191,7 +191,7 @@ GUIEngine::EventPropagation SelectChallengeDialog::processEvent(const std::strin
|
||||
|
||||
// Set up race manager appropriately
|
||||
race_manager->setNumPlayers(1);
|
||||
race_manager->setLocalKartInfo(0, UserConfigParams::m_default_kart);
|
||||
race_manager->setPlayerKart(0, UserConfigParams::m_default_kart);
|
||||
race_manager->setReverseTrack(false);
|
||||
|
||||
//int id = StateManager::get()->createActivePlayer( unlock_manager->getCurrentPlayer(), device );
|
||||
|
@ -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.
|
||||
|
@ -1194,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 &&
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user