Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Soul Balls in newer clients #3291

Merged
merged 3 commits into from
May 1, 2024

Conversation

guilherme-gm
Copy link
Member

@guilherme-gm guilherme-gm commented Apr 27, 2024

Pull Request Prelude

Changes Proposed

Fixes soul balls not being properly displayed in newer clients. (2020+).

2020+ clients split the logic for spirit spheres and soul balls, players may now have both at the same time, and a new packet was introduced for soul balls only (being separated from the spirit spheres one).

Implementation based on rAthena logic/packet. also huge thanks to 4144 for packet dates.

I decided to split clif_spiritball into 2 functions and leave the number of balls to the caller so we can simplify those functions. There were 2 reasons for that:

  1. We now have to deal with different packets for each case depending on client
  2. Pretty much every call was converting sd/hd to bl, to convert back to sd/hd inside the function... leaving to the caller simplifies things and gives flexibility if someone is looking for some sort of customization

Issues addressed:
None, I think (someone mentioned it in discord)

@guilherme-gm guilherme-gm force-pushed the fix-soulball branch 2 times, most recently from 71d33f4 to dc9bd31 Compare April 27, 2024 14:45
@guilherme-gm guilherme-gm changed the title [WIP] Fix Soul Balls in newer clients Fix Soul Balls in newer clients Apr 27, 2024
@guilherme-gm guilherme-gm marked this pull request as ready for review April 27, 2024 14:46
case BALL_TYPE_NONE:
break;
}
clif->send(&p, sizeof(struct PACKET_ZC_SPIRITS), ((bl == NULL && spirit == BALL_TYPE_SOUL) ? &sd->bl : bl), (spirit == BALL_TYPE_SPIRIT ? AREA : target));
Copy link
Member Author

Choose a reason for hiding this comment

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

the logic here in previous version is somewhat confusing to me, but:

  1. nullpo_retv(bl); at the start, so (bl == NULL && ..) is always false, thus bl is always the target (Well, it would be anyway)
  2. the target for SPIRIT is always AREA, this is given by the caller already.

so simply changing to bl, target is equivalent.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. I agree
  2. target is not always AREA

src/map/clif.c Outdated
@@ -9761,7 +9751,7 @@ static void clif_refresh(struct map_session_data *sd)
if (sd->charm_type != CHARM_TYPE_NONE && sd->charm_count > 0)
clif->charm_single(sd->fd, sd);
if (sd->soulball > 0)
clif->spiritball(&sd->bl, BALL_TYPE_SOUL, SELF);
clif->soulball(&sd->bl, sd->soulball, SELF);
Copy link
Contributor

Choose a reason for hiding this comment

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

Like this one.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, what I tried to say is that for BALL_TYPE_SPIRIT, clif->spiritball is already called with AREA every time, no need to "hardcode" it in the ternary (thus, simply using target is enough). Just trying to justify that removing the ternary was safe, because clif->spiritball was already called with AREA every time it was called for "spirit ball" instead of "soul ball".

This one was not AREA, but it was also not BALL_TYPE_SPIRIT

@MishimaHaruna MishimaHaruna added this to the Release v2024.04 milestone Apr 30, 2024
src/map/clif.h Outdated Show resolved Hide resolved
- newer clients uses separate packets, making a mess to handle both in
  the same function
- those functions now expect caller to give the number of balls, since
  most of the time there is a "generalization" to be  "specialized"
  again
spirit spheres and soul balls are handled separately in newer clients,
and thus, using ZC_SPIRITS always show spirit balls, even for classes
that would show soul balls before
@MishimaHaruna MishimaHaruna merged commit f281814 into HerculesWS:master May 1, 2024
307 of 346 checks passed
@guilherme-gm guilherme-gm deleted the fix-soulball branch May 1, 2024 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants