Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Logic, Logic, Logic

Logic, Logic, Logic

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Kelsid   USA  (35 posts)  Bio
Date Fri 02 Nov 2001 05:55 AM (UTC)

Amended on Fri 02 Nov 2001 05:58 AM (UTC) by Kelsid

Message
Ok all,

I gots myself a logic error here. Like usual I see whats going wrong, and my brain stack dumped about an hour ago.


My problem is in act_info.c (function show_list_to_char). Heres the code:


 void show_list_to_char( OBJ_DATA *list, CHAR_DATA *ch, bool fShort, bool fShowNothing, const int iDefaultAction )
{
    char **prgpstrShow;
    char **prgpstrName;        /* for MXP */
    char **prgpstrShortName;   /* for MXP */
    int *prgnShow;
    int *pitShow;
    char *pstrShow;
    char *pstrName;            /* for MXP */
    char *pstrShortName;       /* for MXP */
    OBJ_DATA *obj;
    int nShow;
    int iShow;
    int count,count2, count3, offcount, tmp, ms, cnt;
    bool fCombine;
    char * pAction = NULL;

    if ( !ch->desc )
	return;

    /*
     * if there's no list... then don't do all this crap!  -

-------snip-------------
   
    {	ch_printf (ch, MXPTAG ("%s '%s' '%s'"), pAction, prgpstrName[iShow], prgpstrShortName[iShow]);
        count3 = 0;
        count2 = 0;
        for ( obj = list; obj; obj = obj->next_content )
        count3++;
        
        for ( obj = list; obj; obj = obj->next_content )
	{
	 count2++;
         if (count3 == 1)
	      {
	      	send_to_char( prgpstrShow[iShow], ch );
	        ch_printf( ch, "." );
	      }
	     if (count2 < count3 && count3 != 1)
	      {
	       send_to_char( prgpstrShow[iShow], ch );
	       ch_printf( ch, ", " );
	      }
	     if ( count2 == count3 && count3 != 1)
	      {
	       ch_printf( ch, "and " );
	       send_to_char( prgpstrShow[iShow], ch );
	       ch_printf( ch, "." );               
              }
       }
  }



---------snip---------


Ok... The code works great when there is only one object in room... Heres an example of what the output looks like.


[Mercuria, Grand Center]
 You are standing before a gigantic fountain in the center
 of the city.  The buildings tower above you, seeming to
 climb into the heavens themselves.  Never before have you
 seen such wonderful architecture.  Children run past you,
 as townsfolk go about their daily business.  You also see
 a fountain.

Also here:
a town guard, and a fuzzy grey kitten.
Exits: north east south west.

<1013hp 500m 740mv> 




Ok... now the tricky part, when there are two or more objects in the room, I get an output simmilar to this:


[Mercuria, Grand Center]
 You are standing before a gigantic fountain in the center
 of the city.  The buildings tower above you, seeming to
 climb into the heavens themselves.  Never before have you
 seen such wonderful architecture.  Children run past you,
 as townsfolk go about their daily business.  You also see
 a fountain, a fountain, and a fountain.a town guard
 corpse, a town guard corpse, and a town guard corpse.some
 spilled blood, some spilled blood, and some spilled blood.

Also here:
a fuzzy grey kitten.
Exits: north east south west.



Now basically my logic error is this, if there are three objects in the room, it lists all the objects three times.... if there are four.... it lists them all four times. I know my problem is with my for statement, but my brain is just not working.... and help would be appreciated.


-Kelsid

-Kelsid
Top

Posted by Kelsid   USA  (35 posts)  Bio
Date Reply #1 on Fri 02 Nov 2001 07:42 AM (UTC)
Message
Nevermind..... I had a brain fart...

Helps alot of I add a return;



Code works beautiful now..... I got some MPXTAG work ahead of me.... but all in all its running sweet...


-Kelsid

-Kelsid
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,274 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.