



Identical (lines 3446-3501)
Back to List
Browsing parserm.h
3446 ! Identical decides whether or not two objects can be distinguished from
3447 ! each other by anything the player can type. If not, it returns true.
3448 ! ----------------------------------------------------------------------------
3449
3450 [ Identical o1 o2 p1 p2 n1 n2 i j flag;
3451 if (o1 == o2) rtrue; ! This should never happen, but to be on the safe side
3452 if (o1 == 0 || o2 == 0) rfalse; ! Similarly
3453 if (parent(o1) == compass || parent(o2) == compass) rfalse; ! Saves time
3454
3455 ! What complicates things is that o1 or o2 might have a parsing routine,
3456 ! so the parser can't know from here whether they are or aren't the same.
3457 ! If they have different parsing routines, we simply assume they're
3458 ! different. If they have the same routine (which they probably got from
3459 ! a class definition) then the decision process is as follows:
3460 !
3461 ! the routine is called (with self being o1, not that it matters)
3462 ! with noun and second being set to o1 and o2, and action being set
3463 ! to the fake action TheSame. If it returns -1, they are found
3464 ! identical; if -2, different; and if >=0, then the usual method
3465 ! is used instead.
3466
3467 if (o1.parse_name ~= 0 || o2.parse_name ~= 0) {
3468 if (o1.parse_name ~= o2.parse_name) rfalse;
3469 parser_action = ##TheSame; parser_one = o1; parser_two = o2;
3470 j = wn; i = RunRoutines(o1,parse_name); wn = j;
3471 if (i == -1) rtrue;
3472 if (i == -2) rfalse;
3473 }
3474
3475 ! This is the default algorithm: do they have the same words in their
3476 ! "name" (i.e. property no. 1) properties. (Note that the following allows
3477 ! for repeated words and words in different orders.)
3478
3479 p1 = o1.&1; n1 = (o1.#1)/WORDSIZE;
3480 p2 = o2.&1; n2 = (o2.#1)/WORDSIZE;
3481
3482 ! for (i=0 : i
Last updated 27 February 2004. The librarian in charge of this page is Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight. Please email any comments, suggestions or corrections to cedenqs@inform-fiction.org.