summaryrefslogtreecommitdiff
path: root/src/common/core.c
diff options
context:
space:
mode:
authortoms <toms@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-27 18:47:53 +0000
committertoms <toms@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-27 18:47:53 +0000
commit95edabf40aaa4b14c46d5e085360998f54c4dc69 (patch)
tree532b7c6da2de511b6e4bee3e29d0f9e90c248010 /src/common/core.c
parent3c8999edce9e1f0d5c0dee3ff8311e781d64c684 (diff)
downloadhercules-95edabf40aaa4b14c46d5e085360998f54c4dc69.tar.gz
hercules-95edabf40aaa4b14c46d5e085360998f54c4dc69.tar.bz2
hercules-95edabf40aaa4b14c46d5e085360998f54c4dc69.tar.xz
hercules-95edabf40aaa4b14c46d5e085360998f54c4dc69.zip
- Updated svn-revision reading, now it can read the new svn file system
- Fixed a bug with homunc which could spawn on a non-walkable cell git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8500 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/core.c')
-rw-r--r--src/common/core.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/src/common/core.c b/src/common/core.c
index fe16d26a9..6f9bb4548 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -8,6 +8,7 @@
#endif
#include <signal.h>
#include <string.h>
+#include <ctype.h>
#include "core.h"
#include "../common/db.h"
@@ -32,6 +33,7 @@ char **arg_v = NULL;
char *SERVER_NAME = NULL;
char SERVER_TYPE = ATHENA_SERVER_NONE;
static void (*term_func)(void) = NULL;
+static char eA_svn_version[10];
/*======================================
* CORE : Set function
@@ -130,23 +132,45 @@ void signals_init (void)
#else
const char* get_svn_revision(void)
{
- static char version[10];
FILE *fp;
- if ((fp = fopen(".svn/entries", "r")) != NULL) {
+ if(*eA_svn_version)
+ return eA_svn_version;
+
+ if ((fp = fopen(".svn/entries", "r")))
+ {
char line[1024];
int rev;
- while (fgets(line,1023,fp))
- if (strstr(line,"revision=")) break;
- fclose(fp);
- if (sscanf(line," %*[^\"]\"%d%*[^\n]", &rev) == 1) {
- sprintf(version, "%d", rev);
- return version;
+ // Check the version
+ if (fgets(line,sizeof(line),fp))
+ {
+ if(!isdigit(line[0]))
+ {
+ // XML File format
+ while (fgets(line,sizeof(line),fp))
+ if (strstr(line,"revision=")) break;
+ fclose(fp);
+ if (sscanf(line," %*[^\"]\"%d%*[^\n]", &rev) == 1) {
+ snprintf(eA_svn_version, sizeof(eA_svn_version), "%d", rev);
+ }
+ }
+ else
+ {
+ // Bin File format
+ fgets(line,sizeof(line),fp); // Get the name
+ fgets(line,sizeof(line),fp); // Get the entries kind
+ if(fgets(line,sizeof(line),fp)) // Get the rev numver
+ {
+ snprintf(eA_svn_version, sizeof(eA_svn_version), "%d", atoi(line));
+ }
+ }
}
}
- // if getting revision has failed
- return "Unknown";
+ if(!(*eA_svn_version))
+ snprintf(eA_svn_version, sizeof(eA_svn_version), "Unknown");
+
+ return eA_svn_version;
}
#endif
@@ -207,6 +231,7 @@ int main (int argc, char **argv)
SERVER_NAME = ++p;
arg_c = argc;
arg_v = argv;
+ *eA_svn_version = '\0';
}
set_server_type();