Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Parse Errors Galore!

Parse Errors Galore!

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Saryn   USA  (28 posts)  Bio
Date Sun 07 Sep 2003 02:18 AM (UTC)
Message
Me again! This one should be faily simple, but I just dont see it yet. Ok I am adding the Gangiens snippet for wizhelp, making it sort the immortal commands by types. I am getting a parse error for some of the code I didnt change, and weird enough, all my braces have a partner. In my perfect world atleast.

act_wiz.c: In function `do_cedit':
act_wiz.c:7963: parse error before "ch"
act_wiz.c:7990: structure has no member named `type'
act_wiz.c:8020: structure has no member named `type'
act_wiz.c:8021: structure has no member named `type'
act_wiz.c:8022: structure has no member named `type'
act_wiz.c:8023: structure has no member named `type'
act_wiz.c:8024: structure has no member named `type'
act_wiz.c:8027: parse error before '}' token
act_wiz.c:8161: structure has no member named `type' 


Im hoping the type error will go away once I fix thi parse error. Ok the code from the start of the funcion (at 7938) to 8027 is...

void do_cedit( CHAR_DATA *ch, char *argument )
{
    CMDTYPE *command;
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];

    set_char_color( AT_IMMORT, ch );

    smash_tilde( argument );
    argument = one_argument( argument, arg1 );
    argument = one_argument( argument, arg2 );
    if ( arg1[0] == '\0' )
    {
	send_to_char( "Syntax: cedit save cmdtable\n\r", ch );
	if ( get_trust(ch) > LEVEL_SUB_IMPLEM  )
	{
	    send_to_char( "Syntax: cedit <command> create 
\n\r", ch );
	    send_to_char( "Syntax: cedit <command> delete\n\r", ch );
	    send_to_char( "Syntax: cedit <command> show\n\r", ch );
	    send_to_char( "Syntax: cedit <command> raise\n\r", ch );
	    send_to_char( "Syntax: cedit <command> lower\n\r", ch );
	    send_to_char( "Syntax: cedit <command> list\n\r", ch );
	    send_to_char( "Syntax: cedit <command> [field]\n\r", ch );
	    send_to_char( "Syntax: cedit <command> type [type]\n\r",ch);
	    send_to_char( "\n\rType being one of:\n\r",ch);
            send_to_char( "0=mortal, 1=misc, 2=admin, 3=punish, 4=general 5=build\n\r"ch);
	    send_to_char( "\n\rField being one of:\n\r", ch );
	    send_to_char( "  level position log code flags\n\r", ch );
	}
	return;
    }

    if (get_trust(ch) > LEVEL_GREATER 
	 && !str_cmp( arg1, "save" ) && !str_cmp( arg2, "cmdtable") )
    {
	save_commands();
	send_to_char( "Saved.\n\r", ch );
	return;
    }

    command = find_command( arg1 );
    if ( get_trust(ch) > LEVEL_SUB_IMPLEM &&    !str_cmp( arg2, "create" ) )
    {
	if ( command )
	{
	    send_to_char( "That command already exists!\n\r", ch );
	    return;
	}
	CREATE( command, CMDTYPE, 1 );
	command->lag_count = 0; /* FB */
	command->name = str_dup( arg1 );
	command->level = get_trust(ch);
	command->type = 0;
	if ( *argument )
	    one_argument(argument, arg2);
	else
	    sprintf( arg2, "do_%s", arg1 );
	command->do_fun = skill_function( arg2 );
	add_command( command );
	send_to_char( "Command added.\n\r", ch );
	if ( command->do_fun == skill_notfound )
	    ch_printf( ch, "Code %s not found.  Set to no code.\n\r", arg2 );
	return;
    }

    if ( !command )
    {
	send_to_char( "Command not found.\n\r", ch );
	return;
    }
    else
    if ( command->level > get_trust(ch) )
    {
	send_to_char( "You cannot touch this command.\n\r", ch );
	return;
    }

if ( arg2[0] == '\0' || !str_cmp( arg2, "show" ) )
    {
        ch_printf( ch, "Command:  %s\n\rLevel:    %d\n\rPosition: %d\n\rLog: %d\n\rCode:     %s\n\rType:     %s\n\rFlags:  %s\n\r",
            command->name, command->level, command->position, command->log,
            skill_name(command->do_fun),
            command->type == 0 ? "Mortal" :
            command->type == 1 ? "Misc" :
            command->type == 2 ? "Admin" :
            command->type == 3 ? "Punish" :
            command->type == 4 ? "General" : "Build",
            flag_string(command->flags, cmd_flags));
        if ( command->userec.num_uses )
    }


If someone can find the lonely brace in their, I sure would love to hear from you.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Sun 07 Sep 2003 02:24 AM (UTC)

Amended on Sun 07 Sep 2003 02:26 AM (UTC) by David Haley

Message
I don't know about the type errors but this sure as heck isn't right:

if ( command->userec.num_uses )
    }

That's at the very bottom.


This also isn't right:
send_to_char( "\n\rType being one of:\n\r",ch);
send_to_char( "0=mortal, 1=misc, 2=admin, 3=punish, 4=general 5=build\n\r"ch);


You're missing a comma before "ch".
That's at the top in the usage text (if the user entered bad arguments.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Saryn   USA  (28 posts)  Bio
Date Reply #2 on Sun 07 Sep 2003 02:36 AM (UTC)

Amended on Sun 07 Sep 2003 02:47 AM (UTC) by Saryn

Message
the type errors are part of the new code...it adds the type to use in the cedit command. (type mortal, type punish, whatever). I added that comma and it did nothing noticble to my compile.

But guess what! I took out the line

if ( command->userec.num_uses )

