Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
tintin++ ogg sound player script for linux
Author: Robert Smith
Submitted by: Vladaar
6Dragons ogg Soundpack
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.4
Author: Vladaar
Submitted by: Vladaar
LoP 1.46
Author: Remcon
Submitted by: Remcon
LOP 1.45
Author: Remcon
Submitted by: Remcon
Users Online
CommonCrawl, Yandex, Bing

Members: 0
Guests: 2
Stats
Files
Topics
Posts
Members
Newest Member
481
3,734
19,366
618
Micheal64X
Today's Birthdays
Vintar (28)
Related Links
» SmaugMuds.org » General » Coding » Introduce for SmaugFUSS?
Forum Rules | Mark all | Recent Posts

Introduce for SmaugFUSS?
< Newer Topic :: Older Topic >

Pages:<< prev 1, 2 next >>
Post is unread #1 Sep 1, 2008, 4:06 am
Go to the top of the page
Go to the bottom of the page

Trevlyn13
Apprentice
GroupMembers
Posts64
JoinedNov 30, 2007

I want to implement the introduce/remember system found in SWR into my SmaugFUSS. I did very careful searching through the SWRFotE and found all the new stuff, the problem I'm having is with const *char to *char conversions. For some reason it's having a lot of issues; one step that seemed to help was removing const from the name and descs in char_data. That brought up some issues with quicklink( and stralloc(. Anyone know where I can find a simplified snippet of this or even some basic instructions. The more I try and debug this, the more I realize the SWRFotE made some big changes and this isn't going to be as simple as I thought.
       
Post is unread #2 Sep 1, 2008, 11:54 am
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

You really don't want to be removing the const qualifiers -- that will only cause you grief because you're working against the fix that was recently put in. It would be better to fix the snippet to be properly const compliant. What kind of issues were you having?
       
Post is unread #3 Sep 1, 2008, 2:48 pm
Go to the top of the page
Go to the bottom of the page

Trevlyn13
Apprentice
GroupMembers
Posts64
JoinedNov 30, 2007

All of the errors were about converting const *char to *char. This is one example of a section that was giving me problems:

FELLOW_DATA *fellow; (declared at the top of the function)

fellow->victim = QUICKLINK( ch->name );
fellow->knownas = STRALLOC( argument ); (two lines that were giving const *char/*char errors)

This is how that structure is defined in Mud.h

typedef struct fellow_data FELLOW_DATA;

struct fellow_data
{

char *victim;
char *knownas;
FELLOW_DATA *next;
FELLOW_DATA *prev;
};


I'd assume I need to somehow make the new stuff const, but I'm not sure exactly how. const char *knownas, etc??
       
Post is unread #4 Sep 1, 2008, 3:10 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

Can you give us the exact errors and the exact lines?
       
Post is unread #5 Sep 1, 2008, 4:45 pm   Last edited Sep 1, 2008, 4:50 pm by Trevlyn13
Go to the top of the page
Go to the bottom of the page

Trevlyn13
Apprentice
GroupMembers
Posts64
JoinedNov 30, 2007

Okay, I restored my backup of the pre-introduce code and readded everything. Nothing has been changed from SmaugFUSS, I've only added the new introduce stuff. Here's what I'm getting upon compile.

make -s smaug
Compiling o/act_comm.o....
Compiling o/act_info.o....
act_info.c: In function 'void do_introduce(CHAR_DATA*, char*)':
act_info.c:5188: error: invalid conversion from 'const char*' to 'char*'
act_info.c:5196: error: invalid conversion from 'const char*' to 'char*'
act_info.c:5197: error: invalid conversion from 'const char*' to 'char*'
act_info.c: In function 'void do_remember(CHAR_DATA*, char*)':
act_info.c:5277: error: invalid conversion from 'const char*' to 'char*'
act_info.c:5284: error: invalid conversion from 'const char*' to 'char*'
act_info.c:5285: error: invalid conversion from 'const char*' to 'char*'
make[1]: *** [o/act_info.o] Error 1
make: *** [all] Error 2

Here's code of the functions, I marked line 5188 and 5277, they are about 90% down into their respective functions

[code]
void do_introduce( CHAR_DATA * ch, char *argument )
{
CHAR_DATA *victim;
CHAR_DATA *rch;
char arg1[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
FELLOW_DATA *vfellow;
FELLOW_DATA *fellow;
int count;

argument = one_argument( argument, arg1 );
argument = remand( argument );

if( IS_NPC( ch ) )
return;

if( arg1[0] == '\0' || argument[0] == '\0' || ( !isalpha( argument[0] ) && !isdigit( argument[0] ) ) )
{
send_to_char( "&RSyntax: introduce <person/all> <your preferred name>\r\n", ch );
return;
}

arg1[0] = UPPER( arg1[0] );
argument[0] = UPPER( argument[0] );

if( ( str_cmp( arg1, "all" ) ) && ( victim = get_char_room( ch, arg1 ) ) == NULL )
{
send_to_char( "They aren't here.\r\n", ch );
return;
}

if( ch == victim )
{
send_to_char( "Schizophrenic, eh?\r\n", ch );
return;
}


if( strlen( argument ) < 3 )
{
send_to_char( "Introductions must be at least 3 characters long.\r\n", ch );
return;
}

if( strlen( argument ) > 40 )
argument[40] = '\0';

if( argument[1] == '.' )
argument[1] = 'x';

if( !str_cmp( argument, "Someone" ) )
{
send_to_char( "Nice try, ass.\r\n", ch );
return;
}

if( !str_cmp( arg1, "all" ) )
{
count = 0;
for( rch = ch->in_room->first_person; rch; rch = rch->next_in_room )
{
if( IS_NPC( rch ) || rch == ch )
continue;

if( can_see( ch, rch ) )
{
sprintf( buf, "__%s ", rch->name );
strcat( buf, argument );
do_introduce( ch, buf );
count++;
}
}
if( count == 0 )
{
send_to_char( "There's nobody here.\r\n", ch );
return;
}
return;
}


if( IS_NPC( victim ) || IS_NPC( ch ) )
{
send_to_char( "They aren't worth your time.\r\n", ch );
return;
}

smash_tilde( argument );

for( vfellow = victim->first_fellow; vfellow; vfellow = vfellow->next )
{
if( !str_cmp( vfellow->victim, ch->name ) )
{
if( !str_cmp( vfellow->knownas, argument ) )
{
ch_printf( ch, "They already know you as %s.\r\n", argument );
return;
}

ch_printf( ch, "&GYou reintroduce yourself to %s as %s.\r\n", PERS( victim, ch ), argument );
ch_printf( victim, "&G%s reintroduces %sself as %s.\r\n", PERS( ch, victim ),
ch->sex == 2 ? "her" : ch->sex == 1 ? "him" : "it", argument );

STRFREE( vfellow->knownas );
vfellow->knownas = STRALLOC( argument ); ----------------------------------------------------<LINE 5188>--------------------------------------
return;
}
}
ch_printf( victim, "&G%s introduces %sself as %s.\r\n", PERS( ch, victim ),
ch->sex == 2 ? "her" : ch->sex == 1 ? "him" : "it", argument );

CREATE( fellow, FELLOW_DATA, 1 );
fellow->victim = QUICKLINK( ch->name );
fellow->knownas = STRALLOC( argument );
LINK( fellow, victim->first_fellow, victim->last_fellow, next, prev );

ch_printf( ch, "&GYou introduce yourself to %s as %s.\r\n", PERS( victim, ch ), argument );
return;
}

void do_remember( CHAR_DATA * ch, char *argument )
{
CHAR_DATA *victim;
char arg1[MAX_INPUT_LENGTH];
FELLOW_DATA *fellow;
FELLOW_DATA *nfellow;

argument = one_argument( argument, arg1 );
argument = remand( argument );

if( IS_NPC( ch ) )
return;

if( arg1[0] == '\0' || argument[0] == '\0' )
{
send_to_char( "&RSyntax: remember <person> <name>\r\n", ch );
return;
}

arg1[0] = UPPER( arg1[0] );
argument[0] = UPPER( argument[0] );

if( !( victim = get_char_room( ch, arg1 ) ) )
{
send_to_char( "They aren't here.\r\n", ch );
return;
}

if( ch == victim )
{
send_to_char( "Remembering yourself... RP a little memory loss, would you?\r\n", ch );
return;
}

if( strlen( argument ) < 3 )
{
send_to_char( "You find it quite hard to remember them with such a short name.\r\n", ch );
return;
}

if( strlen( argument ) > 40 )
argument[40] = '\0';

if( argument[1] == '.' )
argument[1] = 'x';

if( !str_cmp( argument, "Someone" ) )
{
send_to_char( "Perhaps a little more descriptive?\r\n", ch );
return;
}

if( IS_NPC( victim ) || IS_NPC( ch ) )
{
send_to_char( "They aren't worth your time.\r\n", ch );
return;
}

smash_tilde( argument );

for( fellow = ch->first_fellow; fellow; fellow = fellow->next )
{
if( !str_cmp( fellow->victim, victim->name ) )
{
if( !str_cmp( fellow->knownas, argument ) )
{
ch_printf( ch, "You already know them as %s.\r\n", argument );
return;
}

ch_printf( ch, "%s will be remembered as %s.\r\n", PERS( victim, ch ), argument );

STRFREE( fellow->knownas );
fellow->knownas = STRALLOC( argument ); ----------------------------------------------------<LINE 5277>--------------------------------------
return;
}
}
ch_printf( ch, "%s will be remembered as %s.\r\n", PERS( victim, ch ), argument );

CREATE( nfellow, FELLOW_DATA, 1 );
nfellow->victim = QUICKLINK( victim->name );
nfellow->knownas = STRALLOC( argument );
LINK( nfellow, ch->first_fellow, ch->last_fellow, next, prev );
return;
}
       
Post is unread #6 Sep 1, 2008, 4:55 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

struct fellow_data
{

  char *victim;
  char *knownas;
  FELLOW_DATA *next;
  FELLOW_DATA *prev;
}; 


Just add 'const' in front of the two "char *".
       
Post is unread #7 Sep 1, 2008, 5:03 pm
Go to the top of the page
Go to the bottom of the page

Trevlyn13
Apprentice
GroupMembers
Posts64
JoinedNov 30, 2007

Okay, that fixed it to a point, now I'm getting this set of errors:

comm.c:3073: error: expected `)' before '(' token
comm.c:3073: error: abstract declarator 'char*' used as declaration
comm.c:3073: error: expected primary-expression before '*' token
comm.c:3073: error: 'looker' was not declared in this scope
comm.c:3073: error: expected primary-expression before '*' token
comm.c:3073: error: 'ch' was not declared in this scope
make[1]: *** [o/comm.o] Error 1

Here is the block of code, 3073 is the first line.

[code]
char *PERS( CHAR_DATA * ch, CHAR_DATA * looker )
{
static char buf[MAX_STRING_LENGTH];
char race[MAX_STRING_LENGTH];
FELLOW_DATA *fellow;

if( can_see( looker, ch ) )
{
if( IS_NPC( ch ) )
return ch->short_descr;
else
{
if( IS_IMMORTAL( looker ) || ch == looker )
return ch->name;
else if( ( fellow = knowsof( looker, ch ) ) != NULL )
return fellow->knownas;
else
{
if( IS_IMMORTAL( ch ) )
return ch->name;
sprintf( race, "%s", npc_race[ch->race] );
race[0] = tolower( race[0] );
sprintf( buf, "%s %s %s of %s height", aoran( build_name[ch->build] ), race,
ch->sex == 1 ? "male" : ch->sex == 2 ? "female" : "neutral", height_name[ch->pheight] );

return buf;
}
}
}
else
{
if( IS_IMMORTAL( ch ) )
return "Immortal";
else
return "someone";
}
}
       
Post is unread #8 Sep 1, 2008, 5:08 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

Change the prototype for PERS to return a const char*. You will have to do that in both comm.c and whichever .h file it's declared in.
       
Post is unread #9 Sep 1, 2008, 5:12 pm
Go to the top of the page
Go to the bottom of the page

Trevlyn13
Apprentice
GroupMembers
Posts64
JoinedNov 30, 2007

Changed 'em both, still getting errors:

comm.c:3073: error: expected `)' before '(' token
comm.c:3073: error: abstract declarator 'const char*' used as declaration
comm.c:3073: error: expected primary-expression before '*' token
comm.c:3073: error: 'looker' was not declared in this scope
comm.c:3073: error: expected primary-expression before '*' token
comm.c:3073: error: 'ch' was not declared in this scope
make[1]: *** [o/comm.o] Error 1
make: *** [all] Error 2
       
Post is unread #10 Sep 1, 2008, 5:19 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

Which one is 3073?

How is PERS declared in the .h files?
       
Post is unread #11 Sep 1, 2008, 5:23 pm
Go to the top of the page
Go to the bottom of the page

Trevlyn13
Apprentice
GroupMembers
Posts64
JoinedNov 30, 2007

Line 3073:

const char *PERS( CHAR_DATA * ch, CHAR_DATA * looker )

*PERS as declared in Mud.h:

const char *PERS args( ( CHAR_DATA * ch, CHAR_DATA * looker ) );
       
Post is unread #12 Sep 1, 2008, 5:23 pm   Last edited Sep 1, 2008, 5:24 pm by Samson
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,643
JoinedJan 1, 2002

Trevlyn13 said:

Changed 'em both, still getting errors:

comm.c:3073: error: expected `)' before '(' token
comm.c:3073: error: abstract declarator 'const char*' used as declaration
comm.c:3073: error: expected primary-expression before '*' token
comm.c:3073: error: 'looker' was not declared in this scope
comm.c:3073: error: expected primary-expression before '*' token
comm.c:3073: error: 'ch' was not declared in this scope
make[1]: *** [o/comm.o] Error 1
make: *** [all] Error 2


That means you've got something out of place at or above line 3073 in comm.c. Though the wording is different, you've got yourself a parse error. This one seems caused by an uneven number of parentheses.

Edit in response:

const char *PERS args( ( CHAR_DATA * ch, CHAR_DATA * looker ) ); <--- Too many parentheses. Remove the word "args" and take off one ( and one ) then recompile.
       
Post is unread #13 Sep 1, 2008, 5:31 pm
Go to the top of the page
Go to the bottom of the page

Trevlyn13
Apprentice
GroupMembers
Posts64
JoinedNov 30, 2007

Compiling o/act_comm.o....
mud.h:4472: error: expected `)' before '(' token
mud.h:4472: error: abstract declarator 'const char*' used as declaration
mud.h:4472: error: expected primary-expression before '*' token
mud.h:4472: error: 'looker' was not declared in this scope
mud.h:4472: error: expected primary-expression before '*' token
mud.h:4472: error: 'ch' was not declared in this scope
make[1]: *** [o/act_comm.o] Error 1
make: *** [all] Error 2

Line 4472:

const char *PERS( CHAR_DATA * ch, CHAR_DATA * looker );
       
Post is unread #14 Sep 1, 2008, 5:31 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

What are the lines around line 4472?
       
Post is unread #15 Sep 1, 2008, 5:32 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

Are you sure that is the only declaration of PERS, and that it's declared elsewhere as, say, a macro?
       
Post is unread #16 Sep 1, 2008, 5:45 pm
Go to the top of the page
Go to the bottom of the page

Trevlyn13
Apprentice
GroupMembers
Posts64
JoinedNov 30, 2007

The two functions I added to comm.c

FELLOW_DATA *knowsof( CHAR_DATA * ch, CHAR_DATA * victim )
{
   FELLOW_DATA *fellow;

   for( fellow = ch->first_fellow; fellow; fellow = fellow->next )
   {
      if( fellow->victim == victim->name )
         return fellow;
   }

   return NULL;
}

const char *PERS( CHAR_DATA * ch, CHAR_DATA * looker )
{
   static char buf[MAX_STRING_LENGTH];
   char race[MAX_STRING_LENGTH];
   FELLOW_DATA *fellow;

   if( can_see( looker, ch ) )
   {
      if( IS_NPC( ch ) )
         return ch->short_descr;
      else
      {
         if( IS_IMMORTAL( looker ) || ch == looker )
            return ch->name;
         else if( ( fellow = knowsof( looker, ch ) ) != NULL )
            return fellow->knownas;
         else
         {
            if( IS_IMMORTAL( ch ) )
               return ch->name;
            sprintf( race, "%s", npc_race[ch->race] );
            race[0] = tolower( race[0] );
               sprintf( buf, "%s %s %s of %s height", aoran( build_name[ch->build] ), race,
                        ch->sex == 1 ? "male" : ch->sex == 2 ? "female" : "neutral", height_name[ch->pheight] );

            return buf;
         }
      }
   }
   else
   {
      if( IS_IMMORTAL( ch ) )
         return "Immortal";
      else
         return "someone";
   }
}


Mud.h where they are declared:

const char *PERS( CHAR_DATA * ch, CHAR_DATA * looker  );
FELLOW_DATA *knowsof args( ( CHAR_DATA * ch, CHAR_DATA * victim ) );


Not finding any other macros or references to either.
       
Post is unread #17 Sep 1, 2008, 5:52 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

My copy of FUSS has a PERS macro defined in mud.h. I don't mean to state the potentially obvious but did you try text-searching through mud.h for PERS?
       
Post is unread #18 Sep 1, 2008, 5:57 pm
Go to the top of the page
Go to the bottom of the page

Trevlyn13
Apprentice
GroupMembers
Posts64
JoinedNov 30, 2007

Bah, you were right. I was searching for *PERS, not just PERS. What should I do to it?

#define PERS(ch, looker) ( can_see( (looker), (ch) ) ? \
( IS_NPC(ch) ? (ch)->short_descr \
: (ch)->name ) : "someone" )
       
Post is unread #19 Sep 1, 2008, 6:01 pm
Go to the top of the page
Go to the bottom of the page

David Haley
Sorcerer
GroupMembers
Posts903
JoinedJan 29, 2007

You can probably just get rid of the macro, since it looks like the function is meant to supersede it. They don't behave exactly the same (e.g. the function returns "Immortal", not "someone";) but it's the same idea.
       
Post is unread #20 Sep 1, 2008, 6:07 pm
Go to the top of the page
Go to the bottom of the page

Trevlyn13
Apprentice
GroupMembers
Posts64
JoinedNov 30, 2007

Okay, it's compiling fine now, getting a seg fault when I put two mortals in the same room. Any suggestions? Thanks for all the help.
       
Pages:<< prev 1, 2 next >>