Example #1
0
int mapif_save_pet (int fd, int account_id, struct s_pet *data)
{
	//here process pet save request.
	int len;
	RFIFOHEAD (fd);
	len = RFIFOW (fd, 2);

	if (sizeof (struct s_pet) != len - 8) {
		ShowError ("mapif_save_pet: erro no tamanho dos dados %d %d\n", sizeof (struct s_pet), len - 8);
	} else {
		if (data->hungry < 0)
			data->hungry = 0;
		else if (data->hungry > 100)
			data->hungry = 100;

		if (data->intimate < 0)
			data->intimate = 0;
		else if (data->intimate > 1000)
			data->intimate = 1000;

		inter_pet_tosql (data->pet_id, data);
		mapif_save_pet_ack (fd, account_id, 0);
	}

	return 0;
}
Example #2
0
int mapif_save_pet(int fd,int account_id,struct s_pet *data)
{
	struct s_pet *p;
	int pet_id, len;
	RFIFOHEAD(fd);
	len=RFIFOW(fd,2);
	
	if(sizeof(struct s_pet)!=len-8) {
		ShowError("inter pet: data size error %d %d\n",sizeof(struct s_pet),len-8);
	}
	else{
		pet_id = data->pet_id;
		if (pet_id == 0)
			pet_id = data->pet_id = pet_newid++;
		p = (struct s_pet*)idb_ensure(pet_db,pet_id,create_pet);
		if(data->hungry < 0)
			data->hungry = 0;
		else if(data->hungry > 100)
			data->hungry = 100;
		if(data->intimate < 0)
			data->intimate = 0;
		else if(data->intimate > 1000)
			data->intimate = 1000;
		memcpy(p,data,sizeof(struct s_pet));
		if(p->incuvate == 1)
			p->account_id = p->char_id = 0;

		mapif_save_pet_ack(fd,account_id,0);
	}

	return 0;
}
Example #3
0
int mapif_save_pet(int fd, int account_id, struct s_pet *data) {
	//here process pet save request.
	int len;
	RFIFOHEAD(fd);
	len=RFIFOW(fd, 2);
	if (sizeof(struct s_pet) != len-8) {
		ShowError("inter pet: data size mismatch: %d != %"PRIuS"\n", len-8, sizeof(struct s_pet));
		return 0;
	}

	if (data->hungry < 0)
		data->hungry = 0;
	else if (data->hungry > 100)
		data->hungry = 100;
	if (data->intimate < 0)
		data->intimate = 0;
	else if (data->intimate > 1000)
		data->intimate = 1000;
	inter_pet_tosql(data->pet_id,data);
	mapif_save_pet_ack(fd, account_id, 0);

	return 0;
}