Пример #1
0
//-----------------------
// A member change of map
//-----------------------
void mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, char *map, unsigned char online, int lv) { // online: 0: offline, 1:online
	int i;

	inter_party_fromsql(party_id); // fill party_tmp with informations of the party (or set all values to 0)

	if (party_tmp.party_id <= 0) // party doesn't exist
		return;

	for(i = 0; i < MAX_PARTY; i++) {
		if (party_tmp.member[i].account_id == account_id) { // same account can have more than character in same party. we must check name here too!
			memset(party_tmp.member[i].map, 0, sizeof(party_tmp.member[i].map));
			strncpy(party_tmp.member[i].map, map, 16); // 17 - NULL
			party_tmp.member[i].online = online; // online: 0: offline, 1:online
			party_tmp.member[i].lv = lv;
			mapif_party_membermoved(&party_tmp, i);

			if (party_tmp.exp > 0 && !party_check_exp_share(&party_tmp)) {
				party_tmp.exp = 0;
				mapif_party_optionchanged(fd, &party_tmp, 0, 0);
			}
			break;
		}
	}
	inter_party_tosql(party_id, &party_tmp);

	return;
}
Пример #2
0
// Create Party
int mapif_parse_CreateParty(int fd,int account_id,char *name,char *nick,char *map,int lv)
{
	struct party *p;

	if( (p=search_partyname(name))!=NULL){
		printf("int_party: same name party exists [%s]\n",name);
		mapif_party_created(fd,account_id,NULL);
		return 0;
	}
	p=party_pt;
	if(p==NULL){
		printf("int_party: out of memory !\n");
		mapif_party_created(fd,account_id,NULL);
		return 0;
	}
	memset(p,0,sizeof(struct party));
	p->party_id=party_newid++;
	memcpy(p->name,name,24);
	p->exp=0;
	p->item=0;
	p->member[0].account_id=account_id;
	memcpy(p->member[0].name,nick,24);
	memcpy(p->member[0].map,map,16);
	p->member[0].leader=1;
	p->member[0].online=1;
	p->member[0].lv=lv;
	
	inter_party_tosql(p->party_id,p);
	
	mapif_party_created(fd,account_id,p);
	mapif_party_info(fd,p);
	
	return 0;
}
Пример #3
0
// パーティー設定変更要求
int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int item)
{
	struct party *p;
	int flag=0;

	p = party_pt;
	if(p==NULL){
		ShowFatalError("int_party: out of memory !\n");
		return 0;
	}

	inter_party_fromsql(party_id, p);

	if(p->party_id <= 0){
		return 0;
	}

	p->exp=exp;
	if( exp>0 && !party_check_exp_share(p) ){
		flag|=0x01;
		p->exp=0;
	}

	p->item=item;

	mapif_party_optionchanged(fd,p,account_id,flag);
	inter_party_tosql(party_id, p);
	return 0;
}
Пример #4
0
// Create Party
int mapif_parse_CreateParty (int fd, char *name, int item, int item2, struct party_member *leader)
{
	struct party_data *p;
	int i;

	if ( (p = search_partyname (name)) != NULL)
	{
		mapif_party_created (fd, leader->account_id, leader->char_id, NULL);
		return 0;
	}

	// Check Authorised letters/symbols in the name of the character
	if (char_name_option == 1)   // only letters/symbols in char_name_letters are authorised
	{
		for (i = 0; i < NAME_LENGTH && name[i]; i++)
			if (strchr (char_name_letters, name[i]) == NULL)
			{
				mapif_party_created (fd, leader->account_id, leader->char_id, NULL);
				return 0;
			}
	}
	else if (char_name_option == 2)     // letters/symbols in char_name_letters are forbidden
	{
		for (i = 0; i < NAME_LENGTH && name[i]; i++)
			if (strchr (char_name_letters, name[i]) != NULL)
			{
				mapif_party_created (fd, leader->account_id, leader->char_id, NULL);
				return 0;
			}
	}

	p = (struct party_data *) aCalloc (1, sizeof (struct party_data));
	memcpy (p->party.name, name, NAME_LENGTH);
	p->party.exp = 0;
	p->party.item = (item ? 1 : 0) | (item2 ? 2 : 0);
	memcpy (&p->party.member[0], leader, sizeof (struct party_member));
	p->party.member[0].leader = 1;
	p->party.member[0].online = 1;
	p->party.party_id = -1; //New party.

	if (inter_party_tosql (&p->party, PS_CREATE | PS_ADDMEMBER, 0))
	{
		//Add party to db
		int_party_calc_state (p);
		idb_put (party_db_, p->party.party_id, p);
		mapif_party_info (fd, &p->party, 0);
		mapif_party_created (fd, leader->account_id, leader->char_id, &p->party);
	}
	else     //Failed to create party.
	{
		aFree (p);
		mapif_party_created (fd, leader->account_id, leader->char_id, NULL);
	}

	return 0;
}
Пример #5
0
//--------------------
// Creation of a party
//--------------------
void mapif_parse_CreateParty(int fd, int account_id, char *party_name, char *nick, char *map, int lv, unsigned char item, unsigned char item2) {
	char t_name[49]; // 24 * 2 + NULL
	int i;

// check of structure of party_name is done in map-server

/* moved to map-server------------
	// check control chars and del
	for(i = 0; i < 24 && party_name[i]; i++) {
		if (!(party_name[i] & 0xe0) || party_name[i] == 0x7f) {
			printf("int_party: illegal party name [%s]\n", party_name);
			mapif_party_created(fd, account_id, NULL);
			return;
		}
	}--------------------*/

	// search if a party exists with the same name
	db_sql_escape_string(t_name, party_name, strlen(party_name));
	sql_request("SELECT count(1) FROM `%s` WHERE `name`='%s'", party_db, t_name);
	if (sql_get_row()) {
		if (sql_get_integer(0) > 0) {
			//printf("int_party: same name party exists [%s].\n", name);
			mapif_party_created(fd, account_id, NULL);
			return;
		}
	}

	memset(&party_tmp, 0, sizeof(struct party));
	party_tmp.party_id = party_newid++;
	strncpy(party_tmp.name, party_name, 24);
	//party_tmp.exp = 0;
	party_tmp.item = item; // <item1>�A�C�e�����W���@�B0�Ōl�ʁA1�Ńp�[�e�B���L
	party_tmp.itemc = item2; // <item2>�A�C�e�����z���@�B0�Ōl�ʁA1�Ńp�[�e�B�ɋϓ����z

	party_tmp.member[0].account_id = account_id;
	strncpy(party_tmp.member[0].name, nick, 24);
	strncpy(party_tmp.member[0].map, map, 16); // 17 - NULL
	party_tmp.member[0].leader = 1;
	party_tmp.member[0].online = 1;
	party_tmp.member[0].lv = lv;

	inter_party_tosql(party_tmp.party_id, &party_tmp);

	mapif_party_created(fd, account_id, &party_tmp);
	mapif_party_info(fd, &party_tmp);

	// Update character in memory
	for(i = 0; i < char_num; i++)
		if (char_dat[i].account_id == account_id && memcmp(char_dat[i].name, nick, 24) == 0) {
			char_dat[i].party_id = party_tmp.party_id;
			break;
		}

	return;
}
Пример #6
0
// Is there any member in the party?
int party_check_empty(struct party_data *p)
{
	int i;
	if (p==NULL||p->party.party_id==0) return 1;
	for(i=0;i<MAX_PARTY && !p->party.member[i].account_id;i++);
	if (i < MAX_PARTY) return 0;
	// If there is no member, then break the party
	mapif_party_broken(p->party.party_id,0);
	inter_party_tosql(&p->party, PS_BREAK, 0);
	return 1;
}
Пример #7
0
// パーティ解散要求
int mapif_parse_BreakParty(int fd,int party_id)
{
	struct party_data *p;

	p = inter_party_fromsql(party_id);

	if(!p)
		return 0;
	inter_party_tosql(&p->party,PS_BREAK,0);
	mapif_party_broken(fd,party_id);
	return 0;
}
Пример #8
0
//-----------------
// Break of a party
//-----------------
void mapif_parse_BreakParty(int fd, int party_id) {
	inter_party_fromsql(party_id); // fill party_tmp with informations of the party (or set all values to 0)

	if (party_tmp.party_id <= 0) // party doesn't exist
		return;

	inter_party_tosql(party_id, &party_tmp);

	mapif_party_broken(party_id);

	return;
}
Пример #9
0
//Request leave party
int mapif_parse_PartyLeave(int fd, int party_id, uint32 account_id, uint32 char_id, char *name, enum e_party_member_withdraw type)
{
	struct party_data *p;
	int i,j=-1;

	p = inter_party_fromsql(party_id);
	if( p == NULL )
	{// Party does not exists?
		if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", schema_config.char_db, party_id) )
			Sql_ShowDebug(sql_handle);
		return 0;
	}

	for (i = 0; i < MAX_PARTY; i++) {
		if(p->party.member[i].account_id == account_id &&
			p->party.member[i].char_id == char_id) {
			break;
		}
	}
	if (i >= MAX_PARTY)
		return 0; //Member not found?

	mapif_party_withdraw(party_id, account_id, char_id, name, type);

	if (p->party.member[i].leader){
		// TODO: Official allow 'leaderless' party
		p->party.member[i].account_id = 0;
		for (j = 0; j < MAX_PARTY; j++) {
			if (!p->party.member[j].account_id)
				continue;
			mapif_party_withdraw(party_id, p->party.member[j].account_id, p->party.member[j].char_id, p->party.member[j].name, type);
			p->party.member[j].account_id = 0;
		}
		//Party gets deleted on the check_empty call below.
	} else {
		inter_party_tosql(&p->party,PS_DELMEMBER,i);
		j = p->party.member[i].lv;
		if(p->party.member[i].online) p->party.count--;
		memset(&p->party.member[i], 0, sizeof(struct party_member));
		p->size--;
		if (j == p->min_lv || j == p->max_lv || p->family)
		{
			if(p->family) p->family = 0; //Family state broken.
			int_party_check_lv(p);
		}
	}

	if (party_check_empty(p) == 0)
		mapif_party_info(-1, &p->party, 0);
	return 0;
}
Пример #10
0
// Is there any member in the party?
int party_check_empty(struct party *p)
{
	int i;
	if (p==NULL||p->party_id==0) return 1;
//	printf("party check empty %08X\n",(int)p);
	for(i=0;i<MAX_PARTY;i++){
//		printf("%d acc=%d\n",i,p->member[i].account_id);
		if(p->member[i].account_id>0){
			return 0;
		}
	}
	// If there is no member, then break the party
	mapif_party_broken(p->party_id,0);
	inter_party_tosql(p->party_id,p);
	return 1;
}
Пример #11
0
// パーティ追加要求
int mapif_parse_PartyAddMember(int fd,int party_id,int account_id,char *nick,char *map,int lv)
{
	struct party *p;
	int i;

	p = party_pt;
	if(p==NULL){
		ShowFatalError("int_party: out of memory !\n");
		return 0;
	}
	inter_party_fromsql(party_id, p);

	if(p->party_id <= 0){
		mapif_party_memberadded(fd,party_id,account_id,1);
		return 0;
	}

	for(i=0;i<MAX_PARTY;i++){
		if(p->member[i].account_id==0){
			int flag=0;

			p->member[i].account_id=account_id;
			memcpy(p->member[i].name,nick,NAME_LENGTH-1);
			memcpy(p->member[i].map,map,MAP_NAME_LENGTH-1);
			p->member[i].leader=0;
			p->member[i].online=1;
			p->member[i].lv=lv;
			mapif_party_memberadded(fd,party_id,account_id,0);
			mapif_party_info(-1,p);

			if( p->exp>0 && !party_check_exp_share(p) ){
				p->exp=0;
				flag=0x01;
			}
			if(flag)
				mapif_party_optionchanged(fd,p,0,0);

			inter_party_tosql(party_id, p);
			return 0;
		}
	}
	mapif_party_memberadded(fd,party_id,account_id,1);
	//inter_party_tosql(party_id, p);
	return 0;
}
Пример #12
0
// パーティー設定変更要求
int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int item)
{
	struct party_data *p;
	int flag = 0;
	p = inter_party_fromsql(party_id);

	if(!p)
		return 0;

	p->party.exp=exp;
	if( exp && !party_check_exp_share(p) ){
		flag|=0x01;
		p->party.exp=0;
	}
	p->party.item = item&0x3; //Filter out invalid values.
	mapif_party_optionchanged(fd,&p->party,account_id,flag);
	inter_party_tosql(&p->party, PS_BASIC, 0);
	return 0;
}
Пример #13
0
//-------------------------------
// Is there members in the party?
//-------------------------------
int party_check_empty(struct party *p) {
	int i;

//	if (p == NULL || p->party_id == 0)
	if (p->party_id == 0)
		return 1;

	//printf("Party #%d: check empty.\n", p->party_id);
	for(i = 0; i < MAX_PARTY; i++) {
		//printf("Member #%d account: %d.\n", i, p->member[i].account_id);
		if (p->member[i].account_id > 0)
			return 0;
	}
	// If there is no member, then break the party
	mapif_party_broken(p->party_id);
	inter_party_tosql(p->party_id, p);

	return 1;
}
Пример #14
0
// パーティ追加要求
int mapif_parse_PartyAddMember (int fd, int party_id, struct party_member *member)
{
	struct party_data *p;
	int i;
	p = inter_party_fromsql (party_id);

	if (p == NULL || p->size == MAX_PARTY)
	{
		mapif_party_memberadded (fd, party_id, member->account_id, member->char_id, 1);
		return 0;
	}

	ARR_FIND (0, MAX_PARTY, i, p->party.member[i].account_id == 0);

	if (i == MAX_PARTY)
	{
		// Party full
		mapif_party_memberadded (fd, party_id, member->account_id, member->char_id, 1);
		return 0;
	}

	memcpy (&p->party.member[i], member, sizeof (struct party_member));
	p->party.member[i].leader = 0;

	if (p->party.member[i].online) p->party.count++;

	p->size++;

	if (p->size == 3) //Check family state.
		int_party_calc_state (p);
	else //Check even share range.
		if (member->lv < p->min_lv || member->lv > p->max_lv || p->family)
		{
			if (p->family) p->family = 0; //Family state broken.

			int_party_check_lv (p);
		}

	mapif_party_info (-1, &p->party, 0);
	mapif_party_memberadded (fd, party_id, member->account_id, member->char_id, 0);
	inter_party_tosql (&p->party, PS_ADDMEMBER, i);
	return 0;
}
Пример #15
0
// パーティ解散要求
int mapif_parse_BreakParty(int fd,int party_id)
{
	struct party *p;

	p = party_pt;
	if(p==NULL){
		ShowFatalError("int_party: out of memory !\n");
		return 0;
	}

	inter_party_fromsql(party_id, p);

	if(p->party_id <= 0){
		return 0;
	}
	inter_party_tosql(party_id,p);

	mapif_party_broken(fd,party_id);
	return 0;
}
Пример #16
0
//---------------------------
// Adding a member in a party
//---------------------------
void mapif_parse_PartyAddMember(int fd, int party_id, int account_id, char *nick, char *map, int lv) {
	int i;

	inter_party_fromsql(party_id); // fill party_tmp with informations of the party (or set all values to 0)

	if (party_tmp.party_id <= 0) { // party doesn't exist
		mapif_party_memberadded(fd, party_id, account_id, 1);
		return;
	}

	for(i = 0; i < MAX_PARTY; i++) {
		if (party_tmp.member[i].account_id == 0) { // must we check if an other character of same account is in the party?
			party_tmp.member[i].account_id = account_id;
			memset(party_tmp.member[i].name, 0, sizeof(party_tmp.member[i].name));
			strncpy(party_tmp.member[i].name, nick, 24);
			memset(party_tmp.member[i].map, 0, sizeof(party_tmp.member[i].map));
			strncpy(party_tmp.member[i].map, map, 16); // 17 - NULL
			party_tmp.member[i].leader = 0;
			party_tmp.member[i].online = 1;
			party_tmp.member[i].lv = lv;
			mapif_party_memberadded(fd, party_id, account_id, 0);
			mapif_party_info(-1, &party_tmp);
			// Update character in memory
			for(i = 0; i < char_num; i++)
				if (char_dat[i].account_id == account_id && memcmp(char_dat[i].name, nick, 24) == 0) {
					char_dat[i].party_id = party_tmp.party_id;
					break;
				}

			if (party_tmp.exp > 0 && !party_check_exp_share(&party_tmp)) {
				party_tmp.exp = 0;
				mapif_party_optionchanged(fd, &party_tmp, 0, 0);
			}
			inter_party_tosql(party_id, &party_tmp);
			return;
		}
	}
	mapif_party_memberadded(fd, party_id, account_id, 1);

	return;
}
Пример #17
0
int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id)
{
	struct party_data *p;
	int i;

	p = inter_party_fromsql(party_id);

	if(!p)
		return 0;

	for(i = 0; i < MAX_PARTY; i++) {
		if(p->party.member[i].leader)
			p->party.member[i].leader = 0;
		if(p->party.member[i].account_id == account_id &&
		   p->party.member[i].char_id == char_id) {
			p->party.member[i].leader = 1;
			inter_party_tosql(&p->party,PS_LEADER, i);
		}
	}
	return 1;
}
Пример #18
0
//--------------------------------------
// Request to change a option in a party
//--------------------------------------
void mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, unsigned short exp, unsigned char item) {
	int flag;

	inter_party_fromsql(party_id); // fill party_tmp with informations of the party (or set all values to 0)

	if (party_tmp.party_id <= 0) // party doesn't exist
		return;

	flag = 0;
	party_tmp.exp = exp;
	if (exp > 0 && !party_check_exp_share(&party_tmp)) {
		flag = 1;
		party_tmp.exp = 0;
	}

	party_tmp.item = item;

	mapif_party_optionchanged(fd, &party_tmp, account_id, flag);
	inter_party_tosql(party_id, &party_tmp);

	return;
}
Пример #19
0
// Create Party
int mapif_parse_CreateParty(int fd,int account_id,char *name,char *nick,char *map,int lv, int item, int item2)
{
	struct party *p;
	if( (p=search_partyname(name))!=NULL){
//		printf("int_party: same name party exists [%s]\n",name);
		mapif_party_created(fd,account_id,NULL);
		return 0;
	}
	p=party_pt;
	if(p==NULL){
		ShowFatalError("int_party: out of memory !\n");
		mapif_party_created(fd,account_id,NULL);
		return 0;
	}
	memset(p,0,sizeof(struct party));
	p->party_id=party_newid++;
	memcpy(p->name,name,NAME_LENGTH-1);
	p->exp=0;
	p->item=item;
	//<item1>アイテム?集方法。0で個人別、1でパ?ティ公有
	//<item2>アイテム分配方法。0で個人別、1でパ?ティに均等分配
	//difference between "collection" and "distribution" is...? ^^;
	p->itemc = 0;

	p->member[0].account_id=account_id;
	memcpy(p->member[0].name,nick,NAME_LENGTH-1);
	memcpy(p->member[0].map,map,MAP_NAME_LENGTH-1);
	p->member[0].leader=1;
	p->member[0].online=1;
	p->member[0].lv=lv;

	inter_party_tosql(p->party_id,p);

	mapif_party_created(fd,account_id,p);
	mapif_party_info(fd,p);

	return 0;
}
Пример #20
0
// When member goes to other map
int mapif_parse_PartyChangeMap(int fd,int party_id,int account_id,char *map,int online,int lv)
{
	struct party *p;
	int i;
	
	p = party_pt;
	if(p==NULL){
		printf("int_party: out of memory !\n");
		return 0;
	}
	inter_party_fromsql(party_id, p);
	
	if(p->party_id <= 0){
		return 0;
	}
	for(i=0;i<MAX_PARTY;i++){
		if(p->member[i].account_id==account_id){
			int flag=0;
			
			memcpy(p->member[i].map,map,16);
			p->member[i].online=online;
			p->member[i].lv=lv;
			mapif_party_membermoved(p,i);

			if( p->exp>0 && !party_check_exp_share(p) ){
				p->exp=0;
				flag=1;
			}
			if(flag)
				mapif_party_optionchanged(fd,p,0,0);
			break;
		}
	}
	inter_party_tosql(party_id, p);
	return 0;
}
Пример #21
0
int convert_init(void)
{
	char line[65536];
	int ret;
	int tmp_int[2], lineno, count;
	char input;
	FILE *fp;

	ShowWarning("Make sure you backup your databases before continuing!\n");
	ShowMessage("\n");

	ShowNotice("Do you wish to convert your Character Database to SQL? (y/n) : ");
	input = getchar();
	if(input == 'y' || input == 'Y')
	{
		struct character_data char_dat;
		struct accreg reg;

		ShowStatus("Converting Character Database...\n");
		if( (fp = fopen(char_txt, "r")) == NULL )
		{
			ShowError("Unable to open file [%s]!\n", char_txt);
			return 0;
		}
		lineno = count = 0;
		while(fgets(line, sizeof(line), fp))
		{
			lineno++;
			memset(&char_dat, 0, sizeof(struct character_data));
			ret=mmo_char_fromstr(line, &char_dat.status, char_dat.global, &char_dat.global_num);
			if(ret > 0) {
				count++;
				parse_friend_txt(&char_dat.status); //Retrieve friends.
				mmo_char_tosql(char_dat.status.char_id , &char_dat.status);

				memset(&reg, 0, sizeof(reg));
				reg.account_id = char_dat.status.account_id;
				reg.char_id = char_dat.status.char_id;
				reg.reg_num = char_dat.global_num;
				memcpy(&reg.reg, &char_dat.global, reg.reg_num*sizeof(struct global_reg));
				inter_accreg_tosql(reg.account_id, reg.char_id, &reg, 3); //Type 3: Character regs
			} else {
				ShowError("Error %d converting character line [%s] (at %s:%d).\n", ret, line, char_txt, lineno);
			}
		}
		ShowStatus("Converted %d characters.\n", count);
		fclose(fp);
		ShowStatus("Converting Account variables Database...\n");
		if( (fp = fopen(accreg_txt, "r")) == NULL )
		{
			ShowError("Unable to open file %s!", accreg_txt);
			return 1;
		}
		lineno = count = 0;
		while(fgets(line, sizeof(line), fp))
		{
			lineno++;
			memset (&reg, 0, sizeof(struct accreg));
			if(inter_accreg_fromstr(line, &reg) == 0 && reg.account_id > 0) {
				count++;
				inter_accreg_tosql(reg.account_id, 0, &reg, 2); //Type 2: Account regs
			} else {
				ShowError("accreg reading: broken data [%s] at %s:%d\n", line, accreg_txt, lineno);
			}
		}
		ShowStatus("Converted %d account registries.\n", count);
		fclose(fp);
	}
	
	while(getchar() != '\n');
	ShowMessage("\n");
	ShowNotice("Do you wish to convert your Storage Database to SQL? (y/n) : ");
	input = getchar();
	if(input == 'y' || input == 'Y')
	{
		struct storage_data storage;
		ShowMessage("\n");
		ShowStatus("Converting Storage Database...\n");
		if( (fp = fopen(storage_txt,"r")) == NULL )
		{
			ShowError("can't read : %s\n", storage_txt);
			return 0;
		}
		lineno = count = 0;
		while(fgets(line, sizeof(line), fp))
		{
			int account_id;

			lineno++;
			if( sscanf(line,"%d,%d",&tmp_int[0],&tmp_int[1]) != 2 )
				continue;

			memset(&storage, 0, sizeof(struct storage_data));
			if( storage_fromstr(line,&account_id,&storage) )
			{
				count++;
				storage_tosql(account_id,&storage); //to sql. (dump)
			} else
				ShowError("Error parsing storage line [%s] (at %s:%d)\n", line, storage_txt, lineno);
		}
		ShowStatus("Converted %d storages.\n", count);
		fclose(fp);
	}

	//FIXME: CONVERT STATUS DATA HERE!!!

	while(getchar() != '\n');
	ShowMessage("\n");
	ShowNotice("Do you wish to convert your Pet Database to SQL? (y/n) : ");
	input=getchar();
	if(input == 'y' || input == 'Y')
	{
		struct s_pet p;
		ShowMessage("\n");
		ShowStatus("Converting Pet Database...\n");
		if( (fp = fopen(pet_txt, "r")) == NULL )
		{
			ShowError("Unable to open file %s!", pet_txt);
			return 1;
		}
		lineno = count = 0;
		while(fgets(line, sizeof(line), fp))
		{
			lineno++;
			memset (&p, 0, sizeof(struct s_pet));
			if(inter_pet_fromstr(line, &p)==0 && p.pet_id>0) {
				count++;
				inter_pet_tosql(p.pet_id,&p);
			} else {
				ShowError("pet reading: broken data [%s] at %s:%d\n", line, pet_txt, lineno);
			}
		}
		ShowStatus("Converted %d pets.\n", count);
		fclose(fp);
	}

	//FIXME: CONVERT HOMUNCULUS DATA AND SKILLS HERE!!!

	while(getchar() != '\n');
	ShowMessage("\n");
	ShowNotice("Do you wish to convert your Party Database to SQL? (y/n) : ");
	input=getchar();
	if(input == 'y' || input == 'Y')
	{
		struct party p;
		ShowMessage("\n");
		ShowStatus("Converting Party Database...\n");
		if( (fp = fopen(party_txt, "r")) == NULL )
		{
			ShowError("Unable to open file %s!", party_txt);
			return 1;
		}
		lineno = count = 0;
		while(fgets(line, sizeof(line), fp))
		{
			lineno++;
			memset (&p, 0, sizeof(struct party));
			if(inter_party_fromstr(line, &p) == 0 &&
				p.party_id > 0 &&
				inter_party_tosql(&p, PS_CREATE, 0))
				count++;
			else{
				ShowError("party reading: broken data [%s] at %s:%d\n", line, pet_txt, lineno);
			}
		}
		ShowStatus("Converted %d parties.\n", count);
		fclose(fp);
	}

	while(getchar() != '\n');
	ShowMessage("\n");
	ShowNotice("Do you wish to convert your Guilds and Castles Database to SQL? (y/n) : ");
	input=getchar();
	if(input == 'y' || input == 'Y')
	{
		struct guild g;
		struct guild_castle gc;
		ShowMessage("\n");
		ShowStatus("Converting Guild Database...\n");
		if( (fp = fopen(guild_txt, "r")) == NULL )
		{
			ShowError("Unable to open file %s!", guild_txt);
			return 1;
		}
		lineno = count = 0;
		while(fgets(line, sizeof(line), fp))
		{
			lineno++;
			memset (&g, 0, sizeof(struct guild));
			if (inter_guild_fromstr(line, &g) == 0 &&
				g.guild_id > 0 &&
				inter_guild_tosql(&g,GS_MASK))
				count++;
			else
				ShowError("guild reading: broken data [%s] at %s:%d\n", line, guild_txt, lineno);
		}
		ShowStatus("Converted %d guilds.\n", count);
		fclose(fp);
		ShowStatus("Converting Guild Castles Database...\n");
		if( (fp = fopen(castle_txt, "r")) == NULL )
		{
			ShowError("Unable to open file %s!", castle_txt);
			return 1;
		}
		lineno = count = 0;
		while(fgets(line, sizeof(line), fp))
		{
			lineno++;
			memset(&gc, 0, sizeof(struct guild_castle));
			if (inter_guildcastle_fromstr(line, &gc) == 0) {
				inter_guildcastle_tosql(&gc);
				count++;
			}
			else
				ShowError("guild castle reading: broken data [%s] at %s:%d\n", line, castle_txt, lineno);
		}
		ShowStatus("Converted %d guild castles.\n", count);
		fclose(fp);
	}

	while(getchar() != '\n');
	ShowMessage("\n");
	ShowNotice("Do you wish to convert your Guild Storage Database to SQL? (y/n) : ");
	input=getchar();
	if(input == 'y' || input == 'Y')
	{
		struct guild_storage storage_;
		ShowMessage("\n");
		ShowStatus("Converting Guild Storage Database...\n");
		if( (fp = fopen(guild_storage_txt, "r")) == NULL )
		{
			ShowError("can't read : %s\n", guild_storage_txt);
			return 0;
		}
		lineno = count = 0;
		while(fgets(line, sizeof(line), fp))
		{
			lineno++;
			memset(&storage_, 0, sizeof(struct guild_storage));
			if (sscanf(line,"%d",&storage_.guild_id) == 1 &&
				storage_.guild_id > 0 &&
				guild_storage_fromstr(line,&storage_) == 0
			) {
				count++;
				guild_storage_tosql(storage_.guild_id, &storage_);
			} else
				ShowError("Error parsing guild storage line [%s] (at %s:%d)\n", line, guild_storage_txt, lineno);
		}
		ShowStatus("Converted %d guild storages.\n", count);
		fclose(fp);
	}

	return 0;
}