瀏覽代碼

- Fame list size is now defined by MAX_FAME_LIST constant (mmo.h)
- Char server can now specify the max size for blacksmith/alchemist/taekwon rankers.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5435 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 19 年之前
父節點
當前提交
8a67a7cf35
共有 9 個文件被更改,包括 98 次插入24 次删除
  1. 4 0
      Changelog-Trunk.txt
  2. 5 0
      conf-tmpl/char_athena.conf
  3. 26 3
      src/char/char.c
  4. 29 6
      src/char_sql/char.c
  5. 2 0
      src/common/mmo.h
  6. 3 3
      src/map/chrif.c
  7. 20 3
      src/map/clif.c
  8. 6 6
      src/map/pc.c
  9. 3 3
      src/map/pc.h

+ 4 - 0
Changelog-Trunk.txt

@@ -5,6 +5,10 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.  EV
 GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS
 
 2006/03/02
+	* Max fame list size is now defined by MAX_FAME_LIST constant (mmo.h)
+	  [Skotlex]
+	* Individual fame lists sizes can now be specified through the char-server
+	  (check the fame list configs in char_athena.conf) [Skotlex]
 	* Some cleanup on mob_can_reach code to prevent unnecessary path-searching
 	  [Skotlex]
 	* Optimized the path-searching ai for mobs to try target cells around the

+ 5 - 0
conf-tmpl/char_athena.conf

@@ -133,6 +133,11 @@ start_armor: 2301
 // Starting zeny for new characters
 start_zeny: 0
 
+// Size for the fame-lists
+fame_list_alchemist: 10
+fame_list_blacksmith: 10
+fame_list_taekwon: 10
+
 // Name used for unknown characters
 unknown_char_name: Unknown
 

+ 26 - 3
src/char/char.c

@@ -128,6 +128,11 @@ int start_zeny = 500;
 int start_weapon = 1201;
 int start_armor = 2301;
 
+//Custom limits for the fame lists. [Skotlex]
+int fame_list_size_chemist = MAX_FAME_LIST;
+int fame_list_size_smith = MAX_FAME_LIST;
+int fame_list_size_taekwon = MAX_FAME_LIST;
+
 // Initial position (it's possible to set it in conf file)
 struct point start_point = { 0, 53, 111};
 
