summaryrefslogtreecommitdiff
path: root/src/map/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/map.c')
-rw-r--r--src/map/map.c250
1 files changed, 113 insertions, 137 deletions
diff --git a/src/map/map.c b/src/map/map.c
index a7b171ddf..e01a25366 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -111,7 +111,7 @@ int map_usercount(void) {
*------------------------------------------*/
int map_freeblock (struct block_list *bl) {
nullpo_retr(map->block_free_lock, bl);
-
+
if (map->block_free_lock == 0) {
if( bl->type == BL_ITEM )
ers_free(map->flooritem_ers, bl);
@@ -119,10 +119,9 @@ int map_freeblock (struct block_list *bl) {
aFree(bl);
bl = NULL;
} else {
-
if( map->block_free_count >= map->block_free_list_size )
map_block_free_expand();
-
+
map->block_free[map->block_free_count++] = bl;
}
@@ -139,7 +138,6 @@ int map_freeblock_lock (void) {
* Remove the lock on map_bl
*------------------------------------------*/
int map_freeblock_unlock (void) {
-
if ((--map->block_free_lock) == 0) {
int i;
for (i = 0; i < map->block_free_count; i++) {
@@ -375,8 +373,6 @@ int map_moveblock(struct block_list *bl, int x1, int y1, int64 tick) {
) {
sc->data[SC_PROPERTYWALK]->val3++;
}
-
-
}
/* Guild Aura Moving */
if( bl->type == BL_PC && ((TBL_PC*)bl)->state.gmaster_flag ) {
@@ -840,7 +836,7 @@ static int bl_vgetall_inshootrange(struct block_list *bl, va_list args)
if (!check_distance_bl(center, bl, range))
return 0;
#endif
- if (!path->search_long(NULL, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL))
+ if (!path->search_long(NULL, center, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL))
return 0;
return 1;
}
@@ -1195,7 +1191,7 @@ static int bl_vgetall_inpath(struct block_list *bl, va_list args)
if ( k < 0 || k > len_limit ) //Since more skills use this, check for ending point as well.
return 0;
- if ( k > magnitude2 && !path->search_long(NULL, m, x0, y0, xi, yi, CELL_CHKWALL) )
+ if ( k > magnitude2 && !path->search_long(NULL, NULL, m, x0, y0, xi, yi, CELL_CHKWALL) )
return 0; //Targets beyond the initial ending point need the wall check.
//All these shifts are to increase the precision of the intersection point and distance considering how it's
@@ -1366,7 +1362,6 @@ int map_clearflooritem_timer(int tid, int64 tick, int id, intptr_t data) {
return 1;
}
-
if (pet->search_petDB_index(fitem->item_data.nameid, PET_EGG) >= 0)
intif->delete_petdata(MakeDWord(fitem->item_data.card[1], fitem->item_data.card[2]));
@@ -1397,7 +1392,7 @@ void map_clearflooritem(struct block_list *bl) {
* to place an BL_ITEM object. Scan area is 9x9, returns 1 on success.
* x and y are modified with the target cell when successful.
*------------------------------------------*/
-int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) {
+int map_searchrandfreecell(int16 m, const struct block_list *bl, int16 *x, int16 *y, int stack) {
int free_cell,i,j;
int free_cells[9][2];
@@ -1407,7 +1402,7 @@ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) {
for(j=-1;j<=1;j++){
if(j+*x<0 || j+*x>=map->list[m].xs)
continue;
- if(map->getcell(m,j+*x,i+*y,CELL_CHKNOPASS) && !map->getcell(m,j+*x,i+*y,CELL_CHKICEWALL))
+ if (map->getcell(m, bl, j + *x, i + *y, CELL_CHKNOPASS) && !map->getcell(m, bl, j + *x, i + *y, CELL_CHKICEWALL))
continue;
//Avoid item stacking to prevent against exploits. [Skotlex]
if(stack && map->count_oncell(m,j+*x,i+*y, BL_ITEM, 0) > stack)
@@ -1424,7 +1419,6 @@ int map_searchrandfreecell(int16 m,int16 *x,int16 *y,int stack) {
return 1;
}
-
int map_count_sub(struct block_list *bl,va_list ap) {
return 1;
}
@@ -1466,7 +1460,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1
//No range? Return the target cell then....
*x = bx;
*y = by;
- return map->getcell(m,*x,*y,CELL_CHKREACH);
+ return map->getcell(m, src, *x, *y, CELL_CHKREACH);
}
if (rx >= 0 && ry >= 0) {
@@ -1484,7 +1478,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1
if (*x == bx && *y == by)
continue; //Avoid picking the same target tile.
- if (map->getcell(m,*x,*y,CELL_CHKREACH)) {
+ if (map->getcell(m, src, *x, *y, CELL_CHKREACH)) {
if(flag&2 && !unit->can_reach_pos(src, *x, *y, 1))
continue;
if(flag&4) {
@@ -1511,7 +1505,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1
* flag:
* 0x1 - only count standing units
*------------------------------------------*/
-bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag)
+bool map_closest_freecell(int16 m, const struct block_list *bl, int16 *x, int16 *y, int type, int flag)
{
uint8 dir = 6;
int16 tx = *x;
@@ -1530,7 +1524,7 @@ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag)
if(dir%2 == 0 && costrange%MOVE_COST == 0) {
tx = *x+dx*(costrange/MOVE_COST);
ty = *y+dy*(costrange/MOVE_COST);
- if(!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m,tx,ty,CELL_CHKPASS)) {
+ if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) {
*x = tx;
*y = ty;
return true;
@@ -1540,7 +1534,7 @@ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag)
else if(dir%2 == 1 && costrange%MOVE_DIAGONAL_COST == 0) {
tx = *x+dx*(costrange/MOVE_DIAGONAL_COST);
ty = *y+dy*(costrange/MOVE_DIAGONAL_COST);
- if(!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m,tx,ty,CELL_CHKPASS)) {
+ if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) {
*x = tx;
*y = ty;
return true;
@@ -1550,14 +1544,14 @@ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag)
else if(dir%2 == 1 && costrange%MOVE_COST == 4) {
tx = *x+dx*((dir%4==3)?(costrange/MOVE_COST):1);
ty = *y+dy*((dir%4==1)?(costrange/MOVE_COST):1);
- if(!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m,tx,ty,CELL_CHKPASS)) {
+ if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) {
*x = tx;
*y = ty;
return true;
}
tx = *x+dx*((dir%4==1)?(costrange/MOVE_COST):1);
ty = *y+dy*((dir%4==3)?(costrange/MOVE_COST):1);
- if(!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m,tx,ty,CELL_CHKPASS)) {
+ if (!map->count_oncell(m, tx, ty, type, flag) && map->getcell(m, bl, tx, ty, CELL_CHKPASS)) {
*x = tx;
*y = ty;
return true;
@@ -1591,19 +1585,19 @@ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag)
* @first_charid, @second_charid, @third_charid, looting priority
* @flag: &1 MVP item. &2 do stacking check.
*------------------------------------------*/
-int map_addflooritem(struct item *item_data,int amount,int16 m,int16 x,int16 y,int first_charid,int second_charid,int third_charid,int flags)
+int map_addflooritem(const struct block_list *bl, struct item *item_data, int amount, int16 m, int16 x, int16 y, int first_charid, int second_charid, int third_charid, int flags)
{
int r;
struct flooritem_data *fitem=NULL;
nullpo_ret(item_data);
- if (!map->searchrandfreecell(m, &x, &y, (flags&2)?1:0))
+ if (!map->searchrandfreecell(m, bl, &x, &y, (flags&2)?1:0))
return 0;
r=rnd();
fitem = ers_alloc(map->flooritem_ers, struct flooritem_data);
-
+
fitem->bl.type = BL_ITEM;
fitem->bl.prev = fitem->bl.next = NULL;
fitem->bl.m = m;
@@ -1789,7 +1783,7 @@ int map_quit(struct map_session_data *sd) {
//Non-active players should not have loaded any data yet (or it was cleared already) so no additional cleanups are needed.
return 0;
}
-
+
if( sd->expiration_tid != INVALID_TIMER )
timer->delete(sd->expiration_tid,pc->expiration_timer);
@@ -1882,7 +1876,7 @@ int map_quit(struct map_session_data *sd) {
if( sd->state.vending ) {
idb_remove(vending->db, sd->status.char_id);
}
-
+
party->booking_delete(sd); // Party Booking [Spiria]
pc->makesavestatus(sd);
pc->clean_skilltree(sd);
@@ -2567,8 +2561,8 @@ int map_random_dir(struct block_list *bl, int16 *x, int16 *y)
xi = bl->x + segment*dirx[j];
segment = (short)sqrt((float)(dist2 - segment*segment)); //The complement of the previously picked segment
yi = bl->y + segment*diry[j];
- } while ( (map->getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH))
- && (++i)<100 );
+ } while ((map->getcell(bl->m, bl, xi, yi, CELL_CHKNOPASS) || !path->search(NULL, bl, bl->m, bl->x, bl->y, xi, yi, 1, CELL_CHKNOREACH))
+ && (++i)<100);
if (i < 100) {
*x = xi;
@@ -2640,11 +2634,11 @@ void map_cellfromcache(struct map_data *m) {
/*==========================================
* Confirm if celltype in (m,x,y) match the one given in cellchk
*------------------------------------------*/
-int map_getcell(int16 m,int16 x,int16 y,cell_chk cellchk) {
- return (m < 0 || m >= map->count) ? 0 : map->list[m].getcellp(&map->list[m],x,y,cellchk);
+int map_getcell(int16 m, const struct block_list *bl, int16 x, int16 y, cell_chk cellchk) {
+ return (m < 0 || m >= map->count) ? 0 : map->list[m].getcellp(&map->list[m], bl, x, y, cellchk);
}
-int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) {
+int map_getcellp(struct map_data* m, const struct block_list *bl, int16 x, int16 y, cell_chk cellchk) {
struct mapcell cell;
nullpo_ret(m);
@@ -2663,14 +2657,11 @@ int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) {
// base gat type checks
case CELL_CHKWALL:
return (!cell.walkable && !cell.shootable);
-
case CELL_CHKWATER:
return (cell.water);
-
case CELL_CHKCLIFF:
return (!cell.walkable && cell.shootable);
-
// base cell type checks
case CELL_CHKNPC:
return (cell.npc);
@@ -2715,12 +2706,13 @@ int map_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) {
}
/* [Ind/Hercules] */
-int map_sub_getcellp(struct map_data* m,int16 x,int16 y,cell_chk cellchk) {
+int map_sub_getcellp(struct map_data* m, const struct block_list *bl, int16 x, int16 y, cell_chk cellchk) {
map->cellfromcache(m);
m->getcellp = map->getcellp;
m->setcell = map->setcell;
- return m->getcellp(m,x,y,cellchk);
+ return m->getcellp(m, bl, x, y, cellchk);
}
+
/*==========================================
* Change the type/flags of a map cell
* 'cell' - which flag to modify
@@ -2808,7 +2800,7 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable
if( (iwall = (struct iwall_data *)strdb_get(map->iwall_db, wall_name)) != NULL )
return false; // Already Exists
- if( map->getcell(m, x, y, CELL_CHKNOREACH) )
+ if (map->getcell(m, NULL, x, y, CELL_CHKNOREACH))
return false; // Starting cell problem
CREATE(iwall, struct iwall_data, 1);
@@ -2823,13 +2815,13 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable
for( i = 0; i < size; i++ ) {
map->iwall_nextxy(x, y, dir, i, &x1, &y1);
- if( map->getcell(m, x1, y1, CELL_CHKNOREACH) )
+ if (map->getcell(m, NULL, x1, y1, CELL_CHKNOREACH))
break; // Collision
map->list[m].setcell(m, x1, y1, CELL_WALKABLE, false);
map->list[m].setcell(m, x1, y1, CELL_SHOOTABLE, shootable);
- clif->changemapcell(0, m, x1, y1, map->getcell(m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP);
+ clif->changemapcell(0, m, x1, y1, map->getcell(m, NULL, x1, y1, CELL_GETTYPE), ALL_SAMEMAP);
}
iwall->size = i;
@@ -2856,7 +2848,7 @@ void map_iwall_get(struct map_session_data *sd) {
for( i = 0; i < iwall->size; i++ ) {
map->iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1);
- clif->changemapcell(sd->fd, iwall->m, x1, y1, map->getcell(iwall->m, x1, y1, CELL_GETTYPE), SELF);
+ clif->changemapcell(sd->fd, iwall->m, x1, y1, map->getcell(iwall->m, &sd->bl, x1, y1, CELL_GETTYPE), SELF);
}
}
dbi_destroy(iter);
@@ -2876,7 +2868,7 @@ void map_iwall_remove(const char *wall_name)
map->list[iwall->m].setcell(iwall->m, x1, y1, CELL_SHOOTABLE, true);
map->list[iwall->m].setcell(iwall->m, x1, y1, CELL_WALKABLE, true);
- clif->changemapcell(0, iwall->m, x1, y1, map->getcell(iwall->m, x1, y1, CELL_GETTYPE), ALL_SAMEMAP);
+ clif->changemapcell(0, iwall->m, x1, y1, map->getcell(iwall->m, NULL, x1, y1, CELL_GETTYPE), ALL_SAMEMAP);
}
map->list[iwall->m].iwall_num--;
@@ -3044,7 +3036,6 @@ int map_readfromcache(struct map_data *m, char *buffer) {
return 0; // Not found
}
-
int map_addmap(const char* mapname) {
map->list[map->count].instance_id = -1;
mapindex->getmapname(mapname, map->list[map->count++].name);
@@ -3081,38 +3072,38 @@ int map_delmap(char* mapname) {
**/
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);
-
+
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]);
}
-
+
if( zone->disabled_commands )
aFree(zone->disabled_commands);
-
+
for(i = 0; i < zone->capped_skills_count; i++) {
aFree(zone->capped_skills[i]);
}
-
+
if( zone->capped_skills )
aFree(zone->capped_skills);
}
@@ -3122,11 +3113,11 @@ void map_zone_clear_single(struct map_zone_data *zone) {
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) */
@@ -3244,10 +3235,10 @@ void do_final_maps(void) {
if( map->list[i].channel )
channel->delete(map->list[i].channel);
-
+
if( map->list[i].qi_data )
aFree(map->list[i].qi_data);
-
+
if( map->list[i].hdata )
{
for( v = 0; v < map->list[i].hdatac; v++ ) {
@@ -3323,10 +3314,10 @@ void map_flags_init(void) {
map->list[i].misc_damage_rate = 100;
map->list[i].short_damage_rate = 100;
map->list[i].long_damage_rate = 100;
-
+
if( map->list[i].qi_data )
aFree(map->list[i].qi_data);
-
+
map->list[i].qi_data = NULL;
map->list[i].qi_count = 0;
}
@@ -3717,7 +3708,7 @@ int inter_config_read(char *cfgName) {
while (fgets(line, sizeof(line), fp)) {
if (line[0] == '/' && line[1] == '/')
continue;
-
+
if (sscanf(line,"%1023[^:]: %1023[^\r\n]", w1, w2) < 2)
continue;
/* table names */
@@ -3855,34 +3846,32 @@ struct map_zone_data *map_merge_zone(struct map_zone_data *main, struct map_zone
char newzone[MAP_ZONE_NAME_LENGTH];
struct map_zone_data *zone = NULL;
int cursor, i, j;
-
+
sprintf(newzone, "%s+%s",main->name,other->name);
-
+
if( (zone = strdb_get(map->zone_db, newzone)) )
return zone;/* this zone has already been merged */
-
+
CREATE(zone, struct map_zone_data, 1);
-
safestrncpy(zone->name, newzone, MAP_ZONE_NAME_LENGTH);
-
+ zone->merge_type = MZMT_NEVERMERGE;
zone->disabled_skills_count = main->disabled_skills_count + other->disabled_skills_count;
zone->disabled_items_count = main->disabled_items_count + other->disabled_items_count;
zone->mapflags_count = main->mapflags_count + other->mapflags_count;
zone->disabled_commands_count = main->disabled_commands_count + other->disabled_commands_count;
zone->capped_skills_count = main->capped_skills_count + other->capped_skills_count;
-
+
CREATE(zone->disabled_skills, struct map_zone_disabled_skill_entry *, zone->disabled_skills_count );
-
for(i = 0, cursor = 0; i < main->disabled_skills_count; i++, cursor++ ) {
CREATE(zone->disabled_skills[cursor], struct map_zone_disabled_skill_entry, 1 );
memcpy(zone->disabled_skills[cursor], main->disabled_skills[i], sizeof(struct map_zone_disabled_skill_entry));
}
-
+
for(i = 0; i < other->disabled_skills_count; i++, cursor++ ) {
CREATE(zone->disabled_skills[cursor], struct map_zone_disabled_skill_entry, 1 );
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] ) {
@@ -3893,11 +3882,10 @@ struct map_zone_data *map_merge_zone(struct map_zone_data *main, struct map_zone
}
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++) {
for(j = 0; j < main->cant_disable_items_count; j++) {
if( other->disabled_items[i] == main->cant_disable_items[j] ) {
@@ -3911,45 +3899,40 @@ struct map_zone_data *map_merge_zone(struct map_zone_data *main, struct map_zone
}
CREATE(zone->mapflags, char *, zone->mapflags_count );
-
for(i = 0, cursor = 0; i < main->mapflags_count; i++, cursor++ ) {
CREATE(zone->mapflags[cursor], char, MAP_ZONE_MAPFLAG_LENGTH );
safestrncpy(zone->mapflags[cursor], main->mapflags[i], MAP_ZONE_MAPFLAG_LENGTH);
}
-
+
for(i = 0; i < other->mapflags_count; i++, cursor++ ) {
CREATE(zone->mapflags[cursor], char, MAP_ZONE_MAPFLAG_LENGTH );
safestrncpy(zone->mapflags[cursor], other->mapflags[i], MAP_ZONE_MAPFLAG_LENGTH);
}
-
+
CREATE(zone->disabled_commands, struct map_zone_disabled_command_entry *, zone->disabled_commands_count);
-
for(i = 0, cursor = 0; i < main->disabled_commands_count; i++, cursor++ ) {
CREATE(zone->disabled_commands[cursor], struct map_zone_disabled_command_entry, 1);
memcpy(zone->disabled_commands[cursor], main->disabled_commands[i], sizeof(struct map_zone_disabled_command_entry));
}
-
+
for(i = 0; i < other->disabled_commands_count; i++, cursor++ ) {
CREATE(zone->disabled_commands[cursor], struct map_zone_disabled_command_entry, 1);
memcpy(zone->disabled_commands[cursor], other->disabled_commands[i], sizeof(struct map_zone_disabled_command_entry));
}
-
+
CREATE(zone->capped_skills, struct map_zone_skill_damage_cap_entry *, zone->capped_skills_count);
-
for(i = 0, cursor = 0; i < main->capped_skills_count; i++, cursor++ ) {
CREATE(zone->capped_skills[cursor], struct map_zone_skill_damage_cap_entry, 1);
memcpy(zone->capped_skills[cursor], main->capped_skills[i], sizeof(struct map_zone_skill_damage_cap_entry));
}
-
+
for(i = 0; i < other->capped_skills_count; i++, cursor++ ) {
CREATE(zone->capped_skills[cursor], struct map_zone_skill_damage_cap_entry, 1);
memcpy(zone->capped_skills[cursor], other->capped_skills[i], sizeof(struct map_zone_skill_damage_cap_entry));
}
-
- zone->info.special = 2;
-
+
+ zone->info.merged = 1;
strdb_put(map->zone_db, newzone, zone);
-
return zone;
}
@@ -3958,17 +3941,17 @@ void map_zone_change2(int m, struct map_zone_data *zone) {
if( map->list[m].zone == zone )
return;
-
- if( map->list[m].zone->info.special != 2 ) /* we don't update it for merged zones! */
+
+ if( !map->list[m].zone->info.merged ) /* we don't update it for merged zones! */
map->list[m].prev_zone = map->list[m].zone;
-
+
if( map->list[m].zone_mf_count )
map->zone_remove(m);
- if( zone->info.special ) {
+ if( zone->merge_type == MZMT_MERGEABLE && map->list[m].prev_zone->merge_type != MZMT_NEVERMERGE ) {
zone = map->merge_zone(zone,map->list[m].prev_zone);
}
-
+
map->zone_apply(m,zone,empty,empty,empty);
}
/* when changing from a mapflag to another during runtime */
@@ -4917,12 +4900,15 @@ void read_map_zone_db(void) {
/* is this the global template? */
if( strncmpi(zonename,MAP_ZONE_NORMAL_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
zone = &map->zone_all;
+ zone->merge_type = MZMT_NEVERMERGE;
is_all = true;
} else if( strncmpi(zonename,MAP_ZONE_PK_NAME,MAP_ZONE_NAME_LENGTH) == 0 ) {
zone = &map->zone_pk;
+ zone->merge_type = MZMT_NEVERMERGE;
is_all = true;
} else {
CREATE( zone, struct map_zone_data, 1 );
+ zone->merge_type = MZMT_NORMAL;
zone->disabled_skills_count = 0;
zone->disabled_items_count = 0;
}
@@ -4987,7 +4973,6 @@ void read_map_zone_db(void) {
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);
@@ -5273,17 +5258,17 @@ void read_map_zone_db(void) {
}
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' zones in '"CL_WHITE"%s"CL_RESET"'.\n", zone_count, config_filename);
- /* not supposed to go in here but in skill_final whatever */
- libconfig->destroy(&map_zone_db);
-
+
/* post-load processing */
if( (zone = strdb_get(map->zone_db, MAP_ZONE_PVP_NAME)) )
- zone->info.special = 1;
+ zone->merge_type = MZMT_MERGEABLE;
if( (zone = strdb_get(map->zone_db, MAP_ZONE_GVG_NAME)) )
- zone->info.special = 1;
+ zone->merge_type = MZMT_MERGEABLE;
if( (zone = strdb_get(map->zone_db, MAP_ZONE_BG_NAME)) )
- zone->info.special = 1;
+ zone->merge_type = MZMT_MERGEABLE;
}
+ /* not supposed to go in here but in skill_final whatever */
+ libconfig->destroy(&map_zone_db);
}
int map_get_new_bonus_id (void) {
@@ -5292,22 +5277,22 @@ int map_get_new_bonus_id (void) {
void map_add_questinfo(int m, struct questinfo *qi) {
unsigned short i;
-
+
/* duplicate, override */
for(i = 0; i < map->list[m].qi_count; i++) {
if( map->list[m].qi_data[i].nd == qi->nd )
break;
}
-
+
if( i == map->list[m].qi_count )
RECREATE(map->list[m].qi_data, struct questinfo, ++map->list[m].qi_count);
-
+
memcpy(&map->list[m].qi_data[i], qi, sizeof(struct questinfo));
}
bool map_remove_questinfo(int m, struct npc_data *nd) {
unsigned short i;
-
+
for(i = 0; i < map->list[m].qi_count; i++) {
struct questinfo *qi = &map->list[m].qi_data[i];
if( qi->nd == nd ) {
@@ -5318,7 +5303,6 @@ bool map_remove_questinfo(int m, struct npc_data *nd) {
return true;
}
}
-
return false;
}
@@ -5397,10 +5381,10 @@ int do_final(void) {
struct s_mapiterator* iter;
ShowStatus("Terminating...\n");
-
+
channel->config->closing = true;
HPM->event(HPET_FINAL);
-
+
if (map->cpsd) aFree(map->cpsd);
//Ladies and babies first.
@@ -5461,7 +5445,7 @@ int do_final(void) {
vending->final();
HPM_map_do_final();
-
+
map->map_db->destroy(map->map_db, map->db_final);
mapindex->final();
@@ -5487,8 +5471,7 @@ int do_final(void) {
aFree(map->block_free);
if( map->bl_list )
aFree(map->bl_list);
-
-
+
if( !map->enable_grf )
aFree(map->cache_buffer);
@@ -5500,7 +5483,7 @@ int do_final(void) {
aFree(map->GRF_PATH_FILENAME);
aFree(map->INTER_CONF_NAME);
aFree(map->LOG_CONF_NAME);
-
+
HPM->event(HPET_POST_FINAL);
ShowStatus("Finished.\n");
@@ -5512,7 +5495,6 @@ int map_abort_sub(struct map_session_data* sd, va_list ap) {
return 1;
}
-
//------------------------------
// Function called when the server
// has received a crash signal.
@@ -5541,7 +5523,6 @@ void set_server_type(void) {
SERVER_TYPE = SERVER_TYPE_MAP;
}
-
/// Called when a terminate signal is received.
void do_shutdown(void)
{
@@ -5593,12 +5574,12 @@ CPCMD(gm_use) {
}
map->cpsd_active = true;
-
+
if( !atcommand->exec(map->cpsd->fd, map->cpsd, line, false) )
ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' failed\n",line);
else
ShowInfo("HCP: '"CL_WHITE"%s"CL_RESET"' was used\n",line);
-
+
map->cpsd_active = false;
}
/* Hercules Console Parser */
@@ -5802,11 +5783,10 @@ static CMDLINEARG(loadscript)
**/
static CMDLINEARG(generatetranslations) {
script->lang_export_file = aStrdup("./generated_translations.pot");
-
+
if( !(script->lang_export_fp = fopen(script->lang_export_file,"wb")) ) {
ShowError("export-dialog: failed to open '%s' for writing\n",script->lang_export_file);
}
-
core->runflag = CORE_ST_STOP;
return true;
}
@@ -5838,7 +5818,7 @@ int do_init(int argc, char *argv[])
#ifdef GCOLLECT
GC_enable_incremental();
#endif
-
+
map_load_defaults();
map->INTER_CONF_NAME = aStrdup("conf/inter-server.conf");
@@ -5853,9 +5833,9 @@ int do_init(int argc, char *argv[])
HPM_map_do_init();
cmdline->exec(argc, argv, CMDLINE_OPT_PREINIT);
HPM->config_read();
-
+
HPM->event(HPET_PRE_INIT);
-
+
cmdline->exec(argc, argv, CMDLINE_OPT_NORMAL);
minimal = map->minimal;/* temp (perhaps make minimal a mask with options of what to load? e.g. plugin 1 does minimal |= mob_db; */
if (!minimal) {
@@ -5936,7 +5916,6 @@ int do_init(int argc, char *argv[])
map->readallmaps();
-
if (!minimal) {
timer->add_func_list(map->freeblock_timer, "map_freeblock_timer");
timer->add_func_list(map->clearflooritem_timer, "map_clearflooritem_timer");
@@ -5990,19 +5969,19 @@ int do_init(int argc, char *argv[])
HPM->event(HPET_READY);
exit(EXIT_SUCCESS);
}
-
+
npc->event_do_oninit( false ); // Init npcs (OnInit)
npc->market_fromsql(); /* after OnInit */
-
+
if (battle_config.pk_mode)
ShowNotice("Server is running on '"CL_WHITE"PK Mode"CL_RESET"'.\n");
Sql_HerculesUpdateCheck(map->mysql_handle);
-
+
#ifdef CONSOLE_INPUT
console->input->setSQL(map->mysql_handle);
#endif
-
+
ShowStatus("Server is '"CL_GREEN"ready"CL_RESET"' and listening on port '"CL_WHITE"%d"CL_RESET"'.\n\n", map->port);
if( core->runflag != CORE_ST_STOP ) {
@@ -6033,14 +6012,14 @@ void map_defaults(void) {
map->extra_scripts = NULL;
map->extra_scripts_count = 0;
-
+
sprintf(map->db_path ,"db");
sprintf(map->help_txt ,"conf/help.txt");
sprintf(map->help2_txt ,"conf/help2.txt");
sprintf(map->charhelp_txt ,"conf/charhelp.txt");
-
+
sprintf(map->wisp_server_name ,"Server"); // can be modified in char-server configuration file
-
+
map->autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
map->minsave_interval = 100;
map->save_settings = 0xFFFF;
@@ -6048,18 +6027,18 @@ void map_defaults(void) {
map->agit2_flag = 0;
map->night_flag = 0; // 0=day, 1=night [Yor]
map->enable_spy = 0; //To enable/disable @spy commands, which consume too much cpu time when sending packets. [Skotlex]
-
+
map->db_use_sql_item_db = 0;
map->db_use_sql_mob_db = 0;
map->db_use_sql_mob_skill_db = 0;
-
+
sprintf(map->item_db_db, "item_db");
sprintf(map->item_db2_db, "item_db2");
sprintf(map->mob_db_db, "mob_db");
sprintf(map->mob_db2_db, "mob_db2");
sprintf(map->mob_skill_db_db, "mob_skill_db");
sprintf(map->mob_skill_db2_db, "mob_skill_db2");
-
+
map->INTER_CONF_NAME="conf/inter-server.conf";
map->LOG_CONF_NAME="conf/logs.conf";
map->MAP_CONF_NAME = "conf/map-server.conf";
@@ -6068,7 +6047,7 @@ void map_defaults(void) {
map->SCRIPT_CONF_NAME = "conf/script.conf";
map->MSG_CONF_NAME = "conf/messages.conf";
map->GRF_PATH_FILENAME = "conf/grf-files.txt";
-
+
map->default_codepage[0] = '\0';
map->server_port = 3306;
sprintf(map->server_ip,"127.0.0.1");
@@ -6079,15 +6058,15 @@ void map_defaults(void) {
map->default_lang_str[0] = '\0';
map->cpsd_active = false;
-
+
map->port = 0;
map->users = 0;
map->ip_set = 0;
map->char_ip_set = 0;
map->enable_grf = 0;
-
+
memset(&map->index2mapid, -1, sizeof(map->index2mapid));
-
+
map->id_db = NULL;
map->pc_db = NULL;
map->mobid_db = NULL;
@@ -6106,16 +6085,16 @@ void map_defaults(void) {
map->bl_list = NULL;
map->bl_list_count = 0;
map->bl_list_size = 0;
-
+
//all in a big chunk, respects order
memset(ZEROED_BLOCK_POS(map), 0, ZEROED_BLOCK_SIZE(map));
-
+
map->cpsd = NULL;
map->list = NULL;
-
+
map->iterator_ers = NULL;
map->cache_buffer = NULL;
-
+
map->flooritem_ers = NULL;
/* */
map->bonus_id = SP_LAST_KNOWN;
@@ -6282,19 +6261,17 @@ void map_defaults(void) {
map->abort_sub = map_abort_sub;
map->update_cell_bl = map_update_cell_bl;
-
map->get_new_bonus_id = map_get_new_bonus_id;
-
+
map->add_questinfo = map_add_questinfo;
map->remove_questinfo = map_remove_questinfo;
-
+
map->merge_zone = map_merge_zone;
map->zone_clear_single = map_zone_clear_single;
-
+
/**
* mapit interface
**/
-
mapit = &mapit_s;
mapit->alloc = mapit_alloc;
@@ -6304,5 +6281,4 @@ void map_defaults(void) {
mapit->next = mapit_next;
mapit->prev = mapit_prev;
mapit->exists = mapit_exists;
-
}