I know I asked this before, and you said it was a destination buffer but I have an example from my SWR based MUD and I just wanted to ask a few questions. First I'll put in the example...
switch( ch->substate )
{
default:
if ( arg[0] == '\0' )
{
send_to_char( "&RUsage: Makeblade <name>\n\r&w", ch);
return;
}
checktool = FALSE;
checkdura = FALSE;
checkbatt = FALSE;
checkoven = FALSE;
if ( !IS_SET( ch->in_room->room_flags, ROOM_FACTORY ) )
{
send_to_char( "&RYou need to be in a factory or workshop to do that.\n\r", ch);
return;
}
for ( obj = ch->last_carrying; obj; obj = obj->prev_content )
{
if (obj->item_type == ITEM_TOOLKIT)
checktool = TRUE;
if (obj->item_type == ITEM_DURASTEEL)
checkdura = TRUE;
if (obj->item_type == ITEM_BATTERY)
checkbatt = TRUE;
if (obj->item_type == ITEM_OVEN)
checkoven = TRUE;
}
if ( !checktool )
{
send_to_char( "&RYou need toolkit to make a vibro-blade.\n\r", ch);
return;
}
if ( !checkdura )
{
send_to_char( "&RYou need something to make it out of.\n\r", ch);
return;
}
if ( !checkbatt )
{
send_to_char( "&RYou need a power source for your blade.\n\r", ch);
return;
}
if ( !checkoven )
{
send_to_char( "&RYou need a small furnace to heat the metal.\n\r", ch);
return;
}
chance = IS_NPC(ch) ? ch->top_level
: (int) (ch->pcdata->learned[gsn_makeblade]);
if ( number_percent( ) < chance )
{
send_to_char( "&GYou begin the long process of crafting a vibroblade.\n\r", ch);
act( AT_PLAIN, "$n takes $s tools and a small oven and begins to work on something.", ch,
NULL, argument , TO_ROOM );
add_timer ( ch , TIMER_DO_FUN , 25 , do_makeblade , 1 );
ch->dest_buf = str_dup(arg);
return;
}
send_to_char("&RYou can't figure out how to fit the parts together.\n\r",ch);
learn_from_failure( ch, gsn_makeblade );
return;
case 1:
if ( !ch->dest_buf )
return;
strcpy(arg, ch->dest_buf);
DISPOSE( ch->dest_buf);
break;
case SUB_TIMER_DO_ABORT:
DISPOSE( ch->dest_buf );
ch->substate = SUB_NONE;
send_to_char("&RYou are interupted and fail to finish your work.\n\r", ch);
return;
}
ch->substate = SUB_NONE;
Alright, there is more code but that is the section I have questions on. And yes, I know this is a timer....
Question 1: What exactly is dest_buf used for?
Question 2: Some codes like this use dest_buf_2, how do I know of I need to use dest_buf_2?
Question 3: Dest_buf and dest_buf_2 are defined as void, shouldn't they be defined with other values?
Question 4: Could I switch the ch->substate in the switch statement to ch->cusstate? I'm making a code that involves a lot of timers and I just wanted to make sure I knew how all of this stuff worked so I didn't sit there for hours wondering why.
Thanks for any and all help. I really appreciate it.
switch( ch->substate )
{
default:
if ( arg[0] == '\0' )
{
send_to_char( "&RUsage: Makeblade <name>\n\r&w", ch);
return;
}
checktool = FALSE;
checkdura = FALSE;
checkbatt = FALSE;
checkoven = FALSE;
if ( !IS_SET( ch->in_room->room_flags, ROOM_FACTORY ) )
{
send_to_char( "&RYou need to be in a factory or workshop to do that.\n\r", ch);
return;
}
for ( obj = ch->last_carrying; obj; obj = obj->prev_content )
{
if (obj->item_type == ITEM_TOOLKIT)
checktool = TRUE;
if (obj->item_type == ITEM_DURASTEEL)
checkdura = TRUE;
if (obj->item_type == ITEM_BATTERY)
checkbatt = TRUE;
if (obj->item_type == ITEM_OVEN)
checkoven = TRUE;
}
if ( !checktool )
{
send_to_char( "&RYou need toolkit to make a vibro-blade.\n\r", ch);
return;
}
if ( !checkdura )
{
send_to_char( "&RYou need something to make it out of.\n\r", ch);
return;
}
if ( !checkbatt )
{
send_to_char( "&RYou need a power source for your blade.\n\r", ch);
return;
}
if ( !checkoven )
{
send_to_char( "&RYou need a small furnace to heat the metal.\n\r", ch);
return;
}
chance = IS_NPC(ch) ? ch->top_level
: (int) (ch->pcdata->learned[gsn_makeblade]);
if ( number_percent( ) < chance )
{
send_to_char( "&GYou begin the long process of crafting a vibroblade.\n\r", ch);
act( AT_PLAIN, "$n takes $s tools and a small oven and begins to work on something.", ch,
NULL, argument , TO_ROOM );
add_timer ( ch , TIMER_DO_FUN , 25 , do_makeblade , 1 );
ch->dest_buf = str_dup(arg);
return;
}
send_to_char("&RYou can't figure out how to fit the parts together.\n\r",ch);
learn_from_failure( ch, gsn_makeblade );
return;
case 1:
if ( !ch->dest_buf )
return;
strcpy(arg, ch->dest_buf);
DISPOSE( ch->dest_buf);
break;
case SUB_TIMER_DO_ABORT:
DISPOSE( ch->dest_buf );
ch->substate = SUB_NONE;
send_to_char("&RYou are interupted and fail to finish your work.\n\r", ch);
return;
}
ch->substate = SUB_NONE;
Alright, there is more code but that is the section I have questions on. And yes, I know this is a timer....
Question 1: What exactly is dest_buf used for?
Question 2: Some codes like this use dest_buf_2, how do I know of I need to use dest_buf_2?
Question 3: Dest_buf and dest_buf_2 are defined as void, shouldn't they be defined with other values?
Question 4: Could I switch the ch->substate in the switch statement to ch->cusstate? I'm making a code that involves a lot of timers and I just wanted to make sure I knew how all of this stuff worked so I didn't sit there for hours wondering why.
Thanks for any and all help. I really appreciate it.