From bd42f51b3846cce5494ce26432a64c013d308ab2 Mon Sep 17 00:00:00 2001 From: notify Date: Sat, 17 Jun 2023 20:18:40 +0800 Subject: [PATCH] Ctest (#200) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 加了个version命令行参数,为ctest做准备... 但并没有写任何test... --- src/main.cpp | 9 ++++++++- src/server/roomthread.cpp | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 2c1c5612..f7fd55d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -199,14 +199,21 @@ int main(int argc, char *argv[]) { // 分析命令行,如果有 -s 或者 --server 就在命令行直接开服务器 QCommandLineParser parser; parser.setApplicationDescription("FreeKill server"); - parser.addHelpOption(); parser.addVersionOption(); parser.addOption({{"s", "server"}, "start server at ", "port"}); + parser.addOption({{"h", "help"}, "display help information"}); QStringList cliOptions; for (int i = 0; i < argc; i++) cliOptions << argv[i]; parser.parse(cliOptions); + if (parser.isSet("version")) { + parser.showVersion(); + return 0; + } else if (parser.isSet("help")) { + parser.showHelp(); + return 0; + } bool startServer = parser.isSet("server"); ushort serverPort = 9527; diff --git a/src/server/roomthread.cpp b/src/server/roomthread.cpp index e4f6dfbd..d61bedfe 100644 --- a/src/server/roomthread.cpp +++ b/src/server/roomthread.cpp @@ -87,6 +87,7 @@ bool RoomThread::hasRequest() { void RoomThread::trySleep(int ms) { if (sema_wake.available() > 0) { sema_wake.acquire(sema_wake.available()); + return; } sema_wake.tryAcquire(1, ms);