mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Publish if cheats or unlimited replays allowed to all players
This commit is contained in:
parent
07a06ea08a
commit
8b59b78003
@ -63,7 +63,11 @@
|
||||
"vcmi.mainMenu.serverClosing" : "Closing...",
|
||||
"vcmi.mainMenu.hostTCP" : "Host TCP/IP game",
|
||||
"vcmi.mainMenu.joinTCP" : "Join TCP/IP game",
|
||||
|
||||
|
||||
"vcmi.multiplayerWelcomeMessage.additionalSettings" : "Additional settings",
|
||||
"vcmi.multiplayerWelcomeMessage.cheatsAllowed" : "Cheats allowed",
|
||||
"vcmi.multiplayerWelcomeMessage.unlimitedReplays" : "Unlimited battle replays",
|
||||
|
||||
"vcmi.lobby.filepath" : "File path",
|
||||
"vcmi.lobby.creationDate" : "Creation date",
|
||||
"vcmi.lobby.scenarioName" : "Scenario name",
|
||||
|
@ -63,7 +63,11 @@
|
||||
"vcmi.mainMenu.serverClosing" : "Trenne...",
|
||||
"vcmi.mainMenu.hostTCP" : "Hoste TCP/IP Spiel",
|
||||
"vcmi.mainMenu.joinTCP" : "Trete TCP/IP Spiel bei",
|
||||
|
||||
|
||||
"vcmi.multiplayerWelcomeMessage.additionalSettings" : "Zusätzliche Einstellungen",
|
||||
"vcmi.multiplayerWelcomeMessage.cheatsAllowed" : "Cheats erlaubt",
|
||||
"vcmi.multiplayerWelcomeMessage.unlimitedReplays" : "Unbegrenzte Kampfwiederholungen",
|
||||
|
||||
"vcmi.lobby.filepath" : "Dateipfad",
|
||||
"vcmi.lobby.creationDate" : "Erstellungsdatum",
|
||||
"vcmi.lobby.scenarioName" : "Szenario-Name",
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "processors/PlayerMessageProcessor.h"
|
||||
|
||||
#include "../lib/CHeroHandler.h"
|
||||
#include "../lib/CPlayerState.h"
|
||||
#include "../lib/MetaString.h"
|
||||
#include "../lib/registerTypes/RegisterTypesLobbyPacks.h"
|
||||
#include "../lib/serializer/CMemorySerializer.h"
|
||||
@ -332,6 +333,8 @@ void CVCMIServer::startGameImmediately()
|
||||
setState(EServerState::GAMEPLAY);
|
||||
lastTimerUpdateTime = gameplayStartTime = std::chrono::steady_clock::now();
|
||||
onTimer();
|
||||
|
||||
multiplayerWelcomeMessage();
|
||||
}
|
||||
|
||||
void CVCMIServer::onDisconnected(const std::shared_ptr<INetworkConnection> & connection, const std::string & errorMessage)
|
||||
@ -979,6 +982,38 @@ ui8 CVCMIServer::getIdOfFirstUnallocatedPlayer() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CVCMIServer::multiplayerWelcomeMessage()
|
||||
{
|
||||
int humanPlayer = 0;
|
||||
for (auto & pi : si->playerInfos)
|
||||
if(gh->getPlayerState(pi.first)->isHuman())
|
||||
humanPlayer++;
|
||||
|
||||
if(humanPlayer < 2) // Singleplayer
|
||||
return;
|
||||
|
||||
std::vector<std::string> optionIds;
|
||||
if(si->extraOptionsInfo.cheatsAllowed)
|
||||
optionIds.push_back("vcmi.multiplayerWelcomeMessage.cheatsAllowed");
|
||||
if(si->extraOptionsInfo.unlimitedReplay)
|
||||
optionIds.push_back("vcmi.multiplayerWelcomeMessage.unlimitedReplays");
|
||||
|
||||
if(!optionIds.size()) // No settings to publish
|
||||
return;
|
||||
|
||||
MetaString str;
|
||||
str.appendTextID("vcmi.multiplayerWelcomeMessage.additionalSettings");
|
||||
str.appendRawString(": ");
|
||||
for(int i = 0; i < optionIds.size(); i++)
|
||||
{
|
||||
str.appendTextID(optionIds[i]);
|
||||
if(i < optionIds.size() - 1)
|
||||
str.appendRawString(", ");
|
||||
}
|
||||
|
||||
gh->playerMessages->broadcastSystemMessage(str);
|
||||
}
|
||||
|
||||
INetworkHandler & CVCMIServer::getNetworkHandler()
|
||||
{
|
||||
return *networkHandler;
|
||||
|
@ -130,4 +130,6 @@ public:
|
||||
void setCampaignBonus(int bonusId);
|
||||
|
||||
ui8 getIdOfFirstUnallocatedPlayer() const;
|
||||
|
||||
void multiplayerWelcomeMessage();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user