diff options
author | remoitnane <remoit(DOT)nane(AT)gmail(DOT)com> | 2010-09-08 01:37:20 -0700 |
---|---|---|
committer | remoitnane <remoit(DOT)nane(AT)gmail(DOT)com> | 2010-09-08 01:37:20 -0700 |
commit | 2864134d79c5a176e570b54fe58974a3bec87eff (patch) | |
tree | 8006a885423f31be878dd1aca013f4fcd480e662 /src/map/party.c | |
parent | e2f46583ef4b9fb062b8cf85b2337a893ded5641 (diff) | |
download | tmwa-2864134d79c5a176e570b54fe58974a3bec87eff.tar.gz tmwa-2864134d79c5a176e570b54fe58974a3bec87eff.tar.bz2 tmwa-2864134d79c5a176e570b54fe58974a3bec87eff.tar.xz tmwa-2864134d79c5a176e570b54fe58974a3bec87eff.zip |
Simplify party invitation logic and clean up comments
This eliminates part of the client's burden to manage the ID of the
player sending the invitation. This also introduces a new response
value (3) for the invitation acknowledgement packet (0x00fd) to
indicate the party is full.
Resolves: TMW Mantis #676
Diffstat (limited to 'src/map/party.c')
-rw-r--r-- | src/map/party.c | 72 |
1 files changed, 50 insertions, 22 deletions
diff --git a/src/map/party.c b/src/map/party.c index 8ddfca2..a6e9f24 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -219,45 +219,63 @@ int party_recv_info (struct party *sp) return 0; } -// ƒp[ƒeƒB‚Ö‚ÌŠ©—U +/* Process party invitation from sd to account_id. */ int party_invite (struct map_session_data *sd, int account_id) { struct map_session_data *tsd = map_id2sd (account_id); struct party *p = party_search (sd->status.party_id); int i; + int full = 1; /* Indicates whether or not there's room for one more. */ nullpo_retr (0, sd); - if (tsd == NULL || p == NULL) + if (!tsd || !p || !tsd->fd) return 0; - printf ("\tA\n"); - if (!battle_config.invite_request_check) { + /* Disallow the invitation under these conditions. */ if (tsd->guild_invite > 0 || tsd->trade_partner || tsd->npc_id || tsd->npc_shopid || pc_checkskill (tsd, NV_PARTY) < 1) { - clif_party_inviteack (sd, tsd->status.name, 0); + clif_party_inviteack (sd, tsd->status.name, 1); return 0; } } - printf ("\tB\n"); + + /* The target player is already in a party, or has a pending invitation. */ if (tsd->status.party_id > 0 || tsd->party_invite > 0) - { // ‘ŠŽè‚ÌŠ‘®Šm”F + { clif_party_inviteack (sd, tsd->status.name, 0); return 0; } - printf ("\tC\n"); + for (i = 0; i < MAX_PARTY; i++) - { // “¯ƒAƒJƒEƒ“ƒgŠm”F + { + /* + * A character from the target account is already in the same party. + * The response isn't strictly accurate, as they're separate + * characters, but we're making do with what was already in place and + * leaving this (mostly) alone for now. + */ if (p->member[i].account_id == account_id) { - clif_party_inviteack (sd, tsd->status.name, 0); + clif_party_inviteack (sd, tsd->status.name, 1); return 0; } + + if (!p->member[i].account_id) + full = 0; } - printf ("\tD\n"); + + /* There isn't enough room for a new member. */ + if (full) + { + clif_party_inviteack (sd, tsd->status.name, 3); + return 0; + } + + /* Otherwise, relay the invitation to the target player. */ tsd->party_invite = sd->status.party_id; tsd->party_invite_account = sd->status.account_id; @@ -265,26 +283,36 @@ int party_invite (struct map_session_data *sd, int account_id) return 0; } -// ƒp[ƒeƒBŠ©—U‚ւ̕ԓš +/* Process response to party invitation. */ int party_reply_invite (struct map_session_data *sd, int account_id, int flag) { - struct map_session_data *tsd = map_id2sd (account_id); - nullpo_retr (0, sd); + /* There is no pending invitation. */ + if (!sd->party_invite || !sd->party_invite_account) + return 0; + + /* + * Only one invitation can be pending, so these have to be the same. Since + * the client continues to send the wrong ID, and it's already managed on + * this side of things, the sent ID is being ignored. + */ + account_id = sd->party_invite_account; + + /* The invitation was accepted. */ if (flag == 1) - { // ³‘ø - //interŽI‚֒ljÁ—v‹ intif_party_addmember (sd->party_invite, sd->status.account_id); - return 0; - } + /* The invitation was rejected. */ else - { // ‹‘”Û + { + /* This is the player who sent the invitation. */ + struct map_session_data *tsd = NULL; + sd->party_invite = 0; sd->party_invite_account = 0; - if (tsd == NULL) - return 0; - clif_party_inviteack (tsd, sd->status.name, 1); + + if ((tsd = map_id2sd (account_id))) + clif_party_inviteack (tsd, sd->status.name, 1); } return 0; } |