Well, this isn't really a new snippet or anything, but I've been changing around the races a bit in my mud just to fit my theme a little better (in my mind).
So I started by changing the names within the code, and ran into a problem here:
Code:
if ((IS_HUMAN(ch) && NOTRADE_HUMAN(shop_nr)) ||
(IS_KAVAARUN(ch) && NOTRADE_KAVAARUN(shop_nr)) ||
(IS_VALNAR(ch) && NOTRADE_VALNAR(shop_nr)) ||
(IS_HALF_BREED(ch) && NOTRADE_HALF_BREED(shop_nr)) ||
(IS_WILD_FEILAN(ch) && NOTRADE_WILD_FEILAN(shop_nr)) ||
(IS_LUPAR(ch) && NOTRADE_LUPAR(shop_nr)) ||
(IS_FEILAN(ch) && NOTRADE_FEILAN(shop_nr)) ||
(IS_RODENT(ch) && NOTRADE_RODENT(shop_nr)) {
snprintf(buf, sizeof(buf), "%s %s", GET_NAME(ch), MSG_NO_SELL_RACE);
do_tell(keeper, buf, cmd_tell, 0);
return (FALSE);
}
return (TRUE);
if ((IS_MAGIC_USER(ch) && NOTRADE_MAGIC_USER(shop_nr)) ||
(IS_CLERIC(ch) && NOTRADE_CLERIC(shop_nr)) ||
(IS_WARRIOR(ch) && NOTRADE_WARRIOR(shop_nr)) ||
(IS_ROGUE(ch) && NOTRADE_ROGUE(shop_nr)) ||
(IS_RANGER(ch) && NOTRADE_RANGER(shop_nr)) ||
(IS_ENGINEER(ch) && NOTRADE_ENGINEER(shop_nr))) {
snprintf(buf, sizeof(buf), "%s %s", GET_NAME(ch), MSG_NO_SELL_CLASS);
do_tell(keeper, buf, cmd_tell, 0);
return (FALSE);
}
return (TRUE);
}
It gives me this error:
Code:
shop.c: In function ‘is_ok_char’:
shop.c:149:51: error: expected ‘)’ before ‘{’ token
(IS_RODENT(ch) && NOTRADE_RODENT(shop_nr))) {
^
shop.c:167:1: error: expected ‘)’ before ‘}’ token
}
^
shop.c:167:1: error: expected ‘)’ before ‘}’ token
shop.c:167:1: error: expected ‘)’ before ‘}’ token
shop.c:167:1: error: expected ‘)’ before ‘}’ token
shop.c:167:1: error: expected ‘)’ before ‘}’ token
shop.c:167:1: error: expected expression before ‘}’ token
Here is the very very strange thing: I didn't change the parenthesis at all, save for removing one line of code since I subtracted one from the number of races. Here is what it used to look like:
Code:
static int is_ok_char(struct char_data *keeper, struct char_data *ch, int shop_nr)
{
char buf[MAX_INPUT_LENGTH];
if (!CAN_SEE(keeper, ch)) {
char actbuf[MAX_INPUT_LENGTH] = MSG_NO_SEE_CHAR;
do_say(keeper, actbuf, cmd_say, 0);
return (FALSE);
}
if (IS_GOD(ch))
return (TRUE);
if ((IS_GOOD(ch) && NOTRADE_GOOD(shop_nr)) ||
(IS_EVIL(ch) && NOTRADE_EVIL(shop_nr)) ||
(IS_NEUTRAL(ch) && NOTRADE_NEUTRAL(shop_nr))) {
snprintf(buf, sizeof(buf), "%s %s", GET_NAME(ch), MSG_NO_SELL_ALIGN);
do_tell(keeper, buf, cmd_tell, 0);
return (FALSE);
}
if (IS_NPC(ch))
return (TRUE);
if ((IS_HUMAN(ch) && NOTRADE_HUMAN(shop_nr)) ||
(IS_DWARF(ch) && NOTRADE_DWARF(shop_nr)) ||
(IS_ELF(ch) && NOTRADE_ELF(shop_nr)) ||
(IS_HALF_ELF(ch) && NOTRADE_HALF_ELF(shop_nr)) ||
(IS_GNOME(ch) && NOTRADE_GNOME(shop_nr)) ||
(IS_HALFLING(ch) && NOTRADE_HALFLING(shop_nr)) ||
(IS_LUPAR(ch) && NOTRADE_LUPAR(shop_nr)) ||
(IS_FEILAN(ch) && NOTRADE_FEILAN(shop_nr)) ||
(IS_RODENT(ch) && NOTRADE_RODENT(shop_nr))) {
snprintf(buf, sizeof(buf), "%s %s", GET_NAME(ch), MSG_NO_SELL_RACE);
do_tell(keeper, buf, cmd_tell, 0);
return (FALSE);
}
return (TRUE);
if ((IS_MAGIC_USER(ch) && NOTRADE_MAGIC_USER(shop_nr)) ||
(IS_CLERIC(ch) && NOTRADE_CLERIC(shop_nr)) ||
(IS_WARRIOR(ch) && NOTRADE_WARRIOR(shop_nr)) ||
(IS_ROGUE(ch) && NOTRADE_ROGUE(shop_nr)) ||
(IS_RANGER(ch) && NOTRADE_RANGER(shop_nr)) ||
(IS_ENGINEER(ch) && NOTRADE_ENGINEER(shop_nr))) {
snprintf(buf, sizeof(buf), "%s %s", GET_NAME(ch), MSG_NO_SELL_CLASS);
do_tell(keeper, buf, cmd_tell, 0);
return (FALSE);
}
return (TRUE);
}
Now I can compile the old code just fine (except for the lack of definitions for all the old races, but no "Hey you're missing a )" error). As soon as I even replace one of the old races with a new one (IS_KAVAARUN instead of IS_DWARF), BAM it gives me the parenthesis error. I've checked repeatedly throughout the whole function, making sure that the parenthesis all match up (which they do, I've seriously checked five or six times). What is going on with this?