and poof...parse error is gone. Odd. BUt I still have the type errors.


act_wiz.c: In function `do_cedit':
act_wiz.c:7990: structure has no member named `type'
act_wiz.c:8020: structure has no member named `type'
act_wiz.c:8021: structure has no member named `type'
act_wiz.c:8022: structure has no member named `type'
act_wiz.c:8023: structure has no member named `type'
act_wiz.c:8024: structure has no member named `type'
act_wiz.c:8160: structure has no member named `type'


(Added)
When I was looking through the compile results, I saw this, and thought it might help a little


act_wiz.c: In function `type_found':
act_wiz.c:517: structure has no member named `type'
act_wiz.c: In function `do_wizhelp':
act_wiz.c:565: structure has no member named `type'
act_wiz.c:586: structure has no member named `type'
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #3 on Sun 07 Sep 2003 02:45 AM (UTC)
Message
That means that the data structure wasn't updated. Did you remember to add the data member "type" to the structure in mud.h?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Saryn   USA  (28 posts)  Bio
Date Reply #4 on Sun 07 Sep 2003 03:00 AM (UTC)
Message
In mud.h after
sh_int position;
I added
sh_int type;

In tables.c I added (supposivly) in the function fread_command

case 'T':
KEY( "Type", command->type, fread_number(fp) );
break;

But I have a feeling I put it in the wrong place.
I put it after


	case 'P':
	    /* KEY( "Position",	command->position,	fread_number(fp) ); */
	    if ( !str_cmp(word, "Position") )
	    {
		fMatch = TRUE;
		command->position = fread_number(fp);
		if( command->position<100 )
		{
		    switch(command->position)
		    {
			default:
			case 0:
			case 1:
			case 2:
			case 3:
			case 4: break;
			case 5: command->position=6; break;
			case 6: command->position=8; break;
			case 7: command->position=9; break;
 			case 8: command->position=12; break;
			case 9: command->position=13; break;
			case 10: command->position=14; break;
			case 11: command->position=15; break;
		    }
		}
		else
		    command->position-=100;
		break;
	    }
	    break;
	}
	
	if ( !fMatch )
	{
            sprintf( buf, "Fread_command: no match: %s", word );
	    bug( buf, 0 );
	}
    }
}


I didnt see anywhere else suitable for it so I put it right there after the last brace.
Top

Posted by Saryn   USA  (28 posts)  Bio
Date Reply #5 on Sun 07 Sep 2003 03:09 AM (UTC)
Message
OK I saw a mistake in that alone..and put the

case 'T':
KEY( "Type", command->type,
fread_number(fp) );
break;
before the 2nd brace at the end ..but didnt help. I think its getting to late for me to code :P
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #6 on Sun 07 Sep 2003 03:17 AM (UTC)
Message
First off, I'm not really sure if this would affect your code, but I think this is the way I would have done it:


if ( arg2[0] == '\0' || !str_cmp( arg2, "show" ) )
    {
        ch_printf( ch, "Command:  %s\n\rLevel:    %d\n\rPosition: %d\n\rLog: %d\n\rCode:     %s\n\rType:     %s\n\rFlags:  %s\n\r",
            command->name, command->level, command->position, command->log,
            skill_name(command->do_fun),
            command->type == 0 ? "Mortal" :
            (command->type == 1 ? "Misc" :
            (command->type == 2 ? "Admin" :
            (command->type == 3 ? "Punish" :
            (command->type == 4 ? "General" : "Build" ) ) ) ),
            flag_string(command->flags, cmd_flags));
    }



Second, this should go after case 'S':
case 'T':
KEY( "Type", command->type, fread_number(fp) );
break;

or somewhere -ABOVE-:


	if ( !fMatch )
	{
            sprintf( buf, "Fread_command: no match: %s", word );
	    bug( buf, 0 );
	}


Lastely, its late here also and I might be talking about nothing that would help. Anyways, you might just try switching that stuff around and fixing it up the way I did it, for it might work. I dunno, hope I helpped in some way, shape, or form.

Good Luck.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Saryn   USA  (28 posts)  Bio
Date Reply #7 on Sun 07 Sep 2003 03:34 AM (UTC)
Message
Life would be easier if there was a case s, wouldn't it? ;)

Ok All that did was make it look neater and fancier. The compile still makes me look like an idiot.

OK I posted the file I got that told me what to add to where and do what.

http://sembia.hopto.org/wizhelp.txt

It was fun sorting through that and finding where the code ends and stuff. I cleaned it up a little bit so that things are easier to read.
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #8 on Sun 07 Sep 2003 03:40 AM (UTC)

Amended on Sun 07 Sep 2003 03:46 AM (UTC) by Nick Cash

Message
Is it possible you put sh_int type; in the wrong struct?

According to my code, there are many places where sh_int position is defined. If you didn't know, it needs to go in the cmd_type struct.

~Nick Cash
http://www.nick-cash.com
Top

Posted by Saryn   USA  (28 posts)  Bio
Date Reply #9 on Sun 07 Sep 2003 03:48 AM (UTC)
Message
Im going to cry. I really am. Im now going to put a curfew for my coding before like 9pm...I did put the sh_int type; in the wrong place. Lmao.

Thanks for putting up with me. Now for my nap!
Top

Posted by Nick Cash   USA  (626 posts)  Bio
Date Reply #10 on Sun 07 Sep 2003 03:55 AM (UTC)
Message
I think I'd best as go as well. I don't remember where I read it, but it was in some documentation of something. It said that if you stay up all night coding you will get less done then if you went to sleep and tried again when you could think better. I guess I should start abiding by this rule so I won't have so many stupid questions to ask. :)

Good Luck Saryn.

~Nick Cash
http://www.nick-cash.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


22,021 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.