From d57781cee04e99fa8be7c209a75b949a57eba59d Mon Sep 17 00:00:00 2001 From: panikon Date: Sat, 19 Apr 2014 18:28:51 -0300 Subject: Fixed issue: 8150 * http://hercules.ws/board/tracker/issue-8150-cash-shop-updating-quantity-bug/ * Also fixed issue where when using ATitem to get more than one pet egg would result on getting only one egg * Changed packet 0x3880 structure now it also contains pet class and dropped flag from this packet, it was pointless --- src/char/int_pet.c | 16 ++++++++-------- src/map/intif.c | 4 ++-- src/map/pet.c | 37 +++++++++++++++++++++++++------------ src/map/pet.h | 2 +- 4 files changed, 36 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 2867aed77..25f00e6f0 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -122,18 +122,18 @@ int inter_pet_delete(int pet_id){ //------------------------------------------------------ int mapif_pet_created(int fd, int account_id, struct s_pet *p) { - WFIFOHEAD(fd, 11); - WFIFOW(fd, 0) =0x3880; - WFIFOL(fd, 2) =account_id; + WFIFOHEAD(fd, 12); + WFIFOW(fd, 0) = 0x3880; + WFIFOL(fd, 2) = account_id; if(p!=NULL){ - WFIFOB(fd, 6)=0; - WFIFOL(fd, 7) =p->pet_id; + WFIFOW(fd, 6) = p->class_; + WFIFOL(fd, 8) = p->pet_id; ShowInfo("int_pet: created pet %d - %s\n", p->pet_id, p->name); }else{ - WFIFOB(fd, 6)=1; - WFIFOL(fd, 7)=0; + WFIFOB(fd, 6) = 0; + WFIFOL(fd, 8) = 0; } - WFIFOSET(fd, 11); + WFIFOSET(fd, 12); return 0; } diff --git a/src/map/intif.c b/src/map/intif.c index 40ceda917..0f65daa6b 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1316,7 +1316,7 @@ void intif_parse_GuildMasterChanged(int fd) { // Request pet creation void intif_parse_CreatePet(int fd) { - pet->get_egg(RFIFOL(fd,2),RFIFOL(fd,7),RFIFOB(fd,6)); + pet->get_egg(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOB(fd,8)); } // ACK pet data @@ -2298,7 +2298,7 @@ void intif_defaults(void) { -1,-1, 7, 7, 7,11, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3850 Auctions [Zephyrus] itembound[Akinari] -1, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3860 Quests [Kevin] [Inkfish] -1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 3, 3, 0, //0x3870 Mercenaries [Zephyrus] / Elemental [pakpil] - 11,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880 + 12,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3880 -1,-1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, //0x3890 Homunculus [albator] }; diff --git a/src/map/pet.c b/src/map/pet.c index c04d9267a..b5870a858 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -537,25 +537,38 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) { return 0; } -///This function is invoked when a new pet has been created, and at no other time! -int pet_get_egg(int account_id,int pet_id,int flag) { +/** + * Is invoked _only_ when a new pet has been created is a product of packet 0x3880 + * see mapif_pet_created@int_pet.c for more information + * Handles new pet data from inter-server and prepares item information + * to add pet egg + * + * pet_id - Should contain pet id otherwise means failure + * returns true on success + **/ +bool pet_get_egg(int account_id, short pet_class, int pet_id ) { struct map_session_data *sd; struct item tmp_item; - int i=0,ret=0; + int i = 0, ret = 0; - if(flag) - return 0; - - sd = map->id2sd(account_id); - if(sd == NULL) - return 0; + if( pet_id == 0 || pet_class == 0 ) + return false; - i = pet->search_petDB_index(sd->catch_target_class,PET_CLASS); + sd = map->id2sd(account_id); + if( sd == NULL ) + return false; + + // i = pet->search_petDB_index(sd->catch_target_class,PET_CLASS); + // issue: 8150 + // Before this change in cases where more than one pet egg were requested in a short + // period of time it wasn't possible to know which kind of egg was being requested after + // the first request. [Panikon] + i = pet->search_petDB_index(pet_class,PET_CLASS); sd->catch_target_class = -1; if(i < 0) { intif->delete_petdata(pet_id); - return 0; + return false; } memset(&tmp_item,0,sizeof(tmp_item)); @@ -570,7 +583,7 @@ int pet_get_egg(int account_id,int pet_id,int flag) { map->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } - return 1; + return true; } int pet_menu(struct map_session_data *sd,int menunum) diff --git a/src/map/pet.h b/src/map/pet.h index 537a50c4b..4ec30b3fb 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -127,7 +127,7 @@ struct pet_interface { int (*select_egg) (struct map_session_data *sd, short egg_index); int (*catch_process1) (struct map_session_data *sd, int target_class); int (*catch_process2) (struct map_session_data *sd, int target_id); - int (*get_egg) (int account_id, int pet_id, int flag); + bool (*get_egg) (int account_id, short pet_class, int pet_id ); int (*unequipitem) (struct map_session_data *sd, struct pet_data *pd); int (*food) (struct map_session_data *sd, struct pet_data *pd); int (*ai_sub_hard_lootsearch) (struct block_list *bl, va_list ap); -- cgit v1.2.3-70-g09d2