Skip to content

Commit

Permalink
Fixed #854
Browse files Browse the repository at this point in the history
Thanks to @theultramage for reporting and pinpointing the error as always!

Commiting this one for @aleos89, he fixed it for you guys.
  • Loading branch information
Lemongrass3110 committed Dec 30, 2015
1 parent 2f471a1 commit 4871dab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/common/mmo.h
Expand Up @@ -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.
Expand Down
12 changes: 9 additions & 3 deletions src/map/skill.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );

Expand Down

2 comments on commit 4871dab

@theultramage
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhm, okay. So L14141 limits WL_COMET to MAX_PARTY, but the code in battle.c still has p_sd[5].
Furthermore, the way you split up that check is not equivalent to the old code. You are now missing the "*c >= 1 in all other cases" check. I see AB_ADORAMUS and WM_GREAT_ECHO also calling this. I too had trouble rewriting this check into something more readable.

@aleos89
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WM_GREAT_ECHO is a Chorus skill, so it should get flagged by:

bool is_chorus = ( skill_get_inf2(skill_id)&INF2_CHORUS_SKILL );

And return:

    if ((inf2&INF2_CHORUS_SKILL || skill_id == WL_COMET) && *c == MAX_PARTY)
        return 0; // Entire party accounted for.

I left out the miscellaneous case because we pretty much have all the other cases checked. If we just have:

    if (*c >= 1)
        return 0;

It would be more of a fail safe check I guess.

You are correct about WL_COMET and AB_ADORAMUS though. Thanks!

Please sign in to comment.