Restring Option with free_string

Posted by Rash on Tue 17 Feb 2004 10:39 PM — 5 posts, 19,974 views.

United Kingdom #0
Please i need a littl help with this...
( iv added a edit to this to point out the lines thats causing the error)

void do_restring (CHAR_DATA * ch, char *argument)
{
   int i;
   long cost;
   OBJ_DATA *obj;
   char arg1[MAX_INPUT_LENGTH];   /*Object*/
   char string_where[MAX_INPUT_LENGTH];
   char *string;
   bool errors, isName; 

   isName = FALSE;
   errors = FALSE;
   cost   = 250000;

   /*Gold check*/
   if ((ch->gold - cost) < 0)
   {
      send_to_char("You're poor!  Get a job, you shiftless bum!\n\r", ch);      return;
   }

   if ( argument == NULL || argument[0] == '\0' )
      return;

   smash_tilde (argument);
   argument = one_argument (argument, arg1);
   argument = one_argument (argument, string_where);
   string = argument;

   if ((obj = get_obj_carry (ch, arg1)) == NULL)
   {
       send_to_char ("You aren't carrying that object.\n\r", ch);
       return;
   }

   /* Sanity check for empty strings */
   if( string == NULL || string[0] == '\0'){
      send_to_char("You have to provide a string, smartypants!\n\r", ch);   	
      return;
   }
  
   /*Don't allow colors at all in 'name' for objects'*/
   if (!str_prefix(string_where, "name"))
      isName = TRUE;
      
   /* Start looping through *string */
   for(i = 0; i < strlen(string); i++)
   {      
       /* When the end is reached, break.*/
	if(string[i] == '\0') {
		break;
	}
        
        /* If string[i] isn't '&', then continue.
         * Placed here to save time as most chars won't be.
         */
	else if(string[i] != '&' ) {
		continue;
	}
        else if(string[i] == '&' && isName) {
              {errors = TRUE; break;}
        }
        		
	/* If string[i] is '&' and string[i+1] is '\0'
         * Whoa, wrong, return.  It'll bleed.  For example, string{ .
         */
	else if (string[i] == '&' && string[i+1] == '\0' ) {
		send_to_char("That string will colorbleed--please"
		             " end your strings with &g.\n\r", ch);
		return;
	}
	
	/* If string[i] is '&' and string[i+1] isn't '\0', but
	 * string[i+2] is \0.  If so, we need to make sure that
	 * the color won't bleed.  
	 */
	else if (string[i] == '&' && string[i+1] != '\0' && string[i+2] == '\0')
	{
	   /* All done*/
	   if (string[i+1] == 'g')
	      break;
	   else
	   /*Color bleeding (string&& or string&g for example)*/
	   {
		send_to_char("That string will colorbleed--please"
		             " end your strings with &g.\n\r", ch);
		return;
           }
	}
        	
	/* Isn't needed, but makes me feel better ;)
         */
	else { continue; }
   }

   if (errors)
   {
      send_to_char("Colors are not allowed in the name of an object.\n\r", ch);
      return;
   }

   if (!str_prefix (string_where, "name"))
   {
<ERROR - its the free_String)>       free_string (obj->name);
       obj->name = str_dup (string);
   }
   else if (!str_prefix (string_where, "short"))
   {
<ERROR - its the free_String)>       free_string (obj->short_descr);
       obj->short_descr = str_dup (string);
   }
   else if (!str_prefix (string_where, "long"))
   {
<ERROR - its the free_String)>       free_string (obj->description);
       obj->description = str_dup (string);
   }
   else
   {
      send_to_char("The commissary man stares blankly at you for a moment before finally pointing at a sign on the wall labeled 'help autostring'.\n\r",ch);
      return;
   }
   
   ch->gold -= cost;
      send_to_char("All done!\n\r",ch);
   return;
}


heres the problem:

undefined refrence to _free_string

then the usal error2

What i want to know is is there a fix for this or some other way of renaming items? (this is for mortals and i dont want them let lose with oedit) any help would be great thankx

(oh this code is part rom so if that helps the problem?)

Rash
Amended on Wed 18 Feb 2004 01:16 AM by Nick Gammon
Canada #1
Can you paste the actual error from the compiler, and if its on a specific line, what line its on? It would help use figure it out. Though the last time this happened to me, I was missing a ;
United Kingdom #2
How do you copy the compile errors in Cygwin? iv forgotten...
iv edited my origial post to show the error lines u cant miss them now.
Amended on Tue 17 Feb 2004 10:49 PM by Rash
Australia Forum Administrator #3
If you are using forum codes you need to "escape" things like [, ] and \ otherwise they might be interpreted as other things. In your case the [i] made the rest of the post go into italics.

I've fixed it for you, you can use MUSHclient's notepad to do it, or any editor to change:

\ to \\
[ to \[
] to \]

(Better do it in that order).

To copy compile errors, click on the top LH corner of your Cygwin screen (the System menu), or type Alt+Space, find "Edit->Mark" and then click and drag over the error messages, and the press <enter>. You can then paste them into the forum.
United Kingdom #4
Thanks nick, ill remember that frmo now on, any idea on this problem of mine tho? its not causeing any problems really its just i thought a restring command for items for players would be good. anyway any help would be as usal apreciated.
Rash