aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2025-06-16 01:30:08 -0300
committerfusion32 <marcopuzziello@gmail.com>2025-06-16 01:30:08 -0300
commit0612480d9beb19b9e90b3a4f1198b3da1fd21f6a (patch)
treee5d3a525cc395393f450a18194f0b6f5390273ff
parent5bdedeecea69a5892e3ce8854e85f78537cf7ca4 (diff)
downloadgame-0612480d9beb19b9e90b3a4f1198b3da1fd21f6a.tar.gz
game-0612480d9beb19b9e90b3a4f1198b3da1fd21f6a.zip
party functions
-rw-r--r--reference/game.c940
-rw-r--r--src/cr.hh2
-rw-r--r--src/operate.cc450
-rw-r--r--src/operate.hh16
4 files changed, 465 insertions, 943 deletions
diff --git a/reference/game.c b/reference/game.c
index 6b71785..8baf67a 100644
--- a/reference/game.c
+++ b/reference/game.c
@@ -18375,816 +18375,6 @@ void __static_initialization_and_destruction_0(int __initialize_p,int __priority
return;
}
-TParty * GetParty(ulong Leader)
-
-{
- TParty *pTVar1;
- int i;
- int i_00;
-
- i_00 = 0;
- if (0 < Parties) {
- do {
- pTVar1 = vector<TParty>::operator()(&Party,i_00);
- if (pTVar1->Leader == Leader) {
- pTVar1 = vector<TParty>::operator()(&Party,i_00);
- return pTVar1;
- }
- i_00 = i_00 + 1;
- } while (i_00 < Parties);
- }
- return (TParty *)0x0;
-}
-
-
-
-bool IsInvitedToParty(ulong Guest,ulong Host)
-
-{
- ulong *puVar1;
- int i;
- int iVar2;
- TParty *pTVar3;
-
- iVar2 = 0;
- if (0 < Parties) {
- do {
- pTVar3 = vector<TParty>::operator()(&Party,iVar2);
- if (pTVar3->Leader == Host) {
- pTVar3 = vector<TParty>::operator()(&Party,iVar2);
- goto LAB_0809b6b8;
- }
- iVar2 = iVar2 + 1;
- } while (iVar2 < Parties);
- }
- pTVar3 = (TParty *)0x0;
-LAB_0809b6b8:
- if ((pTVar3 != (TParty *)0x0) && (iVar2 = 0, 0 < pTVar3->InvitedPlayers)) {
- do {
- puVar1 = vector<>::operator()(&pTVar3->InvitedPlayer,iVar2);
- if (Guest == *puVar1) {
- return true;
- }
- iVar2 = iVar2 + 1;
- } while (iVar2 < pTVar3->InvitedPlayers);
- }
- return false;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: leader
-
-void DisbandParty(ulong Leader)
-
-{
- vector<> *this;
- TPlayer *pl;
- TPlayer *pTVar1;
- ulong *puVar2;
- TPlayer *pTVar3;
- TParty *pTVar4;
- int i;
- int iVar5;
- int iVar6;
- int iVar7;
- TPlayer *pl_1;
- int local_1c;
- int i_2;
- TPlayer *leader;
-
- iVar5 = 0;
- pTVar1 = GetPlayer(Leader);
- if (0 < Parties) {
- do {
- pTVar4 = vector<TParty>::operator()(&Party,iVar5);
- if (pTVar4->Leader == Leader) {
- i_2 = (int)vector<TParty>::operator()(&Party,iVar5);
- goto LAB_0809b76c;
- }
- iVar5 = iVar5 + 1;
- } while (iVar5 < Parties);
- }
- i_2 = 0;
-LAB_0809b76c:
- if (i_2 == 0) {
- error(&DAT_08100dc0,Leader);
- }
- else {
- iVar6 = 0;
- iVar5 = *(int *)(i_2 + 0x24);
- if (0 < iVar5) {
- do {
- puVar2 = vector<>::operator()((vector<> *)(i_2 + 4),iVar6);
- pTVar3 = GetPlayer(*puVar2);
- if (pTVar3 != (TPlayer *)0x0) {
- TPlayer::LeaveParty(pTVar3);
- }
- iVar6 = iVar6 + 1;
- iVar5 = *(int *)(i_2 + 0x24);
- } while (iVar6 < iVar5);
- }
- *(undefined4 *)i_2 = 0;
- local_1c = 0;
- if (0 < iVar5) {
- this = (vector<> *)(i_2 + 4);
- do {
- puVar2 = vector<>::operator()(this,local_1c);
- pTVar3 = GetPlayer(*puVar2);
- if (pTVar3 == (TPlayer *)0x0) {
- iVar5 = *(int *)(i_2 + 0x24);
- }
- else {
- SendMessage((pTVar3->super_TCreature).Connection,0x16,
- "Your party has been disbanded.");
- iVar5 = *(int *)(i_2 + 0x24);
- iVar6 = 0;
- if (0 < iVar5) {
- do {
- puVar2 = vector<>::operator()(this,iVar6);
- SendCreatureParty((pTVar3->super_TCreature).Connection,*puVar2);
- iVar7 = iVar6 + 1;
- puVar2 = vector<>::operator()(this,iVar6);
- SendCreatureSkull((pTVar3->super_TCreature).Connection,*puVar2);
- iVar5 = *(int *)(i_2 + 0x24);
- iVar6 = iVar7;
- } while (iVar7 < iVar5);
- }
- }
- local_1c = local_1c + 1;
- } while (local_1c < iVar5);
- }
- if ((pTVar1 != (TPlayer *)0x0) && (0 < *(int *)(i_2 + 0x48))) {
- iVar5 = 0;
- do {
- puVar2 = vector<>::operator()((vector<> *)(i_2 + 0x28),iVar5);
- pTVar3 = GetPlayer(*puVar2);
- if (pTVar3 != (TPlayer *)0x0) {
- SendCreatureParty((pTVar3->super_TCreature).Connection,Leader);
- SendCreatureParty((pTVar1->super_TCreature).Connection,
- (pTVar3->super_TCreature).ID);
- }
- iVar5 = iVar5 + 1;
- } while (iVar5 < *(int *)(i_2 + 0x48));
- }
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Guest_local
-
-void InviteToParty(ulong Host,ulong Guest)
-
-{
- TPlayer *this;
- TPlayer *this_00;
- ulong uVar1;
- TParty *pTVar2;
- ulong *puVar3;
- char *pcVar4;
- TConnection *Connection;
- TParty *P;
- int iVar5;
- int i;
- TPlayer *host;
- vector<> *local_20;
- TParty *local_1c;
- TPlayer *guest;
- ulong Guest_local;
-
- if (Host != Guest) {
- this = GetPlayer(Host);
- if (this == (TPlayer *)0x0) {
- Host = (ulong)s_InviteToParty__Einladender_Spiel_08100ec0;
-LAB_0809bd08:
- error((char *)Host);
- return;
- }
- this_00 = GetPlayer(Guest);
- if (this_00 == (TPlayer *)0x0) {
- SendResult((this->super_TCreature).Connection,PLAYERNOTONLINE);
- return;
- }
- uVar1 = TPlayer::GetPartyLeader(this,true);
- if (uVar1 == 0) {
- uVar1 = TPlayer::GetPartyLeader(this_00,true);
- if (uVar1 == 0) {
- iVar5 = 0;
- if (0 < Parties) {
- do {
- pTVar2 = vector<TParty>::operator()(&Party,iVar5);
- if (pTVar2->Leader == 0) {
- pTVar2 = vector<TParty>::operator()(&Party,iVar5);
- goto LAB_0809b9e5;
- }
- iVar5 = iVar5 + 1;
- } while (iVar5 < Parties);
- }
- pTVar2 = (TParty *)0x0;
-LAB_0809b9e5:
- if (pTVar2 == (TParty *)0x0) {
- pTVar2 = vector<TParty>::operator()(&Party,Parties);
- Parties = Parties + 1;
- }
- pTVar2->Leader = Host;
- puVar3 = vector<>::operator()(&pTVar2->Member,0);
- *puVar3 = Host;
- pTVar2->Members = 1;
- puVar3 = vector<>::operator()(&pTVar2->InvitedPlayer,0);
- *puVar3 = Guest;
- pTVar2->InvitedPlayers = 1;
- TPlayer::JoinParty(this,Host);
- SendMessage((this->super_TCreature).Connection,0x16,"%s has been invited.",
- (this_00->super_TCreature).Name);
- pcVar4 = "his";
- if ((this->super_TCreature).Sex != 1) {
- pcVar4 = "her";
- }
- SendMessage((this_00->super_TCreature).Connection,0x16,"%s invites you to %s party."
- ,(this->super_TCreature).Name,pcVar4);
- SendCreatureParty((this->super_TCreature).Connection,Host);
- SendCreatureSkull((this->super_TCreature).Connection,Host);
-LAB_0809bac9:
- SendCreatureParty((this->super_TCreature).Connection,Guest);
- SendCreatureParty((this_00->super_TCreature).Connection,Host);
- return;
- }
- Connection = (this->super_TCreature).Connection;
- pcVar4 = "%s is already member of a party.";
-LAB_0809bb73:
- SendMessage(Connection,0x16,pcVar4,(this_00->super_TCreature).Name);
- }
- else {
- uVar1 = TPlayer::GetPartyLeader(this,false);
- if (uVar1 == Host) {
- uVar1 = TPlayer::GetPartyLeader(this_00,true);
- if (uVar1 == 0) {
- iVar5 = 0;
- if (0 < Parties) {
- do {
- pTVar2 = vector<TParty>::operator()(&Party,iVar5);
- if (pTVar2->Leader == Host) {
- local_1c = vector<TParty>::operator()(&Party,iVar5);
- goto LAB_0809bbfc;
- }
- iVar5 = iVar5 + 1;
- } while (iVar5 < Parties);
- }
- local_1c = (TParty *)0x0;
-LAB_0809bbfc:
- if (local_1c == (TParty *)0x0) {
- Host = (ulong)&DAT_08100e40;
- goto LAB_0809bd08;
- }
- i = 0;
- iVar5 = local_1c->InvitedPlayers;
- if (0 < iVar5) {
- do {
- puVar3 = vector<>::operator()(&local_1c->InvitedPlayer,i);
- if (*puVar3 == Guest) {
- Connection = (this->super_TCreature).Connection;
- pcVar4 = "%s has already been invited.";
- goto LAB_0809bb73;
- }
- i = i + 1;
- iVar5 = local_1c->InvitedPlayers;
- } while (i < iVar5);
- }
- local_20 = &local_1c->InvitedPlayer;
- puVar3 = vector<>::operator()(local_20,iVar5);
- *puVar3 = Guest;
- local_1c->InvitedPlayers = local_1c->InvitedPlayers + 1;
- SendMessage((this->super_TCreature).Connection,0x16,"%s has been invited.",
- (this_00->super_TCreature).Name);
- pcVar4 = "his";
- if ((this->super_TCreature).Sex != 1) {
- pcVar4 = "her";
- }
- SendMessage((this_00->super_TCreature).Connection,0x16,
- "%s invites you to %s party.",(this->super_TCreature).Name,pcVar4);
- goto LAB_0809bac9;
- }
- pcVar4 = "your";
- uVar1 = TPlayer::GetPartyLeader(this_00,true);
- if (uVar1 != Host) {
- pcVar4 = "a";
- }
- SendMessage((this->super_TCreature).Connection,0x16,
- "%s is already member of %s party.",(this_00->super_TCreature).Name,
- pcVar4);
- }
- else {
- SendMessage((this->super_TCreature).Connection,0x16,"You may not invite players.");
- }
- }
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Host_local
-
-void RevokeInvitation(ulong Host,ulong Guest)
-
-{
- TPlayer *this;
- TPlayer *pTVar1;
- ulong uVar2;
- TConnection *Connection;
- ulong *puVar3;
- ulong *puVar4;
- TParty *pTVar5;
- int Position;
- int iVar6;
- int i;
- int i_1;
- int iVar7;
- char *pcVar8;
- TParty *local_24;
- TPlayer *guest;
- TPlayer *host;
- ulong Guest_local;
- ulong Host_local;
-
- if (Host == Guest) {
- return;
- }
- this = GetPlayer(Host);
- if (this == (TPlayer *)0x0) {
- Host = (ulong)s_RevokeInvitation__Einladender_Sp_08100fc0;
-LAB_0809c05e:
- error((char *)Host);
- return;
- }
- pTVar1 = GetPlayer(Guest);
- uVar2 = TPlayer::GetPartyLeader(this,false);
- if (uVar2 == Host) {
- iVar6 = 0;
- if (0 < Parties) {
- do {
- pTVar5 = vector<TParty>::operator()(&Party,iVar6);
- if (pTVar5->Leader == Host) {
- local_24 = vector<TParty>::operator()(&Party,iVar6);
- goto LAB_0809be65;
- }
- iVar6 = iVar6 + 1;
- } while (iVar6 < Parties);
- }
- local_24 = (TParty *)0x0;
-LAB_0809be65:
- if (local_24 == (TParty *)0x0) {
- Host = (ulong)&DAT_08100f80;
- goto LAB_0809c05e;
- }
- i = -1;
- iVar6 = local_24->InvitedPlayers;
- if (0 < iVar6) {
- iVar7 = 0;
- do {
- puVar3 = vector<>::operator()(&local_24->InvitedPlayer,iVar7);
- iVar6 = local_24->InvitedPlayers;
- if (*puVar3 == Guest) {
- i = iVar7;
- }
- iVar7 = iVar7 + 1;
- } while (iVar7 < iVar6);
- }
- if (i != -1) {
- if (i < iVar6 + -1) {
- do {
- iVar7 = i + 1;
- puVar3 = vector<>::operator()(&local_24->InvitedPlayer,i);
- puVar4 = vector<>::operator()(&local_24->InvitedPlayer,iVar7);
- *puVar3 = *puVar4;
- iVar6 = local_24->InvitedPlayers;
- i = iVar7;
- } while (iVar7 < iVar6 + -1);
- }
- local_24->InvitedPlayers = iVar6 + -1;
- if (pTVar1 == (TPlayer *)0x0) {
- SendMessage((this->super_TCreature).Connection,0x16,"Invitation has been revoked.");
- }
- else {
- SendMessage((this->super_TCreature).Connection,0x16,
- "Invitation for %s has been revoked.",(pTVar1->super_TCreature).Name);
- pcVar8 = "his";
- if ((this->super_TCreature).Sex != 1) {
- pcVar8 = "her";
- }
- SendMessage((pTVar1->super_TCreature).Connection,0x16,
- "%s has revoked %s invitation.",(this->super_TCreature).Name,pcVar8);
- SendCreatureParty((this->super_TCreature).Connection,Guest);
- SendCreatureParty((pTVar1->super_TCreature).Connection,Host);
- }
- if (local_24->Members != 1) {
- return;
- }
- if (local_24->InvitedPlayers != 0) {
- return;
- }
- DisbandParty(Host);
- return;
- }
- if (pTVar1 != (TPlayer *)0x0) {
- SendMessage((this->super_TCreature).Connection,0x16,"%s has not been invited.",
- (pTVar1->super_TCreature).Name);
- return;
- }
- Connection = (this->super_TCreature).Connection;
- pcVar8 = "This player has not been invited.";
- }
- else {
- Connection = (this->super_TCreature).Connection;
- pcVar8 = "You may not invite players.";
- }
- SendMessage(Connection,0x16,pcVar8);
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Guest_local
-
-void JoinParty(ulong Guest,ulong Host)
-
-{
- vector<> *this;
- TPlayer *this_00;
- TPlayer *pTVar1;
- ulong uVar2;
- ulong *puVar3;
- ulong *puVar4;
- ulong uVar5;
- int i;
- int iVar6;
- int i_2;
- char *pcVar7;
- TParty *pTVar8;
- TConnection *pTVar9;
- char *Text;
- int local_24;
- int Position;
- TPlayer *host;
- TPlayer *guest;
- ulong Host_local;
- ulong Guest_local;
-
- if (Guest != Host) {
- this_00 = GetPlayer(Guest);
- if (this_00 == (TPlayer *)0x0) {
- error("JoinParty: Eingeladener Spieler %lu existiert nicht.\n");
- return;
- }
- pTVar1 = GetPlayer(Host);
- if (pTVar1 == (TPlayer *)0x0) {
- SendResult((this_00->super_TCreature).Connection,PLAYERNOTONLINE);
- return;
- }
- uVar2 = TPlayer::GetPartyLeader(this_00,true);
- if (uVar2 == 0) {
- iVar6 = 0;
- if (0 < Parties) {
- do {
- pTVar8 = vector<TParty>::operator()(&Party,iVar6);
- if (pTVar8->Leader == Host) {
- pTVar8 = vector<TParty>::operator()(&Party,iVar6);
- goto LAB_0809c131;
- }
- iVar6 = iVar6 + 1;
- } while (iVar6 < Parties);
- }
- pTVar8 = (TParty *)0x0;
-LAB_0809c131:
- local_24 = -1;
- if ((pTVar8 != (TParty *)0x0) && (iVar6 = 0, 0 < pTVar8->InvitedPlayers)) {
- do {
- puVar3 = vector<>::operator()(&pTVar8->InvitedPlayer,iVar6);
- if (*puVar3 == Guest) {
- local_24 = iVar6;
- }
- iVar6 = iVar6 + 1;
- } while (iVar6 < pTVar8->InvitedPlayers);
- }
- if (local_24 != -1) {
- this = &pTVar8->Member;
- puVar3 = vector<>::operator()(this,pTVar8->Members);
- *puVar3 = Guest;
- pTVar8->Members = pTVar8->Members + 1;
- pTVar8->InvitedPlayers = pTVar8->InvitedPlayers + -1;
- puVar3 = vector<>::operator()(&pTVar8->InvitedPlayer,local_24);
- puVar4 = vector<>::operator()(&pTVar8->InvitedPlayer,pTVar8->InvitedPlayers);
- *puVar3 = *puVar4;
- TPlayer::JoinParty(this_00,Host);
- SendMessage((this_00->super_TCreature).Connection,0x16,
- "You have joined %s\'s party.",(pTVar1->super_TCreature).Name);
- iVar6 = 0;
- SendCreatureParty((this_00->super_TCreature).Connection,Guest);
- SendCreatureSkull((this_00->super_TCreature).Connection,Guest);
- if (pTVar8->Members < 1) {
- return;
- }
- do {
- puVar3 = vector<>::operator()(this,iVar6);
- if (*puVar3 != Guest) {
- pTVar9 = (this_00->super_TCreature).Connection;
- puVar3 = vector<>::operator()(this,iVar6);
- SendCreatureParty(pTVar9,*puVar3);
- pTVar9 = (this_00->super_TCreature).Connection;
- puVar3 = vector<>::operator()(this,iVar6);
- SendCreatureSkull(pTVar9,*puVar3);
- puVar3 = vector<>::operator()(this,iVar6);
- pTVar1 = GetPlayer(*puVar3);
- if (pTVar1 != (TPlayer *)0x0) {
- SendMessage((pTVar1->super_TCreature).Connection,0x16,
- "%s has joined the party.",(this_00->super_TCreature).Name);
- SendCreatureParty((pTVar1->super_TCreature).Connection,Guest);
- SendCreatureSkull((pTVar1->super_TCreature).Connection,Guest);
- }
- }
- iVar6 = iVar6 + 1;
- } while (iVar6 < pTVar8->Members);
- return;
- }
- pTVar9 = (this_00->super_TCreature).Connection;
- pcVar7 = (pTVar1->super_TCreature).Name;
- Text = "%s has not invited you.";
- }
- else {
- pcVar7 = "this";
- uVar2 = TPlayer::GetPartyLeader(this_00,true);
- uVar5 = TPlayer::GetPartyLeader(pTVar1,true);
- if (uVar2 != uVar5) {
- pcVar7 = "a";
- }
- pTVar9 = (this_00->super_TCreature).Connection;
- Text = "You are already member of %s party.";
- }
- SendMessage(pTVar9,0x16,Text,pcVar7);
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: oldLeader
-
-void PassLeadership(ulong OldLeader,ulong NewLeader)
-
-{
- TPlayer *pl;
- TPlayer *this;
- TPlayer *pTVar1;
- ulong uVar2;
- ulong *puVar3;
- TPlayer *pTVar4;
- TParty *pTVar5;
- int i;
- int iVar6;
- int iVar7;
- int InvitedPlayers;
- int i_2;
- TPlayer *newLeader;
- TPlayer *oldLeader;
-
- if (OldLeader != NewLeader) {
- this = GetPlayer(OldLeader);
- if (this == (TPlayer *)0x0) {
- OldLeader = (ulong)&DAT_08101160;
-LAB_0809c6c4:
- error((char *)OldLeader);
- return;
- }
- pTVar1 = GetPlayer(NewLeader);
- if (pTVar1 == (TPlayer *)0x0) {
- SendResult((this->super_TCreature).Connection,PLAYERNOTONLINE);
- return;
- }
- uVar2 = TPlayer::GetPartyLeader(this,false);
- if (uVar2 == OldLeader) {
- uVar2 = TPlayer::GetPartyLeader(pTVar1,false);
- if (uVar2 == OldLeader) {
- iVar6 = 0;
- if (0 < Parties) {
- do {
- pTVar5 = vector<TParty>::operator()(&Party,iVar6);
- if (pTVar5->Leader == OldLeader) {
- i_2 = (int)vector<TParty>::operator()(&Party,iVar6);
- goto LAB_0809c51b;
- }
- iVar6 = iVar6 + 1;
- } while (iVar6 < Parties);
- }
- i_2 = 0;
-LAB_0809c51b:
- if (i_2 == 0) {
- OldLeader = (ulong)&DAT_08101120;
- goto LAB_0809c6c4;
- }
- iVar7 = 0;
- iVar6 = *(int *)(i_2 + 0x24);
- *(ulong *)i_2 = NewLeader;
- if (0 < iVar6) {
- do {
- puVar3 = vector<>::operator()((vector<> *)(i_2 + 4),iVar7);
- pTVar4 = GetPlayer(*puVar3);
- if (pTVar4 != (TPlayer *)0x0) {
- TPlayer::JoinParty(pTVar4,NewLeader);
- }
- iVar7 = iVar7 + 1;
- iVar6 = *(int *)(i_2 + 0x24);
- } while (iVar7 < iVar6);
- }
- InvitedPlayers = 0;
- if (0 < iVar6) {
- do {
- puVar3 = vector<>::operator()((vector<> *)(i_2 + 4),InvitedPlayers);
- pTVar4 = GetPlayer(*puVar3);
- if (pTVar4 != (TPlayer *)0x0) {
- if (pTVar4 == pTVar1) {
- SendMessage((pTVar4->super_TCreature).Connection,0x16,
- "You are now leader of your party.");
- }
- else {
- SendMessage((pTVar4->super_TCreature).Connection,0x16,
- "%s is now leader of your party.",
- (pTVar1->super_TCreature).Name);
- }
- SendCreatureParty((pTVar4->super_TCreature).Connection,OldLeader);
- SendCreatureParty((pTVar4->super_TCreature).Connection,NewLeader);
- }
- InvitedPlayers = InvitedPlayers + 1;
- } while (InvitedPlayers < *(int *)(i_2 + 0x24));
- }
- iVar6 = *(int *)(i_2 + 0x48);
- iVar7 = 0;
- *(undefined4 *)(i_2 + 0x48) = 0;
- if (0 < iVar6) {
- do {
- puVar3 = vector<>::operator()((vector<> *)(i_2 + 0x28),iVar7);
- pTVar1 = GetPlayer(*puVar3);
- if (pTVar1 != (TPlayer *)0x0) {
- SendCreatureParty((pTVar1->super_TCreature).Connection,OldLeader);
- SendCreatureParty((this->super_TCreature).Connection,
- (pTVar1->super_TCreature).ID);
- }
- iVar7 = iVar7 + 1;
- } while (iVar7 < iVar6);
- }
- }
- else {
- SendMessage((this->super_TCreature).Connection,0x16,
- "%s is not member of your party.",(pTVar1->super_TCreature).Name);
- }
- }
- else {
- SendMessage((this->super_TCreature).Connection,0x16,"You are not leader of a party.");
- }
- }
- return;
-}
-
-
-
-// WARNING: Variable defined which should be unmapped: Member_local
-
-void LeaveParty(ulong Member,bool Forced)
-
-{
- vector<> *this;
- TConnection *pTVar1;
- ulong NewLeader;
- TPlayer *this_00;
- ulong uVar2;
- ulong *puVar3;
- ulong *puVar4;
- TPlayer *pTVar5;
- TParty *pTVar6;
- int Position;
- int iVar7;
- int i;
- int i_1;
- int iVar8;
- TParty *local_20;
- TPlayer *member;
- bool Forced_local;
- ulong Member_local;
-
- this_00 = GetPlayer(Member);
- if (this_00 == (TPlayer *)0x0) {
- Member = (ulong)s_LeaveParty__Mitglied_existiert_n_081012c0;
- }
- else {
- uVar2 = TPlayer::GetPartyLeader(this_00,false);
- if (uVar2 != 0) {
- if ((Forced) || ((this_00->super_TCreature).EarliestLogoutRound <= RoundNr)) {
- iVar7 = 0;
- uVar2 = TPlayer::GetPartyLeader(this_00,false);
- if (0 < Parties) {
- do {
- pTVar6 = vector<TParty>::operator()(&Party,iVar7);
- if (pTVar6->Leader == uVar2) {
- local_20 = vector<TParty>::operator()(&Party,iVar7);
- goto LAB_0809c7c8;
- }
- iVar7 = iVar7 + 1;
- } while (iVar7 < Parties);
- }
- local_20 = (TParty *)0x0;
-LAB_0809c7c8:
- if (local_20 == (TParty *)0x0) {
- TPlayer::GetPartyLeader(this_00,false);
- error(&DAT_081011e0);
- return;
- }
- iVar7 = local_20->Members;
- if ((iVar7 == 1) || ((iVar7 == 2 && (local_20->InvitedPlayers == 0)))) {
- DisbandParty(local_20->Leader);
- return;
- }
- if (local_20->Leader == Member) {
- puVar3 = vector<>::operator()(&local_20->Member,0);
- uVar2 = *puVar3;
- if (uVar2 == Member) {
- puVar3 = vector<>::operator()(&local_20->Member,1);
- uVar2 = *puVar3;
- }
- PassLeadership(Member,uVar2);
- iVar7 = local_20->Members;
- }
- i = -1;
- if (0 < iVar7) {
- iVar8 = 0;
- do {
- puVar3 = vector<>::operator()(&local_20->Member,iVar8);
- iVar7 = local_20->Members;
- if (*puVar3 == Member) {
- i = iVar8;
- }
- iVar8 = iVar8 + 1;
- } while (iVar8 < iVar7);
- }
- if (i == -1) {
- Member = (ulong)s_LeaveParty__Mitglied_nicht_gefun_081011a0;
- goto LAB_0809c9e0;
- }
- if (i < iVar7 + -1) {
- do {
- iVar8 = i + 1;
- puVar3 = vector<>::operator()(&local_20->Member,i);
- puVar4 = vector<>::operator()(&local_20->Member,iVar8);
- *puVar3 = *puVar4;
- iVar7 = local_20->Members;
- i = iVar8;
- } while (iVar8 < iVar7 + -1);
- }
- local_20->Members = iVar7 + -1;
- TPlayer::LeaveParty(this_00);
- if (!Forced) {
- SendMessage((this_00->super_TCreature).Connection,0x16,
- "You have left the party.");
- }
- SendCreatureParty((this_00->super_TCreature).Connection,Member);
- SendCreatureSkull((this_00->super_TCreature).Connection,Member);
- if (0 < local_20->Members) {
- this = &local_20->Member;
- iVar7 = 0;
- do {
- pTVar1 = (this_00->super_TCreature).Connection;
- puVar3 = vector<>::operator()(this,iVar7);
- SendCreatureParty(pTVar1,*puVar3);
- pTVar1 = (this_00->super_TCreature).Connection;
- puVar3 = vector<>::operator()(this,iVar7);
- SendCreatureSkull(pTVar1,*puVar3);
- puVar3 = vector<>::operator()(this,iVar7);
- pTVar5 = GetPlayer(*puVar3);
- if (pTVar5 != (TPlayer *)0x0) {
- SendMessage((pTVar5->super_TCreature).Connection,0x16,
- "%s has left the party.",(this_00->super_TCreature).Name);
- SendCreatureParty((pTVar5->super_TCreature).Connection,Member);
- SendCreatureSkull((pTVar5->super_TCreature).Connection,Member);
- }
- iVar7 = iVar7 + 1;
- } while (iVar7 < local_20->Members);
- }
- }
- else {
- SendMessage((this_00->super_TCreature).Connection,0x16,
- "You may not leave your party during or immediately after a fight!");
- }
- return;
- }
- Member = (ulong)s_LeaveParty__Spieler_ist_kein_Mit_08101280;
- }
-LAB_0809c9e0:
- error((char *)Member);
- return;
-}
-
-
-
void __tcf_0(void *param_1)
{
@@ -19288,136 +18478,6 @@ void _GLOBAL__I_Channel(void)
return;
}
-
-
-// DWARF original prototype: void TChannel(TChannel * this)
-
-void __thiscall TChannel::TChannel(TChannel *this)
-
-{
- vector<>::vector(&this->Subscriber,0,10,10);
- // try { // try from 0809ccd0 to 0809ccd4 has its CatchHandler @ 0809ccf3
- vector<>::vector(&this->InvitedPlayer,0,10,10);
- this->Moderator = 0;
- this->Subscribers = 0;
- this->InvitedPlayers = 0;
- return;
-}
-
-
-
-// DWARF original prototype: void TParty(TParty * this)
-
-void __thiscall TParty::TParty(TParty *this)
-
-{
- vector<>::vector(&this->Member,0,10,10);
- // try { // try from 0809cd60 to 0809cd64 has its CatchHandler @ 0809cd83
- vector<>::vector(&this->InvitedPlayer,0,10,10);
- this->Leader = 0;
- this->Members = 0;
- this->InvitedPlayers = 0;
- return;
-}
-
-// DWARF original prototype: TStatement * append(fifo<TStatement> * this)
-
-TStatement * __thiscall fifo<TStatement>::append(fifo<TStatement> *this)
-
-{
- TStatement *pTVar1;
- undefined3 uVar2;
- TStatement *pTVar3;
- int iVar4;
- int iVar5;
- int iVar6;
- int i;
- int iVar7;
- TStatement *NewEntry;
-
- iVar5 = this->Head;
- iVar6 = this->Size;
- iVar4 = iVar6;
- if ((iVar5 - this->Tail) + 1 == iVar6) {
- iVar4 = iVar6 * 2;
- pTVar3 = (TStatement *)operator_new__(iVar6 * 0x38);
- iVar5 = this->Head;
- iVar6 = this->Tail;
- if (iVar6 <= iVar5) {
- do {
- iVar5 = iVar6 % iVar4;
- iVar7 = iVar6 + 1;
- iVar6 = iVar6 % this->Size;
- pTVar1 = this->Entry;
- pTVar3[iVar5].StatementID = pTVar1[iVar6].StatementID;
- pTVar3[iVar5].TimeStamp = pTVar1[iVar6].TimeStamp;
- pTVar3[iVar5].CharacterID = pTVar1[iVar6].CharacterID;
- pTVar3[iVar5].Mode = pTVar1[iVar6].Mode;
- pTVar3[iVar5].Channel = pTVar1[iVar6].Channel;
- pTVar3[iVar5].Text = pTVar1[iVar6].Text;
- uVar2 = *(undefined3 *)&pTVar1[iVar6].field_0x19;
- pTVar3[iVar5].Reported = pTVar1[iVar6].Reported;
- *(undefined3 *)&pTVar3[iVar5].field_0x19 = uVar2;
- iVar5 = this->Head;
- iVar6 = iVar7;
- } while (iVar7 <= iVar5);
- }
- if (this->Entry != (TStatement *)0x0) {
- operator_delete__(this->Entry);
- iVar5 = this->Head;
- }
- this->Entry = pTVar3;
- this->Size = iVar4;
- }
- this->Head = iVar5 + 1;
- return this->Entry + (iVar5 + 1) % iVar4;
-}
-
-
-
-// DWARF original prototype: TListener * append(fifo<TListener> * this)
-
-TListener * __thiscall fifo<TListener>::append(fifo<TListener> *this)
-
-{
- ulong uVar1;
- TListener *pTVar2;
- int iVar3;
- int iVar4;
- int i;
- int iVar5;
- int iVar6;
- TListener *NewEntry;
-
- iVar3 = this->Head;
- iVar5 = this->Size;
- iVar4 = iVar5;
- if ((iVar3 - this->Tail) + 1 == iVar5) {
- iVar4 = iVar5 * 2;
- pTVar2 = (TListener *)operator_new__(iVar5 << 4);
- iVar5 = this->Tail;
- iVar3 = this->Head;
- if (iVar5 <= iVar3) {
- do {
- iVar6 = iVar5 + 1;
- uVar1 = this->Entry[iVar5 % this->Size].CharacterID;
- pTVar2[iVar5 % iVar4].StatementID = this->Entry[iVar5 % this->Size].StatementID;
- pTVar2[iVar5 % iVar4].CharacterID = uVar1;
- iVar3 = this->Head;
- iVar5 = iVar6;
- } while (iVar6 <= iVar3);
- }
- if (this->Entry != (TListener *)0x0) {
- operator_delete__(this->Entry);
- iVar3 = this->Head;
- }
- this->Entry = pTVar2;
- this->Size = iVar4;
- }
- this->Head = iVar3 + 1;
- return this->Entry + (iVar3 + 1) % iVar4;
-}
-
void __static_initialization_and_destruction_0(int __initialize_p,int __priority)
{
diff --git a/src/cr.hh b/src/cr.hh
index 32d0090..0c7d373 100644
--- a/src/cr.hh
+++ b/src/cr.hh
@@ -702,6 +702,8 @@ struct TPlayer: TCreature {
int GetQuestValue(int Number);
void SetQuestValue(int Number, int Value);
+ void JoinParty(uint32 Leader);
+ void LeaveParty(void);
uint32 GetPartyLeader(bool CheckFormer);
bool SpellKnown(int SpellNr);
diff --git a/src/operate.cc b/src/operate.cc
index 7d18a94..07f3c50 100644
--- a/src/operate.cc
+++ b/src/operate.cc
@@ -3843,3 +3843,453 @@ void TParty::operator=(const TParty &Other){
*this->InvitedPlayer.at(i) = Other.InvitedPlayer.copyAt(i);
}
}
+
+TParty *GetParty(uint32 LeaderID){
+ TParty *Result = NULL;
+ for(int i = 0; i < Parties; i += 1){
+ if(Party.at(i)->Leader == LeaderID){
+ Result = Party.at(i);
+ break;
+ }
+ }
+ return Result;
+}
+
+bool IsInvitedToParty(uint32 GuestID, uint32 HostID){
+ bool Result = false;
+ TParty *P = GetParty(HostID);
+ if(P != NULL){
+ for(int i = 0; i < P->InvitedPlayers; i += 1){
+ if(*P->InvitedPlayer.at(i) == GuestID){
+ Result = true;
+ break;
+ }
+ }
+ }
+ return Result;
+}
+
+void DisbandParty(uint32 LeaderID){
+ TParty *P = GetParty(LeaderID);
+ if(P == NULL){
+ error("DisbandParty: Party von Anführer %u nicht gefunden.\n", LeaderID);
+ return;
+ }
+
+ // NOTE(fusion): We need to iterate over members twice because `SendCreatureParty`
+ // and `SendCreatureSkull` use party information, which is annoying.
+
+ for(int i = 0; i < P->Members; i += 1){
+ uint32 MemberID = *P->Member.at(i);
+ TPlayer *Member = GetPlayer(MemberID);
+ if(Member != NULL){
+ Member->LeaveParty();
+ }
+ }
+
+ P->Leader = 0;
+
+ for(int i = 0; i < P->Members; i += 1){
+ uint32 MemberID = *P->Member.at(i);
+ TPlayer *Member = GetPlayer(MemberID);
+ if(Member != NULL && Member->Connection != NULL){
+ SendMessage(Member->Connection, TALK_INFO_MESSAGE,
+ "Your party has been disbanded.");
+ for(int j = 0; j < P->Members; j += 1){
+ uint32 OtherID = *P->Member.at(j);
+ SendCreatureParty(Member->Connection, OtherID);
+ SendCreatureSkull(Member->Connection, OtherID);
+ }
+ }
+ }
+
+ TPlayer *Leader = GetPlayer(LeaderID);
+ if(Leader != NULL){
+ for(int i = 0; i < P->InvitedPlayers; i += 1){
+ uint32 GuestID = *P->InvitedPlayer.at(i);
+ TPlayer *Guest = GetPlayer(GuestID);
+ if(Guest != NULL){
+ SendCreatureParty(Guest->Connection, LeaderID);
+ SendCreatureParty(Leader->Connection, GuestID);
+ }
+ }
+ }
+}
+
+void InviteToParty(uint32 HostID, uint32 GuestID){
+ if(HostID == GuestID){
+ return;
+ }
+
+ TPlayer *Host = GetPlayer(HostID);
+ if(Host == NULL){
+ error("InviteToParty: Einladender Spieler %u existiert nicht.\n", HostID);
+ return;
+ }
+
+ TPlayer *Guest = GetPlayer(GuestID);
+ if(Guest == NULL){
+ SendResult(Host->Connection, PLAYERNOTONLINE);
+ return;
+ }
+
+ if(Host->GetPartyLeader(true) == 0){
+ if(Guest->GetPartyLeader(true) != 0){
+ SendMessage(Host->Connection, TALK_INFO_MESSAGE,
+ "%s is already member of a party.", Guest->Name);
+ return;
+ }
+
+ TParty *P = GetParty(0);
+ if(P == NULL){
+ P = Party.at(Parties);
+ Parties += 1;
+ }
+
+ P->Leader = HostID;
+ *P->Member.at(0) = HostID;
+ P->Members = 1;
+ *P->InvitedPlayer.at(0) = GuestID;
+ P->InvitedPlayers = 1;
+
+ Host->JoinParty(HostID);
+ SendMessage(Host->Connection, TALK_INFO_MESSAGE,
+ "%s has been invited.", Guest->Name);
+ SendMessage(Guest->Connection, TALK_INFO_MESSAGE,
+ "%s invites you to %s party.", Host->Name,
+ (Host->Sex == 1 ? "his" : "her"));
+ SendCreatureParty(Host->Connection, HostID);
+ SendCreatureSkull(Host->Connection, HostID);
+ SendCreatureParty(Host->Connection, GuestID);
+ SendCreatureParty(Guest->Connection, HostID);
+ }else if(Host->GetPartyLeader(false) == HostID){
+ if(Guest->GetPartyLeader(true) != 0){
+ SendMessage(Host->Connection, TALK_INFO_MESSAGE,
+ "%s is already member of %s party.", Guest->Name,
+ (Guest->GetPartyLeader(true) == HostID ? "your" : "a"));
+ return;
+ }
+
+ TParty *P = GetParty(HostID);
+ if(P == NULL){
+ error("InviteToParty: Party von Anführer %u nicht gefunden.\n", HostID);
+ return;
+ }
+
+ for(int i = 0; i < P->InvitedPlayers; i += 1){
+ if(*P->InvitedPlayer.at(i) == GuestID){
+ SendMessage(Host->Connection, TALK_INFO_MESSAGE,
+ "%s has already been invited.", Guest->Name);
+ return;
+ }
+ }
+
+ *P->InvitedPlayer.at(P->InvitedPlayers) = GuestID;
+ P->InvitedPlayers += 1;
+
+ SendMessage(Host->Connection, TALK_INFO_MESSAGE,
+ "%s has been invited.", Guest->Name);
+ SendMessage(Guest->Connection, TALK_INFO_MESSAGE,
+ "%s invites you to %s party.", Host->Name,
+ (Host->Sex == 1 ? "his" : "her"));
+ SendCreatureParty(Host->Connection, GuestID);
+ SendCreatureParty(Guest->Connection, HostID);
+ }else{
+ SendMessage(Host->Connection, TALK_INFO_MESSAGE,
+ "You may not invite players.");
+ }
+}
+
+void RevokeInvitation(uint32 HostID, uint32 GuestID){
+ TPlayer *Host = GetPlayer(HostID);
+ if(Host == NULL){
+ error("RevokeInvitation: Einladender Spieler %u existiert nicht.\n", HostID);
+ return;
+ }
+
+ if(Host->GetPartyLeader(false) != HostID){
+ SendMessage(Host->Connection, TALK_INFO_MESSAGE,
+ "You may not invite players.");
+ return;
+ }
+
+ TParty *P = GetParty(HostID);
+ if(P == NULL){
+ error("RevokeInvitation: Party von Anführer %u nicht gefunden.\n", HostID);
+ return;
+ }
+
+ int InviteIndex = 0;
+ while(InviteIndex < P->InvitedPlayers){
+ if(*P->InvitedPlayer.at(InviteIndex) == GuestID){
+ break;
+ }
+ InviteIndex += 1;
+ }
+
+ TPlayer *Guest = GetPlayer(GuestID);
+ if(InviteIndex >= P->InvitedPlayers){
+ if(Guest != NULL){
+ SendMessage(Host->Connection, TALK_INFO_MESSAGE,
+ "%s has not been invited.", Guest->Name);
+ }else{
+ SendMessage(Host->Connection, TALK_INFO_MESSAGE,
+ "This player has not been invited.");
+ }
+ return;
+ }
+
+ // TODO(fusion): This ordered removal isn't relevant at all. It could be a
+ // swap and pop just like in `JoinParty`, unlike when removing members.
+ P->InvitedPlayers -= 1;
+ for(int i = InviteIndex; i < P->InvitedPlayers; i += 1){
+ *P->InvitedPlayer.at(i) = *P->InvitedPlayer.at(i + 1);
+ }
+
+ if(Guest != NULL){
+ SendMessage(Host->Connection, TALK_INFO_MESSAGE,
+ "Invitation for %s has been revoked.", Guest->Name);
+ SendMessage(Guest->Connection, TALK_INFO_MESSAGE,
+ "%s has revoked %s invitation.", Host->Name,
+ (Host->Sex == 1 ? "his" : "her"));
+ SendCreatureParty(Host->Connection, GuestID);
+ SendCreatureParty(Guest->Connection, HostID);
+ }else{
+ SendMessage(Host->Connection, TALK_INFO_MESSAGE,
+ "Invitation has been revoked.");
+ }
+
+ if(P->Members == 1 && P->InvitedPlayers == 0){
+ DisbandParty(HostID);
+ }
+}
+
+void JoinParty(uint32 GuestID, uint32 HostID){
+ if(GuestID == HostID){
+ return;
+ }
+
+ TPlayer *Guest = GetPlayer(GuestID);
+ if(Guest == NULL){
+ error("JoinParty: Eingeladener Spieler %u existiert nicht.\n", GuestID);
+ return;
+ }
+
+ TPlayer *Host = GetPlayer(HostID);
+ if(Host == NULL){
+ SendResult(Guest->Connection, PLAYERNOTONLINE);
+ return;
+ }
+
+ if(Guest->GetPartyLeader(true) != 0){
+ bool SameParty = Guest->GetPartyLeader(true) == Host->GetPartyLeader(true);
+ SendMessage(Guest->Connection, TALK_INFO_MESSAGE,
+ "You are already member of %s party.",
+ (SameParty ? "this" : "a"));
+ return;
+ }
+
+ TParty *P = GetParty(HostID);
+ if(P == NULL){
+ SendMessage(Guest->Connection, TALK_INFO_MESSAGE,
+ "%s has not invited you.", Host->Name);
+ return;
+ }
+
+ int InviteIndex = 0;
+ while(InviteIndex < P->InvitedPlayers){
+ if(*P->InvitedPlayer.at(InviteIndex) == GuestID){
+ break;
+ }
+ InviteIndex += 1;
+ }
+
+ if(InviteIndex >= P->InvitedPlayers){
+ SendMessage(Guest->Connection, TALK_INFO_MESSAGE,
+ "%s has not invited you.", Host->Name);
+ return;
+ }
+
+ // NOTE(fusion): A little swap and pop action.
+ P->InvitedPlayers -= 1;
+ *P->InvitedPlayer.at(InviteIndex) = *P->InvitedPlayer.at(P->InvitedPlayers);
+
+ *P->Member.at(P->Members) = GuestID;
+ P->Members += 1;
+
+ Guest->JoinParty(HostID);
+ SendMessage(Guest->Connection, TALK_INFO_MESSAGE,
+ "You have joined %s\'s party.", Host->Name);
+ for(int i = 0; i < P->Members; i += 1){
+ uint32 MemberID = *P->Member.at(i);
+ SendCreatureParty(Guest->Connection, MemberID);
+ SendCreatureSkull(Guest->Connection, MemberID);
+ if(MemberID != GuestID){
+ TPlayer *Member = GetPlayer(MemberID);
+ if(Member != NULL){
+ SendMessage(Member->Connection, TALK_INFO_MESSAGE,
+ "%s has joined the party.", Guest->Name);
+ SendCreatureParty(Member->Connection, GuestID);
+ SendCreatureSkull(Member->Connection, GuestID);
+ }
+ }
+ }
+}
+
+void PassLeadership(uint32 OldLeaderID, uint32 NewLeaderID){
+ if(OldLeaderID == NewLeaderID){
+ return;
+ }
+
+ TPlayer *OldLeader = GetPlayer(OldLeaderID);
+ if(OldLeader == NULL){
+ error("PassLeadership: Alter Anführer %u existiert nicht.\n", OldLeaderID);
+ return;
+ }
+
+ TPlayer *NewLeader = GetPlayer(NewLeaderID);
+ if(NewLeader == NULL){
+ SendResult(OldLeader->Connection, PLAYERNOTONLINE);
+ return;
+ }
+
+ if(OldLeader->GetPartyLeader(false) != OldLeaderID){
+ SendMessage(OldLeader->Connection, TALK_INFO_MESSAGE,
+ "You are not leader of a party.");
+ return;
+ }
+
+ if(NewLeader->GetPartyLeader(false) != OldLeaderID){
+ SendMessage(OldLeader->Connection, TALK_INFO_MESSAGE,
+ "%s is not member of your party.", NewLeader->Name);
+ return;
+ }
+
+ TParty *P = GetParty(OldLeaderID);
+ if(P == NULL){
+ error("PassLeadership: Party von Anführer %u nicht gefunden.\n", OldLeaderID);
+ return;
+ }
+
+ P->Leader = NewLeaderID;
+
+ // NOTE(fusion): Same as `DisbandParty`.
+ for(int i = 0; i < P->Members; i += 1){
+ uint32 MemberID = *P->Member.at(i);
+ TPlayer *Member = GetPlayer(MemberID);
+ if(Member != NULL){
+ Member->JoinParty(NewLeaderID);
+ }
+ }
+
+ for(int i = 0; i < P->Members; i += 1){
+ uint32 MemberID = *P->Member.at(i);
+ TPlayer *Member = GetPlayer(MemberID);
+ if(Member != NULL){
+ if(MemberID == NewLeaderID){
+ SendMessage(Member->Connection, TALK_INFO_MESSAGE,
+ "You are now leader of your party.");
+ }else{
+ SendMessage(Member->Connection, TALK_INFO_MESSAGE,
+ "%s is now leader of your party.", NewLeader->Name);
+ }
+ SendCreatureParty(Member->Connection, OldLeaderID);
+ SendCreatureParty(Member->Connection, NewLeaderID);
+ }
+ }
+
+ // NOTE(fusion): The list of invited players is cleared here.
+ int InvitedPlayers = P->InvitedPlayers;
+ P->InvitedPlayers = 0;
+
+ for(int i = 0; i < InvitedPlayers; i += 1){
+ uint32 GuestID = *P->InvitedPlayer.at(i);
+ TPlayer *Guest = GetPlayer(GuestID);
+ if(Guest != NULL){
+ SendCreatureParty(Guest->Connection, OldLeaderID);
+ SendCreatureParty(OldLeader->Connection, GuestID);
+ }
+ }
+}
+
+void LeaveParty(uint32 MemberID, bool Forced){
+ TPlayer *Member = GetPlayer(MemberID);
+ if(Member == NULL){
+ error("LeaveParty: Mitglied existiert nicht.\n");
+ return;
+ }
+
+ uint32 LeaderID = Member->GetPartyLeader(false);
+ if(LeaderID == 0){
+ error("LeaveParty: Spieler ist kein Mitglied einer Jagdgruppe.\n");
+ return;
+ }
+
+ if(!Forced && Member->EarliestLogoutRound > RoundNr){
+ SendMessage(Member->Connection, TALK_INFO_MESSAGE,
+ "You may not leave your party during or immediately after a fight!");
+ return;
+ }
+
+ TParty *P = GetParty(LeaderID);
+ if(P == NULL){
+ error("LeaveParty: Party von Anführer %u nicht gefunden.\n", LeaderID);
+ return;
+ }
+
+ if(P->Members == 1 || (P->Members == 2 && P->InvitedPlayers == 0)){
+ DisbandParty(LeaderID);
+ return;
+ }
+
+ if(LeaderID == MemberID){
+ LeaderID = *P->Member.at(0);
+ if(LeaderID == MemberID){
+ LeaderID = *P->Member.at(1);
+ }
+ PassLeadership(MemberID, LeaderID);
+ }
+
+ int MemberIndex = 0;
+ while(MemberIndex < P->Members){
+ if(*P->Member.at(MemberIndex) == MemberID){
+ break;
+ }
+ MemberIndex += 1;
+ }
+
+ if(MemberIndex >= P->Members){
+ error("LeaveParty: Mitglied nicht gefunden.\n");
+ return;
+ }
+
+ // NOTE(fusion): This ordered removal is important because we want the oldest
+ // members to get leadership when the leader leaves.
+ P->Members -= 1;
+ for(int i = MemberIndex; i < P->Members; i += 1){
+ *P->Member.at(i) = *P->Member.at(i + 1);
+ }
+
+ Member->LeaveParty();
+ if(!Forced){
+ SendMessage(Member->Connection, TALK_INFO_MESSAGE,
+ "You have left the party.");
+ }
+
+ SendCreatureParty(Member->Connection, MemberID);
+ SendCreatureSkull(Member->Connection, MemberID);
+
+ for(int i = 0; i < P->Members; i += 1){
+ uint32 OtherID = *P->Member.at(i);
+ SendCreatureParty(Member->Connection, OtherID);
+ SendCreatureSkull(Member->Connection, OtherID);
+
+ TPlayer *Other = GetPlayer(OtherID);
+ if(Other != NULL){
+ SendMessage(Other->Connection, TALK_INFO_MESSAGE,
+ "%s has left the party.", Member->Name);
+ SendCreatureParty(Other->Connection, MemberID);
+ SendCreatureSkull(Other->Connection, MemberID);
+ }
+ }
+}
diff --git a/src/operate.hh b/src/operate.hh
index 4942569..3cb5075 100644
--- a/src/operate.hh
+++ b/src/operate.hh
@@ -22,6 +22,7 @@ enum : int {
OBJECT_MOVED = 3,
};
+#if 0
// TODO(fusion): Use these?
enum : int {
CHANNEL_GUILD = 0,
@@ -33,11 +34,11 @@ enum : int {
CHANNEL_RLCHAT = 6,
CHANNEL_HELP = 7,
- CHANNEL_PUBLIC_FIRST = 0,
- CHANNEL_PUBLIC_LAST = 7,
CHANNEL_PRIVATE_FIRST = 8,
- CHANNEL_PRIVATE_LAST = 0xFFFF,
+ CHANNEL_FIRST = 0,
+ CHANNEL_LAST = 0xFFFF,
};
+#endif
struct TChannel {
TChannel(void);
@@ -188,4 +189,13 @@ bool JoinChannel(int ChannelID, uint32 CharacterID);
void LeaveChannel(int ChannelID, uint32 CharacterID, bool Close);
void LeaveAllChannels(uint32 CharacterID);
+TParty *GetParty(uint32 LeaderID);
+bool IsInvitedToParty(uint32 GuestID, uint32 HostID);
+void DisbandParty(uint32 LeaderID);
+void InviteToParty(uint32 HostID, uint32 GuestID);
+void RevokeInvitation(uint32 HostID, uint32 GuestID);
+void JoinParty(uint32 GuestID, uint32 HostID);
+void PassLeadership(uint32 OldLeaderID, uint32 NewLeaderID);
+void LeaveParty(uint32 MemberID, bool Forced);
+
#endif //TIBIA_OPERATE_HH_