Пример #1
0
// ギルド勧誘への返答
int guild_reply_invite(struct map_session_data *sd,int guild_id,int flag)
{
	struct map_session_data *tsd;

	nullpo_retr(0, sd);
	
	//nullpo_retr(0, tsd= map_id2sd( sd->guild_invite_account ));
	//I checked the code, and there's no "check" for the case where the guy
	//that invites another to a guild quits the map-server before being replied.
	//Hence that's a valid null pointer scenario. :) [Skotlex]
	if ((tsd= map_id2sd( sd->guild_invite_account )) == NULL)
	{	//Do we send a "invitation failed" msg or something to the player?
		//Or should we accept the invitation and add it to the guild anyway?
		//afterall, guild_invite holds the guild id that the player was invited to.
		sd->guild_invite=0;
		sd->guild_invite_account=0;
		return 0;
	}

	if(sd->guild_invite!=guild_id)	// 勧誘とギルドIDが違う
		return 0;

	if(flag==1){	// 承諾
		struct guild_member m;
		struct guild *g;
		int i;

		// 定員確認
		if( (g=guild_search(tsd->status.guild_id))==NULL ){
			sd->guild_invite=0;
			sd->guild_invite_account=0;
			return 0;
		}
		for(i=0;i<g->max_member;i++)
			if(g->member[i].account_id==0)
				break;
		if(i==g->max_member){
			sd->guild_invite=0;
			sd->guild_invite_account=0;
			clif_guild_inviteack(tsd,3);
			return 0;
		}


		//inter鯖へ追加要求
		guild_makemember(&m,sd);
		intif_guild_addmember( sd->guild_invite, &m );
		return 0;
	}else{		// 拒否
		sd->guild_invite=0;
		sd->guild_invite_account=0;
		clif_guild_inviteack(tsd,1);
	}
	return 0;
}
Пример #2
0
/// Guild invitation reply.
/// flag: 0:rejected, 1:accepted
int guild_reply_invite(struct map_session_data* sd, int guild_id, int flag)
{
	struct map_session_data* tsd;

	nullpo_ret(sd);

	// subsequent requests may override the value
	if( sd->guild_invite != guild_id )
		return 0; // mismatch

	// look up the person who sent the invite
	//NOTE: this can be NULL because the person might have logged off in the meantime
	tsd = map_id2sd(sd->guild_invite_account);

	if ( sd->status.guild_id > 0 ) // [Paradox924X]
	{ // Already in another guild.
		if ( tsd ) clif_guild_inviteack(tsd,0);
		return 0;
	}
	else if( flag == 0 )
	{// rejected
		sd->guild_invite = 0;
		sd->guild_invite_account = 0;
		if( tsd ) clif_guild_inviteack(tsd,1);
	}
	else
	{// accepted
		struct guild_member m;
		struct guild* g;
		int i;

		if( (g=guild_search(guild_id)) == NULL )
		{
			sd->guild_invite = 0;
			sd->guild_invite_account = 0;
			return 0;
		}

		ARR_FIND( 0, g->max_member, i, g->member[i].account_id == 0 );
		if( i == g->max_member )
		{
			sd->guild_invite = 0;
			sd->guild_invite_account = 0;
			if( tsd ) clif_guild_inviteack(tsd,3);
			return 0;
		}

		guild_makemember(&m,sd);
		intif_guild_addmember(guild_id, &m);
		//TODO: send a minimap update to this player
	}

	return 0;
}