Browse Source

- 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://svn.code.sf.net/p/rathena/svn/trunk@8500 54d463be-8e91-2dee-dedb-b68131a5f0ec

toms 18 years ago
parent
commit
6dc1c19fdb
3 changed files with 49 additions and 12 deletions
  1. 3 0
      Changelog-Trunk.txt
  2. 35 10
      src/common/core.c
  3. 11 2
      src/map/mercenary.c

+ 3 - 0
Changelog-Trunk.txt

@@ -3,6 +3,9 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2006/08/27
+	* Updated svn-revision reading, now it can read the new svn file system [Toms]
+	* Fixed a bug with homunc which could spawn on a non-walkable cell [Toms]
 2006/08/26
 	* Optional macro MEMSET_TURBO for faster low-level memory initializations. [Lance]
 	* Small bug fix in read_homunculus_expdb (a warning was always displayed) [Toms]

+ 35 - 10
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();

+ 11 - 2
src/map/mercenary.c

@@ -588,7 +588,8 @@ int search_homunculusDB_index(int key,int type)
 int merc_hom_alloc(struct map_session_data *sd)
 {
 	struct homun_data *hd;
-	int i = 0 ;
+	int i = 0;
+	short x,y;
 
 	nullpo_retr(1, sd);
 
@@ -605,8 +606,16 @@ int merc_hom_alloc(struct map_session_data *sd)
 	hd->master = sd;
 
 	hd->bl.m = sd->bl.m;
+
+	// Find a random valid pos around the player
 	hd->bl.x = sd->bl.x;
-	hd->bl.y = sd->bl.y - 1 ;
+	hd->bl.y = sd->bl.y;
+	x = sd->bl.x + 1;
+	y = sd->bl.y + 1;
+	map_random_dir(&hd->bl, &x, &y);
+	hd->bl.x = x;
+	hd->bl.y = y;
+
 	hd->bl.subtype = MONS;
 	hd->bl.type = BL_HOM;
 	hd->bl.id = npc_get_new_npc_id();