Re: [PROBABLY IDIOTIC] Prompt System

From: Phillip A Ames (kirk47@juno.com)
Date: 01/22/00


On Sat, 22 Jan 2000 11:57:22 -0800 "Daniel A. Koepke"
<dkoepke@CALIFORNIA.COM> writes:
> I.e., pointers to some arbitrary memory.  If you changed them to NULL,
> you'd at least not corrupt other memory before crashing, but I guess
you
> don't want it to crash at all.  You probably want an array of char
rather
> than arbitrary pointers to lala land.
>
> -dak

Well, with your/George's help, that problem is fixed, but now I've got
(sigh) another.  In order to get this thing to work, I basically
duplicated the title system and just modified make_prompt() to parse
ch->player.prompt and return that instead of using pref flags.  I
basically copied all of the functions pertaining to title, including the
if(ch->player.title) then free(ch->player.title) stuff and made
if(ch->player.prompt) etc.  This is probably the driving force behind my
rage when I get the error below..

--------------------Configuration: VC - Win32 Debug--------------------
Compiling...
limits.c
limits.c(233) : error C2106: '=' : left operand must be l-value
Error executing cl.exe.

circle.exe - 1 error(s), 0 warning(s)


As you can see, in my char_player_data structure, prompt is an
indirection as well as title...

/* general player-related info, usually PC's and NPC's */
struct char_player_data {
   [...]
   char *title;        /* PC / NPC's title                     */
   char         *prompt;       // PC / NPC's prompt
   [...]
};


This function is a near duplicate of set_title()...

void set_prompt(struct char_data *ch, char *prompt)
{

  if (strlen(prompt) > MAX_PROMPT_LENGTH)
    prompt[MAX_PROMPT_LENGTH] = '\0';

  if (GET_PROMPT(ch) != NULL)
    free(GET_PROMPT(ch));

  GET_PROMPT(ch) = str_dup(prompt);                (line 233)

}


Just as this is a near duplicate of do_title()...

ACMD(do_display)
{
  skip_spaces(&argument);
  delete_doubledollar(argument);

  if (strlen(argument) > MAX_PROMPT_LENGTH) {
    sprintf(buf, "Sorry, prompts can't be longer than %d
characters.\r\n",
            MAX_PROMPT_LENGTH);
    send_to_char(buf, ch);
  } else {
    set_prompt(ch, argument);
    sprintf(buf, "Your prompt has been changed to \"%s\".\r\n",
GET_PROMPT(ch));
    send_to_char(buf, ch);
  }
}


Is there something that I'm missing?  I'm clueless here.

-Phillip

Phillip Ames       | AOL IM: Grathol  | ICQ: 8778335 |
------------------------------------------------------
"I will break you into pieces, hold you up for all the
world to see, what makes you think you are better than
me?" -Everclear, Like A California King, 1997

________________________________________________________________
YOU'RE PAYING TOO MUCH FOR THE INTERNET!
Juno now offers FREE Internet Access!
Try it today - there's no risk!  For your FREE software, visit:
http://dl.www.juno.com/get/tagj.


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