[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  SWR slicing snippet

SWR slicing snippet

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Jason   (109 posts)  [Biography] bio
Date Sat 22 Nov 2003 05:14 AM (UTC)
Message
I'm looking for a snippet for my swr mud. where might i find some for slicing?.. ad help would be thanked.
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #1 on Sat 22 Nov 2003 08:34 PM (UTC)
Message
Hmm, the SWFotE codebase had slicing in it. Perhaps you could rip it from there, and add it to your mud. As for the snippet, I've never seen one.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Greven   Canada  (835 posts)  [Biography] bio
Date Reply #2 on Sun 23 Nov 2003 01:34 AM (UTC)
Message
What is it in 'sliciing' that your looking for? There's lots of things that a slicer would do, its practically a class, so you might wanna specify what your looking for.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
[Go to top] top

Posted by Jason   (109 posts)  [Biography] bio
Date Reply #3 on Mon 08 Dec 2003 11:30 PM (UTC)
Message
well i was looking for the whole class... but i am taking from the SWFOTE code... but i have encountered a problem if any one can i'd be most please.... it has to do with the showbeacon command here is where my debugger is saying this is the problem in interp.c

char *one_argument( char *argument, char *arg_first )
{
char cEnd;
sh_int count;

count = 0;

while ( isspace(*argument) )
argument++;

cEnd = ' ';
if ( *argument == '\'' || *argument == '"' )
cEnd = *argument++;

while ( *argument != '\0' || ++count >= 255 )
{
if ( *argument == cEnd )
{
argument++;
break;
}
*arg_first = LOWER(*argument);
arg_first++;
argument++;
}
*arg_first = '\0';

while ( isspace(*argument) )
argument++;

return argument;
}

HERE IS THE CODE FOR The skill (show beacons crashes the mud as soon as used)

void do_showbeacons( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
SHIP_DATA *ship2;
char buf[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char buf3[MAX_STRING_LENGTH];
int count = 0;

if(IS_NPC(ch)) return;
if (number_percent() > ch->pcdata->learned[gsn_showbeacons])
{
send_to_char("You can't figure out what to do.\n\r", ch);
learn_from_failure(ch,gsn_showbeacons);
return;
}

send_to_char("\n\r",ch);
send_to_char("&zRequesting response from active locator beacons...\n\r", ch);
send_to_char("&w__________________________________________________\n\r\n\r",ch);

for ( ship = first_ship; ship; ship = ship->next )
{
if(is_name(ch->name, ship->pbeacon))
{
if(!ship->in_room && ship->shipstate != SHIP_HYPERSPACE)
sprintf(buf3, "&w%.0f&z, &w%.0f&z, &w%.0f", ship->vx, ship->vy, ship->vz);
if(ship->shipstate == SHIP_HYPERSPACE)
sprintf(buf3, "In Hyperspace");

for(ship2 = first_ship; ship2; ship2 = ship2->next)
{
if(ship->in_room)
{
if(ship->in_room->vnum == ship2->hanger1)
{
sprintf(buf, "%s", ship2->name);
sprintf(buf2, "%s", ship->in_room->name);
break;
}
if(ship->in_room->vnum == ship2->hanger2)
{
sprintf(buf, "%s", ship2->name);
sprintf(buf2, "%s", ship->in_room->name);
break;
}
if(ship->in_room->vnum == ship2->hanger3)
{
sprintf(buf, "%s", ship2->name);
sprintf(buf2, "%s", ship->in_room->name);
break;
}
if(ship->in_room->vnum == ship2->hanger4)
{
sprintf(buf, "%s", ship2->name);
sprintf(buf2, "%s", ship->in_room->name);
break;
}
}
}

ch_printf(ch,"^g&xACTIVE^x&z: &w%-15.15s&z Location:&w %s &z(&w%s&z)&w\n\r", ship->name,

(ship->in_room && ship->in_room->area->planet) ?
ship->in_room->area->planet->name :
(ship->in_room && !ship->in_room->area->planet) ?
buf :
(!ship->in_room && ship->starsystem) ? ship->starsystem->name :
ship->shipstate == SHIP_HYPERSPACE ? "Unknown" : "Unknown",

(ship->in_room && ship->in_room->area->planet) ?
ship->in_room->name :
(ship->in_room && !ship->in_room->area->planet) ?
buf2 :
ship->shipstate == SHIP_HYPERSPACE ? "In Hyperspace" :
(!ship->in_room) ? buf3 : "Unknown");
count++;
}
}
if(count == 0)
send_to_char(" &zNo active beacons found.\n\r", ch);
learn_from_success(ch,gsn_showbeacons);
}
[Go to top] top

Posted by Jason   (109 posts)  [Biography] bio
Date Reply #4 on Mon 08 Dec 2003 11:31 PM (UTC)
Message
this is the only skill i am having problems with so far... everything else i have gotten to work.
[Go to top] top

Posted by Jason   (109 posts)  [Biography] bio
Date Reply #5 on Mon 08 Dec 2003 11:32 PM (UTC)
Message
oh the debugger is saying that the problem is with this line of that code:

while ( isspace(*argument) )
argument++;


The first one.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #6 on Mon 08 Dec 2003 11:40 PM (UTC)
Message
The first thing you need to figure out, if you think that the beacon command is causing the problem, is why you ever entered one_argument even though it's never called in the function.

In your debugger you should do a backtrace and see what functions were called when from where... at the moment you don't have enough information to do much of anything. I'm sure that (unless you modified it) the one_argument function works just fine, as long as you call it with valid arguments.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Jason   (109 posts)  [Biography] bio
Date Reply #7 on Tue 09 Dec 2003 12:27 AM (UTC)
Message
ok i did a back trace and here is what i got:
char *one_argument( char *argument, char *arg_first )
{
char cEnd;
sh_int count;

count = 0;

HERE--->while ( isspace(*argument) )
argument++;

cEnd = ' ';
if ( *argument == '\'' || *argument == '"' )
cEnd = *argument++;
Then it went to handler.c and this is what it has:
bool is_name( const char *str, char *namelist )
{
HERE--->char name[MAX_INPUT_LENGTH];

for ( ; ; )
{
namelist = one_argument( namelist, name );
if ( name[0] == '\0' )
return FALSE;
if ( !str_cmp( str, name ) )
return TRUE;
}
}
Then it went to do showbeacons
void do_showbeacons( CHAR_DATA *ch, char *argument )
{
SHIP_DATA *ship;
SHIP_DATA *ship2;
char buf[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char buf3[MAX_STRING_LENGTH];
int count = 0;

if(IS_NPC(ch)) return;
if (number_percent() > ch->pcdata->learned[gsn_showbeacons])
{
send_to_char("You can't figure out what to do.\n\r", ch);
learn_from_failure(ch,gsn_showbeacons);
return;
}

send_to_char("\n\r",ch);
send_to_char("&zRequesting response from active locator beacons...\n\r", ch);
send_to_char("&w__________________________________________________\n\r\n\r",ch);

for ( ship = first_ship; ship; ship = ship->next )
{
HERE--->if(is_name(ch->name, ship->pbeacon))
{
if(!ship->in_room && ship->shipstate != SHIP_HYPERSPACE)
sprintf(buf3, "&w%.0f&z, &w%.0f&z, &w%.0f", ship->vx, ship->vy, ship->vz);
if(ship->shipstate == SHIP_HYPERSPACE)
sprintf(buf3, "In Hyperspace");

for(ship2 = first_ship; ship2; ship2 = ship2->next)
{
if(ship->in_room)
{
if(ship->in_room->vnum == ship2->hanger1)
{
sprintf(buf, "%s", ship2->name);
sprintf(buf2, "%s", ship->in_room->name);
break;
}
if(ship->in_room->vnum == ship2->hanger2)
{
sprintf(buf, "%s", ship2->name);
sprintf(buf2, "%s", ship->in_room->name);
break;
}
if(ship->in_room->vnum == ship2->hanger3)
{
sprintf(buf, "%s", ship2->name);
sprintf(buf2, "%s", ship->in_room->name);
break;
}
if(ship->in_room->vnum == ship2->hanger4)
{
sprintf(buf, "%s", ship2->name);
sprintf(buf2, "%s", ship->in_room->name);
break;
}
}
}

ch_printf(ch,"^g&xACTIVE^x&z: &w%-15.15s&z Location:&w %s &z(&w%s&z)&w\n\r", ship->name,

(ship->in_room && ship->in_room->area->planet) ?
ship->in_room->area->planet->name :
(ship->in_room && !ship->in_room->area->planet) ?
buf :
(!ship->in_room && ship->starsystem) ? ship->starsystem->name :
ship->shipstate == SHIP_HYPERSPACE ? "Unknown" : "Unknown",

(ship->in_room && ship->in_room->area->planet) ?
ship->in_room->name :
(ship->in_room && !ship->in_room->area->planet) ?
buf2 :
ship->shipstate == SHIP_HYPERSPACE ? "In Hyperspace" :
(!ship->in_room) ? buf3 : "Unknown");
count++;
}
}
if(count == 0)
send_to_char(" &zNo active beacons found.\n\r", ch);
learn_from_success(ch,gsn_showbeacons);
}
THEN IT WENT TO intrep.c and it is:
/*
* Look for command in skill and socials table.
*/
if ( !found )
{
HERE--->( !check_skill( ch, command, argument )
&& !check_social( ch, command, argument ) )
{
EXIT_DATA *pexit;

/* check for an auto-matic exit command */
if ( (pexit = find_door( ch, command, TRUE )) != NULL
&& IS_SET( pexit->exit_info, EX_xAUTO ))
{
if ( IS_SET(pexit->exit_info, EX_CLOSED)
&& (!IS_AFFECTED(ch, AFF_PASS_DOOR)
|| IS_SET(pexit->exit_info, EX_NOPASSDOOR)) )
{
if ( !IS_SET( pexit->exit_info, EX_SECRET ) )
act( AT_PLAIN, "The $d is closed.", ch, NULL, pexit->keyword, TO_CHAR );
else
send_to_char( "You cannot do that here.\n\r", ch );
return;
}
move_char( ch, pexit, 0 );
return;
}
send_to_char( "Huh?\n\r", ch );
}
return;
}
then it went to comm.c and i got:
[Go to top] top

Posted by Jason   (109 posts)  [Biography] bio
Date Reply #8 on Tue 09 Dec 2003 12:27 AM (UTC)
Message
void game_loop( )
{
struct timeval last_time;
char cmdline[MAX_INPUT_LENGTH];
DESCRIPTOR_DATA *d;
/* time_t last_check = 0; */

signal( SIGPIPE, SIG_IGN );
signal( SIGALRM, caught_alarm );
/* signal( SIGSEGV, SegVio ); */
gettimeofday( &last_time, NULL );
current_time = (time_t) last_time.tv_sec;

/* Main loop */
while ( !mud_down )
{
accept_new( control );
accept_new( control2 );
accept_new( conclient);
accept_new( conjava );
/*
* Kick out descriptors with raised exceptions
* or have been idle, then check for input.
*/
for ( d = first_descriptor; d; d = d_next )
{
if ( d == d->next )
{
bug( "descriptor_loop: loop found & fixed" );
d->next = NULL;
}
d_next = d->next;

d->idle++; /* make it so a descriptor can idle out */
if ( FD_ISSET( d->descriptor, &exc_set ) )
{
FD_CLR( d->descriptor, &in_set );
FD_CLR( d->descriptor, &out_set );
if ( d->character
&& ( d->connected == CON_PLAYING
|| d->connected == CON_EDITING ) )
save_char_obj( d->character );
d->outtop = 0;
close_socket( d, TRUE );
continue;
}
else
if ( (!d->character && d->idle > 360) /* 2 mins */
|| ( d->connected != CON_PLAYING && d->idle > 1200) /* 5 mins */
|| d->idle > 28800 ) /* 2 hrs */
{
write_to_descriptor( d->descriptor,
"Idle timeout... disconnecting.\n\r", 0 );
d->outtop = 0;
close_socket( d, TRUE );
continue;
}
else if (d->idle > 3600 && (d->character) && !IS_SET(d->character->act, PLR_AFK))
{
send_to_char("Idle for 15minutes, AFK has been automatically set on you.\n\r", d->character);
do_afk(d->character, "");
continue;
}
else
{
d->fcommand = FALSE;

if ( FD_ISSET( d->descriptor, &in_set ) )
{
d->idle = 0;
if ( d->character )
d->character->timer = 0;
if ( !read_from_descriptor( d ) )
{
FD_CLR( d->descriptor, &out_set );
if ( d->character
&& ( d->connected == CON_PLAYING
|| d->connected == CON_EDITING ) )
save_char_obj( d->character );
d->outtop = 0;
close_socket( d, FALSE );
continue;
}
}

/* IDENT authentication */
if ( ( d->auth_fd == -1 ) && ( d->atimes < 20 )
&& !str_cmp( d->user, "unknown" ) )
start_auth( d );

if ( d->auth_fd != -1)
{
if ( FD_ISSET( d->auth_fd, &in_set ) )
{
read_auth( d );
/* if ( !d->auth_state )
check_ban( d );*/
}
else
if ( FD_ISSET( d->auth_fd, &out_set )
&& IS_SET( d->auth_state, FLAG_WRAUTH) )
{
send_auth( d );
/* if ( !d->auth_state )
check_ban( d );*/
}
}
if ( d->character && d->character->wait > 0 )
{
--d->character->wait;
continue;
}

read_from_buffer( d );
if ( d->incomm[0] != '\0' )
{
d->fcommand = TRUE;
stop_idling( d->character );

strcpy( cmdline, d->incomm );
d->incomm[0] = '\0';

if ( d->character )
set_cur_char( d->character );

if ( d->pagepoint )
set_pager_input(d, cmdline);
else
switch( d->connected )
{
default:
nanny( d, cmdline );
break;
case CON_PLAYING:
HERE---> interpret( d->character, cmdline );
break;
case CON_EDITING:
edit_buffer( d->character, cmdline );
break;
}
}
}
if ( d == last_descriptor )
break;
}
then it went to comm.c again and i got
game_loop( );
/*
* That's all, folks.
*/
log_string( "Normal termination of game." );
exit( 0 );
return 0;
}


Hope fully you can help with this
[Go to top] top

Posted by Jason   (109 posts)  [Biography] bio
Date Reply #9 on Tue 09 Dec 2003 12:28 AM (UTC)
Message
ALL LINES THAT HAD ERROR IS MARKED WITH HERE---->
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #10 on Tue 09 Dec 2003 12:48 AM (UTC)
Message
Format that properly and make it readable using the [code] [/code] tags and I'll go through it... :)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #11 on Tue 09 Dec 2003 12:57 AM (UTC)
Message
And you also posted a whole bunch of completely irrelevant code... if you know that the bad code is from do_showbeacons onwards, then why are you posting the network and main loop code?

Maybe you should do a search on Google for how to use the debugger program, or how to debug code efficiently...

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (22,973 posts)  [Biography] bio   Forum Administrator
Date Reply #12 on Tue 09 Dec 2003 03:44 AM (UTC)
Message
Quote:

while ( isspace(*argument) )
argument++;


About the only way these lines could go wrong is if "argument" is invalid, eg. null (zero) or not pointing to a valid portion of memory.

In the debugger, see what "argument" is.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by halkeye   Canada  (28 posts)  [Biography] bio
Date Reply #13 on Tue 16 Dec 2003 08:48 AM (UTC)
Message
[quote]if(is_name(ch->name, ship->pbeacon))[/quote]
I know for a fact that line calls one_argument.

I'd suggest making sure that ship->pbeacon is not null. And it defanatly would not hurt to throw in a line one_argument (and one_argument2, and probably all the is_name and such) such as:

[code]if (argument == NULL) return NULL;[/code]

~ Gavin


Gavin
Dark Warriors - Coder
http://darkwars.wolfpaw.net
telnet://darkwars.wolfpaw.net:4848
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


26,554 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]