summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-10-18 13:21:34 +0200
committerHaru <haru@dotalux.com>2014-04-17 06:09:49 +0200
commit7b12dd06420fae973fbcc2f81f5d385e59788c78 (patch)
tree5bad1c4f2e44f5d4b49c82fafdd46177d15b9b97 /src/map
parent8a84d46a19b0112b7e2417728b8816e8b34b7383 (diff)
downloadhercules-7b12dd06420fae973fbcc2f81f5d385e59788c78.tar.gz
hercules-7b12dd06420fae973fbcc2f81f5d385e59788c78.tar.bz2
hercules-7b12dd06420fae973fbcc2f81f5d385e59788c78.tar.xz
hercules-7b12dd06420fae973fbcc2f81f5d385e59788c78.zip
Added sysinfo (System Information) functionalities
- More informative messages are displayed during startup, to make it easier to identify what system and environment Hercules is running. - Git/SVN revision detection is improved, separating the source version (cached at compile time) from the runtime version, in case the user updated their working copy without recompiling the server. Git version detection is also more reliable, in case a non-default branch is used. - The get_revision script command has been removed (as it was useless to begin with, after the switch to git). An alternative will be provided later, for feature-probing purposes. - The patch was tested under Linux (Gentoo / gcc 4.7 on i686 and x86_64, Debian 6 / gcc 4.4 on i686, Raspbian / gcc 4.6 on armv6l, CentOS 5 / gcc 4.1 on i686, CentOS 6 / gcc 4.4 on x86_64, Linux Mint 15 / gcc 4.7 on x86_64, OS X Mountain Lion / clang 5.0 and gcc 4.8 on x86_64, Cygwin-NT-5.1/gcc 4.8 on i686, FreeBSD 8 / gcc 4.2 on i386, FreeBSD 9 / gcc 4.2 on amd64, FreeBSD 10 / clang 3.3 on amd64, NetBSD 5 / gcc 4.1 on i386, NetBSD 6 / gcc 4.5 on amd64, OpenBSD 5 / gcc 4.2 on amd64, Solaris 11 / gcc 4.5 on i86pc, Windows 7 / Visual Studio 2012 on x86, Windows 8 / Visual Studio 2010 on WOW64, Windows 8.1 / Visual Studio 2013 on WOW64. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/Makefile.in9
-rw-r--r--src/map/atcommand.c18
-rw-r--r--src/map/battle.c8
-rw-r--r--src/map/map.c3
-rw-r--r--src/map/pc.c10
-rw-r--r--src/map/script.c17
6 files changed, 24 insertions, 41 deletions
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index e3a47abeb..e4f2d9953 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -1,9 +1,12 @@
+# Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+# See the LICENSE file
CONFIG_D = ../config
CONFIG_H = $(wildcard $(CONFIG_D)/*.h) $(wildcard $(CONFIG_D)/*/*.h)
COMMON_D = ../common
COMMON_H = $(wildcard $(COMMON_D)/*.h)
+SYSINFO_INC = $(COMMON_D)/sysinfo.inc
LIBCONFIG_D = ../../3rdparty/libconfig
LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
@@ -33,7 +36,7 @@ MAP_H = atcommand.h battle.h battleground.h buyingstore.h chat.h chrif.h \
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
- MAP_SERVER_SQL_DEPENDS=$(MAP_OBJ) $(COMMON_D)/obj_sql/common_sql.a $(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ)
+ MAP_SERVER_SQL_DEPENDS=$(MAP_OBJ) $(COMMON_D)/obj_sql/common_sql.a $(COMMON_D)/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ $(SYSINFO_INC))
else
MAP_SERVER_SQL_DEPENDS=needs_mysql
endif
@@ -79,6 +82,10 @@ help:
Makefile: Makefile.in
@$(MAKE) -C ../.. src/map/Makefile
+$(SYSINFO_INC): $(MAP_C) $(MAP_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H)
+ @echo " MAKE $@"
+ @$(MAKE) -C ../.. sysinfo
+
needs_mysql:
@echo "MySQL not found or disabled by the configure script"
@exit 1
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 9e33f3c68..6668214fa 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -14,6 +14,7 @@
#include "../common/strlib.h"
#include "../common/utils.h"
#include "../common/conf.h"
+#include "../common/sysinfo.h"
#include "atcommand.h"
#include "battle.h"
@@ -7208,18 +7209,11 @@ ACMD(whereis)
}
ACMD(version) {
- const char *git = get_git_hash();
- const char *svn = get_svn_revision();
-
- if ( git[0] != HERC_UNKNOWN_VER ) {
- sprintf(atcmd_output,msg_txt(1295),git); // Git Hash '%s'
- clif->message(fd,atcmd_output);
- } else if ( svn[0] != HERC_UNKNOWN_VER ) {
- sprintf(atcmd_output,msg_txt(1294),git); // SVN r%s
- clif->message(fd,atcmd_output);
- } else
- clif->message(fd,msg_txt(1296)); // Cannot determine version
-
+ sprintf(atcmd_output, msg_txt(1296), sysinfo->is64bit() ? 64 : 32, sysinfo->platform()); // Hercules %d-bit for %s
+ clif->message(fd, atcmd_output);
+ sprintf(atcmd_output, msg_txt(1295), sysinfo->vcstype(), sysinfo->vcsrevision_src(), sysinfo->vcsrevision_scripts()); // %s revision '%s' (src) / '%s' (scripts)
+ clif->message(fd, atcmd_output);
+
return true;
}
diff --git a/src/map/battle.c b/src/map/battle.c
index 2217ccecc..d64c14b2f 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -12,6 +12,7 @@
#include "../common/socket.h"
#include "../common/strlib.h"
#include "../common/utils.h"
+#include "../common/sysinfo.h"
#include "../common/HPM.h"
#include "map.h"
@@ -6748,8 +6749,6 @@ static const struct _battle_data {
void Hercules_report(char* date, char *time_c) {
int i, bd_size = ARRAYLENGTH(battle_data);
unsigned int config = 0;
- const char *svn = get_svn_revision();
- const char *git = get_git_hash();
char timestring[25];
time_t curtime;
char* buf;
@@ -6776,6 +6775,9 @@ void Hercules_report(char* date, char *time_c) {
C_SEND_SHORTLIST = 0x40000,
};
+ // TODO[Haru]: Add sysinfo->platform(), sysinfo->osversion(), sysinfo->cpu(), sysinfo->arch(),
+ // sysinfo->vcstype(), sysinfo->vcsrevision_scripts() to the stat server
+
/* we get the current time */
time(&curtime);
strftime(timestring, 24, "%Y-%m-%d %H:%M:%S", localtime(&curtime));
@@ -6867,7 +6869,7 @@ void Hercules_report(char* date, char *time_c) {
safestrncpy((char*)WBUFP(buf,6 + 12), time_c, 9);
safestrncpy((char*)WBUFP(buf,6 + 12 + 9), timestring, 24);
- safestrncpy((char*)WBUFP(buf,6 + 12 + 9 + 24), git[0] != HERC_UNKNOWN_VER ? git : svn[0] != HERC_UNKNOWN_VER ? svn : "Unknown", 41);
+ safestrncpy((char*)WBUFP(buf,6 + 12 + 9 + 24), sysinfo->vcsrevision_src(), 41);
WBUFL(buf,6 + 12 + 9 + 24 + 41) = map->getusers();
WBUFL(buf,6 + 12 + 9 + 24 + 41 + 4) = config;
diff --git a/src/map/map.c b/src/map/map.c
index a423e6973..7adeee3d5 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -5373,9 +5373,6 @@ void map_helpscreen(bool do_exit)
* Map-Server Version Screen [MC Cameri]
*------------------------------------------------------*/
void map_versionscreen(bool do_exit) {
- const char *svn = get_svn_revision();
- const char *git = get_git_hash();
- ShowInfo(CL_WHITE"Hercules version: %s" CL_RESET"\n", git[0] != HERC_UNKNOWN_VER ? git : svn[0] != HERC_UNKNOWN_VER ? svn : "Unknown");
ShowInfo(CL_GREEN"Website/Forum:"CL_RESET"\thttp://hercules.ws/\n");
ShowInfo(CL_GREEN"IRC Channel:"CL_RESET"\tirc://irc.rizon.net/#Hercules\n");
ShowInfo("Open "CL_WHITE"readme.txt"CL_RESET" for more information.\n");
diff --git a/src/map/pc.c b/src/map/pc.c
index 848238ed2..afb06527d 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -14,6 +14,7 @@
#include "../common/utils.h"
#include "../common/conf.h"
#include "../common/mmo.h" //NAME_LENGTH
+#include "../common/sysinfo.h"
#include "pc.h"
#include "atcommand.h" // get_atcommand_level()
@@ -1147,15 +1148,8 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
if( !changing_mapservers ) {
if (battle_config.display_version == 1) {
- const char* svn = get_svn_revision();
- const char* git = get_git_hash();
char buf[256];
- if( git[0] != HERC_UNKNOWN_VER )
- sprintf(buf,"Git Hash: %s", git);
- else if( svn[0] != HERC_UNKNOWN_VER )
- sprintf(buf,"SVN Revision: %s", svn);
- else
- sprintf(buf,"Unknown Version");
+ sprintf(buf, msg_txt(1295), sysinfo->vcstype(), sysinfo->vcsrevision_src(), sysinfo->vcsrevision_scripts()); // %s revision '%s' (src) / '%s' (scripts)
clif->message(sd->fd, buf);
}
diff --git a/src/map/script.c b/src/map/script.c
index 312e40696..8ac657f93 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -12,6 +12,7 @@
#include "../common/strlib.h"
#include "../common/timer.h"
#include "../common/utils.h"
+#include "../common/sysinfo.h"
#include "map.h"
#include "path.h"
@@ -4499,6 +4500,8 @@ int script_reload(void) {
itemdb->name_constants();
+ sysinfo->vcsrevision_reload();
+
return 0;
}
/* returns name of current function being run, from within the stack [Ind/Hercules] */
@@ -17315,19 +17318,6 @@ BUILDIN(is_function) {
return true;
}
/**
- * get_revision() -> retrieves the current svn revision (if available)
- **/
-BUILDIN(get_revision) {
- const char *svn = get_svn_revision();
-
- if ( svn[0] != HERC_UNKNOWN_VER )
- script_pushint(st,atoi(svn));
- else
- script_pushint(st,-1);//unknown
-
- return true;
-}
-/**
* freeloop(<toggle>) -> toggles this script instance's looping-check ability
**/
BUILDIN(freeloop) {
@@ -19152,7 +19142,6 @@ void script_parse_builtin(void) {
BUILDIN_DEF(getargcount,""),
BUILDIN_DEF(getcharip,"?"),
BUILDIN_DEF(is_function,"s"),
- BUILDIN_DEF(get_revision,""),
BUILDIN_DEF(freeloop,"i"),
BUILDIN_DEF(getrandgroupitem,"ii"),
BUILDIN_DEF(cleanmap,"s"),