/*
** cleanupmap.c  Copyright 1991 Kent Paul Dolan,
**               Mountain View, CA, USA 94039-0755
**
** Written to satisfy an inquiry on USENet's rec.games.programmer newsgroup.
** May be freely used or modified in any non-commercial work.  Copyrighted
** only to prevent patenting by someone else.
*/

#include <stdio.h>
#include "townmaze.h"
#include "townproto.h"

#ifdef __STDC__
void cleanupmap()
#else
int cleanupmap()
#endif
{

/*
** Isolated "posts" of wall segments are left by the normal map making
** process; clean them up to make nice open courtyards.
*/

  int i, j;

#if PROGRESS
  fprintf(stderr,"Clean up map ");
#endif

  for (i = 4; i < (mazeheight - 4); i += 2)
    for (j = 4; j < (mazewidth - 4); j += 2)
      if (   (cmaze[i-1][j] == BLANK)
          && (cmaze[i][j+1] == BLANK)
          && (cmaze[i+1][j] == BLANK)
          && (cmaze[i][j-1] == BLANK)
         )
        cmaze[i][j] = BLANK;
  return;

}
