diff --git a/server/main.cpp b/server/main.cpp index 3265b8a..2fa58a3 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -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 +} + +//---------------------------------------------------- diff --git a/server/main.h b/server/main.h new file mode 100644 index 0000000..2bf346b --- /dev/null +++ b/server/main.h @@ -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 + #include +#else +#endif + +// -------- +// INCLUDES +// -------- + +// Regular crap +#include +#include + +void logprintf(char* format, ...); + +#endif // SAMPSRV_MAIN_H diff --git a/server/server.ncb b/server/server.ncb index a1e45a7..f11011d 100644 Binary files a/server/server.ncb and b/server/server.ncb differ diff --git a/server/server.suo b/server/server.suo index 3a0c53f..4dcf6fa 100644 Binary files a/server/server.suo and b/server/server.suo differ diff --git a/server/server.vcproj b/server/server.vcproj index 89dccaa..7e142d2 100644 --- a/server/server.vcproj +++ b/server/server.vcproj @@ -111,6 +111,9 @@ + +