加了个version命令行参数,为ctest做准备...
但并没有写任何test...
This commit is contained in:
notify 2023-06-17 20:18:40 +08:00 committed by GitHub
parent a7fa1d9ec0
commit bd42f51b38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -199,14 +199,21 @@ int main(int argc, char *argv[]) {
// 分析命令行,如果有 -s 或者 --server 就在命令行直接开服务器 // 分析命令行,如果有 -s 或者 --server 就在命令行直接开服务器
QCommandLineParser parser; QCommandLineParser parser;
parser.setApplicationDescription("FreeKill server"); parser.setApplicationDescription("FreeKill server");
parser.addHelpOption();
parser.addVersionOption(); parser.addVersionOption();
parser.addOption({{"s", "server"}, "start server at <port>", "port"}); parser.addOption({{"s", "server"}, "start server at <port>", "port"});
parser.addOption({{"h", "help"}, "display help information"});
QStringList cliOptions; QStringList cliOptions;
for (int i = 0; i < argc; i++) for (int i = 0; i < argc; i++)
cliOptions << argv[i]; cliOptions << argv[i];
parser.parse(cliOptions); 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"); bool startServer = parser.isSet("server");
ushort serverPort = 9527; ushort serverPort = 9527;

View File

@ -87,6 +87,7 @@ bool RoomThread::hasRequest() {
void RoomThread::trySleep(int ms) { void RoomThread::trySleep(int ms) {
if (sema_wake.available() > 0) { if (sema_wake.available() > 0) {
sema_wake.acquire(sema_wake.available()); sema_wake.acquire(sema_wake.available());
return;
} }
sema_wake.tryAcquire(1, ms); sema_wake.tryAcquire(1, ms);