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 ➜ Restring Option with free_string

Restring Option with free_string

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


Posted by Rash   United Kingdom  (56 posts)  Bio
Date Tue 17 Feb 2004 10:39 PM (UTC)

Amended on Wed 18 Feb 2004 01:16 AM (UTC) by Nick Gammon

Message
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
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #1 on Tue 17 Feb 2004 10:42 PM (UTC)
Message
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 ;

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Rash   United Kingdom  (56 posts)  Bio
Date Reply #2 on Tue 17 Feb 2004 10:43 PM (UTC)

Amended on Tue 17 Feb 2004 10:49 PM (UTC) by Rash

Message
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.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 18 Feb 2004 01:19 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rash   United Kingdom  (56 posts)  Bio
Date Reply #4 on Wed 18 Feb 2004 10:50 AM (UTC)
Message
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
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.


15,319 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.