27 Jan, 2014, Xrakisis wrote in the 1st comment:
Votes: 0
I'm using Kavir's Wilderness. It has bits for WILD_ defines..
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..



void do_construct

stc("syntax: Construct <building><foundation><material>\n\r",ch);


if (!str_cmp(arg1,"dwelling"))
{
set_map_data(ch->x, ch->y, WILD_HUT);
set_building(ch->x, ch->y, B_DWELLING);
set_owner(ch->x, ch->y, ch->pcdata->switchname);
ch->pcdata->citybuildings[B_DWELLING]++;
sprintf(buf,"You build a Dwelling, here at X%d Y%d.\n\r",x,y);
stc(buf,ch);
}

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 );
}







My Wild Write
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;


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;
}
27 Jan, 2014, Ripley wrote in the 2nd comment:
Votes: 0
What does set_building do?
27 Jan, 2014, Xrakisis wrote in the 3rd comment:
Votes: 0
reads the building number from the file, and puts it into the map
when it read the map and loads it.

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;
}
28 Jan, 2014, Aule wrote in the 4th comment:
Votes: 0
Not familiar with Kavir's wilderness, but…

In set_building it looks like you're overrunning your array (bmap_data) by accepting x and y == WILDERNESS_SIZE, where everyone else you've marked that as being an invalid coordinate.

You just say its crashing, have you run it in gdb to take a closer look at what is happening?
28 Jan, 2014, Ripley wrote in the 5th comment:
Votes: 0
Where is the declaration of bmap_data[][]?
28 Jan, 2014, quixadhal wrote in the 6th comment:
Votes: 0
grep is your friend.
29 Jan, 2014, Ripley wrote in the 7th comment:
Votes: 0
Sure, but it is not in the code he posted - So I asked.
29 Jan, 2014, Tijer wrote in the 8th comment:
Votes: 0
i've worked with Xrakisis before… and hes been coding for many years now, but still does not grasp the fact that before adding new features to your mud you need to fix the broken stuff, you added to your mud previously.

He was hosted on my server.. but the MUD regularly ran using 20-25% of system resources, with 1 or 2 players online. Many times i tried to help him sort out his code issues, and many times id sort them, only for him to
paste something in from another codebase, bringing back said issues.

Does wilderness actually work now Xrakisis? because if it doesnt, i dont think adding new building types will be worth it… (last i knew wilderness wasnt loading the co-ordinate tiles properly)

For all new MUD coders.. concentrate on fixing issues with your code before adding new features which cause even more problems….

This is not a flame… its just a message to Xrakisis to actually FIX broken things first!!
06 Feb, 2014, Nathan wrote in the 9th comment:
Votes: 0
Tijer said:
i've worked with Xrakisis before… and hes been coding for many years now, but still does not grasp the fact that before adding new features to your mud you need to fix the broken stuff, you added to your mud previously.

He was hosted on my server.. but the MUD regularly ran using 20-25% of system resources, with 1 or 2 players online. Many times i tried to help him sort out his code issues, and many times id sort them, only for him to
paste something in from another codebase, bringing back said issues.

Does wilderness actually work now Xrakisis? because if it doesnt, i dont think adding new building types will be worth it… (last i knew wilderness wasnt loading the co-ordinate tiles properly)

For all new MUD coders.. concentrate on fixing issues with your code before adding new features which cause even more problems….

This is not a flame… its just a message to Xrakisis to actually FIX broken things first!!


For what's it's worth, bug-fixing/fixing broken things isn't high on the priorities of what anyone really wants to do. Especially if it's some kind of design conflict resulting from one intent and the realities of the codebase being in conflict.
16 Apr, 2014, Xrakisis wrote in the 10th comment:
Votes: 0
Wilderness works.. And in the wilderness files, instead of just one letter for the terrain type.. its saving the terrain then the building and then the owner..
N 0 (null)
E 0 (null)
p 0 (null)
x 0 (null)
p 0 (null)

Ive been fixing things as i go along. A player tries about everything out and notes me so i can get it sorted.
I haven't been adding anything new, the only coding i do are fixes (at present)..
The only thing i need wilderness to do, via another command, is build a building (the zero number would be changed).
and set the players name (to replace the null). Once thats done it should be smooth sailing.
Not sure or dont remember why AOH ran high on godwars.net, but it runs consistantly with 1% cpu and 4.5 MEM..
I'm gonna take another look at an expanded building system tonight or soon. (its been a while since i worked on what i was trying to do,
and have to remember/pick up where i left off.)
16 Apr, 2014, Xrakisis wrote in the 11th comment:
Votes: 0
syntax: constr dwelling slate berch
You build a Dwelling, here at X14 Y986.
Zone saved.

syntax: constr dwelling marble berch.. Crash

#0 0xb7611453 in re_search_internal () from /lib/libc.so.6
#1 0xb75e6f62 in strftime_l () from /lib/libc.so.6
#2 0x0818fd2f in wild_write (x=0, y=9) at wild_io.c:69
#3 0x0818a0e6 in do_wsave (ch=0xb4fae458, argument=0x83f6630 "zone") at wild_cmd.c:89
#4 0x0818d5a2 in do_construct (ch=0xb4fae458, argument=0xb4fae0ef "dwelling marble berch") at wild_cmd.c:2261
#5 0x080de34c in interpret (ch=0xb4fae458, argument=0xb4fae0ef "dwelling marble berch") at interp.c:1489
#6 0x0809d237 in game_loop_unix (control=4) at comm.c:868
#7 0x0809cb7d in main (argc=4, argv=0xbfd797c4) at comm.c:475



wild_io.c
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;
}



wild_data.c

static char vmap_data [WILDERNESS_SIZE] [WILDERNESS_SIZE];
static char bmap_data [WILDERNESS_SIZE] [WILDERNESS_SIZE];
static char omap_data [WILDERNESS_SIZE] [WILDERNESS_SIZE];


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 );
}
16 Apr, 2014, Xrakisis wrote in the 12th comment:
Votes: 0
Wsave Zone
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;
}
16 Apr, 2014, Xrakisis wrote in the 13th comment:
Votes: 0
There still seems to be an issue with movement.. its a little off,
but construct is working.. and the loading and saving of the 3 variables for each coordinate.
Since i use my material system for the foundation and wood type, i should probably save
those 2 for each coord as well. (for a nicer desc, adding more onto the dynamic descriptions)
And to make it actually matter what is used in construction.
I gotta turn the 3 number values into words, still gotta have the define numbers correlate to the foundation, wood-type, and building name.
16 Apr, 2014, Davion wrote in the 14th comment:
Votes: 0
What is at line 69 (:devil:) of wild_io.c. Don't see anything calling strftime.
16 Apr, 2014, Xrakisis wrote in the 15th comment:
Votes: 0
I'm not sure.. I changed most of the above code, at least slightly, so nano +69 wild_io.c wont bring me back to that spot.
16 Apr, 2014, quixadhal wrote in the 16th comment:
Votes: 0
What's being passed to strftime? It expect to get a writeable char pointer, and a size that ensures it doesn't overrun that buffer you pre-allocated for it… which is 99% likely to be the reason for a crash from it.
0.0/16