Ejemplo n.º 1
0
int guild_create(struct map_session_data *sd, const char *name)
{
	char tname[NAME_LENGTH];
	struct guild_member m;
	nullpo_ret(sd);

	safestrncpy(tname, name, NAME_LENGTH);
	trim(tname);

	if( !tname[0] )
		return 0; // empty name

	if( sd->status.guild_id )
	{// already in a guild
		clif_guild_created(sd,1);
		return 0;
	}
	if( battle_config.guild_emperium_check && pc_search_inventory(sd,714) == -1 )
	{// item required
		clif_guild_created(sd,3);
		return 0;
	}

	guild_makemember(&m,sd);
	m.position=0;
	intif_guild_create(name,&m);
	return 1;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
// 作成要求
int guild_create(struct map_session_data *sd,char *name)
{
	nullpo_retr(0, sd);

	if(sd->status.guild_id==0){
		if(!battle_config.guild_emperium_check || pc_search_inventory(sd,714) >= 0) {
			struct guild_member m;
			guild_makemember(&m,sd);
			m.position=0;
			intif_guild_create(name,&m);
		} else
			clif_guild_created(sd,3);	// エンペリウムがいない
	}else
		clif_guild_created(sd,1);	// すでに所属している

	return 0;
}