Sfoglia il codice sorgente

* Fixed db/packet_db.txt reading not checking for max. amount of positions.
* Introduced MAX_GUILD_SKILL_REQUIRE to fix inconsistency in amount of prereq. guild skills.

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

ai4rei 13 anni fa
parent
commit
95775b10ae
4 ha cambiato i file con 23 aggiunte e 8 eliminazioni
  1. 3 0
      Changelog-Trunk.txt
  2. 7 0
      src/map/clif.c
  3. 8 4
      src/map/clif.h
  4. 5 4
      src/map/guild.c

+ 3 - 0
Changelog-Trunk.txt

@@ -1,5 +1,8 @@
 Date	Added
 
+2011/10/28
+	* Fixed db/packet_db.txt reading not checking for max. amount of positions. [Ai4rei]
+	* Introduced MAX_GUILD_SKILL_REQUIRE to fix inconsistency in amount of prereq. guild skills.
 2011/10/26
 	* Fixed a mistake in RID description in doc/script_commands.txt (since r2402). [Ai4rei]
 2011/10/23

+ 7 - 0
src/map/clif.c

@@ -15592,6 +15592,13 @@ static int packetdb_readdb(void)
 			if(p2) *p2++=0;
 			k = atoi(str2[j]);
 			// if (packet_db[packet_ver][cmd].pos[j] != k && clif_config.prefer_packet_db)	// not used for now
+
+			if( j >= MAX_PACKET_POS )
+			{
+				ShowError("Too many positions found for packet 0x%04x (max=%d).\n", cmd, MAX_PACKET_POS);
+				break;
+			}
+
 			packet_db[packet_ver][cmd].pos[j] = k;
 		}
 	}

+ 8 - 4
src/map/clif.h

@@ -27,14 +27,18 @@ struct battleground_data;
 struct quest;
 struct party_booking_ad_info;
 #include <stdarg.h>
-// packet DB
-#define MAX_PACKET_DB		0x900
-#define MAX_PACKET_VER		26
+
+enum
+{// packet DB
+	MAX_PACKET_DB  = 0x900,
+	MAX_PACKET_VER = 26,
+	MAX_PACKET_POS = 20,
+};
 
 struct s_packet_db {
 	short len;
 	void (*func)(int, struct map_session_data *);
-	short pos[20];
+	short pos[MAX_PACKET_POS];
 };
 
 // packet_db[SERVER] is reserved for server use

+ 5 - 4
src/map/guild.c

@@ -52,13 +52,14 @@ struct guild_expcache {
 };
 static struct eri *expcache_ers; //For handling of guild exp payment.
 
+#define MAX_GUILD_SKILL_REQUIRE 5
 struct{
 	int id;
 	int max;
 	struct{
 		short id;
 		short lv;
-	}need[6];
+	}need[MAX_GUILD_SKILL_REQUIRE];
 } guild_skill_tree[MAX_GUILDSKILL];
 
 int guild_payexp_timer(int tid, unsigned int tick, int id, intptr_t data);
@@ -124,7 +125,7 @@ static bool guild_read_guildskill_tree_db(char* split[], int columns, int curren
 		guild_skill_tree[id].max = 1;
 	}
 
-	for( k = 0; k < 5; k++ )
+	for( k = 0; k < MAX_GUILD_SKILL_REQUIRE; k++ )
 	{
 		guild_skill_tree[id].need[k].id = atoi(split[k*2+2]);
 		guild_skill_tree[id].need[k].lv = atoi(split[k*2+3]);
@@ -147,7 +148,7 @@ int guild_check_skill_require(struct guild *g,int id)
 	if (idx < 0 || idx >= MAX_GUILDSKILL)
 		return 0;
 
-	for(i=0;i<5;i++)
+	for(i=0;i<MAX_GUILD_SKILL_REQUIRE;i++)
 	{
 		if(guild_skill_tree[idx].need[i].id == 0) break;
 		if(guild_skill_tree[idx].need[i].lv > guild_checkskill(g,guild_skill_tree[idx].need[i].id))
@@ -1943,7 +1944,7 @@ void do_init_guild(void)
 	sv_readdb(db_path, "castle_db.txt", ',', 4, 5, -1, &guild_read_castledb);
 
 	memset(guild_skill_tree,0,sizeof(guild_skill_tree));
-	sv_readdb(db_path, "guild_skill_tree.txt", ',', 12, 12, -1, &guild_read_guildskill_tree_db); //guild skill tree [Komurka]
+	sv_readdb(db_path, "guild_skill_tree.txt", ',', 2+MAX_GUILD_SKILL_REQUIRE*2, 2+MAX_GUILD_SKILL_REQUIRE*2, -1, &guild_read_guildskill_tree_db); //guild skill tree [Komurka]
 
 	add_timer_func_list(guild_payexp_timer,"guild_payexp_timer");
 	add_timer_func_list(guild_send_xy_timer, "guild_send_xy_timer");