mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Few minor code improvements
* All command line options now case insensetive. * SDL_VIDEO_X11_DGAMOUS unused in SDL2 so it's removed. * Added current year into the --help output for client and server. * Moved DO_NOT_START_SERVER into session settings.
This commit is contained in:
parent
6c8192956e
commit
eeff7ee315
@ -60,6 +60,7 @@
|
||||
#endif
|
||||
|
||||
namespace po = boost::program_options;
|
||||
namespace po_style = boost::program_options::command_line_style;
|
||||
namespace bfs = boost::filesystem;
|
||||
|
||||
/*
|
||||
@ -200,15 +201,13 @@ static void prog_version(void)
|
||||
|
||||
static void prog_help(const po::options_description &opts)
|
||||
{
|
||||
auto time = std::time(0);
|
||||
printf("%s - A Heroes of Might and Magic 3 clone\n", GameConstants::VCMI_VERSION.c_str());
|
||||
printf("Copyright (C) 2007-2017 VCMI dev team - see AUTHORS file\n");
|
||||
printf("Copyright (C) 2007-%d VCMI dev team - see AUTHORS file\n", std::localtime(&time)->tm_year + 1900);
|
||||
printf("This is free software; see the source for copying conditions. There is NO\n");
|
||||
printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||
printf("\n");
|
||||
printf("Usage:\n");
|
||||
std::cout << opts;
|
||||
// printf(" -h, --help display this help and exit\n");
|
||||
// printf(" -v, --version display version information and exit\n");
|
||||
}
|
||||
|
||||
static void SDLLogCallback(void* userdata,
|
||||
@ -293,7 +292,7 @@ int main(int argc, char** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
po::store(po::parse_command_line(argc, argv, opts), vm);
|
||||
po::store(po::parse_command_line(argc, argv, opts, po_style::unix_style|po_style::case_insensitive), vm);
|
||||
}
|
||||
catch(std::exception &e)
|
||||
{
|
||||
@ -312,16 +311,6 @@ int main(int argc, char** argv)
|
||||
prog_version();
|
||||
return 0;
|
||||
}
|
||||
if(vm.count("donotstartserver"))
|
||||
{
|
||||
CServerHandler::DO_NOT_START_SERVER = true;
|
||||
}
|
||||
|
||||
// Have effect on X11 system only (Linux).
|
||||
// For whatever reason in fullscreen mode SDL takes "raw" mouse input from DGA X11 extension
|
||||
// (DGA = Direct graphics access). Because this is raw input (before any speed\acceleration proceesing)
|
||||
// it may result in very small \ very fast mouse when game in fullscreen mode
|
||||
putenv((char*)"SDL_VIDEO_X11_DGAMOUSE=0");
|
||||
|
||||
// Init old logging system and new (temporary) logging system
|
||||
CStopWatch total, pomtime;
|
||||
@ -347,6 +336,9 @@ int main(int argc, char** argv)
|
||||
session["headless"].Bool() = true;
|
||||
session["onlyai"].Bool() = true;
|
||||
}
|
||||
// Server settings
|
||||
session["donotstartserver"].Bool() = vm.count("donotstartserver");
|
||||
|
||||
// Shared memory options
|
||||
session["disable-shm"].Bool() = vm.count("disable-shm");
|
||||
session["enable-shm-uuid"].Bool() = vm.count("enable-shm-uuid");
|
||||
@ -1331,7 +1323,7 @@ static void mainLoop()
|
||||
|
||||
void startGame(StartInfo * options, CConnection *serv/* = nullptr*/)
|
||||
{
|
||||
if(!CServerHandler::DO_NOT_START_SERVER)
|
||||
if(!settings["session"]["donotstartserver"].Bool())
|
||||
{
|
||||
serverAlive.waitWhileTrue();
|
||||
serverAlive.setn(true);
|
||||
|
@ -693,7 +693,7 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EGameM
|
||||
if(isHost())
|
||||
{
|
||||
assert(playerNames.size() == 1 && vstd::contains(playerNames, 1)); //TODO hot-seat/network combo
|
||||
if(CServerHandler::DO_NOT_START_SERVER)
|
||||
if(settings["session"]["donotstartserver"].Bool())
|
||||
serv = CServerHandler::justConnectToServer(Address, Port);
|
||||
else
|
||||
serv = sh->connectToServer();
|
||||
@ -3170,7 +3170,7 @@ void CMultiMode::hostTCP()
|
||||
Settings name = settings.write["general"]["playerName"];
|
||||
name->String() = txt->text;
|
||||
GH.popIntTotally(this);
|
||||
if(CServerHandler::DO_NOT_START_SERVER)
|
||||
if(settings["session"]["donotstartserver"].Bool())
|
||||
GH.pushInt(new CSimpleJoinScreen(CMenuScreen::MULTI_NETWORK_HOST));
|
||||
else
|
||||
GH.pushInt(new CSelectionScreen(CMenuScreen::newGame, CMenuScreen::MULTI_NETWORK_HOST));
|
||||
|
@ -986,11 +986,9 @@ std::string CClient::aiNameForPlayer(bool battleAI)
|
||||
return goodAI;
|
||||
}
|
||||
|
||||
bool CServerHandler::DO_NOT_START_SERVER = false;
|
||||
|
||||
void CServerHandler::startServer()
|
||||
{
|
||||
if(DO_NOT_START_SERVER)
|
||||
if(settings["session"]["donotstartserver"].Bool())
|
||||
return;
|
||||
|
||||
th.update();
|
||||
@ -1007,7 +1005,7 @@ void CServerHandler::startServer()
|
||||
|
||||
void CServerHandler::waitForServer()
|
||||
{
|
||||
if(DO_NOT_START_SERVER)
|
||||
if(settings["session"]["donotstartserver"].Bool())
|
||||
return;
|
||||
|
||||
if(!serverThread)
|
||||
@ -1071,7 +1069,7 @@ CServerHandler::CServerHandler(bool runServer /*= false*/)
|
||||
uuid = boost::uuids::to_string(boost::uuids::random_generator()());
|
||||
|
||||
#ifndef VCMI_ANDROID
|
||||
if(DO_NOT_START_SERVER || settings["session"]["disable-shm"].Bool())
|
||||
if(settings["session"]["donotstartserver"].Bool() || settings["session"]["disable-shm"].Bool())
|
||||
return;
|
||||
|
||||
std::string sharedMemoryName = "vcmi_memory";
|
||||
|
@ -42,8 +42,6 @@ class CServerHandler
|
||||
private:
|
||||
void callServer(); //calls server via system(), should be called as thread
|
||||
public:
|
||||
static bool DO_NOT_START_SERVER;
|
||||
|
||||
CStopWatch th;
|
||||
boost::thread *serverThread; //thread that called system to run server
|
||||
SharedMemory * shared;
|
||||
|
@ -562,15 +562,14 @@ static void handleCommandOptions(int argc, char *argv[])
|
||||
}
|
||||
|
||||
po::notify(cmdLineOptions);
|
||||
|
||||
if (cmdLineOptions.count("help"))
|
||||
{
|
||||
auto time = std::time(0);
|
||||
printf("%s - A Heroes of Might and Magic 3 clone\n", GameConstants::VCMI_VERSION.c_str());
|
||||
printf("Copyright (C) 2007-2014 VCMI dev team - see AUTHORS file\n");
|
||||
printf("Copyright (C) 2007-%d VCMI dev team - see AUTHORS file\n", std::localtime(&time)->tm_year + 1900);
|
||||
printf("This is free software; see the source for copying conditions. There is NO\n");
|
||||
printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
|
||||
printf("\n");
|
||||
printf("Usage:\n");
|
||||
std::cout << opts;
|
||||
exit(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user