Re: [NEWBIE-ISH] [DG SCRIPTS]

From: Sean Daley (sdaley@BBNPLANET.COM)
Date: 09/29/98


>>
>> As far as I knew, that _was_ an if statement due to the if above it...
>> If there ship number is greater than/equal to 0, they have a ship.  I
>> have them stored in a file, similar to clans...
>>
>

>I have never seen an if statement do this "if (x = y >= z)". I will bet
>if you change that, you will get some better results.
>If someone knows that this can be done or show me an application that
>does this, I would like to see it or understand what it is actually
>trying to compare. seems like your better off doing x = y && x >= z or
>x = y && y >= z

The line I think you're questioning is ....

if ((ship_num=find_ship_by_id(GET_SHIP(c)))>=0&&ship_num<num_of_ships)

So in this case x = ship_num, y = find_ship_by_id, and z = 0

If he were to change it to what you said
if (x = y && x >=z ... )

then it would never allow a ship_num of 0 which he says above is
what he wants (>= 0) for if ship_num ends up being 0 then we'd
get
if ( 0 && 0 >= 0) which would fail.
Now doing it the way he did would be ...
if ( (0) >= 0) which would work.

Hope this makes sense.
Sorry I don't know an actual fix to the problem here.
Also, when you say you've never seen an if statement setup
like that before let me point you to some code you've
most likely looked at before.

comm.c
...
} else if ((port = atoi(argv[pos])) <= 1024) {
  log("SYSERR: Illegal port number %d.", port);
  exit(1);
}
...

Circlemud code is FULL of if statements like this.

Sean


     +------------------------------------------------------------+
     | 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