Bläddra i källkod

- Some fine-tuning of the warp portal code which prevents it from messing up other skills if you "precast" it.
- Fixed the weapon refine code using sd->skillid instead of sd->menuskill_id
- Fixed some npc_event error reports (three error where displaying at the exact same msg, making it impossible to tell which one of the three actually happened)


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

skotlex 19 år sedan
förälder
incheckning
9399f60ace
3 ändrade filer med 36 tillägg och 14 borttagningar
  1. 6 0
      Changelog-Trunk.txt
  2. 10 3
      src/map/npc.c
  3. 20 11
      src/map/skill.c

+ 6 - 0
Changelog-Trunk.txt

@@ -5,6 +5,12 @@ 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/02/21
+	* Some cleaning of the warp portal code so that when it is "pre-casted" it
+	  doesn't mess up with other casted skills. [Skotlex]
+	* Some fixing on the weapon-refine code. [Skotlex]
+	* Cleaned up some npc_event error reporting. [Skotlex]
+	* Some cleanup of the castend routines to not clear the skill variables if
+	  for some reason the casted skill triggers another skill. [Skotlex]
 	* Vending is now cancelled on a pc_setpos [Skotlex]
 	* Pressure again ignores Basilica. [Skotlex]
 	* Fixed attacker's sc being nulled when the target's sc is empty (fixes

+ 10 - 3
src/map/npc.c

@@ -208,7 +208,7 @@ int npc_timer_event(const unsigned char *eventname)	// Added by RoVeRT
 //	int xs,ys;
 
 	if((ev==NULL || (nd=ev->nd)==NULL)){
-		ShowWarning("npc_event: event not found [%s]\n",eventname);
+		ShowWarning("npc_timer_event: event not found [%s]\n",eventname);
 		return 0;
 	}
 
@@ -435,11 +435,18 @@ int npc_event_do_oninit(void)
 int npc_addeventtimer(struct npc_data *nd,int tick,const char *name)
 {
 	int i;
+	unsigned char *evname;
+	
 	for(i=0;i<MAX_EVENTTIMER;i++)
 		if( nd->eventtimer[i]==-1 )
 			break;
 	if(i<MAX_EVENTTIMER){
-		unsigned char *evname=(unsigned char *) aCallocA(NAME_LENGTH, sizeof(char));
+		if (!strdb_get(ev_db,name)) {
+			if (battle_config.error_log)
+				ShowError("npc_addeventimer: Event %s does not exists.\n", name);
+			return 1; //Event does not exists!
+		}
+		evname =(unsigned char *) aCallocA(NAME_LENGTH, sizeof(char));
 		if(evname==NULL){
 			ShowFatalError("npc_addeventtimer: out of memory !\n");exit(1);
 		}
@@ -802,7 +809,7 @@ int npc_event (struct map_session_data *sd, const unsigned char *eventname, int
 			ev = strdb_get(ev_db, mobevent);
 			if (ev == NULL || (nd = ev->nd) == NULL) {
 				if (strnicmp(eventname, "GM_MONSTER",10) != 0)
-					ShowError("npc_event: event not found [%s]\n", mobevent);
+					ShowError("npc_event: (mob_kill) event not found [%s]\n", mobevent);
 				return 0;
 			}
 		} else {

+ 20 - 11
src/map/skill.c

@@ -5730,8 +5730,10 @@ int skill_castend_id( int tid, unsigned int tick, int id,int data )
 		status_change_end(&sd->bl,SC_MAGICPOWER,-1);		
 
 	//Clean this up for future references to battle_getcurrentskill. [Skotlex]
-	sd->skillid = sd->skilllv = -1;
-	sd->skilltarget = 0;
+	if (sd->skilltimer == -1) {
+		sd->skillid = sd->skilllv = -1;
+		sd->skilltarget = 0;
+	}
 	return 0;
 #undef skill_failed
 }
@@ -5831,8 +5833,10 @@ int skill_castend_pos( int tid, unsigned int tick, int id,int data )
 
 	skill_castend_pos2(&sd->bl,sd->skillx,sd->skilly,sd->skillid,sd->skilllv,tick,0);
 
-	if (sd->skillid != AL_WARP)
-		sd->skillid = sd->skilllv = -1; //Clean this up for future references to battle_getcurrentskill. [Skotlex]
+  	//Clean this up for future references to battle_getcurrentskill. [Skotlex]
+	if (sd->skilltimer == -1) {
+		sd->skillid = sd->skilllv = -1;
+	}
 	return 0;
 #undef skill_failed
 }
@@ -6143,7 +6147,7 @@ int skill_castend_map( struct map_session_data *sd,int skill_num, const char *ma
 	nullpo_retr(0, sd);
 
 //Simplify skill_failed code.
-#define skill_failed(sd) { sd->skillid = sd->skilllv = sd->skillitem = sd->skillitemlv = -1; sd->menuskill_id = sd->menuskill_lv = 0; }
+#define skill_failed(sd) { sd->menuskill_id = sd->menuskill_lv = 0; }
 
 	if( sd->bl.prev == NULL || pc_isdead(sd) )
 		return 0;
@@ -6242,17 +6246,22 @@ int skill_castend_map( struct map_session_data *sd,int skill_num, const char *ma
 				skill_failed(sd);
 				return 0;
 			}
-			//FIXME: What is gonna be done in the case other skills are being used
-			//in the middle of this block of code? Something more robust needs be
-			//figured out. And what about when you use another ground skill? skillx
+			//FIXME:  What about when you use another ground skill? skillx
 			//and skilly are messed up already... [Skotlex]
+			i = sd->skillid;
+			lv = sd->skilllv;
 			sd->skillid = sd->menuskill_id;
 			sd->skilllv = sd->menuskill_lv;
-			if(!skill_check_condition(sd,3))
+			if(!skill_check_condition(sd,3)) //This checks versus skillid/skilllv...
 			{
+				sd->skillid = i;
+				sd->skilllv = lv;
 				skill_failed(sd);
 				return 0;
 			}
+			sd->skillid = i;
+			sd->skilllv = lv;
+			lv = sd->menuskill_lv;
 			
 			if(skill_check_unit_range2(&sd->bl,sd->bl.m,sd->skillx,sd->skilly,skill_num,lv) > 0) {
 				clif_skill_fail(sd,0,0,0);
@@ -9049,11 +9058,11 @@ void skill_weaponrefine(struct map_session_data *sd,int idx)
 		item = &sd->status.inventory[idx];
 
 		if(item->nameid > 0 && ditem->type == 4) {
-			if (item->refine >= sd->skilllv ||
+			if (item->refine >= sd->menuskill_lv ||
 				item->refine >= MAX_REFINE ||		// if it's no longer refineable
 				ditem->flag.no_refine ||	// if the item isn't refinable
 				(i = pc_search_inventory(sd, material [ditem->wlv])) < 0 ) { //fixed by Lupus (item pos can be = 0!)
-				clif_skill_fail(sd,sd->skillid,0,0);
+				clif_skill_fail(sd,sd->menuskill_id,0,0);
 				return;
 			}