Skip to content

Commit

Permalink
*delwall now give a friendly warning to remind non-existent wall
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnieRuru committed Apr 10, 2018
1 parent 7b097da commit e711447
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/map/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -3166,13 +3166,13 @@ void map_iwall_get(struct map_session_data *sd)
dbi_destroy(iter);
}

void map_iwall_remove(const char *wall_name)
bool map_iwall_remove(const char *wall_name)
{
struct iwall_data *iwall;
int16 i, x1, y1;

if( (iwall = (struct iwall_data *)strdb_get(map->iwall_db, wall_name)) == NULL )
return; // Nothing to do
return false;

for( i = 0; i < iwall->size; i++ ) {
map->iwall_nextxy(iwall->x, iwall->y, iwall->dir, i, &x1, &y1);
Expand All @@ -3185,6 +3185,7 @@ void map_iwall_remove(const char *wall_name)

map->list[iwall->m].iwall_num--;
strdb_remove(map->iwall_db, iwall->wall_name);
return true;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/map/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ END_ZEROED_BLOCK;

bool (*iwall_set) (int16 m, int16 x, int16 y, int size, int8 dir, bool shootable, const char* wall_name);
void (*iwall_get) (struct map_session_data *sd);
void (*iwall_remove) (const char *wall_name);
bool (*iwall_remove) (const char *wall_name);

int (*addmobtolist) (unsigned short m, struct spawn_data *spawn); // [Wizputer]
void (*spawnmobs) (int16 m); // [Wizputer]
Expand Down
10 changes: 8 additions & 2 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -13998,9 +13998,15 @@ BUILDIN(setwall) {
map->iwall_set(m, x, y, size, dir, shootable, name);
return true;
}
BUILDIN(delwall) {

BUILDIN(delwall)
{
const char *name = script_getstr(st,2);
map->iwall_remove(name);

if (!map->iwall_remove(name)) {
ShowWarning("script:delwall: Non-existent %s provided.\n", name);
return false;
}

return true;
}
Expand Down

0 comments on commit e711447

Please sign in to comment.