mirror of
https://github.com/dashr9230/SA-MP.git
synced 2024-12-22 14:37:29 +08:00
[server] Implement LoadLogFile and some parts of logprintf
This commit is contained in:
parent
2d4252fbde
commit
6e5a70c61f
@ -1,6 +1,75 @@
|
||||
|
||||
int main()
|
||||
#include "main.h"
|
||||
|
||||
FILE *pLogFile;
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
void LoadLogFile()
|
||||
{
|
||||
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\".");
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
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));
|
||||
|
||||
// TODO: main
|
||||
|
||||
fclose(pLogFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
|
33
server/main.h
Normal file
33
server/main.h
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
#ifndef SAMPSRV_MAIN_H
|
||||
#define SAMPSRV_MAIN_H
|
||||
|
||||
// ------------
|
||||
// VERSION INFO
|
||||
// ------------
|
||||
|
||||
#define SAMP_VERSION "0.3.7-R2"
|
||||
|
||||
// ------------
|
||||
// OS SPECIFICS
|
||||
// ------------
|
||||
|
||||
#ifdef WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <windows.h>
|
||||
#include <time.h>
|
||||
#else
|
||||
#endif
|
||||
|
||||
// --------
|
||||
// INCLUDES
|
||||
// --------
|
||||
|
||||
// Regular crap
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void logprintf(char* format, ...);
|
||||
|
||||
#endif // SAMPSRV_MAIN_H
|
Binary file not shown.
Binary file not shown.
@ -111,6 +111,9 @@
|
||||
<File
|
||||
RelativePath=".\main.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\main.h">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
Loading…
Reference in New Issue
Block a user