summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-10-19 16:22:46 -0300
committershennetsind <ind@henn.et>2013-10-19 16:22:46 -0300
commitd02f9afab959909398e8ebff6ab50186084c68c5 (patch)
tree248df5dd7cdd816884abcfde30b64181f6488b6c /src
parent93f61040ac281b84c038af72e322a03f60bc6e03 (diff)
parent448dce82b996930e361038dd5c94dd94a6deffe7 (diff)
downloadhercules-d02f9afab959909398e8ebff6ab50186084c68c5.tar.gz
hercules-d02f9afab959909398e8ebff6ab50186084c68c5.tar.bz2
hercules-d02f9afab959909398e8ebff6ab50186084c68c5.tar.xz
hercules-d02f9afab959909398e8ebff6ab50186084c68c5.zip
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Diffstat (limited to 'src')
-rw-r--r--src/map/clif.c83
-rw-r--r--src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc4
-rw-r--r--src/plugins/HPMHooking/HPMHooking.HookingPoints.inc1
-rw-r--r--src/plugins/HPMHooking/HPMHooking.Hooks.inc26
4 files changed, 67 insertions, 47 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 060509807..82eb01ca9 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -17247,9 +17247,9 @@ void clif_parse_MoveItem(int fd, struct map_session_data *sd) {
/* [Ind/Hercules] */
void clif_cashshop_db(void) {
config_t cashshop_conf;
- config_setting_t *cashshop = NULL;
+ config_setting_t *cashshop = NULL, *cats = NULL;
const char *config_filename = "db/cashshop_db.conf"; // FIXME hardcoded name
- int i;
+ int i, item_count_t = 0;
for( i = 0; i < CASHSHOP_TAB_MAX; i++ ) {
CREATE(clif->cs.data[i], struct hCSData *, 1);
clif->cs.item_count[i] = 0;
@@ -17262,67 +17262,53 @@ void clif_cashshop_db(void) {
cashshop = config_lookup(&cashshop_conf, "cash_shop");
- if (cashshop != NULL) {
- config_setting_t *cats = config_setting_get_elem(cashshop, 0);
- config_setting_t *cat;
- int k, item_count_t = 0;
-
+ if( cashshop != NULL && (cats = config_setting_get_elem(cashshop, 0)) != NULL ) {
for(i = 0; i < CASHSHOP_TAB_MAX; i++) {
+ config_setting_t *cat;
char entry_name[10];
sprintf(entry_name,"cat_%d",i);
if( (cat = config_setting_get_member(cats, entry_name)) != NULL ) {
- int item_count = config_setting_length(cat);
+ int k, item_count = config_setting_length(cat);
- if( item_count == 0 ) {
- ShowWarning("cashshop_db: category '%s' is empty! adding dull apple!\n", entry_name);
- RECREATE(clif->cs.data[i], struct hCSData *, ++clif->cs.item_count[i]);
- CREATE(clif->cs.data[i][ clif->cs.item_count[i] - 1 ], struct hCSData , 1);
-
- clif->cs.data[i][ clif->cs.item_count[i] - 1 ]->id = UNKNOWN_ITEM_ID;
- clif->cs.data[i][ clif->cs.item_count[i] - 1 ]->price = 999;
- } else {
- for(k = 0; k < item_count; k++) {
- config_setting_t *entry = config_setting_get_elem(cat,k);
- const char *name = config_setting_name(entry);
- int price = config_setting_get_int(entry);
- struct item_data * data = NULL;
-
- if( price < 1 ) {
- ShowWarning("cashshop_db: unsupported price '%d' for entry named '%s' in category '%s'\n", price, name, entry_name);
+ for(k = 0; k < item_count; k++) {
+ config_setting_t *entry = config_setting_get_elem(cat,k);
+ const char *name = config_setting_name(entry);
+ int price = config_setting_get_int(entry);
+ struct item_data * data = NULL;
+
+ if( price < 1 ) {
+ ShowWarning("cashshop_db: unsupported price '%d' for entry named '%s' in category '%s'\n", price, name, entry_name);
+ continue;
+ }
+
+ if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
+ if( !( data = itemdb->exists(atoi(name+2))) ) {
+ ShowWarning("cashshop_db: unknown item id '%s' in category '%s'\n", name+2, entry_name);
continue;
}
-
- if( name[0] == 'I' && name[1] == 'D' && strlen(name) <= 7 ) {
- if( !( data = itemdb->exists(atoi(name+2))) ) {
- ShowWarning("cashshop_db: unknown item id '%s' in category '%s'\n", name+2, entry_name);
- continue;
- }
- } else {
- if( !( data = itemdb->search_name(name) ) ) {
- ShowWarning("cashshop_db: unknown item name '%s' in category '%s'\n", name, entry_name);
- continue;
- }
+ } else {
+ if( !( data = itemdb->search_name(name) ) ) {
+ ShowWarning("cashshop_db: unknown item name '%s' in category '%s'\n", name, entry_name);
+ continue;
}
-
-
- RECREATE(clif->cs.data[i], struct hCSData *, ++clif->cs.item_count[i]);
- CREATE(clif->cs.data[i][ clif->cs.item_count[i] - 1 ], struct hCSData , 1);
-
- clif->cs.data[i][ clif->cs.item_count[i] - 1 ]->id = data->nameid;
- clif->cs.data[i][ clif->cs.item_count[i] - 1 ]->price = price;
- item_count_t++;
}
+
+
+ RECREATE(clif->cs.data[i], struct hCSData *, ++clif->cs.item_count[i]);
+ CREATE(clif->cs.data[i][ clif->cs.item_count[i] - 1 ], struct hCSData , 1);
+
+ clif->cs.data[i][ clif->cs.item_count[i] - 1 ]->id = data->nameid;
+ clif->cs.data[i][ clif->cs.item_count[i] - 1 ]->price = price;
+ item_count_t++;
}
- } else {
- ShowError("cashshop_db: category '%s' (%d) not found!!\n",entry_name,i);
}
}
- ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", item_count_t, config_filename);
config_destroy(&cashshop_conf);
}
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", item_count_t, config_filename);
}
/// Items that are in favorite tab of inventory (ZC_ITEM_FAVORITE).
/// 0900 <index>.W <favorite>.B
@@ -17377,6 +17363,9 @@ void clif_parse_CashShopSchedule(int fd, struct map_session_data *sd) {
int i, j = 0;
for( i = 0; i < CASHSHOP_TAB_MAX; i++ ) {
+ if( clif->cs.item_count[i] == 0 )
+ continue; // Skip empty tabs, the client only expects filled ones
+
WFIFOHEAD(fd, 8 + ( clif->cs.item_count[i] * 6 ) );
WFIFOW(fd, 0) = 0x8ca;
WFIFOW(fd, 2) = 8 + ( clif->cs.item_count[i] * 6 );
@@ -17478,7 +17467,7 @@ void clif_parse_CashShopReqTab(int fd, struct map_session_data *sd) {
short tab = RFIFOW(fd, 2);
int j;
- if( tab < 0 || tab > CASHSHOP_TAB_MAX )
+ if( tab < 0 || tab > CASHSHOP_TAB_MAX || clif->cs.item_count[tab] == 0 )
return;
WFIFOHEAD(fd, 10 + ( clif->cs.item_count[tab] * 6 ) );
diff --git a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc
index 03534821e..6fbb45016 100644
--- a/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc
+++ b/src/plugins/HPMHooking/HPMHooking.HPMHooksCore.inc
@@ -2847,6 +2847,8 @@ struct {
struct HPMHookPoint *HP_map_addblcell_post;
struct HPMHookPoint *HP_map_delblcell_pre;
struct HPMHookPoint *HP_map_delblcell_post;
+ struct HPMHookPoint *HP_map_get_new_bonus_id_pre;
+ struct HPMHookPoint *HP_map_get_new_bonus_id_post;
struct HPMHookPoint *HP_mapit_alloc_pre;
struct HPMHookPoint *HP_mapit_alloc_post;
struct HPMHookPoint *HP_mapit_free_pre;
@@ -7726,6 +7728,8 @@ struct {
int HP_map_addblcell_post;
int HP_map_delblcell_pre;
int HP_map_delblcell_post;
+ int HP_map_get_new_bonus_id_pre;
+ int HP_map_get_new_bonus_id_post;
int HP_mapit_alloc_pre;
int HP_mapit_alloc_post;
int HP_mapit_free_pre;
diff --git a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc
index dcd283641..6ca0002f4 100644
--- a/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc
+++ b/src/plugins/HPMHooking/HPMHooking.HookingPoints.inc
@@ -1445,6 +1445,7 @@ struct HookingPointData HookingPoints[] = {
{ HP_POP(map->arg_next_value, HP_map_arg_next_value) },
{ HP_POP(map->addblcell, HP_map_addblcell) },
{ HP_POP(map->delblcell, HP_map_delblcell) },
+ { HP_POP(map->get_new_bonus_id, HP_map_get_new_bonus_id) },
/* mapit */
{ HP_POP(mapit->alloc, HP_mapit_alloc) },
{ HP_POP(mapit->free, HP_mapit_free) },
diff --git a/src/plugins/HPMHooking/HPMHooking.Hooks.inc b/src/plugins/HPMHooking/HPMHooking.Hooks.inc
index 3d045ece6..9a34af7b4 100644
--- a/src/plugins/HPMHooking/HPMHooking.Hooks.inc
+++ b/src/plugins/HPMHooking/HPMHooking.Hooks.inc
@@ -36471,6 +36471,32 @@ void HP_map_delblcell(struct block_list *bl) {
}
return;
}
+int HP_map_get_new_bonus_id(void) {
+ int hIndex = 0;
+ int retVal___ = 0;
+ if( HPMHooks.count.HP_map_get_new_bonus_id_pre ) {
+ int (*preHookFunc) (void);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_map_get_new_bonus_id_pre; hIndex++ ) {
+ preHookFunc = HPMHooks.list.HP_map_get_new_bonus_id_pre[hIndex].func;
+ retVal___ = preHookFunc();
+ }
+ if( *HPMforce_return ) {
+ *HPMforce_return = false;
+ return retVal___;
+ }
+ }
+ {
+ retVal___ = HPMHooks.source.map.get_new_bonus_id();
+ }
+ if( HPMHooks.count.HP_map_get_new_bonus_id_post ) {
+ int (*postHookFunc) (int retVal___);
+ for(hIndex = 0; hIndex < HPMHooks.count.HP_map_get_new_bonus_id_post; hIndex++ ) {
+ postHookFunc = HPMHooks.list.HP_map_get_new_bonus_id_post[hIndex].func;
+ retVal___ = postHookFunc(retVal___);
+ }
+ }
+ return retVal___;
+}
/* mapit */
struct s_mapiterator* HP_mapit_alloc(enum e_mapitflags flags, enum bl_type types) {
int hIndex = 0;