Explorar o código

* Made skill_tree.txt reading use sv_readdb. [Ai4rei]
- Added define for skill entry requirements.
- Reports duplicate skills within same job class.
- Updated comments for skill Berserk in skill_tree.txt, among others because they would cause errors the way they are read now.

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

ai4rei %!s(int64=14) %!d(string=hai) anos
pai
achega
cbc43338bf
Modificáronse 8 ficheiros con 72 adicións e 60 borrados
  1. 3 0
      Changelog-Trunk.txt
  2. 2 0
      db/Changelog.txt
  3. 3 3
      db/skill_tree.txt
  4. 1 1
      src/map/atcommand.c
  5. 2 2
      src/map/homunculus.c
  6. 52 53
      src/map/pc.c
  7. 2 1
      src/map/pc.h
  8. 7 0
      src/map/status.c

+ 3 - 0
Changelog-Trunk.txt

@@ -1,6 +1,9 @@
 Date	Added
 
 2010/11/30
+	* Made skill_tree.txt reading use sv_readdb. [Ai4rei]
+	- Added define for skill entry requirements.
+	- Reports duplicate skills within same job class.
 	* Added a define for star gladiator feel/hate info array length (follow up to r8721 and r11840). [Ai4rei]
 	* Fixed script command getusers causing 'player not attached' errors when asking for character count in entire server (bugreport:4591, since r14495). [Ai4rei]
 2010/11/29

+ 2 - 0
db/Changelog.txt

@@ -8,6 +8,8 @@
 	1475 Equestrian's Spear:	NEED INFO.
 	13005 Angelic Wing Dagger:	NEED INFO.
 =======================
+2010/11/30
+	* Rev. 14524 Updated comments for skill Berserk in skill_tree.txt, among others because they would cause errors the way they are read now. [Ai4rei]
 2010/11/26
 	* Rev. 14507 Added killerrid and killedrid param constants to const.txt [ultramage]
 2010/11/21

+ 3 - 3
db/skill_tree.txt

@@ -1,4 +1,4 @@
-//JobNo,Skill-ID,MaxLV,Prerequisite Skill-ID-1,Prerequisite Skill-ID-1-Lv,PrereqSkill-ID-2,PrereqSkill-ID-2-Lv,PrereqSkill-ID-3,PrereqSkill-ID-3-Lv,PrereqSkill-ID-4,PrereqSkill-ID-4-Lv,PrereqSkill-ID-5,PrereqSkill-ID-5-Lv//CLASS_SKILLNAME#Skill Name#
+//JobNo,Skill-ID,MaxLV{,JobLV},Prerequisite Skill-ID-1,Prerequisite Skill-ID-1-Lv,PrereqSkill-ID-2,PrereqSkill-ID-2-Lv,PrereqSkill-ID-3,PrereqSkill-ID-3-Lv,PrereqSkill-ID-4,PrereqSkill-ID-4-Lv,PrereqSkill-ID-5,PrereqSkill-ID-5-Lv//CLASS_SKILLNAME#Skill Name#
 //Novice
 0,1,9,0,0,0,0,0,0,0,0,0,0 //NV_BASIC#Basic Skill#
 0,142,1,0,0,0,0,0,0,0,0,0,0 //NV_FIRSTAID#First Aid#
@@ -853,7 +853,7 @@
 4008,356,10,3,10,6,5,60,3,0,0,0,0 //LK_PARRYING#Parrying#
 4008,357,5,4,1,55,5,63,1,0,0,0,0 //LK_CONCENTRATION#Concentration#
 4008,358,1,4,10,6,5,8,3,0,0,0,0 //LK_TENSIONRELAX#Relax#
-4008,359,1,50,0,0,0,0,0,0,0,0,0,0 //LK_BERSERK#Frenzy# //It has an extra collumn after "MaxLevel" for Job Level 50 requeriment
+4008,359,1,50,0,0,0,0,0,0,0,0,0,0 //LK_BERSERK#Frenzy# //It has an extra column after "MaxLevel" for Job Level 50 requirement
 4008,397,5,55,10,56,5,58,5,63,1,0,0 //LK_SPIRALPIERCE#Spiral Pierce#
 4008,398,5,55,9,63,1,0,0,0,0,0,0 //LK_HEADCRUSH#Traumatic Blow#
 4008,399,10,55,9,64,3,398,3,0,0,0,0 //LK_JOINTBEAT#Vital Strike#
@@ -1084,7 +1084,7 @@
 4014,356,10,3,10,6,5,60,3,0,0,0,0 //LK_PARRYING#Parrying#
 4014,357,5,4,1,55,5,63,1,0,0,0,0 //LK_CONCENTRATION#Concentration#
 4014,358,1,4,10,6,5,8,3,0,0,0,0 //LK_TENSIONRELAX#Relax#
