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:
@@ -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);
|
||||||
@@ -55,9 +53,9 @@ void startGame(const QStringList & args)
|
|||||||
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
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user