



Magician

GroupMembers
Posts128
JoinedApr 9, 2010
please explain about the format
I mean I understand what the word format means, but I fail to see what I did wrong in the format
I mean I understand what the word format means, but I fail to see what I did wrong in the format



Geomancer

GroupAdministrators
Posts1,992
JoinedJul 26, 2005
You have
when this is so much easier to follow and look at
You would be amazed by how much faster an issue can be found and fixed in a nicely formated code compared to one where you spend time trying to figure out what is going on first.
void do_invoke( CHAR_DATA * ch, char *argument ) { OBJ_DATA *fire, *shard; bool found; int mana; if( !can_use_skill( ch, 0, gsn_invoke ) ) { send_to_char( "A skill such as this requires more magical ability than you have.\n\r", ch ); return; } if( argument[0] == '\0' ) { send_to_char( "Invoke which element?\n\r", ch); return; } mana = (ch->max_mana / 5); if( !str_cmp( argument, "fireshard" ) ) { found = FALSE; for( fire = ch->in_room->first_content; fire; fire = fire->next_content ) { if( fire->item_type == ITEM_FIRE ) { found = TRUE; break; } } if( !found ) { send_to_char(" There must be a fire here to invoke a FireShard.\n\r", ch); return; } if( !can_use_skill( ch, number_percent( ), gsn_invoke ) ) { set_char_color( AT_MAGIC, ch ); send_to_char( "You failed to make a FireShard.\n\r", ch ); // Decided against PCs learning from failure //learn_from_failure( ch, gsn_invoke ); ch->mana -= ( mana ); return; } //SUCCESS shard = create_object( get_obj_index( OBJ_VNUM_SM_FIRESHARD ), 0 ); learn_from_success(ch, gsn_invoke); ch->mana -= (ch->mana / 10); act( AT_MAGIC, "$n invokes the fire and creates a FireShard.", ch, NULL, NULL, TO_ROOM ); act( AT_MAGIC, "You invoke the fire and create a FireShard.", ch, NULL, NULL, TO_CHAR ); obj_to_char( shard, ch); learn_noncombat( ch, SK_CHANNEL); }
when this is so much easier to follow and look at

void do_invoke( CHAR_DATA * ch, char *argument ) { OBJ_DATA *fire, *shard; bool found; int mana; if( !can_use_skill( ch, 0, gsn_invoke ) ) { send_to_char( "A skill such as this requires more magical ability than you have.\n\r", ch ); return; } if( argument[0] == '\0' ) { send_to_char( "Invoke which element?\n\r", ch); return; } mana = (ch->max_mana / 5); if( !str_cmp( argument, "fireshard" ) ) { found = FALSE; for( fire = ch->in_room->first_content; fire; fire = fire->next_content ) { if( fire->item_type == ITEM_FIRE ) { found = TRUE; break; } } if( !found ) { send_to_char(" There must be a fire here to invoke a FireShard.\n\r", ch); return; } if( !can_use_skill( ch, number_percent( ), gsn_invoke ) ) { set_char_color( AT_MAGIC, ch ); send_to_char( "You failed to make a FireShard.\n\r", ch ); // Decided against PCs learning from failure // learn_from_failure( ch, gsn_invoke ); ch->mana -= ( mana ); return; } // SUCCESS shard = create_object( get_obj_index( OBJ_VNUM_SM_FIRESHARD ), 0 ); learn_from_success(ch, gsn_invoke); ch->mana -= (ch->mana / 10); act( AT_MAGIC, "$n invokes the fire and creates a FireShard.", ch, NULL, NULL, TO_ROOM ); act( AT_MAGIC, "You invoke the fire and create a FireShard.", ch, NULL, NULL, TO_CHAR ); obj_to_char( shard, ch); learn_noncombat( ch, SK_CHANNEL); }
You would be amazed by how much faster an issue can be found and fixed in a nicely formated code compared to one where you spend time trying to figure out what is going on first.



Magician

GroupMembers
Posts128
JoinedApr 9, 2010
Ah so just make sure everything lines up
I will definitely keep that in mind and try to format it correctly
thank you
I will definitely keep that in mind and try to format it correctly
thank you



Geomancer

GroupAdministrators
Posts1,992
JoinedJul 26, 2005
yw and thanks




Magician

GroupMembers
Posts128
JoinedApr 9, 2010
I once again need some help from the most excellent coders here.
I'm importing the istagged and isflagged with variables to be able to assign variables to players
I'm getting this error when compiling
this is the section of code
in fact I have a bunch of these same errors all over, but I figure I can fix all the same errors from this one example
I'm importing the istagged and isflagged with variables to be able to assign variables to players
I'm getting this error when compiling
variables.c:585: warning: passing arg 1 of `free' discards qualifiers from pointer target type
this is the section of code
case 'E': if( !str_cmp( word, "End" ) ) { switch ( pvd->type ) { default: { bug( "%s: invalid/incomplete variable: %s", __FUNCTION__, pvd->tag ); DISPOSE( pvd->tag ); DISPOSE( pvd ); break; } case vtSTR: case vtXBIT: if( !pvd->data ) { bug( "%s: invalid/incomplete variable: %s", __FUNCTION__, pvd->tag ); line 585 -> DISPOSE( pvd->tag ); DISPOSE( pvd ); break; } case vtINT: tag_char( ch, pvd, 1 ); break; } return; } break;
in fact I have a bunch of these same errors all over, but I figure I can fix all the same errors from this one example


Magician

GroupMembers
Posts128
JoinedApr 9, 2010
Ah answered my own question
I was passing is a const char when it took just a char
ah and my last warning I have
in the code
I was passing is a const char when it took just a char
ah and my last warning I have
variables.c:66: warning: passing arg 1 of `free' discards qualifiers from pointer target type
in the code
void delete_variable( VARIABLE_DATA * var ) { delete_vdata( var ); line 66 -> DISPOSE( var->tag ); DISPOSE( var ); }


Magician

GroupMembers
Posts128
JoinedApr 9, 2010
Ok so I'm having a couple of problems with istagged
the first problem I'm having is it just doesn't do anything it stops the prog right where the istagged if check is
The test prog is
here is the code for istagged in mudprog.c
I am able to successfully tag a player with a variable.
The second problem I'm having is the variable isn't actually saving to the player file.... I'm definitely going to need some help with that
the first problem I'm having is it just doesn't do anything it stops the prog right where the istagged if check is
The test prog is
>speech_prog test if istagged($n, test) >= 1 say Your test tag is not 0. else say Your test tag is ZERO. endif
here is the code for istagged in mudprog.c
if( !str_cmp( chck, "istagged" ) ) { VARIABLE_DATA *vd; int vnum = mob->pIndexData->vnum; if( argc < 3 ) return BERR; if( argc > 3 ) vnum = atoi( argv[3] ); if( ( p = strchr( argv[2], ':' ) ) != NULL ) { *p++ = '\0'; vnum = atoi( p ); } if( ( vd = get_tag( chkchar, argv[2], vnum ) ) == NULL ) return FALSE; if( !*opr && !*rval ) return TRUE; switch ( vd->type ) { case vtSTR: return mprog_seval( ( char * )vd->data, opr, rval, mob ); case vtINT: return mprog_veval( ( long )vd->data, opr, atoi( rval ), mob ); case vtXBIT: return FALSE; /* for now */ } return FALSE; }
I am able to successfully tag a player with a variable.
The second problem I'm having is the variable isn't actually saving to the player file.... I'm definitely going to need some help with that