Ejemplo n.º 1
0
/*==========================================
 * join an existing chatroom
 *------------------------------------------*/
int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
{
	struct chat_data* cd;

	nullpo_retr(0, sd);
	cd = (struct chat_data*)map_id2bl(chatid);

	if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->vender_id || sd->chatID || cd->users >= cd->limit )
	{
		clif_joinchatfail(sd,0);
		return 0;
	}

	if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !(battle_config.gm_join_chat && pc_isGM(sd) >= battle_config.gm_join_chat) )
	{
		clif_joinchatfail(sd,1);
		return 0;
	}

	pc_stop_walking(sd,1);
	cd->usersd[cd->users] = sd;
	cd->users++;

	pc_setchatid(sd,cd->bl.id);

	clif_joinchatok(sd,cd);	// 新たに参加した人には全員のリスト
	clif_addchat(cd,sd);	// 既に中に居た人には追加した人の報告
	clif_dispchat(cd,0);	// 周囲の人には人数変化報告

	chat_triggerevent(cd); // イベント
	
	return 0;
}
Ejemplo n.º 2
0
/*==========================================
 * join an existing chatroom
 *------------------------------------------*/
int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
{
	struct chat_data* cd;

	nullpo_ret(sd);
	cd = (struct chat_data*)map_id2bl(chatid);

	if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || cd->users >= cd->limit )
	{
		clif_joinchatfail(sd,0);
		return 0;
	}

	if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !(battle_config.gm_join_chat && pc_isGM(sd) >= battle_config.gm_join_chat) )
	{
		clif_joinchatfail(sd,1);
		return 0;
	}

	if( cd->upperBool && pc_jobid2mapid(sd->status.class_)&JOBL_UPPER )
	{
		clif_joinchatfail(sd,7);
		return 0;
	}

	if( sd->status.base_level < cd->minLvl || sd->status.base_level > cd->maxLvl )
	{
		if(sd->status.base_level < cd->minLvl)
			clif_joinchatfail(sd,5);
		else
			clif_joinchatfail(sd,6);

		return 0;
	}

	if( sd->status.zeny < cd->zeny )
	{
		clif_joinchatfail(sd,4);
		return 0;
	}

	pc_stop_walking(sd,1);
	cd->usersd[cd->users] = sd;
	cd->users++;

	pc_setchatid(sd,cd->bl.id);

	clif_joinchatok(sd,cd);	// 新たに参加した人には全員のリスト
	clif_addchat(cd,sd);	// 既に中に居た人には追加した人の報告
	clif_dispchat(cd,0);	// 周囲の人には人数変化報告

	chat_triggerevent(cd); // イベント
	
	return 0;
}
Ejemplo n.º 3
0
 /**
 * Join an existing chat room.
 * @param sd : player requesting
 * @param chatid : ID of the chat room
 * @param pass : password of chat room
 * @return 0
 */
int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
{
	struct chat_data* cd;

	nullpo_ret(sd);

	cd = (struct chat_data*)map_id2bl(chatid);

	if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit ) {
		clif_joinchatfail(sd,0);
		return 0;
	}

	if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !pc_has_permission(sd, PC_PERM_JOIN_ALL_CHAT) ) {
		clif_joinchatfail(sd,1);
		return 0;
	}

	if( sd->status.base_level < cd->minLvl || sd->status.base_level > cd->maxLvl ) {
		if(sd->status.base_level < cd->minLvl)
			clif_joinchatfail(sd,5);
		else
			clif_joinchatfail(sd,6);

		return 0;
	}

	if( sd->status.zeny < cd->zeny ) {
		clif_joinchatfail(sd,4);
		return 0;
	}

	if( cd->owner->type != BL_NPC && idb_exists(cd->kick_list,sd->status.char_id) ) {
		clif_joinchatfail(sd,2);//You have been kicked out of the room.
		return 0;
	}

	pc_stop_walking(sd,1);
	cd->usersd[cd->users] = sd;
	cd->users++;

	pc_setchatid(sd,cd->bl.id);

	clif_joinchatok(sd, cd); //To the person who newly joined the list of all
	clif_addchat(cd, sd); //Reports To the person who already in the chat
	clif_dispchat(cd, 0); //Reported number of changes to the people around

	if (cd->owner->type == BL_PC)
		achievement_update_objective(map_id2sd(cd->owner->id), AG_CHAT_COUNT, 1, cd->users);

	chat_triggerevent(cd); //Event

	return 0;
}
Ejemplo n.º 4
0
/*==========================================
 * 既存チャットルームに参加
 *------------------------------------------
 */
