Re: Loop Problem

From: Wesley Fonvergne (tadrith@GATEKEEP.NET)
Date: 03/07/98


        Sorry, the << was a typo, that's now how the code looks. :) However, this
DID help me quite a bit! Thanks! :)


>Two things: that 'break' there will only make it load one mobile.  The
>other thing is you want "i < invasion_size" not "i << invasion_size".
>The latter--that you have--is a mathematical operation (even in C++,
>but certain classes [istream/ostream] use operator overloading to
>define new behavior for the operator), and indicates that you should
>left shift 'i' by 'invasion_size' bits.  However, the code as you
>presented it would not cause the mobiles to load forever.  It would
>only load one mobile, even if you took out the 'break;' statement
>because of the fact that when i = 0, i << invasion_size will also
>equal 0 and thus, "i << invasion_size" is false (0) and the loop ends.
>So, either you've changed the code since it loaded mobiles repeatedly,
>or you have posted the wrong code, or you just didn't identify the
>behavior correctly.
>
>In addition, it's not desirable to do "char_to_room(mob, location);"
>more than once with the same mobile.  You probably want code
>equivalent to,
>
>  mob = read_mobile(mob_rnum, REAL);
>  char_to_room(mob, room_rnum);
>
>Of course, using your variables in place of mine.  How you have it,
>you are doing char_to_room() for the same one mobile over and over
>again, which I doubt is what you want to do (that means that the
>character ends up in the list invasion_size amount of times, but it's
>still only one character, and will probably cause a crash).

                [ Tadrith Skandrakae, Implementor of Dreamscape ]
                [     - telnet://mud.dreamscape.org:1234/ -     ]
                ["I lay my dreams before your feet;             ]
                [    tread softly, for you tread on my dreams.  ]


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST