otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.59k stars 1.06k forks source link

Party Leader problem #221

Closed TheSumm closed 5 months ago

TheSumm commented 10 years ago

If my understanding isn't wrong I think there is a bug when leader leaves the party.

Player::getPartyShield will still return SHIELD_YELLOW for that player if the method of any member is called as the check is: if (party->getLeader() == player) {

I do not know if that is the right way to fix it or if it has any side effects. if (party->getLeader() == player && player->getParty()) {

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

marksamman commented 10 years ago

If "player" is the leader of a party that obviously means he is in a party, so it is redundant to check if he is in a party. It's showing up properly in the Tibia client (unless I misunderstood the problem, but I tried from the perspective as a member of the party and the leader who left the party).

TheSumm commented 10 years ago

I will message back tomorrow after doing some more tests.

TheSumm commented 10 years ago

When the leader leaves the party which only has 1 member (and no invites) the leadership will not be passed. However, the leaders party is set to nullptr already. When updating the shields for the member (s) now it will still return yellow shield as the player is the leader but actually got no party.

In Party::disband updateShields is called before the members' party is set to nullptr so it will send yellow shield again.

Also, the leader gets 2 messages: You have left the party. YourName has left the party.

dalkon commented 10 years ago

@TheSumm, I have posted a pull request for the otclient that fixes this.

TheSumm commented 10 years ago

The bug still exists for me. For both OTClient and Real Tibia Client. I create a party with Char "Leader" and invited "Member", then "Member" joins the party and "Leader" leaves the party. In "Member"'s client "Leader" will still have yellow shield.

Member's Client log: ERROR: Shield 4 for Leader ERROR: Skull 0 for Leader ERROR: Shield 4 for Leader ERROR: Shield 0 for Member(self) ERROR: Skull 0 for Member(self) ERROR: Skull 0 for Leader

I do not know if you can reproduce it or if it is a mistake on my end, I tested it with the currently latest commit and "git status" shows no changes.

marksamman commented 10 years ago

The issue with the yellow shield should be fixed now, but there's still much room for improvement in Party::leaveParty and Party::disband and the issue with "YourName has left the party." needs to be addressed too, so I'm leaving this issue open for that.

ramon-bernardo commented 5 months ago

This issue can be closed.

The problem does not occur when there are only two players in the party. If either the member or leader leaves, the party disbands. When there are more than two players, leadership is transferred to another player, and the shields are updated.