Re: Autoexits problem

From: Mike Stilson (mike@velgarian.sytes.net)
Date: 09/08/02


On Mon, Sep 09, 2002 at 11:03:51AM +1000, Ben Merton wrote:
>Unfortunately this gets me back into the original problem I had with
>autoexits, that being with this snippet there will always be a comma at the
>end of the exits string. Therefore you end up with:

So why don't you just smash the comma with a \0 before your format it
into buf2 (using the below code).

>Exits: North, East, West,.
the variable looks like this:

buf="North, East, West,"
buf[strlen(buf)-1] = ','

So.. just "buf[strlen(buf)-1] = '\0';

>>void do_auto_exits(struct char_data * ch)
>>{
>>   int door;
>>
>>   *buf = '\0';
>>
>>   for (door = 0; door < NUM_OF_DIRS; door++)
>>     if (EXIT(ch, door) && EXIT(ch, door)->to_room != NOWHERE) {
>>       if (IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED))
>>         sprintf(buf + strlen(buf), " %s(Closed),", capdirs[door]);
>>       else
>>         sprintf(buf + strlen(buf), " %s,", capdirs[door]);
>>     }
+    buf(strlen(buf)-1) = '\0';
>>   sprintf(buf2, "&cExits:%s.&n\r\n", ((*buf) ? buf : " None"));

btw, you can replace the final sprintf and use of buf2 by just changing
it to:
send_to_char(ch, "&cExits:%s&n\r\n", ((*buf) ? buf : " None"));

-me

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT