Bout them invasions....

Posted by Longbow on Fri 15 Jul 2005 09:14 PM — 22 posts, 71,615 views.

#0
Howdy folks! Long time no see! I just added the invade snippet by the folks at Lost Prophecy. Now the only error I'm getting is as follows:

request for member 'bits' in something not a structure or union


Which is speaking of this line of code:

if (xIS_SET( location->room_flags, ROOM_SAFE))

Now what would be the solution for this? I'm not sure I understand WHAT the error is.

Thanks,
Longbow
USA #1
What is location defined as? Doesn't sound like ROOM_DATA or the sort.
USA #2
Chances are that room_flags is not an extended bit vector. But, you're using xIS_SET, not IS_SET. To fix this, you could probably use IS_SET - although you need to think about whether you want the room flags to be extended or not.
#3
Ok, what's the definition of an extended bit for rooms? Use layman's terms.

Longbow
Amended on Sat 16 Jul 2005 07:50 PM by Longbow
USA #4
See:
http://www.auricmud.com/snippets/bitvectors.html
#5
This is what I get if I remove that simple little x in xIS_SET.


invade.c:8: error: parse error before '*' token
invade.c: In function `do_invade':
invade.c:10: error: `MAX_INPUT_LENGTH' undeclared (first use in this function)
invade.c:10: error: (Each undeclared identifier is reported only once
invade.c:10: error: for each function it appears in.)
invade.c:13: error: `CHAR_DATA' undeclared (first use in this function)
invade.c:13: error: `victim' undeclared (first use in this function)
invade.c:14: error: `AREA_DATA' undeclared (first use in this function)
invade.c:14: error: `tarea' undeclared (first use in this function)
invade.c:16: error: `bool' undeclared (first use in this function)
invade.c:16: error: parse error before "found"
invade.c:17: error: `MOB_INDEX_DATA' undeclared (first use in this function)
invade.c:17: error: `pMobIndex' undeclared (first use in this function)
invade.c:18: error: `ROOM_INDEX_DATA' undeclared (first use in this function)
invade.c:18: error: `location' undeclared (first use in this function)
invade.c:20: error: `argument' undeclared (first use in this function)
invade.c:20: warning: implicit declaration of function `one_argument'
invade.c:23: warning: implicit declaration of function `atoi'
invade.c:26: warning: implicit declaration of function `send_to_char'
invade.c:26: error: `ch' undeclared (first use in this function)
invade.c:29: error: `first_area' undeclared (first use in this function)
invade.c:30: warning: implicit declaration of function `str_cmp'
invade.c:32: error: `found' undeclared (first use in this function)
invade.c:32: error: `TRUE' undeclared (first use in this function)
invade.c:45: warning: implicit declaration of function `get_mob_index'
invade.c:45: error: `NULL' undeclared (first use in this function)
invade.c:53: warning: implicit declaration of function `get_room_index'
invade.c:53: warning: implicit declaration of function `number_range'
invade.c:58: warning: implicit declaration of function `IS_SET'
invade.c:58: error: `ROOM_SAFE' undeclared (first use in this function)
invade.c:63: warning: implicit declaration of function `create_mobile'
invade.c:64: warning: implicit declaration of function `char_to_room'
invade.c:65: warning: implicit declaration of function `act'
invade.c:65: error: `AT_IMMORT' undeclared (first use in this function)
invade.c:65: error: `TO_ROOM' undeclared (first use in this function)
invade.c:10: warning: unused variable `arg1'
invade.c:11: warning: unused variable `arg2'
invade.c:12: warning: unused variable `arg3'
make[1]: *** [invade.o] Error 1
make: *** [all] Error 2
#6
If you want the original code for a look, here is invade.c unchanged:


/* Use cedit to add in as imm command.
 * Syntax is: Invade <area filename> <# of invaders> <vnum of mobs> 
 * example: Invade newacad.are 300 10399 would send 300 mistress tsythia's rampaging 
 * through the academy. This function doesnt make the mobiles aggressive but can be
 * modified to do so easily if you wish this, or you can just edit the mob before
 * hand.
 */
