Fixed #1228 (crash when no default player is set and -N, -R, ... is used).
This commit is contained in:
parent
605e4c6dff
commit
58a5928b17
@ -144,6 +144,48 @@ void PlayerManager::deletePlayer(PlayerProfile *player)
|
||||
m_all_players.erase(player);
|
||||
} // deletePlayer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** This function makes sure that a current player is defined. This is called
|
||||
* when a screen skipping command line option is given (-N, -R, ...), in
|
||||
* which case there might not be a current player (if no default player is
|
||||
* set in players.xml, i.e. the 'remember be' option was not picked ). Since
|
||||
* a lot of code depends on having a local player, just set the most
|
||||
* frequently used non-guest to be the current player.
|
||||
*/
|
||||
void PlayerManager::enforceCurrentPlayer()
|
||||
{
|
||||
if (m_current_player) return;
|
||||
|
||||
PlayerProfile *player;
|
||||
for_in(player, m_all_players)
|
||||
{
|
||||
if (!player->isGuestAccount())
|
||||
{
|
||||
Log::info("PlayerManager", "Enfocring current player '%ls'.",
|
||||
player->getName().c_str() );
|
||||
m_current_player = player;
|
||||
return;
|
||||
}
|
||||
} // for player in m_all_players
|
||||
|
||||
// This shouldn't happen - but just in case: add the default players
|
||||
// again, and search again for a non-guest player.
|
||||
addDefaultPlayer();
|
||||
for_in(player, m_all_players)
|
||||
{
|
||||
if (!player->isGuestAccount())
|
||||
{
|
||||
Log::info("PlayerManager", "Enfocring current player '%s'.",
|
||||
player->getName().c_str());
|
||||
m_current_player = player;
|
||||
return;
|
||||
}
|
||||
} // for player in m_all_players
|
||||
|
||||
// Now this really really should not happen.
|
||||
Log::fatal("PlayerManager", "Failed to find a non-guest player.");
|
||||
} // enforceCurrentPlayer
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Called when no player profiles exists. It creates two players: one
|
||||
* guest player, and one non-guest player for whic hit tries to guess a
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
void deletePlayer(PlayerProfile *player);
|
||||
void setCurrentPlayer(PlayerProfile *player, bool remember_me);
|
||||
const PlayerProfile *getPlayerById(unsigned int id);
|
||||
void enforceCurrentPlayer();
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the current player. */
|
||||
PlayerProfile* getCurrentPlayer() { return m_current_player; }
|
||||
|
88
src/main.cpp
88
src/main.cpp
@ -1061,18 +1061,43 @@ void initRest()
|
||||
} // initRest
|
||||
|
||||
//=============================================================================
|
||||
#ifdef BREAKPAD
|
||||
bool ShowDumpResults(const wchar_t* dump_path,
|
||||
const wchar_t* minidump_id,
|
||||
void* context,
|
||||
EXCEPTION_POINTERS* exinfo,
|
||||
MDRawAssertionInfo* assertion,
|
||||
bool succeeded)
|
||||
void askForInternetPermission()
|
||||
{
|
||||
wprintf(L"Path: %s id %s.\n", dump_path, minidump_id);
|
||||
return succeeded;
|
||||
}
|
||||
#endif
|
||||
if (UserConfigParams::m_internet_status ==
|
||||
Online::RequestManager::IPERM_NOT_ASKED)
|
||||
{
|
||||
class ConfirmServer :
|
||||
public MessageDialog::IConfirmDialogListener
|
||||
{
|
||||
public:
|
||||
virtual void onConfirm()
|
||||
{
|
||||
UserConfigParams::m_internet_status =
|
||||
Online::RequestManager::IPERM_ALLOWED;
|
||||
GUIEngine::ModalDialog::dismiss();
|
||||
} // onConfirm
|
||||
// --------------------------------------------------------
|
||||
virtual void onCancel()
|
||||
{
|
||||
UserConfigParams::m_internet_status =
|
||||
Online::RequestManager::IPERM_NOT_ALLOWED;
|
||||
GUIEngine::ModalDialog::dismiss();
|
||||
} // onCancel
|
||||
}; // ConfirmServer
|
||||
|
||||
new MessageDialog(_("SuperTuxKart may connect to a server "
|
||||
"to download add-ons and notify you of updates. Would you "
|
||||
"like this feature to be enabled? (To change this setting "
|
||||
"at a later time, go to options, select tab "
|
||||
"'User Interface', and edit \"Allow STK to connect to the "
|
||||
"Internet\")."),
|
||||
MessageDialog::MESSAGE_DIALOG_CONFIRM,
|
||||
new ConfirmServer(), true);
|
||||
}
|
||||
|
||||
} // askForInternetPermission
|
||||
|
||||
//=============================================================================
|
||||
|
||||
#if defined(DEBUG) && defined(WIN32) && !defined(__CYGWIN__)
|
||||
#pragma comment(linker, "/SUBSYSTEM:console")
|
||||
@ -1081,10 +1106,6 @@ bool ShowDumpResults(const wchar_t* dump_path,
|
||||
// ----------------------------------------------------------------------------
|
||||
int main(int argc, char *argv[] )
|
||||
{
|
||||
#ifdef BREAKPAD
|
||||
google_breakpad::ExceptionHandler eh(L"C:\\Temp", NULL, ShowDumpResults,
|
||||
NULL, google_breakpad::ExceptionHandler::HANDLER_ALL);
|
||||
#endif
|
||||
CommandLine::init(argc, argv);
|
||||
|
||||
CrashReporting::installHandlers();
|
||||
@ -1209,40 +1230,15 @@ int main(int argc, char *argv[] )
|
||||
wiimote_manager->askUserToConnectWiimotes();
|
||||
}
|
||||
#endif
|
||||
if(UserConfigParams::m_internet_status ==
|
||||
Online::RequestManager::IPERM_NOT_ASKED)
|
||||
{
|
||||
class ConfirmServer :
|
||||
public MessageDialog::IConfirmDialogListener
|
||||
{
|
||||
public:
|
||||
virtual void onConfirm()
|
||||
{
|
||||
UserConfigParams::m_internet_status =
|
||||
Online::RequestManager::IPERM_ALLOWED;
|
||||
GUIEngine::ModalDialog::dismiss();
|
||||
} // onConfirm
|
||||
// --------------------------------------------------------
|
||||
virtual void onCancel()
|
||||
{
|
||||
UserConfigParams::m_internet_status =
|
||||
Online::RequestManager::IPERM_NOT_ALLOWED;
|
||||
GUIEngine::ModalDialog::dismiss();
|
||||
} // onCancel
|
||||
}; // ConfirmServer
|
||||
|
||||
new MessageDialog(_("SuperTuxKart may connect to a server "
|
||||
"to download add-ons and notify you of updates. Would you "
|
||||
"like this feature to be enabled? (To change this setting "
|
||||
"at a later time, go to options, select tab "
|
||||
"'User Interface', and edit \"Allow STK to connect to the "
|
||||
"Internet\")."),
|
||||
MessageDialog::MESSAGE_DIALOG_CONFIRM,
|
||||
new ConfirmServer(), true);
|
||||
}
|
||||
askForInternetPermission();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Skip the start screen. This esp. means that no login screen is
|
||||
// displayed (if necessary), so we have to make sure there is
|
||||
// a current player
|
||||
PlayerManager::get()->enforceCurrentPlayer();
|
||||
|
||||
InputDevice *device;
|
||||
|
||||
// Use keyboard 0 by default in --no-start-screen
|
||||
|
Loading…
x
Reference in New Issue
Block a user