diff options
-rw-r--r-- | conf/battle/guild.conf | 6 | ||||
-rw-r--r-- | src/char/char.c | 14 | ||||
-rw-r--r-- | src/map/chrif.c | 2 | ||||
-rw-r--r-- | src/map/clif.c | 51 | ||||
-rw-r--r-- | src/map/clif.h | 2 | ||||
-rw-r--r-- | src/map/map.h | 3 | ||||
-rw-r--r-- | src/map/pc.c | 34 | ||||
-rw-r--r-- | src/map/pc.h | 6 | ||||
-rw-r--r-- | src/map/script.c | 2 | ||||
-rw-r--r-- | src/map/unit.c | 4 |
10 files changed, 91 insertions, 33 deletions
diff --git a/conf/battle/guild.conf b/conf/battle/guild.conf index e9b025adb..a40cbbe3a 100644 --- a/conf/battle/guild.conf +++ b/conf/battle/guild.conf @@ -16,9 +16,9 @@ guild_exp_limit: 50 // Maximum castles one guild can own (0 = unlimited) guild_max_castles: 0 -// Activate guild skills delay by relog? (Note 1) -// Official setting is "yes", otherwise allow guild leaders to relog to cancel the 5 minute delay. -guild_skill_relog_delay: yes +// Restart guild skills cooldown by relog? (Note 1) +// When "no", you relog with the same cooldown remaining as from when you logged out, "yes" restarts the cooldown upon login to its full duration. +guild_skill_relog_delay: no // Damage adjustments for WOE battles against defending Guild monsters (Note 2) castle_defense_rate: 100 diff --git a/src/char/char.c b/src/char/char.c index dcdab8d0a..310163e3a 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2849,8 +2849,7 @@ int parse_frommap(int fd) Sql_ShowDebug(sql_handle); break; } - if( SQL->NumRows(sql_handle) > 0 ) - { + if( SQL->NumRows(sql_handle) > 0 ) { struct status_change_data scdata; int count; char* data; @@ -2871,8 +2870,7 @@ int parse_frommap(int fd) } if (count >= 50) ShowWarning("Too many status changes for %d:%d, some of them were not loaded.\n", aid, cid); - if (count > 0) - { + if (count > 0) { WFIFOW(fd,2) = 14 + count*sizeof(struct status_change_data); WFIFOW(fd,12) = count; WFIFOSET(fd,WFIFOW(fd,2)); @@ -2881,6 +2879,14 @@ int parse_frommap(int fd) if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) ) Sql_ShowDebug(sql_handle); } + } else { //no sc (needs a response) + WFIFOHEAD(fd,14); + WFIFOW(fd,0) = 0x2b1d; + WFIFOW(fd,2) = 14; + WFIFOL(fd,4) = aid; + WFIFOL(fd,8) = cid; + WFIFOW(fd,12) = 0; + WFIFOSET(fd,WFIFOW(fd,2)); } SQL->FreeResult(sql_handle); #endif diff --git a/src/map/chrif.c b/src/map/chrif.c index 4efc5bce4..a13217060 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1212,6 +1212,8 @@ int chrif_load_scdata(int fd) { data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data)); status->change_start(&sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15); } + + pc->scdata_received(sd); #endif return 0; diff --git a/src/map/clif.c b/src/map/clif.c index 205374aad..414884394 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -289,7 +289,7 @@ int clif_send_sub(struct block_list *bl, va_list ap) { len = va_arg(ap,int); nullpo_ret(src_bl = va_arg(ap,struct block_list*)); type = va_arg(ap,int); - + switch(type) { case AREA_WOS: if (bl == src_bl) @@ -321,6 +321,10 @@ int clif_send_sub(struct block_list *bl, va_list ap) { #endif } + /* unless visible, hold it here */ + if( clif->ally_only && !sd->special_state.intravision && battle->check_target( src_bl, &sd->bl, BCT_ENEMY ) > 0 ) + return 0; + WFIFOHEAD(fd, len); if (WFIFOP(fd,0) == buf) { ShowError("WARNING: Invalid use of clif->send function\n"); @@ -1539,6 +1543,10 @@ void clif_walkok(struct map_session_data *sd) void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *ud) { + struct status_change *sc = NULL; + + if( (sc = status->get_sc(bl)) && sc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE|OPTION_CHASEWALK) ) + clif->ally_only = true; clif->set_unit_walking(bl,NULL,ud,AREA_WOS); @@ -1570,6 +1578,8 @@ void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *u clif->send_petdata(NULL, (TBL_PET*)bl, 3, vd->head_bottom); break; } + + clif->ally_only = false; } @@ -1579,9 +1589,9 @@ void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *u void clif_move(struct unit_data *ud) { unsigned char buf[16]; - struct view_data* vd; - struct block_list* bl = ud->bl; - + struct view_data *vd; + struct block_list *bl = ud->bl; + struct status_change *sc = NULL; vd = status->get_viewdata(bl); if (!vd || vd->class_ == INVISIBLE_CLASS) return; //This performance check is needed to keep GM-hidden objects from being notified to bots. @@ -1599,6 +1609,9 @@ void clif_move(struct unit_data *ud) clif->move2(bl, vd, ud); return; } + + if( (sc = status->get_sc(bl)) && sc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE|OPTION_CHASEWALK) ) + clif->ally_only = true; WBUFW(buf,0)=0x86; WBUFL(buf,2)=bl->id; @@ -1609,6 +1622,8 @@ void clif_move(struct unit_data *ud) WBUFL(buf,2)=-bl->id; clif->send(buf, packet_len(0x86), bl, SELF); } + + clif->ally_only = false; } @@ -1686,11 +1701,11 @@ void clif_blown(struct block_list *bl) /// isn't walkable, the char doesn't move at all. If the char is /// sitting it will stand up (ZC_STOPMOVE). /// 0088 <id>.L <x>.W <y>.W -void clif_fixpos(struct block_list *bl) -{ +void clif_fixpos(struct block_list *bl) { unsigned char buf[10]; + nullpo_retv(bl); - + WBUFW(buf,0) = 0x88; WBUFL(buf,2) = bl->id; WBUFW(buf,6) = bl->x; @@ -2916,7 +2931,8 @@ void clif_updatestatus(struct map_session_data *sd,int type) case SP_HP: WFIFOL(fd,4)=sd->battle_status.hp; // TODO: Won't these overwrite the current packet? - clif->hpmeter(sd); + if( map->list[sd->bl.m].hpmeter_visible ) + clif->hpmeter(sd); if( !battle_config.party_hp_mode && sd->status.party_id ) clif->party_hp(sd); if( sd->bg_id ) @@ -4722,7 +4738,7 @@ int clif_insight(struct block_list *bl,va_list ap) tsd = BL_CAST(BL_PC, tbl); if (tsd && tsd->fd) { //Tell tsd that bl entered into his view - switch(bl->type){ + switch(bl->type) { case BL_ITEM: clif->getareachar_item(tsd,(struct flooritem_data*)bl); break; @@ -9243,13 +9259,11 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { if( map->list[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) map->spawnmobs(sd->bl.m); + if( !(sd->sc.option&OPTION_INVISIBLE) ) { // increment the number of pvp players on the map map->list[sd->bl.m].users_pvp++; } - if( map->list[sd->bl.m].instance_id >= 0 ) { - instance->list[map->list[sd->bl.m].instance_id].users++; - instance->check_idle(map->list[sd->bl.m].instance_id); - } + sd->state.debug_remove_map = 0; // temporary state to track double remove_map's [FlavioJS] // reset the callshop flag if the player changes map @@ -9439,6 +9453,16 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) { clif->broadcast(&sd->bl, output, strlen(output) + 1, BC_BLUE, SELF); } + if( map->list[sd->bl.m].instance_id >= 0 ) { + instance->list[map->list[sd->bl.m].instance_id].users++; + instance->check_idle(map->list[sd->bl.m].instance_id); + } + + if( pc->has_permission(sd,PC_PERM_VIEW_HPMETER) ) { + map->list[sd->bl.m].hpmeter_visible++; + sd->state.hpmeter_visible = 1; + } + map->iwall_get(sd); // Updates Walls Info on this Map to Client status_calc_pc(sd, false);/* some conditions are map-dependent so we must recalculate */ sd->state.changemap = false; @@ -18082,6 +18106,7 @@ void clif_defaults(void) { /* vars */ clif->bind_ip = INADDR_ANY; clif->map_port = 5121; + clif->ally_only = false; /* core */ clif->init = do_init_clif; clif->final = do_final_clif; diff --git a/src/map/clif.h b/src/map/clif.h index e815d39e1..cbe3fa857 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -523,6 +523,8 @@ struct clif_interface { } cs; /* */ unsigned int cryptKey[3]; + /* */ + bool ally_only; /* core */ int (*init) (void); void (*final) (void); diff --git a/src/map/map.h b/src/map/map.h index c8b043acb..6b7d2a630 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -706,6 +706,9 @@ struct map_data { /* ShowEvent Data Cache */ struct questinfo *qi_data; unsigned short qi_count; + + /* speeds up clif_updatestatus processing by causing hpmeter to run only when someone with the permission can view it */ + unsigned short hpmeter_visible; }; /// Stores information about a remote map (for multi-mapserver setups). diff --git a/src/map/pc.c b/src/map/pc.c index f25dd8911..0244c6c84 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -443,7 +443,20 @@ int pc_inventory_rental_clear(struct map_session_data *sd) return 1; } - +/* assumes i is valid (from default areas where it is called, it is) */ +void pc_rental_expire(struct map_session_data *sd, int i) { + short nameid = sd->status.inventory[i].nameid; + + /* Soon to be dropped, we got plans to integrate it with item db */ + switch( nameid ) { + case ITEMID_REINS_OF_MOUNT: + status_change_end(&sd->bl,SC_ALL_RIDING,INVALID_TIMER); + break; + } + + clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid); + pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER); +} void pc_inventory_rentals(struct map_session_data *sd) { int i, c = 0; @@ -457,12 +470,7 @@ void pc_inventory_rentals(struct map_session_data *sd) continue; if( sd->status.inventory[i].expire_time <= time(NULL) ) { - if( sd->status.inventory[i].nameid == ITEMID_REINS_OF_MOUNT - && sd->sc.data[SC_ALL_RIDING] ) { - status_change_end(&sd->bl,SC_ALL_RIDING,INVALID_TIMER); - } - clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid); - pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_OTHER); + pc->rental_expire(sd,i); } else { expire_tick = (int64)(sd->status.inventory[i].expire_time - time(NULL)) * 1000; clif->rental_time(sd->fd, sd->status.inventory[i].nameid, (int)(expire_tick / 1000)); @@ -1269,8 +1277,6 @@ int pc_reg_received(struct map_session_data *sd) clif->pLoadEndAck(sd->fd, sd); } - pc->inventory_rentals(sd); - if( sd->sc.option & OPTION_INVISIBLE ) { sd->vd.class_ = INVISIBLE_CLASS; clif->message(sd->fd, msg_txt(11)); // Invisible: On @@ -3929,8 +3935,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l /* rental item check */ if( item_data->expire_time ) { if( time(NULL) > item_data->expire_time ) { - clif->rental_expired(sd->fd, i, sd->status.inventory[i].nameid); - pc->delitem(sd, i, sd->status.inventory[i].amount, 1, 0, LOG_TYPE_OTHER); + pc->rental_expire(sd,i); } else { int seconds = (int)( item_data->expire_time - time(NULL) ); clif->rental_time(sd->fd, sd->status.inventory[i].nameid, seconds); @@ -10132,6 +10137,10 @@ void pc_bank_withdraw(struct map_session_data *sd, int money) { clif->bank_withdraw(sd,BWA_SUCCESS); } } +/* status change data arrived from char-server */ +void pc_scdata_received(struct map_session_data *sd) { + pc->inventory_rentals(sd); +} /*========================================== * pc Init/Terminate @@ -10459,4 +10468,7 @@ void pc_defaults(void) { pc->bank_withdraw = pc_bank_withdraw; pc->bank_deposit = pc_bank_deposit; + + pc->rental_expire = pc_rental_expire; + pc->scdata_received = pc_scdata_received; } diff --git a/src/map/pc.h b/src/map/pc.h index 32c1e4ee0..14e1da5f4 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -177,6 +177,7 @@ struct map_session_data { unsigned int workinprogress : 3; // 1 = disable skill/item, 2 = disable npc interaction, 3 = disable both unsigned int hold_recalc : 1; unsigned int snovice_call_flag : 3; //Summon Angel (stage 1~3) + unsigned int hpmeter_visible : 1; } state; struct { unsigned char no_weapon_damage, no_magic_damage, no_misc_damage; @@ -545,7 +546,7 @@ enum equip_pos { EQP_COSTUME_HEAD_TOP = 0x000400, //1024 EQP_COSTUME_HEAD_MID = 0x000800, //2048 EQP_COSTUME_HEAD_LOW = 0x001000, //4096 - EQP_COSTUME_GARMENT = 0x002000, //8192 + EQP_COSTUME_GARMENT = 0x002000, //8192 //UNUSED_COSTUME_FLOOR = 0x004000, //16384 EQP_AMMO = 0x008000, //32768 EQP_SHADOW_ARMOR = 0x010000, //65536 @@ -977,6 +978,9 @@ struct pc_interface { void (*bank_deposit) (struct map_session_data *sd, int money); void (*bank_withdraw) (struct map_session_data *sd, int money); + + void (*rental_expire) (struct map_session_data *sd, int i); + void (*scdata_received) (struct map_session_data *sd); }; struct pc_interface *pc; diff --git a/src/map/script.c b/src/map/script.c index 6198f21da..2a83f3918 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -14015,7 +14015,7 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle) if( SQL_ERROR == SQL->QueryStr(handle, query) ) { Sql_ShowDebug(handle); - script_pushint(st, 0); + st->state = END; return false; } diff --git a/src/map/unit.c b/src/map/unit.c index 7b4ac2c50..08e97cfee 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2194,6 +2194,10 @@ int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, i instance->list[map->list[bl->m].instance_id].users--; instance->check_idle(map->list[bl->m].instance_id); } + if( sd->state.hpmeter_visible ) { + map->list[bl->m].hpmeter_visible--; + sd->state.hpmeter_visible = 0; + } sd->state.debug_remove_map = 1; // temporary state to track double remove_map's [FlavioJS] sd->debug_file = file; sd->debug_line = line; |