Re: [Newbie Sort of] Hidden Exits/ Hidden Doors/ Hidden Rooms

From: Mike Redick (Telos@MAD.SCIENTIST.COM)
Date: 01/04/01


On Wed, 3 Jan 2001 22:54:17 -0500, Griffin Hernandez <griffent@SOFTCOM.NET>
wrote:

>Hello again.
>I was adding the hidden exits code i found on the website and it didnt give
>really clear description on how to add exits flags to olc
>I dont know how to add exit flags, I tried and i acomplished something but
>not what i wanted. It made all doors hidden, I Fixed that.
>
>In  case REDIT_EXIT_DOORFLAGS: , where
>OLC_EXIT(d)->exit_info = (number == 0 ? 0 :
>(number == 1 ? EX_ISDOOR :
>(number == 2 ? EX_ISDOOR | EX_PICKPROOF : 0));
>
>are, I try to add another line to it so it would be
>
>OLC_EXIT(d)->exit_info = (number == 0 ? 0 :
>(number == 1 ? EX_ISDOOR :
>(number == 2 ? EX_ISDOOR | EX_PICKPROOF : 0)
>(number == 3 ? EX_ISDOOR | EX_HIDDEN    : 0));
>
>and i get the error
>
>C:\WINDOWS\Desktop\src\redit.c(698) : error C2064: term does not evaluate
>to a function


The problem is that the ?: operator works like this:

condition ? true_result : false_result

Actually this is kinda messy, just had to go disect it in another window.
But broken down it's like this:

condition1     number == 0
true_result1   0
false_result1  (number == 1 ? EX_ISDOOR : (number == 2 ? EX_ISDOOR |
EX_PICKPROOF : 0));

now false_result1 needs to be broken down so:

condition2     number == 1
true_result2   EX_ISDOOR
false_result2  (number == 2 ? EX_ISDOOR | EX_PICKPROOF : 0)

wee! now we can break down false_result2:

condition3     number == 2
true_result3   EX_ISDOOR | EX_PICKPROOF
false_result3 0

Now here's the fix you need... notice how the other conditions were nested
at the end, right?  What your solution did was just plug
(number == 3 ? EX_ISDOOR | EX_HIDDEN    : 0) in after the last condition...
so basically the entire first conditional ended then it ran into your
condition when it wasn't expecting it.  You need to put your whole
conditional thing in place of false_result3...  or you could take the easy
way out and replace the whole damn thing with if else statements... heh.

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/03/01 PST