mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-19 21:10:12 +02:00
fix repeated launches of single player
now server actually terminates
This commit is contained in:
parent
b7bc8495d8
commit
cd4b68c034
@ -190,7 +190,7 @@ void CServerHandler::startLocalServerAndConnect()
|
||||
boost::condition_variable cond;
|
||||
threadRunLocalServer = std::make_shared<boost::thread>([&cond, this] {
|
||||
setThreadName("CVCMIServer");
|
||||
CVCMIServer::create(&cond);
|
||||
CVCMIServer::create(&cond, uuid);
|
||||
// todo ios copypaste
|
||||
threadRunLocalServer.reset();
|
||||
CSH->campaignServerRestartLock.setn(false);
|
||||
|
@ -855,8 +855,11 @@ void handleLinuxSignal(int sig)
|
||||
|
||||
static void handleCommandOptions(int argc, char * argv[], boost::program_options::variables_map & options)
|
||||
{
|
||||
#ifndef VCMI_IOS
|
||||
namespace po = boost::program_options;
|
||||
#ifdef VCMI_IOS
|
||||
options.emplace("run-by-client", po::variable_value{true, true});
|
||||
options.emplace("uuid", po::variable_value{std::string{argv[1]}, true});
|
||||
#else
|
||||
po::options_description opts("Allowed options");
|
||||
opts.add_options()
|
||||
("help,h", "display help and exit")
|
||||
@ -878,8 +881,11 @@ static void handleCommandOptions(int argc, char * argv[], boost::program_options
|
||||
std::cerr << "Failure during parsing command-line options:\n" << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
po::notify(options);
|
||||
|
||||
#ifndef VCMI_IOS
|
||||
if(options.count("help"))
|
||||
{
|
||||
auto time = std::time(0);
|
||||
@ -916,7 +922,6 @@ int main(int argc, char * argv[])
|
||||
signal(SIGSEGV, handleLinuxSignal);
|
||||
#endif
|
||||
|
||||
// todo ios: double console log in single-process mode. Why removing the lines below breaks connecting to local server?!
|
||||
console = new CConsoleHandler();
|
||||
CBasicLogConfigurator logConfig(VCMIDirs::get().userLogsPath() / "VCMI_Server_log.txt", console);
|
||||
logConfig.configureDefault();
|
||||
@ -932,8 +937,7 @@ int main(int argc, char * argv[])
|
||||
srand((ui32)time(nullptr));
|
||||
|
||||
#ifdef VCMI_IOS
|
||||
argc = 1;
|
||||
boost::condition_variable * cond = reinterpret_cast<boost::condition_variable *>(argv[1]);
|
||||
boost::condition_variable * cond = reinterpret_cast<boost::condition_variable *>(argv[0]);
|
||||
cond->notify_one();
|
||||
#endif
|
||||
|
||||
@ -983,10 +987,12 @@ void CVCMIServer::create()
|
||||
main(1, const_cast<char **>(foo));
|
||||
}
|
||||
#elif defined(VCMI_IOS)
|
||||
void CVCMIServer::create(boost::condition_variable * cond)
|
||||
void CVCMIServer::create(boost::condition_variable * cond, const std::string & uuid)
|
||||
{
|
||||
const auto executablePath = VCMIDirs::get().serverPath();
|
||||
void *argv[] = {const_cast<char *>(executablePath.c_str()), cond};
|
||||
main(2, reinterpret_cast<char **>(argv));
|
||||
const std::initializer_list<const void *> argv = {
|
||||
cond,
|
||||
uuid.c_str(),
|
||||
};
|
||||
main(argv.size(), reinterpret_cast<char **>(const_cast<void **>(argv.begin())));
|
||||
}
|
||||
#endif
|
||||
|
@ -109,6 +109,6 @@ public:
|
||||
#ifdef VCMI_ANDROID
|
||||
static void create();
|
||||
#elif defined(VCMI_IOS)
|
||||
static void create(boost::condition_variable * cond);
|
||||
static void create(boost::condition_variable * cond, const std::string & uuid);
|
||||
#endif
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user