Error Compiling Act_wiz.c, (fixed)

Posted by Dextermovies on Tue 01 Dec 2009 12:11 AM — 21 posts, 82,157 views.

#0
Here are there errors I get
act_wiz.c:2018: error: subscripted value is neither array nor pointer
act_wiz.c:2024: warning: implicit declaration of function ‘stc’
act_wiz.c:2028: error: subscripted value is neither array nor pointer
act_wiz.c:2031: warning: implicit declaration of function ‘set_pc_name’
act_wiz.c:2041: error: subscripted value is neither array nor pointer
act_wiz.c:2045: warning: implicit declaration of function ‘set_enter_room_text’
make: *** [obj/act_wiz.o] Error 1


Here is the command in question:
void do_form(CHAR_DATA *ch, char *argument)
{
    	char buf[MAX_STRING_LENGTH];

    	if (argument[0]=='\0')
    	{
		send_to_char("Change your form to resemble what?\n\r",ch);
		return;
    	}
    
	if (!str_cmp(argument,"self") )
    	{
		if (!IS_AFFECTED(ch,AFF_POLYMORPH) && !IS_VAMPAFF(ch,VAM_DISGUISED))
		{
	    		send_to_char( "You already look like yourself!\n\r", ch );
	    		return;
		}
	
		stc("You transform back to your old form",ch);
    		sprintf(buf, "%s's form blurs and shifts to resemble %s.",	ch->name,argument);
    		act(buf,ch,NULL,NULL,TO_ROOM);
		REMOVE_BIT(ch->affected_by, AFF_POLYMORPH);
		REMOVE_BIT(ch->pcdata->stats[UNI_AFF], VAM_DISGUISED);
    		free_string( ch->morph );
    		ch->morph = str_dup( "" );
		set_pc_name(ch, ch->pcdata->switchname);
		return;
    	}

    	sprintf(buf, "%s's form blurs and shifts to resemble %s.",	ch->name,argument);
    	act(buf,ch,NULL,NULL,TO_ROOM);
    	set_pc_name(ch, argument);
    	free_string( ch->morph );
    	ch->morph = str_dup( argument );
    	SET_BIT(ch->affected_by, AFF_POLYMORPH);
    	SET_BIT(ch->pcdata->stats[UNI_AFF], VAM_DISGUISED);    
    	send_to_char("Your form blurs and shifts to resemble ",ch);
    	send_to_char(argument,ch);
    	send_to_char(".\n\r",ch);
    	set_enter_room_text(ch, "");
    	return;
}


If you need any other info please let me know, I am new to coding muds
USA #1
What lines are what?
#2
		if (!IS_AFFECTED(ch,AFF_POLYMORPH) && !IS_VAMPAFF(ch,VAM_DISGUISED))

REMOVE_BIT(ch->affected_by, AFF_POLYMORPH);

SET_BIT(ch->pcdata->stats[UNI_AFF], VAM_DISGUISED);    
[\code]
Australia Forum Administrator #3
You gave error messages with 6 lines: 2018, 2024, 2028, 2031, 2041 and 2045.

Your recent post doesn't clarify that much. Can you indicate on the original post which of the lines have those lines numbers (eg. put a comment at the end of each line).

Also, are there other messages further up, like missing include files?

#4

2006void do_form(CHAR_DATA *ch, char *argument)
2007{
2008    	char buf[MAX_STRING_LENGTH];
2009
2010    	if (argument[0]=='\0')
2011  	{
2012		send_to_char("Change your form to resemble what?\n\r",ch);
2013		return;
2014    	}
2015    
2016	if (!str_cmp(argument,"self") )
2017    	{
2018		if (!IS_AFFECTED(ch,AFF_POLYMORPH) && !IS_VAMPAFF(ch,VAM_DISGUISED))
2019		{
2020	    		send_to_char( "You already look like yourself!\n\r", ch );
2021	    		return;
2022		}
2023	
2024		stc("You transform back to your old form",ch);
2025    		sprintf(buf, "%s's form blurs and shifts to resemble %s.",	ch->name,argument);
2026    		act(buf,ch,NULL,NULL,TO_ROOM);
2027		REMOVE_BIT(ch->affected_by, AFF_POLYMORPH);
2028		REMOVE_BIT(ch->pcdata->stats[UNI_AFF], VAM_DISGUISED);
2029    		free_string( ch->morph );
2030    		ch->morph = str_dup( "" );
2031		set_pc_name(ch, ch->pcdata->switchname);
2032		return;
2033    	}
2034
2035    	sprintf(buf, "%s's form blurs and shifts to resemble %s.",	ch->name,argument);
2036   	act(buf,ch,NULL,NULL,TO_ROOM);
2037    	set_pc_name(ch, argument);
2038    	free_string( ch->morph );
2039    	ch->morph = str_dup( argument );
2040    	SET_BIT(ch->affected_by, AFF_POLYMORPH);
2041    	SET_BIT(ch->pcdata->stats[UNI_AFF], VAM_DISGUISED);    
2041    	send_to_char("Your form blurs and shifts to resemble ",ch);
2042    	send_to_char(argument,ch);
2043    	send_to_char(".\n\r",ch);
2044    	set_enter_room_text(ch, "");
2045    	return;
2046 }  



