1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Fix crash due to passing args

This commit is contained in:
nordsoft
2022-11-13 23:38:27 +04:00
parent cfe1867d4a
commit 694fedc662
4 changed files with 6 additions and 9 deletions

View File

@@ -29,8 +29,6 @@ int main(int argc, char * argv[])
{ {
int result; int result;
#ifdef VCMI_IOS #ifdef VCMI_IOS
argcForClient = argc;
argvForClient = argv;
{ {
#endif #endif
QApplication vcmilauncher(argc, argv); QApplication vcmilauncher(argc, argv);
@@ -51,13 +49,13 @@ void startGame(const QStringList & args)
#ifdef Q_OS_IOS #ifdef Q_OS_IOS
argcForClient = args.size() + 1; //first argument is omitted argcForClient = args.size() + 1; //first argument is omitted
argvForClient = new char*[argcForClient]; argvForClient = new char*[argcForClient];
argvForClient[0] = "vcmiclient"; argvForClient[0] = "vcmiclient";
for(int i = 1; i < argcForClient; ++i) for(int i = 1; i < argcForClient; ++i)
{ {
const char * s = args[i - 1].toLocal8Bit().constData(); std::string s = args.at(i - 1).toStdString();
argvForClient[i] = new char[strlen(s)]; argvForClient[i] = new char[s.size() + 1];
strcpy(argvForClient[i], s); strcpy(argvForClient[i], s.c_str());
} }
qApp->quit(); qApp->quit();
#else #else

View File

@@ -12,8 +12,6 @@
void startGame(const QStringList & args); void startGame(const QStringList & args);
#ifdef VCMI_IOS #ifdef VCMI_IOS
extern int argcForClient;
extern char** argvForClient;
extern "C" void launchGame(int argc, char * argv[]); extern "C" void launchGame(int argc, char * argv[]);
#else #else
void startExecutable(QString name, const QStringList & args); void startExecutable(QString name, const QStringList & args);

View File

@@ -207,7 +207,7 @@ void CVCMIServer::establishRemoteConnections()
int port = cmdLineOptions["lobby-port"].as<ui16>(); int port = cmdLineOptions["lobby-port"].as<ui16>();
logGlobal->info("Server is connecting to remote at %s:%d with uuid %d times", address, port, uuid, numOfConnections); logGlobal->info("Server is connecting to remote at %s:%d with uuid %d times", address, port, uuid, numOfConnections);
for(int i = 0; i < numOfConnections; ++i) for(int i = 0; i < numOfConnections && i == remotePipeConnections; ++i, ++remotePipeConnections)
connectToRemote(address, port); connectToRemote(address, port);
} }

View File

@@ -53,6 +53,7 @@ class CVCMIServer : public LobbyInfo
boost::recursive_mutex mx; boost::recursive_mutex mx;
std::shared_ptr<CApplier<CBaseForServerApply>> applier; std::shared_ptr<CApplier<CBaseForServerApply>> applier;
std::unique_ptr<boost::thread> announceLobbyThread, remoteConnectionsThread; std::unique_ptr<boost::thread> announceLobbyThread, remoteConnectionsThread;
int remotePipeConnections = 0;
public: public:
std::shared_ptr<CGameHandler> gh; std::shared_ptr<CGameHandler> gh;