Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 Couple bugs
Today, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, DotBot, Google, Yahoo!

Members: 0
Guests: 8
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SmaugFUSS » fly a kitty
Forum Rules | Mark all | Recent Posts

fly a kitty
< Newer Topic :: Older Topic >

Pages:<< prev 1, 2 next >>
Post is unread #1 Apr 24, 2013, 10:26 am
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

Hi!!
First I'm not a coder. So take it easy please. I'm working on a harry potter mud. What I want is to change the way people cast the spells. I'm using SMAUGFUSS19
Ex:
-say fly.
You rise into the air.
-say hello
You say 'hello'
-say fly a kitty
You say 'fly a kitty'
-point cat
-say fly
A cat rises into the air.
-point self
You get a nice core "Segmentation fault" :S:S:S

What I tried:

int aAbort;

void *locate_objectives( CHAR_DATA * ch, char *arg, CHAR_DATA ** victim, OBJ_DATA ** obj )
{
   void *vo = NULL;

   *victim = NULL;
   *obj = NULL;


   if(( ( *victim = get_char_room( ch, arg ) ) == NULL ) && ( ( *obj = get_obj_carry( ch, arg ) ) == NULL ) &&
   ( ( *obj = get_obj_here( ch, arg ) ) == NULL ) )
   {
           send_to_char( "Nop.\r\n", ch );
           return &aAbort;
   }

   return vo;   
}

CMDF( do_pointing )
{
   char arg[MIL];
   OBJ_DATA *wand;
   CHAR_DATA *victim;
   OBJ_DATA *obj;
   char buf[MSL];
   void *vo = NULL;
   
    wand = get_eq_char(ch,WEAR_HOLD);
    argument = one_argument ( argument, arg );
	if (wand == NULL || wand->item_type != ITEM_WAND)
    {
        send_to_char("You need to hold a wand to point with.\n\r",ch);
        return;
    }
    if( arg[0] == '\0' )
    {
        send_to_char( "Point what?\r\n", ch );
        return;
    }
	vo = locate_objectives( ch, arg, &victim, &obj );
	 if( vo == &aAbort )
        return;
	else
	{
        sprintf( buf, "%s.\n\r", arg );
        send_to_char( buf, ch);
	    DISPOSE( ch->pcdata->pointing );   // <-This gives me problems
	    ch->pcdata->pointing = str_dup ( arg );
        return;
	}	
}


and

