summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-09-09 17:50:58 -0300
committershennetsind <ind@henn.et>2013-09-09 17:50:58 -0300
commit24ced6fcef1a95a2abd0c60b4fe90cbbc3aea268 (patch)
treef8c81547351c116b141910e49433311a6dbf876f /src
parentae850bdefd7d9ecfecdb20d6e5803896fad00dfd (diff)
downloadhercules-24ced6fcef1a95a2abd0c60b4fe90cbbc3aea268.tar.gz
hercules-24ced6fcef1a95a2abd0c60b4fe90cbbc3aea268.tar.bz2
hercules-24ced6fcef1a95a2abd0c60b4fe90cbbc3aea268.tar.xz
hercules-24ced6fcef1a95a2abd0c60b4fe90cbbc3aea268.zip
Fixed Bug #7631
having an empty category in the cash shop would lead to the item list duplicating itself on every map change (client fault), added a warning when parsing the file with a empty category, and the creation of a dummy apple to that category (priced at 999). Special Thanks to Tepoo for all the information. http://hercules.ws/board/tracker/issue-7631-cashshop-itemslist-increases-by-every-warpmapchange/ Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src')
-rw-r--r--src/map/clif.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 218e088f1..4ad4f266b 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -17165,36 +17165,45 @@ void clif_cashshop_db(void) {
if( (cat = config_setting_get_member(cats, entry_name)) != NULL ) {
int item_count = config_setting_length(cat);
- 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( 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);
- 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);
+ clif->cs.data[i][ clif->cs.item_count[i] - 1 ]->id = 512;
+ 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);
continue;
}
- } else {
- if( !( data = itemdb->search_name(name) ) ) {
- ShowWarning("cashshop_db: unknown item name '%s' in category '%s'\n", 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;
+ }
+ } 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);