Re: Practice adding

From: Patrick Dughi (dughi@imaxx.net)
Date: 03/22/00


        For new coders; if you are using MSVC, replace all instances of
'grep' with 'use the find in files function to look for'.

> Hi I know this may sound silly, but i am looking for the variable for
> "player practices", i am coding a spell and script to allow players to
> buy, for a high price, practices, but i can't seem to find the variable
> name any where.  Cheers Alex

        It _is_ sort of silly. I'll give you the answer, but it will
require you doing work.

        First, Think to yourself where the program would have to check
that variable.  The first thing I came up with was when I type "prac" when
I'm not at a guildmaster, it tells me how many prac's I have left.  This
gives me two places:
        the command "practice"
        the guildmaster spec_proc.

        I'll start with the command.  I know that all commands are entered
into the big command list in interpreter.c.  So, I grep for practice in
interpreter.c;

$ grep practice interpreter.c
ACMD(do_practice);
  { "practice" , POS_RESTING , do_practice , 1, 0 },
$

        I see there that practice calls the function "do_practice".  I
grep for do_practice.

$ grep do_practice *[ch]             ([ch] means either c, or h)
act.other.c:ACMD(do_practice);
act.other.c:ACMD(do_practice)
interpreter.c:ACMD(do_practice);
interpreter.c:  { "practice" , POS_RESTING , do_practice , 1, 0 },
$

        Apparently, it's in act.other.c.  I open up said file, and go look
at the function definition.  I see it either prints out a message
about being in your guild, or calls a function (which I'm not
going to name). Nothing about practices.  It must be in the unnamed
function.

        I search for where that function exists, again, using grep.

$ grep <my function> *[ch]
act.other.c:void <my function>(struct char_data * ch);
act.other.c:    <my function>(ch);
spec_procs.c:void <my function>(struct char_data * ch);
spec_procs.c:void <my function>(struct char_data * ch)
spec_procs.c:    <my function>(ch);
$

        Ah-ha. I see it's in spec_procs.c, according to the 4'th line.  I
edit spec_procs.c, and go to that function.  Amazingly enough, after the
variable declarations, the next 6 lines are responsible for printing that
message about how many practice sessions you have left!  I know because
i've used the command, that it's filling in the %d (integer) in the buffer
string with the variable I'm looking for.  In this case, the variable is a
macro.

        In most situations, it'd be okay to just use the macro, assuming
it's globaly defined.  You probably want to do this anyway.  If not
though, remember that most macros are defined in the header files.. that's
right... grep again:

$ grep <MACRO NAME> *.h
utils.h:#define <MACRO NAME>    <Macro definition>
$
        And there we see the exact variable!

        I hope this helps you to help yourself :)
                                                        PjD


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