コード例 #1
0
ファイル: inter.c プロジェクト: TidusBR/brAthena-Old
/* [Dekamaster/Nightroad] */
void mapif_parse_accinfo(int fd)
{
	int u_fd = RFIFOL(fd,2), aid = RFIFOL(fd,6), castergroup = RFIFOL(fd,10);
	char query[NAME_LENGTH], query_esq[NAME_LENGTH*2+1];
	int account_id;
	char *data;

	safestrncpy(query, (char *) RFIFOP(fd,14), NAME_LENGTH);

	Sql_EscapeString(sql_handle, query_esq, query);

	account_id = atoi(query);

	if(account_id < START_ACCOUNT_NUM) {    // is string
		if(SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq)
			|| Sql_NumRows(sql_handle) == 0) {
			if(Sql_NumRows(sql_handle) == 0) {
				inter_msg_to_fd(fd, u_fd, aid, read_message("Source.char.inter_parse_accinfo_s1"), query);
			} else {
				Sql_ShowDebug(sql_handle);
				inter_msg_to_fd(fd, u_fd, aid, read_message("Source.char.inter_parse_accinfo_s2"));
			}
			Sql_FreeResult(sql_handle);
			return;
		} else {
			if(Sql_NumRows(sql_handle) == 1) {  //we found a perfect match
				Sql_NextRow(sql_handle);
				Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
				Sql_FreeResult(sql_handle);
			} else {// more than one, listing... [Dekamaster/Nightroad]
				inter_msg_to_fd(fd, u_fd, aid, read_message("Source.char.inter_parse_accinfo_s3"), (int)Sql_NumRows(sql_handle));
				while (SQL_SUCCESS == Sql_NextRow(sql_handle)) {
					int class_;
					short base_level, job_level, online;
					char name[NAME_LENGTH];

					Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
					Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
					Sql_GetData(sql_handle, 2, &data, NULL); class_ = atoi(data);
					Sql_GetData(sql_handle, 3, &data, NULL); base_level = atoi(data);
					Sql_GetData(sql_handle, 4, &data, NULL); job_level = atoi(data);
					Sql_GetData(sql_handle, 5, &data, NULL); online = atoi(data);

					inter_msg_to_fd(fd, u_fd, aid, read_message("Source.char.inter_parse_accinfo_s4"), account_id, name, job_name(class_), base_level, job_level, online?"Online":"Offline");
				}
				Sql_FreeResult(sql_handle);
				return;
			}
		}
	}

	/* it will only get here if we have a single match */
	/* and we will send packet with account id to login server asking for account info */
	if(account_id) {
		mapif_on_parse_accinfo(account_id, u_fd, aid, castergroup, fd);
	}

	return;
}
コード例 #2
0
ファイル: inter.c プロジェクト: AxeelDavis/Cronus
/* [Dekamaster/Nightroad] */
void mapif_parse_accinfo(int fd) {
	int u_fd = RFIFOL(fd,2), aid = RFIFOL(fd,6), castergroup = RFIFOL(fd,10);
	char query[NAME_LENGTH], query_esq[NAME_LENGTH*2+1];
	int account_id;
	char *data;

	safestrncpy(query, (char*) RFIFOP(fd,14), NAME_LENGTH);

	SQL->EscapeString(sql_handle, query_esq, query);

	account_id = atoi(query);

	if (account_id < START_ACCOUNT_NUM) {	// is string
		if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq)
				|| SQL->NumRows(sql_handle) == 0 ) {
			if( SQL->NumRows(sql_handle) == 0 ) {
				inter_msg_to_fd(fd, u_fd, aid, "Nenhum dado foi retornado com base nos parâmetros da pesquisa: '%s'",query);
			} else {
				Sql_ShowDebug(sql_handle);
				inter_msg_to_fd(fd, u_fd, aid, "Falha na pesquisa de dados.");
			}
			SQL->FreeResult(sql_handle);
			return;
		} else {
			if( SQL->NumRows(sql_handle) == 1 ) {//we found a perfect match
				SQL->NextRow(sql_handle);
				SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
				SQL->FreeResult(sql_handle);
			} else {// more than one, listing... [Dekamaster/Nightroad]
				inter_msg_to_fd(fd, u_fd, aid, "Sua pesquisa retornou %d resultados. Por favor, seja mais especifico...",(int)SQL->NumRows(sql_handle));
				while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
					int class_;
					short base_level, job_level, online;
					char name[NAME_LENGTH];

					SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
					SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
					SQL->GetData(sql_handle, 2, &data, NULL); class_ = atoi(data);
					SQL->GetData(sql_handle, 3, &data, NULL); base_level = atoi(data);
					SQL->GetData(sql_handle, 4, &data, NULL); job_level = atoi(data);
					SQL->GetData(sql_handle, 5, &data, NULL); online = atoi(data);

					inter_msg_to_fd(fd, u_fd, aid, "[AID: %d] %s | %s | Nível: %d/%d | %s", account_id, name, job_name(class_), base_level, job_level, online?"Online":"Offline");
				}
				SQL->FreeResult(sql_handle);
				return;
			}
		}
	}

	/* it will only get here if we have a single match */
	/* and we will send packet with account id to login server asking for account info */
	if( account_id ) {
		mapif_on_parse_accinfo(account_id, u_fd, aid, castergroup, fd);
	}

	return;
}