diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/Makefile.in | 7 | ||||
-rw-r--r-- | src/map/atcommand.c | 2 | ||||
-rw-r--r-- | src/map/battle.c | 18 | ||||
-rw-r--r-- | src/map/chrif.h | 2 | ||||
-rw-r--r-- | src/map/clif.c | 62 | ||||
-rw-r--r-- | src/map/clif.h | 5 | ||||
-rw-r--r-- | src/map/guild.c | 44 | ||||
-rw-r--r-- | src/map/homunculus.c | 6 | ||||
-rw-r--r-- | src/map/itemdb.c | 18 | ||||
-rw-r--r-- | src/map/itemdb.h | 1 | ||||
-rw-r--r-- | src/map/log.c | 5 | ||||
-rw-r--r-- | src/map/map.c | 34 | ||||
-rw-r--r-- | src/map/map.h | 2 | ||||
-rw-r--r-- | src/map/npc.c | 6 | ||||
-rw-r--r-- | src/map/npc.h | 2 | ||||
-rw-r--r-- | src/map/packets.h | 104 | ||||
-rw-r--r-- | src/map/pc.c | 104 | ||||
-rw-r--r-- | src/map/pc.h | 4 | ||||
-rw-r--r-- | src/map/script.c | 94 | ||||
-rw-r--r-- | src/map/script.h | 1 | ||||
-rw-r--r-- | src/map/skill.c | 30 | ||||
-rw-r--r-- | src/map/skill.h | 1 | ||||
-rw-r--r-- | src/map/status.c | 8 | ||||
-rw-r--r-- | src/map/storage.c | 2 | ||||
-rw-r--r-- | src/map/unit.c | 26 | ||||
-rw-r--r-- | src/map/unit.h | 1 |
26 files changed, 416 insertions, 173 deletions
diff --git a/src/map/Makefile.in b/src/map/Makefile.in index d5e362e48..70c0cd900 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -48,6 +48,9 @@ endif @SET_MAKE@ +CC = @CC@ +export CC + ##################################################################### .PHONY : all txt sql clean help @@ -92,13 +95,13 @@ obj_sql: map-server: obj_sql $(MAP_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a @echo " LD $@" - @@CC@ @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ + @$(CC) @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ # map object files obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) @echo " CC $<" - @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files ../common/obj_all/common.a: diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 950961b29..29bd43d16 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -10260,9 +10260,9 @@ void atcommand_defaults(void) { atcommand->final = do_final_atcommand; atcommand->parse = is_atcommand; + atcommand->create = atcommand_hp_add; atcommand->can_use = atcommand_can_use; atcommand->can_use2 = atcommand_can_use2; - atcommand->create = atcommand_hp_add; atcommand->load_groups = atcommand_db_load_groups; atcommand->exists = atcommand_exists; atcommand->msg_read = msg_config_read; diff --git a/src/map/battle.c b/src/map/battle.c index 2016efa3b..2fca9ef9c 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -1133,7 +1133,7 @@ int battle_calc_cardfix(int attack_type, struct block_list *src, struct block_li if( wflag&BF_SHORT ) cardfix = cardfix * (100 - tsd->bonus.near_attack_def_rate) / 100; else // BF_LONG (there's no other choice) - cardfix = cardfix * (100 - tsd->bonus.near_attack_def_rate) / 100; + cardfix = cardfix * (100 - tsd->bonus.long_attack_def_rate) / 100; if( tsd->sc.data[SC_PROTECT_DEF] ) cardfix = cardfix * (100 - tsd->sc.data[SC_PROTECT_DEF]->val1) / 100; @@ -6784,18 +6784,11 @@ void battle_defaults(void) { battle->calc_damage = battle_calc_damage; battle->calc_gvg_damage = battle_calc_gvg_damage; battle->calc_bg_damage = battle_calc_bg_damage; - battle->calc_base_damage = battle_calc_base_damage; - battle->calc_misc_attack = battle_calc_misc_attack; - battle->calc_magic_attack = battle_calc_magic_attack; battle->weapon_attack = battle_weapon_attack; + battle->calc_weapon_attack = battle_calc_weapon_attack; battle->delay_damage = battle_delay_damage; battle->drain = battle_drain; battle->calc_return_damage = battle_calc_return_damage; - battle->calc_weapon_attack = battle_calc_weapon_attack; -#ifdef RENEWAL - battle->calc_weapon_damage = battle_calc_weapon_damage; -#endif - battle->calc_defense = battle_calc_defense; battle->attr_ratio = battle_attr_ratio; battle->attr_fix = battle_attr_fix; battle->calc_cardfix = battle_calc_cardfix; @@ -6803,6 +6796,10 @@ void battle_defaults(void) { battle->calc_masteryfix = battle_calc_masteryfix; battle->calc_skillratio = battle_calc_skillratio; battle->calc_sizefix = battle_calc_sizefix; +#ifdef RENEWAL + battle->calc_weapon_damage = battle_calc_weapon_damage; +#endif + battle->calc_defense = battle_calc_defense; battle->get_master = battle_get_master; battle->get_targeted = battle_gettargeted; battle->get_enemy = battle_getenemy; @@ -6818,6 +6815,9 @@ void battle_defaults(void) { battle->delay_damage_sub = battle_delay_damage_sub; battle->blewcount_bonus = battle_blewcount_bonus; battle->range_type = battle_range_type; + battle->calc_base_damage = battle_calc_base_damage; + battle->calc_misc_attack = battle_calc_misc_attack; + battle->calc_magic_attack = battle_calc_magic_attack; battle->adjust_skill_damage = battle_adjust_skill_damage; battle->add_mastery = battle_addmastery; battle->calc_drain = battle_calc_drain; diff --git a/src/map/chrif.h b/src/map/chrif.h index a6a5fc6bf..b6883d855 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -68,7 +68,7 @@ struct chrif_interface { int (*send_users_tochar) (void); int (*char_online) (struct map_session_data *sd); int (*changesex) (struct map_session_data *sd); - int (*chardisconnect) (struct map_session_data *sd); + //int (*chardisconnect) (struct map_session_data *sd); // FIXME: Commented out in clif.c, function does not exist int (*divorce) (int partner_id1, int partner_id2); int (*removefriend) (int char_id, int friend_id); diff --git a/src/map/clif.c b/src/map/clif.c index 1b96d45fb..951969a0f 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -7379,7 +7379,7 @@ void clif_guild_belonginfo(struct map_session_data *sd, struct guild *g) WFIFOL(fd,2)=g->guild_id; WFIFOL(fd,6)=g->emblem_id; WFIFOL(fd,10)=g->position[ps].mode; - WFIFOB(fd,14)=(bool)(sd->state.gmaster_flag==g); + WFIFOB(fd,14)=(bool)(sd->state.gmaster_flag == 1); WFIFOL(fd,15)=0; // InterSID (unknown purpose) memcpy(WFIFOP(fd,19),g->name,NAME_LENGTH); WFIFOSET(fd,packet_len(0x16c)); @@ -9633,10 +9633,10 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) /* Guild Aura Init */ if( sd->state.gmaster_flag ) { - guild->aura_refresh(sd,GD_LEADERSHIP,guild->checkskill(sd->state.gmaster_flag,GD_LEADERSHIP)); - guild->aura_refresh(sd,GD_GLORYWOUNDS,guild->checkskill(sd->state.gmaster_flag,GD_GLORYWOUNDS)); - guild->aura_refresh(sd,GD_SOULCOLD,guild->checkskill(sd->state.gmaster_flag,GD_SOULCOLD)); - guild->aura_refresh(sd,GD_HAWKEYES,guild->checkskill(sd->state.gmaster_flag,GD_HAWKEYES)); + guild->aura_refresh(sd,GD_LEADERSHIP,guild->checkskill(sd->guild,GD_LEADERSHIP)); + guild->aura_refresh(sd,GD_GLORYWOUNDS,guild->checkskill(sd->guild,GD_GLORYWOUNDS)); + guild->aura_refresh(sd,GD_SOULCOLD,guild->checkskill(sd->guild,GD_SOULCOLD)); + guild->aura_refresh(sd,GD_HAWKEYES,guild->checkskill(sd->guild,GD_HAWKEYES)); } if( sd->state.vending ) { /* show we have a vending */ @@ -10494,9 +10494,9 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) } // if player ignores everyone - if (dstsd->state.ignoreAll) { + if (dstsd->state.ignoreAll && pc->get_group_level(sd) <= pc->get_group_level(dstsd)) { if (dstsd->sc.option & OPTION_INVISIBLE && pc->get_group_level(sd) < pc->get_group_level(dstsd)) - clif->wis_end(fd, 1); // 1: target character is not loged in + clif->wis_end(fd, 1); // 1: target character is not logged in else clif->wis_end(fd, 3); // 3: everyone ignored by target return; @@ -11408,7 +11408,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) if( skill_id >= GD_SKILLBASE ) { if( sd->state.gmaster_flag ) - skill_lv = guild->checkskill(sd->state.gmaster_flag, skill_id); + skill_lv = guild->checkskill(sd->guild, skill_id); else skill_lv = 0; } else { @@ -17934,6 +17934,8 @@ void clif_defaults(void) { clif->item_sub = clif_item_sub; clif->getareachar_item = clif_getareachar_item; clif->cart_additem_ack = clif_cart_additem_ack; + clif->cashshop_load = clif_cashshop_db; + clif->package_announce = clif_package_item_announce; /* unit-related */ clif->clearunit_single = clif_clearunit_single; clif->clearunit_area = clif_clearunit_area; @@ -18334,19 +18336,6 @@ void clif_defaults(void) { /* elemental-related */ clif->elemental_info = clif_elemental_info; clif->elemental_updatestatus = clif_elemental_updatestatus; - /* Hercules Channel System */ - clif->chsys_create = clif_hercules_chsys_create; - clif->chsys_msg = clif_hercules_chsys_msg; - clif->chsys_msg2 = clif_hercules_chsys_msg2; - clif->chsys_send = clif_hercules_chsys_send; - clif->chsys_join = clif_hercules_chsys_join; - clif->chsys_left = clif_hercules_chsys_left; - clif->chsys_delete = clif_hercules_chsys_delete; - clif->chsys_mjoin = clif_hercules_chsys_mjoin; - clif->chsys_quit = clif_hercules_chsys_quit; - clif->chsys_quitg = clif_hercules_chsys_quitg; - clif->chsys_gjoin = clif_hercules_chsys_gjoin; - clif->chsys_gleave = clif_hercules_chsys_gleave; /* bgqueue */ clif->bgqueue_ack = clif_bgqueue_ack; clif->bgqueue_notice_delete = clif_bgqueue_notice_delete; @@ -18361,10 +18350,21 @@ void clif_defaults(void) { clif->notify_time = clif_notify_time; clif->user_count = clif_user_count; clif->noask_sub = clif_noask_sub; - clif->cashshop_load = clif_cashshop_db; - clif->package_announce = clif_package_item_announce; clif->bc_ready = clif_bc_ready; clif->undisguise_timer = clif_undisguise_timer; + /* Hercules Channel System */ + clif->chsys_create = clif_hercules_chsys_create; + clif->chsys_msg = clif_hercules_chsys_msg; + clif->chsys_msg2 = clif_hercules_chsys_msg2; + clif->chsys_send = clif_hercules_chsys_send; + clif->chsys_join = clif_hercules_chsys_join; + clif->chsys_left = clif_hercules_chsys_left; + clif->chsys_delete = clif_hercules_chsys_delete; + clif->chsys_mjoin = clif_hercules_chsys_mjoin; + clif->chsys_quit = clif_hercules_chsys_quit; + clif->chsys_quitg = clif_hercules_chsys_quitg; + clif->chsys_gjoin = clif_hercules_chsys_gjoin; + clif->chsys_gleave = clif_hercules_chsys_gleave; /*------------------------ *- Parse Incoming Packet *------------------------*/ @@ -18402,6 +18402,7 @@ void clif_defaults(void) { clif->pKickFromChat = clif_parse_KickFromChat; clif->pChatLeave = clif_parse_ChatLeave; clif->pTradeRequest = clif_parse_TradeRequest; + clif->chann_config_read = read_channels_config; clif->pTradeAck = clif_parse_TradeAck; clif->pTradeAddItem = clif_parse_TradeAddItem; clif->pTradeOk = clif_parse_TradeOk; @@ -18456,7 +18457,6 @@ void clif_defaults(void) { clif->pLeaveParty = clif_parse_LeaveParty; clif->pRemovePartyMember = clif_parse_RemovePartyMember; clif->pPartyChangeOption = clif_parse_PartyChangeOption; - clif->chann_config_read = read_channels_config; clif->pPartyMessage = clif_parse_PartyMessage; clif->pPartyChangeLeader = clif_parse_PartyChangeLeader; clif->pPartyBookingRegisterReq = clif_parse_PartyBookingRegisterReq; @@ -18561,17 +18561,19 @@ void clif_defaults(void) { clif->pDebug = clif_parse_debug; clif->pSkillSelectMenu = clif_parse_SkillSelectMenu; clif->pMoveItem = clif_parse_MoveItem; + /* dull */ + clif->pDull = clif_parse_dull; + /* BGQueue */ + clif->pBGQueueRegister = clif_parse_bgqueue_register; + clif->pBGQueueCheckState = clif_parse_bgqueue_checkstate; + clif->pBGQueueRevokeReq = clif_parse_bgqueue_revoke_req; + clif->pBGQueueBattleBeginAck = clif_parse_bgqueue_battlebegin_ack; /* RagExe Cash Shop [Ind/Hercules] */ clif->pCashShopOpen = clif_parse_CashShopOpen; clif->pCashShopClose = clif_parse_CashShopClose; clif->pCashShopReqTab = clif_parse_CashShopReqTab; clif->pCashShopSchedule = clif_parse_CashShopSchedule; clif->pCashShopBuy = clif_parse_CashShopBuy; - /* BGQueue */ - clif->pBGQueueRegister = clif_parse_bgqueue_register; - clif->pBGQueueCheckState = clif_parse_bgqueue_checkstate; - clif->pBGQueueRevokeReq = clif_parse_bgqueue_revoke_req; - clif->pBGQueueBattleBeginAck = clif_parse_bgqueue_battlebegin_ack; /* */ clif->pPartyTick = clif_parse_PartyTick; clif->pGuildInvite2 = clif_parse_GuildInvite2; @@ -18583,6 +18585,4 @@ void clif_defaults(void) { clif->pPartyBookingRefuseVolunteer = clif_parse_PartyBookingRefuseVolunteer; clif->pPartyBookingCancelVolunteer = clif_parse_PartyBookingCancelVolunteer; #endif - /* dull */ - clif->pDull = clif_parse_dull; } diff --git a/src/map/clif.h b/src/map/clif.h index e1744b4e8..2cf193965 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -918,6 +918,9 @@ struct clif_interface { void (*notify_time) (struct map_session_data* sd, unsigned long time); void (*user_count) (struct map_session_data* sd, int count); void (*noask_sub) (struct map_session_data *src, struct map_session_data *target, int type); + void (*bc_ready) (void); + int (*undisguise_timer) (int tid, unsigned int tick, int id, intptr_t data); + /* Hercules Channel System */ void (*chsys_create) (struct hChSysCh *channel, char *name, char *pass, unsigned char color); void (*chsys_msg) (struct hChSysCh *channel, struct map_session_data *sd, char *msg); void (*chsys_msg2) (struct hChSysCh *channel, char *msg); @@ -930,8 +933,6 @@ struct clif_interface { void (*chsys_quitg) (struct map_session_data *sd); void (*chsys_gjoin) (struct guild *g1,struct guild *g2); void (*chsys_gleave) (struct guild *g1,struct guild *g2); - void (*bc_ready) (void); - int (*undisguise_timer) (int tid, unsigned int tick, int id, intptr_t data); /*------------------------ *- Parse Incoming Packet *------------------------*/ diff --git a/src/map/guild.c b/src/map/guild.c index 5ff0254dc..e5ea6809d 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -564,7 +564,7 @@ int guild_recv_info(struct guild *sg) { //Also set the guild master flag. sd->guild = g; - sd->state.gmaster_flag = g; + sd->state.gmaster_flag = 1; clif->charnameupdate(sd); // [LuzZza] clif->guild_masterormember(sd); } @@ -754,7 +754,7 @@ void guild_member_joined(struct map_session_data *sd) return; } if (strcmp(sd->status.name,g->master) == 0) { // set the Guild Master flag - sd->state.gmaster_flag = g; + sd->state.gmaster_flag = 1; // prevent Guild Skills from being used directly after relog if( battle_config.guild_skill_relog_delay ) guild->block_skill(sd, 300000); @@ -933,6 +933,10 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c if( g->instances ) instance->check_kick(sd); clif->charnameupdate(sd); //Update display name [Skotlex] + status_change_end(&sd->bl, SC_LEADERSHIP, INVALID_TIMER); + status_change_end(&sd->bl, SC_GLORYWOUNDS, INVALID_TIMER); + status_change_end(&sd->bl, SC_SOULCOLD, INVALID_TIMER); + status_change_end(&sd->bl, SC_HAWKEYES, INVALID_TIMER); //TODO: send emblem update to self and people around } return 0; @@ -1756,8 +1760,13 @@ int guild_broken(int guild_id,int flag) gstorage->pc_quit(sd,1); sd->status.guild_id=0; sd->guild = NULL; + sd->state.gmaster_flag = 0; clif->guild_broken(g->member[i].sd,0); clif->charnameupdate(sd); // [LuzZza] + status_change_end(&sd->bl, SC_LEADERSHIP, INVALID_TIMER); + status_change_end(&sd->bl, SC_GLORYWOUNDS, INVALID_TIMER); + status_change_end(&sd->bl, SC_SOULCOLD, INVALID_TIMER); + status_change_end(&sd->bl, SC_HAWKEYES, INVALID_TIMER); } } @@ -1828,7 +1837,7 @@ int guild_gm_changed(int guild_id, int account_id, int char_id) if (g->member[0].sd && g->member[0].sd->fd) { clif->message(g->member[0].sd->fd, msg_txt(679)); //"You have become the Guild Master!" - g->member[0].sd->state.gmaster_flag = g; + g->member[0].sd->state.gmaster_flag = 1; //Block his skills for 5 minutes to prevent abuse. guild->block_skill(g->member[0].sd, 300000); } @@ -1849,9 +1858,9 @@ int guild_gm_changed(int guild_id, int account_id, int char_id) /*==================================================== * Guild disbanded *---------------------------------------------------*/ -int guild_break(struct map_session_data *sd,char *name) -{ +int guild_break(struct map_session_data *sd,char *name) { struct guild *g; + struct unit_data *ud; int i; nullpo_ret(sd); @@ -1872,7 +1881,30 @@ int guild_break(struct map_session_data *sd,char *name) clif->guild_broken(sd,2); return 0; } - + + /* regardless of char server allowing it, we clear the guild master's auras */ + if( (ud = unit_bl2ud(&sd->bl)) ) { + int count = 0; + struct skill_unit_group *groups[4]; + for (i=0;i<MAX_SKILLUNITGROUP && ud->skillunit[i];i++) { + switch (ud->skillunit[i]->skill_id) { + case GD_LEADERSHIP: + case GD_GLORYWOUNDS: + case GD_SOULCOLD: + case GD_HAWKEYES: + if( count == 4 ) + ShowWarning("guild_break:'%s' got more than 4 guild aura instances! (%d)\n",sd->status.name,ud->skillunit[i]->skill_id); + else + groups[count++] = ud->skillunit[i]; + break; + } + + } + for(i = 0; i < count; i++) { + skill->del_unitgroup(groups[i],ALC_MARK); + } + } + intif_guild_break(g->guild_id); return 1; } diff --git a/src/map/homunculus.c b/src/map/homunculus.c index 9bf752ef7..a1dd38b68 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -1146,8 +1146,8 @@ bool homunculus_read_skill_db_sub(char* split[], int columns, int current) { int j; int minJobLevelPresent = 0; - if( columns == 14 ) - minJobLevelPresent = 1; // MinJobLvl has been added + if( columns == 15 ) + minJobLevelPresent = 1; // MinJobLvl has been added - FIXME: is this extra field even needed anymore? // check for bounds [celest] classid = atoi(split[0]) - HM_CLASS_BASE; @@ -1295,4 +1295,6 @@ void homunculus_defaults(void) { homun->read_skill_db_sub = homunculus_read_skill_db_sub; homun->skill_db_read = homunculus_skill_db_read; homun->exp_db_read = homunculus_exp_db_read; + homun->addspiritball = homunculus_addspiritball; + homun->delspiritball = homunculus_delspiritball; } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 036075e57..139a62e06 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -900,7 +900,7 @@ bool itemdb_read_cached_packages(const char *config_filename) { fclose(file); - ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", pcount, config_filename); + ShowStatus("Done reading '"CL_WHITE"%lu"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"' ("CL_GREEN"C"CL_RESET").\n", pcount, config_filename); return true; } @@ -1942,9 +1942,6 @@ static void itemdb_read(void) { sv->readdb(iMap->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore); sv->readdb(iMap->db_path, "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse); - - itemdb->name_constants(); - itemdb_uid_load(); } @@ -2111,6 +2108,16 @@ void itemdb_name_constants(void) { dbi_destroy(iter); } +/* used to clear conflicts during script reload */ +void itemdb_force_name_constants(void) { + DBIterator *iter = db_iterator(itemdb->names); + struct item_data *data; + + for( data = dbi_first(iter); dbi_exists(iter); data = dbi_next(iter) ) + script->set_constant_force(data->name,data->nameid,0); + + dbi_destroy(iter); +} void do_final_itemdb(void) { int i; @@ -2168,6 +2175,7 @@ void itemdb_defaults(void) { itemdb->final = do_final_itemdb; itemdb->reload = itemdb_reload;//incomplete itemdb->name_constants = itemdb_name_constants; + itemdb->force_name_constants = itemdb_force_name_constants; /* */ itemdb->groups = NULL; itemdb->group_count = 0; @@ -2187,13 +2195,13 @@ void itemdb_defaults(void) { itemdb->write_cached_packages = itemdb_write_cached_packages; itemdb->read_cached_packages = itemdb_read_cached_packages; /* */ + itemdb->name2id = itemdb_name2id; itemdb->search_name = itemdb_searchname; itemdb->search_name_array = itemdb_searchname_array; itemdb->load = itemdb_load; itemdb->search = itemdb_search; itemdb->parse_dbrow = itemdb_parse_dbrow; itemdb->exists = itemdb_exists;//incomplete - itemdb->name2id = itemdb_name2id; itemdb->in_group = itemdb_in_group; itemdb->group_item = itemdb_searchrandomid; itemdb->chain_item = itemdb_chain_item; diff --git a/src/map/itemdb.h b/src/map/itemdb.h index 93bb8e0b9..41f40895b 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -280,6 +280,7 @@ struct itemdb_interface { void (*final) (void); void (*reload) (void); void (*name_constants) (void); + void (*force_name_constants) (void); /* */ struct item_group *groups; unsigned short group_count; diff --git a/src/map/log.c b/src/map/log.c index 79e3b87e6..daf96b930 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -513,8 +513,6 @@ void log_defaults(void) { logs->atcommand = log_atcommand; logs->branch = log_branch; logs->mvpdrop = log_mvpdrop; - logs->config_read = log_config_read; - logs->config_done = log_config_complete; /* will be modified in a few seconds once loading is complete. */ logs->pick_sub = log_pick_sub_txt; @@ -525,4 +523,7 @@ void log_defaults(void) { logs->branch_sub = log_branch_sub_txt; logs->mvpdrop_sub = log_mvpdrop_sub_txt; + logs->config_read = log_config_read; + logs->config_done = log_config_complete; + } diff --git a/src/map/map.c b/src/map/map.c index 05ba2edc2..db3bcf001 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5583,6 +5583,23 @@ void map_defaults(void) { iMap->charid2nick = map_charid2nick; iMap->charid2sd = map_charid2sd; + iMap->map_foreachpc = map_map_foreachpc; + iMap->map_foreachmob = map_map_foreachmob; + iMap->map_foreachnpc = map_map_foreachnpc; + iMap->map_foreachregen = map_map_foreachregen; + iMap->map_foreachiddb = map_map_foreachiddb; + + iMap->foreachinrange = map_foreachinrange; + iMap->foreachinshootrange = map_foreachinshootrange; + iMap->foreachinarea = map_foreachinarea; + iMap->forcountinrange = map_forcountinrange; + iMap->forcountinarea = map_forcountinarea; + iMap->foreachinmovearea = map_foreachinmovearea; + iMap->foreachincell = map_foreachincell; + iMap->foreachinpath = map_foreachinpath; + iMap->foreachinmap = map_foreachinmap; + iMap->foreachininstance = map_foreachininstance; + iMap->id2sd = map_id2sd; iMap->id2md = map_id2md; iMap->id2nd = map_id2nd; @@ -5628,23 +5645,6 @@ void map_defaults(void) { iMap->do_shutdown = do_shutdown; - iMap->map_foreachpc = map_map_foreachpc; - iMap->map_foreachmob = map_map_foreachmob; - iMap->map_foreachnpc = map_map_foreachnpc; - iMap->map_foreachregen = map_map_foreachregen; - iMap->map_foreachiddb = map_map_foreachiddb; - - iMap->foreachinrange = map_foreachinrange; - iMap->foreachinshootrange = map_foreachinshootrange; - iMap->foreachinarea=map_foreachinarea; - iMap->forcountinrange=map_forcountinrange; - iMap->forcountinarea=map_forcountinarea; - iMap->foreachinmovearea = map_foreachinmovearea; - iMap->foreachincell=map_foreachincell; - iMap->foreachinpath=map_foreachinpath; - iMap->foreachinmap=map_foreachinmap; - iMap->foreachininstance=map_foreachininstance; - /* temporary until the map.c "Hercules Renewal Phase One" design is complete. [Ind] */ mapit = &mapit_s; diff --git a/src/map/map.h b/src/map/map.h index ec5921509..7826e00b3 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -902,7 +902,7 @@ struct map_interface { int (*addmobtolist) (unsigned short m, struct spawn_data *spawn); // [Wizputer] void (*spawnmobs) (int16 m); // [Wizputer] void (*removemobs) (int16 m); // [Wizputer] - void (*do_reconnect_map) (void); //Invoked on map-char reconnection [Skotlex] Note used but still keeping it, just in case + //void (*do_reconnect_map) (void); //Invoked on map-char reconnection [Skotlex] Note used but still keeping it, just in case void (*addmap2db) (struct map_data *m); void (*removemapdb) (struct map_data *m); void (*clean) (int i); diff --git a/src/map/npc.c b/src/map/npc.c index 77c101f14..6aa19198f 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -3844,7 +3844,9 @@ int npc_reload(void) { "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Cached\n" "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n", npc_id - npc_new_min, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob); - + + itemdb->name_constants(); + for(i = 0; i < instance->instances; i++) { instance->destroy(i); } @@ -3999,6 +4001,8 @@ int do_init_npc(void) "\t-'"CL_WHITE"%d"CL_RESET"' Mobs Not Cached\n", npc_id - START_NPC_NUM, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob); + itemdb->name_constants(); + iMap->zone_init(); npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */ diff --git a/src/map/npc.h b/src/map/npc.h index 16e6fe74c..48c27b297 100644 --- a/src/map/npc.h +++ b/src/map/npc.h @@ -99,7 +99,7 @@ enum actor_classes //Checks if a given id is a valid npc id. [Skotlex] //Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001) -#define npcdb_checkid(id) ( ( (id) >= 46 && (id) <= 125) || (id) == HIDDEN_WARP_CLASS || ( (id) > 400 && (id) < MAX_NPC_CLASS ) || (id) == INVISIBLE_CLASS || ( (id) > 10000 && (id) < 10049 ) ) +#define npcdb_checkid(id) ( ( (id) >= 46 && (id) <= 125) || (id) == HIDDEN_WARP_CLASS || ( (id) > 400 && (id) < MAX_NPC_CLASS ) || (id) == INVISIBLE_CLASS || ( (id) > MAX_NPC_CLASS2_START && (id) < MAX_NPC_CLASS2_END ) ) #ifdef PCRE_SUPPORT void npc_chat_finalize(struct npc_data* nd); diff --git a/src/map/packets.h b/src/map/packets.h index f90c3b29d..091c48a77 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2272,6 +2272,102 @@ packet(0x020d,-1); packet(0x0883,36,clif->pStoragePassword,0); #endif +//2013-06-12Ragexe (Shakto) +#if PACKETVER >= 20130612 + packet(0x087E,5,clif->pChangeDir,2,4); + packet(0x0919,19,clif->pWantToConnection,2,6,10,14,18); + packet(0x0940,26,clif->pFriendsListAdd,2); + packet(0x093A,5,clif->pHomMenu,2,4); + packet(0x0964,36,clif->pStoragePassword,0); +#endif + +//2013-06-18Ragexe (Shakto) +#if PACKETVER >= 20130618 + packet(0x0889,7,clif->pActionRequest,2,6); + packet(0x0951,10,clif->pUseSkillToId,2,4,6); + packet(0x088E,5,clif->pWalkToXY,2); + packet(0x0930,6,clif->pTickSend,2); + packet(0x08A6,5,clif->pChangeDir,2,4); + packet(0x0962,6,clif->pTakeItem,2); + packet(0x0917,6,clif->pDropItem,2,4); + packet(0x0885,8,clif->pMoveToKafra,2,4); + packet(0x0936,8,clif->pMoveFromKafra,2,4); + packet(0x096A,10,clif->pUseSkillToPos,2,4,6,8); + packet(0x094F,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); + packet(0x0944,6,clif->pGetCharNameRequest,2); + packet(0x0945,6,clif->pSolveCharName,2); + packet(0x0890,12,clif->pSearchStoreInfoListItemClick,2,6,10); + packet(0x0363,2,clif->pSearchStoreInfoNextPage,0); + packet(0x0281,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); + packet(0x0891,-1,clif->pReqTradeBuyingStore,2,4,8,12); + packet(0x0862,6,clif->pReqClickBuyingStore,2); + packet(0x085A,2,clif->pReqCloseBuyingStore,0); + packet(0x0932,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); + packet(0x08A7,41,clif->pPartyBookingRegisterReq,2,4); + // packet(0x087A,8); // CZ_JOIN_BATTLE_FIELD + packet(0x0942,-1,clif->pItemListWindowSelected,2,4,8); + packet(0x095B,19,clif->pWantToConnection,2,6,10,14,18); + packet(0x0887,26,clif->pPartyInvite2,2); + // packet(0x0878,4); // CZ_GANGSI_RANK + packet(0x0953,26,clif->pFriendsListAdd,2); + packet(0x02C4,5,clif->pHomMenu,2,4); + packet(0x0864,36,clif->pStoragePassword,0); +#endif + +//2013-06-26Ragexe (Shakto) +#if PACKETVER >= 20130626 + packet(0x0369,7,clif->pActionRequest,2,6); + packet(0x083C,10,clif->pUseSkillToId,2,4,6); + packet(0x0437,5,clif->pWalkToXY,2); + packet(0x035F,6,clif->pTickSend,2); + packet(0x094D,5,clif->pChangeDir,2,4); + packet(0x088B,6,clif->pTakeItem,2); + packet(0x0952,6,clif->pDropItem,2,4); + packet(0x0921,8,clif->pMoveToKafra,2,4); + packet(0x0817,8,clif->pMoveFromKafra,2,4); + packet(0x0438,10,clif->pUseSkillToPos,2,4,6,8); + packet(0x0366,90,clif->pUseSkillToPosMoreInfo,2,4,6,8,10); + packet(0x096A,6,clif->pGetCharNameRequest,2); + packet(0x0368,6,clif->pSolveCharName,2); + packet(0x0838,12,clif->pSearchStoreInfoListItemClick,2,6,10); + packet(0x0835,2,clif->pSearchStoreInfoNextPage,0); + packet(0x0819,-1,clif->pSearchStoreInfo,2,4,5,9,13,14,15); + packet(0x0811,-1,clif->pReqTradeBuyingStore,2,4,8,12); + packet(0x0360,6,clif->pReqClickBuyingStore,2); + packet(0x0365,2,clif->pReqCloseBuyingStore,0); + packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); + packet(0x0894,41,clif->pPartyBookingRegisterReq,2,4); + // packet(0x0860,8); // CZ_JOIN_BATTLE_FIELD + packet(0x08A5,-1,clif->pItemListWindowSelected,2,4,8); + packet(0x088C,19,clif->pWantToConnection,2,6,10,14,18); + packet(0x0895,26,clif->pPartyInvite2,2); + // packet(0x088F,4); // CZ_GANGSI_RANK + packet(0x08AB,26,clif->pFriendsListAdd,2); + packet(0x0960,5,clif->pHomMenu,2,4); + packet(0x0930,36,clif->pStoragePassword,0); +#endif + +//2013-07-03Ragexe (Shakto) +#if PACKETVER >= 20130703 + packet(0x0930,5,clif->pChangeDir,2,4); + packet(0x07E4,6,clif->pTakeItem,2); + packet(0x0362,6,clif->pDropItem,2,4); + packet(0x07EC,8,clif->pMoveToKafra,2,4); + packet(0x0364,8,clif->pMoveFromKafra,2,4); + packet(0x0202,6,clif->pReqClickBuyingStore,2); + packet(0x0817,2,clif->pReqCloseBuyingStore,0); + packet(0x0815,-1,clif->pReqOpenBuyingStore,2,4,8,9,89); + packet(0x0365,41,clif->pPartyBookingRegisterReq,2,4); + // packet(0x0363,8); // CZ_JOIN_BATTLE_FIELD + packet(0x0281,-1,clif->pItemListWindowSelected,2,4,8); + packet(0x022D,19,clif->pWantToConnection,2,6,10,14,18); + packet(0x0802,26,clif->pPartyInvite2,2); + // packet(0x0436,4); // CZ_GANGSI_RANK + packet(0x0360,26,clif->pFriendsListAdd,2); + packet(0x094A,5,clif->pHomMenu,2,4); + packet(0x0873,36,clif->pStoragePassword,0); +#endif + /* PacketKeys: http://hercules.ws/board/topic/1105-hercules-wpe-free-june-14th-patch/ */ #if PACKETVER >= 20110817 packetKeys(0x053D5CED,0x3DED6DED,0x6DED6DED); /* Thanks to Shakto */ @@ -2453,5 +2549,13 @@ packet(0x020d,-1); packetKeys(0x434115DE,0x34A10FE9,0x6791428E); /* Thanks to Shakto */ #endif +#if PACKETVER >= 20130626 + packetKeys(0x38F453EF,0x6A040FD8,0X65BD6668); /* Thanks to Shakto */ +#endif + +#if PACKETVER >= 20130703 + packetKeys(0x4FF90E23,0x0F1432F2,0x4CFA1EDA); /* Thanks to Shakto */ +#endif + #endif /* _PACKETS_H_ */ diff --git a/src/map/pc.c b/src/map/pc.c index 84cfe7eb3..d58e39227 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1331,7 +1331,7 @@ int pc_calc_skilltree(struct map_session_data *sd) if( sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED && sd->status.skill[i].flag != SKILL_FLAG_PERM_GRANTED ) //Don't touch these sd->status.skill[i].id = 0; //First clear skills. /* permanent skills that must be re-checked */ - if( sd->status.skill[i].flag == SKILL_FLAG_PERM_GRANTED ) { + if( sd->status.skill[i].flag == SKILL_FLAG_PERMANENT ) { switch( skill_db[i].nameid ) { case NV_TRICKDEAD: if( (sd->class_&MAPID_UPPERMASK) != MAPID_NOVICE ) { @@ -1445,7 +1445,7 @@ int pc_calc_skilltree(struct map_session_data *sd) continue; //Cannot be learned via normal means. Note this check DOES allows raising already known skills. sd->status.skill[idx].id = id; - + if(inf2&INF2_SPIRIT_SKILL) { //Spirit skills cannot be learned, they will only show up on your tree when you get buffed. sd->status.skill[idx].lv = 1; // need to manually specify a skill level sd->status.skill[idx].flag = SKILL_FLAG_TEMPORARY; //So it is not saved, and tagged as a "bonus" skill. @@ -1536,6 +1536,7 @@ static void pc_check_skilltree(struct map_session_data *sd, int skill_id) continue; //Cannot be learned via normal means. sd->status.skill[idx].id = id; + flag = 1; } } while(flag); @@ -4220,6 +4221,12 @@ int pc_isUseitem(struct map_session_data *sd,int n) else if( itemdb_is_poison(nameid) && (sd->class_&MAPID_THIRDMASK) != MAPID_GUILLOTINE_CROSS ) return 0; + if( (item->package || item->group) && pc_is90overweight(sd) ) { + //##TODO## find official response to this + clif->colormes(sd->fd,COLOR_RED,msg_txt(1477));// Item cannot be open when overweight by 90% + return 0; + } + //Gender check if(item->sex != 2 && sd->status.sex != item->sex) return 0; @@ -6139,7 +6146,74 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { if( !(index = skill->get_index(skill_id)) ) return 0; + + if( battle_config.skillup_limit ) { + /* [Ind/Hercules] */ + if( (sd->class_&JOBL_2) && (sd->class_&MAPID_UPPERMASK) != MAPID_SUPER_NOVICE ){ + while(1) { + int c, i = 0, k = 0, pts = 0, pts_second = 0, id = 0; + bool can_skip = false; + + c = sd->class_ & MAPID_BASEMASK; + + k = pc_class2idx(pc_mapid2jobid(c, sd->status.sex)); + + for(i = 0; i < MAX_SKILL_TREE && (id=skill_tree[k][i].id) > 0 ; i++){ + int inf2 = skill->get_inf2(id), idx = skill_tree[k][i].idx; + + if( skill_id == id ) { + can_skip = true; + break;/* its oki we can skip */ + } + + if ( inf2&INF2_QUEST_SKILL || (inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL)) || id == NV_BASIC ) + continue; + + if( sd->status.skill[idx].id && sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT ) + pts += pc_checkskill(sd, id); + } + + if( can_skip ) break; + + if( pts < 40 ) { + clif->msg_value(sd, 0x61E, 40 - pts); + return 0; + } + + if( sd->class_&JOBL_THIRD ) { + bool is_trans = sd->class_&JOBL_UPPER? true : false; + + c = is_trans ? (sd->class_ &~ JOBL_THIRD)/* find fancy way */ : sd->class_ & MAPID_UPPERMASK; + + k = pc_class2idx(pc_mapid2jobid(c, sd->status.sex)); + for(i = 0; i < MAX_SKILL_TREE && (id=skill_tree[k][i].id) > 0 ; i++){ + int inf2 = skill->get_inf2(id), idx = skill_tree[k][i].idx; + + if( skill_id == id ) { + can_skip = true; + break;/* its oki we can skip */ + } + + if ( inf2&INF2_QUEST_SKILL || (inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL)) || id == NV_BASIC ) + continue; + + if( sd->status.skill[idx].id && sd->status.skill[idx].flag == SKILL_FLAG_PERMANENT ) + pts_second += pc_checkskill(sd, id); + } + + if( can_skip ) break; + + if( pts_second - pts < ( is_trans ? 70 : 50 ) ) { + clif->msg_value(sd, 0x61F, ( is_trans ? 70 : 50 ) - (pts_second - pts)); + return 0; + } + } + break; + } + } + } + if( sd->status.skill_point > 0 && sd->status.skill[index].id && sd->status.skill[index].flag == SKILL_FLAG_PERMANENT && //Don't allow raising while you have granted skills. [Skotlex] @@ -6160,21 +6234,7 @@ int pc_skillup(struct map_session_data *sd,uint16 skill_id) { clif->updatestatus(sd,SP_CARTINFO); if (!pc_has_permission(sd, PC_PERM_ALL_SKILL)) // may skill everything at any time anyways, and this would cause a huge slowdown clif->skillinfoblock(sd); - }else if( battle_config.skillup_limit ){ - int pts = 0, i, id; - for(i = 0; i < MAX_SKILL_TREE && (id=skill_tree[pc_class2idx(sd->status.class_)][i].id) > 0 ; i++){ - int inf2 = skill->get_inf2(id); - if ( inf2&INF2_QUEST_SKILL || (inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL)) || id == NV_BASIC ) - continue; - if( sd->status.skill[id].id && sd->status.skill[id].flag == SKILL_FLAG_PERMANENT ) - pts += pc_checkskill(sd, id); - } - if( pts < sd->change_level_2nd ) - clif->msg_value(sd, 0x61E, sd->change_level_2nd-pts); - else if( pts < (sd->change_level_3rd + sd->change_level_2nd) ) - clif->msg_value(sd, 0x61F, sd->change_level_3rd - (pts - sd->change_level_2nd)); } - return 0; } @@ -6987,10 +7047,10 @@ void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp) { pc->setinvincibletimer(sd, battle_config.pc_invincible_time); if( sd->state.gmaster_flag ) { - guild->aura_refresh(sd,GD_LEADERSHIP,guild->checkskill(sd->state.gmaster_flag,GD_LEADERSHIP)); - guild->aura_refresh(sd,GD_GLORYWOUNDS,guild->checkskill(sd->state.gmaster_flag,GD_GLORYWOUNDS)); - guild->aura_refresh(sd,GD_SOULCOLD,guild->checkskill(sd->state.gmaster_flag,GD_SOULCOLD)); - guild->aura_refresh(sd,GD_HAWKEYES,guild->checkskill(sd->state.gmaster_flag,GD_HAWKEYES)); + guild->aura_refresh(sd,GD_LEADERSHIP,guild->checkskill(sd->guild,GD_LEADERSHIP)); + guild->aura_refresh(sd,GD_GLORYWOUNDS,guild->checkskill(sd->guild,GD_GLORYWOUNDS)); + guild->aura_refresh(sd,GD_SOULCOLD,guild->checkskill(sd->guild,GD_SOULCOLD)); + guild->aura_refresh(sd,GD_HAWKEYES,guild->checkskill(sd->guild,GD_HAWKEYES)); } } // script @@ -8933,12 +8993,12 @@ int pc_checkitem(struct map_session_data *sd) } if (sd->state.gmaster_flag) { - struct guild_storage *guild_storage = gstorage->id2storage2(sd->state.gmaster_flag->guild_id); + struct guild_storage *guild_storage = gstorage->id2storage2(sd->guild->guild_id); if (guild_storage) { for( i = 0; i < MAX_GUILD_STORAGE; i++ ) { id = guild_storage->items[i].nameid; if( id && !itemdb_available(id) ) { - ShowWarning("Removed invalid/disabled item id %d from guild storage (amount=%d, char_id=%d, guild_id=%d).\n", id, guild_storage->items[i].amount, sd->status.char_id, sd->state.gmaster_flag->guild_id); + ShowWarning("Removed invalid/disabled item id %d from guild storage (amount=%d, char_id=%d, guild_id=%d).\n", id, guild_storage->items[i].amount, sd->status.char_id, sd->guild->guild_id); gstorage->delitem(sd, guild_storage, i, guild_storage->items[i].amount); gstorage->close(sd); // force closing } diff --git a/src/map/pc.h b/src/map/pc.h index 58dd85083..a69c77efe 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -158,7 +158,7 @@ struct map_session_data { unsigned short autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus] unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish] - struct guild *gmaster_flag; + unsigned int gmaster_flag : 1; unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not. unsigned int warping : 1;//states whether you're in the middle of a warp processing unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc(). @@ -752,7 +752,7 @@ struct pc_interface { int (*class2idx) (int class_); int (*get_group_level) (struct map_session_data *sd); - int (*getrefinebonus) (int lv,int type); + //int (*getrefinebonus) (int lv,int type); FIXME: This function does not exist, nor it is ever called bool (*can_give_items) (struct map_session_data *sd); bool (*can_use_command) (struct map_session_data *sd, const char *command); diff --git a/src/map/script.c b/src/map/script.c index c48610d3c..04d834f74 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -569,6 +569,7 @@ int add_str(const char* p) safestrncpy(script->str_buf+script->str_pos, p, len+1); script->str_data[script->str_num].type = C_NOP; script->str_data[script->str_num].str = script->str_pos; + script->str_data[script->str_num].val = 0; script->str_data[script->str_num].next = 0; script->str_data[script->str_num].func = NULL; script->str_data[script->str_num].backpatch = -1; @@ -1964,10 +1965,15 @@ void script_set_constant(const char* name, int value, bool isparameter) { ShowError("script_set_constant: Invalid name for %s '%s' (already defined as %s).\n", isparameter ? "parameter" : "constant", name, script_op2name(script->str_data[n].type)); } } -/* will override if necessary */ +/* adds data to a existent constant in the database, inserted normally via parse */ void script_set_constant2(const char *name, int value, bool isparameter) { int n = add_str(name); - + + if( ( script->str_data[n].type == C_NAME || script->str_data[n].type == C_PARAM ) && ( script->str_data[n].val != 0 || script->str_data[n].backpatch != -1 ) ) { // existing parameter or constant + ShowNotice("Conflicting item/script var '%s', prioritising the script var\n",name); + return; + } + if( script->str_data[n].type != C_NOP ) { script->str_data[n].func = NULL; script->str_data[n].backpatch = -1; @@ -1976,6 +1982,22 @@ void script_set_constant2(const char *name, int value, bool isparameter) { script->str_data[n].type = isparameter ? C_PARAM : C_INT; script->str_data[n].val = value; + +} +/* same as constant2 except it will override if necessary, used to clear conflicts during reload */ +void script_set_constant_force(const char *name, int value, bool isparameter) { + int n = add_str(name); + + if( script->str_data[n].type == C_PARAM ) + return;/* the one type we don't mess with, reload doesn't affect it. */ + + if( script->str_data[n].type != C_NOP ) { + script->str_data[n].type = C_NOP; + script->str_data[n].val = 0; + script->str_data[n].func = NULL; + script->str_data[n].backpatch = -1; + script->str_data[n].label = -1; + } } /*========================================== * Reading constant databases @@ -3869,6 +3891,9 @@ int script_reload() { db_clear(script->st_db); mapreg_reload(); + + itemdb->force_name_constants(); + return 0; } @@ -12594,20 +12619,15 @@ BUILDIN(npctalk) } // change npc walkspeed [Valaris] -BUILDIN(npcspeed) -{ +BUILDIN(npcspeed) { struct npc_data* nd; int speed; speed = script_getnum(st,2); - nd =(struct npc_data *)iMap->id2bl(st->oid); + nd = (struct npc_data *)iMap->id2bl(st->oid); if( nd ) { - if( nd->ud == &npc_base_ud ) { - nd->ud = NULL; - CREATE(nd->ud, struct unit_data, 1); - unit_dataset(&nd->bl); - } + unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit nd->speed = speed; nd->ud->state.speed_changed = 1; } @@ -12622,13 +12642,8 @@ BUILDIN(npcwalkto) { x=script_getnum(st,2); y=script_getnum(st,3); - if(nd) { - if( nd->ud == &npc_base_ud ) { - nd->ud = NULL; - CREATE(nd->ud, struct unit_data, 1); - unit_dataset(&nd->bl); - } - + if( nd ) { + unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit if (!nd->status.hp) { status_calc_npc(nd, true); } else { @@ -12640,11 +12655,11 @@ BUILDIN(npcwalkto) { return true; } // stop an npc's movement [Valaris] -BUILDIN(npcstop) -{ - struct npc_data *nd=(struct npc_data *)iMap->id2bl(st->oid); +BUILDIN(npcstop) { + struct npc_data *nd = (struct npc_data *)iMap->id2bl(st->oid); - if(nd) { + if( nd ) { + unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit unit_stop_walking(&nd->bl,1|4); } @@ -14885,23 +14900,23 @@ BUILDIN(pcstopfollow) /// /// unitwalk(<unit_id>,<x>,<y>) -> <bool> /// unitwalk(<unit_id>,<map_id>) -> <bool> -BUILDIN(unitwalk) -{ +BUILDIN(unitwalk) { struct block_list* bl; bl = iMap->id2bl(script_getnum(st,2)); - if( bl == NULL ) - { + if( bl == NULL ) { script_pushint(st, 0); + return true; } - else if( script_hasdata(st,4) ) - { + + if( bl->type == BL_NPC ) { + unit_bl2ud2(bl); // ensure the ((TBL_NPC*)bl)->ud is safe to edit + } + if( script_hasdata(st,4) ) { int x = script_getnum(st,3); int y = script_getnum(st,4); script_pushint(st, unit_walktoxy(bl,x,y,0));// We'll use harder calculations. - } - else - { + } else { int map_id = script_getnum(st,3); script_pushint(st, unit_walktobl(bl,iMap->id2bl(map_id),65025,1)); } @@ -14925,8 +14940,7 @@ BUILDIN(unitkill) /// Returns if it was successfull /// /// unitwarp(<unit_id>,"<map name>",<x>,<y>) -> <bool> -BUILDIN(unitwarp) -{ +BUILDIN(unitwarp) { int unit_id; int map; short x; @@ -14949,10 +14963,12 @@ BUILDIN(unitwarp) else map = iMap->mapname2mapid(mapname); - if( map >= 0 && bl != NULL ) + if( map >= 0 && bl != NULL ) { + unit_bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit script_pushint(st, unit_warp(bl,map,x,y,CLR_OUTSIGHT)); - else + } else { script_pushint(st, 0); + } return true; } @@ -15022,8 +15038,7 @@ BUILDIN(unitattack) /// Makes the unit stop attacking and moving /// /// unitstop <unit_id>; -BUILDIN(unitstop) -{ +BUILDIN(unitstop) { int unit_id; struct block_list* bl; @@ -15032,6 +15047,7 @@ BUILDIN(unitstop) bl = iMap->id2bl(unit_id); if( bl != NULL ) { + unit_bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit unit_stop_attack(bl); unit_stop_walking(bl,4); if( bl->type == BL_MOB ) @@ -18139,8 +18155,8 @@ void script_defaults(void) { script->hqs = script->hqis = 0; memset(&script->hqe, 0, sizeof(script->hqe)); - script->buildin_count = 0; script->buildin = NULL; + script->buildin_count = 0; script->str_data = NULL; script->str_data_size = 0; @@ -18175,7 +18191,9 @@ void script_defaults(void) { script->pop_stack = pop_stack; script->set_constant = script_set_constant; script->set_constant2 = script_set_constant2; + script->set_constant_force = script_set_constant_force; script->get_constant = script_get_constant; + script->label_add = script_label_add; script->queue = script_hqueue_get; script->queue_add = script_hqueue_add; @@ -18183,6 +18201,4 @@ void script_defaults(void) { script->queue_remove = script_hqueue_remove; script->queue_create = script_hqueue_create; script->queue_clear = script_hqueue_clear; - - script->label_add = script_label_add; } diff --git a/src/map/script.h b/src/map/script.h index 25a891897..8e2c4a6f5 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -384,6 +384,7 @@ struct script_interface { void (*pop_stack) (struct script_state* st, int start, int end); void (*set_constant) (const char* name, int value, bool isparameter); void (*set_constant2) (const char *name, int value, bool isparameter); + void (*set_constant_force) (const char *name, int value, bool isparameter); bool (*get_constant) (const char* name, int* value); void (*label_add)(int key, int pos); /* */ diff --git a/src/map/skill.c b/src/map/skill.c index 1b350f74c..28c5245bb 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -2954,24 +2954,6 @@ int skill_check_unit_range2 (struct block_list *bl, int x, int y, uint16 skill_i type, skill_id); } -int skill_guildaura_sub (struct map_session_data* sd, int id, int strvit, int agidex) -{ - if(id == sd->bl.id && battle_config.guild_aura&16) - return 0; // Do not affect guild leader - - if (sd->sc.data[SC_GUILDAURA]) { - struct status_change_entry *sce = sd->sc.data[SC_GUILDAURA]; - if( sce->val3 != strvit || sce->val4 != agidex ) { - sce->val3 = strvit; - sce->val4 = agidex; - status_calc_bl(&sd->bl, iStatus->sc2scb_flag(SC_GUILDAURA)); - } - return 0; - } - sc_start4(&sd->bl, SC_GUILDAURA,100, 1, id, strvit, agidex, 1000); - return 1; -} - /*========================================== * Checks that you have the requirements for casting a skill for homunculus/mercenary. * Flag: @@ -7521,7 +7503,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui int j = 0; struct guild *g; // i don't know if it actually summons in a circle, but oh well. ;P - g = sd?sd->state.gmaster_flag:guild->search(iStatus->get_guild_id(src)); + g = sd ? sd->guild : guild->search(iStatus->get_guild_id(src)); if (!g) break; clif->skill_nodamage(src,bl,skill_id,skill_lv,1); @@ -13900,7 +13882,7 @@ int skill_vfcastfix (struct block_list *bl, double time, uint16 skill_id, uint16 if (sc && sc->count && !(skill->get_castnodex(skill_id, skill_lv)&2) ) { // All variable cast additive bonuses must come first - if (sc->data[SC_MAGICPOWER] ) + if ( sc->data[SC_MAGICPOWER] && !( sd && time == 0 && sd->skillitem == skill_id )) time += 700; if (sc->data[SC_SLOWCAST]) VARCAST_REDUCTION(-sc->data[SC_SLOWCAST]->val2); @@ -18140,6 +18122,7 @@ void skill_defaults(void) { skill->get_mhp = skill_get_mhp; skill->get_sp = skill_get_sp; skill->get_state = skill_get_state; + skill->get_spiritball = skill_get_spiritball; skill->get_zeny = skill_get_zeny; skill->get_num = skill_get_num; skill->get_cast = skill_get_cast; @@ -18162,7 +18145,6 @@ void skill_defaults(void) { skill->get_unit_target = skill_get_unit_target; skill->get_unit_interval = skill_get_unit_interval; skill->get_unit_bl_target = skill_get_unit_bl_target; - skill->get_spiritball = skill_get_spiritball; skill->get_unit_layout_type = skill_get_unit_layout_type; skill->get_unit_range = skill_get_unit_range; skill->get_cooldown = skill_get_cooldown; @@ -18202,15 +18184,13 @@ void skill_defaults(void) { skill->delay_fix = skill_delay_fix; skill->check_condition_castbegin = skill_check_condition_castbegin; skill->check_condition_castend = skill_check_condition_castend; - skill->check_condition_char_sub = skill_check_condition_char_sub; + skill->consume_requirement = skill_consume_requirement; skill->get_requirement = skill_get_requirement; skill->check_pc_partner = skill_check_pc_partner; - skill->consume_requirement = skill_consume_requirement; skill->unit_move = skill_unit_move; - skill->unit_move_unit_group = skill_unit_move_unit_group; skill->unit_onleft = skill_unit_onleft; skill->unit_onout = skill_unit_onout; - skill->guildaura_sub = skill_guildaura_sub; + skill->unit_move_unit_group = skill_unit_move_unit_group; skill->sit = skill_sit; skill->brandishspear = skill_brandishspear; skill->repairweapon = skill_repairweapon; diff --git a/src/map/skill.h b/src/map/skill.h index 1ca5f235a..f9dbd0f1a 100644 --- a/src/map/skill.h +++ b/src/map/skill.h @@ -1842,7 +1842,6 @@ struct skill_interface { int (*unit_onleft) (uint16 skill_id, struct block_list *bl,unsigned int tick); int (*unit_onout) (struct skill_unit *src, struct block_list *bl, unsigned int tick); int (*unit_move_unit_group) ( struct skill_unit_group *group, int16 m,int16 dx,int16 dy); - int (*guildaura_sub) (struct map_session_data* sd, int id, int strvit, int agidex); int (*sit) (struct map_session_data *sd, int type); void (*brandishspear) (struct block_list* src, struct block_list* bl, uint16 skill_id, uint16 skill_lv, unsigned int tick, int flag); void (*repairweapon) (struct map_session_data *sd, int idx); diff --git a/src/map/status.c b/src/map/status.c index 0d8bedc5e..58e844529 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -6940,6 +6940,14 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val case SC_ELECTRICSHOCKER: case SC_MAGNETICFIELD: + // Masquerades + case SC__ENERVATION: + case SC__GROOMY: + case SC__LAZINESS: + case SC__UNLUCKY: + case SC__WEAKNESS: + case SC__IGNORANCE: + return 0; } } diff --git a/src/map/storage.c b/src/map/storage.c index e0b751863..5ebbb0dde 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -745,8 +745,8 @@ void storage_defaults(void) { storage->delitem = storage_delitem; storage->open = storage_storageopen; storage->add = storage_storageadd; - storage->additem = storage_additem; storage->get = storage_storageget; + storage->additem = storage_additem; storage->addfromcart = storage_storageaddfromcart; storage->gettocart = storage_storagegettocart; storage->close = storage_storageclose; diff --git a/src/map/unit.c b/src/map/unit.c index ce097dda0..4a8a87920 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -44,8 +44,13 @@ const short dirx[8]={0,-1,-1,-1,0,1,1,1}; const short diry[8]={1,1,0,-1,-1,-1,0,1}; -struct unit_data* unit_bl2ud(struct block_list *bl) -{ +/** + * Returns the unit_data for the given block_list. If the object is using + * shared unit_data (i.e. in case of BL_NPC), it returns the shared data. + * @param bl block_list to process + * @return a pointer to the given object's unit_data + **/ +struct unit_data* unit_bl2ud(struct block_list *bl) { if( bl == NULL) return NULL; if( bl->type == BL_PC) return &((struct map_session_data*)bl)->ud; if( bl->type == BL_MOB) return &((struct mob_data*)bl)->ud; @@ -57,6 +62,23 @@ struct unit_data* unit_bl2ud(struct block_list *bl) return NULL; } +/** + * Returns the unit_data for the given block_list. If the object is using + * shared unit_data (i.e. in case of BL_NPC), it recreates a copy of the + * data so that it's safe to modify. + * @param bl block_list to process + * @return a pointer to the given object's unit_data + */ +struct unit_data* unit_bl2ud2(struct block_list *bl) { + if( bl && bl->type == BL_NPC && ((struct npc_data*)bl)->ud == &npc_base_ud ) { + struct npc_data *nd = (struct npc_data *)bl; + nd->ud = NULL; + CREATE(nd->ud, struct unit_data, 1); + unit_dataset(&nd->bl); + } + return unit_bl2ud(bl); +} + static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data); static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data); diff --git a/src/map/unit.h b/src/map/unit.h index 9d1c02a31..a4c7fc0cc 100644 --- a/src/map/unit.h +++ b/src/map/unit.h @@ -124,6 +124,7 @@ void unit_dataset(struct block_list *bl); int unit_fixdamage(struct block_list *src,struct block_list *target,unsigned int tick,int sdelay,int ddelay,int damage,int div,int type,int damage2); // ‚»‚Ì‘¼ struct unit_data* unit_bl2ud(struct block_list *bl); +struct unit_data* unit_bl2ud2(struct block_list *bl); void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype); void unit_free_pc(struct map_session_data *sd); #define unit_remove_map(bl,clrtype) unit_remove_map_(bl,clrtype,__FILE__,__LINE__,__func__) |