int chat_joinchat (struct map_session_data *sd, int chatid, char* pass)
{
	struct chat_data *cd;

	nullpo_retr(0, sd);
	cd = (struct chat_data*)map_id2bl(chatid);

 //No need for a nullpo check. The chatid was sent by the client, if they lag or mess with the packet 
 //a wrong chat id can be received. [Skotlex]
	if (cd == NULL)
		return 1;
	if (cd->bl.m != sd->bl.m || sd->vender_id || sd->chatID || cd->limit <= cd->users) {
		clif_joinchatfail(sd,0);
		return 0;
	}
	//Allows Gm access to protected room with any password they want by valaris
	if ((cd->pub == 0 && strncmp(pass, (char *)cd->pass, 8) && (pc_isGM(sd) < battle_config.gm_join_chat || !battle_config.gm_join_chat)) ||
		chatid == (int)sd->chatID) //Double Chat fix by Alex14, thx CHaNGeTe
	{
		clif_joinchatfail(sd,1);
		return 0;
	}

	pc_stop_walking(sd,1);
	cd->usersd[cd->users] = sd;
	cd->users++;

	pc_setchatid(sd,cd->bl.id);

	clif_joinchatok(sd,cd);	// 新たに参加した人には全員のリスト
	clif_addchat(cd,sd);	// 既に中に居た人には追加した人の報告
	clif_dispchat(cd,0);	// 周囲の人には人数変化報告

	chat_triggerevent(cd); // イベント
	
	return 0;
}
Ejemplo n.º 5
0
/*==========================================
 * 既存チャットルームに参加
 *------------------------------------------
 */
int chat_joinchat(struct map_session_data *sd,int chatid,char* pass)
{
	struct chat_data *cd;

	cd=(struct chat_data*)map_id2bl(chatid);
	if(cd==NULL)
		return 1;

	if(cd->bl.m != sd->bl.m || cd->limit <= cd->users){
		clif_joinchatfail(sd,0);
		return 0;
	}
	if(cd->pub==0 && strncmp(pass,cd->pass,8)){
		clif_joinchatfail(sd,1);
		return 0;
	}

	cd->usersd[cd->users] = sd;
	cd->users++;

	pc_setchatid(sd,cd->bl.id);

	// 新たに参加した人には全員のリスト
	clif_joinchatok(sd,cd);

	// 既に中に居た人には追加した人の報告
	clif_addchat(cd,sd);

	// 周囲の人には人数変化報告
	clif_dispchat(cd,0);

	// 満員でイベントが定義されてるなら実行
	if(cd->users>=cd->limit && cd->npc_event[0])
		npc_event(sd,cd->npc_event);
		
	return 0;
}
Ejemplo n.º 6
0
/*==========================================
 * 既存チャットルームに参加
 *------------------------------------------
 */
void chat_joinchat(struct map_session_data *sd, int chatid, const char* pass)
{
	struct chat_data *cd;

	nullpo_retv(sd);

	if((cd = map_id2cd(chatid)) == NULL)
		return;

	if(cd->bl.m != sd->bl.m || sd->state.store || sd->state.joinchat || path_distance(cd->bl.x,cd->bl.y,sd->bl.x,sd->bl.y) > AREA_SIZE) {
		clif_joinchatfail(sd,3);
		return;
	}
	if(cd->limit <= cd->users || cd->users >= sizeof(cd->usersd)/sizeof(cd->usersd[0])) {
		clif_joinchatfail(sd,0);
		return;
	}
	if(cd->pub == 0 && strncmp(pass,cd->pass,8)) {
		clif_joinchatfail(sd,1);
		return;
	}
	if(linkdb_exists(&cd->ban_list, INT2PTR(sd->status.char_id))) {
		clif_joinchatfail(sd,2);
		return;
	}
	if(cd->zeny > sd->status.zeny) {
		clif_joinchatfail(sd,4);
		return;
	}
	if(cd->lowlv > sd->status.base_level) {
		clif_joinchatfail(sd,5);
		return;
	}
	if(cd->highlv < sd->status.base_level) {
		clif_joinchatfail(sd,6);
		return;
	}
	if((pc_get_job_bit(sd->s_class.job) & cd->job) == 0) {
		clif_joinchatfail(sd,7);
		return;
	}
	if(cd->upper) {
		if(((1<<sd->s_class.upper)&cd->upper) == 0) {
			clif_joinchatfail(sd,7);
			return;
		}
	}

	cd->usersd[cd->users] = sd;
	cd->users++;

	sd->chatID         = cd->bl.id;
	sd->state.joinchat = 1;

	clif_joinchatok(sd,cd);	// 新たに参加した人には全員のリスト
	clif_addchat(cd,sd);	// 既に中に居た人には追加した人の報告
	clif_dispchat(cd,-1);	// 周囲の人には人数変化報告

	chat_triggerevent(cd);	// イベント

	return;
}