27 Sep, 2007, Meryk wrote in the 1st comment:
Votes: 0
I really do appreciate all of the help you all have given so far. One of these days I'll break down and by a programming book or something. Anyhow, I'm trying to install some code that was not written by me, but will not compile because of the following error.

cc1plus: warnings being treated as errors
act_obj.c: In function âvoid wield_random_armor(CHAR_DATA*)â:
act_obj.c:3811: warning: comparison between signed and unsigned integer expressions
make[1]: *** [o/act_obj.o] Error 1
make: *** [all] Error 2

if (obj->item_type == ITEM_ARMOR)
{
>>>>> int ac_type = URANGE(0, mob->level/5, nelems(armor_types)-1); <<<<<
name = armor_types[ac_type];
obj->weight *= armor_mul[ac_type];
obj->weight /= armor_div[ac_type];


Once again, I appreciate the help and advice.

Thanks.
27 Sep, 2007, Zeno wrote in the 2nd comment:
Votes: 0
What does nelems return?
27 Sep, 2007, Meryk wrote in the 3rd comment:
Votes: 0
Very good question. I honestly don't know. :cry:

Would this be it?
static char *armor_types[] = { "leather", "fur", "studded leather", "bronze",
"steel", "chain mail", "silver", "mithril" };
static int armor_mul[] = { 1, 1, 3, 2, 5, 6, 10, 10 };
static int armor_div[] = { 1, 2, 2, 1, 1, 3, 1, 3 };
27 Sep, 2007, Zeno wrote in the 4th comment:
Votes: 0
I don't see nelems mentioned in that.
27 Sep, 2007, Meryk wrote in the 5th comment:
Votes: 0
Oops…wrong chunk.

void wield_random_armor( CHAR_DATA *mob )
{
int item_type = number_range(0, MAX_WEAR - 1); /* template from LIMBO.ARE */
OBJ_INDEX_DATA *pObjIndex = get_obj_index( item_type + 1600 );
OBJ_DATA *obj = create_object( pObjIndex, number_fuzzy( mob->level ) );
int n_adj1 = number_range(0, nelems(adj1)-1);
int n_adj2 = number_range(0, nelems(adj2)-1);
extern bool randomid;
char *name = "bright";
27 Sep, 2007, Zeno wrote in the 6th comment:
Votes: 0
Nope, that's not it either. Those are just calls to nelems.
27 Sep, 2007, Meryk wrote in the 7th comment:
Votes: 0
Then my noobness is is the spotlight. :sad:

Here is the entire wield_random_armor chunk.

void wield_random_armor( CHAR_DATA *mob )
{
int item_type = number_range(0, MAX_WEAR - 1); /* template from LIMBO.ARE */
OBJ_INDEX_DATA *pObjIndex = get_obj_index( item_type + 1600 );
OBJ_DATA *obj = create_object( pObjIndex, number_fuzzy( mob->level ) );
int n_adj1 = number_range(0, nelems(adj1)-1);
int n_adj2 = number_range(0, nelems(adj2)-1);
extern bool randomid;
char *name = "bright";

// Armor stuff
static char *armor_types[] = { "leather", "fur", "studded leather", "bronze",
"steel", "chain mail", "silver", "mithril" };
static int armor_mul[] = { 1, 1, 3, 2, 5, 6, 10, 10 };
static int armor_div[] = { 1, 2, 2, 1, 1, 3, 1, 3 };

// Weapon stuff
static char *weapon_types[] = { "sword", "sword", "sword", "sword", "sword",
"short sword", "dagger", "dagger", "hammer", "mace", "mace", "whip" };
static int weapon_dam[] = { 3, 3, 3, 3, 3, 11, 11, 11, 0, 7, 7, 4 };

// Trinket stuff
static char *noun[] = { "pebble", "bauble", "stone", "charm", "fetish",
"bone", "trinket" };
char buffer[64];

char buf[MAX_STRING_LENGTH];

if (obj->item_type == ITEM_ARMOR)
{
int ac_type = URANGE(0, mob->level/5, nelems(armor_types)-1);
name = armor_types[ac_type];
obj->weight *= armor_mul[ac_type];
obj->weight /= armor_div[ac_type];

if (number_percent() <= 100)
random_apply(obj, mob);
}
else if (obj->item_type == ITEM_WEAPON)
{
int wea_type = number_range(0, nelems(weapon_types)-1);
name = weapon_types[wea_type];
obj->value[3] = weapon_dam[wea_type];
}
else if (obj->item_type == ITEM_TREASURE)
{
if (number_percent() < mob->level)
{
random_apply(obj, mob);

if (number_percent() <= 100)
random_apply(obj, mob);
}

if (obj->wear_flags & ITEM_HOLD) /* trinket? */
sprintf(buffer, "%s %s %s", adj1[n_adj1],
adj2[n_adj2],
noun[number_range(0, nelems(noun)-1)]);
//random_apply(obj, mob);
else /* no, necklace or something */
sprintf(buffer, "%s %s", adj1[n_adj1],
adj2[n_adj2]);
name = buffer;
random_apply(obj, mob);
}

sprintf( buf, obj->short_descr, name );
STRFREE( obj->short_descr );
obj->short_descr = str_dup( buf );

STRFREE( obj->name );
obj->name = obj->short_descr;

sprintf( buf, "%s rests upon the ground here.",
obj->short_descr );
STRFREE( obj->description );
obj->description = str_dup( buf );
obj->level = 1;

if(randomid)
{
xSET_BIT(obj->extra_flags, ITEM_HAS_MARK);
}

obj_to_char( obj, mob );
equip_char( mob, obj, obj->wear_loc );
}
27 Sep, 2007, Zeno wrote in the 8th comment:
Votes: 0
Again, no. I'm looking for the nelems function.
27 Sep, 2007, Meryk wrote in the 9th comment:
Votes: 0
Oh. Please forgive my noobness. I realize I must be frustrating. I'm just filling in as much as I can to help a friend.


Is this what you're looking for?
#define nelems(a) (sizeof (a)/sizeof (a)[0])
27 Sep, 2007, Zeno wrote in the 10th comment:
Votes: 0
Ah okay. I believe sizeof returns an unsigned. So with this code:
URANGE(0, mob->level/5, nelems(armor_types)-1);


Changing it to this should work:
URANGE(0, mob->level/5, (int) nelems(armor_types)-1);
27 Sep, 2007, Meryk wrote in the 11th comment:
Votes: 0
Thank you. Not only for your help, but for tolerating my incompetence.
0.0/11