mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
Add Fifo console for easier automation
This commit is contained in:
parent
5e537f24c6
commit
5cd69f29ac
41
src/engine/server/fifoconsole.cpp
Normal file
41
src/engine/server/fifoconsole.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include "fifoconsole.h"
|
||||
|
||||
#include <engine/shared/config.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <pthread.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
FifoConsole::FifoConsole(IConsole *pConsole)
|
||||
{
|
||||
void *fifoThread = thread_create(ListenFifoThread, pConsole);
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
pthread_detach((pthread_t)fifoThread);
|
||||
#endif
|
||||
}
|
||||
|
||||
void FifoConsole::ListenFifoThread(void *pUser)
|
||||
{
|
||||
IConsole *pConsole = (IConsole *)pUser;
|
||||
|
||||
if (str_comp(g_Config.m_SvInputFifo, "") == 0)
|
||||
return;
|
||||
|
||||
if (mkfifo(g_Config.m_SvInputFifo, 0600))
|
||||
return;
|
||||
|
||||
std::ifstream f;
|
||||
char aBuf[256];
|
||||
|
||||
while (true)
|
||||
{
|
||||
f.open(g_Config.m_SvInputFifo);
|
||||
while (f.getline(aBuf, 256))
|
||||
{
|
||||
pConsole->ExecuteLineFlag(aBuf, CFGFLAG_SERVER, -1);
|
||||
}
|
||||
f.close();
|
||||
}
|
||||
}
|
14
src/engine/server/fifoconsole.h
Normal file
14
src/engine/server/fifoconsole.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef ENGINE_FIFOCONSOLE_H
|
||||
#define ENGINE_FIFOCONSOLE_H
|
||||
|
||||
#include <engine/console.h>
|
||||
|
||||
class FifoConsole
|
||||
{
|
||||
static void ListenFifoThread(void *pUser);
|
||||
|
||||
public:
|
||||
FifoConsole(IConsole *pConsole);
|
||||
};
|
||||
|
||||
#endif // FILE_ENGINE_FIFOCONSOLE_H
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include "register.h"
|
||||
#include "server.h"
|
||||
#include "fifoconsole.h"
|
||||
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
#define _WIN32_WINNT 0x0501
|
||||
|
@ -1824,11 +1825,14 @@ int main(int argc, const char **argv) // ignore_convention
|
|||
|
||||
pEngine->InitLogfile();
|
||||
|
||||
FifoConsole *fifoConsole = new FifoConsole(pConsole);
|
||||
|
||||
// run the server
|
||||
dbg_msg("server", "starting...");
|
||||
pServer->Run();
|
||||
|
||||
// free
|
||||
delete fifoConsole;
|
||||
delete pServer;
|
||||
delete pKernel;
|
||||
delete pEngineMap;
|
||||
|
|
|
@ -204,6 +204,7 @@ MACRO_CONFIG_INT(SvVotePause, sv_vote_pause, 1, 0, 1, CFGFLAG_SERVER, "Allow vot
|
|||
MACRO_CONFIG_INT(SvVotePauseTime, sv_vote_pause_time, 10, 0, 360, CFGFLAG_SERVER, "The time (in seconds) players have to wait in pause when paused by vote")
|
||||
MACRO_CONFIG_INT(SvTuneReset, sv_tune_reset, 0, 0, 1, CFGFLAG_SERVER, "Whether tuning is reset after each map change or not")
|
||||
MACRO_CONFIG_STR(SvResetFile, sv_reset_file, 128, "reset.cfg", CFGFLAG_SERVER, "File to execute on map change or reload to set the default server settings")
|
||||
MACRO_CONFIG_STR(SvInputFifo, sv_input_fifo, 128, "", CFGFLAG_SERVER, "Fifo file to use as input")
|
||||
MACRO_CONFIG_INT(SvDDRaceTuneReset, sv_ddrace_tune_reset, 1, 0, 1, CFGFLAG_SERVER, "Whether DDRace tuning(sv_hit, Sv_Endless_Drag & Sv_Old_Laser) is reset after each map change or not")
|
||||
MACRO_CONFIG_INT(SvNamelessScore, sv_nameless_score, 0, 0, 1, CFGFLAG_SERVER, "Whether nameless tee has a score or not")
|
||||
MACRO_CONFIG_INT(SvTimeInBroadcastInterval, sv_time_in_broadcast_interval, 1, 0, 60, CFGFLAG_SERVER, "How often to update the broadcast time")
|
||||
|
|
Loading…
Reference in a new issue