Welcome to the Builder Academy

Question A Very Odd Problem: Changing Races

More
16 Aug 2018 06:02 - 16 Aug 2018 06:02 #8185 by Papaya Pete
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?
Last edit: 16 Aug 2018 06:02 by Papaya Pete.

Please Log in or Create an account to join the conversation.

More
16 Aug 2018 07:59 #8186 by JTP
Well you did add an extra ) to this line the second time you posted it:
(IS_RODENT(ch) && NOTRADE_RODENT(shop_nr))) {

It was missing the first time

Please Log in or Create an account to join the conversation.

More
16 Aug 2018 15:17 #8187 by Papaya Pete
Ah, I looked and that extra ) was there. Not sure how that went missing.

So this is where the problem was at: in shop.h
Code:
#define NOTRADE_HUMAN(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOHUMAN)) #define NOTRADE_KAVAARUN(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOKAVAARUN)) // <<--- Forgot parenthesis here, oops! #define NOTRADE_VALNAR(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOVALNAR)) #define NOTRADE_HALF_BREED(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOHALF_BREED)) #define NOTRADE_WILD_FEILAN(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOWILD_FEILAN)) #define NOTRADE_LUPAR(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOLUPAR)) #define NOTRADE_FEILAN(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NOFEILAN)) #define NOTRADE_RODENT(i) (IS_SET(SHOP_TRADE_WITH((i)), TRADE_NORODENT))

Alright, so that was something new to me! I didn't expect something like that to be able to happen. I guess we learn something new everyday. :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.257 seconds