void do_invade( CHAR_DATA *ch , char *argument )
{
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    char arg3[MAX_INPUT_LENGTH];
    CHAR_DATA *victim;
    AREA_DATA *tarea;
    int count, created;
    bool found=FALSE;
    MOB_INDEX_DATA *pMobIndex;
    ROOM_INDEX_DATA *location;

    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    argument = one_argument( argument, arg3 );
    count = atoi( arg2 );
    if ( arg1[0] == '\0' || arg2[0] == '\0' )
    {
	send_to_char( "Invade <area> <# of invaders> <mob vnum>\n\r", ch );
	return;
    }
    for ( tarea = first_area; tarea; tarea = tarea->next )
	if ( !str_cmp( tarea->filename, arg1 ) )
	{
	  found = TRUE;
	  break;
	}
    if ( !found )
    {
	send_to_char( "Area not found.\n\r", ch );
	return;
    }
    if ( count > 300)
    {
	send_to_char( "Whoa...Less than 300 please.\n\r", ch );
	return;
    }
    if ( ( pMobIndex = get_mob_index( atoi(arg3) ) ) == NULL )
    {
	send_to_char( "No mobile has that vnum.\n\r", ch );
	return;
    }

    for ( created=0; created < count; created++ )
    {
	if ( (location = get_room_index(number_range(tarea->low_r_vnum, tarea->hi_r_vnum ))) == NULL )
        {
          --created;
	  continue;
        }
	if (xIS_SET( location->room_flags, ROOM_SAFE))
        {
          --created;
	  continue;
        }
        victim = create_mobile( pMobIndex );
        char_to_room( victim, location );
        act( AT_IMMORT, "$N appears as part of an invasion force!", ch, NULL, victim, TO_ROOM );
    }
	send_to_char( "The invasion was successful!\n\r", ch );

 return;
}


Longbow
USA #7
You forgot to include mud.h, but why not just put that function in a normal file?
#8
Ok, I've fixed it. You guys were a bunch of help. Thanks a lot!

Godbless,
Longbow
#9
Ok, I put in a piece of code and I solved all the errors with it myself(ain't ya proud of me?) except this one:

'TO_ROOM' undeclared(first use in this function)

I put a bit of the code here with 5 asterisks by the error line.



                {
send_to_char( "You didn't realize it when you started, but you haven't enough material\n\r", ch);
                    return;
                }
                extract_obj( material );
         }
                 obj_to_char( clothing, ch );
         send_to_char("You snip and sew, creating a new piece of clothing.\n\r", ch);
act( AT_ACTION,"$n snips and sews, creating a new piece of clothing.", ch, NULL, NULL, T0_ROOM); *****
         xnum = number_range(0, 100);
         if (xnum < 25) /*did the sewkit break?*/
         {
                extract_obj( sewkit );
     act( AT_ACTION, "$n pulls too hard on the needle and it breaks!", ch, NULL, NULL, TO_ROOM);
                send_to_char( "You pull too hard on the needle and it breaks!\n\r", ch );
        }
        learn_from_failure( ch, gsn_tailor );
        return;
        }

 else  /* failure of skill */
        {
        for (x=number_range(1,9); x<=mnum; x++)
         {
                material = get_obj_carry (ch, arg1 );
                if (material == NULL)
                {
                      send_to_char( "Your thread knots, and your material is ruined.\n\r", ch);
                        return;
                }
                extract_obj( material );
         }
        send_to_char("You snip and sew, but only make a mess.\n\r", ch);
act( AT_ACTION, "$n snips and sews but doesn't make anything useful.", ch, NULL, NULL, TO_ROOM);
        xnum = number_range(0, 100);
        if (xnum < 25) /*did the sewkit break?*/
  {
                extract_obj( sewkit );
    act( AT_ACTION, "$n pulls too hard on the needle and it breaks!", ch, NULL, NULL, TO_ROOM);
                send_to_char( "You pull too hard on the needle and it breaks!\n\r", ch );
        }
                learn_from_success( ch, gsn_tailor );
        }
}


Any ideas?

Godbless,
Longbow
Amended on Mon 18 Jul 2005 09:45 PM by Longbow
USA #10
Look carefully - you used the digit zero, not the letter 'o'. This is easy to spot when you use a font that marks the difference well. I use one that happens to do so nicely: http://david.the-haleys.org/faq/index.php?sid=95&lang=en&action=artikel&cat=3&id=2&artlang=en
#11
Good night! You're right! Wow, you're a good bit more observant than I. :) Thanks a bundle!

