...
 
Commits (2)
......@@ -197,96 +197,6 @@ void Host_InitializeGameDLL(void)
Cbuf_Execute();
}
void Host_Motd_f(void)
{
int length;
FileHandle_t pFile;
char *pFileList;
char *next;
pFileList = motdfile.string;
if (*pFileList == '/' || Q_strstr(pFileList, ":") || Q_strstr(pFileList, "..") || Q_strstr(pFileList, "\\"))
{
Con_Printf("Unable to open %s (contains illegal characters)\n", pFileList);
return;
}
pFile = FS_Open(pFileList, "rb");
if (!pFile)
{
Con_Printf("Unable to open %s\n", pFileList);
return;
}
length = FS_Size(pFile);
if (length > 0)
{
char* buf = (char *)Mem_Malloc(length + 1);
if (buf)
{
FS_Read(buf, length, 1, pFile);
buf[length] = 0;
char* now = buf;
Con_Printf("motd:");
next = Q_strchr(now, '\n');
while (next != NULL)
{
*next = 0;
Con_Printf("%s\n", now);
now = next + 1;
next = Q_strchr(now, '\n');
}
Con_Printf("%s\n", now);
Mem_Free(buf);
}
}
FS_Close(pFile);
}
void Host_Motd_Write_f(void)
{
char newFile[2048] = "";
unsigned int i;
FileHandle_t pFile;
if (!g_psv.active || cmd_source != src_command || g_pcls.state)
return;
if (!IsSafeFileToDownload(motdfile.string) || !Q_strstr(motdfile.string, ".txt"))
{
Con_Printf("Invalid motdfile name (%s)\n", motdfile.string);
return;
}
pFile = FS_Open(motdfile.string, "wb+");
if (!pFile)
{
Con_Printf("Unable to open %s\n", motdfile.string);
return;
}
#ifdef REHLDS_FIXES
if (Cmd_Args()) {
Q_strncpy(newFile, Cmd_Args(), ARRAYSIZE(newFile) - 1);
newFile[ARRAYSIZE(newFile) - 1] = '\0';
}
#else // REHLDS_FIXES
Q_strncpy(newFile, Cmd_Args(), ARRAYSIZE(newFile));
#endif // REHLDS_FIXES
auto len = Q_strlen(newFile);
for (i = 0; i < len; i++)
{
if (newFile[i] == '\\' && newFile[i + 1] == 'n')
{
newFile[i] = '\n';
Q_memmove(&newFile[i + 1], &newFile[i + 2], Q_strlen(&newFile[i + 2]) + 1);
}
}
FS_Write(newFile, Q_strlen(newFile), 1, pFile);
FS_Close(pFile);
Con_Printf("Done.\n");
}
int Host_GetStartTime(void)
{
return startTime;
......@@ -3114,8 +3024,6 @@ void Host_InitCommands(void)
Cmd_AddCommand("unpause", Host_Unpause_f);
Cmd_AddCommand("kick", Host_Kick_f);
Cmd_AddCommand("ping", Host_Ping_f);
Cmd_AddCommand("motd", Host_Motd_f);
Cmd_AddCommand("motd_write", Host_Motd_Write_f);
Cmd_AddCommand("stats", Host_Stats_f);
Cmd_AddCommand("load", Host_Loadgame_f);
Cmd_AddCommand("save", Host_Savegame_f);
......
......@@ -101,8 +101,6 @@ extern char *g_pPostRestartCmdLineArgs;
void SV_GetPlayerHulls(void);
void Host_InitializeGameDLL(void);
void Host_Motd_f(void);
void Host_Motd_Write_f(void);
int Host_GetStartTime(void);
void Host_UpdateStats(void);
void GetStatsString(char *buf, int bufSize);
......
......@@ -127,7 +127,7 @@ cvar_t sv_wateramp = { "sv_wateramp", "0", 0, 0.0f, NULL };
cvar_t sv_skyname = { "sv_skyname", "desert", 0, 0.0f, NULL };
cvar_t mapcyclefile = { "mapcyclefile", "mapcycle.txt", 0, 0.0f, NULL };
cvar_t motdfile = { "motdfile", "motd.txt", 0, 0.0f, NULL };
cvar_t motdfile = { "motdfile", "MOTD.txt", 0, 0.0f, NULL }; // TODO: this is a deprecated code, but it is needed for compatibility with other modifications, from which there is no source. Accordingly, we must add a macro to exclude the code when we implement the engine assembly for each game separately.
cvar_t servercfgfile = { "servercfgfile", "server.cfg", 0, 0.0f, NULL };
cvar_t lservercfgfile = { "lservercfgfile", "listenserver.cfg", 0, 0.0f, NULL };
cvar_t logsdir = { "logsdir", "logs", 0, 0.0f, NULL };
......