diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 1093a5d275..6e64c8ee43 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -77,13 +77,8 @@ const char* mapindex_getmapname_ext(const char* string, char* output) { /// Returns 1 if successful, 0 oherwise int mapindex_addmap(int index, const char* name) { char map_name[MAP_NAME_LENGTH]; - - if (index == -1){ - for (index = 1; index < max_index; index++) { - //if (strcmp(indexes[index].name,"#CLEARED#")==0) - if (indexes[index].name[0] == '\0') - break; - } + if (index == -1){ //autogive index + ARR_FIND(1,max_index,index,(indexes[index].name[0] == '\0')); } if (index < 0 || index >= MAX_MAPINDEX) { diff --git a/src/config/core.h b/src/config/core.h index 5d8fceb7db..1e8ce9992a 100644 --- a/src/config/core.h +++ b/src/config/core.h @@ -29,7 +29,7 @@ /// Uncomment to disable rAthena's anonymous stat report /// We kindly ask you to consider keeping it enabled, it helps us improve rAthena. -//define STATS_OPT_OUT +//#define STATS_OPT_OUT /// uncomment to enable query_sql script command and mysql logs to function on it's own thread /// be aware this feature is under tests and you should use at your own risk, we however diff --git a/src/map/clif.c b/src/map/clif.c index 72ebdf8d1d..2299cc7437 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -2272,7 +2272,7 @@ void clif_item_sub_v5(unsigned char *buf, int n, int idx, struct item *i, struct } else { //normal 24B WBUFW(buf,n+5)=i->amount; - WBUFL(buf,n+7)= id->equip; //wear state + WBUFL(buf,n+7)=(equip == -2 && id->equip == EQP_AMMO)?id->equip:0; //wear state clif_addcards(WBUFP(buf, n+11), i); //EQUIPSLOTINFO 8B WBUFL(buf,n+19) = i->expire_time; //V5_ITEM_flag @@ -2307,7 +2307,7 @@ void clif_item_sub(unsigned char *buf, int n, int idx, struct item *i, struct it #endif } else { //Stackable item. 22.B WBUFW(buf,n+6)=i->amount; - WBUFW(buf,n+8)=(equip == -2 && id->equip == EQP_AMMO)?id->equip:0; + WBUFW(buf,n+8)=(equip == -2 && id->equip == EQP_AMMO)?i->equip:0; clif_addcards(WBUFP(buf, n+10), i); //8B #if PACKETVER >= 20071002 WBUFL(buf,n+18)=i->expire_time; @@ -2453,26 +2453,34 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items unsigned char *buf; unsigned char *bufe; #if PACKETVER < 5 - const int s = 10; //Entry size. + const int s = 10; //Entry size.normal item + const int sidx=4; //start itemlist idx #elif PACKETVER < 20080102 const int s = 18; + const int sidx=4; #elif PACKETVER < 20120925 const int s = 22; + const int sidx=4; #else const int s = 24; + const int sidx = 4+24; #endif #if PACKETVER < 20071002 - const int cmd = 20; + const int se = 20; //entry size equip + const int sidxe = 4; //start itemlist idx #elif PACKETVER < 20100629 - const int cmd = 26; + const int se = 26; + const int sidxe = 4; #elif PACKETVER < 20120925 - const int cmd = 28; + const int se = 28; + const int sidxe = 4; #else - const int cmd = 31; + const int se = 31; + const int sidxe = 4+24; #endif - buf = (unsigned char*)aMalloc(items_length * s + 4); - bufe = (unsigned char*)aMalloc(items_length * cmd + 4); + buf = (unsigned char*)aMalloc(items_length * s + sidx); + bufe = (unsigned char*)aMalloc(items_length * se + sidxe); for( i = 0, n = 0, ne = 0; i < items_length; i++ ) { @@ -2480,11 +2488,11 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items continue; id = itemdb_search(items[i].nameid); if( !itemdb_isstackable2(id) ) { //Equippable - clif_item_sub(bufe, ne*cmd+4,i+1, &items[i], id, id->equip); + clif_item_sub(bufe, ne*se+sidx,i+1, &items[i], id, id->equip); ne++; } else { //Stackable - clif_item_sub(buf, n*s+4,i+1, &items[i], id,-1); + clif_item_sub(buf, n*s+sidx,i+1, &items[i], id,-1); n++; } } @@ -2498,8 +2506,9 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items WBUFW(buf,0)=0x2ea; #else WBUFW(buf,0)=0x995; + memset((char*)WBUFP(buf,6),0,24); //storename #endif - WBUFW(buf,2)=4+n*s; + WBUFW(buf,2)=n*s+sidx; clif_send(buf, WBUFW(buf,2), &sd->bl, SELF); } if( ne ) @@ -2510,8 +2519,9 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items WBUFW(bufe,0)=0x2d1; #else WBUFW(bufe,0)=0x996; + memset((char*)WBUFP(bufe,6),0,24); //storename #endif - WBUFW(bufe,2)=4+ne*cmd; + WBUFW(bufe,2)=ne*se+sidxe; clif_send(bufe, WBUFW(bufe,2), &sd->bl, SELF); } diff --git a/src/map/elemental.c b/src/map/elemental.c index 1c0c695311..64855c019f 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -261,6 +261,7 @@ int elemental_data_received(struct s_elemental *ele, bool flag) { status_calc_elemental(ed,1); ed->last_spdrain_time = ed->last_thinktime = gettick(); ed->summon_timer = INVALID_TIMER; + ed->masterteleport_timer = INVALID_TIMER; elemental_summon_init(ed); } else { memcpy(&sd->ed->elemental, ele, sizeof(struct s_elemental)); diff --git a/src/map/guild.c b/src/map/guild.c index 270722e189..bc86b16282 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -828,7 +828,7 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i if( (ps=guild_getposition(g,sd))<0 || !(g->position[ps].mode&0x0010) ) return 0; //Expulsion permission - //Can't leave inside guild castles. + //Can't leave inside guild castles. if ((tsd = map_id2sd(account_id)) && tsd->status.char_id == char_id && ((agit_flag || agit2_flag) && map[tsd->bl.m].flag.gvg_castle)) diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 23b1b3b692..f1e5aacc34 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -798,6 +798,7 @@ int merc_hom_alloc(struct map_session_data *sd, struct s_homunculus *hom) status_calc_homunculus(hd,1); hd->hungry_timer = INVALID_TIMER; + hd->masterteleport_timer = INVALID_TIMER; return 0; } diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 732b443dcf..4fa06d6ea4 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -321,6 +321,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag) map_addiddb(&md->bl); status_calc_mercenary(md,1); md->contract_timer = INVALID_TIMER; + md->masterteleport_timer = INVALID_TIMER; merc_contract_init(md); } else @@ -473,7 +474,7 @@ static bool read_mercenary_skilldb_sub(char* str[], int columns, int current) ShowError("read_mercenary_skilldb : Class %d not found in mercenary_db for skill entry.\n", class_); return false; } - + skill_id = atoi(str[1]); if( skill_id < MC_SKILLBASE || skill_id >= MC_SKILLBASE + MAX_MERCSKILL ) { @@ -502,7 +503,7 @@ int do_init_mercenary(void) { read_mercenarydb(); read_mercenary_skilldb(); - + //add_timer_func_list(mercenary_contract, "mercenary_contract"); return 0; } diff --git a/src/map/pet.c b/src/map/pet.c index f6b9d60299..9ad0daad2e 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -382,6 +382,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet) if( interval <= 0 ) interval = 1; pd->pet_hungry_timer = add_timer(gettick() + interval, pet_hungry, sd->bl.id, 0); + pd->masterteleport_timer = INVALID_TIMER; return 0; } diff --git a/src/map/unit.c b/src/map/unit.c index f0bff0332f..55f36c7d33 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -140,22 +140,15 @@ int unit_teleport_timer(int tid, unsigned int tick, int id, intptr_t data){ struct block_list *bl = map_id2bl(id); int *mast_tid = unit_get_masterteleport_timer(bl); - if(tid == INVALID_TIMER) + if(tid == INVALID_TIMER || mast_tid == NULL) return 0; - else if(*mast_tid && *mast_tid != tid) + else if(*mast_tid != tid) return 0; else { TBL_PC *msd = unit_get_master(bl); - switch(data){ - case BL_HOM: - case BL_ELEM: - case BL_PET : - case BL_MER : - if(msd && *mast_tid != INVALID_TIMER && !check_distance_bl(&msd->bl, bl, MAX_MER_DISTANCE)){ - *mast_tid = INVALID_TIMER; - unit_warp(bl, msd->bl.id, msd->bl.x, msd->bl.y, CLR_TELEPORT ); - } - break; + if(msd && !check_distance_bl(&msd->bl, bl, data)){ + *mast_tid = INVALID_TIMER; + unit_warp(bl, msd->bl.id, msd->bl.x, msd->bl.y, CLR_TELEPORT ); } } return 0; @@ -163,19 +156,19 @@ int unit_teleport_timer(int tid, unsigned int tick, int id, intptr_t data){ int unit_check_start_teleport_timer(struct block_list *sbl){ TBL_PC *msd = unit_get_master(sbl); - int max_dist=AREA_SIZE; + int max_dist=0; switch(sbl->type){ - //case BL_HOM: max_dist = MAX_HOM_DISTANCE; break; + case BL_HOM: max_dist = AREA_SIZE; break; case BL_ELEM: max_dist = MAX_ELEDISTANCE; break; - //case BL_PET : max_dist = MAX_PET_DISTANCE; break; + case BL_PET : max_dist = AREA_SIZE; break; case BL_MER : max_dist = MAX_MER_DISTANCE; break; } - if(msd){ //if there is a master + if(msd && max_dist){ //if there is a master and it's a valid type int *msd_tid = unit_get_masterteleport_timer(sbl); - + if(msd_tid == NULL) return 0; if (!check_distance_bl(&msd->bl, sbl, max_dist)) { if(*msd_tid == INVALID_TIMER || *msd_tid == 0) - *msd_tid = add_timer(gettick()+3000,unit_teleport_timer,sbl->id,BL_MER); + *msd_tid = add_timer(gettick()+3000,unit_teleport_timer,sbl->id,max_dist); } else { if(*msd_tid && *msd_tid != INVALID_TIMER)