Godbless,
Longbow
#12
K, just when I think everything is solved I get a batch of errors I've never seen before:

skills.o(.text+0xf105): In function `do_dye.0':
/cygdrive/c/windows/desktop/bakups/textfinal/smaug1/smaug/dist/src/skills.c:6469: undefined reference to `_gsn_dye'
skills.o(.text+0xf142):/cygdrive/c/windows/desktop/bakups/textfinal/smaug1/smaug/dist/src/skills.c:6471: undefined reference to `_gsn_dye'
skills.o(.text+0xfa13):/cygdrive/c/windows/desktop/bakups/textfinal/smaug1/smaug/dist/src/skills.c:6599: undefined reference to `_gsn_dye'
skills.o(.text+0xfa82):/cygdrive/c/windows/desktop/bakups/textfinal/smaug1/smaug/dist/src/skills.c:6607: undefined reference to `_gsn_dye'
skills.o(.text+0xfac8): In function `do_tailor':
/cygdrive/c/windows/desktop/bakups/textfinal/smaug1/smaug/dist/src/skills.c:6275: undefined reference to `_gsn_tailor'
skills.o(.text+0xfb05):/cygdrive/c/windows/desktop/bakups/textfinal/smaug1/smaug/dist/src/skills.c:6277: undefined reference to `_gsn_tailor'
skills.o(.text+0x10322):/cygdrive/c/windows/desktop/bakups/textfinal/smaug1/smaug/dist/src/skills.c:6433: undefined reference to `_gsn_tailor'
skills.o(.text+0x10448):/cygdrive/c/windows/desktop/bakups/textfinal/smaug1/smaug/dist/src/skills.c:6458: undefined reference to `_gsn_tailor'
tables.o(.text+0x1560): In function `skill_function':
/cygdrive/c/windows/desktop/bakups/textfinal/smaug1/smaug/dist/src/tables.c:269: undefined reference to `_do_dye'
tables.o(.text+0x4d84): In function `skill_name':
/cygdrive/c/windows/desktop/bakups/textfinal/smaug1/smaug/dist/src/tables.c:949: undefined reference to `_do_dye'
collect2: ld returned 1 exit status
make[1]: *** [smaug] Error 1
make: *** [all] Error 2

I don't see anywhere where I put an extra _ in these examples.


Longbow
USA #13
You didn't, the _ is inserted by the compiler. Chances are you forgot to put the file you created in the list of files the makefile uses.
#14
I don't think so. It's a skill and I put it in skills.c, and I also removed it and tried it under a file of its own and still got the same message.

Godbless,
Longbow
USA #15
Did you remember to define those gsns in mud.h? Or you may have forgot an include.
USA #16
It's not a declaration error, it's that the symbols were indeed declared somewhere (as externs) but no memory is allocated for them anywhere.
USA #17
Yeah just realized it after I posted but didn't get a chance to edit it since I'm at work.
#18
So what should I do? I still haven't got it to work?


Godbless,
Longbow
USA #19
Make sure all .c files you want are on the makefile list.

Make sure that you've actually defined the symbols, e.g. you need to add the GSNs to the list in db.c.

What it's telling you is that you've told it a symbol exists (in a .h file) but you've not told it where the memory for that symbol exists (in a .c file.)
#20
Hrrrmmm, I removed the do_dye skill and function because I couldn't get it fixed, but I made a seperate .c file for the do_tailor function and it works now. I still don't know how that happened but oh well, I'll keep looking into it. Perhaps if I do the same to the do_dye function it'll work.

In the meantime, I put in do_tailor and the skill works fine, but for some reason it refuses to accept the objtype ITEM_SEWKIT, which is required for the skill, as a valid skill. I put in entries in db.c, act_obj.c, and mud.h, and it still don't show as a working itemtype. Did I miss an entry somewhere? I've never put in a new type before.

Thanks and Godbless,
Longbow

I went and added a .c file for the do_dye. it fixed the problem. Now does anyone know what I need to do to make the item types work?
Amended on Wed 20 Jul 2005 10:24 PM by Longbow
#21
Howdy folks, I'm back after a long break. Would somebody please tell me how to put in a new object type? I've grepped and grepped on other types and I thought I had all the places required put in, but I guess not. Would somebody give me a list of where I need to put in the new type?


Thanks and Godbless,
Longbow



You know, I could have made this a whole new subject, but why not use this old one? :D