Browse Source

Fixed #854

Thanks to @theultramage for reporting and pinpointing the error as always!

Commiting this one for @aleos89, he fixed it for you guys.
Lemongrass3110 9 years ago
parent
commit
4871dab7de
2 changed files with 14 additions and 3 deletions
  1. 5 0
      src/common/mmo.h
  2. 9 3
      src/map/skill.c

+ 5 - 0
src/common/mmo.h

@@ -822,6 +822,11 @@ enum e_pc_reg_loading {
 #error MAX_ZENY is too big
 #endif
 
+// This sanity check is required, because some other places(like skill.c) rely on this
+#if MAX_PARTY < 2
+#error MAX_PARTY is too small, you need at least 2 players for a party
+#endif
+
 #ifndef VIP_ENABLE
 	#define MIN_STORAGE MAX_STORAGE // If the VIP system is disabled the min = max.
 	#define MIN_CHARS MAX_CHARS // Default number of characters per account.

+ 9 - 3
src/map/skill.c

@@ -14132,8 +14132,14 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap)
 	p_sd = va_arg(ap, int *);
 	skill_id = va_arg(ap,int);
 
-	if ( ((skill_id != PR_BENEDICTIO && *c >=1) || *c >=2) && !(skill_get_inf2(skill_id)&INF2_CHORUS_SKILL) )
-		return 0; //Partner found for ensembles, or the two companions for Benedictio. [Skotlex]
+	if (skill_id == PR_BENEDICTIO && *c >= 2)
+		return 0; // Two companions found for Benedictio. [Skotlex]
+
+	if (skill_get_inf2(skill_id)&INF2_ENSEMBLE_SKILL && *c >= 1)
+		return 0; // Partner found for ensembles.
+
+	if ((skill_get_inf2(skill_id)&INF2_CHORUS_SKILL || skill_id == WL_COMET) && *c == MAX_PARTY)
+		return 0; // Entire party accounted for.
 
 	if (bl == src)
 		return 0;
@@ -14207,7 +14213,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap)
 int skill_check_pc_partner(struct map_session_data *sd, uint16 skill_id, uint16 *skill_lv, int range, int cast_flag)
 {
 	static int c=0;
-	static int p_sd[2] = { 0, 0 };
+	static int p_sd[MAX_PARTY];
 	int i;
 	bool is_chorus = ( skill_get_inf2(skill_id)&INF2_CHORUS_SKILL );