[mod menu] new: tell the user to restart the game after changing the server

This commit is contained in:
Robin C. Ladiges 2024-07-09 09:02:57 +02:00
parent 82cc6ffe91
commit 8797d58c94
No known key found for this signature in database
GPG key ID: B494D3DF92661B99
3 changed files with 25 additions and 0 deletions

View file

@ -135,6 +135,8 @@ class Client {
static const int getCurrentPort();
static const bool hasServerChanged();
static int getConnectCount() {
if (sInstance) {
return sInstance->mConnectCount;

View file

@ -1305,6 +1305,21 @@ const int Client::getCurrentPort() {
return -1;
}
/**
* @brief
*
* @return const bool
*/
const bool Client::hasServerChanged() {
if (!sInstance) {
return false;
}
return (
getCurrentPort() != sInstance->mSocket->getPort()
|| strcmp(getCurrentIP(), sInstance->mSocket->getIP()) != 0
);
}
/**
* @brief sets server IP to supplied string, used specifically for loading IP from the save file.
*

View file

@ -109,6 +109,14 @@ void StageSceneStateServerConfig::appear(void) {
void StageSceneStateServerConfig::kill(void) {
mCurrentMenu->startEnd("End");
al::NerveStateBase::kill();
if (Client::hasServerChanged()) {
#if EMU
Client::showUIMessage(u"You changed the server and have to restart the emulator now.");
#else
Client::showUIMessage(u"You changed the server and have to restart the game now.");
#endif
}
}
al::MessageSystem* StageSceneStateServerConfig::getMessageSystem(void) const {