diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/char/char.c | 25 | ||||
-rw-r--r-- | src/common/HPM.c | 4 | ||||
-rw-r--r-- | src/common/HPM.h | 2 | ||||
-rw-r--r-- | src/login/login.c | 12 | ||||
-rw-r--r-- | src/map/atcommand.c | 3 | ||||
-rw-r--r-- | src/map/chrif.c | 6 | ||||
-rw-r--r-- | src/map/clif.c | 33 | ||||
-rw-r--r-- | src/map/clif.h | 1 | ||||
-rw-r--r-- | src/map/itemdb.h | 2 | ||||
-rw-r--r-- | src/map/packets.h | 7 | ||||
-rw-r--r-- | src/map/pc.c | 16 | ||||
-rw-r--r-- | src/map/pc.h | 2 | ||||
-rw-r--r-- | src/map/script.c | 77 | ||||
-rw-r--r-- | src/map/script.h | 1 | ||||
-rw-r--r-- | src/map/status.c | 8 | ||||
-rw-r--r-- | src/map/unit.c | 16 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc | 12 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc | 3 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 79 | ||||
-rw-r--r-- | src/plugins/constdb2doc.c | 197 |
20 files changed, 460 insertions, 46 deletions
diff --git a/src/char/char.c b/src/char/char.c index 09f74034c..d05d13d4b 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2637,11 +2637,11 @@ int char_parse_fromlogin(int fd) { } } - while(RFIFOREST(fd) >= 2) { + while (RFIFOREST(fd) >= 2) { uint16 command = RFIFOW(fd,0); if (VECTOR_LENGTH(HPM->packets[hpParse_FromLogin]) > 0) { - int result = HPM->parse_packets(fd,hpParse_FromLogin); + int result = HPM->parse_packets(fd,command,hpParse_FromLogin); if (result == 1) continue; if (result == 2) @@ -3926,16 +3926,17 @@ int char_parse_frommap(int fd) return 0; } - while(RFIFOREST(fd) >= 2) { + while (RFIFOREST(fd) >= 2) { + int packet_id = RFIFOW(fd,0); if (VECTOR_LENGTH(HPM->packets[hpParse_FromMap]) > 0) { - int result = HPM->parse_packets(fd,hpParse_FromMap); + int result = HPM->parse_packets(fd,packet_id,hpParse_FromMap); if (result == 1) continue; if (result == 2) return 0; } - switch(RFIFOW(fd,0)) { + switch (packet_id) { case 0x2b0a: if( RFIFOREST(fd) < RFIFOW(fd, 2) ) return 0; @@ -5106,21 +5107,21 @@ int char_parse_char(int fd) return 0; } - while( RFIFOREST(fd) >= 2 ) { - //For use in packets that depend on an sd being present [Skotlex] - #define FIFOSD_CHECK(rest) do { if(RFIFOREST(fd) < (rest)) return 0; if (sd==NULL || !sd->auth) { RFIFOSKIP(fd,(rest)); return 0; } } while (0) + while (RFIFOREST(fd) >= 2) { + cmd = RFIFOW(fd,0); + +//For use in packets that depend on an sd being present [Skotlex] +#define FIFOSD_CHECK(rest) do { if(RFIFOREST(fd) < (rest)) return 0; if (sd==NULL || !sd->auth) { RFIFOSKIP(fd,(rest)); return 0; } } while (0) if (VECTOR_LENGTH(HPM->packets[hpParse_Char]) > 0) { - int result = HPM->parse_packets(fd,hpParse_Char); + int result = HPM->parse_packets(fd,cmd,hpParse_Char); if (result == 1) continue; if (result == 2) return 0; } - cmd = RFIFOW(fd,0); - - switch( cmd ) { + switch (cmd) { // request to connect // 0065 <account id>.L <login id1>.L <login id2>.L <???>.W <sex>.B case 0x65: diff --git a/src/common/HPM.c b/src/common/HPM.c index 62ef54499..d9c3262d7 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -718,13 +718,13 @@ CPCMD(plugins) * @retval 1 OK * @retval 2 incomplete packet */ -unsigned char hplugins_parse_packets(int fd, enum HPluginPacketHookingPoints point) +unsigned char hplugins_parse_packets(int fd, int packet_id, enum HPluginPacketHookingPoints point) { struct HPluginPacket *packet = NULL; int i; int16 length; - ARR_FIND(0, VECTOR_LENGTH(HPM->packets[point]), i, VECTOR_INDEX(HPM->packets[point], i).cmd == RFIFOW(fd,0)); + ARR_FIND(0, VECTOR_LENGTH(HPM->packets[point]), i, VECTOR_INDEX(HPM->packets[point], i).cmd == packet_id); if (i == VECTOR_LENGTH(HPM->packets[point])) return 0; diff --git a/src/common/HPM.h b/src/common/HPM.h index 215161a86..109549aad 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -157,7 +157,7 @@ struct HPM_interface { void (*share) (void *value, const char *name); void (*config_read) (void); char *(*pid2name) (unsigned int pid); - unsigned char (*parse_packets) (int fd, enum HPluginPacketHookingPoints point); + unsigned char (*parse_packets) (int fd, int packet_id, enum HPluginPacketHookingPoints point); void (*load_sub) (struct hplugin *plugin); bool (*addhook_sub) (enum HPluginHookType type, const char *target, void *hook, unsigned int pID); /* for custom config parsing */ diff --git a/src/login/login.c b/src/login/login.c index 7ed0ada89..d4768df86 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -808,18 +808,18 @@ int login_parse_fromchar(int fd) ipl = server[id].ip; sockt->ip2str(ipl, ip); - while( RFIFOREST(fd) >= 2 ) { + while (RFIFOREST(fd) >= 2) { uint16 command = RFIFOW(fd,0); if (VECTOR_LENGTH(HPM->packets[hpParse_FromChar]) > 0) { - int result = HPM->parse_packets(fd,hpParse_FromChar); + int result = HPM->parse_packets(fd,command,hpParse_FromChar); if (result == 1) continue; if (result == 2) return 0; } - switch( command ) { + switch (command) { case 0x2712: // request from char-server to authenticate an account if( RFIFOREST(fd) < 23 ) @@ -1619,18 +1619,18 @@ int login_parse_login(int fd) sd->fd = fd; } - while( RFIFOREST(fd) >= 2 ) { + while (RFIFOREST(fd) >= 2) { uint16 command = RFIFOW(fd,0); if (VECTOR_LENGTH(HPM->packets[hpParse_Login]) > 0) { - int result = HPM->parse_packets(fd,hpParse_Login); + int result = HPM->parse_packets(fd,command,hpParse_Login); if (result == 1) continue; if (result == 2) return 0; } - switch( command ) { + switch (command) { case 0x0200: // New alive packet: structure: 0x200 <account.userid>.24B. used to verify if client is always alive. if (RFIFOREST(fd) < 26) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index e223f698c..08119457d 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -8414,6 +8414,7 @@ ACMD(charcommands) atcommand->commands_sub(sd, fd, COMMAND_CHARCOMMAND); return true; } + /* for new mounts */ ACMD(cashmount) { @@ -8425,7 +8426,7 @@ ACMD(cashmount) clif->message(sd->fd,msg_fd(fd,1362)); // NOTICE: If you crash with mount your LUA is outdated. if (!sd->sc.data[SC_ALL_RIDING]) { clif->message(sd->fd,msg_fd(fd,1363)); // You have mounted. - sc_start(NULL,&sd->bl,SC_ALL_RIDING,100,0,-1); + sc_start(NULL,&sd->bl,SC_ALL_RIDING,100,25,-1); } else { clif->message(sd->fd,msg_fd(fd,1364)); // You have released your mount. status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER); diff --git a/src/map/chrif.c b/src/map/chrif.c index 1f7fbe96e..258d550d4 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1394,16 +1394,16 @@ int chrif_parse(int fd) { } while (RFIFOREST(fd) >= 2) { + cmd = RFIFOW(fd,0); + if (VECTOR_LENGTH(HPM->packets[hpChrif_Parse]) > 0) { - int result = HPM->parse_packets(fd,hpChrif_Parse); + int result = HPM->parse_packets(fd,cmd,hpChrif_Parse); if (result == 1) continue; if (result == 2) return 0; } - cmd = RFIFOW(fd,0); - if (cmd < 0x2af8 || cmd >= 0x2af8 + ARRAYLENGTH(chrif->packet_len_table) || chrif->packet_len_table[cmd-0x2af8] == 0) { int result = intif->parse(fd); // Passed on to the intif diff --git a/src/map/clif.c b/src/map/clif.c index 1cd18b68d..817579e23 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -11484,6 +11484,22 @@ void clif_parse_ItemIdentify(int fd,struct map_session_data *sd) clif_menuskill_clear(sd); } +/// Identifying item with right-click (CZ_REQ_ONECLICK_ITEMIDENTIFY). +/// 0A35 <index>.W +void clif_parse_OneClick_ItemIdentify(int fd, struct map_session_data *sd) +{ + int cmd = RFIFOW(fd,0); + short idx = RFIFOW(fd, packet_db[cmd].pos[0]) - 2; + int n; + + if (idx < 0 || idx >= MAX_INVENTORY || sd->inventory_data[idx] == NULL || sd->status.inventory[idx].nameid <= 0) + return; + + if ((n = pc->have_magnifier(sd) ) != INDEX_NOT_FOUND && + pc->delitem(sd, n, 1, 0, DELITEM_NORMAL, LOG_TYPE_OTHER) == 0) + skill->identify(sd, idx); +} + void clif_parse_SelectArrow(int fd,struct map_session_data *sd) __attribute__((nonnull (2))); /// Answer to arrow crafting item selection dialog (CZ_REQ_MAKINGARROW). /// 01ae <name id>.W @@ -18729,21 +18745,21 @@ int clif_parse(int fd) { if (RFIFOREST(fd) < 2) return 0; + if (sd) + parse_cmd_func = sd->parse_cmd_func; + else + parse_cmd_func = clif->parse_cmd; + + cmd = parse_cmd_func(fd,sd); + if (VECTOR_LENGTH(HPM->packets[hpClif_Parse]) > 0) { - int result = HPM->parse_packets(fd,hpClif_Parse); + int result = HPM->parse_packets(fd,cmd,hpClif_Parse); if (result == 1) continue; if (result == 2) return 0; } - if( sd ) - parse_cmd_func = sd->parse_cmd_func; - else - parse_cmd_func = clif->parse_cmd; - - cmd = parse_cmd_func(fd,sd); - // filter out invalid / unsupported packets if (cmd > MAX_PACKET_DB || cmd < MIN_PACKET_DB || packet_db[cmd].len == 0) { ShowWarning("clif_parse: Received unsupported packet (packet 0x%04x (0x%04x), %"PRIuS" bytes received), disconnecting session #%d.\n", @@ -19707,4 +19723,5 @@ void clif_defaults(void) { clif->add_random_options = clif_add_random_options; clif->pHotkeyRowShift = clif_parse_HotkeyRowShift; clif->dressroom_open = clif_dressroom_open; + clif->pOneClick_ItemIdentify = clif_parse_OneClick_ItemIdentify; } diff --git a/src/map/clif.h b/src/map/clif.h index 250689e90..3d43b064c 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -1338,6 +1338,7 @@ struct clif_interface { void (*add_random_options) (unsigned char* buf, struct item* item); void (*pHotkeyRowShift) (int fd, struct map_session_data *sd); void (*dressroom_open) (struct map_session_data *sd, int view); + void (*pOneClick_ItemIdentify) (int fd,struct map_session_data *sd); /* Cart Deco */ void(*selectcart) (struct map_session_data *sd); void(*pSelectCart) (int fd, struct map_session_data *sd); diff --git a/src/map/itemdb.h b/src/map/itemdb.h index cde73f3b4..8a0ec389d 100644 --- a/src/map/itemdb.h +++ b/src/map/itemdb.h @@ -64,6 +64,7 @@ enum item_itemid { ITEMID_BRANCH_OF_DEAD_TREE = 604, ITEMID_ANODYNE = 605, ITEMID_ALOEBERA = 606, + ITEMID_MAGNIFIER = 611, ITEMID_POISON_BOTTLE = 678, ITEMID_EMPTY_BOTTLE = 713, ITEMID_EMPERIUM = 714, @@ -136,6 +137,7 @@ enum item_itemid { ITEMID_MAGIC_CASTLE = 12308, ITEMID_BULGING_HEAD = 12309, ITEMID_THICK_MANUAL50 = 12312, + ITEMID_NOVICE_MAGNIFIER = 12325, ITEMID_ANCILLA = 12333, ITEMID_REPAIR_A = 12392, ITEMID_REPAIR_B = 12393, diff --git a/src/map/packets.h b/src/map/packets.h index 6174d76d2..0badd94f5 100644 --- a/src/map/packets.h +++ b/src/map/packets.h @@ -2910,9 +2910,10 @@ packet(0x96e,-1,clif->ackmergeitems); packet(0x08A8,26,clif->pFriendsListAdd,2); packet(0x0817,5,clif->pHomMenu,2,4); packet(0x0923,36,clif->pStoragePassword,0); - packet(0x09e8,11,clif->pDull); // CZ_OPEN_MAILBOX - packet(0x0a2e,6,clif->pDull); // TITLE - packet(0x0a02,4); // ZC_DRESSROOM_OPEN + packet(0x09E8,11,clif->pDull); // CZ_OPEN_MAILBOX + packet(0x0A2E,6,clif->pDull); // TITLE + packet(0x0A02,4); // ZC_DRESSROOM_OPEN + packet(0x0A35,4,clif->pOneClick_ItemIdentify,2); #endif #if PACKETVER >= 20150805 // RagexeRE diff --git a/src/map/pc.c b/src/map/pc.c index 2dfd9519b..491584385 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -11479,6 +11479,20 @@ bool pc_db_checkid(unsigned int class_) || (class_ >= JOB_REBELLION && class_ < JOB_MAX ); } +/** + * checks if player have any kind of magnifier in inventory + * @param sd map_session_data of Player + * @return index of magnifer, INDEX_NOT_FOUND if it is not found + */ +int pc_have_magnifier(struct map_session_data *sd) +{ + int n; + n = pc->search_inventory(sd, ITEMID_MAGNIFIER); + if (n == INDEX_NOT_FOUND) + n = pc->search_inventory(sd, ITEMID_NOVICE_MAGNIFIER); + return n; +} + void do_final_pc(void) { db_destroy(pc->itemcd_db); pc->at_db->destroy(pc->at_db,pc->autotrade_final); @@ -11846,4 +11860,6 @@ void pc_defaults(void) { pc->check_job_name = pc_check_job_name; pc->update_idle_time = pc_update_idle_time; + + pc->have_magnifier = pc_have_magnifier; } diff --git a/src/map/pc.h b/src/map/pc.h index 23b46a631..06bc5e5ae 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1088,6 +1088,8 @@ END_ZEROED_BLOCK; /* End */ int (*check_job_name) (const char *name); void (*update_idle_time) (struct map_session_data* sd, enum e_battle_config_idletime type); + + int (*have_magnifier) (struct map_session_data *sd); }; #ifdef HERCULES_CORE diff --git a/src/map/script.c b/src/map/script.c index 35a71868a..ca53b6f6d 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2322,6 +2322,15 @@ void read_constdb(void) ShowWarning("read_constdb: Invalid constant name %s. Skipping.\n", name); continue; } + if (strcmp(name, "comment__") == 0) { + const char *comment = libconfig->setting_get_string(t); + if (comment == NULL) + continue; + if (*comment == '\0') + comment = NULL; + script->constdb_comment(comment); + continue; + } if (config_setting_is_aggregate(t)) { int i32; if (!libconfig->setting_lookup_int(t, "Value", &i32)) { @@ -2342,9 +2351,22 @@ void read_constdb(void) } script->set_constant(name, value, is_parameter, is_deprecated); } + script->constdb_comment(NULL); libconfig->destroy(&constants_conf); } +/** + * Sets the current constdb comment. + * + * This function does nothing (used by plugins only) + * + * @param comment The comment to set (NULL to unset) + */ +void script_constdb_comment(const char *comment) +{ + (void)comment; +} + // Standard UNIX tab size is 8 #define TAB_SIZE 8 #define update_tabstop(tabstop,chars) \ @@ -18490,7 +18512,7 @@ BUILDIN(setcashmount) if (sd->sc.data[SC_ALL_RIDING]) status_change_end(&sd->bl, SC_ALL_RIDING, INVALID_TIMER); else - sc_start(NULL,&sd->bl, SC_ALL_RIDING, 100, 0, -1); + sc_start(NULL,&sd->bl, SC_ALL_RIDING, 100, 25, -1); script_pushint(st,1);//in both cases, return 1. } return true; @@ -20820,9 +20842,11 @@ void script_label_add(int key, int pos) { **/ void script_hardcoded_constants(void) { + script->constdb_comment("Boolean"); script->set_constant("true", 1, false, false); script->set_constant("false", 0, false, false); - /* server defines */ + + script->constdb_comment("Server defines"); script->set_constant("PACKETVER",PACKETVER,false, false); script->set_constant("MAX_LEVEL",MAX_LEVEL,false, false); script->set_constant("MAX_STORAGE",MAX_STORAGE,false, false); @@ -20834,7 +20858,7 @@ void script_hardcoded_constants(void) script->set_constant("MAX_CHAT_USERS",MAX_CHAT_USERS,false, false); script->set_constant("MAX_REFINE",MAX_REFINE,false, false); - /* status options */ + script->constdb_comment("status options"); script->set_constant("Option_Nothing",OPTION_NOTHING,false, false); script->set_constant("Option_Sight",OPTION_SIGHT,false, false); script->set_constant("Option_Hide",OPTION_HIDE,false, false); @@ -20860,11 +20884,11 @@ void script_hardcoded_constants(void) script->set_constant("Option_Hanbok",OPTION_HANBOK,false, false); script->set_constant("Option_Oktoberfest",OPTION_OKTOBERFEST,false, false); - /* status option compounds */ + script->constdb_comment("status option compounds"); script->set_constant("Option_Dragon",OPTION_DRAGON,false, false); script->set_constant("Option_Costume",OPTION_COSTUME,false, false); - /* send_target */ + script->constdb_comment("send_target"); script->set_constant("ALL_CLIENT",ALL_CLIENT,false, false); script->set_constant("ALL_SAMEMAP",ALL_SAMEMAP,false, false); script->set_constant("AREA",AREA,false, false); @@ -20898,7 +20922,46 @@ void script_hardcoded_constants(void) script->set_constant("BG_AREA_WOS",BG_AREA_WOS,false, false); script->set_constant("BG_QUEUE",BG_QUEUE,false, false); - /* Renewal */ + script->constdb_comment("LOOK_ constants, use in setlook/changelook script commands"); + script->set_constant("LOOK_BASE", LOOK_BASE, false, false); + script->set_constant("LOOK_HAIR", LOOK_HAIR, false, false); + script->set_constant("LOOK_WEAPON", LOOK_WEAPON, false, false); + script->set_constant("LOOK_HEAD_BOTTOM", LOOK_HEAD_BOTTOM, false, false); + script->set_constant("LOOK_HEAD_TOP", LOOK_HEAD_TOP, false, false); + script->set_constant("LOOK_HEAD_MID", LOOK_HEAD_MID, false, false); + script->set_constant("LOOK_HAIR_COLOR", LOOK_HAIR_COLOR, false, false); + script->set_constant("LOOK_CLOTHES_COLOR", LOOK_CLOTHES_COLOR, false, false); + script->set_constant("LOOK_SHIELD", LOOK_SHIELD, false, false); + script->set_constant("LOOK_SHOES", LOOK_SHOES, false, false); + script->set_constant("LOOK_BODY", LOOK_BODY, false, false); + script->set_constant("LOOK_FLOOR", LOOK_FLOOR, false, false); + script->set_constant("LOOK_ROBE", LOOK_ROBE, false, false); + script->set_constant("LOOK_BODY2", LOOK_BODY2, false, false); + + script->constdb_comment("Equip Position in Bits, use with *getiteminfo type 5, or @inventorylist_equip"); + script->set_constant("EQP_HEAD_LOW", EQP_HEAD_LOW, false, false); + script->set_constant("EQP_HEAD_MID", EQP_HEAD_MID, false, false); + script->set_constant("EQP_HEAD_TOP", EQP_HEAD_TOP, false, false); + script->set_constant("EQP_HAND_R", EQP_HAND_R, false, false); + script->set_constant("EQP_HAND_L", EQP_HAND_L, false, false); + script->set_constant("EQP_ARMOR", EQP_ARMOR, false, false); + script->set_constant("EQP_SHOES", EQP_SHOES, false, false); + script->set_constant("EQP_GARMENT", EQP_GARMENT, false, false); + script->set_constant("EQP_ACC_L", EQP_ACC_L, false, false); + script->set_constant("EQP_ACC_R", EQP_ACC_R, false, false); + script->set_constant("EQP_COSTUME_HEAD_TOP", EQP_COSTUME_HEAD_TOP, false, false); + script->set_constant("EQP_COSTUME_HEAD_MID", EQP_COSTUME_HEAD_MID, false, false); + script->set_constant("EQP_COSTUME_HEAD_LOW", EQP_COSTUME_HEAD_LOW, false, false); + script->set_constant("EQP_COSTUME_GARMENT", EQP_COSTUME_GARMENT, false, false); + script->set_constant("EQP_AMMO", EQP_AMMO, false, false); + script->set_constant("EQP_SHADOW_ARMOR", EQP_SHADOW_ARMOR, false, false); + script->set_constant("EQP_SHADOW_WEAPON", EQP_SHADOW_WEAPON, false, false); + script->set_constant("EQP_SHADOW_SHIELD", EQP_SHADOW_SHIELD, false, false); + script->set_constant("EQP_SHADOW_SHOES", EQP_SHADOW_SHOES, false, false); + script->set_constant("EQP_SHADOW_ACC_R", EQP_SHADOW_ACC_R, false, false); + script->set_constant("EQP_SHADOW_ACC_L", EQP_SHADOW_ACC_L, false, false); + + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); #else @@ -20934,6 +20997,7 @@ void script_hardcoded_constants(void) #else script->set_constant("RENEWAL_ASPD", 0, false, false); #endif + script->constdb_comment(NULL); } /** @@ -21111,6 +21175,7 @@ void script_defaults(void) { script->parse_expr = parse_expr; script->parse_line = parse_line; script->read_constdb = read_constdb; + script->constdb_comment = script_constdb_comment; script->print_line = script_print_line; script->errorwarning_sub = script_errorwarning_sub; script->set_reg = set_reg; diff --git a/src/map/script.h b/src/map/script.h index dbb0f8a03..e6164092e 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -726,6 +726,7 @@ struct script_interface { const char* (*parse_expr) (const char *p); const char* (*parse_line) (const char *p); void (*read_constdb) (void); + void (*constdb_comment) (const char *comment); const char* (*print_line) (StringBuf *buf, const char *p, const char *mark, int line); void (*errorwarning_sub) (StringBuf *buf, const char *src, const char *file, int start_line, const char *error_msg, const char *error_pos); int (*set_reg) (struct script_state *st, struct map_session_data *sd, int64 num, const char *name, const void *value, struct reg_db *ref); diff --git a/src/map/status.c b/src/map/status.c index db8c0d6c5..879f10efb 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -5542,8 +5542,10 @@ unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc if(sc->data[SC_FUSION]) { val = 25; } else if (sd) { - if (pc_isridingpeco(sd) || pc_isridingdragon(sd) || sd->sc.data[SC_ALL_RIDING]) + if (pc_isridingpeco(sd) || pc_isridingdragon(sd)) val = 25;//Same bonus + else if (sd->sc.data[SC_ALL_RIDING]) + val = sd->sc.data[SC_ALL_RIDING]->val1; else if (pc_isridingwug(sd)) val = 15 + 5 * pc->checkskill(sd, RA_WUGRIDER); else if (pc_ismadogear(sd)) { @@ -8981,8 +8983,8 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t tick_time = 3000; // [GodLesZ] tick time break; case SC_CLOAKINGEXCEED: - val2 = ( val1 + 1 ) / 2; // Hits - val3 = 90 + val1 * 10; // Walk speed + val2 = (val1 + 1) / 2; // Hits + val3 = (val1 - 1) * 10; // Walk speed if (bl->type == BL_PC) val4 |= battle_config.pc_cloak_check_type&7; else diff --git a/src/map/unit.c b/src/map/unit.c index 26104e4e0..bea0913d2 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -1976,6 +1976,7 @@ bool unit_can_reach_pos(struct block_list *bl,int x,int y, int easy) bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y) { short dx,dy; + struct walkpath_data wpd; nullpo_retr(false, bl); nullpo_retr(false, tbl); @@ -2005,7 +2006,20 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, if (x) *x = tbl->x-dx; if (y) *y = tbl->y-dy; - return path->search(NULL,bl,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH); + + if (!path->search(&wpd,bl,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH)) + return false; + +#ifdef OFFICIAL_WALKPATH + if( !path->search_long(NULL, bl, bl->m, bl->x, bl->y, tbl->x-dx, tbl->y-dy, CELL_CHKNOPASS) // Check if there is an obstacle between + && wpd.path_len > 14 // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett] + && (bl->type != BL_NPC) ) // If type is a NPC, please disregard. + return false; +#endif + + return true; + + } /*========================================== * Calculates position of Pet/Mercenary/Homunculus/Elemental diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc index e0c5a4df3..f5ac1e70a 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc @@ -1848,6 +1848,8 @@ struct { struct HPMHookPoint *HP_clif_pHotkeyRowShift_post; struct HPMHookPoint *HP_clif_dressroom_open_pre; struct HPMHookPoint *HP_clif_dressroom_open_post; + struct HPMHookPoint *HP_clif_pOneClick_ItemIdentify_pre; + struct HPMHookPoint *HP_clif_pOneClick_ItemIdentify_post; struct HPMHookPoint *HP_clif_selectcart_pre; struct HPMHookPoint *HP_clif_selectcart_post; struct HPMHookPoint *HP_clif_pSelectCart_pre; @@ -4322,6 +4324,8 @@ struct { struct HPMHookPoint *HP_pc_check_job_name_post; struct HPMHookPoint *HP_pc_update_idle_time_pre; struct HPMHookPoint *HP_pc_update_idle_time_post; + struct HPMHookPoint *HP_pc_have_magnifier_pre; + struct HPMHookPoint *HP_pc_have_magnifier_post; struct HPMHookPoint *HP_libpcre_compile_pre; struct HPMHookPoint *HP_libpcre_compile_post; struct HPMHookPoint *HP_libpcre_study_pre; @@ -4624,6 +4628,8 @@ struct { struct HPMHookPoint *HP_script_parse_line_post; struct HPMHookPoint *HP_script_read_constdb_pre; struct HPMHookPoint *HP_script_read_constdb_post; + struct HPMHookPoint *HP_script_constdb_comment_pre; + struct HPMHookPoint *HP_script_constdb_comment_post; struct HPMHookPoint *HP_script_print_line_pre; struct HPMHookPoint *HP_script_print_line_post; struct HPMHookPoint *HP_script_errorwarning_sub_pre; @@ -7689,6 +7695,8 @@ struct { int HP_clif_pHotkeyRowShift_post; int HP_clif_dressroom_open_pre; int HP_clif_dressroom_open_post; + int HP_clif_pOneClick_ItemIdentify_pre; + int HP_clif_pOneClick_ItemIdentify_post; int HP_clif_selectcart_pre; int HP_clif_selectcart_post; int HP_clif_pSelectCart_pre; @@ -10163,6 +10171,8 @@ struct { int HP_pc_check_job_name_post; int HP_pc_update_idle_time_pre; int HP_pc_update_idle_time_post; + int HP_pc_have_magnifier_pre; + int HP_pc_have_magnifier_post; int HP_libpcre_compile_pre; int HP_libpcre_compile_post; int HP_libpcre_study_pre; @@ -10465,6 +10475,8 @@ struct { int HP_script_parse_line_post; int HP_script_read_constdb_pre; int HP_script_read_constdb_post; + int HP_script_constdb_comment_pre; + int HP_script_constdb_comment_post; int HP_script_print_line_pre; int HP_script_print_line_post; int HP_script_errorwarning_sub_pre; diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc index 5bbad878a..f7ee233c3 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc @@ -944,6 +944,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(clif->add_random_options, HP_clif_add_random_options) }, { HP_POP(clif->pHotkeyRowShift, HP_clif_pHotkeyRowShift) }, { HP_POP(clif->dressroom_open, HP_clif_dressroom_open) }, + { HP_POP(clif->pOneClick_ItemIdentify, HP_clif_pOneClick_ItemIdentify) }, { HP_POP(clif->selectcart, HP_clif_selectcart) }, { HP_POP(clif->pSelectCart, HP_clif_pSelectCart) }, /* cmdline */ @@ -2211,6 +2212,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(pc->autotrade_final, HP_pc_autotrade_final) }, { HP_POP(pc->check_job_name, HP_pc_check_job_name) }, { HP_POP(pc->update_idle_time, HP_pc_update_idle_time) }, + { HP_POP(pc->have_magnifier, HP_pc_have_magnifier) }, /* libpcre */ { HP_POP(libpcre->compile, HP_libpcre_compile) }, { HP_POP(libpcre->study, HP_libpcre_study) }, @@ -2366,6 +2368,7 @@ struct HookingPointData HookingPoints[] = { { HP_POP(script->parse_expr, HP_script_parse_expr) }, { HP_POP(script->parse_line, HP_script_parse_line) }, { HP_POP(script->read_constdb, HP_script_read_constdb) }, + { HP_POP(script->constdb_comment, HP_script_constdb_comment) }, { HP_POP(script->print_line, HP_script_print_line) }, { HP_POP(script->errorwarning_sub, HP_script_errorwarning_sub) }, { HP_POP(script->set_reg, HP_script_set_reg) }, diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index 87d85cc6c..5dfdb8c2a 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -24067,6 +24067,32 @@ void HP_clif_dressroom_open(struct map_session_data *sd, int view) { } return; } +void HP_clif_pOneClick_ItemIdentify(int fd, struct map_session_data *sd) { + int hIndex = 0; + if( HPMHooks.count.HP_clif_pOneClick_ItemIdentify_pre ) { + void (*preHookFunc) (int *fd, struct map_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pOneClick_ItemIdentify_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_clif_pOneClick_ItemIdentify_pre[hIndex].func; + preHookFunc(&fd, sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.clif.pOneClick_ItemIdentify(fd, sd); + } + if( HPMHooks.count.HP_clif_pOneClick_ItemIdentify_post ) { + void (*postHookFunc) (int *fd, struct map_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_pOneClick_ItemIdentify_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_clif_pOneClick_ItemIdentify_post[hIndex].func; + postHookFunc(&fd, sd); + } + } + return; +} void HP_clif_selectcart(struct map_session_data *sd) { int hIndex = 0; if( HPMHooks.count.HP_clif_selectcart_pre ) { @@ -57623,6 +57649,33 @@ void HP_pc_update_idle_time(struct map_session_data *sd, enum e_battle_config_id } return; } +int HP_pc_have_magnifier(struct map_session_data *sd) { + int hIndex = 0; + int retVal___ = 0; + if( HPMHooks.count.HP_pc_have_magnifier_pre ) { + int (*preHookFunc) (struct map_session_data *sd); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_have_magnifier_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_pc_have_magnifier_pre[hIndex].func; + retVal___ = preHookFunc(sd); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return retVal___; + } + } + { + retVal___ = HPMHooks.source.pc.have_magnifier(sd); + } + if( HPMHooks.count.HP_pc_have_magnifier_post ) { + int (*postHookFunc) (int retVal___, struct map_session_data *sd); + for(hIndex = 0; hIndex < HPMHooks.count.HP_pc_have_magnifier_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_pc_have_magnifier_post[hIndex].func; + retVal___ = postHookFunc(retVal___, sd); + } + } + return retVal___; +} /* libpcre */ pcre* HP_libpcre_compile(const char *pattern, int options, const char **errptr, int *erroffset, const unsigned char *tableptr) { int hIndex = 0; @@ -61678,6 +61731,32 @@ void HP_script_read_constdb(void) { } return; } +void HP_script_constdb_comment(const char *comment) { + int hIndex = 0; + if( HPMHooks.count.HP_script_constdb_comment_pre ) { + void (*preHookFunc) (const char *comment); + *HPMforce_return = false; + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_constdb_comment_pre; hIndex++ ) { + preHookFunc = HPMHooks.list.HP_script_constdb_comment_pre[hIndex].func; + preHookFunc(comment); + } + if( *HPMforce_return ) { + *HPMforce_return = false; + return; + } + } + { + HPMHooks.source.script.constdb_comment(comment); + } + if( HPMHooks.count.HP_script_constdb_comment_post ) { + void (*postHookFunc) (const char *comment); + for(hIndex = 0; hIndex < HPMHooks.count.HP_script_constdb_comment_post; hIndex++ ) { + postHookFunc = HPMHooks.list.HP_script_constdb_comment_post[hIndex].func; + postHookFunc(comment); + } + } + return; +} const char* HP_script_print_line(StringBuf *buf, const char *p, const char *mark, int line) { int hIndex = 0; const char* retVal___ = NULL; diff --git a/src/plugins/constdb2doc.c b/src/plugins/constdb2doc.c new file mode 100644 index 000000000..1d5f37ad5 --- /dev/null +++ b/src/plugins/constdb2doc.c @@ -0,0 +1,197 @@ +/** + * This file is part of Hercules. + * http://herc.ws - http://github.com/HerculesWS/Hercules + * + * Copyright (C) 2016 Hercules Dev Team + * Copyright (C) 2016 Haru <haru@dotalux.com> + * + * Hercules is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/// db/constants.conf -> doc/constants.md generator plugin + +#include "common/hercules.h" +//#include "common/memmgr.h" +#include "common/nullpo.h" +#include "common/strlib.h" +#include "map/itemdb.h" +#include "map/mob.h" +#include "map/script.h" +#include "map/skill.h" + +#include "common/HPMDataCheck.h" + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <sys/stat.h> + +#define OUTPUTFILENAME "doc" PATHSEP_STR "constants.md" + +HPExport struct hplugin_info pinfo = { + "constdb2doc", // Plugin name + SERVER_TYPE_MAP, // Which server types this plugin works with? + "0.1", // Plugin version + HPM_VERSION, // HPM Version (don't change, macro is automatically updated) +}; + +FILE *out_fp; +bool torun = false; + +/// To override script_constdb_comment +void constdb2doc_constdb_comment(const char *comment) +{ + nullpo_retv(out_fp); + if (comment == NULL) + fprintf(out_fp, "\n"); + else + fprintf(out_fp, "\n### %s\n\n", comment); +} + +/// To override script_set_constant, called by script_read_constdb +void constdb2doc_script_set_constant(const char *name, int value, bool is_parameter, bool is_deprecated) +{ + nullpo_retv(out_fp); + + if (is_parameter) + fprintf(out_fp, "- `%s`: [param]%s\n", name, is_deprecated ? " **(DEPRECATED)**" : ""); + else + fprintf(out_fp, "- `%s`: %d%s\n", name, value, is_deprecated ? " **(DEPRECATED)**" : ""); +} + +void constdb2doc_constdb(void) +{ + void (*script_set_constant) (const char* name, int value, bool is_parameter, bool is_deprecated) = NULL; + void (*script_constdb_comment) (const char *comment) = NULL; + + nullpo_retv(out_fp); + + /* Link */ + script_set_constant = script->set_constant; + script->set_constant = constdb2doc_script_set_constant; + script_constdb_comment = script->constdb_comment; + script->constdb_comment = constdb2doc_constdb_comment; + + /* Run */ + fprintf(out_fp, "## Constants (db/constants.conf)\n\n"); + script->read_constdb(); + fprintf(out_fp, "\n"); + + fprintf(out_fp, "## Hardcoded Constants (source)\n\n"); + script->hardcoded_constants(); + fprintf(out_fp, "\n"); + + /* Unlink */ + script->set_constant = script_set_constant; + script->constdb_comment = script_constdb_comment; +} + +void constdb2doc_skilldb(void) +{ + int i; + + nullpo_retv(out_fp); + + fprintf(out_fp, "## Skills (db/"DBPATH"skill_db.txt)\n\n"); + for (i = 1; i < MAX_SKILL_DB; i++) { + if (skill->dbs->db[i].name[0] != '\0') + fprintf(out_fp, "- `%s`: %d\n", skill->dbs->db[i].name, skill->dbs->db[i].nameid); + } + fprintf(out_fp, "\n"); +} + +void constdb2doc_mobdb(void) +{ + int i; + + nullpo_retv(out_fp); + + fprintf(out_fp, "## Mobs (db/"DBPATH"mob_db.txt)\n\n"); + for (i = 0; i < MAX_MOB_DB; i++) { + struct mob_db *md = mob->db(i); + if (md == mob->dummy || md->sprite[0] == '\0') + continue; + fprintf(out_fp, "- `%s`: %d\n", md->sprite, i); + } + fprintf(out_fp, "\n"); +} + +/// Cloned from itemdb_search +struct item_data *constdb2doc_itemdb_search(int nameid) +{ + if (nameid >= 0 && nameid < ARRAYLENGTH(itemdb->array)) + return itemdb->array[nameid]; + + return idb_get(itemdb->other, nameid); +} + +void constdb2doc_itemdb(void) +{ + int i; + + nullpo_retv(out_fp); + + fprintf(out_fp, "## Items (db/"DBPATH"item_db.conf)\n"); + for (i = 0; i < ARRAYLENGTH(itemdb->array); i++) { + struct item_data *id = constdb2doc_itemdb_search(i); + if (id == NULL || id->name[0] == '\0') + continue; + fprintf(out_fp, "- `%s`: %d\n", id->name, id->nameid); + } + fprintf(out_fp, "\n"); +} + +void do_constdb2doc(void) +{ + /* File Type Detector */ + if ((out_fp = fopen(OUTPUTFILENAME, "wt+")) == NULL) { + ShowError("do_constdb2doc: Unable to open output file.\n"); + return; + } + + fprintf(out_fp, + "# Constants\n\n" + "> This document contains all the constants available to the script engine.\n\n"); + + constdb2doc_constdb(); + + constdb2doc_skilldb(); + + constdb2doc_mobdb(); + + constdb2doc_itemdb(); + + fprintf(out_fp, "> End of list\n"); + + fclose(out_fp); +} +CPCMD(constdb2doc) { + do_constdb2doc(); +} +CMDLINEARG(constdb2doc) +{ + map->minimal = torun = true; + return true; +} +HPExport void server_preinit(void) { + addArg("--constdb2doc", false, constdb2doc, NULL); +} +HPExport void plugin_init(void) { + addCPCommand("server:tools:constdb2doc", constdb2doc); +} +HPExport void server_online(void) { + if (torun) + do_constdb2doc(); +} |