Move every thing up one line, there seems to be a one line discrepancy in my code :(

And no there is no ini file missing errors or warnings :(
Amended on Wed 02 Dec 2009 03:13 AM by Nick Gammon
USA #5
Does REMOVE_BIT work in other places?

Are you sure you aren't suppose to be using xREMOVE_BIT?
#6
Yes it works in other places, After adding the x I now get This

act_wiz.c: In function ‘do_form’:
act_wiz.c:2018: error: subscripted value is neither array nor pointer
act_wiz.c:2024: warning: implicit declaration of function ‘stc’
act_wiz.c:2027: warning: implicit declaration of function ‘xREMOVE_BIT’
act_wiz.c:2028: error: subscripted value is neither array nor pointer
act_wiz.c:2031: warning: implicit declaration of function ‘set_pc_name’
act_wiz.c:2040: warning: implicit declaration of function ‘xSET_BIT’
act_wiz.c:2041: error: subscripted value is neither array nor pointer
act_wiz.c:2045: warning: implicit declaration of function ‘set_enter_room_text’
make: *** [obj/act_wiz.o] Error 1
Amended on Tue 01 Dec 2009 05:33 PM by Dextermovies
USA #7
If you comment out REMOVE_BIT(ch->affected_by, AFF_POLYMORPH); does it remove one error?

Does a different AFF work instead of polymorph?

Does REMOVE_BIT(ch->affected_by, AFF_POLYMORPH); in a different code section work?
#8
Yes that removes an error.
I am un sure as it is not my code, I am redoing TBW ( The Beast Within )
And yes it does work other places.
USA #9
It works in other places? Other files, or other functions?

If other files, sounds like you're missing an include somewhere or missing externs.

If another function in the same file, then I have no idea. That wouldn't make much sense.

What is UNI_AFF? Where is it declared?
#10
UNI_AFF is an AFF made after the orignal creator of TBW Unifex .... it is defined in dystopia.h

It was a diff file, soi I must be missing a include some where .., thanks
#11
Nope I am not missing an include
USA #12
Can you show the declaration for ch->pcdata->stats? UNI_AFF and VAM_DISGUISED too.
#13
Found in dystopia.h That is not all of pc data.

struct pc_data
{
int            stats;
}

I did not find any thing else not related to other mud classes in the code for it.


AFF_UNI


#define IS_VAMPAFF(ch, sn)	(IS_SET((ch)->pcdata->stats[UNI_AFF], (sn)))

#define UNI_AFF		1 /* vampaff */



Nothing for the last one.



USA #14
It's impossible that stats is just an int and yet used as an array. That code could never have possibly worked. Where did you get this source?
#15
I obtained it from Kayosuke.
So how might I go about fixing this code ?
USA #16
Do you have a download link?

To fix this, you'd need to make stats an array, but figuring out why it's not an array in the first place is probably pretty important... basically, that code could never possibly work, so we might be trying to "fix" code that is simply wrong through and through.
#17
Well I am basing this code off of tbw, I am making it into a dystopia 2 mud, I was going to add several commands to the db then release the source for the dystopia I had modified. Here is a link to my dystopia 2 code, do not once you fix this issue, savefdb and loadfdb both crash the server .. I Am not to sure why right now. http://www30.zippyshare.com/v/61185731/file.html
Amended on Thu 03 Dec 2009 02:11 AM by Dextermovies
USA #18
Is that the original codebase, or your modified version?

What I'm trying to get is the original codebase that you are working off of. I am a little surprised that somebody would release a codebase that simply won't compile, and not due to some obscure reason or due to a compiler upgrade; the error you're seeing is an extremely basic one. It's treating something as an array when it is not an array.

Basically, I'm trying to establish if this was a problem with the original codebase, or if it's something you changed. If it's something you changed, the next questions are: why? can you change it back?
#19
The original code base has not been released to the public, so I can not provide a link to it. How ever it will compile fine, I am just screwing some thing up in my code trying to make a dystopia 1.01 mud work in dystopia 2. And that is my modified code.
#20
I added [60] to the int stats ... it now works :D thank you guys so much for your support :D