Started adding guest account, so that multiplayer gameplay is not hindered by having to make a player account for everyone
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5038 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
7f7b7de8c5
commit
5e45b7e1b5
@ -30,25 +30,30 @@
|
||||
*/
|
||||
class PlayerProfile
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
|
||||
/** For saving to config file. */
|
||||
GroupUserConfigParam m_player_group;
|
||||
|
||||
StringUserConfigParam m_name;
|
||||
|
||||
BoolUserConfigParam m_is_guest_account;
|
||||
|
||||
public:
|
||||
|
||||
PlayerProfile(const char* name) : m_player_group("Player", "Represents one human player"),
|
||||
m_name(name, "name", &m_player_group) //, m_last_kart_id(-1)
|
||||
m_name(name, "name", &m_player_group), //, m_last_kart_id(-1)
|
||||
m_is_guest_account(false, "guest", &m_player_group)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void setName(const std::string &name_){ m_name = name_;}
|
||||
void setName(const std::string &name_){ m_name = name_; }
|
||||
|
||||
const char* getName() const { return m_name.c_str(); }
|
||||
|
||||
bool isGuestAccount() const { return m_is_guest_account; }
|
||||
|
||||
//int getLastKartId(){ return m_last_kart_id; }
|
||||
//void setLastKartId(int newLastKartId){ m_last_kart_id = newLastKartId; }
|
||||
};
|
||||
|
@ -347,6 +347,19 @@ void UserConfig::addDefaultPlayer()
|
||||
else if(getenv("LOGNAME")!=NULL) // Linux, Macs
|
||||
username = getenv("LOGNAME");
|
||||
|
||||
|
||||
class GuestPlayerProfile : public PlayerProfile
|
||||
{
|
||||
public:
|
||||
GuestPlayerProfile() : PlayerProfile("Guest")
|
||||
{
|
||||
m_is_guest_account = true;
|
||||
}
|
||||
};
|
||||
|
||||
// add default guest player
|
||||
UserConfigParams::m_all_players.push_back( new GuestPlayerProfile() );
|
||||
|
||||
// Set the name as the default name for all players.
|
||||
UserConfigParams::m_all_players.push_back( new PlayerProfile(username.c_str()) );
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
||||
cause an undefined game action now
|
||||
6: Added stick configurations.
|
||||
*/
|
||||
const int CURRENT_CONFIG_VERSION = 7;
|
||||
const int CURRENT_CONFIG_VERSION = 8;
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
@ -1053,10 +1053,13 @@ void KartSelectionScreen::eventCallback(Widget* widget, const std::string& name,
|
||||
{
|
||||
if (n == playerID) continue; // don't check a kart against itself
|
||||
|
||||
if (m_kart_widgets[n].isReady() &&
|
||||
(m_kart_widgets[n].getAssociatedPlayer()->getProfile() ==
|
||||
m_kart_widgets[playerID].getAssociatedPlayer()->getProfile() ||
|
||||
sameKart(m_kart_widgets[n], m_kart_widgets[playerID])))
|
||||
const bool player_ready = m_kart_widgets[n].isReady();
|
||||
const bool ident_conflict = !m_kart_widgets[n].getAssociatedPlayer()->getProfile()->isGuestAccount() &&
|
||||
m_kart_widgets[n].getAssociatedPlayer()->getProfile() ==
|
||||
m_kart_widgets[playerID].getAssociatedPlayer()->getProfile();
|
||||
const bool kart_conflict = sameKart(m_kart_widgets[n], m_kart_widgets[playerID]);
|
||||
|
||||
if (player_ready && (ident_conflict || kart_conflict))
|
||||
{
|
||||
printf("\n***\n*** You can't select this identity or kart, someone already took it!! ***\n***\n\n");
|
||||
|
||||
@ -1225,12 +1228,22 @@ bool KartSelectionScreen::validateIdentChoices()
|
||||
}
|
||||
}
|
||||
|
||||
// perform actual checking
|
||||
for (int n=0; n<amount; n++)
|
||||
{
|
||||
// skip players that took a guest account, they can be many on the same identity in this case
|
||||
if (m_kart_widgets[n].getAssociatedPlayer()->getProfile()->isGuestAccount())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// check if another kart took the same identity as the current one
|
||||
for (int m=n+1; m<amount; m++)
|
||||
{
|
||||
|
||||
// check if 2 players took the same name
|
||||
if (m_kart_widgets[n].getAssociatedPlayer()->getProfile() == m_kart_widgets[m].getAssociatedPlayer()->getProfile())
|
||||
if (m_kart_widgets[n].getAssociatedPlayer()->getProfile() ==
|
||||
m_kart_widgets[m].getAssociatedPlayer()->getProfile())
|
||||
{
|
||||
printf("\n***\n*** Identity conflict!! ***\n***\n\n");
|
||||
std::cout << " Player " << n << " chose " << m_kart_widgets[n].getAssociatedPlayer()->getProfile()->getName() << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user