Browse Source

update

git-svn-id: https://svn.code.sf.net/p/rathena/svn/branches/stable@829 54d463be-8e91-2dee-dedb-b68131a5f0ec
amber 20 năm trước cách đây
mục cha
commit
0a9e77526d
2 tập tin đã thay đổi với 26 bổ sung26 xóa
  1. 1 0
      Changelog.txt
  2. 25 26
      src/map/map.c

+ 1 - 0
Changelog.txt

@@ -1,5 +1,6 @@
 Date	Added
 12/27
+	* Modified the map progress bar to reduce updates (SVN 829) [MouseJstr]
         * Updated map cache system from jA 1087 - change read_map_from_bitmap to 2 to
           enable zlib compression [celest]
 	* don't delete alive_timers of -1  (SVN 823) [MouseJstr]

+ 25 - 26
src/map/map.c

@@ -1882,7 +1882,7 @@ static int map_readafm(int m,char *fn) {
 /*==========================================
  * ƒ}ƒbƒv1–‡“Ç‚Ý�ž‚Ý
  * ===================================================*/
-static int map_readmap(int m,char *fn, char *alias, int *map_cache) {
+static int map_readmap(int m,char *fn, char *alias, int *map_cache, int maxmap) {
 	unsigned char *gat="";
 	size_t size;
 	
@@ -1892,14 +1892,28 @@ static int map_readmap(int m,char *fn, char *alias, int *map_cache) {
 
 	//printf("\rLoading Maps [%d/%d]: %-50s  ",m,map_num,fn);
 	if (map_num) { //avoid map-server crashing if there are 0 maps
-		printf("\r");
-		ShowStatus("Progress: ");
-		i=m*20/420;
-		printf("[");
-		for (e=0;e<i;e++) progress[e] = '#';
-		printf(progress);
-		printf("] Working: [");
-		fflush(stdout);
+		char c;
+		static int lasti = -1;
+		static int last_time = -1;
+		i=m*20/maxmap;
+		if ((i != lasti) || (last_time != time(0))) {
+			lasti = i;
+			printf("\r");
+			ShowStatus("Progress: ");
+			printf("[");
+			for (e=0;e<i;e++) progress[e] = '#';
+			printf(progress);
+			printf("] Working: [");
+			last_time = time(0);
+			switch(last_time % 4) {
+				case 0: c='\\'; break;
+				case 1: c='|'; break;
+				case 2: c='/'; break;
+				case 3: c='-'; break;
+			}
+			printf("%c]",c);
+			fflush(stdout);
+		}
 	}
 
 	if(map_cache_read(&map[m])) {
@@ -1970,9 +1984,6 @@ static int map_readmap(int m,char *fn, char *alias, int *map_cache) {
 int map_readallmap(void) {
 	int i,maps_removed=0;
 	char fn[256];
-	char c = '-';
-	time_t last_time = time(0);
-	int busy = 0;
 #ifdef USE_AFM
 	FILE *afm_file;
 #endif
@@ -2024,23 +2035,11 @@ int map_readallmap(void) {
 				map[i].alias = NULL;
 
 			sprintf(fn,"data\\%s",map[i].name);
-			if(map_readmap(i,fn, p, &map_cache) == -1) {
+			if(map_readmap(i,fn, p, &map_cache, map_num) == -1) {
 				map_delmap(map[i].name);
 				maps_removed++;
 				i--;
-			} else {
-				if (last_time != time(0)) {
-					last_time = time(0);
-					switch(busy) {
-						case 0: c='\\'; busy++; break;
-						case 1: c='|'; busy++; break;
-						case 2: c='/'; busy++; break;
-						case 3: c='-'; busy=0;
-					}
-				}
-				printf("%c]",c);
-				fflush(stdout);
-			}
+			} 
 		}
 	}