Explorar el Código

* Reduced MAX_SKILL_LEVEL to 10
* Tidied up parts in skill_castfix a bit
* Fixed map-server crashing if an empty line was added in any of the skill-xx db files
* Updated skill_castnodex reading

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

celest hace 20 años
padre
commit
7beb492f29
Se han modificado 6 ficheros con 81 adiciones y 40 borrados
  1. 8 0
      Changelog.txt
  2. 17 13
      db/skill_castnodex_db.txt
  3. 1 1
      src/map/map.h
  4. 4 1
      src/map/mob.c
  5. 50 25
      src/map/skill.c
  6. 1 0
      src/map/skill.h

+ 8 - 0
Changelog.txt

@@ -1,5 +1,13 @@
 Date	Added
 01/02
+        * Reduced MAX_SKILL_LEVEL to 10 to save a bit of memory and speed [celest]
+        * Tidied up parts in skill_castfix a bit [celest]
+        * Fixed map-server crashing if an empty line was added in any of the skill-xx
+          db files [celest]
+        * Updated skill_castnodex reading - An *optional* 3rd value can be added to set
+          whether a skill's delay time can be affected by dex [celest]
+          Example: 46,1,1 - double strafe's delay is not affected by dex
+                   46,1,0:0:0:0:1 - only level 5 double strafe is not affected by dex
 	* More atempts at memory leak fixes [Codemaster] [SVN 890]
         * Updated weapon breaking rates, thanks to DracoRPG [celest]
         * Optimized enchanting skills success rates calculation, thanks to Wallex

+ 17 - 13
db/skill_castnodex_db.txt

@@ -1,13 +1,17 @@
-//<Skill id>,<1 or 0>
-// With 1, dex does not effect the skill's cast rate
-// With 0, dex effects the skill's cast rate
-46,1
-47,1
-129,1
-366,1
-381,1
-382,1
-383,1
-394,1
-403,1
-406,1
+//<Skill id>,<Cast: 1 or 0>,<Delay (Optional): 1 or 0>
+// Cast: With 1, dex does not affect the skill's cast rate
+// Cast: With 0, dex affects the skill's cast rate
+// Delay: With 1, dex does not affect the skill's delay rate
+// Delay: With 0, dex affects the skill's delay rate
+// Example - 46,1,1 = Double Strafe's casting time and delay is not affected by dex.
+
+46,1	//AC_DOUBLE
+47,1	//AC_SHOWER
+129,1	//HT_FALCON
+366,1	//HW_MAGICPOWER
+381,1	//SN_FALCONASSAULT
+382,1	//SN_SHARPSHOOTING
+383,1	//SN_WINDWALK
+394,1	//CG_ARROWVULCAN
+403,1	//PF_MEMORIZE
+406,0,1	//ASC_METEORASSAULT

+ 1 - 1
src/map/map.h

@@ -16,7 +16,7 @@
 #define LIFETIME_FLOORITEM 60
 #define DAMAGELOG_SIZE 30
 #define LOOTITEM_SIZE 10
-#define MAX_SKILL_LEVEL 100
+#define MAX_SKILL_LEVEL 10
 #define MAX_STATUSCHANGE 210
 #define MAX_SKILLUNITGROUP 32
 #define MAX_MOBSKILLUNITGROUP 8

+ 4 - 1
src/map/mob.c

@@ -4205,7 +4205,10 @@ static int mob_readskilldb(void)
 					ms->state=state[j].id;
 			}
 			ms->skill_id=atoi(sp[3]);
-			ms->skill_lv=atoi(sp[4]);
+			j=atoi(sp[4]);
+			if (j<=0 || j>MAX_SKILL_DB)
+				continue;
+			ms->skill_lv=j;
 			ms->permillage=atoi(sp[5]);
 			ms->casttime=atoi(sp[6]);
 			ms->delay=atoi(sp[7]);

+ 50 - 25
src/map/skill.c

@@ -854,6 +854,11 @@ int	skill_get_castnodex( int id ,int lv ){
 	if ((id > MAX_SKILL) || (id < 0)) return 0;
 	return (lv <= 0) ? 0:skill_db[id].castnodex[lv-1];
 }
