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, Google, Sogou, Bing

Members: 0
Guests: 3
Stats
Files
Topics
Posts
Members
Newest Member
481
3,733
19,363
618
Micheal64X
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » General » Coding » Crafting snippet, CREATING, W...
Forum Rules | Mark all | Recent Posts

Crafting snippet, CREATING, Weird compiler error.
< Newer Topic :: Older Topic >

Pages:<< prev 1, 2 next >>
Post is unread #1 Mar 2, 2008, 5:35 pm
Go to the top of the page
Go to the bottom of the page

Zernon
Fledgling
GroupMembers
Posts14
JoinedMar 1, 2008

Hello again, making a crafting snippet for those who may want it, however I need help getting rid of last error

update.c: In function 'void advance_craft_level(CHAR_DATA*, int)':
update.c:148: error: no match for 'operator&=' in 'ch->char_data::act &= -0x00000000000000002'

this is my error, and here is the code to go with it. I might be overlooking something in another file, if u have any ideas to what I am missing, or did wrong, please help.

void advance_craft_level( CHAR_DATA *ch , int craft )
{
    if ( ch->top_craft_level < ch->craft_level[craft] && ch->top_craft_level < 100 )
    {
          ch->top_craft_level = URANGE( 1 , ch->craft_level[craft] , 100 );
    }

    if ( !IS_NPC(ch) )
        REMOVE_BIT( ch->act, PLR_BOUGHT_PET );

    return;
}

there it is.
any help would be much appreciated.
       
Post is unread #2 Mar 2, 2008, 5:48 pm   Last edited Mar 2, 2008, 5:51 pm by Kayle
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Change it to look like:

void advance_craft_level( CHAR_DATA *ch , int craft )
{
    if ( ch->top_craft_level < ch->craft_level[craft] && ch->top_craft_level < 100 )
    {
          ch->top_craft_level = URANGE( 1 , ch->craft_level[craft] , 100 );
    }

    if ( !IS_NPC(ch) )
        xREMOVE_BIT( ch->act, PLR_BOUGHT_PET );

    return;
}


[Edit]: because I'm retarded and missed the preview button.

The reason you want the xREMOVE_BIT macro, is because ch->act is a Extended bitvector, so it requires different guts to the manipulation then REMOVE_BIT has. REMOVE_BIT just handles bitvectors, xREMOVE_BIT handles Extended bitvectors, Someone who is better at explaining things can teach you about Extended bitvectors if you care to learn, but I'd only confuse the hell out of you. :)
       
Post is unread #3 Mar 2, 2008, 5:55 pm
Go to the top of the page
Go to the bottom of the page

Zernon
Fledgling
GroupMembers
Posts14
JoinedMar 1, 2008

ok, that fixed that issue, new set of compiler errors
Sorry im a noob coder, and still learning, so please be patient if I dont know answeres to some questions.

