[Circle] name_from_drinkcon()

From: Patrick Dughi (dughi@imaxx.net)
Date: 02/17/00

        I thought this had been fixed, but perusing the latest code I saw
it had not been....If no one noticed, if, when making a drink container
item, you do not make the first keyword in the name equal to the
drinkname[] of the liquid it holds by default, when it is emptied the
first time, the first keyword (no matter what it is) is removed.

        So, you have a 'wooden barrel' that is half full of beer, when you
pour it out/finish it, you will be left with a 'barrel'.

        Catches alot of people, and though we could enforce writing
policies, it's so much easier to just fix code.  This isn't the most
beautific code, but it's functional. I'll clean it up later.

        Disclaimer: If you can't read this code and undestand EXACTLY what
it does the first or second time through, wait till something like this is
put in a release.

void xap_name_from_drinkcon(struct obj_data * obj)
  char *s,*e,*newname;
  char searchname[256];
  int i;

  extern char *drinknames[];
  extern struct obj_data *obj_proto;

  /* verify that the name is there */
  if(!(s=strstr(obj->name,drinknames[GET_OBJ_VAL(obj,2)]))) {
        /* else, we have the name, w/o spaces */
  for(i=0;(*((obj->name)+i) !=' ') && (*((obj->name) + i) != '\0'); i++);
  /* check if name is at the beginning (if so, life is easy) */

  if(s == obj->name) {
    if(*((obj->name) +i) == ' ') {
    } else {
      /* no name but the drink name! what do we do? */
    if (GET_OBJ_RNUM(obj) < 0 || obj->name != obj_proto[GET_OBJ_RNUM(obj)].name)
  } else {      /* it's not at the beginning. */
    sprintf(searchname," %s",drinknames[GET_OBJ_VAL(obj,2)]);
    if(!(s=strstr(obj->name,searchname))) {
  /* no name afterall - require one space in front if it's not
                                                the first keyword */
    for(i=1;(*(s+i) !=' ') && (*(s + i) != '\0');i++);

        /* ugly */
    e=(s +i);
    *(s) = '\0';
    *s = 'a';

    if (GET_OBJ_RNUM(obj) < 0 || obj->name != obj_proto[GET_OBJ_RNUM(obj)].name)

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

This archive was generated by hypermail 2b30 : 04/10/01 PDT