Re: [CODE] [NEWBIE] Printing brief room desc when enter key hit

From: Ben Shadwick (bshadwic@CLARK.EDU)
Date: 04/20/98


Peters@pp.okstate.edu wrote on Mon Apr 20 20:08:03 1998:
>I don't have the source in front of me, but I can give you a starter
>check in interpreter.c for the main command_interpreter function
>I think it's named command_interpreter, or something close
>somewhere at the beginning it will have something like
>
>/* drop to the next line for hitting CR */
>right after that, instead of just returning, have it do a
>look_at_room(ch), then return.
>I don't know if that does the brief description or not, but it would
>give you something to start with.

On Mon, 20 Apr 1998, Patrick J. Dughi wrote:
>         Hey - no problem.  Find the function, command_interpreter() in
> interpreter.c.  locate the lines that read
>
>   /* just drop to next line for hitting CR */
>   skip_spaces(&argument);
>   if (!*argument)
>     return;
>
>   now, change it to something like this:
>
>   /* just drop to next line for hitting CR */
>   skip_spaces(&argument);
>   if (!*argument) {
>      look_at_room(ch,0);
>      return;
>   }

Thanks! I made the change, recompiled and tested it, and it works fine -
well except for one thing: whether or not the room's long description is
printed depends on what the player's brief mode is toggled to. I expected
this, and decided to look at the code for look_at_room (in
act.informative.c). Here's what the part of look_at_room dealing with
printing the long room description looks like:

  if (!PRF_FLAGGED(ch, PRF_BRIEF) || ignore_brief ||
      ROOM_FLAGGED(ch->in_room, ROOM_DEATH))
    send_to_char(world[ch->in_room].description, ch);

(ignore_brief contains the value of the second argument to look_at_room)
Now, I'm wondering if there's a logic error in there, or if look_at_room
just wasn't intended to be able to be forced to skip the long room desc.
The reason for this is that (from what I can tell) in order for the long
desc to be skipped, the following must be met:
1) the player is in brief mode
2) ignore_brief is equal to 0
3) the player is not in a deathtrap room? (this doesn't matter, since you
   want it to print the long description anyways probably)

As you can see, regardless of the value of ignore_brief, look_at_room will
still show the long desc if the player is not in brief mode.

SO, (sorry for being so wordy) what would be the best way to work around
this so that, when the user hits ENTER at the command prompt, the game
does look_in_room WITHOUT printing the long room desc? Probably the safest
way (to keep other code from breaking/misbehaving) that I can think of is
to make a copy of look_in_room, rename the copy, and take out the first
condition in the if() statement above (then have command_interpreter()
call the new function). Does this sound like the best way to go, or is
there a better way? Thanks!

>         Next time though, you might want to look through the code
> yourself, or at least familairze yourself with the location of important
> frequently used functions like command_interpreter, act, etc.

First of all, I DID look around in the code for at least a half an hour,
with little success. As I said, I'm new to the CircleMUD code (and MUD
coding in general). Currently I do not know what most of the "important
frequently used functions" are (nor their locations), although I intend to
find out (by diving in - not by bugging the helpful people on this list =)

Is there some sort of doc/FAQ that I can read to find out more about the
current organization of the CircleMUD code?

>                 I won't say the RTFC thing, cause I'm sure that someone
> will have already sent it out before this message actually gets through,
> but as is obvious, this takes about 20 seconds to realize and do.  It

I don't see how it would be very obvious, unless you already know what
you're looking for (which I didn't). Perhaps you'd like to write some docs
on it if there aren't any already? ;)

> wouldn't be a bad learning experience to figure this one out.

I'm not afraid to get my hands dirty! In fact, I very much look forward to
it (actually, I am already in the process of experimenting =)

Thanks again for the help everybody!


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



This archive was generated by hypermail 2b30 : 12/15/00 PST