o/update.o: In function `gain_craft_exp2(char_data*, int, int)':/muds/unlimitedgundam/Muds/Aranythera/src/update.c:165: undefined reference to `exp_craft_level(short)'
:/muds/unlimitedgundam/Muds/Aranythera/src/update.c:161: undefined reference to `exp_craft_level(short)'
o/update.o: In function `gain_craft_exp(char_data*, int, int)':/muds/unlimitedgundam/Muds/Aranythera/src/update.c:183: undefined reference to `exp_craft_level(short)'
:/muds/unlimitedgundam/Muds/Aranythera/src/update.c:186: undefined reference to `exp_craft_level(short)'
:/muds/unlimitedgundam/Muds/Aranythera/src/update.c:194: undefined reference to `exp_craft_level(short)'
:/muds/unlimitedgundam/Muds/Aranythera/src/update.c:197: undefined reference to `craft_name'
:/muds/unlimitedgundam/Muds/Aranythera/src/update.c:190:
       
Post is unread #4 Mar 2, 2008, 6:11 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Undefined references are calls to functions that don't have prototypes.

Typically, if the functions in question are defined in a file not the same as the one their being called in, and you have plans to call them in multiple places, a lot of times it's easier to put your prototypes in mud.h with the other prototypes near the bottom of the file. A prototype would be something like

short exp_craft_level  args( ( short level ) );


except it would mimic the actual function, not my rough guess. If they're all in the same file, and you don't have plans to call them in other files, you can put the prototypes at the top of the given file with the other local prototypes. in the instance of update.c it might look similar to:

/*
 * Local functions.
 */
int hitGain( CHAR_DATA * ch );
int manaGain( CHAR_DATA * ch );
int moveGain( CHAR_DATA * ch );
void mobileUpdate( void );
void timeUpdate( void );  /* FB */
void charUpdate( void );
void objUpdate( void );
void aggrUpdate( void );
void roomActUpdate( void );
void objActUpdate( void );
void charCheck( void );
void drunkRandoms( CHAR_DATA * ch );
void hallucinations( CHAR_DATA * ch );
void subtractTimes( struct timeval *etime, struct timeval *sttime );
static bool updateMonthTrigger;
void taskUpdate args( ( void ) );


Yours might look a little different from mine, but you should have similar function names, yours probably use underscores.
       
Post is unread #5 Mar 2, 2008, 6:24 pm
Go to the top of the page
Go to the bottom of the page

Zernon
Fledgling
GroupMembers
Posts14
JoinedMar 1, 2008

ok, not to sound like a noob (even though I am) I dont understand, in mud.h
in the /*update.c*/ this is what it looks like.

/* update.c */
void advance_level( CHAR_DATA * ch );
void gain_exp( CHAR_DATA * ch, int gain );
void    advance_crafting_level  args( ( CHAR_DATA *ch , int craft ) );
void    gain_craft_exp  args( ( CHAR_DATA *ch, int gain_craft , int craft) );
void    gain_craft_exp2 args( ( CHAR_DATA *ch, int gain_craft , int craft) );
int     max_craft_level( CHAR_DATA *ch, int craft);
void gain_condition( CHAR_DATA * ch, int iCond, int value );
void check_alignment( CHAR_DATA * ch );
void update_handler( void );
void reboot_check( time_t reset );
void auction_update( void );
void remove_portal( OBJ_DATA * portal );
void weather_update( void );

is that where I was suppose to put it?
or does it need to be in another spot also?
       
Post is unread #6 Mar 2, 2008, 6:32 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

Did you make sure to clean compile?
       
Post is unread #7 Mar 2, 2008, 6:35 pm
Go to the top of the page
Go to the bottom of the page

Zernon
Fledgling
GroupMembers
Posts14
JoinedMar 1, 2008

yes, make clean, then make.

Here is my yahoo name, maybe you could help me on it, to get this right. I want to put this snippet up for other smaugs to use. I have skills planned out, and was gonna include them once I get this done.


my yahoo name is: jynx101022
       
Post is unread #8 Mar 2, 2008, 6:36 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Yeah, that's where it should have gone in mud.h. If you have the prototypes in mud.h you won't need them anywhere else, because every file includes (or should) mud.h.

And don't worry about sounding like a noob. Everyone starts somewhere.

And Zeno's right. You should do a make clean, then a make to ensure that the executable you generate is free of any remnants. It's generally a good practice to get into, and something I typically do whenever I edit anything in mud.h or any other .h file for that matter.
       
Post is unread #9 Mar 2, 2008, 6:39 pm
Go to the top of the page
Go to the bottom of the page

Zernon
Fledgling
GroupMembers
Posts14
JoinedMar 1, 2008

yea, just did another make clean just to be sure. still getting same errors, if someone could yahoo me, and we could post things back and forth into there, or if they want my shell access, what ever it takes. I know people would want this snippet, I just need to get it in mine first, make sure it works. then I can post it on here ^^
once again my yahoo is jynx101022
       
Post is unread #10 Mar 2, 2008, 6:43 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

Have you written the actual functions for advance_crafting_level, gain_craft_exp, gain_craft_exp2, max_craft_level yet? Davion just pointed that out on IMC, and I missed it in your errors, but it looks more like the actual functions are missing rather than just the prototypes.
       
Post is unread #11 Mar 2, 2008, 6:46 pm   Last edited Mar 2, 2008, 6:47 pm by Zeno
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

I don't see where you posted the prototype for exp_craft_level.

I see you posted some for gain_craft_exp but not the level one.
       
Post is unread #12 Mar 2, 2008, 6:51 pm
Go to the top of the page
Go to the bottom of the page

Zernon
Fledgling
GroupMembers
Posts14
JoinedMar 1, 2008

ok, here is my code for those ^^
int max_craft_level( CHAR_DATA *ch, int craft)
{
    int craft_level = 0;

    if ( IS_NPC(ch) )
      return 100;

    if ( IS_IMMORTAL(ch))
      return 100;

    if ( craft == WOODWORKING_CRAFT )
    {
       if ( ch->main_craft == craft ) craft_level = 100;
       if ( ch->secondary_craft == craft ) craft_level = 75;
    }

    if ( craft == MINING_CRAFT )
    {
       if ( ch->main_craft == craft ) craft_level = 100;
       if ( ch->secondary_craft == craft ) craft_level = 75;
   }
    if ( craft == FISHING_CRAFT )
    {
       if ( ch->main_craft == craft ) craft_level = 100;
       if ( ch->secondary_craft == craft ) craft_level = 75;

    }

    if ( craft == COOKING_CRAFT )
    {
       if ( ch->main_craft == craft ) craft_level = 100;
       if ( ch->secondary_craft == craft ) craft_level = 75;

    }

    if ( craft == LUMBERJACK_CRAFT )
    {
       if ( ch->main_craft == craft ) craft_level = 100;
       if ( ch->secondary_craft == craft ) craft_level = 75;
    }
 if ( craft == SMITHING_CRAFT )
    {
       if ( ch->main_craft == craft ) craft_level = 100;
       if ( ch->secondary_craft == craft ) craft_level = 75;
        }

    if ( craft == SKINNING_CRAFT )
    {
       if ( ch->main_craft == craft ) craft_level = 100;
       if ( ch->secondary_craft == craft ) craft_level = 75;
    }


    if ( craft == LEATHERWORKING_CRAFT )
    {
       if ( ch->main_craft == craft  )    craft_level = 100;
       if ( ch->secondary_craft == craft  ) craft_level = 75;
    }
    if ( craft == HERBALISM_CRAFT )
    {
       if ( ch->main_craft == craft ) craft_level = 100;
       if ( ch->secondary_craft == craft ) craft_level = 75;
    }
    if ( craft == ALCHEMY_CRAFT )
    {
       if ( ch->main_craft == craft ) craft_level = 100;
       if ( ch->secondary_craft == craft ) craft_level = 75;
    }


    return craft_level;
}

void advance_craft_level( CHAR_DATA *ch , int craft )
{
    if ( ch->top_craft_level < ch->craft_level[craft] && ch->top_craft_level < 100 )
    {
          ch->top_craft_level = URANGE( 1 , ch->craft_level[craft] , 100 );
    }

    if ( !IS_NPC(ch) )
        xREMOVE_BIT( ch->act, PLR_BOUGHT_PET );

    return;
}

void gain_craft_exp2( CHAR_DATA *ch, int gain_craft , int craft )
{

    if ( IS_NPC(ch) )
        return;

    ch->craft_experience[craft] = UMAX( 0, ch->craft_experience[craft] + gain_craft );

    while ( ch->craft_experience[craft] >= exp_craft_level( ch->craft_level[craft]+1))
    {
        if ( ch->craft_level[craft] >= max_craft_level(ch , craft) )
        {
          ch->craft_experience[craft] = (exp_craft_level( ch->craft_level[craft]+1 ) - 1);
          return;
        }
        ++ch->craft_level[craft];
        advance_craft_level( ch , craft);
    }

    return;
}
void gain_craft_exp( CHAR_DATA *ch, int gain_craft , int craft )
{
    if ( IS_NPC(ch) )
        return;

    ch->craft_experience[craft] = UMAX( 0, ch->craft_experience[craft] + gain_craft );

    if (NOT_AUTHED(ch) && ch->craft_experience[craft] >= exp_craft_level(ch->craft_level[craft]+1))
    {
        send_to_char("You can not ascend to a high crafting level until you are authorized.\n\r", ch);
        ch->craft_experience[craft] = (exp_craft_level( ch->craft_level[craft]+1 ) - 1);
        return;
    }

    while ( ch->craft_experience[craft] >= exp_craft_level( ch->craft_level[craft]+1))
    {
        if ( ch->craft_level[craft] >= max_craft_level(ch , craft) )
        {
         ch->craft_experience[craft] = (exp_craft_level( ch->craft_level[craft]+1 ) - 1);
        }
        set_char_color( AT_WHITE + AT_BLINK, ch );
        ch_printf( ch, "You have now obtained %s level %d!\n\r", craft_name[craft], ++ch->craft_level[craft] );
        advance_craft_level( ch , craft);
    }

    return;
}

I know its a lot, sorry about the lack of comments, I am gonna be doing those after it works.
       
Post is unread #13 Mar 2, 2008, 6:54 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

Er no, I meant the prototype.
       
Post is unread #14 Mar 2, 2008, 6:57 pm   Last edited Mar 2, 2008, 6:58 pm by Zernon
Go to the top of the page
Go to the bottom of the page

Zernon
Fledgling
GroupMembers
Posts14
JoinedMar 1, 2008

I dont understand, and your right, I did miss, one, ill add that now, and see what that all fixes
       
Post is unread #15 Mar 2, 2008, 6:58 pm
Go to the top of the page
Go to the bottom of the page

Kayle
Off the Edge of the Map
GroupAdministrators
Posts1,195
JoinedMar 21, 2006

It looks like you have your function names mixed up.

In your compiler errors is says:
:/muds/unlimitedgundam/Muds/Aranythera/src/update.c:186: undefined reference to `exp_craft_level(short)'
:/muds/unlimitedgundam/Muds/Aranythera/src/update.c:194: undefined reference to `exp_craft_level(short)'
:/muds/unlimitedgundam/Muds/Aranythera/src/update.c:197: undefined reference to `craft_name' 


