Re: [NEWBIE] [CODE] Locate Object

From: Thomas Arp (t_arp@mail1.stofanet.dk)
Date: 11/01/00


This is quite long - and the issue has been adressed before.
However, I just _needed_ to write some mailer code :)
<--snip-->

> ASPELL(spell_locate_object)

Definition from spells.h:
#define ASPELL(spellname) \
void spellname(int level, struct char_data *ch, \
    struct char_data *victim, struct obj_data *obj)

So - an _object_ is passed. The parsing of the argument happens
before the call of spell_locate_object - This is an old problem, which has
been adressed on the list before. I can suggest searching for
'locate object' on the list archives to read more.

> {
>   struct obj_data *i, *container, *next_container;
>   char name[MAX_INPUT_LENGTH];
>   int j;
>   bool check = FALSE;
>
>   strcpy(name, fname(obj->name));

This is where things go wrong - in your example you now have:
name="mega armor" - not just mega which was what you were
looking for.

>   j = GET_LEVEL(ch);
>
>   for (i = object_list; i && (j > 0); i = i->next) {
>     if (!isname(name, i->name))
>       continue;
<--snip-->

isname(arg, arg2) (in stock circle)checks to see if _any_ words in 'arg' are
present in 'arg2'. Thus in your example, all objects with either 'mega' or
'armor' in their alias list are printed.

To solve this you will want to pass the argument of the spell to the
spell function itself. Several solutions have been mentioned on the mailing
list, and they can be found in the archives. One solution could be to
simply pass the argument to all manual spells by redefining ASPELL:

#define ASPELL(spellname) \
void spellname(int level, struct char_data *ch, \
    struct char_data *victim, struct obj_data *obj, char *argument)

and making sure to change the MANUAL_SPELL to

#define MANUAL_SPELL(spellname) spellname(level, caster, cvict, ovict, argument);

and some more subtle changes in the spell system to make sure the argument
actually gets to the MANUAL_SPELL call:

int call_magic(struct char_data *caster, struct char_data *cvict,
  struct obj_data *ovict, int spellnum, int level, int casttype, char *argument);

int cast_spell(struct char_data * ch, struct char_data * tch,
            struct obj_data * tobj, int spellnum, char *argument);

and to make sure to change all calls to these functions to include
the argument.

Welcor of Cruel World


     +------------------------------------------------------------+
     | 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/11/01 PDT