2023-10-19 08:02:29 +08:00
|
|
|
|
2023-10-20 08:31:31 +08:00
|
|
|
#include "main.h"
|
|
|
|
|
2023-10-25 00:01:33 +08:00
|
|
|
CConsole *pConsole = NULL;
|
|
|
|
|
2023-10-20 08:31:31 +08:00
|
|
|
FILE *pLogFile;
|
|
|
|
|
|
|
|
//----------------------------------------------------
|
|
|
|
|
|
|
|
void LoadLogFile()
|
2023-10-19 08:02:29 +08:00
|
|
|
{
|
2023-10-20 08:31:31 +08:00
|
|
|
int reload = 0;
|
|
|
|
if (pLogFile)
|
|
|
|
{
|
|
|
|
fclose(pLogFile);
|
|
|
|
reload = 1;
|
|
|
|
}
|
|
|
|
pLogFile = fopen("server_log.txt", "a");
|
|
|
|
if (pLogFile)
|
|
|
|
{
|
|
|
|
logprintf("");
|
|
|
|
logprintf("----------");
|
|
|
|
if (reload) logprintf("Reloaded log file: \"server_log.txt\".");
|
|
|
|
else logprintf("Loaded log file: \"server_log.txt\".");
|
|
|
|
logprintf("----------");
|
|
|
|
} else {
|
|
|
|
logprintf("Failed to load log file: \"server_log.txt\".");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-25 00:01:33 +08:00
|
|
|
#ifdef LINUX
|
|
|
|
|
|
|
|
// strlwr is not included with the GNU C lib it seems.
|
|
|
|
char* strlwr(char* str)
|
|
|
|
{
|
|
|
|
size_t maxlen=strlen(str);
|
|
|
|
for (size_t i=0; i<maxlen; i++)
|
|
|
|
{
|
|
|
|
if ((str[i] >= 'A') && (str[i] <= 'Z'))
|
|
|
|
{
|
|
|
|
str[i] -= 32;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // #ifdef LINUX
|
|
|
|
|
2023-10-20 08:31:31 +08:00
|
|
|
//----------------------------------------------------
|
|
|
|
|
|
|
|
int main (int argc, char** argv)
|
|
|
|
{
|
|
|
|
|
|
|
|
// Open the log file
|
|
|
|
LoadLogFile();
|
|
|
|
|
|
|
|
// Write welcome message.
|
|
|
|
logprintf("");
|
|
|
|
logprintf("SA-MP Dedicated Server");
|
|
|
|
logprintf("----------------------");
|
|
|
|
logprintf("v" SAMP_VERSION ", (C)2005-2015 SA-MP Team\n");
|
|
|
|
|
|
|
|
srand(time(NULL));
|
|
|
|
|
2023-10-25 00:01:33 +08:00
|
|
|
// Create the Console
|
|
|
|
pConsole = new CConsole();
|
|
|
|
|
2023-10-19 08:02:29 +08:00
|
|
|
// TODO: main
|
2023-10-20 08:31:31 +08:00
|
|
|
|
|
|
|
fclose(pLogFile);
|
|
|
|
|
2023-10-19 08:02:29 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2023-10-20 08:31:31 +08:00
|
|
|
|
|
|
|
//----------------------------------------------------
|
|
|
|
|
|
|
|
void logprintf(char* format, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, format);
|
|
|
|
|
|
|
|
char buffer[2048];
|
|
|
|
vsprintf(buffer, format, ap);
|
|
|
|
|
|
|
|
va_end(ap);
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
char output[2048];
|
|
|
|
CharToOem(buffer, output);
|
|
|
|
puts(output);
|
|
|
|
fflush(stdout);
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// TODO: logprintf
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------
|