-Follow up r17346, Fix bugreport:7701 (mapcrash cause by slave teleport & disconect)

-Fix bugreport:7697 (storagelist not displayed for 2013+ client)


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@17349 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
glighta 2013-06-06 22:14:26 +00:00
parent 5aa72eaee3
commit 882c446520
9 changed files with 44 additions and 42 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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);
}

View File

@ -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));

View File

@ -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))

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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)