Minor issues with assemblies patch.

From: Mathew Earle Reuther (graymere@zipcon.net)
Date: 09/20/02


I've installed the assemblies patch off the ftp site, and have it up and
working with some modifications to make it work for my purposes.  However,
I've got one issue with the way things are done.  I don't like the fact
that you can only use one word in your argument!

As near as I can tell, the stock behavior is this:

have an assembly of type brew for item 111 using components 112 and 113.
item 11 is called a flagon of red dragon and has a namelist of flagon and
dragon.

at the prompt:
brew a flagon of red dragon
(can't do that message)

brew flagon of red dragon
(again, can't)

brew flagon dragon
(yet again, no)

brew flagon
(yep, success!)

Now, what do I do if I want to be able to brew a flagon of orc's breath
ale?  How about a flagon of dark dwarf malt?

Essentially, you must have items which have unique short descriptions in
order to use the assemblies patch.  Now, I'm creative . . . but I'm not
THAT creative.  And I strongly suspect that people will get very tired of
picking up 80 different types of drinks that have 160 different names
assigned to them. :)

So, my question is this.  How do I make it so that the entire shortdesc is
matched?

And, i have no idea why, but at first glance it looks like only words
that are both in the namelist and the short desc work . . . of course, I'm
not entirely positive on that as it's difficult to test with all the
editing of things that needs to be done, but that's first assumption.

Here's the functions which are breaking (failing to do what I've
described):

First, the part of the ACMD(do_assemble) which is returning the failure
message:
  skip_spaces(&argument);

  if (*argument == '\0') {
    sprintf(buf, "%s what?\r\n", CMD_NAME);
    send_to_char(ch, CAP(buf));
    return;
  } else if ((lVnum = assemblyFindAssembly(argument)) < 0) {
    sprintf(buf, "You can't %s %s %s.\r\n", CMD_NAME, AN(argument),
argument);
    send_to_char(ch, buf);
    return;
  }

Then the function which takes the argument and checks for a match:
long assemblyFindAssembly( const char *pszAssemblyName )
{
  long          i = 0;
  long          lRnum = NOTHING;

  if( g_pAssemblyTable == NULL )
    return (-1);
  else if( pszAssemblyName == NULL || *pszAssemblyName == '\0' )
    return (-1);

  for( i = 0; i < g_lNumAssemblies; i++ )
  {
    if( (lRnum = real_object( g_pAssemblyTable[ i ].lVnum )) < 0 )
      log( "SYSERR: assemblyFindAssembly(): Invalid vnum #%ld in assembly
table.", g_pAssemblyTable[i].lVnum );
    else if( isname( pszAssemblyName, obj_proto[ lRnum ].name ) )
      return (g_pAssemblyTable[ i ].lVnum);
  }

  return (-1);
}

Then as far as I can tell, it dies in isname because the argument (which
has been run through skip spaces?) isn't ending up as a match . . .

Here's the normal isname for reference:
int isname(const char *str, const char *namelist)
{
  const char *curname, *curstr;

  curname = namelist;
  for (;;) {
    for (curstr = str;; curstr++, curname++) {
      if (!*curstr && !isalpha(*curname))
        return (1);

      if (!*curname)
        return (0);

      if (!*curstr || *curname == ' ')
        break;

      if (LOWER(*curstr) != LOWER(*curname))
        break;
    }

    /* skip to next name */

    for (; isalpha(*curname); curname++);
    if (!*curname)
      return (0);
    curname++;                  /* first char of new name */
  }
}

*shrug*

I'm confused.  I'm not entirely clear on how arguments are parsed and
such, so I'm not really sure how to deal with getting this to behave in a
more appropriate manner.

If any of you can help me out with working through this, I'd greatly
appreciate it.  I've spent a good deal of time getting this thing in,
working, and modified.  Now it looks like I have this one last difficulty
that I can't seem overcome. :)

-Mathew

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