CMDF( do_say )
{
   char buf[MSL];
   CHAR_DATA *vch;
   EXT_BV actflags;
   int sn;   
   char arg[MIL];
   char arg1[MIL];
   const char *pointing;   
#ifndef SCRAMBLE
   int speaking = -1, lang;

   for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      if( ch->speaking & lang_array[lang] )
      {
         speaking = lang;
         break;
      }
#endif

   if( argument[0] == '\0' )
   {
      send_to_char( "Say what?\r\n", ch );
      return;
   }
   argument = one_argument( argument, arg );
   argument = one_argument( argument, arg1 );
   pointing = ch->pcdata->pointing;
   if ( pointing[0] == '\0')
   {
	if( ( ( sn = find_spell( ch, arg, TRUE ) ) >= 0 ) && arg1[0] == '\0' )
	{
      do_cast( ch, arg );
	  ch_printf( ch, "case 1:%s\r\n",arg );
      return;
	}
   }
   if ( pointing[0] != '\0')
   {
	char buf1[MSL];
    char buf2[MSL];
	sprintf( buf2, "%s", ch->pcdata->pointing);
	sprintf( buf1, "%s %s", arg, pointing);
	DISPOSE( ch->pcdata->pointing );   // <-This gives me problems
	pointing = str_dup ( buf1 );
	if( ( ( sn = find_spell( ch, arg, TRUE ) ) >= 0 ) && arg1[0] == '\0' )
	{
	ch_printf( ch, "&cCase 2:%s\n\r", pointing);
      do_cast( ch, pointing );
	DISPOSE( ch->pcdata->pointing );    // <-This gives me problems
	pointing = str_dup ( buf2 );
      return;
	}
   }
...


I tried to do it with the STRFREE & STRALLOC but then it says: STRFREEing bad pointer:blablabla..
If I use no STRFREE and no str_dup at all I get something like this:

Len: 0 Lnks: 2 Str:
Total strings in hash 0: 1
Len: 3 Lnks: 1 Str: cat
Total strings in hash 3: 1
Len: 4 Lnks: 15 Str: self
Total strings in hash 4: 1
Len: 7 Lnks: 1 Str: fly cat
...

I checked and double checked it in every ocasion, when I used STRFREE I used it everywhere with STRALLOC, and when I used str_dup, I used DISPOSE. I duplicated the way other char data gets stored in mud.h and save.c and I'm completly lost by now.

Any Idea of how it should be?
Please don't ask me why I'm doing it this way, It just seemed it could work and I tried.
Thanks for your time.
       
Post is unread #2 Apr 24, 2013, 11:45 am
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

In this case, I get the feeling

	    DISPOSE( ch->pcdata->pointing );   // <-This gives me problems


Is crashing because at times ch->pcdata->pointing could be null?
       
Post is unread #3 Apr 24, 2013, 3:24 pm   Last edited Apr 24, 2013, 3:25 pm by Remcon
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

try these
void *locate_objectives( CHAR_DATA * ch, char *arg, CHAR_DATA ** victim, OBJ_DATA ** obj )
{
   void *vo = NULL;

   *victim = NULL;
   *obj = NULL;


   if( ( ( *victim = get_char_room( ch, arg ) ) == NULL )
   && ( ( *obj = get_obj_carry( ch, arg ) ) == NULL )
   && ( ( *obj = get_obj_here( ch, arg ) ) == NULL ) )
   {
      send_to_char( "Nop.\r\n", ch );
      return NULL;
   }

   return vo;   
}

CMDF( do_pointing )
{
   char arg[MIL];
   OBJ_DATA *wand;
   CHAR_DATA *victim;
   OBJ_DATA *obj;
   char buf[MSL];
   void *vo = NULL;
   
    wand = get_eq_char(ch,WEAR_HOLD);
    argument = one_argument ( argument, arg );
    if (wand == NULL || wand->item_type != ITEM_WAND)
    {
        send_to_char("You need to hold a wand to point with.\n\r",ch);
        return;
    }
    if( arg[0] == '\0' )
    {
        send_to_char( "Point what?\r\n", ch );
        return;
    }

    if( !( vo = locate_objectives( ch, arg, &victim, &obj ) ) )
       return;
    else
    {
       sprintf( buf, "%s.\n\r", arg );
       send_to_char( buf, ch);
       if( ch->pcdata->pointing )
          DISPOSE( ch->pcdata->pointing );
       ch->pcdata->pointing = str_dup ( arg );
       return;
   }
}

CMDF( do_say )
{
   char buf[MSL];
   CHAR_DATA *vch;
   EXT_BV actflags;
   int sn;   
   char arg[MIL];
   char arg1[MIL];

#ifndef SCRAMBLE
   int speaking = -1, lang;

   for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      if( ch->speaking & lang_array[lang] )
      {
         speaking = lang;
         break;
      }
#endif

   if( argument[0] == '\0' )
   {
      send_to_char( "Say what?\r\n", ch );
      return;
   }
   argument = one_argument( argument, arg );
   argument = one_argument( argument, arg1 );

   if( ( sn = find_spell( ch, arg, TRUE ) ) >= 0 )
   {
      char buf1[MSL];

      /* We are pointing at someone/something, and didn't specify anyone else */
      if( ch->pcdata->pointing && ( !arg1 || arg1[0] == '\0' ) )
         snprintf( arg1, sizeof( arg1 ), "%s", ch->pcdata->pointing );


      /* Do this on yourself */
      if( !arg1 || arg1[0] == '\0' )
      {
         do_cast( ch, arg );
         return;
      }

      /* Do it on someone/something else */
      if( ch->pcdata->pointing )
         DISPOSE( ch->pcdata->pointing );
      ch->pcdata->pointing = str_dup( arg1 );

      snprintf( buf1, sizeof( buf1 ), "%s %s", arg, arg1 );
      do_cast( ch, buf1 );
      return;
   }
...

Let me know how it goes since I haven't tested it or anything.
       
Post is unread #4 Apr 24, 2013, 3:32 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005


I tried to do it with the STRFREE & STRALLOC but then it says: STRFREEing bad pointer:blablabla..
If I use no STRFREE and no str_dup at all I get something like this:

Len: 0 Lnks: 2 Str:
Total strings in hash 0: 1
Len: 3 Lnks: 1 Str: cat
Total strings in hash 3: 1
Len: 4 Lnks: 15 Str: self
Total strings in hash 4: 1
Len: 7 Lnks: 1 Str: fly cat
...

If you use STRALLOC you need to use STRFREE at some point to free it out or it will show in the hash later on since it is never freed. If you free it when it isn't set then you get the bad pointer message, if you DISPOSE of it then you have issues in other ways.

str_dup and DISPOSE don't add things to the hash strings but does have it in memory. At some point it needs DISPOSED of. the way i gave it to you has no default DISPOSE after use so it is set to keep the one they are pointing at, you could DISPOSE after it is used or if nothing else when they character logs off.
       
Post is unread #5 Apr 24, 2013, 4:01 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

First of all, thanks to both of you, Zeno and Remcon :)

When I've seen Zeno's post I added if( ch->pcdata->pointing ) before every DISPOSE,
and then it seemed to work but then if I say the same spell two consecutive times I get:
0x00403682 in do_say (ch=0x20377920, argument=0x22a7b3 "";) at act_comm.c:847
847        if ( pointing[0] == '\0')


Then I changed that line but then if I say the same spell two times, the second time I cast It on me insted of on the victim. And I stil get the "Len: 0 Lnks: 2 Str: Total strings in hash 0: 1 Len: 3 Lnks: 1 Str: cat " when I shutdown the mud.

At that point I saw Remcon's post and I tried what you say but...

act_comm.c:852:38: error: the address of ‘arg1’ will always evaluate as ‘true’
act_comm.c:857:12: error: the address of ‘arg1’ will always evaluate as ‘true’

lines 852 and 857 are that ones:

      /* We are pointing at someone/something, and didn't specify anyone else */
852      if( ch->pcdata->pointing && ( !arg1 || arg1[0] == '\0' ) )

      /* Do this on yourself */
857      if( !arg1 || arg1[0] == '\0' )


I tried changing them to:

852      if( ch->pcdata->pointing && ( arg1[0] == '\0' ) )
857      if( !arg1 || arg1[0] == '\0' )

and it compiled right, but I can't point to my victims, well I point to them, but when after pointing I say the spell I always try to cast it on myself. :S

And the Len: 0 Lnks: 2 Str:..... are there still. :(
       
Post is unread #6 Apr 24, 2013, 4:04 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

ok do me a favor and copy and paste what you currently have for them.
       
Post is unread #7 Apr 24, 2013, 4:13 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

well at this moment I'm working with two versions:

CMDF( do_say )
{
   char buf[MSL];
   CHAR_DATA *vch;
   EXT_BV actflags;
   int sn;   
   char arg[MIL];
   char arg1[MIL];

#ifndef SCRAMBLE
   int speaking = -1, lang;

   for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      if( ch->speaking & lang_array[lang] )
      {
         speaking = lang;
         break;
      }
#endif

   if( argument[0] == '\0' )
   {
      send_to_char( "Say what?\r\n", ch );
      return;
   }
   argument = one_argument( argument, arg );
   argument = one_argument( argument, arg1 );

   if( ( sn = find_spell( ch, arg, TRUE ) ) >= 0 )
   {
      char buf1[MSL];

      /* We are pointing at someone/something, and didn't specify anyone else */
      if( ch->pcdata->pointing && ( arg1[0] == '\0' ) )
         snprintf( arg1, sizeof( arg1 ), "%s", ch->pcdata->pointing );


      /* Do this on yourself */
      if( arg1[0] == '\0' )
      {
         do_cast( ch, arg );
         return;
      }

      /* Do it on someone/something else */
      if( ch->pcdata->pointing )
         DISPOSE( ch->pcdata->pointing );
      ch->pcdata->pointing = str_dup( arg1 );

      snprintf( buf1, sizeof( buf1 ), "%s %s", arg, arg1 );
      do_cast( ch, buf1 );
      return;
   }

void *locate_objectives( CHAR_DATA * ch, char *arg, CHAR_DATA ** victim, OBJ_DATA ** obj )
{
   void *vo = NULL;

   *victim = NULL;
   *obj = NULL;


   if( ( ( *victim = get_char_room( ch, arg ) ) == NULL )
   && ( ( *obj = get_obj_carry( ch, arg ) ) == NULL )
   && ( ( *obj = get_obj_here( ch, arg ) ) == NULL ) )
   {
      send_to_char( "Nop.\r\n", ch );
      return NULL;
   }

   return vo;   
}

CMDF( do_pointing )
{
   char arg[MIL];
   OBJ_DATA *wand;
   CHAR_DATA *victim;
   OBJ_DATA *obj;
   char buf[MSL];
   void *vo = NULL;
   
    wand = get_eq_char(ch,WEAR_HOLD);
    argument = one_argument ( argument, arg );
    if (wand == NULL || wand->item_type != ITEM_WAND)
    {
        send_to_char("You need to hold a wand to point with.\n\r",ch);
        return;
    }
    if( arg[0] == '\0' )
    {
        send_to_char( "Point what?\r\n", ch );
        return;
    }

    if( !( vo = locate_objectives( ch, arg, &victim, &obj ) ) )
       return;
    else
    {
       sprintf( buf, "%s.\n\r", arg );
       send_to_char( buf, ch);
       if( ch->pcdata->pointing )
          DISPOSE( ch->pcdata->pointing );
       ch->pcdata->pointing = str_dup ( arg );
       return;
   }
}


and

void *locate_objectives( CHAR_DATA * ch, char *arg, CHAR_DATA ** victim, OBJ_DATA ** obj )
{
   void *vo = NULL;

   *victim = NULL;
   *obj = NULL;


   if(( ( *victim = get_char_room( ch, arg ) ) == NULL ) && ( ( *obj = get_obj_carry( ch, arg ) ) == NULL ) &&
   ( ( *obj = get_obj_here( ch, arg ) ) == NULL ) )
   {
           send_to_char( "Nop.\r\n", ch );
           return &aAbort;
   }

   return vo;   
}

CMDF( do_pointing )
{
   char arg[MIL];
   OBJ_DATA *wand;
   CHAR_DATA *victim;
   OBJ_DATA *obj;
   char buf[MSL];
   void *vo = NULL;
   
    wand = get_eq_char(ch,WEAR_HOLD);
    argument = one_argument ( argument, arg );
	if (wand == NULL || wand->item_type != ITEM_WAND)
    {
        send_to_char("You need to hold a wand to point with.\n\r",ch);
        return;
    }
    if( arg[0] == '\0' )
    {
        send_to_char( "Point what?\r\n", ch );
        return;
    }
	vo = locate_objectives( ch, arg, &victim, &obj );
	 if( vo == &aAbort )
        return;
	else
	{
        sprintf( buf, "&c%s.&D\n\r", arg );
        send_to_char( buf, ch);
		if( ch->pcdata->pointing )
	    STRFREE( ch->pcdata->pointing );
	    ch->pcdata->pointing = STRALLOC ( arg );
        return;
	}	
}

CMDF( do_say )
{
   char buf[MSL];
   CHAR_DATA *vch;
   EXT_BV actflags;
   int sn;   
   char arg[MIL];
   char arg1[MIL];
   const char *pointing;   
#ifndef SCRAMBLE
   int speaking = -1, lang;

   for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      if( ch->speaking & lang_array[lang] )
      {
         speaking = lang;
         break;
      }
#endif

   if( argument[0] == '\0' )
   {
      send_to_char( "Say what?\r\n", ch );
      return;
   }
   argument = one_argument( argument, arg );
   argument = one_argument( argument, arg1 );
   pointing = ch->pcdata->pointing;
   if ( pointing == NULL )
   {
	if( ( ( sn = find_spell( ch, arg, TRUE ) ) >= 0 ) && arg1[0] == '\0' )
	{
      do_cast( ch, arg );
	  ch_printf( ch, "case 1:%s\r\n",arg );
      return;
	}
   }
   if ( pointing != NULL )
   {
	char buf1[MSL];
    char buf2[MSL];
	sprintf( buf2, "%s", ch->pcdata->pointing);
	sprintf( buf1, "%s %s", arg, pointing);
	if( ch->pcdata->pointing )
	STRFREE( ch->pcdata->pointing );
	pointing = STRALLOC ( buf1 );
	if( ( ( sn = find_spell( ch, arg, TRUE ) ) >= 0 ) && arg1[0] == '\0' )
	{
	ch_printf( ch, "&cCase 2:%s\n\r", pointing);
      do_cast( ch, pointing );
	if ( ch->pcdata->pointing );
	STRFREE( ch->pcdata->pointing );
	pointing = STRALLOC ( buf2 );
	ch_printf( ch, "&cCase 2bis:%s\n\r", pointing);
      return;
	}
   }
       
Post is unread #8 Apr 24, 2013, 4:37 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

The second version seems to work but,

point cat
cat.

<464hp 249m 740mv> <#1200> 
say fly
Case 2:fly cat
The cat rises into the currents of air...
Case 2bis:cat

<464hp 239m 740mv> <#1200> 
say fly
You failed.
case 1:fly


And I don't know why if the "Case 2bis" message says I'm still pointing to the cat, the second time I say fly, I try to cast it on me. :rolleyes:

And I can't seem to get rid of:

Len: 3 Lnks: 1 Str: cat
Total strings in hash 3: 1
Len: 7 Lnks: 1 Str: fly cat
Total strings in hash 7: 1
       
Post is unread #9 Apr 24, 2013, 4:44 pm   Last edited Apr 24, 2013, 4:44 pm by Remcon
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005


<24hp 145m 109mv> <#21004> point guard
You point at the guard.

<24hp 145m 109mv> <#21004> say2 fly
The guard rises into the currents of air...

<24hp 135m 109mv> <#21004> say2 fly self
You rise into the currents of air...

<24hp 125m 109mv> <#21004> say2 armor
Your armor begins to glow softly as it is enhanced by a cantrip.

<24hp 120m 109mv> <#21004> say2 armor guard
The guard's armor begins to glow softly as it is enhanced by a cantrip.

<24hp 115m 108mv> <#21003> say2 heal
You lay a hand of healing upon the guard.

Ok seems to work fine this way

void *locate_objectives( CHAR_DATA * ch, char *arg, CHAR_DATA ** victim, OBJ_DATA ** obj )
{
   void *vo = NULL;

   *victim = NULL;
   *obj = NULL;


   if( ( ( *victim = get_char_room( ch, arg ) ) == NULL )
   && ( ( *obj = get_obj_carry( ch, arg ) ) == NULL )
   && ( ( *obj = get_obj_here( ch, arg ) ) == NULL ) )
   {
      send_to_char( "Nop.\r\n", ch );
      return NULL;
   }

   if( victim )
      vo = victim;
   else if( obj )
      vo = obj;
   return vo;   
}

CMDF( do_pointing )
{
   char arg[MIL];
   OBJ_DATA *wand;
   CHAR_DATA *victim;
   OBJ_DATA *obj;
   void *vo = NULL;
   
    wand = get_eq_char(ch,WEAR_HOLD);
    argument = one_argument ( argument, arg );
    if (wand == NULL || wand->item_type != ITEM_WAND)
    {
        send_to_char("You need to hold a wand to point with.\n\r",ch);
        return;
    }
    if( arg == NULL || arg[0] == '\0' )
    {
        send_to_char( "Point what?\r\n", ch );
        return;
    }

    if( !( vo = locate_objectives( ch, arg, &victim, &obj ) ) )
       return;
    else
    {
       if( ch->pcdata->pointing )
          DISPOSE( ch->pcdata->pointing );
       ch->pcdata->pointing = str_dup ( arg );
       if( victim )
       {
          act( AT_ACTION, "$n points at $N.", ch, NULL, victim, TO_ROOM );
          act( AT_ACTION, "You point at $N.", ch, NULL, victim, TO_CHAR );
          act( AT_ACTION, "$n points at you.", ch, NULL, victim, TO_VICT );
       }
       return;
   }
}

CMDF( do_say2 )
{
   int sn;   
   char arg[MIL];
   char arg1[MIL];

#ifndef SCRAMBLE
   int speaking = -1, lang;

   for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      if( ch->speaking & lang_array[lang] )
      {
         speaking = lang;
         break;
      }
#endif

   if( argument[0] == '\0' )
   {
      send_to_char( "Say what?\r\n", ch );
      return;
   }
   argument = one_argument( argument, arg );
   argument = one_argument( argument, arg1 );

   if( ( sn = find_spell( ch, arg, TRUE ) ) >= 0 )
   {
      char buf1[MSL];

      /* We are pointing at someone/something, and didn't specify anyone else */
      if( ch->pcdata->pointing && ( arg1 == NULL || arg1[0] == '\0' ) )
         snprintf( arg1, sizeof( arg1 ), "%s", ch->pcdata->pointing );


      /* Do this on yourself */
      if( arg1 == NULL || arg1[0] == '\0' )
      {
         do_cast( ch, arg );
         return;
      }

      /* Do it on someone/something else */
      if( ch->pcdata->pointing )
         DISPOSE( ch->pcdata->pointing );
      ch->pcdata->pointing = str_dup( arg1 );

      snprintf( buf1, sizeof( buf1 ), "%s %s", arg, arg1 );
      do_cast( ch, buf1 );
      return;
   }
}

Youll notice I did it as a say2 just for testing so change that back or just set up yours like it.
       
Post is unread #10 Apr 24, 2013, 5:23 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

say cause
Cast the spell on whom?

<464hp 294m 740mv> <#1200>
say cause self
Cast this on yourself? Okay...

<424hp 284m 740mv> <#1200>
point cat
Nop.

<424hp 284m 740mv> <#1200>
point self
You point at Leia.

say cause
Cast this on yourself? Okay...


Ohh sorry.. the cat is dead!! :rofl:

And ooouuupss, look at what happened with the new cat:

point cat
Log: DISPOSE called on STRALLOC pointer: act_move.c, line 3066

Log: Attempting to correct.
You point at black cat.


But, but.... I used STRALLOC nowhere mmmm, rechecking... nop, nowhere :S

CMDF( do_pointing )
{
   char arg[MIL];
   OBJ_DATA *wand;
   CHAR_DATA *victim;
   OBJ_DATA *obj;
   void *vo = NULL;
   
    wand = get_eq_char(ch,WEAR_HOLD);
    argument = one_argument ( argument, arg );
    if (wand == NULL || wand->item_type != ITEM_WAND)
    {
        send_to_char("You need to hold a wand to point with.\n\r",ch);
        return;
    }
    if( arg == NULL || arg[0] == '\0' )
    {
        send_to_char( "Point what?\r\n", ch );
        return;
    }

    if( !( vo = locate_objectives( ch, arg, &victim, &obj ) ) )
       return;
    else
    {
       if( ch->pcdata->pointing )
          DISPOSE( ch->pcdata->pointing );    <---- line 3066
       ch->pcdata->pointing = str_dup ( arg );
       if( victim )
       {
          act( AT_ACTION, "$n points at $N.", ch, NULL, victim, TO_ROOM );
          act( AT_ACTION, "You point at $N.", ch, NULL, victim, TO_CHAR );
          act( AT_ACTION, "$n points at you.", ch, NULL, victim, TO_VICT );
       }
       return;
   }
}
       
Post is unread #11 Apr 24, 2013, 5:26 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

kk, post what your using, for do_say and do_pointing please :) personally i advise using STRALLOC and STRFREE for them anyways lol
       
Post is unread #12 Apr 24, 2013, 5:37 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

Aparently the "DISPOSE called on STRALLOC pointer" message disappeared without doing anything.

CMDF( do_pointing )
{
char arg[MIL];
OBJ_DATA *wand;
CHAR_DATA *victim;
OBJ_DATA *obj;
void *vo = NULL;

wand = get_eq_char(ch,WEAR_HOLD);
argument = one_argument ( argument, arg );
if (wand == NULL || wand->item_type != ITEM_WAND)
{
send_to_char("You need to hold a wand to point with.\n\r",ch);
return;
}
if( arg == NULL || arg[0] == '\0' )
{
send_to_char( "Point what?\r\n", ch );
return;
}

if( !( vo = locate_objectives( ch, arg, &victim, &obj ) ) )
return;
else
{
if( ch->pcdata->pointing )
DISPOSE( ch->pcdata->pointing );
ch->pcdata->pointing = str_dup ( arg );
if( victim )
{
act( AT_ACTION, "$n points at $N.", ch, NULL, victim, TO_ROOM );
act( AT_ACTION, "You point at $N.", ch, NULL, victim, TO_CHAR );
act( AT_ACTION, "$n points at you.", ch, NULL, victim, TO_VICT );
}
return;
}
}

CMDF( do_say )
{
char buf[MSL];
CHAR_DATA *vch;
EXT_BV actflags;
int sn;
char arg[MIL];
char arg1[MIL];

#ifndef SCRAMBLE
int speaking = -1, lang;

for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
if( ch->speaking & lang_array[lang] )
{
speaking = lang;
break;
}
#endif

if( argument[0] == '\0' )
{
send_to_char( "Say what?\r\n", ch );
return;
}
argument = one_argument( argument, arg );
argument = one_argument( argument, arg1 );

if( ( sn = find_spell( ch, arg, TRUE ) ) >= 0 )
{
char buf1[MSL];

/* We are pointing at someone/something, and didn't specify anyone else */
if( ch->pcdata->pointing && ( arg1 == NULL || arg1[0] == '\0' ) )
snprintf( arg1, sizeof( arg1 ), "%s", ch->pcdata->pointing );


/* Do this on yourself */
if( arg1 == NULL || arg1[0] == '\0' )
{
do_cast( ch, arg );
return;
}

/* Do it on someone/something else */
if( ch->pcdata->pointing )
DISPOSE( ch->pcdata->pointing );
ch->pcdata->pointing = str_dup( arg1 );

snprintf( buf1, sizeof( buf1 ), "%s %s", arg, arg1 );
do_cast( ch, buf1 );
return;
}
       
Post is unread #13 Apr 24, 2013, 5:43 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

is it working like it should? you know that the do_say looking like that won't actually say anything though right? you have to have it like the old do_say with the needed parts added in where you had them orginally
       
Post is unread #14 Apr 24, 2013, 7:18 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

It isn't working like it should.

First: that reapears the first time I say a spell or I point to something:
Log: DISPOSE called on STRALLOC pointer: act_comm.c, line 865
Log: Attempting to correct.


and the rest works but not as it should, if I type "say hello" the mud says "You say 'hello' but if I type "say fly a kite" the mud says You failed. The entire idea of using "point cat" "say fly" instead of "say fly cat" was to avoid that to happen. I'm not truly understanding how we use arg1. And it doesn't work if I change arg1 for something else.

CMDF( do_say )
{
   char buf[MSL];
   CHAR_DATA *vch;
   EXT_BV actflags;
   int sn;   
   char arg[MIL];
   char arg1[MIL];
   
#ifndef SCRAMBLE
   int speaking = -1, lang;

   for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      if( ch->speaking & lang_array[lang] )
      {
         speaking = lang;
         break;
      }
#endif

   if( argument[0] == '\0' )
   {
      send_to_char( "Say what?\r\n", ch );
      return;
   }
   argument = one_argument( argument, arg );
   argument = one_argument( argument, arg1 );

   if( ( sn = find_spell( ch, arg, TRUE ) ) >= 0 )
   {
      char buf1[MSL];

      /* We are pointing at someone/something, and didn't specify anyone else */
      if( ch->pcdata->pointing && ( arg1 == NULL || arg1[0] == '\0' ) )
         snprintf( arg1, sizeof( arg1 ), "%s", ch->pcdata->pointing );


      /* Do this on yourself */
      if( arg1 == NULL || arg1[0] == '\0' )
      {
         do_cast( ch, arg );
         return;
      }

      /* Do it on someone/something else */
      if( ch->pcdata->pointing )
         DISPOSE( ch->pcdata->pointing );
      ch->pcdata->pointing = str_dup( arg1 );

      snprintf( buf1, sizeof( buf1 ), "%s %s", arg, arg1 );
      do_cast( ch, buf1 );
      return;
   }

   if( xIS_SET( ch->in_room->room_flags, ROOM_SILENCE ) )
   {
      send_to_char( "You can't do that here.\r\n", ch );
      return;
   }

   actflags = ch->act;
   if( IS_NPC( ch ) )
      xREMOVE_BIT( ch->act, ACT_SECRETIVE );
   for( vch = ch->in_room->first_person; vch; vch = vch->next_in_room )
   {
      const char *sbuf = argument;

      if( vch == ch )
         continue;

      /*
       * Check to see if character is ignoring speaker 
       */
      if( is_ignoring( vch, ch ) )
      {
         /*
          * continue unless speaker is an immortal 
          */
         if( !IS_IMMORTAL( ch ) || get_trust( vch ) > get_trust( ch ) )
            continue;
         else
         {
            set_char_color( AT_IGNORE, vch );
            ch_printf( vch, "You attempt to ignore %s, but" " are unable to do so.\r\n", ch->name );
         }
      }

#ifndef SCRAMBLE
      if( speaking != -1 && ( !IS_NPC( ch ) || ch->speaking ) )
      {
         int speakswell = UMIN( knows_language( vch, ch->speaking, ch ),
                                knows_language( ch, ch->speaking, vch ) );

         if( speakswell < 75 )
            sbuf = translate( speakswell, argument, lang_names[speaking] );
      }
#else
      if( !knows_language( vch, ch->speaking, ch ) && ( !IS_NPC( ch ) || ch->speaking != 0 ) )
         sbuf = scramble( argument, ch->speaking );
#endif
      sbuf = drunk_speech( sbuf, ch );

      MOBtrigger = FALSE;
	  if (arg1[0] == '\0')
	  {
         ch_printf( vch, "&c%s say '", ch->name );
	     ch_printf( vch, "&w%s&c'", arg );
	  }
	  if ((arg1[0] != '\0') && (buf == '\0'))
	  {
         ch_printf( vch, "&c%s say '", ch->name );
	     ch_printf( vch, "&w%s", arg );
	     ch_printf( vch, " %s&c'", arg1 );
	  }
	  if ((arg1[0] != '\0') && (buf != '\0'))
	  {
         ch_printf( vch, "&c%s say '", ch->name );
	     ch_printf( vch, "&w%s", arg );
	     ch_printf( vch, " %s ", arg1 );
         act( AT_SAY, "$t&D'", ch, sbuf, vch, TO_VICT );
	  }	  
   }
/*    MOBtrigger = FALSE;
    act( AT_SAY, "$n says '$T'", ch, NULL, argument, TO_ROOM );*/
   ch->act = actflags;
   MOBtrigger = FALSE;
   
   if (arg1[0] == '\0')
   {
      ch_printf( ch, "&cYou say '&w%s&c'", arg );
   }
   if ((arg1[0] != '\0') && (buf == '\0'))
   {
      ch_printf( ch, "&cYou say '&w%s", arg );
      ch_printf( ch, " &w%s&c'", arg1 );
   }
   if ((arg1[0] != '\0') && (buf != '\0'))
   {
      ch_printf( ch, "&cYou say '&w%s", arg );
      ch_printf( ch, " &w%s ", arg1 );
      act( AT_SAY, "&w$T&c'&D", ch, NULL, drunk_speech( argument, ch ), TO_CHAR );
   }
   
   if( xIS_SET( ch->in_room->room_flags, ROOM_LOGSPEECH ) )
   {
      snprintf( buf, MSL, "%s: %s", IS_NPC( ch ) ? ch->short_descr : ch->name, argument );
      append_to_file( LOG_FILE, buf );
   }
   mprog_speech_trigger( argument, ch );
   if( char_died( ch ) )
      return;
   oprog_speech_trigger( argument, ch );
   if( char_died( ch ) )
      return;
   rprog_speech_trigger( argument, ch );
   return;
}

       
Post is unread #15 Apr 24, 2013, 7:25 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

whats your do_point looking like? it should work fine. you might want to check and make sure somewhere you aren't using STRALLOC on ch->pcdata->pointing or just go ahead and change those to use STRALLOC and STRFREE also
       
Post is unread #16 Apr 24, 2013, 7:57 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

I'm using STRALLOC and STRFREE now, and aparently all is formally fine.. But it isn't doing what it should.

point cat
You point at black cat.

say fly
Black cat rises into the currents of air...

say hello
You say 'Hello'

say fly a kite
They aren't here.


void *locate_objectives( CHAR_DATA * ch, char *arg, CHAR_DATA ** victim, OBJ_DATA ** obj )
{
   void *vo = NULL;

   *victim = NULL;
   *obj = NULL;


   if( ( ( *victim = get_char_room( ch, arg ) ) == NULL )
   && ( ( *obj = get_obj_carry( ch, arg ) ) == NULL )
   && ( ( *obj = get_obj_here( ch, arg ) ) == NULL ) )
   {
      send_to_char( "Nop.\r\n", ch );
      return NULL;
   }

   if( victim )
      vo = victim;
   else if( obj )
      vo = obj;
   return vo;   
}

CMDF( do_pointing )
{
   char arg[MIL];
   OBJ_DATA *wand;
   CHAR_DATA *victim;
   OBJ_DATA *obj;
   void *vo = NULL;
   
    wand = get_eq_char(ch,WEAR_HOLD);
    argument = one_argument ( argument, arg );
    if (wand == NULL || wand->item_type != ITEM_WAND)
    {
        send_to_char("You need to hold a wand to point with.\n\r",ch);
        return;
    }
    if( arg == NULL || arg[0] == '\0' )
    {
        send_to_char( "Point what?\r\n", ch );
        return;
    }

    if( !( vo = locate_objectives( ch, arg, &victim, &obj ) ) )
       return;
    else
    {
       if( ch->pcdata->pointing )
          STRFREE( ch->pcdata->pointing );
       ch->pcdata->pointing = STRALLOC ( arg );
       if( victim )
       {
          act( AT_ACTION, "$n points at $N.", ch, NULL, victim, TO_ROOM );
          act( AT_ACTION, "You point at $N.", ch, NULL, victim, TO_CHAR );
          act( AT_ACTION, "$n points at you.", ch, NULL, victim, TO_VICT );
       }
       return;
   }
}


CMDF( do_say )
{
   char buf[MSL];
   CHAR_DATA *vch;
   EXT_BV actflags;
   int sn;   
   char arg[MIL];
   char arg1[MIL];
   
#ifndef SCRAMBLE
   int speaking = -1, lang;

   for( lang = 0; lang_array[lang] != LANG_UNKNOWN; lang++ )
      if( ch->speaking & lang_array[lang] )
      {
         speaking = lang;
         break;
      }
#endif

   if( argument[0] == '\0' )
   {
      send_to_char( "Say what?\r\n", ch );
      return;
   }
   argument = one_argument( argument, arg );
   argument = one_argument( argument, arg1 );

   if( ( sn = find_spell( ch, arg, TRUE ) ) >= 0 )
   {
      char buf1[MSL];

      /* We are pointing at someone/something, and didn't specify anyone else */
      if( ch->pcdata->pointing && ( arg1 == NULL || arg1[0] == '\0' ) )
         snprintf( arg1, sizeof( arg1 ), "%s", ch->pcdata->pointing );


      /* Do this on yourself */
      if( arg1 == NULL || arg1[0] == '\0' )
      {
         do_cast( ch, arg );
         return;
      }

      /* Do it on someone/something else */
      if( ch->pcdata->pointing )
         STRFREE( ch->pcdata->pointing );
      ch->pcdata->pointing = STRALLOC( arg1 );

      snprintf( buf1, sizeof( buf1 ), "%s %s", arg, arg1 );
      do_cast( ch, buf1 );
      return;
   }

   if( xIS_SET( ch->in_room->room_flags, ROOM_SILENCE ) )
   {
      send_to_char( "You can't do that here.\r\n", ch );
      return;
   }

   actflags = ch->act;
   if( IS_NPC( ch ) )
      xREMOVE_BIT( ch->act, ACT_SECRETIVE );
   for( vch = ch->in_room->first_person; vch; vch = vch->next_in_room )
   {
      const char *sbuf = argument;

      if( vch == ch )
         continue;

      /*
       * Check to see if character is ignoring speaker 
       */
      if( is_ignoring( vch, ch ) )
      {
         /*
          * continue unless speaker is an immortal 
          */
         if( !IS_IMMORTAL( ch ) || get_trust( vch ) > get_trust( ch ) )
            continue;
         else
         {
            set_char_color( AT_IGNORE, vch );
            ch_printf( vch, "You attempt to ignore %s, but" " are unable to do so.\r\n", ch->name );
         }
      }

#ifndef SCRAMBLE
      if( speaking != -1 && ( !IS_NPC( ch ) || ch->speaking ) )
      {
         int speakswell = UMIN( knows_language( vch, ch->speaking, ch ),
                                knows_language( ch, ch->speaking, vch ) );

         if( speakswell < 75 )
            sbuf = translate( speakswell, argument, lang_names[speaking] );
      }
#else
      if( !knows_language( vch, ch->speaking, ch ) && ( !IS_NPC( ch ) || ch->speaking != 0 ) )
         sbuf = scramble( argument, ch->speaking );
#endif
      sbuf = drunk_speech( sbuf, ch );

      MOBtrigger = FALSE;                                     //notice this part where I try to send
	  if (arg1[0] == '\0')                         //the text if we aren't casting a spell.
         {                                                                
         ch_printf( vch, "&c%s say '", ch->name );
	     ch_printf( vch, "&w%s&c'", arg );
	  }
	  if ((arg1[0] != '\0') && (buf == '\0'))
	  {
         ch_printf( vch, "&c%s say '", ch->name );
	     ch_printf( vch, "&w%s", arg );
	     ch_printf( vch, " %s&c'", arg1 );
	  }
	  if ((arg1[0] != '\0') && (buf != '\0'))
	  {
         ch_printf( vch, "&c%s say '", ch->name );
	     ch_printf( vch, "&w%s", arg );
	     ch_printf( vch, " %s ", arg1 );
         act( AT_SAY, "$t&D'", ch, sbuf, vch, TO_VICT );
	  }	  
   }
/*    MOBtrigger = FALSE;
    act( AT_SAY, "$n says '$T'", ch, NULL, argument, TO_ROOM );*/
   ch->act = actflags;
   MOBtrigger = FALSE;
   
   if (arg1[0] == '\0')
   {
      ch_printf( ch, "&cYou say '&w%s&c'", arg );
   }
   if ((arg1[0] != '\0') && (buf == '\0'))
   {
      ch_printf( ch, "&cYou say '&w%s", arg );
      ch_printf( ch, " &w%s&c'", arg1 );
   }
   if ((arg1[0] != '\0') && (buf != '\0'))
   {
      ch_printf( ch, "&cYou say '&w%s", arg );
      ch_printf( ch, " &w%s ", arg1 );
      act( AT_SAY, "&w$T&c'&D", ch, NULL, drunk_speech( argument, ch ), TO_CHAR );
   }
   
   if( xIS_SET( ch->in_room->room_flags, ROOM_LOGSPEECH ) )
   {
      snprintf( buf, MSL, "%s: %s", IS_NPC( ch ) ? ch->short_descr : ch->name, argument );
      append_to_file( LOG_FILE, buf );
   }
   mprog_speech_trigger( argument, ch );
   if( char_died( ch ) )
      return;
   oprog_speech_trigger( argument, ch );
   if( char_died( ch ) )
      return;
   rprog_speech_trigger( argument, ch );
   return;
}
       
Post is unread #17 Apr 24, 2013, 8:04 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

well actually i assume a kite is an object in the room, problem is that fly is a spell that is only usable on mobiles and players not objects, try having an unenchanted sword in inventory/room and doing say enchant sword
       
Post is unread #18 Apr 24, 2013, 8:12 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

Nono, the kite isn't in the room :rofl:

What I want is:

if I say a spell and nothing else ---> cast the spell.
if I say a spell and I'm pointing ---> cast the spell to the victim.
if I say a spell and something else ----> You say 'fly a kite'
if I say a word that isn't a learned spell ----> You say 'hello'
       
Post is unread #19 Apr 24, 2013, 8:16 pm
Go to the top of the page
Go to the bottom of the page

Leia
Fledgling
GroupMembers
Posts21
JoinedJul 8, 2012

And.. "say enchant sword" implies that it won't result in "You say 'enchant sword' and that is what I want.
If you want to enchant a sword you have to point to the sword first and say enchant.
       
Post is unread #20 Apr 24, 2013, 8:22 pm
Go to the top of the page
Go to the bottom of the page

Remcon
Geomancer
GroupAdministrators
Posts1,858
JoinedJul 26, 2005

ah so you wanted it to say that? well problem is that fly is a spell so naturally it goes through the process and treats it like a spell is being cast, the they aren't here message is sent from do_cast. the fastest way around it is to simply if your wanting it to say something and the first word is a spell type
say 'fly a kite'

putting it in the ' should make it work right since it will look for a 'fly a kite' spell lol
       
Pages:<< prev 1, 2 next >>