Browse Source

- A mob's HP is set temporarily to 0 before invoking it's on-death script, prevents said scripts being able to "rekill" the mob indefinitely (if stuff like killmonster is used within)
- Some small cleanups in chat.c


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

skotlex 18 years ago
parent
commit
a4f893ed15
3 changed files with 26 additions and 14 deletions
  1. 4 0
      Changelog-Trunk.txt
  2. 20 14
      src/map/chat.c
  3. 2 0
      src/map/mob.c

+ 4 - 0
Changelog-Trunk.txt

@@ -4,6 +4,10 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/09/20
+	* A mob's HP is set temporarily to 0 before invoking it's on-death script,
+	  prevents said scripts being able to "rekill" the mob indefinitely (if stuff
+	  like killmonster is used within) [Skotlex]
+	* Some small cleanups in chat.c [Skotlex]
 	* Fixed party_sub_count (TK_POWER) failing when the idle_no_share setting
 	  was disabled. [Skotlex]
 	* Enabled Star Gladiators and Soul Linkers to do /doridori [Skotlex]

+ 20 - 14
src/map/chat.c

@@ -120,8 +120,10 @@ int chat_leavechat(struct map_session_data *sd)
 	nullpo_retr(1, sd);
 
 	cd=(struct chat_data*)map_id2bl(sd->chatID);
-	if(cd==NULL)
+	if(cd==NULL) {
+		sd->chatID = 0;
 		return 1;
+	}
 
 	for(i = 0,leavechar=-1;i < cd->users;i++){
 		if(cd->usersd[i] == sd){
@@ -129,8 +131,11 @@ int chat_leavechat(struct map_session_data *sd)
 			break;
 		}
 	}
-	if(leavechar<0)	// そのchatに所属していないらしい (バグ時のみ)
+	if(leavechar<0)
+  	{	//Not found in the chatroom?
+		sd->chatID = 0;
 		return -1;
+	}
 
 	if(leavechar==0 && cd->users>1 && (*cd->owner)->type==BL_PC){
 		// 所有者だった&他に人が居る&PCのチャット
@@ -148,18 +153,19 @@ int chat_leavechat(struct map_session_data *sd)
 		//Delete empty chatroom
 		clif_clearchat(cd,0);
 		map_delobject(cd->bl.id);
-	} else {
-		for(i=leavechar;i < cd->users;i++)
-			cd->usersd[i] = cd->usersd[i+1];
-		if(leavechar==0 && (*cd->owner)->type==BL_PC){
-			//Adjust Chat location after owner has been changed.
-			map_delblock( &cd->bl );
-			cd->bl.x=cd->usersd[0]->bl.x;
-			cd->bl.y=cd->usersd[0]->bl.y;
-			map_addblock( &cd->bl );
-		}
-		clif_dispchat(cd,0);
+		return 1;
+	}
+	for(i=leavechar;i < cd->users;i++)
+		cd->usersd[i] = cd->usersd[i+1];
+
+	if(leavechar==0 && (*cd->owner)->type==BL_PC){
+		//Adjust Chat location after owner has been changed.
+		map_delblock( &cd->bl );
+		cd->bl.x=cd->usersd[0]->bl.x;
+		cd->bl.y=cd->usersd[0]->bl.y;
+		map_addblock( &cd->bl );
 	}
+	clif_dispchat(cd,0);
 
 	return 0;
 }
@@ -194,7 +200,7 @@ int chat_changechatowner(struct map_session_data *sd,char *nextownername)
 	clif_clearchat(cd,0);
 
 	// userlistの順番変更 (0が所有者なので)
-	if( (tmp_sd = cd->usersd[0]) == NULL )
+	if( (tmp_sd = cd->usersd[0]) == NULL ) //FIXME: How is this even possible!? Invoking character should be owner, hence, it SHOULD be on sc->usersd[0]!
 		return 1; //ありえるのかな?
 	cd->usersd[0] = cd->usersd[nextowner];
 	cd->usersd[nextowner] = tmp_sd;

+ 2 - 0
src/map/mob.c

@@ -2134,12 +2134,14 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 	if(md->nd)
 		mob_script_callback(md, src, CALLBACK_DEAD);
 	else if(md->npc_event[0]){
+		md->status.hp = 0; //So that npc_event invoked functions KNOW that I am dead.
 		if(src && src->type == BL_PET)
 			sd = ((struct pet_data *)src)->msd;
 		if(sd && battle_config.mob_npc_event_type)
 			npc_event(sd,md->npc_event,0);
 		else if(mvp_sd)
 			npc_event(mvp_sd,md->npc_event,0);
+		md->status.hp = 1;
 	} else if (mvp_sd) {	//lordalfa
 		pc_setglobalreg(mvp_sd,"killedrid",md->class_);
 		if(mvp_sd->state.event_kill_mob)