void set_building( int x, int y, int building_type )
{
/* Check that the 'x' and 'y' coordinates are valid */
if ( x >= 0 && x <= WILDERNESS_SIZE &&
y >= 0 && y <= WILDERNESS_SIZE )
{
/* Set the map_data structure to the building parameter */
bmap_data[x][y] = building_type;
}
return;
}
void wild_write( int x, int y )
{
char strsave[MAX_INPUT_LENGTH];
FILE *fp;
int loopx, loopy, xx, yy;
int linecount = 0;
if ( x < 0 || x >= (WILDERNESS_SIZE/100) ||
y < 0 || y >= (WILDERNESS_SIZE/100) )
{
bug( "Map location out of range.", 0 );
return;
}
xx = x * 100;
yy = y * 100;
fflush( fpReserve );
fclose( fpReserve );
sprintf( strsave, "%sX%d.Y%d", WORLD_DIR, x, y );
if ( ( fp = fopen( strsave, "w" ) ) == NULL )
bug("Cannot Open map data file.", 0);
else
{
for ( loopx = 0; loopx < 100; loopx++ )
{
for ( loopy = 0; loopy < 100; loopy++ )
{
fprintf( fp, "%c %d %s\n",
map_data(loopx+xx,loopy+yy),
building_data(loopx+xx,loopy+yy),
owner_data(loopx+xx,loopy+yy) );
}
}
}
fflush( fp );
fclose( fp );
fpReserve = fopen( NULL_FILE, "r" );
return;
}
char owner_data( int x, int y)
{
char return_owner; /* This stores the return value from the call */
/* Check that the 'x' coordinate is valid */
if ( x < 0 || x >= WILDERNESS_SIZE )
{
/* Return value is set to 0 as default */
return_owner = NULL;
}
/* Check that the 'y' coordinate is valid */
else if ( y < 0 || y >= WILDERNESS_SIZE )
{
/* Return value is set to 0 as default */
return_owner = NULL;
}
else /* Both 'x' and 'y' coordinates are valid */
{
/* Return value is determined from the map_data array */
return_owner = omap_data[x][y];
}
/* Return the appropriate data */
return ( return_owner );
}
int building_data( int x, int y)
{
int return_building; /* This stores the return value from the call */
/* Check that the 'x' coordinate is valid */
if ( x < 0 || x >= WILDERNESS_SIZE )
{
/* Return value is set to 0 as default */
return_building = 0;
}
/* Check that the 'y' coordinate is valid */
else if ( y < 0 || y >= WILDERNESS_SIZE )
{
/* Return value is set to 0 as default */
return_building = 0;
}
else /* Both 'x' and 'y' coordinates are valid */
{
/* Return value is determined from the map_data array */
return_building = bmap_data[x][y];
}
/* Return the appropriate data */
return ( return_building );
}
char map_data( int x, int y )
{
char return_value; /* This stores the return value from the call */
/* Check that the 'x' coordinate is valid */
if ( x < 0 || x >= WILDERNESS_SIZE )
{
/* Return value is set to 0 as default */
return_value = 0;
}
/* Check that the 'y' coordinate is valid */
else if ( y < 0 || y >= WILDERNESS_SIZE )
{
/* Return value is set to 0 as default */
return_value = 0;
}
else /* Both 'x' and 'y' coordinates are valid */
{
/* Return value is determined from the map_data array */
return_value = vmap_data[x][y];
}
/* Return the appropriate data */
return ( return_value );
}
if (!str_cmp(arg,"zone"))
{
if (ch->x < 0 || ch->x >= WILDERNESS_SIZE ||
ch->y < 0 || ch->y >= WILDERNESS_SIZE)
{
send_to_char("You are not in a wilderness zone.\n\r",ch);
return;
}
x = ch->x / 100;
y = ch->y / 100;
wild_write(x,y);
send_to_char("Zone saved.\n\r",ch);
return;
}
these are saved and loaded..
You can go to x:35 y:125 and build a hut..
Im trying to add set_building and set_owner,
(that will also save in the wilderness files)
(i'll use a WILD_BUILDING generic define in the wild bits,
that will look up the building number (not a bit)
bring up different symbols for the new buildings…
for a x,y coordinate.
It's crashing on set_building and im not sure why..
My Wild Write