-4014,359,1,50,0,0,0,0,0,0,0,0,0,0 //LK_BERSERK#Frenzy# //check this, the last ",0" shouldn't be needed I think
+4014,359,1,50,0,0,0,0,0,0,0,0,0,0 //LK_BERSERK#Frenzy# //It has an extra column after "MaxLevel" for Job Level 50 requirement
 4014,397,5,55,10,56,5,58,5,63,1,0,0 //LK_SPIRALPIERCE#Spiral Pierce#
 4014,398,5,55,9,63,1,0,0,0,0,0,0 //LK_HEADCRUSH#Traumatic Blow#
 4014,399,10,55,9,64,3,398,3,0,0,0,0 //LK_JOINTBEAT#Vital Strike#

+ 1 - 1
src/map/atcommand.c

@@ -5786,7 +5786,7 @@ ACMD_FUNC(skilltree)
 	ent = &skill_tree[c][j];
 
 	meets = 1;
-	for(j=0;j<5;j++)
+	for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
 	{
 		if( ent->need[j].id && pc_checkskill(sd,ent->need[j].id) < ent->need[j].lv)
 		{

+ 2 - 2
src/map/homunculus.c

@@ -147,7 +147,7 @@ int merc_hom_calc_skilltree(struct homun_data *hd)
 			continue; //Skill already known.
 		if(!battle_config.skillfree)
 		{
-			for(j=0;j<5;j++)
+			for(j=0;j<MAX_PC_SKILL_REQUIRE;j++)
 			{
 				if( hskill_tree[c][i].need[j].id &&
 					merc_hom_checkskill(hd,hskill_tree[c][i].need[j].id) < hskill_tree[c][i].need[j].lv) 
@@ -1088,7 +1088,7 @@ int read_homunculus_skilldb(void)
 		if (minJobLevelPresent)
 			hskill_tree[classid][j].joblv=atoi(split[3]);
 
-		for(k=0;k<5;k++){
+		for(k=0;k<MAX_PC_SKILL_REQUIRE;k++){
 			hskill_tree[classid][j].need[k].id=atoi(split[3+k*2+minJobLevelPresent]);
 			hskill_tree[classid][j].need[k].lv=atoi(split[3+k*2+minJobLevelPresent+1]);
 		}

+ 52 - 53
src/map/pc.c

@@ -1199,7 +1199,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
 
 			f = 1;
 			if(!battle_config.skillfree) {
-				for(j = 0; j < 5; j++) {
+				for(j = 0; j < MAX_PC_SKILL_REQUIRE; j++) {
 					if((k=skill_tree[c][i].need[j].id))
 					{
 						if (!sd->status.skill[k].id || sd->status.skill[k].flag == 13)
@@ -1296,7 +1296,7 @@ static void pc_check_skilltree(struct map_session_data *sd, int skill)
 			if( sd->status.skill[id].id ) //Already learned
 				continue;
 			
-			for( j = 0; j < 5; j++ )
+			for( j = 0; j < MAX_PC_SKILL_REQUIRE; j++ )
 			{
 				if( (k = skill_tree[c][i].need[j].id) )
 				{
@@ -7910,13 +7910,58 @@ int pc_split_atoui(char* str, unsigned int* val, char sep, int max)
 /*==========================================
  * DB reading.
  * exp.txt        - required experience values
- * job_db1.txt    - weight, hp, sp, aspd
- * job_db2.txt    - job level stat bonuses
  * skill_tree.txt - skill tree for every class
  * attr_fix.txt   - elemental adjustment table
- * size_fix.txt   - size adjustment table for weapons
- * refine_db.txt  - refining data table
+ * statpoint.txt  - status points per base level
  *------------------------------------------*/
+static bool pc_readdb_skilltree(char* fields[], int columns, int current)
+{
+	unsigned char joblv = 0, skilllv;
+	unsigned short skillid;
+	int idx, class_;
+	unsigned int i, offset = 3, skillidx;
+
+	class_  = atoi(fields[0]);
+	skillid = (unsigned short)atoi(fields[1]);
+	skilllv = (unsigned char)atoi(fields[2]);
+
+	if(columns==4+MAX_PC_SKILL_REQUIRE*2)
+	{// job level requirement extra column
+		joblv = (unsigned char)atoi(fields[3]);
+		offset++;
+	}
+
+	if(!pcdb_checkid(class_))
+	{
+		ShowWarning("pc_readdb_skilltree: Invalid job class %d specified.\n", class_);
+		return false;
+	}
+	idx = pc_class2idx(class_);
+
+	//This is to avoid adding two lines for the same skill. [Skotlex]
+	ARR_FIND( 0, MAX_SKILL_TREE, skillidx, skill_tree[idx][skillidx].id == 0 || skill_tree[idx][skillidx].id == skillid );
+	if( skillidx == MAX_SKILL_TREE )
+	{
+		ShowWarning("pc_readdb_skilltree: Unable to load skill %hu into job %d's tree. Maximum number of skills per class has been reached.\n", skillid, class_);
+		return false;
+	}
+	else if(skill_tree[idx][skillidx].id)
+	{
+		ShowNotice("pc_readdb_skilltree: Overwriting skill %hu for job class %d.\n", skillid, class_);
+	}
+
+	skill_tree[idx][skillidx].id    = skillid;
+	skill_tree[idx][skillidx].max   = skilllv;
+	skill_tree[idx][skillidx].joblv = joblv;
+
+	for(i = 0; i < MAX_PC_SKILL_REQUIRE; i++)
+	{
+		skill_tree[idx][skillidx].need[i].id = atoi(fields[i*2+offset]);
+		skill_tree[idx][skillidx].need[i].lv = atoi(fields[i*2+offset+1]);
+	}
+	return true;
+}
+
 int pc_readdb(void)
 {
 	int i,j,k;
@@ -8008,53 +8053,7 @@ int pc_readdb(void)
 
 	// スキルツリ?
 	memset(skill_tree,0,sizeof(skill_tree));
-	sprintf(line, "%s/skill_tree.txt", db_path);
-	fp=fopen(line,"r");
-	if(fp==NULL){
-		ShowError("can't read %s\n", line);
-		return 1;
-	}
-
-	while(fgets(line, sizeof(line), fp))
-	{
-		char *split[50];
-		int f=0, m=3, idx;
-		if(line[0]=='/' && line[1]=='/')
-			continue;
-		for(j=0,p=line;j<14 && p;j++){
-			split[j]=p;
-			p=strchr(p,',');
-			if(p) *p++=0;
-		}
-		if(j<13)
-			continue;
-		if (j == 14) {
-			f=1;	// MinJobLvl has been added
-			m++;
-		}
-		// check for bounds [celest]
-		idx = atoi(split[0]);
-		if(!pcdb_checkid(idx))
-			continue;
-		idx = pc_class2idx(idx);
-		k = atoi(split[1]); //This is to avoid adding two lines for the same skill. [Skotlex]
-		ARR_FIND( 0, MAX_SKILL_TREE, j, skill_tree[idx][j].id == 0 || skill_tree[idx][j].id == k );
-		if( j == MAX_SKILL_TREE )
-		{
-			ShowWarning("Unable to load skill %d into job %d's tree. Maximum number of skills per class has been reached.\n", k, atoi(split[0]));
-			continue;
-		}
-		skill_tree[idx][j].id=k;
-		skill_tree[idx][j].max=atoi(split[2]);
-		if (f) skill_tree[idx][j].joblv=atoi(split[3]);
-
-		for(k=0;k<5;k++){
-			skill_tree[idx][j].need[k].id=atoi(split[k*2+m]);
-			skill_tree[idx][j].need[k].lv=atoi(split[k*2+m+1]);
-		}
-	}
-	fclose(fp);
-	ShowStatus("Done reading '"CL_WHITE"%s"CL_RESET"'.\n","skill_tree.txt");
+	sv_readdb(db_path, "skill_tree.txt", ',', 3+MAX_PC_SKILL_REQUIRE*2, 4+MAX_PC_SKILL_REQUIRE*2, -1, &pc_readdb_skilltree);
 
 	// ?性修正テ?ブル
 	for(i=0;i<4;i++)

+ 2 - 1
src/map/pc.h

@@ -17,6 +17,7 @@
 #include "mob.h"
 
 #define MAX_PC_BONUS 10
+#define MAX_PC_SKILL_REQUIRE 5
 #define MAX_PC_FEELHATE 3
 
 struct weapon_data {
@@ -722,7 +723,7 @@ struct skill_tree_entry {
 	struct {
 		short id;
 		unsigned char lv;
-	} need[5];
+	} need[MAX_PC_SKILL_REQUIRE];
 }; // Celest
 extern struct skill_tree_entry skill_tree[CLASS_COUNT][MAX_SKILL_TREE];
 

+ 7 - 0
src/map/status.c

@@ -7676,6 +7676,13 @@ static int status_natural_heal_timer(int tid, unsigned int tick, int id, intptr
 	return 0;
 }
 
+/*==========================================
+ * DB reading.
+ * job_db1.txt    - weight, hp, sp, aspd
+ * job_db2.txt    - job level stat bonuses
+ * size_fix.txt   - size adjustment table for weapons
+ * refine_db.txt  - refining data table
+ *------------------------------------------*/
 int status_readdb(void)
 {
 	int i,j,class_;