@@ -2888,7 +2893,7 @@ int parse_frommap(int fd) {
 			// starting to send to map
 			WBUFW(buf,0) = 0x2b1b;
 			// add list for blacksmiths
-			for (i = 0, j = 0; i < char_num && j < 10; i++) {
+			for (i = 0, j = 0; i < char_num && j < fame_list_size_smith; i++) {
 				if (char_dat[id[i]].status.fame && (char_dat[id[i]].status.class_ == 10 ||
 					char_dat[id[i]].status.class_ == 4011 ||
 					char_dat[id[i]].status.class_ == 4033))
@@ -2906,7 +2911,7 @@ int parse_frommap(int fd) {
 			WBUFW(buf, 6) = len;
 			
 			// add list for alchemists
-			for (i = 0, j = 0; i < char_num && j < 10; i++) {
+			for (i = 0, j = 0; i < char_num && j < fame_list_size_chemist; i++) {
 				if (char_dat[id[i]].status.fame && (char_dat[id[i]].status.class_ == 18 ||
 					char_dat[id[i]].status.class_ == 4019 ||
 					char_dat[id[i]].status.class_ == 4041))
@@ -2924,7 +2929,7 @@ int parse_frommap(int fd) {
 			WBUFW(buf, 4) = len;
 
 			// adding list for taekwons
-			for (i = 0, j = 0; i < char_num && j < 10; i++) {
+			for (i = 0, j = 0; i < char_num && j < fame_list_size_taekwon; i++) {
 				if (char_dat[id[i]].status.fame && char_dat[id[i]].status.class_ == 4046)
 				{
 					fame_item.id = char_dat[id[i]].status.char_id;
@@ -3997,6 +4002,24 @@ int char_config_read(const char *cfgName) {
 		} else if (strcmpi(w1, "console") == 0) {
 			if(strcmpi(w2,"on") == 0 || strcmpi(w2,"yes") == 0 )
 				console = 1;
+		} else if (strcmpi(w1, "fame_list_alchemist") == 0) {
+			fame_list_size_chemist = atoi(w2);
+			if (fame_list_size_chemist > MAX_FAME_LIST) {
+				ShowWarning("Max fame list size is %d (fame_list_alchemist)\n", MAX_FAME_LIST);
+				fame_list_size_chemist = MAX_FAME_LIST;
+			}
+		} else if (strcmpi(w1, "fame_list_blacksmith") == 0) {
+			fame_list_size_smith = atoi(w2);
+			if (fame_list_size_smith > MAX_FAME_LIST) {
+				ShowWarning("Max fame list size is %d (fame_list_blacksmith)\n", MAX_FAME_LIST);
+				fame_list_size_smith = MAX_FAME_LIST;
+			}
+		} else if (strcmpi(w1, "fame_list_taekwon") == 0) {
+			fame_list_size_taekwon = atoi(w2);
+			if (fame_list_size_taekwon > MAX_FAME_LIST) {
+				ShowWarning("Max fame list size is %d (fame_list_taekwon)\n", MAX_FAME_LIST);
+				fame_list_size_taekwon = MAX_FAME_LIST;
+			}
 		} else if (strcmpi(w1, "import") == 0) {
 			char_config_read(w2);
 		}

+ 29 - 6
src/char_sql/char.c

@@ -146,6 +146,11 @@ int start_zeny = 500;
 int start_weapon = 1201;
 int start_armor = 2301;
 
+//Custom limits for the fame lists. [Skotlex]
+int fame_list_size_chemist = MAX_FAME_LIST;
+int fame_list_size_smith = MAX_FAME_LIST;
+int fame_list_size_taekwon = MAX_FAME_LIST;
+
 // check for exit signal
 // 0 is saving complete
 // other is char_id
@@ -2751,7 +2756,7 @@ int parse_frommap(int fd) {
 			struct fame_list fame_item;
 
 			WBUFW(buf,0) = 0x2b1b;
-			sprintf(tmp_sql, "SELECT `char_id`,`fame`, `name` FROM `%s` WHERE `fame`>0 AND (`class`='10' OR `class`='4011'OR `class`='4033') ORDER BY `fame` DESC LIMIT 0,10", char_db);
+			sprintf(tmp_sql, "SELECT `char_id`,`fame`, `name` FROM `%s` WHERE `fame`>0 AND (`class`='10' OR `class`='4011'OR `class`='4033') ORDER BY `fame` DESC LIMIT 0,%d", char_db, fame_list_size_smith);
 			if (mysql_query(&mysql_handle, tmp_sql)) {
 				ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
 				ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
@@ -2765,7 +2770,7 @@ int parse_frommap(int fd) {
 
 					memcpy(WBUFP(buf,len), &fame_item, sizeof(struct fame_list));
 					len += sizeof(struct fame_list);
-					if (++num == 10)
+					if (++num == fame_list_size_smith)
 						break;
 				}
    			mysql_free_result(sql_res);
@@ -2773,7 +2778,7 @@ int parse_frommap(int fd) {
 			WBUFW(buf, 6) = len; //Blacksmith block size
 
 			num = 0;
-			sprintf(tmp_sql, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='18' OR `class`='4019' OR `class`='4041') ORDER BY `fame` DESC LIMIT 0,10", char_db);
+			sprintf(tmp_sql, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND (`class`='18' OR `class`='4019' OR `class`='4041') ORDER BY `fame` DESC LIMIT 0,%d", char_db, fame_list_size_chemist);
 			if (mysql_query(&mysql_handle, tmp_sql)) {
 				ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
 				ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
@@ -2786,7 +2791,7 @@ int parse_frommap(int fd) {
 					strncpy(fame_item.name, sql_row[2], NAME_LENGTH);
 					memcpy(WBUFP(buf,len), &fame_item, sizeof(struct fame_list));
 					len += sizeof(struct fame_list);
-					if (++num == 10)
+					if (++num == fame_list_size_chemist)
 						break;
 				}
 				mysql_free_result(sql_res);
@@ -2794,7 +2799,7 @@ int parse_frommap(int fd) {
 			WBUFW(buf, 4) = len; //Alchemist block size
 
 			num = 0;
-			sprintf(tmp_sql, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND `class`='4046' ORDER BY `fame` DESC LIMIT 0,10", char_db);
+			sprintf(tmp_sql, "SELECT `char_id`,`fame`,`name` FROM `%s` WHERE `fame`>0 AND `class`='4046' ORDER BY `fame` DESC LIMIT 0,%d", char_db, fame_list_size_taekwon);
 			if (mysql_query(&mysql_handle, tmp_sql)) {
 				ShowSQL("DB error - %s\n",mysql_error(&mysql_handle));
 				ShowDebug("at %s:%d - %s\n", __FILE__,__LINE__,tmp_sql);
@@ -2807,7 +2812,7 @@ int parse_frommap(int fd) {
 					strncpy(fame_item.name, sql_row[2], NAME_LENGTH);
 					memcpy(WBUFP(buf,len), &fame_item, sizeof(struct fame_list));
 					len += sizeof(struct fame_list);
-					if (++num == 10)
+					if (++num == fame_list_size_taekwon)
 						break;
 				}
 				mysql_free_result(sql_res);
@@ -4039,6 +4044,24 @@ int char_config_read(const char *cfgName) {
 		} else if (strcmpi(w1, "console") == 0) {
 			if(strcmpi(w2,"on") == 0 || strcmpi(w2,"yes") == 0 )
 				console = 1;
+		} else if (strcmpi(w1, "fame_list_alchemist") == 0) {
+			fame_list_size_chemist = atoi(w2);
+			if (fame_list_size_chemist > MAX_FAME_LIST) {
+				ShowWarning("Max fame list size is %d (fame_list_alchemist)\n", MAX_FAME_LIST);
+				fame_list_size_chemist = MAX_FAME_LIST;
+			}
+		} else if (strcmpi(w1, "fame_list_blacksmith") == 0) {
+			fame_list_size_smith = atoi(w2);
+			if (fame_list_size_smith > MAX_FAME_LIST) {
+				ShowWarning("Max fame list size is %d (fame_list_blacksmith)\n", MAX_FAME_LIST);
+				fame_list_size_smith = MAX_FAME_LIST;
+			}
+		} else if (strcmpi(w1, "fame_list_taekwon") == 0) {
+			fame_list_size_taekwon = atoi(w2);
+			if (fame_list_size_taekwon > MAX_FAME_LIST) {
+				ShowWarning("Max fame list size is %d (fame_list_taekwon)\n", MAX_FAME_LIST);
+				fame_list_size_taekwon = MAX_FAME_LIST;
+			}
 		} else if (strcmpi(w1, "import") == 0) {
 			char_config_read(w2);
 		}

+ 2 - 0
src/common/mmo.h

@@ -106,6 +106,8 @@
 #define MAX_FRIENDS 40
 #define MAX_MEMOPOINTS 10
 
+//Size of the fame list arrays.
+#define MAX_FAME_LIST 10
 //These max values can be exceeded and the char/map servers will update them with no problems
 //These are just meant to minimize the updating needed between char/map servers as players login.
 //Room for initial 10K accounts

+ 3 - 3
src/map/chrif.c

@@ -1122,21 +1122,21 @@ int chrif_recvfamelist(int fd)
 	memset (taekwon_fame_list, 0, sizeof(taekwon_fame_list));
 
 	size = RFIFOW(fd,6); //Blacksmith block size
-	for (num = 0; len < size && num < 10; num++) {
+	for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
 		memcpy(&smith_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
  		len += sizeof(struct fame_list);
 	}
 	total += num;
 
 	size = RFIFOW(fd,4); //Alchemist block size
-	for (num = 0; len < size && num < 10; num++) {
+	for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
 		memcpy(&chemist_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
  		len += sizeof(struct fame_list);
 	}
 	total += num;
 
 	size = RFIFOW(fd,2); //Total packet length
-	for (num = 0; len < size && num < 10; num++) {
+	for (num = 0; len < size && num < MAX_FAME_LIST; num++) {
 		memcpy(&taekwon_fame_list[num], RFIFOP(fd,len), sizeof(struct fame_list));
  		len += sizeof(struct fame_list);
 	}

+ 20 - 3
src/map/clif.c

@@ -11568,7 +11568,8 @@ void clif_parse_Blacksmith(int fd,struct map_session_data *sd)
 
 	WFIFOHEAD(fd,packet_len_table[0x219]);
 	WFIFOW(fd,0) = 0x219;
-	for (i = 0; i < 10; i++) {
+	//Packet size limits this list to 10 elements. [Skotlex]
+	for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
 		if (smith_fame_list[i].id > 0) {
 			if (strcmp(smith_fame_list[i].name, "-") == 0 &&
 				(name = map_charid2nick(smith_fame_list[i].id)) != NULL)
@@ -11580,6 +11581,11 @@ void clif_parse_Blacksmith(int fd,struct map_session_data *sd)
 			strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), "None", 5);
 		WFIFOL(fd, 242 + i * 4) = smith_fame_list[i].fame;
 	}
+	for(;i < 10; i++) { //In case the MAX is less than 10.
+		strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), "Unavailable", 12);
+		WFIFOL(fd, 242 + i * 4) = 0;
+	}
+
 	WFIFOSET(fd, packet_len_table[0x219]);
 }
 
@@ -11606,7 +11612,8 @@ void clif_parse_Alchemist(int fd,struct map_session_data *sd)
 
 	WFIFOHEAD(fd,packet_len_table[0x21a]);
 	WFIFOW(fd,0) = 0x21a;
-	for (i = 0; i < 10; i++) {
+	//Packet size limits this list to 10 elements. [Skotlex]
+	for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
 		if (chemist_fame_list[i].id > 0) {
 			if (strcmp(chemist_fame_list[i].name, "-") == 0 &&
 				(name = map_charid2nick(chemist_fame_list[i].id)) != NULL)
@@ -11618,6 +11625,11 @@ void clif_parse_Alchemist(int fd,struct map_session_data *sd)
 			memcpy(WFIFOP(fd, 2 + 24 * i), "None", NAME_LENGTH);
 		WFIFOL(fd, 242 + i * 4) = chemist_fame_list[i].fame;
 	}
+	for(;i < 10; i++) { //In case the MAX is less than 10.
+		memcpy(WFIFOP(fd, 2 + 24 * i), "Unavailable", NAME_LENGTH);
+		WFIFOL(fd, 242 + i * 4) = 0;
+	}
+
 	WFIFOSET(fd, packet_len_table[0x21a]);
 }
 
@@ -11644,7 +11656,8 @@ void clif_parse_Taekwon(int fd,struct map_session_data *sd)
 
 	WFIFOHEAD(fd,packet_len_table[0x226]);
 	WFIFOW(fd,0) = 0x226;
-	for (i = 0; i < 10; i++) {
+	//Packet size limits this list to 10 elements. [Skotlex]
+	for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) {
 		if (taekwon_fame_list[i].id > 0) {
 			if (strcmp(taekwon_fame_list[i].name, "-") == 0 &&
 				(name = map_charid2nick(taekwon_fame_list[i].id)) != NULL)
@@ -11656,6 +11669,10 @@ void clif_parse_Taekwon(int fd,struct map_session_data *sd)
 			memcpy(WFIFOP(fd, 2 + 24 * i), "None", NAME_LENGTH);
 		WFIFOL(fd, 242 + i * 4) = taekwon_fame_list[i].fame;
 	}
+	for(;i < 10; i++) { //In case the MAX is less than 10.
+		memcpy(WFIFOP(fd, 2 + 24 * i), "Unavailable", NAME_LENGTH);
+		WFIFOL(fd, 242 + i * 4) = 0;
+	}
 	WFIFOSET(fd, packet_len_table[0x226]);
 }
 

+ 6 - 6
src/map/pc.c

@@ -55,9 +55,9 @@ int night_timer_tid;
 static int dirx[8]={0,-1,-1,-1,0,1,1,1};
 static int diry[8]={1,1,0,-1,-1,-1,0,1};
 
-struct fame_list smith_fame_list[10];
-struct fame_list chemist_fame_list[10];
-struct fame_list taekwon_fame_list[10];
+struct fame_list smith_fame_list[MAX_FAME_LIST];
+struct fame_list chemist_fame_list[MAX_FAME_LIST];
+struct fame_list taekwon_fame_list[MAX_FAME_LIST];
 
 static unsigned int equip_pos[11]={0x0080,0x0008,0x0040,0x0004,0x0001,0x0200,0x0100,0x0010,0x0020,0x0002,0x8000};
 
@@ -272,19 +272,19 @@ int pc_istop10fame(int char_id,int job) {
     int i;
 	switch(job){
 	case MAPID_BLACKSMITH: // Blacksmith
-	    for(i=0;i<10;i++){
+	    for(i=0;i<MAX_FAME_LIST;i++){
 			if(smith_fame_list[i].id==char_id)
 			    return smith_fame_list[i].fame;
 		}
 		break;
 	case MAPID_ALCHEMIST: // Alchemist
-	    for(i=0;i<10;i++){
+	    for(i=0;i<MAX_FAME_LIST;i++){
 	        if(chemist_fame_list[i].id==char_id)
 	            return chemist_fame_list[i].fame;
 		}
 		break;
 	case MAPID_TAEKWON: // Taekwon
-	    for(i=0;i<10;i++){
+	    for(i=0;i<MAX_FAME_LIST;i++){
 	        if(taekwon_fame_list[i].id==char_id)
 	            return taekwon_fame_list[i].fame;
 		}

+ 3 - 3
src/map/pc.h

@@ -225,9 +225,9 @@ int pc_eventtimer(int tid,unsigned int tick,int id,int data); // for npc_dequeue
 
 int pc_run(struct map_session_data *sd, int skilllv, int dir);
 
-extern struct fame_list smith_fame_list[10];
-extern struct fame_list chemist_fame_list[10];
-extern struct fame_list taekwon_fame_list[10];
+extern struct fame_list smith_fame_list[MAX_FAME_LIST];
+extern struct fame_list chemist_fame_list[MAX_FAME_LIST];
+extern struct fame_list taekwon_fame_list[MAX_FAME_LIST];
 
 int pc_readdb(void);
 int do_init_pc(void);