添加readline优化控制台输入
This commit is contained in:
parent
18dfa2d933
commit
a6ef7126be
@ -2569,6 +2569,7 @@ if(SERVER)
|
||||
PROPERTY OUTPUT_NAME ${SERVER_EXECUTABLE}
|
||||
)
|
||||
target_link_libraries(game-server ${LIBS_SERVER})
|
||||
target_link_libraries(game-server readline)
|
||||
target_include_directories(game-server PRIVATE ${PNG_INCLUDE_DIRS})
|
||||
list(APPEND TARGETS_OWN game-server)
|
||||
list(APPEND TARGETS_LINK game-server)
|
||||
|
@ -1,4 +1,5 @@
|
||||
|
||||
#include <readline/readline.h>
|
||||
#define _WIN32_WINNT 0x0501
|
||||
|
||||
#include <base/logger.h>
|
||||
@ -47,6 +48,9 @@ void HandleSigIntTerm(int Param)
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
signal(SIGINT, HandleSigIntTerm);
|
||||
signal(SIGTERM, HandleSigIntTerm);
|
||||
|
||||
CCmdlineFix CmdlineFix(&argc, &argv);
|
||||
bool Silent = false;
|
||||
|
||||
@ -94,9 +98,6 @@ int main(int argc, const char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
signal(SIGINT, HandleSigIntTerm);
|
||||
signal(SIGTERM, HandleSigIntTerm);
|
||||
|
||||
#if defined(CONF_EXCEPTION_HANDLING)
|
||||
init_exception_handler();
|
||||
#endif
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <base/system.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <engine/config.h>
|
||||
#include <engine/console.h>
|
||||
#include <engine/engine.h>
|
||||
@ -39,8 +41,12 @@
|
||||
// DDRace
|
||||
#include <engine/shared/linereader.h>
|
||||
#include <pthread.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <zlib.h>
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#include <csignal>
|
||||
|
||||
#include "antibot.h"
|
||||
#include "databases/connection.h"
|
||||
@ -2528,14 +2534,11 @@ int CServer::LoadMap(const char *pMapName)
|
||||
void* CreateConsoleThread(void* p){
|
||||
IConsole* console=(IConsole*)p;
|
||||
while(true){
|
||||
printf(" ->");
|
||||
char cmd[256];
|
||||
int result=scanf("%s",cmd);
|
||||
if(result==1){
|
||||
char* cmd=readline("\001\033[34m\002DDNet->\001\033[0m\002");
|
||||
if(!*cmd) continue;
|
||||
add_history(cmd);
|
||||
console->ExecuteLine(cmd);
|
||||
}else{
|
||||
printf("命令格式错误!\n");
|
||||
}
|
||||
free(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user