summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/mmo.h1
-rw-r--r--src/map/atcommand.c8
-rw-r--r--src/map/clif.c18
-rw-r--r--src/map/clif.h6
-rw-r--r--src/map/status.c3
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc4
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc1
-rw-r--r--src/plugins/HPMHooking/HPMHooking_map.Hooks.inc27
8 files changed, 57 insertions, 11 deletions
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 75b62fdc4..012eec935 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -299,6 +299,7 @@ enum e_mmo_charstatus_opt {
};
enum e_item_bound_type {
+ IBT_NONE = 0x0,
IBT_MIN = 0x1,
IBT_ACCOUNT = 0x1,
IBT_GUILD = 0x2,
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 37f50dc5e..15422a74a 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -242,16 +242,16 @@ ACMD(send)
}\
} while(0) //define GET_VALUE
- if (type > 0 && type < MAX_PACKET_DB) {
+ if (type >= MIN_PACKET_DB && type <= MAX_PACKET_DB) {
int off = 2;
if (len) {
// show packet length
- safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, packet_db[type].len); // Packet 0x%x length: %d
+ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,904), type, clif->packet(type)->len); // Packet 0x%x length: %d
clif->message(fd, atcmd_output);
return true;
}
- len=packet_db[type].len;
+ len = clif->packet(type)->len;
if (len == 0) {
// unknown packet - ERROR
safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,905), type); // Unknown packet: 0x%x
@@ -402,7 +402,7 @@ ACMD(send)
SKIP_VALUE(message);
}
- if(packet_db[type].len == -1) {// send dynamic packet
+ if (clif->packet(type)->len == -1) { // send dynamic packet
WFIFOW(sd->fd,2)=TOW(off);
WFIFOSET(sd->fd,off);
} else {// send static packet
diff --git a/src/map/clif.c b/src/map/clif.c
index 0d25be0a6..59c8a7197 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -18362,7 +18362,7 @@ void clif_openmergeitem(int fd, struct map_session_data *sd)
for (i = 0; i < MAX_INVENTORY; i++) {
struct item *item_data = &sd->status.inventory[i];
- if (item_data->nameid == 0 || !itemdb->isstackable(item_data->nameid))
+ if (item_data->nameid == 0 || !itemdb->isstackable(item_data->nameid) || item_data->bound != IBT_NONE)
continue;
merge_items[n].nameid = item_data->nameid;
@@ -18436,7 +18436,7 @@ void clif_ackmergeitems(int fd, struct map_session_data *sd)
it = &sd->status.inventory[idx];
- if (it->nameid == 0 || !itemdb->isstackable(it->nameid))
+ if (it->nameid == 0 || !itemdb->isstackable(it->nameid) || it->bound != IBT_NONE)
continue;
if (nameid == 0)
@@ -18680,6 +18680,19 @@ int clif_parse(int fd) {
return 0;
}
+/**
+ * Returns information about the given packet ID.
+ *
+ * @param packet_id The packet ID.
+ * @return The corresponding packet_db entry, if any.
+ */
+const struct s_packet_db *clif_packet(int packet_id)
+{
+ if (packet_id < MIN_PACKET_DB || packet_id > MAX_PACKET_DB || packet_db[packet_id].len == 0)
+ return NULL;
+ return &packet_db[packet_id];
+}
+
static void __attribute__ ((unused)) packetdb_addpacket(short cmd, int len, ...) {
va_list va;
int i;
@@ -18815,6 +18828,7 @@ void clif_defaults(void) {
clif->parse = clif_parse;
clif->parse_cmd = clif_parse_cmd_optional;
clif->decrypt_cmd = clif_decrypt_cmd;
+ clif->packet = clif_packet;
/* auth */
clif->authok = clif_authok;
clif->authrefuse = clif_authrefuse;
diff --git a/src/map/clif.h b/src/map/clif.h
index f6f0d4fe7..40610b7c1 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -597,6 +597,7 @@ struct clif_interface {
int (*send_sub) (struct block_list *bl, va_list ap);
int (*send_actual) (int fd, void *buf, int len);
int (*parse) (int fd);
+ const struct s_packet_db *(*packet) (int packet_id);
unsigned short (*parse_cmd) ( int fd, struct map_session_data *sd );
unsigned short (*decrypt_cmd) ( int cmd, struct map_session_data *sd );
/* auth */
@@ -1323,11 +1324,6 @@ struct clif_interface {
};
#ifdef HERCULES_CORE
-/**
- * Vars
- **/
-extern struct s_packet_db packet_db[MAX_PACKET_DB + 1];
-
void clif_defaults(void);
#endif // HERCULES_CORE
diff --git a/src/map/status.c b/src/map/status.c
index 3ba80e531..c815eeaff 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -8960,6 +8960,9 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t
{
int hp = status_get_hp(bl), sp = status_get_sp(bl), lv = 5;
+ if (sp < 1) sp = 1;
+ if (hp < 1) hp = 1;
+
if( rnd()%100 > (25 + 10 * val1) - status_get_int(bl) / 2)
return 0;
diff --git a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
index 68c4ecb3c..bb0f05cff 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HPMHooksCore.inc
@@ -497,6 +497,8 @@ struct {
struct HPMHookPoint *HP_clif_send_actual_post;
struct HPMHookPoint *HP_clif_parse_pre;
struct HPMHookPoint *HP_clif_parse_post;
+ struct HPMHookPoint *HP_clif_packet_pre;
+ struct HPMHookPoint *HP_clif_packet_post;
struct HPMHookPoint *HP_clif_parse_cmd_pre;
struct HPMHookPoint *HP_clif_parse_cmd_post;
struct HPMHookPoint *HP_clif_decrypt_cmd_pre;
@@ -6252,6 +6254,8 @@ struct {
int HP_clif_send_actual_post;
int HP_clif_parse_pre;
int HP_clif_parse_post;
+ int HP_clif_packet_pre;
+ int HP_clif_packet_post;
int HP_clif_parse_cmd_pre;
int HP_clif_parse_cmd_post;
int HP_clif_decrypt_cmd_pre;
diff --git a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
index bc023d3f3..a73e70c33 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.HookingPoints.inc
@@ -260,6 +260,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(clif->send_sub, HP_clif_send_sub) },
{ HP_POP(clif->send_actual, HP_clif_send_actual) },
{ HP_POP(clif->parse, HP_clif_parse) },
+ { HP_POP(clif->packet, HP_clif_packet) },
{ HP_POP(clif->parse_cmd, HP_clif_parse_cmd) },
{ HP_POP(clif->decrypt_cmd, HP_clif_decrypt_cmd) },
{ HP_POP(clif->authok, HP_clif_authok) },
diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
index d5c6b40c6..cd88ee6bd 100644
--- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc
@@ -6672,6 +6672,33 @@ int HP_clif_parse(int fd) {
}
return retVal___;
}
+const struct s_packet_db* HP_clif_packet(int packet_id) {
+ int hIndex = 0;
+ const struct s_packet_db* retVal___ = NULL;
+ if( HPMHooks.count.HP_clif_packet_pre ) {
+ const struct s_packet_db* (*preHookFunc) (int *packet_id);
+ *HPMforce_return = false;
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_packet_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_clif_packet_pre[hIndex].func;
+ retVal___ = preHookFunc(&packet_id);
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.clif.packet(packet_id);
+ }
+ if( HPMHooks.count.HP_clif_packet_post ) {
+ const struct s_packet_db* (*postHookFunc) (const struct s_packet_db* retVal___, int *packet_id);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_clif_packet_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_clif_packet_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___, &packet_id);
+ }
+ }
+ return retVal___;
+}
unsigned short HP_clif_parse_cmd(int fd, struct map_session_data *sd) {
int hIndex = 0;
unsigned short retVal___ = 0;