Renamed all instanced of RandomKart in the race_manager to
AIKart (e.g. m_random_kart_list -> m_ai_kart_list) - since this describes what the lists and function actually are (in network the name is not entirely correct, but since this will be re-implemented anyway, we leave the proper naming till later). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6103 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
3bc2a8b93d
commit
a973e8b84f
@ -48,7 +48,7 @@ RaceInfoMessage::RaceInfoMessage(const std::vector<RemoteKartInfo>& kart_info)
|
||||
+ getCharLength() // kart_info[i].getLocalPlayerId())
|
||||
+ getStringLength(kart_info[i].getPlayerName());
|
||||
}
|
||||
const std::vector<std::string>& rkl=race_manager->getRandomKartList();
|
||||
const std::vector<std::string>& rkl=race_manager->getAIKartList();
|
||||
len += getStringVectorLength(rkl);
|
||||
|
||||
allocate(len);
|
||||
@ -113,5 +113,5 @@ RaceInfoMessage::RaceInfoMessage(ENetPacket* pkt):Message(pkt, MT_RACE_INFO)
|
||||
race_manager->setPlayerKart(i, kart_info[i]);
|
||||
}
|
||||
std::vector<std::string> rkl=getStringVector();
|
||||
race_manager->setRandomKartList(rkl);
|
||||
race_manager->setAIKartList(rkl);
|
||||
} // RaceInfoMessage
|
||||
|
@ -180,20 +180,18 @@ void RaceManager::computeRandomKartList()
|
||||
m_num_karts -= n;
|
||||
n = 0;
|
||||
}
|
||||
m_random_kart_list=kart_properties_manager->getRandomKartList(n,
|
||||
m_player_karts);
|
||||
m_ai_kart_list=kart_properties_manager->getRandomKartList(n, m_player_karts);
|
||||
|
||||
} // computeRandomKartList
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Starts a new race or GP (or other mode). It sets up the list of player
|
||||
* karts, AI karts, laps etc., and then uses startNextRace to actually start
|
||||
* the race.
|
||||
* \pre computeRandomKartList() must have been called first I think.
|
||||
* FIXME: remove this silly precondition, the race manager should be able to
|
||||
* do this automatically. If one forgets to call computeRandomKartList,
|
||||
* like it sure happened to me, one gets weird and hard to debug crashes.
|
||||
* The public interface of the RaceManager should NOT allow for this.
|
||||
* the race.6
|
||||
* \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 RaceManager::startNew()
|
||||
{
|
||||
@ -213,14 +211,15 @@ void RaceManager::startNew()
|
||||
// ==========================================================================
|
||||
m_kart_status.clear();
|
||||
|
||||
assert(m_num_karts == m_random_kart_list.size()+m_player_karts.size());
|
||||
// Before thi
|
||||
assert(m_num_karts == m_ai_kart_list.size()+m_player_karts.size());
|
||||
// First add the AI karts (randomly chosen)
|
||||
// ----------------------------------------
|
||||
int init_gp_rank = 0;
|
||||
const unsigned int ai_kart_count = m_random_kart_list.size();
|
||||
const unsigned int ai_kart_count = m_ai_kart_list.size();
|
||||
for(unsigned int i=0; i<ai_kart_count; i++)
|
||||
{
|
||||
m_kart_status.push_back(KartStatus(m_random_kart_list[i], i, -1, -1,
|
||||
m_kart_status.push_back(KartStatus(m_ai_kart_list[i], i, -1, -1,
|
||||
init_gp_rank, KT_AI));
|
||||
init_gp_rank ++;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ private:
|
||||
std::vector<int> m_host_ids;
|
||||
std::vector<int> m_num_laps;
|
||||
std::vector<int> m_score_for_position;
|
||||
std::vector<std::string> m_random_kart_list;
|
||||
std::vector<std::string> m_ai_kart_list;
|
||||
int m_track_number;
|
||||
GrandPrixData m_grand_prix;
|
||||
int m_num_karts;
|
||||
@ -305,9 +305,9 @@ public:
|
||||
bool allPlayerFinished() const {return
|
||||
m_num_finished_players==m_player_karts.size();}
|
||||
const std::vector<std::string>&
|
||||
getRandomKartList() const { return m_random_kart_list; }
|
||||
void setRandomKartList(const std::vector<std::string>& rkl)
|
||||
{ m_random_kart_list = rkl; }
|
||||
getAIKartList() const { return m_ai_kart_list; }
|
||||
void setAIKartList(const std::vector<std::string>& rkl)
|
||||
{ m_ai_kart_list = rkl; }
|
||||
void computeRandomKartList();
|
||||
void startNew(); // start new race/GP/...
|
||||
void next(); // start the next race or go back to the start screen
|
||||
|
@ -147,13 +147,16 @@ void ChallengesScreen::eventCallback(GUIEngine::Widget* widget, const std::strin
|
||||
// Go straight to the race
|
||||
StateManager::get()->enterGameState();
|
||||
|
||||
//FIXME: why do we need to invoke the network manager for local games??
|
||||
// Initialise global data - necessary even in local games to avoid
|
||||
// many if tests in other places (e.g. if network_game call
|
||||
// network_manager else call race_manager).
|
||||
network_manager->initCharacterDataStructures();
|
||||
|
||||
// Launch challenge
|
||||
unlock_manager->getChallenge(selection)->setRace();
|
||||
|
||||
// Sets up kart info, including random list of kart for AI
|
||||
network_manager->setupPlayerKartInfo();
|
||||
//race_manager->computeRandomKartList();
|
||||
race_manager->startNew();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user