1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Fixed CID 1366403

This commit is contained in:
AlexVinS 2016-11-28 02:01:07 +03:00
parent bf3f94a106
commit 9094c99759

View File

@ -70,7 +70,7 @@ namespace bfs = boost::filesystem;
std::string NAME_AFFIX = "client"; std::string NAME_AFFIX = "client";
std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; //application name std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; //application name
CGuiHandler GH; CGuiHandler GH;
static CClient *client=nullptr; static CClient *client = nullptr;
int preferredDriverIndex = -1; int preferredDriverIndex = -1;
SDL_Window * mainWindow = nullptr; SDL_Window * mainWindow = nullptr;
@ -619,17 +619,22 @@ void processCommand(const std::string &message)
} }
else if(cn=="save") else if(cn=="save")
{ {
if(!client)
{
std::cout << "Game in not active";
return;
}
std::string fname; std::string fname;
readed >> fname; readed >> fname;
client->save(fname); client->save(fname);
} }
else if(cn=="load") // else if(cn=="load")
{ // {
// TODO: this code should end the running game and manage to call startGame instead // // TODO: this code should end the running game and manage to call startGame instead
std::string fname; // std::string fname;
readed >> fname; // readed >> fname;
client->loadGame(fname); // client->loadGame(fname);
} // }
else if(message=="get txt") else if(message=="get txt")
{ {
std::cout << "Command accepted.\t"; std::cout << "Command accepted.\t";
@ -832,6 +837,11 @@ void processCommand(const std::string &message)
else if(cn == "gosolo") else if(cn == "gosolo")
{ {
boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim); boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
if(!client)
{
std::cout << "Game in not active";
return;
}
PlayerColor color; PlayerColor color;
if(session["aiSolo"].Bool()) if(session["aiSolo"].Bool())
{ {
@ -866,6 +876,11 @@ void processCommand(const std::string &message)
boost::to_lower(colorName); boost::to_lower(colorName);
boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim); boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
if(!client)
{
std::cout << "Game in not active";
return;
}
PlayerColor color; PlayerColor color;
if(LOCPLINT) if(LOCPLINT)
color = LOCPLINT->playerID; color = LOCPLINT->playerID;
@ -1245,7 +1260,7 @@ void startGame(StartInfo * options, CConnection *serv/* = nullptr*/)
} }
} }
client = new CClient; client = new CClient();
CPlayerInterface::howManyPeople = 0; CPlayerInterface::howManyPeople = 0;
switch(options->mode) //new game switch(options->mode) //new game
{ {
@ -1264,7 +1279,7 @@ void startGame(StartInfo * options, CConnection *serv/* = nullptr*/)
break; break;
} }
client->connectionHandler = new boost::thread(&CClient::run, client); client->connectionHandler = new boost::thread(&CClient::run, client);
} }
void endGame() void endGame()