+int	skill_get_delaynodex( int id ,int lv ){
+	if (id >= 10000 && id < 10015) id-= 9500;
+	if ((id > MAX_SKILL) || (id < 0)) return 0;
+	return (lv <= 0) ? 0:skill_db[id].delaynodex[lv-1];
+}
 int	skill_get_nocast ( int id ){
 	if (id >= 10000 && id < 10015) id-= 9500;
 	if ((id > MAX_SKILL) || (id < 0)) return 0;
@@ -7390,23 +7395,23 @@ int skill_check_condition(struct map_session_data *sd,int type)
  */
 int skill_castfix( struct block_list *bl, int time )
 {
-	struct map_session_data *sd;
+	struct map_session_data *sd = NULL;
 	struct mob_data *md; // [Valaris]
 	struct status_change *sc_data;
 	int dex;
 	int castrate=100;
-	int skill,lv,castnodex;
+	int skill,lv;
 
 	nullpo_retr(0, bl);
 
 	if(bl->type==BL_MOB){ // Crash fix [Valaris]
-		md=(struct mob_data*)bl;
+		nullpo_retr(0, md=(struct mob_data*)bl);
 		skill = md->skillid;
 		lv = md->skilllv;
 	}
 
 	else { 
-	sd=(struct map_session_data*)bl;
+		nullpo_retr(0, sd=(struct map_session_data*)bl);
 		skill = sd->skillid;
 		lv = sd->skilllv;
 	}
@@ -7419,8 +7424,6 @@ int skill_castfix( struct block_list *bl, int time )
 	if (skill > MAX_SKILL_DB || skill < 0)
 	    return 0;
 
-	castnodex=skill_get_castnodex(skill, lv);
-
 	/* サフラギウム */
 	if(sc_data && sc_data[SC_SUFFRAGIUM].timer!=-1 )
 		time=time*(100-sc_data[SC_SUFFRAGIUM].val1*15)/100;
@@ -7428,12 +7431,14 @@ int skill_castfix( struct block_list *bl, int time )
 
 	if(time==0)
 		return 0;
-	if(castnodex > 0 && bl->type==BL_PC)
-		castrate=((struct map_session_data *)bl)->castrate;
-	else if (castnodex <= 0 && bl->type==BL_PC) {
-		castrate=((struct map_session_data *)bl)->castrate;
-		time=time*castrate*(battle_config.castrate_dex_scale - dex)/(battle_config.castrate_dex_scale * 100);
-		time=time*battle_config.cast_rate/100;
+	if (sd) {
+		if(skill_get_castnodex(skill, lv) > 0)
+			castrate=((struct map_session_data *)bl)->castrate;
+		else {
+			castrate=((struct map_session_data *)bl)->castrate;
+			time=time*castrate*(battle_config.castrate_dex_scale - dex)/(battle_config.castrate_dex_scale * 100);
+			time=time*battle_config.cast_rate/100;
+		}
 	}
 
 	/* ブラギの詩 */
@@ -7450,15 +7455,24 @@ int skill_castfix( struct block_list *bl, int time )
 int skill_delayfix( struct block_list *bl, int time )
 {
 	struct status_change *sc_data;
-
+	struct map_session_data *sd = NULL;
+	int skill,lv = 0;
+	
 	nullpo_retr(0, bl);
 
+	if(bl->type==BL_PC){
+		nullpo_retr(0, sd=(struct map_session_data*)bl);
+		skill = sd->skillid;
+		lv = sd->skilllv;
+	}
+
+	if(lv <= 0) return 0;
+
 	sc_data = battle_get_sc_data(bl);
-/*	if(time<=0)
-		return ( battle_get_adelay(bl) / 2 );*/
 
-	if(bl->type == BL_PC) {
-		if( battle_config.delay_dependon_dex )	/* dexの影響を計算する */
+	if(sd) {
+		if(battle_config.delay_dependon_dex &&	/* dexの影響を計算する */
+			skill_get_delaynodex(skill, lv) > 0)
 			time=time*(battle_config.castrate_dex_scale - battle_get_dex(bl))/battle_config.castrate_dex_scale;
 		time=time*battle_config.delay_rate/100;
 	}
@@ -11646,7 +11660,7 @@ int skill_readdb(void)
 		i=atoi(split[0]);
 		if (i>=10000 && i<10015) // for guild skills [Celest]
 			i -= 9500;
-		else if(i<0 || i>MAX_SKILL_DB)
+		else if(i<=0 || i>MAX_SKILL_DB)
 			continue;
 
 /*		printf("skill id=%d\n",i); */
@@ -11721,7 +11735,7 @@ int skill_readdb(void)
 		i=atoi(split[0]);
 		if (i>=10000 && i<10015) // for guild skills [Celest]
 			i -= 9500;
-		else if(i<0 || i>MAX_SKILL_DB)
+		else if(i<=0 || i>MAX_SKILL_DB)
 			continue;
 
 		memset(split2,0,sizeof(split2));
@@ -11863,7 +11877,7 @@ int skill_readdb(void)
 		i=atoi(split[0]);
 		if (i>=10000 && i<10015) // for guild skills [Celest]
 			i -= 9500;
-		else if(i<0 || i>MAX_SKILL_DB)
+		else if(i<=0 || i>MAX_SKILL_DB)
 			continue;
 
 		memset(split2,0,sizeof(split2));
@@ -12030,10 +12044,10 @@ int skill_readdb(void)
 	}
 	while(fgets(line,1020,fp)){
 		char *split[50], *split2[MAX_SKILL_LEVEL];
-		memset(split,0,sizeof(split));
 		if(line[0]=='/' && line[1]=='/')
 			continue;
-		for(j=0,p=line;j<2 && p;j++){
+		memset(split,0,sizeof(split));
+		for(j=0,p=line;j<3 && p;j++){
 			split[j]=p;
 			p=strchr(p,',');
 			if(p) *p++=0;
@@ -12042,9 +12056,9 @@ int skill_readdb(void)
 		i=atoi(split[0]);
 		if (i>=10000 && i<10015) // for guild skills [Celest]
 			i -= 9500;
-		else if(i<0 || i>MAX_SKILL_DB)
+		else if(i<=0 || i>MAX_SKILL_DB)
 			continue;
-
+		
 		memset(split2,0,sizeof(split2));
 		for(j=0,p=split[1];j<MAX_SKILL_LEVEL && p;j++){
 			split2[j]=p;
@@ -12053,6 +12067,17 @@ int skill_readdb(void)
 		}
 		for(k=0;k<MAX_SKILL_LEVEL;k++)
 			skill_db[i].castnodex[k]=(split2[k])? atoi(split2[k]):atoi(split2[0]);
+
+		if (!split[2])
+			continue;
+		memset(split2,0,sizeof(split2));
+		for(j=0,p=split[2];j<MAX_SKILL_LEVEL && p;j++){
+			split2[j]=p;
+			p=strchr(p,':');
+			if(p) *p++=0;
+		}
+		for(k=0;k<MAX_SKILL_LEVEL;k++)
+			skill_db[i].delaynodex[k]=(split2[k])? atoi(split2[k]):atoi(split2[0]);
 	}
 	fclose(fp);
 	sprintf(tmp_output,"Done reading '"CL_WHITE"%s"CL_RESET"'.\n","db/skill_castnodex_db.txt");
@@ -12079,7 +12104,7 @@ int skill_readdb(void)
 		i=atoi(split[0]);
 		if (i>=10000 && i<10015) // for guild skills [Celest]
 			i -= 9500;
-		else if(i<0 || i>MAX_SKILL_DB)
+		else if(i<=0 || i>MAX_SKILL_DB)
 			continue;
 		skill_db[i].nocast=atoi(split[1]);
 		k++;

+ 1 - 0
src/map/skill.h

@@ -23,6 +23,7 @@ struct skill_db {
 	int weapon,state,spiritball[MAX_SKILL_LEVEL];
 	int itemid[10],amount[10];
 	int castnodex[MAX_SKILL_LEVEL];
+	int delaynodex[MAX_SKILL_LEVEL];
 	int nocast;
 };
 extern struct skill_db skill_db[MAX_SKILL_DB];