object has no member??

Posted by Kronos on Sun 29 Dec 2002 11:01 AM — 8 posts, 28,469 views.

USA #0
im trying to put in this command that allows items to be connected together producing a final item.. now when i compile, it says:

act_obj.c: In function `do_connect':
act_obj.c:455: structure has no member named `level'

here's the part of the code in which it refers to:

/* check to see if the pieces connect */

if ( ( first_ob->value[0] == second_ob->pIndexData->vnum )
&& ( second_ob->value[0] == first_ob->pIndexData->vnum )
&& ( first_ob->value[1] == second_ob->value[1] )
&& (first_ob->pIndexData->vnum != second_ob->pIndexData->vnum) )
/* good connection */
{
new_ob = create_object( get_obj_index( first_ob->value[2] ), ch->level );/*!!!!!!!RIGHT HERE!!!!!!*/
extract_obj( first_ob );
extract_obj( second_ob );
obj_to_char( new_ob , ch );
act( AT_ACTION, "$n jiggles some pieces together...\r\n ...suddenly they snap in place, creating $p!", ch, new_ob,NULL, TO_ROOM );
act( AT_ACTION, "You jiggle the pieces together...\r\n ...suddenly they snap into place, creating $p!", ch, new_ob, NULL, TO_CHAR);

}
else
{
act( AT_ACTION, "$n jiggles some pieces together, but can't seem to make them connect.", ch, NULL, NULL, TO_ROOM);
act( AT_ACTION, "You try to fit them together every which way, but they just don't want to fit together.", ch, NULL, NULL, TO_CHAR);

Now what does it mean has no member? what do i need to do to fix it?

this is in the SWR codebase, of the act_obj.c file where i added it.

somebody please help!

-Kronos
Australia Forum Administrator #1
Hmm - what is "ch" in this context? Can we see the declaration for it?
USA #2
This is my act_obj.c file:

http://barbarian25.tripod.com/act_obj.c

and this is where im getting the code im trying to add from:

http://www.mindcloud.com/smaug/files/connect.c


Now as someone had suggested, i changed the origional ch->level to ch->top_level

It compiled no problem, and i put the command into the mud.

When i use it, it'll fail just fine, everything works except that when i actually connect the correct pieces, the mud crashes. So i have come to the conclusion that my changing ch->level to ch->top_level is the issue. but if i leave it as level, it does the structure has no member thing (previously mentioned in post farther up in this thread).

help if you can, thanks,
-Kronos
United Kingdom #3
Where is it crashing?
USA #4
well, its a smaug snippet, and therefore for smaug. SWR has its slight code differences, but the only problem here is that it gives me the 'has no member' error about the
ch->level thing. it crashes because in order to get it to compile i changed level to top_level as you can see in my act_obj.c

so it crashes when i successfully connect the two pieces. it doesnt say anything, it just crashes when i type connect <piece1> <piece2>

so i assume the problem is in my changing ch->level to
ch->top_level

its a smaug snippet im trying to put in SWR, but can anyone help me get it to work?

-Kronos
United Kingdom #5
I suggest you find out how to run your mud under gdb, and then you can get the line number its crashing at, and lots of other joyous information. Without that, it's like trying to assemble an aircraft from nuts and bolts in the dark.
USA #6
My personal recommendation is to scrap the whole ACK snipet and just mob programs. I've built and coded on ACK, DoT, Circle and a few other codebases and 99% of the time unless you have an absolute pressing need to convert something from another codebase, its easier to either write it from scratch (I'm guessing thats beyond your capabilities or you'd not be asking for help with a snipet) or find a non-coded solution. Besides, unless that snipet included the ACK rare items code, (or you use the limited intem snipet in another post on this forum) you'll not get the full functionality of the code without heavy mobprog use anyway. Even with the other snipets it's still less headache to write mobprogs to mimic the connection sequence and you can better control who can create the connected items.

Just a suggestion.
Australia Forum Administrator #7
The type CHAR_DATA has a member "level", however there is no guarantee that "ch" in your code is type CHAR_DATA. You need to check that.

As for why it crashes, it might be more than just the change to top_level. For instance, ch might be NULL.