summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2015-01-24 13:13:30 -0200
committershennetsind <ind@henn.et>2015-01-24 13:13:30 -0200
commit1f40b88a9b27f1437d2d8b2f4c5dcb56a1e477db (patch)
treec42ecbcccc60f0bab2a72d5a2ae40a37bc7b5630 /src/map
parent6f3a82487fdffabf221a9a2dfc5ace027c333f95 (diff)
downloadhercules-1f40b88a9b27f1437d2d8b2f4c5dcb56a1e477db.tar.gz
hercules-1f40b88a9b27f1437d2d8b2f4c5dcb56a1e477db.tar.bz2
hercules-1f40b88a9b27f1437d2d8b2f4c5dcb56a1e477db.tar.xz
hercules-1f40b88a9b27f1437d2d8b2f4c5dcb56a1e477db.zip
Fixed Bug 8395
Adjusted zone merging logic to not merge items the main zone originally intended to enable (i.e. normal zone disables Velum_Jamadhar, gvg zone sets Velum_Jamadhar: false) Special Thanks to Ancyker, Michieru http://hercules.ws/board/tracker/issue-8395-map-zone-db-stacking-incorrectly-siege-gears-not-working/ Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/map.c134
-rw-r--r--src/map/map.h3
2 files changed, 80 insertions, 57 deletions
diff --git a/src/map/map.c b/src/map/map.c
index 1f893269b..745814f78 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -3073,70 +3073,66 @@ int map_delmap(char* mapname) {
}
return 0;
}
-void map_zone_db_clear(void) {
- struct map_zone_data *zone;
- int i;
- DBIterator *iter = db_iterator(map->zone_db);
- for(zone = dbi_first(iter); dbi_exists(iter); zone = dbi_next(iter)) {
- for(i = 0; i < zone->disabled_skills_count; i++) {
- aFree(zone->disabled_skills[i]);
- }
+/**
+ *
+ **/
+void map_zone_clear_single(struct map_zone_data *zone) {
+ int i;
+
+ for(i = 0; i < zone->disabled_skills_count; i++) {
+ aFree(zone->disabled_skills[i]);
+ }
+
+ if( zone->disabled_skills )
aFree(zone->disabled_skills);
+
+ if( zone->disabled_items )
aFree(zone->disabled_items);
- for(i = 0; i < zone->mapflags_count; i++) {
- aFree(zone->mapflags[i]);
- }
+
+ if( zone->cant_disable_items )
+ aFree(zone->cant_disable_items);
+
+ for(i = 0; i < zone->mapflags_count; i++) {
+ aFree(zone->mapflags[i]);
+ }
+
+ if( zone->mapflags )
aFree(zone->mapflags);
- for(i = 0; i < zone->disabled_commands_count; i++) {
- aFree(zone->disabled_commands[i]);
- }
+
+ for(i = 0; i < zone->disabled_commands_count; i++) {
+ aFree(zone->disabled_commands[i]);
+ }
+
+ if( zone->disabled_commands )
aFree(zone->disabled_commands);
- for(i = 0; i < zone->capped_skills_count; i++) {
- aFree(zone->capped_skills[i]);
- }
+
+ for(i = 0; i < zone->capped_skills_count; i++) {
+ aFree(zone->capped_skills[i]);
+ }
+
+ if( zone->capped_skills )
aFree(zone->capped_skills);
+}
+/**
+ *
+ **/
+void map_zone_db_clear(void) {
+ struct map_zone_data *zone;
+ DBIterator *iter = db_iterator(map->zone_db);
+
+ for(zone = dbi_first(iter); dbi_exists(iter); zone = dbi_next(iter)) {
+ map->zone_clear_single(zone);
}
+
dbi_destroy(iter);
db_destroy(map->zone_db);/* will aFree(zone) */
/* clear the pk zone stuff */
- for(i = 0; i < map->zone_pk.disabled_skills_count; i++) {
- aFree(map->zone_pk.disabled_skills[i]);
- }
- aFree(map->zone_pk.disabled_skills);
- aFree(map->zone_pk.disabled_items);
- for(i = 0; i < map->zone_pk.mapflags_count; i++) {
- aFree(map->zone_pk.mapflags[i]);
- }
- aFree(map->zone_pk.mapflags);
- for(i = 0; i < map->zone_pk.disabled_commands_count; i++) {
- aFree(map->zone_pk.disabled_commands[i]);
- }
- aFree(map->zone_pk.disabled_commands);
- for(i = 0; i < map->zone_pk.capped_skills_count; i++) {
- aFree(map->zone_pk.capped_skills[i]);
- }
- aFree(map->zone_pk.capped_skills);
+ map->zone_clear_single(&map->zone_pk);
/* clear the main zone stuff */
- for(i = 0; i < map->zone_all.disabled_skills_count; i++) {
- aFree(map->zone_all.disabled_skills[i]);
- }
- aFree(map->zone_all.disabled_skills);
- aFree(map->zone_all.disabled_items);
- for(i = 0; i < map->zone_all.mapflags_count; i++) {
- aFree(map->zone_all.mapflags[i]);
- }
- aFree(map->zone_all.mapflags);
- for(i = 0; i < map->zone_all.disabled_commands_count; i++) {
- aFree(map->zone_all.disabled_commands[i]);
- }
- aFree(map->zone_all.disabled_commands);
- for(i = 0; i < map->zone_all.capped_skills_count; i++) {
- aFree(map->zone_all.capped_skills[i]);
- }
- aFree(map->zone_all.capped_skills);
+ map->zone_clear_single(&map->zone_all);
}
void map_clean(int i) {
int v;
@@ -3832,7 +3828,7 @@ int map_sql_close(void)
struct map_zone_data *map_merge_zone(struct map_zone_data *main, struct map_zone_data *other) {
char newzone[MAP_ZONE_NAME_LENGTH];
struct map_zone_data *zone = NULL;
- int cursor, i;
+ int cursor, i, j;
sprintf(newzone, "%s+%s",main->name,other->name);
@@ -3861,14 +3857,31 @@ struct map_zone_data *map_merge_zone(struct map_zone_data *main, struct map_zone
memcpy(zone->disabled_skills[cursor], other->disabled_skills[i], sizeof(struct map_zone_disabled_skill_entry));
}
+ for(j = 0; j < main->cant_disable_items_count; j++) {
+ for(i = 0; i < other->disabled_items_count; i++) {
+ if( other->disabled_items[i] == main->cant_disable_items[j] ) {
+ zone->disabled_items_count--;
+ break;
+ }
+ }
+ }
+
CREATE(zone->disabled_items, int, zone->disabled_items_count );
for(i = 0, cursor = 0; i < main->disabled_items_count; i++, cursor++ ) {
zone->disabled_items[cursor] = main->disabled_items[i];
}
- for(i = 0; i < other->disabled_items_count; i++, cursor++ ) {
+ for(i = 0; i < other->disabled_items_count; i++) {
+ for(j = 0; j < main->cant_disable_items_count; j++) {
+ if( other->disabled_items[i] == main->cant_disable_items[j] ) {
+ break;
+ }
+ }
+ if( j != main->cant_disable_items_count )
+ continue;
zone->disabled_items[cursor] = other->disabled_items[i];
+ cursor++;
}
CREATE(zone->mapflags, char *, zone->mapflags_count );
@@ -4847,7 +4860,7 @@ void read_map_zone_db(void) {
config_setting_t *caps;
const char *name;
const char *zonename;
- int i,h,v;
+ int i,h,v,j;
int zone_count = 0, disabled_skills_count = 0, disabled_items_count = 0, mapflags_count = 0,
disabled_commands_count = 0, capped_skills_count = 0;
enum map_zone_skill_subtype subtype;
@@ -4945,12 +4958,19 @@ void read_map_zone_db(void) {
}
/* all ok, process */
CREATE( zone->disabled_items, int, disabled_items_count );
- for(h = 0, v = 0; h < libconfig->setting_length(items); h++) {
+ if( (libconfig->setting_length(items) - disabled_items_count) > 0 ) { //Some are forcefully enabled
+ zone->cant_disable_items_count = libconfig->setting_length(items) - disabled_items_count;
+ CREATE(zone->cant_disable_items, int, zone->cant_disable_items_count);
+
+ }
+ for(h = 0, v = 0, j = 0; h < libconfig->setting_length(items); h++) {
config_setting_t *item = libconfig->setting_get_elem(items, h);
+ name = config_setting_name(item);
if( libconfig->setting_get_bool(item) ) { /* only add if enabled */
- name = config_setting_name(item);
zone->disabled_items[v++] = map->zone_str2itemid(name);
+ } else { /** forcefully enabled **/
+ zone->cant_disable_items[j++] = map->zone_str2itemid(name);
}
}
@@ -5081,7 +5101,6 @@ void read_map_zone_db(void) {
int mapflags_count_i = 0; /* mapflag count from inherit zone */
int disabled_commands_count_i = 0; /* commands count from inherit zone */
int capped_skills_count_i = 0; /* skill capped count from inherit zone */
- int j;
name = libconfig->setting_get_string_elem(inherit_tree, h);
libconfig->setting_lookup_string(zone_e, "name", &zonename);/* will succeed for we validated it earlier */
@@ -6283,6 +6302,7 @@ void map_defaults(void) {
map->remove_questinfo = map_remove_questinfo;
map->merge_zone = map_merge_zone;
+ map->zone_clear_single = map_zone_clear_single;
/**
* mapit interface
diff --git a/src/map/map.h b/src/map/map.h
index 9fca3e606..da69bacee 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -560,6 +560,8 @@ struct map_zone_data {
int disabled_skills_count;
int *disabled_items;
int disabled_items_count;
+ int *cant_disable_items; /** when a zone wants to ensure such a item is never disabled (i.e. gvg zone enables a item that is restricted everywhere else) **/
+ int cant_disable_items_count;
char **mapflags;
int mapflags_count;
struct map_zone_disabled_command_entry **disabled_commands;
@@ -1079,6 +1081,7 @@ struct map_interface {
void (*add_questinfo) (int m, struct questinfo *qi);
bool (*remove_questinfo) (int m, struct npc_data *nd);
struct map_zone_data *(*merge_zone) (struct map_zone_data *main, struct map_zone_data *other);
+ void (*zone_clear_single) (struct map_zone_data *zone);
};
struct map_interface *map;