Clean up party invitation reply. (#1471)
* Clean up party invitation reply. * Added reply result as enum. * Added official party restriction. * Added configuration in party.conf Signed-off-by: Cydh Ramdh <cydh@pservero.com>
This commit is contained in:
parent
600e8ae7ce
commit
47276e94a6
@ -56,3 +56,6 @@ party_even_share_bonus: 0
|
||||
// Display party name regardless if player is in a guild.
|
||||
// Official servers do not display party name unless the user is in a guild. (Note 1)
|
||||
display_party_name: no
|
||||
|
||||
// Prevent multiple characters of the same account to join the same party. (Note 1)
|
||||
block_account_in_same_party: yes
|
||||
|
@ -9092,6 +9092,7 @@ The command returns 1 upon success, and these values upon failure:
|
||||
-2: Player already has a party.
|
||||
-3: Party not found.
|
||||
-4: Party is full.
|
||||
-5: Another character from the same account is already in the party.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
|
@ -8331,6 +8331,7 @@ static const struct _battle_data {
|
||||
{ "mvp_exp_reward_message", &battle_config.mvp_exp_reward_message, 0, 0, 1, },
|
||||
{ "can_damage_skill", &battle_config.can_damage_skill, 1, 0, BL_ALL, },
|
||||
{ "atcommand_levelup_events", &battle_config.atcommand_levelup_events, 0, 0, 1, },
|
||||
{ "block_account_in_same_party", &battle_config.block_account_in_same_party, 1, 0, 1, },
|
||||
|
||||
#include "../custom/battle_config_init.inc"
|
||||
};
|
||||
|
@ -611,6 +611,7 @@ extern struct Battle_Config
|
||||
int mvp_exp_reward_message;
|
||||
int can_damage_skill; //Which BL types can damage traps
|
||||
int atcommand_levelup_events;
|
||||
int block_account_in_same_party;
|
||||
|
||||
#include "../custom/battle_config_struct.inc"
|
||||
} battle_config;
|
||||
|
@ -7288,23 +7288,14 @@ void clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd)
|
||||
/// Party invite result.
|
||||
/// 00fd <nick>.24S <result>.B (ZC_ACK_REQ_JOIN_GROUP)
|
||||
/// 02c5 <nick>.24S <result>.L (ZC_PARTY_JOIN_REQ_ACK)
|
||||
/// result=0 : char is already in a party -> MsgStringTable[80]
|
||||
/// result=1 : party invite was rejected -> MsgStringTable[81]
|
||||
/// result=2 : party invite was accepted -> MsgStringTable[82]
|
||||
/// result=3 : party is full -> MsgStringTable[83]
|
||||
/// result=4 : char of the same account already joined the party -> MsgStringTable[608]
|
||||
/// result=5 : char blocked party invite -> MsgStringTable[1324] (since 20070904)
|
||||
/// result=7 : char is not online or doesn't exist -> MsgStringTable[71] (since 20070904)
|
||||
/// result=8 : (%s) TODO instance related? -> MsgStringTable[1388] (since 20080527)
|
||||
/// return=9 : TODO map prohibits party joining? -> MsgStringTable[1871] (since 20110205)
|
||||
void clif_party_inviteack(struct map_session_data* sd, const char* nick, int result)
|
||||
void clif_party_invite_reply(struct map_session_data* sd, const char* nick, enum e_party_invite_reply reply)
|
||||
{
|
||||
int fd;
|
||||
nullpo_retv(sd);
|
||||
fd=sd->fd;
|
||||
|
||||
#if PACKETVER < 20070904
|
||||
if( result == 7 ) {
|
||||
if( reply == PARTY_REPLY_OFFLINE ) {
|
||||
clif_displaymessage(fd, msg_txt(sd,3));
|
||||
return;
|
||||
}
|
||||
@ -7314,13 +7305,13 @@ void clif_party_inviteack(struct map_session_data* sd, const char* nick, int res
|
||||
WFIFOHEAD(fd,packet_len(0xfd));
|
||||
WFIFOW(fd,0) = 0xfd;
|
||||
safestrncpy((char*)WFIFOP(fd,2),nick,NAME_LENGTH);
|
||||
WFIFOB(fd,26) = result;
|
||||
WFIFOB(fd,26) = reply;
|
||||
WFIFOSET(fd,packet_len(0xfd));
|
||||
#else
|
||||
WFIFOHEAD(fd,packet_len(0x2c5));
|
||||
WFIFOW(fd,0) = 0x2c5;
|
||||
safestrncpy((char*)WFIFOP(fd,2),nick,NAME_LENGTH);
|
||||
WFIFOL(fd,26) = result;
|
||||
WFIFOL(fd,26) = reply;
|
||||
WFIFOSET(fd,packet_len(0x2c5));
|
||||
#endif
|
||||
}
|
||||
|
@ -149,6 +149,19 @@ enum e_wip_block {
|
||||
WIP_DISABLE_ALL = 0x3,
|
||||
};
|
||||
|
||||
enum e_party_invite_reply {
|
||||
PARTY_REPLY_JOIN_OTHER_PARTY = 0, ///< result=0 : "The Character already joined another party." -> MsgStringTable[80]
|
||||
PARTY_REPLY_REJECTED, ///< result=1 : "Request for party rejected." -> MsgStringTable[81]
|
||||
PARTY_REPLY_ACCEPTED, ///< result=2 : "Request for party accepted." -> MsgStringTable[82]
|
||||
PARTY_REPLY_FULL, ///< result=3 : "Party Capacity exceeded." -> MsgStringTable[83]
|
||||
PARTY_REPLY_DUAL, ///< result=4 : "Character in the same account already joined." -> MsgStringTable[608]
|
||||
PARTY_REPLY_JOINMSG_REFUSE, ///< result=5 : !TODO "The character blocked the party invitation." -> MsgStringTable[1324] (since 20070904)
|
||||
PARTY_REPLY_UNKNOWN_ERROR, ///< result=6 : ??
|
||||
PARTY_REPLY_OFFLINE, ///< result=7 : "The Character is not currently online or does not exist." -> MsgStringTable[71] (since 20070904)
|
||||
PARTY_REPLY_INVALID_MAPPROPERTY, ///< result=8 : !TODO "Unable to organize a party in this map" -> MsgStringTable[1388] (since 20080527)
|
||||
PARTY_REPLY_INVALID_MAPPROPERTY_ME, ///< return=9 : !TODO "Cannot join a party in this map" -> MsgStringTable[1871] (since 20110205)
|
||||
};
|
||||
|
||||
// packet_db[SERVER] is reserved for server use
|
||||
#define SERVER 0
|
||||
#define packet_len(cmd) packet_db[SERVER][cmd].len
|
||||
@ -706,7 +719,7 @@ void clif_party_created(struct map_session_data *sd,int result);
|
||||
void clif_party_member_info(struct party_data *p, struct map_session_data *sd);
|
||||
void clif_party_info(struct party_data* p, struct map_session_data *sd);
|
||||
void clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd);
|
||||
void clif_party_inviteack(struct map_session_data* sd, const char* nick, int result);
|
||||
void clif_party_invite_reply(struct map_session_data* sd, const char* nick, enum e_party_invite_reply reply);
|
||||
void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag);
|
||||
void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, uint32 account_id, const char* name, int flag);
|
||||
void clif_party_message(struct party_data* p, uint32 account_id, const char* mes, int len);
|
||||
|
@ -353,6 +353,7 @@ int party_recv_info(struct party* sp, uint32 char_id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
///! TODO: Party invitation cross map-server through inter-server, so does with the reply.
|
||||
int party_invite(struct map_session_data *sd,struct map_session_data *tsd)
|
||||
{
|
||||
struct party_data *p;
|
||||
@ -371,11 +372,19 @@ int party_invite(struct map_session_data *sd,struct map_session_data *tsd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tsd && battle_config.block_account_in_same_party) {
|
||||
ARR_FIND(0, MAX_PARTY, i, p->party.member[i].account_id == tsd->status.account_id);
|
||||
if (i < MAX_PARTY) {
|
||||
clif_party_invite_reply(sd, tsd->status.name, PARTY_REPLY_DUAL);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// confirm if there is an open slot in the party
|
||||
ARR_FIND(0, MAX_PARTY, i, p->party.member[i].account_id == 0);
|
||||
|
||||
if( i == MAX_PARTY ) {
|
||||
clif_party_inviteack(sd, (tsd?tsd->status.name:""), 3);
|
||||
clif_party_invite_reply(sd, (tsd?tsd->status.name:""), PARTY_REPLY_FULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -386,25 +395,25 @@ int party_invite(struct map_session_data *sd,struct map_session_data *tsd)
|
||||
}
|
||||
|
||||
if( tsd == NULL) {
|
||||
clif_party_inviteack(sd, "", 7);
|
||||
clif_party_invite_reply(sd, "", PARTY_REPLY_OFFLINE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(!battle_config.invite_request_check) {
|
||||
if (tsd->guild_invite>0 || tsd->trade_partner || tsd->adopt_invite) {
|
||||
clif_party_inviteack(sd,tsd->status.name,0);
|
||||
clif_party_invite_reply(sd,tsd->status.name,PARTY_REPLY_JOIN_OTHER_PARTY);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tsd->fd) { //You can't invite someone who has already disconnected.
|
||||
clif_party_inviteack(sd,tsd->status.name,1);
|
||||
clif_party_invite_reply(sd,tsd->status.name,PARTY_REPLY_REJECTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( tsd->status.party_id > 0 || tsd->party_invite > 0 )
|
||||
{// already associated with a party
|
||||
clif_party_inviteack(sd,tsd->status.name,0);
|
||||
clif_party_invite_reply(sd,tsd->status.name,PARTY_REPLY_JOIN_OTHER_PARTY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -438,7 +447,7 @@ int party_reply_invite(struct map_session_data *sd,int party_id,int flag)
|
||||
sd->party_invite_account = 0;
|
||||
|
||||
if( tsd != NULL )
|
||||
clif_party_inviteack(tsd,sd->status.name,1);
|
||||
clif_party_invite_reply(tsd,sd->status.name,PARTY_REPLY_REJECTED);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -497,7 +506,7 @@ int party_member_added(int party_id,uint32 account_id,uint32 char_id, int flag)
|
||||
|
||||
if( flag ) { // failed
|
||||
if( sd2 != NULL )
|
||||
clif_party_inviteack(sd2,sd->status.name,3);
|
||||
clif_party_invite_reply(sd2,sd->status.name,PARTY_REPLY_FULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -508,7 +517,7 @@ int party_member_added(int party_id,uint32 account_id,uint32 char_id, int flag)
|
||||
clif_party_info(p,sd);
|
||||
|
||||
if( sd2 != NULL )
|
||||
clif_party_inviteack(sd2,sd->status.name,2);
|
||||
clif_party_invite_reply(sd2,sd->status.name,PARTY_REPLY_ACCEPTED);
|
||||
|
||||
for( i = 0; i < ARRAYLENGTH(p->data); ++i ) { // hp of the other party members
|
||||
sd2 = p->data[i].sd;
|
||||
|
@ -20227,6 +20227,7 @@ BUILDIN_FUNC(party_create)
|
||||
* @param party_id: The party that will be entered by player
|
||||
* @param char_id: Char id of player that will be joined to the party
|
||||
* @return val: Result value
|
||||
* -5 - another character of the same account is in the party
|
||||
* -4 - party is full
|
||||
* -3 - party is not found
|
||||
* -2 - player is in party already
|
||||
@ -20255,6 +20256,15 @@ BUILDIN_FUNC(party_addmember)
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
if (battle_config.block_account_in_same_party) {
|
||||
int i;
|
||||
ARR_FIND(0, MAX_PARTY, i, party->party.member[i].account_id == sd->status.account_id);
|
||||
if (i < MAX_PARTY) {
|
||||
script_pushint(st,-5);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if( party->party.count >= MAX_PARTY ) {
|
||||
script_pushint(st,-4);
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user