You don't seem to have an exp_craft_level function, or a craft_name. You might want to see about making those. Once they exist it should stem your linker errors. :)
       
Post is unread #16 Mar 2, 2008, 7:04 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005


Zernon said:

I dont understand, and your right, I did miss, one, ill add that now, and see what that all fixes

http://en.wikipedia.org/wiki/Function_prototype
       
Post is unread #17 Mar 2, 2008, 8:38 pm
Go to the top of the page
Go to the bottom of the page

Zernon
Fledgling
GroupMembers
Posts14
JoinedMar 1, 2008

I put one of the functions in handler.c, however, it did not like being in there, and that was causeing the errors, moved it to update.c, and BAM full make ^^ thanks everyone, ill finish up my snippet and if someone can help me find a place to put it, I will put it there ^^
       
Post is unread #18 Mar 2, 2008, 8:41 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

If you want to release the snippet, MudBytes is a great place to do so. :)
       
Post is unread #19 Mar 2, 2008, 9:49 pm   Last edited Mar 2, 2008, 9:54 pm by Zernon
Go to the top of the page
Go to the bottom of the page

Zernon
Fledgling
GroupMembers
Posts14
JoinedMar 1, 2008

ok, on to next step, makeing skills. remember, I am new to coding, and I want my crafting skills to use recipes.
so how would I set that up in code to look in another file, lets call it recipe.txt to find if they have the ingrediants for said recipe? I could use a hand on this, I think this is all that I have left. So far, I have skinner, mine, cook, fish, makeleatherarmor, makearmour, makeweapon, cuttree, herbalism, makepotion. I want to be able to set the recipes to have certain skill levels in each craft skill, I have the craft skill up stuff all coded in, now its just making the skills, recipe database, and figureing out how to do a check on the recipe, any ideas? Or, better yet, if anyone wants to be a coder on an upcoming original themed mud, hit me up too. using smaugfuss 1.8
       
Post is unread #20 Mar 2, 2008, 10:05 pm
Go to the top of the page
Go to the bottom of the page

Zeno
Sorcerer
GroupMembers
Posts723
JoinedMar 5, 2005

Wall of text. >.>

Could you er... ask a more specific question?
       
Pages:<< prev 1, 2 next >>