diff options
-rw-r--r-- | Changelog.txt | 4 | ||||
-rw-r--r-- | src/common/GNUmakefile | 16 | ||||
-rw-r--r-- | src/common/Makefile | 16 | ||||
-rw-r--r-- | src/common/core.c | 25 | ||||
-rw-r--r-- | src/common/showmsg.c | 8 | ||||
-rw-r--r-- | src/common/showmsg.h | 26 | ||||
-rw-r--r-- | src/map/map.c | 4 |
7 files changed, 67 insertions, 32 deletions
diff --git a/Changelog.txt b/Changelog.txt index 52ef95715..59d433abc 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,4 +1,8 @@ Date Added +11/27 + * Added get_svn_revision() in core.c [MC Cameri] + -Only if you have the file .svn\entries, it will show the revision # at runtime. + 11/26 * Fixed Abrakadabra (2 minor bugs of consumed items - they were ignored if placed in 0 pos) [Lupus] * Finished Full Strip, Weapon Refine, Slim Pitcher and Full Protection. [celest] diff --git a/src/common/GNUmakefile b/src/common/GNUmakefile index d1a8ee0c6..b15d4d481 100644 --- a/src/common/GNUmakefile +++ b/src/common/GNUmakefile @@ -1,13 +1,13 @@ txt sql all: core.o socket.o timer.o grfio.o db.o lock.o nullpo.o malloc.o showmsg.o -core.o: core.c core.h -socket.o: socket.c socket.h mmo.h -timer.o: timer.c timer.h -grfio.o: grfio.c grfio.h -db.o: db.c db.h -lock.o: lock.h -nullpo.o: nullpo.c nullpo.h -malloc.o: malloc.c malloc.h +core.o: core.c core.h showmsg.h +socket.o: socket.c socket.h mmo.h showmsg.h +timer.o: timer.c timer.h showmsg.h +grfio.o: grfio.c grfio.h showmsg.h +db.o: db.c db.h showmsg.h +lock.o: lock.h showmsg.h +nullpo.o: nullpo.c nullpo.h showmsg.h +malloc.o: malloc.c malloc.h showmsg.h showmsg.o: showmsg.c showmsg.h clean: diff --git a/src/common/Makefile b/src/common/Makefile index d1a8ee0c6..b15d4d481 100644 --- a/src/common/Makefile +++ b/src/common/Makefile @@ -1,13 +1,13 @@ txt sql all: core.o socket.o timer.o grfio.o db.o lock.o nullpo.o malloc.o showmsg.o -core.o: core.c core.h -socket.o: socket.c socket.h mmo.h -timer.o: timer.c timer.h -grfio.o: grfio.c grfio.h -db.o: db.c db.h -lock.o: lock.h -nullpo.o: nullpo.c nullpo.h -malloc.o: malloc.c malloc.h +core.o: core.c core.h showmsg.h +socket.o: socket.c socket.h mmo.h showmsg.h +timer.o: timer.c timer.h showmsg.h +grfio.o: grfio.c grfio.h showmsg.h +db.o: db.c db.h showmsg.h +lock.o: lock.h showmsg.h +nullpo.o: nullpo.c nullpo.h showmsg.h +malloc.o: malloc.c malloc.h showmsg.h showmsg.o: showmsg.c showmsg.h clean: diff --git a/src/common/core.c b/src/common/core.c index 6bf68c47f..167b38efb 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -7,11 +7,13 @@ #include <unistd.h> #endif #include <signal.h> +#include <string.h> #include "core.h" #include "socket.h" #include "timer.h" #include "version.h" +#include "showmsg.h" #ifdef MEMWATCH #include "memwatch.h" @@ -51,6 +53,23 @@ static void sig_proc(int sn) } } +int get_svn_revision(char *svnentry) { // Warning: minor syntax checking + char line[1024]; + int rev = 0; + FILE *fp; + if ((fp = fopen(svnentry, "r")) == NULL) { + return 0; + } else { + while (fgets(line,1023,fp)) if (strstr(line,"revision=")) break; + fclose(fp); + if (sscanf(line," %*[^\"]\"%d%*[^\n]",&rev)==1) + return rev; + else + return 0; + } +// return 0; +} + /*====================================== * CORE : Display title *-------------------------------------- @@ -58,6 +77,7 @@ static void sig_proc(int sn) static void display_title(void) { + int revision; // for help with the console colors look here: // http://www.edoceo.com/liberum/?doc=printf-with-color // some code explanation (used here): @@ -82,6 +102,11 @@ static void display_title(void) printf("\033[0;44m (\033[1m \033[0;44m)\033[K\033[0m\n"); // yellow writing (33) printf("\033[0;44m (\033[1;33m Advanced Fusion Maps (c) 2003-2004 The Fusion Project \033[0;44m)\033[K\033[0m\n"); // yellow writing (33) printf("\033[37;44m (=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=)\033[K\033[0m\n\n"); // reset color + + if ((revision = get_svn_revision(".svn\\entries"))>0) { + snprintf(tmp_output,sizeof(tmp_output),"SVN Revision: %d.\n",revision); + ShowInfo(tmp_output); + } } // Added by Gabuzomeu diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 28bf58edc..56c41b89d 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -3,7 +3,9 @@ #include <string.h> #include "showmsg.h" -int _ShowMessage(const char *string, int flag){ // by MC Cameri +char tmp_output[1024] = "\0"; + +int _ShowMessage(const char *string, enum msg_type flag){ // by MC Cameri /* _ShowMessage MUST be used instead of printf as of 10/24/2004. Return: 0 = Successful, 1 = Failed. @@ -12,7 +14,7 @@ int _ShowMessage(const char *string, int flag){ // by MC Cameri char prefix[40]; char *output; if (strlen(string) <= 0) { - ShowMessage("Empty string passed to ShowMessage().\n",MSG_ERROR); + ShowError("Empty string passed to ShowMessage().\n"); return 1; } switch (flag) { @@ -40,7 +42,7 @@ int _ShowMessage(const char *string, int flag){ // by MC Cameri strcpy(prefix,"\033[1;31m[Fatal Error]\033[0;0m: "); break; default: - ShowMessage("In function ShowMessage() -> Invalid flag passed.\n",MSG_ERROR); + ShowError("In function _ShowMessage() -> Invalid flag passed.\n"); return 1; } output = (char*)malloc(sizeof(char)*(strlen(prefix)+strlen(string))+1); diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 2389410b3..03ffe310b 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -1,14 +1,20 @@ #ifndef _SHOWMSG_H_ #define _SHOWMSG_H_ +extern char tmp_output[1024]; + +enum msg_type {MSG_STATUS,/* MSG_SQL, */MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_ERROR,MSG_FATALERROR}; + +extern int _ShowMessage(const char *string, enum msg_type flag); + /* MSG_XX */ #define ShowMsg(string,flag) _ShowMessage(string,flag) - #define DisplayMsg(string,flag) _ShowMessage(string,flag) - #define ShowMessage(string,flag) _ShowMessage(string,flag) +// #define DisplayMsg(string,flag) _ShowMessage(string,flag) +// #define ShowMessage(string,flag) _ShowMessage(string,flag) /* MSG_STATUS */ #define ShowStatus(string) _ShowMessage(string,MSG_STATUS) - #define DisplayStatus(string) _ShowMessage(string,MSG_STATUS) +// #define DisplayStatus(string) _ShowMessage(string,MSG_STATUS) /* MSG_SQL*/ // #define ShowSQL(string) _ShowMessage(string,MSG_SQL) @@ -16,33 +22,29 @@ /* MSG_INFORMATION */ #define ShowInfo(string) _ShowMessage(string,MSG_INFORMATION) - #define DisplayInfo(string) _ShowMessage(string,MSG_INFORMATION) +// #define DisplayInfo(string) _ShowMessage(string,MSG_INFORMATION) // #define ShowInformation(string) _ShowMessage(string,MSG_INFORMATION) // #define DisplayInformation(string) _ShowMessage(string,MSG_INFORMATION) /* MSG_NOTICE */ #define ShowNotice(string) _ShowMessage(string,MSG_NOTICE) - #define DisplayNotice(string) _ShowMessage(string,MSG_NOTICE) +// #define DisplayNotice(string) _ShowMessage(string,MSG_NOTICE) /* */ #define ShowWarning(string) _ShowMessage(string,MSG_WARNING) - #define DisplayWarning(string) _ShowMessage(string,MSG_WARNING) +// #define DisplayWarning(string) _ShowMessage(string,MSG_WARNING) // #define Warn(string) _ShowMessage(string,MSG_WARNING) /* MSG_ERROR */ #define ShowError(string) _ShowMessage(string,MSG_ERROR) - #define DisplayError(string) _ShowMessage(string,MSG_ERROR) +// #define DisplayError(string) _ShowMessage(string,MSG_ERROR) // #define OutputError(string) _ShowMessage(string,MSG_ERROR) /* MSG_FATALERROR */ #define ShowFatalError(string) _ShowMessage(string,MSG_FATALERROR) - #define DisplayFatalError(string) _ShowMessage(string,MSG_ERROR) +// #define DisplayFatalError(string) _ShowMessage(string,MSG_ERROR) // #define Terminate(string) _ShowMessage(string,MSG_FATALERROR) // #define Kill(string) _ShowMessage(string,MSG_FATALERROR) // #define AbortEx(string) _ShowMessage(string,MSG_FATALERROR) -enum msg_type {MSG_STATUS,/* MSG_SQL, */MSG_INFORMATION,MSG_NOTICE,MSG_WARNING,MSG_ERROR,MSG_FATALERROR}; - -extern int _ShowMessage(const char *string, int flag); - #endif diff --git a/src/map/map.c b/src/map/map.c index 102354823..254883e93 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -37,6 +37,7 @@ #include "nullpo.h" #include "socket.h" #include "log.h" +#include "showmsg.h" #ifdef MEMWATCH #include "memwatch.h" @@ -1816,7 +1817,8 @@ int map_config_read(char *cfgName) { char_ip_set_ = 1; h = gethostbyname (w2); if(h != NULL) { - printf("Character server IP address : %s -> %d.%d.%d.%d\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); + snprintf(tmp_output,sizeof(tmp_output),"Character server IP address : %s -> %d.%d.%d.%d\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); + ShowInfo(tmp_output); sprintf(w2,"%d.%d.%d.%d", (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]); } chrif_setip(w2); |