From 6e5a70c61f768ffa8870a7bda028d86adc0ab773 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Fri, 20 Oct 2023 08:31:31 +0800 Subject: [PATCH] [server] Implement LoadLogFile and some parts of logprintf --- server/main.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++- server/main.h | 33 ++++++++++++++++++++ server/server.ncb | Bin 19456 -> 27648 bytes server/server.suo | Bin 8192 -> 8704 bytes server/server.vcproj | 3 ++ 5 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 server/main.h 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 a1e45a7daf4186b875fe967f7d17548e85b5afab..f11011d90a84849dcc9488ca198e5d20fc2f7b66 100644 GIT binary patch literal 27648 zcmeHPO>7%Q6dpTn(-zwN(DKtlyNv{eR&3m)kg7_nL~W`D#UUgp1<5FNHk)LN?X}iU z(nBj%f&=1E2?(7~;_x8P+jOPS?*`KUfXWP#nJ7#4@&Rbn}I=y?>{&OP=lu{~z(*f`$FzG>klA|CX z2yAc!PX5q7zaS(C2m)IYfm?^}Y{~B}Us@0l1Qr(Fw2voxE~niF*fHN7x-;|RXEV>d z@?6(TpFcEup9PujGO$x8fBieO)g26Ek^tv0SeBL9FO`#d2lBos3!s z?xY*IMaS)5(m}g(DqGGKO3rLK-PtvK!W6QFoL9`2-C))YLfLjoCH=|Jls&(=_|f`S zR^HRJ+KDf>2TbSYr>AiM9RW9jS=<38!T(WxVAg*Rd@uL`@OJPU;CsMqvkm+Lco$em z5ZE9H?8bdw0>8*{5Yf$~7EVCNVekQ%KL4v=4u>n?`@wu>>;pH0o4_sLRxta#56s~u zBnSus^@{+jes3FYpt+2b5rNKzRAbtzF z#795x)Vc)B+x@CY9jk=(QtBynLH&wif|GryYg7l-arH4Or4|;Nv~CA%ga&m5I`TE} z>tJ?7dt)5@F3UoKfFSU{An*&uA8htp%F-Wy0Fk~&VGPiYH@b%v{;0eCX~O7QQR61t zwj53xT?;&b)6i|Nj{k&8;xC1^beDC#Bz%e;>U-9!>KfobH0fuI<@ljPfvX4cH-LIA zXwUN>o*`^2BnSusYeE3S3iM4foXbO5YeI4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