int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet_lv,short pet_egg_id, short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name) { struct s_pet *p; p= (struct s_pet *) aCalloc(sizeof(struct s_pet), 1); if(p==NULL){ ShowFatalError("int_pet: out of memory !\n"); mapif_pet_created(fd,account_id,NULL); return 0; } // memset(p,0,sizeof(struct s_pet)); unnecessary after aCalloc [Skotlex] p->pet_id = pet_newid++; memcpy(p->name,pet_name,NAME_LENGTH); if(incuvate == 1) p->account_id = p->char_id = 0; else { p->account_id = account_id; p->char_id = char_id; } p->class_ = pet_class; p->level = pet_lv; p->egg_id = pet_egg_id; p->equip = pet_equip; p->intimate = intimate; p->hungry = hungry; p->rename_flag = rename_flag; p->incuvate = incuvate; if(p->hungry < 0) p->hungry = 0; else if(p->hungry > 100) p->hungry = 100; if(p->intimate < 0) p->intimate = 0; else if(p->intimate > 1000) p->intimate = 1000; idb_put(pet_db,p->pet_id,p); mapif_pet_created(fd,account_id,p); return 0; }
int mapif_create_pet (int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id, short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name) { memset (pet_pt, 0, sizeof (struct s_pet)); strncpy (pet_pt->name, pet_name, NAME_LENGTH); if (incuvate == 1) pet_pt->account_id = pet_pt->char_id = 0; else { pet_pt->account_id = account_id; pet_pt->char_id = char_id; } pet_pt->class_ = pet_class; pet_pt->level = pet_lv; pet_pt->egg_id = pet_egg_id; pet_pt->equip = pet_equip; pet_pt->intimate = intimate; pet_pt->hungry = hungry; pet_pt->rename_flag = rename_flag; pet_pt->incuvate = incuvate; if (pet_pt->hungry < 0) pet_pt->hungry = 0; else if (pet_pt->hungry > 100) pet_pt->hungry = 100; if (pet_pt->intimate < 0) pet_pt->intimate = 0; else if (pet_pt->intimate > 1000) pet_pt->intimate = 1000; pet_pt->pet_id = -1; //Signal NEW pet. if (inter_pet_tosql (pet_pt->pet_id, pet_pt)) mapif_pet_created (fd, account_id, pet_pt); else //Failed... mapif_pet_created (fd, account_id, NULL); return 0; }