Browse Source

Added pc_isidle() to simplify a few idle-no-share checks.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11026 54d463be-8e91-2dee-dedb-b68131a5f0ec
ultramage 18 years ago
parent
commit
e8f6f4ad38
2 changed files with 5 additions and 7 deletions
  1. 4 7
      src/map/party.c
  2. 1 0
      src/map/pc.h

+ 4 - 7
src/map/party.c

@@ -711,8 +711,7 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b
 
 	// count the number of players eligible for exp sharing
 	for (i = c = 0; i < MAX_PARTY; i++) {
-		if( (sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) ||
-			(battle_config.idle_no_share && (sd[c]->chatID || sd[c]->vender_id || sd[c]->idletime < last_tick - battle_config.idle_no_share)) )
+		if( (sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) || (battle_config.idle_no_share && pc_isidle(sd[c])) )
 			continue;
 		c++;
 	}
@@ -760,8 +759,7 @@ int party_share_loot(struct party_data* p, TBL_PC* sd, struct item* item_data, i
 				if (i >= MAX_PARTY)
 					i = 0;	// reset counter to 1st person in party so it'll stop when it reaches "itemc"
 
-				if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) ||
-					(battle_config.idle_no_share && (psd->chatID || psd->vender_id || last_tick - battle_config.idle_no_share > psd->idletime)) )
+				if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) || (battle_config.idle_no_share && pc_isidle(psd)) )
 					continue;
 				
 				if (pc_additem(psd,item_data,item_data->amount))
@@ -779,8 +777,7 @@ int party_share_loot(struct party_data* p, TBL_PC* sd, struct item* item_data, i
 			int count = 0;
 			//Collect pick candidates
 			for (i = 0; i < MAX_PARTY; i++) {
-				if( (psd[count] = p->data[i].sd) == NULL || psd[count]->bl.m != sd->bl.m || pc_isdead(psd[count]) ||
-					(battle_config.idle_no_share && (psd[count]->chatID || psd[count]->vender_id || last_tick - battle_config.idle_no_share > psd[count]->idletime)) )
+				if( (psd[count] = p->data[i].sd) == NULL || psd[count]->bl.m != sd->bl.m || pc_isdead(psd[count]) || (battle_config.idle_no_share && pc_isidle(psd[count])) )
 					continue;
 
 				count++;
@@ -833,7 +830,7 @@ int party_sub_count(struct block_list *bl, va_list ap)
 	if (sd->state.autotrade)
 		return 0;
 	
-	if (battle_config.idle_no_share && (sd->chatID || sd->vender_id || (sd->idletime < (last_tick - battle_config.idle_no_share))))
+	if (battle_config.idle_no_share && pc_isidle(sd))
 		return 0;
 
 	return 1;

+ 1 - 0
src/map/pc.h

@@ -89,6 +89,7 @@ enum {
 #define pc_setsit(sd) ((sd)->state.dead_sit = (sd)->vd.dead_sit = 2)
 #define pc_isdead(sd) ((sd)->state.dead_sit == 1)
 #define pc_issit(sd) ((sd)->vd.dead_sit == 2)
+#define pc_isidle(sd) ((sd)->chatID || (sd)->vender_id || DIFF_TICK(last_tick, sd->idletime) >= battle_config.idle_no_share)
 #define pc_setdir(sd,b,h) ((sd)->ud.dir = (b) ,(sd)->head_dir = (h) )
 #define pc_setchatid(sd,n) ((sd)->chatID = n)
 #define pc_ishiding(sd) ((sd)->sc.option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK))