Exemple #1
0
/**
 * Make a player join the guild channel
 * - Create a guild channel if it does not exist
 * @param sd: Player data
 * @param flag: Join type (1 - Guild chat, 2 - Ally chat)
 * @return
 *   0: Success
 *  -1: Invalid player
 *  -2: Player has no guild attached
 */
int channel_gjoin(struct map_session_data *sd, int flag){
	struct Channel *channel;
	struct guild *g;

	if(!sd || sd->state.autotrade) return -1;
	g = sd->guild;
	if(!g) return -2;

	channel = g->channel;
	if(!channel){
		channel = channel_create_simple(NULL,NULL,CHAN_TYPE_ALLY,g->guild_id);
		g->channel = channel;
		channel_ajoin(g);
	}
	if(flag&1) {
		channel_join(channel,sd);	//join our guild chat
	}
	if(flag&2){
		int i;
		for (i = 0; i < MAX_GUILDALLIANCE; i++){
			struct guild *ag; //allied guld
			struct guild_alliance *ga = &g->alliance[i]; //guild alliance
			if(ga->guild_id && (ga->opposition==0) && (ag=guild_search(ga->guild_id)) ) //only join allies
				channel_join(ag->channel,sd);
		}
	}
	return 0;
}
Exemple #2
0
/**
 * A player is attempting to create a channel
 * @param sd: Player data
 * @param chname: Channel name
 * @param chpass: Channel password
 * @return 0 on success or -1 on failure
 */
int channel_pccreate(struct map_session_data *sd, char *chname, char *chpass){
	char output[CHAT_SIZE_MAX];
	int8 res;

	if(!sd || !chname)
		return 0;

	res = channel_chk(chname,chpass,7);
	if(res==0){ //success
		struct Channel *channel = channel_create_simple(chname,chpass,CHAN_TYPE_PRIVATE,sd->status.char_id);
		channel_join(channel,sd);
		if( ( channel->opt & CHAN_OPT_ANNOUNCE_SELF ) ) {
			sprintf(output, msg_txt(sd,1403),chname); // You're now in the '%s' channel.
			clif_displaymessage(sd->fd, output);
		}
	} else { //failure display cause
		switch(res){
		case -1: sprintf(output, msg_txt(sd,1405), CHAN_NAME_LENGTH); break;// Channel name must start with '#'.
		case -2: sprintf(output, msg_txt(sd,1406), CHAN_NAME_LENGTH); break;// Channel length must be between 3 and %d.
		case -3: sprintf(output, msg_txt(sd,1436), CHAN_NAME_LENGTH); break;// Channel password can't be over %d characters.
		case -4: sprintf(output, msg_txt(sd,1407), chname);// Channel '%s' is not available.
		}
		clif_displaymessage(sd->fd, output);
		return -1;
	}
	return 0;
}
Exemple #3
0
int channel_invite_accept(struct map_session_data *sd)
{
	struct channel_data *cd;
	const struct TimerData * td;
	char output[CHAT_SIZE_MAX];
	char *name = NULL;

	if( sd == NULL || sd->channel_invite_timer == INVALID_TIMER )
		return 0;

	if( (td = get_timer(sd->channel_invite_timer)) == NULL )
	{
		sd->channel_invite_timer = INVALID_TIMER;
		return 0; // Error
	}

	name = (char *)td->data;

	if( (cd = (struct channel_data *)strdb_get(channel_db, name)) == NULL )
	{
		sprintf(output, msg_txt(899), name);
		clif_displaymessage(sd->fd, output);
		channel_invite_clear(sd);
	}
	else
	{
		channel_invite_clear(sd);
		channel_join(sd, cd->name, cd->pass, true);
	}

	return 1;
}
Exemple #4
0
/**
 * A player is attempting to join a channel
 * @param sd: Player data
 * @param chname: Channel name
 * @param pass: Channel password
 * @return 0 on success or -1 on failure
 */
int channel_pcjoin(struct map_session_data *sd, char *chname, char *pass){
	struct Channel *channel;
	char output[CHAT_SIZE_MAX];

	if(!sd || !chname)
		return 0;

	if( channel_chk(chname,NULL,1) ) {
		clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
		return -1;
	}

	channel = channel_name2channel(chname,sd,1);
	if(channel){
		if (!pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) && !channel_pccheckgroup(channel, sd->group_id)) {
			sprintf(output, msg_txt(sd,1407), chname); // Channel '%s' is not available.
			clif_displaymessage(sd->fd, output);
			return -1;
		}
		if(channel_haspc(channel,sd)==1) {
			sprintf(output, msg_txt(sd,1434),chname); // You're already in the '%s' channel.
			clif_displaymessage(sd->fd, output);
			return -1;
		}
		else if( channel->pass[0] != '\0') { //chan has a pass
			if(strcmp(channel->pass,pass) != 0){ //wrong pass entry
				if( pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) ) {
					sd->stealth = true;
				} else {
					sprintf(output, msg_txt(sd,1401),chname,"@join"); // Channel '%s' is password-protected (usage: %s <#channel_name> <password>).
					clif_displaymessage(sd->fd, output);
					return -1;
				}
			}
		}
	}
	else {
		sprintf(output, msg_txt(sd,1400),chname,"@join"); // Unknown channel '%s' (usage: %s <#channel_name>).
		clif_displaymessage(sd->fd, output);
		return -1;
	}

	switch(channel->type){
	case CHAN_TYPE_ALLY: channel_gjoin(sd,3); break;
	case CHAN_TYPE_MAP: channel_mjoin(sd); break;
	default: //private and public atm
		if (channel_join(channel,sd) != 0)
			return -1;
	}

	if( ( channel->opt & CHAN_OPT_ANNOUNCE_SELF ) ) {
		sprintf(output, msg_txt(sd,1403),chname); // You're now in the '%s' channel.
		clif_displaymessage(sd->fd, output);
	}

	return 0;
}
Exemple #5
0
/**
 * Make a player join the map channel
 * - Create the map_channel if it does not exist
 * @param sd: Player data
 * @return
 *  -1: Invalid player
 *  -2: Player already in channel (channel_join)
 *  -3: Player banned (channel_join)
 */
int channel_mjoin(struct map_session_data *sd) {
	char mout[60];
	if(!sd) return -1;

	if( !map[sd->bl.m].channel ) {
		map[sd->bl.m].channel = channel_create_simple(NULL,NULL,CHAN_TYPE_MAP,sd->bl.m);
	}

	if( map[sd->bl.m].channel->opt & CHAN_OPT_ANNOUNCE_SELF ) {
		sprintf(mout, msg_txt(sd,1435),map[sd->bl.m].channel->name,map[sd->bl.m].name); // You're now in the '#%s' channel for '%s'.
		clif_messagecolor(&sd->bl, color_table[COLOR_LIGHT_GREEN], mout, false, SELF);
	}

	return channel_join(map[sd->bl.m].channel,sd);
}
Exemple #6
0
/**
 * Make all ally members of a guild join the guild channel
 * - They only join if they are in their own guild channel (if not they probably left it)
 * @param g: Guild data
 * @return
 *   0: Success
 *  -1: Invalid guild or no channel for guild
 */
int channel_ajoin(struct guild *g){
	int i, j;
	struct map_session_data *pl_sd;

	if(!g || !g->channel) return -1;
	for (i = 0; i < MAX_GUILDALLIANCE; i++){
		struct guild *ag; //allied guld
		struct guild_alliance *ga = &g->alliance[i]; //guild alliance
		if(ga->guild_id && (ga->opposition==0) && (ag=guild_search(ga->guild_id))){
			for (j = 0; j < ag->max_member; j++){ //load all guildmember
				pl_sd = ag->member[j].sd;
				if(channel_haspc(ag->channel,pl_sd)==1)  //only if they are in their own guildchan
					channel_join(g->channel,pl_sd);
			}
		}
	}
	return 0;
}